Index: asp3_gr_sakura/trunk/Debug/Makefile
===================================================================
--- asp3_gr_sakura/trunk/Debug/Makefile	(revision 317)
+++ asp3_gr_sakura/trunk/Debug/Makefile	(revision 317)
@@ -0,0 +1,630 @@
+#
+#  TOPPERS/ASP Kernel
+#      Toyohashi Open Platform for Embedded Real-Time Systems/
+#      Advanced Standard Profile Kernel
+# 
+#  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: Makefile 735 2016-04-03 14:11:07Z ertl-hiro $
+# 
+
+#
+#  ã¿ã¼ã²ããã®æå®ï¼Makefile.targetã§ä¸æ¸ããããã®ãé²ãããï¼
+#
+all:
+
+#
+#  ã¿ã¼ã²ããç¥ç§°ã®å®ç¾©
+#
+TARGET = gr_sakura_gcc
+
+#
+#  ãã­ã°ã©ãã³ã°è¨èªã®å®ç¾©
+#
+SRCLANG = c
+ifeq ($(SRCLANG),c)
+	LIBS = -lc
+endif
+ifeq ($(SRCLANG),c++)
+	USE_CXX = true
+	CXXLIBS = -lstdc++ -lm -lc
+	CXXRTS = cxxrt.o newlibrt.o
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+SRCDIR = ..
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µå­ã®è¨­å®
+#
+OBJEXT = elf
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.aï¼ã®ãã£ã¬ã¯ããªå
+#  ï¼ã«ã¼ãã«ã©ã¤ãã©ãªãmakeå¯¾è±¡ã«ããæã¯ï¼ç©ºã«å®ç¾©ããï¼
+#
+KERNEL_LIB = 
+
+#
+#  ã«ã¼ãã«ãé¢æ°åä½ã§ã³ã³ãã¤ã«ãããã©ããã®å®ç¾©
+#
+KERNEL_FUNCOBJS = 
+
+#
+#  TECSãå¤ããã©ããã®å®ç¾©
+#
+OMIT_TECS = 
+
+#
+#  ãã¬ã¼ã¹ã­ã°ãåå¾ãããã©ããã®å®ç¾©
+#
+ENABLE_TRACE = 
+
+#
+#  éçºãã¼ã«ï¼ã³ã³ãã¤ã©ç­ï¼ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+DEVTOOLDIR = 
+
+#
+#  ã¦ã¼ãã£ãªãã£ãã­ã°ã©ã ã®åç§°
+#
+CFG = ruby -Eutf-8 $(SRCDIR)/cfg/cfg.rb
+TECSGEN = ruby -Eutf-8 $(SRCDIR)/tecsgen/tecsgen.rb
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®å®ç¾©
+#
+OBJNAME = asp
+ifdef OBJEXT
+	OBJFILE = $(OBJNAME).$(OBJEXT)
+	CFG1_OUT = cfg1_out.$(OBJEXT)
+else
+	OBJFILE = $(OBJNAME)
+	CFG1_OUT = cfg1_out
+endif
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ãç½®ããã£ã¬ã¯ããªã®å®ç¾©
+#
+DEPDIR = deps
+
+#
+#  ã¿ã¼ã²ããä¾å­é¨ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TARGETDIR = $(SRCDIR)/target/$(TARGET)
+
+#
+#  ã¿ã¼ã²ããä¾å­ã®å®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(TARGETDIR)/Makefile.target
+
+#
+#  TECSçæãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TECSGENDIR = ./gen
+ifndef OMIT_TECS
+	TECSGEN_TIMESTAMP = $(TECSGENDIR)/tecsgen.timestamp
+	INIT_TECS_COBJ = init_tecs.o
+endif
+
+#
+#  TECSãçæããå®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+ifndef OMIT_TECS
+	GEN_DIR = $(TECSGENDIR)
+	-include $(TECSGENDIR)/Makefile.tecsgen
+endif
+
+#
+#  å
+±éã³ã³ãã¤ã«ãªãã·ã§ã³ã®å®ç¾©
+#
+COPTS := -g  $(COPTS)
+ifndef OMIT_WARNING_ALL
+	COPTS := -Wall $(COPTS)
+endif
+ifndef OMIT_OPTIMIZATION
+	COPTS := -Og $(COPTS)
+endif
+ifdef OMIT_TECS
+	CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
+endif
+CDEFS := $(CDEFS) 
+INCLUDES := -I. -I$(SRCDIR)/include $(INCLUDES) -I$(SRCDIR)
+LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref
+LIBS := $(LIBS) $(CXXLIBS)
+CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
+
+#
+#  ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã«é¢ããå®ç¾©
+#
+APPLNAME = sample1
+APPLDIRS = $(SRCDIR)/sample
+APPL_CFG = sample1.cfg
+APPL_CDL = sample1.cdl
+
+APPL_DIRS := $(APPLDIRS) $(SRCDIR)/library
+APPL_ASMOBJS :=
+ifdef USE_CXX
+	APPL_CXXOBJS := sample1.o
+	APPL_COBJS :=
+else
+	APPL_COBJS := sample1.o
+endif
+APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
+APPL_CFLAGS := $(APPL_CFLAGS)
+ifdef APPLDIRS
+	INCLUDES := $(INCLUDES) $(foreach dir,$(APPLDIRS),-I$(dir))
+endif
+
+TINETDIR = 
+ifdef TINETDIR
+	#
+	#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+	#
+
+	NO_USE_TINET_LIBRARY = true
+
+	#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+	NET_IF = ether
+
+	#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+	NET_DEV = if_rx62n
+
+	#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+	#SUPPORT_INET6 = true
+	SUPPORT_INET4 = true
+
+	#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+	#API_CFG_IP4MAPPED_ADDR = true
+
+	#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+	SUPPORT_TCP = true
+	#SUPPORT_UDP = true
+
+	#
+	#  ãããã¯ã¼ã¯ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+	#
+	include $(SRCDIR)/$(TINETDIR)/Makefile.tinet
+endif
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã«é¢ããå®ç¾©
+#
+SYSSVC_DIRS := $(TECSGENDIR) $(SRCDIR)/tecs_kernel \
+				$(SYSSVC_DIRS) $(SRCDIR)/syssvc
+SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
+SYSSVC_COBJS := $(INIT_TECS_COBJ) $(TECS_COBJS) $(SYSSVC_COBJS) \
+				 $(CXXRTS)
+SYSSVC_CFLAGS := $(SYSSVC_CFLAGS)
+INCLUDES := $(INCLUDES) -I$(TECSGENDIR) -I$(SRCDIR)/tecs_kernel
+
+#
+#  ã¿ã¼ã²ãããã¡ã¤ã«
+#
+.PHONY: all
+ifndef OMIT_TECS
+all: tecs
+#	@$(MAKE) check
+	@$(MAKE) check $(OBJNAME).bin
+#	@$(MAKE) check $(OBJNAME).srec
+else
+#all: check
+all: check $(OBJNAME).bin
+#all: check $(OBJNAME).srec
+endif
+
+##### ä»¥ä¸ã¯ç·¨éããªããã¨ #####
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã«é¢ããå®ç¾©
+#
+ifndef TINETDIR
+  CFG_TRB := -T $(TARGETDIR)/target_kernel.trb
+  CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \
+			--symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
+else
+  CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T $(TARGETDIR)/target_kernel.trb:kernel
+  CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \
+			--api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
+			--symval-table $(SRCDIR)/tinet/tcpip_sym.def \
+			--symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
+endif
+CFG_ASMOBJS := $(CFG_ASMOBJS) kernel_cfg_asm.o
+CFG_COBJS := kernel_cfg.o $(CFG_COBJS)
+CFG_OBJS := $(CFG_ASMOBJS) $(CFG_COBJS)
+CFG2_OUT_SRCS := kernel_cfg.h kernel_cfg.c $(CFG2_OUT_SRCS)
+CFG_CFLAGS := -DTOPPERS_CB_TYPE_ONLY $(CFG_CFLAGS)
+
+#
+#  ã«ã¼ãã«ã«é¢ããå®ç¾©
+#
+#  KERNEL_ASMOBJS: ã«ã¼ãã«ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãã¢ã»ã³ããªè¨èªã®
+#				   ãªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_COBJS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãCè¨èªã§ï¼ã½ã¼ã¹
+#				 ãã¡ã¤ã«ã¨1å¯¾1ã«å¯¾å¿ãããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_LCSRCS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããCè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ã§ï¼
+#				  1ã¤ã®ã½ã¼ã¹ãã¡ã¤ã«ããè¤æ°ã®ãªãã¸ã§ã¯ããã¡ã¤ã«ãç
+#				  æãããã®ï¼
+#  KERNEL_LCOBJS: ä¸ã®ã½ã¼ã¹ãã¡ã¤ã«ããçæããããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#
+KERNEL_DIRS := $(KERNEL_DIRS) $(SRCDIR)/kernel
+KERNEL_ASMOBJS := $(KERNEL_ASMOBJS)
+KERNEL_COBJS := $(KERNEL_COBJS)
+KERNEL_CFLAGS := $(KERNEL_CFLAGS) -I$(SRCDIR)/kernel
+
+#
+#  ã«ã¼ãã«ã®ãã¡ã¤ã«æ§æã®å®ç¾©
+#
+include $(SRCDIR)/kernel/Makefile.kernel
+ifdef KERNEL_FUNCOBJS
+	KERNEL_LCSRCS := $(KERNEL_FCSRCS)
+	KERNEL_LCOBJS := $(foreach file,$(KERNEL_FCSRCS),$($(file:.c=)))
+else
+	KERNEL_CFLAGS := -DALLFUNC $(KERNEL_CFLAGS)
+	KERNEL_COBJS := $(KERNEL_COBJS) \
+					$(foreach file,$(KERNEL_FCSRCS),$(file:.c=.o))
+endif
+ifdef OMIT_OFFSET_H
+	OFFSET_H =
+else
+	OFFSET_H = offset.h
+endif
+ifndef TARGET_OFFSET_TRB
+	TARGET_OFFSET_TRB := $(TARGETDIR)/target_offset.trb
+endif
+ifndef TARGET_KERNEL_TRB
+	TARGET_KERNEL_TRB := $(TARGETDIR)/target_kernel.trb
+endif
+ifndef TARGET_CHECK_TRB
+	TARGET_CHECK_TRB := $(TARGETDIR)/target_check.trb
+endif
+ifndef TARGET_KERNEL_CFG
+	TARGET_KERNEL_CFG := $(TARGETDIR)/target_kernel.cfg
+endif
+ifndef TARGET_TCPIP_TRB
+	TARGET_TCPIP_TRB := $(SRCDIR)/tinet/tinet.trb
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãããã£ã¬ã¯ããªã«é¢ããå®ç¾©
+#
+vpath %.c $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.S $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.cfg $(APPL_DIRS)
+vpath %.cdl $(APPL_DIRS)
+
+#
+#  ã³ã³ãã¤ã«ã®ããã®å¤æ°ã®å®ç¾©
+#
+KERNEL_LIB_OBJS = $(KERNEL_ASMOBJS) $(KERNEL_COBJS) $(KERNEL_LCOBJS)
+SYSSVC_OBJS = $(SYSSVC_ASMOBJS) $(SYSSVC_COBJS) $(HIDDEN_OBJS)
+APPL_OBJS = $(APPL_ASMOBJS) $(APPL_COBJS) $(APPL_CXXOBJS)
+ALL_OBJS = $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+											$(END_OBJS) $(HIDDEN_OBJS)
+ALL_LIBS = -lkernel $(LIBS)
+ifdef KERNEL_LIB
+	LIBS_DEP = $(KERNEL_LIB)/libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L$(KERNEL_LIB)
+	REALCLEAN_FILES := libkernel.a $(REALCLEAN_FILES)
+else
+	LIBS_DEP = libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L.
+endif
+
+ifdef TEXT_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Ttext,$(TEXT_START_ADDRESS)
+endif
+ifdef DATA_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Tdata,$(DATA_START_ADDRESS)
+endif
+ifdef LDSCRIPT
+	LDFLAGS := $(LDFLAGS) -T $(LDSCRIPT)
+endif
+
+#
+#  tecsgenããCããªãã­ã»ããµãå¼ã³åºãéã®ãªãã·ã§ã³ã®å®ç¾©
+#
+TECS_CPP = $(CC) $(CDEFS) $(INCLUDES) $(SYSSVC_CFLAGS) -D TECSGEN -E
+
+#
+#  tecsgenã®å¼åºã
+#
+.PHONY: tecs
+tecs $(TECSGEN_SRCS) $(TECS_HEADERS): $(TECSGEN_TIMESTAMP) ;
+$(TECSGEN_TIMESTAMP): $(APPL_CDL) $(TECS_IMPORTS)
+	$(TECSGEN) $< -R $(INCLUDES) --cpp "$(TECS_CPP)" -g $(TECSGENDIR)
+
+#
+#  ã«ã¼ãã«ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®çæ
+#
+cfg1_out.c cfg1_out.db: cfg1_out.timestamp ;
+cfg1_out.timestamp: $(APPL_CFG) $(TECSGEN_TIMESTAMP)
+	echo $(CFG_TABS)
+	$(CFG) --pass 1 --kernel asp $(INCLUDES) $(CFG_TABS) \
+						-M $(DEPDIR)/cfg1_out_c.d $(TARGET_KERNEL_CFG) $<
+
+$(CFG1_OUT): $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS) $(HIDDEN_OBJS)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(CFG1_OUT_LDFLAGS) -o $(CFG1_OUT) \
+						$(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS)
+
+cfg1_out.syms: $(CFG1_OUT)
+	$(NM) -n $(CFG1_OUT) > cfg1_out.syms
+
+cfg1_out.srec: $(CFG1_OUT)
+	$(OBJCOPY) -O srec -S $(CFG1_OUT) cfg1_out.srec
+
+$(CFG2_OUT_SRCS) cfg2_out.db: kernel_cfg.timestamp ;
+kernel_cfg.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 --kernel asp $(INCLUDES) $(CFG_TRB)
+
+#
+#  ãªãã»ãããã¡ã¤ã«ï¼offset.hï¼ã®çæè¦å
+#
+$(OFFSET_H): offset.timestamp ;
+offset.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 -O --kernel asp $(INCLUDES) -T $(TARGET_OFFSET_TRB) \
+				--rom-symbol cfg1_out.syms --rom-image cfg1_out.srec
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªãã¡ã¤ã«ã®çæ
+#
+libkernel.a: $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f libkernel.a
+	$(AR) -rcs libkernel.a $(KERNEL_LIB_OBJS)
+	$(RANLIB) libkernel.a
+
+#
+#  ç¹å¥ãªä¾å­é¢ä¿ã®å®ç¾©
+#
+tBannerMain.o: $(filter-out tBannerMain.o,$(ALL_OBJS)) $(LIBS_DEP)
+
+#
+#  å
+¨ä½ã®ãªã³ã¯
+#
+$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
+			$(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+			$(ALL_LIBS) $(END_OBJS)
+
+#
+#  ã·ã³ãã«ãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).syms: $(OBJFILE)
+	$(NM) -n $(OBJFILE) > $(OBJNAME).syms
+
+#
+#  ãã¤ããªãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).bin: $(OBJFILE)
+	$(OBJCOPY) -O binary -S $(OBJFILE) $(OBJNAME).bin
+	$(OBJDUMP) -h $(OBJFILE)
+	$(SIZE) $(OBJFILE)
+
+#
+#  Sã¬ã³ã¼ããã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).srec: $(OBJFILE)
+	$(OBJCOPY) -O srec -S $(OBJFILE) $(OBJNAME).srec
+
+#
+#  ã¨ã©ã¼ãã§ãã¯å¦ç
+#
+.PHONY: check
+check: check.timestamp ;
+check.timestamp: cfg2_out.db $(OBJNAME).syms $(OBJNAME).srec
+	$(CFG) --pass 3 --kernel asp -O $(INCLUDES) -T $(TARGET_CHECK_TRB) \
+				--rom-symbol $(OBJNAME).syms --rom-image $(OBJNAME).srec
+	@echo "configuration check passed"
+
+#
+#  ã³ã³ãã¤ã«çµæã®æ¶å»
+#
+.PHONY: clean
+clean:
+	rm -f \#* *~ *.o $(DEPDIR)/*.d $(CLEAN_FILES) check.timestamp
+	rm -f $(OBJFILE) $(OBJNAME).syms $(OBJNAME).srec $(OBJNAME).bin
+	rm -f kernel_cfg.timestamp $(CFG2_OUT_SRCS) cfg2_out.db
+	rm -f offset.timestamp $(OFFSET_H)
+	rm -f cfg1_out.syms cfg1_out.srec $(CFG1_OUT)
+	rm -f cfg1_out.timestamp cfg1_out.c cfg1_out.db
+	rm -rf $(TECSGENDIR)
+ifndef KERNEL_LIB
+	rm -f libkernel.a
+endif
+
+.PHONY: cleankernel
+cleankernel:
+	rm -f $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f $(KERNEL_LIB_OBJS:%.o=$(DEPDIR)/%.d)
+
+.PHONY: realclean
+realclean: clean
+	rm -f $(REALCLEAN_FILES)
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã®ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã¯ï¼å
+±éã®ã³ã³ãã¤ã«ãªãã·ã§ã³
+#  ã®ã¿ãä»ãã¦ã³ã³ãã¤ã«ããï¼
+#
+ALL_CFG_COBJS = $(CFG_COBJS) cfg1_out.o
+ALL_CFG_ASMOBJS = $(CFG_ASMOBJS)
+
+$(ALL_CFG_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+#
+-include $(DEPDIR)/*.d
+
+#
+#  éçºãã¼ã«ã®ã³ãã³ãåã®å®ç¾©
+#
+ifeq ($(TOOL),gcc)
+	#
+	#  GNUéçºç°å¢ç¨
+	#
+	ifdef GCC_TARGET
+		GCC_TARGET_PREFIX = $(GCC_TARGET)-
+	else
+		GCC_TARGET_PREFIX =
+	endif
+	CC := $(GCC_TARGET_PREFIX)gcc
+	CXX := $(GCC_TARGET_PREFIX)g++
+	AS := $(GCC_TARGET_PREFIX)as
+	LD := $(GCC_TARGET_PREFIX)ld
+	AR := $(GCC_TARGET_PREFIX)ar
+	NM := $(GCC_TARGET_PREFIX)nm
+	RANLIB := $(GCC_TARGET_PREFIX)ranlib
+	OBJCOPY := $(GCC_TARGET_PREFIX)objcopy
+	OBJDUMP := $(GCC_TARGET_PREFIX)objdump
+	SIZE := $(GCC_TARGET_PREFIX)size
+endif
+
+ifdef DEVTOOLDIR
+	CC := $(DEVTOOLDIR)/$(CC)
+	CXX := $(DEVTOOLDIR)/$(CXX)
+	AS := $(DEVTOOLDIR)/$(AS)
+	LD := $(DEVTOOLDIR)/$(LD)
+	AR := $(DEVTOOLDIR)/$(AR)
+	NM := $(DEVTOOLDIR)/$(NM)
+	RANLIB := $(DEVTOOLDIR)/$(RANLIB)
+	OBJCOPY := $(DEVTOOLDIR)/$(OBJCOPY)
+	OBJDUMP := $(DEVTOOLDIR)/$(OBJDUMP)
+endif
+
+ifdef USE_CXX
+	LINK = $(CXX)
+else
+	LINK = $(CC)
+endif
+
+#
+#  ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+$(KERNEL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS): %.o:
+	$(CC) -DTOPPERS_$(*F) -o $@ -c -MD -MP -MF $(DEPDIR)/$*.d \
+									$(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS:.o=.s): %.s:
+	$(CC) -DTOPPERS_$(*F) -o $@ -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(SYSSVC_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(APPL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS): %.o: %.cpp
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS:.o=.s): %.s: %.cpp
+	$(CXX) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+#
+#  ããã©ã«ãã³ã³ãã¤ã«ã«ã¼ã«ãä¸æ¸ã
+#
+%.o: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -S $(CFLAGS) $<
+
+%.o: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -S $(CFLAGS) $<
+
+%.o: %.S
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
Index: asp3_gr_sakura/trunk/MANIFEST
===================================================================
--- asp3_gr_sakura/trunk/MANIFEST	(revision 317)
+++ asp3_gr_sakura/trunk/MANIFEST	(revision 317)
@@ -0,0 +1,162 @@
+PACKAGE asp3
+VERSION 3.1.0
+
+configure.rb
+MANIFEST
+README.txt
+
+doc/asp_spec.txt
+doc/configurator.txt
+doc/design.txt
+doc/extension.txt
+doc/migration.txt
+doc/porting.txt
+doc/user.txt
+doc/version.txt
+
+include/itron.h
+include/kernel.h
+include/log_output.h
+include/queue.h
+include/sil.h
+include/t_stddef.h
+include/t_stdlib.h
+include/t_syslog.h
+
+kernel/Makefile.kernel
+kernel/alarm.c
+kernel/alarm.h
+kernel/alarm.trb
+kernel/allfunc.h
+kernel/check.h
+kernel/cyclic.c
+kernel/cyclic.h
+kernel/cyclic.trb
+kernel/dataqueue.c
+kernel/dataqueue.h
+kernel/dataqueue.trb
+kernel/eventflag.c
+kernel/eventflag.h
+kernel/eventflag.trb
+kernel/exception.c
+kernel/exception.h
+kernel/exception.trb
+kernel/genoffset.trb
+kernel/interrupt.c
+kernel/interrupt.h
+kernel/interrupt.trb
+kernel/kernel.trb
+kernel/kernel_api.def
+kernel/kernel_check.trb
+kernel/kernel_impl.h
+kernel/kernel_int.h
+kernel/kernel_rename.def
+kernel/kernel_rename.h
+kernel/kernel_sym.def
+kernel/kernel_unrename.h
+kernel/mempfix.c
+kernel/mempfix.h
+kernel/mempfix.trb
+kernel/mutex.c
+kernel/mutex.h
+kernel/mutex.trb
+kernel/pridataq.c
+kernel/pridataq.h
+kernel/pridataq.trb
+kernel/semaphore.c
+kernel/semaphore.h
+kernel/semaphore.trb
+kernel/startup.c
+kernel/sys_manage.c
+kernel/task.c
+kernel/task.h
+kernel/task.trb
+kernel/task_manage.c
+kernel/task_refer.c
+kernel/task_sync.c
+kernel/task_term.c
+kernel/taskhook.c
+kernel/taskhook.h
+kernel/time_event.c
+kernel/time_event.h
+kernel/time_manage.c
+kernel/wait.c
+kernel/wait.h
+
+tecs_kernel/init_tecs.c
+tecs_kernel/kernel.cdl
+tecs_kernel/tAlarmNotifier.c
+tecs_kernel/tAlarmNotifier_inline.h
+tecs_kernel/tCpuExceptionHandler.c
+tecs_kernel/tCyclicNotifier.c
+tecs_kernel/tCyclicNotifier_inline.h
+tecs_kernel/tDataqueue_inline.h
+tecs_kernel/tEventflag_inline.h
+tecs_kernel/tFixedSizeMemoryPool_inline.h
+tecs_kernel/tISR.c
+tecs_kernel/tInitializeRoutine.c
+tecs_kernel/tInterruptHandler.c
+tecs_kernel/tInterruptRequest_inline.h
+tecs_kernel/tKernel_inline.h
+tecs_kernel/tMutex_inline.h
+tecs_kernel/tPriorityDataqueue_inline.h
+tecs_kernel/tSemaphore_inline.h
+tecs_kernel/tTask.c
+tecs_kernel/tTask_inline.h
+tecs_kernel/tTerminateRoutine.c
+tecs_kernel/tecs_kernel.h
+
+syssvc/histogram.h
+syssvc/serial.h
+syssvc/syslog.h
+syssvc/tHistogram.c
+syssvc/tHistogram.cdl
+syssvc/tHistogram.h
+syssvc/tHistogramAdapter.c
+syssvc/tHistogramAdapter.cdl
+syssvc/tBanner.cdl
+syssvc/tBannerMain.c
+syssvc/tLogTask.cdl
+syssvc/tLogTaskMain.c
+syssvc/tSerialAdapter.c
+syssvc/tSerialAdapter.cdl
+syssvc/tSerialPort.cdl
+syssvc/tSerialPortMain.c
+syssvc/tSysLog.c
+syssvc/tSysLog.cdl
+syssvc/tSysLogAdapter.c
+syssvc/tSysLogAdapter.cdl
+syssvc/tTestService.c
+syssvc/tTestService.cdl
+syssvc/test_svc.h
+
+library/log_output.c
+library/strerror.c
+library/t_perror.c
+library/vasyslog.c
+
+arch/gcc/tool_stddef.h
+
+arch/tracelog/trace_log.h
+arch/tracelog/tTraceLog.c
+arch/tracelog/tTraceLog.cdl
+
+utils/applyrename.rb
+utils/genrename.rb
+utils/gentest.rb
+utils/makerelease.rb
+
+sample/Makefile
+sample/sample1.c
+sample/sample1.cdl
+sample/sample1.cfg
+sample/sample1.h
+sample/tSample2.c
+sample/tSample2.cdl
+sample/tSample2.cfg
+sample/tSample2.h
+
+INCLUDE cfg/MANIFEST
+INCLUDE test/MANIFEST
+INCLUDE extension/MANIFEST
+INCLUDE target/dummy_gcc/MANIFEST
Index: asp3_gr_sakura/trunk/README.txt
===================================================================
--- asp3_gr_sakura/trunk/README.txt	(revision 317)
+++ asp3_gr_sakura/trunk/README.txt	(revision 317)
@@ -0,0 +1,56 @@
+
+	TOPPERS/ASP3 Kernelï¼Release 3.1ï¼
+		Toyohashi Open Platform for Embedded Real-Time Systems/
+		Advanced Standard Profile Kernel
+
+TOPPERS/ASP3ã«ã¼ãã«ï¼TOPPERS/ASPã«ã¼ãã« Release 3.Xï¼ä»¥ä¸ï¼ASP3ã«ã¼ã
+ã«ï¼ã¯ï¼TOPPERS/ASPã«ã¼ãã«ãæ¡å¼µã»æ¹è¯ãããã®ã§ï¼TOPPERSç¬¬3ä¸ä»£ã«ã¼ã
+ã«ï¼ITRONç³»ï¼ã®åºç¤ã¨ãªããã®ã¨ãã¦éçºãããªã¢ã«ã¿ã¤ã ã«ã¼ãã«ã§ãï¼
+
+TOPPERS/ASPã«ã¼ãã«ã¯ï¼Î¼ITRON4.0ä»æ§ã®ã¹ã¿ã³ãã¼ããã­ãã¡ã¤ã«æºæ ã®ãª
+ã¢ã«ã¿ã¤ã ã«ã¼ãã«ã§ããTOPPERS/JSPã«ã¼ãã«ãæ¡å¼µã»æ¹è¯ããå½¢ã§éçºãã
+ãã®ã§ãï¼
+
+ãæåã«èª­ãã¹ããã­ã¥ã¡ã³ãã
+
+ASP3ã«ã¼ãã«ã®ä»æ§æ¦è¦ãdoc/asp_spec.txtã«ï¼ã¦ã¼ã¶ã¼ãºããã¥ã¢ã«ã
+doc/user.txtã«ããã¾ãï¼ã¾ãï¼å¾æ¥ã®TOPPERSã«ã¼ãã«ããASP3ã«ã¼ãã«ã¸ç§»
+è¡ããããã®æ¹æ³ãè¨è¿°ãããã¤ã°ã¬ã¼ã·ã§ã³ã¬ã¤ããdoc/migration.txtã«ã
+ãã¾ãï¼ASP3ã«ã¼ãã«ãä½¿ç¨ããå ´åã«ã¯ï¼ã¾ãã¯ãããã®ãã­ã¥ã¡ã³ããã
+èª­ã¿ä¸ããï¼
+
+ããã¡ã¤ã«ã®é²è¦§ã«ããã£ã¦ã
+
+ASP3ã«ã¼ãã«ã®ãã­ã¥ã¡ã³ãï¼ãã¬ã¼ã³ãã­ã¹ããã¡ã¤ã«ï¼ããã³ã½ã¼ã¹ãã¡
+ã¤ã«ãèª­ãéã«ã¯ï¼TABã4ã«è¨­å®ãã¦ãã ããï¼
+
+ãå©ç¨æ¡ä»¶ã
+
+ASP3ã«ã¼ãã«ã®å©ç¨æ¡ä»¶ã¯ï¼åãã¡ã¤ã«ã®å
+é ­ã«è¡¨ç¤ºããã¦ããTOPPERSã©ã¤ã»
+ã³ã¹ã§ãï¼TOPPERSã©ã¤ã»ã³ã¹ã«é¢ããFAQãï¼ä»¥ä¸ã®ãã¼ã¸ã«ããã¾ãï¼
+
+	http://www.toppers.jp/faq/faq_ct12.html
+
+ãè³ªåã»ãã°ã¬ãã¼ãã»æè¦ç­ã®éä»å
+ã
+
+ASP3ã«ã¼ãã«ãããè¯ããã®ã«ããããã®ãæè¦ç­ãæ­è¿ãã¾ãï¼ASP3ã«ã¼ã
+ã«ã«é¢ããè³ªåããã°ã¬ãã¼ãï¼ãæè¦ç­ã¯ï¼TOPPERSãã­ã¸ã§ã¯ãã®ä¼å¡ã¯
+TOPPERSéçºè
+ã¡ã¼ãªã³ã°ãªã¹ãï¼dev@toppers.jpï¼å®ã¾ãã¯ASP3ã«ã¼ãã«ã®ã
+ã°ãã©ãã­ã³ã°ã·ã¹ãã ï¼Tracï¼ã«ï¼ãã®ä»ã®æ¹ã¯TOPPERSã¦ã¼ã¶ã¼ãºã¡ã¼ãªã³
+ã°ãªã¹ãï¼users@toppers.jpï¼å®ã«ãé¡ããã¾ãï¼
+
+TOPPERSã¦ã¼ã¶ã¼ãºã¡ã¼ãªã³ã°ãªã¹ãã¸ã®ç»é²æ¹æ³ã«ã¤ãã¦ã¯ï¼ä»¥ä¸ã®ãã¼ã¸ã«
+èª¬æãããã¾ãï¼
+
+	http://www.toppers.jp/community.html
+
+ããã¼ãã£ã³ã°ã«ããã£ã¦ã
+
+ASP3ã«ã¼ãã«ãï¼TOPPERSãã­ã¸ã§ã¯ããããªã¼ãã³ã½ã¼ã¹ã«ãããã¨ãåæã«ï¼
+æªãµãã¼ãã®ã¿ã¼ã²ããã«ãã¼ãã£ã³ã°ãããå ´åã«ã¯ï¼ããããããç¸è«ã
+ã ããã¨å¹¸ãã§ãï¼
+
+ä»¥ä¸
Index: asp3_gr_sakura/trunk/arch/gcc/tool_stddef.h
===================================================================
--- asp3_gr_sakura/trunk/arch/gcc/tool_stddef.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/gcc/tool_stddef.h	(revision 317)
@@ -0,0 +1,218 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		t_stddef.hã®éçºç°å¢ä¾å­é¨ï¼GCCç¨ï¼
+ */
+
+#ifndef TOPPERS_TOOL_STDDEF_H
+#define TOPPERS_TOOL_STDDEF_H
+
+/*
+ *  ã³ã³ãã¤ã©ã®æ¡å¼µæ©è½ã®ããã®ãã¯ã­å®ç¾©
+ */
+#ifndef __cplusplus					/* C++ã«ã¯inline ããã */
+#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
+									/* C99ã«ã¯inline ããã */
+#define inline	__inline__			/* ã¤ã³ã©ã¤ã³é¢æ° */
+#endif /* !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L */
+#endif /* __cplusplus */
+
+#define Inline	static inline		/* ã¤ã³ã©ã¤ã³é¢æ° */
+
+#ifndef __cplusplus					/* C++ã«ã¯asmããã */
+#define asm		__asm__				/* ã¤ã³ã©ã¤ã³ã¢ã»ã³ãã© */
+#endif /* __cplusplus */
+
+#define Asm		__asm__ volatile	/* ã¤ã³ã©ã¤ã³ã¢ã»ã³ãã©ï¼æé©åææ­¢ï¼*/
+
+#define NoReturn	__attribute__((__noreturn__))
+									/* ãªã¿ã¼ã³ããªãé¢æ° */
+
+/*
+ *  éçºç°å¢ã®æ¨æºã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã®å©ç¨
+ *
+ *  NULLã®å®ç¾©ãstddef.hããï¼INT_MAXï¼INT_MINï¼UINT_MAXï¼LONG_MAXï¼
+ *  LONG_MINï¼ULONG_MAXï¼CHAR_BITã®å®ç¾©ãlimits.hããåãè¾¼ãï¼
+ *
+ *  C++/EC++ã§ã¯ï¼æ¨æºä»æ§ä¸ã¯ãããã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ãç¨æããã¦
+ *  ããã¨ã¯éããªãã®ã§æ³¨æãå¿
+è¦ã§ããï¼ã»ã¨ãã©ã®éçºç°å¢ã§ç¨æãã
+ *  ã¦ããï¼ï¼
+ */
+#ifndef TOPPERS_MACRO_ONLY
+#include <stddef.h>
+#include <limits.h>
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  stdint.hã®ä»£ç¨ã¨ãªãå®ç¾©
+ *
+ *  éçºç°å¢ã«stdint.hãç¨æããã¦ãããï¼åæ´æ°åã®ãµã¤ãºããããã¿ã¼
+ *  ã³ã«å½ã¦ã¯ã¾ãå ´åã«ï¼stdint.hã®ä»£ç¨ã¨ãªãå®ç¾©ãä¸ããï¼
+ *
+ *  TOPPERS_STDINT_TYPE1: char/short/int/long longã®ãããé·ããããã
+ *                        8/16/32/64ãããã§ï¼ãã¤ã³ã¿ã®ãããé·ãlong
+ *                        ã®ãããé·ã¨ä¸è´ããå ´å
+ */
+#ifdef TOPPERS_STDINT_TYPE1
+
+/*
+ *  ã³ã³ãã¤ã©ä¾å­ã®ãã¼ã¿åã®å®ç¾©
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+typedef signed char			int8_t;		/* ç¬¦å·ä»ã8ãããæ´æ° */
+typedef unsigned char		uint8_t;	/* ç¬¦å·ç¡ã8ãããæ´æ° */
+
+typedef signed short		int16_t;	/* ç¬¦å·ä»ã16ãããæ´æ° */
+typedef unsigned short		uint16_t;	/* ç¬¦å·ç¡ã16ãããæ´æ° */
+
+typedef signed int			int32_t;	/* ç¬¦å·ä»ã32ãããæ´æ° */
+typedef unsigned int		uint32_t;	/* ç¬¦å·ç¡ã32ãããæ´æ° */
+
+typedef signed long long	int64_t;	/* ç¬¦å·ä»ã64ãããæ´æ° */
+typedef unsigned long long	uint64_t;	/* ç¬¦å·ç¡ã64ãããæ´æ° */
+
+typedef int8_t				int_least8_t;	/* 8ãããä»¥ä¸ã®ç¬¦å·ä»ãæ´æ° */
+typedef uint8_t				uint_least8_t;	/* 8ãããä»¥ä¸ã®ç¬¦å·ç¡ãæ´æ° */
+
+typedef long				intptr_t;	/* ãã¤ã³ã¿ãæ ¼ç´ã§ããç¬¦å·ä»ãæ´æ° */
+typedef unsigned long		uintptr_t;	/* ãã¤ã³ã¿ãæ ¼ç´ã§ããç¬¦å·ç¡ãæ´æ° */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  ã³ã³ãã¤ã©ä¾å­ã®ãã¼ã¿åã®æ´æ°å®æ°ãä½ããã¯ã­
+ */
+#ifndef INT8_C
+#define INT8_C(val)			(val)
+#endif /* INT8_C */
+
+#ifndef UINT8_C
+#define UINT8_C(val)		(val ## U)
+#endif /* UINT8_C */
+
+#ifndef INT16_C
+#define INT16_C(val)		(val)
+#endif /* INT16_C */
+
+#ifndef UINT16_C
+#define UINT16_C(val)		(val ## U)
+#endif /* UINT16_C */
+
+#ifndef INT32_C
+#define INT32_C(val)		(val)
+#endif /* INT32_C */
+
+#ifndef UINT32_C
+#define UINT32_C(val)		(val ## U)
+#endif /* UINT32_C */
+
+#ifndef INT64_C
+#define INT64_C(val)		(val ## LL)
+#endif /* INT64_C */
+
+#ifndef UINT64_C
+#define UINT64_C(val)		(val ## ULL)
+#endif /* UINT64_C */
+
+/*
+ *  ã³ã³ãã¤ã©ä¾å­ã®ãã¼ã¿åã«æ ¼ç´ã§ããæå¤§å¤ã¨æå°å¤ã®å®ç¾©
+ */
+#define INT8_MAX			SCHAR_MAX
+#define INT8_MIN			SCHAR_MIN
+#define UINT8_MAX			UCHAR_MAX
+
+#define INT16_MAX			SHRT_MAX
+#define INT16_MIN			SHRT_MIN
+#define UINT16_MAX			USHRT_MAX
+
+#define INT32_MAX			INT_MAX
+#define INT32_MIN			INT_MIN
+#define UINT32_MAX			UINT_MAX
+
+#define INT64_MAX			LLONG_MAX
+#define INT64_MIN			LLONG_MIN
+#define UINT64_MAX			ULLONG_MAX
+
+#define INT_LEAST8_MAX		INT8_MAX
+#define INT_LEAST8_MIN		INT8_MIN
+#define UINT_LEAST8_MAX		INT8_MAX
+
+#endif /* TOPPERS_STDINT_TYPE1 */
+
+/*
+ *  æµ®åå°æ°ç¹åã«é¢ããå®ç¾©
+ *
+ *  TOPPERS_STDFLOAT_TYPE1: floatãIEEE754æºæ ã®åç²¾åº¦æµ®åå°æ°ç¹æ°ï¼
+ *							doubleãåç²¾åº¦æµ®åå°æ°ç¹æ°ã®å ´å
+ */
+#ifdef TOPPERS_STDFLOAT_TYPE1
+#ifndef TOPPERS_MACRO_ONLY
+
+typedef float		float32_t;			/* IEEE754æºæ ã®åç²¾åº¦æµ®åå°æ°ç¹æ° */
+typedef double		double64_t;			/* IEEE754æºæ ã®åç²¾åº¦æµ®åå°æ°ç¹æ° */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#define FLOAT32_MIN		1.17549435e-38F
+#define FLOAT32_MAX		3.40282347e+38F
+#define DOUBLE64_MIN	2.2250738585072014e-308
+#define DOUBLE64_MAX	1.7976931348623157e+308
+
+#endif /* TOPPERS_STDFLOAT_TYPE1 */
+#endif /* TOPPERS_TOOL_STDDEF_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/Makefile.prc
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/Makefile.prc	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/Makefile.prc	(revision 317)
@@ -0,0 +1,42 @@
+#
+#		Makefileã®ãã­ã»ããµä¾å­é¨ï¼M68040ç¨ï¼
+#
+
+#
+#  GNUéçºç°å¢ã®ã¿ã¼ã²ããã¢ã¼ã­ãã¯ãã£ã®å®ç¾©
+#
+GCC_TARGET = rx-elf
+
+#
+#  ãã­ã»ããµä¾å­é¨ãã£ã¬ã¯ããªåã®å®ç¾©
+#
+PRCDIR = $(SRCDIR)/arch/$(PRC)_$(TOOL)
+
+#
+#  ãã¼ã«ä¾å­é¨ãã£ã¬ã¯ããªåã®å®ç¾© 
+#
+TOOLDIR = $(SRCDIR)/arch/$(TOOL)
+
+#
+#  ã³ã³ãã¤ã«ãªãã·ã§ã³
+#
+INCLUDES := $(INCLUDES) -I$(TOOLDIR) -I$(PRCDIR)
+COPTS := $(COPTS) -ffunction-sections -fno-function-cse -fsigned-char -fdata-sections -mlittle-endian-data -mcpu=rx600 -m64bit-doubles
+LDFLAGS := $(LDFLAGS) -flto
+
+#
+#  ã«ã¼ãã«ã«é¢ããå®ç¾©
+#
+KERNEL_DIRS := $(KERNEL_DIRS) $(PRCDIR)
+KERNEL_ASMOBJS := $(KERNEL_ASMOBJS) prc_support.o prc_test.o
+KERNEL_COBJS := $(KERNEL_COBJS) prc_kernel_impl.o rx630_kernel_impl.o
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿é¢ä¿ã®å¤æ°ã®å®ç¾©
+#
+CFG_TABS := $(CFG_TABS) --symval-table $(PRCDIR)/prc_sym.def
+
+#
+#  ãªãã»ãããã¡ã¤ã«çæã®ããã®å®ç¾©
+#
+TARGET_OFFSET_TRB = $(PRCDIR)/prc_offset.trb
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_cfg1_out.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_cfg1_out.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_cfg1_out.h	(revision 317)
@@ -0,0 +1,49 @@
+/*
+ *		cfg1_out.cã®ãªã³ã¯ã«å¿
+è¦ãªã¹ã¿ãã®å®ç¾©
+ */
+
+void sta_ker( void )
+{
+}
+
+void hardware_init_hook( void )
+{
+}
+
+void software_init_hook( void )
+{
+}
+
+const size_t	_kernel_istksz = 0;
+
+STK_T *const	_kernel_istk = NULL;
+
+/*
+ *  ãªãã»ãããã¡ã¤ã«ãçæããããã®å®ç¾©
+ */
+const uint8_t	MAGIC_1 = 0x12;
+const uint16_t	MAGIC_2 = 0x1234;
+const uint32_t	MAGIC_4 = 0x12345678;
+
+const TCB	TCB_enatex = {
+	{ NULL, NULL },			/* task_queue */
+	NULL,					/* p_tinib */
+	0U,						/* tstat */
+	0U,						/* bpriority */
+	0U,						/* priority */
+	false,					/* acqeue */
+	false,					/* wupque */
+	true,					/* enatex */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	false,					/* staovr */
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+	0U,						/* texptn */
+	NULL,					/* p_winifo */
+	NULL,			/* mutex_queue */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	0U,						/* leftotm */
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	{ NULL, NULL }			/* tskctxb */
+};
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_check.trb
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_check.trb	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_check.trb	(revision 317)
@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+# 
+#		ãã¹3ã®çæã¹ã¯ãªããã®ã³ã¢ä¾å­é¨ï¼ARMç¨ï¼
+# 
+#  $Id: core_check.trb 730 2016-04-03 02:04:52Z ertl-hiro $
+#
+
+#
+#  ã¿ã¼ã²ããéä¾å­é¨ã®ã¤ã³ã¯ã«ã¼ã
+#
+IncludeTrb("kernel/kernel_check.trb")
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_insn.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_insn.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_insn.h	(revision 317)
@@ -0,0 +1,179 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã­ã»ããµã®ç¹æ®å½ä»¤ã®ã¤ã³ã©ã¤ã³é¢æ°å®ç¾©ï¼RX630ç¨ï¼
+ */
+
+#ifndef	TOPPERS_PRC_INSN_H
+#define	TOPPERS_PRC_INSN_H
+
+#ifndef TOPPERS_MACRO_ONLY
+
+static uint32_t current_psw( void );
+static void set_psw( uint32_t psw );
+Inline uint32_t current_ipl( void );
+Inline void set_ipl( uint32_t ipl );
+static void disint( void );
+static void enaint( void );
+static uint16_t rev_endian_uint16( uint16_t data );
+static uint32_t rev_endian_uint32( uint32_t data );
+
+/*
+ *  Iãã©ã°, IPLãåå¾ããããã®ãã¯ã­å®ç¾©
+ */
+#define PSW_I_MASK		( 0x00010000UL )
+#define PSW_IPL_MASK	( 0x0F000000UL )
+
+#else /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  Iãã©ã°, IPLãåå¾ããããã®ãã¯ã­å®ç¾©
+ */
+#define PSW_I_MASK		( 0x00010000 )
+#define PSW_IPL_MASK	( 0x0F000000 )
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ãã­ã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã®ç¾å¨å¤ã®èª­åºã
+ */
+static uint32_t
+current_psw( void )
+{
+	uint32_t psw;
+	Asm("mvfc	psw, %0" : "=r"(psw));
+	return psw;
+}
+
+
+/*
+ *  ãã­ã»ããµã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿(PSW)ã¸è¨­å®
+ */
+static void
+set_psw( uint32_t psw )
+{
+	Asm("mvtc %0, psw" :: "r"(psw));
+}
+
+
+/*
+ *  IPLã®ç¾å¨å¤ã®èª­åºã
+ */
+Inline uint32_t
+current_ipl( void )
+{
+	return ( uint32_t )( current_psw() & PSW_IPL_MASK );
+}
+
+
+/*
+ *  IPLã¸è¨­å®
+ */
+Inline void
+set_ipl( uint32_t ipl )
+{
+	set_psw( ( current_psw() & ( ~PSW_IPL_MASK ) ) | ipl );
+}
+
+
+/*
+ *  NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®ç¦æ­¢
+ */
+static void
+disint( void )
+{
+	Asm("clrpsw	i");
+}
+
+
+/*
+ *  NMIãé¤ããã¹ã¦ã®å²è¾¼ã¿ã®è¨±å¯
+ */
+static void
+enaint( void )
+{
+	Asm("setpsw	i");
+}
+
+
+/*
+ *  ã¨ã³ãã£ã¢ã³å¤æ 16bit
+ */
+static uint16_t
+rev_endian_uint16( uint16_t data )
+{
+	Asm("revw %0, %1" : "=r"(data) : "r"(data));
+	return data;
+}
+
+/*
+ *  ã¨ã³ãã£ã¢ã³å¤æ 32bit
+ */
+static uint32_t
+rev_endian_uint32( uint32_t data )
+{
+	Asm("revl %0, %1" : "=r"(data) : "r"(data));
+	return data;
+}
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#endif /* TOPPERS_PRC_INSN_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.h	(revision 317)
@@ -0,0 +1,119 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		kernel.hã®ãã­ã»ããµä¾å­é¨ï¼RX630ç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼target_kernel.hï¼ã¾ãã¯ï¼ããããã¤ã³ã¯
+ *  ã«ã¼ãããããã¡ã¤ã«ï¼ã®ã¿ããã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡ã¤ã«ãã
+ *  ç´æ¥ã¤ã³ã¯ã«ã¼ããã¦ã¯ãªããªãï¼
+ */
+
+#ifndef TOPPERS_PRC_KERNEL_H
+#define TOPPERS_PRC_KERNEL_H
+
+/*
+ *  ã«ã¼ãã«æ¬ä½ãã³ã³ãã¤ã«ããããã®ãã¯ã­å®ç¾©
+ */
+//#define ALLFUNC
+
+
+/*
+ *  ãµãã¼ãããæ©è½ã®å®ç¾©
+ */
+#define TOPPERS_TARGET_SUPPORT_DIS_INT		/* dis_intããµãã¼ããã */
+#define TOPPERS_TARGET_SUPPORT_ENA_INT		/* ena_intããµãã¼ããã */
+#define TOPPERS_TARGET_SUPPORT_CLR_INT		/* clr_intããµãã¼ããã */
+#define TOPPERS_TARGET_SUPPORT_RAS_INT		/* ras_intããµãã¼ããã */
+#define TOPPERS_TARGET_SUPPORT_PRB_INT		/* prb_intããµãã¼ããã */
+
+/*
+ *  ã«ã¼ãã«ç®¡çã®å²è¾¼ã¿åªå
+åº¦ã®ç¯å²
+ *
+ *  TMIN_INTPRIã®å®ç¾©ãå¤æ´ãããã¨ã§ï¼ã©ã®ã¬ãã«ãããé«ãå²è¾¼ã¿åªå
+åº¦
+ *  ãæã¤ãã®ãã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿ã¨ããããå¤æ´ã§ããï¼
+ *
+ *  TMIN_INTPRIã«è¨­å®ã§ããå¤ã¯ï¼-15ï½-1ã®ç¯å²ã§ããï¼ä¾ãã°TMIN_INTPRI
+ *  ã-14ã«è¨­å®ããã¨ï¼NMIã«å ãã¦ã¬ãã«7ã®å²è¾¼ã¿ãã«ã¼ãã«ç®¡çå¤ã¨ãªãï¼
+ *  TMIN_INTPRIã-15ã«è¨­å®ããã¨ï¼NMIä»¥å¤ã«ã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿ã
+ *  è¨­ããªããã¨ã«ãªãï¼
+ */
+#ifndef TMIN_INTPRI
+#define TMIN_INTPRI		( -15 )		/* å²è¾¼ã¿åªå
+åº¦ã®æå°å¤ï¼æé«å¤ï¼*/
+#endif /* TMIN_INTPRI */
+#define TMAX_INTPRI		( -1 )		/* å²è¾¼ã¿åªå
+åº¦ã®æå¤§å¤ï¼æä½å¤ï¼ */
+
+
+/*
+ *  å²è¾¼ã¿å±æ§ã®å®ç¾©
+ */
+#define	TA_POSEDGE		TA_EDGE			/* ãã¸ãã£ãã¨ãã¸ããªã¬ */
+#define	TA_NEGEDGE		UINT_C( 0x04 )	/* ãã¬ãã£ãã¨ãã¸ããªã¬ */
+#define	TA_BOTHEDGE		UINT_C( 0x08 )	/* ä¸¡ã¨ãã¸ããªã¬ */
+
+#define	TA_LOWLEVEL		UINT_C( 0x10 )	/* Lã¬ãã« */
+
+
+/*
+ *  ããã©ã«ãã®å²è¾¼ã¿/ä¾å¤ãã³ãã©ã®æç¡
+ */
+/*#define	OMIT_DEFAULT_INT_HANDLER*/
+/*#define	OMIT_DEFAULT_EXC_HANDLER*/
+
+
+#endif /* TOPPERS_PRC_KERNEL_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.trb
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.trb	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel.trb	(revision 317)
@@ -0,0 +1,367 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: core_kernel.trb 662 2016-02-27 02:33:51Z ertl-hiro $
+# 
+
+#
+#		ãã¹2ã®çæã¹ã¯ãªããã®ã³ã¢ä¾å­é¨ï¼RXç¨ï¼
+#
+
+# 
+#  å²è¾¼ã¿çªå·ã¨å²è¾¼ã¿ãã³ãã©çªå·ã®å®ç¾©
+# 
+#  RX630ã§ã¯å²è¾¼ã¿çªå·ã¨å²è¾¼ã¿ãã³ãã©çªå·ã1å¯¾1ã§å¯¾å¿ããï¼
+# 
+$INTNO_VALID = [ 16, 21, 23, *(27..59), 62, *(64..79), 90, 91, 92, 93, 98, 102, *(106..112), 114, *(122..167), *(170..203), *(214..253) ]
+$INHNO_VALID = $INTNO_VALID
+
+# 
+#  ä¾å¤çªå·ã®å®ç¾©
+# 
+#  åºå®ãã¯ã¿ãã¼ãã«ã®ãã¯ã¿ãã¼ãã«ã¢ãã¬ã¹ã®å°ããé çªã«ä¾å¤çªå·ãå²æ¯ãï¼
+#  (äºç´é åãå«ã)
+# 
+
+$EXCNO_VALID = [ 20, 23, 25, 30 ]
+
+# 
+#  INTå²è¾¼ã¿ã®çªå·
+# 
+
+$INTNO_INT = [ *(64..79) ]
+
+# 
+#  å²è¾¼ã¿çªå·ï¼å²è¾¼ã¿ãã³ãã©çªå·ï¼ä¾å¤çªå·ã®ç¯å²
+# 
+# (äºç´é åãå«ã)
+# 
+
+$INTNO_RANGE = [ *(0..255) ]
+$INHNO_RANGE = $INTNO_RANGE
+$EXCNO_RANGE = [ *(0..31)  ]
+
+# 
+#  ATT_ISRã§ä½¿ç¨ã§ããå²è¾¼ã¿çªå·ã¨ããã«å¯¾å¿ããå²è¾¼ã¿ãã³ãã©çªå·
+# 
+
+$INTNO_ATTISR_VALID = $INTNO_VALID
+$INHNO_ATTISR_VALID = $INHNO_VALID
+
+
+# 
+#  DEF_INTï¼DEF_EXCã§ä½¿ç¨ã§ããå²è¾¼ã¿ãã³ãã©çªå·ï¼CPUä¾å¤ãã³ãã©çªå·
+# 
+
+$INHNO_DEFINH_VALID = $INHNO_VALID
+$EXCNO_DEFEXC_VALID = $EXCNO_VALID
+
+
+# 
+#  CFG_INTã§ä½¿ç¨ã§ããå²è¾¼ã¿çªå·ã¨å²è¾¼ã¿åªå
+åº¦
+# 
+
+$INTNO_CFGINT_VALID = $INHNO_VALID
+$INTPRI_CFGINT_VALID = [ *(-7..-1) ]
+
+
+# 
+#  ã¿ã¼ã²ããéä¾å­é¨ã«å«ã¾ããæ¨æºã®å²è¾¼ã¿ç®¡çæ©è½/ä¾å¤ç®¡çæ©è½ã®åæåå¦çãä½¿ç¨ãã
+# 
+
+$OMIT_INITIALIZE_INTERRUPT = false
+$OMIT_INITIALIZE_EXCEPTION = false
+
+
+# 
+#  ã¹ã¿ãã¯ãµã¤ãºã®ãã§ãã¯æ¹æ³æå®
+# 
+
+$CHECK_STKSZ_ALIGN = 4
+
+
+# 
+#  ã¿ã¹ã¯ã¹ã¿ãã¯ãµã¤ãºã®æå°å¤
+# 
+#  ã¿ã¹ã¯èµ·åæã«4byte,
+#  å²è¾¼ã¿å
+¥å£å¦çã«ã¦48byte, CPUä¾å¤å
+¥å£å¦çã«ã¦84byte,
+#  ã§ãããã, æå°å¤ã¯88byteã¨ãã.
+# 
+
+$TARGET_MIN_STKSZ = 88
+
+# 
+#  å®æ°å®ç¾©
+# 
+
+$TA_POSEDGE = $TA_EDGE
+
+#
+#  ã¿ã¼ã²ããå®ç¾©ã®å²è¾¼ã¿è¦æ±ã©ã¤ã³å±æ§
+#
+$TARGET_INTATR = $TA_POSEDGE|$TA_NEGEDGE|$TA_BOTHEDGE|$TA_LOWLEVEL
+
+# 
+# ã¿ã¼ã²ããä¾å­ã®å²è¾¼ã¿ãã³ãã©å±æ§ã®å®ç¾©
+# 
+
+$TARGET_INHATR = $TA_NONKERNEL
+
+
+# 
+# ã«ã¼ãã«ç®¡çå¤å²è¾¼ã¿ãã³ãã©ã¯åºå®ãããªããã,
+# INTNO_FIX_KERNEL
+# INHNO_FIX_KERNEL
+# INHNO_FIX_NONKERNEL
+# INHNO_FIX_NONKERNEL
+# ãå®ç¾©ããªã.
+# 
+
+$USE_INHINIB_TABLE = true
+$USE_INTINIB_TABLE = true
+
+#
+#  æ¨æºãã³ãã¬ã¼ããã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+#
+IncludeTrb("kernel/kernel.trb")
+
+#
+#  å²è¾¼ã¿çªå·ããå²è¾¼ã¿åªå
+åº¦åã³å±æ§ãåãåºããã¼ãã«
+#
+$kernelCfgC.comment_header("Interrupt Level and Attribute Table")
+
+$kernelCfgC.add("const CFG_INT_INFO _kernel_cfg_int_table[#{$INTNO_RANGE.length}] = {")
+$INTNO_RANGE.each do |intnoVal|
+  if $cfgData[:CFG_INT].has_key?(intnoVal)
+    $kernelCfgC.append("\t{ #{-$cfgData[:CFG_INT][intnoVal][:intpri].val}, #{$cfgData[:CFG_INT][intnoVal][:intatr]} }")
+  else
+    $kernelCfgC.append("\t{  0, 0xFFFFFFFF }")
+  end
+  $kernelCfgC.append(",") if intnoVal < ($INTNO_RANGE.length - 1)
+  $kernelCfgC.add("\t/* #{sprintf("%02u", intnoVal)} */ ")
+end
+$kernelCfgC.add2("};")
+
+$kernelCfgAsm = GenFile.new("kernel_cfg_asm.S")
+
+#
+#  å²è¾¼ã¿ãã¯ã¿åã³å²è¾¼ã¿ãã³ãã©å®ç¾©
+#
+$kernelCfgAsm.add(<<EOS)
+;
+;  RX630ã¢ã¼ã­ãã¯ãã£ä¾å­åºåãã¡ã¤ã«
+;
+;  å²è¾¼ã¿ãã¯ã¿åã³å²è¾¼ã¿ãã³ãã©å®ç¾©
+;
+
+
+	.section P, CODE
+	.global	_kernel_interrupt
+	.global	__kernel_default_int_handler
+	.global	__kernel_default_exc_handler
+EOS
+
+$INHNO_RANGE.each do |inhnoVal|
+  if $cfgData[:DEF_INH].has_key?(inhnoVal)
+    $kernelCfgAsm.add(<<EOS)
+	.global	_#{$cfgData[:DEF_INH][inhnoVal][:inthdr]}
+	.global	__kernel_#{$cfgData[:DEF_INH][inhnoVal][:inthdr]}_#{inhnoVal}_entry
+__kernel_#{$cfgData[:DEF_INH][inhnoVal][:inthdr]}_#{inhnoVal}_entry:
+	pushm	r1-r5
+	mov.l	\##{inhnoVal}, r1
+	mov.l	\#_#{$cfgData[:DEF_INH][inhnoVal][:inthdr]}, r2
+	bra.a	_kernel_interrupt
+EOS
+    $kernelCfgAsm.add
+  end
+end
+
+$kernelCfgAsm.add(<<EOS)
+	.global	__kernel_default_int_handler_entry
+__kernel_default_int_handler_entry:
+	pushm	r1-r5
+	mov.l	\#0FFFFFFFFH, r1
+	mov.l	\#__kernel_default_int_handler, r2
+	bra.a	_kernel_interrupt
+
+	.global	__kernel_break_int_handler_entry
+__kernel_break_int_handler_entry:
+	rts
+EOS
+$kernelCfgAsm.add
+
+$kernelCfgAsm.add(<<EOS)
+	.global	_kernel_exception
+EOS
+
+$EXCNO_VALID.each do |excnoVal|
+  if $cfgData[:DEF_EXC].has_key?(excnoVal)
+    $kernelCfgAsm.add(<<EOS)
+	.global	_#{$cfgData[:DEF_EXC][excnoVal][:exchdr]}
+	.global	__kernel_#{$cfgData[:DEF_EXC][excnoVal][:exchdr]}_#{excnoVal}_entry
+__kernel_#{$cfgData[:DEF_EXC][excnoVal][:exchdr]}_#{excnoVal}_entry:
+	pushm	r1-r5
+	mov.l	\##{excnoVal}, r1
+	mov.l	\#_#{$cfgData[:DEF_EXC][excnoVal][:exchdr]}, r2
+	bra.a	_kernel_exception
+EOS
+    $kernelCfgAsm.add
+  end
+end
+
+$kernelCfgAsm.add(<<EOS)
+	.global	__kernel_default_exc_handler_entry
+__kernel_default_exc_handler_entry:
+	pushm	r1-r5
+	mov.l	\#0FFFFFFFFH, r1
+	mov.l	\#__kernel_default_exc_handler, r2
+	bra.a	_kernel_exception
+EOS
+$kernelCfgAsm.add
+
+$kernelCfgAsm.append(<<EOS)
+;
+;  å¯å¤ãã¯ã¿ãã¼ãã«
+;
+
+	.global	_start
+
+	.global	_vvector_table
+
+
+	.section .rvectors, ROMDATA
+
+_vvector_table:
+EOS
+
+$INHNO_RANGE.each do |inhnoVal|
+  if $cfgData[:DEF_INH].has_key?(inhnoVal)
+    $kernelCfgAsm.append("	.lword	__kernel_#{$cfgData[:DEF_INH][inhnoVal][:inthdr]}_#{inhnoVal}_entry")
+  elsif inhnoVal != 0
+    $kernelCfgAsm.append("	.lword	__kernel_default_int_handler_entry")
+  else
+    $kernelCfgAsm.append("	.lword	__kernel_break_int_handler_entry")
+  end
+  $kernelCfgAsm.add("		; #{sprintf("%02d", inhnoVal)} ")
+end
+
+$kernelCfgAsm.add2
+
+$kernelCfgAsm.append(<<EOS)
+;
+;  åºå®ãã¯ã¿ãã¼ãã«
+;
+
+	.global	_fvector_table
+
+	.section .fvectors, ROMDATA
+
+_fvector_table:
+	 .word	 0FFFFFFFFH 	 ; Endian Select Register (little)
+	 .space	 004H
+	 .word	 0FFFFFFFFH 	 ; OFS1
+	 .word	 0FFFFFFFFH 	 ; OFS0
+	 .space	 010H
+	 .word	 0FFFFFFFFH 	 ; å¶å¾¡ã³ã¼ã, IDã³ã¼ã1 - 3
+	 .word	 0FFFFFFFFH 	 ; IDã³ã¼ã4 - 7
+	 .word	 0FFFFFFFFH 	 ; IDã³ã¼ã8 - 11
+	 .word	 0FFFFFFFFH 	 ; IDã³ã¼ã12 - 15
+EOS
+(12..30).each do |excnoVal|
+  if $cfgData[:DEF_EXC].has_key?(excnoVal)
+    $kernelCfgAsm.append("	.word	 __kernel_#{$cfgData[:DEF_EXC][excnoVal][:exchdr]}_#{excnoVal}_entry")
+  elsif $EXCNO_VALID.include?(excnoVal)
+    $kernelCfgAsm.append("	.word	 __kernel_default_exc_handler_entry")
+  else
+    $kernelCfgAsm.append("	.word	 0")
+  end
+  $kernelCfgAsm.add("		; #{excnoVal} ")
+end
+
+$kernelCfgAsm.add("	.word	 _start		; 31:Reset")
+$kernelCfgAsm.add2(".end")
+
+#
+#  å²è¾¼ã¿è¦æ±ã©ã¤ã³å±æ§ã«é¢ããã¿ã¼ã²ããä¾å­ã®ã¨ã©ã¼ãã§ãã¯
+#
+$cfgData[:CFG_INT].each do |key, params|
+  # IRQå²è¾¼ã¿çªå·ãã©ããããã§ãã¯
+  if $INTNO_INT.include?(key)
+    # TA_POSEDGEã¨TA_NEGEDGEãåæã«è¨­å®ããã¦ããå ´å
+    if (params[:intatr].val & $TA_POSEDGE|$TA_NEGEDGE) == $TA_POSEDGE|$TA_NEGEDGE
+      error_illegal_sym("E_RSATR", params, :intatr, :intno)
+    end
+    # TA_POSEDGEã¨TA_BOTHEDGEãåæã«è¨­å®ããã¦ããå ´å
+    if (params[:intatr].val & $TA_POSEDGE|$TA_BOTHEDGE) == $TA_POSEDGE|$TA_BOTHEDGE
+      error_illegal_sym("E_RSATR", params, :intatr, :intno)
+    end
+    # TA_NEGEDGEã¨TA_BOTHEDGEãåæã«è¨­å®ããã¦ããå ´å
+    if (params[:intatr].val & $TA_NEGEDGE|$TA_BOTHEDGE) == $TA_NEGEDGE|$TA_BOTHEDGE
+      error_illegal_sym("E_RSATR", params, :intatr, :intno)
+    end
+    # TA_POSEDGEã¨TA_NEGEDGEã¨TA_BOTHEDGEãåæã«è¨­å®ããã¦ããå ´å
+    if (params[:intatr].val & $TA_POSEDGE|$TA_NEGEDGE|$TA_BOTHEDGE) == $TA_POSEDGE|$TA_NEGEDGE|$TA_BOTHEDGE
+      error_illegal_sym("E_RSATR", params, :intatr, :intno)
+    end
+  else
+    # IRQå²è¾¼ã¿ä»¥å¤ã®å²è¾¼ã¿ã«å¯¾ãã¦å²è¾¼ã¿å±æ§ãæå®ããã¦ããå ´å
+    if (params[:intatr].val & (~($TA_ENAINT|$TA_EDGE))) != 0
+      error_illegal_sym("E_RSATR", params, :intatr, :intno)
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.c
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.c	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.c	(revision 317)
@@ -0,0 +1,260 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ */
+
+#include "kernel_impl.h"
+#include "sil.h"
+
+
+/*
+ *  å²è¾¼ã¿çºçåæ°ãä¿å­ããå¤æ°
+ */
+uint16_t	intnest;
+
+/*
+ *  CPUã­ãã¯ãã©ã°å®ç¾ã®ããã®å¤æ°
+ */
+#if TIPM_LOCK != -15
+bool_t		lock_flag;		/* CPUã­ãã¯ãã©ã°ã®å¤ãä¿æããå¤æ° */
+uint32_t	saved_ipl;		/* å²è¾¼ã¿åªå
+åº¦ã¬ãã«ãä¿å­ããå¤æ° */
+#endif	/* TIPM_LOCK != -15	*/
+
+
+/*
+ *  ãã­ã»ããµä¾å­ã®åæå
+ */
+void
+prc_initialize( void )
+{
+	/*
+	 *  å²è¾¼ã¿çºçåæ°ã®åæå
+	 *
+	 *  ã¹ã¿ã¼ãã¢ããã¯å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ & éã¿ã¹ã¯ã³ã³ãã­ã¹ã
+	 *  ã«ã¦åä½ãããã, éã¿ã¹ã¯ã³ã³ãã­ã¹ãã«å½è£
+ãã.
+	 */
+	intnest = 1U;
+
+#if TIPM_LOCK != -15
+	/*
+	 *  CPUã­ãã¯ãã©ã°å®ç¾ã®ããã®å¤æ°ã®åæå
+	 */
+	lock_flag = true;
+	saved_ipl = IPL_ENAALL;
+#endif	/* TIPM_LOCK != -15	*/
+}
+
+
+/*
+ *  ãã­ã»ããµä¾å­ã®çµäºå¦ç
+ */
+void
+prc_terminate( void )
+{
+	/*
+	 *  ç¹ã«å¿
+è¦ãªå¦çã¯ãªã
+	 */
+}
+
+
+/*
+ *  CPUä¾å¤ã®çºçç¶æ³ã®ã­ã°åºå
+ *
+ *  CPUä¾å¤ãã³ãã©ã®ä¸­ããï¼CPUä¾å¤æ
+å ±ãã¤ã³ã¿ï¼p_excinfï¼ãå¼æ°ã¨ã
+ *  ã¦å¼ã³åºããã¨ã§ï¼CPUä¾å¤ã®çºçç¶æ³ãã·ã¹ãã ã­ã°ã«åºåããï¼
+ */
+#ifdef SUPPORT_XLOG_SYS
+void
+xlog_sys( void *p_excinf )
+{
+	syslog(LOG_ERROR , "r1 = %u") , *((uint32_t*)((intptr_t)p_excinf + 14));
+	syslog(LOG_ERROR , "r2 = %u") , *((uint32_t*)((intptr_t)p_excinf + 15));
+	syslog(LOG_ERROR , "r3 = %u") , *((uint32_t*)((intptr_t)p_excinf + 16));
+	syslog(LOG_ERROR , "r4 = %u") , *((uint32_t*)((intptr_t)p_excinf + 17));
+	syslog(LOG_ERROR , "r5 = %u") , *((uint32_t*)((intptr_t)p_excinf + 18));
+	syslog(LOG_ERROR , "r6 = %u") , *((uint32_t*)((intptr_t)p_excinf + 1));
+	syslog(LOG_ERROR , "r7 = %u") , *((uint32_t*)((intptr_t)p_excinf + 2));
+	syslog(LOG_ERROR , "r8 = %u") , *((uint32_t*)((intptr_t)p_excinf + 3));
+	syslog(LOG_ERROR , "r9 = %u") , *((uint32_t*)((intptr_t)p_excinf + 4));
+	syslog(LOG_ERROR , "r10 = %u") , *((uint32_t*)((intptr_t)p_excinf + 5));
+	syslog(LOG_ERROR , "r11 = %u") , *((uint32_t*)((intptr_t)p_excinf + 6));
+	syslog(LOG_ERROR , "r12 = %u") , *((uint32_t*)((intptr_t)p_excinf + 7));
+	syslog(LOG_ERROR , "r13 = %u") , *((uint32_t*)((intptr_t)p_excinf + 8));
+	syslog(LOG_ERROR , "r14 = %u") , *((uint32_t*)((intptr_t)p_excinf + 12));
+	syslog(LOG_ERROR , "r15 = %u") , *((uint32_t*)((intptr_t)p_excinf + 13));
+	syslog(LOG_ERROR , "fpsw = %u") , *((uint32_t*)((intptr_t)p_excinf + 11));
+	syslog(LOG_ERROR , "acclo = %u") , *((uint32_t*)((intptr_t)p_excinf + 10));
+	syslog(LOG_ERROR , "acchi = %u") , *((uint32_t*)((intptr_t)p_excinf + 9));
+	syslog(LOG_ERROR , "pc = %x") , *((uint32_t*)((intptr_t)p_excinf + 19));
+	syslog(LOG_ERROR , "psw = %x") , *((uint32_t*)((intptr_t)p_excinf + 20));
+}
+#endif /* SUPPORT_XLOG_SYS */
+
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³ã®å±æ§ã®è¨­å®
+ *
+ *  ASPã«ã¼ãã«ã§ã®å©ç¨ãæ³å®ãã¦ï¼ãã©ã¡ã¼ã¿ã¨ã©ã¼ã¯ã¢ãµã¼ã·ã§ã³ã§ãã§ã
+ *  ã¯ãã¦ããï¼cfg_intãµã¼ãã¹ã³ã¼ã«ãè¨­ããå ´åã«ã¯ï¼ã¨ã©ã¼ãè¿ããã
+ *  ã«ãã¹ãã§ãããï¼
+ */
+void
+config_int( INTNO intno, ATR intatr, PRI intpri )
+{
+	uint8_t		irq_offset;
+	uint8_t		irq_val;
+
+	assert( VALID_INTNO_CFGINT(intno) );
+
+	assert( ( -15 <= intpri ) && ( intpri <= TMAX_INTPRI ) );
+#if TIPM_LOCK != -15
+	if( intatr == TA_NONKERNEL ){
+		assert( intpri < TMIN_INTPRI );
+ 	}
+	else{
+		assert( TMIN_INTPRI <= intpri ); 
+	}
+#endif
+
+	/*
+	 *  å²è¾¼ã¿ã®ãã¹ã¯
+	 *
+	 *  å²è¾¼ã¿ãåãä»ããã¾ã¾ï¼ã¬ãã«ããªã¬ï¼ã¨ãã¸ããªã¬ã®è¨­å®ãï¼å²
+	 *  è¾¼ã¿åªå
+åº¦ã®è¨­å®ãè¡ãã®ã¯å±éºãªããï¼å²è¾¼ã¿å±æ§ã«ãããããï¼
+	 *  ä¸æ¦ãã¹ã¯ããï¼
+	 */
+	( void )disable_int( intno );
+
+	/*
+	 *  ã¬ãã«ããªã¬/ã¨ãã¸ããªã¬ã®è¨­å®
+	 *
+	 *  IRQã®ã¿ãµãã¼ããã
+	 */
+	if( INTNO_IRQ( intno ) != 0U ){
+		irq_offset = INTNO_IRQ_OFFSET( intno );
+
+		if( ( intatr & TA_POSEDGE ) != 0U ){
+			irq_val = IRQ_POSEDGE;
+		}
+		else if( ( intatr & TA_NEGEDGE ) != 0U ){
+			irq_val = IRQ_NEGEDGE;
+		}
+		else if( ( intatr & TA_BOTHEDGE ) != 0U ){
+			irq_val = IRQ_BOTHEDGE;
+		}
+		else if( ( intatr & TA_LOWLEVEL ) != 0U ){
+			irq_val = IRQ_LOWLEVEL;
+		}
+		else{
+			/*
+			 *  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã«ã¦ãã§ãã¯ãã¦ãããã,
+			 *  ããã¸ãããã¨ã¯ããããªã.
+			 */
+			irq_val = 0U;
+		}
+
+		sil_wrb_mem((uint8_t *)irqcr_reg_addr[irq_offset], irq_val);
+	}
+
+	/*
+	 *  å²è¾¼ã¿ã¬ãã«ã®è¨­å®
+	 *
+	 *  å²è¾¼ã¿çªå·ã«å¯¾å¿ããIPRå¤ãè¨­å®ãã.
+	 */
+	sil_wrb_mem((uint8_t *)ipr_reg_addr[intno], cfg_int_table[intno].intpri);
+
+	/*
+	 *  å²è¾¼ã¿ã®ãã¹ã¯è§£é¤
+ 	 */
+	if( ( intatr & TA_ENAINT ) != 0U ){
+		( void )enable_int( intno );
+	}
+}
+
+
+#ifndef OMIT_DEFAULT_INT_HANDLER
+/*
+ *  æªç»é²ã®å²è¾¼ã¿ãçºçããå ´åã«å¼ã³åºããã
+ */
+void
+default_int_handler( void )
+{
+	syslog(LOG_EMERG, "Unregistered Interrupt occurs.");
+}
+#endif /* OMIT_DEFAULT_INT_HANDLER */
+
+#ifndef OMIT_DEFAULT_EXC_HANDLER
+/*
+ *  æªç»é²ã®ä¾å¤ãçºçããå ´åã«å¼ã³åºããã
+ */
+void
+default_exc_handler( void )
+{
+	syslog(LOG_EMERG, "Unregistered Expevt error occurs.");
+}
+#endif /* OMIT_DEFAULT_EXC_HANDLER */
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_kernel_impl.h	(revision 317)
@@ -0,0 +1,799 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼target_kernel_impl.hï¼ã¾ãã¯ï¼ããããã¤ã³ã¯
+ *  ã«ã¼ãããããã¡ã¤ã«ï¼ã®ã¿ããã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡ã¤ã«ãã
+ *  ç´æ¥ã¤ã³ã¯ã«ã¼ããã¦ã¯ãªããªãï¼
+ */
+
+#ifndef TOPPERS_PRC_CONFIG_H
+#define TOPPERS_PRC_CONFIG_H
+
+/*
+ *  ãã­ã»ããµã®ç¹æ®å½ä»¤ã®ã¤ã³ã©ã¤ã³é¢æ°å®ç¾©
+ */
+#include "prc_insn.h"
+#include "sil.h"
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯åæå¤
+ */
+
+#define TOPPERS_ISTKPT( istk, istksz ) (( STK_T * )(( char * )( istk ) + ( istksz )))
+
+/*
+ *  ã¿ã¹ã¯ã³ã³ãã­ã¹ããã­ãã¯ã®å®ç¾©
+ */
+typedef struct task_context_block {
+	void	*sp;		/* ã¹ã¿ãã¯ãã¤ã³ã¿ */
+	FP		pc;			/* ãã­ã°ã©ã ã«ã¦ã³ã¿ */
+} TSKCTXB;
+
+
+/*
+ *  å²è¾¼ã¿çºçåæ°ãä¿å­ããå¤æ°
+ */
+extern uint16_t intnest;
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã§ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯
+ *
+ *  TIPM_LOCKã¯ï¼CPUã­ãã¯ç¶æ
+ã§ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼ããªãã¡ï¼ã«ã¼ã
+ *  ã«ç®¡çå¤ã®ãã®ãé¤ããã¹ã¦ã®å²è¾¼ã¿è¦æ±ããã¹ã¯ããå¤ã«å®ç¾©ããï¼
+ *
+ *  TMIN_INTPRIå¤æ´ãããã¨ã§ç®¡çå¤å²è¾¼ã¿ã®æç¡ãæ±ºå®ããï¼
+ *  ä¾ãã°TMIN_INTPRIã-14ã«è¨­å®ããã¨ï¼ã¬ãã«15ã®å²è¾¼ã¿ãã«ã¼ãã«ç®¡çå¤ã¨
+ *  ãªãï¼TMIN_INTPRIã-15ã«è¨­å®ããã¨ï¼NMIä»¥å¤ã«ã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿ã
+ *  è¨­ããªããã¨ã«ãªãï¼ãã®å ´åã«ã¯-15ã«è¨­å®ãããã¨ãæ¨å¥¨ããï¼ï¼
+ */
+#ifndef TIPM_LOCK
+#define TIPM_LOCK	TMIN_INTPRI
+#endif /* TIPM_LOCK */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  TOPPERSæ¨æºå²è¾¼ã¿å¦çã¢ãã«ã®å®ç¾
+ */
+/*
+ *  ã³ã³ãã­ã¹ãã®åç
+§
+ *
+ *  RXã§ã¯ï¼å²è¾¼ã¿ã®æ»ãå
+ãã¿ã¹ã¯ãã©ãããå¤æ­ããããã« intnest
+ *  ãä½¿ç¨ãã¦ããï¼ãããç¨ãã¦ã³ã³ãã­ã¹ããå¤æ­ããï¼
+ */
+Inline bool_t
+sense_context( void )
+{
+	/*  ãã¹ãã«ã¦ã³ã¿0ããå¤§ãªãéã¿ã¹ã¯ã³ã³ãã­ã¹ã  */
+	return ( intnest > 0U );
+}
+
+
+/*
+ *  CPUã­ãã¯ãã©ã°å®ç¾ã®ããã®å¤æ°
+ *
+ *  ãããã®å¤æ°ã¯ï¼CPUã­ãã¯ç¶æ
+ã®æã®ã¿æ¸ãæãã¦ãããã®ã¨ããï¼
+ */
+#if TIPM_LOCK != -15
+extern bool_t	lock_flag;		/* CPUã­ãã¯ãã©ã°ã®å¤ãä¿æããå¤æ° */
+extern uint32_t	saved_ipl;		/* å²è¾¼ã¿åªå
+åº¦ã¬ãã«ãä¿å­ããå¤æ° */
+#endif	/* TIPM_LOCK != -15	*/
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®å¤é¨è¡¨ç¾ã¨å
+é¨è¡¨ç¾ã®å¤æ
+ *
+ *  RX630ã§ã¯ï¼ãã­ã»ããµã¹ãã¼ã¿ã¹ã¯ã¼ãã¬ã¸ã¹ã¿ï¼PSWï¼ã®ä¸ãã
+ *  24ï½27ãããç®ã®4ãããã«å²è¾¼ã¿åªå
+åº¦ã¬ãã«ï¼IPLï¼ãç½®ããã¦ããï¼
+ *  ã«ã¼ãã«ç®¡çå¤å²è¾¼ã¿ãå®è£
+ããå ´åã«IPLãä½¿ç¨ããå¶å¾¡ãè¡ãï¼
+ *  ã«ã¼ãã«ã¯å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼-1ããé£ç¶ããè² ã®å¤ï¼ã§ç®¡çããã¦
+ *  ããããIPLã¨ã®å¤æãå¿
+è¦ã¨ãªãï¼
+ */
+#define IPL_TO_IPM( ipl )	(-(( PRI )(( ipl ) >> 24U )))		/* IPLãIPMã«	*/
+#define IPM_TO_IPL( ipm )	((( uint32_t )(-( ipm ))) << 24U )	/* IPMãIPLã«	*/
+
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã§ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®IPL
+ */
+#define IPL_LOCK		( IPM_TO_IPL( TIPM_LOCK ) )
+
+/*
+ *  TIPM_ENAALLï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ï¼ã®IPL
+ */
+#define IPL_ENAALL		( IPM_TO_IPL( TIPM_ENAALL ) )
+
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  å²è¾¼ã¿è¦å æ¯ã®ã¬ãã« & å±æ§å®ç¾©ãã¼ãã«
+ *  (ãã³ãã¬ã¼ããã¡ã¤ã«ã«ããåºå)
+ */
+typedef struct cfg_int_info {
+	PRI		intpri;
+	ATR		intatr;
+} CFG_INT_INFO;
+
+extern const CFG_INT_INFO cfg_int_table[];
+
+
+/*
+ *  å²è¾¼ã¿çªå·ã®ç¯å²ã®å¤å®
+ *
+ *  å²è¾¼ã¿çªå·ãæå¹ãªå¤ãå³å¯ã«ãã§ãã¯ãããã,
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿åºåãã¼ãã«ãåç
+§ãã.
+ */
+#define VALID_INTNO( intno )	\
+ 				( cfg_int_table[( intno )].intpri > 0 )
+#define VALID_INTNO_DISINT( intno )	VALID_INTNO( intno )
+#define VALID_INTNO_CFGINT( intno )	VALID_INTNO( intno )
+
+/* cre_intã§æå¹ãªå²è¾¼ã¿çªå·ã®æå®  */
+#define VALID_INTNO_CREINT          VALID_INTNO_CFGINT((intno))
+
+/* cre_isrã§æå¹ãªå²è¾¼ã¿çªå·ã®æå®  */
+#define	VALID_INTNO_CREISR(intno)	VALID_INTNO_CFGINT((intno))
+
+
+/*
+ *  å²è¾¼ã¿å¶å¾¡ã¬ã¸ã¹ã¿é¢é£ã®å®ç¾©
+ */
+#define	IRQ_POSEDGE			( 0x08U )
+#define	IRQ_NEGEDGE			( 0x04U )
+#define	IRQ_BOTHEDGE		( 0x0CU )
+#define	IRQ_LOWLEVEL		( 0x00U )
+
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã¸ã®ç§»è¡
+ *
+ *  IPMï¼ãã¼ãã¦ã§ã¢ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼ãï¼saved_iipmã«ä¿å­ãï¼ã«ã¼
+ *  ãã«ç®¡çå¤ã®ãã®ãé¤ããã¹ã¦ã®å²è¾¼ã¿è¦æ±ããã¹ã¯ããå¤ï¼TIPM_LOCKï¼
+ *  ã«è¨­å®ããï¼ã¾ãï¼lock_flagãTRUEã«ããï¼
+ *
+ *  IPMãï¼æåããTIPM_LOCKã¨åããããããé«ãå ´åã«ã¯ï¼ããã
+ *  saved_iipmã«ä¿å­ããã®ã¿ã§ï¼TIPM_LOCKã«ã¯è¨­å®ããªãï¼ããã¯ï¼ã¢ãã«
+ *  ä¸ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ãï¼TIPM_LOCKã¨åããããããé«ãã¬ãã«ã«è¨­å®
+ *  ããã¦ããç¶æ
+ã«ãããï¼
+ *
+ *  ãã®é¢æ°ã¯ï¼CPUã­ãã¯ç¶æ
+ï¼lock_flagãTRUEã®ç¶æ
+ï¼ã§å¼ã°ãããã¨ã¯
+ *  ãªããã®ã¨æ³å®ãã¦ããï¼
+ */
+Inline void
+lock_cpu( void )
+{
+#if TIPM_LOCK == -15
+	disint();
+#else	/* TIPM_LOCK == -15	*/
+	uint32_t	ipl;
+
+	/*
+	 *  current_ipl()ã®è¿ãå¤ãç´æ¥saved_iplã«ä¿å­ããï¼ä¸æå¤æ°ipl
+	 *  ãç¨ãã¦ããã®ã¯ï¼current_ipl()ãå¼ãã ç´å¾ã«å²è¾¼ã¿ãçºçãï¼
+	 *  èµ·åãããå²è¾¼ã¿å¦çã§saved_iplãå¤æ´ãããå¯è½æ§ãããããã§
+	 *  ããï¼
+	 */
+	ipl = current_ipl();
+	if( IPL_LOCK > ipl ){
+		set_ipl( IPL_LOCK );
+	}
+
+	saved_ipl = ipl;
+	lock_flag = true;
+#endif	/* TIPM_LOCK == -15	*/
+}
+
+#define lock_cpu_dsp()	lock_cpu()
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®è§£é¤
+ *
+ *  lock_flagãFALSEã«ãï¼IPMï¼ãã¼ãã¦ã§ã¢ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼ãï¼
+ *  saved_iipmã«ä¿å­ããå¤ã«æ»ãï¼
+ *
+ *  ãã®é¢æ°ã¯ï¼CPUã­ãã¯ç¶æ
+ï¼lock_flagãtrueã®ç¶æ
+ï¼ã§ã®ã¿å¼ã°ããã
+ *  ã®ã¨æ³å®ãã¦ããï¼
+ */
+Inline void
+unlock_cpu( void )
+{
+#if TIPM_LOCK == -15
+	enaint();
+#else	/* TIPM_LOCK == -15	*/
+	lock_flag = false;
+	set_ipl( saved_ipl );
+#endif	/* TIPM_LOCK == -15	*/
+}
+
+#define unlock_cpu_dsp()	unlock_cpu()
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+sense_lock( void )
+{
+#if TIPM_LOCK == -15
+	return (( bool_t )(( current_psw() & PSW_I_MASK) == 0 ));
+#else	/* TIPM_LOCK == -15	*/
+	return lock_flag;
+#endif	/* TIPM_LOCK == -15	*/
+}
+
+
+/*
+ *  å²è¾¼ã¿å±æ§ã®è¨­å®ã®ãã§ãã¯
+ */
+Inline bool_t
+check_intno_cfg(INTNO intno)
+{
+	return(cfg_int_table[intno].intpri != 0U);
+}
+
+/*
+ * ï¼ã¢ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®è¨­å®
+ *
+ *  CPUã­ãã¯ãã©ã°ãã¯ãªã¢ããã¦ããæã¯ï¼ãã¼ãã¦ã§ã¢ã®å²è¾¼ã¿åªå
+åº¦ã
+ *  ã¹ã¯ãè¨­å®ããï¼CPUã­ãã¯ãã©ã°ãã»ããããã¦ããæã¯ï¼saved_iipm
+ *  ãè¨­å®ãï¼ããã«ï¼ãã¼ãã¦ã§ã¢ã®å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ãï¼è¨­å®ãããã¨
+ *  ããï¼ã¢ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã¨TIPM_LOCKã®é«ãæ¹ã«è¨­å®ããï¼
+ */
+Inline void
+t_set_ipm( PRI intpri )
+{
+	uint32_t	ipl = IPM_TO_IPL( intpri );
+#if TIPM_LOCK == -15
+	set_ipl(ipl);
+#else	/* TIPM_LOCK == -15	*/
+	if( !lock_flag ){
+		set_ipl(ipl);
+	}
+	else {
+		saved_ipl = ipl;
+		set_ipl(ipl > IPL_LOCK ? ipl : IPL_LOCK);
+    }
+#endif	/* TIPM_LOCK == -15	*/
+}
+
+
+
+/*
+ * ï¼ã¢ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®åç
+§
+ *
+ *  CPUã­ãã¯ãã©ã°ãã¯ãªã¢ããã¦ããæã¯ãã¼ãã¦ã§ã¢ã®å²è¾¼ã¿åªå
+åº¦ã
+ *  ã¹ã¯ãï¼ã»ããããã¦ããæã¯saved_iipmãåç
+§ããï¼
+ */
+Inline PRI
+t_get_ipm( void )
+{
+	uint32_t	ipl;
+#if TIPM_LOCK == -15
+	ipl = current_ipl();
+#else	/* TIPM_LOCK == -15	*/
+	if (!lock_flag) {
+		ipl = current_ipl();
+	}
+	else {
+		ipl = saved_ipl;
+	}
+#endif	/* TIPM_LOCK == -15	*/
+	return IPL_TO_IPM( ipl );
+}
+
+
+
+/*
+ *  å²è¾¼ã¿è¦æ±ç¦æ­¢ãã©ã°ã®ã»ãã
+ *
+ *  å²è¾¼ã¿å±æ§ãè¨­å®ããã¦ããªãå²è¾¼ã¿è¦æ±ã©ã¤ã³ã«å¯¾ãã¦å²è¾¼ã¿è¦æ±ç¦æ­¢
+ *  ãã©ã°ãã»ãããããã¨ããå ´åã«ã¯ï¼FALSEãè¿ãï¼
+ */
+Inline bool_t
+disable_int( INTNO intno )
+{
+	/*
+	 *  ã¬ãã«å®ç¾©ã0ã§ããå ´åã¯CFG_INTããã¦ããªã
+	 */
+	if( cfg_int_table[intno].intpri == 0 ){
+		return ( false );
+	}
+
+	*ier_reg_addr[intno].addr &= ( ~ier_reg_addr[intno].offset );
+
+	return ( true );
+}
+
+
+/*
+ *  å²è¾¼ã¿è¦æ±ç¦æ­¢ãã©ã°ã®ã¯ãªã¢
+ *
+ *  å²è¾¼ã¿å±æ§ãè¨­å®ããã¦ããªãå²è¾¼ã¿è¦æ±ã©ã¤ã³ã«å¯¾ãã¦å²è¾¼ã¿è¦æ±ç¦æ­¢
+ *  ãã©ã°ãã¯ãªã¢ãããã¨ããå ´åã«ã¯ï¼FALSEãè¿ãï¼
+ */
+Inline bool_t
+enable_int( INTNO intno )
+{
+	/*
+	 *  ã¬ãã«å®ç¾©ã0ã§ããå ´åã¯CFG_INTããã¦ããªã
+	 */
+	if( cfg_int_table[intno].intpri == 0 ){
+		return ( false );
+	}
+
+	*ier_reg_addr[intno].addr |= ier_reg_addr[intno].offset;
+
+	return ( true );
+}
+
+
+/*
+ *  å²è¾¼ã¿è¦æ±ãã¯ãªã¢ã§ããç¶æ
+ãï¼
+ */
+Inline bool_t
+check_intno_clear(INTNO intno)
+{
+	return(true);
+}
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ã¯ãªã¢
+ */
+Inline void
+clear_int( INTNO intno )
+{
+	*IR_REG(intno) = 0U;
+}
+
+
+/*
+ *  å²è¾¼ã¿ãè¦æ±ã§ããç¶æ
+ãï¼
+ */
+Inline bool_t
+check_intno_raise(INTNO intno)
+{
+	return(true);
+}
+
+/*
+ * å²è¾¼ã¿ã®è¦æ±
+ * æ³¨æï¼ãããã§ãµãã¼ãããã¦ããªãæä½
+ */
+Inline void
+raise_int( INTNO intno )
+{
+	*IR_REG(intno) = 1U;
+}
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ãã§ãã¯
+ */
+Inline bool_t
+probe_int( INTNO intno )
+{
+	/*
+	 *  å²è¾¼ã¿è¦æ±ã¬ã¸ã¹ã¿ã¯0 or 1ã§ãããªããã,
+	 *  ãã®ã¾ã¾ã®å¤ãè¿ã.
+	 */
+	return ( *IR_REG(intno) );
+}
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³ã®å±æ§ã®è¨­å®
+ */
+extern void	config_int( INTNO intno, ATR intatr, PRI intpri );
+
+/*
+ *  å²è¾¼ã¿ãåãä»ããããã®é
+å»¶å¦ç
+ */
+Inline void
+delay_for_interrupt(void)
+{
+}
+
+/*
+ *  æé«åªå
+é ä½ã¿ã¹ã¯ã¸ã®ãã£ã¹ãããï¼prc_support.a30ï¼
+ *
+ *  dispatchã¯ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãããå¼ã³åºããããµã¼ãã¹ã³ã¼ã«å¦çã
+ *  ãå¼ã³åºãã¹ããã®ã§ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãã»CPUã­ãã¯ç¶æ
+ã»ãã£ã¹ãã
+ *  ãè¨±å¯ç¶æ
+ã»ï¼ã¢ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+ã§å¼ã³åºããª
+ *  ããã°ãªããªãï¼
+ */
+extern void	dispatch( void );
+
+/*
+ *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãããã®ãã£ã¹ãããè¦æ±
+ */
+#define request_dispatch()
+
+/*
+ *  ãã£ã¹ãããã£ã®åä½éå§ï¼prc_support.a30ï¼
+ *
+ *  start_dispatchã¯ï¼ã«ã¼ãã«èµ·åæã«å¼ã³åºãã¹ããã®ã§ï¼ãã¹ã¦ã®å²è¾¼
+ *  ã¿ãç¦æ­¢ããç¶æ
+ï¼å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã¨åç­ã®ç¶æ
+ï¼ã§å¼ã³åºããªããã°
+ *  ãªããªãï¼
+ */
+extern void	start_dispatch( void ) NoReturn;
+
+/*
+ *  ç¾å¨ã®ã³ã³ãã­ã¹ããæ¨ã¦ã¦ãã£ã¹ãããï¼prc_support.a30ï¼
+ *
+ *  exit_and_dispatchã¯ï¼ext_tskããå¼ã³åºãã¹ããã®ã§ï¼ã¿ã¹ã¯ã³ã³ãã­
+ *  ã¹ãã»CPUã­ãã¯ç¶æ
+ã»ãã£ã¹ãããè¨±å¯ç¶æ
+ã»ï¼ã¢ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+
+ *  åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+ã§å¼ã³åºããªããã°ãªããªãï¼
+ */
+#define _kernel_exit_and_dispatch();	\
+	_exit_and_dispatch();		\
+	ercd = E_SYS;
+
+extern void	_exit_and_dispatch( void ) NoReturn;
+
+/*
+ *  ã«ã¼ãã«ã®çµäºå¦çã®å¼åºãï¼prc_support.a30ï¼
+ *
+ *  call_exit_kernelã¯ï¼ã«ã¼ãã«ã®çµäºæã«å¼ã³åºãã¹ããã®ã§ï¼éã¿ã¹ã¯
+ *  ã³ã³ãã­ã¹ãã«åãæãã¦ï¼ã«ã¼ãã«ã®çµäºå¦çï¼exit_kernelï¼ãå¼ã³åº
+ *  ãï¼
+ */
+extern void call_exit_kernel( void ) NoReturn;
+
+/*
+ *  ã¿ã¹ã¯ã³ã³ãã­ã¹ãã®åæå
+ *
+ *  ã¿ã¹ã¯ãä¼æ­¢ç¶æ
+ããå®è¡ã§ããç¶æ
+ã«ç§»è¡ããæã«å¼ã°ããï¼ãã®æç¹
+ *  ã§ã¹ã¿ãã¯é åãä½¿ã£ã¦ã¯ãªããªãï¼
+ *
+ *  activate_contextãï¼ã¤ã³ã©ã¤ã³é¢æ°ã§ã¯ãªããã¯ã­å®ç¾©ã¨ãã¦ããã®ã¯ï¼
+ *  ãã®æç¹ã§ã¯TCBãå®ç¾©ããã¦ããªãããã§ããï¼
+ */
+extern void	start_r( void );
+
+#define activate_context( p_tcb )														\
+{																						\
+	{																					\
+																						\
+		/*  ã¹ã¿ãã¯ãã¤ã³ã¿åæå¤ã®è¨­å®  */											\
+		( p_tcb )->tskctxb.sp = ( void * )((( uint32_t ) ( p_tcb )->p_tinib->stk ) + 	\
+								( p_tcb )->p_tinib->stksz );							\
+		/* èµ·åçªå°ã®è¨­å® */															\
+		( p_tcb )->tskctxb.pc = ( FP ) start_r;											\
+	}																					\
+}
+
+
+/*
+ *  calltexã¯ä½¿ç¨ããªã
+ */
+#define OMIT_CALLTEX
+
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©ã®è¨­å®
+ *
+ *  RX630ã¯ROMã«å²è¾¼ã¿ãã¯ã¿ãé
+ç½®ããããï¼æ¬é¢æ°ã¯ç©ºé¢æ°ã§å®è£
+ããï¼
+ */
+Inline void
+define_inh( INHNO inhno, FP inthdr )
+{
+}
+
+/*
+ *  CPUä¾å¤ãã³ãã©ã®è¨­å®
+ *
+ *  RX630ã¯ROMã«ä¾å¤ãã¯ã¿ãé
+ç½®ããããï¼æ¬é¢æ°ã¯ç©ºé¢æ°ã§å®è£
+ããï¼
+ */
+Inline void
+define_exc( EXCNO excno, FP exchdr )
+{
+}
+
+/*
+ *  å²è¾¼ã¿/ä¾å¤ãã³ãã©ã®å
+¥å£å¦çã®çæãã¯ã­
+ *
+ *  ãã³ãã¬ã¼ããã¡ã¤ã«ã«ããçæããããç©ºãã¯ã­ã¨ããï¼
+ */
+#define HDR_ENTRY(hdr, intexc_num , tobejmp)
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©ã®å
+¥å£å¦çã®çæãã¯ã­
+ */
+#define _INT_ENTRY(inhno, inthdr)				_kernel_##inthdr##_##inhno##_entry
+#define INT_ENTRY(inhno, inthdr)				_INT_ENTRY(inhno , inthdr)
+
+#define _INTHDR_ENTRY(inhno, inhno_num ,inthdr)	\
+		extern void _kernel_##inthdr##_##inhno##_entry(void);
+#define INTHDR_ENTRY(inhno, inhno_num ,inthdr)	_INTHDR_ENTRY(inhno, inhno_num ,inthdr)
+
+
+/*
+ *  CPUä¾å¤ãã³ãã©ã®å
+¥å£å¦çã®çæãã¯ã­
+ */
+#define _EXC_ENTRY(excno , exchdr)					_kernel_##exchdr##_##excno##_entry
+#define EXC_ENTRY(excno , exchdr)					_EXC_ENTRY(excno , exchdr)
+
+#define _EXCHDR_ENTRY(excno , excno_num , exchdr)	\
+		extern void _kernel_##exchdr##_##excno##_entry(void);
+#define EXCHDR_ENTRY(excno , excno_num , exchdr)	_EXCHDR_ENTRY(excno , excno_num , exchdr)
+
+
+/*
+ *  CPUä¾å¤ã®çºçããæã®ã³ã³ãã­ã¹ãã®åç
+§
+ *
+ *  CPUä¾å¤ã®çºçããæã®ã³ã³ãã­ã¹ããï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãã®æã«FALSEï¼
+ *  ããã§ãªãæã«trueãè¿ãï¼
+ */
+Inline bool_t
+exc_sense_context( void *p_excinf )
+{
+	/* 
+	 *  ãã¹ãã«ã¦ã³ã¿ã1ããå¤§ãªãéã¿ã¹ã¯ã³ã³ãã­ã¹ã
+	 */
+	return( intnest > 1U );
+}
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  CPUä¾å¤æ
+å ± p_excinf ãã PSW ã®å¤ãåå¾ããããã®ãªãã»ããå¤
+ *  EXCNO + ACC + FPSW + R1ï½R15 + PC
+ */
+#define EXC_GET_PSW_OFFSET	(4+8+4+60+4)
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  CPUä¾å¤ã®çºçããæã®IPLã®åç
+§
+ */
+Inline uint32_t
+exc_get_ipl(void *p_excinf)
+{
+	return((*((uint32_t *)((uintptr_t)p_excinf+EXC_GET_PSW_OFFSET)))
+			& PSW_IPL_MASK);
+}
+
+Inline bool_t
+exc_sense_i(void *p_excinf)
+{
+	return((*(((uint32_t *)((uintptr_t)p_excinf+EXC_GET_PSW_OFFSET)))
+			 & PSW_I_MASK) != 0u);
+}
+
+
+/*
+ *  CPUä¾å¤ã®çºçããæã®ã³ã³ãã­ã¹ãã¨å²è¾¼ã¿ã®ãã¹ã¯ç¶æ
+ã®åç
+§
+ *
+ *  CPUä¾å¤ã®çºçããæã®ã·ã¹ãã ç¶æ
+ãï¼ã«ã¼ãã«å®è¡ä¸­ã§ãªãï¼ã¿ã¹ã¯ã³
+ *  ã³ãã­ã¹ãã§ããï¼å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã§ãªãï¼CPUã­ãã¯ç¶æ
+ã§ãªãï¼ï¼ã¢
+ *  ãã«ä¸ã®ï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+ã§ããæã«trueï¼ããã§ãªãæ
+ *  ã«FALSEãè¿ãï¼CPUä¾å¤ãã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿å¦çä¸­ã§çºçããå ´å
+ *  ã«ãFALSEãè¿ãï¼ï¼
+ *  
+ *  ã«ã¼ãã«å®è¡ä¸­ã§ãªãâ (TIPM_LOCK== -15) Iãã©ã° == 1
+ *                         (else)           IPL < IPL_LOCK
+ *  ã¿ã¹ã¯ã³ã³ãã­ã¹ãã§ããâintnest == 0
+ *  å
+¨å²è¾¼ã¿ã­ãã¯ã§ãªãâ Iãã©ã° == 1
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ãå
+¨è§£é¤âIPL == 0
+ *  
+ *  
+ */
+Inline bool_t
+exc_sense_intmask(void *p_excinf)
+{
+	return((!exc_sense_context(p_excinf))
+			&& exc_sense_i(p_excinf)
+			&& (exc_get_ipl(p_excinf) == IPL_ENAALL));
+}
+
+/*
+ *  CPUä¾å¤ã®çºçããæã®ã³ã³ãã­ã¹ãã¨å²è¾¼ã¿ï¼CPUã­ãã¯ç¶æ
+ã®åç
+§
+ *
+ *  CPUä¾å¤ã®çºçããæã®ã·ã¹ãã ç¶æ
+ãï¼ã«ã¼ãã«å®è¡ä¸­ã§ãªãï¼ã¿ã¹ã¯ã³
+ *  ã³ãã­ã¹ãã§ããï¼å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã§ãªãï¼CPUã­ãã¯ç¶æ
+ã§ãªãæã«
+ *  trueï¼ããã§ãªãæã«falseãè¿ãï¼CPUä¾å¤ãã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿å¦
+ *  çä¸­ã§çºçããå ´åã«ãfalseãè¿ãï¼ï¼
+ *  
+ *  ã«ã¼ãã«å®è¡ä¸­ã§ãªãâ (TIPM_LOCK== -15) Iãã©ã° == 1
+ *                         (else)           IPL < TIPM_LOCK
+ *  ã¿ã¹ã¯ã³ã³ãã­ã¹ãã§ããâintnest < 1 
+ *  å
+¨å²è¾¼ã¿ã­ãã¯ã§ãªãâ Iãã©ã° == 1
+ *  CPUã­ãã¯ç¶æ
+ã§ãªãâ(TIPM_LOCK== -15) Iãã©ã° == 1
+ *                         (else)           IPL < TIPM_LOCK
+ */
+Inline bool_t
+exc_sense_unlock(void *p_excinf)
+{
+#if TIPM_LOCK == -15
+	return((!exc_sense_context(p_excinf))
+			&& exc_sense_i(p_excinf));
+#else
+	return((!exc_sense_context(p_excinf))
+			&& exc_sense_i(p_excinf)
+			&& exc_get_ipl(p_excinf) < IPL_LOCK);
+#endif
+}
+
+
+/*
+ *  ãã­ã»ããµä¾å­ã®åæå
+ */
+extern void	prc_initialize( void );
+
+/*
+ *  ãã­ã»ããµä¾å­ã®çµäºæå¦ç
+ */
+extern void	prc_terminate( void );
+
+
+#ifndef OMIT_DEFAULT_INT_HANDLER
+/*
+ *  æªç»é²ã®å²è¾¼ã¿ãçºçããå ´åã«å¼ã³åºããã
+ */
+void default_int_handler( void );
+#endif /* OMIT_DEFAULT_INT_HANDLER */
+
+#ifndef OMIT_DEFAULT_EXC_HANDLER
+/*
+ *  æªç»é²ã®ä¾å¤ãçºçããå ´åã«å¼ã³åºããã
+ */
+void default_exc_handler( void );
+#endif /* OMIT_DEFAULT_EXC_HANDLER */
+
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#endif /* TOPPERS_PRC_CONFIG_H */
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_offset.trb
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_offset.trb	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_offset.trb	(revision 317)
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+#
+#		ãªãã»ãããã¡ã¤ã«çæç¨Rubyãã³ãã¬ã¼ãï¼ARMç¨ï¼
+#
+#  $Id: core_offset.trb 572 2016-02-01 14:40:09Z ertl-hiro $
+#
+
+#
+#  ã¿ã¼ã²ããéä¾å­é¨ã®ã¤ã³ã¯ã«ã¼ã
+#
+IncludeTrb("kernel/genoffset.trb")
+
+#
+#  ãã£ã¼ã«ãã®ãªãã»ããã®å®ç¾©ã®çæ
+#
+GenerateDefine("TCB_p_tinib", $offsetof_TCB_p_tinib)
+GenerateDefine("TCB_sp", $offsetof_TCB_sp)
+GenerateDefine("TCB_pc", $offsetof_TCB_pc)
+GenerateDefine("TINIB_exinf", $offsetof_TINIB_exinf)
+GenerateDefine("TINIB_task", $offsetof_TINIB_task)
+GenerateDefine("TINIB_stksz", $offsetof_TINIB_stksz)
+GenerateDefine("TINIB_stk", $offsetof_TINIB_stk)
+GenerateDefineBit("TCB_enatex", $sizeof_TCB, "B")
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.def
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.def	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.def	(revision 317)
@@ -0,0 +1,27 @@
+# prc_kernel_impl.c
+intnest
+lock_flag
+saved_ipl
+prc_initialize
+prc_terminate
+config_int
+default_int_handler
+default_exc_handler
+
+# prc_support.src
+dispatch
+start_dispatch
+exit_and_dispatch
+call_exit_kernel
+start_r
+interrupt
+exception
+
+# rx610_kernel_impl.c
+ipr_reg_addr
+ier_reg_addr
+ir_reg_addr
+irqcr_reg_addr
+
+# kernel_cfg.c
+cfg_int_table
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_rename.h	(revision 317)
@@ -0,0 +1,84 @@
+/* This file is generated from prc_rename.def by genrename. */
+
+#ifndef TOPPERS_PRC_RENAME_H
+#define TOPPERS_PRC_RENAME_H
+
+/*
+ *  prc_kernel_impl.c
+ */
+#define intnest						_kernel_intnest
+#define lock_flag					_kernel_lock_flag
+#define saved_ipl					_kernel_saved_ipl
+#define prc_initialize				_kernel_prc_initialize
+#define prc_terminate				_kernel_prc_terminate
+#define config_int					_kernel_config_int
+#define default_int_handler			_kernel_default_int_handler
+#define default_exc_handler			_kernel_default_exc_handler
+
+/*
+ *  prc_support.src
+ */
+#define dispatch					_kernel_dispatch
+#define start_dispatch				_kernel_start_dispatch
+#define exit_and_dispatch			_kernel_exit_and_dispatch
+#define call_exit_kernel			_kernel_call_exit_kernel
+#define start_r						_kernel_start_r
+#define interrupt					_kernel_interrupt
+#define exception					_kernel_exception
+
+/*
+ *  rx630_kernel_impl.c
+ */
+#define ipr_reg_addr				_kernel_ipr_reg_addr
+#define ier_reg_addr				_kernel_ier_reg_addr
+#define ir_reg_addr					_kernel_ir_reg_addr
+#define irqcr_reg_addr				_kernel_irqcr_reg_addr
+
+/*
+ *  kernel_cfg.c
+ */
+#define cfg_int_table				_kernel_cfg_int_table
+
+#ifdef TOPPERS_LABEL_ASM
+
+/*
+ *  prc_kernel_impl.c
+ */
+#define _intnest					__kernel_intnest
+#define _lock_flag					__kernel_lock_flag
+#define _saved_ipl					__kernel_saved_ipl
+#define _prc_initialize				__kernel_prc_initialize
+#define _prc_terminate				__kernel_prc_terminate
+#define _config_int					__kernel_config_int
+#define _default_int_handler		__kernel_default_int_handler
+#define _default_exc_handler		__kernel_default_exc_handler
+
+/*
+ *  prc_support.src
+ */
+#define _dispatch					__kernel_dispatch
+#define _start_dispatch				__kernel_start_dispatch
+#define _exit_and_dispatch			__kernel_exit_and_dispatch
+#define _call_exit_kernel			__kernel_call_exit_kernel
+#define _start_r					__kernel_start_r
+#define _interrupt					__kernel_interrupt
+#define _exception					__kernel_exception
+
+
+/*
+ *  rx630_kernel_impl.c
+ */
+#define _ipr_reg_addr				__kernel_ipr_reg_addr
+#define _ier_reg_addr				__kernel_ier_reg_addr
+#define _ir_reg_addr				__kernel_ir_reg_addr
+#define _irqcr_reg_addr				__kernel_irqcr_reg_addr
+
+/*
+ *  kernel_cfg.c
+ */
+#define _cfg_int_table				__kernel_cfg_int_table
+
+#endif /* TOPPERS_LABEL_ASM */
+
+
+#endif /* TOPPERS_PRC_RENAME_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sil.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sil.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sil.h	(revision 317)
@@ -0,0 +1,314 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		sil.hã®ãã­ã»ããµä¾å­é¨ï¼RX630ç¨ï¼
+ */
+
+#ifndef TOPPERS_PRC_SIL_H
+#define TOPPERS_PRC_SIL_H
+
+
+#ifndef TOPPERS_MACRO_ONLY
+#include "prc_insn.h"
+
+
+/*
+ *  å
+¨å²è¾¼ã¿ç¦æ­¢
+ */
+Inline uint32_t
+TOPPERS_disint( void )
+{
+	volatile uint32_t	TOPPERS_psw;
+
+	TOPPERS_psw = current_psw();
+	disint();
+
+	return( TOPPERS_psw );
+}
+
+
+/*
+ *  å
+¨å²è¾¼ã¿è¨±å¯
+ */
+Inline void
+TOPPERS_enaint( uint32_t TOPPERS_psw )
+{
+	if( TOPPERS_psw & PSW_I_MASK ){
+		enaint();
+	}
+}
+
+
+/*
+ *  å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã®å¶å¾¡
+ */
+#define SIL_PRE_LOC		uint32_t TOPPERS_i_psw;
+#define SIL_LOC_INT()	( ( void )( TOPPERS_i_psw = TOPPERS_disint() ) )
+#define SIL_UNL_INT()	( TOPPERS_enaint( TOPPERS_i_psw ) )
+
+
+/*
+ *  ã¨ã³ãã£ã¢ã³ã®åè»¢
+ *
+ *  æ¬éçºç°å¢ã§ã¯ã¨ã³ãã£ã¢ã³å¤æå½ä»¤ãå­å¨ãããã,
+ *  ã¢ã¼ã­ãã¯ãã£ä¾å­é¨ã«ã¦ãã¯ã­ãä¸æ¸ããã.
+ */
+#define TOPPERS_SIL_REV_ENDIAN_UINT16( data )	\
+ 								rev_endian_uint16( data )
+#define TOPPERS_SIL_REV_ENDIAN_UINT32( data )	\
+ 								rev_endian_uint32( data )
+
+
+/*
+ *  å¾®å°æéå¾
+ã¡
+ */
+extern void sil_dly_nse( ulong_t dlytim ) throw();
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+
+/*
+ *  ãã­ã»ããµã®ã¨ã³ãã£ã¢ã³
+ */
+#define SIL_ENDIAN_LITTLE			/* ãªãã«ã¨ã³ãã£ã¢ã³ */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã¡ã¢ãªç©ºéã¢ã¯ã»ã¹é¢æ°
+ */
+#define TOPPERS_OMIT_SIL_ACCESS
+
+/*
+ *  8ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+#ifdef UINT8_MAX
+
+Inline uint8_t
+sil_reb_mem(const volatile uint8_t *mem)
+{
+	uint8_t	data;
+
+	data = *((const volatile uint8_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrb_mem(volatile uint8_t *mem, uint8_t data)
+{
+	*((volatile uint8_t *) mem) = data;
+}
+
+#endif /* UINT8_MAX */
+
+/*
+ *  16ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+
+Inline uint16_t
+sil_reh_mem(const volatile uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrh_mem(volatile uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = data;
+}
+
+#ifdef SIL_ENDIAN_BIG			/* ããã°ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_reh_bem(mem)		sil_reh_mem(mem)
+#define	sil_wrh_bem(mem, data)	sil_wrh_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REH_LEM
+
+Inline uint16_t
+sil_reh_lem(const volatile uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REH_LEM */
+#ifndef TOPPERS_OMIT_SIL_WRH_LEM
+
+Inline void
+sil_wrh_lem(volatile uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRH_LEM */
+#else /* SIL_ENDIAN_BIG */
+#ifdef SIL_ENDIAN_LITTLE		/* ãªãã«ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_reh_lem(mem)		sil_reh_mem(mem)
+#define	sil_wrh_lem(mem, data)	sil_wrh_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REH_BEM
+
+Inline uint16_t
+sil_reh_bem(const volatile uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REH_BEM */
+#ifndef TOPPERS_OMIT_SIL_WRH_BEM
+
+Inline void
+sil_wrh_bem(volatile uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRH_BEM */
+#else /* SIL_ENDIAN_LITTLE */
+
+#error Neither SIL_ENDIAN_BIG nor SIL_ENDIAN_LITTLE is defined.
+
+#endif /* SIL_ENDIAN_LITTLE */
+#endif /* SIL_ENDIAN_BIG */
+
+/*
+ *  32ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+
+Inline uint32_t
+sil_rew_mem(const volatile uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrw_mem(volatile uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = data;
+}
+
+#ifdef SIL_ENDIAN_BIG			/* ããã°ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_rew_bem(mem)		sil_rew_mem(mem)
+#define	sil_wrw_bem(mem, data)	sil_wrw_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REW_LEM
+
+Inline uint32_t
+sil_rew_lem(const volatile uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REW_LEM */
+#ifndef TOPPERS_OMIT_SIL_WRW_LEM
+
+Inline void
+sil_wrw_lem(volatile uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRW_LEM */
+#else /* SIL_ENDIAN_BIG */		/* ãªãã«ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_rew_lem(mem)		sil_rew_mem(mem)
+#define	sil_wrw_lem(mem, data)	sil_wrw_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REW_BEM
+
+Inline uint32_t
+sil_rew_bem(const volatile uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REW_BEM */
+#ifndef TOPPERS_OMIT_SIL_WRW_BEM
+
+Inline void
+sil_wrw_bem(volatile uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRW_BEM */
+#endif /* SIL_ENDIAN_BIG */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#endif /* TOPPERS_PRC_SIL_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_stddef.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_stddef.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_stddef.h	(revision 317)
@@ -0,0 +1,70 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		t_stddef.hã®ãã­ã»ããµä¾å­é¨ï¼RX630ç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼target_stddef.hï¼ã¾ãã¯ï¼ããããã¤ã³ã¯
+ *  ã«ã¼ãããããã¡ã¤ã«ï¼ã®ã¿ããã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡ã¤ã«ãã
+ *  ç´æ¥ã¤ã³ã¯ã«ã¼ããã¦ã¯ãªããªãï¼
+ */
+
+#ifndef TOPPERS_PRC_STDDEF_H
+#define TOPPERS_PRC_STDDEF_H
+
+/*
+ *  ã¿ã¼ã²ãããè­å¥ããããã®ãã¯ã­ã®å®ç¾©
+ */
+#define TOPPERS_RX630				/* ãã­ã»ããµç¥ç§° */
+
+#endif /* TOPPERS_PRC_STDDEF_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_support.S
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_support.S	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_support.S	(revision 317)
@@ -0,0 +1,1035 @@
+; 
+;   TOPPERS/ASP Kernel
+;       Toyohashi Open Platform for Embedded Real-Time Systems/
+;       Advanced Standard Profile Kernel
+;  
+;   Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+;                               Toyohashi Univ. of Technology, JAPAN
+;   Copyright (C) 2007      by Embedded and Real-Time Systems Laboratory
+;               Graduate School of Information Science, Nagoya Univ., JAPAN
+;   Copyright (C) 2010 by Witz Corporation, JAPAN
+;   Copyright (C) 2013      by Mitsuhiro Matsuura
+;   Copyright (C) 2017      by Cores Co., Ltd. Japan
+;  
+;   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+;   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+;   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+;   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+;       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+;       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+;   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+;       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+;       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+;       ã¨ï¼
+;     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+;         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+;         å ±åãããã¨ï¼
+;   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+;       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+;       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+;       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+;       å
+è²¬ãããã¨ï¼
+;  
+;   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+;   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+;   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+;   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+;   ã®è²¬ä»»ãè² ããªãï¼
+;  
+;  @(#) $Id$
+;
+
+;
+;  ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã« ã¢ã»ã³ããªè¨èªé¨ï¼RX630ç¨ï¼
+;
+#define TOPPERS_MACRO_ONLY
+#define UINT_C(val)			(val)		/* uint_tåã®å®æ°ãä½ããã¯ã­ */
+#define ULONG_C(val)		(val)		/* ulong_tåã®å®æ°ãä½ããã¯ã­ */
+#define CAST(type, val)		(val)		/* åã­ã£ã¹ããè¡ããã¯ã­ */
+#include "kernel_impl.h"
+
+;
+;  ãã£ã¹ãããã£ããã³å²è¾¼ã¿(CPUä¾å¤)åºå
+¥ãå£ã®ã«ã¼ã«:
+;	åä½ã¢ã¼ããä»¥ä¸ã®ããã«å®ç¾©ãã.
+;		ãã£ã¹ãããã£ã¢ã¼ã:
+;			CPUã­ãã¯ç¶æ
+, å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+,
+;			ã¿ã¹ã¯ã³ã³ãã­ã¹ã(intnest = 0), ã¿ã¹ã¯ã¹ã¿ãã¯
+;		å²è¾¼ã¿(CPUä¾å¤)å¦çã¢ã¼ã
+;			å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+(PSWã¬ã¸ã¹ã¿Iããã = 0),
+;			å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªãç¶æ
+(IPL != 0)
+;			å²è¾¼ã¿ã³ã³ãã­ã¹ã(intnest != 0), å²è¾¼ã¿ã¹ã¿ãã¯
+;
+;	ã«ã¼ãã«ç®¡çå¤å²è¾¼ã¿ã®ãµãã¼ãæç¡ã¨, CPUã­ãã¯ç¶æ
+, å²è¾¼ã¿åªå
+åº¦
+;	ãã¹ã¯å
+¨è§£é¤ç¶æ
+ã®é¢ä¿ã¯ä»¥ä¸ã®éãã§ãã.
+;		ã«ã¼ãã«ç®¡çå¤å²è¾¼ã¿æªãµãã¼ãæ:
+;			CPUã­ãã¯ç¶æ
+(PSWã¬ã¸ã¹ã¿Iããã = 0)
+;			å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+(IPL = 0)
+;		ã«ã¼ãã«ç®¡çå¤å²è¾¼ã¿ãµãã¼ãæ:
+;			CPUã­ãã¯ç¶æ
+
+;				(PSWã¬ã¸ã¹ã¿Iããã = 0, IPL = IPL_LOCK, lock_flag = true)
+;			å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+(saved_ipl = 0)
+;
+;	åæ§é ä½ãã¤ã³ã¿ãä»¥ä¸ã®ããã«åã¬ã¸ã¹ã¿ã«ã¢ãµã¤ã³ãã.
+;		r15 = p_runtsk	ãã ããã£ã¹ãããã£ã®ååºå£ã§ã¯ç¡å¹
+;		r14 = *p_runtsk	dispatcher ã®ä¸­ã§ã¯ p_runtsk ç¢ºå®æã«ååå¾ãã
+;	åå
+¥ãå£ããæåã«å¤æ°ã¢ã¯ã»ã¹ããã¨ãã«ä¸è¨ã¬ã¸ã¹ã¿ã«ä¿å­ãã.
+;
+;	æ§é ä½ã¢ã©ã¤ã¡ã³ãã¸ã®å¯¾å¿
+;		æ§é ä½ã¢ã©ã¤ã¡ã³ãã4Byte(ã¢ã³ããã¯)ã®å ´å:
+;			ä¸è¬çãªã¬ã¸ã¹ã¿ç¸å¯¾ã¢ãã¬ãã·ã³ã°ãå¯è½
+;				ä¾:	mov.l	#__kernel_p_runtsk, r15
+;					mov.l  	r0, TCB_sp[r15]
+;		æ§é ä½ã¢ã©ã¤ã¡ã³ãã4Byteã§ã¯ãªã(ããã¯)ã®å ´å:
+;			mov.lã®ããã«ã­ã³ã°ãµã¤ãºæå®ã®å ´åãç¸å¯¾å¤ã¯4ã®åæ°ã®ã¿æå¹
+;			ãã®ãã, ä¸åº¦å¯¾è±¡ã¢ãã¬ã¹ãæ±ãã¦ããã¢ã¯ã»ã¹ããå¿
+è¦ããã
+;				ä¾:	mov.l	#__kernel_p_runtsk, r15
+;					add		#TCB_sp, r15, r5
+;					mov.l  	r0, [r5]
+;		åãªãã»ããå¤ãå¤æ­ã, æ¡ä»¶ã¢ã»ã³ãã«ã«ããã³ã¼ããåãæ¿ãã
+;
+
+;
+;  æ§é ä½ã¢ã¯ã»ã¹ã®ãªãã»ããå®ç¾©
+;
+#include "offset.h"
+
+;
+;  åç¨®EQUå®ç¾©(Hãã¡ã¤ã«ã®#defineå®ç¾©)
+;
+#include "target_kernel_impl.h"
+#include "prc_kernel_impl.h"
+
+	.global	__kernel_istkpt
+	
+	.global	__kernel_p_runtsk
+	.global	__kernel_p_schedtsk
+
+	.global	__kernel_dispatch
+	.global	__exit_and_dispatch
+	.global	__kernel_start_r
+	.global	__kernel_call_texrtn
+	.global	_kernel_interrupt
+	.global	_kernel_exception
+	.global	__kernel_intnest
+	.global	__kernel_call_exit_kernel
+	.global	__kernel_start_dispatch
+
+	.global	_ext_tsk
+	.global	__kernel_exit_kernel
+
+#if	TIPM_LOCK != -15
+	.global	__kernel_lock_flag
+	.global	__kernel_saved_ipl
+#endif
+
+	.global	__kernel_break_wait
+	.global	_sil_dly_nse
+
+#if LOG_INH_ENTER == 1
+	.global	_kernel_log_inh_enter
+#endif	/* LOG_INH_ENTER == 1 */
+#if LOG_INH_LEAVE == 1
+	.global	_kernel_log_inh_leave
+#endif	/* LOG_INH_LEAVE == 1 */
+#if LOG_EXC_ENTER == 1
+	.global	_kernel_log_exc_enter
+#endif	/* LOG_EXC_ENTER == 1 */
+#if LOG_EXC_LEAVE == 1
+	.global	_kernel_log_exc_leave
+#endif	/* LOG_EXC_LEAVE == 1 */
+#if LOG_DSP_ENTER == 1
+	.global	_kernel_log_dsp_enter
+#endif	/* LOG_DSP_ENTER == 1 */
+#if LOG_DSP_LEAVE == 1
+	.global	_kernel_log_dsp_leave
+#endif	/* LOG_DSP_LEAVE == 1 */
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	.global	__kernel_ovrtimer_start
+	.global	__kernel_ovrtimer_stop
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+;
+;  TCB_sp ã¸ã®æ¸è¾¼ã¿ãã¯ã­
+;
+.macro	st_TCB_sp	src, tcb, tmp
+#if (TCB_sp % 4) == 0
+	mov.l	\src, TCB_sp[\tcb]
+#else
+	add		#TCB_sp, \tcb, \tmp
+	mov.l	\src, [\tmp]
+#endif
+.endm
+
+;
+;  TCB_sp ããã®èª­åºããã¯ã­
+;
+.macro	ld_TCB_sp	dst, tcb, tmp
+#if (TCB_sp % 4) == 0
+	mov.l	TCB_sp[\tcb], \dst
+#else
+	add		#TCB_sp, \tcb, \tmp
+	mov.l	[tmp], \dst
+#endif
+.endm
+
+;
+;  TCB_pc ã¸ã®æ¸è¾¼ã¿ãã¯ã­
+;
+.macro	st_TCB_pc	src, tcb, tmp
+#if (TCB_pc % 4) == 0
+	mov.l	\src, TCB_pc[\tcb]
+#else
+	add		#TCB_pc, \tcb, \tmp
+	mov.l	\src, [\tmp]
+#endif
+.endm
+
+;
+;  TCB_pc ããã®èª­åºããã¯ã­
+;
+.macro	ld_TCB_pc	dst, tcb, tmp
+#if (TCB_pc % 4) == 0
+	mov.l	TCB_pc[\tcb], \dst
+#else
+	add		#TCB_pc, \tcb, \tmp
+	mov.l	[\tmp], \dst
+#endif
+.endm
+
+;
+;  TCB_texptn ããã®èª­åºããã¯ã­
+;
+.macro	ld_TCB_texptn	dst, tcb, tmp
+#if (TCB_texptn % 4) == 0
+	mov.l	TCB_texptn[\tcb], \dst
+#else
+	add		#TCB_texptn, \tcb, \tmp
+	mov.l	[\tmp], \dst
+#endif
+.endm
+
+;
+;  TCB_p_tinib ããã®èª­åºããã¯ã­
+;
+.macro	ld_TCB_p_tinib	dst, tcb, tmp
+#if (TCB_p_tinib % 4) == 0
+	mov.l	TCB_p_tinib[\tcb], \dst
+#else
+	add		#TCB_p_tinib, \tcb, \tmp
+	mov.l	[\tmp], \dst
+#endif
+.endm
+
+;
+;  TINIB_exinf ããã®èª­åºããã¯ã­
+;
+.macro	ld_TINIB_exinf	dst, tinib, tmp
+#if (TINIB_exinf % 4) == 0
+	mov.l	TINIB_exinf[\tinib], \dst
+#else
+	add		#TINIB_exinf, \tinib, \tmp
+	mov.l	[\tmp], \dst
+#endif
+.endm
+
+;
+;  TINIB_task ããã®èª­åºããã¯ã­
+;
+.macro	ld_TINIB_task	dst, tinib, tmp
+#if (TINIB_task % 4) == 0
+	mov.l	TINIB_task[\tinib], \dst
+#else
+	add		#TINIB_task, \tinib, \tmp
+	mov.l	[\tmp], \dst
+#endif
+.endm
+
+
+	.section	P, CODE
+
+;
+;  APIããã®ã¿ã¹ã¯ãã£ã¹ãããã£å
+¥å£
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã£ã¹ãããã£ã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, ã³ã³ãã­ã¹ãã®éé¿ã¨, å®è¡åéçªå°ã®è¨­å®ããã.
+;
+__kernel_dispatch:
+#ifdef TOPPERS_SUPPORT_OVRHDR /* (6-5-3-1) */
+	mov.l	#255, r1					; r1ã«ããã¼å²è¾¼ã¿çªå·
+	bsr		__kernel_ovrtimer_stop
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	pushm	r6-r13						; éã¹ã¯ã©ããã¬ã¸ã¹ã¿ä¿å­
+	mov.l	#__kernel_p_runtsk, r15
+	mov.l	[r15], r14
+	st_TCB_sp	r0, r14, r5				; ã¹ã¿ãã¯ãã¤ã³ã¿ãTCBã«ä¿å­
+	st_TCB_pc	#dispatch_r, r14, r5	; å®è¡åéçªå°ãTCBã«ä¿å­
+	bra		dispatcher
+
+;
+;  APIã¸ã®ã¿ã¹ã¯ãã£ã¹ãããã£åºå£
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã£ã¹ãããã£ã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, ã¿ã¹ã¯ä¾å¤ãã³ãã©å¼åºãã¨, ã³ã³ãã­ã¹ãã®å¾©å¸°ããã.
+;
+dispatch_r:
+dispatch_r_rts:
+	popm 	r6-r13						; éã¹ã¯ã©ããã¬ã¸ã¹ã¿å¾©å¸°
+#ifdef TOPPERS_SUPPORT_OVRHDR /* (6-5-3-2) */
+	bsr		__kernel_ovrtimer_start
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	rts  	                        	; dispatch å¼ã³åºãå
+ã¸æ»ã.
+
+;
+;  ã¿ã¹ã¯èµ·åå¦ç(ã¿ã¹ã¯å
+é ­ã¸ã®ã¿ã¹ã¯ãã£ã¹ãããã£åºå£)
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã£ã¹ãããã£ã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, CPUã­ãã¯è§£é¤ç¶æ
+ã«ã, ã¿ã¹ã¯ãèµ·åãã.
+;
+__kernel_start_r:
+#ifdef TOPPERS_SUPPORT_OVRHDR /* (6-5-6-1) */
+	push.l	r14
+	bsr		__kernel_ovrtimer_start
+	pop		r14
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	mov.l 	#_ext_tsk, r5
+	push.l	r5							; æ»ãçªå°ãã¹ã¿ãã¯ã«ç©ã
+	ld_TCB_p_tinib	r5, r14, r4
+	ld_TINIB_exinf	r1, r5, r4			; æ¡å¼µæ
+å ±ãç¬¬ä¸å¼æ°ã«è¨­å®
+	ld_TINIB_task	r5, r5, r4			; ã¿ã¹ã¯ã®èµ·åçªå°ãåå¾
+.if	TIPM_LOCK == -15
+	setpsw	i							; å²è¾¼ã¿è¨±å¯(CPUã­ãã¯è§£é¤ç¶æ
+)
+.else
+	mov.l	#__kernel_lock_flag, r4		; CPUã­ãã¯è§£é¤ç¶æ
+ã¸
+	mov.l	#0, [r4]					; ããã«æ¥ãã¨ãã¯å¿
+ã saved_ipl ã®
+	mvtc	#00010000H, psw				; å¤ã¯ 0 ã®ãã, ç´å¤ãè¨­å®ãã.
+								; å
+¨å²è¾¼ã¿ã­ãã¯è§£é¤ç¶æ
+( I = 1 )
+								; å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+( IPL = 0 )
+.endif
+	jmp		r5
+
+;
+;  ã«ã¼ãã«èµ·åããã®ã¿ã¹ã¯ãã£ã¹ãããã£å
+¥å£
+;
+;  ãã®ã«ã¼ãã³ã¯ï¼ã«ã¼ãã«èµ·åæã«ï¼ãã¹ã¦ã®å²è¾¼ã¿ãç¦æ­¢ããç¶æ
+
+; ï¼å²è¾¼ã¿ã­ãã¯ç¶æ
+ã¨åç­ï¼ã§å¼ã³åºãããï¼ã¾ãï¼å²è¾¼ã¿ã¢ã¼ãï¼é
+;  ã¿ã¹ã¯ã³ã³ãã­ã¹ãã¨åç­ï¼ã§å¼ã³åºããããã¨ãæ³å®ãã¦ããï¼
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»å²è¾¼ã¿(CPUä¾å¤)å¦çã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, ãã£ã¹ãããã£ã¢ã¼ãã«å¤æ´ãã.
+;
+__kernel_start_dispatch:
+	mov.l	#__kernel_intnest, r5
+	mov.w	#0, [r5]					; ã¿ã¹ã¯ã³ã³ãã­ã¹ãã«åæã
+#if	TIPM_LOCK != -15
+	mvtc	#(IPL_LOCK | 00010000H), psw	; å
+¨å²è¾¼ã¿ã­ãã¯è§£é¤ç¶æ
+
+										; å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªãç¶æ
+
+#endif
+
+;
+; ã¿ã¹ã¯çµäº(ç¾å¨ã®ã³ã³ãã­ã¹ããæ¨ã¦ã)ããã®ã¿ã¹ã¯ãã£ã¹ãããã£å
+¥å£
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã£ã¹ãããã£ã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, ä½ããããã¨ã¯ãªã.
+;  ãªã, p_runtsk ã®ã¢ãã¬ã¹åå¾ã ãã¯è¡ãªã.
+;
+__exit_and_dispatch:
+	mov.l	#__kernel_p_runtsk, r15     
+.if	LOG_DSP_ENTER == 1
+	mov.l	[r15], r14
+.endif
+;
+; ãã£ã¹ãããã£æ¬ä½
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã¹ã¦ã®ã¿ã¹ã¯ã®ã³ã³ãã­ã¹ãã¯ä¿å­ããã¦ãã.
+;
+;  dispatcher å¼åºæã®ã¹ã¿ãã¯:
+;	ã»__kernel_dispatch ããããå ´å			: ã¿ã¹ã¯ã¹ã¿ãã¯
+;	ã»exit_and_dispatch ããããå ´å: 
+;		exit_task ããããå ´å					: ã¿ã¹ã¯ã¹ã¿ãã¯
+;		ã«ã¼ãã«èµ·åæ(__kernel_start_dispatch)	: å²è¾¼ã¿ã¹ã¿ãã¯
+;	ã»ret_int ããããå ´å						: ã¿ã¹ã¯ã¹ã¿ãã¯
+;	ã»dispatcher_idle_loop ããããå ´å			: å²è¾¼ã¿ã¹ã¿ãã¯
+;
+dispatcher:
+.if	LOG_DSP_ENTER == 1
+	push.l	r15
+	mov.l	r14, r1						; å¼æ°(ãã£ã¹ãããå
+TCB)ãè¨­å®
+	bsr		__kernel_log_dsp_enter
+	pop		r15
+.endif
+	mov.l	#__kernel_p_schedtsk, r5     
+	mov.l	[r5], [r15]					; p_schedtsk ã p_runtsk ã«
+	mov.l	[r15], r14
+	cmp		#0, r14
+	bz		dispatcher_pre_idle			; schedtsk ããªããã°ã¢ã¤ãã«ã«ã¼ãã¸
+	ld_TCB_sp	r0, r14, r5				; ã¿ã¹ã¯ã¹ã¿ãã¯ãã¤ã³ã¿ãå¾©å¸°
+.if	LOG_DSP_LEAVE == 1
+	push.l	r14
+	mov.l	r14, r1						; å¼æ°(ãã£ã¹ãããå
+TCB)ãè¨­å®
+	bsr		__kernel_log_dsp_leave
+	pop		r14
+.endif
+	ld_TCB_pc	r5, r14, r4
+	jmp		r5					; å®è¡åéçªå°ã¸ã¸ã£ã³ã
+
+;
+;  schdedtskãNULLã®å ´åã¯ã¢ã¤ãã«ã«ã¼ãã«å
+¥ã
+;  ã¢ã¤ãã«ã«ã¼ãã¯å²è¾¼ã¿å¦çã¢ã¼ãã§åä½ããã
+;
+;  ããã§å²è¾¼ã¿ã¢ã¼ãã«åãæããã®ã¯ï¼ããã§çºçããå²è¾¼ã¿å¦çã«
+;  ã©ã®ã¹ã¿ãã¯ãä½¿ããã¨ããåé¡ã®è§£æ±ºã¨ï¼å²è¾¼ã¿ãã³ãã©å
+ã§ã®ã¿
+;  ã¹ã¯ãã£ã¹ãããã®é²æ­¢ã¨ãã2ã¤ã®æå³ãããï¼
+;
+dispatcher_pre_idle:
+	mov.l	#__kernel_istkpt,r5
+	mov.l	[r5], r0					; å²è¾¼ã¿ç¨ã®ã¹ã¿ãã¯ã¸åæ¿ã
+	mov.l	#__kernel_intnest, r5
+	mov.w	#1, [r5]					; éã¿ã¹ã¯ã³ã³ãã­ã¹ãã«åæã
+#if	TIPM_LOCK != -15
+	mov.l	#__kernel_lock_flag, r5		; CPUã­ãã¯è§£é¤ç¶æ
+ã¸
+	mov.l	#0, [r5]
+	mvtc	#0, psw						; åªå
+åº¦0ã®å²è¾¼ã¿å¦çä¸­ãå½è£
+
+#endif
+
+dispatcher_idle_loop:
+	setpsw	i							; å
+¨å²è¾¼ã¿è¨±å¯
+	clrpsw	i							; å
+¨å²è¾¼ã¿ç¦æ­¢
+
+	mov.l	#__kernel_p_schedtsk, r4
+	mov.l	[r4], r4					; p_schedtsk -> r4
+	mov.l	#__kernel_p_runtsk, r5
+	mov.l	[r5], r5					; p_runtsk -> r5
+	cmp		r4, r5						; p_schedtsk ã¨ p_runtsk ãåãã§ãã£ã¹ãããè¦æ±ç¡ããªã
+	beq		dispatcher_idle_loop		; ã¢ã¤ãã«ã«ã¼ããç¹°ãè¿ã
+	mov.l	#0, [r5]					; reqflgãtrueãªãfalseã«ãã
+	mov.l	#__kernel_intnest, r5
+	mov.w	#0, [r5]					; ã¿ã¹ã¯ã³ã³ãã­ã¹ãã«åæã
+#if	TIPM_LOCK != -15
+	mov.l	#__kernel_lock_flag, r5		; CPUã­ãã¯ç¶æ
+ã¸
+	mov.l	#1, [r5]
+	mov.l	#__kernel_saved_ipl, r5
+	mov.l	#0, [r5]
+	mvtc	#(IPL_LOCK | PSW_I_MASK), psw	; å
+¨å²è¾¼ã¿ã­ãã¯è§£é¤ç¶æ
+
+										; å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªãç¶æ
+
+#endif
+	bra		dispatcher					; dispatcher ã¸æ»ã
+
+
+;
+; ã«ã¼ãã«ã®çµäºå¦çã®å¼åºã
+;
+; ã¢ã¼ãã¨ã¹ã¿ãã¯ãéã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã«åãæ¿ãï¼
+;
+	.global	__kernel_call_exit_kernel
+__kernel_call_exit_kernel:
+#if	TIPM_LOCK != -15
+	clrpsw	i							; å
+¨å²è¾¼ã¿ç¦æ­¢
+	mov.l	#__kernel_lock_flag, r5		; CPUã­ãã¯è§£é¤ç¶æ
+ã¸
+	mov.l	#0, [r5]
+#endif
+	mov.l	#__kernel_istkpt, r5
+	mov.l	[r5], r0					; å²è¾¼ã¿ç¨ã®ã¹ã¿ãã¯ã¸åæ¿ã
+	mov.l	#__kernel_intnest, r5
+	mov.w	#1, [r5]					; éã¿ã¹ã¯ã³ã³ãã­ã¹ãã«åæã
+	bsr		__kernel_exit_kernel
+	bra		__kernel_call_exit_kernel
+
+
+;
+;  å²è¾¼ã¿(CPUä¾å¤)ããã®ã¿ã¹ã¯ãã£ã¹ãããã£å
+¥å£
+;
+;	å¼åºãæ¡ä»¶:
+;	ã»å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+(PSWã¬ã¸ã¹ã¿Iããã = 0)
+;	ã»å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªãç¶æ
+(IPL != 0)
+;	ã»ã¿ã¹ã¯ã³ã³ãã­ã¹ã(intnest=0)
+;	ã»ä½¿ç¨ã¹ã¿ãã¯ã¯ã¿ã¹ã¯ã¹ã¿ãã¯
+;	ã»reqflg = true
+;
+;  ããã§ã¯, ãã£ã¹ãããã£ã¢ã¼ãã«å¤æ´ã, reqflgãOFFã«ãã¦ãã, 
+;  é
+å»¶ãã£ã¹ãããã®æç¡ãå¤æ­ãã.
+;
+
+;
+;  ret_intå
+é ­ã§ã¹ã¿ãã¯ã«ç©ã¾ãã¦ããPSWã¬ã¸ã¹ã¿ã¸ã®ãªãã»ãã
+;  ACC + FPSW + R14--R15 + R1--R5 + PC
+;
+	.equ	RET_INT_GET_PSW_OFFSET,	(8+4+28+4)
+
+ret_int:
+.if	TIPM_LOCK == -15
+	mov.l	RET_INT_GET_PSW_OFFSET[r0], r5	; å²è¾¼ã¿/CPUä¾å¤çºçåã®IPLå¤åå¾
+	and		#PSW_IPL_MASK, r5
+	mvtc	r5, psw						; å
+¨å²è¾¼ã¿ã­ãã¯(CPUã­ãã¯)ç¶æ
+
+										; å²è¾¼ã¿/CPUä¾å¤çºçåã®å²è¾¼ã¿åªå
+åº¦
+.else
+	mov.l	#__kernel_lock_flag, r5		; CPUã­ãã¯ç¶æ
+ã¸
+	mov.l	#1, [r5]
+	mov.l	RET_INT_GET_PSW_OFFSET[r0], r5	; å²è¾¼ã¿/CPUä¾å¤çºçåã®IPLå¤åå¾
+	and		#PSW_IPL_MASK, r5
+	mov.l	#__kernel_saved_ipl, r4
+	mov.l	r5, [r4]
+	mvtc	#(IPL_LOCK | PSW_I_MASK), psw	; å
+¨å²è¾¼ã¿ã­ãã¯è§£é¤ç¶æ
+
+										; å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªãç¶æ
+
+.endif
+	mov.l	#__kernel_p_runtsk, r15     
+	mov.l	[r15], r14
+	mov.l	#__kernel_p_schedtsk, r5
+	mov.l	[r5], r5
+	cmp		r5, r14						; p_schedtsk ã¨ p_runtsk ãåããªã
+	beq  	ret_int_r_call_tex			; ret_int_r_call_tex ã¸
+	pushm	r6-r13						; éã¹ã¯ã©ããã¬ã¸ã¹ã¿ä¿å­
+	st_TCB_sp	r0, r14, r5				; ã¹ã¿ãã¯ãã¤ã³ã¿ãTCBã«ä¿å­
+	st_TCB_pc	#ret_int_r, r14, r5		; å®è¡åéçªå°ãTCBã«ä¿å­
+	bra		dispatcher
+
+;
+;  å²è¾¼ã¿(CPUä¾å¤)ã¸ã®ã¿ã¹ã¯ãã£ã¹ãããã£åºå£
+;
+;  å¼ã³åºãæ¡ä»¶:
+;	ã»ãã£ã¹ãããã£ã¢ã¼ã(ãã¡ã¤ã«ãããåç
+§)
+;
+;  ããã§ã¯, ã¿ã¹ã¯ä¾å¤ãã³ãã©å¼åºãã¨, å²è¾¼ã¿(CPUä¾å¤)å¦çã¢ã¼ãã¸ã®
+;  å¤æ´ã¨, ã³ã³ãã­ã¹ãã®å¾©å¸°ãè¡ã, å²è¾¼ã¿(CUPä¾å¤)çºçå
+ã¸æ»ã.
+;
+__kernel_break_wait:					;ã¿ã¹ã¯ã¢ãã¿ç¨ã©ãã«
+ret_int_r:
+	popm 	r6-r13						; éã¹ã¯ã©ããã¬ã¸ã¹ã¿å¾©å¸°
+ret_int_r_call_tex:
+#ifdef TOPPERS_SUPPORT_OVRHDR /* 6.6.1 & 6.7.1 */
+	push.l	r14
+	bsr		__kernel_ovrtimer_start
+	pop		r14
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+ret_int_r_rte:
+#if	TIPM_LOCK != -15
+	clrpsw	i							; å
+¨å²è¾¼ã¿ç¦æ­¢
+	mov.l	#__kernel_lock_flag, r5		; CPUã­ãã¯è§£é¤ç¶æ
+ã¸
+	mov.l	#0, [r5]
+#endif
+	popm	r4-r5						; ã¢ã­ã¥ã ã¬ã¼ã¿å¾©å¸°
+	mvtaclo	r5							; ACCæä¸ä½16bitã¯0ã§å¾©å¸°
+	mvtachi	r4
+	popc	fpsw						; FPUã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r14-r15						; ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r1-r5
+	rte									; å²è¾¼ã¿åã®å¦çã«æ»ã
+
+
+;
+;  å²è¾¼ã¿ã®åºå
+¥å£å¦ç(ã¢ã»ã³ããªè¨èªè¨è¿°é¨å)
+;
+;  å¼åºãæ¡ä»¶:
+;  ã»å²è¾¼ã¿çºçæã®H/Wå¦çã«ãã, PSWã¬ã¸ã¹ã¿ã®Iããã=0, IPLã¯åä»ã
+;    ãå²è¾¼ã¿ã®IPL.
+;  ã»ã¹ã¿ãã¯ã¯å¤éå²ãè¾¼ã¿ãªãå²è¾¼ã¿ã¹ã¿ãã¯, ããã§ãªããã°
+;    ã¿ã¹ã¯ã¹ã¿ãã¯
+;  ã»å²è¾¼ã¿çºçæã®H/Wå¦çã«ãã,ã¹ã¿ãã¯ã«å²è¾¼ã¿ããã®å¾©å¸°PCã¨PSWã
+;    ä¿å­ããã¦ãã.
+;  ã»ãã¯ã¿ãã¼ãã«ã«ç»é²ãããåå¥ã®å
+¥ãå£å¦çã«ãã, ã¹ã¿ãã¯ã«
+;    ã¹ã¯ã©ããã¬ã¸ã¹ã¿(R1-R5)ãä¿å­ããã¦ãã.
+;
+;  å¼æ°:
+;  ã»r1:å²è¾¼ã¿è¦å çªå·
+;  ã»r2:å²è¾¼ã¿ãã³ãã©ã®ã¢ãã¬ã¹
+;
+;  ã¬ã¸ã¹ã¿ãã¹ã¿ãã¯ä¸ã«ã©ã®ããã«ä¿å­ããã¦ããããä»¥ä¸ã«ç¤ºã.
+;  ãã®å³ã§ã¯ä¸ãä½ä½, ä¸ãé«ä½ã®ã¢ãã¬ã¹ã§, ã¹ã¿ãã¯ã¯ä¸ãã
+;  ä¸æ¹åã«åãã£ã¦ç©ã¿ä¸ãããããã®ã¨ãã.
+;
+;	-------------------------
+;	|       ACC-HI(4byte)   |
+;	-------------------------(SP + 0)
+;	|       ACC-LO(4byte)   |
+;	-------------------------(SP + 4)
+;	|       FPSW(4byte)     |
+;	-------------------------(SP + 8)
+;	|       R14(4byte)      |
+;	-------------------------(SP + 12)
+;	|       R15(4byte)      |
+;	-------------------------(SP + 16)
+;	|       R1(4byte)       |
+;	-------------------------(SP + 20)
+;	|       R2(4byte)       |
+;	-------------------------(SP + 24)
+;	|       R3(4byte)       |
+;	-------------------------(SP + 28)
+;	|       R4(4byte)       |
+;	-------------------------(SP + 32)
+;	|       R5(4byte)       |
+;	-------------------------(SP + 36)
+;	|       PC(4byte)       |
+;	-------------------------(SP + 40)
+;	|       PSW(4byte)      |
+;	-------------------------(SP + 44)
+;
+;  ããã§ã¯, å²è¾¼ã¿å¦çã¢ã¼ãã«å¤æ´ãã¦ãã³ãã©ãå®è¡ãã.
+;
+;  ãã³ãã©ãããªã¿ã¼ã³ããå¾ã¯, å¤éå²è¾¼ã¿ã§ãªã, ãã¤ reqflg ã
+;  TRUE ã«ãªã£ãæã«ï¼ret_int ã¸åå²(é
+å»¶ãã£ã¹ããã)ããï¼
+;
+;  å¤éå²è¾¼ã¿ãã©ããã¯å²è¾¼ã¿ãã¹ãã«ã¦ã³ã¿ã®å¤ã§å¤å®ãã.
+;  intnest != 0 ãªãã°å¤éå²è¾¼ã¿ã§ããã¨å¤å®ãã.
+;
+;  reqflg ã¯CPUã­ãã¯ç¶æ
+ã§ãã§ãã¯ãã. ããã§ãªãã¨ï¼
+;  reqflg ãã§ãã¯å¾ã«èµ·åãããå²è¾¼ã¿ãã³ãã©å
+ã§
+;  ãã£ã¹ããããè¦æ±ãããå ´åã«ï¼ãã£ã¹ããããããªã.
+;
+_kernel_interrupt:
+	pushm	r14-r15						; ã¹ã¯ã©ããã¬ã¸ã¹ã¿ãéé¿
+	pushc	fpsw						; FPUã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿éé¿
+	mvfacmi	r5
+	shll	#16, r5						; ACCæä¸ä½16bitã¯0ã¨ãã
+	mvfachi	r4
+	pushm	r4-r5						; ã¢ã­ã¥ã ã¬ã¼ã¿éé¿
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	add		#1, r4						; ãã¹ãåæ°ãã¤ã³ã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#1, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		interrupt_from_int			; å ç®åã0ã§ãªããã°å¤éå²è¾¼ã¿
+						; åæ®µã®å²è¾¼ã¿
+#ifdef TOPPERS_SUPPORT_OVRHDR /* 6.6.1 */
+	pushm	r1-r5
+	bsr		__kernel_ovrtimer_stop		; r1ã«å²è¾¼ã¿çªå·
+	popm	r1-r5
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	mov.l	r0, r3						; ã¹ã¿ãã¯ãã¤ã³ã¿ãåãåºã
+	mov.l	#__kernel_istkpt, r5		; å²è¾¼ã¿ç¨ã®ã¹ã¿ãã¯ã¸åæ¿ãã
+	mov.l	[r5], r0
+	push.l	r3							; ã¿ã¹ã¯ã¹ã¿ãã¯ãä¿æ
+interrupt_from_int:		; å¤éå²è¾¼ã¿
+	setpsw	i							; å²è¾¼ã¿è¨±å¯(CPUã­ãã¯è§£é¤ç¶æ
+)
+
+.if	LOG_INH_LEAVE == 1
+	push.l	r1							; ã­ã°ãã¬ã¼ã¹ã®å¼æ°ãä¿æ
+.endif
+
+.if	LOG_INH_ENTER == 1
+	push.l	r2
+	bsr		__kernel_log_inh_enter		; ã­ã°ãã¬ã¼ã¹é¢æ°ã®å¼åºã
+							; å¼æ°ã®å²è¾¼ã¿è¦å çªå·ã¯æ¢ã«r1ã«å
+¥ã£ã¦ãã
+	pop		r2
+.endif
+
+	jsr  	r2							; Cã«ã¼ãã³å¼ã³åºã
+
+.if	LOG_INH_LEAVE == 1
+	pop		r1							; å¼æ°ã«å²è¾¼ã¿è¦å çªå·ãè¨­å®
+	bsr		__kernel_log_inh_leave		; ã­ã°ãã¬ã¼ã¹é¢æ°ã®å¼åºã
+.endif
+
+	clrpsw	i							; å²è¾¼ã¿ç¦æ­¢(CPUã­ãã¯ç¶æ
+)
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	sub		#1, r4						; ãã¹ãåæ°ããã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#0, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		interrupt_return			; å¤éå²ãè¾¼ã¿ãªããªã¿ã¼ã³
+	; åæ®µã®å²è¾¼ã¿
+	pop		r0							; ã¿ã¹ã¯ã®ã¹ã¿ãã¯ã«æ»ã
+	mov.l	#__kernel_p_schedtsk, r4
+	mov.l	[r4], r4					; p_schedtsk -> r4
+	mov.l	#__kernel_p_runtsk, r5
+	mov.l	[r5], r5					; p_runtsk -> r5
+	cmp		r4, r5						; p_schedtsk ã¨ p_runtsk ãç°ãªããã£ã¹ãããè¦æ±æããªã
+	bne		ret_int						; ret_int ã¸ã¸ã£ã³ã
+#ifdef TOPPERS_SUPPORT_OVRHDR /* 6.6.1 */
+	mov.l	#__kernel_p_runtsk, r5
+	mov.l	[r5], r4
+	cmp		#0, r4
+	beq		interrupt_return
+	bsr		__kernel_ovrtimer_start
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+interrupt_return:
+	popm	r4-r5						; ã¢ã­ã¥ã ã¬ã¼ã¿å¾©å¸°
+	mvtaclo	r5							; ACCæä¸ä½16bitã¯0ã§å¾©å¸°
+	mvtachi	r4
+	popc	fpsw						; FPUã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r14-r15						; ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r1-r5
+	rte									; å²è¾¼ã¿åã®å¦çã«æ»ã
+
+
+;
+;  CPUä¾å¤ã®åºå
+¥å£å¦ç(ã¢ã»ã³ããªè¨èªè¨è¿°é¨å)
+;
+;  å¼åºãæ¡ä»¶:
+;  ã»CPUä¾å¤çºçæã®H/Wå¦çã«ãã, PSWã¬ã¸ã¹ã¿ã®Iããã=0, IPL=0.
+;  ã»ã¹ã¿ãã¯ã¯å¤éå²ãè¾¼ã¿ãªãå²è¾¼ã¿ã¹ã¿ãã¯, ããã§ãªããã°
+;    ã¿ã¹ã¯ã¹ã¿ãã¯
+;  ã»CPUä¾å¤çºçæã®H/Wå¦çã«ãã,ã¹ã¿ãã¯ã«CPUä¾å¤ããã®å¾©å¸°PCã¨
+;    PSWãä¿å­ããã¦ãã.
+;  ã»ãã¯ã¿ãã¼ãã«ã«ç»é²ãããåå¥ã®å
+¥ãå£å¦çã«ãã, ã¹ã¿ãã¯ã«
+;    ã¹ã¯ã©ããã¬ã¸ã¹ã¿(R1-R5)ãä¿å­ããã¦ãã.
+;
+;  å¼æ°:
+;  ã»r1:CPUä¾å¤è¦å çªå·
+;  ã»r2:CPUä¾å¤ãã³ãã©ã®ã¢ãã¬ã¹
+;
+;  ã¬ã¸ã¹ã¿ãã¹ã¿ãã¯ä¸ã«ã©ã®ããã«ä¿å­ããã¦ããããä»¥ä¸ã«ç¤ºã.
+;  ãã®å³ã§ã¯ä¸ãä½ä½, ä¸ãé«ä½ã®ã¢ãã¬ã¹ã§, ã¹ã¿ãã¯ã¯ä¸ãã
+;  ä¸æ¹åã«åãã£ã¦ç©ã¿ä¸ãããããã®ã¨ãã.
+;  ãªã, CPUä¾å¤è¦å çªå·ã¨R6-R13ã¯CPUä¾å¤ãã³ãã©å
+ã§æ
+å ±ãåå¾
+;  ããç®çã§éé¿ãã¦ãã, åºå£å¦çã§ã¯ä¿å­å
+å®¹ãç ´æ£ããã°ãã.
+;
+;	-------------------------
+;	|    CPUä¾å¤è¦å çªå·    | <----- p_excinf
+;	------------------------- (intptr_t)(p_excinf + 0)
+;	|       R6(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 4)
+;	|       R7(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 8)
+;	|       R8(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 12)
+;	|       R9(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 16)
+;	|       R10(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 20)
+;	|       R11(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 24)
+;	|       R12(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 28)
+;	|       R13(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 32)
+;	|       ACC-HI(4byte)   |
+;	------------------------- (intptr_t)(p_excinf + 36)
+;	|       ACC-LO(4byte)   |
+;	------------------------- (intptr_t)(p_excinf + 40)
+;	|       FPSW(4byte)     |
+;	------------------------- (intptr_t)(p_excinf + 44)
+;	|       R14(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 48)
+;	|       R15(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 52)
+;	|       R1(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 56)
+;	|       R2(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 60)
+;	|       R3(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 64)
+;	|       R4(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 68)
+;	|       R5(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 72)
+;	|       PC(4byte)       |
+;	------------------------- (intptr_t)(p_excinf + 76)
+;	|       PSW(4byte)      |
+;	------------------------- (intptr_t)(p_excinf + 80)
+;
+;  ããã§ã¯, å²è¾¼ã¿å¦çã¢ã¼ãã«å¤æ´ãã¦ãã³ãã©ãå®è¡ãã.
+;  CPUä¾å¤ãã³ãã©ã«æ¸¡ãVPåã®å¤æ° p_excinf ã¨ãã¦ISPã®å¤æ¸¡ãï¼
+;
+;  ãã³ãã©ãããªã¿ã¼ã³ããå¾ã¯, å¤éå²è¾¼ã¿ã§ãªã, ãã¤ reqflg ã
+;  TRUE ã«ãªã£ãæã«ï¼ret_int ã¸åå²(é
+å»¶ãã£ã¹ããã)ããï¼
+;
+;  å¤éå²è¾¼ã¿ãã©ããã¯å²è¾¼ã¿ãã¹ãã«ã¦ã³ã¿ã®å¤ã§å¤å®ãã.
+;  intnest != 0 ãªãã°å¤éå²è¾¼ã¿ã§ããã¨å¤å®ãã.
+;
+;  reqflg ã¯CPUã­ãã¯ç¶æ
+ã§ãã§ãã¯ãã. ããã§ãªãã¨ï¼
+;  reqflg ãã§ãã¯å¾ã«èµ·åãããå²è¾¼ã¿ãã³ãã©å
+ã§
+;  ãã£ã¹ããããè¦æ±ãããå ´åã«ï¼ãã£ã¹ããããããªã.
+;
+;
+;  CPUä¾å¤å
+¥å£å¦ç
+;
+;  ããã§ã¯, å²è¾¼ã¿å¦çã¢ã¼ãã«å¤æ´ãã¦ãã³ãã©ãå®è¡ãã.
+;
+
+;
+;  CPUä¾å¤ãã³ãã©å¼åºãå¾ã«ä¸è¦ã¨ãªãã¹ã¿ãã¯æ
+å ±ã®ãµã¤ãº
+;  EXCNO + R6--R13
+;
+	.equ	EXCINF_REG_SIZE,	(4+32)
+
+_kernel_exception:
+	pushm	r14-r15						; ã¹ã¯ã©ããã¬ã¸ã¹ã¿ãéé¿
+	pushc	fpsw
+	mvfacmi	r5
+	shll	#16, r5						; ACCæä¸ä½16bitã¯0ã¨ãã
+	mvfachi	r4
+	pushm	r4-r5						; ã¢ã­ã¥ã ã¬ã¼ã¿éé¿
+	pushm	r6-r13						; éã¹ã¯ã©ããã¬ã¸ã¹ã¿ä¿å­
+	push.l	r1							; CPUä¾å¤è¦å çªå·ãä¿æ
+	mov.l	r0, r3						; ã¹ã¿ãã¯ãã¤ã³ã¿ãåãåºã
+	mov.l	EXC_GET_PSW_OFFSET[r3], r5
+	and		#PSW_I_MASK, r5
+	bz		exception_nonkernel			; å
+¨å²è¾¼ã¿ç¦æ­¢(CPUã­ãã¯)ç¶æ
+ãªãç®¡çå¤
+#if	TIPM_LOCK != -15
+	mov.l	EXC_GET_PSW_OFFSET[r3], r5
+	and		#PSW_IPL_MASK, r5
+	cmp		#IPL_LOCK, r5
+	bgt	exception_nonkernel			; IPLãCPUã­ãã¯ã¬ãã«ä»¥ä¸ãªãç®¡çå¤
+#endif
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	add		#1, r4						; ãã¹ãåæ°ãã¤ã³ã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#1, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		exception_from_int			; å ç®åã0ã§ãªããã°å¤éå²è¾¼ã¿
+						; åæ®µã®å²è¾¼ã¿
+#ifdef TOPPERS_SUPPORT_OVRHDR /* 6.7.1 */
+	pushm	r1-r5
+	mov.l	#255, r1					; r1ã«ããã¼å²è¾¼ã¿çªå·
+	bsr		__kernel_ovrtimer_stop
+	popm	r1-r5
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	mov.l	#__kernel_istkpt, r5		; å²è¾¼ã¿ç¨ã®ã¹ã¿ãã¯ã¸åæ¿ãã
+	mov.l	[r5], r0
+	push.l	r3							; ã¿ã¹ã¯ã¹ã¿ãã¯ãä¿æ
+exception_from_int:		; å¤éå²è¾¼ã¿
+	mov.l	EXC_GET_PSW_OFFSET[r3], r5
+	mvtc	r5, psw						; CPUä¾å¤çºçåã®ç¶æ
+ã«æ»ã
+#if	LOG_EXC_LEAVE == 1
+	push.l	r1							; ã­ã°ãã¬ã¼ã¹ã®å¼æ°ãä¿æ
+#endif
+
+#if	LOG_EXC_ENTER == 1
+	pushm	r2-r3
+	bsr		__kernel_log_exc_enter		; ã­ã°ãã¬ã¼ã¹é¢æ°ã®å¼åºã
+							; å¼æ°ã®å²è¾¼ã¿è¦å çªå·ã¯æ¢ã«r1ã«å
+¥ã£ã¦ãã
+	popm	r2-r3
+#endif
+
+	mov.l	r3, r1						; å¼æ°ã®p_excinfãè¨­å®
+	jsr  	r2							; Cã«ã¼ãã³å¼ã³åºã
+
+.if	LOG_EXC_LEAVE == 1
+	pop		r1							; å¼æ°ã«å²è¾¼ã¿è¦å çªå·ãè¨­å®
+	bsr		__kernel_log_exc_leave		; ã­ã°ãã¬ã¼ã¹é¢æ°ã®å¼åºã
+.endif
+
+	clrpsw	i							; ããããã¯å¿
+ãå²è¾¼ã¿ç¦æ­¢
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	sub		#1, r4						; ãã¹ãåæ°ããã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#0, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		exception_return			; å¤éå²ãè¾¼ã¿ãªããªã¿ã¼ã³
+	; åæ®µã®å²è¾¼ã¿
+	pop		r0							; ã¿ã¹ã¯ã®ã¹ã¿ãã¯ã«æ»ã
+	mov.l	#__kernel_p_schedtsk, r4
+	mov.l	[r4], r4					; p_schedtsk -> r4
+	mov.l	#__kernel_p_runtsk, r5
+	mov.l	[r5], r5					; p_runtsk -> r5
+	cmp		r4, r5						; p_schedtsk ã¨ p_runtsk ãåãã§ãã£ã¹ãããè¦æ±ç¡ãã
+#ifndef TOPPERS_SUPPORT_OVRHDR /* 6.7.1 */
+	beq		exception_return			; ãªããã°ãªã¿ã¼ã³
+	add		#EXCINF_REG_SIZE, r0		; CPUä¾å¤æ
+å ±ã®ç ´æ£
+	bra		ret_int						; ããã° ret_int ã¸ã¸ã£ã³ã
+#else /* TOPPERS_SUPPORT_OVRHDR */
+	beq		exception_return_ovr		; ãªããã°ãªã¿ã¼ã³
+	add		#EXCINF_REG_SIZE, r0		; CPUä¾å¤æ
+å ±ã®ç ´æ£
+	bra		ret_int						; ããã° ret_int ã¸ã¸ã£ã³ã
+exception_return_ovr:
+	mov.l	#__kernel_p_runtsk, r5
+	mov.l	[r5], r4
+	cmp		#0, r4
+	beq		exception_return
+	bsr		__kernel_ovrtimer_start
+	bra		exception_return
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+exception_nonkernel:
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	add		#1, r4						; ãã¹ãåæ°ãã¤ã³ã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#1, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		exception_from_nonkernelint	; å ç®åã0ã§ãªããã°å¤éå²è¾¼ã¿
+						; åæ®µã®å²è¾¼ã¿
+	mov.l	#__kernel_istkpt, r5		; å²è¾¼ã¿ç¨ã®ã¹ã¿ãã¯ã¸åæ¿ãã
+	mov.l	[r5], r0
+	push.l	r3							; ã¿ã¹ã¯ã¹ã¿ãã¯ãä¿æ
+exception_from_nonkernelint:	; å¤éå²è¾¼ã¿
+	mov.l	EXC_GET_PSW_OFFSET[r3], r5
+	mvtc	r5, psw						; CPUä¾å¤çºçåã®ç¶æ
+ã«æ»ã
+
+	mov.l	r3, r1						; å¼æ°ã®p_excinfãè¨­å®
+	jsr  	r2							; Cã«ã¼ãã³å¼ã³åºã
+
+	clrpsw	i							; ããããã¯å¿
+ãå²è¾¼ã¿ç¦æ­¢
+	mov.l	#__kernel_intnest, r5
+	mov.w	[r5], r4
+	sub		#1, r4						; ãã¹ãåæ°ããã¯ãªã¡ã³ã
+	mov.w	r4, [r5]
+	cmp		#0, r4						; å¤éå²ãè¾¼ã¿ãã©ãã
+	bnz		exception_return			; å¤éå²ãè¾¼ã¿ãªããªã¿ã¼ã³
+	; åæ®µã®å²è¾¼ã¿
+	pop		r0							; ã¿ã¹ã¯ã®ã¹ã¿ãã¯ã«æ»ã
+
+exception_return:
+	add		#EXCINF_REG_SIZE, r0		; CPUä¾å¤æ
+å ±ã®ç ´æ£
+	popm	r4-r5						; ã¢ã­ã¥ã ã¬ã¼ã¿å¾©å¸°
+	mvtaclo	r5							; ACCæä¸ä½16bitã¯0ã§å¾©å¸°
+	mvtachi	r4
+	popc	fpsw						; FPUã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r14-r15						; ã¬ã¸ã¹ã¿å¾©å¸°
+	popm	r1-r5
+	rte									; å²è¾¼ã¿åã®å¦çã«æ»ã
+
+
+;
+;  å¾®å°æéå¾
+ã¡
+;
+_sil_dly_nse:
+	mov.l	#SIL_DLY_TIM1, r5
+	sub		r5, r1
+	ble		sil_dly_nse_ret
+sil_dly_nse_loop:
+	mov.l	#SIL_DLY_TIM2, r5
+	sub		r5, r1
+	bgt		sil_dly_nse_loop
+sil_dly_nse_ret:
+	rts
+
+	.end
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sym.def
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sym.def	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_sym.def	(revision 317)
@@ -0,0 +1,13 @@
+TA_EDGE
+TA_LOWLEVEL
+TA_BOTHEDGE
+TA_NEGEDGE
+TIPM_LOCK,,signed
+IPL_LOCK
+PSW_I_MASK
+PSW_IPL_MASK
+EXC_GET_PSW_OFFSET
+sizeof_TCB,sizeof(TCB)
+offsetof_TCB_p_tinib,"offsetof(TCB,p_tinib)"
+offsetof_TCB_sp,"offsetof(TCB,tskctxb.sp)"
+offsetof_TCB_pc,"offsetof(TCB,tskctxb.pc)"
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_syssvc.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_syssvc.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_syssvc.h	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã¹ããã­ã°ã©ã ã®ã¿ã¼ã²ããä¾å­å®ç¾©ï¼RX630ç¨ï¼
+ */
+
+#ifndef TOPPERS_PRC_SYSSVC_H
+#define TOPPERS_PRC_SYSSVC_H
+
+/*
+ *  èµ·åã¡ãã»ã¼ã¸ã«ã¿ã¼ã²ããä¾å­é¨ã®èä½æ¨©è¡¨ç¤ºã
+ *  è¿½å ããããã®ãã¯ã­ï¼
+ */
+#define PRC_COPYRIGHT										\
+	"Copyright (C) 2010 by Witz Corporation, JAPAN\n"		\
+	"Copyright (C) 2011 by Meika Sugimoto\n"				\
+	"Copyright (C) 2013 by Mitsuhiro Matsuura\n"
+
+#endif	/* TOPPERS_PRC_SYSSVC_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.S
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.S	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.S	(revision 317)
@@ -0,0 +1,73 @@
+;*
+;*  TOPPERS/ASP Kernel
+;*      Toyohashi Open Platform for Embedded Real-Time Systems/
+;*      Advanced Standard Profile Kernel
+;* 
+;*  Copyright (C) 2010 by Witz Corporation, JAPAN
+;* 
+;*  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+;*  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+;*  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+;*  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+;*      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+;*      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+;*  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+;*      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+;*      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+;*      ã¨ï¼
+;*    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+;*        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+;*        å ±åãããã¨ï¼
+;*  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+;*      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+;*      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+;*      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+;*      å
+è²¬ãããã¨ï¼
+;* 
+;*  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+;*  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+;*  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+;*  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+;*  ã®è²¬ä»»ãè² ããªãï¼
+;* 
+;*  @(#) $Id$
+;* 
+
+	.section	P, CODE
+
+	.global	_trigger_cpu_exception
+
+_trigger_cpu_exception:
+	;
+	;  CPUä¾å¤ã®çºç
+	;
+	;  ã¼ã­å²ãç®ãè¡ããã¨ã§, æµ®åå°æ°ç¹ä¾å¤ã
+	;  çºçããã.
+	;
+	mvtc	#00001000H, fpsw
+	mov.l	#1, r5
+	fdiv	#0, r5
+	mvtc	#00000000H, fpsw
+	rts
+
+	.end
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_test.h	(revision 317)
@@ -0,0 +1,67 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã¹ããã­ã°ã©ã ã®ã¿ã¼ã²ããä¾å­å®ç¾©ï¼RX630ç¨ï¼
+ */
+
+#ifndef TOPPERS_PRC_TEST_H
+#define TOPPERS_PRC_TEST_H
+
+#define CPUEXC1					25		/* æµ®åå°æ°ç¹ä¾å¤ */
+#define RAISE_CPU_EXCEPTION		trigger_cpu_exception()
+
+extern void trigger_cpu_exception( void );
+
+#endif /* TOPPERS_PRC_TEST_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/prc_unrename.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/prc_unrename.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/prc_unrename.h	(revision 317)
@@ -0,0 +1,83 @@
+/* This file is generated from prc_rename.def by genrename. */
+
+#ifndef TOPPERS_PRC_RENAME_H
+#define TOPPERS_PRC_RENAME_H
+
+/*
+ *  prc_kernel_impl.c
+ */
+#undef intnest
+#undef lock_flag
+#undef saved_ipl
+#undef prc_initialize
+#undef prc_terminate
+#undef config_int
+#undef default_int_handler
+#undef default_exc_handler
+
+/*
+ *  prc_support.src
+ */
+#undef dispatch
+#undef start_dispatch
+#undef exit_and_dispatch
+#undef call_exit_kernel
+#undef start_r
+#undef interrupt
+#undef exception
+
+/*
+ *  rx630_kernel_impl.c
+ */
+#undef ipr_reg_addr
+#undef ier_reg_addr
+#undef ir_reg_addr
+#undef irqcr_reg_addr
+
+/*
+ *  kernel_cfg.c
+ */
+#undef cfg_int_table
+
+#ifdef TOPPERS_LABEL_ASM
+
+/*
+ *  prc_kernel_impl.c
+ */
+#undef _intnest
+#undef _lock_flag
+#undef _saved_ipl
+#undef _prc_initialize
+#undef _prc_terminate
+#undef _x_config_int
+#undef _default_int_handler
+#undef _default_exc_handler
+
+/*
+ *  prc_support.src
+ */
+#undef _dispatch
+#undef _start_dispatch
+#undef _exit_and_dispatch
+#undef _call_exit_kernel
+#undef _start_r
+#undef _interrupt
+#undef _exception
+
+/*
+ *  rx630_kernel_impl.c
+ */
+#undef _ipr_reg_addr
+#undef _ier_reg_addr
+#undef _ir_reg_addr
+#undef _irqcr_reg_addr
+
+/*
+ *  kernel_cfg.c
+ */
+#undef _cfg_int_table
+
+#endif /* TOPPERS_LABEL_ASM */
+
+
+#endif /* TOPPERS_PRC_RENAME_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/rx630.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/rx630.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/rx630.h	(revision 317)
@@ -0,0 +1,1929 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  RX630ã«ä¾å­ããå®ç¾©
+ */
+#ifndef TOPPERS_RX630_H
+#define TOPPERS_RX630_H
+
+#define __evenaccess
+
+/*
+ *  CPUä¾å¤ãã³ãã©çªå·ã®å®ç¾©(åºå®ãã¯ã¿ãã¼ãã«)
+ *
+ *  çªå·ã®ç¯å²ã¯0 - 31
+ */
+#define INT_PRIVILEGED_INSTRUNCTION		20		/* ç¹æ¨©å½ä»¤ä¾å¤ */
+#define INT_UNDEF_INSTRUNCTION			23		/* æªå®ç¾©å½ä»¤ä¾å¤ */
+#define INT_FLOATINGPOINT_INSTRUCTION	25		/* æµ®åå°æ°ç¹ä¾å¤ */
+#define INT_NMI							30		/* ãã³ãã¹ã«ãã«å²ãè¾¼ã¿ */
+#define INT_RESET						31		/* ãªã»ãã */
+
+/*
+ *  å²è¾¼ã¿çªå·ã®å®ç¾©(å¯å¤ãã¯ã¿ãã¼ãã«)
+ */
+#define INT_BUSERR			16
+#define INT_FCU_FCUERR		21
+#define INT_FCU_FRDYI		23
+#define INT_ICU_SWINT		27
+#define INT_CMT0_CMI		28
+#define INT_CMT1_CMI		29
+#define INT_CMT2_CMI		30
+#define INT_CMT3_CMI		31
+#define INT_ETH_EINT		32
+#define INT_USB0_D0FIFO0	33
+#define INT_USB0_D1FIFO0	34
+#define INT_USB0_USBI0		35
+#define INT_USB1_D0FIFO1	36
+#define INT_USB1_D1FIFO1	37
+#define INT_USB1_USBI1		38
+#define INT_RSPI0_SPRI0		39
+#define INT_RSPI0_SPTI0		40
+#define INT_RSPI0_SPII0		41
+#define INT_RSPI1_SPRI1		42
+#define INT_RSPI1_SPTI1		43
+#define INT_RSPI1_SPII1		44
+#define INT_RSPI2_SPRI2		45
+#define INT_RSPI2_SPTI2		46
+#define INT_RSPI2_SPII2		47
+#define INT_CAN0_RXF0		48
+#define INT_CAN0_TXF0		49
+#define INT_CAN0_RXM0		50
+#define INT_CAN0_TXM0		51
+#define INT_CAN1_RXF1		52
+#define INT_CAN1_TXF1		53
+#define INT_CAN1_RXM1		54
+#define INT_CAN1_TXM1		55
+#define INT_CAN2_RXF2		56
+#define INT_CAN2_TXF2		57
+#define INT_CAN2_RXM2		58
+#define INT_CAN2_TXM2		59
+#define INT_RTC_CUP			62
+#define INT_IRQ0			64
+#define INT_IRQ1			65
+#define INT_IRQ2			66
+#define INT_IRQ3			67
+#define INT_IRQ4			68
+#define INT_IRQ5			69
+#define INT_IRQ6			70
+#define INT_IRQ7			71
+#define INT_IRQ8			72
+#define INT_IRQ9			73
+#define INT_IRQ10			74
+#define INT_IRQ11			75
+#define INT_IRQ12			76
+#define INT_IRQ13			77
+#define INT_IRQ14			78
+#define INT_IRQ15			79
+#define INT_USB_USBR0		90
+#define INT_USB_USBR1		91
+#define INT_RTC_ALM			92
+#define INT_RTC_PRD			93
+#define INT_AD0_ADI0		98
+#define INT_S12AD_S12ADI0	102
+#define INT_ICU_GROUP0		106
+#define INT_ICU_GROUP1		107
+#define INT_ICU_GROUP2		108
+#define INT_ICU_GROUP3		109
+#define INT_ICU_GROUP4		110
+#define INT_ICU_GROUP5		111
+#define INT_ICU_GROUP6		112
+#define INT_ICU_GROUP12		114
+#define INT_SCI12_SCIX0		122
+#define INT_SCI12_SCIX1		123
+#define INT_SCI12_SCIX2		124
+#define INT_SCI12_SCIX3		125
+#define INT_TPU0_TGI0A		126
+#define INT_TPU0_TGI0B		127
+#define INT_TPU0_TGI0C		128
+#define INT_TPU0_TGI0D		129
+#define INT_TPU1_TGI0A		130
+#define INT_TPU1_TGI0B		131
+#define INT_TPU2_TGI0A		132
+#define INT_TPU2_TGI0B		133
+#define INT_TPU3_TGI0A		134
+#define INT_TPU3_TGI0B		135
+#define INT_TPU3_TGI0C		136
+#define INT_TPU3_TGI0D		137
+#define INT_TPU4_TGI0A		138
+#define INT_TPU4_TGI0B		139
+#define INT_TPU5_TGI0A		140
+#define INT_TPU5_TGI0B		141
+#define INT_MTU0_TGIA0		142
+#define INT_MTU0_TGIB0		143
+#define INT_MTU0_TGIC0		144
+#define INT_MTU0_TGID0		145
+#define INT_MTU0_TCIE0		146
+#define INT_MTU0_TCIF0		147
+#define INT_MTU1_TGIA1		148
+#define INT_MTU1_TGIB1		149
+#define INT_MTU2_TGIA2		150
+#define INT_MTU2_TGIB2		151
+#define INT_MTU3_TGIA3		152
+#define INT_MTU3_TGIB3		153
+#define INT_MTU3_TGIC3		154
+#define INT_MTU3_TGID3		155
+#define INT_MTU4_TGIA4		156
+#define INT_MTU4_TGIB4		157
+#define INT_MTU4_TGIC4		158
+#define INT_MTU4_TGID4		159
+#define INT_MTU4_TCIV4		160
+#define INT_MTU5_TGIU5		161
+#define INT_MTU5_TGIV5		162
+#define INT_MTU5_TGIW5		163
+#define INT_MTU5_TGI11A		164
+#define INT_MTU5_TGI11B		165
+#define INT_POE_OEI1		166
+#define INT_POE_OEI2		167
+#define INT_TMR0_CMI0A		170
+#define INT_TMR0_CMI0B		171
+#define INT_TMR0_OV0I		172
+#define INT_TMR1_CMI1A		173
+#define INT_TMR1_CMI1B		174
+#define INT_TMR1_OV1I		175
+#define INT_TMR2_CMI2A		176
+#define INT_TMR2_CMI2B		177
+#define INT_TMR2_OV2I		178
+#define INT_TMR3_CMI3A		179
+#define INT_TMR3_CMI3B		180
+#define INT_TMR3_OV3I		181
+#define INT_RIIC0_EEI		182
+#define INT_RIIC0_RXI		183
+#define INT_RIIC0_TXI		184
+#define INT_RIIC0_TEI		185
+#define INT_RIIC1_EEI		186
+#define INT_RIIC1_RXI		187
+#define INT_RIIC1_TXI		188
+#define INT_RIIC1_TEI		189
+#define INT_RIIC2_EEI		190
+#define INT_RIIC2_RXI		191
+#define INT_RIIC2_TXI		192
+#define INT_RIIC2_TEI		193
+#define INT_RIIC3_EEI		194
+#define INT_RIIC3_RXI		195
+#define INT_RIIC3_TXI		196
+#define INT_RIIC3_TEI		197
+#define INT_DMAC_DMAC0I		198
+#define INT_DMAC_DMAC1I		199
+#define INT_DMAC_DMAC2I		200
+#define INT_DMAC_DMAC3I		201
+#define INT_SCI0_RXI		214
+#define INT_SCI0_TXI		215
+#define INT_SCI0_TEI		216
+#define INT_SCI1_RXI		217
+#define INT_SCI1_TXI		218
+#define INT_SCI1_TEI		219
+#define INT_SCI2_RXI		220
+#define INT_SCI2_TXI		221
+#define INT_SCI2_TEI		222
+#define INT_SCI3_RXI		223
+#define INT_SCI3_TXI		224
+#define INT_SCI3_TEI		225
+#define INT_SCI4_RXI		226
+#define INT_SCI4_TXI		227
+#define INT_SCI4_TEI		228
+#define INT_SCI5_RXI		229
+#define INT_SCI5_TXI		230
+#define INT_SCI5_TEI		231
+#define INT_SCI6_RXI		232
+#define INT_SCI6_TXI		233
+#define INT_SCI6_TEI		234
+#define INT_SCI7_RXI		235
+#define INT_SCI7_TXI		236
+#define INT_SCI7_TEI		237
+#define INT_SCI8_RXI		238
+#define INT_SCI8_TXI		239
+#define INT_SCI8_TEI		240
+#define INT_SCI9_RXI		241
+#define INT_SCI9_TXI		242
+#define INT_SCI9_TEI		243
+#define INT_SCI10_RXI		244
+#define INT_SCI10_TXI		245
+#define INT_SCI10_TEI		246
+#define INT_SCI11_RXI		247
+#define INT_SCI11_TXI		248
+#define INT_SCI11_TEI		249
+#define INT_SCI12_RXI		250
+#define INT_SCI12_TXI		251
+#define INT_SCI12_TEI		252
+#define INT_IEB_IEBINT		253
+
+/*
+ *  åã¢ã¸ã¥ã¼ã«ã®ã¬ã¸ã¹ã¿åã³è¨­å®ãããæ
+å ±
+ */
+
+#define SYSTEM_SYSCR0_ADDR		( ( volatile uint16_t __evenaccess * )0x00080006 )
+
+/*
+ * ã¢ã¸ã¥ã¼ã«ã¹ãããã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿Aï¼MSTPCRAï¼
+ */
+#define SYSTEM_MSTPCRA_ADDR			( ( volatile uint32_t __evenaccess * )0x00080010 )
+#define SYSTEM_MSTPCRA_MSTPA0_BIT	( 1UL << 0U )
+#define SYSTEM_MSTPCRA_MSTPA1_BIT	( 1UL << 1U )
+#define SYSTEM_MSTPCRA_MSTPA2_BIT	( 1UL << 2U )
+#define SYSTEM_MSTPCRA_MSTPA3_BIT	( 1UL << 3U )
+#define SYSTEM_MSTPCRA_MSTPA4_BIT	( 1UL << 4U )
+#define SYSTEM_MSTPCRA_MSTPA5_BIT	( 1UL << 5U )
+#define SYSTEM_MSTPCRA_MSTPA6_BIT	( 1UL << 6U )
+#define SYSTEM_MSTPCRA_MSTPA7_BIT	( 1UL << 7U )
+#define SYSTEM_MSTPCRA_MSTPA8_BIT	( 1UL << 8U )
+#define SYSTEM_MSTPCRA_MSTPA9_BIT	( 1UL << 9U )
+#define SYSTEM_MSTPCRA_MSTPA10_BIT	( 1UL << 10U )
+#define SYSTEM_MSTPCRA_MSTPA11_BIT	( 1UL << 11U )
+#define SYSTEM_MSTPCRA_MSTPA12_BIT	( 1UL << 12U )
+#define SYSTEM_MSTPCRA_MSTPA13_BIT	( 1UL << 13U )
+#define SYSTEM_MSTPCRA_MSTPA14_BIT	( 1UL << 14U )
+#define SYSTEM_MSTPCRA_MSTPA15_BIT	( 1UL << 15U )
+#define SYSTEM_MSTPCRA_MSTPA16_BIT	( 1UL << 16U )
+#define SYSTEM_MSTPCRA_MSTPA17_BIT	( 1UL << 17U )
+#define SYSTEM_MSTPCRA_MSTPA18_BIT	( 1UL << 18U )
+#define SYSTEM_MSTPCRA_MSTPA19_BIT	( 1UL << 19U )
+#define SYSTEM_MSTPCRA_MSTPA20_BIT	( 1UL << 20U )
+#define SYSTEM_MSTPCRA_MSTPA21_BIT	( 1UL << 21U )
+#define SYSTEM_MSTPCRA_MSTPA22_BIT	( 1UL << 22U )
+#define SYSTEM_MSTPCRA_MSTPA23_BIT	( 1UL << 23U )
+#define SYSTEM_MSTPCRA_MSTPA24_BIT	( 1UL << 24U )
+#define SYSTEM_MSTPCRA_MSTPA25_BIT	( 1UL << 25U )
+#define SYSTEM_MSTPCRA_MSTPA26_BIT	( 1UL << 26U )
+#define SYSTEM_MSTPCRA_MSTPA27_BIT	( 1UL << 27U )
+#define SYSTEM_MSTPCRA_MSTPA28_BIT	( 1UL << 28U )
+#define SYSTEM_MSTPCRA_MSTPA29_BIT	( 1UL << 29U )
+#define SYSTEM_MSTPCRA_MSTPA30_BIT	( 1UL << 30U )
+#define SYSTEM_MSTPCRA_MSTPA31_BIT	( 1UL << 31U )
+#define SYSTEM_MSTPCRA_ACSE_BIT		( 1UL << 31U)
+
+/*
+ * ã¢ã¸ã¥ã¼ã«ã¹ãããã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿Bï¼MSTPCRBï¼
+ */
+#define SYSTEM_MSTPCRB_ADDR			( ( volatile uint32_t __evenaccess * )0x00080014 )
+#define SYSTEM_MSTPCRB_MSTPB0_BIT	( 1UL << 0U )
+#define SYSTEM_MSTPCRB_MSTPB1_BIT	( 1UL << 1U )
+#define SYSTEM_MSTPCRB_MSTPB2_BIT	( 1UL << 2U )
+#define SYSTEM_MSTPCRB_MSTPB3_BIT	( 1UL << 3U )
+#define SYSTEM_MSTPCRB_MSTPB4_BIT	( 1UL << 4U )
+#define SYSTEM_MSTPCRB_MSTPB5_BIT	( 1UL << 5U )
+#define SYSTEM_MSTPCRB_MSTPB6_BIT	( 1UL << 6U )
+#define SYSTEM_MSTPCRB_MSTPB7_BIT	( 1UL << 7U )
+#define SYSTEM_MSTPCRB_MSTPB8_BIT	( 1UL << 8U )
+#define SYSTEM_MSTPCRB_MSTPB9_BIT	( 1UL << 9U )
+#define SYSTEM_MSTPCRB_MSTPB10_BIT	( 1UL << 10U )
+#define SYSTEM_MSTPCRB_MSTPB11_BIT	( 1UL << 11U )
+#define SYSTEM_MSTPCRB_MSTPB12_BIT	( 1UL << 12U )
+#define SYSTEM_MSTPCRB_MSTPB13_BIT	( 1UL << 13U )
+#define SYSTEM_MSTPCRB_MSTPB14_BIT	( 1UL << 14U )
+#define SYSTEM_MSTPCRB_MSTPB15_BIT	( 1UL << 15U )
+#define SYSTEM_MSTPCRB_MSTPB16_BIT	( 1UL << 16U )
+#define SYSTEM_MSTPCRB_MSTPB17_BIT	( 1UL << 17U )
+#define SYSTEM_MSTPCRB_MSTPB18_BIT	( 1UL << 18U )
+#define SYSTEM_MSTPCRB_MSTPB19_BIT	( 1UL << 19U )
+#define SYSTEM_MSTPCRB_MSTPB20_BIT	( 1UL << 20U )
+#define SYSTEM_MSTPCRB_MSTPB21_BIT	( 1UL << 21U )
+#define SYSTEM_MSTPCRB_MSTPB22_BIT	( 1UL << 22U )
+#define SYSTEM_MSTPCRB_MSTPB23_BIT	( 1UL << 23U )
+#define SYSTEM_MSTPCRB_MSTPB24_BIT	( 1UL << 24U )
+#define SYSTEM_MSTPCRB_MSTPB25_BIT	( 1UL << 25U )
+#define SYSTEM_MSTPCRB_MSTPB26_BIT	( 1UL << 26U )
+#define SYSTEM_MSTPCRB_MSTPB27_BIT	( 1UL << 27U )
+#define SYSTEM_MSTPCRB_MSTPB28_BIT	( 1UL << 28U )
+#define SYSTEM_MSTPCRB_MSTPB29_BIT	( 1UL << 29U )
+#define SYSTEM_MSTPCRB_MSTPB30_BIT	( 1UL << 30U )
+#define SYSTEM_MSTPCRB_MSTPB31_BIT	( 1UL << 31U )
+
+/*
+ * ã¢ã¸ã¥ã¼ã«ã¹ãããã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿Cï¼MSTPCRCï¼
+ */
+#define SYSTEM_MSTPCRC_ADDR			( ( volatile uint32_t __evenaccess * )0x00080018 )
+#define SYSTEM_MSTPCRC_MSTPC0_BIT	( 1UL << 0U )
+#define SYSTEM_MSTPCRC_MSTPC1_BIT	( 1UL << 1U )
+#define SYSTEM_MSTPCRC_MSTPC2_BIT	( 1UL << 2U )
+#define SYSTEM_MSTPCRC_MSTPC3_BIT	( 1UL << 3U )
+#define SYSTEM_MSTPCRC_MSTPC4_BIT	( 1UL << 4U )
+#define SYSTEM_MSTPCRC_MSTPC5_BIT	( 1UL << 5U )
+#define SYSTEM_MSTPCRC_MSTPC6_BIT	( 1UL << 6U )
+#define SYSTEM_MSTPCRC_MSTPC7_BIT	( 1UL << 7U )
+#define SYSTEM_MSTPCRC_MSTPC8_BIT	( 1UL << 8U )
+#define SYSTEM_MSTPCRC_MSTPC9_BIT	( 1UL << 9U )
+#define SYSTEM_MSTPCRC_MSTPC10_BIT	( 1UL << 10U )
+#define SYSTEM_MSTPCRC_MSTPC11_BIT	( 1UL << 11U )
+#define SYSTEM_MSTPCRC_MSTPC12_BIT	( 1UL << 12U )
+#define SYSTEM_MSTPCRC_MSTPC13_BIT	( 1UL << 13U )
+#define SYSTEM_MSTPCRC_MSTPC14_BIT	( 1UL << 14U )
+#define SYSTEM_MSTPCRC_MSTPC15_BIT	( 1UL << 15U )
+#define SYSTEM_MSTPCRC_MSTPC16_BIT	( 1UL << 16U )
+#define SYSTEM_MSTPCRC_MSTPC17_BIT	( 1UL << 17U )
+#define SYSTEM_MSTPCRC_MSTPC18_BIT	( 1UL << 18U )
+#define SYSTEM_MSTPCRC_MSTPC19_BIT	( 1UL << 19U )
+#define SYSTEM_MSTPCRC_MSTPC20_BIT	( 1UL << 20U )
+#define SYSTEM_MSTPCRC_MSTPC21_BIT	( 1UL << 21U )
+#define SYSTEM_MSTPCRC_MSTPC22_BIT	( 1UL << 22U )
+#define SYSTEM_MSTPCRC_MSTPC23_BIT	( 1UL << 23U )
+#define SYSTEM_MSTPCRC_MSTPC24_BIT	( 1UL << 24U )
+#define SYSTEM_MSTPCRC_MSTPC25_BIT	( 1UL << 25U )
+#define SYSTEM_MSTPCRC_MSTPC26_BIT	( 1UL << 26U )
+#define SYSTEM_MSTPCRC_MSTPC27_BIT	( 1UL << 27U )
+#define SYSTEM_MSTPCRC_MSTPC28_BIT	( 1UL << 28U )
+#define SYSTEM_MSTPCRC_MSTPC29_BIT	( 1UL << 29U )
+#define SYSTEM_MSTPCRC_MSTPC30_BIT	( 1UL << 30U )
+#define SYSTEM_MSTPCRC_MSTPC31_BIT	( 1UL << 31U )
+
+/*
+ * ã¯ã­ãã¯çºçåè·¯
+ */
+#define SYSTEM_SCKCR_ADDR			( ( volatile uint32_t __evenaccess * )0x00080020 )
+#define SYSTEM_SCKCR2_ADDR		( ( volatile uint16_t __evenaccess * )0x00080024 )
+#define SYSTEM_SCKCR2_UCK_OFFSET	( 4U )
+#define SYSTEM_SCKCR2_UCK_MASK		( 0xFU << SYSTEM_SCKCR2_UCK_OFFSET )
+#define SYSTEM_SCKCR3_ADDR		( ( volatile uint16_t __evenaccess * )0x00080026 )
+#define SYSTEM_SCKCR3_CKSEL_OFFSET	( 8U )
+#define SYSTEM_SCKCR3_CKSEL_MASK	( 0x7U << SYSTEM_SCKCR3_CKSEL_OFFSET )
+#define SYSTEM_PLLCR_ADDR		( ( volatile uint16_t __evenaccess * )0x00080028 )
+#define SYSTEM_PLLCR_STC_OFFSET		( 8U )
+#define SYSTEM_PLLCR_STC_MASK		( 0x3FU << SYSTEM_PLLCR_STC_OFFSET )
+#define SYSTEM_PLLCR2_ADDR			( ( volatile uint8_t __evenaccess * )0x0008002A )
+#define SYSTEM_PLLCR2_PLLEN			( 1UL << 0U )
+#define SYSTEM_MOFCR_ADDR		( ( volatile uint8_t __evenaccess * )0x0008C293 )
+#define SYSTEM_MOFCR_MOFXIN		( 1UL << 0U )
+#define SYSTEM_MOSCCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00080032 )
+#define SYSTEM_MOSCCR_MOSTP			( 1UL << 0U )
+
+/*
+ * ãã­ãã¯ãã¬ã¸ã¹ã¿
+ */
+#define SYSTEM_PRCR_ADDR		( ( volatile uint16_t __evenaccess * )0x000803FE )
+
+/*
+ * å²ãè¾¼ã¿è¦æ±ã¬ã¸ã¹ã¿
+ */
+#define ICU_IR000_ADDR			( ( volatile uint8_t __evenaccess * )0x00087000 )
+#define ICU_IR001_ADDR			( ( volatile uint8_t __evenaccess * )0x00087001 )
+#define ICU_IR002_ADDR			( ( volatile uint8_t __evenaccess * )0x00087002 )
+#define ICU_IR003_ADDR			( ( volatile uint8_t __evenaccess * )0x00087003 )
+#define ICU_IR004_ADDR			( ( volatile uint8_t __evenaccess * )0x00087004 )
+#define ICU_IR005_ADDR			( ( volatile uint8_t __evenaccess * )0x00087005 )
+#define ICU_IR006_ADDR			( ( volatile uint8_t __evenaccess * )0x00087006 )
+#define ICU_IR007_ADDR			( ( volatile uint8_t __evenaccess * )0x00087007 )
+#define ICU_IR008_ADDR			( ( volatile uint8_t __evenaccess * )0x00087008 )
+#define ICU_IR009_ADDR			( ( volatile uint8_t __evenaccess * )0x00087009 )
+#define ICU_IR010_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700A )
+#define ICU_IR011_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700B )
+#define ICU_IR012_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700C )
+#define ICU_IR013_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700D )
+#define ICU_IR014_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700E )
+#define ICU_IR015_ADDR			( ( volatile uint8_t __evenaccess * )0x0008700F )
+#define ICU_IR016_ADDR			( ( volatile uint8_t __evenaccess * )0x00087010 )
+#define ICU_IR017_ADDR			( ( volatile uint8_t __evenaccess * )0x00087011 )
+#define ICU_IR018_ADDR			( ( volatile uint8_t __evenaccess * )0x00087012 )
+#define ICU_IR019_ADDR			( ( volatile uint8_t __evenaccess * )0x00087013 )
+#define ICU_IR020_ADDR			( ( volatile uint8_t __evenaccess * )0x00087014 )
+#define ICU_IR021_ADDR			( ( volatile uint8_t __evenaccess * )0x00087015 )
+#define ICU_IR022_ADDR			( ( volatile uint8_t __evenaccess * )0x00087016 )
+#define ICU_IR023_ADDR			( ( volatile uint8_t __evenaccess * )0x00087017 )
+#define ICU_IR024_ADDR			( ( volatile uint8_t __evenaccess * )0x00087018 )
+#define ICU_IR025_ADDR			( ( volatile uint8_t __evenaccess * )0x00087019 )
+#define ICU_IR026_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701A )
+#define ICU_IR027_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701B )
+#define ICU_IR028_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701C )
+#define ICU_IR029_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701D )
+#define ICU_IR030_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701E )
+#define ICU_IR031_ADDR			( ( volatile uint8_t __evenaccess * )0x0008701F )
+#define ICU_IR032_ADDR			( ( volatile uint8_t __evenaccess * )0x00087020 )
+#define ICU_IR033_ADDR			( ( volatile uint8_t __evenaccess * )0x00087021 )
+#define ICU_IR034_ADDR			( ( volatile uint8_t __evenaccess * )0x00087022 )
+#define ICU_IR035_ADDR			( ( volatile uint8_t __evenaccess * )0x00087023 )
+#define ICU_IR036_ADDR			( ( volatile uint8_t __evenaccess * )0x00087024 )
+#define ICU_IR037_ADDR			( ( volatile uint8_t __evenaccess * )0x00087025 )
+#define ICU_IR038_ADDR			( ( volatile uint8_t __evenaccess * )0x00087026 )
+#define ICU_IR039_ADDR			( ( volatile uint8_t __evenaccess * )0x00087027 )
+#define ICU_IR040_ADDR			( ( volatile uint8_t __evenaccess * )0x00087028 )
+#define ICU_IR041_ADDR			( ( volatile uint8_t __evenaccess * )0x00087029 )
+#define ICU_IR042_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702A )
+#define ICU_IR043_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702B )
+#define ICU_IR044_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702C )
+#define ICU_IR045_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702D )
+#define ICU_IR046_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702E )
+#define ICU_IR047_ADDR			( ( volatile uint8_t __evenaccess * )0x0008702F )
+#define ICU_IR048_ADDR			( ( volatile uint8_t __evenaccess * )0x00087030 )
+#define ICU_IR049_ADDR			( ( volatile uint8_t __evenaccess * )0x00087031 )
+#define ICU_IR050_ADDR			( ( volatile uint8_t __evenaccess * )0x00087032 )
+#define ICU_IR051_ADDR			( ( volatile uint8_t __evenaccess * )0x00087033 )
+#define ICU_IR052_ADDR			( ( volatile uint8_t __evenaccess * )0x00087034 )
+#define ICU_IR053_ADDR			( ( volatile uint8_t __evenaccess * )0x00087035 )
+#define ICU_IR054_ADDR			( ( volatile uint8_t __evenaccess * )0x00087036 )
+#define ICU_IR055_ADDR			( ( volatile uint8_t __evenaccess * )0x00087037 )
+#define ICU_IR056_ADDR			( ( volatile uint8_t __evenaccess * )0x00087038 )
+#define ICU_IR057_ADDR			( ( volatile uint8_t __evenaccess * )0x00087039 )
+#define ICU_IR058_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703A )
+#define ICU_IR059_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703B )
+#define ICU_IR060_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703C )
+#define ICU_IR061_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703D )
+#define ICU_IR062_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703E )
+#define ICU_IR063_ADDR			( ( volatile uint8_t __evenaccess * )0x0008703F )
+#define ICU_IR064_ADDR			( ( volatile uint8_t __evenaccess * )0x00087040 )
+#define ICU_IR065_ADDR			( ( volatile uint8_t __evenaccess * )0x00087041 )
+#define ICU_IR066_ADDR			( ( volatile uint8_t __evenaccess * )0x00087042 )
+#define ICU_IR067_ADDR			( ( volatile uint8_t __evenaccess * )0x00087043 )
+#define ICU_IR068_ADDR			( ( volatile uint8_t __evenaccess * )0x00087044 )
+#define ICU_IR069_ADDR			( ( volatile uint8_t __evenaccess * )0x00087045 )
+#define ICU_IR070_ADDR			( ( volatile uint8_t __evenaccess * )0x00087046 )
+#define ICU_IR071_ADDR			( ( volatile uint8_t __evenaccess * )0x00087047 )
+#define ICU_IR072_ADDR			( ( volatile uint8_t __evenaccess * )0x00087048 )
+#define ICU_IR073_ADDR			( ( volatile uint8_t __evenaccess * )0x00087049 )
+#define ICU_IR074_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704A )
+#define ICU_IR075_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704B )
+#define ICU_IR076_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704C )
+#define ICU_IR077_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704D )
+#define ICU_IR078_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704E )
+#define ICU_IR079_ADDR			( ( volatile uint8_t __evenaccess * )0x0008704F )
+#define ICU_IR080_ADDR			( ( volatile uint8_t __evenaccess * )0x00087050 )
+#define ICU_IR081_ADDR			( ( volatile uint8_t __evenaccess * )0x00087051 )
+#define ICU_IR082_ADDR			( ( volatile uint8_t __evenaccess * )0x00087052 )
+#define ICU_IR083_ADDR			( ( volatile uint8_t __evenaccess * )0x00087053 )
+#define ICU_IR084_ADDR			( ( volatile uint8_t __evenaccess * )0x00087054 )
+#define ICU_IR085_ADDR			( ( volatile uint8_t __evenaccess * )0x00087055 )
+#define ICU_IR086_ADDR			( ( volatile uint8_t __evenaccess * )0x00087056 )
+#define ICU_IR087_ADDR			( ( volatile uint8_t __evenaccess * )0x00087057 )
+#define ICU_IR088_ADDR			( ( volatile uint8_t __evenaccess * )0x00087058 )
+#define ICU_IR089_ADDR			( ( volatile uint8_t __evenaccess * )0x00087059 )
+#define ICU_IR090_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705A )
+#define ICU_IR091_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705B )
+#define ICU_IR092_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705C )
+#define ICU_IR093_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705D )
+#define ICU_IR094_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705E )
+#define ICU_IR095_ADDR			( ( volatile uint8_t __evenaccess * )0x0008705F )
+#define ICU_IR096_ADDR			( ( volatile uint8_t __evenaccess * )0x00087060 )
+#define ICU_IR097_ADDR			( ( volatile uint8_t __evenaccess * )0x00087061 )
+#define ICU_IR098_ADDR			( ( volatile uint8_t __evenaccess * )0x00087062 )
+#define ICU_IR099_ADDR			( ( volatile uint8_t __evenaccess * )0x00087063 )
+#define ICU_IR100_ADDR			( ( volatile uint8_t __evenaccess * )0x00087064 )
+#define ICU_IR101_ADDR			( ( volatile uint8_t __evenaccess * )0x00087065 )
+#define ICU_IR102_ADDR			( ( volatile uint8_t __evenaccess * )0x00087066 )
+#define ICU_IR103_ADDR			( ( volatile uint8_t __evenaccess * )0x00087067 )
+#define ICU_IR104_ADDR			( ( volatile uint8_t __evenaccess * )0x00087068 )
+#define ICU_IR105_ADDR			( ( volatile uint8_t __evenaccess * )0x00087069 )
+#define ICU_IR106_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706A )
+#define ICU_IR107_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706B )
+#define ICU_IR108_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706C )
+#define ICU_IR109_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706D )
+#define ICU_IR110_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706E )
+#define ICU_IR111_ADDR			( ( volatile uint8_t __evenaccess * )0x0008706F )
+#define ICU_IR112_ADDR			( ( volatile uint8_t __evenaccess * )0x00087070 )
+#define ICU_IR113_ADDR			( ( volatile uint8_t __evenaccess * )0x00087071 )
+#define ICU_IR114_ADDR			( ( volatile uint8_t __evenaccess * )0x00087072 )
+#define ICU_IR115_ADDR			( ( volatile uint8_t __evenaccess * )0x00087073 )
+#define ICU_IR116_ADDR			( ( volatile uint8_t __evenaccess * )0x00087074 )
+#define ICU_IR117_ADDR			( ( volatile uint8_t __evenaccess * )0x00087075 )
+#define ICU_IR118_ADDR			( ( volatile uint8_t __evenaccess * )0x00087076 )
+#define ICU_IR119_ADDR			( ( volatile uint8_t __evenaccess * )0x00087077 )
+#define ICU_IR120_ADDR			( ( volatile uint8_t __evenaccess * )0x00087078 )
+#define ICU_IR121_ADDR			( ( volatile uint8_t __evenaccess * )0x00087079 )
+#define ICU_IR122_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707A )
+#define ICU_IR123_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707B )
+#define ICU_IR124_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707C )
+#define ICU_IR125_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707D )
+#define ICU_IR126_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707E )
+#define ICU_IR127_ADDR			( ( volatile uint8_t __evenaccess * )0x0008707F )
+#define ICU_IR128_ADDR			( ( volatile uint8_t __evenaccess * )0x00087080 )
+#define ICU_IR129_ADDR			( ( volatile uint8_t __evenaccess * )0x00087081 )
+#define ICU_IR130_ADDR			( ( volatile uint8_t __evenaccess * )0x00087082 )
+#define ICU_IR131_ADDR			( ( volatile uint8_t __evenaccess * )0x00087083 )
+#define ICU_IR132_ADDR			( ( volatile uint8_t __evenaccess * )0x00087084 )
+#define ICU_IR133_ADDR			( ( volatile uint8_t __evenaccess * )0x00087085 )
+#define ICU_IR134_ADDR			( ( volatile uint8_t __evenaccess * )0x00087086 )
+#define ICU_IR135_ADDR			( ( volatile uint8_t __evenaccess * )0x00087087 )
+#define ICU_IR136_ADDR			( ( volatile uint8_t __evenaccess * )0x00087088 )
+#define ICU_IR137_ADDR			( ( volatile uint8_t __evenaccess * )0x00087089 )
+#define ICU_IR138_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708A )
+#define ICU_IR139_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708B )
+#define ICU_IR140_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708C )
+#define ICU_IR141_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708D )
+#define ICU_IR142_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708E )
+#define ICU_IR143_ADDR			( ( volatile uint8_t __evenaccess * )0x0008708F )
+#define ICU_IR144_ADDR			( ( volatile uint8_t __evenaccess * )0x00087090 )
+#define ICU_IR145_ADDR			( ( volatile uint8_t __evenaccess * )0x00087091 )
+#define ICU_IR146_ADDR			( ( volatile uint8_t __evenaccess * )0x00087092 )
+#define ICU_IR147_ADDR			( ( volatile uint8_t __evenaccess * )0x00087093 )
+#define ICU_IR148_ADDR			( ( volatile uint8_t __evenaccess * )0x00087094 )
+#define ICU_IR149_ADDR			( ( volatile uint8_t __evenaccess * )0x00087095 )
+#define ICU_IR150_ADDR			( ( volatile uint8_t __evenaccess * )0x00087096 )
+#define ICU_IR151_ADDR			( ( volatile uint8_t __evenaccess * )0x00087097 )
+#define ICU_IR152_ADDR			( ( volatile uint8_t __evenaccess * )0x00087098 )
+#define ICU_IR153_ADDR			( ( volatile uint8_t __evenaccess * )0x00087099 )
+#define ICU_IR154_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709A )
+#define ICU_IR155_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709B )
+#define ICU_IR156_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709C )
+#define ICU_IR157_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709D )
+#define ICU_IR158_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709E )
+#define ICU_IR159_ADDR			( ( volatile uint8_t __evenaccess * )0x0008709F )
+#define ICU_IR160_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A0 )
+#define ICU_IR161_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A1 )
+#define ICU_IR162_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A2 )
+#define ICU_IR163_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A3 )
+#define ICU_IR164_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A4 )
+#define ICU_IR165_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A5 )
+#define ICU_IR166_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A6 )
+#define ICU_IR167_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A7 )
+#define ICU_IR168_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A8 )
+#define ICU_IR169_ADDR			( ( volatile uint8_t __evenaccess * )0x000870A9 )
+#define ICU_IR170_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AA )
+#define ICU_IR171_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AB )
+#define ICU_IR172_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AC )
+#define ICU_IR173_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AD )
+#define ICU_IR174_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AE )
+#define ICU_IR175_ADDR			( ( volatile uint8_t __evenaccess * )0x000870AF )
+#define ICU_IR176_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B0 )
+#define ICU_IR177_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B1 )
+#define ICU_IR178_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B2 )
+#define ICU_IR179_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B3 )
+#define ICU_IR180_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B4 )
+#define ICU_IR181_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B5 )
+#define ICU_IR182_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B6 )
+#define ICU_IR183_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B7 )
+#define ICU_IR184_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B8 )
+#define ICU_IR185_ADDR			( ( volatile uint8_t __evenaccess * )0x000870B9 )
+#define ICU_IR186_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BA )
+#define ICU_IR187_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BB )
+#define ICU_IR188_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BC )
+#define ICU_IR189_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BD )
+#define ICU_IR190_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BE )
+#define ICU_IR191_ADDR			( ( volatile uint8_t __evenaccess * )0x000870BF )
+#define ICU_IR192_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C0 )
+#define ICU_IR193_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C1 )
+#define ICU_IR194_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C2 )
+#define ICU_IR195_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C3 )
+#define ICU_IR196_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C4 )
+#define ICU_IR197_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C5 )
+#define ICU_IR198_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C6 )
+#define ICU_IR199_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C7 )
+#define ICU_IR200_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C8 )
+#define ICU_IR201_ADDR			( ( volatile uint8_t __evenaccess * )0x000870C9 )
+#define ICU_IR202_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CA )
+#define ICU_IR203_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CB )
+#define ICU_IR204_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CC )
+#define ICU_IR205_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CD )
+#define ICU_IR206_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CE )
+#define ICU_IR207_ADDR			( ( volatile uint8_t __evenaccess * )0x000870CF )
+#define ICU_IR208_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D0 )
+#define ICU_IR209_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D1 )
+#define ICU_IR210_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D2 )
+#define ICU_IR211_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D3 )
+#define ICU_IR212_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D4 )
+#define ICU_IR213_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D5 )
+#define ICU_IR214_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D6 )
+#define ICU_IR215_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D7 )
+#define ICU_IR216_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D8 )
+#define ICU_IR217_ADDR			( ( volatile uint8_t __evenaccess * )0x000870D9 )
+#define ICU_IR218_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DA )
+#define ICU_IR219_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DB )
+#define ICU_IR220_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DC )
+#define ICU_IR221_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DD )
+#define ICU_IR222_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DE )
+#define ICU_IR223_ADDR			( ( volatile uint8_t __evenaccess * )0x000870DF )
+#define ICU_IR224_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E0 )
+#define ICU_IR225_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E1 )
+#define ICU_IR226_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E2 )
+#define ICU_IR227_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E3 )
+#define ICU_IR228_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E4 )
+#define ICU_IR229_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E5 )
+#define ICU_IR230_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E6 )
+#define ICU_IR231_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E7 )
+#define ICU_IR232_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E8 )
+#define ICU_IR233_ADDR			( ( volatile uint8_t __evenaccess * )0x000870E9 )
+#define ICU_IR234_ADDR			( ( volatile uint8_t __evenaccess * )0x000870EA )
+#define ICU_IR235_ADDR			( ( volatile uint8_t __evenaccess * )0x000870EB )
+#define ICU_IR236_ADDR			( ( volatile uint8_t __evenaccess * )0x000870EC )
+#define ICU_IR237_ADDR			( ( volatile uint8_t __evenaccess * )0x000870ED )
+#define ICU_IR238_ADDR			( ( volatile uint8_t __evenaccess * )0x000870EE )
+#define ICU_IR239_ADDR			( ( volatile uint8_t __evenaccess * )0x000870EF )
+#define ICU_IR240_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F0 )
+#define ICU_IR241_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F1 )
+#define ICU_IR242_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F2 )
+#define ICU_IR243_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F3 )
+#define ICU_IR244_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F4 )
+#define ICU_IR245_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F5 )
+#define ICU_IR246_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F6 )
+#define ICU_IR247_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F7 )
+#define ICU_IR248_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F8 )
+#define ICU_IR249_ADDR			( ( volatile uint8_t __evenaccess * )0x000870F9 )
+#define ICU_IR250_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FA )
+#define ICU_IR251_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FB )
+#define ICU_IR252_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FC )
+#define ICU_IR253_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FD )
+#define ICU_IR254_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FE )
+#define ICU_IR255_ADDR			( ( volatile uint8_t __evenaccess * )0x000870FF )
+#define ICU_IR_BIT				( 1U << 0U )
+
+/*
+ * å²ãè¾¼ã¿è¦æ±å
+è¨­å®ã¬ã¸ã¹ã¿
+ */
+#define ICU_ISELR000_ADDR		( ( volatile uint8_t __evenaccess * )0x00087100 )
+#define ICU_ISELR001_ADDR		( ( volatile uint8_t __evenaccess * )0x00087101 )
+#define ICU_ISELR002_ADDR		( ( volatile uint8_t __evenaccess * )0x00087102 )
+#define ICU_ISELR003_ADDR		( ( volatile uint8_t __evenaccess * )0x00087103 )
+#define ICU_ISELR004_ADDR		( ( volatile uint8_t __evenaccess * )0x00087104 )
+#define ICU_ISELR005_ADDR		( ( volatile uint8_t __evenaccess * )0x00087105 )
+#define ICU_ISELR006_ADDR		( ( volatile uint8_t __evenaccess * )0x00087106 )
+#define ICU_ISELR007_ADDR		( ( volatile uint8_t __evenaccess * )0x00087107 )
+#define ICU_ISELR008_ADDR		( ( volatile uint8_t __evenaccess * )0x00087108 )
+#define ICU_ISELR009_ADDR		( ( volatile uint8_t __evenaccess * )0x00087109 )
+#define ICU_ISELR010_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710A )
+#define ICU_ISELR011_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710B )
+#define ICU_ISELR012_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710C )
+#define ICU_ISELR013_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710D )
+#define ICU_ISELR014_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710E )
+#define ICU_ISELR015_ADDR		( ( volatile uint8_t __evenaccess * )0x0008710F )
+#define ICU_ISELR016_ADDR		( ( volatile uint8_t __evenaccess * )0x00087110 )
+#define ICU_ISELR017_ADDR		( ( volatile uint8_t __evenaccess * )0x00087111 )
+#define ICU_ISELR018_ADDR		( ( volatile uint8_t __evenaccess * )0x00087112 )
+#define ICU_ISELR019_ADDR		( ( volatile uint8_t __evenaccess * )0x00087113 )
+#define ICU_ISELR020_ADDR		( ( volatile uint8_t __evenaccess * )0x00087114 )
+#define ICU_ISELR021_ADDR		( ( volatile uint8_t __evenaccess * )0x00087115 )
+#define ICU_ISELR022_ADDR		( ( volatile uint8_t __evenaccess * )0x00087116 )
+#define ICU_ISELR023_ADDR		( ( volatile uint8_t __evenaccess * )0x00087117 )
+#define ICU_ISELR024_ADDR		( ( volatile uint8_t __evenaccess * )0x00087118 )
+#define ICU_ISELR025_ADDR		( ( volatile uint8_t __evenaccess * )0x00087119 )
+#define ICU_ISELR026_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711A )
+#define ICU_ISELR027_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711B )
+#define ICU_ISELR028_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711C )
+#define ICU_ISELR029_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711D )
+#define ICU_ISELR030_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711E )
+#define ICU_ISELR031_ADDR		( ( volatile uint8_t __evenaccess * )0x0008711F )
+#define ICU_ISELR032_ADDR		( ( volatile uint8_t __evenaccess * )0x00087120 )
+#define ICU_ISELR033_ADDR		( ( volatile uint8_t __evenaccess * )0x00087121 )
+#define ICU_ISELR034_ADDR		( ( volatile uint8_t __evenaccess * )0x00087122 )
+#define ICU_ISELR035_ADDR		( ( volatile uint8_t __evenaccess * )0x00087123 )
+#define ICU_ISELR036_ADDR		( ( volatile uint8_t __evenaccess * )0x00087124 )
+#define ICU_ISELR037_ADDR		( ( volatile uint8_t __evenaccess * )0x00087125 )
+#define ICU_ISELR038_ADDR		( ( volatile uint8_t __evenaccess * )0x00087126 )
+#define ICU_ISELR039_ADDR		( ( volatile uint8_t __evenaccess * )0x00087127 )
+#define ICU_ISELR040_ADDR		( ( volatile uint8_t __evenaccess * )0x00087128 )
+#define ICU_ISELR041_ADDR		( ( volatile uint8_t __evenaccess * )0x00087129 )
+#define ICU_ISELR042_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712A )
+#define ICU_ISELR043_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712B )
+#define ICU_ISELR044_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712C )
+#define ICU_ISELR045_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712D )
+#define ICU_ISELR046_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712E )
+#define ICU_ISELR047_ADDR		( ( volatile uint8_t __evenaccess * )0x0008712F )
+#define ICU_ISELR048_ADDR		( ( volatile uint8_t __evenaccess * )0x00087130 )
+#define ICU_ISELR049_ADDR		( ( volatile uint8_t __evenaccess * )0x00087131 )
+#define ICU_ISELR050_ADDR		( ( volatile uint8_t __evenaccess * )0x00087132 )
+#define ICU_ISELR051_ADDR		( ( volatile uint8_t __evenaccess * )0x00087133 )
+#define ICU_ISELR052_ADDR		( ( volatile uint8_t __evenaccess * )0x00087134 )
+#define ICU_ISELR053_ADDR		( ( volatile uint8_t __evenaccess * )0x00087135 )
+#define ICU_ISELR054_ADDR		( ( volatile uint8_t __evenaccess * )0x00087136 )
+#define ICU_ISELR055_ADDR		( ( volatile uint8_t __evenaccess * )0x00087137 )
+#define ICU_ISELR056_ADDR		( ( volatile uint8_t __evenaccess * )0x00087138 )
+#define ICU_ISELR057_ADDR		( ( volatile uint8_t __evenaccess * )0x00087139 )
+#define ICU_ISELR058_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713A )
+#define ICU_ISELR059_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713B )
+#define ICU_ISELR060_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713C )
+#define ICU_ISELR061_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713D )
+#define ICU_ISELR062_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713E )
+#define ICU_ISELR063_ADDR		( ( volatile uint8_t __evenaccess * )0x0008713F )
+#define ICU_ISELR064_ADDR		( ( volatile uint8_t __evenaccess * )0x00087140 )
+#define ICU_ISELR065_ADDR		( ( volatile uint8_t __evenaccess * )0x00087141 )
+#define ICU_ISELR066_ADDR		( ( volatile uint8_t __evenaccess * )0x00087142 )
+#define ICU_ISELR067_ADDR		( ( volatile uint8_t __evenaccess * )0x00087143 )
+#define ICU_ISELR068_ADDR		( ( volatile uint8_t __evenaccess * )0x00087144 )
+#define ICU_ISELR069_ADDR		( ( volatile uint8_t __evenaccess * )0x00087145 )
+#define ICU_ISELR070_ADDR		( ( volatile uint8_t __evenaccess * )0x00087146 )
+#define ICU_ISELR071_ADDR		( ( volatile uint8_t __evenaccess * )0x00087147 )
+#define ICU_ISELR072_ADDR		( ( volatile uint8_t __evenaccess * )0x00087148 )
+#define ICU_ISELR073_ADDR		( ( volatile uint8_t __evenaccess * )0x00087149 )
+#define ICU_ISELR074_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714A )
+#define ICU_ISELR075_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714B )
+#define ICU_ISELR076_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714C )
+#define ICU_ISELR077_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714D )
+#define ICU_ISELR078_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714E )
+#define ICU_ISELR079_ADDR		( ( volatile uint8_t __evenaccess * )0x0008714F )
+#define ICU_ISELR080_ADDR		( ( volatile uint8_t __evenaccess * )0x00087150 )
+#define ICU_ISELR081_ADDR		( ( volatile uint8_t __evenaccess * )0x00087151 )
+#define ICU_ISELR082_ADDR		( ( volatile uint8_t __evenaccess * )0x00087152 )
+#define ICU_ISELR083_ADDR		( ( volatile uint8_t __evenaccess * )0x00087153 )
+#define ICU_ISELR084_ADDR		( ( volatile uint8_t __evenaccess * )0x00087154 )
+#define ICU_ISELR085_ADDR		( ( volatile uint8_t __evenaccess * )0x00087155 )
+#define ICU_ISELR086_ADDR		( ( volatile uint8_t __evenaccess * )0x00087156 )
+#define ICU_ISELR087_ADDR		( ( volatile uint8_t __evenaccess * )0x00087157 )
+#define ICU_ISELR088_ADDR		( ( volatile uint8_t __evenaccess * )0x00087158 )
+#define ICU_ISELR089_ADDR		( ( volatile uint8_t __evenaccess * )0x00087159 )
+#define ICU_ISELR090_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715A )
+#define ICU_ISELR091_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715B )
+#define ICU_ISELR092_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715C )
+#define ICU_ISELR093_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715D )
+#define ICU_ISELR094_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715E )
+#define ICU_ISELR095_ADDR		( ( volatile uint8_t __evenaccess * )0x0008715F )
+#define ICU_ISELR096_ADDR		( ( volatile uint8_t __evenaccess * )0x00087160 )
+#define ICU_ISELR097_ADDR		( ( volatile uint8_t __evenaccess * )0x00087161 )
+#define ICU_ISELR098_ADDR		( ( volatile uint8_t __evenaccess * )0x00087162 )
+#define ICU_ISELR099_ADDR		( ( volatile uint8_t __evenaccess * )0x00087163 )
+#define ICU_ISELR100_ADDR		( ( volatile uint8_t __evenaccess * )0x00087164 )
+#define ICU_ISELR101_ADDR		( ( volatile uint8_t __evenaccess * )0x00087165 )
+#define ICU_ISELR102_ADDR		( ( volatile uint8_t __evenaccess * )0x00087166 )
+#define ICU_ISELR103_ADDR		( ( volatile uint8_t __evenaccess * )0x00087167 )
+#define ICU_ISELR104_ADDR		( ( volatile uint8_t __evenaccess * )0x00087168 )
+#define ICU_ISELR105_ADDR		( ( volatile uint8_t __evenaccess * )0x00087169 )
+#define ICU_ISELR106_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716A )
+#define ICU_ISELR107_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716B )
+#define ICU_ISELR108_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716C )
+#define ICU_ISELR109_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716D )
+#define ICU_ISELR110_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716E )
+#define ICU_ISELR111_ADDR		( ( volatile uint8_t __evenaccess * )0x0008716F )
+#define ICU_ISELR112_ADDR		( ( volatile uint8_t __evenaccess * )0x00087170 )
+#define ICU_ISELR113_ADDR		( ( volatile uint8_t __evenaccess * )0x00087171 )
+#define ICU_ISELR114_ADDR		( ( volatile uint8_t __evenaccess * )0x00087172 )
+#define ICU_ISELR115_ADDR		( ( volatile uint8_t __evenaccess * )0x00087173 )
+#define ICU_ISELR116_ADDR		( ( volatile uint8_t __evenaccess * )0x00087174 )
+#define ICU_ISELR117_ADDR		( ( volatile uint8_t __evenaccess * )0x00087175 )
+#define ICU_ISELR118_ADDR		( ( volatile uint8_t __evenaccess * )0x00087176 )
+#define ICU_ISELR119_ADDR		( ( volatile uint8_t __evenaccess * )0x00087177 )
+#define ICU_ISELR120_ADDR		( ( volatile uint8_t __evenaccess * )0x00087178 )
+#define ICU_ISELR121_ADDR		( ( volatile uint8_t __evenaccess * )0x00087179 )
+#define ICU_ISELR122_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717A )
+#define ICU_ISELR123_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717B )
+#define ICU_ISELR124_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717C )
+#define ICU_ISELR125_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717D )
+#define ICU_ISELR126_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717E )
+#define ICU_ISELR127_ADDR		( ( volatile uint8_t __evenaccess * )0x0008717F )
+#define ICU_ISELR128_ADDR		( ( volatile uint8_t __evenaccess * )0x00087180 )
+#define ICU_ISELR129_ADDR		( ( volatile uint8_t __evenaccess * )0x00087181 )
+#define ICU_ISELR130_ADDR		( ( volatile uint8_t __evenaccess * )0x00087182 )
+#define ICU_ISELR131_ADDR		( ( volatile uint8_t __evenaccess * )0x00087183 )
+#define ICU_ISELR132_ADDR		( ( volatile uint8_t __evenaccess * )0x00087184 )
+#define ICU_ISELR133_ADDR		( ( volatile uint8_t __evenaccess * )0x00087185 )
+#define ICU_ISELR134_ADDR		( ( volatile uint8_t __evenaccess * )0x00087186 )
+#define ICU_ISELR135_ADDR		( ( volatile uint8_t __evenaccess * )0x00087187 )
+#define ICU_ISELR136_ADDR		( ( volatile uint8_t __evenaccess * )0x00087188 )
+#define ICU_ISELR137_ADDR		( ( volatile uint8_t __evenaccess * )0x00087189 )
+#define ICU_ISELR138_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718A )
+#define ICU_ISELR139_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718B )
+#define ICU_ISELR140_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718C )
+#define ICU_ISELR141_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718D )
+#define ICU_ISELR142_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718E )
+#define ICU_ISELR143_ADDR		( ( volatile uint8_t __evenaccess * )0x0008718F )
+#define ICU_ISELR144_ADDR		( ( volatile uint8_t __evenaccess * )0x00087190 )
+#define ICU_ISELR145_ADDR		( ( volatile uint8_t __evenaccess * )0x00087191 )
+#define ICU_ISELR146_ADDR		( ( volatile uint8_t __evenaccess * )0x00087192 )
+#define ICU_ISELR147_ADDR		( ( volatile uint8_t __evenaccess * )0x00087193 )
+#define ICU_ISELR148_ADDR		( ( volatile uint8_t __evenaccess * )0x00087194 )
+#define ICU_ISELR149_ADDR		( ( volatile uint8_t __evenaccess * )0x00087195 )
+#define ICU_ISELR150_ADDR		( ( volatile uint8_t __evenaccess * )0x00087196 )
+#define ICU_ISELR151_ADDR		( ( volatile uint8_t __evenaccess * )0x00087197 )
+#define ICU_ISELR152_ADDR		( ( volatile uint8_t __evenaccess * )0x00087198 )
+#define ICU_ISELR153_ADDR		( ( volatile uint8_t __evenaccess * )0x00087199 )
+#define ICU_ISELR154_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719A )
+#define ICU_ISELR155_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719B )
+#define ICU_ISELR156_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719C )
+#define ICU_ISELR157_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719D )
+#define ICU_ISELR158_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719E )
+#define ICU_ISELR159_ADDR		( ( volatile uint8_t __evenaccess * )0x0008719F )
+#define ICU_ISELR160_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A0 )
+#define ICU_ISELR161_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A1 )
+#define ICU_ISELR162_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A2 )
+#define ICU_ISELR163_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A3 )
+#define ICU_ISELR164_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A4 )
+#define ICU_ISELR165_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A5 )
+#define ICU_ISELR166_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A6 )
+#define ICU_ISELR167_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A7 )
+#define ICU_ISELR168_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A8 )
+#define ICU_ISELR169_ADDR		( ( volatile uint8_t __evenaccess * )0x000871A9 )
+#define ICU_ISELR170_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AA )
+#define ICU_ISELR171_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AB )
+#define ICU_ISELR172_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AC )
+#define ICU_ISELR173_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AD )
+#define ICU_ISELR174_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AE )
+#define ICU_ISELR175_ADDR		( ( volatile uint8_t __evenaccess * )0x000871AF )
+#define ICU_ISELR176_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B0 )
+#define ICU_ISELR177_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B1 )
+#define ICU_ISELR178_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B2 )
+#define ICU_ISELR179_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B3 )
+#define ICU_ISELR180_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B4 )
+#define ICU_ISELR181_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B5 )
+#define ICU_ISELR182_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B6 )
+#define ICU_ISELR183_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B7 )
+#define ICU_ISELR184_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B8 )
+#define ICU_ISELR185_ADDR		( ( volatile uint8_t __evenaccess * )0x000871B9 )
+#define ICU_ISELR186_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BA )
+#define ICU_ISELR187_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BB )
+#define ICU_ISELR188_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BC )
+#define ICU_ISELR189_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BD )
+#define ICU_ISELR190_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BE )
+#define ICU_ISELR191_ADDR		( ( volatile uint8_t __evenaccess * )0x000871BF )
+#define ICU_ISELR192_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C0 )
+#define ICU_ISELR193_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C1 )
+#define ICU_ISELR194_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C2 )
+#define ICU_ISELR195_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C3 )
+#define ICU_ISELR196_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C4 )
+#define ICU_ISELR197_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C5 )
+#define ICU_ISELR198_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C6 )
+#define ICU_ISELR199_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C7 )
+#define ICU_ISELR200_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C8 )
+#define ICU_ISELR201_ADDR		( ( volatile uint8_t __evenaccess * )0x000871C9 )
+#define ICU_ISELR202_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CA )
+#define ICU_ISELR203_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CB )
+#define ICU_ISELR204_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CC )
+#define ICU_ISELR205_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CD )
+#define ICU_ISELR206_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CE )
+#define ICU_ISELR207_ADDR		( ( volatile uint8_t __evenaccess * )0x000871CF )
+#define ICU_ISELR208_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D0 )
+#define ICU_ISELR209_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D1 )
+#define ICU_ISELR210_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D2 )
+#define ICU_ISELR211_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D3 )
+#define ICU_ISELR212_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D4 )
+#define ICU_ISELR213_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D5 )
+#define ICU_ISELR214_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D6 )
+#define ICU_ISELR215_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D7 )
+#define ICU_ISELR216_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D8 )
+#define ICU_ISELR217_ADDR		( ( volatile uint8_t __evenaccess * )0x000871D9 )
+#define ICU_ISELR218_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DA )
+#define ICU_ISELR219_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DB )
+#define ICU_ISELR220_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DC )
+#define ICU_ISELR221_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DD )
+#define ICU_ISELR222_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DE )
+#define ICU_ISELR223_ADDR		( ( volatile uint8_t __evenaccess * )0x000871DF )
+#define ICU_ISELR224_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E0 )
+#define ICU_ISELR225_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E1 )
+#define ICU_ISELR226_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E2 )
+#define ICU_ISELR227_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E3 )
+#define ICU_ISELR228_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E4 )
+#define ICU_ISELR229_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E5 )
+#define ICU_ISELR230_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E6 )
+#define ICU_ISELR231_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E7 )
+#define ICU_ISELR232_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E8 )
+#define ICU_ISELR233_ADDR		( ( volatile uint8_t __evenaccess * )0x000871E9 )
+#define ICU_ISELR234_ADDR		( ( volatile uint8_t __evenaccess * )0x000871EA )
+#define ICU_ISELR235_ADDR		( ( volatile uint8_t __evenaccess * )0x000871EB )
+#define ICU_ISELR236_ADDR		( ( volatile uint8_t __evenaccess * )0x000871EC )
+#define ICU_ISELR237_ADDR		( ( volatile uint8_t __evenaccess * )0x000871ED )
+#define ICU_ISELR238_ADDR		( ( volatile uint8_t __evenaccess * )0x000871EE )
+#define ICU_ISELR239_ADDR		( ( volatile uint8_t __evenaccess * )0x000871EF )
+#define ICU_ISELR240_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F0 )
+#define ICU_ISELR241_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F1 )
+#define ICU_ISELR242_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F2 )
+#define ICU_ISELR243_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F3 )
+#define ICU_ISELR244_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F4 )
+#define ICU_ISELR245_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F5 )
+#define ICU_ISELR246_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F6 )
+#define ICU_ISELR247_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F7 )
+#define ICU_ISELR248_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F8 )
+#define ICU_ISELR249_ADDR		( ( volatile uint8_t __evenaccess * )0x000871F9 )
+#define ICU_ISELR250_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FA )
+#define ICU_ISELR251_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FB )
+#define ICU_ISELR252_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FC )
+#define ICU_ISELR253_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FD )
+#define ICU_ISELR254_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FE )
+#define ICU_ISELR255_ADDR		( ( volatile uint8_t __evenaccess * )0x000871FF )
+#define ICU_ISEL_BIT			( 3U << 0U )
+
+/*
+ * å²ãè¾¼ã¿è¦æ±è¨±å¯ã¬ã¸ã¹ã¿
+ */
+#define ICU_IER02_ADDR			( ( volatile uint8_t __evenaccess * )0x00087202 )
+#define ICU_IER03_ADDR			( ( volatile uint8_t __evenaccess * )0x00087203 )
+#define ICU_IER04_ADDR			( ( volatile uint8_t __evenaccess * )0x00087204 )
+#define ICU_IER05_ADDR			( ( volatile uint8_t __evenaccess * )0x00087205 )
+#define ICU_IER06_ADDR			( ( volatile uint8_t __evenaccess * )0x00087206 )
+#define ICU_IER07_ADDR			( ( volatile uint8_t __evenaccess * )0x00087207 )
+#define ICU_IER08_ADDR			( ( volatile uint8_t __evenaccess * )0x00087208 )
+#define ICU_IER09_ADDR			( ( volatile uint8_t __evenaccess * )0x00087209 )
+#define ICU_IER0B_ADDR			( ( volatile uint8_t __evenaccess * )0x0008720B )
+#define ICU_IER0C_ADDR			( ( volatile uint8_t __evenaccess * )0x0008720C )
+#define ICU_IER0D_ADDR			( ( volatile uint8_t __evenaccess * )0x0008720D )
+#define ICU_IER0E_ADDR			( ( volatile uint8_t __evenaccess * )0x0008720E )
+#define ICU_IER0F_ADDR			( ( volatile uint8_t __evenaccess * )0x0008720F )
+#define ICU_IER10_ADDR			( ( volatile uint8_t __evenaccess * )0x00087210 )
+#define ICU_IER11_ADDR			( ( volatile uint8_t __evenaccess * )0x00087211 )
+#define ICU_IER12_ADDR			( ( volatile uint8_t __evenaccess * )0x00087212 )
+#define ICU_IER13_ADDR			( ( volatile uint8_t __evenaccess * )0x00087213 )
+#define ICU_IER14_ADDR			( ( volatile uint8_t __evenaccess * )0x00087214 )
+#define ICU_IER15_ADDR			( ( volatile uint8_t __evenaccess * )0x00087215 )
+#define ICU_IER16_ADDR			( ( volatile uint8_t __evenaccess * )0x00087216 )
+#define ICU_IER17_ADDR			( ( volatile uint8_t __evenaccess * )0x00087217 )
+#define ICU_IER18_ADDR			( ( volatile uint8_t __evenaccess * )0x00087218 )
+#define ICU_IER19_ADDR			( ( volatile uint8_t __evenaccess * )0x00087219 )
+#define ICU_IER1A_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721A )
+#define ICU_IER1B_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721B )
+#define ICU_IER1C_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721C )
+#define ICU_IER1D_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721D )
+#define ICU_IER1E_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721E )
+#define ICU_IER1F_ADDR			( ( volatile uint8_t __evenaccess * )0x0008721F )
+#define ICU_IEN0_BIT			( 1U << 0U )
+#define ICU_IEN1_BIT			( 1U << 1U )
+#define ICU_IEN2_BIT			( 1U << 2U )
+#define ICU_IEN3_BIT			( 1U << 3U )
+#define ICU_IEN4_BIT			( 1U << 4U )
+#define ICU_IEN5_BIT			( 1U << 5U )
+#define ICU_IEN6_BIT			( 1U << 6U )
+#define ICU_IEN7_BIT			( 1U << 7U )
+
+/* 
+ * å²ãè¾¼ã¿è¦å ãã©ã¤ãªãªãã£ã¬ã¸ã¹ã¿i(i=0ï½253)ã®è¨­å®
+ */
+#define ICU_IPR000_ADDR			( ( volatile uint8_t __evenaccess * )0x00087300 )
+#define ICU_IPR001_ADDR			( ( volatile uint8_t __evenaccess * )0x00087301 )
+#define ICU_IPR002_ADDR			( ( volatile uint8_t __evenaccess * )0x00087302 )
+#define ICU_IPR003_ADDR			( ( volatile uint8_t __evenaccess * )0x00087303 )
+#define ICU_IPR004_ADDR			( ( volatile uint8_t __evenaccess * )0x00087304 )
+#define ICU_IPR005_ADDR			( ( volatile uint8_t __evenaccess * )0x00087305 )
+#define ICU_IPR006_ADDR			( ( volatile uint8_t __evenaccess * )0x00087306 )
+#define ICU_IPR007_ADDR			( ( volatile uint8_t __evenaccess * )0x00087307 )
+#define ICU_IPR008_ADDR			( ( volatile uint8_t __evenaccess * )0x00087308 )
+#define ICU_IPR009_ADDR			( ( volatile uint8_t __evenaccess * )0x00087309 )
+#define ICU_IPR010_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730A )
+#define ICU_IPR011_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730B )
+#define ICU_IPR012_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730C )
+#define ICU_IPR013_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730D )
+#define ICU_IPR014_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730E )
+#define ICU_IPR015_ADDR			( ( volatile uint8_t __evenaccess * )0x0008730F )
+#define ICU_IPR016_ADDR			( ( volatile uint8_t __evenaccess * )0x00087310 )
+#define ICU_IPR017_ADDR			( ( volatile uint8_t __evenaccess * )0x00087311 )
+#define ICU_IPR018_ADDR			( ( volatile uint8_t __evenaccess * )0x00087312 )
+#define ICU_IPR019_ADDR			( ( volatile uint8_t __evenaccess * )0x00087313 )
+#define ICU_IPR020_ADDR			( ( volatile uint8_t __evenaccess * )0x00087314 )
+#define ICU_IPR021_ADDR			( ( volatile uint8_t __evenaccess * )0x00087315 )
+#define ICU_IPR022_ADDR			( ( volatile uint8_t __evenaccess * )0x00087316 )
+#define ICU_IPR023_ADDR			( ( volatile uint8_t __evenaccess * )0x00087317 )
+#define ICU_IPR024_ADDR			( ( volatile uint8_t __evenaccess * )0x00087318 )
+#define ICU_IPR025_ADDR			( ( volatile uint8_t __evenaccess * )0x00087319 )
+#define ICU_IPR026_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731A )
+#define ICU_IPR027_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731B )
+#define ICU_IPR028_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731C )
+#define ICU_IPR029_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731D )
+#define ICU_IPR030_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731E )
+#define ICU_IPR031_ADDR			( ( volatile uint8_t __evenaccess * )0x0008731F )
+#define ICU_IPR032_ADDR			( ( volatile uint8_t __evenaccess * )0x00087320 )
+#define ICU_IPR033_ADDR			( ( volatile uint8_t __evenaccess * )0x00087321 )
+#define ICU_IPR034_ADDR			( ( volatile uint8_t __evenaccess * )0x00087322 )
+#define ICU_IPR035_ADDR			( ( volatile uint8_t __evenaccess * )0x00087323 )
+#define ICU_IPR036_ADDR			( ( volatile uint8_t __evenaccess * )0x00087324 )
+#define ICU_IPR037_ADDR			( ( volatile uint8_t __evenaccess * )0x00087325 )
+#define ICU_IPR038_ADDR			( ( volatile uint8_t __evenaccess * )0x00087326 )
+#define ICU_IPR039_ADDR			( ( volatile uint8_t __evenaccess * )0x00087327 )
+#define ICU_IPR040_ADDR			( ( volatile uint8_t __evenaccess * )0x00087328 )
+#define ICU_IPR041_ADDR			( ( volatile uint8_t __evenaccess * )0x00087329 )
+#define ICU_IPR042_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732A )
+#define ICU_IPR043_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732B )
+#define ICU_IPR044_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732C )
+#define ICU_IPR045_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732D )
+#define ICU_IPR046_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732E )
+#define ICU_IPR047_ADDR			( ( volatile uint8_t __evenaccess * )0x0008732F )
+#define ICU_IPR048_ADDR			( ( volatile uint8_t __evenaccess * )0x00087330 )
+#define ICU_IPR049_ADDR			( ( volatile uint8_t __evenaccess * )0x00087331 )
+#define ICU_IPR050_ADDR			( ( volatile uint8_t __evenaccess * )0x00087332 )
+#define ICU_IPR051_ADDR			( ( volatile uint8_t __evenaccess * )0x00087333 )
+#define ICU_IPR052_ADDR			( ( volatile uint8_t __evenaccess * )0x00087334 )
+#define ICU_IPR053_ADDR			( ( volatile uint8_t __evenaccess * )0x00087335 )
+#define ICU_IPR054_ADDR			( ( volatile uint8_t __evenaccess * )0x00087336 )
+#define ICU_IPR055_ADDR			( ( volatile uint8_t __evenaccess * )0x00087337 )
+#define ICU_IPR056_ADDR			( ( volatile uint8_t __evenaccess * )0x00087338 )
+#define ICU_IPR057_ADDR			( ( volatile uint8_t __evenaccess * )0x00087339 )
+#define ICU_IPR058_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733A )
+#define ICU_IPR059_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733B )
+#define ICU_IPR060_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733C )
+#define ICU_IPR061_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733D )
+#define ICU_IPR062_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733E )
+#define ICU_IPR063_ADDR			( ( volatile uint8_t __evenaccess * )0x0008733F )
+#define ICU_IPR064_ADDR			( ( volatile uint8_t __evenaccess * )0x00087340 )
+#define ICU_IPR065_ADDR			( ( volatile uint8_t __evenaccess * )0x00087341 )
+#define ICU_IPR066_ADDR			( ( volatile uint8_t __evenaccess * )0x00087342 )
+#define ICU_IPR067_ADDR			( ( volatile uint8_t __evenaccess * )0x00087343 )
+#define ICU_IPR068_ADDR			( ( volatile uint8_t __evenaccess * )0x00087344 )
+#define ICU_IPR069_ADDR			( ( volatile uint8_t __evenaccess * )0x00087345 )
+#define ICU_IPR070_ADDR			( ( volatile uint8_t __evenaccess * )0x00087346 )
+#define ICU_IPR071_ADDR			( ( volatile uint8_t __evenaccess * )0x00087347 )
+#define ICU_IPR072_ADDR			( ( volatile uint8_t __evenaccess * )0x00087348 )
+#define ICU_IPR073_ADDR			( ( volatile uint8_t __evenaccess * )0x00087349 )
+#define ICU_IPR074_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734A )
+#define ICU_IPR075_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734B )
+#define ICU_IPR076_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734C )
+#define ICU_IPR077_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734D )
+#define ICU_IPR078_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734E )
+#define ICU_IPR079_ADDR			( ( volatile uint8_t __evenaccess * )0x0008734F )
+#define ICU_IPR080_ADDR			( ( volatile uint8_t __evenaccess * )0x00087350 )
+#define ICU_IPR081_ADDR			( ( volatile uint8_t __evenaccess * )0x00087351 )
+#define ICU_IPR082_ADDR			( ( volatile uint8_t __evenaccess * )0x00087352 )
+#define ICU_IPR083_ADDR			( ( volatile uint8_t __evenaccess * )0x00087353 )
+#define ICU_IPR084_ADDR			( ( volatile uint8_t __evenaccess * )0x00087354 )
+#define ICU_IPR085_ADDR			( ( volatile uint8_t __evenaccess * )0x00087355 )
+#define ICU_IPR086_ADDR			( ( volatile uint8_t __evenaccess * )0x00087356 )
+#define ICU_IPR087_ADDR			( ( volatile uint8_t __evenaccess * )0x00087357 )
+#define ICU_IPR088_ADDR			( ( volatile uint8_t __evenaccess * )0x00087358 )
+#define ICU_IPR089_ADDR			( ( volatile uint8_t __evenaccess * )0x00087359 )
+#define ICU_IPR090_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735A )
+#define ICU_IPR091_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735B )
+#define ICU_IPR092_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735C )
+#define ICU_IPR093_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735D )
+#define ICU_IPR094_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735E )
+#define ICU_IPR095_ADDR			( ( volatile uint8_t __evenaccess * )0x0008735F )
+#define ICU_IPR096_ADDR			( ( volatile uint8_t __evenaccess * )0x00087360 )
+#define ICU_IPR097_ADDR			( ( volatile uint8_t __evenaccess * )0x00087361 )
+#define ICU_IPR098_ADDR			( ( volatile uint8_t __evenaccess * )0x00087362 )
+#define ICU_IPR099_ADDR			( ( volatile uint8_t __evenaccess * )0x00087363 )
+#define ICU_IPR100_ADDR			( ( volatile uint8_t __evenaccess * )0x00087364 )
+#define ICU_IPR101_ADDR			( ( volatile uint8_t __evenaccess * )0x00087365 )
+#define ICU_IPR102_ADDR			( ( volatile uint8_t __evenaccess * )0x00087366 )
+#define ICU_IPR103_ADDR			( ( volatile uint8_t __evenaccess * )0x00087367 )
+#define ICU_IPR104_ADDR			( ( volatile uint8_t __evenaccess * )0x00087368 )
+#define ICU_IPR105_ADDR			( ( volatile uint8_t __evenaccess * )0x00087369 )
+#define ICU_IPR106_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736A )
+#define ICU_IPR107_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736B )
+#define ICU_IPR108_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736C )
+#define ICU_IPR109_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736D )
+#define ICU_IPR110_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736E )
+#define ICU_IPR111_ADDR			( ( volatile uint8_t __evenaccess * )0x0008736F )
+#define ICU_IPR112_ADDR			( ( volatile uint8_t __evenaccess * )0x00087370 )
+#define ICU_IPR113_ADDR			( ( volatile uint8_t __evenaccess * )0x00087371 )
+#define ICU_IPR114_ADDR			( ( volatile uint8_t __evenaccess * )0x00087372 )
+#define ICU_IPR115_ADDR			( ( volatile uint8_t __evenaccess * )0x00087373 )
+#define ICU_IPR116_ADDR			( ( volatile uint8_t __evenaccess * )0x00087374 )
+#define ICU_IPR117_ADDR			( ( volatile uint8_t __evenaccess * )0x00087375 )
+#define ICU_IPR118_ADDR			( ( volatile uint8_t __evenaccess * )0x00087376 )
+#define ICU_IPR119_ADDR			( ( volatile uint8_t __evenaccess * )0x00087377 )
+#define ICU_IPR120_ADDR			( ( volatile uint8_t __evenaccess * )0x00087378 )
+#define ICU_IPR121_ADDR			( ( volatile uint8_t __evenaccess * )0x00087379 )
+#define ICU_IPR122_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737A )
+#define ICU_IPR123_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737B )
+#define ICU_IPR124_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737C )
+#define ICU_IPR125_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737D )
+#define ICU_IPR126_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737E )
+#define ICU_IPR127_ADDR			( ( volatile uint8_t __evenaccess * )0x0008737F )
+#define ICU_IPR128_ADDR			( ( volatile uint8_t __evenaccess * )0x00087380 )
+#define ICU_IPR129_ADDR			( ( volatile uint8_t __evenaccess * )0x00087381 )
+#define ICU_IPR130_ADDR			( ( volatile uint8_t __evenaccess * )0x00087382 )
+#define ICU_IPR131_ADDR			( ( volatile uint8_t __evenaccess * )0x00087383 )
+#define ICU_IPR132_ADDR			( ( volatile uint8_t __evenaccess * )0x00087384 )
+#define ICU_IPR133_ADDR			( ( volatile uint8_t __evenaccess * )0x00087385 )
+#define ICU_IPR134_ADDR			( ( volatile uint8_t __evenaccess * )0x00087386 )
+#define ICU_IPR135_ADDR			( ( volatile uint8_t __evenaccess * )0x00087387 )
+#define ICU_IPR136_ADDR			( ( volatile uint8_t __evenaccess * )0x00087388 )
+#define ICU_IPR137_ADDR			( ( volatile uint8_t __evenaccess * )0x00087389 )
+#define ICU_IPR138_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738A )
+#define ICU_IPR139_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738B )
+#define ICU_IPR140_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738C )
+#define ICU_IPR141_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738D )
+#define ICU_IPR142_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738E )
+#define ICU_IPR143_ADDR			( ( volatile uint8_t __evenaccess * )0x0008738F )
+#define ICU_IPR144_ADDR			( ( volatile uint8_t __evenaccess * )0x00087390 )
+#define ICU_IPR145_ADDR			( ( volatile uint8_t __evenaccess * )0x00087391 )
+#define ICU_IPR146_ADDR			( ( volatile uint8_t __evenaccess * )0x00087392 )
+#define ICU_IPR147_ADDR			( ( volatile uint8_t __evenaccess * )0x00087393 )
+#define ICU_IPR148_ADDR			( ( volatile uint8_t __evenaccess * )0x00087394 )
+#define ICU_IPR149_ADDR			( ( volatile uint8_t __evenaccess * )0x00087395 )
+#define ICU_IPR150_ADDR			( ( volatile uint8_t __evenaccess * )0x00087396 )
+#define ICU_IPR151_ADDR			( ( volatile uint8_t __evenaccess * )0x00087397 )
+#define ICU_IPR152_ADDR			( ( volatile uint8_t __evenaccess * )0x00087398 )
+#define ICU_IPR153_ADDR			( ( volatile uint8_t __evenaccess * )0x00087399 )
+#define ICU_IPR154_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739A )
+#define ICU_IPR155_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739B )
+#define ICU_IPR156_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739C )
+#define ICU_IPR157_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739D )
+#define ICU_IPR158_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739E )
+#define ICU_IPR159_ADDR			( ( volatile uint8_t __evenaccess * )0x0008739F )
+#define ICU_IPR160_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A0 )
+#define ICU_IPR161_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A1 )
+#define ICU_IPR162_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A2 )
+#define ICU_IPR163_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A3 )
+#define ICU_IPR164_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A4 )
+#define ICU_IPR165_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A5 )
+#define ICU_IPR166_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A6 )
+#define ICU_IPR167_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A7 )
+#define ICU_IPR168_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A8 )
+#define ICU_IPR169_ADDR			( ( volatile uint8_t __evenaccess * )0x000873A9 )
+#define ICU_IPR170_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AA )
+#define ICU_IPR171_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AB )
+#define ICU_IPR172_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AC )
+#define ICU_IPR173_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AD )
+#define ICU_IPR174_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AE )
+#define ICU_IPR175_ADDR			( ( volatile uint8_t __evenaccess * )0x000873AF )
+#define ICU_IPR176_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B0 )
+#define ICU_IPR177_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B1 )
+#define ICU_IPR178_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B2 )
+#define ICU_IPR179_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B3 )
+#define ICU_IPR180_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B4 )
+#define ICU_IPR181_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B5 )
+#define ICU_IPR182_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B6 )
+#define ICU_IPR183_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B7 )
+#define ICU_IPR184_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B8 )
+#define ICU_IPR185_ADDR			( ( volatile uint8_t __evenaccess * )0x000873B9 )
+#define ICU_IPR186_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BA )
+#define ICU_IPR187_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BB )
+#define ICU_IPR188_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BC )
+#define ICU_IPR189_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BD )
+#define ICU_IPR190_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BE )
+#define ICU_IPR191_ADDR			( ( volatile uint8_t __evenaccess * )0x000873BF )
+#define ICU_IPR192_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C0 )
+#define ICU_IPR193_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C1 )
+#define ICU_IPR194_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C2 )
+#define ICU_IPR195_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C3 )
+#define ICU_IPR196_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C4 )
+#define ICU_IPR197_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C5 )
+#define ICU_IPR198_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C6 )
+#define ICU_IPR199_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C7 )
+#define ICU_IPR200_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C8 )
+#define ICU_IPR201_ADDR			( ( volatile uint8_t __evenaccess * )0x000873C9 )
+#define ICU_IPR202_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CA )
+#define ICU_IPR203_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CB )
+#define ICU_IPR204_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CC )
+#define ICU_IPR205_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CD )
+#define ICU_IPR206_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CE )
+#define ICU_IPR207_ADDR			( ( volatile uint8_t __evenaccess * )0x000873CF )
+#define ICU_IPR208_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D0 )
+#define ICU_IPR209_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D1 )
+#define ICU_IPR210_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D2 )
+#define ICU_IPR211_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D3 )
+#define ICU_IPR212_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D4 )
+#define ICU_IPR213_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D5 )
+#define ICU_IPR214_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D6 )
+#define ICU_IPR215_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D7 )
+#define ICU_IPR216_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D8 )
+#define ICU_IPR217_ADDR			( ( volatile uint8_t __evenaccess * )0x000873D9 )
+#define ICU_IPR218_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DA )
+#define ICU_IPR219_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DB )
+#define ICU_IPR220_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DC )
+#define ICU_IPR221_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DD )
+#define ICU_IPR222_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DE )
+#define ICU_IPR223_ADDR			( ( volatile uint8_t __evenaccess * )0x000873DF )
+#define ICU_IPR224_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E0 )
+#define ICU_IPR225_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E1 )
+#define ICU_IPR226_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E2 )
+#define ICU_IPR227_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E3 )
+#define ICU_IPR228_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E4 )
+#define ICU_IPR229_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E5 )
+#define ICU_IPR230_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E6 )
+#define ICU_IPR231_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E7 )
+#define ICU_IPR232_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E8 )
+#define ICU_IPR233_ADDR			( ( volatile uint8_t __evenaccess * )0x000873E9 )
+#define ICU_IPR234_ADDR			( ( volatile uint8_t __evenaccess * )0x000873EA )
+#define ICU_IPR235_ADDR			( ( volatile uint8_t __evenaccess * )0x000873EB )
+#define ICU_IPR236_ADDR			( ( volatile uint8_t __evenaccess * )0x000873EC )
+#define ICU_IPR237_ADDR			( ( volatile uint8_t __evenaccess * )0x000873ED )
+#define ICU_IPR238_ADDR			( ( volatile uint8_t __evenaccess * )0x000873EE )
+#define ICU_IPR239_ADDR			( ( volatile uint8_t __evenaccess * )0x000873EF )
+#define ICU_IPR240_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F0 )
+#define ICU_IPR241_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F1 )
+#define ICU_IPR242_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F2 )
+#define ICU_IPR243_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F3 )
+#define ICU_IPR244_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F4 )
+#define ICU_IPR245_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F5 )
+#define ICU_IPR246_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F6 )
+#define ICU_IPR247_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F7 )
+#define ICU_IPR248_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F8 )
+#define ICU_IPR249_ADDR			( ( volatile uint8_t __evenaccess * )0x000873F9 )
+#define ICU_IPR250_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FA )
+#define ICU_IPR251_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FB )
+#define ICU_IPR252_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FC )
+#define ICU_IPR253_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FD )
+#define ICU_IPR254_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FE )
+#define ICU_IPR255_ADDR			( ( volatile uint8_t __evenaccess * )0x000873FF )
+#define ICU_IPR_BIT				( 7U << 0U )
+
+
+/*
+ *  IRQã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿
+ */
+#define ICU_IRQ0_ADDR			( ( volatile uint8_t __evenaccess * )0x00087500 )
+#define ICU_IRQ1_ADDR			( ( volatile uint8_t __evenaccess * )0x00087501 )
+#define ICU_IRQ2_ADDR			( ( volatile uint8_t __evenaccess * )0x00087502 )
+#define ICU_IRQ3_ADDR			( ( volatile uint8_t __evenaccess * )0x00087503 )
+#define ICU_IRQ4_ADDR			( ( volatile uint8_t __evenaccess * )0x00087504 )
+#define ICU_IRQ5_ADDR			( ( volatile uint8_t __evenaccess * )0x00087505 )
+#define ICU_IRQ6_ADDR			( ( volatile uint8_t __evenaccess * )0x00087506 )
+#define ICU_IRQ7_ADDR			( ( volatile uint8_t __evenaccess * )0x00087507 )
+#define ICU_IRQ8_ADDR			( ( volatile uint8_t __evenaccess * )0x00087508 )
+#define ICU_IRQ9_ADDR			( ( volatile uint8_t __evenaccess * )0x00087509 )
+#define ICU_IRQ10_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750A )
+#define ICU_IRQ11_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750B )
+#define ICU_IRQ12_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750C )
+#define ICU_IRQ13_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750D )
+#define ICU_IRQ14_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750E )
+#define ICU_IRQ15_ADDR			( ( volatile uint8_t __evenaccess * )0x0008750F )
+#define ICU_IRQMD_BIT			( 3U << 2U )
+
+
+/*
+ *  åãã£ã³ãã«ã®ã¬ã¸ã¹ã¿åã³è¨­å®ãããæ
+å ±
+ */
+#define CMT_CMSTR0_ADDR			( ( volatile uint16_t __evenaccess * )0x00088000 )
+#define CMT_CMSTR0_STR0_BIT		( 1U << 0U )
+#define CMT_CMSTR0_STR1_BIT		( 1U << 1U )
+#define CMT_CMSTR1_ADDR			( ( volatile uint16_t __evenaccess * )0x00088010 )
+#define CMT_CMSTR1_STR2_BIT		( 1U << 0U )
+#define CMT_CMSTR1_STR3_BIT		( 1U << 1U )
+#define CMT0_CMCR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088002 )
+#define CMT0_CMCR_CKS_BIT		( 3U )
+#define CMT0_CMCR_CMIE_BIT		( 1U << 6U )
+#define CMT1_CMCR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088008 )
+#define CMT1_CMCR_CKS_BIT		( 3U )
+#define CMT1_CMCR_CMIE_BIT		( 1U << 6U )
+#define CMT2_CMCR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088012 )
+#define CMT2_CMCR_CKS_BIT		( 3U)
+#define CMT2_CMCR_CMIE_BIT		( 1U << 6U )
+#define CMT3_CMCR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088018 )
+#define CMT3_CMCR_CKS_BIT		( 3U )
+#define CMT3_CMCR_CMIE_BIT		( 1U << 6U )
+#define CMT0_CMCNT_ADDR			( ( volatile uint16_t __evenaccess * )0x00088004 )
+#define CMT1_CMCNT_ADDR			( ( volatile uint16_t __evenaccess * )0x0008800A )
+#define CMT2_CMCNT_ADDR			( ( volatile uint16_t __evenaccess * )0x00088014 )
+#define CMT3_CMCNT_ADDR			( ( volatile uint16_t __evenaccess * )0x0008801A )
+#define CMT0_CMCOR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088006 )
+#define CMT1_CMCOR_ADDR			( ( volatile uint16_t __evenaccess * )0x0008800C )
+#define CMT2_CMCOR_ADDR			( ( volatile uint16_t __evenaccess * )0x00088016 )
+#define CMT3_CMCOR_ADDR			( ( volatile uint16_t __evenaccess * )0x0008801C )
+
+#define SCI0_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A000 )
+#define SCI0_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A001 )
+#define SCI0_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A002 )
+#define SCI0_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A003 )
+#define SCI0_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A004 )
+#define SCI0_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A005 )
+#define SCI0_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A006 )
+#define SCI0_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A007 )
+#define SCI1_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A020 )
+#define SCI1_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A021 )
+#define SCI1_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A022 )
+#define SCI1_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A023 )
+#define SCI1_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A024 )
+#define SCI1_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A025 )
+#define SCI1_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A026 )
+#define SCI1_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A027 )
+#define SCI2_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A040 )
+#define SCI2_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A041 )
+#define SCI2_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A042 )
+#define SCI2_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A043 )
+#define SCI2_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A044 )
+#define SCI2_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A045 )
+#define SCI2_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A046 )
+#define SCI2_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A047 )
+#define SCI3_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A060 )
+#define SCI3_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A061 )
+#define SCI3_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A062 )
+#define SCI3_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A063 )
+#define SCI3_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A064 )
+#define SCI3_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A065 )
+#define SCI3_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A066 )
+#define SCI3_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A067 )
+#define SCI4_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A080 )
+#define SCI4_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A081 )
+#define SCI4_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A082 )
+#define SCI4_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A083 )
+#define SCI4_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A084 )
+#define SCI4_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A085 )
+#define SCI4_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A086 )
+#define SCI4_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A087 )
+#define SCI5_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A0 )
+#define SCI5_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A1 )
+#define SCI5_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A2 )
+#define SCI5_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A3 )
+#define SCI5_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A4 )
+#define SCI5_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A5 )
+#define SCI5_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A6 )
+#define SCI5_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0A7 )
+#define SCI6_SMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C0 )
+#define SCI6_BRR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C1 )
+#define SCI6_SCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C2 )
+#define SCI6_TDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C3 )
+#define SCI6_SSR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C4 )
+#define SCI6_RDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C5 )
+#define SCI6_SCMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C6 )
+#define SCI6_SEMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008A0C7 )
+#define SCI_SMR_CKS_BIT			( 3U << 0U )
+#define SCI_SMR_STOP_BIT		( 1U << 3U )
+#define SCI_SMR_PM_BIT			( 1U << 4U )
+#define SCI_SMR_PE_BIT			( 1U << 5U )
+#define SCI_SMR_CHR_BIT			( 1U << 6U )
+#define SCI_SMR_CM_BIT			( 1U << 7U )
+#define SCI_SCR_CKE_BIT			( 3U << 0U )
+#define SCI_SCR_TEIE_BIT		( 1U << 2U )
+#define SCI_SCR_RE_BIT			( 1U << 4U )
+#define SCI_SCR_TE_BIT			( 1U << 5U )
+#define SCI_SCR_RIE_BIT			( 1U << 6U )
+#define SCI_SCR_TIE_BIT			( 1U << 7U )
+#define SCI_SSR_TEND_BIT		( 1U << 2U )
+#define SCI_SSR_PER_BIT			( 1U << 3U )
+#define SCI_SSR_FER_BIT			( 1U << 4U )
+#define SCI_SSR_ORER_BIT		( 1U << 5U )
+#define SCI_SCMR_SMIF_BIT		( 1U << 0U )
+#define SCI_SCMR_SINV_BIT		( 1U << 2U )
+#define SCI_SCMR_SDIR_BIT		( 1U << 3U )
+#define SCI_SCMR_BCP2_BIT		( 1U << 7U )
+#define SCI_SEMR_ACS0_BIT		( 1U << 0U )
+#define SCI_SEMR_ABCS_BIT		( 1U << 4U )
+
+/*
+ *  I/Oãã¼ãã®ã¬ã¸ã¹ã¿åã³è¨­å®ãããæ
+å ±
+ */
+#define PORT0_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C000 )
+#define PORT1_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C001 )
+#define PORT2_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C002 )
+#define PORT3_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C003 )
+#define PORT4_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C004 )
+#define PORT5_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C005 )
+#define PORT6_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C006 )
+#define PORT7_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C007 )
+#define PORT8_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C008 )
+#define PORT9_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C009 )
+#define PORTA_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00A )
+#define PORTB_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00B )
+#define PORTC_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00C )
+#define PORTD_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00D )
+#define PORTE_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00E )
+#define PORTF_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C00F )
+#define PORTG_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C010 )
+#define PORTJ_PDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C012 )
+#define PORT_PDR_B0_BIT			( 0x01U << 0U )
+#define PORT_PDR_B1_BIT			( 0x01U << 1U )
+#define PORT_PDR_B2_BIT			( 0x01U << 2U )
+#define PORT_PDR_B3_BIT			( 0x01U << 3U )
+#define PORT_PDR_B4_BIT			( 0x01U << 4U )
+#define PORT_PDR_B5_BIT			( 0x01U << 5U )
+#define PORT_PDR_B6_BIT			( 0x01U << 6U )
+#define PORT_PDR_B7_BIT			( 0x01U << 7U )
+#define PORT0_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C020 )
+#define PORT1_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C021 )
+#define PORT2_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C022 )
+#define PORT3_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C023 )
+#define PORT4_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C024 )
+#define PORT5_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C025 )
+#define PORT6_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C026 )
+#define PORT7_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C027 )
+#define PORT8_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C028 )
+#define PORT9_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C029 )
+#define PORTA_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02A )
+#define PORTB_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02B )
+#define PORTC_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02C )
+#define PORTD_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02D )
+#define PORTE_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02E )
+#define PORTF_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C02F )
+#define PORTG_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C030 )
+#define PORTJ_PODR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C032 )
+#define PORT_PODR_B0_BIT		( 0x01U << 0U )
+#define PORT_PODR_B1_BIT		( 0x01U << 1U )
+#define PORT_PODR_B2_BIT		( 0x01U << 2U )
+#define PORT_PODR_B3_BIT		( 0x01U << 3U )
+#define PORT_PODR_B4_BIT		( 0x01U << 4U )
+#define PORT_PODR_B5_BIT		( 0x01U << 5U )
+#define PORT_PODR_B6_BIT		( 0x01U << 6U )
+#define PORT_PODR_B7_BIT		( 0x01U << 7U )
+#define PORT0_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C040 )
+#define PORT1_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C041 )
+#define PORT2_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C042 )
+#define PORT3_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C043 )
+#define PORT4_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C044 )
+#define PORT5_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C045 )
+#define PORT6_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C046 )
+#define PORT7_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C047 )
+#define PORT8_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C048 )
+#define PORT9_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C049 )
+#define PORTA_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04A )
+#define PORTB_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04B )
+#define PORTC_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04C )
+#define PORTD_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04D )
+#define PORTE_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04E )
+#define PORTF_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C04F )
+#define PORTG_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C050 )
+#define PORTJ_PIDR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C052 )
+#define PORT_PIDR_B0_BIT		( 0x01U << 0U )
+#define PORT_PIDR_B1_BIT		( 0x01U << 1U )
+#define PORT_PIDR_B2_BIT		( 0x01U << 2U )
+#define PORT_PIDR_B3_BIT		( 0x01U << 3U )
+#define PORT_PIDR_B4_BIT		( 0x01U << 4U )
+#define PORT_PIDR_B5_BIT		( 0x01U << 5U )
+#define PORT_PIDR_B6_BIT		( 0x01U << 6U )
+#define PORT_PIDR_B7_BIT		( 0x01U << 7U )
+#define PORT0_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C060 )
+#define PORT1_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C061 )
+#define PORT2_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C062 )
+#define PORT3_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C063 )
+#define PORT4_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C064 )
+#define PORT5_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C065 )
+#define PORT6_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C066 )
+#define PORT7_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C067 )
+#define PORT8_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C068 )
+#define PORT9_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C069 )
+#define PORTA_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06A )
+#define PORTB_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06B )
+#define PORTC_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06C )
+#define PORTD_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06D )
+#define PORTE_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06E )
+#define PORTF_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C06F )
+#define PORTG_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C070 )
+#define PORTJ_PMR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C072 )
+#define PORT_PMR_B0_BIT			( 0x01U << 0U )
+#define PORT_PMR_B1_BIT			( 0x01U << 1U )
+#define PORT_PMR_B2_BIT			( 0x01U << 2U )
+#define PORT_PMR_B3_BIT			( 0x01U << 3U )
+#define PORT_PMR_B4_BIT			( 0x01U << 4U )
+#define PORT_PMR_B5_BIT			( 0x01U << 5U )
+#define PORT_PMR_B6_BIT			( 0x01U << 6U )
+#define PORT_PMR_B7_BIT			( 0x01U << 7U )
+#define PORT0_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C0 )
+#define PORT1_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C1 )
+#define PORT2_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C2 )
+#define PORT3_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C3 )
+#define PORT4_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C4 )
+#define PORT5_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C5 )
+#define PORT6_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C6 )
+#define PORT7_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C7 )
+#define PORT8_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C8 )
+#define PORT9_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0C9 )
+#define PORTA_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CA )
+#define PORTB_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CB )
+#define PORTC_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CC )
+#define PORTD_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CD )
+#define PORTE_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CE )
+#define PORTF_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0CF )
+#define PORTG_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0D0 )
+#define PORTJ_PCR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0D2 )
+#define PORT_PCR_B0_BIT			( 0x01U << 0U )
+#define PORT_PCR_B1_BIT			( 0x01U << 1U )
+#define PORT_PCR_B2_BIT			( 0x01U << 2U )
+#define PORT_PCR_B3_BIT			( 0x01U << 3U )
+#define PORT_PCR_B4_BIT			( 0x01U << 4U )
+#define PORT_PCR_B5_BIT			( 0x01U << 5U )
+#define PORT_PCR_B6_BIT			( 0x01U << 6U )
+#define PORT_PCR_B7_BIT			( 0x01U << 7U )
+#define PORT0_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C080 )
+#define PORT1_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C082 )
+#define PORT2_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C084 )
+#define PORT3_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C086 )
+#define PORT4_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C088 )
+#define PORT5_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08A )
+#define PORT6_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08C )
+#define PORT7_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08E )
+#define PORT8_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C090 )
+#define PORT9_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C092 )
+#define PORTA_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C094 )
+#define PORTB_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C096 )
+#define PORTC_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C098 )
+#define PORTD_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09A )
+#define PORTE_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09C )
+#define PORTF_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09E )
+#define PORTG_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0A0 )
+#define PORTJ_ODR0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0A4 )
+#define PORT0_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C081 )
+#define PORT1_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C083 )
+#define PORT2_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C085 )
+#define PORT3_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C087 )
+#define PORT4_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C089 )
+#define PORT5_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08B )
+#define PORT6_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08D )
+#define PORT7_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C08F )
+#define PORT8_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C091 )
+#define PORT9_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C093 )
+#define PORTA_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C095 )
+#define PORTB_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C097 )
+#define PORTC_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C099 )
+#define PORTD_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09B )
+#define PORTE_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09D )
+#define PORTF_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C09F )
+#define PORTG_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0A1 )
+#define PORTJ_ODR1_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C0A5 )
+
+/*
+ *  ãã«ããã¡ã³ã¯ã·ã§ã³ãã³ã³ã³ãã­ã¼ã©ã®ã¬ã¸ã¹ã¿æ
+å ±
+ */
+#define MPC_PFUSB0_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C114 )
+#define MPC_PFUSB0_PDHZS_BIT	( 0x01U << 2U )
+#define MPC_PFUSB0_PUPHZS_BIT	( 0x01U << 3U )
+#define MPC_PWPR_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C11F )
+#define MPC_PWPR_PFSWE			( 0x01U << 6U )
+#define MPC_PWPR_B0WI			( 0x01U << 7U )
+#define MPC_P00PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C140 )
+#define MPC_P01PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C141 )
+#define MPC_P02PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C142 )
+#define MPC_P03PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C143 )
+#define MPC_P04PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C144 )
+#define MPC_P05PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C145 )
+#define MPC_P06PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C146 )
+#define MPC_P07PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C147 )
+#define MPC_P10PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C148 )
+#define MPC_P11PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C149 )
+#define MPC_P12PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14A )
+#define MPC_P13PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14B )
+#define MPC_P14PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14C )
+#define MPC_P15PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14D )
+#define MPC_P16PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14E )
+#define MPC_P17PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C14F )
+#define MPC_P20PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C150 )
+#define MPC_P21PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C151 )
+#define MPC_P22PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C152 )
+#define MPC_P23PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C153 )
+#define MPC_P24PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C154 )
+#define MPC_P25PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C155 )
+#define MPC_P26PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C156 )
+#define MPC_P27PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C157 )
+#define MPC_P30PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C158 )
+#define MPC_P31PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C159 )
+#define MPC_P32PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15A )
+#define MPC_P33PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15B )
+#define MPC_P34PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15C )
+#define MPC_P35PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15D )
+#define MPC_P36PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15E )
+#define MPC_P37PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C15F )
+#define MPC_P40PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C160 )
+#define MPC_P41PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C161 )
+#define MPC_P42PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C162 )
+#define MPC_P43PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C163 )
+#define MPC_P44PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C164 )
+#define MPC_P45PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C165 )
+#define MPC_P46PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C166 )
+#define MPC_P47PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C167 )
+#define MPC_P50PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C168 )
+#define MPC_P51PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C169 )
+#define MPC_P52PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16A )
+#define MPC_P53PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16B )
+#define MPC_P54PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16C )
+#define MPC_P55PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16D )
+#define MPC_P56PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16E )
+#define MPC_P57PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C16F )
+#define MPC_P60PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C170 )
+#define MPC_P61PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C171 )
+#define MPC_P62PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C172 )
+#define MPC_P63PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C173 )
+#define MPC_P64PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C174 )
+#define MPC_P65PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C175 )
+#define MPC_P66PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C176 )
+#define MPC_P67PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C177 )
+#define MPC_P70PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C178 )
+#define MPC_P71PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C179 )
+#define MPC_P72PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17A )
+#define MPC_P73PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17B )
+#define MPC_P74PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17C )
+#define MPC_P75PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17D )
+#define MPC_P76PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17E )
+#define MPC_P77PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C17F )
+#define MPC_P80PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C180 )
+#define MPC_P81PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C181 )
+#define MPC_P82PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C182 )
+#define MPC_P83PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C183 )
+#define MPC_P84PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C184 )
+#define MPC_P85PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C185 )
+#define MPC_P86PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C186 )
+#define MPC_P87PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C187 )
+#define MPC_P90PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C188 )
+#define MPC_P91PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C189 )
+#define MPC_P92PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18A )
+#define MPC_P93PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18B )
+#define MPC_P94PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18C )
+#define MPC_P95PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18D )
+#define MPC_P96PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18E )
+#define MPC_P97PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C18F )
+#define MPC_PA0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C190 )
+#define MPC_PA1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C191 )
+#define MPC_PA2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C192 )
+#define MPC_PA3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C193 )
+#define MPC_PA4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C194 )
+#define MPC_PA5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C195 )
+#define MPC_PA6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C196 )
+#define MPC_PA7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C197 )
+#define MPC_PB0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C198 )
+#define MPC_PB1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C199 )
+#define MPC_PB2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19A )
+#define MPC_PB3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19B )
+#define MPC_PB4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19C )
+#define MPC_PB5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19D )
+#define MPC_PB6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19E )
+#define MPC_PB7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C19F )
+#define MPC_PC0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A0 )
+#define MPC_PC1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A1 )
+#define MPC_PC2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A2 )
+#define MPC_PC3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A3 )
+#define MPC_PC4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A4 )
+#define MPC_PC5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A5 )
+#define MPC_PC6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A6 )
+#define MPC_PC7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A7 )
+#define MPC_PD0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A8 )
+#define MPC_PD1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1A9 )
+#define MPC_PD2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AA )
+#define MPC_PD3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AB )
+#define MPC_PD4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AC )
+#define MPC_PD5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AD )
+#define MPC_PD6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AE )
+#define MPC_PD7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1AF )
+#define MPC_PE0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B0 )
+#define MPC_PE1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B1 )
+#define MPC_PE2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B2 )
+#define MPC_PE3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B3 )
+#define MPC_PE4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B4 )
+#define MPC_PE5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B5 )
+#define MPC_PE6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B6 )
+#define MPC_PE7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B7 )
+#define MPC_PF0PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B8 )
+#define MPC_PF1PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1B9 )
+#define MPC_PF2PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BA )
+#define MPC_PF3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BB )
+#define MPC_PF4PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BC )
+#define MPC_PF5PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BD )
+#define MPC_PF6PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BE )
+#define MPC_PF7PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1BF )
+#define MPC_PJ3PFS_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C1D3 )
+
+/*
+ * ãªã¢ã«ã¿ã¤ã ã¯ã­ãã¯
+ */
+#define RTC_R64CNT_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C400 )
+#define RTC_RSECCNT_ADDR		( ( volatile uint8_t __evenaccess * )0x0008C402 )
+#define RTC_RMINCNT_ADDR		( ( volatile uint8_t __evenaccess * )0x0008C404 )
+#define RTC_RHRCNT_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C406 )
+#define RTC_RWKCNT_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C408 )
+#define RTC_RDAYCNT_ADDR		( ( volatile uint8_t __evenaccess * )0x0008C40A )
+#define RTC_RMONCNT_ADDR		( ( volatile uint8_t __evenaccess * )0x0008C40C )
+#define RTC_RYRCNT_ADDR			( ( volatile uint8_t __evenaccess * )0x0008C40E )
+
+/*
+ * 12 ãããA/D ã³ã³ãã¼ã¿
+ */
+#define S12AD_ADCSR_ADDR		( ( volatile uint8_t __evenaccess * )0x00089000 )
+#define S12AD_ADCSR_ADST_BIT	0x80
+#define S12AD_ADANS0_ADDR		( ( volatile uint16_t __evenaccess * )0x00089004 )
+#define S12AD_ADANS1_ADDR		( ( volatile uint16_t __evenaccess * )0x00089006 )
+#define S12AD_ADEXICR_ADDR		( ( volatile uint16_t __evenaccess * )0x00089012 )
+#define S12AD_ADDR0_ADDR		( ( volatile uint16_t __evenaccess * )0x00089020 )
+#define S12AD_ADDR1_ADDR		( ( volatile uint16_t __evenaccess * )0x00089022 )
+#define S12AD_ADDR2_ADDR		( ( volatile uint16_t __evenaccess * )0x00089024 )
+#define S12AD_ADDR3_ADDR		( ( volatile uint16_t __evenaccess * )0x00089026 )
+#define S12AD_ADDR4_ADDR		( ( volatile uint16_t __evenaccess * )0x00089028 )
+#define S12AD_ADDR5_ADDR		( ( volatile uint16_t __evenaccess * )0x0008902A )
+#define S12AD_ADDR6_ADDR		( ( volatile uint16_t __evenaccess * )0x0008902C )
+#define S12AD_ADDR7_ADDR		( ( volatile uint16_t __evenaccess * )0x0008902E )
+#define S12AD_ADDR8_ADDR		( ( volatile uint16_t __evenaccess * )0x00089030 )
+#define S12AD_ADDR9_ADDR		( ( volatile uint16_t __evenaccess * )0x00089032 )
+#define S12AD_ADDR10_ADDR		( ( volatile uint16_t __evenaccess * )0x00089034 )
+#define S12AD_ADDR11_ADDR		( ( volatile uint16_t __evenaccess * )0x00089036 )
+#define S12AD_ADDR12_ADDR		( ( volatile uint16_t __evenaccess * )0x00089038 )
+#define S12AD_ADDR13_ADDR		( ( volatile uint16_t __evenaccess * )0x0008903A )
+#define S12AD_ADDR14_ADDR		( ( volatile uint16_t __evenaccess * )0x0008903C )
+#define S12AD_ADDR15_ADDR		( ( volatile uint16_t __evenaccess * )0x0008903E )
+#define S12AD_ADDR16_ADDR		( ( volatile uint16_t __evenaccess * )0x00089040 )
+#define S12AD_ADDR17_ADDR		( ( volatile uint16_t __evenaccess * )0x00089042 )
+#define S12AD_ADDR18_ADDR		( ( volatile uint16_t __evenaccess * )0x00089044 )
+#define S12AD_ADDR19_ADDR		( ( volatile uint16_t __evenaccess * )0x00089046 )
+#define S12AD_ADDR20_ADDR		( ( volatile uint16_t __evenaccess * )0x00089048 )
+
+#define TPU0_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088110 )
+#define TPU1_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088120 )
+#define TPU2_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088130 )
+#define TPU3_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088140 )
+#define TPU4_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088150 )
+#define TPU5_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088160 )
+#define TPU6_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088180 )
+#define TPU7_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088190 )
+#define TPU8_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881A0 )
+#define TPU9_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881B0 )
+#define TPU10_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881C0 )
+#define TPU11_TCR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881D0 )
+#define TPU_TCR_TPSC_OFFSET		( 0U )
+#define TPU_TCR_TPSC_MASK		( 0x7U << TPU_TCR_TPSC_OFFSET )
+#define TPU_TCR_CKEG_OFFSET		( 3U )
+#define TPU_TCR_CKEG_MASK		( 0x3U << TPU_TCR_CKEG_OFFSET )
+#define TPU_TCR_CCLR_OFFSET		( 5U )
+#define TPU_TCR_CCLR_MASK		( 0x7U << TPU_TCR_CCLR_OFFSET )
+
+#define TPU0_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088111 )
+#define TPU1_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088121 )
+#define TPU2_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088131 )
+#define TPU3_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088141 )
+#define TPU4_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088151 )
+#define TPU5_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088161 )
+#define TPU6_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088181 )
+#define TPU7_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088191 )
+#define TPU8_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881A1 )
+#define TPU9_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881B1 )
+#define TPU10_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881C1 )
+#define TPU11_TMDR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881D1 )
+
+#define TPU0_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881C0 )
+#define TPU0_TIORH_ADDR			( ( volatile uint8_t __evenaccess * )0x00088112 )
+#define TPU0_TIORL_ADDR			( ( volatile uint8_t __evenaccess * )0x00088113 )
+#define TPU1_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088122 )
+#define TPU2_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088132 )
+#define TPU3_TIORH_ADDR			( ( volatile uint8_t __evenaccess * )0x00088142 )
+#define TPU3_TIORL_ADDR			( ( volatile uint8_t __evenaccess * )0x00088143 )
+#define TPU4_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088152 )
+#define TPU5_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088162 )
+#define TPU6_TIORH_ADDR			( ( volatile uint8_t __evenaccess * )0x00088182 )
+#define TPU6_TIORL_ADDR			( ( volatile uint8_t __evenaccess * )0x00088183 )
+#define TPU7_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088192 )
+#define TPU8_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881A2 )
+#define TPU9_TIORH_ADDR			( ( volatile uint8_t __evenaccess * )0x000881B2 )
+#define TPU9_TIORL_ADDR			( ( volatile uint8_t __evenaccess * )0x000881B3 )
+#define TPU10_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881C2 )
+#define TPU11_TIOR_ADDR			( ( volatile uint8_t __evenaccess * )0x000881D2 )
+#define TPU_TIORL_IOA_OFFSET	( 0U )
+#define TPU_TIORL_IOA_MASK		( 0xFU << TPU_TIORL_IOA_OFFSET )
+#define TPU_TIORL_IOB_OFFSET	( 4U )
+#define TPU_TIORL_IOB_MASK		( 0xFU << TPU_TIORL_IOB_OFFSET )
+#define TPU_TIORL_IOC_OFFSET	( 0U )
+#define TPU_TIORL_IOC_MASK		( 0xFU << TPU_TIORL_IOC_OFFSET )
+#define TPU_TIORL_IOD_OFFSET	( 4U )
+#define TPU_TIORL_IOD_MASK		( 0xFU << TPU_TIORL_IOD_OFFSET )
+
+#define TPU0_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088118 )
+#define TPU0_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008811A )
+#define TPU0_TGRC_ADDR			( ( volatile uint16_t __evenaccess * )0x0008811C )
+#define TPU0_TGRD_ADDR			( ( volatile uint16_t __evenaccess * )0x0008811E )
+#define TPU1_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088128 )
+#define TPU1_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008812A )
+#define TPU2_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088138 )
+#define TPU2_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008813A )
+#define TPU3_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088148 )
+#define TPU3_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008814A )
+#define TPU3_TGRC_ADDR			( ( volatile uint16_t __evenaccess * )0x0008814C )
+#define TPU3_TGRD_ADDR			( ( volatile uint16_t __evenaccess * )0x0008814E )
+#define TPU4_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088158 )
+#define TPU4_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008815A )
+#define TPU5_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088168 )
+#define TPU5_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008816A )
+#define TPU6_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088188 )
+#define TPU6_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008818A )
+#define TPU6_TGRC_ADDR			( ( volatile uint16_t __evenaccess * )0x0008818C )
+#define TPU6_TGRD_ADDR			( ( volatile uint16_t __evenaccess * )0x0008818E )
+#define TPU7_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x00088198 )
+#define TPU7_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x0008819A )
+#define TPU8_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x000881A8 )
+#define TPU8_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x000881AA )
+#define TPU9_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x000881B8 )
+#define TPU9_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x000881BA )
+#define TPU9_TGRC_ADDR			( ( volatile uint16_t __evenaccess * )0x000881BC )
+#define TPU9_TGRD_ADDR			( ( volatile uint16_t __evenaccess * )0x000881BE )
+#define TPU10_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x000881C8 )
+#define TPU10_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x000881CA )
+#define TPU11_TGRA_ADDR			( ( volatile uint16_t __evenaccess * )0x000881D8 )
+#define TPU11_TGRB_ADDR			( ( volatile uint16_t __evenaccess * )0x000881DA )
+
+#define TPUA_TSTR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088100 )
+#define TPUB_TSTR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088170 )
+#define TPU_TSTR_CST0_BIT		( 0x01U << 0U )
+#define TPU_TSTR_CST1_BIT		( 0x01U << 1U )
+#define TPU_TSTR_CST2_BIT		( 0x01U << 2U )
+#define TPU_TSTR_CST3_BIT		( 0x01U << 3U )
+#define TPU_TSTR_CST4_BIT		( 0x01U << 4U )
+#define TPU_TSTR_CST5_BIT		( 0x01U << 5U )
+
+#define TPUA_TSYR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088101 )
+#define TPUB_TSYR_ADDR			( ( volatile uint8_t __evenaccess * )0x00088171 )
+#define TPU_TSYR_SYNC0_BIT		( 0x01U << 0U )
+#define TPU_TSYR_SYNC1_BIT		( 0x01U << 1U )
+#define TPU_TSYR_SYNC2_BIT		( 0x01U << 2U )
+#define TPU_TSYR_SYNC3_BIT		( 0x01U << 3U )
+#define TPU_TSYR_SYNC4_BIT		( 0x01U << 4U )
+#define TPU_TSYR_SYNC5_BIT		( 0x01U << 5U )
+
+/*
+ * RSPI
+ */
+#define RSPI0_SPCR_ADDR		( ( volatile uint8_t __evenaccess * )0x00088380 )
+#define RSPI1_SPCR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883A0 )
+#define RSPI2_SPCR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883C0 )
+#define RSPI_SPCR_SPMS_BIT	( 0x01U << 0U )
+#define RSPI_SPCR_TXMD_BIT	( 0x01U << 1U )
+#define RSPI_SPCR_MODFEN_BIT	( 0x01U << 2U )
+#define RSPI_SPCR_MSTR_BIT	( 0x01U << 3U )
+#define RSPI_SPCR_SPEIE_BIT	( 0x01U << 4U )
+#define RSPI_SPCR_SPTIE_BIT	( 0x01U << 5U )
+#define RSPI_SPCR_SPE_BIT	( 0x01U << 6U )
+#define RSPI_SPCR_SPRIE_BIT	( 0x01U << 7U )
+
+#define RSPI0_SSLP_ADDR		( ( volatile uint8_t __evenaccess * )0x00088381 )
+#define RSPI1_SSLP_ADDR		( ( volatile uint8_t __evenaccess * )0x000883A1 )
+#define RSPI2_SSLP_ADDR		( ( volatile uint8_t __evenaccess * )0x000883C1 )
+
+#define RSPI0_SPPCR_ADDR	( ( volatile uint8_t __evenaccess * )0x00088382 )
+#define RSPI1_SPPCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883A2 )
+#define RSPI2_SPPCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883C2 )
+
+#define RSPI0_SPSR_ADDR		( ( volatile uint8_t __evenaccess * )0x00088383 )
+#define RSPI1_SPSR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883A3 )
+#define RSPI2_SPSR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883C3 )
+
+#define RSPI0_SPDR_ADDR		( ( volatile uint32_t __evenaccess * )0x00088384 )
+#define RSPI1_SPDR_ADDR		( ( volatile uint32_t __evenaccess * )0x000883A4 )
+#define RSPI2_SPDR_ADDR		( ( volatile uint32_t __evenaccess * )0x000883C4 )
+
+#define RSPI0_SPSCR_ADDR	( ( volatile uint8_t __evenaccess * )0x00088388 )
+#define RSPI1_SPSCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883A8 )
+#define RSPI2_SPSCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883C8 )
+
+#define RSPI0_SPSSR_ADDR	( ( volatile uint8_t __evenaccess * )0x00088389 )
+#define RSPI1_SPSSR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883A9 )
+#define RSPI2_SPSSR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883C9 )
+
+#define RSPI0_SPBR_ADDR		( ( volatile uint8_t __evenaccess * )0x0008838A )
+#define RSPI1_SPBR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883AA )
+#define RSPI2_SPBR_ADDR		( ( volatile uint8_t __evenaccess * )0x000883CA )
+
+#define RSPI0_SPDCR_ADDR	( ( volatile uint8_t __evenaccess * )0x0008838B )
+#define RSPI1_SPDCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883AB )
+#define RSPI2_SPDCR_ADDR	( ( volatile uint8_t __evenaccess * )0x000883CB )
+
+#define RSPI0_SPCKD_ADDR	( ( volatile uint8_t __evenaccess * )0x0008838C )
+#define RSPI1_SPCKD_ADDR	( ( volatile uint8_t __evenaccess * )0x000883AC )
+#define RSPI2_SPCKD_ADDR	( ( volatile uint8_t __evenaccess * )0x000883CC )
+
+#define RSPI0_SSLND_ADDR	( ( volatile uint8_t __evenaccess * )0x0008838D )
+#define RSPI1_SSLND_ADDR	( ( volatile uint8_t __evenaccess * )0x000883AD )
+#define RSPI2_SSLND_ADDR	( ( volatile uint8_t __evenaccess * )0x000883CD )
+
+#define RSPI0_SPND_ADDR		( ( volatile uint8_t __evenaccess * )0x0008838E )
+#define RSPI1_SPND_ADDR		( ( volatile uint8_t __evenaccess * )0x000883AE )
+#define RSPI2_SPND_ADDR		( ( volatile uint8_t __evenaccess * )0x000883CE )
+
+#define RSPI0_SPCR2_ADDR	( ( volatile uint8_t __evenaccess * )0x0008838F )
+#define RSPI1_SPCR2_ADDR	( ( volatile uint8_t __evenaccess * )0x000883AF )
+#define RSPI2_SPCR2_ADDR	( ( volatile uint8_t __evenaccess * )0x000883CF )
+
+#define RSPI0_SPCMD0_ADDR	( ( volatile uint16_t __evenaccess * )0x00088390 )
+#define RSPI0_SPCMD1_ADDR	( ( volatile uint16_t __evenaccess * )0x00088392 )
+#define RSPI0_SPCMD2_ADDR	( ( volatile uint16_t __evenaccess * )0x00088394 )
+#define RSPI0_SPCMD3_ADDR	( ( volatile uint16_t __evenaccess * )0x00088396 )
+#define RSPI0_SPCMD4_ADDR	( ( volatile uint16_t __evenaccess * )0x00088398 )
+#define RSPI0_SPCMD5_ADDR	( ( volatile uint16_t __evenaccess * )0x0008839A )
+#define RSPI0_SPCMD6_ADDR	( ( volatile uint16_t __evenaccess * )0x0008839C )
+#define RSPI0_SPCMD7_ADDR	( ( volatile uint16_t __evenaccess * )0x0008839E )
+#define RSPI1_SPCMD0_ADDR	( ( volatile uint16_t __evenaccess * )0x000883B0 )
+#define RSPI1_SPCMD1_ADDR	( ( volatile uint16_t __evenaccess * )0x000883B2 )
+#define RSPI1_SPCMD2_ADDR	( ( volatile uint16_t __evenaccess * )0x000883B4 )
+#define RSPI1_SPCMD3_ADDR	( ( volatile uint16_t __evenaccess * )0x000883B6 )
+#define RSPI1_SPCMD4_ADDR	( ( volatile uint16_t __evenaccess * )0x000883B8 )
+#define RSPI1_SPCMD5_ADDR	( ( volatile uint16_t __evenaccess * )0x000883BA )
+#define RSPI1_SPCMD6_ADDR	( ( volatile uint16_t __evenaccess * )0x000883BC )
+#define RSPI1_SPCMD7_ADDR	( ( volatile uint16_t __evenaccess * )0x000883BE )
+#define RSPI2_SPCMD0_ADDR	( ( volatile uint16_t __evenaccess * )0x000883D0 )
+#define RSPI2_SPCMD1_ADDR	( ( volatile uint16_t __evenaccess * )0x000883D2 )
+#define RSPI2_SPCMD2_ADDR	( ( volatile uint16_t __evenaccess * )0x000883D4 )
+#define RSPI2_SPCMD3_ADDR	( ( volatile uint16_t __evenaccess * )0x000883D6 )
+#define RSPI2_SPCMD4_ADDR	( ( volatile uint16_t __evenaccess * )0x000883D8 )
+#define RSPI2_SPCMD5_ADDR	( ( volatile uint16_t __evenaccess * )0x000883DA )
+#define RSPI2_SPCMD6_ADDR	( ( volatile uint16_t __evenaccess * )0x000883DC )
+#define RSPI2_SPCMD7_ADDR	( ( volatile uint16_t __evenaccess * )0x000883DE )
+#define RSPI_SPCMD_SPB_OFFSET	(8)
+#define RSPI_SPCMD_SPB_MASK (0xF << RSPI_SPCMD_SPB_OFFSET)
+
+/*
+ *  UARTé¢é£ã®å®ç¾©
+ *
+ *  pdicã®rx600/rx630_uart.cã§ä½¿ç¨ããï¼
+ */
+/*
+ *  ã·ãªã¢ã«I/Oã®åæ°
+ */
+#define TNUM_SIOP	( 2 )
+
+#endif	/* TOPPERS_RX630_H */
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.c
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.c	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.c	(revision 317)
@@ -0,0 +1,610 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013 by Mitsuhiro Matsuura
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ */
+
+#include "kernel_impl.h"
+
+
+/*
+ *  å²è¾¼ã¿è¦å ãã©ã¤ãªãªãã£ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ãã¼ãã«
+ */
+volatile uint8_t __evenaccess * const ipr_reg_addr[ INHNO_MAX ] = {
+	NULL,							/* No.0  äºç´ */
+	NULL,							/* No.1  äºç´ */
+	NULL,							/* No.2  äºç´ */
+	NULL,							/* No.3  äºç´ */
+	NULL,							/* No.4  äºç´ */
+	NULL,							/* No.5  äºç´ */
+	NULL,							/* No.6  äºç´ */
+	NULL,							/* No.7  äºç´ */
+	NULL,							/* No.8  äºç´ */
+	NULL,							/* No.9  äºç´ */
+	NULL,							/* No.10  äºç´ */
+	NULL,							/* No.11  äºç´ */
+	NULL,							/* No.12  äºç´ */
+	NULL,							/* No.13  äºç´ */
+	NULL,							/* No.14  äºç´ */
+	NULL,							/* No.15  äºç´ */
+	ICU_IPR000_ADDR,				/* No.16  ãã¹ã¨ã©ã¼ BUSERR */
+	NULL,							/* No.17  äºç´ */
+	NULL,							/* No.18  äºç´ */
+	NULL,							/* No.19  äºç´ */
+	NULL,							/* No.20  äºç´ */
+	ICU_IPR001_ADDR,				/* No.21  FCU FIFERR */
+	NULL,							/* No.22  äºç´ */
+	ICU_IPR002_ADDR,				/* No.23  FCU FRDYI */
+	NULL,							/* No.24  äºç´ */
+	NULL,							/* No.25  äºç´ */
+	NULL,							/* No.26  äºç´ */
+	ICU_IPR003_ADDR,				/* No.27  SWINT */
+	ICU_IPR004_ADDR,				/* No.28  CMTã¦ããã0 CMT0 */
+	ICU_IPR005_ADDR,				/* No.29  CMTã¦ããã0 CMT1 */
+	ICU_IPR006_ADDR,				/* No.30  CMTã¦ããã1 CMT2 */
+	ICU_IPR007_ADDR,				/* No.31  CMTã¦ããã1 CMT3 */
+	ICU_IPR032_ADDR,				/* No.32  ETHER */
+	ICU_IPR033_ADDR,				/* No.33  USB0 D0FIFO0 */
+	ICU_IPR034_ADDR,				/* No.34  USB0 D1FIFO0 */
+	ICU_IPR035_ADDR,				/* No.35  USB0 USBI0 */
+	ICU_IPR036_ADDR,				/* No.36  USB1 D0FIFO1 */
+	ICU_IPR037_ADDR,				/* No.37  USB1 D1FIFO1 */
+	ICU_IPR038_ADDR,				/* No.38  USB1 USBI1 */
+	ICU_IPR039_ADDR,				/* No.39  SPRI0 */
+	ICU_IPR039_ADDR,				/* No.40  SPTI0 */
+	ICU_IPR039_ADDR,				/* No.41  SPII0 */
+	ICU_IPR042_ADDR,				/* No.42  SPRI1 */
+	ICU_IPR042_ADDR,				/* No.43  SPTI1 */
+	ICU_IPR042_ADDR,				/* No.44  SPII1 */
+	ICU_IPR045_ADDR,				/* No.45  SPRI2 */
+	ICU_IPR045_ADDR,				/* No.46  SPTI2 */
+	ICU_IPR045_ADDR,				/* No.47  SPII2 */
+	ICU_IPR048_ADDR, 				/* No.48  CAN RXF0 */
+	ICU_IPR048_ADDR, 				/* No.49  CAN TXF0 */
+	ICU_IPR048_ADDR, 				/* No.50  CAN RXM0 */
+	ICU_IPR048_ADDR, 				/* No.51  CAN TXM0 */
+	ICU_IPR052_ADDR, 				/* No.52  CAN RXF1 */
+	ICU_IPR052_ADDR, 				/* No.53  CAN TXF1 */
+	ICU_IPR052_ADDR, 				/* No.54  CAN RXM1 */
+	ICU_IPR052_ADDR, 				/* No.55  CAN TXM1 */
+	ICU_IPR056_ADDR, 				/* No.56  CAN RXF2 */
+	ICU_IPR056_ADDR, 				/* No.57  CAN TXF2 */
+	ICU_IPR056_ADDR, 				/* No.58  CAN RXM2 */
+	ICU_IPR056_ADDR, 				/* No.59  CAN TXM2 */
+	NULL,							/* No.60  äºç´ */
+	NULL,							/* No.61  äºç´ */
+	ICU_IPR062_ADDR,			 	/* No.62  RTC PRD */
+	NULL,							/* No.63  äºç´ */
+	ICU_IPR064_ADDR,				/* No.64  å¤é¨ç«¯å­ IRQ0 */
+	ICU_IPR065_ADDR,				/* No.65  å¤é¨ç«¯å­ IRQ1 */
+	ICU_IPR066_ADDR,				/* No.66  å¤é¨ç«¯å­ IRQ2 */
+	ICU_IPR067_ADDR,				/* No.67  å¤é¨ç«¯å­ IRQ3 */
+	ICU_IPR068_ADDR,				/* No.68  å¤é¨ç«¯å­ IRQ4 */
+	ICU_IPR069_ADDR,				/* No.69  å¤é¨ç«¯å­ IRQ5 */
+	ICU_IPR070_ADDR,				/* No.70  å¤é¨ç«¯å­ IRQ6 */
+	ICU_IPR071_ADDR,				/* No.71  å¤é¨ç«¯å­ IRQ7 */
+	ICU_IPR072_ADDR,				/* No.72  å¤é¨ç«¯å­ IRQ8 */
+	ICU_IPR073_ADDR,				/* No.73  å¤é¨ç«¯å­ IRQ9 */
+	ICU_IPR074_ADDR,				/* No.74  å¤é¨ç«¯å­ IRQ10 */
+	ICU_IPR075_ADDR,				/* No.75  å¤é¨ç«¯å­ IRQ11 */
+	ICU_IPR076_ADDR,				/* No.76  å¤é¨ç«¯å­ IRQ12 */
+	ICU_IPR077_ADDR,				/* No.77  å¤é¨ç«¯å­ IRQ13 */
+	ICU_IPR078_ADDR,				/* No.78  å¤é¨ç«¯å­ IRQ14 */
+	ICU_IPR079_ADDR,				/* No.79  å¤é¨ç«¯å­ IRQ15 */
+	NULL,							/* No.80  äºç´ */
+	NULL,							/* No.81  äºç´ */
+	NULL,							/* No.82  äºç´ */
+	NULL,							/* No.83  äºç´ */
+	NULL,							/* No.84  äºç´ */
+	NULL,							/* No.85  äºç´ */
+	NULL,							/* No.86  äºç´ */
+	NULL,							/* No.87  äºç´ */
+	NULL,							/* No.88  äºç´ */
+	NULL,							/* No.89  äºç´ */
+	ICU_IPR090_ADDR, 				/* No.90  USBR0 */
+	ICU_IPR091_ADDR, 				/* No.91  USBR1 */
+	ICU_IPR092_ADDR,				/* No.92  RTC ALM */
+	ICU_IPR093_ADDR,				/* No.93  RTC PRD */
+	NULL,							/* No.94  äºç´ */
+	NULL,							/* No.95  äºç´ */
+	NULL,							/* No.96  äºç´ */
+	NULL,							/* No.97  äºç´ */
+	ICU_IPR098_ADDR,				/* No.98  AD ADI0 */
+	NULL,							/* No.99  äºç´ */
+	NULL,							/* No.100  äºç´ */
+	NULL,							/* No.101  äºç´ */
+	ICU_IPR102_ADDR,				/* No.102 S12AD S12ADIO */
+	NULL,							/* No.103  äºç´ */
+	NULL,							/* No.104  äºç´ */
+	NULL,							/* No.105  äºç´ */
+	ICU_IPR106_ADDR,				/* No.106 ICU GROUP0 */
+	ICU_IPR107_ADDR,				/* No.107 ICU GROUP1 */
+	ICU_IPR108_ADDR,				/* No.108 ICU GROUP2 */
+	ICU_IPR109_ADDR,				/* No.109 ICU GROUP3 */
+	ICU_IPR110_ADDR,				/* No.110 ICU GROUP4 */
+	ICU_IPR111_ADDR,				/* No.111 ICU GROUP5 */
+	ICU_IPR112_ADDR,				/* No.112 ICU GROUP6 */
+	NULL,							/* No.113  äºç´ */
+	ICU_IPR114_ADDR,				/* No.114 ICU GROUP12 */
+	NULL,							/* No.115  äºç´ */
+	NULL,							/* No.116  äºç´ */
+	NULL,							/* No.117  äºç´ */
+	NULL,							/* No.118  äºç´ */
+	NULL,							/* No.119  äºç´ */
+	NULL,							/* No.120  äºç´ */
+	NULL,							/* No.121  äºç´ */
+	ICU_IPR122_ADDR,				/* No.122 SCI12 SCIX0 */
+	ICU_IPR123_ADDR,				/* No.123 SCI12 SCIX1 */
+	ICU_IPR124_ADDR,				/* No.124 SCI12 SCIX2 */
+	ICU_IPR125_ADDR,				/* No.125 SCI12 SCIX3 */
+	ICU_IPR126_ADDR,				/* No.126 TPU0 TGI0A */
+	ICU_IPR126_ADDR,				/* No.127 TPU0 TGI0B */
+	ICU_IPR126_ADDR,				/* No.128 TPU0 TGI0C */
+	ICU_IPR126_ADDR,				/* No.129 TPU0 TGI0D */
+	ICU_IPR130_ADDR,				/* No.130 TPU1 TGI1A */
+	ICU_IPR130_ADDR,				/* No.131 TPU1 TGI1B */
+	ICU_IPR132_ADDR,				/* No.132 TPU2 TGI2A */
+	ICU_IPR132_ADDR,				/* No.133 TPU2 TGI2B */
+	ICU_IPR134_ADDR,				/* No.134 TPU3 TGI3A */
+	ICU_IPR134_ADDR,				/* No.135 TPU3 TGI3B */
+	ICU_IPR134_ADDR,				/* No.136 TPU3 TGI3C */
+	ICU_IPR134_ADDR,				/* No.137 TPU3 TGI3D */
+	ICU_IPR138_ADDR,				/* No.138 TPU4 TGI4A */
+	ICU_IPR138_ADDR,				/* No.139 TPU4 TGI4B */
+	ICU_IPR140_ADDR,				/* No.140 TPU5 TGI5A */
+	ICU_IPR140_ADDR,				/* No.141 TPU5 TGI5B */
+	ICU_IPR142_ADDR,				/* No.142 TPU6 TGI6A */
+	ICU_IPR142_ADDR,				/* No.143 TPU6 TGI6B */
+	ICU_IPR142_ADDR,				/* No.144 TPU6 TGI6C */
+	ICU_IPR142_ADDR,				/* No.145 TPU6 TGI6D */
+	ICU_IPR146_ADDR,				/* No.146 TGIE0 */
+	ICU_IPR146_ADDR,				/* No.147 TGIF0 */
+	ICU_IPR148_ADDR,				/* No.148 TPU7 TGI7A */
+	ICU_IPR148_ADDR,				/* No.149 TPU7 TGI7B */
+	ICU_IPR150_ADDR,				/* No.150 TPU8 TGI8A */
+	ICU_IPR150_ADDR,				/* No.151 TPU8 TGI8B */
+	ICU_IPR152_ADDR,				/* No.152 TPU9 TGI9A */
+	ICU_IPR152_ADDR,				/* No.153 TPU9 TGI9B */
+	ICU_IPR152_ADDR,				/* No.154 TPU9 TGI9C */
+	ICU_IPR152_ADDR,				/* No.155 TPU9 TGI9D */
+	ICU_IPR156_ADDR,				/* No.156 TPU10 TGI10A */
+	ICU_IPR156_ADDR,				/* No.157 TPU10 TGI10B */
+	ICU_IPR156_ADDR,				/* No.158 TGIC4 */
+	ICU_IPR156_ADDR,				/* No.159 TGID4 */
+	ICU_IPR160_ADDR,				/* No.160 TGIV4 */
+	ICU_IPR161_ADDR,				/* No.161 TGIU5 */
+	ICU_IPR162_ADDR,				/* No.162 TGIV5 */
+	ICU_IPR163_ADDR,				/* No.163 TGIW5 */
+	ICU_IPR164_ADDR,				/* No.164 TCI11A */
+	ICU_IPR165_ADDR,				/* No.165 TCI11B */
+	ICU_IPR167_ADDR,				/* No.166 POE OEI1 */
+	ICU_IPR167_ADDR,				/* No.167 POE OEI2 */
+	NULL,							/* No.168  äºç´ */
+	NULL,							/* No.169  äºç´ */
+	ICU_IPR170_ADDR,				/* No.170 TMR0 CMIA0 */
+	ICU_IPR170_ADDR,				/* No.171 TMR0 CMIB0 */
+	ICU_IPR170_ADDR,				/* No.172 TMR0 OVI0 */
+	ICU_IPR173_ADDR,				/* No.173 TMR1 CMIA1 */
+	ICU_IPR173_ADDR,				/* No.174 TMR1 CMIB1 */
+	ICU_IPR173_ADDR,				/* No.175 TMR1 OVI1 */
+	ICU_IPR176_ADDR,				/* No.176 TMR2 CMIA2 */
+	ICU_IPR176_ADDR,				/* No.177 TMR2 CMIB2 */
+	ICU_IPR176_ADDR,				/* No.178 TMR2 OVI2 */
+	ICU_IPR179_ADDR,				/* No.179 TMR3 CMIA3 */
+	ICU_IPR179_ADDR,				/* No.180 TMR3 CMIB3 */
+	ICU_IPR179_ADDR,				/* No.181 TMR3 OVI3 */
+	ICU_IPR182_ADDR,				/* No.182 RIIC0 EEI0 */
+	ICU_IPR183_ADDR,				/* No.183 RIIC0 RXI0 */
+	ICU_IPR184_ADDR,				/* No.184 RIIC0 TXI0 */
+	ICU_IPR185_ADDR,				/* No.185 RIIC0 TEI0 */
+	ICU_IPR186_ADDR,				/* No.186 RIIC0 EEI1 */
+	ICU_IPR187_ADDR,				/* No.187 RIIC0 RXI1 */
+	ICU_IPR188_ADDR,				/* No.188 RIIC0 TXI1 */
+	ICU_IPR189_ADDR,				/* No.189 RIIC0 TEI1 */
+	ICU_IPR190_ADDR,				/* No.190 RIIC0 EEI2 */
+	ICU_IPR191_ADDR,				/* No.191 RIIC0 RXI2 */
+	ICU_IPR192_ADDR,				/* No.192 RIIC0 TXI2 */
+	ICU_IPR193_ADDR,				/* No.193 RIIC0 TEI2 */
+	ICU_IPR194_ADDR,				/* No.194 RIIC0 EEI3 */
+	ICU_IPR195_ADDR,				/* No.195 RIIC0 RXI3 */
+	ICU_IPR196_ADDR,				/* No.196 RIIC0 TXI3 */
+	ICU_IPR197_ADDR,				/* No.197 RIIC0 TEI3 */
+	ICU_IPR198_ADDR,				/* No.198 DMAC DMTEND0 */
+	ICU_IPR199_ADDR,				/* No.199 DMAC DMTEND1 */
+	ICU_IPR200_ADDR,				/* No.200 DMAC DMTEND2 */
+	ICU_IPR201_ADDR,				/* No.201 DMAC DMTEND3 */
+	ICU_IPR202_ADDR,				/* No.202 EXDMAC EXDMACI0 */
+	ICU_IPR203_ADDR,				/* No.203 EXDMAC EXDMACI1 */
+	NULL,							/* No.204  äºç´ */
+	NULL,							/* No.205  äºç´ */
+	NULL,							/* No.206  äºç´ */
+	NULL,							/* No.207  äºç´ */
+	NULL,							/* No.208  äºç´ */
+	NULL,							/* No.209  äºç´ */
+	NULL,							/* No.210  äºç´ */
+	NULL,							/* No.211  äºç´ */
+	NULL,							/* No.212  äºç´ */
+	NULL,							/* No.213  äºç´ */
+	ICU_IPR214_ADDR,				/* No.214 SCI0 RXI0 */
+	ICU_IPR214_ADDR,				/* No.215 SCI0 TXI0 */
+	ICU_IPR214_ADDR,				/* No.216 SCI0 TEI0 */
+	ICU_IPR217_ADDR,				/* No.217 SCI1 RXI1 */
+	ICU_IPR217_ADDR,				/* No.218 SCI1 TXI1 */
+	ICU_IPR217_ADDR,				/* No.219 SCI1 TEI1 */
+	ICU_IPR220_ADDR,				/* No.220 SCI2 RXI2 */
+	ICU_IPR220_ADDR,				/* No.221 SCI2 TXI2 */
+	ICU_IPR220_ADDR,				/* No.222 SCI2 TEI2 */
+	ICU_IPR223_ADDR,				/* No.223 SCI3 RXI3 */
+	ICU_IPR223_ADDR,				/* No.224 SCI3 TXI3 */
+	ICU_IPR223_ADDR,				/* No.225 SCI3 TEI3 */
+	ICU_IPR226_ADDR,				/* No.226 SCI4 RXI4 */
+	ICU_IPR226_ADDR,				/* No.227 SCI4 TXI4 */
+	ICU_IPR226_ADDR,				/* No.228 SCI4 TEI4 */
+	ICU_IPR229_ADDR,				/* No.229 SCI5 RXI5 */
+	ICU_IPR229_ADDR,				/* No.230 SCI5 TXI5 */
+	ICU_IPR229_ADDR,				/* No.231 SCI5 TEI5 */
+	ICU_IPR232_ADDR,				/* No.232 SCI6 RXI6 */
+	ICU_IPR232_ADDR,				/* No.233 SCI6 TXI6 */
+	ICU_IPR232_ADDR,				/* No.234 SCI6 TEI6 */
+	ICU_IPR235_ADDR,				/* No.235 SCI7 RXI7 */
+	ICU_IPR235_ADDR,				/* No.236 SCI7 TXI7 */
+	ICU_IPR235_ADDR,				/* No.237 SCI7 TEI7 */
+	ICU_IPR238_ADDR,				/* No.238 SCI8 RXI8 */
+	ICU_IPR238_ADDR,				/* No.239 SCI8 TXI8 */
+	ICU_IPR238_ADDR,				/* No.240 SCI8 TEI8 */
+	ICU_IPR241_ADDR,				/* No.241 SCI9 RXI9 */
+	ICU_IPR241_ADDR,				/* No.242 SCI9 TXI9 */
+	ICU_IPR241_ADDR,				/* No.243 SCI9 TEI9 */
+	ICU_IPR244_ADDR,				/* No.244 SCI10 RXI10 */
+	ICU_IPR244_ADDR,				/* No.245 SCI10 TXI10 */
+	ICU_IPR244_ADDR,				/* No.246 SCI10 TEI10 */
+	ICU_IPR247_ADDR,				/* No.247 SCI11 RXI11 */
+	ICU_IPR247_ADDR,				/* No.248 SCI11 TXI11 */
+	ICU_IPR247_ADDR,				/* No.249 SCI11 TEI11 */
+	ICU_IPR250_ADDR,				/* No.250 SCI12 RXI12 */
+	ICU_IPR250_ADDR,				/* No.251 SCI12 TXI12 */
+	ICU_IPR250_ADDR,				/* No.252 SCI12 TEI12 */
+	ICU_IPR253_ADDR,				/* No.253 IEB IEBINT */
+	NULL,							/* No.254  äºç´ */
+	NULL,							/* No.255  äºç´ */
+};
+
+
+/*
+ *  å²è¾¼ã¿è¦æ±è¨±å¯ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ãã¼ãã«
+ */
+const IER_INFO ier_reg_addr[ INHNO_MAX ] = {
+	{ NULL, INVALID_OFFSET },			/* No.0   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.1   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.2   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.3   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.4   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.5   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.6   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.7   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.8   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.9   äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.10  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.11  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.12  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.13  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.14  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.15  äºç´ */
+	{ ICU_IER02_ADDR, ICU_IEN0_BIT },	/* No.16  ãã¹ã¨ã©ã¼ BUSERR */
+	{ NULL, INVALID_OFFSET },			/* No.17  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.18  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.19  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.20  äºç´ */
+	{ ICU_IER02_ADDR, ICU_IEN5_BIT },	/* No.21  FCU FIFERR */
+	{ NULL, INVALID_OFFSET },			/* No.22  äºç´ */
+	{ ICU_IER02_ADDR, ICU_IEN7_BIT },	/* No.23  FCU FRDYI */
+	{ NULL, INVALID_OFFSET },			/* No.24  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.25  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.26  äºç´ */
+	{ ICU_IER03_ADDR, ICU_IEN3_BIT },	/* No.27  SWINT */
+	{ ICU_IER03_ADDR, ICU_IEN4_BIT },	/* No.28  CMTã¦ããã0 CMT0 */
+	{ ICU_IER03_ADDR, ICU_IEN5_BIT },	/* No.29  CMTã¦ããã0 CMT1 */
+	{ ICU_IER03_ADDR, ICU_IEN6_BIT },	/* No.30  CMTã¦ããã1 CMT2 */
+	{ ICU_IER03_ADDR, ICU_IEN7_BIT },	/* No.31  CMTã¦ããã1 CMT3 */
+	{ ICU_IER04_ADDR, ICU_IEN0_BIT },	/* No.32  ETHER */
+	{ ICU_IER04_ADDR, ICU_IEN1_BIT },	/* No.33  USB0 D0FIFO0 */
+	{ ICU_IER04_ADDR, ICU_IEN2_BIT },	/* No.34  USB0 D1FIFO0 */
+	{ ICU_IER04_ADDR, ICU_IEN3_BIT },	/* No.35  USB0 USBI0 */
+	{ ICU_IER04_ADDR, ICU_IEN4_BIT },	/* No.36  USB1 D0FIFO1 */
+	{ ICU_IER04_ADDR, ICU_IEN5_BIT },	/* No.37  USB1 D1FIFO1 */
+	{ ICU_IER04_ADDR, ICU_IEN6_BIT },	/* No.38  USB1 USBI1 */
+	{ ICU_IER04_ADDR, ICU_IEN7_BIT },	/* No.39  RSPI0 SPRI0 */
+	{ ICU_IER05_ADDR, ICU_IEN0_BIT },	/* No.40  RSPI0 SPTI0 */
+	{ ICU_IER05_ADDR, ICU_IEN1_BIT },	/* No.41  RSPI0 SPII0 */
+	{ ICU_IER05_ADDR, ICU_IEN2_BIT },	/* No.42  RSPI1 SPRI1 */
+	{ ICU_IER05_ADDR, ICU_IEN3_BIT },	/* No.43  RSPI1 SPTI1 */
+	{ ICU_IER05_ADDR, ICU_IEN4_BIT },	/* No.44  RSPI1 SPII1 */
+	{ ICU_IER05_ADDR, ICU_IEN5_BIT },	/* No.45  RSPI2 SPRI2 */
+	{ ICU_IER05_ADDR, ICU_IEN6_BIT },	/* No.46  RSPI2 SPTI2 */
+	{ ICU_IER05_ADDR, ICU_IEN7_BIT },	/* No.47  RSPI2 SPII2 */
+	{ ICU_IER06_ADDR, ICU_IEN0_BIT },	/* No.48  CAN0 RXF0 */
+	{ ICU_IER06_ADDR, ICU_IEN1_BIT },	/* No.49  CAN0 TXF0 */
+	{ ICU_IER06_ADDR, ICU_IEN2_BIT },	/* No.50  CAN0 RXM0 */
+	{ ICU_IER06_ADDR, ICU_IEN3_BIT },	/* No.51  CAN0 TXM0 */
+	{ ICU_IER06_ADDR, ICU_IEN4_BIT },	/* No.52  CAN1 RXF1 */
+	{ ICU_IER06_ADDR, ICU_IEN5_BIT },	/* No.53  CAN1 TXF1 */
+	{ ICU_IER06_ADDR, ICU_IEN6_BIT },	/* No.54  CAN1 RXM1 */
+	{ ICU_IER06_ADDR, ICU_IEN7_BIT },	/* No.55  CAN1 TXM1 */
+	{ ICU_IER07_ADDR, ICU_IEN0_BIT },	/* No.56  CAN2 RXF2 */
+	{ ICU_IER07_ADDR, ICU_IEN1_BIT },	/* No.57  CAN2 TXF2 */
+	{ ICU_IER07_ADDR, ICU_IEN2_BIT },	/* No.58  CAN2 RXM2 */
+	{ ICU_IER07_ADDR, ICU_IEN3_BIT },	/* No.59  CAN2 TXM2 */
+	{ NULL, INVALID_OFFSET },			/* No.60  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.61  äºç´ */
+	{ ICU_IER07_ADDR, ICU_IEN6_BIT },	/* No.62  RTC PRD */
+	{ NULL, INVALID_OFFSET },			/* No.63  äºç´ */
+	{ ICU_IER08_ADDR, ICU_IEN0_BIT },	/* No.64  å¤é¨ç«¯å­ IRQ0 */
+	{ ICU_IER08_ADDR, ICU_IEN1_BIT },	/* No.65  å¤é¨ç«¯å­ IRQ1 */
+	{ ICU_IER08_ADDR, ICU_IEN2_BIT },	/* No.66  å¤é¨ç«¯å­ IRQ2 */
+	{ ICU_IER08_ADDR, ICU_IEN3_BIT },	/* No.67  å¤é¨ç«¯å­ IRQ3 */
+	{ ICU_IER08_ADDR, ICU_IEN4_BIT },	/* No.68  å¤é¨ç«¯å­ IRQ4 */
+	{ ICU_IER08_ADDR, ICU_IEN5_BIT },	/* No.69  å¤é¨ç«¯å­ IRQ5 */
+	{ ICU_IER08_ADDR, ICU_IEN6_BIT },	/* No.70  å¤é¨ç«¯å­ IRQ6 */
+	{ ICU_IER08_ADDR, ICU_IEN7_BIT },	/* No.71  å¤é¨ç«¯å­ IRQ7 */
+	{ ICU_IER09_ADDR, ICU_IEN0_BIT },	/* No.72  å¤é¨ç«¯å­ IRQ8 */
+	{ ICU_IER09_ADDR, ICU_IEN1_BIT },	/* No.73  å¤é¨ç«¯å­ IRQ9 */
+	{ ICU_IER09_ADDR, ICU_IEN2_BIT },	/* No.74  å¤é¨ç«¯å­ IRQ10 */
+	{ ICU_IER09_ADDR, ICU_IEN3_BIT },	/* No.75  å¤é¨ç«¯å­ IRQ11 */
+	{ ICU_IER09_ADDR, ICU_IEN4_BIT },	/* No.76  å¤é¨ç«¯å­ IRQ12 */
+	{ ICU_IER09_ADDR, ICU_IEN5_BIT },	/* No.77  å¤é¨ç«¯å­ IRQ13 */
+	{ ICU_IER09_ADDR, ICU_IEN6_BIT },	/* No.78  å¤é¨ç«¯å­ IRQ14 */
+	{ ICU_IER09_ADDR, ICU_IEN7_BIT },	/* No.79  å¤é¨ç«¯å­ IRQ15 */
+	{ NULL, INVALID_OFFSET },			/* No.80  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.81  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.82  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.83  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.84  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.85  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.86  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.87  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.88  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.89  äºç´ */
+	{ ICU_IER0B_ADDR, ICU_IEN2_BIT },	/* No.90  USBR0 */
+	{ ICU_IER0B_ADDR, ICU_IEN3_BIT },	/* No.91  USBR1 */
+	{ ICU_IER0B_ADDR, ICU_IEN4_BIT },	/* No.92  RTC ALM */
+	{ ICU_IER0B_ADDR, ICU_IEN5_BIT },	/* No.92  RTC PRD */
+	{ NULL, INVALID_OFFSET },			/* No.94  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.95  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.96  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.97  äºç´ */
+	{ ICU_IER0C_ADDR, ICU_IEN2_BIT },	/* No.98  AD0 ADI0 */
+	{ NULL, INVALID_OFFSET },			/* No.99  äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.100 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.101 äºç´ */
+	{ ICU_IER0C_ADDR, ICU_IEN6_BIT },	/* No.102 S12AD S12ADI00 */
+	{ NULL, INVALID_OFFSET },			/* No.103 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.104 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.105 äºç´ */
+	{ ICU_IER0D_ADDR, ICU_IEN2_BIT },	/* No.106 ICU GROUP0 */
+	{ ICU_IER0D_ADDR, ICU_IEN3_BIT },	/* No.107 ICU GROUP1 */
+	{ ICU_IER0D_ADDR, ICU_IEN4_BIT },	/* No.108 ICU GROUP2 */
+	{ ICU_IER0D_ADDR, ICU_IEN5_BIT },	/* No.109 ICU GROUP3 */
+	{ ICU_IER0D_ADDR, ICU_IEN6_BIT },	/* No.110 ICU GROUP4 */
+	{ ICU_IER0D_ADDR, ICU_IEN7_BIT },	/* No.111 ICU GROUP5 */
+	{ ICU_IER0E_ADDR, ICU_IEN0_BIT },	/* No.112 ICU GROUP6 */
+	{ NULL, INVALID_OFFSET },			/* No.113 äºç´ */
+	{ ICU_IER0E_ADDR, ICU_IEN1_BIT },	/* No.114 ICU GROUP12 */
+	{ NULL, INVALID_OFFSET },			/* No.115 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.116 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.117 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.118 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.119 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.120 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.121 äºç´ */
+	{ ICU_IER0F_ADDR, ICU_IEN2_BIT },	/* No.122 SCI12 SCIX0 */
+	{ ICU_IER0F_ADDR, ICU_IEN3_BIT },	/* No.123 SCI12 SCIX1 */
+	{ ICU_IER0F_ADDR, ICU_IEN4_BIT },	/* No.124 SCI12 SCIX2 */
+	{ ICU_IER0F_ADDR, ICU_IEN5_BIT },	/* No.125 SCI12 SCIX3 */
+	{ ICU_IER0F_ADDR, ICU_IEN6_BIT },	/* No.126 TPU0 TGI0A */
+	{ ICU_IER0F_ADDR, ICU_IEN7_BIT },	/* No.127 TPU0 TGI0B */
+	{ ICU_IER10_ADDR, ICU_IEN0_BIT },	/* No.128 TPU0 TGI0C */
+	{ ICU_IER10_ADDR, ICU_IEN1_BIT },	/* No.129 TPU0 TGI0D */
+	{ ICU_IER10_ADDR, ICU_IEN2_BIT },	/* No.130 TPU1 TGI1A */
+	{ ICU_IER10_ADDR, ICU_IEN3_BIT },	/* No.131 TPU1 TGI1B */
+	{ ICU_IER10_ADDR, ICU_IEN4_BIT },	/* No.132 TPU2 TGI2A */
+	{ ICU_IER10_ADDR, ICU_IEN5_BIT },	/* No.133 TPU2 TGI2B */
+	{ ICU_IER10_ADDR, ICU_IEN6_BIT },	/* No.134 TPU3 TGI3A */
+	{ ICU_IER10_ADDR, ICU_IEN7_BIT },	/* No.135 TPU3 TGI3B */
+	{ ICU_IER11_ADDR, ICU_IEN0_BIT },	/* No.136 TPU3 TGI3C */
+	{ ICU_IER11_ADDR, ICU_IEN1_BIT },	/* No.137 TPU3 TGI3D */
+	{ ICU_IER11_ADDR, ICU_IEN2_BIT },	/* No.138 TPU4 TGI4A */
+	{ ICU_IER11_ADDR, ICU_IEN3_BIT },	/* No.139 TPU4 TGI4B */
+	{ ICU_IER11_ADDR, ICU_IEN4_BIT },	/* No.140 TPU5 TGI5A */
+	{ ICU_IER11_ADDR, ICU_IEN5_BIT },	/* No.141 TPU5 TGI5B */
+	{ ICU_IER11_ADDR, ICU_IEN6_BIT },	/* No.142 TPU6 TGI6A */
+	{ ICU_IER11_ADDR, ICU_IEN7_BIT },	/* No.143 TPU6 TGI6B */
+	{ ICU_IER12_ADDR, ICU_IEN0_BIT },	/* No.144 TPU6 TGI6C */
+	{ ICU_IER12_ADDR, ICU_IEN1_BIT },	/* No.145 TPU6 TGI6D */
+	{ ICU_IER12_ADDR, ICU_IEN2_BIT },	/* No.146 TPU6 TGIE0 */
+	{ ICU_IER12_ADDR, ICU_IEN3_BIT },	/* No.147 TPU6 TGIF0 */
+	{ ICU_IER12_ADDR, ICU_IEN4_BIT },	/* No.148 TPU7 TGI7A */
+	{ ICU_IER12_ADDR, ICU_IEN5_BIT },	/* No.149 TPU7 TGI7B */
+	{ ICU_IER12_ADDR, ICU_IEN6_BIT },	/* No.150 TPU8 TGI8A */
+	{ ICU_IER12_ADDR, ICU_IEN7_BIT },	/* No.151 TPU8 TGI8B */
+	{ ICU_IER13_ADDR, ICU_IEN0_BIT },	/* No.152 TPU9 TGI9A */
+	{ ICU_IER13_ADDR, ICU_IEN1_BIT },	/* No.153 TPU9 TGI9B */
+	{ ICU_IER13_ADDR, ICU_IEN2_BIT },	/* No.154 TPU9 TGI9C */
+	{ ICU_IER13_ADDR, ICU_IEN3_BIT },	/* No.155 TPU9 TGI9D */
+	{ ICU_IER13_ADDR, ICU_IEN4_BIT },	/* No.156 TPU10 TGI10A */
+	{ ICU_IER13_ADDR, ICU_IEN5_BIT },	/* No.157 TPU10 TGI10B */
+	{ ICU_IER13_ADDR, ICU_IEN6_BIT },	/* No.158 TPU10 TGIC4 */
+	{ ICU_IER13_ADDR, ICU_IEN7_BIT },	/* No.159 TPU10 TGID4 */
+	{ ICU_IER14_ADDR, ICU_IEN0_BIT },	/* No.160 TPU10 TGIV4 */
+	{ ICU_IER14_ADDR, ICU_IEN1_BIT },	/* No.161 TPU11 TGIU5 */
+	{ ICU_IER14_ADDR, ICU_IEN2_BIT },	/* No.162 TPU11 TGIV5 */
+	{ ICU_IER14_ADDR, ICU_IEN3_BIT },	/* No.163 TPU11 TGIW5 */
+	{ ICU_IER14_ADDR, ICU_IEN4_BIT },	/* No.164 TPU11 TCI11A */
+	{ ICU_IER14_ADDR, ICU_IEN5_BIT },	/* No.165 TPU11 TCI11B */
+	{ ICU_IER14_ADDR, ICU_IEN6_BIT },	/* No.166 POE OEI1 */
+	{ ICU_IER14_ADDR, ICU_IEN7_BIT },	/* No.167 POE OEI2 */
+	{ NULL, INVALID_OFFSET },			/* No.168 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.169 äºç´ */
+	{ ICU_IER15_ADDR, ICU_IEN2_BIT },	/* No.170 TMR0 CMIA0 */
+	{ ICU_IER15_ADDR, ICU_IEN3_BIT },	/* No.171 TMR0 CMIB0 */
+	{ ICU_IER15_ADDR, ICU_IEN4_BIT },	/* No.172 TMR0 OVI0 */
+	{ ICU_IER15_ADDR, ICU_IEN5_BIT },	/* No.173 TMR1 CMIA1 */
+	{ ICU_IER15_ADDR, ICU_IEN6_BIT },	/* No.174 TMR1 CMIB1 */
+	{ ICU_IER15_ADDR, ICU_IEN7_BIT },	/* No.175 TMR1 OVI1 */
+	{ ICU_IER16_ADDR, ICU_IEN0_BIT },	/* No.176 TMR2 CMIA2 */
+	{ ICU_IER16_ADDR, ICU_IEN1_BIT },	/* No.177 TMR2 CMIB2 */
+	{ ICU_IER16_ADDR, ICU_IEN2_BIT },	/* No.178 TMR2 OVI2 */
+	{ ICU_IER16_ADDR, ICU_IEN3_BIT },	/* No.179 TMR3 CMIA3 */
+	{ ICU_IER16_ADDR, ICU_IEN4_BIT },	/* No.180 TMR3 CMIB3 */
+	{ ICU_IER16_ADDR, ICU_IEN5_BIT },	/* No.181 TMR3 OVI3 */
+	{ ICU_IER16_ADDR, ICU_IEN6_BIT },	/* No.182 RIIC0 EEI0 */
+	{ ICU_IER16_ADDR, ICU_IEN7_BIT },	/* No.183 RIIC0 RXI0 */
+	{ ICU_IER17_ADDR, ICU_IEN0_BIT },	/* No.184 RIIC0 TXI0 */
+	{ ICU_IER17_ADDR, ICU_IEN1_BIT },	/* No.185 RIIC0 TEI0 */
+	{ ICU_IER17_ADDR, ICU_IEN2_BIT },	/* No.186 RIIC0 EEI1 */
+	{ ICU_IER17_ADDR, ICU_IEN3_BIT },	/* No.187 RIIC0 RXI1 */
+	{ ICU_IER17_ADDR, ICU_IEN4_BIT },	/* No.188 RIIC0 TXI1 */
+	{ ICU_IER17_ADDR, ICU_IEN5_BIT },	/* No.189 RIIC0 TEI1 */
+	{ ICU_IER17_ADDR, ICU_IEN6_BIT },	/* No.190 RIIC0 EEI2 */
+	{ ICU_IER17_ADDR, ICU_IEN7_BIT },	/* No.191 RIIC0 RXI2 */
+	{ ICU_IER18_ADDR, ICU_IEN0_BIT },	/* No.192 RIIC0 TXI2 */
+	{ ICU_IER18_ADDR, ICU_IEN1_BIT },	/* No.193 RIIC0 TEI2 */
+	{ ICU_IER18_ADDR, ICU_IEN2_BIT },	/* No.194 RIIC0 EEI3 */
+	{ ICU_IER18_ADDR, ICU_IEN3_BIT },	/* No.195 RIIC0 RXI3 */
+	{ ICU_IER18_ADDR, ICU_IEN4_BIT },	/* No.196 RIIC0 TXI3 */
+	{ ICU_IER18_ADDR, ICU_IEN5_BIT },	/* No.197 RIIC0 TEI3 */
+	{ ICU_IER18_ADDR, ICU_IEN6_BIT },	/* No.198 DMAC DMAC0I */
+	{ ICU_IER18_ADDR, ICU_IEN7_BIT },	/* No.199 DMAC DMAC1I */
+	{ ICU_IER19_ADDR, ICU_IEN0_BIT },	/* No.200 DMAC DMAC2I */
+	{ ICU_IER19_ADDR, ICU_IEN1_BIT },	/* No.201 DMAC DMAC3I */
+	{ ICU_IER19_ADDR, ICU_IEN2_BIT },	/* No.202 EXDMAC EXDMAC0I */
+	{ ICU_IER19_ADDR, ICU_IEN3_BIT },	/* No.203 EXDMAC EXDMAC1I */
+	{ NULL, INVALID_OFFSET },			/* No.204 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.205 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.206 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.207 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.208 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.209 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.210 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.211 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.212 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.213 äºç´ */
+	{ ICU_IER1A_ADDR, ICU_IEN6_BIT },	/* No.214 SCI0 RXI0 */
+	{ ICU_IER1A_ADDR, ICU_IEN7_BIT },	/* No.215 SCI0 TXI0 */
+	{ ICU_IER1B_ADDR, ICU_IEN0_BIT },	/* No.216 SCI0 TEI0 */
+	{ ICU_IER1B_ADDR, ICU_IEN1_BIT },	/* No.217 SCI1 RXI1 */
+	{ ICU_IER1B_ADDR, ICU_IEN2_BIT },	/* No.228 SCI1 TXI1 */
+	{ ICU_IER1B_ADDR, ICU_IEN3_BIT },	/* No.229 SCI1 TEI1 */
+	{ ICU_IER1B_ADDR, ICU_IEN4_BIT },	/* No.220 SCI2 RXI2 */
+	{ ICU_IER1B_ADDR, ICU_IEN5_BIT },	/* No.221 SCI2 TXI2 */
+	{ ICU_IER1B_ADDR, ICU_IEN6_BIT },	/* No.222 SCI2 TEI2 */
+	{ ICU_IER1B_ADDR, ICU_IEN7_BIT },	/* No.223 SCI3 RXI3 */
+	{ ICU_IER1C_ADDR, ICU_IEN0_BIT },	/* No.224 SCI3 TXI3 */
+	{ ICU_IER1C_ADDR, ICU_IEN1_BIT },	/* No.225 SCI3 TEI3 */
+	{ ICU_IER1C_ADDR, ICU_IEN2_BIT },	/* No.226 SCI4 RXI4 */
+	{ ICU_IER1C_ADDR, ICU_IEN3_BIT },	/* No.227 SCI4 TXI4 */
+	{ ICU_IER1C_ADDR, ICU_IEN4_BIT },	/* No.228 SCI4 TEI4 */
+	{ ICU_IER1C_ADDR, ICU_IEN5_BIT },	/* No.229 SCI5 RXI5 */
+	{ ICU_IER1C_ADDR, ICU_IEN6_BIT },	/* No.230 SCI5 TXI5 */
+	{ ICU_IER1C_ADDR, ICU_IEN7_BIT },	/* No.231 SCI5 TEI5 */
+	{ ICU_IER1D_ADDR, ICU_IEN0_BIT },	/* No.232 SCI6 RXI6 */
+	{ ICU_IER1D_ADDR, ICU_IEN1_BIT },	/* No.233 SCI6 TXI6 */
+	{ ICU_IER1D_ADDR, ICU_IEN2_BIT },	/* No.234 SCI6 TEI6 */
+	{ ICU_IER1D_ADDR, ICU_IEN3_BIT },	/* No.235 SCI7 RXI7 */
+	{ ICU_IER1D_ADDR, ICU_IEN4_BIT },	/* No.236 SCI7 TXI7 */
+	{ ICU_IER1D_ADDR, ICU_IEN5_BIT },	/* No.237 SCI7 TEI7 */
+	{ ICU_IER1D_ADDR, ICU_IEN6_BIT },	/* No.238 SCI8 RXI8 */
+	{ ICU_IER1D_ADDR, ICU_IEN7_BIT },	/* No.239 SCI8 TXI8 */
+	{ ICU_IER1E_ADDR, ICU_IEN0_BIT },	/* No.240 SCI8 TEI8 */
+	{ ICU_IER1E_ADDR, ICU_IEN1_BIT },	/* No.241 SCI9 RXI9 */
+	{ ICU_IER1E_ADDR, ICU_IEN2_BIT },	/* No.242 SCI9 TXI9 */
+	{ ICU_IER1E_ADDR, ICU_IEN3_BIT },	/* No.243 SCI9 TEI9 */
+	{ ICU_IER1E_ADDR, ICU_IEN4_BIT },	/* No.244 SCI10 RXI10 */
+	{ ICU_IER1E_ADDR, ICU_IEN5_BIT },	/* No.245 SCI10 TXI10 */
+	{ ICU_IER1E_ADDR, ICU_IEN6_BIT },	/* No.246 SCI10 TEI10 */
+	{ ICU_IER1E_ADDR, ICU_IEN7_BIT },	/* No.247 SCI11 RXI11 */
+	{ ICU_IER1F_ADDR, ICU_IEN0_BIT },	/* No.248 SCI11 TXI11 */
+	{ ICU_IER1F_ADDR, ICU_IEN1_BIT },	/* No.249 SCI11 TEI11 */
+	{ ICU_IER1F_ADDR, ICU_IEN2_BIT },	/* No.250 SCI12 RXI12 */
+	{ ICU_IER1F_ADDR, ICU_IEN3_BIT },	/* No.251 SCI12 TXI12 */
+	{ ICU_IER1F_ADDR, ICU_IEN4_BIT },	/* No.252 SCI12 TEI12 */
+	{ ICU_IER1F_ADDR, ICU_IEN5_BIT },	/* No.253 IEB IEBINT */
+	{ NULL, INVALID_OFFSET },			/* No.254 äºç´ */
+	{ NULL, INVALID_OFFSET },			/* No.255 äºç´ */
+};
+
+
+/*
+ *  IRQã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ãã¼ãã«
+ */
+volatile uint8_t __evenaccess * const irqcr_reg_addr[ IRQ_MAX ] = {
+	ICU_IRQ0_ADDR,
+	ICU_IRQ1_ADDR,
+	ICU_IRQ2_ADDR,
+	ICU_IRQ3_ADDR,
+	ICU_IRQ4_ADDR,
+	ICU_IRQ5_ADDR,
+	ICU_IRQ6_ADDR,
+	ICU_IRQ7_ADDR,
+	ICU_IRQ8_ADDR,
+	ICU_IRQ9_ADDR,
+	ICU_IRQ10_ADDR,
+	ICU_IRQ11_ADDR,
+	ICU_IRQ12_ADDR,
+	ICU_IRQ13_ADDR,
+	ICU_IRQ14_ADDR,
+	ICU_IRQ15_ADDR,
+};
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/rx630_kernel_impl.h	(revision 317)
@@ -0,0 +1,120 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼target_kernel_impl.hï¼ã¾ãã¯ï¼ããããã¤ã³ã¯
+ *  ã«ã¼ãããããã¡ã¤ã«ï¼ã®ã¿ããã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡ã¤ã«ãã
+ *  ç´æ¥ã¤ã³ã¯ã«ã¼ããã¦ã¯ãªããªãï¼
+ */
+
+
+#ifndef TOPPERS_RX630_CONFIG_H
+#define TOPPERS_RX630_CONFIG_H
+
+
+/*
+ *  å²è¾¼ã¿è¦å æ°
+ */
+#define	INHNO_MAX	UINT_C( 256 )
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  å²è¾¼ã¿å¶å¾¡ç¨åå®ç¾©
+ */
+typedef struct ier_info {
+	volatile uint8_t __evenaccess	*addr;
+			 uint8_t				offset;
+} IER_INFO;
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  å²è¾¼ã¿å¶å¾¡ç¨å®ç¾©
+ */
+#define	INVALID_OFFSET				( 0xFFU )
+#define	INTNO_IRQ( intno )			( ( 64U <= ( intno ) ) && ( ( intno ) <= 79U ) )
+#define	INTNO_IRQ_OFFSET( intno )	( ( intno ) - 64U )
+#define	IRQ_MAX						UINT_C( 16 )
+
+#define IR_TOP						(0x00087010)
+#define IR_REG( intno )				((volatile uint8_t __evenaccess * )(IR_TOP + (intno-16)))
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  å²è¾¼ã¿å¶å¾¡ç¨ãã¼ãã«
+ */
+
+/* å²è¾¼ã¿è¦å ãã©ã¤ãªãªãã£ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ */
+extern volatile uint8_t __evenaccess * const ipr_reg_addr[];
+/* å²è¾¼ã¿è¦æ±è¨±å¯ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ */
+extern const IER_INFO ier_reg_addr[];
+/* å²è¾¼ã¿è¦æ±ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ */
+extern volatile uint8_t __evenaccess * const ir_reg_addr[];
+/* IRQã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ */
+extern volatile uint8_t __evenaccess * const irqcr_reg_addr[];
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ */
+#include "prc_kernel_impl.h"
+
+#endif	/* TOPPERS_RX630_CONFIG_H */
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/scif.h
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/scif.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/scif.h	(revision 317)
@@ -0,0 +1,141 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ *
+ *  Copyright (C) 2001-2011 by Industrial Technology Institute,
+ *                              Miyagi Prefectural Government, JAPAN
+ *  Copyright (C) 2007-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ *
+ *  $Id$
+ */
+
+/*
+ *		FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ã«é¢ããå®ç¾©
+ */
+
+#ifndef TOPPERS_SCIF_H
+#define TOPPERS_SCIF_H
+
+/*
+ *  SCIã¬ã¸ã¹ã¿ã®ãã¼ã¹çªå°ã®å®ç¾©
+ */
+#define SCI0_BASE	((uint32_t)(SCI0_SMR_ADDR))
+#define SCI1_BASE	((uint32_t)(SCI1_SMR_ADDR))
+#define SCI2_BASE	((uint32_t)(SCI2_SMR_ADDR))
+#define SCI3_BASE	((uint32_t)(SCI3_SMR_ADDR))
+#define SCI4_BASE	((uint32_t)(SCI4_SMR_ADDR))
+#define SCI5_BASE	((uint32_t)(SCI5_SMR_ADDR))
+#define SCI6_BASE	((uint32_t)(SCI6_SMR_ADDR))
+
+/* ã¢ã¸ã¥ã¼ã«ã¹ãããã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿B bit */
+#define SCI_NUM(base)	((base - SCI0_BASE) / 0x20)
+#define SCI_MSTPCRB_BIT(base)	(1 << (31 - SCI_NUM(base)))
+
+/* æå®å¯è½ãªã¯ã­ãã¯ã½ã¼ã¹ */
+#define CLK_F1	UINT_C(0x00)
+#define CLK_F4	UINT_C(0x01)
+#define CLK_F16	UINT_C(0x02)
+#define CLK_F64	UINT_C(0x03)
+
+/* ã·ãªã¢ã«ã¢ã¼ãã¬ã¸ã¹ã¿ï¼SMR) */
+#define CKS			UINT_C(0x03)
+#define STOP		UINT_C(0x08)
+#define PM			UINT_C(0x10)
+#define PE			UINT_C(0x20)
+#define CHR			UINT_C(0x40)
+#define CM			UINT_C(0x80)
+#define ASYNC_7BIT	UINT_C(0x00)
+#define ASYNC_8BIT	UINT_C(0x40)
+
+/* ã·ãªã¢ã«ã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿ï¼SCR) */
+#define CKE			UINT_C(0x03)
+#define TEIE		UINT_C(0x04)
+#define RE			UINT_C(0x10)
+#define TE			UINT_C(0x20)
+#define RIE			UINT_C(0x40)
+#define TIE			UINT_C(0x80)
+
+/* ã·ãªã¢ã«ã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ï¼SSRï¼ */
+#define TEND		UINT_C(0x04)
+#define PER			UINT_C(0x08)
+#define FER			UINT_C(0x10)
+#define ORER		UINT_C(0x20)
+
+/* ã·ãªã¢ã«æ¡å¼µã¢ã¼ãã¬ã¸ã¹ã¿ï¼SEMR) */
+#define ACS0		UINT_C(0x01)
+#define ABCS		UINT_C(0x10)
+
+#define SCI_SCR_FLG_ENABLE	(RE | TE)
+#define SCI_SMR_FLG_ENABLE	(STOP | PM | PE | CHR | CM)
+
+/*
+ *  SCIã¬ã¸ã¹ã¿ã®çªå°ã®å®ç¾©
+ */
+#define SCI_SMR(base)		((uint8_t *)(base + 0x00U))
+#define SCI_BRR(base)		((uint8_t *)(base + 0x01U))
+#define SCI_SCR(base)		((uint8_t *)(base + 0x02U))
+#define SCI_TDR(base)		((uint8_t *)(base + 0x03U))
+#define SCI_SSR(base)		((uint8_t *)(base + 0x04U))
+#define SCI_RDR(base)		((uint8_t *)(base + 0x05U))
+#define SCI_SCMR(base)		((uint8_t *)(base + 0x06U))
+#define SCI_SEMR(base)		((uint8_t *)(base + 0x07U))
+#define SCI_SNFR(base)		((uint8_t *)(base + 0x08U))
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã³ã¼ã«ããã¯ã«ã¼ãã³ã®è­å¥çªå·
+ */
+#define SIO_RDY_SND    (1U)        /* éä¿¡å¯è½ã³ã¼ã«ããã¯ */
+#define SIO_RDY_RCV    (2U)        /* åä¿¡éç¥ã³ã¼ã«ããã¯ */
+
+#endif /* TOPPERS_MACRO_ONLY */
+#endif /* TOPPERS_SCIF_H */
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/sectrx.inc
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/sectrx.inc	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/sectrx.inc	(revision 317)
@@ -0,0 +1,145 @@
+;*
+;*  TOPPERS/ASP Kernel
+;*      Toyohashi Open Platform for Embedded Real-Time Systems/
+;*      Advanced Standard Profile Kernel
+;* 
+;*  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+;* 
+;*  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+;*  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+;*  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+;*  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+;*      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+;*      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+;*  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+;*      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+;*      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+;*      ã¨ï¼
+;*    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+;*        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+;*        å ±åãããã¨ï¼
+;*  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+;*      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+;*      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+;*      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+;*      å
+è²¬ãããã¨ï¼
+;* 
+;*  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+;*  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+;*  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+;*  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+;*  ã®è²¬ä»»ãè² ããªãï¼
+;* 
+;*  @(#) $Id$
+;* 
+
+;
+;  ã¿ã¼ã²ããã·ã¹ãã ä¾å­ã»ã¯ã·ã§ã³å®ç¾©ãã¡ã¤ã«(ã¹ã¿ã¼ã¿ã¼ã­ããç¨)
+;
+
+;
+;  ã»ã¯ã·ã§ã³ã®å®ç¾©
+;
+;  ã»ã¯ã·ã§ã³ã®ã¢ãã¬ã¹å®ç¾©ã¯HEWä¸ã®æé©åãªã³ã«ã®
+;  ãªãã·ã§ã³ã«ã¦å®æ½ãã.
+;
+
+	;
+	;  åæå¤æããã¼ã¿é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	.section	D, ROMDATA
+	.section	D_2, ROMDATA, ALIGN = 2
+	.section	D_1, ROMDATA
+
+
+	;
+	;  åæå¤ç¡ããã¼ã¿é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	.section	B, DATA, ALIGN = 4
+	.section	B_2, DATA, ALIGN = 2
+	.section	B_1, DATA
+	.section	W, ROMDATA,ALIGN = 4
+	.section	W_1, ROMDATA
+	.section	W_2, ROMDATA, ALIGN = 2
+
+
+	;
+	;  ã«ã¼ãã«ã¹ã¿ãã¯é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	;  ä»¥ä¸.blkbå½ä»¤ã§ç¢ºä¿ãã¦ããã«ã¼ãã«ã¹ã¿ãã¯é åã®ãµã¤ãºã
+	;  å¤æ´ããå ´åã¯, target_kernel_impl.hã®DEFAULT_ISTKSZã®å¤ã, åã
+	;  å¤ã«å¤æ´ãããã¨.
+	;
+;	.section	SI, DATA, ALIGN = 4
+;	.global _DEFAULT_ISTACK
+;_DEFAULT_ISTACK:
+;	.blkb		DEFAULT_ISTKSZ
+;	.global DEFAULT_ISTACK_TOP
+;DEFAULT_ISTACK_TOP:
+
+	;
+	;  å®æ°é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	C, ROMDATA, ALIGN = 4
+	.section	C_2, ROMDATA, ALIGN = 2
+	.section	C_1, ROMDATA
+
+	;
+	;  åæå¤æããã¼ã¿é åã®åæå¤
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	R, DATA, ALIGN = 4
+	.section	R_2, DATA, ALIGN = 2
+	.section	R_1, DATA
+
+	;
+	;  å¯å¤ãã¯ã¿ãã¼ãã«é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	.fvectors, ROMDATA, ALIGN = 4
+	.global VVECTOR_TOP
+VVECTOR_TOP:
+
+	;
+	;  ãã­ã°ã©ã é åã®ã»ã¯ã·ã§ã³
+	;
+	;  FFE80000h - FFFFFF7Fh
+	;
+	.section	P, CODE
+
+	;
+	;  åºå®ãã¯ã¿ãã¼ãã«é åã®ã»ã¯ã·ã§ã³
+	;
+	;  FFFFFF80h - FFFFFFFFh
+	;
+	.section	FVECT, ROMDATA, ALIGN = 4
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/start.S
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/start.S	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/start.S	(revision 317)
@@ -0,0 +1,170 @@
+;*
+;*  TOPPERS/ASP Kernel
+;*      Toyohashi Open Platform for Embedded Real-Time Systems/
+;*      Advanced Standard Profile Kernel
+;* 
+;*  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+;*                              Toyohashi Univ. of Technology, JAPAN
+;*  Copyright (C) 2005,2006 by Embedded and Real-Time Systems Laboratory
+;*              Graduate School of Information Science, Nagoya Univ., JAPAN
+;*  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+;* 
+;*  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+;*  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+;*  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+;*  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+;*      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+;*      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+;*  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+;*      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+;*      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+;*      ã¨ï¼
+;*    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+;*        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+;*        å ±åãããã¨ï¼
+;*  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+;*      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+;*      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+;*      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+;*      å
+è²¬ãããã¨ï¼
+;* 
+;*  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+;*  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+;*  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+;*  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+;*  ã®è²¬ä»»ãè² ããªãï¼
+;* 
+;*  @(#) $Id$
+;* 
+
+#define TOPPERS_MACRO_ONLY
+#define UINT_C(val)			(val)		/* uint_tåã®å®æ°ãä½ããã¯ã­ */
+#define ULONG_C(val)		(val)		/* ulong_tåã®å®æ°ãä½ããã¯ã­ */
+#define CAST(type, val)		(val)		/* åã­ã£ã¹ããè¡ããã¯ã­ */
+#include "kernel_impl.h"
+#include "sectrx.inc"
+
+	;
+	;  ã¡ã¢ãªãããã®å®ç¾©(ã¿ã¼ã²ããä¾å­é¨)
+	;
+
+.equ	DFLRE,				007FC440H		; DFLREã¬ã¸ã¹ã¿
+
+.equ	DB_BLOCK_ENABLE,	02D0FH
+
+;
+;  åæåã«ã¼ãã³
+;
+	.section	P, CODE
+
+	.global	_start
+	.global	_sta_ker
+	.global	_software_init_hook
+	.global	_hardware_init_hook
+	.global	__kernel_istkpt
+	.global	_vvector_table
+
+_start:
+	;
+	;  é»æºæå
+¥å¾ã¯ã¬ãã«0, å
+¨å²è¾¼ã¿ç¦æ­¢ç¶æ
+ã§ãã.
+	;  ã«ã¼ãã«ã§ã¯é«éå²è¾¼ã¿ãä½¿ç¨ããªããããBPC, BPSWåã³FINTV
+	;  ã®åæåã¯è¡ããªã.
+	;
+
+	;
+	;  å
+èµROMï¼ãã¼ã¿ãã©ãã·ã¥ï¼é åã®è¨­å®
+	;
+	;  ãªã»ããå¾, ãã¼ã¿ãã©ãã·ã¥é åã¯èª­ã¿åºãç¦æ­¢ã¨ãªã£ã¦ãã
+	;  ãã, èª­ã¿åºãè¨±å¯ã«è¨­å®ãã.
+	;
+	mov.l	#DFLRE, r5
+	mov.w	#DB_BLOCK_ENABLE, [R5]
+	
+	;
+	;  ã¹ã¿ãã¯ãã¤ã³ã¿ã®è¨­å®
+	;
+	;  ã¦ã¼ã¶ã«ã¦éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã¹ã¿ãã¯é åãç¨æããå ´å,
+	;  ã¦ã¼ã¶é åãè¨­å®ãã.
+	;  kernel_cfg.cã«ã¦"_kernel_istkpt"ã®å¤ãæ±ºå®ãã.
+	;
+	mov.l	#__kernel_istkpt, r5
+	mov.l	[r5], r0			; éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã¹ã¿ãã¯é åãè¨­å®
+
+	;
+	;  å¯å¤ãã¯ã¿ãã¼ãã«ã®è¨­å®
+	;
+	; mvtc	#VVECTOR_TOP, intb	; ãã¯ã¿ãã¼ãã«ã®è¨­å®
+	mvtc	#_vvector_table, intb	; ãã¯ã¿ãã¼ãã«ã®è¨­å®
+
+	;
+	;  ãã¼ãã¦ã§ã¢åºæã®åæåã«ã¼ãã³ã®å¼åºã
+	;
+	mov.l	#_hardware_init_hook, r5
+	cmp		#0, r5
+	beq.b	init_D
+	jsr		r5
+
+	;
+	;  åæå¤ããå¤æ°é åã®åæå
+	;
+init_D:
+	mov.l	#(_edata - _data), r3
+	cmp		#0, r3
+	beq.b	clear_B						; ãµã¤ãº0ãªãåæåå¿
+è¦ãªã
+	mov.l	#(_data), r1
+	mov.l	#(_mdata), r2
+	smovf
+
+	;
+	;  åæå¤ãªãå¤æ°é åã®åæå
+	;
+clear_B:
+	mov.l	#0, r2
+	mov.l	#(_bss), r1
+	mov.l	#(_ebss - _bss) , r3
+	sstr.b
+
+	;
+	;  software_init_hook ãå¼åºãï¼0 ã§ãªãå ´åï¼
+	;
+	;  ã½ããã¦ã§ã¢ç°å¢ï¼ç¹ã«ã©ã¤ãã©ãªï¼ã«ä¾å­ãã¦å¿
+è¦ãªåæåå¦ç
+	;  ãããå ´åã¯ï¼software_init_hook ã¨ããé¢æ°ãç¨æããã°ãã.
+	;
+	mov.l	#_software_init_hook, r5
+	cmp		#0, r5
+	beq.b	kernel_link
+	jsr		r5
+
+	;
+	;  ã«ã¼ãã«ã¹ã¿ã¼ã
+	;
+kernel_link:
+	bra.a	_sta_ker					; --> _sta_ker()
+
+	.end
+
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.c
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.c	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.c	(revision 317)
@@ -0,0 +1,318 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ç¨ ç°¡æSIOãã©ã¤ã
+ */
+
+#include <sil.h>
+#include "tSCIF_tecsgen.h"
+#include "scif.h"
+
+/*
+ *  ããªããã£ããªéä¿¡ï¼åä¿¡é¢æ°
+ */
+
+/*
+ *  åä¿¡ãããã¡ã«æå­ããããï¼
+ */
+Inline bool_t
+scif_getready(CELLCB *p_cellcb)
+{
+	/*
+	 *  åä¿¡ãã©ã°ãONã®ã¨ãã®ã¿åä¿¡ãããã¡ããæå­ãåå¾ãã.
+	 *  ããã¯, ãã¼ãªã³ã°åä¿¡ã«å¯¾å¿ããããã§ãã.
+	 *  ããã, RX600ã·ãªã¼ãºã§ã¯åä¿¡ãã©ã°ããªããã¨, ã·ã¹ãã ãµã¼ãã¹
+	 *  ã§ã¯åä¿¡å²è¾¼ã¿ã®ä¸­ãããããã¼ã¿ãåä¿¡ãã«æ¥ãªããã¨ãã, å¸¸ã«
+	 *  åä¿¡ãããã¡ããæå­ãåå¾ãã.
+	 */
+	return true;
+}
+
+/*
+ *  éä¿¡ãããã¡ã«ç©ºãããããï¼
+ */
+Inline bool_t
+scif_putready(CELLCB *p_cellcb)
+{
+	if((sil_reb_mem(SCI_SSR(ATTR_baseAddress)) & SCI_SSR_TEND_BIT) != 0){
+		return(true);
+	}
+	return(false);
+}
+
+/*
+ *  éä¿¡ããæå­ã®æ¸è¾¼ã¿
+ */
+Inline void
+scif_putchar(CELLCB *p_cellcb, char c)
+{
+	sil_wrb_mem(SCI_TDR(ATTR_baseAddress), c);
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãã®ãªã¼ãã³
+ */
+void
+eSIOPort_open(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	uint_t	cnt, brr, clk;
+	volatile uint8_t i;
+
+	if (VAR_initialized) {
+		/*
+		 *  æ¢ã«åæåãã¦ããå ´åã¯ãäºéã«åæåããªãï¼
+		 */
+		return;
+	}
+
+	cnt = (FREQ_PCLK * 1000) / (16 * ATTR_baudRate);
+	if (cnt < 512)
+		clk = 0;
+	else if (cnt < 4 * 512)
+		clk = 1;
+	else if (cnt < 16 * 512)
+		clk = 2;
+	else if (cnt < 64 * 512)
+		clk = 3;
+	else
+		return;
+
+	brr = cnt / (1 << (2 * clk));
+	brr = (brr / 2) + (brr % 2) - 1;
+
+	/*
+	 *  SCIãã©ã¤ãã®åæåã«ã¼ãã³
+	 */
+
+	/*
+	 *  å²ãè¾¼ã¿è¦æ±å
+ã¬ã¸ã¹ã¿ã®è¨­å®(ISELRi)
+	 *
+	 *  ãªã»ããå¤ã¨åãå¤ãè¨­å®ãããã¨ã«ãªããã,
+	 *  å¦çã¯çç¥ãã.
+	 */
+
+	/*
+	 *  ã¢ã¸ã¥ã¼ã«ã¹ãããæ©è½ã®è¨­å®
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRB_ADDR,
+		sil_rew_mem(SYSTEM_MSTPCRB_ADDR) & ~SCI_MSTPCRB_BIT(ATTR_baseAddress));
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, (uint16_t)0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+
+	/* éåä¿¡ç¦æ­¢, SCKnç«¯å­ã¯å
+¥åºåãã¼ãã¨ãã¦ä½¿ç¨ */
+	sil_wrb_mem(SCI_SCR(ATTR_baseAddress), 0x00U);
+
+	/* ã¯ã­ãã¯é¸æããã(SMR.CKS[1:0]ããããè¨­å®) */
+	sil_wrb_mem(SCI_SMR(ATTR_baseAddress),
+		(sil_reb_mem(SCI_SMR(ATTR_baseAddress)) & ~0x03) | clk);
+
+	/* SMRã«éä¿¡ï¼ åä¿¡ãã©ã¼ããããè¨­å®) */
+	sil_wrb_mem(SCI_SMR(ATTR_baseAddress),
+			sil_reb_mem(SCI_SMR(ATTR_baseAddress)) & (~SCI_SMR_FLG_ENABLE));
+
+	/* ãããã¬ã¼ããè¨­å® */
+	sil_wrb_mem(SCI_BRR(ATTR_baseAddress), brr);
+
+	/* ãããæé(åºæ¬ã¯ã­ãã¯16ãµã¤ã¯ã«ã®æéã1ãããæéã¨ãªã) */
+	for(i = 0; i < 16; i++) { }
+
+	/* éåä¿¡è¨±å¯ */
+	sil_wrb_mem(SCI_SCR(ATTR_baseAddress),
+			(sil_reb_mem(SCI_SCR(ATTR_baseAddress)) | SCI_SCR_FLG_ENABLE));
+
+	VAR_initialized = true;
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãã®ã¯ã­ã¼ãº
+ */
+void
+eSIOPort_close(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	/*
+	 *  UARTåæ­¢
+	 */
+	sil_wrb_mem(SCI_SCR(ATTR_baseAddress), 0x00U);
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãã¸ã®æå­éä¿¡
+ */
+bool_t
+eSIOPort_putChar(CELLIDX idx, char c)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	if (scif_putready(p_cellcb)){
+		scif_putchar(p_cellcb, c);
+		return(true);
+	}
+	return(false);
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãããã®æå­åä¿¡
+ */
+int_t
+eSIOPort_getChar(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	uint8_t reg;
+	int_t c = -1;
+
+	/* ãªã¼ãã©ã³ã¨ã©ã¼ãã§ãã¯ */ /* ZZZ */
+	reg = sil_reb_mem(SCI_SSR(ATTR_baseAddress));
+	while((reg & SCI_SSR_ORER_BIT) != 0) {
+		sil_wrb_mem(SCI_SSR(ATTR_baseAddress), reg & ~SCI_SSR_ORER_BIT);
+		reg = sil_reb_mem(SCI_SSR(ATTR_baseAddress));
+	}
+
+	/*
+	 *  åä¿¡ãã©ã°ãONã®ã¨ãã®ã¿åä¿¡ãããã¡ããæå­ãåå¾ãã.
+	 *  ããã¯, ãã¼ãªã³ã°åä¿¡ã«å¯¾å¿ããããã§ãã.
+	 *  ããã, RX600ã·ãªã¼ãºã§ã¯åä¿¡ãã©ã°ããªããã¨, ã·ã¹ãã ãµã¼ãã¹
+	 *  ã§ã¯åä¿¡å²è¾¼ã¿ã®ä¸­ãããããã¼ã¿ãåä¿¡ãã«æ¥ãªããã¨ãã, å¸¸ã«
+	 *  åä¿¡ãããã¡ããæå­ãåå¾ãã.
+	 */
+	c = (int)(sil_reb_mem(SCI_RDR(ATTR_baseAddress)));
+
+	return c;
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
+ */
+void
+eSIOPort_enableCBR(CELLIDX idx, uint_t cbrtn)
+{
+	CELLCB		*p_cellcb = GET_CELLCB(idx);
+
+	switch (cbrtn) {
+		case SIO_RDY_SND:
+			sil_wrb_mem(SCI_SCR(ATTR_baseAddress),
+				(sil_reb_mem(SCI_SCR(ATTR_baseAddress)) | SCI_SCR_TEIE_BIT));
+			break;
+		case SIO_RDY_RCV:
+			sil_wrb_mem(SCI_SCR(ATTR_baseAddress),
+				(sil_reb_mem(SCI_SCR(ATTR_baseAddress)) | SCI_SCR_RIE_BIT));
+			break;
+		default:
+			assert(1);
+			break;
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ­¢
+ */
+void
+eSIOPort_disableCBR(CELLIDX idx, uint_t cbrtn)
+{
+	CELLCB		*p_cellcb = GET_CELLCB(idx);
+
+	switch (cbrtn) {
+		case SIO_RDY_SND:
+			sil_wrb_mem(SCI_SCR(ATTR_baseAddress),
+				(sil_reb_mem(SCI_SCR(ATTR_baseAddress)) & (~SCI_SCR_TEIE_BIT)));
+			break;
+		case SIO_RDY_RCV:
+			sil_wrb_mem(SCI_SCR(ATTR_baseAddress),
+				(sil_reb_mem(SCI_SCR(ATTR_baseAddress)) & (~SCI_SCR_RIE_BIT)));
+			break;
+		default:
+			assert(1);
+			break;
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãã«å¯¾ããåä¿¡å²è¾¼ã¿å¦ç
+ */
+void
+eiRxISR_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	if (scif_getready(p_cellcb)) {
+		/*
+		 *  åä¿¡éç¥ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
+		 */
+		ciSIOCBR_readyReceive();
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«I/Oãã¼ãã«å¯¾ããéä¿¡å²è¾¼ã¿å¦ç
+ */
+void
+eiTxISR_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	if (scif_putready(p_cellcb)) {
+		/*
+		 *  éä¿¡å¯è½ã³ã¼ã«ããã¯ã«ã¼ãã³ãå¼ã³åºãï¼
+		 */
+		ciSIOCBR_readySend();
+	}
+}
Index: asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.cdl
===================================================================
--- asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/arch/rx630_gcc/tSCIF.cdl	(revision 317)
@@ -0,0 +1,89 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ç¨ ç°¡æSIOãã©
+ *		ã¤ãã®ã³ã³ãã¼ãã³ãè¨è¿°
+ */
+
+/*
+ *  FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ã«é¢ããå®ç¾©ã®ã¤ã³
+ *  ãã¼ã
+ */
+import_C("scif.h");
+
+/*
+ *  FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ç¨ ç°¡æSIOãã©ã¤ã
+ *  ã®ã»ã«ã¿ã¤ã
+ */
+celltype tSCIF {
+	entry	sSIOPort	eSIOPort;
+	call	siSIOCBR	ciSIOCBR;
+
+	entry	siHandlerBody	eiRxISR;
+	entry	siHandlerBody	eiTxISR;
+
+	attr {
+		uintptr_t	baseAddress;	/* SCIFã¬ã¸ã¹ã¿ã®ãã¼ã¹ã¢ãã¬ã¹ */
+		uint32_t	baudRate;		/* ãã¼ã¬ã¼ãã®è¨­å®å¤ */
+	};
+	var {
+		bool_t		initialized = false;	/* åæåæ¸ã¿ */
+	};
+};
Index: asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.c
===================================================================
--- asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.c	(revision 317)
+++ asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.c	(revision 317)
@@ -0,0 +1,351 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¬ã¼ã¹ã­ã°æ©è½
+ */
+
+#include "tTraceLog_tecsgen.h"
+#include "kernel/kernel_impl.h"
+#include "kernel/task.h"
+#include "kernel/time_event.h"
+#include <sil.h>
+#include <log_output.h>
+#include "target_syssvc.h"
+
+/*
+ *  ãã¬ã¼ã¹æå»ã®åãåºã
+ *
+ *  ããã©ã«ãã§ã¯ï¼ã­ã°æå»ã¨ãã¦ï¼é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ãç¨ãã¦
+ *  ããï¼ã¿ã¼ã²ããä¾å­ã§å¤æ´ããå ´åã«ã¯ï¼SYSLOG_GET_LOGTIMã«ï¼ã­ã°æ
+ *  å»ãåãåºããã¯ã­ãå®ç¾©ããï¼
+ */
+#ifndef SYSLOG_GET_LOGTIM
+#define SYSLOG_GET_LOGTIM(p_logtim) \
+				(*(p_logtim) = target_hrt_get_current())
+#endif /* SYSLOG_GET_TIM */
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®éå§
+ */
+ER
+eTraceLog_start(MODE mode)
+{
+	if ((mode & TRACE_CLEAR) != 0U) {
+		VAR_count = 0U;
+		VAR_head = 0U;
+		VAR_tail = 0U;
+		mode &= ~TRACE_CLEAR;
+	}
+	VAR_mode = mode;
+	return(E_OK);
+}     
+
+/* 
+ *  ãã¬ã¼ã¹ã­ã°ã®æ¸è¾¼ã¿
+ */
+ER
+eTraceLog_write(const TRACE *p_trace)
+{
+	SIL_PRE_LOC;
+
+	if ((VAR_mode & (TRACE_RINGBUF | TRACE_AUTOSTOP)) != 0U) {
+		SIL_LOC_INT();
+
+		/*
+		 *  ãã¬ã¼ã¹æå»ã®è¨­å®
+		 */
+		SYSLOG_GET_LOGTIM(&(((SYSLOG *) p_trace)->logtim));
+
+		/*
+		 *  ãã¬ã¼ã¹ãããã¡ã«è¨é²
+		 */
+		VAR_logBuffer[VAR_tail] = *p_trace;
+		VAR_tail++;
+		if (VAR_tail >= ATTR_logBufferSize) {
+			VAR_tail = 0U;
+		}
+		if (VAR_count < ATTR_logBufferSize) {
+			VAR_count++;
+			if (VAR_count >= ATTR_logBufferSize
+						&& (VAR_mode & TRACE_AUTOSTOP) != 0U) {
+				VAR_mode = TRACE_STOP;
+			}
+		}
+		else {
+			VAR_head = VAR_tail;
+		}
+
+		SIL_UNL_INT();
+	}
+	return(E_OK);
+}
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®èª­åºã
+ */
+ER
+eTraceLog_read(TRACE* p_trace)
+{
+	ER_UINT	ercd;
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+
+	/*
+	 *  ãã¬ã¼ã¹ã­ã°ãããã¡ããã®ååºã
+	 */
+	if (VAR_count > 0U) {
+		*p_trace = VAR_logBuffer[VAR_head];
+		VAR_count--;
+		VAR_head++;
+		if (VAR_head >= ATTR_logBufferSize) {
+			VAR_head = 0U;
+		}
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_OBJ;
+	}
+
+	SIL_UNL_INT();
+	return(ercd);
+}
+
+/*
+ *  ã¢ã»ã³ããªè¨èªã§è¨è¿°ãããã³ã¼ããããã¬ã¼ã¹ã­ã°ãåºåããããã®é¢
+ *  æ°
+ */
+
+void
+log_dsp_enter(TCB *p_tcb)
+{
+	trace_1(LOG_TYPE_DSP|LOG_ENTER, p_tcb);
+}
+
+void
+log_dsp_leave(TCB *p_tcb)
+{
+	trace_1(LOG_TYPE_DSP|LOG_LEAVE, p_tcb);
+}
+
+void
+log_inh_enter(INHNO inhno)
+{
+	trace_1(LOG_TYPE_INH|LOG_ENTER, inhno);
+}
+
+void
+log_inh_leave(INHNO inhno)
+{
+	trace_1(LOG_TYPE_INH|LOG_LEAVE, inhno);
+}
+
+void
+log_exc_enter(EXCNO excno)
+{
+	trace_1(LOG_TYPE_EXC|LOG_ENTER, excno);
+}
+
+void
+log_exc_leave(EXCNO excno)
+{
+	trace_1(LOG_TYPE_EXC|LOG_LEAVE, excno);
+}
+
+/* 
+ *  ã«ã¼ãã«æ
+å ±ã®ååºã
+ */
+static intptr_t
+get_tskid(intptr_t info)
+{
+	TCB		*p_tcb;
+	ID		tskid;
+
+	p_tcb = (TCB *) info;
+	if (p_tcb == NULL) {
+		tskid = 0;
+	}
+	else {
+		tskid = TSKID(p_tcb);
+	}
+	return((intptr_t) tskid);
+}
+
+static intptr_t
+get_tskstat(intptr_t info)
+{
+	uint_t		tstat;
+	const char	*tstatstr;
+
+	tstat = (uint_t) info;
+	if (TSTAT_DORMANT(tstat)) {
+		tstatstr = "DORMANT";
+	}
+	else {
+		if (TSTAT_SUSPENDED(tstat)) {
+			if (TSTAT_WAITING(tstat)) {
+				tstatstr = "WAITING-SUSPENDED";
+			}
+			else {
+				tstatstr = "SUSPENDED";
+			}
+		}
+		else if (TSTAT_WAITING(tstat)) {
+			tstatstr = "WAITING";
+		}
+		else {
+			tstatstr = "RUNNABLE";
+		}
+	}
+	return((intptr_t) tstatstr);
+}
+
+/* 
+ *  ãã¬ã¼ã¹ã­ã°ã®è¡¨ç¤º
+ */
+static void
+trace_print(TRACE *p_trace, void (*putc)(char))
+{
+	intptr_t	traceinfo[TNUM_LOGPAR + 1];
+	const char	*tracemsg;
+	int_t		i;
+
+	traceinfo[0] = (intptr_t)(p_trace->logtim);
+	syslog_printf("[%d] ", traceinfo, putc);
+
+	switch (p_trace->logtype) {
+	case LOG_TYPE_TSKSTAT:
+		traceinfo[0] = get_tskid(p_trace->logpar[0]);
+		traceinfo[1] = get_tskstat(p_trace->logpar[1]);
+		tracemsg = "task %d becomes %s.";
+		break;
+	case LOG_TYPE_DSP|LOG_ENTER:
+		traceinfo[0] = get_tskid(p_trace->logpar[0]);
+		tracemsg = "dispatch from task %d.";
+		break;
+	case LOG_TYPE_DSP|LOG_LEAVE:
+		traceinfo[0] = get_tskid(p_trace->logpar[0]);
+		tracemsg = "dispatch to task %d.";
+		break;
+	case LOG_TYPE_COMMENT:
+		for (i = 1; i < TNUM_LOGPAR; i++) {
+			traceinfo[i-1] = p_trace->logpar[i];
+		}
+		tracemsg = (const char *)(p_trace->logpar[0]);
+		break;
+	case LOG_TYPE_ASSERT:
+		traceinfo[0] = p_trace->logpar[0];
+		traceinfo[1] = p_trace->logpar[1];
+		traceinfo[2] = p_trace->logpar[2];
+		tracemsg = "%s:%u: Assertion `%s' failed.";
+		break;
+	case LOG_TYPE_INH|LOG_ENTER:
+		traceinfo[0] = p_trace->logpar[0];
+		tracemsg = "interrupt IN: %d";
+		break;
+	case LOG_TYPE_INH|LOG_LEAVE:
+		traceinfo[0] = p_trace->logpar[0];
+		tracemsg = "interrupt OUT: %d";
+		break;
+	case LOG_TYPE_EXC|LOG_ENTER:
+		traceinfo[0] = p_trace->logpar[0];
+		tracemsg = "exception IN: %d";
+		break;
+	case LOG_TYPE_EXC|LOG_LEAVE:
+		traceinfo[0] = p_trace->logpar[0];
+		tracemsg = "exception OUT: %d";
+		break;
+	default:
+		traceinfo[0] = p_trace->logtype;
+		tracemsg = "unknown trace log type: %d.";
+		break;
+	}
+	syslog_printf(tracemsg, traceinfo, putc);
+	(*putc)('\n');
+}
+
+/*
+ *  ä½ã¬ãã«åºåã®å¼åºãé¢æ°
+ */
+static void
+low_putchar(char c)
+{
+	cPutLog_putChar(c);
+}
+
+/* 
+ *  ãã¬ã¼ã¹ã­ã°ã®ãã³ã
+ */
+void
+eTraceLog_dump(void)
+{
+	TRACE	trace;
+
+	while (trace_rea_log(&trace) >= 0) {
+		trace_print(&trace, low_putchar);
+	}
+}
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®ãã³ãï¼åãå£é¢æ°ï¼
+ */
+void
+tTraceLog_eDump_main(uintptr_t exinf)
+{
+	eTraceLog_dump();
+}
Index: asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.cdl
===================================================================
--- asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/arch/tracelog/tTraceLog.cdl	(revision 317)
@@ -0,0 +1,114 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¬ã¼ã¹ã­ã°æ©è½ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°åºåã«é¢ããå®ç¾©
+ */
+import_C("arch/tracelog/trace_log.h");
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°æ©è½ã®ã·ã°ããã£
+ */
+signature sTraceLog {
+	/*
+	 *  ãã¬ã¼ã¹ã­ã°ã®éå§
+	 */
+	ER		start([in] MODE mode);
+
+	/*
+	 *  ãã¬ã¼ã¹ã­ã°ã®æ¸è¾¼ã¿
+	 */
+	ER		write([in] const TRACE *p_trace);
+
+	/*
+	 *  ãã¬ã¼ã¹ã­ã°ã®èª­åºã
+	 */
+	ER		read([out] TRACE *p_trace);
+
+	/*
+	 *  ãã¬ã¼ã¹ã­ã°ã®ãã³ã
+	 */
+	void	dump(void);
+};
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°æ©è½ã®ã»ã«ã¿ã¤ã
+ */
+[singleton, active]
+celltype tTraceLog {
+	entry	sTraceLog		eTraceLog;
+	entry	sRoutineBody	eDump;		/* çµäºå¦çã«ã¼ãã³ã¨ã®æ¥ç¶ */
+	call	sPutLog			cPutLog;	/* ä½ã¬ãã«åºåã¨ã®æ¥ç¶ */
+
+	attr {
+		uint_t	logBufferSize;			/* ã­ã°ãããã¡ãµã¤ãº */
+		MODE	initialMode = C_EXP("TRACE_STOP");
+										/* åæåå¾ã®ã¢ã¼ã */
+	};
+	var {
+		[size_is(logBufferSize)] TRACE	*logBuffer;	/* ã­ã°ãããã¡ */
+		uint_t	count = 0;				/* ã­ã°ãããã¡ä¸­ã®ã­ã°ã®æ° */
+		uint_t	head = 0;				/* å
+é ­ã®ã­ã°ã®æ ¼ç´ä½ç½® */
+		uint_t	tail = 0;				/* æ¬¡ã®ã­ã°ã®æ ¼ç´ä½ç½® */
+		MODE	mode = initialMode;		/* ãã¬ã¼ã¹ã¢ã¼ã */
+	};
+};
Index: asp3_gr_sakura/trunk/arch/tracelog/trace_log.h
===================================================================
--- asp3_gr_sakura/trunk/arch/tracelog/trace_log.h	(revision 317)
+++ asp3_gr_sakura/trunk/arch/tracelog/trace_log.h	(revision 317)
@@ -0,0 +1,226 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¬ã¼ã¹ã­ã°ã«é¢ããè¨­å®
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼target_kernel_impl.hããã³
+ *  target_syssvc.hã®ã¿ããã¤ã³ã¯ã«ã¼ããããï¼ã¾ãï¼ãã¬ã¼ã¹ã­ã°æ©è½ã®
+ *  åæåãè¨é²ã®éå§ï¼åæ­¢ï¼ãã¬ã¼ã¹ã­ã°ã®ãã³ããè¡ããã­ã°ã©ã ãã
+ *  ã¤ã³ã¯ã«ã¼ããããã¨ãæ³å®ãã¦ããï¼
+ */
+
+#ifndef TOPPERS_TRACE_CONFIG_H
+#define TOPPERS_TRACE_CONFIG_H
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®ãã¼ã¿æ§é 
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ã­ã°æ
+å ±ã®ãã¼ã¿æ§é ã¨åããã®ãç¨ããï¼
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+#include <t_syslog.h>
+typedef	SYSLOG	TRACE;
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  ãã¬ã¼ã¹ã¢ã¼ãã®å®ç¾©
+ */
+#define TRACE_STOP			UINT_C(0x00)	/* ãã¬ã¼ã¹åæ­¢ */
+#define TRACE_RINGBUF		UINT_C(0x01)	/* ãªã³ã°ãããã¡ã¢ã¼ã */
+#define TRACE_AUTOSTOP		UINT_C(0x02)	/* èªååæ­¢ã¢ã¼ã */
+#define TRACE_CLEAR			UINT_C(0x04)	/* ãã¬ã¼ã¹ã­ã°ã®ã¯ãªã¢ */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  TECSã§è¨è¿°ããããã¹ããã­ã°ã©ã ç¨ã®ãµã¼ãã¹ãç´æ¥å¼ã³åºãããã®å®ç¾©
+ *
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSã§è¨è¿°ããããã¬ã¼ã¹ã­ã°
+ *  æ©è½ãå¼ã³åºãããã«ã¯ï¼ã¢ããã¿ãç¨ããã®ãæ­£å½ãªæ¹æ³ã§ãããï¼ã
+ *  ã¬ã¼ã¹ã­ã°æ©è½ãã·ã³ã°ã«ãã³ã§ãããã¨ãå©ç¨ãã¦ç´æ¥å¼ã³åºãï¼
+ */
+extern ER	tTraceLog_eTraceLog_start(MODE mode);
+extern ER	tTraceLog_eTraceLog_write(const TRACE *p_trace);
+extern ER	tTraceLog_eTraceLog_read(TRACE* p_trace);
+extern void	tTraceLog_eTraceLog_dump(void);
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®éå§
+ *
+ *  ãã¬ã¼ã¹ã­ã°ã®è¨é²ãéå§ï¼åæ­¢ããï¼å¼æ°ã«ããæ¬¡ã®åä½ãè¡ãï¼
+ *
+ *  TRACE_STOPï¼ãã¬ã¼ã¹ãåæ­¢ï¼
+ *  TRACE_RINGBUFï¼ãªã³ã°ãããã¡ã¢ã¼ãã§ãã¬ã¼ã¹ãéå§ï¼
+ *  TRACE_AUTOSTOPï¼èªååæ­¢ã¢ã¼ãã§ãã¬ã¼ã¹ãéå§ï¼
+ *  TRACE_CLEARï¼ãã¬ã¼ã¹ã­ã°ãã¯ãªã¢ï¼
+ */
+Inline ER
+trace_sta_log(MODE mode)
+{
+	return(tTraceLog_eTraceLog_start(mode));
+}
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®æ¸è¾¼ã¿
+ */
+Inline ER
+trace_wri_log(TRACE *p_trace)
+{
+	return(tTraceLog_eTraceLog_write(p_trace));
+}
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã®èª­åºã
+ */
+Inline ER
+trace_rea_log(TRACE *p_trace)
+{
+	return(tTraceLog_eTraceLog_read(p_trace));
+}
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãåºåããããã®ã©ã¤ãã©ãªé¢æ°
+ */
+
+Inline void
+trace_write_0(uint_t type)
+{
+	TRACE	trace;
+
+	trace.logtype = type;
+	(void) trace_wri_log(&trace);
+}
+
+Inline void
+trace_write_1(uint_t type, intptr_t arg1)
+{
+	TRACE	trace;
+
+	trace.logtype = type;
+	trace.logpar[0] = arg1;
+	(void) trace_wri_log(&trace);
+}
+
+Inline void
+trace_write_2(uint_t type, intptr_t arg1, intptr_t arg2)
+{
+	TRACE	trace;
+
+	trace.logtype = type;
+	trace.logpar[0] = arg1;
+	trace.logpar[1] = arg2;
+	(void) trace_wri_log(&trace);
+}
+
+Inline void
+trace_write_3(uint_t type, intptr_t arg1, intptr_t arg2, intptr_t arg3)
+{
+	TRACE	trace;
+
+	trace.logtype = type;
+	trace.logpar[0] = arg1;
+	trace.logpar[1] = arg2;
+	trace.logpar[2] = arg3;
+	(void) trace_wri_log(&trace);
+}
+														
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãåºåããããã®ãã¯ã­
+ */
+
+#define trace_0(type) \
+				trace_write_0(type)
+
+#define trace_1(type, arg1) \
+				trace_write_1(type, (intptr_t)(arg1))
+
+#define trace_2(type, arg1, arg2) \
+				trace_write_2(type, (intptr_t)(arg1), (intptr_t)(arg2))
+
+#define trace_3(type, arg1, arg2, arg3) \
+				trace_write_3(type, (intptr_t)(arg1), (intptr_t)(arg2), \
+														(intptr_t)(arg3))
+
+/* 
+ *  ãã¬ã¼ã¹ã­ã°ã®ãã³ã
+ *
+ *  ãã¬ã¼ã¹ã­ã°ããã³ãããï¼çµäºå¦çã«ã¼ãã³ã¨ãã¦ç»é²ãããã¨ãæ³å®
+ *  ãã¦ããï¼å¼æ°ã¨ãã¦ï¼ãã³ãå
+ã¨ãªãæå­åºåé¢æ°ã¸ã®ãã¤ã³ã¿ãæ¸¡ãï¼
+ *  ã¿ã¼ã²ããä¾å­ã®ä½ã¬ãã«æå­åºåãå©ç¨ããå ´åã«ã¯ï¼target_putcãæ¸¡
+ *  ãï¼
+ */
+Inline void
+trace_dump(void)
+{
+	tTraceLog_eTraceLog_dump();
+}
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°æ¹æ³ã®è¨­å®
+ */
+#define LOG_TSKSTAT(p_tcb)		trace_2(LOG_TYPE_TSKSTAT, p_tcb, p_tcb->tstat)
+
+#define LOG_TSYSLOG_ESYSLOG_WRITE_ENTER(priority, p_syslog) \
+								trace_wri_log((TRACE *) p_syslog)
+
+#endif /* TOPPERS_TRACE_CONFIG_H */
Index: asp3_gr_sakura/trunk/cfg/GenFile.rb
===================================================================
--- asp3_gr_sakura/trunk/cfg/GenFile.rb	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/GenFile.rb	(revision 317)
@@ -0,0 +1,123 @@
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Configurator by Ruby
+#
+#  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#  Copyright (C) 2016 by APTJ Co., Ltd., JAPAN
+#
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+#
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+#
+#  $Id: GenFile.rb 111 2016-03-16 23:50:27Z ertl-hiro $
+#
+
+#
+#		ãã¡ã¤ã«ä½æã¯ã©ã¹
+#
+
+#
+# ãã¡ã¤ã«ã«æ¸ããã¨ããå
+å®¹ãå¤æ°ã«èç©ãï¼ãã­ã°ã©ã ã®çµäºæï¼output
+# ã¡ã½ãããå¼ã°ããæï¼ã«ãã¡ã¤ã«ã«åºåããï¼æ¢ã«ãã¡ã¤ã«ãå­å¨ãï¼å·®
+# åããªãå ´åã¯åºåããªãï¼ã¿ã¤ã ã¹ã¿ã³ããæ´æ°ããªãï¼ï¼
+#
+class GenFile
+  @@fileDataHash = {}
+
+  def initialize(fileName)
+    @selfFileName = fileName
+    if !@@fileDataHash.has_key?(fileName)
+      @@fileDataHash[@selfFileName] = ""
+    end
+  end
+
+  # ãã¡ã¤ã«ãã¼ã¿ã®æ«å°¾ã«æå­åãè¿½å ãã
+  def append(code = "")
+    @@fileDataHash[@selfFileName] << code
+  end
+
+  # ãã¡ã¤ã«ãã¼ã¿ã«1è¡è¿½å ãã
+  def add(code = "")
+    @@fileDataHash[@selfFileName] << code << "\n"
+  end
+
+  # ãã¡ã¤ã«ãã¼ã¿ã«1è¡è¿½å ãã(æ¹è¡2å)
+  def add2(code = "")
+    add(code + "\n")
+  end
+
+  # ã³ã¡ã³ãããããè¿½å ãã
+  def comment_header(comment)
+    add("/*")
+    comment.split("\n").each do |sLine|
+      add(" *  " + sLine)
+    end
+    add2(" */")
+  end
+
+  # ãã¡ã¤ã«ãã¼ã¿ãè¡¨ç¤ºãã
+  def print()
+    puts(@@fileDataHash[@selfFileName])
+  end
+
+  # å
+¨ãã¡ã¤ã«ãåºåãã
+  def self.output()
+    @@fileDataHash.each do |fileName, fileData|
+      # æ¢ã«ãã¡ã¤ã«ãå­å¨ãï¼å·®åããªãå ´åã¯åºåããªã
+      #ï¼ã¿ã¤ã ã¹ã¿ã³ããæ´æ°ããªãï¼
+      if File.exist?(fileName)
+        if fileData == File.read(fileName)
+          next
+        end
+      end
+      File.open(fileName, "w") do |file|
+        puts("[#{File.basename($0)}] Generated #{fileName}")
+        file.puts(fileData)
+      end
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/cfg/MANIFEST
===================================================================
--- asp3_gr_sakura/trunk/cfg/MANIFEST	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/MANIFEST	(revision 317)
@@ -0,0 +1,8 @@
+MANIFEST
+cfg.rb
+pass1.rb
+pass2.rb
+GenFile.rb
+SRecord.rb
+
+doc/cfg_user.txt
Index: asp3_gr_sakura/trunk/cfg/SRecord.rb
===================================================================
--- asp3_gr_sakura/trunk/cfg/SRecord.rb	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/SRecord.rb	(revision 317)
@@ -0,0 +1,190 @@
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Configurator by Ruby
+#
+#  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+#
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+#
+#  $Id: SRecord.rb 107 2016-03-14 03:29:58Z ertl-hiro $
+#
+
+#
+#		Sã¬ã³ã¼ããã¡ã¤ã«å¦çã¯ã©ã¹
+#
+
+#
+# Sã¬ã³ã¼ããã¡ã¤ã«ãå¤æ°ã«èª­ã¿è¾¼ã¿ï¼è¦æ±ãããçªå°ã®ãã¼ã¿ãè¿ãï¼
+#
+# @sRecDataã¯ï¼å
+é ­çªå°ãã­ã¼ã¨ãï¼ããããã®ãã¼ã¿ï¼ãã­ãµãã³ãå½¢å¼ï¼
+# ãå¤ã¨ãã­ãã¯ãæ ¼ç´ãããããã·ã¥ã§ããï¼é£ç¶ãããã­ãã¯ã¯ï¼1ã¤ã®ã
+# ã­ãã¯ã«ã¾ã¨ãã¦æ ¼ç´ãããã®ã¨ããï¼ããããªãã¨ï¼ãã¼ã¿ã®ååºãããµã¼
+# ããé¢åã«ãªãï¼ï¼
+#
+class SRecord
+  def initialize(fileName)
+    @sRecData = {}
+    File.open(fileName) do |file|
+      prevAddress = 0
+      prevData = ""
+      file.each do |line|
+        # ãã¼ã¿ã¬ã³ã¼ãã«ããåå²
+        case line.slice(0, 2)
+        when "S1"
+          # ãã¼ã¿é·ï¼ã¢ãã¬ã¹å[2byte]+ãã§ãã¯ãµã å1byteãæ¸ç®ï¼
+          length = line.slice(2, 2).hex - 2 - 1
+
+          # ã¢ãã¬ã¹ï¼4æå­=2byteï¼
+          address = line.slice(4, 4).hex
+
+          # ãã¼ã¿ï¼ãã®æç¹ã§ã¯æå­åã§åã£ã¦ããï¼
+          data = line.slice(8, length * 2)
+        when "S2"
+          # ãã¼ã¿é·ï¼ã¢ãã¬ã¹å[3byte]+ãã§ãã¯ãµã å1byteãæ¸ç®ï¼
+          length = line.slice(2, 2).hex - 3 - 1
+
+          # ã¢ãã¬ã¹ï¼6æå­=3byteï¼
+          address = line.slice(4, 6).hex
+
+          # ãã¼ã¿ï¼ãã®æç¹ã§ã¯æå­åã§åã£ã¦ããï¼
+          data = line.slice(10, length * 2)
+        when "S3"
+          # ãã¼ã¿é·ï¼ã¢ãã¬ã¹å[4byte]+ãã§ãã¯ãµã å1byteãæ¸ç®ï¼
+          length = line.slice(2, 2).hex - 4 - 1
+
+          # ã¢ãã¬ã¹ï¼8æå­=4byteï¼
+          address = line.slice(4, 8).hex
+
+          # ãã¼ã¿ï¼ãã®æç¹ã§ã¯æå­åã§åã£ã¦ããï¼
+          data = line.slice(12, length * 2)
+        else
+          address = nil
+        end
+
+        if !address.nil?
+          # ãã¼ã¿ãæ ¼ç´ãã
+          if address == prevAddress + prevData.size / 2
+            prevData << data
+          else
+            set_data(prevAddress, prevData) if prevData.size > 0
+            prevAddress = address
+            prevData = data
+          end
+        end
+      end
+      set_data(prevAddress, prevData) if prevData.size > 0
+    end
+  end
+
+  # ãã¼ã¿åå¾
+  def get_data(address, size)
+    endAddress = address + size
+    @sRecData.each do |block, blockData|
+      if (block <= address && endAddress <= block + blockData.size / 2)
+        offset = (address - block) * 2
+        return(blockData[offset, size * 2])
+      end
+    end
+    return(nil)
+  end
+
+  # ãã¼ã¿æ¸è¾¼ã¿
+  def set_data(address, data)
+    endAddress = address + data.size / 2
+    @sRecData.each do |block, blockData|
+      nEndBlock = block + blockData.size / 2
+
+      if nEndBlock < address || endAddress < block
+        # éãªãããªã
+      elsif address < block
+        # æ°è¦ãã¼ã¿ã®æ¹ãå
+é ­çªå°ãå°ãã
+        # ããã§ã¯ endAddress >= block ãæç«ãã¦ãã
+        offset = (endAddress - block) * 2
+        data << blockData[offset..-1]
+        @sRecData.delete(block)
+      else
+        # ç»é²æ¸ã¿ãã¼ã¿ã®æ¹ãå
+é ­çªå°ãå°ãããåã
+        offset = (address - block) * 2
+        address = block
+        blockData[offset, data.size] = data
+        data = blockData
+        @sRecData.delete(block)
+      end
+    end
+    @sRecData[address] = data
+  end
+
+  # å¤ã¨ãã¦ã®ãã¼ã¿åå¾
+  def get_value(address, size, signed)
+    targetData = get_data(address, size)
+    if targetData.nil?
+      return(nil)
+    else
+      if $endianLittle
+        # ãªãã«ã¨ã³ãã£ã¢ã³ã®å ´åï¼ãã¤ããªã¼ãã¼ãéã«ãã
+        reverseData = ""
+        # å¾ããã2æå­ãã¤æãåºãï¼ä¸¦ã³æ¿ãã
+        while targetData.size > 0
+          reverseData << targetData[-2, 2]
+          targetData.slice!(-2, 2)
+        end
+        returnData = reverseData.hex
+      else
+        returnData = targetData.hex
+      end
+
+      # è² ã®æ°ã®å¦ç
+      if signed && (returnData & (1 << (size * 8 - 1))) != 0
+        returnData -= (1 << (size * 8))
+      end
+      return(returnData)
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/cfg/cfg.rb
===================================================================
--- asp3_gr_sakura/trunk/cfg/cfg.rb	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/cfg.rb	(revision 317)
@@ -0,0 +1,753 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Configurator by Ruby
+#
+#  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+#
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+#
+#  $Id: cfg.rb 111 2016-03-16 23:50:27Z ertl-hiro $
+#
+
+if $0 == __FILE__
+  TOOL_ROOT = File.expand_path(File.dirname(__FILE__)) + "/"
+  $LOAD_PATH.unshift(TOOL_ROOT)
+end
+
+require "pp"
+require "csv"
+require "optparse"
+require "pstore"
+require "GenFile.rb"
+require "SRecord.rb"
+
+#
+#  å®æ°å®ç¾©
+#
+# å
+±é
+VERSION = "1.2.2"
+
+# cfg1_outé¢ä¿
+CFG1_PREFIX        = "TOPPERS_cfg_"
+CFG1_MAGIC_NUM     = "TOPPERS_magic_number"
+CFG1_SIZEOF_SIGNED = "TOPPERS_sizeof_signed_t"
+CFG1_OUT_C         = "cfg1_out.c"
+CFG1_OUT_DB        = "cfg1_out.db"
+CFG1_OUT_SREC      = "cfg1_out.srec"
+CFG1_OUT_SYMS      = "cfg1_out.syms"
+CFG1_OUT_TIMESTAMP = "cfg1_out.timestamp"
+CFG1_OUT_TARGET_H  = "target_cfg1_out.h"
+
+# cfg2_outé¢ä¿
+CFG2_OUT_DB        = "cfg2_out.db"
+
+# cfg3_outé¢ä¿
+CFG3_OUT_DB        = "cfg3_out.db"
+
+#
+#  ã¨ã©ã¼çºçæç¡ãã©ã°
+#
+$errorFlag = false
+
+#
+#  ã¨ã©ã¼ï¼è­¦åè¡¨ç¤ºé¢æ°
+#
+# ä¸è¬çãªã¨ã©ã¼è¡¨ç¤ºï¼å¦çãä¸­æ­ï¼
+def error_exit(message, location = "")
+  location += " " if location != ""
+  abort("#{location}error: #{message}")
+end
+
+# ä¸è¬çãªã¨ã©ã¼è¡¨ç¤ºï¼å¦çãç¶ç¶ï¼
+def error(message, location = "")
+  location += " " if location != ""
+  STDERR.puts("#{location}error: #{message}")
+  $errorFlag = true
+end
+
+# ä¸è¬çãªè­¦åè¡¨ç¤º
+def warning(message, location = "")
+  location += " " if location != ""
+  STDERR.puts("#{location}warning: #{message}")
+end
+
+# ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®æ§æè§£ææã®ã¨ã©ã¼
+$noParseError = 0
+def parse_error(cfgFile, message)
+  error(message, "#{cfgFile.getFileName()}:#{cfgFile.getLineNo}:")
+  if ($noParseError += 1) >= 10
+    abort("too many errors emitted, stopping now")
+  end
+end
+
+# ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®æ§æè§£ææã®è­¦å
+def parse_warning(cfgFile, message)
+  warning(message, "#{cfgFile.getFileName()}:#{cfgFile.getLineNo}:")
+end
+
+#
+#  éçAPIå¦çæã®ã¨ã©ã¼ï¼è­¦åè¡¨ç¤ºé¢æ°
+#
+# éçAPIå¦çæã®ã¨ã©ã¼ï¼è­¦åãç­ãè¨è¿°ã§ããããã«ï¼ã¡ãã»ã¼ã¸ä¸­ã®%ã¾
+# ãã¯%%ã§å§ã¾ãè¨è¿°ãä»¥ä¸ã®ããã«å±éããï¼
+#	%label â #{params[:label]}
+#	%%label â label `#{params[:label]}'
+#
+# ã¨ã©ã¼ï¼è­¦åã¡ãã»ã¼ã¸ã®å±é
+def expand_message(message, params)
+  result = message.dup
+  while /%%(\w+)\b/ =~ result
+    param = $1
+    paramVal = params[param.to_sym].to_s
+    result.sub!(/%%#{param}\b/, "#{param} `#{paramVal}'")
+  end
+  while /%(\w+)\b/ =~ result
+    param = $1
+    paramVal = params[param.to_sym].to_s
+    result.sub!(/%#{param}\b/, paramVal)
+  end
+  return(result)
+end
+
+# éçAPIå¦çæã®ã¨ã©ã¼
+def error_api(params, message)
+  error(expand_message(message, params), \
+			"#{params[:_file_]}:#{params[:_line_]}:")
+end
+
+# éçAPIå¦çæã®è­¦å
+def warning_api(params, message)
+  warning(expand_message(message, params), \
+			"#{params[:_file_]}:#{params[:_line_]}:")
+end
+
+# éçAPIå¦çæã®ã¨ã©ã¼ï¼ã¨ã©ã¼ã³ã¼ãä»ãï¼
+def error_ercd(errorCode, params, message)
+  error_api(params, "#{errorCode}: #{message}")
+end
+
+# éçAPIå¦çæã®è­¦åï¼ã¨ã©ã¼ã³ã¼ãä»ãï¼
+def warning_ercd(errorCode, params, message)
+  warning_api(params, "#{errorCode}: #{message}")
+end
+
+# ãã©ã¡ã¼ã¿ã®ã¨ã©ã¼
+def error_wrong(errorCode, params, symbol, wrong)
+  error_ercd(errorCode, params, "%%#{symbol} is #{wrong} in %apiname")
+end
+
+def error_wrong_id(errorCode, params, symbol, objid, wrong)
+  error_ercd(errorCode, params, "%%#{symbol} is #{wrong} " \
+	             					"in %apiname of %#{objid}")
+end
+
+def error_wrong_sym(errorCode, params, symbol, symbol2, wrong)
+  error_ercd(errorCode, params, "%%#{symbol} is #{wrong} " \
+									"in %apiname of %%#{symbol2}")
+end
+
+# ãã©ã¡ã¼ã¿ä¸æ­£ã®ã¨ã©ã¼
+def error_illegal(errorCode, params, symbol)
+  error_ercd(errorCode, params, "illegal %%#{symbol} in %apiname")
+end
+
+def error_illegal_id(errorCode, params, symbol, objid)
+  error_ercd(errorCode, params, "illegal %%#{symbol} " \
+	             					"in %apiname of %#{objid}")
+end
+
+def error_illegal_sym(errorCode, params, symbol, symbol2)
+  error_ercd(errorCode, params, "illegal %%#{symbol} " \
+									"in %apiname of %%#{symbol2}")
+end
+
+#
+#  Stringã¯ã©ã¹ã®æ¡å¼µï¼äºéå¼ç¨ç¬¦ã§å²ã¾ããæå­åã®ä½æï¼å±éï¼
+#
+class String
+  #
+  #  äºéå¼ç¨ç¬¦ã§å²ã¾ããæå­åã®ä½æ
+  #
+  def quote
+    result = ""
+    self.chars do |c|
+      case c
+      when "'"
+        result += "\\\'"
+      when "\""
+        result += "\\\""
+      when "\0"
+        result += "\\0"
+      when "\a"
+        result += "\\a"
+      when "\b"
+        result += "\\b"
+      when "\f"
+        result += "\\f"
+      when "\n"
+        result += "\\n"
+      when "\r"
+        result += "\\r"
+      when "\t"
+        result += "\\t"
+      when "\v"
+        result += "\\v"
+      when "\\"
+        result += "\\\\"
+      else
+        result += c
+      end
+    end
+    return("\"" + result + "\"")
+  end
+
+  #
+  #  äºéå¼ç¨ç¬¦ã§å²ã¾ããæå­åã®å±é
+  #
+  def unquote
+    if /^\"(.*)\"$/m =~ self
+      str = $1
+      result = ""
+      while (/^(.*)\\(.*)$/m =~ str)
+        result += $1
+        str = $2
+        case str
+        when /^[aA](.*)$/m
+          result += "\a"
+          str = $1
+        when /^[bB](.*)$/m
+          result += "\b"
+          str = $1
+        when /^[fF](.*)$/m
+          result += "\f"
+          str = $1
+        when /^[nN](.*)$/m
+          result += "\n"
+          str = $1
+        when /^[rR](.*)$/m
+          result += "\r"
+          str = $1
+        when /^[tT](.*)$/m
+          result += "\t"
+          str = $1
+        when /^[vV](.*)$/m
+          result += "\v"
+          str = $1
+        when /^[xX]([0-9a-fA-F][0-9a-fA-F]?)(.*)$/m
+          result += $1.hex
+          str = $2
+        when /^([0-7][0-7]?[0-7]?)(.*)$/m
+          result += $1.oct
+          str = $2
+        when /^\\(.*)$/m
+          result += "\\"
+          str = $1
+        end
+      end
+      return(result + str)
+    else
+      return(self.dup)
+    end
+  end
+end
+
+#
+#  NumStrã¯ã©ã¹ï¼æ°å¤ã«æå­åãä»å ãããã®ï¼ã®å®ç¾©
+#
+class NumStr
+  def initialize(val, str = val.to_s)
+    @val = val
+    @str = str
+  end
+
+  # æ°å¤æ
+å ±ãè¿ã
+  def val
+    return @val
+  end
+  alias_method :to_i, :val
+
+  # æå­åæ
+å ±ãè¿ã
+  def str
+    return @str
+  end
+  alias_method :to_s, :str
+
+  # æ¯è¼ã¯æ°å¤æ
+å ±ã§è¡ã
+  def ==(other)
+    @val == other
+  end
+  def !=(other)
+    @val != other
+  end
+  def <=>(other)
+    @val <=> other
+  end
+
+  # ããã·ã¥ã®ã­ã¼ã¨ãã¦ä½¿ãæã®æ¯è¼ãæ°å¤æ
+å ±ã§è¡ã
+  def eql?(other)
+    @val == other.val
+  end
+
+  # ããã·ã¥å¤ã®å®ç¾©ãä¸æ¸ããã
+  def hash
+    return @val.hash
+  end
+
+  # æ°å¤ã¯ã©ã¹ã¨æ¼ç®ã§ããããã«ãã
+  def coerce(other)
+    if other.kind_of?(Numeric)
+      return other, @val
+    else
+      raise
+    end
+  end
+
+  # äºéå¼ç¨ç¬¦ã§å²ã¾ããæå­åã®ä½æ
+  def quote
+    str.quote
+  end
+
+  # äºéå¼ç¨ç¬¦ã§å²ã¾ããæå­åã®å±é
+  def unquote
+    str.unquote
+  end
+
+  # ppæã®è¡¨ç¤º
+  def pretty_print(q)
+    q.text("[#{@val}(=0x#{@val.to_s(16)}),")
+    @str.pretty_print(q)
+    q.text("]")
+  end
+
+  # æªå®ç¾©ã®ã¡ã½ããã¯@valã«éã
+  def method_missing(*method)
+    @val.send(*method)
+  end
+end
+
+#
+#  ã·ã³ãã«ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+#
+#  ä»¥ä¸ã®ã¡ã½ããã¯ï¼GNUã®nmãçæããã·ã³ãã«ãã¡ã¤ã«ã«å¯¾å¿ãã¦ããï¼
+#  å¥ã®ãã¼ã«ã«å¯¾å¿ããå ´åã«ã¯ï¼ãã®ã¡ã½ãããæ¸ãæããã°ããï¼
+#
+def ReadSymbolFile(symbolFileName)
+  begin
+    symbolFile = File.open(symbolFileName)
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  symbolAddress = {}
+  symbolFile.each do |line|
+    # ã¹ãã¼ã¹åºåãã§åè§£
+    fields = line.split(/\s+/)
+
+    # 3åã«ãªã£ã¦ããªãè¡ã¯é¤å¤
+    if fields.size == 3
+      symbolAddress[fields[2]] = fields[0].hex
+    end
+  end
+  symbolFile.close
+  return(symbolAddress)
+end
+
+#
+#  å¤åå¾ã·ã³ãã«ãã°ã­ã¼ãã«å¤æ°ã¨ãã¦å®ç¾©ãã
+#
+def DefineSymbolValue
+  $symbolValueTable.each do |symbolName, symbolData|
+    if symbolData.has_key?(:VALUE)
+      eval("$#{symbolName} = #{symbolData[:VALUE]}")
+    end
+  end
+end
+
+#
+#  ã¤ã³ã¯ã«ã¼ããã¹ãããã¡ã¤ã«ãæ¢ã
+#
+def SearchFilePath(fileName)
+  if File.exist?(fileName)
+    # æå®ãããã¡ã¤ã«ãã¹ã«å­å¨ãã
+    return fileName
+  elsif /^\./ =~ fileName
+    # ç¸å¯¾ãã¹ãæå®ãã¦ãã¦è¦ã¤ãããªãã£ãå ´åï¼å­å¨ããªããã®ã¨ãã
+    #ï¼æå³ããªããã¡ã¤ã«ãå¯¾è±¡ã¨ãªããã¨ãé²æ­¢ï¼
+    return nil
+  else
+    # åã¤ã³ã¯ã«ã¼ããã¹ãããã¡ã¤ã«å­å¨ãã§ãã¯
+    $includeDirectories.each do |includeDirectory|
+      path = includeDirectory + "/" + fileName
+      # è¦ã¤ãã£ããç¸å¯¾ãã¹ãè¿ã
+      if File.exist?(path)
+        return path
+      end
+    end
+    return nil
+  end
+end
+
+#
+#  æå®ããçæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼ãæ¤ç´¢ãã¦loadãã
+#
+def IncludeTrb(fileName)
+  filePath = SearchFilePath(fileName)
+  if filePath.nil?
+    error_exit("`#{fileName}' not found")
+  else
+    load(filePath)
+  end
+end
+
+#
+#  ãã¹3ã®å¦ç
+#
+def Pass3
+  #
+  #  ãã¹2ããå¼ãæ¸¡ãããæ
+å ±ããã¡ã¤ã«ããèª­ã¿è¾¼ã
+  #
+  db = PStore.new(CFG2_OUT_DB)
+  db.transaction(true) do
+    $apiDefinition = db[:apiDefinition]
+    $symbolValueTable = db[:symbolValueTable]
+    $cfgFileInfo = db[:cfgFileInfo]
+    $includeFiles = db[:includeFiles]
+    $cfgData = db[:cfgData]
+    $asmLabel = db[:asmLabel]
+    $endianLittle = db[:endianLittle]
+    $cfg2Data = db[:cfg2Data]
+  end
+  $cfg3Data = {}
+
+  #
+  #  å¤åå¾ã·ã³ãã«ãã°ã­ã¼ãã«å¤æ°ã¨ãã¦å®ç¾©ãã
+  #
+  DefineSymbolValue()
+
+  #
+  #  çæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼ãå®è¡ãã
+  #
+  $trbFileNames.each do |trbFileName|
+    IncludeTrb(trbFileName)
+  end
+
+  #
+  #  ãã¹4ã«å¼ãæ¸¡ãæ
+å ±ããã¡ã¤ã«ã«çæ
+  #
+  if $omitOutputDb.nil?
+    db = PStore.new(CFG3_OUT_DB)
+    db.transaction do
+      db[:apiDefinition] = $apiDefinition
+      db[:symbolValueTable] = $symbolValueTable
+      db[:cfgFileInfo] = $cfgFileInfo
+      db[:includeFiles] = $includeFiles
+      db[:cfgData] = $cfgData
+      db[:asmLabel] = $asmLabel
+      db[:endianLittle] = $endianLittle
+      db[:cfg3Data] = $cfg3Data
+    end
+  end
+end
+
+#
+#  ãã¹4ã®å¦ç
+#
+def Pass4
+  #
+  #  ãã¹3ããå¼ãæ¸¡ãããæ
+å ±ããã¡ã¤ã«ããèª­ã¿è¾¼ã
+  #
+  db = PStore.new(CFG3_OUT_DB)
+  db.transaction(true) do
+    $apiDefinition = db[:apiDefinition]
+    $symbolValueTable = db[:symbolValueTable]
+    $cfgFileInfo = db[:cfgFileInfo]
+    $includeFiles = db[:includeFiles]
+    $cfgData = db[:cfgData]
+    $asmLabel = db[:asmLabel]
+    $endianLittle = db[:endianLittle]
+    $cfg3Data = db[:cfg3Data] || db[:cfg2Data]
+  end
+
+  #
+  #  å¤åå¾ã·ã³ãã«ãã°ã­ã¼ãã«å¤æ°ã¨ãã¦å®ç¾©ãã
+  #
+  DefineSymbolValue()
+
+  #
+  #  çæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼ãå®è¡ãã
+  #
+  $trbFileNames.each do |trbFileName|
+    IncludeTrb(trbFileName)
+  end
+end
+
+#
+#  çæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼åãã®é¢æ°
+#
+def SYMBOL(symbol)
+  if !$romSymbol.nil? && $romSymbol.has_key?($asmLabel + symbol)
+    return $romSymbol[$asmLabel + symbol]
+  else
+    return nil
+  end
+end
+
+def BCOPY(fromAddress, toAddress, size)
+  if !$romImage.nil?
+    copyData = $romImage.get_data(fromAddress, size)
+    if !copyData.nil?
+      $romImage.set_data(toAddress, copyData)
+    end
+  end
+end
+
+def BZERO(address, size)
+  if !$romImage.nil?
+    $romImage.set_data(address, "00" * size)
+  end
+end
+
+def PEEK(address, size, signed=false)
+  if !$romImage.nil?
+    return $romImage.get_value(address, size, signed)
+  else
+    return nil
+  end
+end
+
+#
+#  ã°ã­ã¼ãã«å¤æ°ã®åæå
+#
+$kernel = nil
+$pass = nil
+$includeDirectories = []
+$trbFileNames = []
+$apiTableFileNames = []
+$symvalTableFileNames = []
+$romImageFileName = nil
+$romSymbolFileName = nil
+$dependencyFileName = nil
+$idInputFileName = nil
+$idOutputFileName = nil
+
+#
+#  ãªãã·ã§ã³ã®å¦ç
+#
+OptionParser.new(banner="Usage: cfg.rb [options] CONFIG-FILE", 40) do |opt|
+  opt.version = VERSION
+  opt.on("-k KERNEL", "--kernel KERNEL", "kernel profile name") do |val|
+    $kernel = val
+  end
+  opt.on("-p NUM", "--pass NUM", "processing pass number") do |val|
+    $pass = val
+  end
+  opt.on("-I DIRECTORY", "--include-directory DIRECTORY",
+										 "include directory") do |val|
+    $includeDirectories.push(val)
+  end
+  opt.on("-T TRB-FILE", "--trb-file TRB-FILE",
+         "generation script (trb file)") do |val|
+    $trbFileNames.push(val)
+  end
+  opt.on("--api-table API-TABLE-FILE", "static API table file") do |val|
+    $apiTableFileNames.push(val)
+  end
+  opt.on("--symval-table SYMVAL-TABLE-FILE", "symbol-value table file") do |val|
+    $symvalTableFileNames.push(val)
+  end
+  opt.on("--rom-image SREC-FILE", "rom image file (s-record)") do |val|
+    $romImageFileName = val
+  end
+  opt.on("--rom-symbol SYMS-FILE", "rom symbol table file (nm)") do |val|
+    $romSymbolFileName = val
+  end
+  opt.on("--id-input-file ID-FILE", "ID input file") do |val|
+    $idInputFileName = val
+  end
+  opt.on("--id-output-file ID-FILE", "ID output file") do |val|
+    $idOutputFileName = val
+  end
+  opt.on("-M [DEPEND-FILE]", "--print-dependencies [DEPEND-FILE]",
+         "dependency file") do |val|
+    $dependencyFileName = val.nil? ? "" : val
+  end
+  opt.on("-O", "--omit-output-db", "omit DB file output") do
+    $omitOutputDb = true
+  end
+  opt.on("-v", "--version", "show version number") do
+    abort(opt.ver)
+  end
+  opt.on("-h", "--help", "show help (this)") do
+    abort(opt.help)
+  end
+  opt.parse!(ARGV)
+end
+$configFileNames = ARGV
+
+#
+#  ãªãã·ã§ã³ã®ãã§ãã¯
+#
+if $pass.nil?
+  # ãã¹ã®æå®ã¯å¿
+é 
+  abort("`--pass' option is mandatory")
+elsif /^[1234]$/ !~ $pass
+  abort("pass number `#{$pass}' is not valid")
+end
+
+# ãã¹1ã§ã¯ï¼éçAPIãã¼ãã«ã¯å¿
+é 
+if ($pass == "1" && $apiTableFileNames.empty?)
+  abort("`--api-table' option must be specified in pass 1")
+end
+
+# ãã¹1ä»¥å¤ã§ã¯ï¼çæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼ãå¿
+é 
+if ($pass != "1" && $trbFileNames.empty?)
+  abort("`--trb-file' must be specified except in pass 1")
+end
+
+#
+#  ã«ã¼ãã«ãªãã·ã§ã³ã®å¦ç
+#
+case $kernel
+when /^hrp/
+	$supportDomain = true
+when /^fmp/
+	$supportClass = true
+end
+
+#
+#  IDçªå·å
+¥åãã¡ã¤ã«ã®åãè¾¼ã¿
+#
+$inputObjid = {}
+if !$idInputFileName.nil?
+  begin
+    idInputFile = File.open($idInputFileName)
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  idInputFile.each do |line|
+    ( objName, objidNumber ) = line.split(/\s+/)
+    $inputObjid[objName] = objidNumber.to_i
+  end
+
+  idInputFile.close
+end
+
+#
+#  æå®ãããã·ã³ãã«ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+#
+if !$romSymbolFileName.nil?
+  if File.exist?($romSymbolFileName)
+    $romSymbol = ReadSymbolFile($romSymbolFileName)
+  else
+    error_exit("`#{$romSymbolFileName}' not found")
+  end
+end
+
+#
+#  æå®ãããSã¬ã³ã¼ããã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+#
+if !$romImageFileName.nil?
+  if File.exist?($romImageFileName)
+    $romImage = SRecord.new($romImageFileName)
+  else
+    error_exit("`#{$romImageFileName}' not found")
+  end
+end
+
+#
+#  ãã¹ã«å¾ã£ã¦åå¦çãå®è¡
+#
+case $pass
+when "1"
+  load("pass1.rb")
+  Pass1()
+when "2"
+  load("pass2.rb")
+  Pass2()
+when "3"
+  Pass3()
+when "4"
+  Pass4()
+else
+  error_exit("invalid pass: #{$pass}")
+end
+
+# ã¨ã©ã¼çºçæã¯abortãã
+if $errorFlag
+  if ($0 == __FILE__)
+    abort()
+  else
+    # simplecovå¯¾å¿
+    raise()
+  end
+end
+
+#
+#  ä½æãããã¹ã¦ã®ãã¡ã¤ã«ãåºåãã
+#
+GenFile.output
+
+# 
+#  ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®çæ
+# 
+if !$timeStampFileName.nil?
+  File.open($timeStampFileName, "w").close
+end
Index: asp3_gr_sakura/trunk/cfg/pass1.rb
===================================================================
--- asp3_gr_sakura/trunk/cfg/pass1.rb	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/pass1.rb	(revision 317)
@@ -0,0 +1,974 @@
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Configurator by Ruby
+#
+#  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#  Copyright (C) 2015-2017 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+#
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+#
+#  $Id: pass1.rb 126 2016-05-03 06:53:08Z ertl-hiro $
+#
+
+#
+#		ãã¹1ã®å¦ç
+#
+
+#
+#  å¤åå¾ã·ã³ãã«ãã¼ãã«ã¸ã®åºå®ç»é²
+#
+$symbolValueTable = {
+  "CHAR_BIT"  => { EXPR: "CHAR_BIT" },
+  "SCHAR_MAX" => { EXPR: "SCHAR_MAX", SIGNED: true },
+  "SCHAR_MIN" => { EXPR: "SCHAR_MIN", SIGNED: true },
+  "UCHAR_MAX" => { EXPR: "UCHAR_MAX" },
+  "CHAR_MAX"  => { EXPR: "CHAR_MAX",  SIGNED: true },
+  "CHAR_MIN"  => { EXPR: "CHAR_MIN",  SIGNED: true },
+  "SHRT_MAX"  => { EXPR: "SHRT_MAX",  SIGNED: true },
+  "SHRT_MIN"  => { EXPR: "SHRT_MIN",  SIGNED: true },
+  "USHRT_MAX" => { EXPR: "USHRT_MAX" },
+  "INT_MAX"   => { EXPR: "INT_MAX",   SIGNED: true },
+  "INT_MIN"   => { EXPR: "INT_MIN",   SIGNED: true },
+  "UINT_MAX"  => { EXPR: "UINT_MAX" },
+  "LONG_MAX"  => { EXPR: "LONG_MAX",  SIGNED: true },
+  "LONG_MIN"  => { EXPR: "LONG_MIN",  SIGNED: true },
+  "ULONG_MAX" => { EXPR: "ULONG_MAX" }
+}
+
+#
+#  éçAPIãã¼ãã«ã¸ã®åºå®ç»é²
+#
+$apiDefinition = { "INCLUDE" =>
+  { :PARAM => [ { :NAME => :file, :STRING => true }]}}
+
+#
+#  éçAPIãã¼ãã«ã®èª­ã¿è¾¼ã¿
+#
+def ReadApiTableFile
+  $apiTableFileNames.each do |apiTableFileName|
+    if /^(.+):(\w+)$/ =~ apiTableFileName
+      apiTableFileName = $1
+      apiPhase = $2.to_sym
+    end
+
+    if !File.exist?(apiTableFileName)
+      error_exit("`#{apiTableFileName}' not found")
+      next
+    end
+
+    apiFile = File.open(apiTableFileName)
+    apiFile.each do |line|
+      next if /^#/ =~ line			# ã³ã¡ã³ããã¹ã­ãã
+
+      fields = line.split(/\s+/)	# ãã£ã¼ã«ãã«åè§£
+
+      apiName = fields.shift		# APIåã®åãåºã
+      if /^(.+)\[(.+)\]$/ =~ apiName
+        apiName = $1
+        apiDef = { APINAME: apiName, API: $2 }
+      else
+        apiDef = { APINAME: apiName, API: apiName }
+      end
+      if !apiPhase.nil?
+        apiDef[:PHASE] = apiPhase
+      end
+
+      apiParams = []
+      fields.each do |param|
+        case param
+        when /^(\W*)(\w+)(\W*)$/
+          prefix = $1
+          name = $2
+          postfix = $3
+          apiParam = { :NAME => name }
+
+          case prefix
+          when "#"					# ãªãã¸ã§ã¯ãè­å¥åï¼å®ç¾©ï¼
+            apiParam[:ID_DEF] = true
+          when "%"					# ãªãã¸ã§ã¯ãè­å¥åï¼åç
+§ï¼
+            apiParam[:ID_REF] = true
+          when "."					# ç¬¦å·ç¡ãæ´æ°å®æ°å¼ãã©ã¡ã¼ã¿
+            apiParam[:EXPTYPE] = "unsigned_t"
+          when "+"					# ç¬¦å·ä»ãæ´æ°å®æ°å¼ãã©ã¡ã¼ã¿
+            apiParam[:EXPTYPE] = "signed_t"
+            apiParam[:SIGNED] = true
+          when "&"					# ä¸è¬æ´æ°å®æ°å¼ãã©ã¡ã¼ã¿
+            # do nothing
+          when "$"					# æå­åå®æ°å¼ãã©ã¡ã¼ã¿
+            apiParam[:STRING] = true
+          else
+            error_exit("`#{param}' is invalid")
+          end
+
+          case postfix
+          when "*"					# ã­ã¼ãæ±ºãããã©ã¡ã¼ã¿
+            apiDef[:KEYPAR] = name
+          when "?"					# ãªãã·ã§ã³ãã©ã¡ã¼ã¿
+            apiParam[:OPTIONAL] = true
+          when "\.\.\."				# ãªã¹ããã©ã¡ã¼ã¿
+            apiParam[:LIST] = true
+          end
+        
+        when "{"					# {
+          apiParam = { :BRACE => "{" }
+        when "{?"					# {?
+          apiParam = { :BRACE => "{", :OPTBRACE => true }
+
+        when "}"					# }
+          apiParam = { :BRACE => "}" }
+
+        else
+          error_exit("`#{param}' is invalid")
+        end
+        apiParams.push(apiParam)
+      end
+      apiDef[:PARAM] = apiParams
+      $apiDefinition[apiName] = apiDef
+    end
+    apiFile.close
+  end
+end
+
+#
+#  å¤åå¾ã·ã³ãã«ãã¼ãã«ã®èª­ã¿è¾¼ã¿
+#
+def ReadSymvalTable
+  $symvalTableFileNames.each do |symvalTableFileName|
+    if !File.exist?(symvalTableFileName)
+      error_exit("`#{symvalTableFileName}' not found")
+      next
+    end
+
+    symvalCsv = CSV.open(symvalTableFileName,
+						{ skip_blanks: true, skip_lines: /^#/ })
+    symvalCsv.each do |record|
+      # å¤æ°å
+      if record[0].nil?
+        error_exit("invalid variable name in " \
+						"`#{symvalTableFileName}:#{symvalCsv.to_io.lineno}'")
+      end
+
+      symbol = {}
+      variable = record[0]
+
+      # å¼
+      if record[1].nil? || record[1].empty?
+        symbol[:EXPR] = variable
+      else
+        symbol[:EXPR] = record[1]
+      end
+
+      # å¼ã®å
+      if !record[2].nil? && !record[2].empty?
+        case record[2]
+        when /^[bB]/				# çå½å¤
+          symbol[:BOOL] = true
+        when /^[uU]/				# ç¬¦å·ç¡ãæ´æ°å¤
+          # ä½ãè¨­å®ããªã
+        else						# ç¬¦å·ä»ãæ´æ°å¤
+          symbol[:SIGNED] = true
+        end
+      end
+
+      # ã³ã³ãã¤ã«æ¡ä»¶
+      if !record[3].nil? && !record[3].empty?
+        symbol[:CONDITION] = record[3]
+      end
+
+      # æ¡ä»¶ãæç«ããªãæã®å¼
+      if !record[4].nil? && !record[4].empty?
+        symbol[:ELSE_EXPR] = record[4]
+      end
+
+      $symbolValueTable[variable] = symbol
+    end
+    symvalCsv.close
+  end
+end
+
+#
+#  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ããã®èª­ã¿è¾¼ã¿ã¯ã©ã¹
+#
+class ConfigFile
+  def initialize(fileName)
+    @cfgFileName = fileName
+    begin
+      @cfgFile = File.open(@cfgFileName)
+    rescue Errno::ENOENT, Errno::EACCES => ex
+      abort(ex.message)
+    end
+    @lineNo = 0
+    @withinComment = false
+  end
+
+  def close
+    @cfgFile.close
+  end
+
+  def getNextLine(withinApi)
+    line = @cfgFile.gets
+    return(nil) if line.nil?
+
+	line.encode!("UTF-16BE", "UTF-8",	# ä¸æ­£ãªãã¤ãåãé¤å¤ãã
+					:invalid => :replace,
+					:undef => :replace,
+					:replace => '?').encode!("UTF-8")
+    @lineNo += 1
+
+    line.chomp!
+    if @withinComment
+      case line
+      when /\*\//						# Cè¨èªã¹ã¿ã¤ã«ã®ã³ã¡ã³ãçµäº
+        line.sub!(/^.*?\*\//, "")		# æåã®*/ã«ãããããã */
+        @withinComment = false
+      else
+        line = ""
+      end
+    end
+    if !@withinComment
+      line.gsub!(/\/\*.*?\*\//, "")		# Cè¨èªã¹ã¿ã¤ã«ã®ã³ã¡ã³ãã®é¤å»
+										# æåã®*/ã«ãããããã */
+      case line
+      when /^\s*#/						# ããªãã­ã»ããµãã£ã¬ã¯ãã£ã
+        if withinApi
+          parse_error(self, \
+					"preprocessor directive must not be within static API")
+          line = ""
+        end
+      when /\/\*/						# Cè¨èªã¹ã¿ã¤ã«ã®ã³ã¡ã³ãéå§
+        line.sub!(/\/\*.*$/, "")
+        @withinComment = true
+      when /\/\//						# C++è¨èªã¹ã¿ã¤ã«ã®ã³ã¡ã³ã
+        line.sub!(/\/\/.*$/, "")
+      end
+    end
+    return(line)
+  end
+
+  def getFileName
+    return(@cfgFileName)
+  end
+
+  def getLineNo
+    return(@lineNo)
+  end
+end
+
+#
+#  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ãã¼ãµã¼ã¯ã©ã¹
+#
+class CfgParser
+  @@lastApiIndex = 0
+  @@currentDomain = nil
+  @@currentClass = nil
+  @@nestDC = []
+
+  def initialize
+    @line = ""
+    @skipComma = false						# æ¬¡ã,ã§ããã°èª­ã¿é£ã°ã
+  end
+
+  #
+  #  æå­åæ«ã¾ã§èª­ã
+  #
+  def parseString(cfgFile)
+    string = ""
+    begin
+      case @line
+      when /^([^"]*\\\\)(.*)$/				# \\ã¾ã§èª­ã
+        string += $1
+        @line = $2
+      when /^([^"]*\\\")(.*)$/				# \"ã¾ã§èª­ã
+        string += $1
+        @line = $2
+      when /^([^"]*\")(.*)$/				# "ã¾ã§èª­ã
+        string += $1
+        @line = $2
+        return(string)
+      else									# è¡æ«ã¾ã§èª­ã
+        string += @line + "\n"
+        @line = cfgFile.getNextLine(true)
+      end
+    end while (@line)
+    error_exit("unterminated string meets end-of-file")
+    return(string)
+  end
+
+  #
+  #  æå­æ«ã¾ã§èª­ã
+  #
+  def parseChar(cfgFile)
+    string = ""
+    begin
+      case @line
+      when /^([^']*\\\\)(.*)$/				# \\ã¾ã§èª­ã
+        string += $1
+        @line = $2
+      when /^([^']*\\\')(.*)$/				# \'ã¾ã§èª­ã
+        string += $1
+        @line = $2
+      when /^([^']*\')(.*)$/				# 'ã¾ã§èª­ã
+        string += $1
+        @line = $2
+        return(string)
+      else									# è¡æ«ã¾ã§èª­ã
+        string += @line + "\n"
+        @line = cfgFile.getNextLine(true)
+      end
+    end while (@line)
+    error_exit("unterminated string meets end-of-file")
+    return(string)
+  end
+
+  #
+  #  æ¹è¡ã¨ç©ºç½æå­ãèª­ã¿é£ã°ã
+  #
+  def skipSpace(cfgFile, withinApi)
+    loop do
+      return if @line.nil?						# ãã¡ã¤ã«æ«ã§ããã°ãªã¿ã¼ã³
+      @line.lstrip!								# å
+é ­ã®ç©ºç½ãåé¤
+      return if @line != ""						# ç©ºè¡ã§ãªããã°ãªã¿ã¼ã³
+      @line = cfgFile.getNextLine(withinApi)	# æ¬¡ã®è¡ãèª­ã
+    end
+  end
+
+  #
+  #  æ¬¡ã®æå­ã¾ã§èª­ã¿é£ã°ã
+  #
+  def skipToToken(cfgFile, withinApi=true)
+    skipSpace(cfgFile, withinApi)
+    if @line.nil?							# ãã¡ã¤ã«æ«ã§ããã°ã¨ã©ã¼çµäº
+      error_exit("unexpexced end-of-file")
+    end
+  end
+
+  #
+  #  ãã©ã¡ã¼ã¿ã1ã¤èª­ã
+  #
+  # @lineã®å
+é ­ãããã©ã¡ã¼ã¿ã1ã¤èª­ãã§ï¼ãããæå­åã§è¿ãï¼èª­ãã ã
+  # ã©ã¡ã¼ã¿ã¯ï¼@lineããã¯åé¤ããï¼ãã©ã¡ã¼ã¿ã®éä¸­ã§è¡æ«ã«éããæã¯ï¼
+  # cfgFileããæ¬¡ã®è¡ãåãåºãï¼ãã¡ã¤ã«æ«ã«éããæã¯ï¼nilãè¿ãï¼
+  #
+  def parseParam(cfgFile)
+    param = ""								# èª­ãã æå­å
+    parenLevel = 0							# æ¬å¼§ã®ãã¹ãã¬ãã«
+    skipComma = @skipComma
+    @skipComma = false
+
+    skipToToken(cfgFile)					# æ¬¡ã®æå­ã¾ã§èª­ã¿é£ã°ã
+    begin
+      if parenLevel == 0
+        case @line
+        when /^(\s*,)(.*)$/					# ,
+          @line = $2
+          if param == "" && skipComma
+            skipComma = false
+            return(parseParam(cfgFile))		# åå¸°å¼ã³åºã
+          else
+            return(param.strip)
+          end
+        when /^(\s*{)(.*)$/					# {
+          if param != ""
+            return(param.strip)
+          else
+            @line = $2
+            return("{")
+          end
+        when /^(\s*\()(.*)$/				# (
+          param += $1
+          @line = $2
+          parenLevel += 1
+        when /^(\s*([)}]))(.*)$/			# }ã)
+          if param != ""
+            return(param.strip)
+          else
+            @line = $3
+            @skipComma = true if $2 == "}"
+            return($2)
+          end
+        when /^(\s*\")(.*)$/				# "
+          @line = $2
+          param += $1 + parseString(cfgFile)
+        when /^(\s*\')(.*)$/				# '
+          @line = $2
+          param += $1 + parseChar(cfgFile)
+        when /^(\s*[^,{}()"'\s]+)(.*)$/		# ãã®ä»ã®æå­å
+          param += $1
+          @line = $2
+        else								# è¡æ«
+          param += " "
+          @line = cfgFile.getNextLine(true)
+        end
+      else
+        # æ¬å¼§å
+ã®å¦ç
+        case @line
+        when /^(\s*\()(.*)$/				# "("
+          param += $1
+          @line = $2
+          parenLevel += 1
+        when /^(\s*\))(.*)$/				# ")"
+          param += $1
+          @line = $2
+          parenLevel -= 1
+        when /^(\s*\")(.*)$/				# "
+          @line = $2
+          param += $1 + parseString(cfgFile)
+        when /^(\s*\')(.*)$/				# '
+          @line = $2
+          param += $1 + parseChar(cfgFile)
+        when /^(\s*[^()"'\s]+)(.*)$/		# ãã®ä»ã®æå­å
+          param += $1
+          @line = $2
+        else								# è¡æ«
+          param += " "
+          @line = cfgFile.getNextLine(true)
+        end
+      end
+    end while (@line)
+    return(param.strip)
+  end
+
+  def getParam(apiParam, param, cfgFile)
+    if param == ""
+      if !apiParam.has_key?(:OPTIONAL)
+        parse_error(cfgFile, "unexpected `,'")
+      end
+      return(param)
+    end
+
+    if apiParam.has_key?(:ID_DEF) || apiParam.has_key?(:ID_REF)
+      if (/^[A-Za-z_]\w*$/ !~ param)
+        parse_error(cfgFile, "`#{param}' is illegal object ID")
+      end
+      return(param)
+    end
+
+    if apiParam.has_key?(:STRING)
+      return(param.unquote)
+    else
+      return(param)
+    end
+  end
+
+  def parseApi(cfgFile, apiName)
+    # éçAPIã®èª­ã¿è¾¼ã¿
+    staticApi = {}
+    tooFewParams = false
+    skipUntilBrace = 0
+
+    skipToToken(cfgFile)					# æ¬¡ã®æå­ã¾ã§èª­ã¿é£ã°ã
+    if (/^\((.*)$/ =~ @line)
+      @line = $1
+
+      staticApi[:APINAME] = apiName
+      staticApi[:_FILE_] = cfgFile.getFileName
+      staticApi[:_LINE_] = cfgFile.getLineNo
+      apiDef = $apiDefinition[apiName]
+      param = parseParam(cfgFile)
+
+      apiDef[:PARAM].each do |apiParam|
+        return(staticApi) if param.nil?		# ãã¡ã¤ã«æ«ã§ããã°ãªã¿ã¼ã³
+
+        if skipUntilBrace > 0
+          # APIå®ç¾©ã}ã¾ã§ã¹ã­ããä¸­
+          if apiParam.has_key?(:BRACE)
+            case apiParam[:BRACE]
+            when "{"
+              skipUntilBrace += 1
+            when "}"
+              skipUntilBrace -= 1
+            end
+          end
+        elsif apiParam.has_key?(:OPTIONAL)
+          if /^([{})])$/ !~ param
+            store_param = getParam(apiParam, param, cfgFile)
+            if store_param != ""
+              staticApi[apiParam[:NAME]] = store_param
+            end
+            param = parseParam(cfgFile)
+          end
+        elsif apiParam.has_key?(:LIST)
+          staticApi[apiParam[:NAME]] = []
+          while /^([{})])$/ !~ param
+            staticApi[apiParam[:NAME]].push(getParam(apiParam, param, cfgFile))
+            param = parseParam(cfgFile)
+            break if param.nil?				# ãã¡ã¤ã«æ«ã®å ´å
+          end
+        elsif apiParam.has_key?(:OPTBRACE)
+          if param == apiParam[:BRACE]
+            param = parseParam(cfgFile)
+            break if param.nil?				# ãã¡ã¤ã«æ«ã®å ´å
+          else
+            if param == ""
+              param = parseParam(cfgFile)
+              break if param.nil?			# ãã¡ã¤ã«æ«ã®å ´å
+            elsif /^([})])$/ !~ param
+              parse_error(cfgFile, "`{...}' expected before #{param}")
+            end
+            skipUntilBrace += 1          	# APIå®ç¾©ã}ã¾ã§ã¹ã­ãã
+          end
+        elsif !apiParam.has_key?(:BRACE)
+          if /^([{})])$/ !~ param
+            staticApi[apiParam[:NAME]] = getParam(apiParam, param, cfgFile)
+            param = parseParam(cfgFile)
+          elsif !tooFewParams
+            parse_error(cfgFile, "too few parameters before `#{$1}'")
+            tooFewParams = true
+          end
+        elsif param == apiParam[:BRACE]
+          param = parseParam(cfgFile)
+          tooFewParams = false
+        else
+          parse_error(cfgFile, "`#{apiParam[:BRACE]}' expected before #{param}")
+          # )ããã¡ã¤ã«æ«ã¾ã§èª­ã¿é£ã°ã
+          loop do
+            param = parseParam(cfgFile)
+            break if (param.nil? || param == ")")
+          end
+          break
+        end
+      end
+
+      # æå¾
+ããããã©ã¡ã¼ã¿ããã¹ã¦èª­ãã å¾ã®å¦ç
+      if param != ")"
+        begin
+          param = parseParam(cfgFile)
+          return(staticApi) if param.nil?	# ãã¡ã¤ã«æ«ã§ããã°ãªã¿ã¼ã³
+        end while param != ")"
+        parse_error(cfgFile, "too many parameters before `)'")
+      end
+    else
+      parse_error(cfgFile, "syntax error: #{@line}")
+      @line = ""
+    end
+    return(staticApi)
+  end
+
+  def parseOpenBrace(cfgFile)
+    # {ã®èª­ã¿è¾¼ã¿
+    skipToToken(cfgFile)					# æ¬¡ã®æå­ã¾ã§èª­ã¿é£ã°ã
+    if (/^\{(.*)$/ =~ @line)
+      @line = $1
+    else
+      parse_error(cfgFile, "`{' expected before #{@line}")
+    end
+  end
+
+  def parseFile(cfgFileName)
+    cfgFiles = [ ConfigFile.new(cfgFileName) ]
+    @line = ""
+    loop do
+      cfgFile = cfgFiles.last
+
+      skipSpace(cfgFile, false)				# æ¹è¡ã¨ç©ºç½æå­ãèª­ã¿é£ã°ã
+      if @line.nil?
+        # ãã¡ã¤ã«æ«ã®å¦ç
+        cfgFiles.pop.close
+        if cfgFiles.empty?
+          break								# ãã¼ã¹å¦ççµäº
+        else
+          @line = ""						# å
+ã®ãã¡ã¤ã«ã«æ»ã£ã¦ç¶ãã
+        end
+      elsif /^;(.*)$/ =~ @line
+        # ;ã¯èª­ã¿é£ã°ã
+        @line = $1
+      elsif /^#/ =~ @line
+        # ããªãã­ã»ããµãã£ã¬ã¯ãã£ããèª­ã
+        case @line
+        when /^#include\b(.*)$/
+          $includeFiles.push($1.strip)
+        when /^#(ifdef|ifndef|if|endif|else|elif)\b/
+          directive = { :DIRECTIVE => @line.strip }
+          $cfgFileInfo.push(directive)
+        else
+          parse_error(cfgFile, "unknown preprocessor directive: #{@line}")
+        end
+        @line = ""
+      elsif (/^([A-Z_][A-Z0-9_]*)\b(.*)$/ =~ @line)
+        apiName = $1
+        @line = $2
+
+        case apiName
+        when "KERNEL_DOMAIN"
+          if $supportDomain.nil?
+            parse_warning(cfgFile, "`KERNEL_DOMAIN' is not supported")
+          end
+          if !@@currentDomain.nil?
+            parse_error(cfgFile, "`DOMAIN' must not be nested")
+          end
+          @@currentDomain = "TDOM_KERNEL"
+          parseOpenBrace(cfgFile)
+          @@nestDC.push("domain")
+        when "DOMAIN"
+          if $supportDomain.nil?
+            parse_warning(cfgFile, "`DOMAIN' is not supported")
+          end
+          if !@@currentDomain.nil?
+            parse_error(cfgFile, "`DOMAIN' must not be nested")
+          end
+          domid = parseParam(cfgFile).sub(/^\((.+)\)$/m, "\\1").strip
+          if (/^[A-Za-z_]\w*$/ !~ domid)
+            parse_error(cfgFile, "`#{domid}' is illegal domain ID")
+          else
+            if !$domainId.has_key?(domid)
+              if $inputObjid.has_key?(domid)
+                # IDçªå·å
+¥åãã¡ã¤ã«ã«å®ç¾©ããã¦ããå ´å
+                $domainId[domid] = $inputObjid[domid]
+                if $domainId[domid] > 32
+                  error_exit("domain ID for `#{domid}' is too large")
+                end
+              else
+                $domainId[domid] = nil
+              end
+            end
+            @@currentDomain = domid
+          end
+          parseOpenBrace(cfgFile)
+          @@nestDC.push("domain")
+        when "CLASS"
+          if $supportClass.nil?
+            parse_warning(cfgFile, "`CLASS' is not supported")
+          end
+          if !@@currentClass.nil?
+            parse_error(cfgFile, "`CLASS' must not be nested")
+          end
+          @@currentClass = parseParam(cfgFile).sub(/^\((.+)\)$/m, "\\1").strip
+          @@classFile = cfgFile.getFileName
+          @@classLine = cfgFile.getLineNo
+          parseOpenBrace(cfgFile)
+          @@nestDC.push("class")
+        else
+          if $apiDefinition.has_key?(apiName)
+            # éçAPIã1ã¤èª­ã
+            staticApi = parseApi(cfgFile, apiName)
+            if staticApi.empty?
+              # ãã¡ã¤ã«æ«ãææ³ã¨ã©ã¼
+            elsif (staticApi[:APINAME] == "INCLUDE")
+              # INCLUDEã®å¦ç
+              includeFilePath = SearchFilePath(staticApi[:file])
+              if includeFilePath.nil?
+                parse_error(cfgFile, "`#{staticApi[:file]}' not found")
+              else
+                $dependencyFiles.push(includeFilePath)
+                cfgFiles.push(ConfigFile.new(includeFilePath))
+              end
+            else
+              # éçAPIã®å¦ç
+              if !@@currentDomain.nil?
+                staticApi[:DOMAIN] = @@currentDomain
+              end
+              if !@@currentClass.nil?
+                staticApi[:CLASS] = @@currentClass
+                staticApi[:CLASS_FILE_] = @@classFile
+                staticApi[:CLASS_LINE_] = @@classLine
+              end
+              staticApi[:INDEX] = (@@lastApiIndex += 1)
+              $cfgFileInfo.push(staticApi)
+            end
+          else
+            parse_error(cfgFile, "unknown static API: #{apiName}")
+          end
+        end
+      elsif (/^\}(.*)$/ =~ @line)
+        # }ã®å¦ç
+        if @@nestDC.size > 0
+          case @@nestDC.pop
+          when "domain"
+            @@currentDomain = nil
+          when "class"
+            @@currentClass = nil
+          end
+        else
+          error_exit("unexpected `}'")
+        end
+        @line = $1
+      else
+        parse_error(cfgFile, "syntax error: #{@line}")
+        @line = ""
+      end
+    end
+  end
+end
+
+#
+#  cfg1_out.cã®çæ
+#
+module Cfg1OutC
+  #
+  #  éçAPIã®ãã¡ã¤ã«åã¨è¡çªå·ã®åºå
+  #
+  def self.OutLineNumber(cfgInfo)
+    @cfg1Out.add("#line #{cfgInfo[:_LINE_]} \"#{cfgInfo[:_FILE_]}\"")
+  end
+
+  #
+  #  ã¯ã©ã¹è¨è¿°ã®ãã¡ã¤ã«åã¨è¡çªå·ã®åºå
+  #
+  def self.OutClassLineNumber(cfgInfo)
+    @cfg1Out.add("#line #{cfgInfo[:CLASS_LINE_]} \"#{cfgInfo[:CLASS_FILE_]}\"")
+  end
+
+  #
+  #  ãã©ã¡ã¼ã¿ã«é¢ããå®ç¾©ã®åºå
+  #
+  def self.OutParamDef(param, index, apiParam, cfgInfo)
+    if apiParam.has_key?(:ID_DEF)
+      @cfg1Out.add("#define #{param}\t(<>)")
+    elsif apiParam.has_key?(:EXPTYPE)
+      OutLineNumber(cfgInfo)
+      @cfg1Out.add("const #{apiParam[:EXPTYPE]} #{CFG1_PREFIX}valueof_" \
+								"#{apiParam[:NAME]}_#{index} = " \
+								"(#{apiParam[:EXPTYPE]})(#{param});")
+    end
+  end
+
+  #
+  #  cfg1_out.cã®çæï¼ã¡ã¤ã³ã®å¦çï¼
+  #
+  def self.Generate
+    @cfg1Out = GenFile.new(CFG1_OUT_C)
+
+    @cfg1Out.append(<<EOS)
+/* #{CFG1_OUT_C} */
+#define TOPPERS_CFG1_OUT
+#include "kernel/kernel_int.h"
+EOS
+
+    # ã¤ã³ã¯ã«ã¼ãããããã¡ã¤ã«
+    $includeFiles.each do |file|
+      @cfg1Out.add("#include #{file}")
+    end
+
+    @cfg1Out.add(<<EOS)
+
+#ifdef INT64_MAX
+  typedef int64_t signed_t;
+  typedef uint64_t unsigned_t;
+#else
+  typedef int32_t signed_t;
+  typedef uint32_t unsigned_t;
+#endif
+
+#include "#{CFG1_OUT_TARGET_H}"
+
+#if defined(SIL_ENDIAN_BIG) && defined(SIL_ENDIAN_LITTLE)
+#error Both SIL_ENDIAN_BIG and SIL_ENDIAN_LITTLE are defined.
+#endif
+#if !defined(SIL_ENDIAN_BIG) && !defined(SIL_ENDIAN_LITTLE)
+#error Neither SIL_ENDIAN_BIG nor SIL_ENDIAN_LITTLE is defined.
+#endif
+
+const uint32_t #{CFG1_MAGIC_NUM} = 0x12345678;
+const uint32_t #{CFG1_SIZEOF_SIGNED} = sizeof(signed_t);
+EOS
+
+    # å¤åå¾ã·ã³ãã«ã®å¦ç
+    $symbolValueTable.each do |symbolName, symbolData|
+      if symbolData.has_key?(:BOOL) || symbolData.has_key?(:SIGNED)
+        type = "signed_t"
+      else
+        type = "unsigned_t"
+      end
+      if symbolData.has_key?(:CONDITION)
+        @cfg1Out.add("#if #{symbolData[:CONDITION]}")
+      end
+      @cfg1Out.add("const #{type} #{CFG1_PREFIX}#{symbolName} = " \
+								"(#{type})(#{symbolData[:EXPR]});")
+      if symbolData.has_key?(:ELSE_EXPR)
+        @cfg1Out.add("#else")
+        @cfg1Out.add("const #{type} #{CFG1_PREFIX}#{symbolName} = " \
+								"(#{type})(#{symbolData[:ELSE_EXPR]});")
+      end
+      if symbolData.has_key?(:CONDITION)
+        @cfg1Out.add("#endif")
+      end
+    end
+    @cfg1Out.add
+
+    # ãã¡ã¤ã³IDã®å®ç¾©ã®çæ
+    $domainId.each do |domainName, domainVal|
+      if domainVal > 0
+        @cfg1Out.add("#define #{domainName} #{domainVal}")
+      end
+    end
+    @cfg1Out.add
+
+    # éçAPIï¼ããªãã­ã»ããµãã£ã¬ã¯ãã£ãã®å¦ç
+    $cfgFileInfo.each do |cfgInfo|
+      if cfgInfo.has_key?(:DIRECTIVE)
+        @cfg1Out.add2(cfgInfo[:DIRECTIVE])
+      else
+        apiDef = $apiDefinition[cfgInfo[:APINAME]]
+        apiIndex = cfgInfo[:INDEX]
+        OutLineNumber(cfgInfo)
+        @cfg1Out.add("const unsigned_t #{CFG1_PREFIX}static_api_" \
+										"#{apiIndex} = #{apiIndex};")
+        apiDef[:PARAM].each do |apiParam|
+          next unless apiParam.has_key?(:NAME)
+          paramName = apiParam[:NAME]
+          next unless cfgInfo.has_key?(paramName)	# ãã©ã¡ã¼ã¿ããªãå ´å
+          paramData = cfgInfo[paramName]
+
+          if apiParam.has_key?(:LIST)
+            paramData.each.with_index(1) do |param, index|
+              OutParamDef(param, "#{apiIndex}_#{index}", apiParam, cfgInfo)
+            end
+          else
+            OutParamDef(paramData, "#{apiIndex}", apiParam, cfgInfo)
+          end
+        end
+        if cfgInfo.has_key?(:CLASS)
+          # ã¯ã©ã¹IDã®åå¾ã®ããã®å¦ç
+          OutClassLineNumber(cfgInfo)
+          @cfg1Out.add("const signed_t #{CFG1_PREFIX}valueof_CLASS_" \
+                      "#{apiIndex} = (signed_t)(#{cfgInfo[:CLASS]});")
+        end
+        @cfg1Out.add
+      end
+    end
+  end
+end
+
+#
+#  ãã¹1ã®å¦ç
+#
+def Pass1
+  # 
+  #  ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®æå®
+  # 
+  $timeStampFileName = CFG1_OUT_TIMESTAMP
+
+  #
+  #  éçAPIãã¼ãã«ã®èª­ã¿è¾¼ã¿
+  #
+  ReadApiTableFile()
+
+  #
+  #  å¤åå¾ã·ã³ãã«ãã¼ãã«ã®èª­ã¿è¾¼ã¿
+  #
+  ReadSymvalTable()
+
+  #
+  #  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+  #
+  $cfgFileInfo = []
+  $dependencyFiles = $configFileNames.dup
+  $includeFiles = []
+  $domainId = { "TDOM_KERNEL" => -1, "TDOM_NONE" => -2 }
+  $configFileNames.each do |configFileName|
+    CfgParser.new.parseFile(configFileName)
+  end
+  abort if $errorFlag					# ã¨ã©ã¼çºçæã¯abortãã
+
+  #
+  #  ãã¡ã¤ã³IDã®å²å½ã¦å¦ç
+  #
+  nextDomainId = 1
+  $domainId.each do |domainName, domainVal|
+    if domainVal.nil?
+      while $domainId.has_value?(nextDomainId)
+        nextDomainId += 1
+      end
+      $domainId[domainName] = nextDomainId
+      if nextDomainId > 32
+        error_exit("too large number of user domains")
+      end
+      nextDomainId += 1
+    end
+  end
+
+  #
+  #  cfg1_out.cã®çæ
+  #
+  Cfg1OutC::Generate()
+
+  #
+  #  ä¾å­é¢ä¿ã®åºå
+  #
+  if !$dependencyFileName.nil?
+    if $dependencyFileName == ""
+      depFile = STDOUT
+    else
+      begin
+        depFile = File.open($dependencyFileName, "w")
+      rescue Errno::ENOENT, Errno::EACCES => ex
+        abort(ex.message)
+      end
+    end
+
+    depFile.print("#{CFG1_OUT_TIMESTAMP}:")
+    $dependencyFiles.each do |fileName|
+      depFile.print(" #{fileName}")
+    end
+    depFile.puts("")
+
+    if $dependencyFileName != ""
+      depFile.close
+    end
+  end
+
+  #
+  #  ãã¹2ã«å¼ãæ¸¡ãæ
+å ±ããã¡ã¤ã«ã«çæ
+  #
+  if $omitOutputDb.nil?
+    db = PStore.new(CFG1_OUT_DB)
+    db.transaction do
+      db[:apiDefinition] = $apiDefinition
+      db[:symbolValueTable] = $symbolValueTable
+      db[:cfgFileInfo] = $cfgFileInfo
+      db[:includeFiles] = $includeFiles
+      db[:domainId] = $domainId
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/cfg/pass2.rb
===================================================================
--- asp3_gr_sakura/trunk/cfg/pass2.rb	(revision 317)
+++ asp3_gr_sakura/trunk/cfg/pass2.rb	(revision 317)
@@ -0,0 +1,440 @@
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Configurator by Ruby
+#
+#  Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#  Copyright (C) 2015-2017 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+#
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+#
+#  $Id: pass2.rb 105 2016-03-12 07:55:48Z ertl-hiro $
+#
+
+#
+#		ãã¹2ã®å¦ç
+#
+
+#
+#  ãã¹1ã®çæç©ã®èª­ã¿è¾¼ã¿
+#
+module Cfg1Out
+  #
+  #  Sã¬ã³ã¼ããã¡ã¤ã«ããã·ã³ãã«ã®å¤ãåãåºã
+  #
+  def self.GetSymbolValue(symbol, size, signed)
+    if @symbolAddress.has_key?(symbol)
+      return(@cfg1SRec.get_value(@symbolAddress[symbol], size, signed))
+    else
+      return(nil)
+    end
+  end
+
+  #
+  #  ãã¹1ã®çæç©ã®èª­ã¿è¾¼ã¿ï¼ã¡ã¤ã³ã®å¦çï¼
+  #
+  def self.Read
+    # cfg1_out.symsã®èª­ã¿è¾¼ã¿
+    @symbolAddress = ReadSymbolFile(CFG1_OUT_SYMS)
+
+    # cfg1_out.srecã®èª­ã¿è¾¼ã¿
+    begin
+      @cfg1SRec = SRecord.new(CFG1_OUT_SREC)
+    rescue Errno::ENOENT, Errno::EACCES => ex
+      abort(ex.message)
+    end
+
+    # ãã¸ãã¯ãã³ãã¼ã®åå¾
+    if @symbolAddress.has_key?(CFG1_MAGIC_NUM)
+      $asmLabel = ""
+      $cfg1_prefix = CFG1_PREFIX
+    elsif @symbolAddress.has_key?("_" + CFG1_MAGIC_NUM)
+      $asmLabel = "_"
+      $cfg1_prefix = "_" + CFG1_PREFIX
+    else
+      error_exit("`#{CFG1_MAGIC_NUM}' is not found in `#{CFG1_OUT_SYMS}'")
+    end
+
+    magicNumberData = @cfg1SRec.get_data(@symbolAddress \
+							[$asmLabel + CFG1_MAGIC_NUM], 4)
+    if (magicNumberData == "12345678")
+      $endianLittle = false
+    elsif (magicNumberData == "78563412")
+      $endianLittle = true
+    else
+      error_exit("`#{CFG1_MAGIC_NUM}' is invalid in `#{CFG1_OUT_SREC}'")
+    end
+
+    # åºå®åºåããå¤æ°ã®åå¾
+    $sizeOfSigned = GetSymbolValue($asmLabel + CFG1_SIZEOF_SIGNED, 4, false)
+
+    # å¤åå¾ã·ã³ãã«ã®åå¾
+    $symbolValueTable.each do |symbolName, symbolData|
+      symbol = $cfg1_prefix + symbolName
+      if symbolData.has_key?(:BOOL)
+        value = GetSymbolValue(symbol, $sizeOfSigned, true)
+        if !value.nil?
+          # Cè¨èªã®çå½å¤ãRubyã®çå½å¤ã«å¤æãã¦åãè¾¼ã
+          symbolData[:VALUE] = (value != 0)
+        end
+      else
+        value = GetSymbolValue(symbol, $sizeOfSigned, \
+										symbolData.has_key?(:SIGNED))
+        if !value.nil?
+          symbolData[:VALUE] = value
+        end
+      end
+    end
+
+    #
+    #  ããã·ã¥ã®åæå
+    #
+    $cfgData = {}
+    @objidValues = {}
+    $apiDefinition.each do |apiName, apiDef|
+      if apiDef.has_key?(:API)
+        if !$cfgData.has_key?(apiDef[:API].to_sym)
+          $cfgData[apiDef[:API].to_sym] = {}
+        end
+      end
+      apiDef[:PARAM].each do |apiParam|
+        if apiParam.has_key?(:NAME) && apiParam.has_key?(:ID_DEF)
+          @objidValues[apiParam[:NAME]] = {}
+        end
+      end
+    end
+
+    #
+    #  ãã¡ã¤ã³çæãã¼ã¿ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¼ã¿ï¼$cfgDataï¼ã«æ ¼ç´
+    #
+    $cfgData[:CRE_DOM] = {}
+    $domainId.each do |domainName, domainVal|
+      domid = NumStr.new(domainVal, domainName)
+      $cfgData[:CRE_DOM][domainVal] = { :domid => domid }
+    end
+
+    ReadPhase(nil)
+  end
+
+  #
+  #  ãã©ã¡ã¼ã¿ã®å¤ãåãåºã
+  #
+  def self.GetParamValue(paramName, param, apiIndex, index, apiParam, cfgInfo)
+    if apiParam.has_key?(:ID_DEF)				# ãªãã¸ã§ã¯ãè­å¥åï¼å®ç¾©ï¼
+      value = @objidValues[paramName][param]
+    elsif apiParam.has_key?(:ID_REF)			# ãªãã¸ã§ã¯ãè­å¥åï¼åç
+§ï¼
+      if @objidValues[paramName].has_key?(param)
+        value = @objidValues[paramName][param]
+      else
+        apiDef = $apiDefinition[cfgInfo[:APINAME]]
+        error("#{apiDef.has_key?(:KEYPAR) ? "E_NOEXS" : "E_ID"}: " \
+					"`#{param}' in #{cfgInfo[:APINAME]} is not defined", \
+					"#{cfgInfo[:_FILE_]}:#{cfgInfo[:_LINE_]}:")
+        value = nil
+      end
+    elsif apiParam.has_key?(:EXPTYPE)			# æ´æ°å®æ°å¼ãã©ã¡ã¼ã¿
+      if apiIndex.nil?
+        if param.is_a?(NumStr)
+          return(param)
+        else
+          return(NumStr.new(param))
+        end
+      else
+        symbol = "#{$cfg1_prefix}valueof_#{paramName}_#{apiIndex}#{index}"
+        value = GetSymbolValue(symbol, $sizeOfSigned, \
+									apiParam.has_key?(:SIGNED))
+      end
+    else										# ä¸è¬å®æ°å¼ï¼æå­åãã©ã¡ã¼ã¿
+      return(param)
+    end
+    return(NumStr.new(value, param))
+  end
+
+  #
+  #  æå®ãããã§ã¼ãºã®ããã®ãã¹1ã®çæç©ã®èª­ã¿è¾¼ã¿
+  #
+  def self.ReadPhase(phase)
+    #
+    #  ãªãã¸ã§ã¯ãIDã®å²å½ã¦
+    #
+    # å²ãå½ã¦ããªãã¸ã§ã¯ãIDã¯ï¼@objidValuesã«ä¿æããï¼@objidValuesã¯ï¼
+    # 2éã®ããã·ã¥ï¼ããã·ã¥ã®ããã·ã¥ï¼ã§ããï¼
+    #
+    # å
+·ä½çã«ã¯ï¼@objidValuesã¯ï¼ãªãã¸ã§ã¯ãIDã®ãã©ã¡ã¼ã¿åï¼ä¾ãã°ï¼ã»
+    # ããã©IDã§ããã°"semid"ï¼ãããä¿æããå¤æ°åã¯ï¼objidParamNameã¨ã
+    # ãï¼ãã­ã¼ã¨ãï¼ãã®ãªãã¸ã§ã¯ãIDã®å²å½ã¦è¡¨ï¼ãããä¿æããå¤æ°å
+    # ã¯ï¼objidListã¨ããï¼ãå¤ã¨ããããã·ã¥ã§ããï¼ãªãã¸ã§ã¯ãIDã®å²å½
+    # ã¦è¡¨ã¯ï¼ãªãã¸ã§ã¯ãåï¼ãããä¿æããå¤æ°åã¯ï¼objNameã¨ããï¼ãã­ã¼
+    # ã¨ãï¼ãã®IDçªå·ï¼ãããä¿æããå¤æ°åã¯ï¼objidNumberã¨ããï¼ãå¤ã¨
+    # ããããã·ã¥ã§ããï¼
+    #
+    # ä¾ãã°ï¼ã»ããã©SEM1ã®IDçªå·ã1ã®å ´åã«ã¯ï¼æ¬¡ã®ããã«è¨­å®ãããï¼
+    #   @objidValues["semid"]["SEM1"] == 1
+    #
+
+    # IDçªå·å²ãå½ã¦ã®åå¦ç
+    objidParamNameList = []
+    $cfgFileInfo.each do |cfgInfo|
+      # ããªãã­ã»ããµãã£ã¬ã¯ãã£ãã¯èª­ã¿é£ã°ã
+      next if cfgInfo.has_key?(:DIRECTIVE)
+
+      apiDef = $apiDefinition[cfgInfo[:APINAME]]
+      # ç°ãªããã§ã¼ãºã®éçAPIã¯èª­ã¿é£ã°ã
+      next if apiDef[:PHASE] != phase
+
+      apiIndex = cfgInfo[:INDEX]
+      if !apiIndex.nil?
+        # ã·ã³ãã«ãã¡ã¤ã«ã«éçAPIã®ã¤ã³ããã¯ã¹ãå­å¨ããªããã°èª­ã¿é£
+        # ã°ãï¼ifdefç­ã§æ¶ããéçAPIï¼
+        symbol = "#{$cfg1_prefix}static_api_#{apiIndex}"
+        next unless @symbolAddress.has_key?(symbol)
+      end
+
+      apiDef[:PARAM].each do |apiParam|
+        if apiParam.has_key?(:NAME) && apiParam.has_key?(:ID_DEF)
+          objidParamName = apiParam[:NAME]
+          objName = cfgInfo[objidParamName]
+          if $inputObjid.has_key?(objName)
+            # IDçªå·å
+¥åãã¡ã¤ã«ã«å®ç¾©ããã¦ããå ´å
+            @objidValues[objidParamName][objName] = $inputObjid[objName]
+          else
+            @objidValues[objidParamName][objName] = nil
+          end
+          objidParamNameList.push(objidParamName)
+        end
+      end
+    end
+
+    # IDçªå·ã®å²å½ã¦å¦ç
+    objidParamNameList.each do |objidParamName|
+      objidList = @objidValues[objidParamName]
+
+      # æªä½¿ç¨ã®IDçªå·ã®ãªã¹ãï¼ä½¿ç¨ãããã®ããæ¶ãã¦ããï¼
+      unusedObjidList = (1.upto(objidList.keys.size)).to_a
+
+      # å²ãå½ã¦æ¸ã¿ã®IDçªå·ã®å¦ç
+      objidList.each do |objName, objidNumber|
+        if $inputObjid.has_key?(objName)
+          objidIndex = unusedObjidList.index($inputObjid[objName])
+          if objidIndex.nil?
+            # IDçªå·å
+¥åãã¡ã¤ã«ã§æå®ãããå¤ãä¸æ­£
+            error_exit("value of `#{objName}' in ID input file is illegal")
+          else
+            # æªä½¿ç¨ã®IDçªå·ã®ãªã¹ãããåé¤
+            unusedObjidList.delete_at(objidIndex)
+          end
+        end
+      end
+
+      # IDçªå·ã®å²å½ã¦
+      objidList.each do |objName, objidNumber|
+        if objidList[objName].nil?
+          # ä»¥ä¸ã§ï¼@objidValuesãæ¸ãæãã¦ãã
+          objidList[objName] = unusedObjidList.shift
+        end
+      end
+    end
+
+    #
+    #  éçAPIãã¼ã¿ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¼ã¿ï¼$cfgDataï¼ã«æ ¼ç´
+    #
+    $cfgFileInfo.each do |cfgInfo|
+      # ããªãã­ã»ããµãã£ã¬ã¯ãã£ãã¯èª­ã¿é£ã°ã
+      next if cfgInfo.has_key?(:DIRECTIVE)
+
+      apiDef = $apiDefinition[cfgInfo[:APINAME]]
+      # ç°ãªããã§ã¼ãºã®éçAPIã¯èª­ã¿é£ã°ã
+      next if apiDef[:PHASE] != phase
+
+      apiSym = apiDef[:API].to_sym
+      apiIndex = cfgInfo[:INDEX]
+      if !apiIndex.nil?
+        # ã·ã³ãã«ãã¡ã¤ã«ã«éçAPIã®ã¤ã³ããã¯ã¹ãå­å¨ããªããã°èª­ã¿é£
+        # ã°ãï¼ifdefç­ã§æ¶ããéçAPIï¼
+        symbol = "#{$cfg1_prefix}static_api_#{apiIndex}"
+        next unless @symbolAddress.has_key?(symbol)
+      end
+
+      # ãã©ã¡ã¼ã¿ã®å¤ãããã·ã¥å½¢å¼ã«æ ¼ç´
+      params = {}
+      apiDef[:PARAM].each do |apiParam|
+        next unless apiParam.has_key?(:NAME)
+        paramName = apiParam[:NAME]
+        next unless cfgInfo.has_key?(paramName)		# ãã©ã¡ã¼ã¿ããªãå ´å
+        paramData = cfgInfo[paramName]
+
+        if apiParam.has_key?(:LIST)
+          params[paramName.to_sym] = []
+          paramData.each.with_index(1) do |param, index|
+            params[paramName.to_sym].push(GetParamValue(paramName, param, \
+								apiIndex, "_#{index}", apiParam, cfgInfo))
+          end
+        else
+          params[paramName.to_sym] = GetParamValue(paramName, paramData, \
+										apiIndex, "", apiParam, cfgInfo)
+        end
+      end
+
+      # ãã¡ã¤ã³IDãè¿½å 
+      if cfgInfo.has_key?(:DOMAIN)
+        domainName = cfgInfo[:DOMAIN]
+        params[:domain] = $domainId[domainName]
+      end
+
+      # ã¯ã©ã¹IDãè¿½å 
+      if cfgInfo.has_key?(:CLASS)
+        if apiIndex.nil?
+          params[:class] = cfgInfo[:CLASS]
+        else
+          symbol = "#{$cfg1_prefix}valueof_CLASS_#{apiIndex}"
+          value = GetSymbolValue(symbol, $sizeOfSigned, true)
+          params[:class] = NumStr.new(value, cfgInfo[:CLASS])
+        end
+      end
+
+      # APIåï¼ãã¡ã¤ã«åï¼è¡çªå·ãè¿½å 
+      params[:apiname] = cfgInfo[:APINAME]
+      params[:_file_] = cfgInfo[:_FILE_]
+      params[:_line_] = cfgInfo[:_LINE_]
+
+      # ç»é²ã­ã¼ãæ±ºå®ãã
+      if apiDef.has_key?(:KEYPAR)
+        keyParam = params[apiDef[:KEYPAR].to_sym]
+        key = keyParam.val
+        if $cfgData[apiSym].has_key?(key)
+          # ç»é²ã­ã¼ã®éè¤
+          error("E_OBJ: #{apiDef[:KEYPAR]} `#{keyParam}' " \
+								"is duplicated in #{cfgInfo[:APINAME]}",
+								"#{cfgInfo[:_FILE_]}:#{cfgInfo[:_LINE_]}:")
+        end
+      else
+        key = $cfgData[apiSym].count + 1
+      end
+      $cfgData[apiSym][key] = params
+    end
+  end
+
+  #
+  #  IDçªå·åºåãã¡ã¤ã«ã®çæ
+  #
+  def self.OutputId(fileName)
+    idOutputFile = GenFile.new(fileName)
+    @objidValues.each do |objidParamName, objidList|
+      objidList.each do |objName, objidNumber|
+        idOutputFile.add("#{objName} #{objidNumber}")
+      end
+    end
+  end
+end
+
+#
+#  ãã¹2ã®å¦ç
+#
+def Pass2
+  #
+  #  ãã¹1ããå¼ãæ¸¡ãããæ
+å ±ããã¡ã¤ã«ããèª­ã¿è¾¼ã
+  #
+  db = PStore.new(CFG1_OUT_DB)
+  db.transaction(true) do
+    $apiDefinition = db[:apiDefinition]
+    $symbolValueTable = db[:symbolValueTable]
+    $cfgFileInfo = db[:cfgFileInfo]
+    $includeFiles = db[:includeFiles]
+    $domainId = db[:domainId]
+  end
+  $cfg2Data = {}
+
+  #
+  #  ãã¹1ã®çæç©ãèª­ã¿è¾¼ã
+  #
+  Cfg1Out.Read()
+  abort if $errorFlag					# ã¨ã©ã¼çºçæã¯abortãã
+
+  #
+  #  å¤åå¾ã·ã³ãã«ãã°ã­ã¼ãã«å¤æ°ã¨ãã¦å®ç¾©ãã
+  #
+  DefineSymbolValue()
+
+  #
+  #  çæã¹ã¯ãªããï¼trbãã¡ã¤ã«ï¼ãå®è¡ãã
+  #
+  $trbFileNames.each do |trbFileName|
+    if /^(.+):(\w+)$/ =~ trbFileName
+      trbFileName = $1
+      Cfg1Out.ReadPhase($2.to_sym)
+    end
+    IncludeTrb(trbFileName)
+  end
+
+  #
+  #  IDçªå·åºåãã¡ã¤ã«ã®çæ
+  #
+  if !$idOutputFileName.nil?
+    Cfg1Out.OutputId($idOutputFileName)
+  end
+
+  #
+  #  ãã¹3ã«å¼ãæ¸¡ãæ
+å ±ããã¡ã¤ã«ã«çæ
+  #
+  if $omitOutputDb.nil?
+    db = PStore.new(CFG2_OUT_DB)
+    db.transaction do
+      db[:apiDefinition] = $apiDefinition
+      db[:symbolValueTable] = $symbolValueTable
+      db[:cfgFileInfo] = $cfgFileInfo
+      db[:includeFiles] = $includeFiles
+      db[:cfgData] = $cfgData
+      db[:asmLabel] = $asmLabel
+      db[:endianLittle] = $endianLittle
+      db[:cfg2Data] = $cfg2Data
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/configure.rb
===================================================================
--- asp3_gr_sakura/trunk/configure.rb	(revision 317)
+++ asp3_gr_sakura/trunk/configure.rb	(revision 317)
@@ -0,0 +1,386 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Software
+#      Toyohashi Open Platform for Embedded Real-Time Systems
+# 
+#  Copyright (C) 2001-2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: configure.rb 626 2016-02-12 13:46:32Z ertl-hiro $
+# 
+
+require "optparse"
+require "fileutils"
+require "shell"
+
+#  ãªãã·ã§ã³ã®å®ç¾©
+#
+#  -T <target>			ã¿ã¼ã²ããåï¼å¿
+é ï¼
+#  -a <appldirs>		ã¢ããªã±ã¼ã·ã§ã³ã®ãã£ã¬ã¯ããªåï¼è¤æ°æå®å¯ï¼ã
+#						ãã©ã«ãã¯sampleãã£ã¬ã¯ããªï¼
+#  -A <applname>		ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã åï¼ããã©ã«ãã¯sample1ï¼
+#  -t					ã¡ã¤ã³ã®ãªãã¸ã§ã¯ããã¡ã¤ã«ããªã³ã¯å¯¾è±¡ã«å«ããªã
+#  -c <cfgfile>			ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ï¼.cfgãã¡ã¤
+#						ã«åï¼å
+#  -C <cdlflle>			ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«ï¼.cdlãã¡ã¤ã«ï¼å
+#  -U <applobjs>		ä»ã®ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ãã¡ã¤ã«
+#						ï¼.oãã¡ã¤ã«åã§æå®ï¼è¤æ°æå®å¯ï¼
+#  -S <syssvcobjs>		ã·ã¹ãã ãµã¼ãã¹ã®ãã­ã°ã©ã ãã¡ã¤ã«
+#						ï¼.oãã¡ã¤ã«åã§æå®ï¼è¤æ°æå®å¯ï¼
+#  -L <kernel_lib>		ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.aï¼ã®ãã£ã¬ã¯ããªå
+#						ï¼çç¥ããå ´åï¼ã«ã¼ãã«ã©ã¤ãã©ãªãmakeããï¼
+#  -f					ã«ã¼ãã«ãé¢æ°åä½ã§ã³ã³ãã¤ã«ãããã©ããã®æå®
+#  -D <srcdir>			ã«ã¼ãã«ã½ã¼ã¹ã®ç½®ããã¦ãããã£ã¬ã¯ããª
+#  -l <srclang>			ãã­ã°ã©ãã³ã°è¨èªï¼ç¾æç¹ã§ã¯cã¨c++ã®ã¿ãµãã¼ãï¼
+#  -m <tempmakefile>	Makefileã®ãã³ãã¬ã¼ãã®ãã¡ã¤ã«åã®æå®ï¼ããã©ã«
+#						ãã¯sampleãã£ã¬ã¯ããªã®Makefileï¼
+#  -d <depdir>			ä¾å­é¢ä¿ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªåï¼ããã©ã«ãã¯depsï¼
+#  -w					TECSãä½¿ç¨ããªã
+#  -r					ãã¬ã¼ã¹ã­ã°è¨é²ã®ãµã³ãã«ã³ã¼ããä½¿ç¨ãããã©ãã
+#						ã®æå®
+#  -V <devtooldir>		éçºãã¼ã«ï¼ã³ã³ãã¤ã©ç­ï¼ã®ç½®ããã¦ãããã£ã¬ã¯ããª
+#  -R <ruby>			rubyã®ãã¹åï¼æç¤ºçã«æå®ããå ´åï¼
+#  -g <cfg>				ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ï¼cfgï¼ã®ãã¹å
+#  -G <tecsgen>			TECSã¸ã§ãã¬ã¼ã¿ï¼tecsgenï¼ã®ãã¹å
+#  -o <options>			ã³ã³ãã¤ã«ãªãã·ã§ã³ï¼COPTSã«è¿½å ï¼
+#  -O <options>			ã·ã³ãã«å®ç¾©ãªãã·ã§ã³ï¼CDEFSã«è¿½å ï¼
+#  -k <options>			ãªã³ã«ãªãã·ã§ã³ï¼LDFLAGSç­ã«è¿½å ï¼
+#  -e <tinetdir>		TINET ã®ã½ã¼ã¹ã®ç½®ããã¦ãããã£ã¬ã¯ããª
+#  -i <net_if>			ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ï¼TINETãæå¹ã®å ´åã¯å¿
+é ï¼
+#						etherãpppãloop ã®ä½ãããæå®ããã
+#  -v <net_dev>			ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ã
+#  						ï¼ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã« ether ãæå®ããå ´åã¯å¿
+é ï¼
+#  -n <net_proto>		ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ï¼TINETãæå¹ã®å ´åã¯å¿
+é ï¼
+#						inet6ãinet4ãinet6/inet4ãinet6mãinet6m/inet4 ã®ä½ãããæå®ããã
+#  -s <trans_proto>		ãã©ã³ã¹ãã¼ãå±¤ãã­ãã³ã«ï¼TINETãæå¹ã®å ´åã¯å¿
+é ï¼
+#						tcpãudpãtcp/udp ã®ä½ãããæå®ããã
+
+#  ä½¿ç¨ä¾(1)
+#
+#  % ../configure.rb -T ct11mpcore_gcc -O "-DTOPPERS_USE_QEMU" \
+#					-A perf1 -a ../test -S "test_svc.o histogram.o"
+#
+#  ä½¿ç¨ä¾(2)
+#
+#  % ../configure.rb -T macosx_gcc -L .
+#	ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã¯ï¼sample1ã«ãªãï¼
+#
+#  ä½¿ç¨ä¾(3)
+#
+#  % ../configure.rb -T ct11mpcore_gcc -O "-DTOPPERS_USE_QEMU" -A tSample2 -t
+#	ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã¯ï¼TECSçã®ãµã³ãã«ãã­ã°ã©ã ã«ãªãï¼
+#
+#  ä½¿ç¨ä¾(4)
+#
+#  % ../configure.rb -T ct11mpcore_gcc PRC_NUM=4
+#	PRC_NUMã4ã«å®ç¾©ããï¼
+#
+#  ä½¿ç¨ä¾(5)
+#
+#  % ../configure.rb -T gr_sakura_gcc -A sample1n \
+#					-e tinet -i ether -v if_rx62n -n inet4 -s tcp -U sample1.o
+#	TINETãæå¹ã«ããï¼
+
+#
+#  å¤æ°ã®åæå
+#
+$target = nil
+$appldirs = []
+$applobjs = []
+$syssvcobjs = []
+$kernel_lib = ""
+$kernel_funcobjs = ""
+$srclang = "c"
+$depdir = "deps"
+$omit_tecs = ""
+$enable_trace = ""
+$devtooldir = ""
+$ruby = "ruby"
+$copts = []
+$cdefs = []
+$ldflags = []
+
+#
+#  ãªãã·ã§ã³ã®å¦ç
+#
+OptionParser.new(nil, 22) do |opt|
+  opt.on("-T target",		"taget name (mandatory)") do |val|
+    $target = val
+  end
+  opt.on("-a appldirs",		"application directories") do |val|
+    $appldirs += val.split("\s+")
+  end
+  opt.on("-A applname",		"application program name") do |val|
+    $applname = val
+  end
+  opt.on("-t",				"TECS is used for application development") do |val|
+    $option_t = true
+  end
+  opt.on("-c cfgfile",		"system configuration file") do |val|
+    $cfgfile = val
+  end
+  opt.on("-C cdlfile",		"component description file") do |val|
+    $cdlfile = val
+  end
+  opt.on("-U applobjs",		"additional application object files") do |val|
+    $applobjs += val.split("\s+")
+  end
+  opt.on("-S syssvcobjs",	"system service object files") do |val|
+    $syssvcobjs += val.split("\s+")
+  end
+  opt.on("-L kernel_lib",	"directory of built kernel library") do |val|
+    $kernel_lib = val
+  end
+  opt.on("-f", "each function is complied separately in kernel") do |val|
+    $kernel_funcobjs = true
+  end
+  opt.on("-D srcdir",		"path of source code directory") do |val|
+    $srcdir = val
+  end
+  opt.on("-l srclang",		"programming language (C or C++)") do |val|
+    $srclang = val
+  end
+  opt.on("-m tempmakefile", "template file of Makefile") do |val|
+    $tempmakefile = val
+  end
+  opt.on("-d depdir",		"dependency relation file directory") do |val|
+    $depdir = val
+  end
+  opt.on("-w",				"TECS is not used at all") do |val|
+    $omit_tecs = true
+  end
+  opt.on("-r",				"use the sample code for trace log") do |val|
+    $enable_trace = true
+  end
+  opt.on("-V devtooldir",	"development tools directory") do |val|
+    $devtooldir = val
+  end
+  opt.on("-R ruby",			"path of ruby command") do |val|
+    $ruby = val
+  end
+  opt.on("-g cfg",			"path of configurator") do |val|
+    $cfg = val
+  end
+  opt.on("-G tecsgen",		"path of TECS generator") do |val|
+    $tecsgen = val
+  end
+  opt.on("-o options",		"compiler options") do |val|
+    $copts += val.split("\s+")
+  end
+  opt.on("-O options",		"symbol definition options") do |val|
+    $cdefs += val.split("\s+")
+  end
+  opt.on("-k options",		"linker options") do |val|
+    $ldflags += val.split("\s+")
+  end
+  opt.on("-e options",		"path of TINET directory") do |val|
+    $tinetdir = val
+  end
+  opt.on("-i options",		"network interface (ether or ppp or loop)") do |val|
+    $net_if = val
+  end
+  opt.on("-v options",		"ethernet device driver") do |val|
+    $net_dev = val
+  end
+  opt.on("-n options",		"network layer protocol (inet6 or inet4 or inet6/inet4 or inet6m or inet6m/inet4)") do |val|
+    $net_proto = val
+  end
+  opt.on("-s options",		"transeport layer protocol (tcp or udp or tcp/udp)") do |val|
+    $trans_proto = val
+  end
+  opt.parse!(ARGV)
+end
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µå­ãè¿ã
+#
+def GetObjectExtension
+  if /cygwin/ =~ RUBY_PLATFORM
+    return("exe")
+  else
+    return("")
+  end
+end
+
+#
+#  å¤æ°ã®ããã©ã«ãå¤
+#
+if $appldirs.empty?
+  $appldirs.push("\$(SRCDIR)/sample")
+end
+$applname ||= "sample1"
+if $option_t.nil?
+  $applobjs.unshift($applname + ".o")
+end
+$cfgfile ||= $applname + ".cfg"
+$cdlfile ||= $applname + ".cdl"
+if $srcdir.nil?
+  # ã½ã¼ã¹ãã£ã¬ã¯ããªåãåãåºã
+  if /(.*)\/configure/ =~ $0
+    $srcdir = $1
+  else
+    $srcdir = Shell.new.cwd
+  end
+end
+if /^\// =~ $srcdir
+  $srcabsdir = $srcdir
+else
+  $srcabsdir = Shell.new.cwd + "/" + $srcdir
+end
+$tempmakefile ||= $srcdir + "/sample/Makefile"
+$cfg ||= $ruby + " \$(SRCDIR)/cfg/cfg.rb"
+$tecsgen ||= $ruby + " \$(SRCDIR)/tecsgen/tecsgen.rb"
+
+#
+#  -Tãªãã·ã§ã³ã¨ã¿ã¼ã²ããä¾å­é¨ãã£ã¬ã¯ããªã®ç¢ºèª
+#
+if $target.nil?
+  puts("configure.rb: -T option is mandatory")
+elsif !File.directory?($srcdir + "/target/" + $target)
+  puts("configure.rb: #{$srcdir}/target/#{$target} not exist.")
+  $target = nil
+end
+
+if $target.nil?
+  puts("Installed targets are:")
+  Dir.glob($srcdir + "/target/[a-zA-Z0-9]*").each do |target|
+    target.sub!($srcdir + "/target/", "")
+    puts("\t" + target)
+  end
+  abort
+end
+
+#
+#  å¤æ°ãã¼ãã«ã®ä½æ
+#
+$vartable = Hash.new("")
+$vartable["TARGET"] = $target
+$vartable["APPLDIRS"] = $appldirs.join(" ")
+$vartable["APPLNAME"] = $applname
+$vartable["CFGFILE"] = $cfgfile
+$vartable["CDLFILE"] = $cdlfile
+$vartable["APPLOBJS"] = $applobjs.join(" ")
+$vartable["SYSSVCOBJS"] = $syssvcobjs.join(" ")
+$vartable["KERNEL_LIB"] = $kernel_lib
+$vartable["KERNEL_FUNCOBJS"] = $kernel_funcobjs
+$vartable["SRCDIR"] = $srcdir
+$vartable["SRCABSDIR"] = $srcabsdir
+$vartable["SRCLANG"] = $srclang
+$vartable["DEPDIR"] = $depdir
+$vartable["OMIT_TECS"] = $omit_tecs
+$vartable["ENABLE_TRACE"] = $enable_trace
+$vartable["DEVTOOLDIR"] = $devtooldir
+$vartable["RUBY"] = $ruby
+$vartable["CFG"] = $cfg
+$vartable["TECSGEN"] = $tecsgen
+$vartable["COPTS"] = $copts.join(" ")
+$vartable["CDEFS"] = $cdefs.join(" ")
+$vartable["LDFLAGS"] = $ldflags.join(" ")
+$vartable["OBJEXT"] = GetObjectExtension()
+$vartable["TINETDIR"] = $tinetdir
+$vartable["NET_IF"] = $net_if
+$vartable["NET_DEV"] = $net_dev
+$vartable["SUPPORT_INET6"] = ($net_proto == "inet6") || ($net_proto == "inet6/inet4") || ($net_proto == "inet6m") || ($net_proto == "inet6m/inet4")
+$vartable["SUPPORT_INET4"] = ($net_proto == "inet4") || ($net_proto == "inet6/inet4") || ($net_proto == "inet6m/inet4")
+$vartable["SUPPORT_TCP"] = ($trans_proto == "tcp") || ($net_proto == "tcp/udp")
+$vartable["SUPPORT_UDP"] = ($trans_proto == "udp") || ($net_proto == "tcp/udp")
+$vartable["API_CFG_IP4MAPPED_ADDR"] = ($net_proto == "inet6m") || ($net_proto == "inet6m/inet4")
+
+ARGV.each do |arg|
+  if /^([A-Za-z0-9_]+)\s*\=\s*(.*)$/ =~ arg
+    $vartable[$1] = $2
+  else
+    $vartable[arg] = true
+  end
+end
+
+#
+#  ãã¡ã¤ã«ãå¤æãã
+#
+def convert(inFileName, outFileName)
+  puts("Generating #{outFileName} from #{inFileName}.\n")
+  if (File.file?(outFileName))
+    puts("#{outFileName} exists.  Save as #{outFileName}.bak.\n")
+    FileUtils.move(outFileName, outFileName + ".bak")
+  end
+
+  begin
+    inFile = File.open(inFileName)
+    outFile = File.open(outFileName, "w")
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  inFile.each do |line|
+    line.chomp!
+    while line.sub!(/\@\(([A-Za-z0-9_]+)\)/) {|var| $vartable[$1]} do end
+    outFile.print(line,"\n")
+  end
+
+  inFile.close
+  outFile.close
+end
+
+#
+#  Makefileã®çæ
+#
+convert($tempmakefile, "Makefile")
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®ä½æ
+#
+if !File.directory?($depdir)
+  Dir.mkdir($depdir)
+end
Index: asp3_gr_sakura/trunk/include/itron.h
===================================================================
--- asp3_gr_sakura/trunk/include/itron.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/itron.h	(revision 317)
@@ -0,0 +1,164 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ITRONä»æ§å
+±éè¦å®ã®ãã¼ã¿åã»å®æ°ã»ãã¯ã­
+ *
+ *  ãã®ããããã¡ã¤ã«ã¯ï¼ITRONä»æ§å
+±éè¦å®ã®ãã¼ã¿åã»å®æ°ã»ãã¯ã­ã®ä¸­
+ *  ã§ï¼TOPPERSå
+±éããããã¡ã¤ã«ã«å«ã¾ããªããã®ã®å®ç¾©ãå«ãï¼ITRONä»
+ *  æ§ã¨ã®äºææ§ãå¿
+è¦ã¨ããã¢ããªã±ã¼ã·ã§ã³ãã¤ã³ã¯ã«ã¼ããããã¨ãæ³
+ *  å®ãã¦ããï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ããï¼ããã«ããï¼ãã¯ã­å®ç¾©ä»¥å¤ã
+ *  é¤ãããã«ãªã£ã¦ããï¼
+ */
+
+#ifndef TOPPERS_ITRON_H
+#define TOPPERS_ITRON_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *  TOPPERSå
+±éããããã¡ã¤ã«
+ */
+#include <t_stddef.h>
+
+/*
+ *  ITRONä»æ§å
+±éãã¼ã¿å
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+#ifdef INT8_MAX
+typedef	int8_t			B;			/* ç¬¦å·ä»ã8ãããæ´æ° */
+#endif /* INT8_MAX */
+
+#ifdef UINT8_MAX
+typedef	uint8_t			UB;			/* ç¬¦å·ç¡ã8ãããæ´æ° */
+typedef	uint8_t			VB;			/* åãå®ã¾ããªã8ãããã®å¤ */
+#endif /* UINT8_MAX */
+
+typedef	int16_t			H;			/* ç¬¦å·ä»ã16ãããæ´æ° */
+typedef	uint16_t		UH;			/* ç¬¦å·ç¡ã16ãããæ´æ° */
+typedef	uint16_t		VH;			/* åãå®ã¾ããªã16ãããã®å¤ */
+
+typedef	int32_t			W;			/* ç¬¦å·ä»ã32ãããæ´æ° */
+typedef	uint32_t		UW;			/* ç¬¦å·ç¡ã32ãããæ´æ° */
+typedef	uint32_t		VW;			/* åãå®ã¾ããªã32ãããã®å¤ */
+
+#ifdef INT64_MAX
+typedef	int64_t			D;			/* ç¬¦å·ä»ã64ãããæ´æ° */
+#endif /* INT64_MAX */
+
+#ifdef UINT64_MAX
+typedef	uint64_t		UD;			/* ç¬¦å·ç¡ã64ãããæ´æ° */
+typedef	uint64_t		VD;			/* åãå®ã¾ããªã64ãããã®å¤ */
+#endif /* UINT64_MAX */
+
+typedef	void			*VP;		/* åãå®ã¾ããªããã®ã¸ã®ãã¤ã³ã¿ */
+
+typedef int_t			INT;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ä»ãæ´æ° */
+typedef uint_t			UINT;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ç¡ãæ´æ° */
+
+typedef bool_t			BOOL;		/* çå½å¤ */
+
+typedef size_t			SIZE;		/* ã¡ã¢ãªé åã®ãµã¤ãºãè¡¨ãç¬¦å·ç¡ãæ´æ°*/
+typedef	intptr_t		VP_INT;		/* ãã¤ã³ã¿ã¾ãã¯ç¬¦å·ä»ãæ´æ° */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  ITRONä»æ§å
+±éå®æ°
+ */
+#define	TRUE		true			/* ç */
+#define	FALSE		false			/* å½ */
+
+/*
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ããã®å¼·å¶åé
+ */
+#define frsm_tsk(tskid)		rsm_tsk(tskid)
+
+/*
+ *  ãªãã¸ã§ã¯ãå±æ§ã®å®ç¾©
+ */
+#define TA_HLNG			UINT_C(0x00)	/* é«ç´è¨èªç¨ã¤ã³ã¿ãã§ã¼ã¹ */
+#define TA_TFIFO		UINT_C(0x00)	/* ã¿ã¹ã¯ã®å¾
+ã¡è¡åãFIFOé ã« */
+#define TA_WSGL			UINT_C(0x00)	/* å¾
+ã¡ã¿ã¹ã¯ã¯1ã¤ã®ã¿ */
+
+/*
+ *  ãã¹ãåæ°ã®æå¤§å¤
+ */
+#define TMAX_SUSCNT		UINT_C(1)		/* å¼·å¶å¾
+ã¡è¦æ±ãã¹ãæ°ã®æå¤§å¤ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_ITRON_H */
Index: asp3_gr_sakura/trunk/include/kernel.h
===================================================================
--- asp3_gr_sakura/trunk/include/kernel.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/kernel.h	(revision 317)
@@ -0,0 +1,831 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		TOPPERS/ASPã«ã¼ãã« æ¨æºããããã¡ã¤ã«
+ *
+ *  TOPPERS/ASPã«ã¼ãã«ããµãã¼ããããµã¼ãã¹ã³ã¼ã«ã®å®£è¨ã¨ï¼å¿
+è¦ãªãã¼
+ *  ã¿åï¼å®æ°ï¼ãã¯ã­ã®å®ç¾©ãå«ãããããã¡ã¤ã«ï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ããï¼ããã«ããï¼ãã¯ã­å®ç¾©ä»¥å¤ã
+ *  é¤ãããã«ãªã£ã¦ããï¼
+ */
+
+#ifndef TOPPERS_KERNEL_H
+#define TOPPERS_KERNEL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *	TOPPERSå
+±éã®ãã¼ã¿åã»å®æ°ã»ãã¯ã­
+ */
+#include <t_stddef.h>
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨
+ */
+#include "target_kernel.h"
+
+/*
+ *  ãµãã¼ãããæ©è½
+ */
+#ifdef TOPPERS_TARGET_SUPPORT_DIS_INT
+#define TOPPERS_SUPPORT_DIS_INT			/* dis_intããµãã¼ãããã¦ãã */
+#endif /* TOPPERS_TARGET_SUPPORT_DIS_INT */
+
+#ifdef TOPPERS_TARGET_SUPPORT_ENA_INT
+#define TOPPERS_SUPPORT_ENA_INT			/* ena_intããµãã¼ãããã¦ãã */
+#endif /* TOPPERS_TARGET_SUPPORT_ENA_INT */
+
+#ifdef TOPPERS_TARGET_SUPPORT_CLR_INT
+#define TOPPERS_SUPPORT_CLR_INT			/* clr_intããµãã¼ãããã¦ãã */
+#endif /* TOPPERS_TARGET_SUPPORT_CLR_INT */
+
+#ifdef TOPPERS_TARGET_SUPPORT_RAS_INT
+#define TOPPERS_SUPPORT_RAS_INT			/* ras_intããµãã¼ãããã¦ãã */
+#endif /* TOPPERS_TARGET_SUPPORT_RAS_INT */
+
+#ifdef TOPPERS_TARGET_SUPPORT_PRB_INT
+#define TOPPERS_SUPPORT_PRB_INT			/* prb_intããµãã¼ãããã¦ãã */
+#endif /* TOPPERS_TARGET_SUPPORT_PRB_INT */
+
+#ifdef TOPPERS_TARGET_SUPPORT_OVRHDR
+#define TOPPERS_SUPPORT_OVRHDR			/* ãªã¼ãã©ã³ãã³ãã©æ©è½æ¡å¼µ */
+#endif /* TOPPERS_TARGET_SUPPORT_OVRHDR */
+
+#define TOPPERS_SUPPORT_DYNAMIC_CRE		/* åççææ©è½æ¡å¼µ */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ãã¼ã¿åã®å®ç¾©
+ */
+
+/*
+ *  ããããã¿ã¼ã³ããªãã¸ã§ã¯ãçªå·ã®åå®ç¾©
+ */
+typedef	uint_t		FLGPTN;		/* ã¤ãã³ããã©ã°ã®ããããã¿ã¼ã³ */
+typedef	uint_t		INTNO;		/* å²è¾¼ã¿çªå· */
+typedef	uint_t		INHNO;		/* å²è¾¼ã¿ãã³ãã©çªå· */
+typedef	uint_t		EXCNO;		/* CPUä¾å¤ãã³ãã©çªå· */
+
+/*
+ *  å¦çåä½ã®åå®ç¾©
+ */
+typedef void	(*TASK)(intptr_t exinf);
+typedef void	(*TMEHDR)(intptr_t exinf);
+typedef void	(*OVRHDR)(ID tskid, intptr_t exinf);
+typedef void	(*ISR)(intptr_t exinf);
+typedef void	(*INTHDR)(void);
+typedef void	(*EXCHDR)(void *p_excinf);
+typedef void	(*INIRTN)(intptr_t exinf);
+typedef void	(*TERRTN)(intptr_t exinf);
+
+/*
+ *  ã¡ã¢ãªé åç¢ºä¿ã®ããã®åå®ç¾©
+ */
+#ifndef TOPPERS_STK_T
+#define TOPPERS_STK_T	intptr_t
+#endif /* TOPPERS_STK_T */
+typedef	TOPPERS_STK_T	STK_T;	/* ã¹ã¿ãã¯é åãç¢ºä¿ããããã®å */
+
+#ifndef TOPPERS_MPF_T
+#define TOPPERS_MPF_T	intptr_t
+#endif /* TOPPERS_MPF_T */
+typedef	TOPPERS_MPF_T	MPF_T;	/* åºå®é·ã¡ã¢ãªãã¼ã«é åãç¢ºä¿ããããã®å */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®éç¥æ¹æ³ã®ãã±ããå½¢å¼ã®å®ç¾©
+ */
+typedef struct {
+	intptr_t	exinf;		/* ã¿ã¤ã ã¤ãã³ããã³ãã©ã®æ¡å¼µæ
+å ± */
+	TMEHDR		tmehdr;		/* ã¿ã¤ã ã¤ãã³ããã³ãã©ã®å
+é ­çªå° */
+} T_NFY_HDR;
+
+typedef struct {
+	intptr_t	*p_var;		/* å¤æ°ã®çªå° */
+	intptr_t	value;		/* è¨­å®ããå¤ */
+} T_NFY_VAR;
+
+typedef struct {
+	intptr_t	*p_var;		/* å¤æ°ã®çªå° */
+} T_NFY_IVAR;
+
+typedef struct {
+	ID			tskid;		/* ã¿ã¹ã¯ID */
+} T_NFY_TSK;
+
+typedef struct {
+	ID			semid;		/* ã»ããã©ID */
+} T_NFY_SEM;
+
+typedef struct {
+	ID			flgid;		/* ã¤ãã³ããã©ã°ID */
+	FLGPTN		flgptn;		/* ã»ããããããããã¿ã¼ã³ */
+} T_NFY_FLG;
+
+typedef struct {
+	ID			dtqid;		/* ãã¼ã¿ã­ã¥ã¼ID */
+	intptr_t	data;		/* éä¿¡ããå¤ */
+} T_NFY_DTQ;
+
+typedef struct {
+	intptr_t	*p_var;		/* å¤æ°ã®çªå° */
+} T_ENFY_VAR;
+
+typedef struct {
+	ID			dtqid;		/* ãã¼ã¿ã­ã¥ã¼ID */
+} T_ENFY_DTQ;
+
+typedef struct {
+	MODE	nfymode;			/* éç¥å¦çã¢ã¼ã */
+	union {						/* ã¿ã¤ã ã¤ãã³ãã®éç¥ã«é¢ããä»éæ
+å ± */
+		T_NFY_HDR	handler;
+		T_NFY_VAR	setvar;		
+		T_NFY_IVAR	incvar;		
+		T_NFY_TSK	acttsk;
+		T_NFY_TSK	wuptsk;
+		T_NFY_SEM	sigsem;
+		T_NFY_FLG	setflg;
+		T_NFY_DTQ	snddtq;
+	} nfy;
+	union {						/* ã¨ã©ã¼ã®éç¥ã«é¢ããä»éæ
+å ± */
+		T_ENFY_VAR	setvar;
+		T_NFY_IVAR	incvar;		
+		T_NFY_TSK	acttsk;
+		T_NFY_TSK	wuptsk;
+		T_NFY_SEM	sigsem;
+		T_NFY_FLG	setflg;
+		T_ENFY_DTQ	snddtq;
+	} enfy;
+} T_NFYINFO;
+
+/*
+ *  ãã±ããå½¢å¼ã®å®ç¾©
+ */
+typedef struct t_ctsk {
+	ATR			tskatr;		/* ã¿ã¹ã¯å±æ§ */
+	intptr_t	exinf;		/* ã¿ã¹ã¯ã®æ¡å¼µæ
+å ± */
+	TASK		task;		/* ã¿ã¹ã¯ã®ã¡ã¤ã³ã«ã¼ãã³ã®å
+é ­çªå° */
+	PRI			itskpri;	/* ã¿ã¹ã¯ã®èµ·åæåªå
+åº¦ */
+	size_t		stksz;		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®ãµã¤ãº */
+	STK_T 		*stk;		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®å
+é ­çªå° */
+} T_CTSK;
+
+typedef struct t_rtsk {
+	STAT	tskstat;	/* ã¿ã¹ã¯ç¶æ
+ */
+	PRI		tskpri;		/* ã¿ã¹ã¯ã®ç¾å¨åªå
+åº¦ */
+	PRI		tskbpri;	/* ã¿ã¹ã¯ã®ãã¼ã¹åªå
+åº¦ */
+	STAT	tskwait;	/* å¾
+ã¡è¦å  */
+	ID		wobjid;		/* å¾
+ã¡å¯¾è±¡ã®ãªãã¸ã§ã¯ãã®ID */
+	TMO		lefttmo;	/* ã¿ã¤ã ã¢ã¦ãããã¾ã§ã®æé */
+	uint_t	actcnt;		/* èµ·åè¦æ±ã­ã¥ã¼ã¤ã³ã°æ° */
+	uint_t	wupcnt;		/* èµ·åºè¦æ±ã­ã¥ã¼ã¤ã³ã°æ° */
+	bool_t	raster;		/* ã¿ã¹ã¯çµäºè¦æ±ç¶æ
+ */
+	bool_t	dister;		/* ã¿ã¹ã¯çµäºç¦æ­¢ç¶æ
+ */
+} T_RTSK;
+
+typedef struct t_csem {
+	ATR		sematr;		/* ã»ããã©å±æ§ */
+	uint_t	isemcnt;	/* ã»ããã©ã®åæè³æºæ° */
+	uint_t	maxsem;		/* ã»ããã©ã®æå¤§è³æºæ° */
+} T_CSEM;
+
+typedef struct t_rsem {
+	ID		wtskid;		/* ã»ããã©ã®å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®IDçªå· */
+	uint_t	semcnt;		/* ã»ããã©ã®ç¾å¨ã®è³æºæ° */
+} T_RSEM;
+
+typedef struct t_cflg {
+	ATR		flgatr;		/* ã¤ãã³ããã©ã°å±æ§ */
+	FLGPTN	iflgptn;	/* ã¤ãã³ããã©ã°ã®åæããããã¿ã¼ã³ */
+} T_CFLG;
+
+typedef struct t_rflg {
+	ID		wtskid;		/* ã¤ãã³ããã©ã°ã®å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®IDçªå· */
+	FLGPTN	flgptn;		/* ã¤ãã³ããã©ã°ã®ç¾å¨ã®ããããã¿ã¼ã³ */
+} T_RFLG;
+
+typedef struct t_cdtq {
+	ATR		dtqatr;		/* ãã¼ã¿ã­ã¥ã¼å±æ§ */
+	uint_t	dtqcnt;		/* ãã¼ã¿ã­ã¥ã¼ç®¡çé åã«æ ¼ç´ã§ãããã¼ã¿æ° */
+	void 	*dtqmb;		/* ãã¼ã¿ã­ã¥ã¼ç®¡çé åã®å
+é ­çªå° */
+} T_CDTQ;
+
+typedef struct t_rdtq {
+	ID		stskid;		/* ãã¼ã¿ã­ã¥ã¼ã®éä¿¡å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®IDçªå· */
+	ID		rtskid;		/* ãã¼ã¿ã­ã¥ã¼ã®åä¿¡å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®IDçªå· */
+	uint_t	sdtqcnt;	/* ãã¼ã¿ã­ã¥ã¼ç®¡çé åã«æ ¼ç´ããã¦ãããã¼ã¿ã®æ° */
+} T_RDTQ;
+
+typedef struct t_cpdq {
+	ATR		pdqatr;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼å±æ§ */
+	uint_t	pdqcnt;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã«æ ¼ç´ã§ãããã¼ã¿æ° */
+	PRI		maxdpri;	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã«éä¿¡ã§ãããã¼ã¿åªå
+åº¦ã®æ
+						   å¤§å¤ */
+	void 	*pdqmb;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã®å
+é ­çªå° */
+} T_CPDQ;
+
+typedef struct t_rpdq {
+	ID		stskid;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®éä¿¡å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯
+						   ã®IDçªå· */
+	ID		rtskid;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®åä¿¡å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯
+						   ã®IDçªå· */
+	uint_t	spdqcnt;	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã«æ ¼ç´ããã¦ãããã¼
+						   ã¿ã®æ° */
+} T_RPDQ;
+
+typedef struct t_cmtx {
+	ATR		mtxatr;		/* ãã¥ã¼ããã¯ã¹å±æ§ */
+	PRI		ceilpri;	/* ãã¥ã¼ããã¯ã¹ã®ä¸éåªå
+åº¦ */
+} T_CMTX;
+
+typedef struct t_rmtx {
+	ID		htskid;		/* ãã¥ã¼ããã¯ã¹ãã­ãã¯ãã¦ããã¿ã¹ã¯ã®IDçªå· */
+	ID		wtskid;		/* ãã¥ã¼ããã¯ã¹ã®å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®IDçªå· */
+} T_RMTX;
+
+typedef struct t_cmpf {
+	ATR		mpfatr;		/* åºå®é·ã¡ã¢ãªãã¼ã«å±æ§ */
+	uint_t	blkcnt;		/* ç²å¾ã§ããåºå®é·ã¡ã¢ãªãã­ãã¯ã®æ° */
+	uint_t	blksz;		/* åºå®é·ã¡ã¢ãªãã­ãã¯ã®ãµã¤ãº */
+	MPF_T 	*mpf;		/* åºå®é·ã¡ã¢ãªãã¼ã«é åã®å
+é ­çªå° */
+	void 	*mpfmb;		/* åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çé åã®å
+é ­çªå° */
+} T_CMPF;
+
+typedef struct t_rmpf {
+	ID		wtskid;		/* åºå®é·ã¡ã¢ãªãã¼ã«ã®å¾
+ã¡è¡åã®å
+é ­ã®ã¿ã¹ã¯ã®
+						   IDçªå· */
+	uint_t	fblkcnt;	/* åºå®é·ã¡ã¢ãªãã¼ã«é åã®ç©ºãã¡ã¢ãªé åã«å²ã
+						   ä»ãããã¨ãã§ããåºå®é·ã¡ã¢ãªãã­ãã¯ã®æ° */
+} T_RMPF;
+
+typedef struct t_ccyc {
+	ATR			cycatr;		/* å¨æéç¥å±æ§ */
+	T_NFYINFO	nfyinfo;	/* å¨æéç¥ã®éç¥æ¹æ³ */
+	RELTIM		cyctim;		/* å¨æéç¥ã®éç¥å¨æ */
+	RELTIM		cycphs;		/* å¨æéç¥ã®éç¥ä½ç¸ */
+} T_CCYC;
+
+typedef struct t_rcyc {
+	STAT	cycstat;	/* å¨æéç¥ã®åä½ç¶æ
+ */
+	RELTIM	lefttim;	/* æ¬¡åéç¥æå»ã¾ã§ã®ç¸å¯¾æé */
+} T_RCYC;
+
+typedef struct t_calm {
+	ATR			almatr;		/* ã¢ã©ã¼ã éç¥å±æ§ */
+	T_NFYINFO	nfyinfo;	/* ã¢ã©ã¼ã éç¥ã®éç¥æ¹æ³ */
+} T_CALM;
+
+typedef struct t_ralm {
+	STAT	almstat;	/* ã¢ã©ã¼ã éç¥ã®åä½ç¶æ
+ */
+	RELTIM	lefttim;	/* éç¥æå»ã¾ã§ã®ç¸å¯¾æé */
+} T_RALM;
+
+typedef struct t_rovr {
+	STAT	ovrstat;	/* ãªã¼ãã©ã³ãã³ãã©ã®åä½ç¶æ
+ */
+	PRCTIM	leftotm;	/* æ®ããã­ã»ããµæé */
+} T_ROVR;
+
+typedef struct t_cisr {
+	ATR			isratr;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å±æ§ */
+	intptr_t	exinf;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®æ¡å¼µæ
+å ± */
+	INTNO		intno;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ãç»é²ããå²è¾¼ã¿çªå· */
+	ISR			isr;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å
+é ­çªå° */
+	PRI			isrpri;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åªå
+åº¦ */
+} T_CISR;
+
+/*
+ *  ãµã¼ãã¹ã³ã¼ã«ã®å®£è¨
+ */
+
+/*
+ *  ã¿ã¹ã¯ç®¡çæ©è½
+ */
+extern ER_UINT	acre_tsk(const T_CTSK *pk_ctsk) throw();
+extern ER		del_tsk(ID tskid) throw();
+extern ER		act_tsk(ID tskid) throw();
+extern ER_UINT	can_act(ID tskid) throw();
+extern ER		get_tst(ID tskid, STAT *p_tskstat) throw();
+extern ER		chg_pri(ID tskid, PRI tskpri) throw();
+extern ER		get_pri(ID tskid, PRI *p_tskpri) throw();
+extern ER		get_inf(intptr_t *p_exinf) throw();
+extern ER		ref_tsk(ID tskid, T_RTSK *pk_rtsk) throw();
+
+/*
+ *  ã¿ã¹ã¯ä»å±åææ©è½
+ */
+extern ER		slp_tsk(void) throw();
+extern ER		tslp_tsk(TMO tmout) throw();
+extern ER		wup_tsk(ID tskid) throw();
+extern ER_UINT	can_wup(ID tskid) throw();
+extern ER		rel_wai(ID tskid) throw();
+extern ER		sus_tsk(ID tskid) throw();
+extern ER		rsm_tsk(ID tskid) throw();
+extern ER		dly_tsk(RELTIM dlytim) throw();
+
+/*
+ *  ã¿ã¹ã¯çµäºæ©è½
+ */
+extern ER		ext_tsk(void) throw();
+extern ER		ras_ter(ID tskid) throw();
+extern ER		dis_ter(void) throw();
+extern ER		ena_ter(void) throw();
+extern bool_t	sns_ter(void) throw();
+extern ER		ter_tsk(ID tskid) throw();
+
+/*
+ *  åæã»éä¿¡æ©è½
+ */
+extern ER_ID	acre_sem(const T_CSEM *pk_csem) throw();
+extern ER		del_sem(ID semid) throw();
+extern ER		sig_sem(ID semid) throw();
+extern ER		wai_sem(ID semid) throw();
+extern ER		pol_sem(ID semid) throw();
+extern ER		twai_sem(ID semid, TMO tmout) throw();
+extern ER		ini_sem(ID semid) throw();
+extern ER		ref_sem(ID semid, T_RSEM *pk_rsem) throw();
+
+extern ER_ID	acre_flg(const T_CFLG *pk_cflg) throw();
+extern ER		del_flg(ID flgid) throw();
+extern ER		set_flg(ID flgid, FLGPTN setptn) throw();
+extern ER		clr_flg(ID flgid, FLGPTN clrptn) throw();
+extern ER		wai_flg(ID flgid, FLGPTN waiptn,
+						MODE wfmode, FLGPTN *p_flgptn) throw();
+extern ER		pol_flg(ID flgid, FLGPTN waiptn,
+						MODE wfmode, FLGPTN *p_flgptn) throw();
+extern ER		twai_flg(ID flgid, FLGPTN waiptn,
+						MODE wfmode, FLGPTN *p_flgptn, TMO tmout) throw();
+extern ER		ini_flg(ID flgid) throw();
+extern ER		ref_flg(ID flgid, T_RFLG *pk_rflg) throw();
+
+extern ER_ID	acre_dtq(const T_CDTQ *pk_cdtq) throw();
+extern ER		del_dtq(ID dtqid) throw();
+extern ER		snd_dtq(ID dtqid, intptr_t data) throw();
+extern ER		psnd_dtq(ID dtqid, intptr_t data) throw();
+extern ER		tsnd_dtq(ID dtqid, intptr_t data, TMO tmout) throw();
+extern ER		fsnd_dtq(ID dtqid, intptr_t data) throw();
+extern ER		rcv_dtq(ID dtqid, intptr_t *p_data) throw();
+extern ER		prcv_dtq(ID dtqid, intptr_t *p_data) throw();
+extern ER		trcv_dtq(ID dtqid, intptr_t *p_data, TMO tmout) throw();
+extern ER		ini_dtq(ID dtqid) throw();
+extern ER		ref_dtq(ID dtqid, T_RDTQ *pk_rdtq) throw();
+
+extern ER_ID	acre_pdq(const T_CPDQ *pk_cpdq) throw();
+extern ER		del_pdq(ID pdqid) throw();
+extern ER		snd_pdq(ID pdqid, intptr_t data, PRI datapri) throw();
+extern ER		psnd_pdq(ID pdqid, intptr_t data, PRI datapri) throw();
+extern ER		tsnd_pdq(ID pdqid, intptr_t data,
+										PRI datapri, TMO tmout) throw();
+extern ER		rcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri) throw();
+extern ER		prcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri) throw();
+extern ER		trcv_pdq(ID pdqid, intptr_t *p_data,
+										PRI *p_datapri, TMO tmout) throw();
+extern ER		ini_pdq(ID pdqid) throw();
+extern ER		ref_pdq(ID pdqid, T_RPDQ *pk_rpdq) throw();
+
+extern ER_ID	acre_mtx(const T_CMTX *pk_cmtx) throw();
+extern ER		del_mtx(ID mtxid) throw();
+extern ER		loc_mtx(ID mtxid) throw();
+extern ER		ploc_mtx(ID mtxid) throw();
+extern ER		tloc_mtx(ID mtxid, TMO tmout) throw();
+extern ER		unl_mtx(ID mtxid) throw();
+extern ER		ini_mtx(ID mtxid) throw();
+extern ER		ref_mtx(ID mtxid, T_RMTX *pk_rmtx) throw();
+
+/*
+ *  ã¡ã¢ãªãã¼ã«ç®¡çæ©è½
+ */
+extern ER_ID	acre_mpf(const T_CMPF *pk_cmpf) throw();
+extern ER		del_mpf(ID mpfid) throw();
+extern ER		get_mpf(ID mpfid, void **p_blk) throw();
+extern ER		pget_mpf(ID mpfid, void **p_blk) throw();
+extern ER		tget_mpf(ID mpfid, void **p_blk, TMO tmout) throw();
+extern ER		rel_mpf(ID mpfid, void *blk) throw();
+extern ER		ini_mpf(ID mpfid) throw();
+extern ER		ref_mpf(ID mpfid, T_RMPF *pk_rmpf) throw();
+
+/*
+ *  æéç®¡çæ©è½
+ */
+extern ER		set_tim(SYSTIM systim) throw();
+extern ER		get_tim(SYSTIM *p_systim) throw();
+extern ER		adj_tim(int32_t adjtim) throw();
+extern HRTCNT	fch_hrt(void) throw();
+
+extern ER_ID	acre_cyc(const T_CCYC *pk_ccyc) throw();
+extern ER		del_cyc(ID cycid) throw();
+extern ER		sta_cyc(ID cycid) throw();
+extern ER		stp_cyc(ID cycid) throw();
+extern ER		ref_cyc(ID cycid, T_RCYC *pk_rcyc) throw();
+
+extern ER_ID	acre_alm(const T_CALM *pk_calm) throw();
+extern ER		del_alm(ID almid) throw();
+extern ER		sta_alm(ID almid, RELTIM almtim) throw();
+extern ER		stp_alm(ID almid) throw();
+extern ER		ref_alm(ID almid, T_RALM *pk_ralm) throw();
+
+extern ER		sta_ovr(ID tskid, PRCTIM ovrtim) throw();
+extern ER		stp_ovr(ID tskid) throw();
+extern ER		ref_ovr(ID tskid, T_ROVR *pk_rovr) throw();
+
+/*
+ *  ã·ã¹ãã ç¶æ
+ç®¡çæ©è½
+ */
+extern ER		rot_rdq(PRI tskpri) throw();
+extern ER		get_tid(ID *p_tskid) throw();
+extern ER		get_lod(PRI tskpri, uint_t *p_load) throw();
+extern ER		get_nth(PRI tskpri, uint_t nth, ID *p_tskid) throw();
+extern ER		loc_cpu(void) throw();
+extern ER		unl_cpu(void) throw();
+extern ER		dis_dsp(void) throw();
+extern ER		ena_dsp(void) throw();
+extern bool_t	sns_ctx(void) throw();
+extern bool_t	sns_loc(void) throw();
+extern bool_t	sns_dsp(void) throw();
+extern bool_t	sns_dpn(void) throw();
+extern bool_t	sns_ker(void) throw();
+extern ER		ext_ker(void) throw();
+
+/*
+ *  å²è¾¼ã¿ç®¡çæ©è½
+ */
+extern ER_ID	acre_isr(const T_CISR *pk_cisr) throw();
+extern ER		del_isr(ID isrid) throw();
+extern ER		dis_int(INTNO intno) throw();
+extern ER		ena_int(INTNO intno) throw();
+extern ER		clr_int(INTNO intno) throw();
+extern ER		ras_int(INTNO intno) throw();
+extern ER_BOOL	prb_int(INTNO intno) throw();
+extern ER		chg_ipm(PRI intpri) throw();
+extern ER		get_ipm(PRI *p_intpri) throw();
+
+/*
+ *  CPUä¾å¤ç®¡çæ©è½
+ */
+extern bool_t	xsns_dpn(void *p_excinf) throw();
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãããå¼ã³åºãããµã¼ãã¹ã³ã¼ã«
+ */
+#define iact_tsk(tskid)						act_tsk(tskid)
+#define iwup_tsk(tskid)						wup_tsk(tskid)
+#define irel_wai(tskid)						rel_wai(tskid)
+#define isns_ter()							sns_ter()
+#define isig_sem(semid)						sig_sem(semid)
+#define iset_flg(flgid, setptn)				set_flg(flgid, setptn)
+#define ipsnd_dtq(dtqid, data)				psnd_dtq(dtqid, data)
+#define ifsnd_dtq(dtqid, data)				fsnd_dtq(dtqid, data)
+#define ipsnd_pdq(pdqid, data, datapri)		psnd_pdq(pdqid, data, datapri)
+#define ifch_hrt()							fch_hrt()
+#define ista_alm(almid, almtim)				sta_alm(almid, almtim)
+#define istp_alm(almid)						stp_alm(almid)
+#define ista_ovr(tskid, ovrtim)				sta_ovr(tskid, ovrtim)
+#define istp_ovr(tskid)						stp_ovr(tskid)
+#define irot_rdq(tskpri)					rot_rdq(tskpri)
+#define iget_tid(p_tskid)					get_tid(p_tskid)
+#define iloc_cpu()							loc_cpu()
+#define iunl_cpu()							unl_cpu()
+#define isns_ctx()							sns_ctx()
+#define isns_loc()							sns_loc()
+#define isns_dsp()							sns_dsp()
+#define isns_dpn()							sns_dpn()
+#define isns_ker()							sns_ker()
+#define iext_ker()							ext_ker()
+#define idis_int(intno)						dis_int(intno)
+#define iena_int(intno)						ena_int(intno)
+#define iclr_int(intno)						clr_int(intno)
+#define iras_int(intno)						ras_int(intno)
+#define iprb_int(intno)						prb_int(intno)
+#define ixsns_dpn(p_excinf)					xsns_dpn(p_excinf)
+
+/*
+ *  ãªãã¸ã§ã¯ãå±æ§ã®å®ç¾©
+ */
+#define TA_ACT			UINT_C(0x01)	/* ã¿ã¹ã¯ãèµ·åãããç¶æ
+ã§çæ */
+#define TA_NOACTQUE		UINT_C(0x02)	/* èµ·åè¦æ±ãã­ã¥ã¼ã¤ã³ã°ããªã */
+
+#define TA_TPRI			UINT_C(0x01)	/* ã¿ã¹ã¯ã®å¾
+ã¡è¡åãåªå
+åº¦é ã« */
+
+#define TA_WMUL			UINT_C(0x02)	/* è¤æ°ã®å¾
+ã¡ã¿ã¹ã¯ */
+#define TA_CLR			UINT_C(0x04)	/* ã¤ãã³ããã©ã°ã®ã¯ãªã¢æå® */
+
+#define TA_CEILING		UINT_C(0x03)	/* åªå
+åº¦ä¸éãã­ãã³ã« */
+
+#define TA_STA			UINT_C(0x02)	/* å¨æéç¥ãåä½ç¶æ
+ã§çæ */
+
+#define TA_NONKERNEL	UINT_C(0x02)	/* ã«ã¼ãã«ç®¡çå¤ã®å²è¾¼ã¿ */
+
+#define TA_ENAINT		UINT_C(0x01)	/* å²è¾¼ã¿è¦æ±ç¦æ­¢ãã©ã°ãã¯ãªã¢ */
+#define TA_EDGE			UINT_C(0x02)	/* ã¨ãã¸ããªã¬ */
+
+/*
+ *  ãµã¼ãã¹ã³ã¼ã«ã®åä½ã¢ã¼ãã®å®ç¾©
+ */
+#define TWF_ORW			UINT_C(0x01)	/* ã¤ãã³ããã©ã°ã®ORå¾
+ã¡ */
+#define TWF_ANDW		UINT_C(0x02)	/* ã¤ãã³ããã©ã°ã®ANDå¾
+ã¡ */
+
+/*
+ *  éç¥å¦çã¢ã¼ãã®å®ç¾©
+ */
+#define TNFY_HANDLER	UINT_C(0x00)		/* ã¿ã¤ã ã¤ãã³ããã³ãã©ã®å¼åºã */
+#define TNFY_SETVAR		UINT_C(0x01)		/* å¤æ°ã®è¨­å® */
+#define TNFY_INCVAR		UINT_C(0x02)		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ã */
+#define TNFY_ACTTSK		UINT_C(0x03)		/* ã¿ã¹ã¯ã®èµ·å */
+#define TNFY_WUPTSK		UINT_C(0x04)		/* ã¿ã¹ã¯ã®èµ·åº */
+#define TNFY_SIGSEM		UINT_C(0x05)		/* ã»ããã©ã®è³æºã®è¿å´ */
+#define TNFY_SETFLG		UINT_C(0x06)		/* ã¤ãã³ããã©ã°ã®ã»ãã */
+#define TNFY_SNDDTQ		UINT_C(0x07)		/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ */
+
+#define TENFY_SETVAR	UINT_C(0x10)		/* å¤æ°ã®è¨­å® */
+#define TENFY_INCVAR	UINT_C(0x20)		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ã */
+#define TENFY_ACTTSK	UINT_C(0x30)		/* ã¿ã¹ã¯ã®èµ·å */
+#define TENFY_WUPTSK	UINT_C(0x40)		/* ã¿ã¹ã¯ã®èµ·åº */
+#define TENFY_SIGSEM	UINT_C(0x50)		/* ã»ããã©ã®è¿å´ */
+#define TENFY_SETFLG	UINT_C(0x60)		/* ã¤ãã³ããã©ã°ã®ã»ãã */
+#define TENFY_SNDDTQ	UINT_C(0x70)		/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ */
+
+/*
+ *  ãªãã¸ã§ã¯ãã®ç¶æ
+ã®å®ç¾©
+ */
+#define TTS_RUN			UINT_C(0x01)	/* å®è¡ç¶æ
+ */
+#define TTS_RDY			UINT_C(0x02)	/* å®è¡å¯è½ç¶æ
+ */
+#define TTS_WAI			UINT_C(0x04)	/* å¾
+ã¡ç¶æ
+ */
+#define TTS_SUS			UINT_C(0x08)	/* å¼·å¶å¾
+ã¡ç¶æ
+ */
+#define TTS_WAS			UINT_C(0x0c)	/* äºéå¾
+ã¡ç¶æ
+ */
+#define TTS_DMT			UINT_C(0x10)	/* ä¼æ­¢ç¶æ
+ */
+
+#define TTW_SLP			UINT_C(0x0001)	/* èµ·åºå¾
+ã¡ */
+#define TTW_DLY			UINT_C(0x0002)	/* æéçµéå¾
+ã¡ */
+#define TTW_SEM			UINT_C(0x0004)	/* ã»ããã©ã®è³æºç²å¾å¾
+ã¡ */
+#define TTW_FLG			UINT_C(0x0008)	/* ã¤ãã³ããã©ã°å¾
+ã¡ */
+#define TTW_SDTQ		UINT_C(0x0010)	/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡å¾
+ã¡ */
+#define TTW_RDTQ		UINT_C(0x0020)	/* ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡å¾
+ã¡ */
+#define TTW_SPDQ		UINT_C(0x0100)	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡å¾
+ã¡ */
+#define TTW_RPDQ		UINT_C(0x0200)	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡å¾
+ã¡ */
+#define TTW_MTX			UINT_C(0x0080)	/* ãã¥ã¼ããã¯ã¹ã®ã­ãã¯å¾
+ã¡ç¶æ
+ */
+#define TTW_MPF			UINT_C(0x2000)	/* åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾å¾
+ã¡ */
+
+#define TCYC_STP		UINT_C(0x01)	/* å¨æéç¥ãåä½ãã¦ããªã */
+#define TCYC_STA		UINT_C(0x02)	/* å¨æéç¥ãåä½ãã¦ãã */
+
+#define TALM_STP		UINT_C(0x01)	/* ã¢ã©ã¼ã éç¥ãåä½ãã¦ããªã */
+#define TALM_STA		UINT_C(0x02)	/* ã¢ã©ã¼ã éç¥ãåä½ãã¦ãã */
+
+#define TOVR_STP		UINT_C(0x01)	/* ãªã¼ãã©ã³ãã³ãã©ãåä½ãã¦ããªã*/
+#define TOVR_STA		UINT_C(0x02)	/* ãªã¼ãã©ã³ãã³ãã©ãåä½ãã¦ãã */
+
+/*
+ *  ãã®ä»ã®å®æ°ã®å®ç¾©
+ */
+#define TSK_SELF		0			/* èªã¿ã¹ã¯æå® */
+#define TSK_NONE		0			/* è©²å½ããã¿ã¹ã¯ããªã */
+
+#define TPRI_SELF		0			/* èªã¿ã¹ã¯ã®ãã¼ã¹åªå
+åº¦ */
+#define TPRI_INI		0			/* ã¿ã¹ã¯ã®èµ·åæåªå
+åº¦ */
+
+#define TIPM_ENAALL		0			/* å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ */
+
+/*
+ *  æ§æå®æ°ã¨ãã¯ã­
+ */
+
+/*
+ *  åªå
+åº¦ã®ç¯å²
+ */
+#define TMIN_TPRI		1			/* ã¿ã¹ã¯åªå
+åº¦ã®æå°å¤ï¼æé«å¤ï¼*/
+#define TMAX_TPRI		16			/* ã¿ã¹ã¯åªå
+åº¦ã®æå¤§å¤ï¼æä½å¤ï¼*/
+#define TMIN_DPRI		1			/* ãã¼ã¿åªå
+åº¦ã®æå°å¤ï¼æé«å¤ï¼*/
+#define TMAX_DPRI		16			/* ãã¼ã¿åªå
+åº¦ã®æå¤§å¤ï¼æä½å¤ï¼*/
+#define TMIN_ISRPRI		1			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åªå
+åº¦ã®æå°å¤ */
+#define TMAX_ISRPRI		16			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åªå
+åº¦ã®æå¤§å¤ */
+
+/*
+ *  ãã¼ã¸ã§ã³æ
+å ±
+ */
+#define TKERNEL_MAKER	UINT_C(0x0118)	/* ã«ã¼ãã«ã®ã¡ã¼ã«ã¼ã³ã¼ã */
+#define TKERNEL_PRID	UINT_C(0x0007)	/* ã«ã¼ãã«ã®è­å¥çªå· */
+#define TKERNEL_SPVER	UINT_C(0xf631)	/* ã«ã¼ãã«ä»æ§ã®ãã¼ã¸ã§ã³çªå· */
+#define TKERNEL_PRVER	UINT_C(0x3020)	/* ã«ã¼ãã«ã®ãã¼ã¸ã§ã³çªå· */
+
+/*
+ *  ã­ã¥ã¼ã¤ã³ã°åæ°ã®æå¤§å¤
+ */
+#define TMAX_ACTCNT		UINT_C(1)		/* èµ·åè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®æå¤§å¤ */
+#define TMAX_WUPCNT		UINT_C(1)		/* èµ·åºè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®æå¤§å¤ */
+
+/*
+ *  ããããã¿ã¼ã³ã®ãããæ°
+ */
+#ifndef TBIT_FLGPTN					/* ã¤ãã³ããã©ã°ã®ãããæ° */
+#define TBIT_FLGPTN		(sizeof(FLGPTN) * CHAR_BIT)
+#endif /* TBIT_FLGPTN */
+
+/*
+ *  ã·ã¹ãã æå»ã®èª¿æ´ã§ããç¯å²ï¼åä½ï¼Î¼ç§ï¼
+ */
+#define TMIN_ADJTIM		-1000000		/* ã·ã¹ãã æå»ã®æå°èª¿æ´æé */
+#define TMAX_ADJTIM		1000000			/* ã·ã¹ãã æå»ã®æå¤§èª¿æ´æé */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ã®æ®ããã­ã»ããµæéã®æå¤§å¤ï¼åä½ï¼Î¼ç§ï¼
+ */
+#ifndef TMAX_OVRTIM
+#define TMAX_OVRTIM		UINT32_MAX
+#endif /* TMAX_OVRTIM */
+
+/*
+ *  ã¡ã¢ãªé åç¢ºä¿ã®ããã®ãã¯ã­
+ *
+ *  ä»¥ä¸ã®TOPPERS_COUNT_SZã¨TOPPERS_ROUND_SZã®å®ç¾©ã¯ï¼unitã2ã®å·¾ä¹ã§ã
+ *  ããã¨ãä»®å®ãã¦ããï¼
+ */
+#ifndef TOPPERS_COUNT_SZ
+#define TOPPERS_COUNT_SZ(sz, unit)	(((sz) + (unit) - 1) / (unit))
+#endif /* TOPPERS_COUNT_SZ */
+#ifndef TOPPERS_ROUND_SZ
+#define TOPPERS_ROUND_SZ(sz, unit)	(((sz) + (unit) - 1) & ~((unit) - 1))
+#endif /* TOPPERS_ROUND_SZ */
+
+#define COUNT_STK_T(sz)		TOPPERS_COUNT_SZ(sz, sizeof(STK_T))
+#define ROUND_STK_T(sz)		TOPPERS_ROUND_SZ(sz, sizeof(STK_T))
+
+#define COUNT_MPF_T(blksz)	TOPPERS_COUNT_SZ(blksz, sizeof(MPF_T))
+#define ROUND_MPF_T(blksz)	TOPPERS_ROUND_SZ(blksz, sizeof(MPF_T))
+
+#define TSZ_DTQMB(dtqcnt)	(sizeof(intptr_t) * (dtqcnt))
+#define TCNT_DTQMB(dtqcnt)	TOPPERS_COUNT_SZ(TSZ_DTQMB(dtqcnt), sizeof(MB_T))
+
+#ifndef TSZ_PDQMB
+#define TSZ_PDQMB(pdqcnt)	(sizeof(intptr_t) * 3 * (pdqcnt))
+#endif /* TSZ_PDQMB */
+#define TCNT_PDQMB(pdqcnt)	TOPPERS_COUNT_SZ(TSZ_PDQMB(pdqcnt), sizeof(MB_T))
+
+#define TSZ_MPFMB(blkcnt)	(sizeof(uint_t) * (blkcnt))
+#define TCNT_MPFMB(blkcnt)	TOPPERS_COUNT_SZ(TSZ_MPFMB(blkcnt), sizeof(MB_T))
+
+/*
+ *  ãã®ä»ã®æ§æå®æ°
+ */
+#define TMAX_MAXSEM		UINT_MAX	/* ã»ããã©ã®æå¤§è³æºæ°ã®æå¤§å¤ */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_KERNEL_H */
Index: asp3_gr_sakura/trunk/include/log_output.h
===================================================================
--- asp3_gr_sakura/trunk/include/log_output.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/log_output.h	(revision 317)
@@ -0,0 +1,104 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã®ãã©ã¼ãããåºå
+ */
+
+#ifndef TOPPERS_LOG_OUTPUT_H
+#define TOPPERS_LOG_OUTPUT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+
+/*
+ *  æå­åæ´å½¢åºå
+ *
+ *  formatã§æå®ããããã©ã¼ãããè¨è¿°ã¨p_argsã§æå®ãããå¼æ°åããä½
+ *  æããã¡ãã»ã¼ã¸ãï¼1æå­åºåé¢æ°putcãç¨ãã¦åºåããï¼
+ */
+extern void	syslog_printf(const char *format, const intptr_t *p_args,
+										void (*putc)(char)) throw();
+
+/*
+ *  ã­ã°æ
+å ±ã®åºå
+ *
+ *  p_syslogã§æå®ãããã­ã°æ
+å ±ãæå­åã«æ´å½¢ãï¼1æå­åºåé¢æ°putcãç¨
+ *  ãã¦åºåããï¼
+ */
+extern void	syslog_print(const SYSLOG *p_syslog, void (*putc)(char)) throw();
+
+/*
+ *  ã­ã°æ
+å ±åªå¤±ã¡ãã»ã¼ã¸æå­å
+ *
+ *  lostlogåã®ã­ã°æ
+å ±ãå¤±ãããæ¨ã®ã¡ãã»ã¼ã¸ãï¼1æå­åºåé¢æ°putcã
+ *  ç¨ãã¦åºåããï¼
+ */
+extern void	syslog_lostmsg(uint_t lostlog, void (*putc)(char)) throw();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_LOG_OUTPUT_H */
Index: asp3_gr_sakura/trunk/include/queue.h
===================================================================
--- asp3_gr_sakura/trunk/include/queue.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/queue.h	(revision 317)
@@ -0,0 +1,190 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2006-2011 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã­ã¥ã¼æä½ã©ã¤ãã©ãª
+ *
+ *  ãã®ã­ã¥ã¼æä½ã©ã¤ãã©ãªã§ã¯ï¼ã­ã¥ã¼ããããå«ããªã³ã°æ§é ã®ããã«
+ *  ãªã³ã¯ã­ã¥ã¼ãæ±ãï¼å
+·ä½çã«ã¯ï¼ã­ã¥ã¼ãããã®æ¬¡ã¨ã³ããªã¯ã­ã¥ã¼ã®
+ *  å
+é ­ã®ã¨ã³ããªï¼åã¨ã³ããªã¯ã­ã¥ã¼ã®æ«å°¾ã®ã¨ã³ããªã¨ããï¼ã¾ãï¼ã­
+ *  ã¥ã¼ã®å
+é ­ã®ã¨ã³ããªã®åã¨ã³ããªã¨ï¼ã­ã¥ã¼ã®æ«å°¾ã®ã¨ã³ããªã®æ¬¡ã¨ã³
+ *  ããªã¯ï¼ã­ã¥ã¼ãããã¨ããï¼ç©ºã®ã­ã¥ã¼ã¯ï¼æ¬¡ã¨ã³ããªï¼åã¨ã³ããªã¨
+ *  ãèªåèªèº«ãæãã­ã¥ã¼ãããã§ããããï¼
+ */
+
+#ifndef	TOPPERS_QUEUE_H
+#define	TOPPERS_QUEUE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+
+/*
+ *  ã­ã¥ã¼ã®ãã¼ã¿æ§é ã®å®ç¾©
+ */
+typedef struct queue {
+	struct queue *p_next;		/* æ¬¡ã¨ã³ããªã¸ã®ãã¤ã³ã¿ */
+	struct queue *p_prev;		/* åã¨ã³ããªã¸ã®ãã¤ã³ã¿ */
+} QUEUE;
+
+/*
+ *  ã­ã¥ã¼ã®åæå
+ *
+ *  p_queueã«ã¯ã­ã¥ã¼ããããæå®ããï¼
+ */
+Inline void
+queue_initialize(QUEUE *p_queue)
+{
+	p_queue->p_prev = p_queue;
+	p_queue->p_next = p_queue;
+}
+
+/*
+ *  ã­ã¥ã¼ã®åã¨ã³ããªã¸ã®æ¿å
+¥
+ *
+ *  p_queueã®åã«p_entryãæ¿å
+¥ããï¼p_queueã«ã­ã¥ã¼ããããæå®ããå ´
+ *  åã«ã¯ï¼ã­ã¥ã¼ã®æ«å°¾ã«p_entryãæ¿å
+¥ãããã¨ã«ãªãï¼
+ */
+Inline void
+queue_insert_prev(QUEUE *p_queue, QUEUE *p_entry)
+{
+	p_entry->p_prev = p_queue->p_prev;
+	p_entry->p_next = p_queue;
+	p_queue->p_prev->p_next = p_entry;
+	p_queue->p_prev = p_entry;
+}
+
+/*
+ *  ã­ã¥ã¼ã®æ¬¡ã¨ã³ããªã¸ã®æ¿å
+¥
+ *
+ *  p_queueã®æ¬¡ã«p_entryãæ¿å
+¥ããï¼p_queueã«ã­ã¥ã¼ããããæå®ããå ´
+ *  åã«ã¯ï¼ã­ã¥ã¼ã®å
+é ­ã«p_entryãæ¿å
+¥ãããã¨ã«ãªãï¼
+ */
+Inline void
+queue_insert_next(QUEUE *p_queue, QUEUE *p_entry)
+{
+	p_entry->p_prev = p_queue;
+	p_entry->p_next = p_queue->p_next;
+	p_queue->p_next->p_prev = p_entry;
+	p_queue->p_next = p_entry;
+}
+
+/*
+ *  ã¨ã³ããªã®åé¤
+ *
+ *  p_entryãã­ã¥ã¼ããåé¤ããï¼
+ */
+Inline void
+queue_delete(QUEUE *p_entry)
+{
+	p_entry->p_prev->p_next = p_entry->p_next;
+	p_entry->p_next->p_prev = p_entry->p_prev;
+}
+
+/*
+ *  ã­ã¥ã¼ã®æ¬¡ã¨ã³ããªã®ååºã
+ *
+ *  p_queueã®æ¬¡ã¨ã³ããªãã­ã¥ã¼ããåé¤ãï¼åé¤ããã¨ã³ããªãè¿ãï¼
+ *  p_queueã«ã­ã¥ã¼ããããæå®ããå ´åã«ã¯ï¼ã­ã¥ã¼ã®å
+é ­ã®ã¨ã³ããªã
+ *  åãåºããã¨ã«ãªãï¼p_queueã«ç©ºã®ã­ã¥ã¼ãæå®ãã¦å¼ã³åºãã¦ã¯ãªã
+ *  ãªãï¼
+ */
+Inline QUEUE *
+queue_delete_next(QUEUE *p_queue)
+{
+	QUEUE	*p_entry;
+
+	assert(p_queue->p_next != p_queue);
+	p_entry = p_queue->p_next;
+	p_queue->p_next = p_entry->p_next;
+	p_entry->p_next->p_prev = p_queue;
+	return(p_entry);
+}
+
+/*
+ *  ã­ã¥ã¼ãç©ºãã©ããã®ãã§ãã¯
+ *
+ *  p_queueã«ã¯ã­ã¥ã¼ããããæå®ããï¼
+ */
+Inline bool_t
+queue_empty(QUEUE *p_queue)
+{
+	if (p_queue->p_next == p_queue) {
+		assert(p_queue->p_prev == p_queue);
+		return(true);
+	}
+	return(false);
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_QUEUE_H */
Index: asp3_gr_sakura/trunk/include/sil.h
===================================================================
--- asp3_gr_sakura/trunk/include/sil.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/sil.h	(revision 317)
@@ -0,0 +1,303 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2011 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¤ã¤
+ *
+ *  ã·ã¹ãã ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¤ã¤ã®ãµã¼ãã¹ã³ã¼ã«ã®å®ç¾©ã»å®£è¨ã¨ãã¯ã­ãª
+ *  ã©ã®å®ç¾©ãå«ãããããã¡ã¤ã«ï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ãããã¨ã§ï¼ãã¯ã­å®ç¾©ä»¥å¤ã®è¨è¿°ã
+ *  é¤ããã¨ãã§ããï¼
+ */
+
+#ifndef TOPPERS_SIL_H
+#define TOPPERS_SIL_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *	TOPPERSå
+±éã®ãã¼ã¿åã»å®æ°ã»ãã¯ã­
+ */
+#include <t_stddef.h>
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨
+ */
+#include "target_sil.h"
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã®å¶å¾¡
+ *
+ *  SIL_PRE_LOCï¼SIL_LOC_INT()ï¼SIL_UNL_INT()ã¯ï¼ã¿ã¼ã²ããä¾å­é¨ã§ç¨
+ *  æããï¼ããã©ã«ãã®å®ç¾©ã¯ç¨æãã¦ããªãï¼
+ */
+
+/*
+ *  å¾®å°æéå¾
+ã¡
+ */
+extern void	sil_dly_nse(ulong_t dlytim) throw();
+
+/*
+ *  ã¨ã³ãã£ã¢ã³ã®åè»¢
+ */
+#ifndef TOPPERS_SIL_REV_ENDIAN_UINT16
+#define	TOPPERS_SIL_REV_ENDIAN_UINT16(data) \
+				((((data) & 0xffU) << 8) | (((data) >> 8) & 0xffU))
+#endif /* TOPPERS_SIL_REV_ENDIAN_UINT16 */
+
+#ifndef TOPPERS_SIL_REV_ENDIAN_UINT32
+#define	TOPPERS_SIL_REV_ENDIAN_UINT32(data) \
+				((((data) & 0xffU) << 24) | (((data) & 0xff00U) << 8) \
+					| (((data) >> 8) & 0xff00U) | (((data) >> 24) & 0xffU))
+#endif /* TOPPERS_SIL_REV_ENDIAN_UINT32 */
+
+/*
+ *  ã¡ã¢ãªç©ºéã¢ã¯ã»ã¹é¢æ°
+ */
+#ifndef TOPPERS_OMIT_SIL_ACCESS
+
+/*
+ *  8ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+#ifdef UINT8_MAX
+
+Inline uint8_t
+sil_reb_mem(const uint8_t *mem)
+{
+	uint8_t	data;
+
+	data = *((const volatile uint8_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrb_mem(uint8_t *mem, uint8_t data)
+{
+	*((volatile uint8_t *) mem) = data;
+}
+
+#endif /* UINT8_MAX */
+
+/*
+ *  16ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+
+Inline uint16_t
+sil_reh_mem(const uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrh_mem(uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = data;
+}
+
+#ifdef SIL_ENDIAN_BIG			/* ããã°ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_reh_bem(mem)		sil_reh_mem(mem)
+#define	sil_wrh_bem(mem, data)	sil_wrh_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REH_LEM
+
+Inline uint16_t
+sil_reh_lem(const uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REH_LEM */
+#ifndef TOPPERS_OMIT_SIL_WRH_LEM
+
+Inline void
+sil_wrh_lem(uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRH_LEM */
+#else /* SIL_ENDIAN_BIG */
+#ifdef SIL_ENDIAN_LITTLE		/* ãªãã«ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_reh_lem(mem)		sil_reh_mem(mem)
+#define	sil_wrh_lem(mem, data)	sil_wrh_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REH_BEM
+
+Inline uint16_t
+sil_reh_bem(const uint16_t *mem)
+{
+	uint16_t	data;
+
+	data = *((const volatile uint16_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT16(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REH_BEM */
+#ifndef TOPPERS_OMIT_SIL_WRH_BEM
+
+Inline void
+sil_wrh_bem(uint16_t *mem, uint16_t data)
+{
+	*((volatile uint16_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT16(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRH_BEM */
+#else /* SIL_ENDIAN_LITTLE */
+
+#error Neither SIL_ENDIAN_BIG nor SIL_ENDIAN_LITTLE is defined.
+
+#endif /* SIL_ENDIAN_LITTLE */
+#endif /* SIL_ENDIAN_BIG */
+
+/*
+ *  32ãããåä½ã®èª­åºãï¼æ¸è¾¼ã¿
+ */
+
+Inline uint32_t
+sil_rew_mem(const uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(data);
+}
+
+Inline void
+sil_wrw_mem(uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = data;
+}
+
+#ifdef SIL_ENDIAN_BIG			/* ããã°ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_rew_bem(mem)		sil_rew_mem(mem)
+#define	sil_wrw_bem(mem, data)	sil_wrw_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REW_LEM
+
+Inline uint32_t
+sil_rew_lem(const uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REW_LEM */
+#ifndef TOPPERS_OMIT_SIL_WRW_LEM
+
+Inline void
+sil_wrw_lem(uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRW_LEM */
+#else /* SIL_ENDIAN_BIG */		/* ãªãã«ã¨ã³ãã£ã¢ã³ãã­ã»ããµ */
+
+#define	sil_rew_lem(mem)		sil_rew_mem(mem)
+#define	sil_wrw_lem(mem, data)	sil_wrw_mem(mem, data)
+
+#ifndef TOPPERS_OMIT_SIL_REW_BEM
+
+Inline uint32_t
+sil_rew_bem(const uint32_t *mem)
+{
+	uint32_t	data;
+
+	data = *((const volatile uint32_t *) mem);
+	return(TOPPERS_SIL_REV_ENDIAN_UINT32(data));
+}
+
+#endif /* TOPPERS_OMIT_SIL_REW_BEM */
+#ifndef TOPPERS_OMIT_SIL_WRW_BEM
+
+Inline void
+sil_wrw_bem(uint32_t *mem, uint32_t data)
+{
+	*((volatile uint32_t *) mem) = TOPPERS_SIL_REV_ENDIAN_UINT32(data);
+}
+
+#endif /* TOPPERS_OMIT_SIL_WRW_BEM */
+#endif /* SIL_ENDIAN_BIG */
+#endif /* TOPPERS_OMIT_SIL_ACCESS */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_SIL_H */
Index: asp3_gr_sakura/trunk/include/t_stddef.h
===================================================================
--- asp3_gr_sakura/trunk/include/t_stddef.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/t_stddef.h	(revision 317)
@@ -0,0 +1,312 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		TOPPERSå
+±éããããã¡ã¤ã«
+ *
+ *  TOPPERSé¢é£ã®ãã¹ã¦ã®ã½ã¼ã¹ãã¡ã¤ã«ã§ã¤ã³ã¯ã«ã¼ããã¹ãããããã¡ã¤
+ *  ã«ï¼åç¨®ã®ã«ã¼ãã«ãã½ããã¦ã§ã¢é¨åã§å
+±éã«ç¨ãããã¨ãæ³å®ãã¦ã
+ *  ãï¼TOPPERSã®åç¨®ã®ã«ã¼ãã«ãã½ããã¦ã§ã¢é¨åã§å
+±éã«ç¨ãããã¼ã¿åï¼
+ *  å®æ°ï¼ãã¯ã­ã®å®ç¾©ãªã©ãå«ãï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ããï¼ããã«ããï¼ãã¯ã­å®ç¾©ä»¥å¤ã
+ *  é¤ãããã«ãªã£ã¦ããï¼
+ */
+
+#ifndef TOPPERS_T_STDDEF_H
+#define TOPPERS_T_STDDEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨
+ */
+#include "target_stddef.h"
+
+/*
+ *  Cè¨èª/EC++ã§throw()ã«å¯¾å¦ããããã®å®ç¾©
+ */
+#if !defined(__cplusplus) || defined(__embedded_cplusplus)
+#define throw()
+#endif
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®ãã¼ã¿åã®ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef TOPPERS_bool
+#define TOPPERS_bool	int				/* ãã¼ã«å */
+#endif /* TOPPERS_bool */
+
+#ifndef TOPPERS_fp
+struct TOPPERS_dummy_t { int TOPPERS_dummy_field; };
+typedef	void			(*TOPPERS_fp_t)(struct TOPPERS_dummy_t);
+#define TOPPERS_fp		TOPPERS_fp_t	/* ãã­ã°ã©ã ã®èµ·åçªå° */
+#endif /* TOPPERS_fp */
+
+/*
+ *  å
+±éãã¼ã¿å
+ */
+typedef TOPPERS_bool	bool_t;		/* çå½å¤ */
+
+typedef signed int		int_t;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ä»ãæ´æ° */
+typedef unsigned int	uint_t;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ç¡ãæ´æ° */
+
+typedef signed long		long_t;		/* é·ãã®ãµã¤ãºã®ç¬¦å·ä»ãæ´æ° */
+typedef unsigned long	ulong_t;	/* é·ãã®ãµã¤ãºã®ç¬¦å·ç¡ãæ´æ° */
+
+typedef int_t			FN;			/* æ©è½ã³ã¼ã */
+typedef	int_t			ER;			/* ã¨ã©ã¼ã³ã¼ã */
+typedef	int_t			ID;			/* ãªãã¸ã§ã¯ãã®IDçªå· */
+typedef	uint_t			ATR;		/* ãªãã¸ã§ã¯ãã®å±æ§ */
+typedef	uint_t			STAT;		/* ãªãã¸ã§ã¯ãã®ç¶æ
+ */
+typedef	uint_t			MODE;		/* ãµã¼ãã¹ã³ã¼ã«ã®åä½ã¢ã¼ã */
+typedef	int_t			PRI;		/* åªå
+åº¦ */
+typedef	uint32_t		TMO;		/* ã¿ã¤ã ã¢ã¦ãæå® */
+typedef	uint32_t		RELTIM;		/* ç¸å¯¾æéï¼»NGKI0550ï¼½*/
+#ifdef UINT64_MAX
+typedef	uint64_t		SYSTIM;		/* ã·ã¹ãã æå»ï¼»NGKI0548ï¼½*/
+#else /* UINT64_MAX */
+typedef	uint32_t		SYSTIM;		/* ã·ã¹ãã æå»ï¼»NGKI0548ï¼½*/
+#endif /* UINT64_MAX */
+typedef	uint32_t		PRCTIM;		/* ãã­ã»ããµæéï¼»NGKI0573ï¼½*/
+typedef	uint32_t		HRTCNT;		/* é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ */
+
+typedef	TOPPERS_fp		FP;			/* ãã­ã°ã©ã ã®èµ·åçªå° */
+
+typedef	int_t			ER_BOOL;	/* ã¨ã©ã¼ã³ã¼ãã¾ãã¯çå½å¤ */
+typedef	int_t			ER_ID;		/* ã¨ã©ã¼ã³ã¼ãã¾ãã¯IDçªå· */
+typedef	int_t			ER_UINT;	/* ã¨ã©ã¼ã³ã¼ãã¾ãã¯ç¬¦å·ç¡ãæ´æ° */
+
+typedef uintptr_t		MB_T;		/* ç®¡çé åãç¢ºä¿ããããã®ãã¼ã¿å */
+
+typedef	uint32_t		ACPTN;		/* ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ */
+typedef	struct acvct {				/* ã¢ã¯ã»ã¹è¨±å¯ãã¯ã¿ */
+	ACPTN		acptn1;				/* éå¸¸æä½1ã®ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ */
+	ACPTN		acptn2;				/* éå¸¸æä½2ã®ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ */
+	ACPTN		acptn3;				/* ç®¡çæä½ã®ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ */
+	ACPTN		acptn4;				/* åç
+§æä½ã®ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ */
+} ACVCT;
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+/*
+ *  æ´æ°å®æ°ãä½ããã¯ã­
+ */
+#ifndef UINT_C
+#define UINT_C(val)		(val ## U)		/* uint_tåã®å®æ°ãä½ããã¯ã­ */
+#endif /* UINT_C */
+
+#ifndef ULONG_C
+#define ULONG_C(val)	(val ## UL)		/* ulong_tåã®å®æ°ãä½ããã¯ã­ */
+#endif /* ULONG_C */
+
+/*
+ *  ä¸è¬å®æ°
+ */
+#ifndef NULL
+#define NULL		0			/* ç¡å¹ãã¤ã³ã¿ */
+#endif /* NULL */
+
+#ifndef true
+#define true		1			/* ç */
+#endif /* true */
+
+#ifndef false
+#define false		0			/* å½ */
+#endif /* false */
+
+#define E_OK		0			/* æ­£å¸¸çµäº */
+
+/*
+ *  ã¡ã¤ã³ã¨ã©ã¼ã³ã¼ã
+ */
+#define E_SYS		(-5)		/* ã·ã¹ãã ã¨ã©ã¼ */
+#define E_NOSPT		(-9)		/* æªãµãã¼ãæ©è½ */
+#define E_RSFN		(-10)		/* äºç´æ©è½ã³ã¼ã */
+#define E_RSATR		(-11)		/* äºç´å±æ§ */
+#define E_PAR		(-17)		/* ãã©ã¡ã¼ã¿ã¨ã©ã¼ */
+#define E_ID		(-18)		/* ä¸æ­£IDçªå· */
+#define E_CTX		(-25)		/* ã³ã³ãã­ã¹ãã¨ã©ã¼ */
+#define E_MACV		(-26)		/* ã¡ã¢ãªã¢ã¯ã»ã¹éå */
+#define E_OACV		(-27)		/* ãªãã¸ã§ã¯ãã¢ã¯ã»ã¹éå */
+#define E_ILUSE		(-28)		/* ãµã¼ãã¹ã³ã¼ã«ä¸æ­£ä½¿ç¨ */
+#define E_NOMEM		(-33)		/* ã¡ã¢ãªä¸è¶³ */
+#define E_NOID		(-34)		/* IDçªå·ä¸è¶³ */
+#define E_NORES		(-35)		/* è³æºä¸è¶³ */
+#define E_OBJ		(-41)		/* ãªãã¸ã§ã¯ãç¶æ
+ã¨ã©ã¼ */
+#define E_NOEXS		(-42)		/* ãªãã¸ã§ã¯ãæªçæ */
+#define E_QOVR		(-43)		/* ã­ã¥ã¼ã¤ã³ã°ãªã¼ãã¼ãã­ã¼ */
+#define E_RLWAI		(-49)		/* å¾
+ã¡ç¶æ
+ã®å¼·å¶è§£é¤ */
+#define E_TMOUT		(-50)		/* ãã¼ãªã³ã°å¤±æã¾ãã¯ã¿ã¤ã ã¢ã¦ã */
+#define E_DLT		(-51)		/* å¾
+ã¡ãªãã¸ã§ã¯ãã®åé¤ */
+#define E_CLS		(-52)		/* å¾
+ã¡ãªãã¸ã§ã¯ãã®ç¶æ
+å¤å */
+#define E_RASTER	(-53)		/* ã¿ã¹ã¯ã®çµäºè¦æ± */
+#define E_WBLK		(-57)		/* ãã³ãã­ãã­ã³ã°åä»ã */
+#define E_BOVR		(-58)		/* ãããã¡ãªã¼ãã¼ãã­ã¼ */
+#define E_COMM		(-65)		/* éä¿¡ã¨ã©ã¼ */
+
+/*
+ *  ãªãã¸ã§ã¯ãå±æ§
+ */
+#define TA_NULL		UINT_C(0)	/* ãªãã¸ã§ã¯ãå±æ§ãæå®ããªã */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãæå®
+ */
+#define TMO_POL		UINT_C(0)			/* ãã¼ãªã³ã° */
+#define TMO_FEVR	(UINT32_MAX)		/* æ°¸ä¹
+å¾
+ã¡ */
+#define TMO_NBLK	(UINT32_MAX - 1)	/* ãã³ãã­ãã­ã³ã° */
+
+/*
+ *  ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³
+ */
+#define TACP_KERNEL	UINT_C(0)		/* ã«ã¼ãã«ãã¡ã¤ã³ã ãã«ã¢ã¯ã»ã¹ãè¨±å¯ */
+#define TACP_SHARED	(~UINT_C(0))	/* ãã¹ã¦ã®ãã¡ã¤ã³ããã¢ã¯ã»ã¹ãè¨±å¯ */
+
+/*
+ *  åã«é¢ããæ
+å ±ãåãåºãããã®ãã¯ã­
+ *
+ *  ä»¥ä¸ã®ALIGN_TYPEã®å®ç¾©ã¯ï¼ã¢ã©ã¤ã³ã¡ã³ãã®åä½ã2ã®å·¾ä¹ã§ãããã¨ã
+ *  ä»®å®ãã¦ããï¼
+ */
+#ifndef offsetof
+#define	offsetof(structure, field) \
+		((uintptr_t)(((char *) &(((structure *) 0)->field)) - ((char *) 0)))
+#endif /* offsetof */
+
+#ifndef alignof
+#define alignof(type)	offsetof(struct { char field1; type field2; }, field2)
+#endif /* alignof */
+
+#ifndef ALIGN_TYPE				/* ã¢ã©ã¤ã³ã¡ã³ãã®ãã§ãã¯ */
+#define ALIGN_TYPE(addr, type) \
+						((((uintptr_t)(addr)) & (alignof(type) - 1)) == 0U)
+#endif /* ALIGN_TYPE */
+
+/*
+ *  assertãã¯ã­
+ */
+#undef assert
+#ifndef NDEBUG
+#define assert(exp)		((void)((exp) ? 0 : (TOPPERS_assert_fail(#exp, \
+							__FILE__, __LINE__), TOPPERS_assert_abort(), 0)))
+#else /* NDEBUG */
+#define assert(exp)		((void) 0)
+#endif /* NDEBUG */
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ *  ã¨ã©ã¼ã³ã¼ãçæã»åè§£ãã¯ã­
+ *
+ *  ä»¥ä¸ã®ãã¯ã­å®ç¾©ã¯ï¼ç¬¦å·ä»ãæ´æ°ã2ã®è£æ°ã§è¡¨ç¾ããã¦ããï¼å³ã·ãã
+ *  æ¼ç®å­ï¼>>ï¼ãç®è¡ã·ããããããã¨ãä»®å®ãã¦ããï¼ããã§ãªãéçºç°
+ *  å¢ã§ã¯ï¼target_stddef.hã§ãããã®å®ç¾©ãä¸æ¸ãããªããã°ãªããªãï¼
+ *
+ *  MERCDãã¯ã­ã®å®ç¾©ã¯ï¼ã¡ã¤ã³ã¨ã©ã¼ã³ã¼ããè² ã§ãããã¨ãä»®å®ãã¦ããï¼
+ *  ããã§ãªãå ´åï¼2ã¤ã®å®ç¾©ãä¸è´ããªããªãï¼
+ */
+#ifndef ERCD
+#define ERCD(mercd, sercd) \
+				((ER)((((uint_t)(sercd)) << 8) | (((uint_t)(mercd)) & 0xffU)))
+#endif /* ERCD */
+
+#ifndef MERCD
+#ifdef INT8_MAX
+#define MERCD(ercd)		((ER)((int8_t)(ercd)))
+#else /* INT8_MAX */
+#define MERCD(ercd)		((ER)(((uint_t) ercd) | ~0xffU))
+#endif /* INT8_MAX */
+#endif /* MERCD */
+
+#ifndef SERCD
+#define SERCD(ercd)		((ER)((ercd) >> 8))
+#endif /* SERCD */
+
+/*
+ *  ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³çæãã¯ã­
+ */
+#define TACP(domid)		(1U << ((domid) - 1))	/* domidã ãã«ã¢ã¯ã»ã¹ãè¨±å¯ */
+
+/*
+ *  ç¸å¯¾æéï¼RELTIMï¼ã«æå®ã§ããæå¤§å¤ï¼»NGKI0551ï¼½
+ */
+#define TMAX_RELTIM		4000000000U				/* 66å40ç§ã¾ã§æå®å¯ */
+
+#endif /* TOPPERS_T_STDDEF_H */
Index: asp3_gr_sakura/trunk/include/t_stdlib.h
===================================================================
--- asp3_gr_sakura/trunk/include/t_stdlib.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/t_stdlib.h	(revision 317)
@@ -0,0 +1,91 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2006 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		åºæ¬çãªã©ã¤ãã©ãªé¢æ°
+ */
+
+#ifndef TOPPERS_T_STDLIB_H
+#define TOPPERS_T_STDLIB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+
+/*
+ *  ã¨ã©ã¼ã¡ãã»ã¼ã¸æå­åãè¿ãé¢æ°
+ *
+ *  ercdã§æå®ãããã¨ã©ã¼ã³ã¼ãã®ã¡ã¤ã³ã¨ã©ã¼ã³ã¼ãã®åç§°ï¼E_PARï¼
+ *  E_OBJãªã©ï¼ã®æå­åãè¿ãé¢æ°ï¼
+ */
+extern const char	*itron_strerror(ER ercd) throw();
+
+/*
+ *  ã¨ã©ã¼ã¡ãã»ã¼ã¸ã®ã­ã°åºå
+ *
+ *  ãµã¼ãã¹ã³ã¼ã«ãã¨ã©ã¼ãè¿ããå ´åã«ï¼ãã®ãã¡ã¤ã«åï¼è¡çªå·ï¼ã¡ã¤
+ *  ã³ã¨ã©ã¼ã³ã¼ãç­ãè¡¨ç¤ºããããã®é¢æ°ï¼
+ */
+extern void		t_perror(uint_t prio, const char *file, int_t line,
+									const char *expr, ER ercd) throw();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_T_STDLIB_H */
Index: asp3_gr_sakura/trunk/include/t_syslog.h
===================================================================
--- asp3_gr_sakura/trunk/include/t_syslog.h	(revision 317)
+++ asp3_gr_sakura/trunk/include/t_syslog.h	(revision 317)
@@ -0,0 +1,377 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°åºåãè¡ãããã®å®ç¾©
+ *
+ *  ã·ã¹ãã ã­ã°ãµã¼ãã¹ã¯ï¼ã·ã¹ãã ã®ã­ã°æ
+å ±ãåºåããããã®ãµã¼ãã¹
+ *  ã§ããï¼ã«ã¼ãã«ããã®ã­ã°æ
+å ±ã®åºåã«ãç¨ããããï¼å
+é¨ã§å¾
+ã¡ç¶æ
+
+ *  ã«ã¯ãããã¨ã¯ãªãï¼
+ *
+ *  ã­ã°æ
+å ±ã¯ï¼ã«ã¼ãã«å
+ã®ã­ã°ãããã¡ã«æ¸ãè¾¼ããï¼ä½ã¬ãã«ã®æå­åº
+ *  åé¢æ°ãç¨ãã¦åºåããï¼ã©ã¡ããä½¿ããã¯ï¼æ¡å¼µãµã¼ãã¹ã³ã¼ã«ã§åã
+ *  æãããã¨ãã§ããï¼
+ *
+ *  ã­ã°ãããã¡é åããªã¼ããã­ã¼ããå ´åã«ã¯ï¼å¤ãã­ã°æ
+å ±ãæ¶ãã¦ä¸
+ *  æ¸ãããï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ãããã¨ã§ï¼ãã¯ã­å®ç¾©ä»¥å¤ã®è¨è¿°ã
+ *  é¤ããã¨ãã§ããï¼
+ */
+
+#ifndef TOPPERS_T_SYSLOG_H
+#define TOPPERS_T_SYSLOG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+
+/*
+ *  ã­ã°æ
+å ±ã®ç¨®å¥ã®å®ç¾©
+ */
+#define LOG_TYPE_COMMENT	UINT_C(0x01)	/* ã³ã¡ã³ã */
+#define LOG_TYPE_ASSERT		UINT_C(0x02)	/* ã¢ãµã¼ã·ã§ã³ã®å¤±æ */
+
+#define LOG_TYPE_INH		UINT_C(0x11)	/* å²è¾¼ã¿ãã³ãã© */
+#define LOG_TYPE_ISR		UINT_C(0x12)	/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ */
+#define LOG_TYPE_CYC		UINT_C(0x13)	/* å¨æãã³ãã© */
+#define LOG_TYPE_ALM		UINT_C(0x14)	/* ã¢ã©ã¼ã ãã³ãã© */
+#define LOG_TYPE_OVR		UINT_C(0x15)	/* ãªã¼ãã©ã³ãã³ãã© */
+#define LOG_TYPE_EXC		UINT_C(0x16)	/* CPUä¾å¤ãã³ãã© */
+#define LOG_TYPE_TSKSTAT	UINT_C(0x21)	/* ã¿ã¹ã¯ç¶æ
+å¤å */
+#define LOG_TYPE_DSP		UINT_C(0x31)	/* ãã£ã¹ãããã£ */
+#define LOG_TYPE_SVC		UINT_C(0x41)	/* ãµã¼ãã¹ã³ã¼ã« */
+
+#define LOG_ENTER			UINT_C(0x00)	/* å
+¥å£ï¼éå§ */
+#define LOG_LEAVE			UINT_C(0x80)	/* åºå£ï¼çµäº */
+
+/*
+ *  ã­ã°æ
+å ±ã®éè¦åº¦ã®å®ç¾©
+ */
+#define LOG_EMERG			UINT_C(0)		/* ã·ã£ãããã¦ã³ã«å¤ããã¨ã©ã¼ */
+#define LOG_ALERT			UINT_C(1)
+#define LOG_CRIT			UINT_C(2)
+#define LOG_ERROR			UINT_C(3)		/* ã·ã¹ãã ã¨ã©ã¼ */
+#define LOG_WARNING			UINT_C(4)		/* è­¦åã¡ãã»ã¼ã¸ */
+#define LOG_NOTICE			UINT_C(5)
+#define LOG_INFO			UINT_C(6)
+#define LOG_DEBUG			UINT_C(7)		/* ãããã°ç¨ã¡ãã»ã¼ã¸ */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã­ã°æ
+å ±ã®ãã¼ã¿æ§é 
+ */
+
+#ifndef LOGTIM
+#define LOGTIM		HRTCNT			/* ã­ã°æå»ã®ãã¼ã¿å */
+#endif /* LOGTIM */
+
+#define TNUM_LOGPAR		6			/* ã­ã°ãã©ã¡ã¼ã¿ã®æ° */
+
+#ifndef LOGPAR
+#define LOGPAR		intptr_t		/* ã­ã°ãã©ã¡ã¼ã¿ã®ãã¼ã¿å */
+#define ULOGPAR		uintptr_t
+#endif /* LOGPAR */
+
+typedef struct {
+	uint_t	logtype;				/* ã­ã°æ
+å ±ã®ç¨®å¥ */
+	LOGTIM	logtim;					/* ã­ã°æå» */
+	LOGPAR	logpar[TNUM_LOGPAR];	/* ã­ã°ãã©ã¡ã¼ã¿ */
+} SYSLOG;
+
+/*
+ *  ã­ã°æ
+å ±ã®éè¦åº¦ã®ãããããããä½ãããã®ãã¯ã­
+ */
+#define LOG_MASK(prio)		(1U << (prio))
+#define LOG_UPTO(prio)		((1U << ((prio) + 1)) - 1)
+
+/*
+ *  ãã±ããå½¢å¼ã®å®ç¾©
+ */
+typedef struct t_syslog_rlog {
+	uint_t	count;		/* ã­ã°ãããã¡ä¸­ã®ã­ã°ã®æ° */
+	uint_t	lost;		/* å¤±ãããã­ã°ã®æ° */
+	uint_t	logmask;	/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+	uint_t	lowmask;	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+} T_SYSLOG_RLOG;
+
+#ifndef TOPPERS_OMIT_SYSLOG
+
+/*
+ *  ã­ã°æ
+å ±ãåºåããããã®ã©ã¤ãã©ãªé¢æ°
+ *
+ *  TECSã§è¨è¿°ãããã·ã¹ãã ã­ã°æ©è½ãç´æ¥å¼ã³åºãï¼
+ */
+
+extern ER	tSysLog_eSysLog_write(uint_t prio, const SYSLOG *p_syslog) throw();
+
+Inline void
+_syslog_0(uint_t prio, uint_t type)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_1(uint_t prio, uint_t type, LOGPAR arg1)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_2(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	logbuf.logpar[1] = arg2;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_3(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2, LOGPAR arg3)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	logbuf.logpar[1] = arg2;
+	logbuf.logpar[2] = arg3;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_4(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+											LOGPAR arg3, LOGPAR arg4)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	logbuf.logpar[1] = arg2;
+	logbuf.logpar[2] = arg3;
+	logbuf.logpar[3] = arg4;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_5(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+								LOGPAR arg3, LOGPAR arg4, LOGPAR arg5)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	logbuf.logpar[1] = arg2;
+	logbuf.logpar[2] = arg3;
+	logbuf.logpar[3] = arg4;
+	logbuf.logpar[4] = arg5;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+Inline void
+_syslog_6(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+					LOGPAR arg3, LOGPAR arg4, LOGPAR arg5, LOGPAR arg6)
+{
+	SYSLOG	logbuf;
+
+	logbuf.logtype = type;
+	logbuf.logpar[0] = arg1;
+	logbuf.logpar[1] = arg2;
+	logbuf.logpar[2] = arg3;
+	logbuf.logpar[3] = arg4;
+	logbuf.logpar[4] = arg5;
+	logbuf.logpar[5] = arg6;
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+/*
+ *  ã­ã°æ
+å ±ï¼ã³ã¡ã³ãï¼ãåºåããããã®ã©ã¤ãã©ãªé¢æ°ï¼vasyslog.cï¼
+ */
+extern void	syslog(uint_t prio, const char *format, ...) throw();
+
+#else /* TOPPERS_OMIT_SYSLOG */
+
+/*
+ *  ã·ã¹ãã ã­ã°åºåãææ­¢ããå ´å
+ */
+
+Inline void
+_syslog_0(uint_t prio, uint_t type)
+{
+}
+
+Inline void
+_syslog_1(uint_t prio, uint_t type, LOGPAR arg1)
+{
+}
+
+Inline void
+_syslog_2(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2)
+{
+}
+
+Inline void
+_syslog_3(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2, LOGPAR arg3)
+{
+}
+
+Inline void
+_syslog_4(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+											LOGPAR arg3, LOGPAR arg4)
+{
+}
+
+Inline void
+_syslog_5(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+								LOGPAR arg3, LOGPAR arg4, LOGPAR arg5)
+{
+}
+
+Inline void
+_syslog_6(uint_t prio, uint_t type, LOGPAR arg1, LOGPAR arg2,
+					LOGPAR arg3, LOGPAR arg4, LOGPAR arg5, LOGPAR arg6)
+{
+}
+
+Inline void
+syslog(uint_t prio, const char *format, ...)
+{
+}
+
+#endif /* TOPPERS_OMIT_SYSLOG */
+
+/*
+ *  ã­ã°æ
+å ±ï¼ã³ã¡ã³ãï¼ãåºåããããã®ãã¯ã­
+ *
+ *  formatããã³å¾ç¶ã®å¼æ°ããä½æããã¡ãã»ã¼ã¸ãï¼éå¤§åº¦prioã§ã­ã°æ
+
+ *  å ±ã¨ãã¦åºåããããã®ãã¯ã­ï¼arg1ï½argnã¯LOGPARåã«ã­ã£ã¹ãããã
+ *  ãï¼LOGPARåã«åå¤æã§ããä»»æã®åã§ããï¼
+ */
+
+#define syslog_0(prio, format) \
+				_syslog_1(prio, LOG_TYPE_COMMENT, (LOGPAR)(format))
+
+#define syslog_1(prio, format, arg1) \
+				_syslog_2(prio, LOG_TYPE_COMMENT, (LOGPAR)(format), \
+														(LOGPAR)(arg1))
+
+#define syslog_2(prio, format, arg1, arg2) \
+				_syslog_3(prio, LOG_TYPE_COMMENT, (LOGPAR)(format), \
+										(LOGPAR)(arg1), (LOGPAR)(arg2))
+
+#define syslog_3(prio, format, arg1, arg2, arg3) \
+				_syslog_4(prio, LOG_TYPE_COMMENT, (LOGPAR)(format), \
+						(LOGPAR)(arg1), (LOGPAR)(arg2), (LOGPAR)(arg3))
+
+#define syslog_4(prio, format, arg1, arg2, arg3, arg4) \
+				_syslog_5(prio, LOG_TYPE_COMMENT, (LOGPAR)(format), \
+						(LOGPAR)(arg1), (LOGPAR)(arg2), (LOGPAR)(arg3), \
+														(LOGPAR)(arg4))
+
+#define syslog_5(prio, format, arg1, arg2, arg3, arg4, arg5) \
+				_syslog_6(prio, LOG_TYPE_COMMENT, (LOGPAR)(format), \
+						(LOGPAR)(arg1), (LOGPAR)(arg2), (LOGPAR)(arg3), \
+										(LOGPAR)(arg4), (LOGPAR)(arg5))
+
+/*
+ *  ã­ã°æ
+å ±ï¼ã¢ãµã¼ã·ã§ã³ã®å¤±æï¼ãåºåããããã®ãã¯ã­
+ */
+#ifndef TOPPERS_assert_fail
+#define TOPPERS_assert_fail(exp, file, line) \
+				_syslog_3(LOG_EMERG, LOG_TYPE_ASSERT, (LOGPAR)(file), \
+										(LOGPAR)(line), (LOGPAR)(exp))
+#endif /* TOPPERS_assert_fail */
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_T_SYSLOG_H */
Index: asp3_gr_sakura/trunk/kernel/Makefile.kernel
===================================================================
--- asp3_gr_sakura/trunk/kernel/Makefile.kernel	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/Makefile.kernel	(revision 317)
@@ -0,0 +1,160 @@
+#
+#  TOPPERS/ASP Kernel
+#      Toyohashi Open Platform for Embedded Real-Time Systems/
+#      Advanced Standard Profile Kernel
+# 
+#  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: Makefile.kernel 554 2016-01-17 13:21:59Z ertl-hiro $
+# 
+
+#
+#		ã«ã¼ãã«ã®ãã¡ã¤ã«æ§æã®å®ç¾©
+#
+
+#
+#  1ã¤ã®ã½ã¼ã¹ãã¡ã¤ã«ããè¤æ°ã®ãªãã¸ã§ã¯ããã¡ã¤ã«ãçæããããã«ä½
+#  æãããã½ã¼ã¹ãã¡ã¤ã«ã®ãªã¹ã
+#
+KERNEL_FCSRCS = startup.c task.c taskhook.c wait.c time_event.c \
+				task_manage.c task_refer.c task_sync.c task_term.c \
+				semaphore.c eventflag.c dataqueue.c pridataq.c mutex.c \
+				mempfix.c time_manage.c cyclic.c alarm.c overrun.c \
+				sys_manage.c interrupt.c exception.c
+
+#
+#  åã½ã¼ã¹ãã¡ã¤ã«ããçæããããªãã¸ã§ã¯ããã¡ã¤ã«ã®ãªã¹ã
+#
+startup = sta_ker.o ext_ker.o kermem.o
+
+task = tskini.o tsksched.o tskrun.o tsknrun.o \
+		tskdmt.o tskact.o tskpri.o tskrot.o tskterm.o
+
+taskhook = mtxhook.o
+
+wait = waimake.o waicmp.o waitmo.o waitmook.o \
+		wobjwai.o wobjwaitmo.o iniwque.o
+
+time_event = tmeini.o tmeup.o tmedown.o tmecur.o tmeset.o \
+		tmereg.o tmeenq.o tmedeq.o tmechk.o tmeltim.o sigtim.o
+
+task_manage = acre_tsk.o del_tsk.o act_tsk.o can_act.o get_tst.o \
+		chg_pri.o get_pri.o get_inf.o
+
+task_refer = ref_tsk.o
+
+task_sync = slp_tsk.o tslp_tsk.o wup_tsk.o can_wup.o \
+		rel_wai.o sus_tsk.o rsm_tsk.o dly_tsk.o
+
+task_term = ext_tsk.o ras_ter.o ena_ter.o dis_ter.o sns_ter.o ter_tsk.o
+
+semaphore = semini.o acre_sem.o del_sem.o sig_sem.o \
+		wai_sem.o pol_sem.o twai_sem.o ini_sem.o ref_sem.o
+
+eventflag = flgini.o flgcnd.o acre_flg.o del_flg.o set_flg.o clr_flg.o \
+		wai_flg.o pol_flg.o twai_flg.o ini_flg.o ref_flg.o
+
+dataqueue = dtqini.o dtqenq.o dtqfenq.o dtqdeq.o dtqsnd.o dtqfsnd.o dtqrcv.o \
+		acre_dtq.o del_dtq.o snd_dtq.o psnd_dtq.o tsnd_dtq.o fsnd_dtq.o \
+		rcv_dtq.o prcv_dtq.o trcv_dtq.o ini_dtq.o ref_dtq.o
+
+pridataq = pdqini.o pdqenq.o pdqdeq.o pdqsnd.o pdqrcv.o \
+		acre_pdq.o del_pdq.o snd_pdq.o psnd_pdq.o tsnd_pdq.o \
+		rcv_pdq.o prcv_pdq.o trcv_pdq.o ini_pdq.o ref_pdq.o
+
+mutex = mtxini.o mtxchk.o mtxscan.o mtxdrop.o mtxacq.o mtxrel.o mtxrela.o \
+		acre_mtx.o del_mtx.o loc_mtx.o ploc_mtx.o tloc_mtx.o \
+		unl_mtx.o ini_mtx.o ref_mtx.o
+
+mempfix = mpfini.o mpfget.o acre_mpf.o del_mpf.o get_mpf.o \
+		pget_mpf.o tget_mpf.o rel_mpf.o ini_mpf.o ref_mpf.o
+
+time_manage = set_tim.o get_tim.o adj_tim.o fch_hrt.o chknfy.o nfyhdr.o
+
+cyclic = cycini.o acre_cyc.o del_cyc.o sta_cyc.o stp_cyc.o ref_cyc.o cyccal.o
+
+alarm = almini.o acre_alm.o del_alm.o sta_alm.o stp_alm.o ref_alm.o almcal.o
+
+overrun = ovrini.o ovrsta.o ovrstp.o sta_ovr.o stp_ovr.o ref_ovr.o ovrcal.o
+
+sys_manage = rot_rdq.o get_tid.o get_lod.o get_nth.o \
+		loc_cpu.o unl_cpu.o dis_dsp.o ena_dsp.o \
+		sns_ctx.o sns_loc.o sns_dsp.o sns_dpn.o sns_ker.o
+
+interrupt = isrini.o isrcal.o acre_isr.o del_isr.o intini.o \
+		dis_int.o ena_int.o clr_int.o ras_int.o prb_int.o chg_ipm.o get_ipm.o
+
+exception = excini.o xsns_dpn.o
+
+#
+#  çæããããªãã¸ã§ã¯ããã¡ã¤ã«ã®ä¾å­é¢ä¿ã®å®ç¾©
+#
+$(startup) $(startup:.o=.s): startup.c
+$(task) $(task:.o=.s): task.c
+$(taskhook) $(taskhook:.o=.s): taskhook.c
+$(wait) $(wait:.o=.s): wait.c
+$(time_event) $(time_event:.o=.s): time_event.c
+$(task_manage) $(task_manage:.o=.s): task_manage.c
+$(task_refer) $(task_refer:.o=.s): task_refer.c
+$(task_sync) $(task_sync:.o=.s): task_sync.c
+$(task_term) $(task_term:.o=.s): task_term.c
+$(semaphore) $(semaphore:.o=.s): semaphore.c
+$(eventflag) $(eventflag:.o=.s): eventflag.c
+$(dataqueue) $(dataqueue:.o=.s): dataqueue.c
+$(pridataq) $(pridataq:.o=.s): pridataq.c
+$(mutex) $(mutex:.o=.s): mutex.c
+$(mempfix) $(mempfix:.o=.s): mempfix.c
+$(time_manage) $(time_manage:.o=.s): time_manage.c
+$(cyclic) $(cyclic:.o=.s): cyclic.c
+$(alarm) $(alarm:.o=.s): alarm.c
+$(overrun) $(overrun:.o=.s): overrun.c
+$(sys_manage) $(sys_manage:.o=.s): sys_manage.c
+$(interrupt) $(interrupt:.o=.s): interrupt.c
+$(exception) $(exception:.o=.s): exception.c
Index: asp3_gr_sakura/trunk/kernel/alarm.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/alarm.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/alarm.c	(revision 317)
@@ -0,0 +1,419 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¢ã©ã¼ã éç¥æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "alarm.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ALM_ENTER
+#define LOG_ALM_ENTER(p_almcb)
+#endif /* LOG_ALM_ENTER */
+
+#ifndef LOG_ALM_LEAVE
+#define LOG_ALM_LEAVE(p_almcb)
+#endif /* LOG_ALM_LEAVE */
+
+#ifndef LOG_ACRE_ALM_ENTER
+#define LOG_ACRE_ALM_ENTER(pk_calm)
+#endif /* LOG_ACRE_ALM_ENTER */
+
+#ifndef LOG_ACRE_ALM_LEAVE
+#define LOG_ACRE_ALM_LEAVE(ercd)
+#endif /* LOG_ACRE_ALM_LEAVE */
+
+#ifndef LOG_DEL_ALM_ENTER
+#define LOG_DEL_ALM_ENTER(almid)
+#endif /* LOG_DEL_ALM_ENTER */
+
+#ifndef LOG_DEL_ALM_LEAVE
+#define LOG_DEL_ALM_LEAVE(ercd)
+#endif /* LOG_DEL_ALM_LEAVE */
+
+#ifndef LOG_STA_ALM_ENTER
+#define LOG_STA_ALM_ENTER(almid, almtim)
+#endif /* LOG_STA_ALM_ENTER */
+
+#ifndef LOG_STA_ALM_LEAVE
+#define LOG_STA_ALM_LEAVE(ercd)
+#endif /* LOG_STA_ALM_LEAVE */
+
+#ifndef LOG_STP_ALM_ENTER
+#define LOG_STP_ALM_ENTER(almid)
+#endif /* LOG_STP_ALM_ENTER */
+
+#ifndef LOG_STP_ALM_LEAVE
+#define LOG_STP_ALM_LEAVE(ercd)
+#endif /* LOG_STP_ALM_LEAVE */
+
+#ifndef LOG_REF_ALM_ENTER
+#define LOG_REF_ALM_ENTER(almid, pk_ralm)
+#endif /* LOG_REF_ALM_ENTER */
+
+#ifndef LOG_REF_ALM_LEAVE
+#define LOG_REF_ALM_LEAVE(ercd, pk_ralm)
+#endif /* LOG_REF_ALM_LEAVE */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®æ°
+ */
+#define tnum_alm	((uint_t)(tmax_almid - TMIN_ALMID + 1))
+#define tnum_salm	((uint_t)(tmax_salmid - TMIN_ALMID + 1))
+
+/*
+ *  ã¢ã©ã¼ã éç¥IDããã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_ALM(almid)	((uint_t)((almid) - TMIN_ALMID))
+#define get_almcb(almid)	(&(almcb_table[INDEX_ALM(almid)]))
+
+#ifdef TOPPERS_almini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ã®ãªã¹ã
+ *
+ *  ã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ã®å
+é ­ã«ã¯ã­ã¥ã¼ã«ã¤ãªãããã®é åããªãã
+ *  ãï¼ã¿ã¤ã ã¤ãã³ããã­ãã¯ï¼tmevtbï¼ã®é åãç¨ããï¼
+ */
+QUEUE	free_almcb;
+
+/*
+ *  ã¢ã©ã¼ã éç¥æ©è½ã®åæå
+ */
+void
+initialize_alarm(void)
+{
+	uint_t	i, j;
+	ALMCB	*p_almcb;
+	ALMINIB	*p_alminib;
+
+	for (i = 0; i < tnum_salm; i++) {
+		p_almcb = &(almcb_table[i]);
+		p_almcb->p_alminib = &(alminib_table[i]);
+		p_almcb->almsta = false;
+		p_almcb->tmevtb.callback = (CBACK) call_alarm;
+		p_almcb->tmevtb.arg = (void *) p_almcb;
+	}
+	queue_initialize(&free_almcb);
+	for (j = 0; i < tnum_alm; i++, j++) {
+		p_almcb = &(almcb_table[i]);
+		p_alminib = &(aalminib_table[j]);
+		p_alminib->almatr = TA_NOEXS;
+		p_almcb->p_alminib = ((const ALMINIB *) p_alminib);
+		p_almcb->tmevtb.callback = (CBACK) call_alarm;
+		p_almcb->tmevtb.arg = (void *) p_almcb;
+		queue_insert_prev(&free_almcb, ((QUEUE *) &(p_almcb->tmevtb)));
+	}
+}
+
+#endif /* TOPPERS_almini */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®çæ
+ */
+#ifdef TOPPERS_acre_alm
+
+ER_UINT
+acre_alm(const T_CALM *pk_calm)
+{
+	ALMCB		*p_almcb;
+	ALMINIB		*p_alminib;
+	ATR			almatr;
+	T_NFYINFO	nfyinfo, *p_nfyinfo;
+	ER			ercd, rercd;
+
+	LOG_ACRE_ALM_ENTER(pk_calm);
+	CHECK_TSKCTX_UNL();
+
+	almatr = pk_calm->almatr;
+	nfyinfo = pk_calm->nfyinfo;
+
+	CHECK_RSATR(almatr, TA_NULL);
+	rercd = check_nfyinfo(&nfyinfo);
+	if (rercd != E_OK) {
+		ercd = rercd;
+		goto error_exit;
+	}
+
+	lock_cpu();
+	if (tnum_alm == 0 || queue_empty(&free_almcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		p_almcb = ((ALMCB *)(((char *) queue_delete_next(&free_almcb))
+												- offsetof(ALMCB, tmevtb)));
+		p_alminib = (ALMINIB *)(p_almcb->p_alminib);
+		p_alminib->almatr = almatr;
+		if (nfyinfo.nfymode == TNFY_HANDLER) {
+			p_alminib->exinf = nfyinfo.nfy.handler.exinf;
+			p_alminib->nfyhdr = (NFYHDR)(nfyinfo.nfy.handler.tmehdr);
+		}
+		else {
+			p_nfyinfo = &aalm_nfyinfo_table[p_alminib - aalminib_table];
+			*p_nfyinfo = nfyinfo;
+			p_alminib->exinf = (intptr_t) p_nfyinfo;
+			p_alminib->nfyhdr = notify_handler;
+		}
+		p_almcb->almsta = false;
+		ercd = ALMID(p_almcb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_ALM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_alm */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åé¤
+ */
+#ifdef TOPPERS_del_alm
+
+ER
+del_alm(ID almid)
+{
+	ALMCB	*p_almcb;
+	ALMINIB	*p_alminib;
+	ER		ercd;
+
+	LOG_DEL_ALM_ENTER(almid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_ALMID(almid));
+	p_almcb = get_almcb(almid);
+
+	lock_cpu();
+	if (p_almcb->p_alminib->almatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (almid <= tmax_salmid) {
+		ercd = E_OBJ;
+	}
+	else {
+		if (p_almcb->almsta) {
+			p_almcb->almsta = false;
+			tmevtb_dequeue(&(p_almcb->tmevtb));
+		}
+
+		p_alminib = (ALMINIB *)(p_almcb->p_alminib);
+		p_alminib->almatr = TA_NOEXS;
+		queue_insert_prev(&free_almcb, ((QUEUE *) &(p_almcb->tmevtb)));
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_ALM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_alm */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½éå§
+ */
+#ifdef TOPPERS_sta_alm
+
+ER
+sta_alm(ID almid, RELTIM almtim)
+{
+	ALMCB	*p_almcb;
+	ER		ercd;
+
+	LOG_STA_ALM_ENTER(almid, almtim);
+	CHECK_UNL();
+	CHECK_ID(VALID_ALMID(almid));
+	CHECK_PAR(VALID_RELTIM(almtim));
+	p_almcb = get_almcb(almid);
+
+	lock_cpu();
+	if (p_almcb->p_alminib->almatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_almcb->almsta) {
+			tmevtb_dequeue(&(p_almcb->tmevtb));
+		}
+		else {
+			p_almcb->almsta = true;
+		}
+		tmevtb_enqueue(&(p_almcb->tmevtb), almtim);
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_STA_ALM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_sta_alm */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½åæ­¢
+ */
+#ifdef TOPPERS_stp_alm
+
+ER
+stp_alm(ID almid)
+{
+	ALMCB	*p_almcb;
+	ER		ercd;
+
+	LOG_STP_ALM_ENTER(almid);
+	CHECK_UNL();
+	CHECK_ID(VALID_ALMID(almid));
+	p_almcb = get_almcb(almid);
+
+	lock_cpu();
+	if (p_almcb->p_alminib->almatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_almcb->almsta) {
+			p_almcb->almsta = false;
+			tmevtb_dequeue(&(p_almcb->tmevtb));
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_STP_ALM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_stp_alm */
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_alm
+
+ER
+ref_alm(ID almid, T_RALM *pk_ralm)
+{
+	ALMCB	*p_almcb;
+	ER		ercd;
+    
+	LOG_REF_ALM_ENTER(almid, pk_ralm);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_ALMID(almid));
+	p_almcb = get_almcb(almid);
+
+	lock_cpu();
+	if (p_almcb->p_alminib->almatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_almcb->almsta) {
+			pk_ralm->almstat = TALM_STA;
+			pk_ralm->lefttim = tmevt_lefttim(&(p_almcb->tmevtb));
+		}
+		else {
+			pk_ralm->almstat = TALM_STP;
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_ALM_LEAVE(ercd, pk_ralm);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_alm */
+
+/*
+ *  ã¢ã©ã¼ã éç¥èµ·åã«ã¼ãã³
+ */
+#ifdef TOPPERS_almcal
+
+void
+call_alarm(ALMCB *p_almcb)
+{
+	/*
+	 *  ã¢ã©ã¼ã éç¥ãåæ­¢ç¶æ
+ã«ããï¼
+	 */
+	p_almcb->almsta = false;
+
+	/*
+	 *  éç¥ãã³ãã©ãï¼CPUã­ãã¯è§£é¤ç¶æ
+ã§å¼ã³åºãï¼
+	 */
+	unlock_cpu();
+
+	LOG_ALM_ENTER(p_almcb);
+	(*(p_almcb->p_alminib->nfyhdr))(p_almcb->p_alminib->exinf);
+	LOG_ALM_LEAVE(p_almcb);
+
+	if (!sense_lock()) {
+		lock_cpu();
+	}
+}
+
+#endif /* TOPPERS_almcal */
Index: asp3_gr_sakura/trunk/kernel/alarm.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/alarm.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/alarm.h	(revision 317)
@@ -0,0 +1,131 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¢ã©ã¼ã éç¥æ©è½
+ */
+
+#ifndef TOPPERS_ALARM_H
+#define TOPPERS_ALARM_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "time_event.h"
+
+/*
+ *  ã¢ã©ã¼ã éç¥åæåãã­ãã¯
+ */
+typedef struct alarm_handler_initialization_block {
+	ATR			almatr;			/* ã¢ã©ã¼ã éç¥å±æ§ */
+	intptr_t	exinf;			/* éç¥ãã³ãã©ã®æ¡å¼µæ
+å ± */
+	NFYHDR		nfyhdr;			/* éç¥ãã³ãã©ã®èµ·åçªå° */
+} ALMINIB;
+
+/*
+ *  ã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯
+ */
+typedef struct alarm_handler_control_block {
+	const ALMINIB *p_alminib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	bool_t		almsta;			/* ã¢ã©ã¼ã éç¥ã®åä½ç¶æ
+ */
+	TMEVTB		tmevtb;			/* ã¿ã¤ã ã¤ãã³ããã­ãã¯ */
+} ALMCB;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_almcb;
+
+/*
+ *  ã¢ã©ã¼ã éç¥IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_almid;
+extern const ID	tmax_salmid;
+
+/*
+ *  ã¢ã©ã¼ã éç¥åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const ALMINIB	alminib_table[];
+extern ALMINIB			aalminib_table[];
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®éç¥æ¹æ³ã®æ ¼ç´ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern T_NFYINFO	aalm_nfyinfo_table[];
+
+/*
+ *  ã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern ALMCB	almcb_table[];
+
+/*
+ *  ã¢ã©ã¼ã éç¥ç®¡çãã­ãã¯ããã¢ã©ã¼ã éç¥IDãåãåºãããã®ãã¯ã­
+ */
+#define	ALMID(p_almcb)	((ID)(((p_almcb) - almcb_table) + TMIN_ALMID))
+
+/*
+ *  ã¢ã©ã¼ã éç¥æ©è½ã®åæå
+ */
+extern void	initialize_alarm(void);
+
+/*
+ *  ã¢ã©ã¼ã éç¥èµ·åã«ã¼ãã³
+ */
+extern void	call_alarm(ALMCB *p_almcb);
+
+#endif /* TOPPERS_ALARM_H */
Index: asp3_gr_sakura/trunk/kernel/alarm.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/alarm.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/alarm.trb	(revision 317)
@@ -0,0 +1,91 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: alarm.trb 588 2016-02-05 12:54:58Z ertl-hiro $
+# 
+
+#
+#		ã¢ã©ã¼ã éç¥æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class AlarmObject < KernelObject
+  def initialize()
+    super("alm", "alarm")
+    @inibList["T_NFYINFO"] = "aalm_nfyinfo_table"
+  end
+
+  def prepare(key, params)
+    # almatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2491ï¼½
+    #ï¼TA_STAä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:almatr] & ~($TA_STA)) != 0
+      error_illegal_id("E_RSATR", params, :almatr, :almid)
+    end
+
+    # éç¥æ
+å ±ã®å¦ç
+    params[:nfyhdr] = generateNotifyHandler(key, params, :almid)
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:almatr]}), (intptr_t)(#{params[:par1]}), " \
+												"#{params[:nfyhdr]}")
+  end
+end
+
+#
+#  ã¢ã©ã¼ã éç¥ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Alarm Notification Functions")
+AlarmObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/allfunc.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/allfunc.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/allfunc.h	(revision 317)
@@ -0,0 +1,293 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¹ã¦ã®é¢æ°ãã³ã³ãã¤ã«ããããã®å®ç¾©
+ */
+
+#ifndef TOPPERS_ALLFUNC_H
+#define TOPPERS_ALLFUNC_H
+
+/* startup.c */
+#define TOPPERS_sta_ker
+#define TOPPERS_ext_ker
+#define TOPPERS_kermem
+
+/* task.c */
+#define TOPPERS_tskini
+#define TOPPERS_tsksched
+#define TOPPERS_tskrun
+#define TOPPERS_tsknrun
+#define TOPPERS_tskdmt
+#define TOPPERS_tskact
+#define TOPPERS_tskpri
+#define TOPPERS_tskrot
+#define TOPPERS_tskterm
+
+/* taskhook.c */
+#define TOPPERS_mtxhook
+
+/* wait.c */
+#define TOPPERS_waimake
+#define TOPPERS_waicmp
+#define TOPPERS_waitmo
+#define TOPPERS_waitmook
+#define TOPPERS_wobjwai
+#define TOPPERS_wobjwaitmo
+#define TOPPERS_iniwque
+
+/* time_event.c */
+#define TOPPERS_tmeini
+#define TOPPERS_tmeup
+#define TOPPERS_tmedown
+#define TOPPERS_tmecur
+#define TOPPERS_tmeset
+#define TOPPERS_tmereg
+#define TOPPERS_tmeenq
+#define TOPPERS_tmedeq
+#define TOPPERS_tmechk
+#define TOPPERS_tmeltim
+#define TOPPERS_sigtim
+
+/* task_manage.c */
+#define TOPPERS_acre_tsk
+#define TOPPERS_del_tsk
+#define TOPPERS_act_tsk
+#define TOPPERS_can_act
+#define TOPPERS_get_tst
+#define TOPPERS_chg_pri
+#define TOPPERS_get_pri
+#define TOPPERS_get_inf
+
+/* task_refer.c */
+#define TOPPERS_ref_tsk
+
+/* task_sync.c */
+#define TOPPERS_slp_tsk
+#define TOPPERS_tslp_tsk
+#define TOPPERS_wup_tsk
+#define TOPPERS_can_wup
+#define TOPPERS_rel_wai
+#define TOPPERS_sus_tsk
+#define TOPPERS_rsm_tsk
+#define TOPPERS_dly_tsk
+
+/* task_term.c */
+#define TOPPERS_ext_tsk
+#define TOPPERS_ras_ter
+#define TOPPERS_dis_ter
+#define TOPPERS_ena_ter
+#define TOPPERS_sns_ter
+#define TOPPERS_ter_tsk
+
+/* semaphore.c */
+#define TOPPERS_semini
+#define TOPPERS_acre_sem
+#define TOPPERS_del_sem
+#define TOPPERS_sig_sem
+#define TOPPERS_wai_sem
+#define TOPPERS_pol_sem
+#define TOPPERS_twai_sem
+#define TOPPERS_ini_sem
+#define TOPPERS_ref_sem
+
+/* eventflag.c */
+#define TOPPERS_flgini
+#define TOPPERS_flgcnd
+#define TOPPERS_acre_flg
+#define TOPPERS_del_flg
+#define TOPPERS_set_flg
+#define TOPPERS_clr_flg
+#define TOPPERS_wai_flg
+#define TOPPERS_pol_flg
+#define TOPPERS_twai_flg
+#define TOPPERS_ini_flg
+#define TOPPERS_ref_flg
+
+/* dataqueue.c */
+#define TOPPERS_dtqini
+#define TOPPERS_dtqenq
+#define TOPPERS_dtqfenq
+#define TOPPERS_dtqdeq
+#define TOPPERS_dtqsnd
+#define TOPPERS_dtqfsnd
+#define TOPPERS_dtqrcv
+#define TOPPERS_acre_dtq
+#define TOPPERS_del_dtq
+#define TOPPERS_snd_dtq
+#define TOPPERS_psnd_dtq
+#define TOPPERS_tsnd_dtq
+#define TOPPERS_fsnd_dtq
+#define TOPPERS_rcv_dtq
+#define TOPPERS_prcv_dtq
+#define TOPPERS_trcv_dtq
+#define TOPPERS_ini_dtq
+#define TOPPERS_ref_dtq
+
+/* pridataq.c */
+#define TOPPERS_pdqini
+#define TOPPERS_pdqenq
+#define TOPPERS_pdqdeq
+#define TOPPERS_pdqsnd
+#define TOPPERS_pdqrcv
+#define TOPPERS_acre_pdq
+#define TOPPERS_del_pdq
+#define TOPPERS_snd_pdq
+#define TOPPERS_psnd_pdq
+#define TOPPERS_tsnd_pdq
+#define TOPPERS_rcv_pdq
+#define TOPPERS_prcv_pdq
+#define TOPPERS_trcv_pdq
+#define TOPPERS_ini_pdq
+#define TOPPERS_ref_pdq
+
+/* mutex.c */
+#define TOPPERS_mtxini
+#define TOPPERS_mtxchk
+#define TOPPERS_mtxscan
+#define TOPPERS_mtxdrop
+#define TOPPERS_mtxacq
+#define TOPPERS_mtxrel
+#define TOPPERS_mtxrela
+#define TOPPERS_acre_mtx
+#define TOPPERS_del_mtx
+#define TOPPERS_loc_mtx
+#define TOPPERS_ploc_mtx
+#define TOPPERS_tloc_mtx
+#define TOPPERS_unl_mtx
+#define TOPPERS_ini_mtx
+#define TOPPERS_ref_mtx
+
+/* mempfix.c */
+#define TOPPERS_mpfini
+#define TOPPERS_mpfget
+#define TOPPERS_acre_mpf
+#define TOPPERS_del_mpf
+#define TOPPERS_get_mpf
+#define TOPPERS_pget_mpf
+#define TOPPERS_tget_mpf
+#define TOPPERS_rel_mpf
+#define TOPPERS_ini_mpf
+#define TOPPERS_ref_mpf
+
+/* time_manage.c */
+#define TOPPERS_set_tim
+#define TOPPERS_get_tim
+#define TOPPERS_adj_tim
+#define TOPPERS_fch_hrt
+#define TOPPERS_chknfy
+#define TOPPERS_nfyhdr
+
+/* cyclic.c */
+#define TOPPERS_cycini
+#define TOPPERS_acre_cyc
+#define TOPPERS_del_cyc
+#define TOPPERS_sta_cyc
+#define TOPPERS_stp_cyc
+#define TOPPERS_ref_cyc
+#define TOPPERS_cyccal
+
+/* alarm.c */
+#define TOPPERS_almini
+#define TOPPERS_acre_alm
+#define TOPPERS_del_alm
+#define TOPPERS_sta_alm
+#define TOPPERS_stp_alm
+#define TOPPERS_ref_alm
+#define TOPPERS_almcal
+
+/* overrun.c */
+#define TOPPERS_ovrini
+#define TOPPERS_ovrsta
+#define TOPPERS_ovrstp
+#define TOPPERS_sta_ovr
+#define TOPPERS_stp_ovr
+#define TOPPERS_ref_ovr
+#define TOPPERS_ovrcal
+
+/* sys_manage.c */
+#define TOPPERS_rot_rdq
+#define TOPPERS_get_tid
+#define TOPPERS_get_lod
+#define TOPPERS_get_nth
+#define TOPPERS_loc_cpu
+#define TOPPERS_unl_cpu
+#define TOPPERS_dis_dsp
+#define TOPPERS_ena_dsp
+#define TOPPERS_sns_ctx
+#define TOPPERS_sns_loc
+#define TOPPERS_sns_dsp
+#define TOPPERS_sns_dpn
+#define TOPPERS_sns_ker
+
+/* interrupt.c */
+#define TOPPERS_isrini
+#define TOPPERS_isrcal
+#define TOPPERS_acre_isr
+#define TOPPERS_del_isr
+#define TOPPERS_intini
+#define TOPPERS_dis_int
+#define TOPPERS_ena_int
+#define TOPPERS_clr_int
+#define TOPPERS_ras_int
+#define TOPPERS_prb_int
+#define TOPPERS_chg_ipm
+#define TOPPERS_get_ipm
+
+/* exception.c */
+#define TOPPERS_excini
+#define TOPPERS_xsns_dpn
+
+#endif /* TOPPERS_ALLFUNC_H */
Index: asp3_gr_sakura/trunk/kernel/check.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/check.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/check.h	(revision 317)
@@ -0,0 +1,279 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¨ã©ã¼ãã§ãã¯ç¨ãã¯ã­
+ */
+
+#ifndef TOPPERS_CHECK_H
+#define TOPPERS_CHECK_H
+
+#include "kernel_impl.h"
+
+/*
+ *  ãªãã¸ã§ã¯ãIDã®ç¯å²ã®å¤å®
+ */
+#define VALID_TSKID(tskid)	(TMIN_TSKID <= (tskid) && (tskid) <= tmax_tskid)
+#define VALID_SEMID(semid)	(TMIN_SEMID <= (semid) && (semid) <= tmax_semid)
+#define VALID_FLGID(flgid)	(TMIN_FLGID <= (flgid) && (flgid) <= tmax_flgid)
+#define VALID_DTQID(dtqid)	(TMIN_DTQID <= (dtqid) && (dtqid) <= tmax_dtqid)
+#define VALID_PDQID(pdqid)	(TMIN_PDQID <= (pdqid) && (pdqid) <= tmax_pdqid)
+#define VALID_MTXID(mtxid)	(TMIN_MTXID <= (mtxid) && (mtxid) <= tmax_mtxid)
+#define VALID_MPFID(mpfid)	(TMIN_MPFID <= (mpfid) && (mpfid) <= tmax_mpfid)
+#define VALID_CYCID(cycid)	(TMIN_CYCID <= (cycid) && (cycid) <= tmax_cycid)
+#define VALID_ALMID(almid)	(TMIN_ALMID <= (almid) && (almid) <= tmax_almid)
+#define VALID_ISRID(isrid)	(TMIN_ISRID <= (isrid) && (isrid) <= tmax_isrid)
+
+/*
+ *  ãªãã¸ã§ã¯ãçªå·ã®ç¯å²ã®å¤å®
+ */
+#ifndef VALID_INTNO_DISINT
+#define VALID_INTNO_DISINT(intno)    VALID_INTNO(intno)
+#endif /* VALID_INTNO_DISINT */
+
+#ifndef VALID_INTNO_CREISR
+#define VALID_INTNO_CREISR(intno)    VALID_INTNO(intno)
+#endif /* VALID_INTNO_CREISR */
+
+/*
+ *  åªå
+åº¦ã®ç¯å²ã®å¤å®
+ */
+#define VALID_TPRI(tpri)	(TMIN_TPRI <= (tpri) && (tpri) <= TMAX_TPRI)
+
+#define VALID_DPRI(dpri)	(TMIN_DPRI <= (dpri) && (dpri) <= TMAX_DPRI)
+
+#define VALID_ISRPRI(isrpri) \
+				(TMIN_ISRPRI <= (isrpri) && (isrpri) <= TMAX_ISRPRI)
+
+#ifndef VALID_INTPRI_CHGIPM
+#define VALID_INTPRI_CHGIPM(intpri) \
+				(TMIN_INTPRI <= (intpri) && (intpri) <= TIPM_ENAALL)
+#endif /* VALID_INTPRI_CHGIPM */
+
+/*
+ *  ç¸å¯¾æéã®ç¯å²ã®å¤å®
+ */
+#define VALID_RELTIM(reltim)	((reltim) <= TMAX_RELTIM)
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãæå®å¤ã®ç¯å²ã®å¤å®
+ */
+#define VALID_TMOUT(tmout)	((tmout) <= TMAX_RELTIM || (tmout) == TMO_FEVR \
+													|| (tmout) == TMO_POL)
+
+/*
+ *  ã¢ã©ã¤ã³ãã¦ãããã®å¤å®
+ */
+#define ALIGNED(val, align)		((((uintptr_t)(val)) & ((align) - 1U)) == 0U)
+
+#ifdef CHECK_STKSZ_ALIGN
+#define STKSZ_ALIGN(stksz)		ALIGNED(stksz, CHECK_STKSZ_ALIGN)
+#else /* CHECK_STKSZ_ALIGN */
+#define STKSZ_ALIGN(stksz)		true
+#endif /* CHECK_STKSZ_ALIGN */
+
+#ifdef CHECK_INTPTR_ALIGN
+#define INTPTR_ALIGN(p_var)		ALIGNED(p_var, CHECK_INTPTR_ALIGN)
+#else /* CHECK_INTPTR_ALIGN */
+#define INTPTR_ALIGN(p_var)		true
+#endif /* CHECK_INTPTR_ALIGN */
+
+#ifdef CHECK_FUNC_ALIGN
+#define FUNC_ALIGN(func)		ALIGNED(func, CHECK_FUNC_ALIGN)
+#else /* CHECK_FUNC_ALIGN */
+#define FUNC_ALIGN(func)		true
+#endif /* CHECK_FUNC_ALIGN */
+
+#ifdef CHECK_STACK_ALIGN
+#define STACK_ALIGN(stack)		ALIGNED(stack, CHECK_STACK_ALIGN)
+#else /* CHECK_STACK_ALIGN */
+#define STACK_ALIGN(stack)		true
+#endif /* CHECK_STACK_ALIGN */
+
+#ifdef CHECK_MPF_ALIGN
+#define MPF_ALIGN(mpf)			ALIGNED(mpf, CHECK_MPF_ALIGN)
+#else /* CHECK_MPF_ALIGN */
+#define MPF_ALIGN(mpf)			true
+#endif /* CHECK_MPF_ALIGN */
+
+#ifdef CHECK_MB_ALIGN
+#define MB_ALIGN(mb)			ALIGNED(mb, CHECK_MB_ALIGN)
+#else /* CHECK_MB_ALIGN */
+#define MB_ALIGN(mb)			true
+#endif /* CHECK_MB_ALIGN */
+
+/*
+ *  NULLã§ãªããã¨ã®å¤å®
+ */
+#ifdef CHECK_INTPTR_NONNULL
+#define INTPTR_NONNULL(p_var)	((p_var) != NULL)
+#else /* CHECK_INTPTR_NONNULL */
+#define INTPTR_NONNULL(p_var)	true
+#endif /* CHECK_INTPTR_NONNULL */
+
+#ifdef CHECK_FUNC_NONNULL
+#define FUNC_NONNULL(func)		((func) != NULL)
+#else /* CHECK_FUNC_NONNULL */
+#define FUNC_NONNULL(func)		true
+#endif /* CHECK_FUNC_NONNULL */
+
+/*
+ *  å¼åºãã³ã³ãã­ã¹ãã®ãã§ãã¯ï¼E_CTXï¼
+ */
+#define CHECK_TSKCTX() do {									\
+	if (sense_context()) {									\
+		ercd = E_CTX;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®ãã§ãã¯ï¼E_CTXï¼
+ */
+#define CHECK_UNL() do {									\
+	if (sense_lock()) {										\
+		ercd = E_CTX;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  å¼åºãã³ã³ãã­ã¹ãã¨CPUã­ãã¯ç¶æ
+ã®ãã§ãã¯ï¼E_CTXï¼
+ */
+#define CHECK_TSKCTX_UNL() do {								\
+	if (sense_context() || sense_lock()) {					\
+		ercd = E_CTX;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  ãã£ã¹ãããä¿çç¶æ
+ã§ãªããã®ãã§ãã¯ï¼E_CTXï¼
+ */
+#define CHECK_DISPATCH() do {								\
+	if (sense_context() || sense_lock() || !dspflg) {		\
+		ercd = E_CTX;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  ãã®ä»ã®ã³ã³ãã­ã¹ãã¨ã©ã¼ã®ãã§ãã¯ï¼E_CTXï¼
+ */
+#define CHECK_CTX(exp) do {									\
+	if (!(exp)) {											\
+		ercd = E_CTX;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  ãªãã¸ã§ã¯ãIDã®ãã§ãã¯ï¼E_IDï¼
+ */
+#define CHECK_ID(exp) do {									\
+	if (!(exp)) {											\
+		ercd = E_ID;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  äºç´å±æ§ã¨ã©ã¼ã®ãã§ãã¯ï¼E_RSATRï¼
+ */
+#define CHECK_RSATR(atr, valid_atr) do {					\
+	if (((atr) & ~(valid_atr)) != 0U) {						\
+		ercd = E_RSATR;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  ãã©ã¡ã¼ã¿ã¨ã©ã¼ã®ãã§ãã¯ï¼E_PARï¼
+ */
+#define CHECK_PAR(exp) do {									\
+	if (!(exp)) {											\
+		ercd = E_PAR;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  ä¸æ­£ä½¿ç¨ã¨ã©ã¼ã®ãã§ãã¯ï¼E_ILUSEï¼
+ */
+#define CHECK_ILUSE(exp) do {								\
+	if (!(exp)) {											\
+		ercd = E_ILUSE;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+/*
+ *  éçãªãªãã¸ã§ã¯ãç¶æ
+ã¨ã©ã¼ã®ãã§ãã¯ï¼E_OBJï¼
+ */
+#define CHECK_OBJ(exp) do {									\
+	if (!(exp)) {											\
+		ercd = E_OBJ;										\
+		goto error_exit;									\
+	}														\
+} while (false)
+
+#endif /* TOPPERS_CHECK_H */
Index: asp3_gr_sakura/trunk/kernel/cyclic.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/cyclic.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/cyclic.c	(revision 317)
@@ -0,0 +1,447 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å¨æéç¥æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "cyclic.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_CYC_ENTER
+#define LOG_CYC_ENTER(p_cyccb)
+#endif /* LOG_CYC_ENTER */
+
+#ifndef LOG_CYC_LEAVE
+#define LOG_CYC_LEAVE(p_cyccb)
+#endif /* LOG_CYC_LEAVE */
+
+#ifndef LOG_ACRE_CYC_ENTER
+#define LOG_ACRE_CYC_ENTER(pk_ccyc)
+#endif /* LOG_ACRE_CYC_ENTER */
+
+#ifndef LOG_ACRE_CYC_LEAVE
+#define LOG_ACRE_CYC_LEAVE(ercd)
+#endif /* LOG_ACRE_CYC_LEAVE */
+
+#ifndef LOG_DEL_CYC_ENTER
+#define LOG_DEL_CYC_ENTER(cycid)
+#endif /* LOG_DEL_CYC_ENTER */
+
+#ifndef LOG_DEL_CYC_LEAVE
+#define LOG_DEL_CYC_LEAVE(ercd)
+#endif /* LOG_DEL_CYC_LEAVE */
+
+#ifndef LOG_STA_CYC_ENTER
+#define LOG_STA_CYC_ENTER(cycid)
+#endif /* LOG_STA_CYC_ENTER */
+
+#ifndef LOG_STA_CYC_LEAVE
+#define LOG_STA_CYC_LEAVE(ercd)
+#endif /* LOG_STA_CYC_LEAVE */
+
+#ifndef LOG_STP_CYC_ENTER
+#define LOG_STP_CYC_ENTER(cycid)
+#endif /* LOG_STP_CYC_ENTER */
+
+#ifndef LOG_STP_CYC_LEAVE
+#define LOG_STP_CYC_LEAVE(ercd)
+#endif /* LOG_STP_CYC_LEAVE */
+
+#ifndef LOG_REF_CYC_ENTER
+#define LOG_REF_CYC_ENTER(cycid, pk_rcyc)
+#endif /* LOG_REF_CYC_ENTER */
+
+#ifndef LOG_REF_CYC_LEAVE
+#define LOG_REF_CYC_LEAVE(ercd, pk_rcyc)
+#endif /* LOG_REF_CYC_LEAVE */
+
+/*
+ *  å¨æéç¥ã®æ°
+ */
+#define tnum_cyc	((uint_t)(tmax_cycid - TMIN_CYCID + 1))
+#define tnum_scyc	((uint_t)(tmax_scycid - TMIN_CYCID + 1))
+
+/*
+ *  å¨æéç¥IDããå¨æéç¥ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_CYC(cycid)	((uint_t)((cycid) - TMIN_CYCID))
+#define get_cyccb(cycid)	(&(cyccb_table[INDEX_CYC(cycid)]))
+
+#ifdef TOPPERS_cycini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãå¨æéç¥ç®¡çãã­ãã¯ã®ãªã¹ã
+ *
+ *  å¨æéç¥ç®¡çãã­ãã¯ã®å
+é ­ã«ã¯ã­ã¥ã¼ã«ã¤ãªãããã®é åããªãããï¼
+ *  ã¿ã¤ã ã¤ãã³ããã­ãã¯ï¼tmevtbï¼ã®é åãç¨ããï¼
+ */
+QUEUE	free_cyccb;
+
+/*
+ *  å¨æéç¥æ©è½ã®åæå
+ */
+void
+initialize_cyclic(void)
+{
+	uint_t	i, j;
+	CYCCB	*p_cyccb;
+	CYCINIB	*p_cycinib;
+
+	for (i = 0; i < tnum_scyc; i++) {
+		p_cyccb = &(cyccb_table[i]);
+		p_cyccb->p_cycinib = &(cycinib_table[i]);
+		p_cyccb->tmevtb.callback = (CBACK) call_cyclic;
+		p_cyccb->tmevtb.arg = (void *) p_cyccb;
+		if ((p_cyccb->p_cycinib->cycatr & TA_STA) != 0U) {
+			/*
+			 *  ååã®èµ·åã®ããã®ã¿ã¤ã ã¤ãã³ããç»é²ããï¼»ASPD1035ï¼½
+			 *  ï¼»ASPD1062ï¼½ï¼
+			 */
+			p_cyccb->cycsta = true;
+			p_cyccb->tmevtb.evttim = (EVTTIM)(p_cyccb->p_cycinib->cycphs);
+			tmevtb_register(&(p_cyccb->tmevtb));
+		}
+		else {
+			p_cyccb->cycsta = false;
+		}
+	}
+	queue_initialize(&free_cyccb);
+	for (j = 0; i < tnum_cyc; i++, j++) {
+		p_cyccb = &(cyccb_table[i]);
+		p_cycinib = &(acycinib_table[j]);
+		p_cycinib->cycatr = TA_NOEXS;
+		p_cyccb->p_cycinib = ((const CYCINIB *) p_cycinib);
+		p_cyccb->tmevtb.callback = (CBACK) call_cyclic;
+		p_cyccb->tmevtb.arg = (void *) p_cyccb;
+		queue_insert_prev(&free_cyccb, ((QUEUE *) &(p_cyccb->tmevtb)));
+	}
+}
+
+#endif /* TOPPERS_cycini */
+
+/*
+ *  å¨æéç¥ã®çæ
+ */
+#ifdef TOPPERS_acre_cyc
+
+ER_UINT
+acre_cyc(const T_CCYC *pk_ccyc)
+{
+	CYCCB		*p_cyccb;
+	CYCINIB		*p_cycinib;
+	ATR			cycatr;
+	T_NFYINFO	nfyinfo, *p_nfyinfo;
+	RELTIM		cyctim;
+	RELTIM		cycphs;
+	ER			ercd, rercd;
+
+	LOG_ACRE_CYC_ENTER(pk_ccyc);
+	CHECK_TSKCTX_UNL();
+
+	cycatr = pk_ccyc->cycatr;
+	nfyinfo = pk_ccyc->nfyinfo;
+	cyctim = pk_ccyc->cyctim;
+	cycphs = pk_ccyc->cycphs;
+
+	CHECK_RSATR(cycatr, TA_STA);
+	rercd = check_nfyinfo(&nfyinfo);
+	if (rercd != E_OK) {
+		ercd = rercd;
+		goto error_exit;
+	}
+	CHECK_PAR(0 < cyctim && cyctim <= TMAX_RELTIM);
+	CHECK_PAR(0 <= cycphs && cycphs <= TMAX_RELTIM);
+
+	lock_cpu();
+	if (tnum_cyc == 0 || queue_empty(&free_cyccb)) {
+		ercd = E_NOID;
+	}
+	else {
+		p_cyccb = ((CYCCB *)(((char *) queue_delete_next(&free_cyccb))
+												- offsetof(CYCCB, tmevtb)));
+		p_cycinib = (CYCINIB *)(p_cyccb->p_cycinib);
+		p_cycinib->cycatr = cycatr;
+		if (nfyinfo.nfymode == TNFY_HANDLER) {
+			p_cycinib->exinf = nfyinfo.nfy.handler.exinf;
+			p_cycinib->nfyhdr = (NFYHDR)(nfyinfo.nfy.handler.tmehdr);
+		}
+		else {
+			p_nfyinfo = &acyc_nfyinfo_table[p_cycinib - acycinib_table];
+			*p_nfyinfo = nfyinfo;
+			p_cycinib->exinf = (intptr_t) p_nfyinfo;
+			p_cycinib->nfyhdr = notify_handler;
+		}
+		p_cycinib->cyctim = cyctim;
+		p_cycinib->cycphs = cycphs;
+
+		if ((p_cyccb->p_cycinib->cycatr & TA_STA) != 0U) {
+			p_cyccb->cycsta = true;
+			tmevtb_enqueue(&(p_cyccb->tmevtb), p_cyccb->p_cycinib->cycphs);
+		}
+		else {
+			p_cyccb->cycsta = false;
+		}
+		ercd = CYCID(p_cyccb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_CYC_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_cyc */
+
+/*
+ *  å¨æéç¥ã®åé¤
+ */
+#ifdef TOPPERS_del_cyc
+
+ER
+del_cyc(ID cycid)
+{
+	CYCCB	*p_cyccb;
+	CYCINIB	*p_cycinib;
+	ER		ercd;
+
+	LOG_DEL_CYC_ENTER(cycid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_CYCID(cycid));
+	p_cyccb = get_cyccb(cycid);
+
+	lock_cpu();
+	if (p_cyccb->p_cycinib->cycatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (cycid <= tmax_scycid) {
+		ercd = E_OBJ;
+	}
+	else {
+		if (p_cyccb->cycsta) {
+			p_cyccb->cycsta = false;
+			tmevtb_dequeue(&(p_cyccb->tmevtb));
+		}
+
+		p_cycinib = (CYCINIB *)(p_cyccb->p_cycinib);
+		p_cycinib->cycatr = TA_NOEXS;
+		queue_insert_prev(&free_cyccb, ((QUEUE *) &(p_cyccb->tmevtb)));
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_CYC_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_cyc */
+
+/*
+ *  å¨æéç¥ã®åä½éå§
+ */
+#ifdef TOPPERS_sta_cyc
+
+ER
+sta_cyc(ID cycid)
+{
+	CYCCB	*p_cyccb;
+	ER		ercd;
+
+	LOG_STA_CYC_ENTER(cycid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_CYCID(cycid));
+	p_cyccb = get_cyccb(cycid);
+
+	lock_cpu();
+	if (p_cyccb->p_cycinib->cycatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_cyccb->cycsta) {
+			tmevtb_dequeue(&(p_cyccb->tmevtb));
+		}
+		else {
+			p_cyccb->cycsta = true;
+		}
+		/*
+		 *  ååã®èµ·åã®ããã®ã¿ã¤ã ã¤ãã³ããç»é²ããï¼»ASPD1036ï¼½ï¼
+		 */
+		tmevtb_enqueue(&(p_cyccb->tmevtb), p_cyccb->p_cycinib->cycphs);
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_STA_CYC_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_sta_cyc */
+
+/*
+ *  å¨æéç¥ã®åä½åæ­¢
+ */
+#ifdef TOPPERS_stp_cyc
+
+ER
+stp_cyc(ID cycid)
+{
+	CYCCB	*p_cyccb;
+	ER		ercd;
+
+	LOG_STP_CYC_ENTER(cycid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_CYCID(cycid));
+	p_cyccb = get_cyccb(cycid);
+
+	lock_cpu();
+	if (p_cyccb->p_cycinib->cycatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_cyccb->cycsta) {
+			p_cyccb->cycsta = false;
+			tmevtb_dequeue(&(p_cyccb->tmevtb));
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_STP_CYC_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_stp_cyc */
+
+/*
+ *  å¨æéç¥ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_cyc
+
+ER
+ref_cyc(ID cycid, T_RCYC *pk_rcyc)
+{
+	CYCCB	*p_cyccb;
+	ER		ercd;
+    
+	LOG_REF_CYC_ENTER(cycid, pk_rcyc);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_CYCID(cycid));
+	p_cyccb = get_cyccb(cycid);
+
+	lock_cpu();
+	if (p_cyccb->p_cycinib->cycatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		if (p_cyccb->cycsta) {
+			pk_rcyc->cycstat = TCYC_STA;
+			pk_rcyc->lefttim = tmevt_lefttim(&(p_cyccb->tmevtb));
+		}
+		else {
+			pk_rcyc->cycstat = TCYC_STP;
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_CYC_LEAVE(ercd, pk_rcyc);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_cyc */
+
+/*
+ *  å¨æéç¥èµ·åã«ã¼ãã³
+ */
+#ifdef TOPPERS_cyccal
+
+void
+call_cyclic(CYCCB *p_cyccb)
+{
+	/*
+	 *  æ¬¡åã®èµ·åã®ããã®ã¿ã¤ã ã¤ãã³ããç»é²ããï¼»ASPD1037ï¼½ï¼
+	 */
+	p_cyccb->tmevtb.evttim += p_cyccb->p_cycinib->cyctim;	/*ï¼»ASPD1038ï¼½*/
+	tmevtb_register(&(p_cyccb->tmevtb));
+
+	/*
+	 *  éç¥ãã³ãã©ãï¼CPUã­ãã¯è§£é¤ç¶æ
+ã§å¼ã³åºãï¼
+	 */
+	unlock_cpu();
+
+	LOG_CYC_ENTER(p_cyccb);
+	(*(p_cyccb->p_cycinib->nfyhdr))(p_cyccb->p_cycinib->exinf);
+	LOG_CYC_LEAVE(p_cyccb);
+
+	if (!sense_lock()) {
+		lock_cpu();
+	}
+}
+
+#endif /* TOPPERS_cyccal */
Index: asp3_gr_sakura/trunk/kernel/cyclic.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/cyclic.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/cyclic.h	(revision 317)
@@ -0,0 +1,136 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å¨æéç¥æ©è½
+ */
+
+#ifndef TOPPERS_CYCLIC_H
+#define TOPPERS_CYCLIC_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "time_event.h"
+
+/*
+ *  å¨æéç¥åæåãã­ãã¯
+ */
+typedef struct cyclic_handler_initialization_block {
+	ATR			cycatr;			/* å¨æéç¥å±æ§ */
+	intptr_t	exinf;			/* éç¥ãã³ãã©ã®æ¡å¼µæ
+å ± */
+	NFYHDR		nfyhdr;			/* éç¥ãã³ãã©ã®èµ·åçªå° */
+	RELTIM		cyctim;			/* å¨æéç¥ã®èµ·åå¨æ */
+	RELTIM		cycphs;			/* å¨æéç¥ã®èµ·åä½ç¸ */
+} CYCINIB;
+
+/*
+ *  å¨æéç¥ç®¡çãã­ãã¯
+ *
+ *	æ¬¡ã«å¨æéç¥ãèµ·åããæå»ã¯ï¼ã¿ã¤ã ã¤ãã³ããã­ãã¯ï¼tmevtbï¼ä¸­ã®
+ *	ã¿ã¤ã ã¤ãã³ãã®çºçæå»ï¼evttimï¼ã§ä¿æããï¼
+ */
+typedef struct cyclic_handler_control_block {
+	const CYCINIB *p_cycinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	bool_t		cycsta;			/* å¨æéç¥ã®åä½ç¶æ
+ */
+	TMEVTB		tmevtb;			/* ã¿ã¤ã ã¤ãã³ããã­ãã¯ */
+} CYCCB;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãå¨æéç¥ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_cyccb;
+
+/*
+ *  å¨æéç¥IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_cycid;
+extern const ID	tmax_scycid;
+
+/*
+ *  å¨æéç¥åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const CYCINIB	cycinib_table[];
+extern CYCINIB			acycinib_table[];
+
+/*
+ *  å¨æéç¥ã®éç¥æ¹æ³ã®æ ¼ç´ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern T_NFYINFO	acyc_nfyinfo_table[];
+
+/*
+ *  å¨æéç¥ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern CYCCB	cyccb_table[];
+
+/*
+ *  å¨æéç¥ç®¡çãã­ãã¯ããå¨æéç¥IDãåãåºãããã®ãã¯ã­
+ */
+#define	CYCID(p_cyccb)	((ID)(((p_cyccb) - cyccb_table) + TMIN_CYCID))
+
+/*
+ *  å¨æéç¥æ©è½ã®åæå
+ */
+extern void	initialize_cyclic(void);
+
+/*
+ *  å¨æéç¥èµ·åã«ã¼ãã³
+ */
+extern void	call_cyclic(CYCCB *p_cyccb);
+
+#endif /* TOPPERS_CYCLIC_H */
Index: asp3_gr_sakura/trunk/kernel/cyclic.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/cyclic.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/cyclic.trb	(revision 317)
@@ -0,0 +1,101 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: cyclic.trb 588 2016-02-05 12:54:58Z ertl-hiro $
+# 
+
+#
+#		å¨æéç¥æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class CyclicObject < KernelObject
+  def initialize()
+    super("cyc", "cyclic")
+    @inibList["T_NFYINFO"] = "acyc_nfyinfo_table"
+  end
+
+  def prepare(key, params)
+    # cycatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2383ï¼½
+    #ï¼TA_STAä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:cycatr] & ~($TA_STA)) != 0
+      error_illegal_id("E_RSATR", params, :cycatr, :cycid)
+    end
+
+    # (0 < cyctim && cyctim <= TMAX_RELTIM)ã§ãªãå ´åï¼E_PARï¼ï¼»NGKI2397ï¼½
+    if !(0 < params[:cyctim] && params[:cyctim] <= $TMAX_RELTIM)
+      error_illegal_id("E_PAR", params, :cyctim, :cycid)
+    end
+
+    # (0 <= cycphs && cycphs <= TMAX_RELTIM)ã§ãªãå ´åï¼E_PARï¼ï¼»NGKI2399ï¼½
+    if !(0 <= params[:cycphs] && params[:cycphs] <= $TMAX_RELTIM)
+      error_illegal_id("E_PAR", params, :cycphs, :cycid)
+    end
+
+    # éç¥æ
+å ±ã®å¦ç
+    params[:nfyhdr] = generateNotifyHandler(key, params, :cycid)
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:cycatr]}), (intptr_t)(#{params[:par1]}), " \
+			"#{params[:nfyhdr]}, (#{params[:cyctim]}), (#{params[:cycphs]})")
+  end
+end
+
+#
+#  å¨æéç¥ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Cyclic Notification Functions")
+CyclicObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/dataqueue.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/dataqueue.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/dataqueue.c	(revision 317)
@@ -0,0 +1,863 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¼ã¿ã­ã¥ã¼æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "dataqueue.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_DTQ_ENTER
+#define LOG_ACRE_DTQ_ENTER(pk_cdtq)
+#endif /* LOG_ACRE_DTQ_ENTER */
+
+#ifndef LOG_ACRE_DTQ_LEAVE
+#define LOG_ACRE_DTQ_LEAVE(ercd)
+#endif /* LOG_ACRE_DTQ_LEAVE */
+
+#ifndef LOG_DEL_DTQ_ENTER
+#define LOG_DEL_DTQ_ENTER(dtqid)
+#endif /* LOG_DEL_DTQ_ENTER */
+
+#ifndef LOG_DEL_DTQ_LEAVE
+#define LOG_DEL_DTQ_LEAVE(ercd)
+#endif /* LOG_DEL_DTQ_LEAVE */
+
+#ifndef LOG_SND_DTQ_ENTER
+#define LOG_SND_DTQ_ENTER(dtqid, data)
+#endif /* LOG_SND_DTQ_ENTER */
+
+#ifndef LOG_SND_DTQ_LEAVE
+#define LOG_SND_DTQ_LEAVE(ercd)
+#endif /* LOG_SND_DTQ_LEAVE */
+
+#ifndef LOG_PSND_DTQ_ENTER
+#define LOG_PSND_DTQ_ENTER(dtqid, data)
+#endif /* LOG_PSND_DTQ_ENTER */
+
+#ifndef LOG_PSND_DTQ_LEAVE
+#define LOG_PSND_DTQ_LEAVE(ercd)
+#endif /* LOG_PSND_DTQ_LEAVE */
+
+#ifndef LOG_TSND_DTQ_ENTER
+#define LOG_TSND_DTQ_ENTER(dtqid, data, tmout)
+#endif /* LOG_TSND_DTQ_ENTER */
+
+#ifndef LOG_TSND_DTQ_LEAVE
+#define LOG_TSND_DTQ_LEAVE(ercd)
+#endif /* LOG_TSND_DTQ_LEAVE */
+
+#ifndef LOG_FSND_DTQ_ENTER
+#define LOG_FSND_DTQ_ENTER(dtqid, data)
+#endif /* LOG_FSND_DTQ_ENTER */
+
+#ifndef LOG_FSND_DTQ_LEAVE
+#define LOG_FSND_DTQ_LEAVE(ercd)
+#endif /* LOG_FSND_DTQ_LEAVE */
+
+#ifndef LOG_RCV_DTQ_ENTER
+#define LOG_RCV_DTQ_ENTER(dtqid, p_data)
+#endif /* LOG_RCV_DTQ_ENTER */
+
+#ifndef LOG_RCV_DTQ_LEAVE
+#define LOG_RCV_DTQ_LEAVE(ercd, p_data)
+#endif /* LOG_RCV_DTQ_LEAVE */
+
+#ifndef LOG_PRCV_DTQ_ENTER
+#define LOG_PRCV_DTQ_ENTER(dtqid, p_data)
+#endif /* LOG_PRCV_DTQ_ENTER */
+
+#ifndef LOG_PRCV_DTQ_LEAVE
+#define LOG_PRCV_DTQ_LEAVE(ercd, p_data)
+#endif /* LOG_PRCV_DTQ_LEAVE */
+
+#ifndef LOG_TRCV_DTQ_ENTER
+#define LOG_TRCV_DTQ_ENTER(dtqid, p_data, tmout)
+#endif /* LOG_TRCV_DTQ_ENTER */
+
+#ifndef LOG_TRCV_DTQ_LEAVE
+#define LOG_TRCV_DTQ_LEAVE(ercd, p_data)
+#endif /* LOG_TRCV_DTQ_LEAVE */
+
+#ifndef LOG_INI_DTQ_ENTER
+#define LOG_INI_DTQ_ENTER(dtqid)
+#endif /* LOG_INI_DTQ_ENTER */
+
+#ifndef LOG_INI_DTQ_LEAVE
+#define LOG_INI_DTQ_LEAVE(ercd)
+#endif /* LOG_INI_DTQ_LEAVE */
+
+#ifndef LOG_REF_DTQ_ENTER
+#define LOG_REF_DTQ_ENTER(dtqid, pk_rdtq)
+#endif /* LOG_REF_DTQ_ENTER */
+
+#ifndef LOG_REF_DTQ_LEAVE
+#define LOG_REF_DTQ_LEAVE(ercd, pk_rdtq)
+#endif /* LOG_REF_DTQ_LEAVE */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®æ°
+ */
+#define tnum_dtq	((uint_t)(tmax_dtqid - TMIN_DTQID + 1))
+#define tnum_sdtq	((uint_t)(tmax_sdtqid - TMIN_DTQID + 1))
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼IDãããã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_DTQ(dtqid)	((uint_t)((dtqid) - TMIN_DTQID))
+#define get_dtqcb(dtqid)	(&(dtqcb_table[INDEX_DTQ(dtqid)]))
+
+#ifdef TOPPERS_dtqini
+
+/*
+ *  ä½¿ç¨ãã¦ããªããã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_dtqcb;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼æ©è½ã®åæå
+ */
+void
+initialize_dataqueue(void)
+{
+	uint_t	i, j;
+	DTQCB	*p_dtqcb;
+	DTQINIB	*p_dtqinib;
+
+	for (i = 0; i < tnum_sdtq; i++) {
+		p_dtqcb = &(dtqcb_table[i]);
+		queue_initialize(&(p_dtqcb->swait_queue));
+		p_dtqcb->p_dtqinib = &(dtqinib_table[i]);
+		queue_initialize(&(p_dtqcb->rwait_queue));
+		p_dtqcb->count = 0U;
+		p_dtqcb->head = 0U;
+		p_dtqcb->tail = 0U;
+	}
+	queue_initialize(&free_dtqcb);
+	for (j = 0; i < tnum_dtq; i++, j++) {
+		p_dtqcb = &(dtqcb_table[i]);
+		p_dtqinib = &(adtqinib_table[j]);
+		p_dtqinib->dtqatr = TA_NOEXS;
+		p_dtqcb->p_dtqinib = ((const DTQINIB *) p_dtqinib);
+		queue_insert_prev(&free_dtqcb, &(p_dtqcb->swait_queue));
+	}
+}
+
+#endif /* TOPPERS_dtqini */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®æ ¼ç´
+ */
+#ifdef TOPPERS_dtqenq
+
+void
+enqueue_data(DTQCB *p_dtqcb, intptr_t data)
+{
+	(p_dtqcb->p_dtqinib->p_dtqmb + p_dtqcb->tail)->data = data;
+	p_dtqcb->count++;
+	p_dtqcb->tail++;
+	if (p_dtqcb->tail >= p_dtqcb->p_dtqinib->dtqcnt) {
+		p_dtqcb->tail = 0U;
+	}
+}
+
+#endif /* TOPPERS_dtqenq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®å¼·å¶æ ¼ç´
+ */
+#ifdef TOPPERS_dtqfenq
+
+void
+force_enqueue_data(DTQCB *p_dtqcb, intptr_t data)
+{
+	(p_dtqcb->p_dtqinib->p_dtqmb + p_dtqcb->tail)->data = data;
+	p_dtqcb->tail++;
+	if (p_dtqcb->tail >= p_dtqcb->p_dtqinib->dtqcnt) {
+		p_dtqcb->tail = 0U;
+	}
+	if (p_dtqcb->count < p_dtqcb->p_dtqinib->dtqcnt) {
+		p_dtqcb->count++;
+	}
+	else {
+		p_dtqcb->head = p_dtqcb->tail;
+	}
+}
+
+#endif /* TOPPERS_dtqfenq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åããã®ãã¼ã¿ã®ååºã
+ */
+#ifdef TOPPERS_dtqdeq
+
+void
+dequeue_data(DTQCB *p_dtqcb, intptr_t *p_data)
+{
+	*p_data = (p_dtqcb->p_dtqinib->p_dtqmb + p_dtqcb->head)->data;
+	p_dtqcb->count--;
+	p_dtqcb->head++;
+	if (p_dtqcb->head >= p_dtqcb->p_dtqinib->dtqcnt) {
+		p_dtqcb->head = 0U;
+	}
+}
+
+#endif /* TOPPERS_dtqdeq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿éä¿¡
+ */
+#ifdef TOPPERS_dtqsnd
+
+bool_t
+send_data(DTQCB *p_dtqcb, intptr_t data)
+{
+	TCB		*p_tcb;
+
+	if (!queue_empty(&(p_dtqcb->rwait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->rwait_queue));
+		((WINFO_RDTQ *)(p_tcb->p_winfo))->data = data;
+		wait_complete(p_tcb);
+		return(true);
+	}
+	else if (p_dtqcb->count < p_dtqcb->p_dtqinib->dtqcnt) {
+		enqueue_data(p_dtqcb, data);
+		return(true);
+	}
+	else {
+		return(false);
+	}
+}
+
+#endif /* TOPPERS_dtqsnd */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿å¼·å¶éä¿¡
+ */
+#ifdef TOPPERS_dtqfsnd
+
+void
+force_send_data(DTQCB *p_dtqcb, intptr_t data)
+{
+	TCB		*p_tcb;
+
+	if (!queue_empty(&(p_dtqcb->rwait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->rwait_queue));
+		((WINFO_RDTQ *)(p_tcb->p_winfo))->data = data;
+		wait_complete(p_tcb);
+	}
+	else {
+		force_enqueue_data(p_dtqcb, data);
+	}
+}
+
+#endif /* TOPPERS_dtqfsnd */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®ãã¼ã¿åä¿¡
+ */
+#ifdef TOPPERS_dtqrcv
+
+bool_t
+receive_data(DTQCB *p_dtqcb, intptr_t *p_data)
+{
+	TCB		*p_tcb;
+	intptr_t data;
+
+	if (p_dtqcb->count > 0U) {
+		dequeue_data(p_dtqcb, p_data);
+		if (!queue_empty(&(p_dtqcb->swait_queue))) {
+			p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->swait_queue));
+			data = ((WINFO_SDTQ *)(p_tcb->p_winfo))->data;
+			enqueue_data(p_dtqcb, data);
+			wait_complete(p_tcb);
+		}
+		return(true);
+	}
+	else if (!queue_empty(&(p_dtqcb->swait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_dtqcb->swait_queue));
+		*p_data = ((WINFO_SDTQ *)(p_tcb->p_winfo))->data;
+		wait_complete(p_tcb);
+		return(true);
+	}
+	else {
+		return(false);
+	}
+}
+
+#endif /* TOPPERS_dtqrcv */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®çæ
+ */
+#ifdef TOPPERS_acre_dtq
+
+ER_UINT
+acre_dtq(const T_CDTQ *pk_cdtq)
+{
+	DTQCB		*p_dtqcb;
+	DTQINIB		*p_dtqinib;
+	ATR			dtqatr;
+	uint_t		dtqcnt;
+	DTQMB		*p_dtqmb;
+	ER			ercd;
+
+	LOG_ACRE_DTQ_ENTER(pk_cdtq);
+	CHECK_TSKCTX_UNL();
+
+	dtqatr = pk_cdtq->dtqatr;
+	dtqcnt = pk_cdtq->dtqcnt;
+	p_dtqmb = pk_cdtq->dtqmb;
+
+	CHECK_RSATR(dtqatr, TA_TPRI);
+
+	lock_cpu();
+	if (tnum_dtq == 0 || queue_empty(&free_dtqcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		if (dtqcnt != 0 && p_dtqmb == NULL) {
+			p_dtqmb = kernel_malloc(sizeof(DTQMB) * dtqcnt);
+			dtqatr |= TA_MBALLOC;
+		}
+		if (dtqcnt != 0 && p_dtqmb == NULL) {
+			ercd = E_NOMEM;
+		}
+		else {
+			p_dtqcb = ((DTQCB *) queue_delete_next(&free_dtqcb));
+			p_dtqinib = (DTQINIB *)(p_dtqcb->p_dtqinib);
+			p_dtqinib->dtqatr = dtqatr;
+			p_dtqinib->dtqcnt = dtqcnt;
+			p_dtqinib->p_dtqmb = p_dtqmb;
+
+			queue_initialize(&(p_dtqcb->swait_queue));
+			queue_initialize(&(p_dtqcb->rwait_queue));
+			p_dtqcb->count = 0U;
+			p_dtqcb->head = 0U;
+			p_dtqcb->tail = 0U;
+			ercd = DTQID(p_dtqcb);
+		}
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®åé¤
+ */
+#ifdef TOPPERS_del_dtq
+
+ER
+del_dtq(ID dtqid)
+{
+	DTQCB	*p_dtqcb;
+	DTQINIB	*p_dtqinib;
+	ER		ercd;
+
+	LOG_DEL_DTQ_ENTER(dtqid);
+	CHECK_TSKCTX_UNL();
+	CHECK_PAR(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (dtqid <= tmax_sdtqid) {
+		ercd = E_OBJ;
+	}
+	else {
+		init_wait_queue(&(p_dtqcb->swait_queue));
+		init_wait_queue(&(p_dtqcb->rwait_queue));
+		p_dtqinib = (DTQINIB *)(p_dtqcb->p_dtqinib);
+		if ((p_dtqinib->dtqatr & TA_MBALLOC) != 0U) {
+			kernel_free(p_dtqinib->p_dtqmb);
+		}
+		p_dtqinib->dtqatr = TA_NOEXS;
+		queue_insert_prev(&free_dtqcb, &(p_dtqcb->swait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+ */
+#ifdef TOPPERS_snd_dtq
+
+ER
+snd_dtq(ID dtqid, intptr_t data)
+{
+	DTQCB	*p_dtqcb;
+	WINFO_SDTQ winfo_sdtq;
+	ER		ercd;
+
+	LOG_SND_DTQ_ENTER(dtqid, data);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu_dsp();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (send_data(p_dtqcb, data)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		winfo_sdtq.data = data;
+		p_runtsk->tstat = TS_WAITING_SDTQ;
+		wobj_make_wait((WOBJCB *) p_dtqcb, (WINFO_WOBJ *) &winfo_sdtq);
+		dispatch();
+		ercd = winfo_sdtq.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_SND_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_snd_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_psnd_dtq
+
+ER
+psnd_dtq(ID dtqid, intptr_t data)
+{
+	DTQCB	*p_dtqcb;
+	ER		ercd;
+
+	LOG_PSND_DTQ_ENTER(dtqid, data);
+	CHECK_UNL();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (send_data(p_dtqcb, data)) {
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PSND_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_psnd_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_tsnd_dtq
+
+ER
+tsnd_dtq(ID dtqid, intptr_t data, TMO tmout)
+{
+	DTQCB	*p_dtqcb;
+	WINFO_SDTQ winfo_sdtq;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TSND_DTQ_ENTER(dtqid, data, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_DTQID(dtqid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu_dsp();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (send_data(p_dtqcb, data)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		winfo_sdtq.data = data;
+		p_runtsk->tstat = TS_WAITING_SDTQ;
+		wobj_make_wait_tmout((WOBJCB *) p_dtqcb, (WINFO_WOBJ *) &winfo_sdtq,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_sdtq.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TSND_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_tsnd_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®å¼·å¶éä¿¡
+ */
+#ifdef TOPPERS_fsnd_dtq
+
+ER
+fsnd_dtq(ID dtqid, intptr_t data)
+{
+	DTQCB	*p_dtqcb;	
+	ER		ercd;
+
+	LOG_FSND_DTQ_ENTER(dtqid, data);
+	CHECK_UNL();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (!(p_dtqcb->p_dtqinib->dtqcnt > 0U)) {
+		ercd = E_ILUSE;
+	}
+	else {
+		force_send_data(p_dtqcb, data);
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_FSND_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_fsnd_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡
+ */
+#ifdef TOPPERS_rcv_dtq
+
+ER
+rcv_dtq(ID dtqid, intptr_t *p_data)
+{
+	DTQCB	*p_dtqcb;
+	WINFO_RDTQ winfo_rdtq;
+	ER		ercd;
+
+	LOG_RCV_DTQ_ENTER(dtqid, p_data);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu_dsp();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (receive_data(p_dtqcb, p_data)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_RDTQ;
+		make_wait(&(winfo_rdtq.winfo));
+		queue_insert_prev(&(p_dtqcb->rwait_queue), &(p_runtsk->task_queue));
+		winfo_rdtq.p_dtqcb = p_dtqcb;
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo_rdtq.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_data = winfo_rdtq.data;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_RCV_DTQ_LEAVE(ercd, p_data);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rcv_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_prcv_dtq
+
+ER
+prcv_dtq(ID dtqid, intptr_t *p_data)
+{
+	DTQCB	*p_dtqcb;
+	ER		ercd;
+
+	LOG_PRCV_DTQ_ENTER(dtqid, p_data);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (receive_data(p_dtqcb, p_data)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PRCV_DTQ_LEAVE(ercd, p_data);
+	return(ercd);
+}
+
+#endif /* TOPPERS_prcv_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_trcv_dtq
+
+ER
+trcv_dtq(ID dtqid, intptr_t *p_data, TMO tmout)
+{
+	DTQCB	*p_dtqcb;
+	WINFO_RDTQ winfo_rdtq;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TRCV_DTQ_ENTER(dtqid, p_data, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_DTQID(dtqid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu_dsp();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (receive_data(p_dtqcb, p_data)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_RDTQ;
+		make_wait_tmout(&(winfo_rdtq.winfo), &tmevtb, tmout);
+		queue_insert_prev(&(p_dtqcb->rwait_queue), &(p_runtsk->task_queue));
+		winfo_rdtq.p_dtqcb = p_dtqcb;
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo_rdtq.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_data = winfo_rdtq.data;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TRCV_DTQ_LEAVE(ercd, p_data);
+	return(ercd);
+}
+
+#endif /* TOPPERS_trcv_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®ååæå
+ */
+#ifdef TOPPERS_ini_dtq
+
+ER
+ini_dtq(ID dtqid)
+{
+	DTQCB	*p_dtqcb;
+	ER		ercd;
+    
+	LOG_INI_DTQ_ENTER(dtqid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_dtqcb->swait_queue));
+		init_wait_queue(&(p_dtqcb->rwait_queue));
+		p_dtqcb->count = 0U;
+		p_dtqcb->head = 0U;
+		p_dtqcb->tail = 0U;
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_DTQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_dtq */
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_dtq
+
+ER
+ref_dtq(ID dtqid, T_RDTQ *pk_rdtq)
+{
+	DTQCB	*p_dtqcb;
+	ER		ercd;
+    
+	LOG_REF_DTQ_ENTER(dtqid, pk_rdtq);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_DTQID(dtqid));
+	p_dtqcb = get_dtqcb(dtqid);
+
+	lock_cpu();
+	if (p_dtqcb->p_dtqinib->dtqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rdtq->stskid = wait_tskid(&(p_dtqcb->swait_queue));
+		pk_rdtq->rtskid = wait_tskid(&(p_dtqcb->rwait_queue));
+		pk_rdtq->sdtqcnt = p_dtqcb->count;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_DTQ_LEAVE(ercd, pk_rdtq);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_dtq */
Index: asp3_gr_sakura/trunk/kernel/dataqueue.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/dataqueue.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/dataqueue.h	(revision 317)
@@ -0,0 +1,205 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¼ã¿ã­ã¥ã¼æ©è½
+ */
+
+#ifndef TOPPERS_DATAQUEUE_H
+#define TOPPERS_DATAQUEUE_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  ãã¼ã¿ç®¡çãã­ãã¯
+ */
+typedef struct data_management_block {
+	intptr_t	data;			/* ãã¼ã¿æ¬ä½ */
+} DTQMB;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct dataqueue_initialization_block {
+	ATR			dtqatr;			/* ãã¼ã¿ã­ã¥ã¼å±æ§ */
+	uint_t		dtqcnt;			/* ãã¼ã¿ã­ã¥ã¼ã®å®¹é */
+	DTQMB		*p_dtqmb;		/* ãã¼ã¿ã­ã¥ã¼ç®¡çé åã®å
+é ­çªå° */
+} DTQINIB;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct dataqueue_control_block {
+	QUEUE		swait_queue;	/* ãã¼ã¿ã­ã¥ã¼éä¿¡å¾
+ã¡ã­ã¥ã¼ */
+	const DTQINIB *p_dtqinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	QUEUE		rwait_queue;	/* ãã¼ã¿ã­ã¥ã¼åä¿¡å¾
+ã¡ã­ã¥ã¼ */
+	uint_t		count;			/* ãã¼ã¿ã­ã¥ã¼ä¸­ã®ãã¼ã¿ã®æ° */
+	uint_t		head;			/* æåã®ãã¼ã¿ã®æ ¼ç´å ´æ */
+	uint_t		tail;			/* æå¾ã®ãã¼ã¿ã®æ ¼ç´å ´æã®æ¬¡ */
+} DTQCB;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®2ã¤ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct dataqueue_send_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	DTQCB		*p_dtqcb;		/* å¾
+ã£ã¦ãããã¼ã¿ã­ã¥ã¼ã®ç®¡çãã­ãã¯ */
+	intptr_t	data;			/* éä¿¡ãã¼ã¿ */
+} WINFO_SDTQ;
+
+typedef struct dataqueue_receive_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	DTQCB		*p_dtqcb;		/* å¾
+ã£ã¦ãããã¼ã¿ã­ã¥ã¼ã®ç®¡çãã­ãã¯ */
+	intptr_t	data;			/* åä¿¡ãã¼ã¿ */
+} WINFO_RDTQ;
+
+/*
+ *  ä½¿ç¨ãã¦ããªããã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_dtqcb;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_dtqid;
+extern const ID	tmax_sdtqid;
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const DTQINIB	dtqinib_table[];
+extern DTQINIB			adtqinib_table[];
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern DTQCB	dtqcb_table[];
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ãããã¼ã¿ã­ã¥ã¼IDãåãåºãããã®ãã¯ã­
+ */
+#define	DTQID(p_dtqcb)	((ID)(((p_dtqcb) - dtqcb_table) + TMIN_DTQID))
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼æ©è½ã®åæå
+ */
+extern void	initialize_dataqueue(void);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®æ ¼ç´
+ */
+extern void	enqueue_data(DTQCB *p_dtqcb, intptr_t data);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®å¼·å¶æ ¼ç´
+ */
+extern void	force_enqueue_data(DTQCB *p_dtqcb, intptr_t data);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ç®¡çé åããã®ãã¼ã¿ã®ååºã
+ */
+extern void	dequeue_data(DTQCB *p_dtqcb, intptr_t *p_data);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿éä¿¡
+ */
+extern bool_t	send_data(DTQCB *p_dtqcb, intptr_t data);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿å¼·å¶éä¿¡
+ */
+extern void	force_send_data(DTQCB *p_dtqcb, intptr_t data);
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®ãã¼ã¿åä¿¡
+ */
+extern bool_t	receive_data(DTQCB *p_dtqcb, intptr_t *p_data);
+
+#endif /* TOPPERS_DATAQUEUE_H */
Index: asp3_gr_sakura/trunk/kernel/dataqueue.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/dataqueue.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/dataqueue.trb	(revision 317)
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: dataqueue.trb 668 2016-03-03 13:57:53Z ertl-hiro $
+# 
+
+#
+#		ãã¼ã¿ã­ã¥ã¼æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class DataqueueObject < KernelObject
+  def initialize()
+    super("dtq", "dataqueue")
+  end
+
+  def prepare(key, params)
+    # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+    params[:dtqmb] ||= "NULL"
+
+    # dtqatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI1669ï¼½
+    #ï¼TA_TPRIä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:dtqatr] & ~($TA_TPRI)) != 0
+      error_illegal_id("E_RSATR", params, :dtqatr, :dtqid)
+    end
+
+    # dtqmbãNULLã§ãªãå ´åï¼E_NOSPTï¼ï¼»ASPS0132ï¼½
+    if params[:dtqmb] != "NULL"
+      error_illegal_id("E_NOSPT", params, :dtqmb, :dtqid)
+    end
+
+    # ãã¼ã¿ã­ã¥ã¼ç®¡çé å
+    if params[:dtqcnt] > 0
+      dtqmbName = "_kernel_dtqmb_#{params[:dtqid]}"
+      $kernelCfgC.add("static DTQMB #{dtqmbName}[#{params[:dtqcnt]}];")
+      params[:dtqinib_dtqmb] = dtqmbName
+    else
+      params[:dtqinib_dtqmb] = "NULL"
+    end
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:dtqatr]}), (#{params[:dtqcnt]}), " \
+										"#{params[:dtqinib_dtqmb]}")
+  end
+end
+
+#
+#  ãã¼ã¿ã­ã¥ã¼ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Dataqueue Functions")
+DataqueueObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/eventflag.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/eventflag.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/eventflag.c	(revision 317)
@@ -0,0 +1,622 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¤ãã³ããã©ã°æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "eventflag.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_FLG_ENTER
+#define LOG_ACRE_FLG_ENTER(pk_cflg)
+#endif /* LOG_ACRE_FLG_ENTER */
+
+#ifndef LOG_ACRE_FLG_LEAVE
+#define LOG_ACRE_FLG_LEAVE(ercd)
+#endif /* LOG_ACRE_FLG_LEAVE */
+
+#ifndef LOG_DEL_FLG_ENTER
+#define LOG_DEL_FLG_ENTER(flgid)
+#endif /* LOG_DEL_FLG_ENTER */
+
+#ifndef LOG_DEL_FLG_LEAVE
+#define LOG_DEL_FLG_LEAVE(ercd)
+#endif /* LOG_DEL_FLG_LEAVE */
+
+#ifndef LOG_SET_FLG_ENTER
+#define LOG_SET_FLG_ENTER(flgid, setptn)
+#endif /* LOG_SET_FLG_ENTER */
+
+#ifndef LOG_SET_FLG_LEAVE
+#define LOG_SET_FLG_LEAVE(ercd)
+#endif /* LOG_SET_FLG_LEAVE */
+
+#ifndef LOG_CLR_FLG_ENTER
+#define LOG_CLR_FLG_ENTER(flgid, clrptn)
+#endif /* LOG_CLR_FLG_ENTER */
+
+#ifndef LOG_CLR_FLG_LEAVE
+#define LOG_CLR_FLG_LEAVE(ercd)
+#endif /* LOG_CLR_FLG_LEAVE */
+
+#ifndef LOG_WAI_FLG_ENTER
+#define LOG_WAI_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn)
+#endif /* LOG_WAI_FLG_ENTER */
+
+#ifndef LOG_WAI_FLG_LEAVE
+#define LOG_WAI_FLG_LEAVE(ercd, p_flgptn)
+#endif /* LOG_WAI_FLG_LEAVE */
+
+#ifndef LOG_POL_FLG_ENTER
+#define LOG_POL_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn)
+#endif /* LOG_POL_FLG_ENTER */
+
+#ifndef LOG_POL_FLG_LEAVE
+#define LOG_POL_FLG_LEAVE(ercd, p_flgptn)
+#endif /* LOG_POL_FLG_LEAVE */
+
+#ifndef LOG_TWAI_FLG_ENTER
+#define LOG_TWAI_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn, tmout)
+#endif /* LOG_TWAI_FLG_ENTER */
+
+#ifndef LOG_TWAI_FLG_LEAVE
+#define LOG_TWAI_FLG_LEAVE(ercd, p_flgptn)
+#endif /* LOG_TWAI_FLG_LEAVE */
+
+#ifndef LOG_INI_FLG_ENTER
+#define LOG_INI_FLG_ENTER(flgid)
+#endif /* LOG_INI_FLG_ENTER */
+
+#ifndef LOG_INI_FLG_LEAVE
+#define LOG_INI_FLG_LEAVE(ercd)
+#endif /* LOG_INI_FLG_LEAVE */
+
+#ifndef LOG_REF_FLG_ENTER
+#define LOG_REF_FLG_ENTER(flgid, pk_rflg)
+#endif /* LOG_REF_FLG_ENTER */
+
+#ifndef LOG_REF_FLG_LEAVE
+#define LOG_REF_FLG_LEAVE(ercd, pk_rflg)
+#endif /* LOG_REF_FLG_LEAVE */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®æ°
+ */
+#define tnum_flg	((uint_t)(tmax_flgid - TMIN_FLGID + 1))
+#define tnum_sflg	((uint_t)(tmax_sflgid - TMIN_FLGID + 1))
+
+/*
+ *  ã¤ãã³ããã©ã°IDããã¤ãã³ããã©ã°ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_FLG(flgid)	((uint_t)((flgid) - TMIN_FLGID))
+#define get_flgcb(flgid)	(&(flgcb_table[INDEX_FLG(flgid)]))
+
+#ifdef TOPPERS_flgini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã¤ãã³ããã©ã°ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_flgcb;
+
+/*
+ *  ã¤ãã³ããã©ã°æ©è½ã®åæå
+ */
+void
+initialize_eventflag(void)
+{
+	uint_t	i, j;
+	FLGCB	*p_flgcb;
+	FLGINIB	*p_flginib;
+
+	for (i = 0; i < tnum_sflg; i++) {
+		p_flgcb = &(flgcb_table[i]);
+		queue_initialize(&(p_flgcb->wait_queue));
+		p_flgcb->p_flginib = &(flginib_table[i]);
+		p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn;
+	}
+	queue_initialize(&free_flgcb);
+	for (j = 0; i < tnum_flg; i++, j++) {
+		p_flgcb = &(flgcb_table[i]);
+		p_flginib = &(aflginib_table[j]);
+		p_flginib->flgatr = TA_NOEXS;
+		p_flgcb->p_flginib = ((const FLGINIB *) p_flginib);
+		queue_insert_prev(&free_flgcb, &(p_flgcb->wait_queue));
+	}
+}
+
+#endif /* TOPPERS_flgini */
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡è§£é¤æ¡ä»¶ã®ãã§ãã¯
+ */
+#ifdef TOPPERS_flgcnd
+
+bool_t
+check_flg_cond(FLGCB *p_flgcb, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn)
+{
+	if ((wfmode & TWF_ORW) != 0U ? (p_flgcb->flgptn & waiptn) != 0U
+									: (p_flgcb->flgptn & waiptn) == waiptn) {
+		*p_flgptn = p_flgcb->flgptn;
+		if ((p_flgcb->p_flginib->flgatr & TA_CLR) != 0U) {
+			p_flgcb->flgptn = 0U;
+		}
+		return(true);
+	}
+	return(false);
+}
+
+#endif /* TOPPERS_flgcnd */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®çæ
+ *
+ *  pk_cflg->iflgptnã¯ï¼ã¨ã©ã¼ãã§ãã¯ãããï¼ä¸åº¦ããåç
+§ããªãããï¼
+ *  ã­ã¼ã«ã«å¤æ°ã«ã³ãã¼ããå¿
+è¦ããªãï¼éä¸­ã§æ¸ãæãã£ã¦ãæ¯éããª
+ *  ãï¼ï¼
+ */
+#ifdef TOPPERS_acre_flg
+
+ER_UINT
+acre_flg(const T_CFLG *pk_cflg)
+{
+	FLGCB	*p_flgcb;
+	FLGINIB	*p_flginib;
+	ATR		flgatr;
+	ER		ercd;
+
+	LOG_ACRE_FLG_ENTER(pk_cflg);
+	CHECK_TSKCTX_UNL();
+
+	flgatr = pk_cflg->flgatr;
+
+	CHECK_RSATR(flgatr, TA_TPRI|TA_WMUL|TA_CLR);
+
+	lock_cpu();
+	if (tnum_flg == 0 || queue_empty(&free_flgcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		p_flgcb = ((FLGCB *) queue_delete_next(&free_flgcb));
+		p_flginib = (FLGINIB *)(p_flgcb->p_flginib);
+		p_flginib->flgatr = flgatr;
+		p_flginib->iflgptn = pk_cflg->iflgptn;
+
+		queue_initialize(&(p_flgcb->wait_queue));
+		p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn;
+		ercd = FLGID(p_flgcb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_FLG_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®åé¤
+ */
+#ifdef TOPPERS_del_flg
+
+ER
+del_flg(ID flgid)
+{
+	FLGCB	*p_flgcb;
+	FLGINIB	*p_flginib;
+	ER		ercd;
+
+	LOG_DEL_FLG_ENTER(flgid);
+	CHECK_TSKCTX_UNL();
+	CHECK_PAR(VALID_FLGID(flgid));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (flgid <= tmax_sflgid) {
+		ercd = E_OBJ;
+	}
+	else {
+		init_wait_queue(&(p_flgcb->wait_queue));
+		p_flginib = (FLGINIB *)(p_flgcb->p_flginib);
+ 		p_flginib->flgatr = TA_NOEXS;
+		queue_insert_prev(&free_flgcb, &(p_flgcb->wait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_FLG_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã»ãã
+ */
+#ifdef TOPPERS_set_flg
+
+ER
+set_flg(ID flgid, FLGPTN setptn)
+{
+	FLGCB	*p_flgcb;
+	QUEUE	*p_queue;
+	TCB		*p_tcb;
+	WINFO_FLG *p_winfo_flg;
+	ER		ercd;
+
+	LOG_SET_FLG_ENTER(flgid, setptn);
+	CHECK_UNL();
+	CHECK_ID(VALID_FLGID(flgid));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		p_flgcb->flgptn |= setptn;
+		p_queue = p_flgcb->wait_queue.p_next;
+		while (p_queue != &(p_flgcb->wait_queue)) {
+			p_tcb = (TCB *) p_queue;
+			p_queue = p_queue->p_next;
+			p_winfo_flg = (WINFO_FLG *)(p_tcb->p_winfo);
+			if (check_flg_cond(p_flgcb, p_winfo_flg->waiptn,
+							p_winfo_flg->wfmode, &(p_winfo_flg->waiptn))) {
+				queue_delete(&(p_tcb->task_queue));
+				wait_complete(p_tcb);
+				if ((p_flgcb->p_flginib->flgatr & TA_CLR) != 0U) {
+					break;
+				}
+			}
+		}
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_SET_FLG_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_set_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã¯ãªã¢
+ */
+#ifdef TOPPERS_clr_flg
+
+ER
+clr_flg(ID flgid, FLGPTN clrptn)
+{
+	FLGCB	*p_flgcb;
+	ER		ercd;
+
+	LOG_CLR_FLG_ENTER(flgid, clrptn);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_FLGID(flgid));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		p_flgcb->flgptn &= clrptn; 
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_CLR_FLG_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_clr_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡
+ */
+#ifdef TOPPERS_wai_flg
+
+ER
+wai_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn)
+{
+	FLGCB	*p_flgcb;
+	WINFO_FLG winfo_flg;
+	ER		ercd;
+
+	LOG_WAI_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_FLGID(flgid));
+	CHECK_PAR(waiptn != 0U);
+	CHECK_PAR(wfmode == TWF_ORW || wfmode == TWF_ANDW);
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu_dsp();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if ((p_flgcb->p_flginib->flgatr & TA_WMUL) == 0U
+					&& !queue_empty(&(p_flgcb->wait_queue))) {
+		ercd = E_ILUSE;
+	}
+	else if (check_flg_cond(p_flgcb, waiptn, wfmode, p_flgptn)) {
+		ercd = E_OK;
+	}
+	else {
+		winfo_flg.waiptn = waiptn;
+		winfo_flg.wfmode = wfmode;
+		p_runtsk->tstat = TS_WAITING_FLG;
+		wobj_make_wait((WOBJCB *) p_flgcb, (WINFO_WOBJ *) &winfo_flg);
+		dispatch();
+		ercd = winfo_flg.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_flgptn = winfo_flg.waiptn;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_WAI_FLG_LEAVE(ercd, p_flgptn);
+	return(ercd);
+}
+
+#endif /* TOPPERS_wai_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_pol_flg
+
+ER
+pol_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn)
+{
+	FLGCB	*p_flgcb;
+	ER		ercd;
+
+	LOG_POL_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_FLGID(flgid));
+	CHECK_PAR(waiptn != 0U);
+	CHECK_PAR(wfmode == TWF_ORW || wfmode == TWF_ANDW);
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if ((p_flgcb->p_flginib->flgatr & TA_WMUL) == 0U
+					&& !queue_empty(&(p_flgcb->wait_queue))) {
+		ercd = E_ILUSE;
+	}
+	else if (check_flg_cond(p_flgcb, waiptn, wfmode, p_flgptn)) {
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_POL_FLG_LEAVE(ercd, p_flgptn);
+	return(ercd);
+}
+
+#endif /* TOPPERS_pol_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_twai_flg
+
+ER
+twai_flg(ID flgid, FLGPTN waiptn, MODE wfmode, FLGPTN *p_flgptn, TMO tmout)
+{
+	FLGCB	*p_flgcb;
+	WINFO_FLG winfo_flg;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TWAI_FLG_ENTER(flgid, waiptn, wfmode, p_flgptn, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_FLGID(flgid));
+	CHECK_PAR(waiptn != 0U);
+	CHECK_PAR(wfmode == TWF_ORW || wfmode == TWF_ANDW);
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu_dsp();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if ((p_flgcb->p_flginib->flgatr & TA_WMUL) == 0U
+					&& !queue_empty(&(p_flgcb->wait_queue))) {
+		ercd = E_ILUSE;
+	}
+	else if (check_flg_cond(p_flgcb, waiptn, wfmode, p_flgptn)) {
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		winfo_flg.waiptn = waiptn;
+		winfo_flg.wfmode = wfmode;
+		p_runtsk->tstat = TS_WAITING_FLG;
+		wobj_make_wait_tmout((WOBJCB *) p_flgcb, (WINFO_WOBJ *) &winfo_flg,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_flg.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_flgptn = winfo_flg.waiptn;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TWAI_FLG_LEAVE(ercd, p_flgptn);
+	return(ercd);
+}
+
+#endif /* TOPPERS_twai_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ååæå
+ */
+#ifdef TOPPERS_ini_flg
+
+ER
+ini_flg(ID flgid)
+{
+	FLGCB	*p_flgcb;
+	ER		ercd;
+    
+	LOG_INI_FLG_ENTER(flgid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_FLGID(flgid));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_flgcb->wait_queue));
+		p_flgcb->flgptn = p_flgcb->p_flginib->iflgptn;
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_FLG_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_flg */
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_flg
+
+ER
+ref_flg(ID flgid, T_RFLG *pk_rflg)
+{
+	FLGCB	*p_flgcb;
+	ER		ercd;
+    
+	LOG_REF_FLG_ENTER(flgid, pk_rflg);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_FLGID(flgid));
+	p_flgcb = get_flgcb(flgid);
+
+	lock_cpu();
+	if (p_flgcb->p_flginib->flgatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rflg->wtskid = wait_tskid(&(p_flgcb->wait_queue));
+		pk_rflg->flgptn = p_flgcb->flgptn;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_FLG_LEAVE(ercd, pk_rflg);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_flg */
Index: asp3_gr_sakura/trunk/kernel/eventflag.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/eventflag.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/eventflag.h	(revision 317)
@@ -0,0 +1,174 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¤ãã³ããã©ã°æ©è½
+ */
+
+#ifndef TOPPERS_EVENTFLAG_H
+#define TOPPERS_EVENTFLAG_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  ã¤ãã³ããã©ã°åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct eventflag_initialization_block {
+	ATR			flgatr;			/* ã¤ãã³ããã©ã°å±æ§ */
+	FLGPTN		iflgptn;		/* ã¤ãã³ããã©ã°ã®ããããã¿ã¼ã³ã®åæå¤ */
+} FLGINIB;
+
+/*
+ *  ã¤ãã³ããã©ã°ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct eventflag_control_block {
+	QUEUE		wait_queue;		/* ã¤ãã³ããã©ã°å¾
+ã¡ã­ã¥ã¼ */
+	const FLGINIB *p_flginib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	FLGPTN		flgptn;			/* ã¤ãã³ããã©ã°ç¾å¨ãã¿ã¼ã³ */
+} FLGCB;
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®2ã¤ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ *
+ *  waiptnã«ã¯ï¼å¾
+ã¡ç¶æ
+ã®éã¯å¾
+ã¡ãã¿ã¼ã³ãï¼å¾
+ã¡è§£é¤ãããå¾ã¯å¾
+ã¡è§£
+ *  é¤æã®ãã¿ã¼ã³ãå
+¥ããï¼1ã¤ã®ãã£ã¼ã«ãã2ã¤ã®ç®çã«å
+¼ç¨ãã¦ããï¼ï¼
+ */
+typedef struct eventflag_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	FLGCB		*p_flgcb;		/* å¾
+ã£ã¦ããã¤ãã³ããã©ã°ã®ç®¡çãã­ãã¯ */
+	FLGPTN		waiptn;			/* å¾
+ã¡ãã¿ã¼ã³ï¼å¾
+ã¡è§£é¤æã®ãã¿ã¼ã³ */
+	MODE		wfmode;			/* å¾
+ã¡ã¢ã¼ã */
+} WINFO_FLG;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã¤ãã³ããã©ã°ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_flgcb;
+
+/*
+ *  ã¤ãã³ããã©ã°IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_flgid;
+extern const ID	tmax_sflgid;
+
+/*
+ *  ã¤ãã³ããã©ã°åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const FLGINIB	flginib_table[];
+extern FLGINIB			aflginib_table[];
+
+/*
+ *  ã¤ãã³ããã©ã°ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern FLGCB	flgcb_table[];
+
+/*
+ *  ã¤ãã³ããã©ã°ç®¡çãã­ãã¯ããã¤ãã³ããã©ã°IDãåãåºãããã®ãã¯ã­
+ */
+#define	FLGID(p_flgcb)	((ID)(((p_flgcb) - flgcb_table) + TMIN_FLGID))
+
+/*
+ *  ã¤ãã³ããã©ã°æ©è½ã®åæå
+ */
+extern void	initialize_eventflag(void);
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡è§£é¤æ¡ä»¶ã®ãã§ãã¯
+ */
+extern bool_t	check_flg_cond(FLGCB *p_flgcb, FLGPTN waiptn,
+								MODE wfmode, FLGPTN *p_flgptn);
+
+#endif /* TOPPERS_EVENTFLAG_H */
Index: asp3_gr_sakura/trunk/kernel/eventflag.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/eventflag.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/eventflag.trb	(revision 317)
@@ -0,0 +1,90 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: eventflag.trb 588 2016-02-05 12:54:58Z ertl-hiro $
+# 
+
+#
+#		ã¤ãã³ããã©ã°æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class EventflagObject < KernelObject
+  def initialize()
+    super("flg", "eventflag")
+  end
+
+  def prepare(key, params)
+    # flgatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI1562ï¼½
+    #ï¼TA_TPRIï¼TA_WMULï¼TA_CLRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:flgatr] & ~($TA_TPRI|$TA_WMUL|$TA_CLR)) != 0
+      error_illegal_id("E_RSATR", params, :flgatr, :flgid)
+    end
+
+    # iflgptnãFLGPTNã«æ ¼ç´ã§ããªãå ´åï¼E_PARï¼ï¼»NGKI3275ï¼½
+    if (params[:iflgptn] & ~((1 << $TBIT_FLGPTN) - 1)) != 0
+      error_wrong_id("E_PAR", params, :iflgptn, :flgid, "too large")
+    end
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:flgatr]}), (#{params[:iflgptn]})")
+  end
+end
+
+#
+#  ã¤ãã³ããã©ã°ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Eventflag Functions")
+EventflagObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/exception.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/exception.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/exception.c	(revision 317)
@@ -0,0 +1,126 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		CPUä¾å¤ç®¡çæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "task.h"
+#include "exception.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_XSNS_DPN_ENTER
+#define LOG_XSNS_DPN_ENTER(p_excinf)
+#endif /* LOG_XSNS_DPN_ENTER */
+
+#ifndef LOG_XSNS_DPN_LEAVE
+#define LOG_XSNS_DPN_LEAVE(state)
+#endif /* LOG_XSNS_DPN_LEAVE */
+
+/* 
+ *  CPUä¾å¤ãã³ãã©ç®¡çæ©è½ã®åæå
+ */
+#ifdef TOPPERS_excini
+#ifndef OMIT_INITIALIZE_EXCEPTION
+
+void
+initialize_exception(void)
+{
+	uint_t			i;
+	const EXCINIB	*p_excinib;
+
+	for (i = 0; i < tnum_def_excno; i++) {
+		p_excinib = &(excinib_table[i]);
+		define_exc(p_excinib->excno, p_excinib->exc_entry);
+	}
+}
+
+#endif /* OMIT_INITIALIZE_EXCEPTION */
+#endif /* TOPPERS_excini */
+
+/*
+ *  CPUä¾å¤ã®çºçããã³ã³ãã­ã¹ãã®åç
+§
+ */
+
+/*
+ *  CPUä¾å¤çºçæã®ãã£ã¹ãããä¿çç¶æ
+ã®åç
+§
+ *
+ *  CPUä¾å¤ãã³ãã©ä¸­ã§enadspãå¤åãããã¨ã¯ãªãããï¼CPUä¾å¤ãçºçã
+ *  ãæã®enadspãä¿å­ãã¦ããå¿
+è¦ã¯ãªãï¼
+ */
+#ifdef TOPPERS_xsns_dpn
+
+bool_t
+xsns_dpn(void *p_excinf)
+{
+	bool_t	state;
+
+	LOG_XSNS_DPN_ENTER(p_excinf);
+	state = (kerflg && exc_sense_intmask(p_excinf) && enadsp
+								&& p_runtsk != NULL) ? false : true;
+	LOG_XSNS_DPN_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_xsns_dpn */
Index: asp3_gr_sakura/trunk/kernel/exception.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/exception.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/exception.h	(revision 317)
@@ -0,0 +1,96 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2007 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		CPUä¾å¤ç®¡çæ©è½
+ */
+
+#ifndef TOPPERS_EXCEPTION_H
+#define TOPPERS_EXCEPTION_H
+
+#include "kernel_impl.h"
+
+#ifndef OMIT_INITIALIZE_EXCEPTION
+
+/*
+ *  CPUä¾å¤ãã³ãã©åæåãã­ãã¯
+ */
+typedef struct cpu_exception_handler_initialization_block {
+	EXCNO		excno;			/* CPUä¾å¤ãã³ãã©çªå· */
+	ATR			excatr;			/* CPUä¾å¤ãã³ãã©å±æ§ */
+	FP			exc_entry;		/* CPUä¾å¤ãã³ãã©ã®åºå
+¥å£å¦çã®çªå° */
+} EXCINIB;
+
+/*
+ *  å®ç¾©ããCPUä¾å¤ãã³ãã©çªå·ã®æ°ï¼kernel_cfg.cï¼
+ */
+extern const uint_t	tnum_def_excno;
+
+/*
+ *  CPUä¾å¤ãã³ãã©åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const EXCINIB	excinib_table[];
+
+#endif /* OMIT_INITIALIZE_EXCEPTION */
+
+/*
+ *  CPUä¾å¤ãã³ãã©ç®¡çæ©è½ã®åæå
+ */
+extern void	initialize_exception(void);
+
+#endif /* TOPPERS_EXCEPTION_H */
Index: asp3_gr_sakura/trunk/kernel/exception.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/exception.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/exception.trb	(revision 317)
@@ -0,0 +1,126 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: exception.trb 663 2016-02-27 04:45:50Z ertl-hiro $
+# 
+
+#
+#		CPUä¾å¤ç®¡çæ©è½ã®çæã¹ã¯ãªãã
+#
+
+#
+#  kernel_cfg.cã®çæ
+#
+$kernelCfgC.comment_header("CPU Exception Management Functions")
+
+#
+#  CPUä¾å¤ãã³ãã©ã«é¢ããã¨ã©ã¼ãã§ãã¯
+#
+$cfgData[:DEF_EXC].each do |key, params|
+  # excnoãCPUä¾å¤ãã³ãã©çªå·ã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼ï¼»NGKI3134ï¼½
+  if $EXCNO_VALID.index(params[:excno]).nil?
+    error_illegal("E_PAR", params, :excno)
+  end
+
+  # excatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI3131ï¼½
+  #ï¼TARGET_EXCATRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+  if (params[:excatr] & ~($TARGET_EXCATR)) != 0
+    error_illegal_sym("E_RSATR", params, :excatr, :excno)
+  end
+end
+
+#
+#  CPUä¾å¤ãã³ãã©ã®ããã®æ¨æºçãªåæåæ
+å ±ã®çæ
+#
+if !$OMIT_INITIALIZE_EXCEPTION
+  #
+  #  å®ç¾©ããCPUä¾å¤ãã³ãã©ã®æ°
+  #
+  $kernelCfgC.add(<<EOS)
+#define TNUM_DEF_EXCNO	#{$cfgData[:DEF_EXC].size}
+const uint_t _kernel_tnum_def_excno = TNUM_DEF_EXCNO;
+EOS
+
+  if $cfgData[:DEF_EXC].size != 0
+    #
+    #  CPUä¾å¤ãã³ãã©ã®ã¨ã³ããª
+    #
+    $cfgData[:DEF_EXC].each do |key, params|
+      $kernelCfgC.add("EXCHDR_ENTRY(#{params[:excno]}, " \
+						"#{params[:excno].val}, #{params[:exchdr]})")
+    end
+    $kernelCfgC.add("")
+
+    #
+    #  CPUä¾å¤ãã³ãã©åæåãã­ãã¯
+    #
+    $kernelCfgC.add("const EXCINIB _kernel_excinib_table[TNUM_DEF_EXCNO] = {")
+    $cfgData[:DEF_EXC].each_with_index do |(key, params), index|
+      $kernelCfgC.add(",") if index > 0
+      $kernelCfgC.append("\t{ (#{params[:excno]}), (#{params[:excatr]}), " \
+				"(FP)(EXC_ENTRY(#{params[:excno]}, #{params[:exchdr]})) }")
+    end
+    $kernelCfgC.add
+    $kernelCfgC.add2("};")
+  else
+    $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(const EXCINIB, " \
+										"_kernel_excinib_table);")
+  end
+end
+
+#
+#  CPUä¾å¤ç®¡çæ©è½åæåé¢æ°ã®è¿½å 
+#
+$initializeFunctions.push("_kernel_initialize_exception();")
Index: asp3_gr_sakura/trunk/kernel/genoffset.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/genoffset.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/genoffset.trb	(revision 317)
@@ -0,0 +1,164 @@
+# -*- coding: utf-8 -*-
+# 
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2011-2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+#  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: genoffset.trb 662 2016-02-27 02:33:51Z ertl-hiro $
+# 
+
+#
+#		ãªãã»ãããã¡ã¤ã«çæç¨ã®çæã¹ã¯ãªãã
+#
+
+# 
+#  ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®æå®
+# 
+$timeStampFileName = "offset.timestamp"
+
+# 
+#  offset.hã®å
+é ­é¨åã®çæ
+# 
+$offsetH = GenFile.new("offset.h")
+$offsetH.add2("/* offset.h */")
+
+# 
+#  #defineãã£ã¬ã¯ãã£ãã®çæ
+# 
+def GenerateDefine(symbol, value)
+  $offsetH.add("#define #{symbol}\t#{value}")
+end
+
+# 
+#  ãããã®ãµã¼ã
+# 
+def SearchBit(val)
+  (0..7).each do |valBit|
+    if (val & 1) != 0
+      return valBit
+    end
+    val >>= 1
+  end
+end
+
+# 
+#  ããããã£ã¼ã«ãã®ãªãã»ããã¨ãããä½ç½®ã®å®ç¾©ã®çæ
+# 
+def GenerateDefineBit(label, structSize, outputSize)
+  top = SYMBOL(label)
+  if top.nil?
+    error_exit("label `#{label}' not found")
+  else
+    val = 0
+    offset = 0
+    0.upto(structSize - 1).each do |i|
+      tmpVal = PEEK(top + i, 1)
+      if tmpVal != 0
+        val = tmpVal
+        offset = i
+        break
+      end
+    end
+
+    if val == 0
+      error_exit("bit not found in `#{label}'")
+    else
+      valBit = SearchBit(val)
+      case outputSize
+      when "W"
+        if $SIL_ENDIAN_BIG
+          valBit = valBit + 24 - ((offset & 0x03) << 3)
+        else
+          valBit = valBit + ((offset & 0x03) << 3)
+        end
+        offset &= ~0x03
+      when "H"
+        if $SIL_ENDIAN_BIG
+          valBit = valBit + 8 - ((offset & 0x01) << 3)
+        else
+          valBit = valBit + ((offset & 0x01) << 3)
+        end
+        offset &= ~0x01
+      end
+    end
+
+    $offsetH.add("#define #{label}\t#{offset}")
+    $offsetH.add("#define #{label}_bit\t#{valBit}")
+    $offsetH.add("#define #{label}_mask\t#{sprintf("0x%x", 1 << valBit)}")
+  end
+end
+
+# 
+#  ãã¤ãé
+ç½®ã®ãã§ãã¯
+# 
+def magicCheck(size, check)
+  label = "MAGIC_#{size}"
+  top = SYMBOL(label)
+  if top.nil?
+    error_exit("label `#{label}' not found")
+  else
+    1.upto(size).each do |offset|
+      if $SIL_ENDIAN_BIG
+        val = PEEK(top + offset - 1, 1)
+      else
+        val = PEEK(top + size - offset, 1)
+      end
+      if val != check.at(offset - 1)
+        error_exit("value check of `#{label}' failed")
+      end
+    end
+  end
+end
+
+magicCheck(1, [ 0x12 ])
+magicCheck(2, [ 0x12, 0x34 ])
+magicCheck(4, [ 0x12, 0x34, 0x56, 0x78 ])
Index: asp3_gr_sakura/trunk/kernel/interrupt.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/interrupt.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/interrupt.c	(revision 317)
@@ -0,0 +1,707 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å²è¾¼ã¿ç®¡çæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "interrupt.h"
+#include "overrun.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ISR_ENTER
+#define LOG_ISR_ENTER(isrid)
+#endif /* LOG_ISR_ENTER */
+
+#ifndef LOG_ISR_LEAVE
+#define LOG_ISR_LEAVE(isrid)
+#endif /* LOG_ISR_LEAVE */
+
+#ifndef LOG_ACRE_ISR_ENTER
+#define LOG_ACRE_ISR_ENTER(pk_cisr)
+#endif /* LOG_ACRE_ISR_ENTER */
+
+#ifndef LOG_ACRE_ISR_LEAVE
+#define LOG_ACRE_ISR_LEAVE(ercd)
+#endif /* LOG_ACRE_ISR_LEAVE */
+
+#ifndef LOG_DEL_ISR_ENTER
+#define LOG_DEL_ISR_ENTER(isrid)
+#endif /* LOG_DEL_ISR_ENTER */
+
+#ifndef LOG_DEL_ISR_LEAVE
+#define LOG_DEL_ISR_LEAVE(ercd)
+#endif /* LOG_DEL_ISR_LEAVE */
+
+#ifndef LOG_DIS_INT_ENTER
+#define LOG_DIS_INT_ENTER(intno)
+#endif /* LOG_DIS_INT_ENTER */
+
+#ifndef LOG_DIS_INT_LEAVE
+#define LOG_DIS_INT_LEAVE(ercd)
+#endif /* LOG_DIS_INT_LEAVE */
+
+#ifndef LOG_ENA_INT_ENTER
+#define LOG_ENA_INT_ENTER(intno)
+#endif /* LOG_ENA_INT_ENTER */
+
+#ifndef LOG_ENA_INT_LEAVE
+#define LOG_ENA_INT_LEAVE(ercd)
+#endif /* LOG_ENA_INT_LEAVE */
+
+#ifndef LOG_CLR_INT_ENTER
+#define LOG_CLR_INT_ENTER(intno)
+#endif /* LOG_CLR_INT_ENTER */
+
+#ifndef LOG_CLR_INT_LEAVE
+#define LOG_CLR_INT_LEAVE(ercd)
+#endif /* LOG_CLR_INT_LEAVE */
+
+#ifndef LOG_RAS_INT_ENTER
+#define LOG_RAS_INT_ENTER(intno)
+#endif /* LOG_RAS_INT_ENTER */
+
+#ifndef LOG_RAS_INT_LEAVE
+#define LOG_RAS_INT_LEAVE(ercd)
+#endif /* LOG_RAS_INT_LEAVE */
+
+#ifndef LOG_PRB_INT_ENTER
+#define LOG_PRB_INT_ENTER(intno)
+#endif /* LOG_PRB_INT_ENTER */
+
+#ifndef LOG_PRB_INT_LEAVE
+#define LOG_PRB_INT_LEAVE(ercd)
+#endif /* LOG_PRB_INT_LEAVE */
+
+#ifndef LOG_CHG_IPM_ENTER
+#define LOG_CHG_IPM_ENTER(intpri)
+#endif /* LOG_CHG_IPM_ENTER */
+
+#ifndef LOG_CHG_IPM_LEAVE
+#define LOG_CHG_IPM_LEAVE(ercd)
+#endif /* LOG_CHG_IPM_LEAVE */
+
+#ifndef LOG_GET_IPM_ENTER
+#define LOG_GET_IPM_ENTER(p_intpri)
+#endif /* LOG_GET_IPM_ENTER */
+
+#ifndef LOG_GET_IPM_LEAVE
+#define LOG_GET_IPM_LEAVE(ercd, p_intpri)
+#endif /* LOG_GET_IPM_LEAVE */
+
+/*
+ *  å²è¾¼ã¿çªå·ã®ç¯å²ã®å¤å®
+ */
+#ifndef VALID_INTNO_DISINT
+#define VALID_INTNO_DISINT(intno)	VALID_INTNO(intno)
+#endif /* VALID_INTNO_DISINT */
+
+#ifndef VALID_INTNO_CLRINT
+#define VALID_INTNO_CLRINT(intno)	VALID_INTNO(intno)
+#endif /* VALID_INTNO_CLRINT */
+
+#ifndef VALID_INTNO_RASINT
+#define VALID_INTNO_RASINT(intno)	VALID_INTNO(intno)
+#endif /* VALID_INTNO_RASINT */
+
+#ifndef VALID_INTNO_PRBINT
+#define VALID_INTNO_PRBINT(intno)	VALID_INTNO(intno)
+#endif /* VALID_INTNO_PRBINT */
+
+#ifndef VALID_INTNO_CREISR
+#define VALID_INTNO_CREISR(intno)	VALID_INTNO(intno)
+#endif /* VALID_INTNO_CREISR */
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ã®ç¯å²ã®å¤å®
+ */
+#ifndef VALID_INTPRI_CHGIPM
+#define VALID_INTPRI_CHGIPM(intpri)	\
+					(TMIN_INTPRI <= (intpri) && (intpri) <= TIPM_ENAALL)
+#endif /* VALID_INTPRI_CHGIPM */
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®æ°
+ */
+#define tnum_isr	((uint_t)(tmax_isrid - TMIN_ISRID + 1))
+#define tnum_sisr	((uint_t)(tmax_sisrid - TMIN_ISRID + 1))
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³IDããå²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯ãå
+ *  ãåºãããã®ãã¯ã­
+ */
+#define INDEX_ISR(isrid)	((uint_t)((isrid) - TMIN_ISRID))
+#define get_isrcb(isrid)	(&(isrcb_table[INDEX_ISR(isrid)]))
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã­ã¥ã¼ã¸ã®ç»é²
+ */
+Inline void
+enqueue_isr(QUEUE *p_isr_queue, ISRCB *p_isrcb)
+{
+	QUEUE	*p_entry;
+	PRI		isrpri = p_isrcb->p_isrinib->isrpri;
+
+	for (p_entry = p_isr_queue->p_next; p_entry != p_isr_queue;
+											p_entry = p_entry->p_next) {
+		if (isrpri < ((ISRCB *) p_entry)->p_isrinib->isrpri) {
+			break;
+		}
+	}
+	queue_insert_prev(p_entry, &(p_isrcb->isr_queue));
+}
+
+#ifdef TOPPERS_isrini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãå²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_isrcb;
+
+/* 
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³æ©è½ã®åæå
+ */
+void
+initialize_isr(void)
+{
+	uint_t	i, j;
+	ISRCB	*p_isrcb;
+	ISRINIB	*p_isrinib;
+
+	for (i = 0; i < tnum_isr_queue; i++) {
+		queue_initialize(&(isr_queue_table[i]));
+	}
+	for (i = 0; i < tnum_sisr; i++) {
+		j = INDEX_ISR(isrorder_table[i]);
+		p_isrcb = &(isrcb_table[j]);
+		p_isrcb->p_isrinib = &(isrinib_table[j]);
+		enqueue_isr(p_isrcb->p_isrinib->p_isr_queue, p_isrcb);
+	}
+	queue_initialize(&free_isrcb);
+	for (j = 0; i < tnum_isr; i++, j++) {
+		p_isrcb = &(isrcb_table[i]);
+		p_isrinib = &(aisrinib_table[j]);
+		p_isrinib->isratr = TA_NOEXS;
+		p_isrcb->p_isrinib = ((const ISRINIB *) p_isrinib);
+		queue_insert_prev(&free_isrcb, &(p_isrcb->isr_queue));
+	}
+}
+
+#endif /* TOPPERS_isrini */
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å¼åºã
+ */
+#ifdef TOPPERS_isrcal
+
+void
+call_isr(QUEUE *p_isr_queue)
+{
+	QUEUE	*p_queue;
+	ISRCB	*p_isrcb;
+
+	for (p_queue = p_isr_queue->p_next; p_queue != p_isr_queue;
+											p_queue = p_queue->p_next) {
+		p_isrcb = (ISRCB *) p_queue;
+		LOG_ISR_ENTER(ISRID(p_isrcb));
+		(*(p_isrcb->p_isrinib->isr))(p_isrcb->p_isrinib->exinf);
+		LOG_ISR_LEAVE(ISRID(p_isrcb));
+
+		if (p_queue->p_next != p_isr_queue) {
+			/* ISRã®å¼åºãåã®ç¶æ
+ã«æ»ã */
+			if (sense_lock()) {
+				unlock_cpu();
+			}
+		}
+	}
+}
+
+#endif /* TOPPERS_isrcal */
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ã®æ¤ç´¢
+ */
+Inline QUEUE *
+search_isr_queue(INTNO intno)
+{
+	int_t	left, right, i;
+
+	if (tnum_isr_queue == 0) {
+		return(NULL);
+	}
+
+	left = 0;
+	right = tnum_isr_queue - 1;
+	while (left < right) {
+		i = (left + right + 1) / 2;
+		if (intno < isr_queue_list[i].intno) {
+			right = i - 1;
+		}
+		else {
+			left = i;
+		}
+	}
+	if (isr_queue_list[left].intno == intno) {
+		return(isr_queue_list[left].p_isr_queue);
+	}
+	else {
+		return(NULL);
+	}
+}
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®çæ
+ *
+ *  pk_cisr->exinfã¯ï¼ã¨ã©ã¼ãã§ãã¯ãããï¼ä¸åº¦ããåç
+§ããªãããï¼ã­ã¼
+ *  ã«ã«å¤æ°ã«ã³ãã¼ããå¿
+è¦ããªãï¼éä¸­ã§æ¸ãæãã£ã¦ãæ¯éããªãï¼ï¼
+ */
+#ifdef TOPPERS_acre_isr
+
+ER_UINT
+acre_isr(const T_CISR *pk_cisr)
+{
+	ISRCB		*p_isrcb;
+	ISRINIB		*p_isrinib;
+	QUEUE		*p_isr_queue;
+	ATR			isratr;
+	INTNO		intno;
+	ISR			isr;
+	PRI			isrpri;
+	ER			ercd;
+
+	LOG_ACRE_ISR_ENTER(pk_cisr);
+	CHECK_TSKCTX_UNL();
+
+	isratr = pk_cisr->isratr;
+	intno = pk_cisr->intno;
+	isr = pk_cisr->isr;
+	isrpri = pk_cisr->isrpri;
+
+	CHECK_RSATR(isratr, TARGET_ISRATR);
+	CHECK_PAR(VALID_INTNO_CREISR(intno));
+	CHECK_PAR(FUNC_ALIGN(isr));
+	CHECK_PAR(FUNC_NONNULL(isr));
+	CHECK_PAR(VALID_ISRPRI(isrpri));
+
+	p_isr_queue = search_isr_queue(intno);
+	CHECK_OBJ(p_isr_queue != NULL);
+
+	lock_cpu();
+	if (tnum_isr == 0 || queue_empty(&free_isrcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		p_isrcb = ((ISRCB *) queue_delete_next(&free_isrcb));
+		p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib);
+		p_isrinib->isratr = isratr;
+		p_isrinib->exinf = pk_cisr->exinf;
+		p_isrinib->p_isr_queue = p_isr_queue;
+		p_isrinib->isr = isr;
+		p_isrinib->isrpri = isrpri;
+		enqueue_isr(p_isr_queue, p_isrcb);
+		ercd = ISRID(p_isrcb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_ISR_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_isr */
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®åé¤
+ */
+#ifdef TOPPERS_del_isr
+
+ER
+del_isr(ID isrid)
+{
+	ISRCB	*p_isrcb;
+	ISRINIB	*p_isrinib;
+	ER		ercd;
+
+	LOG_DEL_ISR_ENTER(isrid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_ISRID(isrid));
+	p_isrcb = get_isrcb(isrid);
+
+	lock_cpu();
+	if (p_isrcb->p_isrinib->isratr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (isrid <= tmax_sisrid) {
+		ercd = E_OBJ;
+	}
+	else {
+		queue_delete(&(p_isrcb->isr_queue));
+		p_isrinib = (ISRINIB *)(p_isrcb->p_isrinib);
+		p_isrinib->isratr = TA_NOEXS;
+		queue_insert_prev(&free_isrcb, &(p_isrcb->isr_queue));
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_ISR_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_isr */
+
+/* 
+ *  å²è¾¼ã¿ç®¡çæ©è½ã®åæå
+ */
+#ifdef TOPPERS_intini
+#ifndef OMIT_INITIALIZE_INTERRUPT
+
+void
+initialize_interrupt(void)
+{
+	uint_t			i;
+	const INHINIB	*p_inhinib;
+	const INTINIB	*p_intinib;
+
+	for (i = 0; i < tnum_def_inhno; i++) {
+		p_inhinib = &(inhinib_table[i]);
+		define_inh(p_inhinib->inhno, p_inhinib->int_entry);
+	}
+	for (i = 0; i < tnum_cfg_intno; i++) {
+		p_intinib = &(intinib_table[i]);
+		config_int(p_intinib->intno, p_intinib->intatr, p_intinib->intpri);
+	}
+}
+
+#endif /* OMIT_INITIALIZE_INTERRUPT */
+#endif /* TOPPERS_intini */
+
+/*
+ *  å²è¾¼ã¿ã®ç¦æ­¢ï¼»NGKI3555ï¼½
+ */
+#ifdef TOPPERS_dis_int
+#ifdef TOPPERS_SUPPORT_DIS_INT					/*ï¼»NGKI3093ï¼½*/
+
+ER
+dis_int(INTNO intno)
+{
+	bool_t	locked;
+	ER		ercd;
+
+	LOG_DIS_INT_ENTER(intno);
+	CHECK_PAR(VALID_INTNO_DISINT(intno));		/*ï¼»NGKI3083ï¼½ï¼»NGKI3087ï¼½*/
+
+	locked = sense_lock();
+	if (!locked) {
+		lock_cpu();
+	}
+	if (check_intno_cfg(intno)) {
+		disable_int(intno);						/*ï¼»NGKI3086ï¼½*/
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_OBJ;							/*ï¼»NGKI3085ï¼½*/
+	}
+	if (!locked) {
+		unlock_cpu();
+	}
+
+  error_exit:
+	LOG_DIS_INT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_SUPPORT_DIS_INT */
+#endif /* TOPPERS_dis_int */
+
+/*
+ *  å²è¾¼ã¿ã®è¨±å¯ï¼»NGKI3556ï¼½
+ */
+#ifdef TOPPERS_ena_int
+#ifdef TOPPERS_SUPPORT_ENA_INT					/*ï¼»NGKI3106ï¼½*/
+
+ER
+ena_int(INTNO intno)
+{
+	bool_t	locked;
+	ER		ercd;
+
+	LOG_ENA_INT_ENTER(intno);
+	CHECK_PAR(VALID_INTNO_DISINT(intno));		/*ï¼»NGKI3096ï¼½ï¼»NGKI3100ï¼½*/
+
+	locked = sense_lock();
+	if (!locked) {
+		lock_cpu();
+	}
+	if (check_intno_cfg(intno)) {
+		enable_int(intno);						/*ï¼»NGKI3099ï¼½*/
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_OBJ;							/*ï¼»NGKI3098ï¼½*/
+	}
+	if (!locked) {
+		unlock_cpu();
+	}
+
+  error_exit:
+	LOG_ENA_INT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_SUPPORT_ENA_INT */
+#endif /* TOPPERS_ena_int */
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ã¯ãªã¢ï¼»NGKI3920ï¼½
+ */
+#ifdef TOPPERS_clr_int
+#ifdef TOPPERS_SUPPORT_CLR_INT					/*ï¼»NGKI3927ï¼½*/
+
+ER
+clr_int(INTNO intno)
+{
+	bool_t	locked;
+	ER		ercd;
+
+	LOG_CLR_INT_ENTER(intno);
+	CHECK_PAR(VALID_INTNO_CLRINT(intno));		/*ï¼»NGKI3921ï¼½ï¼»NGKI3930ï¼½*/
+
+	locked = sense_lock();
+	if (!locked) {
+		lock_cpu();
+	}
+	if (check_intno_cfg(intno) && check_intno_clear(intno)) {
+		clear_int(intno);						/*ï¼»NGKI3924ï¼½*/
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_OBJ;							/*ï¼»NGKI3923ï¼½ï¼»NGKI3929ï¼½*/
+	}
+	if (!locked) {
+		unlock_cpu();
+	}
+
+  error_exit:
+	LOG_CLR_INT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_SUPPORT_CLR_INT */
+#endif /* TOPPERS_clr_int */
+
+/*
+ *  å²è¾¼ã¿ã®è¦æ±ï¼»NGKI3932ï¼½
+ */
+#ifdef TOPPERS_ras_int
+#ifdef TOPPERS_SUPPORT_RAS_INT					/*ï¼»NGKI3939ï¼½*/
+
+ER
+ras_int(INTNO intno)
+{
+	bool_t	locked;
+	ER		ercd;
+
+	LOG_RAS_INT_ENTER(intno);
+	CHECK_PAR(VALID_INTNO_RASINT(intno));		/*ï¼»NGKI3933ï¼½ï¼»NGKI3942ï¼½*/
+
+	locked = sense_lock();
+	if (!locked) {
+		lock_cpu();
+	}
+	if (check_intno_cfg(intno) && check_intno_raise(intno)) {
+		raise_int(intno);						/*ï¼»NGKI3936ï¼½*/
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_OBJ;							/*ï¼»NGKI3935ï¼½ï¼»NGKI3941ï¼½*/
+	}
+	if (!locked) {
+		unlock_cpu();
+	}
+
+  error_exit:
+	LOG_RAS_INT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_SUPPORT_RAS_INT */
+#endif /* TOPPERS_ras_int */
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ãã§ãã¯ï¼»NGKI3944ï¼½
+ */
+#ifdef TOPPERS_prb_int
+#ifdef TOPPERS_SUPPORT_PRB_INT					/*ï¼»NGKI3951ï¼½*/
+
+ER_BOOL
+prb_int(INTNO intno)
+{
+	bool_t	locked;
+	ER		ercd;
+
+	LOG_PRB_INT_ENTER(intno);
+	CHECK_PAR(VALID_INTNO_PRBINT(intno));		/*ï¼»NGKI3945ï¼½ï¼»NGKI3952ï¼½*/
+
+	locked = sense_lock();
+	if (!locked) {
+		lock_cpu();
+	}
+	if (check_intno_cfg(intno)) {
+		ercd = (ER_BOOL) probe_int(intno);		/*ï¼»NGKI3948ï¼½*/
+	}
+	else {
+		ercd = E_OBJ;							/*ï¼»NGKI3947ï¼½*/
+	}
+	if (!locked) {
+		unlock_cpu();
+	}
+
+  error_exit:
+	LOG_PRB_INT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_SUPPORT_PRB_INT */
+#endif /* TOPPERS_prb_int */
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®å¤æ´ï¼»NGKI3107ï¼½
+ */
+#ifdef TOPPERS_chg_ipm
+
+ER
+chg_ipm(PRI intpri)
+{
+	ER		ercd;
+
+	LOG_CHG_IPM_ENTER(intpri);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3108ï¼½ï¼»NGKI3109ï¼½*/
+	CHECK_PAR(VALID_INTPRI_CHGIPM(intpri));		/*ï¼»NGKI3113ï¼½ï¼»NGKI3114ï¼½*/
+
+	lock_cpu();
+	t_set_ipm(intpri);							/*ï¼»NGKI3111ï¼½*/
+	if (intpri == TIPM_ENAALL && enadsp) {
+		dspflg = true;
+		p_schedtsk = search_schedtsk();
+		if (p_runtsk->raster && p_runtsk->enater) {
+#ifdef TOPPERS_SUPPORT_OVRHDR
+			if (p_runtsk->staovr) {
+				(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+				ovrtimer_flag = false;
+			}
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+			task_terminate(p_runtsk);
+			exit_and_dispatch();
+			ercd = E_SYS;
+		}
+		else {
+			if (p_runtsk != p_schedtsk) {
+				dispatch();
+			}
+			ercd = E_OK;
+		}
+	}
+	else {
+		dspflg = false;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_CHG_IPM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_chg_ipm */
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®åç
+§ï¼»NGKI3115ï¼½
+ */
+#ifdef TOPPERS_get_ipm
+
+ER
+get_ipm(PRI *p_intpri)
+{
+	ER		ercd;
+
+	LOG_GET_IPM_ENTER(p_intpri);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3116ï¼½ï¼»NGKI3117ï¼½*/
+
+	lock_cpu();
+	*p_intpri = t_get_ipm();					/*ï¼»NGKI3120ï¼½*/
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_IPM_LEAVE(ercd, p_intpri);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_ipm */
Index: asp3_gr_sakura/trunk/kernel/interrupt.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/interrupt.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/interrupt.h	(revision 317)
@@ -0,0 +1,210 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å²è¾¼ã¿ç®¡çæ©è½
+ */
+
+#ifndef TOPPERS_INTERRUPT_H
+#define TOPPERS_INTERRUPT_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åæåãã­ãã¯
+ */
+typedef struct isr_initialization_block {
+	ATR			isratr;			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å±æ§ */
+	intptr_t	exinf;			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®æ¡å¼µæ
+å ± */
+	QUEUE		*p_isr_queue;	/* ç»é²å
+å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ */
+	ISR			isr;			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å
+é ­çªå° */
+	PRI			isrpri;			/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åªå
+åº¦ */
+} ISRINIB;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯
+ */
+typedef struct isr_control_block {
+	QUEUE		isr_queue;		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ */
+	const ISRINIB *p_isrinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+} ISRCB;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ãæ¤ç´¢ããããã®ãã¼ã¿æ§é 
+ */
+typedef struct {
+	INTNO		intno;			/* å²è¾¼ã¿çªå· */
+	QUEUE		*p_isr_queue;	/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ */
+} ISR_ENTRY;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ã®ã¨ã³ããªæ°ï¼kernel_cfg.cï¼
+ */
+extern const uint_t tnum_isr_queue;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ãªã¹ãï¼kernel_cfg.cï¼
+ */
+extern const ISR_ENTRY isr_queue_list[];
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³å¼åºãã­ã¥ã¼ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern QUEUE isr_queue_table[];
+
+/*
+ *  ä½¿ç¨ãã¦ããªãå²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_isrcb;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_isrid;
+extern const ID	tmax_sisrid;
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const ISRINIB	isrinib_table[];
+extern ISRINIB			aisrinib_table[];
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³çæé åºãã¼ãã«ï¼kernel_cfg.cï¼
+ */
+extern const ID	isrorder_table[];
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern ISRCB	isrcb_table[];
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç®¡çãã­ãã¯ããå²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³IDãå
+ *  ãåºãããã®ãã¯ã­
+ */
+#define	ISRID(p_isrcb)	((ID)(((p_isrcb) - isrcb_table) + TMIN_ISRID))
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³æ©è½ã®åæå
+ */
+extern void initialize_isr(void);
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å¼åºã
+ */
+extern void call_isr(QUEUE *p_isr_queue);
+
+#if !defined(OMIT_INITIALIZE_INTERRUPT) || defined(USE_INHINIB_TABLE)
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©åæåãã­ãã¯
+ */
+typedef struct interrupt_handler_initialization_block {
+	INHNO		inhno;			/* å²è¾¼ã¿ãã³ãã©çªå· */
+	ATR			inhatr;			/* å²è¾¼ã¿ãã³ãã©å±æ§ */
+	FP			int_entry;		/* å²è¾¼ã¿ãã³ãã©ã®åºå
+¥å£å¦çã®çªå° */
+} INHINIB;
+
+/*
+ *  å®ç¾©ããå²è¾¼ã¿ãã³ãã©çªå·ã®æ°ï¼kernel_cfg.cï¼
+ */
+extern const uint_t	tnum_def_inhno;
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const INHINIB	inhinib_table[];
+
+#endif /* !defined(OMIT_INITIALIZE_INTERRUPT) || defined(USE_INHINIB_TABLE) */
+
+#if !defined(OMIT_INITIALIZE_INTERRUPT) || defined(USE_INTINIB_TABLE)
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³åæåãã­ãã¯
+ */
+typedef struct interrupt_request_initialization_block {
+	INTNO		intno;			/* å²è¾¼ã¿çªå· */
+	ATR			intatr;			/* å²è¾¼ã¿å±æ§ */
+	PRI			intpri;			/* å²è¾¼ã¿åªå
+åº¦ */
+} INTINIB;
+
+/*
+ *  è¨­å®ããå²è¾¼ã¿è¦æ±ã©ã¤ã³ã®æ°ï¼kernel_cfg.cï¼
+ */
+extern const uint_t	tnum_cfg_intno;
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const INTINIB	intinib_table[];
+
+#endif /* !defined(OMIT_INITIALIZE_INTERRUPT) || defined(USE_INTINIB_TABLE) */
+
+/*
+ *  å²è¾¼ã¿ç®¡çæ©è½ã®åæå
+ */
+extern void	initialize_interrupt(void);
+
+#endif /* TOPPERS_INTERRUPT_H */
Index: asp3_gr_sakura/trunk/kernel/interrupt.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/interrupt.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/interrupt.trb	(revision 317)
@@ -0,0 +1,448 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: interrupt.trb 678 2016-03-06 02:36:09Z ertl-hiro $
+# 
+
+#
+#		å²è¾¼ã¿ç®¡çæ©è½ã®çæã¹ã¯ãªãã
+#
+
+#
+#  kernel_cfg.cã®çæ
+#
+$kernelCfgC.comment_header("Interrupt Management Functions")
+
+#
+#  CRE_ISRã§ä½¿ç¨ã§ããå²è¾¼ã¿çªå·ã¨ããã«å¯¾å¿ããå²è¾¼ã¿ãã³ãã©çªå·ã®ã
+#  ãã©ã«ãå®ç¾©
+#
+if $INTNO_CREISR_VALID.nil?
+  $INTNO_CREISR_VALID = $INTNO_VALID
+end
+if $INHNO_CREISR_VALID.nil?
+  $INHNO_CREISR_VALID = $INHNO_VALID
+end
+
+#
+#  CFG_INTã§ä½¿ç¨ã§ããå²è¾¼ã¿åªå
+åº¦ã®ããã©ã«ãå®ç¾©
+# 
+if $INTPRI_CFGINT_VALID.nil?
+  $INTPRI_CFGINT_VALID = $TMIN_INTPRI.upto($TMAX_INTPRI).to_a
+end
+
+#
+#  å²è¾¼ã¿çªå·ã¨å²è¾¼ã¿ãã³ãã©çªå·ã®å¤æãã¼ãã«ã®ä½æ
+#
+if $INTNO_CREISR_VALID.length != $INHNO_CREISR_VALID.length
+  error_exit("length of `INTNO_CREISR_VALID' is different from" \
+									" length of `INHNO_CREISR_VALID'")
+end
+$toInhnoVal = {}
+$toIntnoVal = {}
+inhno_creisr_valid = $INHNO_CREISR_VALID.dup
+$INTNO_CREISR_VALID.each do |intnoVal|
+  inhnoVal = inhno_creisr_valid.shift
+  $toInhnoVal[intnoVal] = inhnoVal
+  $toIntnoVal[inhnoVal] = intnoVal
+end
+
+#
+#  å²è¾¼ã¿è¦æ±ã©ã¤ã³ã«é¢ããã¨ã©ã¼ãã§ãã¯
+#
+$cfgData[:CFG_INT].each do |key, params|
+  #	intnoãå²è¾¼ã¿çªå·ã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼ï¼»NGKI2972ï¼½
+  if $INTNO_VALID.index(params[:intno]).nil?
+    error_illegal("E_PAR", params, :intno)
+  end
+
+  #	intatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2969ï¼½
+  #ï¼TA_ENAINTï¼TA_EDGEï¼TARGET_INTATRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+  if (params[:intatr] & ~($TA_ENAINT|$TA_EDGE|$TARGET_INTATR)) != 0
+    error_illegal_sym("E_RSATR", params, :intatr, :intno)
+  end
+
+  #	intpriãCFG_INTã«å¯¾ããå²è¾¼ã¿åªå
+åº¦ã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼
+  #	ï¼»NGKI2973ï¼½
+  if $INTPRI_CFGINT_VALID.index(params[:intpri]).nil?
+    error_illegal_sym("E_OBJ", params, :intpri, :intno)
+  end
+
+  # ã«ã¼ãã«ç®¡çå¤ã«åºå®ããã¦ããintnoã«å¯¾ãã¦ï¼intpriã«TMIN_INTPRIã
+  #	ããå°ããå¤ãæå®ãããªãã£ãå ´åï¼E_OBJï¼ï¼»NGKI2983ï¼½
+  if !$INTNO_FIX_NONKERNEL.nil?
+    if !$INTNO_FIX_NONKERNEL.index(params[:intno]).nil?
+      if params[:intpri] >= $TMIN_INTPRI
+        error_ercd("E_OBJ", params, "%%intno must have higher priority " \
+											"than TMIN_INTPRI in %apiname")
+      end
+    end
+  end
+
+  #	ã«ã¼ãã«ç®¡çã«åºå®ããã¦ããintnoã«å¯¾ãã¦ï¼intpriã«TMIN_INTPRIãã
+  #	ãå°ããå¤ãæå®ãããå ´åï¼E_OBJï¼ï¼»NGKI2984ï¼½
+  if !$INTNO_FIX_KERNEL.nil?
+    if !$INTNO_FIX_KERNEL.index(params[:intno]).nil?
+      if params[:intpri] < $TMIN_INTPRI
+        error_ercd("E_OBJ", params, "%%intno must have lower or equal " \
+									"priority to TMIN_INTPRI in %apiname")
+      end
+    end
+  end
+end
+
+#
+#  å²è¾¼ã¿ãã³ãã©ã«é¢ããã¨ã©ã¼ãã§ãã¯
+#
+$cfgData[:DEF_INH].each do |key, params|
+  # inhnoãå²è¾¼ã¿ãã³ãã©çªå·ã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼ï¼»NGKI3055ï¼½
+  if $INHNO_VALID.index(params[:inhno]).nil?
+    error_illegal("E_PAR", params, :inhno)
+  end
+
+  # inhatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI3052ï¼½
+  #ï¼TARGET_INHATRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+  if (params[:inhatr] & ~($TARGET_INHATR)) != 0
+    error_illegal_sym("E_RSATR", params, :inhatr, :inhno)
+  end
+
+  #	ã«ã¼ãã«ç®¡çå¤ã«åºå®ããã¦ããinhnoã«å¯¾ãã¦ï¼inhatrã«TA_NONKERNELã
+  #	æå®ããã¦ããªãå ´åï¼E_RSATRï¼ï¼»NGKI3067ï¼½
+  if !$INHNO_FIX_NONKERNEL.nil?
+    if !$INHNO_FIX_NONKERNEL.index(params[:inhno]).nil?
+      if (params[:inhatr] & $TA_NONKERNEL) == 0
+        error_ercd("E_RSATR", params, "%%inhno must be " \
+								"non-kernel interrupt in %apiname")
+      end
+    end
+  end
+
+  #	ã«ã¼ãã«ç®¡çã«åºå®ããã¦ããinhnoã«å¯¾ãã¦ï¼inhatrã«TA_NONKERNELãæ
+  #	å®ããã¦ããå ´åï¼E_RSATRï¼ï¼»NGKI3068ï¼½
+  if !$INHNO_FIX_KERNEL.nil?
+    if !$INHNO_FIX_KERNEL.index(params[:inhno]).nil?
+      if (params[:inhatr] & $TA_NONKERNEL) != 0
+        error_ercd("E_RSATR", params, "%%inhno must not be " \
+								"non-kernel interrupt in %apiname")
+      end
+    end
+  end
+
+  if $toIntnoVal.has_key?(params[:inhno].val)
+    intnoVal = $toIntnoVal[params[:inhno].val]
+
+    # inhnoã«å¯¾å¿ããintnoã«å¯¾ããCFG_INTããªãå ´åï¼E_OBJï¼ï¼»NGKI3062ï¼½
+    if !$cfgData[:CFG_INT].has_key?(intnoVal)
+      error_ercd("E_OBJ", params, "intno `#{intnoVal}' corresponding to " \
+					"%%inhno in %apiname is not configured with CFG_INT")
+    else
+      intnoParams = $cfgData[:CFG_INT][intnoVal]
+      if (params[:inhatr] & $TA_NONKERNEL) == 0
+        # inhatrã«TA_NONKERNELãæå®ããã¦ãããï¼inhnoã«å¯¾å¿ããintno
+        # ã«å¯¾ãã¦CFG_INTã§è¨­å®ãããå²è¾¼ã¿åªå
+åº¦ãTMIN_INTPRIãããå°
+        # ããå ´åï¼E_OBJï¼ï¼»NGKI3065ï¼½
+        if intnoParams[:intpri] < $TMIN_INTPRI
+          error_ercd("E_OBJ", params, "intpri `#{intnoParams[:intpri]}' " \
+				"configured for %%inhno must be lower or equal to TMIN_INTPRI")
+        end
+      else
+        # inhatrã«TA_NONKERNELãæå®ããã¦ããï¼inhnoã«å¯¾å¿ããintnoã«
+        # å¯¾ãã¦CFG_INTã§è¨­å®ãããå²è¾¼ã¿åªå
+åº¦ãTMIN_INTPRIä»¥ä¸ã§ãã
+        # å ´åï¼E_OBJï¼ï¼»NGKI3066ï¼½
+        if intnoParams[:intpri] >= $TMIN_INTPRI
+          error_ercd("E_OBJ", params, "intpri `#{intnoParams[:intpri]}' " \
+					"configured for %%inhno must be higher than TMIN_INTPRI")
+        end
+      end
+    end
+  end
+end
+
+#
+#  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ï¼ISRï¼ã«é¢ããã¨ã©ã¼ãã§ãã¯
+#
+$cfgData[:CRE_ISR].sort.each do |key, params|
+  #	isratrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2998ï¼½
+  #ï¼TARGET_ISRATRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+  if (params[:isratr] & ~($TARGET_ISRATR)) != 0
+    error_illegal("E_RSATR", params, "isratr")
+  end
+
+  #	intnoãCRE_ISRã«å¯¾ããå²è¾¼ã¿çªå·ã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼
+  #	ï¼»NGKI3003ï¼½
+  if $INTNO_CREISR_VALID.index(params[:intno]).nil?
+    error_illegal("E_PAR", params, "intno")
+  end
+
+  #	(TMIN_ISRPRI <= isrpri && isrpri <= TMAX_ISRPRI)ã§ãªãå ´åï¼E_PARï¼
+  #	ï¼»NGKI3005ï¼½
+  if !($TMIN_ISRPRI <= params[:isrpri] && params[:isrpri] <= $TMAX_ISRPRI)
+    error_illegal("E_PAR", params, "isrpri")
+  end
+end
+
+$INTNO_CREISR_VALID.each do |intnoVal|
+  # å²è¾¼ã¿çªå·intnoã«å¯¾ãã¦ç»é²ãããISRã®ãªã¹ãã®ä½æ
+  isrParamsList = []
+  $cfgData[:CRE_ISR].sort.each do |key, params|
+    if params[:intno] == intnoVal
+      isrParamsList.push(params)
+    end
+  end
+
+  #	å²è¾¼ã¿çªå·intnoã«å¯¾ãã¦ç»é²ãããISRãå­å¨ããå ´å
+  if isrParamsList.size > 0
+    inhnoVal = $toInhnoVal[intnoVal]
+
+    # intnoã«å¯¾å¿ããinhnoã«å¯¾ãã¦DEF_INHãããå ´åï¼E_OBJï¼ï¼»NGKI3013ï¼½
+    if $cfgData[:DEF_INH].has_key?(inhnoVal)
+      inhnoParams = $cfgData[:DEF_INH][inhnoVal]
+      error_ercd("E_OBJ", isrParamsList[0], "%%intno in %apiname " \
+					"is duplicated with inhno #{inhnoParams[:inhno]}")
+    end
+
+    # intnoã«å¯¾ããCFG_INTããªãå ´åï¼E_OBJï¼ï¼»NGKI3012ï¼½
+    if !$cfgData[:CFG_INT].has_key?(intnoVal)
+      error_ercd("E_OBJ", isrParamsList[0], "%%intno in %apiname " \
+									"is not configured with CFG_INT")
+    else
+      intnoParams = $cfgData[:CFG_INT][intnoVal]
+
+      #	intnoã«å¯¾ãã¦CFG_INTã§è¨­å®ãããå²è¾¼ã¿åªå
+åº¦ãTMIN_INTPRIããã
+      #	å°ããå ´åï¼E_OBJï¼ï¼»NGKI3014ï¼½
+      if intnoParams[:intpri] < $TMIN_INTPRI
+        error_ercd("E_OBJ", isrParamsList[0],
+						"intpri `#{intnoParams[:intpri]}' configured for " \
+						"%%intno with CFG_INT in higher than TMIN_INTPRI")
+      end
+    end
+  end
+end
+
+#
+#  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ï¼ISRï¼ç®¡çã®ãã¼ã¿æ§é 
+#
+intnoIsrList = []
+$INTNO_CREISR_VALID.each do |intnoVal|
+  inhnoVal = $toInhnoVal[intnoVal]
+  if $cfgData[:CFG_INT].has_key?(intnoVal) \
+							&& !$cfgData[:DEF_INH].has_key?(inhnoVal)
+    intnoIsrList.push(intnoVal)
+  end
+end
+
+intnoIsrList.sort!
+$isrQueueHeader = {}
+intnoIsrList.each_with_index do |intnoVal, index|
+  $isrQueueHeader[intnoVal] = "&(_kernel_isr_queue_table[#{index}])"
+end
+
+$kernelCfgC.add2("const uint_t _kernel_tnum_isr_queue = #{intnoIsrList.size};")
+
+if intnoIsrList.size > 0
+  $kernelCfgC.add("const ISR_ENTRY _kernel_isr_queue_list" \
+										"[#{intnoIsrList.size}] = {")
+  intnoIsrList.each_with_index do |intnoVal, index|
+    $kernelCfgC.add(",") if index > 0
+    $kernelCfgC.append("\t{ #{intnoVal}, #{$isrQueueHeader[intnoVal]} }")
+  end
+  $kernelCfgC.add
+  $kernelCfgC.add2("};")
+  $kernelCfgC.add2("QUEUE _kernel_isr_queue_table[#{intnoIsrList.size}];")
+else
+  $kernelCfgC.add("TOPPERS_EMPTY_LABEL(const ISR_ENTRY, " \
+											"_kernel_isr_queue_list);")
+  $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(QUEUE, _kernel_isr_queue_table);")
+end
+
+#
+#  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ï¼ISRï¼å¼åºãã®ããã®å²è¾¼ã¿ãã³ãã©
+#
+intnoIsrList.each do |intnoVal|
+  inhnoVal = $toInhnoVal[intnoVal]
+
+  # æ¬¡ã®DEF_INHã«ç¸å½ãããã¼ã¿ãçæ
+  # DEF_INH(inhno, { TA_NULL, _kernel_inthdr_<intno> } );
+  $cfgData[:DEF_INH][inhnoVal] = {
+    inhno: NumStr.new(inhnoVal),
+    inhatr: NumStr.new($TA_NULL, "TA_NULL"),
+    inthdr: "_kernel_inthdr_#{intnoVal}"
+  }
+
+  # å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ç¨ã®å²è¾¼ã¿ãã³ãã©
+  $kernelCfgC.add("void")
+  $kernelCfgC.add("_kernel_inthdr_#{intnoVal}(void)")
+  $kernelCfgC.add("{")
+  $kernelCfgC.add("\t_kernel_call_isr(#{$isrQueueHeader[intnoVal]});");
+  $kernelCfgC.add2("}")
+end
+
+#
+#  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã«é¢ããä¸è¬çãªæ
+å ±ã®çæ
+#
+class IsrObject < KernelObject
+  def initialize()
+    super("isr", "isr")
+  end
+
+  def prepare(key, params)
+    # ã¨ã©ã¼ãã§ãã¯ã¯å®æ½æ¸ã¿ãªã®ã§ï¼ããã§ã®å¦çã¯ä¸è¦
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:isratr]}), (intptr_t)(#{params[:exinf]}), " \
+						"(#{$isrQueueHeader[params[:intno].val]}), " \
+						"(ISR)(#{params[:isr]}), (#{params[:isrpri]})")
+  end
+end
+IsrObject.new.generate()
+
+# å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³çæé åºãã¼ãã«ã®çæ
+$kernelCfgC.add("const ID _kernel_isrorder_table[TNUM_SISRID] = { ")
+$kernelCfgC.append("\t")
+$cfgData[:CRE_ISR].each_with_index do |(key, params), index|
+  $kernelCfgC.append(", ") if index > 0
+  $kernelCfgC.append("#{params[:isrid]}")
+end
+$kernelCfgC.add
+$kernelCfgC.add2("};")
+
+#
+#  å²è¾¼ã¿ãã³ãã©ã®ããã®æ¨æºçãªåæåæ
+å ±ã®çæ
+#
+if !$OMIT_INITIALIZE_INTERRUPT || $USE_INHINIB_TABLE
+  #
+  #  å®ç¾©ããå²è¾¼ã¿ãã³ãã©ã®æ°
+  #
+  $kernelCfgC.add(<<EOS)
+#define TNUM_DEF_INHNO	#{$cfgData[:DEF_INH].size}
+const uint_t _kernel_tnum_def_inhno = TNUM_DEF_INHNO;
+EOS
+
+  if $cfgData[:DEF_INH].size != 0
+    #
+    #  å²è¾¼ã¿ãã³ãã©ã®ã¨ã³ããª
+    #
+    $cfgData[:DEF_INH].each do |key, params|
+      if (params[:inhatr] & $TA_NONKERNEL) == 0
+        $kernelCfgC.add("INTHDR_ENTRY(#{params[:inhno]}, " \
+						"#{params[:inhno].val}, #{params[:inthdr]})")
+      end
+    end
+    $kernelCfgC.add("")
+
+    #
+    #  å²è¾¼ã¿ãã³ãã©åæåãã­ãã¯
+    #
+    $kernelCfgC.add("const INHINIB _kernel_inhinib_table[TNUM_DEF_INHNO] = {")
+    $cfgData[:DEF_INH].each_with_index do |(key, params), index|
+      $kernelCfgC.add(",") if index > 0
+      if (params[:inhatr] & $TA_NONKERNEL) == 0
+        inthdr = "(FP)(INT_ENTRY(#{params[:inhno]}, #{params[:inthdr]}))"
+      else
+        inthdr = "(FP)(#{params[:inthdr]})"
+      end
+      $kernelCfgC.append("\t{ (#{params[:inhno]}), (#{params[:inhatr]}), " \
+															"#{inthdr} }")
+    end
+    $kernelCfgC.add
+    $kernelCfgC.add2("};")
+  else
+    $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(const INHINIB, " \
+										"_kernel_inhinib_table);")
+  end
+end
+
+#
+#  å²è¾¼ã¿è¦æ±ã©ã¤ã³ã®ããã®æ¨æºçãªåæåæ
+å ±ã®çæ
+#
+if !$OMIT_INITIALIZE_INTERRUPT || $USE_INTINIB_TABLE
+  #
+  #  è¨­å®ããå²è¾¼ã¿è¦æ±ã©ã¤ã³ã®æ°
+  #
+  $kernelCfgC.add(<<EOS)
+#define TNUM_CFG_INTNO	#{$cfgData[:CFG_INT].size}
+const uint_t _kernel_tnum_cfg_intno = TNUM_CFG_INTNO;
+EOS
+
+  #
+  #  å²è¾¼ã¿è¦æ±ã©ã¤ã³åæåãã­ãã¯
+  #
+  if $cfgData[:CFG_INT].size != 0
+    $kernelCfgC.add("const INTINIB _kernel_intinib_table[TNUM_CFG_INTNO] = {")
+    $cfgData[:CFG_INT].each_with_index do |(key, params), index|
+      $kernelCfgC.add(",") if index > 0
+      $kernelCfgC.append("\t{ (#{params[:intno]}), (#{params[:intatr]}), " \
+													"(#{params[:intpri]}) }")
+    end
+    $kernelCfgC.add
+    $kernelCfgC.add2("};")
+  else
+    $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(const INTINIB, " \
+										"_kernel_intinib_table);")
+  end
+end
+
+#
+#  å²è¾¼ã¿ç®¡çæ©è½åæåé¢æ°ã®è¿½å 
+#
+$initializeFunctions.push("_kernel_initialize_interrupt();")
Index: asp3_gr_sakura/trunk/kernel/kernel.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel.trb	(revision 317)
@@ -0,0 +1,564 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: kernel.trb 716 2016-03-31 06:16:23Z ertl-hiro $
+# 
+
+#
+#		ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®ãã¹2ã®çæã¹ã¯ãªãã
+#
+
+#
+#  ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®æå®
+#
+$timeStampFileName = "kernel_cfg.timestamp"
+
+#
+#  kernel_cfg.hã®å
+é ­é¨åã®çæ
+#
+$kernelCfgH = GenFile.new("kernel_cfg.h")
+$kernelCfgH.add(<<EOS)
+/* kernel_cfg.h */
+#ifndef TOPPERS_KERNEL_CFG_H
+#define TOPPERS_KERNEL_CFG_H
+EOS
+
+#
+#  kernel_cfg.cã®å
+é ­é¨åã®çæ
+#
+$kernelCfgC = GenFile.new("kernel_cfg.c")
+$kernelCfgC.add(<<EOS)
+/* kernel_cfg.c */
+#include "kernel/kernel_int.h"
+#include "kernel_cfg.h"
+
+#if !(TKERNEL_PRID == 0x0007U && (TKERNEL_PRVER & 0xf000U) == 0x3000U)
+#error The kernel does not match this configuration file.
+#endif
+EOS
+
+#
+#  ã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ãã£ãï¼#includeï¼
+#
+$kernelCfgC.comment_header("Include Directives")
+$includeFiles.each do |file|
+  $kernelCfgC.add("#include #{file}")
+end
+$kernelCfgC.add()
+
+#
+#  ã¹ã¿ãã¯é åã®ç¢ºä¿é¢æ°
+#
+#  ã¹ã¿ãã¯é åã®å®ç¾©åã¨ï¼ã¹ã¿ãã¯é åã®ãµã¤ãºè¨è¿°ãé
+åã§è¿ãï¼
+#
+unless defined? AllocStack()
+  def AllocStack(stack, size)
+    # å¤§ããæ¹ã«ä¸¸ãããµã¤ãºã§ç¢ºä¿ããï¼»NGKI1050ï¼½ï¼»NGKI3220ï¼½
+    $kernelCfgC.add("static STK_T #{stack}[COUNT_STK_T(#{size})];")
+    return("ROUND_STK_T(#{size})")
+  end
+end
+
+#
+#  ã«ã¼ãã«ãªãã¸ã§ã¯ãã«é¢ããæ
+å ±ã®çæï¼ä»®æ³ã¯ã©ã¹ï¼
+#
+class KernelObject
+  def initialize(obj, object, obj_s = obj)
+    @obj = obj
+    @OBJ = obj.tr("a-z", "A-Z")
+    @object = object
+    @obj_s = obj_s
+    @OBJ_S = obj_s.tr("a-z", "A-Z")
+    @objid = (obj + "id").to_sym
+    @api = "CRE_#{@OBJ}".to_sym
+    @inibList = { "#{@OBJ_S}INIB" => "a#{@obj_s}inib_table"}
+  end
+
+  def generate()
+    # AID_@OBJã®å¦ç
+    numAutoObjid = 0
+    $cfgData["AID_#{@OBJ}".to_sym].each do |key, params|
+      numAutoObjid += params["no#{@obj}".to_sym]
+    end
+    numObjid = $cfgData[@api].size + numAutoObjid
+
+    # kernel_cfg.hã®çæ
+    $kernelCfgH.add("#define TNUM_#{@OBJ}ID\t#{numObjid}")
+
+    # ãªãã¸ã§ã¯ãã®IDçªå·ã®ãã¯ã­å®ç¾©ã®çæ
+    $cfgData[@api].sort.each do |key, params|
+      $kernelCfgH.add("#define #{params[@objid]}\t#{params[@objid].val}")
+    end
+    $kernelCfgH.add()
+
+    # ãªãã¸ã§ã¯ãã®IDçªå·ãä¿æããå¤æ°
+    if $USE_EXTERNAL_ID
+      $cfgData[@api].sort.each do |key, params|
+        $kernelCfgC.add("const ID #{params[@objid]}_id" \
+										" = #{params[@objid].val};")
+      end
+      $kernelCfgC.add()
+    end
+
+    # éçã«çæããããªãã¸ã§ã¯ãã®æ°
+    $kernelCfgC.add("#define TNUM_S#{@OBJ}ID\t#{$cfgData[@api].size}")
+
+    # ãªãã¸ã§ã¯ãIDçªå·ã®æå¤§å¤
+    $kernelCfgC.add("const ID _kernel_tmax_#{@obj}id" \
+							" = (TMIN_#{@OBJ}ID + TNUM_#{@OBJ}ID - 1);")
+    $kernelCfgC.add2("const ID _kernel_tmax_s#{@obj}id" \
+							" = (TMIN_#{@OBJ}ID + TNUM_S#{@OBJ}ID - 1);")
+
+    # ãã¼ã¿æ§é 
+    if $cfgData[@api].size > 0
+      # äºåæºåï¼ã¨ã©ã¼ãã§ãã¯ï¼ã¡ã¢ãªé åã®çæï¼
+      $cfgData[@api].sort.each do |key, params|
+        prepare(key, params)
+      end
+
+      # ãªãã¸ã§ã¯ãå
+¨ä½ã«å¯¾ãã¦å¿
+è¦ãªã¡ã¢ãªé åã®çæï¼ãªãã·ã§ã³ï¼
+      if respond_to?(:generateData)
+        generateData()
+      end
+
+      # ãªãã¸ã§ã¯ãåæåãã­ãã¯ã®çæ
+      $kernelCfgC.add("const #{@OBJ_S}INIB _kernel_#{@obj_s}inib_table" \
+													"[TNUM_S#{@OBJ}ID] = {")
+      $cfgData[@api].sort.each_with_index do |(key, params), index|
+        $kernelCfgC.add(",") if index > 0
+        $kernelCfgC.append("\t{ " + generateInib(key, params) + " }")
+      end
+      $kernelCfgC.add
+      $kernelCfgC.add2("};")
+    else
+      $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(const #{@OBJ_S}INIB, " \
+										"_kernel_#{@obj_s}inib_table);")
+    end
+
+    # åççæãªãã¸ã§ã¯ãç¨ã®ãªãã¸ã§ã¯ãåæåãã­ãã¯
+    @inibList.each do |type, array|
+      if numAutoObjid > 0
+        $kernelCfgC.add2("#{type} _kernel_#{array}[#{numAutoObjid}];")
+      else
+        $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(#{type}, _kernel_#{array});")
+      end
+    end
+
+    if numObjid > 0
+      # ãªãã¸ã§ã¯ãç®¡çãã­ãã¯ã®çæ
+      $kernelCfgC.add2("#{@OBJ_S}CB _kernel_#{@obj_s}cb_table" \
+													"[TNUM_#{@OBJ}ID];")
+
+      # ãªãã¸ã§ã¯ãåæåé¢æ°ã®è¿½å 
+      $initializeFunctions.push("_kernel_initialize_#{@object}();")
+    else
+      $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(#{@OBJ_S}CB, " \
+										"_kernel_#{@obj_s}cb_table);")
+    end
+  end
+end
+
+#
+#  éç¥ãã³ãã©ã®çæé¢æ°
+#
+def generateNotifyHandler(key, params, objid)
+  # ãã©ã¡ã¼ã¿ãå¤æ°ã«æ ¼ç´
+  nfymode = params[:nfymode]
+  nfymode1 = nfymode & 0x0f
+  nfymode2 = nfymode & ~0x0f
+  par1 = params[:par1]
+  par2 = params[:par2]
+
+  # éç¥å¦çã®ãã©ã¡ã¼ã¿æ°ã«ããè£æ­£å¦ç
+  if nfymode == $TNFY_HANDLER || nfymode1 == $TNFY_SETVAR \
+								|| nfymode1 == $TNFY_SETFLG \
+								|| nfymode1 == $TNFY_SNDDTQ
+    # éç¥å¦çã®ãã©ã¡ã¼ã¿ã2ã¤ã®å ´å
+	numpar = 2
+	epar1 = params[:par3]
+	epar2 = params[:par4]
+  else
+    # éç¥å¦çã®ãã©ã¡ã¼ã¿ã1ã¤ã®å ´å
+    numpar = 1
+    epar1 = params[:par2]
+    epar2 = params[:par3]
+  end
+
+  # ãã©ã¡ã¼ã¿æ°ã®ãã§ãã¯
+  if (numpar == 2 && par2.nil?) || (nfymode2 != 0 && epar1.nil?) \
+								|| (nfymode2 == $TENFY_SETFLG && epar2.nil?)
+    # ãã©ã¡ã¼ã¿ãè¶³ããªãå ´å
+    error_api(params, "too few parameters for nfymode `#{nfymode}' " \
+											"in %apiname of %#{objid}")
+  elsif (nfymode2 == 0 && !epar1.nil?) \
+					|| (nfymode2 != $TENFY_SETFLG && !epar2.nil?)
+    # ãã©ã¡ã¼ã¿ãå¤ãããå ´å
+    error_api(params, "too many parameters for nfymode `#{nfymode}' " \
+											"in %apiname of %#{objid}")
+  elsif nfymode == $TNFY_HANDLER
+    # ã¿ã¤ã ã¤ãã³ããã³ãã©ã®å¼åºã
+    funcname = "(NFYHDR)(#{par2})"
+  else
+    # éç¥ãã³ãã©ã®é¢æ°å
+    funcname = "_kernel_nfyhdr_#{params[objid]}"
+
+    # ã¨ã©ã¼éç¥ã®ããã®å¤æ°ã®ã¢ãã¬ã¹ã¨ãªãã¸ã§ã¯ãIDãæ ¼ç´ãã
+    # å¤æ°ã®çæï¼ã¨ã©ã¼ãã§ãã¯ã®ããã«å¿
+è¦ï¼
+    if nfymode2 == $TENFY_SETVAR || nfymode2 == $TENFY_INCVAR
+      $kernelCfgC.add2("intptr_t *const #{funcname}_p_evar =" \
+											" (intptr_t *)(#{epar1});")
+    elsif nfymode2 == $TENFY_ACTTSK || nfymode2 == $TENFY_WUPTSK
+      $kernelCfgC.add2("const ID #{funcname}_etskid = #{epar1};")
+    elsif nfymode2 == $TENFY_SIGSEM
+      $kernelCfgC.add2("const ID #{funcname}_esemid = #{epar1};")
+    elsif nfymode2 == $TENFY_SETFLG
+      $kernelCfgC.add2("const ID #{funcname}_eflgid = #{epar1};")
+    elsif nfymode2 == $TENFY_SNDDTQ
+      $kernelCfgC.add2("const ID #{funcname}_edtqid = #{epar1};")
+    end
+
+    # é¢æ°ã®å
+é ­é¨åã®çæ
+    $kernelCfgC.add("static void")
+    $kernelCfgC.add("#{funcname}(intptr_t exinf)")
+    $kernelCfgC.add("{")
+
+    if nfymode2 == 0
+      # ã¨ã©ã¼éç¥ããªãå ´å
+      errorCode = "(void) "
+    else
+      # ã¨ã©ã¼éç¥ãããå ´å
+      $kernelCfgC.add2("\tER\tercd;")
+      errorCode = "ercd = "
+    end
+
+    # ã¤ãã³ãéç¥å¦çã®å¦ç
+    if nfymode1 == $TNFY_SETVAR && nfymode2 == 0
+      # å¤æ°ã®è¨­å®
+      $kernelCfgC.add("\t*((intptr_t *) exinf) = (#{par2});")
+    elsif nfymode1 == $TNFY_INCVAR && nfymode2 == 0
+      # å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ã
+      $kernelCfgC.add("\t(void) loc_cpu();")
+      $kernelCfgC.add("\t*((intptr_t *) exinf) += 1;")
+      $kernelCfgC.add("\t(void) unl_cpu();")
+    elsif nfymode1 == $TNFY_ACTTSK
+      # ã¿ã¹ã¯ã®èµ·å
+      $kernelCfgC.add("\t#{errorCode}act_tsk((ID) exinf);")
+    elsif nfymode1 == $TNFY_WUPTSK
+      # ã¿ã¹ã¯ã®èµ·åº
+      $kernelCfgC.add("\t#{errorCode}wup_tsk((ID) exinf);")
+    elsif nfymode1 == $TNFY_SIGSEM
+      # ã»ããã©ã®è¿å´
+      $kernelCfgC.add("\t#{errorCode}sig_sem((ID) exinf);")
+    elsif nfymode1 == $TNFY_SETFLG
+      # ã¤ãã³ããã©ã°ã®ã»ãã
+      $kernelCfgC.add("\t#{errorCode}set_flg(((ID) exinf), #{par2});")
+    elsif nfymode1 == $TNFY_SNDDTQ
+      # ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+      $kernelCfgC.add("\t#{errorCode}psnd_dtq(((ID) exinf), #{par2});")
+    else
+      error_illegal_id("E_PAR", params, :nfymode, objid)
+    end
+			
+    if nfymode2 != 0
+      # ã¨ã©ã¼éç¥å¦çã®å¦ç
+      $kernelCfgC.add("\tif (ercd != E_OK) {")
+
+
+      if nfymode2 == $TENFY_SETVAR
+        # å¤æ°ã®è¨­å®
+        $kernelCfgC.add("\t\t*#{funcname}_p_evar = (intptr_t) ercd;")
+      elsif nfymode2 == $TENFY_INCVAR
+        # å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ã
+        $kernelCfgC.add("\t\t(void) loc_cpu();")
+        $kernelCfgC.add("\t\t*#{funcname}_p_evar += 1;")
+        $kernelCfgC.add("\t\t(void) unl_cpu();")
+      elsif nfymode2 == $TENFY_ACTTSK
+        # ã¿ã¹ã¯ã®èµ·å
+        $kernelCfgC.add("\t\t(void) act_tsk(#{funcname}_etskid);")
+      elsif nfymode2 == $TENFY_WUPTSK
+        # ã¿ã¹ã¯ã®èµ·åº
+        $kernelCfgC.add("\t\t(void) wup_tsk(#{funcname}_etskid);")
+      elsif nfymode2 == $TENFY_SIGSEM
+        # ã»ããã©ã®è¿å´
+        $kernelCfgC.add("\t\t(void) sig_sem(#{funcname}_esemid);")
+      elsif nfymode2 == $TENFY_SETFLG
+        # ã¤ãã³ããã©ã°ã®ã»ãã
+        $kernelCfgC.add("\t\t(void) set_flg(#{funcname}_eflgid, #{epar2});")
+      elsif nfymode2 == $TENFY_SNDDTQ
+        # ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+        $kernelCfgC.add("\t\t(void) psnd_dtq(#{funcname}_edtqid," \
+													" (intptr_t) ercd);")
+      else
+        error_illegal_id("E_PAR", params, :nfymode, objid)
+      end
+      $kernelCfgC.add("\t}")
+    end
+
+    # é¢æ°ã®æ«å°¾é¨åã®çæ
+    $kernelCfgC.add2("}")
+  end
+  return(funcname)
+end
+
+#
+#  åæ©è½ã¢ã¸ã¥ã¼ã«ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³
+#
+$initializeFunctions = []
+IncludeTrb("kernel/task.trb")
+IncludeTrb("kernel/semaphore.trb")
+IncludeTrb("kernel/eventflag.trb")
+IncludeTrb("kernel/dataqueue.trb")
+IncludeTrb("kernel/pridataq.trb")
+IncludeTrb("kernel/mutex.trb")
+IncludeTrb("kernel/mempfix.trb")
+IncludeTrb("kernel/cyclic.trb")
+IncludeTrb("kernel/alarm.trb")
+IncludeTrb("kernel/overrun.trb")
+IncludeTrb("kernel/interrupt.trb")
+IncludeTrb("kernel/exception.trb")
+
+#
+#  éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯é å
+#
+$kernelCfgC.comment_header("Stack Area for Non-task Context")
+
+if $cfgData[:DEF_ICS].size == 0
+  # DEF_ICSããªãå ´åã®ããã©ã«ãå¤ã®è¨­å®
+  if $DEFAULT_ISTK.nil?
+    # ã¹ã¿ãã¯é åã®èªåå²ä»ã
+    istksz = AllocStack("_kernel_istack", "DEFAULT_ISTKSZ")
+    istk = "_kernel_istack"
+  else
+    istksz = "DEFAULT_ISTKSZ"
+    istk = "DEFAULT_ISTK"
+  end
+else
+  # éçAPIãDEF_ICSããè¤æ°ããï¼E_OBJï¼ï¼»NGKI3216ï¼½
+  if $cfgData[:DEF_ICS].size > 1
+    error("E_OBJ: too many DEF_ICS")
+  end
+
+  # DEF_ICSãããå ´åã®å¦ç
+  params = $cfgData[:DEF_ICS][1]
+
+  # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+  params[:istk] ||= "NULL"
+
+  # istkszãã¿ã¼ã²ããå®ç¾©ã®æå°å¤ï¼TARGET_MIN_ISTKSZï¼æªå®ç¾©ã®å ´åã¯1ï¼
+  # ãããå°ããå ´åï¼E_PARï¼ï¼»NGKI3254ï¼½
+  if params[:istksz] < $TARGET_MIN_ISTKSZ
+    error_wrong("E_PAR", params, :istksz, "too small")
+  end
+
+  if params[:istk] == "NULL"
+    # ã¹ã¿ãã¯é åã®èªåå²ä»ã
+    istksz = AllocStack("_kernel_istack", params[:istksz])
+    istk = "_kernel_istack"
+  else
+    # istkszãã¹ã¿ãã¯é åã®ãµã¤ãºã¨ãã¦æ­£ãããªãå ´åï¼E_PARï¼ï¼»NGKI3222ï¼½
+    if (params[:istksz] & ($CHECK_STKSZ_ALIGN - 1)) != 0
+      error_wrong("E_PAR", params, :istksz, "not aligned")
+    end
+
+    istksz = "(#{params[:istksz]})"
+    istk = "(void *)(#{params[:istk]})"
+  end
+end
+
+$kernelCfgC.add(<<EOS)
+const size_t _kernel_istksz = #{istksz};
+STK_T *const _kernel_istk = #{istk};
+
+#ifdef TOPPERS_ISTKPT
+STK_T *const _kernel_istkpt = TOPPERS_ISTKPT(#{istk}, #{istksz});
+#endif /* TOPPERS_ISTKPT */
+EOS
+
+#
+#  ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé å
+#
+$kernelCfgC.comment_header("Memory Area Allocated by Kernel")
+
+if $cfgData[:DEF_KMM].size == 0
+  # DEF_KMMããªãå ´åã®ããã©ã«ãå¤ã®è¨­å®
+  kmmsz = "0"
+  kmm = "NULL"
+else
+  # éçAPIãDEF_KMMããè¤æ°ããï¼E_OBJï¼
+  if ($cfgData[:DEF_KMM].size > 1)
+    error("E_OBJ: too many DEF_KMM")
+  end
+
+  # DEF_KMMãããå ´åã®å¦ç
+  params = $cfgData[:DEF_KMM][1]
+
+  # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+  params[:kmm] ||= "NULL"
+
+  # kmmszã0ã®å ´åï¼E_PARï¼
+  if params[:kmmsz] == 0
+    error_wrong("E_PAR", params, :kmmsz, "zero")
+  end
+
+  if params[:kmm] == "NULL"
+    # ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®èªåå²ä»ã
+    $kernelCfgC.add("static MB_T _kernel_memory" \
+					"[TOPPERS_COUNT_SZ(#{params[:kmmsz]}, sizeof(MB_T))];")
+    kmmsz = "TOPPERS_ROUND_SZ(#{params[:kmmsz]}, sizeof(MB_T))"
+    kmm = "_kernel_memory"
+  else
+    # kmmszãã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®ãµã¤ãºã¨ãã¦æ­£ãããªãå ´å
+    # ï¼E_PARï¼
+    if (params[:kmmsz] & ($CHECK_MB_ALIGN - 1)) != 0
+      error_wrong("E_PAR", params, :kmmsz, "not aligned")
+    end
+
+    kmmsz = "(#{params[:kmmsz]})"
+    kmm = "(void *)(#{params[:kmm]})"
+  end
+end
+
+$kernelCfgC.add(<<EOS)
+const size_t _kernel_kmmsz = #{kmmsz};
+MB_T *const _kernel_kmm = #{kmm};
+EOS
+
+#
+#  ã¿ã¤ã ã¤ãã³ãç®¡ç
+#
+$kernelCfgC.comment_header("Time Event Management")
+$kernelCfgC.add(<<EOS)
+TMEVTN   _kernel_tmevt_heap[1 + TNUM_TSKID + TNUM_CYCID + TNUM_ALMID];
+EOS
+
+#
+#  åã¢ã¸ã¥ã¼ã«ã®åæåé¢æ°
+#
+$kernelCfgC.comment_header("Module Initialization Function")
+$kernelCfgC.append(<<EOS)
+void
+_kernel_initialize_object(void)
+{
+EOS
+$initializeFunctions.each do |func|
+  $kernelCfgC.add("\t#{func}")
+end
+$kernelCfgC.add2("}")
+
+#
+#  åæåã«ã¼ãã³æ©è½
+#
+$kernelCfgC.comment_header("Initialization Routine")
+
+# ã¨ã©ã¼ãã§ãã¯
+$cfgData[:ATT_INI].each do |key, params|
+  # iniatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI3241ï¼½
+  #ï¼TA_NULLã§ãªãå ´åï¼
+  if (params[:iniatr] != $TA_NULL)
+    error_illegal_sym("E_RSATR", params, :iniatr, :inirtn)
+  end
+end
+
+# åæåã«ã¼ãã³ã®å®è¡é¢æ°ã®çæ
+$kernelCfgC.append(<<EOS)
+void
+_kernel_call_inirtn(void)
+{
+EOS
+$cfgData[:ATT_INI].each do |key, params|
+  $kernelCfgC.add("\t((INIRTN)(#{params[:inirtn]}))" \
+								"((intptr_t)(#{params[:exinf]}));")
+end
+$kernelCfgC.add2("}")
+
+#
+#  çµäºå¦çã«ã¼ãã³æ©è½
+#
+$kernelCfgC.comment_header("Termination Routine")
+
+# ã¨ã©ã¼ãã§ãã¯
+$cfgData[:ATT_TER].each do |key, params|
+  # teratrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI3248ï¼½
+  #ï¼TA_NULLã§ãªãå ´åï¼
+  if (params[:teratr] != $TA_NULL)
+    error_illegal_sym("E_RSATR", params, :teratr, :terrtn)
+  end
+end
+
+# çµäºå¦çã«ã¼ãã³ã®å®è¡é¢æ°ã®çæ
+$kernelCfgC.append(<<EOS)
+void
+_kernel_call_terrtn(void)
+{
+EOS
+$cfgData[:ATT_TER].reverse_each do |key, params|
+  $kernelCfgC.add("\t((TERRTN)(#{params[:terrtn]}))" \
+								"((intptr_t)(#{params[:exinf]}));")
+end
+$kernelCfgC.add2("}")
+
+#
+#  kernel_cfg.hã®æ«å°¾é¨åã®çæ
+#
+$kernelCfgH.append(<<EOS)
+#endif /* TOPPERS_KERNEL_CFG_H */
+EOS
Index: asp3_gr_sakura/trunk/kernel/kernel_api.def
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_api.def	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_api.def	(revision 317)
@@ -0,0 +1,28 @@
+CRE_TSK #tskid* { .tskatr &exinf &task +itskpri .stksz &stk? }
+AID_TSK .notsk
+CRE_SEM #semid* { .sematr .isemcnt .maxsem }
+AID_SEM .nosem
+CRE_FLG #flgid* { .flgatr .iflgptn }
+AID_FLG .noflg
+CRE_DTQ #dtqid* { .dtqatr .dtqcnt &dtqmb? }
+AID_DTQ .nodtq
+CRE_PDQ #pdqid* { .pdqatr .pdqcnt +maxdpri &pdqmb? }
+AID_PDQ .nopdq
+CRE_MTX #mtxid* { .mtxatr +ceilpri? }
+AID_MTX .nomtx
+CRE_MPF #mpfid* { .mpfatr .blkcnt .blksz &mpf? &mpfmb? }
+AID_MPF .nompf
+CRE_CYC #cycid* { .cycatr { .nfymode &par1 &par2? &par3? &par4? } .cyctim .cycphs }
+AID_CYC .nocyc
+DEF_OVR { .ovratr &ovrhdr }
+CRE_ALM #almid* { .almatr { .nfymode &par1 &par2? &par3? &par4? } }
+AID_ALM .noalm
+CFG_INT .intno* { .intatr +intpri }
+CRE_ISR #isrid* { .isratr &exinf .intno &isr +isrpri }
+AID_ISR .noisr
+DEF_INH .inhno* { .inhatr &inthdr }
+DEF_EXC .excno* { .excatr &exchdr }
+DEF_ICS { .istksz &istk? }
+DEF_KMM { .kmmsz &kmm? }
+ATT_INI { .iniatr &exinf &inirtn }
+ATT_TER { .teratr &exinf &terrtn }
Index: asp3_gr_sakura/trunk/kernel/kernel_check.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_check.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_check.trb	(revision 317)
@@ -0,0 +1,391 @@
+# -*- coding: utf-8 -*-
+# 
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+#  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: kernel_check.trb 662 2016-02-27 02:33:51Z ertl-hiro $
+#  
+
+#
+#		ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®ãã¹3ã®çæã¹ã¯ãªãã
+#
+
+# 
+#  ã¿ã¤ã ã¹ã¿ã³ããã¡ã¤ã«ã®æå®
+# 
+$timeStampFileName = "check.timestamp"
+
+#
+#  ãã¼ã¿ã»ã¯ã·ã§ã³ã®LMAããVMAã¸ã®ã³ãã¼
+#
+if !$lmaList.nil?
+  $lmaList.each do |lma|
+    startData = SYMBOL(lma[:START_DATA])
+    endData = SYMBOL(lma[:END_DATA])
+    startIdata = SYMBOL(lma[:START_IDATA])
+    if startData.nil?
+      error_exit("symbol `lma[:START_DATA]' not found")
+    elsif endData.nil?
+      error_exit("symbol `lma[:END_DATA]' not found")
+    elsif startIdata.nil?
+      error_exit("symbol `lma[:START_IDATA]' not found")
+    else
+      BCOPY(startIdata, startData, endData - startData)
+    end
+  end
+end
+
+#
+#  éç¥æ
+å ±ã®ãã§ãã¯é¢æ°
+#
+$tmax_tskid = $TMIN_TSKID + $cfgData[:CRE_TSK].size - 1
+$tmax_semid = $TMIN_SEMID + $cfgData[:CRE_SEM].size - 1
+$tmax_flgid = $TMIN_FLGID + $cfgData[:CRE_FLG].size - 1
+$tmax_dtqid = $TMIN_DTQID + $cfgData[:CRE_DTQ].size - 1
+
+def checkNotifyHandler(key, params, objid, exinf, nfyhdr)
+  # ãã©ã¡ã¼ã¿ãå¤æ°ã«æ ¼ç´
+  nfymode = params[:nfymode]
+  nfymode1 = nfymode & 0x0f
+  nfymode2 = nfymode & ~0x0f
+  par1 = params[:par1]
+  par2 = params[:par2]
+  funcname = "_kernel_nfyhdr_#{params[objid]}"
+
+  # éç¥å¦çã®ãã©ã¡ã¼ã¿æ°ã«ããè£æ­£å¦ç
+  if nfymode1 == $TNFY_SETVAR || nfymode1 == $TNFY_SETFLG \
+								|| nfymode1 == $TNFY_SNDDTQ
+    # éç¥å¦çã®ãã©ã¡ã¼ã¿ã2ã¤ã®å ´å
+    epar1 = params[:par3]
+    epar2 = params[:par4]
+  else
+    # éç¥å¦çã®ãã©ã¡ã¼ã¿ã1ã¤ã®å ´å
+    epar1 = params[:par2]
+    epar2 = params[:par3]
+  end
+
+  #	ã¿ã¤ã ã¤ãã³ããã³ãã©ã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI3693ï¼½
+  if nfymode == $TNFY_HANDLER
+    tmehdr = nfyhdr
+    params1 = params.dup
+    params1[:tmehdr] = par2
+    if (tmehdr & ($CHECK_FUNC_ALIGN - 1)) != 0
+      error_wrong_id("E_PAR", params1, :tmehdr, objid, "not aligned")
+    end
+    if $CHECK_FUNC_NONNULL && tmehdr == 0
+      error_wrong_id("E_PAR", params1, :tmehdr, objid, "null")
+    end
+  end
+
+  #	ã¤ãã³ãéç¥å¦çã®å¤æ°ã®çªå°ã¨ãªãã¸ã§ã¯ãIDã®ãã§ãã¯
+  if nfymode1 == $TNFY_SETVAR || nfymode1 == $TNFY_INCVAR
+    # å¤æ°ã®è¨­å®ï¼ã¤ã³ã¯ãªã¡ã³ãã«ããã¿ã¤ã ã¤ãã³ãã®éç¥
+	p_var = exinf
+    params1 = params.dup
+    params1[:p_var] = par1
+
+    # å¤æ°ã®çªå°ã®ãã§ãã¯ï¼»NGKI3699ï¼½ï¼»NGKI3897ï¼½
+    if (p_var & ($CHECK_INTPTR_ALIGN - 1)) != 0
+      error_wrong_id("E_PAR", params1, :p_var, objid, "not aligned")
+    end
+    if $CHECK_INTPTR_NONNULL && p_var == 0
+      error_wrong_id("E_PAR", params1, :p_var, objid, "null")
+    end
+  elsif (nfymode1 == $TNFY_ACTTSK || nfymode1 == $TNFY_WUPTSK)
+    # ã¿ã¹ã¯ã®èµ·åï¼èµ·åºã«ããã¿ã¤ã ã¤ãã³ãã®éç¥
+    tskid = exinf
+    params1 = params.dup
+    params1[:tskid] = par1
+
+    # ã¿ã¹ã¯IDã®ãã§ãã¯ï¼»NGKI3704ï¼½
+    if !($TMIN_TSKID <= tskid && tskid <= $tmax_tskid)
+      error_illegal_id("E_ID", params1, :tskid, objid)
+    end
+  elsif nfymode1 == $TNFY_SIGSEM
+    # ã»ããã©ã®è³æºã®è¿å´ã«ããã¿ã¤ã ã¤ãã³ãã®éç¥
+    semid = exinf
+    params1 = params.dup
+    params1[:semid] = par1
+
+    # ã»ããã©IDã®ãã§ãã¯ï¼»NGKI3707ï¼½
+    if !($TMIN_SEMID <= semid && semid <= $tmax_semid)
+      error_illegal_id("E_ID", params1, :semid, objid)
+    end
+  elsif nfymode1 == $TNFY_SETFLG
+    # ã¤ãã³ããã©ã°ã®ã»ããã«ããã¿ã¤ã ã¤ãã³ãã®éç¥
+    flgid = exinf
+    params1 = params.dup
+    params1[:flgid] = par1
+
+    # ã¤ãã³ããã©ã°IDã®ãã§ãã¯ï¼»NGKI3710ï¼½
+    if !($TMIN_FLGID <= flgid && flgid <= $tmax_flgid)
+      error_illegal_id("E_ID", params1, :flgid, objid)
+    end
+  elsif nfymode1 == $TNFY_SNDDTQ
+    # ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ã«ããã¿ã¤ã ã¤ãã³ãã®éç¥
+    dtqid = exinf
+    params1 = params.dup
+    params1[:dtqid] = par1
+
+    # ãã¼ã¿ã­ã¥ã¼IDã®ãã§ãã¯ï¼»NGKI3713ï¼½
+    if !($TMIN_DTQID <= dtqid && dtqid <= $tmax_dtqid)
+      error_illegal_id("E_ID", params1, :dtqid, objid)
+    end
+  end
+
+  # ã¨ã©ã¼éç¥å¦çã®å¤æ°ã®çªå°ã¨ãªãã¸ã§ã¯ãIDã®ãã§ãã¯
+  if (nfymode2 == $TENFY_SETVAR || nfymode2 == $TENFY_INCVAR)
+    # å¤æ°ã®è¨­å®ï¼ã¤ã³ã¯ãªã¡ã³ãã«ããã¨ã©ã¼ã®éç¥
+    p_var = PEEK(SYMBOL(funcname + "_p_evar"), $sizeof_intptr_t)
+    params1 = params.dup
+    params1[:p_var] = epar1
+
+    # å¤æ°ã®çªå°ã®ãã§ãã¯ï¼»NGKI3701ï¼½ï¼»NGKI3897ï¼½
+    if (p_var & ($CHECK_INTPTR_ALIGN - 1)) != 0
+      error_wrong_id("E_PAR", params1, :p_var, objid, "not aligned")
+    end
+    if $CHECK_INTPTR_NONNULL && p_var == 0
+      error_wrong_id("E_PAR", params1, :p_var, objid, "null")
+    end
+  elsif nfymode2 == $TENFY_ACTTSK || nfymode2 == $TENFY_WUPTSK
+    # ã¿ã¹ã¯ã®èµ·åï¼èµ·åºã«ããã¨ã©ã¼ã®éç¥
+    tskid = PEEK(SYMBOL(funcname + "_etskid"), $sizeof_ID)
+    params1 = params.dup
+    params1[:tskid] = epar1
+
+    # ã¿ã¹ã¯IDã®ãã§ãã¯ï¼»NGKI3704ï¼½
+    if !($TMIN_TSKID <= tskid && tskid <= $tmax_tskid)
+      error_illegal_id("E_ID", params1, :tskid, objid)
+    end
+  elsif nfymode2 == $TENFY_SIGSEM
+    # ã»ããã©ã®è³æºã®è¿å´ã«ããã¨ã©ã¼ã®éç¥
+	semid = PEEK(SYMBOL(funcname + "_esemid"), $sizeof_ID)
+    params1 = params.dup
+    params1[:semid] = epar1
+
+    # ã»ããã©IDã®ãã§ãã¯ï¼»NGKI3707ï¼½
+    if !($TMIN_SEMID <= semid && semid <= $tmax_semid)
+      error_illegal_id("E_ID", params1, :semid, objid)
+    end
+  elsif nfymode2 == $TENFY_SETFLG
+    # ã¤ãã³ããã©ã°ã®ã»ããã«ããã¨ã©ã¼ã®éç¥
+    flgid = PEEK(SYMBOL(funcname + "_eflgid"), $sizeof_ID)
+    params1 = params.dup
+    params1[:flgid] = epar1
+
+    # ã¤ãã³ããã©ã°IDã®ãã§ãã¯ï¼»NGKI3710ï¼½
+    if !($TMIN_FLGID <= flgid && flgid <= $tmax_flgid)
+      error_illegal_id("E_ID", params1, :flgid, objid)
+    end
+  elsif nfymode2 == $TENFY_SNDDTQ
+    # ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ã«ããã¨ã©ã¼ã®éç¥
+    dtqid = PEEK(SYMBOL(funcname + "_edtqid"), $sizeof_ID)
+    params1 = params.dup
+    params1[:dtqid] = epar1
+
+    # ãã¼ã¿ã­ã¥ã¼IDã®ãã§ãã¯ï¼»NGKI3715ï¼½
+    if !($TMIN_DTQID <= dtqid && dtqid <= $tmax_dtqid)
+      error_illegal_id("E_ID", params1, :dtqid, objid)
+    end
+  end
+end
+
+# 
+#  ã¿ã¹ã¯ã«é¢ãããã§ãã¯
+# 
+tinib = SYMBOL("_kernel_tinib_table")
+$cfgData[:CRE_TSK].sort.each do |key, params|
+  task = PEEK(tinib + $offsetof_TINIB_task, $sizeof_TASK)
+
+  # ã¿ã¹ã¯ã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI1033ï¼½
+  if (task & ($CHECK_FUNC_ALIGN - 1)) != 0
+    error_wrong_id("E_PAR", params, :task, :tskid, "not aligned")
+  end
+  if $CHECK_FUNC_NONNULL && task == 0
+    error_wrong_id("E_PAR", params, :task, :tskid, "null")
+  end
+
+  # ã¿ã¹ã¯ã®ã¹ã¿ãã¯é åã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI1056ï¼½
+  if $USE_TSKINICTXB
+    stk = GetStackTskinictxb(key, params, tinib)
+  else
+    stk = PEEK(tinib + $offsetof_TINIB_stk, $sizeof_void_ptr)
+  end
+  if (stk & ($CHECK_STACK_ALIGN - 1)) != 0
+    error_wrong_id("E_PAR", params, :stk, :tskid, "not aligned")
+  end
+  if $CHECK_STACK_NONNULL && stk == 0
+    error_wrong_id("E_PAR", params, :stk, :tskid, "null")
+  end
+
+  tinib += $sizeof_TINIB
+end
+
+# 
+#  åºå®é·ã¡ã¢ãªãã¼ã«ã«é¢ãããã§ãã¯
+# 
+mpfinib = SYMBOL("_kernel_mpfinib_table")
+$cfgData[:CRE_MPF].sort.each do |key, params|
+  mpf = PEEK(mpfinib + $offsetof_MPFINIB_mpf, $sizeof_void_ptr)
+
+  # åºå®é·ã¡ã¢ãªãã¼ã«é åã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI2249ï¼½
+  if (mpf & ($CHECK_MPF_ALIGN - 1)) != 0
+    error_wrong_id("E_PAR", params, :mpf, :mpfid, "not aligned")
+  end
+  if $CHECK_MPF_NONNULL && mpf == 0
+    error_wrong_id("E_PAR", params, :mpf, :mpfid, "null")
+  end
+
+  mpfinib += $sizeof_MPFINIB
+end
+
+# 
+#  å¨æéç¥ã«é¢ãããã§ãã¯
+# 
+cycinib = SYMBOL("_kernel_cycinib_table")
+$cfgData[:CRE_CYC].sort.each do |key, params|
+  exinf = PEEK(cycinib + $offsetof_CYCINIB_exinf, $sizeof_intptr_t)
+  nfyhdr = PEEK(cycinib + $offsetof_CYCINIB_nfyhdr, $sizeof_NFYHDR)
+
+  #	éç¥æ
+å ±ã®ãã§ãã¯
+  checkNotifyHandler(key, params, :cycid, exinf, nfyhdr)
+
+  cycinib += $sizeof_CYCINIB
+end
+
+# 
+#  ã¢ã©ã¼ã éç¥ã«é¢ãããã§ãã¯
+# 
+alminib = SYMBOL("_kernel_alminib_table")
+$cfgData[:CRE_ALM].sort.each do |key, params|
+  exinf = PEEK(alminib + $offsetof_ALMINIB_exinf, $sizeof_intptr_t)
+  nfyhdr = PEEK(alminib + $offsetof_ALMINIB_nfyhdr, $sizeof_NFYHDR)
+
+  #	éç¥æ
+å ±ã®ãã§ãã¯
+  checkNotifyHandler(key, params, :almid, exinf, nfyhdr)
+
+  alminib += $sizeof_ALMINIB
+end
+
+#
+#  ãªã¼ãã©ã³ãã³ãã©ã«é¢ãããã§ãã¯
+#
+ovrinib = SYMBOL("_kernel_ovrinib")
+if $cfgData[:DEF_OVR].size > 0
+  ovrhdr = PEEK(ovrinib + $offsetof_OVRINIB_ovrhdr, $sizeof_OVRHDR)
+
+  # ãªã¼ãã©ã³ãã³ãã©ã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI2613ï¼½
+  if (ovrhdr & ($CHECK_FUNC_ALIGN - 1)) != 0
+    error_wrong("E_PAR", $cfgData[:DEF_OVR][1], :ovrhdr, "not aligned")
+  end
+  if $CHECK_FUNC_NONNULL && ovrhdr == 0
+    error_wrong("E_PAR", $cfgData[:DEF_OVR][1], :ovrhdr, "null")
+  end
+end
+
+#
+#  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã«é¢ãããã§ãã¯
+#
+isrinib = SYMBOL("_kernel_isrinib_table")
+$cfgData[:CRE_ISR].sort.each do |key, params|
+  isr = PEEK(isrinib + $offsetof_ISRINIB_isr, $sizeof_ISR)
+
+  # å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI3004ï¼½
+  if (isr & ($CHECK_FUNC_ALIGN - 1)) != 0
+    error_wrong_id("E_PAR", params, :isr, :isrid, "not aligned")
+  end
+  if $CHECK_FUNC_NONNULL && isr == 0
+    error_wrong_id("E_PAR", params, :isr, :isrid, "null")
+  end
+
+  isrinib += $sizeof_ISRINIB
+end
+
+# 
+#  éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯é åã«é¢ãããã§ãã¯
+# 
+istkAddr = SYMBOL("_kernel_istk")
+if !istkAddr.nil?
+  istk = PEEK(istkAddr, $sizeof_void_ptr)
+
+  # éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯é åã®å
+é ­çªå°ã®ãã§ãã¯ï¼»NGKI3222ï¼½
+  if (istk & ($CHECK_STACK_ALIGN - 1)) != 0
+    error_wrong("E_PAR", $cfgData[:DEF_ICS][1], :istk, "not aligned")
+  end
+  if $CHECK_STACK_NONNULL && istk == 0
+    error_wrong("E_PAR", $cfgData[:DEF_ICS][1], :istk, "null")
+  end
+end
+
+# 
+#  ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã«é¢ãããã§ãã¯
+# 
+kmmAddr = SYMBOL("_kernel_kmm")
+if !kmmAddr.nil?
+  kmm = PEEK(kmmAddr, $sizeof_void_ptr)
+
+  # ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®å
+é ­çªå°ã®ãã§ãã¯
+  if (kmm & ($CHECK_MB_ALIGN - 1)) != 0
+    error_wrong("E_PAR", $cfgData[:DEF_KMM][1], :kmm, "not aligned")
+  end
+end
Index: asp3_gr_sakura/trunk/kernel/kernel_impl.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_impl.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_impl.h	(revision 317)
@@ -0,0 +1,259 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		TOPPERS/ASPã«ã¼ãã«å
+é¨åãæ¨æºããããã¡ã¤ã«
+ *
+ *  ãã®ããããã¡ã¤ã«ã¯ï¼ã«ã¼ãã«ãæ§æãããã­ã°ã©ã ã®ã½ã¼ã¹ãã¡ã¤ã«
+ *  ã§å¿
+ãã¤ã³ã¯ã«ã¼ãããã¹ãæ¨æºããããã¡ã¤ã«ã§ããï¼
+ *
+ *  ã¢ã»ã³ããªè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ãããã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããæ
+ *  ã¯ï¼TOPPERS_MACRO_ONLYãå®ç¾©ãã¦ããï¼ããã«ããï¼ãã¯ã­å®ç¾©ä»¥å¤ã
+ *  é¤ãããã«ãªã£ã¦ããï¼
+ */
+
+#ifndef TOPPERS_KERNEL_IMPL_H
+#define TOPPERS_KERNEL_IMPL_H
+
+/*
+ *  ã«ã¼ãã«ã®å
+é¨è­å¥åã®ãªãã¼ã 
+ */
+#include "kernel_rename.h"
+
+/*
+ *  ã¢ããªã±ã¼ã·ã§ã³ã¨å
+±éã®ããããã¡ã¤ã«
+ */
+#include <kernel.h>
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ããã®å®ç¾©
+ */
+#include <t_syslog.h>
+
+/*
+ *  ã¿ã¼ã²ããä¾å­æ
+å ±ã®å®ç¾©
+ */
+#include "target_kernel_impl.h"
+
+/*
+ *  ãã¹ã¦ã®é¢æ°ãã³ã³ãã¤ã«ããããã®å®ç¾©
+ */
+#ifdef ALLFUNC
+#include "allfunc.h"
+#endif /* ALLFUNC */
+
+/*
+ *  ããããã£ã¼ã«ãã§ã®ç¬¦å·ç¡ãæ´æ°å
+ *
+ *  8ãããä»¥ä¸ã®å¹
+ã®ããããã£ã¼ã«ãã§ï¼ç¬¦å·ç¡ãæ´æ°å¤ãä¿æãããå ´å
+ *  ã«ç¨ããã¹ããã¼ã¿åï¼ANSI Cã§ã¯ï¼ããããã£ã¼ã«ãã®ãã¼ã¿åã«ã¯
+ *  intã¨unsigned intããè¨±ãããªãããï¼ããã©ã«ãã®å®ç¾©ã¯unsigned
+ *  intã¨ãã¦ãããï¼ã¿ã¼ã²ããããã³ãã¼ã«ä¾å­ã§ï¼unsigned charã¾ãã¯
+ *  unsigned shortã«å®ç¾©ããæ¹ãå¹çãè¯ãå ´åãããï¼
+ */
+#ifndef BIT_FIELD_UINT
+#define BIT_FIELD_UINT		unsigned int
+#endif /* BIT_FIELD_UINT */
+
+/*
+ *  ããããã£ã¼ã«ãã§ã®ãã¼ã«å
+ *
+ *  1ãããå¹
+ã®ããããã£ã¼ã«ãã§ï¼ãã¼ã«å¤ãä¿æãããå ´åã«ç¨ããã¹ã
+ *  ãã¼ã¿åï¼ããã©ã«ãã§ã¯BIT_FIELD_UINTã¨åä¸ã«å®ç¾©ãã¦ãããï¼ãã¼
+ *  ã«å¤ãä¿æãããã¨ãæç¤ºããããã«å¥ã®åç§°ã¨ãã¦ããï¼
+ */
+#ifndef BIT_FIELD_BOOL
+#define BIT_FIELD_BOOL		BIT_FIELD_UINT
+#endif /* BIT_FIELD_BOOL */
+
+/*
+ *  ãªãã¸ã§ã¯ãIDã®æå°å¤ã®å®ç¾©
+ */
+#define TMIN_TSKID		1		/* ã¿ã¹ã¯IDã®æå°å¤ */
+#define TMIN_SEMID		1		/* ã»ããã©IDã®æå°å¤ */
+#define TMIN_FLGID		1		/* ãã©ã°IDã®æå°å¤ */
+#define TMIN_DTQID		1		/* ãã¼ã¿ã­ã¥ã¼IDã®æå°å¤ */
+#define TMIN_PDQID		1		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼IDã®æå°å¤ */
+#define TMIN_MTXID		1		/* ãã¥ã¼ããã¯ã¹IDã®æå°å¤ */
+#define TMIN_MPFID		1		/* åºå®é·ã¡ã¢ãªãã¼ã«IDã®æå°å¤ */
+#define TMIN_CYCID		1		/* å¨æéç¥IDã®æå°å¤ */
+#define TMIN_ALMID		1		/* ã¢ã©ã¼ã éç¥IDã®æå°å¤ */
+#define TMIN_ISRID		1		/* å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³IDã®æå°å¤ */
+
+/*
+ *  åªå
+åº¦ã®æ®µéæ°ã®å®ç¾©
+ */
+#define TNUM_TPRI		(TMAX_TPRI - TMIN_TPRI + 1)
+#define TNUM_DPRI		(TMAX_DPRI - TMIN_DPRI + 1)
+#define TNUM_INTPRI		(TMAX_INTPRI - TMIN_INTPRI + 1)
+
+/*
+ *  ã«ã¼ãã«å
+é¨ã§ä½¿ç¨ããå±æ§ã®å®ç¾©
+ */
+#define TA_NOEXS		((ATR)(-1))			/* æªç»é²ç¶æ
+ */
+
+#ifndef TA_MEMALLOC
+#define TA_MEMALLOC		UINT_C(0x8000)		/* ã¡ã¢ãªé åãã«ã¼ãã«ã§ç¢ºä¿ */
+#endif /* TA_MEMALLOC */
+#ifndef TA_MBALLOC
+#define TA_MBALLOC		UINT_C(0x4000)		/* ç®¡çé åãã«ã¼ãã«ã§ç¢ºä¿ */
+#endif /* TA_MBALLOC */
+
+/*
+ *  ã¿ã¼ã²ããå®ç¾©ã®ã¨ã©ã¼ãã§ãã¯ãã¯ã­ã®ããã©ã«ãå¤ã®å®ç¾©
+ */
+#ifndef TARGET_TSKATR
+#define TARGET_TSKATR		0U		/* ã¿ã¼ã²ããå®ç¾©ã®ã¿ã¹ã¯å±æ§ */
+#endif /* TARGET_TSKATR */
+
+#ifndef TARGET_ISRATR
+#define TARGET_ISRATR		0U		/* ã¿ã¼ã²ããå®ç¾©ã®ISRå±æ§ */
+#endif /* TARGET_ISRATR */
+
+/*
+ *  ããããã¡ã¤ã«ãæããªãã¢ã¸ã¥ã¼ã«ã®é¢æ°ã»å¤æ°ã®å®£è¨
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  TECSã®åæåï¼init_tecs.cï¼
+ */
+extern void initialize_tecs(void);
+
+/*
+ *  åã¢ã¸ã¥ã¼ã«ã®åæåï¼kernel_cfg.cï¼
+ */
+extern void	initialize_object(void);
+
+/*
+ *  åæåã«ã¼ãã³ã®å®è¡ï¼kernel_cfg.cï¼
+ */
+extern void	call_inirtn(void);
+
+/*
+ *  çµäºå¦çã«ã¼ãã³ã®å®è¡ï¼kernel_cfg.cï¼
+ */
+extern void	call_terrtn(void);
+
+/*
+ *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯é åï¼kernel_cfg.cï¼
+ */
+extern const size_t	istksz;		/* ã¹ã¿ãã¯é åã®ãµã¤ãºï¼ä¸¸ããå¤ï¼ */
+extern STK_T *const	istk;		/* ã¹ã¿ãã¯é åã®å
+é ­çªå° */
+#ifdef TOPPERS_ISTKPT
+extern STK_T *const	istkpt;		/* ã¹ã¿ãã¯ãã¤ã³ã¿ã®åæå¤ */
+#endif /* TOPPERS_ISTKPT */
+
+/*
+ *  ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åï¼kernel_cfg.cï¼
+ */
+extern const size_t	kmmsz;		/* ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®ãµã¤ãº */
+extern MB_T *const	kmm;		/* ã«ã¼ãã«ãå²ãä»ããã¡ã¢ãªé åã®å
+é ­çªå° */
+
+/*
+ *  ã«ã¼ãã«åä½ç¶æ
+ãã©ã°ï¼startup.cï¼
+ */
+extern bool_t	kerflg;
+
+/*
+ *  ã«ã¼ãã«ã®èµ·åï¼startup.cï¼
+ */
+extern void	sta_ker(void);
+
+/*
+ *  ã«ã¼ãã«ã®çµäºå¦çï¼startup.cï¼
+ */
+extern void	exit_kernel(void);
+
+/*
+ *  ã«ã¼ãã«ã®å²ãä»ããã¡ã¢ãªé åã®ç®¡çï¼startup.cï¼
+ */
+extern void initialize_kmm(void);
+extern void *kernel_malloc(size_t size);
+extern void kernel_free(void *ptr);
+
+/*
+ *  éç¥ãã³ãã©ã®åå®ç¾©
+ */
+typedef void	(*NFYHDR)(intptr_t exinf);
+
+/*
+ *  éç¥æ¹æ³ã®ã¨ã©ã¼ãã§ãã¯
+ */
+extern ER check_nfyinfo(const T_NFYINFO *p_nfyinfo);
+
+/*
+ *  éç¥ãã³ãã©
+ */
+extern void notify_handler(intptr_t exinf);
+
+#endif /* TOPPERS_MACRO_ONLY */
+#endif /* TOPPERS_KERNEL_IMPL_H */
Index: asp3_gr_sakura/trunk/kernel/kernel_int.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_int.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_int.h	(revision 317)
@@ -0,0 +1,102 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		kernel_cfg.cï¼ããã³cfg1_out.cï¼ç¨ããããã¡ã¤ã«
+ */
+
+#ifndef TOPPERS_KERNEL_INT_H
+#define TOPPERS_KERNEL_INT_H
+
+/*
+ *  ã«ã¼ãã«æ¨æºããããã¡ã¤ã«
+ */
+#include "kernel_impl.h"
+
+/*
+ *  ã«ã¼ãã«ã®åããããã¡ã¤ã«
+ */
+#include "task.h"
+#include "semaphore.h"
+#include "eventflag.h"
+#include "dataqueue.h"
+#include "pridataq.h"
+#include "mutex.h"
+#include "mempfix.h"
+#include "cyclic.h"
+#include "alarm.h"
+#include "overrun.h"
+#include "interrupt.h"
+#include "exception.h"
+#include "time_event.h"
+
+/*
+ *  ãªãã¼ã ããã·ã³ãã«ãå
+ã«æ»ãããã®ããããã¡ã¤ã«
+ */
+#include "kernel_unrename.h"
+
+/*
+ *  å
+å®¹ãç©ºã®é
+åãçæããããã®ãã¯ã­
+ */
+#ifndef TOPPERS_EMPTY_LABEL
+#define TOPPERS_EMPTY_LABEL(type, var)		type var[0]
+#endif
+
+#endif /* TOPPERS_KERNEL_INT_H */
Index: asp3_gr_sakura/trunk/kernel/kernel_rename.def
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_rename.def	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_rename.def	(revision 317)
@@ -0,0 +1,206 @@
+# startup.c
+kerflg
+exit_kernel
+initialize_kmm
+kernel_malloc
+kernel_free
+
+# task.c
+p_runtsk
+p_schedtsk
+enadsp
+dspflg
+ready_queue
+ready_primap
+free_tcb
+initialize_task
+search_schedtsk
+make_runnable
+make_non_runnable
+make_dormant
+make_active
+change_priority
+rotate_ready_queue
+task_terminate
+
+# taskhook.c
+mtxhook_check_ceilpri
+mtxhook_scan_ceilmtx
+mtxhook_release_all
+
+# wait.c
+make_wait_tmout
+wait_complete
+wait_tmout
+wait_tmout_ok
+wobj_make_wait
+wobj_make_wait_tmout
+init_wait_queue
+
+# time_event.c
+boundary_evttim
+current_evttim
+current_hrtcnt
+monotonic_evttim
+systim_offset
+in_signal_time
+initialize_tmevt
+tmevt_up
+tmevt_down
+update_current_evttim
+set_hrt_event
+tmevtb_register
+tmevtb_enqueue
+tmevtb_dequeue
+check_adjtim
+tmevt_lefttim
+signal_time
+
+# semaphore.c
+free_semcb
+initialize_semaphore
+
+# eventflag.c
+free_flgcb
+initialize_eventflag
+check_flg_cond
+
+# dataqueue.c
+free_dtqcb
+initialize_dataqueue
+enqueue_data
+force_enqueue_data
+dequeue_data
+send_data
+force_send_data
+receive_data
+
+# pridataq.c
+free_pdqcb
+initialize_pridataq
+enqueue_pridata
+dequeue_pridata
+send_pridata
+receive_pridata
+
+# mutex.c
+free_mtxcb
+initialize_mutex
+mutex_check_ceilpri
+mutex_scan_ceilmtx
+mutex_drop_priority
+mutex_acquire
+mutex_release
+mutex_release_all
+
+# mempfix.c
+free_mpfcb
+initialize_mempfix
+get_mpf_block
+
+# time_manage.c
+check_nfyinfo
+notify_handler
+
+# cyclic.c
+free_cyccb
+initialize_cyclic
+call_cyclic
+
+# alarm.c
+free_almcb
+initialize_alarm
+call_alarm
+
+# interrupt.c
+free_isrcb
+initialize_isr
+call_isr
+initialize_interrupt
+
+# exception.c
+initialize_exception
+
+# overrun.c
+ovrtimer_flag
+initialize_overrun
+ovrtimer_start
+ovrtimer_stop
+call_ovrhdr
+
+# kernel_cfg.c
+initialize_object
+call_inirtn
+call_terrtn
+tmax_tskid
+tmax_stskid
+tinib_table
+atinib_table
+torder_table
+tcb_table
+tmax_semid
+tmax_ssemid
+seminib_table
+aseminib_table
+semcb_table
+tmax_flgid
+tmax_sflgid
+flginib_table
+aflginib_table
+flgcb_table
+tmax_dtqid
+tmax_sdtqid
+dtqinib_table
+adtqinib_table
+dtqcb_table
+tmax_pdqid
+tmax_spdqid
+pdqinib_table
+apdqinib_table
+pdqcb_table
+tmax_mtxid
+tmax_smtxid
+mtxinib_table
+amtxinib_table
+mtxcb_table
+tmax_mpfid
+tmax_smpfid
+mpfinib_table
+ampfinib_table
+mpfcb_table
+tmax_cycid
+tmax_scycid
+cycinib_table
+acycinib_table
+acyc_nfyinfo_table
+cyccb_table
+tmax_almid
+tmax_salmid
+alminib_table
+aalminib_table
+aalm_nfyinfo_table
+almcb_table
+ovrinib
+tnum_isr_queue
+isr_queue_list
+isr_queue_table
+tmax_isrid
+tmax_sisrid
+isrinib_table
+aisrinib_table
+isrorder_table
+isrcb_table
+tnum_def_inhno
+inhinib_table
+tnum_cfg_intno
+intinib_table
+tnum_def_excno
+excinib_table
+tmevt_heap
+istksz
+istk
+istkpt
+kmmsz
+kmm
+
+INCLUDE "target"
Index: asp3_gr_sakura/trunk/kernel/kernel_rename.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_rename.h	(revision 317)
@@ -0,0 +1,250 @@
+/* This file is generated from kernel_rename.def by genrename. */
+
+#ifndef TOPPERS_KERNEL_RENAME_H
+#define TOPPERS_KERNEL_RENAME_H
+
+/*
+ *  startup.c
+ */
+#define kerflg						_kernel_kerflg
+#define exit_kernel					_kernel_exit_kernel
+#define initialize_kmm				_kernel_initialize_kmm
+#define kernel_malloc				_kernel_kernel_malloc
+#define kernel_free					_kernel_kernel_free
+
+/*
+ *  task.c
+ */
+#define p_runtsk					_kernel_p_runtsk
+#define p_schedtsk					_kernel_p_schedtsk
+#define enadsp						_kernel_enadsp
+#define dspflg						_kernel_dspflg
+#define ready_queue					_kernel_ready_queue
+#define ready_primap				_kernel_ready_primap
+#define free_tcb					_kernel_free_tcb
+#define initialize_task				_kernel_initialize_task
+#define search_schedtsk				_kernel_search_schedtsk
+#define make_runnable				_kernel_make_runnable
+#define make_non_runnable			_kernel_make_non_runnable
+#define make_dormant				_kernel_make_dormant
+#define make_active					_kernel_make_active
+#define change_priority				_kernel_change_priority
+#define rotate_ready_queue			_kernel_rotate_ready_queue
+#define task_terminate				_kernel_task_terminate
+
+/*
+ *  taskhook.c
+ */
+#define mtxhook_check_ceilpri		_kernel_mtxhook_check_ceilpri
+#define mtxhook_scan_ceilmtx		_kernel_mtxhook_scan_ceilmtx
+#define mtxhook_release_all			_kernel_mtxhook_release_all
+
+/*
+ *  wait.c
+ */
+#define make_wait_tmout				_kernel_make_wait_tmout
+#define wait_complete				_kernel_wait_complete
+#define wait_tmout					_kernel_wait_tmout
+#define wait_tmout_ok				_kernel_wait_tmout_ok
+#define wobj_make_wait				_kernel_wobj_make_wait
+#define wobj_make_wait_tmout		_kernel_wobj_make_wait_tmout
+#define init_wait_queue				_kernel_init_wait_queue
+
+/*
+ *  time_event.c
+ */
+#define boundary_evttim				_kernel_boundary_evttim
+#define current_evttim				_kernel_current_evttim
+#define current_hrtcnt				_kernel_current_hrtcnt
+#define monotonic_evttim			_kernel_monotonic_evttim
+#define systim_offset				_kernel_systim_offset
+#define in_signal_time				_kernel_in_signal_time
+#define initialize_tmevt			_kernel_initialize_tmevt
+#define tmevt_up					_kernel_tmevt_up
+#define tmevt_down					_kernel_tmevt_down
+#define update_current_evttim		_kernel_update_current_evttim
+#define set_hrt_event				_kernel_set_hrt_event
+#define tmevtb_register				_kernel_tmevtb_register
+#define tmevtb_enqueue				_kernel_tmevtb_enqueue
+#define tmevtb_dequeue				_kernel_tmevtb_dequeue
+#define check_adjtim				_kernel_check_adjtim
+#define tmevt_lefttim				_kernel_tmevt_lefttim
+#define signal_time					_kernel_signal_time
+
+/*
+ *  semaphore.c
+ */
+#define free_semcb					_kernel_free_semcb
+#define initialize_semaphore		_kernel_initialize_semaphore
+
+/*
+ *  eventflag.c
+ */
+#define free_flgcb					_kernel_free_flgcb
+#define initialize_eventflag		_kernel_initialize_eventflag
+#define check_flg_cond				_kernel_check_flg_cond
+
+/*
+ *  dataqueue.c
+ */
+#define free_dtqcb					_kernel_free_dtqcb
+#define initialize_dataqueue		_kernel_initialize_dataqueue
+#define enqueue_data				_kernel_enqueue_data
+#define force_enqueue_data			_kernel_force_enqueue_data
+#define dequeue_data				_kernel_dequeue_data
+#define send_data					_kernel_send_data
+#define force_send_data				_kernel_force_send_data
+#define receive_data				_kernel_receive_data
+
+/*
+ *  pridataq.c
+ */
+#define free_pdqcb					_kernel_free_pdqcb
+#define initialize_pridataq			_kernel_initialize_pridataq
+#define enqueue_pridata				_kernel_enqueue_pridata
+#define dequeue_pridata				_kernel_dequeue_pridata
+#define send_pridata				_kernel_send_pridata
+#define receive_pridata				_kernel_receive_pridata
+
+/*
+ *  mutex.c
+ */
+#define free_mtxcb					_kernel_free_mtxcb
+#define initialize_mutex			_kernel_initialize_mutex
+#define mutex_check_ceilpri			_kernel_mutex_check_ceilpri
+#define mutex_scan_ceilmtx			_kernel_mutex_scan_ceilmtx
+#define mutex_drop_priority			_kernel_mutex_drop_priority
+#define mutex_acquire				_kernel_mutex_acquire
+#define mutex_release				_kernel_mutex_release
+#define mutex_release_all			_kernel_mutex_release_all
+
+/*
+ *  mempfix.c
+ */
+#define free_mpfcb					_kernel_free_mpfcb
+#define initialize_mempfix			_kernel_initialize_mempfix
+#define get_mpf_block				_kernel_get_mpf_block
+
+/*
+ *  time_manage.c
+ */
+#define check_nfyinfo				_kernel_check_nfyinfo
+#define notify_handler				_kernel_notify_handler
+
+/*
+ *  cyclic.c
+ */
+#define free_cyccb					_kernel_free_cyccb
+#define initialize_cyclic			_kernel_initialize_cyclic
+#define call_cyclic					_kernel_call_cyclic
+
+/*
+ *  alarm.c
+ */
+#define free_almcb					_kernel_free_almcb
+#define initialize_alarm			_kernel_initialize_alarm
+#define call_alarm					_kernel_call_alarm
+
+/*
+ *  overrun.c
+ */
+#define ovrtimer_flag				_kernel_ovrtimer_flag
+#define initialize_overrun			_kernel_initialize_overrun
+#define ovrtimer_start				_kernel_ovrtimer_start
+#define ovrtimer_stop				_kernel_ovrtimer_stop
+#define call_ovrhdr					_kernel_call_ovrhdr
+
+/*
+ *  interrupt.c
+ */
+#define free_isrcb					_kernel_free_isrcb
+#define initialize_isr				_kernel_initialize_isr
+#define call_isr					_kernel_call_isr
+#define initialize_interrupt		_kernel_initialize_interrupt
+
+/*
+ *  exception.c
+ */
+#define initialize_exception		_kernel_initialize_exception
+
+/*
+ *  kernel_cfg.c
+ */
+#define initialize_object			_kernel_initialize_object
+#define call_inirtn					_kernel_call_inirtn
+#define call_terrtn					_kernel_call_terrtn
+#define tmax_tskid					_kernel_tmax_tskid
+#define tmax_stskid					_kernel_tmax_stskid
+#define tinib_table					_kernel_tinib_table
+#define atinib_table				_kernel_atinib_table
+#define torder_table				_kernel_torder_table
+#define tcb_table					_kernel_tcb_table
+#define tmax_semid					_kernel_tmax_semid
+#define tmax_ssemid					_kernel_tmax_ssemid
+#define seminib_table				_kernel_seminib_table
+#define aseminib_table				_kernel_aseminib_table
+#define semcb_table					_kernel_semcb_table
+#define tmax_flgid					_kernel_tmax_flgid
+#define tmax_sflgid					_kernel_tmax_sflgid
+#define flginib_table				_kernel_flginib_table
+#define aflginib_table				_kernel_aflginib_table
+#define flgcb_table					_kernel_flgcb_table
+#define tmax_dtqid					_kernel_tmax_dtqid
+#define tmax_sdtqid					_kernel_tmax_sdtqid
+#define dtqinib_table				_kernel_dtqinib_table
+#define adtqinib_table				_kernel_adtqinib_table
+#define dtqcb_table					_kernel_dtqcb_table
+#define tmax_pdqid					_kernel_tmax_pdqid
+#define tmax_spdqid					_kernel_tmax_spdqid
+#define pdqinib_table				_kernel_pdqinib_table
+#define apdqinib_table				_kernel_apdqinib_table
+#define pdqcb_table					_kernel_pdqcb_table
+#define tmax_mtxid					_kernel_tmax_mtxid
+#define tmax_smtxid					_kernel_tmax_smtxid
+#define mtxinib_table				_kernel_mtxinib_table
+#define amtxinib_table				_kernel_amtxinib_table
+#define mtxcb_table					_kernel_mtxcb_table
+#define tmax_mpfid					_kernel_tmax_mpfid
+#define tmax_smpfid					_kernel_tmax_smpfid
+#define mpfinib_table				_kernel_mpfinib_table
+#define ampfinib_table				_kernel_ampfinib_table
+#define mpfcb_table					_kernel_mpfcb_table
+#define tmax_cycid					_kernel_tmax_cycid
+#define tmax_scycid					_kernel_tmax_scycid
+#define cycinib_table				_kernel_cycinib_table
+#define acycinib_table				_kernel_acycinib_table
+#define acyc_nfyinfo_table			_kernel_acyc_nfyinfo_table
+#define cyccb_table					_kernel_cyccb_table
+#define tmax_almid					_kernel_tmax_almid
+#define tmax_salmid					_kernel_tmax_salmid
+#define alminib_table				_kernel_alminib_table
+#define aalminib_table				_kernel_aalminib_table
+#define aalm_nfyinfo_table			_kernel_aalm_nfyinfo_table
+#define almcb_table					_kernel_almcb_table
+#define ovrinib						_kernel_ovrinib
+#define tnum_isr_queue				_kernel_tnum_isr_queue
+#define isr_queue_list				_kernel_isr_queue_list
+#define isr_queue_table				_kernel_isr_queue_table
+#define tmax_isrid					_kernel_tmax_isrid
+#define tmax_sisrid					_kernel_tmax_sisrid
+#define isrinib_table				_kernel_isrinib_table
+#define aisrinib_table				_kernel_aisrinib_table
+#define isrorder_table				_kernel_isrorder_table
+#define isrcb_table					_kernel_isrcb_table
+#define tnum_def_inhno				_kernel_tnum_def_inhno
+#define inhinib_table				_kernel_inhinib_table
+#define tnum_cfg_intno				_kernel_tnum_cfg_intno
+#define intinib_table				_kernel_intinib_table
+#define tnum_def_excno				_kernel_tnum_def_excno
+#define excinib_table				_kernel_excinib_table
+#define tmevt_heap					_kernel_tmevt_heap
+#define istksz						_kernel_istksz
+#define istk						_kernel_istk
+#define istkpt						_kernel_istkpt
+#define kmmsz						_kernel_kmmsz
+#define kmm							_kernel_kmm
+
+
+#include "target_rename.h"
+
+#endif /* TOPPERS_KERNEL_RENAME_H */
Index: asp3_gr_sakura/trunk/kernel/kernel_sym.def
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_sym.def	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_sym.def	(revision 317)
@@ -0,0 +1,155 @@
+TOPPERS_SUPPORT_OVRHDR,true,bool,defined(TOPPERS_SUPPORT_OVRHDR)
+USE_EXTERNAL_ID,true,bool,defined(USE_EXTERNAL_ID)
+SIL_ENDIAN_BIG,true,bool,defined(SIL_ENDIAN_BIG)
+SIL_ENDIAN_LITTLE,true,bool,defined(SIL_ENDIAN_LITTLE)
+TA_NULL
+TA_ACT
+TA_NOACTQUE
+TA_TPRI
+TA_WMUL
+TA_CLR
+TA_CEILING
+TA_STA
+TA_NONKERNEL
+TA_ENAINT
+TA_EDGE
+TNFY_HANDLER
+TNFY_SETVAR
+TNFY_INCVAR
+TNFY_ACTTSK
+TNFY_WUPTSK
+TNFY_SIGSEM
+TNFY_SETFLG
+TNFY_SNDDTQ
+TENFY_SETVAR
+TENFY_INCVAR
+TENFY_ACTTSK
+TENFY_WUPTSK
+TENFY_SIGSEM
+TENFY_SETFLG
+TENFY_SNDDTQ
+TMIN_TPRI,,signed
+TMAX_TPRI,,signed
+TMIN_DPRI,,signed
+TMAX_DPRI,,signed
+TMIN_ISRPRI,,signed
+TMAX_ISRPRI,,signed
+TBIT_FLGPTN
+TMAX_MAXSEM
+TMAX_RELTIM
+TMIN_INTPRI,,signed
+TMAX_INTPRI,,signed
+TMIN_TSKID,,signed
+TMIN_SEMID,,signed
+TMIN_FLGID,,signed
+TMIN_DTQID,,signed
+TMIN_PDQID,,signed
+TMIN_MTXID,,signed
+TMIN_MPFID,,signed
+TMIN_CYCID,,signed
+TMIN_ALMID,,signed
+USE_TSKINICTXB,true,bool,defined(USE_TSKINICTXB)
+OMIT_INITIALIZE_INTERRUPT,true,bool,defined(OMIT_INITIALIZE_INTERRUPT)
+USE_INHINIB_TABLE,true,bool,defined(USE_INHINIB_TABLE)
+USE_INTINIB_TABLE,true,bool,defined(USE_INTINIB_TABLE)
+OMIT_INITIALIZE_EXCEPTION,true,bool,defined(OMIT_INITIALIZE_EXCEPTION)
+DEFAULT_ISTK,,,defined(DEFAULT_ISTK)
+TARGET_TSKATR,,,defined(TARGET_TSKATR),0
+TARGET_INTATR,,,defined(TARGET_INTATR),0
+TARGET_INHATR,,,defined(TARGET_INHATR),0
+TARGET_ISRATR,,,defined(TARGET_ISRATR),0
+TARGET_EXCATR,,,defined(TARGET_EXCATR),0
+TARGET_MIN_STKSZ,,,defined(TARGET_MIN_STKSZ),1
+TARGET_MIN_ISTKSZ,,,defined(TARGET_MIN_ISTKSZ),1
+CHECK_STKSZ_ALIGN,,,defined(CHECK_STKSZ_ALIGN),1
+CHECK_INTPTR_ALIGN,,,defined(CHECK_INTPTR_ALIGN),1
+CHECK_INTPTR_NONNULL,true,bool,defined(CHECK_INTPTR_NONNULL)
+CHECK_FUNC_ALIGN,,,defined(CHECK_FUNC_ALIGN),1
+CHECK_FUNC_NONNULL,true,bool,defined(CHECK_FUNC_NONNULL)
+CHECK_STACK_ALIGN,,,defined(CHECK_STACK_ALIGN),1
+CHECK_STACK_NONNULL,true,bool,defined(CHECK_STACK_NONNULL)
+CHECK_MPF_ALIGN,,,defined(CHECK_MPF_ALIGN),1
+CHECK_MPF_NONNULL,true,bool,defined(CHECK_MPF_NONNULL)
+CHECK_MB_ALIGN,,,defined(CHECK_MB_ALIGN),1
+sizeof_void_ptr,sizeof(void*)
+sizeof_uint_t,sizeof(uint_t)
+sizeof_size_t,sizeof(size_t)
+sizeof_intptr_t,sizeof(intptr_t)
+sizeof_ID,sizeof(ID)
+sizeof_FP,sizeof(FP)
+sizeof_INTNO,sizeof(INTNO)
+sizeof_INHNO,sizeof(INHNO)
+sizeof_EXCNO,sizeof(EXCNO)
+sizeof_TASK,sizeof(TASK)
+sizeof_TMEHDR,sizeof(TMEHDR)
+sizeof_OVRHDR,sizeof(OVRHDR)
+sizeof_ISR,sizeof(ISR)
+sizeof_INTHDR,sizeof(INTHDR)
+sizeof_EXCHDR,sizeof(EXCHDR)
+sizeof_INIRTN,sizeof(INIRTN)
+sizeof_TERRTN,sizeof(TERRTN)
+sizeof_NFYHDR,sizeof(NFYHDR)
+sizeof_TINIB,sizeof(TINIB)
+offsetof_TINIB_tskatr,"offsetof(TINIB,tskatr)"
+offsetof_TINIB_exinf,"offsetof(TINIB,exinf)"
+offsetof_TINIB_task,"offsetof(TINIB,task)"
+offsetof_TINIB_ipriority,"offsetof(TINIB,ipriority)"
+offsetof_TINIB_stksz,"offsetof(TINIB,stksz)",,!defined(USE_TSKINICTXB)
+offsetof_TINIB_stk,"offsetof(TINIB,stk)",,!defined(USE_TSKINICTXB)
+sizeof_SEMINIB,sizeof(SEMINIB)
+offsetof_SEMINIB_sematr,"offsetof(SEMINIB,sematr)"
+offsetof_SEMINIB_isemcnt,"offsetof(SEMINIB,isemcnt)"
+offsetof_SEMINIB_maxsem,"offsetof(SEMINIB,maxsem)"
+sizeof_FLGPTN,sizeof(FLGPTN)
+sizeof_FLGINIB,sizeof(FLGINIB)
+offsetof_FLGINIB_flgatr,"offsetof(FLGINIB,flgatr)"
+offsetof_FLGINIB_iflgptn,"offsetof(FLGINIB,iflgptn)"
+sizeof_DTQINIB,sizeof(DTQINIB)
+offsetof_DTQINIB_dtqatr,"offsetof(DTQINIB,dtqatr)"
+offsetof_DTQINIB_dtqcnt,"offsetof(DTQINIB,dtqcnt)"
+offsetof_DTQINIB_p_dtqmb,"offsetof(DTQINIB,p_dtqmb)"
+sizeof_PDQINIB,sizeof(PDQINIB)
+offsetof_PDQINIB_pdqatr,"offsetof(PDQINIB,pdqatr)"
+offsetof_PDQINIB_pdqcnt,"offsetof(PDQINIB,pdqcnt)"
+offsetof_PDQINIB_maxdpri,"offsetof(PDQINIB,maxdpri)"
+offsetof_PDQINIB_p_pdqmb,"offsetof(PDQINIB,p_pdqmb)"
+sizeof_MTXINIB,sizeof(MTXINIB)
+offsetof_MTXINIB_mtxatr,"offsetof(MTXINIB,mtxatr)"
+offsetof_MTXINIB_ceilpri,"offsetof(MTXINIB,ceilpri)"
+sizeof_MPFINIB,sizeof(MPFINIB)
+offsetof_MPFINIB_mpfatr,"offsetof(MPFINIB,mpfatr)"
+offsetof_MPFINIB_blkcnt,"offsetof(MPFINIB,blkcnt)"
+offsetof_MPFINIB_blksz,"offsetof(MPFINIB,blksz)"
+offsetof_MPFINIB_mpf,"offsetof(MPFINIB,mpf)"
+offsetof_MPFINIB_p_mpfmb,"offsetof(MPFINIB,p_mpfmb)"
+sizeof_CYCINIB,sizeof(CYCINIB)
+offsetof_CYCINIB_cycatr,"offsetof(CYCINIB,cycatr)"
+offsetof_CYCINIB_exinf,"offsetof(CYCINIB,exinf)"
+offsetof_CYCINIB_nfyhdr,"offsetof(CYCINIB,nfyhdr)"
+offsetof_CYCINIB_cyctim,"offsetof(CYCINIB,cyctim)"
+offsetof_CYCINIB_cycphs,"offsetof(CYCINIB,cycphs)"
+sizeof_ALMINIB,sizeof(ALMINIB)
+offsetof_ALMINIB_almatr,"offsetof(ALMINIB,almatr)"
+offsetof_ALMINIB_exinf,"offsetof(ALMINIB,exinf)"
+offsetof_ALMINIB_nfyhdr,"offsetof(ALMINIB,nfyhdr)"
+sizeof_OVRINIB,sizeof(OVRINIB),,defined(TOPPERS_SUPPORT_OVRHDR)
+offsetof_OVRINIB_ovratr,"offsetof(OVRINIB,ovratr)",,defined(TOPPERS_SUPPORT_OVRHDR)
+offsetof_OVRINIB_ovrhdr,"offsetof(OVRINIB,ovrhdr)",,defined(TOPPERS_SUPPORT_OVRHDR)
+sizeof_ISRINIB,sizeof(ISRINIB)
+offsetof_ISRINIB_isratr,"offsetof(ISRINIB,isratr)"
+offsetof_ISRINIB_exinf,"offsetof(ISRINIB,exinf)"
+offsetof_ISRINIB_p_isr_queue,"offsetof(ISRINIB,p_isr_queue)"
+offsetof_ISRINIB_isr,"offsetof(ISRINIB,isr)"
+offsetof_ISRINIB_isrpri,"offsetof(ISRINIB,isrpri)"
+sizeof_INHINIB,sizeof(INHINIB),,!defined(OMIT_INITIALIZE_INTERRUPT)
+offset_INHINIB_inhno,"offsetof(INHINIB,inhno)",,!defined(OMIT_INITIALIZE_INTERRUPT)
+offset_INHINIB_inhatr,"offsetof(INHINIB,inhatr)",,!defined(OMIT_INITIALIZE_INTERRUPT),,
+offset_INHINIB_int_entry,"offsetof(INHINIB,int_entry)",,!defined(OMIT_INITIALIZE_INTERRUPT),,
+sizeof_INTINIB,sizeof(INTINIB),,!defined(OMIT_INITIALIZE_INTERRUPT)
+offset_INTINIB_intno,"offsetof(INTINIB,intno)",,!defined(OMIT_INITIALIZE_INTERRUPT)
+offset_INTINIB_intatr,"offsetof(INTINIB,intatr)",,!defined(OMIT_INITIALIZE_INTERRUPT)
+offset_INTINIB_intpri,"offsetof(INTINIB,intpri)",,!defined(OMIT_INITIALIZE_INTERRUPT)
+sizeof_EXCINIB,sizeof(EXCINIB),,!defined(OMIT_INITIALIZE_EXCEPTION)
+offset_EXCINIB_excno,"offsetof(EXCINIB,excno)",,!defined(OMIT_INITIALIZE_EXCEPTION)
+offset_EXCINIB_excatr,"offsetof(EXCINIB,excatr)",,!defined(OMIT_INITIALIZE_EXCEPTION)
+offset_EXCINIB_exc_entry,"offsetof(EXCINIB,exc_entry)",,!defined(OMIT_INITIALIZE_EXCEPTION)
Index: asp3_gr_sakura/trunk/kernel/kernel_unrename.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/kernel_unrename.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/kernel_unrename.h	(revision 317)
@@ -0,0 +1,251 @@
+/* This file is generated from kernel_rename.def by genrename. */
+
+/* This file is included only when kernel_rename.h has been included. */
+#ifdef TOPPERS_KERNEL_RENAME_H
+#undef TOPPERS_KERNEL_RENAME_H
+
+/*
+ *  startup.c
+ */
+#undef kerflg
+#undef exit_kernel
+#undef initialize_kmm
+#undef kernel_malloc
+#undef kernel_free
+
+/*
+ *  task.c
+ */
+#undef p_runtsk
+#undef p_schedtsk
+#undef enadsp
+#undef dspflg
+#undef ready_queue
+#undef ready_primap
+#undef free_tcb
+#undef initialize_task
+#undef search_schedtsk
+#undef make_runnable
+#undef make_non_runnable
+#undef make_dormant
+#undef make_active
+#undef change_priority
+#undef rotate_ready_queue
+#undef task_terminate
+
+/*
+ *  taskhook.c
+ */
+#undef mtxhook_check_ceilpri
+#undef mtxhook_scan_ceilmtx
+#undef mtxhook_release_all
+
+/*
+ *  wait.c
+ */
+#undef make_wait_tmout
+#undef wait_complete
+#undef wait_tmout
+#undef wait_tmout_ok
+#undef wobj_make_wait
+#undef wobj_make_wait_tmout
+#undef init_wait_queue
+
+/*
+ *  time_event.c
+ */
+#undef boundary_evttim
+#undef current_evttim
+#undef current_hrtcnt
+#undef monotonic_evttim
+#undef systim_offset
+#undef in_signal_time
+#undef initialize_tmevt
+#undef tmevt_up
+#undef tmevt_down
+#undef update_current_evttim
+#undef set_hrt_event
+#undef tmevtb_register
+#undef tmevtb_enqueue
+#undef tmevtb_dequeue
+#undef check_adjtim
+#undef tmevt_lefttim
+#undef signal_time
+
+/*
+ *  semaphore.c
+ */
+#undef free_semcb
+#undef initialize_semaphore
+
+/*
+ *  eventflag.c
+ */
+#undef free_flgcb
+#undef initialize_eventflag
+#undef check_flg_cond
+
+/*
+ *  dataqueue.c
+ */
+#undef free_dtqcb
+#undef initialize_dataqueue
+#undef enqueue_data
+#undef force_enqueue_data
+#undef dequeue_data
+#undef send_data
+#undef force_send_data
+#undef receive_data
+
+/*
+ *  pridataq.c
+ */
+#undef free_pdqcb
+#undef initialize_pridataq
+#undef enqueue_pridata
+#undef dequeue_pridata
+#undef send_pridata
+#undef receive_pridata
+
+/*
+ *  mutex.c
+ */
+#undef free_mtxcb
+#undef initialize_mutex
+#undef mutex_check_ceilpri
+#undef mutex_scan_ceilmtx
+#undef mutex_drop_priority
+#undef mutex_acquire
+#undef mutex_release
+#undef mutex_release_all
+
+/*
+ *  mempfix.c
+ */
+#undef free_mpfcb
+#undef initialize_mempfix
+#undef get_mpf_block
+
+/*
+ *  time_manage.c
+ */
+#undef check_nfyinfo
+#undef notify_handler
+
+/*
+ *  cyclic.c
+ */
+#undef free_cyccb
+#undef initialize_cyclic
+#undef call_cyclic
+
+/*
+ *  alarm.c
+ */
+#undef free_almcb
+#undef initialize_alarm
+#undef call_alarm
+
+/*
+ *  overrun.c
+ */
+#undef ovrtimer_flag
+#undef initialize_overrun
+#undef ovrtimer_start
+#undef ovrtimer_stop
+#undef call_ovrhdr
+
+/*
+ *  interrupt.c
+ */
+#undef free_isrcb
+#undef initialize_isr
+#undef call_isr
+#undef initialize_interrupt
+
+/*
+ *  exception.c
+ */
+#undef initialize_exception
+
+/*
+ *  kernel_cfg.c
+ */
+#undef initialize_object
+#undef call_inirtn
+#undef call_terrtn
+#undef tmax_tskid
+#undef tmax_stskid
+#undef tinib_table
+#undef atinib_table
+#undef torder_table
+#undef tcb_table
+#undef tmax_semid
+#undef tmax_ssemid
+#undef seminib_table
+#undef aseminib_table
+#undef semcb_table
+#undef tmax_flgid
+#undef tmax_sflgid
+#undef flginib_table
+#undef aflginib_table
+#undef flgcb_table
+#undef tmax_dtqid
+#undef tmax_sdtqid
+#undef dtqinib_table
+#undef adtqinib_table
+#undef dtqcb_table
+#undef tmax_pdqid
+#undef tmax_spdqid
+#undef pdqinib_table
+#undef apdqinib_table
+#undef pdqcb_table
+#undef tmax_mtxid
+#undef tmax_smtxid
+#undef mtxinib_table
+#undef amtxinib_table
+#undef mtxcb_table
+#undef tmax_mpfid
+#undef tmax_smpfid
+#undef mpfinib_table
+#undef ampfinib_table
+#undef mpfcb_table
+#undef tmax_cycid
+#undef tmax_scycid
+#undef cycinib_table
+#undef acycinib_table
+#undef acyc_nfyinfo_table
+#undef cyccb_table
+#undef tmax_almid
+#undef tmax_salmid
+#undef alminib_table
+#undef aalminib_table
+#undef aalm_nfyinfo_table
+#undef almcb_table
+#undef ovrinib
+#undef tnum_isr_queue
+#undef isr_queue_list
+#undef isr_queue_table
+#undef tmax_isrid
+#undef tmax_sisrid
+#undef isrinib_table
+#undef aisrinib_table
+#undef isrorder_table
+#undef isrcb_table
+#undef tnum_def_inhno
+#undef inhinib_table
+#undef tnum_cfg_intno
+#undef intinib_table
+#undef tnum_def_excno
+#undef excinib_table
+#undef tmevt_heap
+#undef istksz
+#undef istk
+#undef istkpt
+#undef kmmsz
+#undef kmm
+
+
+#include "target_unrename.h"
+
+#endif /* TOPPERS_KERNEL_RENAME_H */
Index: asp3_gr_sakura/trunk/kernel/mempfix.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/mempfix.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mempfix.c	(revision 317)
@@ -0,0 +1,616 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		åºå®é·ã¡ã¢ãªãã¼ã«æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "mempfix.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_MPF_ENTER
+#define LOG_ACRE_MPF_ENTER(pk_cmpf)
+#endif /* LOG_ACRE_MPF_ENTER */
+
+#ifndef LOG_ACRE_MPF_LEAVE
+#define LOG_ACRE_MPF_LEAVE(ercd)
+#endif /* LOG_ACRE_MPF_LEAVE */
+
+#ifndef LOG_DEL_MPF_ENTER
+#define LOG_DEL_MPF_ENTER(mpfid)
+#endif /* LOG_DEL_MPF_ENTER */
+
+#ifndef LOG_DEL_MPF_LEAVE
+#define LOG_DEL_MPF_LEAVE(ercd)
+#endif /* LOG_DEL_MPF_LEAVE */
+
+#ifndef LOG_GET_MPF_ENTER
+#define LOG_GET_MPF_ENTER(mpfid, p_blk)
+#endif /* LOG_GET_MPF_ENTER */
+
+#ifndef LOG_GET_MPF_LEAVE
+#define LOG_GET_MPF_LEAVE(ercd, p_blk)
+#endif /* LOG_GET_MPF_LEAVE */
+
+#ifndef LOG_PGET_MPF_ENTER
+#define LOG_PGET_MPF_ENTER(mpfid, p_blk)
+#endif /* LOG_PGET_MPF_ENTER */
+
+#ifndef LOG_PGET_MPF_LEAVE
+#define LOG_PGET_MPF_LEAVE(ercd, p_blk)
+#endif /* LOG_PGET_MPF_LEAVE */
+
+#ifndef LOG_TGET_MPF_ENTER
+#define LOG_TGET_MPF_ENTER(mpfid, p_blk, tmout)
+#endif /* LOG_TGET_MPF_ENTER */
+
+#ifndef LOG_TGET_MPF_LEAVE
+#define LOG_TGET_MPF_LEAVE(ercd, p_blk)
+#endif /* LOG_TGET_MPF_LEAVE */
+
+#ifndef LOG_REL_MPF_ENTER
+#define LOG_REL_MPF_ENTER(mpfid, blk)
+#endif /* LOG_REL_MPF_ENTER */
+
+#ifndef LOG_REL_MPF_LEAVE
+#define LOG_REL_MPF_LEAVE(ercd)
+#endif /* LOG_REL_MPF_LEAVE */
+
+#ifndef LOG_INI_MPF_ENTER
+#define LOG_INI_MPF_ENTER(mpfid)
+#endif /* LOG_INI_MPF_ENTER */
+
+#ifndef LOG_INI_MPF_LEAVE
+#define LOG_INI_MPF_LEAVE(ercd)
+#endif /* LOG_INI_MPF_LEAVE */
+
+#ifndef LOG_REF_MPF_ENTER
+#define LOG_REF_MPF_ENTER(mpfid, pk_rmpf)
+#endif /* LOG_REF_MPF_ENTER */
+
+#ifndef LOG_REF_MPF_LEAVE
+#define LOG_REF_MPF_LEAVE(ercd, pk_rmpf)
+#endif /* LOG_REF_MPF_LEAVE */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®æ°
+ */
+#define tnum_mpf	((uint_t)(tmax_mpfid - TMIN_MPFID + 1))
+#define tnum_smpf	((uint_t)(tmax_smpfid - TMIN_MPFID + 1))
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«IDããåºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯ãåãåºãã
+ *  ãã®ãã¯ã­
+ */
+#define INDEX_MPF(mpfid)	((uint_t)((mpfid) - TMIN_MPFID))
+#define get_mpfcb(mpfid)	(&(mpfcb_table[INDEX_MPF(mpfid)]))
+
+/*
+ *  ç¹æ®ãªã¤ã³ããã¯ã¹å¤ã®å®ç¾©
+ */
+#define INDEX_NULL		(~0U)		/* ç©ºããã­ãã¯ãªã¹ãã®æå¾ */
+#define INDEX_ALLOC		(~1U)		/* å²å½ã¦æ¸ã¿ã®ãã­ãã¯ */
+
+#ifdef TOPPERS_mpfini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãåºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_mpfcb;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«æ©è½ã®åæå
+ */
+void
+initialize_mempfix(void)
+{
+	uint_t	i, j;
+	MPFCB	*p_mpfcb;
+	MPFINIB	*p_mpfinib;
+
+	for (i = 0; i < tnum_smpf; i++) {
+		p_mpfcb = &(mpfcb_table[i]);
+		queue_initialize(&(p_mpfcb->wait_queue));
+		p_mpfcb->p_mpfinib = &(mpfinib_table[i]);
+		p_mpfcb->fblkcnt = p_mpfcb->p_mpfinib->blkcnt;
+		p_mpfcb->unused = 0U;
+		p_mpfcb->freelist = INDEX_NULL;
+	}
+	queue_initialize(&free_mpfcb);
+	for (j = 0; i < tnum_mpf; i++, j++) {
+		p_mpfcb = &(mpfcb_table[i]);
+		p_mpfinib = &(ampfinib_table[j]);
+		p_mpfinib->mpfatr = TA_NOEXS;
+		p_mpfcb->p_mpfinib = ((const MPFINIB *) p_mpfinib);
+		queue_insert_prev(&free_mpfcb, &(p_mpfcb->wait_queue));
+	}
+}
+
+#endif /* TOPPERS_mpfini */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ãããã­ãã¯ãç²å¾
+ */
+#ifdef TOPPERS_mpfget
+
+void
+get_mpf_block(MPFCB *p_mpfcb, void **p_blk)
+{
+	uint_t	blkidx;
+
+	if (p_mpfcb->freelist != INDEX_NULL) {
+		blkidx = p_mpfcb->freelist;
+		p_mpfcb->freelist = (p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next;
+	}
+	else {
+		blkidx = p_mpfcb->unused;
+		p_mpfcb->unused++;
+	}
+	*p_blk = (void *)((char *)(p_mpfcb->p_mpfinib->mpf)
+								+ p_mpfcb->p_mpfinib->blksz * blkidx);
+	p_mpfcb->fblkcnt--;
+	(p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next = INDEX_ALLOC;
+}
+
+#endif /* TOPPERS_mpfget */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®çæ
+ */
+#ifdef TOPPERS_acre_mpf
+
+ER_UINT
+acre_mpf(const T_CMPF *pk_cmpf)
+{
+	MPFCB	*p_mpfcb;
+	MPFINIB	*p_mpfinib;
+	ATR		mpfatr;
+	uint_t	blkcnt;
+	uint_t	blksz;
+	MPF_T	*mpf;
+	MPFMB	*p_mpfmb;
+	ER		ercd;
+
+	LOG_ACRE_MPF_ENTER(pk_cmpf);
+	CHECK_TSKCTX_UNL();
+
+	mpfatr = pk_cmpf->mpfatr;
+	blkcnt = pk_cmpf->blkcnt;
+	blksz = pk_cmpf->blksz;
+	mpf = pk_cmpf->mpf;
+	p_mpfmb = pk_cmpf->mpfmb;
+
+	CHECK_RSATR(mpfatr, TA_TPRI);
+	CHECK_PAR(blkcnt != 0);
+	CHECK_PAR(blksz != 0);
+	if (mpf != NULL) {
+		CHECK_PAR(MPF_ALIGN(mpf));
+	}
+	if (p_mpfmb != NULL) {
+		CHECK_PAR(MB_ALIGN(p_mpfmb));
+	}
+
+	lock_cpu();
+	if (tnum_mpf == 0 || queue_empty(&free_mpfcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		if (mpf == NULL) {
+			mpf = kernel_malloc(ROUND_MPF_T(blksz) * blkcnt);
+			mpfatr |= TA_MEMALLOC;
+		}
+		if (mpf == NULL) {
+			ercd = E_NOMEM;
+		}
+		else {
+			if (p_mpfmb == NULL) {
+				p_mpfmb = kernel_malloc(sizeof(MPFMB) * blkcnt);
+				mpfatr |= TA_MBALLOC;
+			}
+			if (p_mpfmb == NULL) {
+				if (mpf == NULL) {
+					kernel_free(mpf);
+				}
+				ercd = E_NOMEM;
+			}
+			else {
+				p_mpfcb = ((MPFCB *) queue_delete_next(&free_mpfcb));
+				p_mpfinib = (MPFINIB *)(p_mpfcb->p_mpfinib);
+				p_mpfinib->mpfatr = mpfatr;
+				p_mpfinib->blkcnt = blkcnt;
+				p_mpfinib->blksz = ROUND_MPF_T(blksz);
+				p_mpfinib->mpf = mpf;
+				p_mpfinib->p_mpfmb = p_mpfmb;
+
+				queue_initialize(&(p_mpfcb->wait_queue));
+				p_mpfcb->fblkcnt = p_mpfcb->p_mpfinib->blkcnt;
+				p_mpfcb->unused = 0U;
+				p_mpfcb->freelist = INDEX_NULL;
+				ercd = MPFID(p_mpfcb);
+			}
+		}
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_MPF_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®åé¤
+ */
+#ifdef TOPPERS_del_mpf
+
+ER
+del_mpf(ID mpfid)
+{
+	MPFCB	*p_mpfcb;
+	MPFINIB	*p_mpfinib;
+	ER		ercd;
+
+	LOG_DEL_MPF_ENTER(mpfid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (mpfid <= tmax_smpfid) {
+		ercd = E_OBJ;
+	}
+	else {
+		init_wait_queue(&(p_mpfcb->wait_queue));
+		p_mpfinib = (MPFINIB *)(p_mpfcb->p_mpfinib);
+		if ((p_mpfinib->mpfatr & TA_MEMALLOC) != 0U) {
+			kernel_free(p_mpfinib->mpf);
+		}
+		if ((p_mpfinib->mpfatr & TA_MBALLOC) != 0U) {
+			kernel_free(p_mpfinib->p_mpfmb);
+		}
+		p_mpfinib->mpfatr = TA_NOEXS;
+		queue_insert_prev(&free_mpfcb, &(p_mpfcb->wait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_MPF_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾
+ */
+#ifdef TOPPERS_get_mpf
+
+ER
+get_mpf(ID mpfid, void **p_blk)
+{
+	MPFCB	*p_mpfcb;
+	WINFO_MPF winfo_mpf;
+	ER		ercd;
+
+	LOG_GET_MPF_ENTER(mpfid, p_blk);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu_dsp();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_mpfcb->fblkcnt > 0) {
+		get_mpf_block(p_mpfcb, p_blk);
+		ercd = E_OK;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_MPF;
+		wobj_make_wait((WOBJCB *) p_mpfcb, (WINFO_WOBJ *) &winfo_mpf);
+		dispatch();
+		ercd = winfo_mpf.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_blk = winfo_mpf.blk;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_GET_MPF_LEAVE(ercd, p_blk);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_pget_mpf
+
+ER
+pget_mpf(ID mpfid, void **p_blk)
+{
+	MPFCB	*p_mpfcb;
+	ER		ercd;
+
+	LOG_PGET_MPF_ENTER(mpfid, p_blk);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_mpfcb->fblkcnt > 0) {
+		get_mpf_block(p_mpfcb, p_blk);
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PGET_MPF_LEAVE(ercd, p_blk);
+	return(ercd);
+}
+
+#endif /* TOPPERS_pget_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_tget_mpf
+
+ER
+tget_mpf(ID mpfid, void **p_blk, TMO tmout)
+{
+	MPFCB	*p_mpfcb;
+	WINFO_MPF winfo_mpf;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TGET_MPF_ENTER(mpfid, p_blk, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_MPFID(mpfid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu_dsp();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_mpfcb->fblkcnt > 0) {
+		get_mpf_block(p_mpfcb, p_blk);
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_MPF;
+		wobj_make_wait_tmout((WOBJCB *) p_mpfcb, (WINFO_WOBJ *) &winfo_mpf,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_mpf.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_blk = winfo_mpf.blk;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TGET_MPF_LEAVE(ercd, p_blk);
+	return(ercd);
+}
+
+#endif /* TOPPERS_tget_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®è¿å´
+ */
+#ifdef TOPPERS_rel_mpf
+
+ER
+rel_mpf(ID mpfid, void *blk)
+{
+	MPFCB	*p_mpfcb;
+	size_t	blkoffset;
+	uint_t	blkidx;
+	TCB		*p_tcb;
+	ER		ercd;
+    
+	LOG_REL_MPF_ENTER(mpfid, blk);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		blkoffset = ((char *) blk) - (char *)(p_mpfcb->p_mpfinib->mpf);
+		blkidx = (uint_t)(blkoffset / p_mpfcb->p_mpfinib->blksz);
+		if (!(p_mpfcb->p_mpfinib->mpf <= blk)
+				|| !(blkoffset % p_mpfcb->p_mpfinib->blksz == 0U)
+				|| !(blkoffset / p_mpfcb->p_mpfinib->blksz < p_mpfcb->unused)
+				|| !((p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next
+															== INDEX_ALLOC)) {
+			ercd = E_PAR;
+		}
+		else if (!queue_empty(&(p_mpfcb->wait_queue))) {
+			p_tcb = (TCB *) queue_delete_next(&(p_mpfcb->wait_queue));
+			((WINFO_MPF *)(p_tcb->p_winfo))->blk = blk;
+			wait_complete(p_tcb);
+			if (p_runtsk != p_schedtsk) {
+				dispatch();
+			}
+			ercd = E_OK;
+		}
+		else {
+			p_mpfcb->fblkcnt++;
+			(p_mpfcb->p_mpfinib->p_mpfmb + blkidx)->next = p_mpfcb->freelist;
+			p_mpfcb->freelist = blkidx;
+			ercd = E_OK;
+		}
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REL_MPF_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rel_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®ååæå
+ */
+#ifdef TOPPERS_ini_mpf
+
+ER
+ini_mpf(ID mpfid)
+{
+	MPFCB	*p_mpfcb;
+	ER		ercd;
+    
+	LOG_INI_MPF_ENTER(mpfid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_mpfcb->wait_queue));
+		p_mpfcb->fblkcnt = p_mpfcb->p_mpfinib->blkcnt;
+		p_mpfcb->unused = 0U;
+		p_mpfcb->freelist = INDEX_NULL;
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_MPF_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_mpf */
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_mpf
+
+ER
+ref_mpf(ID mpfid, T_RMPF *pk_rmpf)
+{
+	MPFCB	*p_mpfcb;
+	ER		ercd;
+    
+	LOG_REF_MPF_ENTER(mpfid, pk_rmpf);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MPFID(mpfid));
+	p_mpfcb = get_mpfcb(mpfid);
+
+	lock_cpu();
+	if (p_mpfcb->p_mpfinib->mpfatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rmpf->wtskid = wait_tskid(&(p_mpfcb->wait_queue));
+		pk_rmpf->fblkcnt = p_mpfcb->fblkcnt;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_MPF_LEAVE(ercd, pk_rmpf);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_mpf */
Index: asp3_gr_sakura/trunk/kernel/mempfix.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/mempfix.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mempfix.h	(revision 317)
@@ -0,0 +1,178 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		åºå®é·ã¡ã¢ãªãã¼ã«æ©è½
+ */
+
+#ifndef TOPPERS_MEMPFIX_H
+#define TOPPERS_MEMPFIX_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ç®¡çãã­ãã¯
+ *
+ *  nextãã£ã¼ã«ãã«ã¯ï¼ã¡ã¢ãªãã­ãã¯ãå²å½ã¦æ¸ã¿ã®å ´åã¯INDEX_ALLOCãï¼
+ *  æªå²å½ã¦ã®å ´åã¯æ¬¡ã®æªå²å½ã¦ãã­ãã¯ã®ã¤ã³ããã¯ã¹çªå·ãæ ¼ç´ããï¼
+ *  æå¾ã®æªå²å½ã¦ãã­ãã¯ã®å ´åã«ã¯ï¼INDEX_NULLãæ ¼ç´ããï¼
+ */
+typedef struct fixed_memoryblock_management_block {
+	uint_t		next;			/* æ¬¡ã®æªå²å½ã¦ãã­ãã¯ */
+} MPFMB;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct fixed_memorypool_initialization_block {
+	ATR			mpfatr;			/* åºå®é·ã¡ã¢ãªãã¼ã«å±æ§ */
+	uint_t		blkcnt;			/* ã¡ã¢ãªãã­ãã¯æ° */
+	uint_t		blksz;			/* ã¡ã¢ãªãã­ãã¯ã®ãµã¤ãºï¼ä¸¸ããå¤ï¼ */
+	void		*mpf;			/* åºå®é·ã¡ã¢ãªãã¼ã«é åã®å
+é ­çªå° */
+	MPFMB		*p_mpfmb;		/* åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çé åã®å
+é ­çªå° */
+} MPFINIB;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct fixed_memorypool_control_block {
+	QUEUE		wait_queue;		/* åºå®é·ã¡ã¢ãªãã¼ã«å¾
+ã¡ã­ã¥ã¼ */
+	const MPFINIB *p_mpfinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	uint_t		fblkcnt;		/* æªå²å½ã¦ãã­ãã¯æ° */
+	uint_t		unused;			/* æªä½¿ç¨ãã­ãã¯ã®å
+é ­ */
+	uint_t		freelist;		/* æªå²å½ã¦ãã­ãã¯ã®ãªã¹ã */
+} MPFCB;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®2ã¤ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct fixed_memorypool_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	MPFCB		*p_mpfcb;		/* å¾
+ã£ã¦ããåºå®é·ã¡ã¢ãªãã¼ã«ã®ç®¡çãã­ãã¯*/
+	void		*blk;			/* ç²å¾ããã¡ã¢ãªãã­ãã¯ */
+} WINFO_MPF;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãåºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_mpfcb;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_mpfid;
+extern const ID	tmax_smpfid;
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const MPFINIB	mpfinib_table[];
+extern MPFINIB			ampfinib_table[];
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern MPFCB	mpfcb_table[];
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çãã­ãã¯ããåºå®é·ã¡ã¢ãªãã¼ã«IDãåãåºãã
+ *  ãã®ãã¯ã­
+ */
+#define	MPFID(p_mpfcb)	((ID)(((p_mpfcb) - mpfcb_table) + TMIN_MPFID))
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«æ©è½ã®åæå
+ */
+extern void	initialize_mempfix(void);
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ãããã­ãã¯ãç²å¾
+ */
+extern void	get_mpf_block(MPFCB *p_mpfcb, void **p_blk);
+
+#endif /* TOPPERS_MEMPFIX_H */
Index: asp3_gr_sakura/trunk/kernel/mempfix.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/mempfix.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mempfix.trb	(revision 317)
@@ -0,0 +1,121 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: mempfix.trb 672 2016-03-05 15:33:08Z ertl-hiro $
+# 
+
+#
+#		åºå®é·ã¡ã¢ãªãã¼ã«æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class MempfixObject < KernelObject
+  def initialize()
+    super("mpf", "mempfix")
+  end
+
+  def prepare(key, params)
+    # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+    params[:mpf] ||= "NULL"
+    params[:mpfmb] ||= "NULL"
+
+    # mpfatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2225ï¼½
+    #ï¼TA_TPRIä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:mpfatr] & ~($TA_TPRI)) != 0
+      error_illegal_id("E_RSATR", params, :mpfatr, :mpfid)
+    end
+
+    # blkcntã0ã®å ´åï¼E_PARï¼ï¼»NGKI2229ï¼½
+    if params[:blkcnt] == 0
+      error_illegal_id("E_PAR", params, :blkcnt, :mpfid)
+    end
+
+    # blkszã0ã®å ´åï¼E_PARï¼ï¼»NGKI2230ï¼½
+    if params[:blksz] == 0
+      error_illegal_id("E_PAR", params, :blksz, :mpfid)
+    end
+
+    # åºå®é·ã¡ã¢ãªãã¼ã«é å
+    if params[:mpf] == "NULL"
+      mpfName = "_kernel_mpf_#{params[:mpfid]}"
+      $kernelCfgC.add("static MPF_T #{mpfName}" \
+				"[#{params[:blkcnt]} * COUNT_MPF_T(#{params[:blksz]})];")
+      params[:mpfinib_mpf] = mpfName
+    else
+      params[:mpfinib_mpf] = "(void *)(#{params[:mpf]})"
+    end
+
+    # mpfmbãNULLã§ãªãå ´åï¼E_NOSPTï¼ï¼»ASPS0166ï¼½
+    if params[:mpfmb] != "NULL"
+      error_illegal_id("E_NOSPT", params, :mpfmb, :mpfid)
+    end
+
+    # åºå®é·ã¡ã¢ãªãã¼ã«ç®¡çé å
+    mpfmbName = "_kernel_mpfmb_#{params[:mpfid]}"
+    $kernelCfgC.add("static MPFMB #{mpfmbName}[#{params[:blkcnt]}];")
+    params[:mpfinib_mpfmb] = mpfmbName
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:mpfatr]}), (#{params[:blkcnt]}), " \
+			"ROUND_MPF_T(#{params[:blksz]}), #{params[:mpfinib_mpf]}, " \
+			"#{params[:mpfinib_mpfmb]}")
+  end
+end
+
+#
+#  åºå®é·ã¡ã¢ãªãã¼ã«ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Fixed-sized Memorypool Functions")
+MempfixObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/mutex.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/mutex.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mutex.c	(revision 317)
@@ -0,0 +1,795 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¥ã¼ããã¯ã¹æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "taskhook.h"
+#include "wait.h"
+#include "mutex.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_MTX_ENTER
+#define LOG_ACRE_MTX_ENTER(pk_cmtx)
+#endif /* LOG_ACRE_MTX_ENTER */
+
+#ifndef LOG_ACRE_MTX_LEAVE
+#define LOG_ACRE_MTX_LEAVE(ercd)
+#endif /* LOG_ACRE_MTX_LEAVE */
+
+#ifndef LOG_DEL_MTX_ENTER
+#define LOG_DEL_MTX_ENTER(mtxid)
+#endif /* LOG_DEL_MTX_ENTER */
+
+#ifndef LOG_DEL_MTX_LEAVE
+#define LOG_DEL_MTX_LEAVE(ercd)
+#endif /* LOG_DEL_MTX_LEAVE */
+
+#ifndef LOG_LOC_MTX_ENTER
+#define LOG_LOC_MTX_ENTER(mtxid)
+#endif /* LOG_LOC_MTX_ENTER */
+
+#ifndef LOG_LOC_MTX_LEAVE
+#define LOG_LOC_MTX_LEAVE(ercd)
+#endif /* LOG_LOC_MTX_LEAVE */
+
+#ifndef LOG_PLOC_MTX_ENTER
+#define LOG_PLOC_MTX_ENTER(mtxid)
+#endif /* LOG_PLOC_MTX_ENTER */
+
+#ifndef LOG_PLOC_MTX_LEAVE
+#define LOG_PLOC_MTX_LEAVE(ercd)
+#endif /* LOG_PLOC_MTX_LEAVE */
+
+#ifndef LOG_TLOC_MTX_ENTER
+#define LOG_TLOC_MTX_ENTER(mtxid, tmout)
+#endif /* LOG_TLOC_MTX_ENTER */
+
+#ifndef LOG_TLOC_MTX_LEAVE
+#define LOG_TLOC_MTX_LEAVE(ercd)
+#endif /* LOG_TLOC_MTX_LEAVE */
+
+#ifndef LOG_UNL_MTX_ENTER
+#define LOG_UNL_MTX_ENTER(mtxid)
+#endif /* LOG_UNL_MTX_ENTER */
+
+#ifndef LOG_UNL_MTX_LEAVE
+#define LOG_UNL_MTX_LEAVE(ercd)
+#endif /* LOG_UNL_MTX_LEAVE */
+
+#ifndef LOG_INI_MTX_ENTER
+#define LOG_INI_MTX_ENTER(mtxid)
+#endif /* LOG_INI_MTX_ENTER */
+
+#ifndef LOG_INI_MTX_LEAVE
+#define LOG_INI_MTX_LEAVE(ercd)
+#endif /* LOG_INI_MTX_LEAVE */
+
+#ifndef LOG_REF_MTX_ENTER
+#define LOG_REF_MTX_ENTER(mtxid, pk_rmtx)
+#endif /* LOG_REF_MTX_ENTER */
+
+#ifndef LOG_REF_MTX_LEAVE
+#define LOG_REF_MTX_LEAVE(ercd, pk_rmtx)
+#endif /* LOG_REF_MTX_LEAVE */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®æ°
+ */
+#define tnum_mtx	((uint_t)(tmax_mtxid - TMIN_MTXID + 1))
+#define tnum_smtx	((uint_t)(tmax_smtxid - TMIN_MTXID + 1))
+
+/*
+ *  ãã¥ã¼ããã¯ã¹IDãããã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_MTX(mtxid)	((uint_t)((mtxid) - TMIN_MTXID))
+#define get_mtxcb(mtxid)	(&(mtxcb_table[INDEX_MTX(mtxid)]))
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ãã­ãã³ã«ãå¤æ­ãããã¯ã­
+ */
+#define MTXPROTO_MASK			0x03U
+#define MTXPROTO(p_mtxcb)		((p_mtxcb)->p_mtxinib->mtxatr & MTXPROTO_MASK)
+#define MTX_CEILING(p_mtxcb)	(MTXPROTO(p_mtxcb) == TA_CEILING)
+
+#ifdef TOPPERS_mtxini
+
+/*
+ *  ä½¿ç¨ãã¦ããªããã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_mtxcb;
+
+/* 
+ *  ãã¥ã¼ããã¯ã¹æ©è½ã®åæå
+ */
+void
+initialize_mutex(void)
+{
+	uint_t	i, j;
+	MTXCB	*p_mtxcb;
+	MTXINIB	*p_mtxinib;
+
+	mtxhook_check_ceilpri = mutex_check_ceilpri;
+	mtxhook_scan_ceilmtx = mutex_scan_ceilmtx;
+	mtxhook_release_all = mutex_release_all;
+
+	for (i = 0; i < tnum_smtx; i++) {
+		p_mtxcb = &(mtxcb_table[i]);
+		queue_initialize(&(p_mtxcb->wait_queue));
+		p_mtxcb->p_mtxinib = &(mtxinib_table[i]);
+		p_mtxcb->p_loctsk = NULL;
+	}
+	queue_initialize(&free_mtxcb);
+	for (j = 0; i < tnum_mtx; i++, j++) {
+		p_mtxcb = &(mtxcb_table[i]);
+		p_mtxinib = &(amtxinib_table[j]);
+		p_mtxinib->mtxatr = TA_NOEXS;
+		p_mtxcb->p_mtxinib = ((const MTXINIB *) p_mtxinib);
+		queue_insert_prev(&free_mtxcb, &(p_mtxcb->wait_queue));
+	}
+}
+
+#endif /* TOPPERS_mtxini */
+
+/* 
+ *  ä¸éåªå
+åº¦éåã®ãã§ãã¯
+ */
+#ifdef TOPPERS_mtxchk
+
+bool_t
+mutex_check_ceilpri(TCB *p_tcb, uint_t bpriority)
+{
+	MTXCB	*p_mtxcb;
+
+	/*
+	 *  ã¿ã¹ã¯ãã­ãã¯ãã¦ããåªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã®ä¸­ã§ï¼ä¸éåªå
+
+	 *  åº¦ãbpriorityãããä½ããã®ãããã°ï¼falseãè¿ãï¼
+	 */
+	p_mtxcb = p_tcb->p_lastmtx;
+	while (p_mtxcb != NULL) {
+		if (MTX_CEILING(p_mtxcb) && bpriority < p_mtxcb->p_mtxinib->ceilpri) {
+			return(false);
+		}
+		p_mtxcb = p_mtxcb->p_prevmtx;
+	}
+
+	/*
+	 *  ã¿ã¹ã¯ãåªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã®ã­ãã¯ãå¾
+ã£ã¦ããå ´åã«ï¼ã
+	 *  ã®ä¸éåªå
+åº¦ãbpriorityãããä½ãããã°ï¼falseãè¿ãï¼
+	 */
+	if (TSTAT_WAIT_MTX(p_tcb->tstat)) {
+		p_mtxcb = ((WINFO_MTX *)(p_tcb->p_winfo))->p_mtxcb;
+		if (MTX_CEILING(p_mtxcb) && bpriority < p_mtxcb->p_mtxinib->ceilpri) {
+			return(false);
+		}
+	}
+
+	/*
+	 *  ãããã®æ¡ä»¶ã«ãå½ã¦ã¯ã¾ããªããã°trueãè¿ãï¼
+	 */
+	return(true);
+}
+
+#endif /* TOPPERS_mtxchk */
+
+/* 
+ *  åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ãã¦ãããã®ãã§ãã¯
+ */
+#ifdef TOPPERS_mtxscan
+
+bool_t
+mutex_scan_ceilmtx(TCB *p_tcb)
+{
+	MTXCB	*p_mtxcb;
+
+	p_mtxcb = p_tcb->p_lastmtx;
+	while (p_mtxcb != NULL) {
+		if (MTX_CEILING(p_mtxcb)) {
+			return(true);
+		}
+		p_mtxcb = p_mtxcb->p_prevmtx;
+	}
+	return(false);
+}
+
+#endif /* TOPPERS_mtxscan */
+
+/* 
+ *  ã¿ã¹ã¯ã®ç¾å¨åªå
+åº¦ã®è¨ç®
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®ç¾å¨åªå
+åº¦ï¼ã«è¨­å®ãã¹ãå¤ï¼ãè¨ç®ããï¼
+ */
+Inline uint_t
+mutex_calc_priority(TCB *p_tcb)
+{
+	uint_t	priority;
+	MTXCB	*p_mtxcb;
+
+	priority = p_tcb->bpriority;
+	p_mtxcb = p_tcb->p_lastmtx;
+	while (p_mtxcb != NULL) {
+		if (MTX_CEILING(p_mtxcb) && p_mtxcb->p_mtxinib->ceilpri < priority) {
+			priority = p_mtxcb->p_mtxinib->ceilpri;
+		}
+		p_mtxcb = p_mtxcb->p_prevmtx;
+	}
+	return(priority);
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ãè§£æ¾ããå ´åã®ç¾å¨åªå
+åº¦å¤æ´å¦ç
+ */
+#ifdef TOPPERS_mtxdrop
+
+void
+mutex_drop_priority(TCB *p_tcb, MTXCB *p_mtxcb)
+{
+	uint_t	newpri;
+
+	if (MTX_CEILING(p_mtxcb)
+					&& p_mtxcb->p_mtxinib->ceilpri == p_tcb->priority) {
+		newpri = mutex_calc_priority(p_tcb);
+		if (newpri != p_tcb->priority) {
+			change_priority(p_tcb, newpri, true);
+		}
+	}
+}
+
+#endif /* TOPPERS_mtxdrop */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯
+ */
+#ifdef TOPPERS_mtxacq
+
+void
+mutex_acquire(TCB *p_tcb, MTXCB *p_mtxcb)
+{
+	p_mtxcb->p_loctsk = p_tcb;
+	p_mtxcb->p_prevmtx = p_tcb->p_lastmtx;
+	p_tcb->p_lastmtx = p_mtxcb;
+	if (MTX_CEILING(p_mtxcb)
+					&& p_mtxcb->p_mtxinib->ceilpri < p_tcb->priority) {
+		change_priority(p_tcb, p_mtxcb->p_mtxinib->ceilpri, true);
+	}
+}
+
+#endif /* TOPPERS_mtxacq */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ */
+#ifdef TOPPERS_mtxrel
+
+void
+mutex_release(MTXCB *p_mtxcb)
+{
+	TCB		*p_tcb;
+
+	if (queue_empty(&(p_mtxcb->wait_queue))) {
+		p_mtxcb->p_loctsk = NULL;
+	}
+	else {
+		/*
+		 *  ãã¥ã¼ããã¯ã¹å¾
+ã¡ã­ã¥ã¼ã®å
+é ­ã¿ã¹ã¯ï¼p_tcbï¼ã«ï¼ãã¥ã¼ãã
+		 *  ã¯ã¹ãã­ãã¯ãããï¼
+		 */
+		p_tcb = (TCB *) queue_delete_next(&(p_mtxcb->wait_queue));
+		wait_dequeue_tmevtb(p_tcb);
+		p_tcb->p_winfo->wercd = E_OK;
+
+		p_mtxcb->p_loctsk = p_tcb;
+		p_mtxcb->p_prevmtx = p_tcb->p_lastmtx;
+		p_tcb->p_lastmtx = p_mtxcb;
+		if (MTX_CEILING(p_mtxcb)) {
+			if (p_mtxcb->p_mtxinib->ceilpri < p_tcb->priority) {
+				p_tcb->priority = p_mtxcb->p_mtxinib->ceilpri;
+			}
+		}
+		make_non_wait(p_tcb);
+	}
+}
+
+#endif /* TOPPERS_mtxrel */
+
+/*
+ *  ã¿ã¹ã¯ãã­ãã¯ãã¦ãããã¹ã¦ã®ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ */
+#ifdef TOPPERS_mtxrela
+
+void
+mutex_release_all(TCB *p_tcb)
+{
+	MTXCB	*p_mtxcb;
+
+	while ((p_mtxcb = p_tcb->p_lastmtx) != NULL) {
+		p_tcb->p_lastmtx = p_mtxcb->p_prevmtx;
+		mutex_release(p_mtxcb);
+	}
+}
+
+#endif /* TOPPERS_mtxrela */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®çæï¼»NGKI2022ï¼½
+ */
+#ifdef TOPPERS_acre_mtx
+
+ER_UINT
+acre_mtx(const T_CMTX *pk_cmtx)
+{
+	MTXCB	*p_mtxcb;
+	MTXINIB	*p_mtxinib;
+	ATR		mtxatr;
+	PRI		ceilpri;
+	ER		ercd;
+
+	LOG_ACRE_MTX_ENTER(pk_cmtx);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI2023ï¼½ï¼»NGKI2024ï¼½*/
+
+	mtxatr = pk_cmtx->mtxatr;
+	ceilpri = pk_cmtx->ceilpri;
+
+	if (mtxatr == TA_CEILING) {
+		CHECK_PAR(VALID_TPRI(ceilpri));			/*ï¼»NGKI2037ï¼½*/
+	}
+	else {
+		CHECK_RSATR(mtxatr, TA_TPRI);			/*ï¼»NGKI2025ï¼½*/
+	}
+
+	lock_cpu();
+	if (tnum_mtx == 0 || queue_empty(&free_mtxcb)) {
+		ercd = E_NOID;							/*ï¼»NGKI2031ï¼½*/
+	}
+	else {
+		p_mtxcb = ((MTXCB *) queue_delete_next(&free_mtxcb));
+		p_mtxinib = (MTXINIB *)(p_mtxcb->p_mtxinib);
+		p_mtxinib->mtxatr = mtxatr;
+		p_mtxinib->ceilpri = INT_PRIORITY(ceilpri);
+
+		queue_initialize(&(p_mtxcb->wait_queue));
+		p_mtxcb->p_loctsk = NULL;				/*ï¼»NGKI2033ï¼½*/
+		ercd = MTXID(p_mtxcb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®åé¤ï¼»NGKI2056ï¼½
+ */
+#ifdef TOPPERS_del_mtx
+
+ER
+del_mtx(ID mtxid)
+{
+	MTXCB	*p_mtxcb, **pp_prevmtx;
+	MTXINIB	*p_mtxinib;
+	TCB		*p_loctsk;
+	ER		ercd;
+
+	LOG_DEL_MTX_ENTER(mtxid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI2057ï¼½ï¼»NGKI2058ï¼½*/
+	CHECK_ID(VALID_MTXID(mtxid));				/*ï¼»NGKI2059ï¼½*/
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI2060ï¼½*/
+	}
+	else if (mtxid <= tmax_smtxid) {
+		ercd = E_OBJ;							/*ï¼»NGKI2062ï¼½*/
+	}
+	else {
+		init_wait_queue(&(p_mtxcb->wait_queue));	/*ï¼»NGKI2065ï¼½*/
+		p_loctsk = p_mtxcb->p_loctsk;
+		if (p_loctsk != NULL) {
+			/*
+			 *  p_loctskãã­ãã¯ãã¦ãããã¥ã¼ããã¯ã¹ã®ãªã¹ãããå¯¾è±¡
+			 *  ãã¥ã¼ã¯ã¹ãåé¤ãï¼å¿
+è¦ãªå ´åã«ã¯p_loctskã®ç¾å¨åªå
+åº¦
+			 *  ãå¤æ´ããï¼»NGKI2064ï¼½ï¼
+			 */
+			pp_prevmtx = &(p_loctsk->p_lastmtx);
+			while (*pp_prevmtx != NULL) {
+				if (*pp_prevmtx == p_mtxcb) {
+					*pp_prevmtx = p_mtxcb->p_prevmtx;
+					break;
+				}
+				pp_prevmtx = &((*pp_prevmtx)->p_prevmtx);
+			}
+			mutex_drop_priority(p_loctsk, p_mtxcb);
+		}
+		p_mtxinib = (MTXINIB *)(p_mtxcb->p_mtxinib);
+		p_mtxinib->mtxatr = TA_NOEXS;						/*ï¼»NGKI2063ï¼½*/
+		queue_insert_prev(&free_mtxcb, &(p_mtxcb->wait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯
+ */
+#ifdef TOPPERS_loc_mtx
+
+ER
+loc_mtx(ID mtxid)
+{
+	MTXCB	*p_mtxcb;
+	WINFO_MTX winfo_mtx;
+	ER		ercd;
+
+	LOG_LOC_MTX_ENTER(mtxid);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_MTXID(mtxid));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu_dsp();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (MTX_CEILING(p_mtxcb)
+				&& p_runtsk->bpriority < p_mtxcb->p_mtxinib->ceilpri) {
+		ercd = E_ILUSE;
+	}
+	else if (p_mtxcb->p_loctsk == NULL) {
+		mutex_acquire(p_runtsk, p_mtxcb);
+		/*
+		 *  åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ããå ´åï¼p_runtskã®åªå
+åº¦
+		 *  ãä¸ããå¯è½æ§ããããï¼ãã£ã¹ããããå¿
+è¦ã«ãªããã¨ã¯ãªãï¼
+		 */
+		assert(p_runtsk == p_schedtsk);
+		ercd = E_OK;
+	}
+	else if (p_mtxcb->p_loctsk == p_runtsk) {
+		ercd = E_OBJ;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_MTX;
+		wobj_make_wait((WOBJCB *) p_mtxcb, (WINFO_WOBJ *) &winfo_mtx);
+		dispatch();
+		ercd = winfo_mtx.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_LOC_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_loc_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_ploc_mtx
+
+ER
+ploc_mtx(ID mtxid)
+{
+	MTXCB	*p_mtxcb;
+	ER		ercd;
+
+	LOG_PLOC_MTX_ENTER(mtxid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MTXID(mtxid));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (MTX_CEILING(p_mtxcb)
+				&& p_runtsk->bpriority < p_mtxcb->p_mtxinib->ceilpri) {
+		ercd = E_ILUSE;
+	}
+	else if (p_mtxcb->p_loctsk == NULL) {
+		mutex_acquire(p_runtsk, p_mtxcb);
+		/*
+		 *  åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ããå ´åï¼p_runtskã®åªå
+åº¦
+		 *  ãä¸ããå¯è½æ§ããããï¼ãã£ã¹ããããå¿
+è¦ã«ãªããã¨ã¯ãªãï¼
+		 */
+		assert(p_runtsk == p_schedtsk);
+		ercd = E_OK;
+	}
+	else if (p_mtxcb->p_loctsk == p_runtsk) {
+		ercd = E_OBJ;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PLOC_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ploc_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_tloc_mtx
+
+ER
+tloc_mtx(ID mtxid, TMO tmout)
+{
+	MTXCB	*p_mtxcb;
+	WINFO_MTX winfo_mtx;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TLOC_MTX_ENTER(mtxid, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_MTXID(mtxid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu_dsp();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (MTX_CEILING(p_mtxcb)
+				&& p_runtsk->bpriority < p_mtxcb->p_mtxinib->ceilpri) {
+		ercd = E_ILUSE;
+	}
+	else if (p_mtxcb->p_loctsk == NULL) {
+		mutex_acquire(p_runtsk, p_mtxcb);
+		/*
+		 *  åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ããå ´åï¼p_runtskã®åªå
+åº¦
+		 *  ãä¸ããå¯è½æ§ããããï¼ãã£ã¹ããããå¿
+è¦ã«ãªããã¨ã¯ãªãï¼
+		 */
+		assert(p_runtsk == p_schedtsk);
+		ercd = E_OK;
+	}
+	else if (p_mtxcb->p_loctsk == p_runtsk) {
+		ercd = E_OBJ;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_MTX;
+		wobj_make_wait_tmout((WOBJCB *) p_mtxcb, (WINFO_WOBJ *) &winfo_mtx,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_mtx.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TLOC_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_tloc_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ */
+#ifdef TOPPERS_unl_mtx
+
+ER
+unl_mtx(ID mtxid)
+{
+	MTXCB	*p_mtxcb;
+	ER		ercd;
+    
+	LOG_UNL_MTX_ENTER(mtxid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MTXID(mtxid));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_mtxcb != p_runtsk->p_lastmtx) {
+		ercd = E_OBJ;
+	}
+	else {
+		p_runtsk->p_lastmtx = p_mtxcb->p_prevmtx;
+		mutex_drop_priority(p_runtsk, p_mtxcb);
+		mutex_release(p_mtxcb);
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_UNL_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_unl_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ååæå
+ */
+#ifdef TOPPERS_ini_mtx
+
+ER
+ini_mtx(ID mtxid)
+{
+	MTXCB	*p_mtxcb, **pp_prevmtx;
+	TCB		*p_loctsk;
+	ER		ercd;
+    
+	LOG_INI_MTX_ENTER(mtxid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MTXID(mtxid));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_mtxcb->wait_queue));
+		p_loctsk = p_mtxcb->p_loctsk;
+		if (p_loctsk != NULL) {
+			p_mtxcb->p_loctsk = NULL;
+			pp_prevmtx = &(p_loctsk->p_lastmtx);
+			while (*pp_prevmtx != NULL) {
+				if (*pp_prevmtx == p_mtxcb) {
+					*pp_prevmtx = p_mtxcb->p_prevmtx;
+					break;
+				}
+				pp_prevmtx = &((*pp_prevmtx)->p_prevmtx);
+			}
+			mutex_drop_priority(p_loctsk, p_mtxcb);
+		}
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_MTX_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_mtx */
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_mtx
+
+ER
+ref_mtx(ID mtxid, T_RMTX *pk_rmtx)
+{
+	MTXCB	*p_mtxcb;
+	ER		ercd;
+    
+	LOG_REF_MTX_ENTER(mtxid, pk_rmtx);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_MTXID(mtxid));
+	p_mtxcb = get_mtxcb(mtxid);
+
+	lock_cpu();
+	if (p_mtxcb->p_mtxinib->mtxatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rmtx->htskid = (p_mtxcb->p_loctsk != NULL) ? TSKID(p_mtxcb->p_loctsk)
+														: TSK_NONE;
+		pk_rmtx->wtskid = wait_tskid(&(p_mtxcb->wait_queue));
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_MTX_LEAVE(ercd, pk_rmtx);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_mtx */
Index: asp3_gr_sakura/trunk/kernel/mutex.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/mutex.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mutex.h	(revision 317)
@@ -0,0 +1,229 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¥ã¼ããã¯ã¹æ©è½
+ */
+
+#ifndef TOPPERS_MUTEX_H
+#define TOPPERS_MUTEX_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  ãã¥ã¼ããã¯ã¹åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct mutex_initialization_block {
+	ATR			mtxatr;			/* ãã¥ã¼ããã¯ã¹å±æ§ */
+	uint_t		ceilpri;		/* ãã¥ã¼ããã¯ã¹ã®ä¸éåªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼*/
+} MTXINIB;
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+struct mutex_control_block {
+	QUEUE		wait_queue;		/* ãã¥ã¼ããã¯ã¹å¾
+ã¡ã­ã¥ã¼ */
+	const MTXINIB *p_mtxinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	TCB			*p_loctsk;		/* ãã¥ã¼ããã¯ã¹ãã­ãã¯ãã¦ããã¿ã¹ã¯ */
+	MTXCB		*p_prevmtx;		/* ãã®åã«ã­ãã¯ãããã¥ã¼ããã¯ã¹ */
+};
+
+/*
+ *  ãã¥ã¼ããã¯ã¹å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  ãã¹ã¦ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct mutex_waiting_information {
+	WINFO	winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	MTXCB	*p_mtxcb;		/* å¾
+ã£ã¦ãããã¥ã¼ããã¯ã¹ã®ç®¡çãã­ãã¯ */
+} WINFO_MTX;
+
+/*
+ *  ä½¿ç¨ãã¦ããªããã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_mtxcb;
+
+/*
+ *  ãã¥ã¼ããã¯ã¹IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_mtxid;
+extern const ID	tmax_smtxid;
+
+/*
+ *  ãã¥ã¼ããã¯ã¹åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const MTXINIB	mtxinib_table[];
+extern MTXINIB			amtxinib_table[];
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern MTXCB	mtxcb_table[];
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ãããã¥ã¼ããã¯ã¹IDãåãåºãããã®ãã¯ã­
+ */
+#define	MTXID(p_mtxcb)	((ID)(((p_mtxcb) - mtxcb_table) + TMIN_MTXID))
+
+/*
+ *  ãã¥ã¼ããã¯ã¹æ©è½ã®åæå
+ */
+extern void	initialize_mutex(void);
+
+/*
+ *  ä¸éåªå
+åº¦éåã®ãã§ãã¯
+ *
+ *  chg_priã®ä¸­ã§ä¸éåªå
+åº¦éåã®ãã§ãã¯ãè¡ãããã«ç¨ããé¢æ°ã§ããï¼
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãã­ãã¯ãã¦ããåªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã¨ï¼
+ *  ã­ãã¯ãå¾
+ã£ã¦ããåªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã®ä¸­ã§ï¼ä¸éåªå
+åº¦ã
+ *  bpriorityãããä½ããã®ãããã°falseãï¼ããã§ãªããã°trueãè¿ãï¼
+ */
+extern bool_t	mutex_check_ceilpri(TCB *p_tcb, uint_t bpriority);
+
+/* 
+ *  åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ãã¦ãããã®ãã§ãã¯
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãåªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ãã­ãã¯ãã¦ããã°
+ *  trueï¼ããã§ãªããã°falseãè¿ãï¼
+ */
+extern bool_t	mutex_scan_ceilmtx(TCB *p_tcb);
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ãã­ãã¯è§£é¤ããå ´åã®ç¾å¨åªå
+åº¦å¤æ´å¦ç
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãï¼p_mtxcbã§æå®ããããã¥ã¼ããã¯ã¹ãã­ã
+ *  ã¯è§£é¤ããéã®ç¾å¨åªå
+åº¦å¤æ´å¦çãè¡ãï¼
+ */
+extern void	mutex_drop_priority(TCB *p_tcb, MTXCB *p_mtxcb);
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã«ï¼p_mtxcbã§æå®ããããã¥ã¼ããã¯ã¹ãã­ã
+ *  ã¯ãããï¼
+ */
+extern void	mutex_acquire(TCB *p_tcb, MTXCB *p_mtxcb);
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ *
+ *  p_mtxcbã§æå®ããããã¥ã¼ããã¯ã¹ãã­ãã¯è§£é¤ããï¼ã­ãã¯è§£é¤ãã
+ *  ãã¥ã¼ããã¯ã¹ã«ï¼ã­ãã¯å¾
+ã¡ç¶æ
+ã®ã¿ã¹ã¯ãããå ´åã«ã¯ï¼ãã®ã¿ã¹ã¯
+ *  ã«ãã¥ã¼ããã¯ã¹ãã­ãã¯ãããï¼
+ */
+extern void	mutex_release(MTXCB *p_mtxcb);
+
+/*
+ *  ã¿ã¹ã¯ãã­ãã¯ãã¦ãããã¹ã¦ã®ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã«ï¼ãããã­ãã¯ãã¦ãããã¹ã¦ã®ãã¥ã¼ããã¯
+ *  ã¹ãã­ãã¯è§£é¤ãããï¼ã­ãã¯è§£é¤ãããã¥ã¼ããã¯ã¹ã«ï¼ã­ãã¯å¾
+ã¡ç¶
+ *  æ
+ã®ã¿ã¹ã¯ãããå ´åã«ã¯ï¼ãã®ã¿ã¹ã¯ã«ãã¥ã¼ããã¯ã¹ãã­ãã¯ãããï¼
+ *
+ *  ãã®é¢æ°ã¯ï¼ã¿ã¹ã¯ã®çµäºæã«ä½¿ããããã®ã§ããããï¼p_tcbã§æå®ãã
+ *  ãã¿ã¹ã¯ã®åªå
+åº¦ãå¤æ´ããå¦çã¯è¡ããªãï¼ãã ãï¼ãã®é¢æ°ã®ä¸­ã§ä»
+ *  ã®ã¿ã¹ã¯ã®åªå
+åº¦ãå¤åãï¼å®è¡ãã¹ãã¿ã¹ã¯ãå¤ãããã¨ãããï¼ãã®
+ *  ããï¼ãã®é¢æ°ããæ»ã£ãå¾ã«ï¼ãã£ã¹ããããå¿
+è¦ãå¤å¥ãã¦ï¼å¿
+è¦ãª
+ *  å ´åã«ã¯ãã£ã¹ããããè¡ããªããã°ãªããªãï¼
+ */
+extern void	mutex_release_all(TCB *p_tcb);
+
+#endif /* TOPPERS_MUTEX_H */
Index: asp3_gr_sakura/trunk/kernel/mutex.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/mutex.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/mutex.trb	(revision 317)
@@ -0,0 +1,108 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: mutex.trb 630 2016-02-14 11:30:17Z ertl-hiro $
+# 
+
+#
+#		ãã¥ã¼ããã¯ã¹æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class MutexObject < KernelObject
+  def initialize()
+    super("mtx", "mutex")
+  end
+
+  def prepare(key, params)
+    # mtxatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2025ï¼½
+    # ï¼TA_NULLï¼TA_TPRIï¼TA_CEILINGã®ãããã§ããªãå ´åï¼
+    if !(params[:mtxatr] == $TA_NULL || params[:mtxatr] == $TA_TPRI \
+										|| params[:mtxatr] == $TA_CEILING)
+      error_illegal_id("E_RSATR", params, :mtxatr, :mtxid)
+    end
+
+    if params[:mtxatr] == $TA_CEILING
+      # åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã®å ´å
+      # ceilpriãæªæå®ã®å ´åã¯ã¨ã©ã¼ã¨ãã
+      if params[:ceilpri].nil?
+        error_api(params, "ceilpri must be specified in %apiname of %mtxid")
+
+      # (TMIN_TPRI <= ceilpri && ceilpri <= TMAX_TPRI)ã§ãªãå ´åï¼E_PARï¼
+      # ï¼»NGKI2037ï¼½
+      elsif !($TMIN_TPRI <= params[:ceilpri] && params[:ceilpri] <= $TMAX_TPRI)
+        error_illegal_id("E_PAR", params, :ceilpri, :mtxid)
+      end
+    else
+      # åªå
+åº¦ä¸éãã¥ã¼ããã¯ã¹ã§ãªãå ´å
+      # ceilpriãæå®ããã¦ããå ´åã¯è­¦åã¡ãã»ã¼ã¸ãåºã
+      if !params[:ceilpri].nil?
+        warning_api(params, "%%ceilpri is ignored in %apiname of %mtxid")
+      end
+      params[:ceilpri] = 0
+    end
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:mtxatr]}), INT_PRIORITY(#{params[:ceilpri]})")
+  end
+end
+
+#
+#  ãã¥ã¼ããã¯ã¹ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Mutex Functions")
+MutexObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/overrun.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/overrun.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/overrun.c	(revision 317)
@@ -0,0 +1,328 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãªã¼ãã©ã³ãã³ãã©æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "overrun.h"
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+#include "target_timer.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_OVR_ENTER
+#define LOG_OVR_ENTER(p_runtsk)
+#endif /* LOG_OVR_ENTER */
+
+#ifndef LOG_OVR_LEAVE
+#define LOG_OVR_LEAVE(p_runtsk)
+#endif /* LOG_OVR_LEAVE */
+
+#ifndef LOG_STA_OVR_ENTER
+#define LOG_STA_OVR_ENTER(tskid, ovrtim)
+#endif /* LOG_STA_OVR_ENTER */
+
+#ifndef LOG_STA_OVR_LEAVE
+#define LOG_STA_OVR_LEAVE(ercd)
+#endif /* LOG_STA_OVR_LEAVE */
+
+#ifndef LOG_STP_OVR_ENTER
+#define LOG_STP_OVR_ENTER(tskid)
+#endif /* LOG_STP_OVR_ENTER */
+
+#ifndef LOG_STP_OVR_LEAVE
+#define LOG_STP_OVR_LEAVE(ercd)
+#endif /* LOG_STP_OVR_LEAVE */
+
+#ifndef LOG_REF_OVR_ENTER
+#define LOG_REF_OVR_ENTER(tskid, pk_rovr)
+#endif /* LOG_REF_OVR_ENTER */
+
+#ifndef LOG_REF_OVR_LEAVE
+#define LOG_REF_OVR_LEAVE(ercd, pk_rovr)
+#endif /* LOG_REF_OVR_LEAVE */
+
+#ifdef TOPPERS_ovrini
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ããåä½ä¸­ããç¤ºããã©ã°
+ */
+bool_t	ovrtimer_flag;
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©æ©è½ã®åæå
+ */
+void
+initialize_overrun(void)
+{
+	ovrtimer_flag = false;
+}
+
+#endif /* TOPPERS_ovrini */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ç¨ã¿ã¤ãã®åä½éå§
+ */
+#ifdef TOPPERS_ovrsta
+#ifndef OMIT_OVRTIMER_START
+
+void
+ovrtimer_start(void)
+{
+	if (p_runtsk->staovr) {
+		target_ovrtimer_start(p_runtsk->leftotm);
+		ovrtimer_flag = true;
+	}
+}
+
+#endif /* OMIT_OVRTIMER_START */
+#endif /* TOPPERS_ovrsta */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ç¨ã¿ã¤ãã®åæ­¢
+ */
+#ifdef TOPPERS_ovrstp
+#ifndef OMIT_OVRTIMER_STOP
+
+void
+ovrtimer_stop(uint_t int_num)
+{
+	if (ovrtimer_flag) {
+		assert(p_runtsk != NULL && p_runtsk->staovr);
+		p_runtsk->leftotm = target_ovrtimer_stop(int_num);
+		ovrtimer_flag = false;
+	}
+}
+
+#endif /* OMIT_OVRTIMER_STOP */
+#endif /* TOPPERS_ovrstp */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ã®åä½éå§
+ */
+#ifdef TOPPERS_sta_ovr
+
+ER
+sta_ovr(ID tskid, PRCTIM ovrtim)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_STA_OVR_ENTER(tskid, ovrtim);
+	CHECK_UNL();
+	CHECK_OBJ(ovrinib[0].ovrhdr != NULL);
+	if (tskid == TSK_SELF && !sense_context()) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+	CHECK_PAR(0U < ovrtim && ovrtim <= TMAX_OVRTIM);
+
+	lock_cpu();
+	if (!sense_context() && p_tcb == p_runtsk) {
+		if (p_runtsk->staovr) {
+			(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+		}
+		target_ovrtimer_start(ovrtim);
+		ovrtimer_flag = true;
+	}
+	p_tcb->staovr = true;
+	p_tcb->leftotm = ovrtim;
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_STA_OVR_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_sta_ovr */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ã®åä½åæ­¢
+ */
+#ifdef TOPPERS_stp_ovr
+
+ER
+stp_ovr(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_STP_OVR_ENTER(tskid);
+	CHECK_UNL();
+	CHECK_OBJ(ovrinib[0].ovrhdr != NULL);
+	if (tskid == TSK_SELF && !sense_context()) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (!sense_context() && p_tcb == p_runtsk) {
+		if (p_runtsk->staovr) {
+			(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+			ovrtimer_flag = false;
+		}
+	}
+	p_tcb->staovr = false;
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_STP_OVR_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_stp_ovr */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_ovr
+
+ER
+ref_ovr(ID tskid, T_ROVR *pk_rovr)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+    
+	LOG_REF_OVR_ENTER(tskid, pk_rovr);
+	CHECK_TSKCTX_UNL();
+	CHECK_OBJ(ovrinib[0].ovrhdr != NULL);
+	if (tskid == TSK_SELF && !sense_context()) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->staovr) {
+		pk_rovr->ovrstat = TOVR_STA;
+		if (p_tcb == p_runtsk) {
+			pk_rovr->leftotm = target_ovrtimer_get_current();
+		}
+		else {
+			pk_rovr->leftotm = p_tcb->leftotm;
+		}
+	}
+	else {
+		pk_rovr->ovrstat = TOVR_STP;
+	}
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_OVR_LEAVE(ercd, pk_rovr);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_ovr */
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©èµ·åã«ã¼ãã³
+ *
+ *  ãªã¼ãã©ã³ãã³ãã©ã®å¼åºãå¾ã«ï¼å¼åºãåã®ç¶æ
+ï¼CPUã­ãã¯ãã©ã°ï¼å²
+ *  è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼ã«æ»ããªãã®ã¯ï¼ãã®ã«ã¼ãã³ããã®ãªã¿ã¼ã³å¾ã«ï¼
+ *  å²è¾¼ã¿åºå£å¦çã§å
+ã®ç¶æ
+ã«æ»ãããã§ããï¼
+ */
+#ifdef TOPPERS_ovrcal
+
+void
+call_ovrhdr(void)
+{
+	assert(sense_context());
+	assert(!sense_lock());
+	assert(ovrinib[0].ovrhdr != NULL);
+
+	lock_cpu();
+	if (p_runtsk != NULL && p_runtsk->staovr && p_runtsk->leftotm == 0U) {
+		p_runtsk->staovr = false;
+		unlock_cpu();
+
+		LOG_OVR_ENTER(p_runtsk);
+		((OVRHDR)(ovrinib[0].ovrhdr))(TSKID(p_runtsk),
+											p_runtsk->p_tinib->exinf);
+		LOG_OVR_LEAVE(p_runtsk);
+	}
+	else {
+		/*
+		 *  ãã®ã«ã¼ãã³ãå¼ã³åºãããåã«ï¼ãªã¼ãã©ã³ãã³ãã©ã®èµ·åã
+		 *  ã­ã£ã³ã»ã«ãããå ´å
+		 */
+		unlock_cpu();
+	}
+}
+
+#endif /* TOPPERS_ovrcal */
+#endif /* TOPPERS_SUPPORT_OVRHDR */
Index: asp3_gr_sakura/trunk/kernel/overrun.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/overrun.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/overrun.h	(revision 317)
@@ -0,0 +1,105 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãªã¼ãã©ã³ãã³ãã©æ©è½
+ */
+
+#ifndef TOPPERS_OVERRUN_H
+#define TOPPERS_OVERRUN_H
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+#include "target_timer.h"
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©åæåãã­ãã¯
+ */
+typedef struct overrun_handler_initialization_block {
+	ATR			ovratr;			/* ãªã¼ãã©ã³ãã³ãã©å±æ§ */
+	OVRHDR		ovrhdr;			/* ãªã¼ãã©ã³ãã³ãã©ã®èµ·åçªå° */
+} OVRINIB;
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const OVRINIB	ovrinib[];
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ããåä½ä¸­ããç¤ºããã©ã°
+ */
+extern bool_t	ovrtimer_flag;
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©æ©è½ã®åæå
+ */
+extern void	initialize_overrun(void);
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ç¨ã¿ã¤ãã®åä½éå§
+ */
+extern void	ovrtimer_start(void);
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ç¨ã¿ã¤ãã®åæ­¢
+ */
+extern void	ovrtimer_stop(uint_t int_num);
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©èµ·åã«ã¼ãã³
+ */
+extern void	call_ovrhdr(void);
+
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+#endif /* TOPPERS_OVERRUN_H */
Index: asp3_gr_sakura/trunk/kernel/overrun.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/overrun.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/overrun.trb	(revision 317)
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+# 
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+#  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: overrun.trb 581 2016-02-04 06:23:23Z ertl-hiro $
+#  
+
+#
+#		ãªã¼ãã©ã³ãã³ãã©æ©è½ã®çæã¹ã¯ãªãã
+#
+
+#
+#  ãªã¼ãã©ã³ãã³ãã©ããµãã¼ãããã¦ããªãå ´åã®ã¨ã©ã¼ãã§ãã¯
+#
+if !$TOPPERS_SUPPORT_OVRHDR
+  if $cfgData.has_key?(:DEF_OVR)
+    error("E_NOSPT: DEF_OVR is not supported on this target")
+  end
+end
+
+#
+#  ãªã¼ãã©ã³ãã³ãã©æ©è½ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Overrun Handler Functions")
+
+if $cfgData[:DEF_OVR].size() > 0
+  # éçAPIãDEF_OVRããè¤æ°ããï¼E_OBJï¼ï¼»NGKI2619ï¼½
+  if $cfgData[:DEF_OVR].size() > 1
+    error("E_OBJ: too many DEF_OVR")
+  end
+
+  params = $cfgData[:DEF_OVR][1]
+
+  # ovratrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI2612ï¼½
+  #ï¼TA_NULLã§ãªãå ´åï¼
+  if params[:ovratr] != $TA_NULL
+    error_illegal("E_RSATR", params, :ovratr)
+  end
+
+  #	ãªã¼ãã©ã³ãã³ãã©åæåãã­ãã¯ã®çæ
+  $kernelCfgC.add("const OVRINIB _kernel_ovrinib[1] = {")
+  $kernelCfgC.add("\t{ (#{params[:ovratr]}), (OVRHDR)(#{params[:ovrhdr]}) }")
+  $kernelCfgC.add2("};")
+
+  # ãªã¼ãã©ã³ãã³ãã©æ©è½åæåé¢æ°ã®è¿½å 
+  $initializeFunctions.push("_kernel_initialize_overrun();")
+else
+  $kernelCfgC.add2("TOPPERS_EMPTY_LABEL(const OVRINIB, _kernel_ovrinib);")
+end
Index: asp3_gr_sakura/trunk/kernel/pridataq.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/pridataq.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/pridataq.c	(revision 317)
@@ -0,0 +1,838 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "pridataq.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_PDQ_ENTER
+#define LOG_ACRE_PDQ_ENTER(pk_cpdq)
+#endif /* LOG_ACRE_PDQ_ENTER */
+
+#ifndef LOG_ACRE_PDQ_LEAVE
+#define LOG_ACRE_PDQ_LEAVE(ercd)
+#endif /* LOG_ACRE_PDQ_LEAVE */
+
+#ifndef LOG_DEL_PDQ_ENTER
+#define LOG_DEL_PDQ_ENTER(pdqid)
+#endif /* LOG_DEL_PDQ_ENTER */
+
+#ifndef LOG_DEL_PDQ_LEAVE
+#define LOG_DEL_PDQ_LEAVE(ercd)
+#endif /* LOG_DEL_PDQ_LEAVE */
+
+#ifndef LOG_SND_PDQ_ENTER
+#define LOG_SND_PDQ_ENTER(pdqid, data, datapri)
+#endif /* LOG_SND_PDQ_ENTER */
+
+#ifndef LOG_SND_PDQ_LEAVE
+#define LOG_SND_PDQ_LEAVE(ercd)
+#endif /* LOG_SND_PDQ_LEAVE */
+
+#ifndef LOG_PSND_PDQ_ENTER
+#define LOG_PSND_PDQ_ENTER(pdqid, data, datapri)
+#endif /* LOG_PSND_PDQ_ENTER */
+
+#ifndef LOG_PSND_PDQ_LEAVE
+#define LOG_PSND_PDQ_LEAVE(ercd)
+#endif /* LOG_PSND_PDQ_LEAVE */
+
+#ifndef LOG_TSND_PDQ_ENTER
+#define LOG_TSND_PDQ_ENTER(pdqid, data, datapri, tmout)
+#endif /* LOG_TSND_PDQ_ENTER */
+
+#ifndef LOG_TSND_PDQ_LEAVE
+#define LOG_TSND_PDQ_LEAVE(ercd)
+#endif /* LOG_TSND_PDQ_LEAVE */
+
+#ifndef LOG_RCV_PDQ_ENTER
+#define LOG_RCV_PDQ_ENTER(pdqid, p_data, p_datapri)
+#endif /* LOG_RCV_PDQ_ENTER */
+
+#ifndef LOG_RCV_PDQ_LEAVE
+#define LOG_RCV_PDQ_LEAVE(ercd, p_data, p_datapri)
+#endif /* LOG_RCV_PDQ_LEAVE */
+
+#ifndef LOG_PRCV_PDQ_ENTER
+#define LOG_PRCV_PDQ_ENTER(pdqid, p_data, p_datapri)
+#endif /* LOG_PRCV_PDQ_ENTER */
+
+#ifndef LOG_PRCV_PDQ_LEAVE
+#define LOG_PRCV_PDQ_LEAVE(ercd, p_data, p_datapri)
+#endif /* LOG_PRCV_PDQ_LEAVE */
+
+#ifndef LOG_TRCV_PDQ_ENTER
+#define LOG_TRCV_PDQ_ENTER(pdqid, p_data, p_datapri, tmout)
+#endif /* LOG_TRCV_PDQ_ENTER */
+
+#ifndef LOG_TRCV_PDQ_LEAVE
+#define LOG_TRCV_PDQ_LEAVE(ercd, p_data, p_datapri)
+#endif /* LOG_TRCV_PDQ_LEAVE */
+
+#ifndef LOG_INI_PDQ_ENTER
+#define LOG_INI_PDQ_ENTER(pdqid)
+#endif /* LOG_INI_PDQ_ENTER */
+
+#ifndef LOG_INI_PDQ_LEAVE
+#define LOG_INI_PDQ_LEAVE(ercd)
+#endif /* LOG_INI_PDQ_LEAVE */
+
+#ifndef LOG_REF_PDQ_ENTER
+#define LOG_REF_PDQ_ENTER(pdqid, pk_rpdq)
+#endif /* LOG_REF_PDQ_ENTER */
+
+#ifndef LOG_REF_PDQ_LEAVE
+#define LOG_REF_PDQ_LEAVE(ercd, pk_rpdq)
+#endif /* LOG_REF_PDQ_LEAVE */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®æ°
+ */
+#define tnum_pdq	((uint_t)(tmax_pdqid - TMIN_PDQID + 1))
+#define tnum_spdq	((uint_t)(tmax_spdqid - TMIN_PDQID + 1))
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼IDããåªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ãåãåºãã
+ *  ãã®ãã¯ã­
+ */
+#define INDEX_PDQ(pdqid)	((uint_t)((pdqid) - TMIN_PDQID))
+#define get_pdqcb(pdqid)	(&(pdqcb_table[INDEX_PDQ(pdqid)]))
+
+#ifdef TOPPERS_pdqini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãåªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_pdqcb;
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æ©è½ã®åæå
+ */
+void
+initialize_pridataq(void)
+{
+	uint_t	i, j;
+	PDQCB	*p_pdqcb;
+	PDQINIB	*p_pdqinib;
+
+	for (i = 0; i < tnum_spdq; i++) {
+		p_pdqcb = &(pdqcb_table[i]);
+		queue_initialize(&(p_pdqcb->swait_queue));
+		p_pdqcb->p_pdqinib = &(pdqinib_table[i]);
+		queue_initialize(&(p_pdqcb->rwait_queue));
+		p_pdqcb->count = 0U;
+		p_pdqcb->p_head = NULL;
+		p_pdqcb->unused = 0U;
+		p_pdqcb->p_freelist = NULL;
+	}
+	queue_initialize(&free_pdqcb);
+	for (j = 0; i < tnum_pdq; i++, j++) {
+		p_pdqcb = &(pdqcb_table[i]);
+		p_pdqinib = &(apdqinib_table[j]);
+		p_pdqinib->pdqatr = TA_NOEXS;
+		p_pdqcb->p_pdqinib = ((const PDQINIB *) p_pdqinib);
+		queue_insert_prev(&free_pdqcb, &(p_pdqcb->swait_queue));
+	}
+}
+
+#endif /* TOPPERS_pdqini */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®æ ¼ç´
+ */
+#ifdef TOPPERS_pdqenq
+
+void
+enqueue_pridata(PDQCB *p_pdqcb, intptr_t data, PRI datapri)
+{
+	PDQMB	*p_pdqmb;
+	PDQMB	**pp_prev_next, *p_next;
+
+	if (p_pdqcb->p_freelist != NULL) {
+		p_pdqmb = p_pdqcb->p_freelist;
+		p_pdqcb->p_freelist = p_pdqmb->p_next;
+	}
+	else {
+		p_pdqmb = p_pdqcb->p_pdqinib->p_pdqmb + p_pdqcb->unused;
+		p_pdqcb->unused++;
+	}
+
+	p_pdqmb->data = data;
+	p_pdqmb->datapri = datapri;
+
+	pp_prev_next = &(p_pdqcb->p_head);
+	while ((p_next = *pp_prev_next) != NULL) {
+		if (p_next->datapri > datapri) {
+			break;
+		}
+		pp_prev_next = &(p_next->p_next);
+	}
+	p_pdqmb->p_next = p_next;
+	*pp_prev_next = p_pdqmb;
+	p_pdqcb->count++;
+}
+
+#endif /* TOPPERS_pdqenq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åããã®ãã¼ã¿ã®ååºã
+ */
+#ifdef TOPPERS_pdqdeq
+
+void
+dequeue_pridata(PDQCB *p_pdqcb, intptr_t *p_data, PRI *p_datapri)
+{
+	PDQMB	*p_pdqmb;
+
+	p_pdqmb = p_pdqcb->p_head;
+	p_pdqcb->p_head = p_pdqmb->p_next;
+	p_pdqcb->count--;
+
+	*p_data = p_pdqmb->data;
+	*p_datapri = p_pdqmb->datapri;
+
+	p_pdqmb->p_next = p_pdqcb->p_freelist;
+	p_pdqcb->p_freelist = p_pdqmb;
+}
+
+#endif /* TOPPERS_pdqdeq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿éä¿¡
+ */
+#ifdef TOPPERS_pdqsnd
+
+bool_t
+send_pridata(PDQCB *p_pdqcb, intptr_t data, PRI datapri)
+{
+	TCB		*p_tcb;
+
+	if (!queue_empty(&(p_pdqcb->rwait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->rwait_queue));
+		((WINFO_RPDQ *)(p_tcb->p_winfo))->data = data;
+		((WINFO_RPDQ *)(p_tcb->p_winfo))->datapri = datapri;
+		wait_complete(p_tcb);
+		return(true);
+	}
+	else if (p_pdqcb->count < p_pdqcb->p_pdqinib->pdqcnt) {
+		enqueue_pridata(p_pdqcb, data, datapri);
+		return(true);
+	}
+	else {
+		return(false);
+	}
+}
+
+#endif /* TOPPERS_pdqsnd */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®ãã¼ã¿åä¿¡
+ */
+#ifdef TOPPERS_pdqrcv
+
+bool_t
+receive_pridata(PDQCB *p_pdqcb, intptr_t *p_data, PRI *p_datapri)
+{
+	TCB		*p_tcb;
+	intptr_t data;
+	PRI		datapri;
+
+	if (p_pdqcb->count > 0U) {
+		dequeue_pridata(p_pdqcb, p_data, p_datapri);
+		if (!queue_empty(&(p_pdqcb->swait_queue))) {
+			p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->swait_queue));
+			data = ((WINFO_SPDQ *)(p_tcb->p_winfo))->data;
+			datapri = ((WINFO_SPDQ *)(p_tcb->p_winfo))->datapri;
+			enqueue_pridata(p_pdqcb, data, datapri);
+			wait_complete(p_tcb);
+		}
+		return(true);
+	}
+	else if (!queue_empty(&(p_pdqcb->swait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_pdqcb->swait_queue));
+		*p_data = ((WINFO_SPDQ *)(p_tcb->p_winfo))->data;
+		*p_datapri = ((WINFO_SPDQ *)(p_tcb->p_winfo))->datapri;
+		wait_complete(p_tcb);
+		return(true);
+	}
+	else {
+		return(false);
+	}
+}
+
+#endif /* TOPPERS_pdqrcv */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®çæ
+ */
+#ifdef TOPPERS_acre_pdq
+
+ER_UINT
+acre_pdq(const T_CPDQ *pk_cpdq)
+{
+	PDQCB	*p_pdqcb;
+	PDQINIB	*p_pdqinib;
+	ATR		pdqatr;
+	uint_t	pdqcnt;
+	PRI		maxdpri;
+	PDQMB	*p_pdqmb;
+	ER		ercd;
+
+	LOG_ACRE_PDQ_ENTER(pk_cpdq);
+	CHECK_TSKCTX_UNL();
+
+	pdqatr = pk_cpdq->pdqatr;
+	pdqcnt = pk_cpdq->pdqcnt;
+	maxdpri = pk_cpdq->maxdpri;
+	p_pdqmb = pk_cpdq->pdqmb;
+
+	CHECK_RSATR(pdqatr, TA_TPRI);
+	CHECK_PAR(VALID_DPRI(maxdpri));
+
+	lock_cpu();
+	if (tnum_pdq == 0 || queue_empty(&free_pdqcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		if (pdqcnt != 0 && p_pdqmb == NULL) {
+			p_pdqmb = kernel_malloc(sizeof(PDQMB) * pdqcnt);
+			pdqatr |= TA_MBALLOC;
+		}
+		if (pdqcnt != 0 && p_pdqmb == NULL) {
+			ercd = E_NOMEM;
+		}
+		else {
+			p_pdqcb = ((PDQCB *) queue_delete_next(&free_pdqcb));
+			p_pdqinib = (PDQINIB *)(p_pdqcb->p_pdqinib);
+			p_pdqinib->pdqatr = pdqatr;
+			p_pdqinib->pdqcnt = pdqcnt;
+			p_pdqinib->maxdpri = maxdpri;
+			p_pdqinib->p_pdqmb = p_pdqmb;
+
+			queue_initialize(&(p_pdqcb->swait_queue));
+			queue_initialize(&(p_pdqcb->rwait_queue));
+			p_pdqcb->count = 0U;
+			p_pdqcb->p_head = NULL;
+			p_pdqcb->unused = 0U;
+			p_pdqcb->p_freelist = NULL;
+			ercd = PDQID(p_pdqcb);
+		}
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®åé¤
+ */
+#ifdef TOPPERS_del_pdq
+
+ER
+del_pdq(ID pdqid)
+{
+	PDQCB	*p_pdqcb;
+	PDQINIB	*p_pdqinib;
+	ER		ercd;
+
+	LOG_DEL_PDQ_ENTER(pdqid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (pdqid <= tmax_spdqid) {
+		ercd = E_OBJ;
+	}
+	else {
+		init_wait_queue(&(p_pdqcb->swait_queue));
+		init_wait_queue(&(p_pdqcb->rwait_queue));
+		p_pdqinib = (PDQINIB *)(p_pdqcb->p_pdqinib);
+		if ((p_pdqinib->pdqatr & TA_MBALLOC) != 0U) {
+			kernel_free(p_pdqinib->p_pdqmb);
+		}
+		p_pdqinib->pdqatr = TA_NOEXS;
+		queue_insert_prev(&free_pdqcb, &(p_pdqcb->swait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+ */
+#ifdef TOPPERS_snd_pdq
+
+ER
+snd_pdq(ID pdqid, intptr_t data, PRI datapri)
+{
+	PDQCB	*p_pdqcb;
+	WINFO_SPDQ winfo_spdq;
+	ER		ercd;
+
+	LOG_SND_PDQ_ENTER(pdqid, data, datapri);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+	CHECK_PAR(TMIN_DPRI <= datapri);
+
+	lock_cpu_dsp();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (datapri > p_pdqcb->p_pdqinib->maxdpri) {
+		ercd = E_PAR;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (send_pridata(p_pdqcb, data, datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		winfo_spdq.data = data;
+		winfo_spdq.datapri = datapri;
+		p_runtsk->tstat = TS_WAITING_SPDQ;
+		wobj_make_wait((WOBJCB *) p_pdqcb, (WINFO_WOBJ *) &winfo_spdq);
+		dispatch();
+		ercd = winfo_spdq.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_SND_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_snd_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_psnd_pdq
+
+ER
+psnd_pdq(ID pdqid, intptr_t data, PRI datapri)
+{
+	PDQCB	*p_pdqcb;
+	ER		ercd;
+
+	LOG_PSND_PDQ_ENTER(pdqid, data, datapri);
+	CHECK_UNL();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+	CHECK_PAR(TMIN_DPRI <= datapri);
+
+	lock_cpu();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (datapri > p_pdqcb->p_pdqinib->maxdpri) {
+		ercd = E_PAR;
+	}
+	else if (send_pridata(p_pdqcb, data, datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PSND_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_psnd_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_tsnd_pdq
+
+ER
+tsnd_pdq(ID pdqid, intptr_t data, PRI datapri, TMO tmout)
+{
+	PDQCB	*p_pdqcb;
+	WINFO_SPDQ winfo_spdq;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TSND_PDQ_ENTER(pdqid, data, datapri, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_PDQID(pdqid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_pdqcb = get_pdqcb(pdqid);
+	CHECK_PAR(TMIN_DPRI <= datapri);
+
+	lock_cpu_dsp();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (datapri > p_pdqcb->p_pdqinib->maxdpri) {
+		ercd = E_PAR;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (send_pridata(p_pdqcb, data, datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		winfo_spdq.data = data;
+		winfo_spdq.datapri = datapri;
+		p_runtsk->tstat = TS_WAITING_SPDQ;
+		wobj_make_wait_tmout((WOBJCB *) p_pdqcb, (WINFO_WOBJ *) &winfo_spdq,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_spdq.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TSND_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_tsnd_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡
+ */
+#ifdef TOPPERS_rcv_pdq
+
+ER
+rcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri)
+{
+	PDQCB	*p_pdqcb;
+	WINFO_RPDQ winfo_rpdq;
+	ER		ercd;
+
+	LOG_RCV_PDQ_ENTER(pdqid, p_data, p_datapri);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu_dsp();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (receive_pridata(p_pdqcb, p_data, p_datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_RPDQ;
+		make_wait(&(winfo_rpdq.winfo));
+		queue_insert_prev(&(p_pdqcb->rwait_queue), &(p_runtsk->task_queue));
+		winfo_rpdq.p_pdqcb = p_pdqcb;
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo_rpdq.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_data = winfo_rpdq.data;
+			*p_datapri = winfo_rpdq.datapri;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_RCV_PDQ_LEAVE(ercd, p_data, p_datapri);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rcv_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_prcv_pdq
+
+ER
+prcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri)
+{
+	PDQCB	*p_pdqcb;
+	ER		ercd;
+
+	LOG_PRCV_PDQ_ENTER(pdqid, p_data, p_datapri);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (receive_pridata(p_pdqcb, p_data, p_datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_PRCV_PDQ_LEAVE(ercd, p_data, p_datapri);
+	return(ercd);
+}
+
+#endif /* TOPPERS_prcv_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_trcv_pdq
+
+ER
+trcv_pdq(ID pdqid, intptr_t *p_data, PRI *p_datapri, TMO tmout)
+{
+	PDQCB	*p_pdqcb;
+	WINFO_RPDQ winfo_rpdq;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TRCV_PDQ_ENTER(pdqid, p_data, p_datapri, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_PDQID(pdqid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu_dsp();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (receive_pridata(p_pdqcb, p_data, p_datapri)) {
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_RPDQ;
+		make_wait_tmout(&(winfo_rpdq.winfo), &tmevtb, tmout);
+		queue_insert_prev(&(p_pdqcb->rwait_queue), &(p_runtsk->task_queue));
+		winfo_rpdq.p_pdqcb = p_pdqcb;
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo_rpdq.winfo.wercd;
+		if (ercd == E_OK) {
+			*p_data = winfo_rpdq.data;
+			*p_datapri = winfo_rpdq.datapri;
+		}
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TRCV_PDQ_LEAVE(ercd, p_data, p_datapri);
+	return(ercd);
+}
+
+#endif /* TOPPERS_trcv_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ååæå
+ */
+#ifdef TOPPERS_ini_pdq
+
+ER
+ini_pdq(ID pdqid)
+{
+	PDQCB	*p_pdqcb;
+	ER		ercd;
+    
+	LOG_INI_PDQ_ENTER(pdqid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_pdqcb->swait_queue));
+		init_wait_queue(&(p_pdqcb->rwait_queue));
+		p_pdqcb->count = 0U;
+		p_pdqcb->p_head = NULL;
+		p_pdqcb->unused = 0U;
+		p_pdqcb->p_freelist = NULL;
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_PDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_pdq */
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_pdq
+
+ER
+ref_pdq(ID pdqid, T_RPDQ *pk_rpdq)
+{
+	PDQCB	*p_pdqcb;
+	ER		ercd;
+    
+	LOG_REF_PDQ_ENTER(pdqid, pk_rpdq);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_PDQID(pdqid));
+	p_pdqcb = get_pdqcb(pdqid);
+
+	lock_cpu();
+	if (p_pdqcb->p_pdqinib->pdqatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rpdq->stskid = wait_tskid(&(p_pdqcb->swait_queue));
+		pk_rpdq->rtskid = wait_tskid(&(p_pdqcb->rwait_queue));
+		pk_rpdq->spdqcnt = p_pdqcb->count;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_PDQ_LEAVE(ercd, pk_rpdq);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_pdq */
Index: asp3_gr_sakura/trunk/kernel/pridataq.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/pridataq.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/pridataq.h	(revision 317)
@@ -0,0 +1,234 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æ©è½
+ */
+
+#ifndef TOPPERS_PRIDATAQ_H
+#define TOPPERS_PRIDATAQ_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ç®¡çãã­ãã¯
+ */
+typedef struct pridata_management_block PDQMB;
+
+struct pridata_management_block {
+	PDQMB		*p_next;		/* æ¬¡ã®ãã¼ã¿ */
+	intptr_t	data;			/* ãã¼ã¿æ¬ä½ */
+	PRI			datapri;		/* ãã¼ã¿åªå
+åº¦ */
+};
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct pridataq_initialization_block {
+	ATR			pdqatr;			/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼å±æ§ */
+	uint_t		pdqcnt;			/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®å®¹é */
+	PRI			maxdpri;		/* ãã¼ã¿åªå
+åº¦ã®æå¤§å¤ */
+	PDQMB		*p_pdqmb;		/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã®å
+é ­çªå° */
+} PDQINIB;
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct pridataq_control_block {
+	QUEUE		swait_queue;	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼éä¿¡å¾
+ã¡ã­ã¥ã¼ */
+	const PDQINIB *p_pdqinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	QUEUE		rwait_queue;	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼åä¿¡å¾
+ã¡ã­ã¥ã¼ */
+	uint_t		count;			/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ä¸­ã®ãã¼ã¿ã®æ° */
+	PDQMB		*p_head;		/* æåã®ãã¼ã¿ */
+	uint_t		unused;			/* æªä½¿ç¨ãã¼ã¿ç®¡çãã­ãã¯ã®å
+é ­ */
+	PDQMB		*p_freelist;	/* æªå²å½ã¦ãã¼ã¿ç®¡çãã­ãã¯ã®ãªã¹ã */
+} PDQCB;
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®2ã¤ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct pridataq_send_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	PDQCB		*p_pdqcb;		/* å¾
+ã£ã¦ããåªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ç®¡çãã­ãã¯*/
+	intptr_t	data;			/* éä¿¡ãã¼ã¿ */
+	PRI			datapri;		/* ãã¼ã¿åªå
+åº¦ */
+} WINFO_SPDQ;
+
+typedef struct pridataq_receive_waiting_information {
+	WINFO		winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	PDQCB		*p_pdqcb;		/* å¾
+ã£ã¦ããåªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ç®¡çãã­ãã¯*/
+	intptr_t	data;			/* åä¿¡ãã¼ã¿ */
+	PRI			datapri;		/* ãã¼ã¿åªå
+åº¦ */
+} WINFO_RPDQ;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãåªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_pdqcb;
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_pdqid;
+extern const ID	tmax_spdqid;
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const PDQINIB	pdqinib_table[];
+extern PDQINIB			apdqinib_table[];
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern PDQCB	pdqcb_table[];
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çãã­ãã¯ããåªå
+åº¦ãã¼ã¿ã­ã¥ã¼IDãåãåºãã
+ *  ãã®ãã¯ã­
+ */
+#define	PDQID(p_pdqcb)	((ID)(((p_pdqcb) - pdqcb_table) + TMIN_PDQID))
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æ©è½ã®åæå
+ */
+extern void	initialize_pridataq(void);
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åã¸ã®ãã¼ã¿ã®æ ¼ç´
+ */
+extern void	enqueue_pridata(PDQCB *p_pdqcb, intptr_t data, PRI datapri);
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé åããã®ãã¼ã¿ã®ååºã
+ */
+extern void	dequeue_pridata(PDQCB *p_pdqcb, intptr_t *p_data, PRI *p_datapri);
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®ãã¼ã¿éä¿¡
+ */
+extern bool_t	send_pridata(PDQCB *p_pdqcb, intptr_t data, PRI datapri);
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®ãã¼ã¿åä¿¡
+ */
+extern bool_t	receive_pridata(PDQCB *p_pdqcb, intptr_t *p_data,
+														PRI *p_datapri);
+
+#endif /* TOPPERS_PRIDATAQ_H */
Index: asp3_gr_sakura/trunk/kernel/pridataq.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/pridataq.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/pridataq.trb	(revision 317)
@@ -0,0 +1,112 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: pridataq.trb 668 2016-03-03 13:57:53Z ertl-hiro $
+# 
+
+#
+#		åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class PridataqObject < KernelObject
+  def initialize()
+    super("pdq", "pridataq")
+  end
+
+  def prepare(key, params)
+    # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+    params[:pdqmb] ||= "NULL"
+
+    # pdqatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI1804ï¼½
+    #ï¼TA_TPRIä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:pdqatr] & ~($TA_TPRI)) != 0
+      error_illegal_id("E_RSATR", params, :pdqatr, :pdqid)
+    end
+
+    # (TMIN_DPRI <= maxdpri && maxdpri <= TMAX_DPRI)ã§ãªãå ´åï¼E_PARï¼
+    # ï¼»NGKI1819ï¼½
+    if !($TMIN_DPRI <= params[:maxdpri] && params[:maxdpri] <= $TMAX_DPRI)
+      error_illegal_id("E_PAR", params, :maxdpri, :pdqid)
+    end
+
+    # pdqmbãNULLã§ãªãå ´åï¼E_NOSPTï¼ï¼»ASPS0142ï¼½
+    if params[:pdqmb] != "NULL"
+      error_illegal_id("E_NOSPT", params, :pdqmb, :pdqid)
+    end
+
+    # åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ç®¡çé å
+    if params[:pdqcnt] > 0
+      pdqmbName = "_kernel_pdqmb_#{params[:pdqid]}"
+      $kernelCfgC.add("static PDQMB #{pdqmbName}[#{params[:pdqcnt]}];")
+      params[:pdqinib_pdqmb] = pdqmbName
+    else
+      params[:pdqinib_pdqmb] = "NULL"
+    end
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:pdqatr]}), (#{params[:pdqcnt]}), " \
+				"(#{params[:maxdpri]}), #{params[:pdqinib_pdqmb]}")
+  end
+end
+
+#
+#  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Priority Dataqueue Functions")
+PridataqObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/semaphore.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/semaphore.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/semaphore.c	(revision 317)
@@ -0,0 +1,523 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã»ããã©æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "semaphore.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_SEM_ENTER
+#define LOG_ACRE_SEM_ENTER(pk_csem)
+#endif /* LOG_ACRE_SEM_ENTER */
+
+#ifndef LOG_ACRE_SEM_LEAVE
+#define LOG_ACRE_SEM_LEAVE(ercd)
+#endif /* LOG_ACRE_SEM_LEAVE */
+
+#ifndef LOG_DEL_SEM_ENTER
+#define LOG_DEL_SEM_ENTER(semid)
+#endif /* LOG_DEL_SEM_ENTER */
+
+#ifndef LOG_DEL_SEM_LEAVE
+#define LOG_DEL_SEM_LEAVE(ercd)
+#endif /* LOG_DEL_SEM_LEAVE */
+
+#ifndef LOG_SIG_SEM_ENTER
+#define LOG_SIG_SEM_ENTER(semid)
+#endif /* LOG_SIG_SEM_ENTER */
+
+#ifndef LOG_SIG_SEM_LEAVE
+#define LOG_SIG_SEM_LEAVE(ercd)
+#endif /* LOG_SIG_SEM_LEAVE */
+
+#ifndef LOG_WAI_SEM_ENTER
+#define LOG_WAI_SEM_ENTER(semid)
+#endif /* LOG_WAI_SEM_ENTER */
+
+#ifndef LOG_WAI_SEM_LEAVE
+#define LOG_WAI_SEM_LEAVE(ercd)
+#endif /* LOG_WAI_SEM_LEAVE */
+
+#ifndef LOG_POL_SEM_ENTER
+#define LOG_POL_SEM_ENTER(semid)
+#endif /* LOG_POL_SEM_ENTER */
+
+#ifndef LOG_POL_SEM_LEAVE
+#define LOG_POL_SEM_LEAVE(ercd)
+#endif /* LOG_POL_SEM_LEAVE */
+
+#ifndef LOG_TWAI_SEM_ENTER
+#define LOG_TWAI_SEM_ENTER(semid, tmout)
+#endif /* LOG_TWAI_SEM_ENTER */
+
+#ifndef LOG_TWAI_SEM_LEAVE
+#define LOG_TWAI_SEM_LEAVE(ercd)
+#endif /* LOG_TWAI_SEM_LEAVE */
+
+#ifndef LOG_INI_SEM_ENTER
+#define LOG_INI_SEM_ENTER(semid)
+#endif /* LOG_INI_SEM_ENTER */
+
+#ifndef LOG_INI_SEM_LEAVE
+#define LOG_INI_SEM_LEAVE(ercd)
+#endif /* LOG_INI_SEM_LEAVE */
+
+#ifndef LOG_REF_SEM_ENTER
+#define LOG_REF_SEM_ENTER(semid, pk_rsem)
+#endif /* LOG_REF_SEM_ENTER */
+
+#ifndef LOG_REF_SEM_LEAVE
+#define LOG_REF_SEM_LEAVE(ercd, pk_rsem)
+#endif /* LOG_REF_SEM_LEAVE */
+
+/*
+ *  ã»ããã©ã®æ°
+ */
+#define tnum_sem	((uint_t)(tmax_semid - TMIN_SEMID + 1))
+#define tnum_ssem	((uint_t)(tmax_ssemid - TMIN_SEMID + 1))
+
+/*
+ *  ã»ããã©IDããã»ããã©ç®¡çãã­ãã¯ãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_SEM(semid)	((uint_t)((semid) - TMIN_SEMID))
+#define get_semcb(semid)	(&(semcb_table[INDEX_SEM(semid)]))
+
+#ifdef TOPPERS_semini
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã»ããã©ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+QUEUE	free_semcb;
+
+/* 
+ *  ã»ããã©æ©è½ã®åæå
+ */
+void
+initialize_semaphore(void)
+{
+	uint_t	i, j;
+	SEMCB	*p_semcb;
+	SEMINIB	*p_seminib;
+
+	for (i = 0; i < tnum_ssem; i++) {
+		p_semcb = &(semcb_table[i]);
+		queue_initialize(&(p_semcb->wait_queue));
+		p_semcb->p_seminib = &(seminib_table[i]);
+		p_semcb->semcnt = p_semcb->p_seminib->isemcnt;
+	}
+	queue_initialize(&free_semcb);
+	for (j = 0; i < tnum_sem; i++, j++) {
+		p_semcb = &(semcb_table[i]);
+		p_seminib = &(aseminib_table[j]);
+		p_seminib->sematr = TA_NOEXS;
+		p_semcb->p_seminib = ((const SEMINIB *) p_seminib);
+		queue_insert_prev(&free_semcb, &(p_semcb->wait_queue));
+	}
+}
+
+#endif /* TOPPERS_semini */
+
+/*
+ *  ã»ããã©ã®çæ
+ */
+#ifdef TOPPERS_acre_sem
+
+ER_UINT
+acre_sem(const T_CSEM *pk_csem)
+{
+	SEMCB	*p_semcb;
+	SEMINIB	*p_seminib;
+	ATR		sematr;
+	uint_t	isemcnt, maxsem;
+	ER		ercd;
+
+	LOG_ACRE_SEM_ENTER(pk_csem);
+	CHECK_TSKCTX_UNL();
+
+	sematr = pk_csem->sematr;
+	isemcnt = pk_csem->isemcnt;
+	maxsem = pk_csem->maxsem;
+
+	CHECK_RSATR(sematr, TA_TPRI);
+	CHECK_PAR(0 <= isemcnt && isemcnt <= maxsem);
+	CHECK_PAR(1 <= maxsem && maxsem <= TMAX_MAXSEM);
+
+	lock_cpu();
+	if (tnum_sem == 0 || queue_empty(&free_semcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		p_semcb = ((SEMCB *) queue_delete_next(&free_semcb));
+		p_seminib = (SEMINIB *)(p_semcb->p_seminib);
+		p_seminib->sematr = sematr;
+		p_seminib->isemcnt = isemcnt;
+		p_seminib->maxsem = maxsem;
+
+		queue_initialize(&(p_semcb->wait_queue));
+		p_semcb->semcnt = p_semcb->p_seminib->isemcnt;
+		ercd = SEMID(p_semcb);
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_sem */
+
+/*
+ *  ã»ããã©ã®åé¤
+ */
+#ifdef TOPPERS_del_sem
+
+ER
+del_sem(ID semid)
+{
+	SEMCB	*p_semcb;
+	SEMINIB	*p_seminib;
+	ER		ercd;
+
+	LOG_DEL_SEM_ENTER(semid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (semid <= tmax_ssemid) {
+		ercd = E_OBJ;
+	}
+	else {
+		init_wait_queue(&(p_semcb->wait_queue));
+		p_seminib = (SEMINIB *)(p_semcb->p_seminib);
+		p_seminib->sematr = TA_NOEXS;
+		queue_insert_prev(&free_semcb, &(p_semcb->wait_queue));
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_sem */
+
+/*
+ *  ã»ããã©è³æºã®è¿å´
+ */
+#ifdef TOPPERS_sig_sem
+
+ER
+sig_sem(ID semid)
+{
+	SEMCB	*p_semcb;
+	TCB		*p_tcb;
+	ER		ercd;
+    
+	LOG_SIG_SEM_ENTER(semid);
+	CHECK_UNL();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (!queue_empty(&(p_semcb->wait_queue))) {
+		p_tcb = (TCB *) queue_delete_next(&(p_semcb->wait_queue));
+		wait_complete(p_tcb);
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	else if (p_semcb->semcnt < p_semcb->p_seminib->maxsem) {
+		p_semcb->semcnt += 1;
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_QOVR;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_SIG_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_sig_sem */
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾
+ */
+#ifdef TOPPERS_wai_sem
+
+ER
+wai_sem(ID semid)
+{
+	SEMCB	*p_semcb;
+	WINFO_SEM winfo_sem;
+	ER		ercd;
+
+	LOG_WAI_SEM_ENTER(semid);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu_dsp();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_semcb->semcnt >= 1) {
+		p_semcb->semcnt -= 1;
+		ercd = E_OK;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_SEM;
+		wobj_make_wait((WOBJCB *) p_semcb, (WINFO_WOBJ *) &winfo_sem);
+		dispatch();
+		ercd = winfo_sem.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_WAI_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_wai_sem */
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾ï¼ãã¼ãªã³ã°ï¼
+ */
+#ifdef TOPPERS_pol_sem
+
+ER
+pol_sem(ID semid)
+{
+	SEMCB	*p_semcb;
+	ER		ercd;
+
+	LOG_POL_SEM_ENTER(semid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_semcb->semcnt >= 1) {
+		p_semcb->semcnt -= 1;
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_TMOUT;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_POL_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_pol_sem */
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_twai_sem
+
+ER
+twai_sem(ID semid, TMO tmout)
+{
+	SEMCB	*p_semcb;
+	WINFO_SEM winfo_sem;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TWAI_SEM_ENTER(semid, tmout);
+	CHECK_DISPATCH();
+	CHECK_ID(VALID_SEMID(semid));
+	CHECK_PAR(VALID_TMOUT(tmout));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu_dsp();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_semcb->semcnt >= 1) {
+		p_semcb->semcnt -= 1;
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_SEM;
+		wobj_make_wait_tmout((WOBJCB *) p_semcb, (WINFO_WOBJ *) &winfo_sem,
+														&tmevtb, tmout);
+		dispatch();
+		ercd = winfo_sem.winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TWAI_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_twai_sem */
+
+/*
+ *  ã»ããã©ã®ååæå
+ */
+#ifdef TOPPERS_ini_sem
+
+ER
+ini_sem(ID semid)
+{
+	SEMCB	*p_semcb;
+	ER		ercd;
+    
+	LOG_INI_SEM_ENTER(semid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		init_wait_queue(&(p_semcb->wait_queue));
+		p_semcb->semcnt = p_semcb->p_seminib->isemcnt;
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_INI_SEM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ini_sem */
+
+/*
+ *  ã»ããã©ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_sem
+
+ER
+ref_sem(ID semid, T_RSEM *pk_rsem)
+{
+	SEMCB	*p_semcb;
+	ER		ercd;
+    
+	LOG_REF_SEM_ENTER(semid, pk_rsem);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_SEMID(semid));
+	p_semcb = get_semcb(semid);
+
+	lock_cpu();
+	if (p_semcb->p_seminib->sematr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		pk_rsem->wtskid = wait_tskid(&(p_semcb->wait_queue));
+		pk_rsem->semcnt = p_semcb->semcnt;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_SEM_LEAVE(ercd, pk_rsem);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_sem */
Index: asp3_gr_sakura/trunk/kernel/semaphore.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/semaphore.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/semaphore.h	(revision 317)
@@ -0,0 +1,153 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã»ããã©æ©è½
+ */
+
+#ifndef TOPPERS_SEMAPHORE_H
+#define TOPPERS_SEMAPHORE_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "wait.h"
+
+/*
+ *  ã»ããã©åæåãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WOBJINIBï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  æåã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct semaphore_initialization_block {
+	ATR			sematr;			/* ã»ããã©å±æ§ */
+	uint_t		isemcnt;		/* ã»ããã©ã®è³æºæ°ã®åæå¤ */
+	uint_t		maxsem;			/* ã»ããã©ã®æå¤§è³æºæ° */
+} SEMINIB;
+
+/*
+ *  ã»ããã©ç®¡çãã­ãã¯
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼
+ *  ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼æåã®2ã¤ã®
+ *  ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct semaphore_control_block {
+	QUEUE		wait_queue;		/* ã»ããã©å¾
+ã¡ã­ã¥ã¼ */
+	const SEMINIB *p_seminib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	uint_t		semcnt;			/* ã»ããã©ç¾å¨ã«ã¦ã³ãå¤ */
+} SEMCB;
+
+/*
+ *  ã»ããã©å¾
+ã¡æ
+å ±ãã­ãã¯ã®å®ç¾©
+ *
+ *  ãã®æ§é ä½ã¯ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *  ï¼WINFO_WOBJï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ï¼
+ *  ãã¹ã¦ã®ãã£ã¼ã«ããå
+±éã«ãªã£ã¦ããï¼
+ */
+typedef struct semaphore_waiting_information {
+	WINFO	winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	SEMCB	*p_semcb;		/* å¾
+ã£ã¦ããã»ããã©ã®ç®¡çãã­ãã¯ */
+} WINFO_SEM;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãã»ããã©ç®¡çãã­ãã¯ã®ãªã¹ã
+ */
+extern QUEUE	free_semcb;
+
+/*
+ *  ã»ããã©IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_semid;
+extern const ID	tmax_ssemid;
+
+/*
+ *  ã»ããã©åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const SEMINIB	seminib_table[];
+extern SEMINIB			aseminib_table[];
+
+/*
+ *  ã»ããã©ç®¡çãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern SEMCB	semcb_table[];
+
+/*
+ *  ã»ããã©ç®¡çãã­ãã¯ããã»ããã©IDãåãåºãããã®ãã¯ã­
+ */
+#define	SEMID(p_semcb)	((ID)(((p_semcb) - semcb_table) + TMIN_SEMID))
+
+/*
+ *  ã»ããã©æ©è½ã®åæå
+ */
+extern void	initialize_semaphore(void);
+
+#endif /* TOPPERS_SEMAPHORE_H */
Index: asp3_gr_sakura/trunk/kernel/semaphore.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/semaphore.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/semaphore.trb	(revision 317)
@@ -0,0 +1,95 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: semaphore.trb 588 2016-02-05 12:54:58Z ertl-hiro $
+# 
+
+#
+#		ã»ããã©æ©è½ã®çæã¹ã¯ãªãã
+#
+
+class SemaphoreObject < KernelObject
+  def initialize()
+    super("sem", "semaphore")
+  end
+
+  def prepare(key, params)
+    # sematrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI1456ï¼½
+    #ï¼TA_TPRIä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:sematr] & ~($TA_TPRI)) != 0
+      error_illegal_id("E_RSATR", params, :sematr, :semid)
+    end
+
+    # (1 <= maxsem && maxsem <= TMAX_MAXSEM)ã§ãªãå ´åï¼E_PARï¼ï¼»NGKI1468ï¼½
+    if !(1 <= params[:maxsem] && params[:maxsem] <= $TMAX_MAXSEM)
+      error_illegal_id("E_PAR", params, :maxsem, :semid)
+    end
+
+    # (0 <= isemcnt && isemcnt <= maxsem)ã§ãªãå ´åï¼E_PARï¼ï¼»NGKI1466ï¼½
+    if !(0 <= params[:isemcnt] && params[:isemcnt] <= params[:maxsem])
+      error_wrong_id("E_PAR", params, :isemcnt, :semid, "too large")
+    end
+  end
+
+  def generateInib(key, params)
+    return("(#{params[:sematr]}), (#{params[:isemcnt]}), (#{params[:maxsem]})")
+  end
+end
+
+#
+#  ã»ããã©ã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Semaphore Functions")
+SemaphoreObject.new.generate()
Index: asp3_gr_sakura/trunk/kernel/startup.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/startup.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/startup.c	(revision 317)
@@ -0,0 +1,244 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã«ã¼ãã«ã®åæåã¨çµäºå¦ç
+ */
+
+#include "kernel_impl.h"
+#include "time_event.h"
+#include <sil.h>
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_KER_ENTER
+#define LOG_KER_ENTER()
+#endif /* LOG_KER_ENTER */
+
+#ifndef LOG_KER_LEAVE
+#define LOG_KER_LEAVE()
+#endif /* LOG_KER_LEAVE */
+
+#ifndef LOG_EXT_KER_ENTER
+#define LOG_EXT_KER_ENTER()
+#endif /* LOG_EXT_KER_ENTER */
+
+#ifndef LOG_EXT_KER_LEAVE
+#define LOG_EXT_KER_LEAVE(ercd)
+#endif /* LOG_EXT_KER_LEAVE */
+
+#ifdef TOPPERS_sta_ker
+
+/*
+ *  ã«ã¼ãã«åä½ç¶æ
+ãã©ã°
+ *
+ *  ã¹ã¿ã¼ãã¢ããã«ã¼ãã³ã§ï¼falseï¼ï¼0ï¼ã«åæåããããã¨ãæå¾
+ãã¦
+ *  ããï¼
+ */
+bool_t	kerflg = false;
+
+/*
+ *  ã«ã¼ãã«ã®èµ·å
+ */
+void
+sta_ker(void)
+{
+	/*
+	 *  TECSã®åæå
+	 */
+#ifndef TOPPERS_OMIT_TECS
+	initialize_tecs();
+#endif /* TOPPERS_OMIT_TECS */
+
+	/*
+	 *  ã¿ã¼ã²ããä¾å­ã®åæå
+	 */
+	target_initialize();
+
+	/*
+	 *  åã¢ã¸ã¥ã¼ã«ã®åæå
+	 *
+	 *  ã¿ã¤ã ã¤ãã³ãç®¡çã¢ã¸ã¥ã¼ã«ã¯ä»ã®ã¢ã¸ã¥ã¼ã«ããå
+ã«åæå
+	 *  ããå¿
+è¦ãããï¼
+	 */
+	initialize_kmm();
+	initialize_tmevt();								/*ï¼»ASPD1061ï¼½*/
+	initialize_object();
+
+	/*
+	 *  åæåã«ã¼ãã³ã®å®è¡
+	 */ 
+	call_inirtn();
+
+	/*
+	 *  é«åè§£è½ã¿ã¤ãã®è¨­å®
+	 */
+	current_hrtcnt = target_hrt_get_current();		/*ï¼»ASPD1063ï¼½*/
+	set_hrt_event();								/*ï¼»ASPD1064ï¼½*/
+
+	/*
+	 *  ã«ã¼ãã«åä½ã®éå§
+	 */
+	kerflg = true;
+	LOG_KER_ENTER();
+	start_dispatch();
+	assert(0);
+}
+
+#endif /* TOPPERS_sta_ker */
+
+/*
+ *  ã«ã¼ãã«ã®çµäº
+ */
+#ifdef TOPPERS_ext_ker
+
+ER
+ext_ker(void)
+{
+	SIL_PRE_LOC;
+
+	LOG_EXT_KER_ENTER();
+
+	/*
+	 *  å²è¾¼ã¿ã­ãã¯ç¶æ
+ã«ç§»è¡
+	 */
+	SIL_LOC_INT();
+
+	/*
+	 *  ã«ã¼ãã«åä½ã®çµäº
+	 */
+	LOG_KER_LEAVE();
+	kerflg = false;
+
+	/*
+	 *  ã«ã¼ãã«ã®çµäºå¦çã®å¼åºã
+	 *
+	 *  éã¿ã¹ã¯ã³ã³ãã­ã¹ãã«åãæãã¦ï¼exit_kernelãå¼ã³åºãï¼
+	 */
+	call_exit_kernel();
+
+	/*
+	 *  ã³ã³ãã¤ã©ã®è­¦åå¯¾ç­ï¼ããã¸æ¥ããã¨ã¯ãªãã¯ãï¼
+	 */
+	SIL_UNL_INT();
+	LOG_EXT_KER_LEAVE(E_SYS);
+	return(E_SYS);
+}
+
+/*
+ *  ã«ã¼ãã«ã®çµäºå¦ç
+ */
+void
+exit_kernel(void)
+{
+	/*
+	 *  çµäºå¦çã«ã¼ãã³ã®å®è¡
+	 */
+	call_terrtn();
+
+	/*
+	 *  ã¿ã¼ã²ããä¾å­ã®çµäºå¦ç
+	 */
+	target_exit();
+	assert(0);
+}
+
+#endif /* TOPPERS_ext_ker */
+
+/*
+ *  ã«ã¼ãã«ã®å²ãä»ããã¡ã¢ãªé åã®ç®¡ç
+ *
+ *  ã¡ã¢ãªé åãå
+é ­ããé ã«å²ãå½ã¦ï¼è§£æ¾ãããã¡ã¢ãªé åãåå©ç¨ããª
+ *  ãã¡ã¢ãªç®¡çã¢ã¸ã¥ã¼ã«ï¼
+ */
+#ifdef TOPPERS_kermem
+#ifndef OMIT_KMM_ALLOCONLY
+
+static void	*kmm_brk;
+
+void
+initialize_kmm(void)
+{
+	kmm_brk = ((char *) kmm) + kmmsz;
+}
+
+void *
+kernel_malloc(size_t size)
+{
+	if (((char *) kmm_brk) - ((char *) kmm) >= size) {
+		kmm_brk = ((char *) kmm_brk) - size;
+		return(kmm_brk);
+	}
+	else {
+		return(NULL);
+	}
+}
+
+void
+kernel_free(void *ptr)
+{
+}
+
+#endif /* OMIT_KMM_ALLOCONLY */
+#endif /* TOPPERS_kermem */
Index: asp3_gr_sakura/trunk/kernel/sys_manage.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/sys_manage.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/sys_manage.c	(revision 317)
@@ -0,0 +1,558 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ç¶æ
+ç®¡çæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "overrun.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ROT_RDQ_ENTER
+#define LOG_ROT_RDQ_ENTER(tskpri)
+#endif /* LOG_ROT_RDQ_ENTER */
+
+#ifndef LOG_ROT_RDQ_LEAVE
+#define LOG_ROT_RDQ_LEAVE(ercd)
+#endif /* LOG_ROT_RDQ_LEAVE */
+
+#ifndef LOG_GET_TID_ENTER
+#define LOG_GET_TID_ENTER(p_tskid)
+#endif /* LOG_GET_TID_ENTER */
+
+#ifndef LOG_GET_TID_LEAVE
+#define LOG_GET_TID_LEAVE(ercd, p_tskid)
+#endif /* LOG_GET_TID_LEAVE */
+
+#ifndef LOG_GET_LOD_ENTER
+#define LOG_GET_LOD_ENTER(tskpri, p_load)
+#endif /* LOG_GET_LOD_ENTER */
+
+#ifndef LOG_GET_LOD_LEAVE
+#define LOG_GET_LOD_LEAVE(ercd, p_load)
+#endif /* LOG_GET_LOD_LEAVE */
+
+#ifndef LOG_GET_NTH_ENTER
+#define LOG_GET_NTH_ENTER(tskpri, nth, p_tskid)
+#endif /* LOG_GET_NTH_ENTER */
+
+#ifndef LOG_GET_NTH_LEAVE
+#define LOG_GET_NTH_LEAVE(ercd, p_tskid)
+#endif /* LOG_GET_NTH_LEAVE */
+
+#ifndef LOG_LOC_CPU_ENTER
+#define LOG_LOC_CPU_ENTER()
+#endif /* LOG_LOC_CPU_ENTER */
+
+#ifndef LOG_LOC_CPU_LEAVE
+#define LOG_LOC_CPU_LEAVE(ercd)
+#endif /* LOG_LOC_CPU_LEAVE */
+
+#ifndef LOG_UNL_CPU_ENTER
+#define LOG_UNL_CPU_ENTER()
+#endif /* LOG_UNL_CPU_ENTER */
+
+#ifndef LOG_UNL_CPU_LEAVE
+#define LOG_UNL_CPU_LEAVE(ercd)
+#endif /* LOG_UNL_CPU_LEAVE */
+
+#ifndef LOG_DIS_DSP_ENTER
+#define LOG_DIS_DSP_ENTER()
+#endif /* LOG_DIS_DSP_ENTER */
+
+#ifndef LOG_DIS_DSP_LEAVE
+#define LOG_DIS_DSP_LEAVE(ercd)
+#endif /* LOG_DIS_DSP_LEAVE */
+
+#ifndef LOG_ENA_DSP_ENTER
+#define LOG_ENA_DSP_ENTER()
+#endif /* LOG_ENA_DSP_ENTER */
+
+#ifndef LOG_ENA_DSP_LEAVE
+#define LOG_ENA_DSP_LEAVE(ercd)
+#endif /* LOG_ENA_DSP_LEAVE */
+
+#ifndef LOG_SNS_CTX_ENTER
+#define LOG_SNS_CTX_ENTER()
+#endif /* LOG_SNS_CTX_ENTER */
+
+#ifndef LOG_SNS_CTX_LEAVE
+#define LOG_SNS_CTX_LEAVE(state)
+#endif /* LOG_SNS_CTX_LEAVE */
+
+#ifndef LOG_SNS_LOC_ENTER
+#define LOG_SNS_LOC_ENTER()
+#endif /* LOG_SNS_LOC_ENTER */
+
+#ifndef LOG_SNS_LOC_LEAVE
+#define LOG_SNS_LOC_LEAVE(state)
+#endif /* LOG_SNS_LOC_LEAVE */
+
+#ifndef LOG_SNS_DSP_ENTER
+#define LOG_SNS_DSP_ENTER()
+#endif /* LOG_SNS_DSP_ENTER */
+
+#ifndef LOG_SNS_DSP_LEAVE
+#define LOG_SNS_DSP_LEAVE(state)
+#endif /* LOG_SNS_DSP_LEAVE */
+
+#ifndef LOG_SNS_DPN_ENTER
+#define LOG_SNS_DPN_ENTER()
+#endif /* LOG_SNS_DPN_ENTER */
+
+#ifndef LOG_SNS_DPN_LEAVE
+#define LOG_SNS_DPN_LEAVE(state)
+#endif /* LOG_SNS_DPN_LEAVE */
+
+#ifndef LOG_SNS_KER_ENTER
+#define LOG_SNS_KER_ENTER()
+#endif /* LOG_SNS_KER_ENTER */
+
+#ifndef LOG_SNS_KER_LEAVE
+#define LOG_SNS_KER_LEAVE(state)
+#endif /* LOG_SNS_KER_LEAVE */
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+é ä½ã®åè»¢ï¼»NGKI3548ï¼½
+ */
+#ifdef TOPPERS_rot_rdq
+
+ER
+rot_rdq(PRI tskpri)
+{
+	uint_t	pri;
+	ER		ercd;
+
+	LOG_ROT_RDQ_ENTER(tskpri);
+	CHECK_UNL();								/*ï¼»NGKI2684ï¼½*/
+	if (tskpri == TPRI_SELF && !sense_context()) {
+		pri = p_runtsk->bpriority;				/*ï¼»NGKI2689ï¼½*/
+	}
+	else {
+		CHECK_PAR(VALID_TPRI(tskpri));			/*ï¼»NGKI2685ï¼½*/
+		pri = INT_PRIORITY(tskpri);
+	}
+
+	lock_cpu();
+	rotate_ready_queue(&(ready_queue[pri]));
+	if (p_runtsk != p_schedtsk) {
+		if (!sense_context()) {
+			dispatch();
+		}
+		else {
+			request_dispatch();
+		}
+	}
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_ROT_RDQ_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rot_rdq */
+
+/*
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯IDã®åç
+§ï¼»NGKI3550ï¼½
+ */
+#ifdef TOPPERS_get_tid
+
+ER
+get_tid(ID *p_tskid)
+{
+	ER		ercd;
+
+	LOG_GET_TID_ENTER(p_tskid);
+	CHECK_UNL();								/*ï¼»NGKI2707ï¼½*/
+
+	lock_cpu();
+	*p_tskid = (p_runtsk == NULL) ? TSK_NONE : TSKID(p_runtsk);
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_TID_LEAVE(ercd, p_tskid);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_tid */
+
+/*
+ *  å®è¡ã§ããã¿ã¹ã¯ã®æ°ã®åç
+§ï¼»NGKI3623ï¼½
+ */
+#ifdef TOPPERS_get_lod
+
+ER
+get_lod(PRI tskpri, uint_t *p_load)
+{
+	uint_t	pri, load;
+	QUEUE	*p_queue, *p_entry;
+	ER		ercd;
+
+	LOG_GET_LOD_ENTER(p_tskid, p_load);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3624ï¼½ï¼»NGKI3625ï¼½*/
+	if (tskpri == TPRI_SELF) {
+		pri = p_runtsk->bpriority;				/*ï¼»NGKI3631ï¼½*/
+	}
+	else {
+		CHECK_PAR(VALID_TPRI(tskpri));			/*ï¼»NGKI3626ï¼½*/
+		pri = INT_PRIORITY(tskpri);
+	}
+	p_queue = &(ready_queue[pri]);
+
+	lock_cpu();
+	load = 0U;
+	for (p_entry = p_queue->p_next; p_entry != p_queue;
+										p_entry = p_entry->p_next) {
+		load += 1U;
+	}
+	*p_load = load;
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_LOD_LEAVE(ercd, p_load);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_lod */
+
+/*
+ *  æå®ããåªå
+é ä½ã®ã¿ã¹ã¯IDã®åç
+§ï¼»NGKI3641ï¼½
+ */
+#ifdef TOPPERS_get_nth
+
+ER
+get_nth(PRI tskpri, uint_t nth, ID *p_tskid)
+{
+	uint_t	pri;
+	QUEUE	*p_queue, *p_entry;
+	ID		tskid;
+	ER		ercd;
+
+	LOG_GET_NTH_ENTER(p_tskid, nth, p_tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3642ï¼½ï¼»NGKI3643ï¼½*/
+	if (tskpri == TPRI_SELF) {
+		pri = p_runtsk->bpriority;				/*ï¼»NGKI3650ï¼½*/
+	}
+	else {
+		CHECK_PAR(VALID_TPRI(tskpri));			/*ï¼»NGKI3644ï¼½*/
+		pri = INT_PRIORITY(tskpri);
+	}
+	p_queue = &(ready_queue[pri]);
+
+	lock_cpu();
+	tskid = TSK_NONE;
+	for (p_entry = p_queue->p_next; p_entry != p_queue;
+										p_entry = p_entry->p_next) {
+		if (nth == 0U) {
+			tskid = TSKID((TCB *) p_entry);
+			break;
+		}
+		nth -= 1U;
+	}
+	*p_tskid = tskid;
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_NTH_LEAVE(ercd, p_tskid);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_nth */
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã¸ã®é·ç§»ï¼»NGKI3538ï¼½
+ */
+#ifdef TOPPERS_loc_cpu
+
+ER
+loc_cpu(void)
+{
+	ER		ercd;
+
+	LOG_LOC_CPU_ENTER();
+
+	if (!sense_lock()) {						/*ï¼»NGKI2731ï¼½*/
+		lock_cpu();								/*ï¼»NGKI2730ï¼½*/
+	}
+	ercd = E_OK;
+
+	LOG_LOC_CPU_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_loc_cpu */
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®è§£é¤ï¼»NGKI3539ï¼½
+ *
+ *  CPUã­ãã¯ä¸­ã¯ï¼ãã£ã¹ããããå¿
+è¦ã¨ãªããµã¼ãã¹ã³ã¼ã«ãå¼ã³åºãã
+ *  ã¨ã¯ã§ããªãããï¼CPUã­ãã¯ç¶æ
+ã®è§£é¤æã«ãã£ã¹ãããã£ãèµ·åãã
+ *  å¿
+è¦ã¯ãªãï¼
+ */
+#ifdef TOPPERS_unl_cpu
+
+ER
+unl_cpu(void)
+{
+	ER		ercd;
+
+	LOG_UNL_CPU_ENTER();
+
+	if (sense_lock()) {							/*ï¼»NGKI2738ï¼½*/
+		unlock_cpu();							/*ï¼»NGKI2737ï¼½*/
+	}
+	ercd = E_OK;
+
+	LOG_UNL_CPU_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_unl_cpu */
+
+/*
+ *  ãã£ã¹ãããã®ç¦æ­¢ï¼»NGKI2740ï¼½
+ */
+#ifdef TOPPERS_dis_dsp
+
+ER
+dis_dsp(void)
+{
+	ER		ercd;
+
+	LOG_DIS_DSP_ENTER();
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI2741ï¼½ï¼»NGKI2742ï¼½*/
+
+	lock_cpu();
+	enadsp = false;
+	dspflg = false;
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_DIS_DSP_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_dis_dsp */
+
+/*
+ *  ãã£ã¹ãããã®è¨±å¯ï¼»NGKI2746ï¼½
+ */
+#ifdef TOPPERS_ena_dsp
+
+ER
+ena_dsp(void)
+{
+	ER		ercd;
+
+	LOG_ENA_DSP_ENTER();
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI2747ï¼½ï¼»NGKI2748ï¼½*/
+
+	lock_cpu();
+	enadsp = true;
+	if (t_get_ipm() == TIPM_ENAALL) {
+		dspflg = true;
+		p_schedtsk = search_schedtsk();
+		if (p_runtsk->raster && p_runtsk->enater) {
+#ifdef TOPPERS_SUPPORT_OVRHDR
+			if (p_runtsk->staovr) {
+				(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+				ovrtimer_flag = false;
+			}
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+			task_terminate(p_runtsk);
+			exit_and_dispatch();
+			ercd = E_SYS;
+		}
+		else {
+			if (p_runtsk != p_schedtsk) {
+				dispatch();
+			}
+			ercd = E_OK;
+		}
+	}
+	else {
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ENA_DSP_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ena_dsp */
+
+/*
+ *  ã³ã³ãã­ã¹ãã®åç
+§ï¼»NGKI2752ï¼½
+ */
+#ifdef TOPPERS_sns_ctx
+
+bool_t
+sns_ctx(void)
+{
+	bool_t	state;
+
+	LOG_SNS_CTX_ENTER();
+	state = sense_context() ? true : false;
+	LOG_SNS_CTX_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_ctx */
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®åç
+§ï¼»NGKI2754ï¼½
+ */
+#ifdef TOPPERS_sns_loc
+
+bool_t
+sns_loc(void)
+{
+	bool_t	state;
+
+	LOG_SNS_LOC_ENTER();
+	state = sense_lock() ? true : false;
+	LOG_SNS_LOC_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_loc */
+
+/*
+ *  ãã£ã¹ãããç¦æ­¢ç¶æ
+ã®åç
+§ï¼»NGKI2756ï¼½
+ */
+#ifdef TOPPERS_sns_dsp
+
+bool_t
+sns_dsp(void)
+{
+	bool_t	state;
+
+	LOG_SNS_DSP_ENTER();
+	state = !enadsp;
+	LOG_SNS_DSP_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_dsp */
+
+/*
+ *  ãã£ã¹ãããä¿çç¶æ
+ã®åç
+§ï¼»NGKI2758ï¼½
+ */
+#ifdef TOPPERS_sns_dpn
+
+bool_t
+sns_dpn(void)
+{
+	bool_t	state;
+
+	LOG_SNS_DPN_ENTER();
+	state = (sense_context() || sense_lock() || !dspflg) ? true : false;
+	LOG_SNS_DPN_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_dpn */
+
+/*
+ *  ã«ã¼ãã«éåä½ç¶æ
+ã®åç
+§ï¼»NGKI2760ï¼½
+ */
+#ifdef TOPPERS_sns_ker
+
+bool_t
+sns_ker(void)
+{
+	bool_t	state;
+
+	LOG_SNS_KER_ENTER();
+	state = kerflg ? false : true;
+	LOG_SNS_KER_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_ker */
Index: asp3_gr_sakura/trunk/kernel/task.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/task.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task.c	(revision 317)
@@ -0,0 +1,493 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯ç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#include "kernel_impl.h"
+#include "task.h"
+#include "taskhook.h"
+#include "wait.h"
+
+#ifdef TOPPERS_tskini
+
+/*
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯
+ */
+TCB		*p_runtsk;
+
+/*
+ *  å®è¡ãã¹ãã¿ã¹ã¯
+ */
+TCB		*p_schedtsk;
+
+/*
+ *  ãã£ã¹ãããè¨±å¯ç¶æ
+
+ */
+bool_t	enadsp;
+
+/*
+ *  ã¿ã¹ã¯ãã£ã¹ãããå¯è½ç¶æ
+
+ */
+bool_t	dspflg;
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼
+ */
+QUEUE	ready_queue[TNUM_TPRI];
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼ãµã¼ãã®ããã®ãããããã
+ */
+uint16_t	ready_primap;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãTCBã®ãªã¹ã
+ */
+QUEUE	free_tcb;
+
+/*
+ *  ã¿ã¹ã¯ç®¡çã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+void
+initialize_task(void)
+{
+	uint_t	i, j;
+	TCB		*p_tcb;
+	TINIB	*p_tinib;
+
+	p_runtsk = NULL;
+	p_schedtsk = NULL;
+	enadsp = true;
+	dspflg = true;
+
+	for (i = 0; i < TNUM_TPRI; i++) {
+		queue_initialize(&(ready_queue[i]));
+	}
+	ready_primap = 0U;
+
+	for (i = 0; i < tnum_stsk; i++) {
+		j = INDEX_TSK(torder_table[i]);
+		p_tcb = &(tcb_table[j]);
+		p_tcb->p_tinib = &(tinib_table[j]);
+		p_tcb->actque = false;
+		make_dormant(p_tcb);
+		if ((p_tcb->p_tinib->tskatr & TA_ACT) != 0U) {
+			make_active(p_tcb);
+		}
+	}
+	queue_initialize(&free_tcb);
+	for (j = 0; i < tnum_tsk; i++, j++) {
+		p_tcb = &(tcb_table[i]);
+		p_tinib = &(atinib_table[j]);
+		p_tinib->tskatr = TA_NOEXS;
+		p_tcb->p_tinib = ((const TINIB *) p_tinib);
+		queue_insert_prev(&free_tcb, &(p_tcb->task_queue));
+	}
+}
+
+#endif /* TOPPERS_tskini */
+
+/*
+ *  ãããããããµã¼ãé¢æ°
+ *
+ *  bitmapå
+ã®1ã®ãããã®å
+ï¼æãä¸ä½ï¼å³ï¼ã®ãã®ããµã¼ããï¼ãã®ãã
+ *  ãçªå·ãè¿ãï¼ãããçªå·ã¯ï¼æä¸ä½ãããã0ã¨ããï¼bitmapã«0ãæå®
+ *  ãã¦ã¯ãªããªãï¼ãã®é¢æ°ã§ã¯ï¼bitmapã16ãããã§ãããã¨ãä»®å®ãï¼
+ *  uint16_tåã¨ãã¦ããï¼
+ *
+ *  ããããµã¼ãå½ä»¤ãæã¤ãã­ã»ããµã§ã¯ï¼ããããµã¼ãå½ä»¤ãä½¿ãããã«
+ *  æ¸ãç´ããæ¹ãå¹çãè¯ãå ´åãããï¼ãã®ãããªå ´åã«ã¯ï¼ã¿ã¼ã²ãã
+ *  ä¾å­é¨ã§ããããµã¼ãå½ä»¤ãä½¿ã£ãbitmap_searchãå®ç¾©ãï¼
+ *  OMIT_BITMAP_SEARCHããã¯ã­å®ç¾©ããã°ããï¼ã¾ãï¼ããããµã¼ãå½ä»¤ã®
+ *  ãµã¼ãæ¹åãéãªã©ã®çç±ã§åªå
+åº¦ã¨ãããã¨ã®å¯¾å¿ãå¤æ´ãããå ´åã«
+ *  ã¯ï¼PRIMAP_BITããã¯ã­å®ç¾©ããã°ããï¼
+ *
+ *  ã¾ãï¼ã©ã¤ãã©ãªã«ffsããããªãï¼æ¬¡ã®ããã«å®ç¾©ãã¦ã©ã¤ãã©ãªé¢æ°ã
+ *  ä½¿ã£ãæ¹ãå¹çãè¯ãå¯è½æ§ãããï¼
+ *		#define	bitmap_search(bitmap) (ffs(bitmap) - 1)
+ */
+#ifndef PRIMAP_BIT
+#define	PRIMAP_BIT(pri)		(1U << (pri))
+#endif /* PRIMAP_BIT */
+
+#ifndef OMIT_BITMAP_SEARCH
+
+static const unsigned char bitmap_search_table[] = { 0, 1, 0, 2, 0, 1, 0,
+												3, 0, 1, 0, 2, 0, 1, 0 };
+
+Inline uint_t
+bitmap_search(uint16_t bitmap)
+{
+	uint_t	n = 0U;
+
+	assert(bitmap != 0U);
+	if ((bitmap & 0x00ffU) == 0U) {
+		bitmap >>= 8;
+		n += 8;
+	}
+	if ((bitmap & 0x0fU) == 0U) {
+		bitmap >>= 4;
+		n += 4;
+	}
+	return(n + bitmap_search_table[(bitmap & 0x0fU) - 1]);
+}
+
+#endif /* OMIT_BITMAP_SEARCH */
+
+/*
+ *  åªå
+åº¦ãããããããç©ºãã®ãã§ãã¯
+ */
+Inline bool_t
+primap_empty(void)
+{
+	return(ready_primap == 0U);
+}
+
+/*
+ *  åªå
+åº¦ããããããã®ãµã¼ã
+ */
+Inline uint_t
+primap_search(void)
+{
+	return(bitmap_search(ready_primap));
+}
+
+/*
+ *  åªå
+åº¦ããããããã®ã»ãã
+ */
+Inline void
+primap_set(uint_t pri)
+{
+	ready_primap |= PRIMAP_BIT(pri);
+}
+
+/*
+ *  åªå
+åº¦ããããããã®ã¯ãªã¢
+ */
+Inline void
+primap_clear(uint_t pri)
+{
+	ready_primap &= ~PRIMAP_BIT(pri);
+}
+
+/*
+ *  æé«åªå
+é ä½ã¿ã¹ã¯ã®ãµã¼ã
+ */
+#ifdef TOPPERS_tsksched
+
+TCB *
+search_schedtsk(void)
+{
+	uint_t	schedpri;
+
+	schedpri = primap_search();
+	return((TCB *)(ready_queue[schedpri].p_next));
+}
+
+#endif /* TOPPERS_tsksched */
+
+/*
+ *  å®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+ *
+ *  å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããã®ã¯ï¼å®è¡ã§ããã¿ã¹ã¯ããªãã£ãå ´åã¨ï¼
+ *  p_tcbã®åªå
+åº¦ãå®è¡ãã¹ãã¿ã¹ã¯ã®åªå
+åº¦ãããé«ãå ´åã§ããï¼
+ */
+#ifdef TOPPERS_tskrun
+
+void
+make_runnable(TCB *p_tcb)
+{
+	uint_t	pri = p_tcb->priority;
+
+	queue_insert_prev(&(ready_queue[pri]), &(p_tcb->task_queue));
+	primap_set(pri);
+
+	if (dspflg) {
+		if (p_schedtsk == (TCB *) NULL || pri < p_schedtsk->priority) {
+			p_schedtsk = p_tcb;
+		}
+	}
+}
+
+#endif /* TOPPERS_tskrun */
+
+/*
+ *  å®è¡ã§ããç¶æ
+ããä»ã®ç¶æ
+ã¸ã®é·ç§»
+ *
+ *  å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããã®ã¯ï¼p_tcbãå®è¡ãã¹ãã¿ã¹ã¯ã§ãã£ãå ´å
+ *  ã§ããï¼p_tcbã¨åãåªå
+åº¦ã®ã¿ã¹ã¯ãä»ã«ããå ´åã¯ï¼p_tcbã®æ¬¡ã®ã¿ã¹
+ *  ã¯ãå®è¡ãã¹ãã¿ã¹ã¯ã«ãªãï¼ããã§ãªãå ´åã¯ï¼ã¬ãã£ã­ã¥ã¼ããµã¼ã
+ *  ããå¿
+è¦ãããï¼
+ */
+#ifdef TOPPERS_tsknrun
+
+void
+make_non_runnable(TCB *p_tcb)
+{
+	uint_t	pri = p_tcb->priority;
+	QUEUE	*p_queue = &(ready_queue[pri]);
+
+	queue_delete(&(p_tcb->task_queue));
+	if (queue_empty(p_queue)) {
+		primap_clear(pri);
+		if (p_schedtsk == p_tcb) {
+			assert(dspflg);
+			p_schedtsk = primap_empty() ? (TCB *) NULL : search_schedtsk();
+		}
+	}
+	else {
+		if (p_schedtsk == p_tcb) {
+			assert(dspflg);
+			p_schedtsk = (TCB *)(p_queue->p_next);
+		}
+	}
+}
+
+#endif /* TOPPERS_tsknrun */
+
+/*
+ *  ä¼æ­¢ç¶æ
+ã¸ã®é·ç§»
+ */
+#ifdef TOPPERS_tskdmt
+
+void
+make_dormant(TCB *p_tcb)
+{
+	p_tcb->tstat = TS_DORMANT;
+	p_tcb->bpriority = p_tcb->p_tinib->ipriority;
+	p_tcb->priority = p_tcb->p_tinib->ipriority;
+	p_tcb->wupque = false;
+	p_tcb->raster = false;
+	p_tcb->enater = true;
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	p_tcb->staovr = false;
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	LOG_TSKSTAT(p_tcb);
+}
+
+#endif /* TOPPERS_tskdmt */
+
+/*
+ *  ä¼æ­¢ç¶æ
+ããå®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+ */
+#ifdef TOPPERS_tskact
+
+void
+make_active(TCB *p_tcb)
+{
+	activate_context(p_tcb);
+	p_tcb->tstat = TS_RUNNABLE;
+	LOG_TSKSTAT(p_tcb);
+	make_runnable(p_tcb);
+}
+
+#endif /* TOPPERS_tskact */
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+åº¦ã®å¤æ´
+ *
+ *  ã¿ã¹ã¯ãå®è¡ã§ããç¶æ
+ã®å ´åã«ã¯ï¼ã¬ãã£ã­ã¥ã¼ã®ä¸­ã§ã®ä½ç½®ãå¤æ´ã
+ *  ãï¼ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã®ä¸­ã§å¾
+ã¡ç¶æ
+ã«ãªã£ã¦ããå ´åã«ã¯ï¼å¾
+
+ *  ã¡ã­ã¥ã¼ã®ä¸­ã§ã®ä½ç½®ãå¤æ´ããï¼
+ *
+ *  å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããã®ã¯ï¼(1) p_tcbãå®è¡ãã¹ãã¿ã¹ã¯ã§ãã£ã¦ï¼
+ *  ãã®åªå
+åº¦ãä¸ããå ´åï¼(2) p_tcbãå®è¡ãã¹ãã¿ã¹ã¯ã§ã¯ãªãï¼å¤æ´å¾
+ *  ã®åªå
+åº¦ãå®è¡ãã¹ãã¿ã¹ã¯ã®åªå
+åº¦ãããé«ãå ´åã§ããï¼(1)ã®å ´åã«
+ *  ã¯ï¼ã¬ãã£ã­ã¥ã¼ããµã¼ãããå¿
+è¦ãããï¼
+ */
+#ifdef TOPPERS_tskpri
+
+void
+change_priority(TCB *p_tcb, uint_t newpri, bool_t mtxmode)
+{
+	uint_t	oldpri;
+
+	oldpri = p_tcb->priority;
+	p_tcb->priority = newpri;
+
+	if (TSTAT_RUNNABLE(p_tcb->tstat)) {
+		/*
+		 *  ã¿ã¹ã¯ãå®è¡ã§ããç¶æ
+ã®å ´å
+		 */
+		queue_delete(&(p_tcb->task_queue));
+		if (queue_empty(&(ready_queue[oldpri]))) {
+			primap_clear(oldpri);
+		}
+		if (mtxmode) {
+			queue_insert_next(&(ready_queue[newpri]), &(p_tcb->task_queue));
+		}
+		else {
+			queue_insert_prev(&(ready_queue[newpri]), &(p_tcb->task_queue));
+		}
+		primap_set(newpri);
+
+		if (dspflg) {
+			if (p_schedtsk == p_tcb) {
+				if (newpri >= oldpri) {
+					p_schedtsk = search_schedtsk();
+				}
+			}
+			else {
+				if (mtxmode ? newpri <= p_schedtsk->priority
+							: newpri < p_schedtsk->priority) {
+					p_schedtsk = p_tcb;
+				}
+			}
+		}
+	}
+	else {
+		if (TSTAT_WAIT_WOBJCB(p_tcb->tstat)) {
+			/*
+			 *  ã¿ã¹ã¯ãï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨
+			 *  åï¼WOBJCBï¼ã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªããã¦ããå ´å
+			 */
+			wobj_change_priority(((WINFO_WOBJ *)(p_tcb->p_winfo))->p_wobjcb,
+																	p_tcb);
+		}
+	}
+}
+
+#endif /* TOPPERS_tskpri */
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼ã®åè»¢
+ *
+ *  å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããã®ã¯ï¼å®è¡ãã¹ãã¿ã¹ã¯ãã¿ã¹ã¯ã­ã¥ã¼ã®æ«
+ *  å°¾ã«ç§»åããå ´åã§ããï¼
+ */
+#ifdef TOPPERS_tskrot
+
+void
+rotate_ready_queue(QUEUE *p_queue)
+{
+	QUEUE	*p_entry;
+
+	if (!queue_empty(p_queue) && p_queue->p_next->p_next != p_queue) {
+		p_entry = queue_delete_next(p_queue);
+		queue_insert_prev(p_queue, p_entry);
+		if (dspflg) {
+			if (p_schedtsk == (TCB *) p_entry) {
+				p_schedtsk = (TCB *)(p_queue->p_next);
+			}
+		}
+	}
+}
+
+#endif /* TOPPERS_tskrot */
+
+/*
+ *  ã¿ã¹ã¯ã®çµäºå¦ç
+ */
+#ifdef TOPPERS_tskterm
+
+void
+task_terminate(TCB *p_tcb)
+{
+	if (TSTAT_RUNNABLE(p_tcb->tstat)) {
+		make_non_runnable(p_tcb);
+	}
+	else if (TSTAT_WAITING(p_tcb->tstat)) {
+		wait_dequeue_wobj(p_tcb);
+		wait_dequeue_tmevtb(p_tcb);
+	}
+	if (p_tcb->p_lastmtx != NULL) {
+		(*mtxhook_release_all)(p_tcb);
+	}
+	make_dormant(p_tcb);
+	if (p_tcb->actque) {
+		p_tcb->actque = false;
+		make_active(p_tcb);
+	}
+}
+
+#endif /* TOPPERS_tskterm */
Index: asp3_gr_sakura/trunk/kernel/task.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/task.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task.h	(revision 317)
@@ -0,0 +1,666 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯ç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#ifndef TOPPERS_TASK_H
+#define TOPPERS_TASK_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "time_event.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_TSKSTAT
+#define LOG_TSKSTAT(p_tcb)
+#endif /* LOG_TSKSTAT */
+
+/*
+ *  ã¿ã¹ã¯åªå
+åº¦ã®å
+é¨è¡¨ç¾ã»å¤é¨è¡¨ç¾å¤æãã¯ã­
+ */
+#define INT_PRIORITY(x)		((uint_t)((x) - TMIN_TPRI))
+#define EXT_TSKPRI(x)		((PRI)(x) + TMIN_TPRI)
+
+/*
+ *  ã¿ã¹ã¯ç¶æ
+ã®å
+é¨è¡¨ç¾
+ *
+ *  TCBä¸­ã®ã¿ã¹ã¯ç¶æ
+ã®ãã£ã¼ã«ãã§ã¯ï¼ã¿ã¹ã¯ã®ç¶æ
+ã¨ï¼ã¿ã¹ã¯ãå¾
+ã¡ç¶æ
+
+ *  ã®æã®å¾
+ã¡è¦å ãè¡¨ãï¼ãã ãï¼å®è¡ç¶æ
+ï¼RUNNINGï¼ã¨å®è¡å¯è½ç¶æ
+
+ *  ï¼READYï¼ã¯åºå¥ããï¼ä¸¡ç¶æ
+ããããã¦å®è¡ã§ããç¶æ
+ï¼RUNNABLEï¼ã¨ã
+ *  ã¦ç®¡çããï¼äºéå¾
+ã¡ç¶æ
+ã¯ï¼(TS_WAITING_??? | TS_SUSPENDED)ã§è¡¨ãï¼
+ *
+ *  ã¿ã¹ã¯ãå¾
+ã¡ç¶æ
+ï¼äºéå¾
+ã¡ç¶æ
+ãå«ãï¼ã®æã¯ï¼TS_WAITING_???ã§å¾
+ã¡
+ *  è¦å ãè¡¨ãï¼å¾
+ã¡è¦å ï¼5ãããã§è¡¨ç¾ãããï¼ã®ä¸ä½2ãããã§ï¼åæã»
+ *  éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªãã£ã¦ãããã©ãããè¡¨ãï¼åæã»
+ *  éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªãããªããã®ã¯ä¸ä½2ãããã00ï¼å
+ *  æã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼ã®å¾
+ã¡ã­ã¥ã¼
+ *  ã«ã¤ãªãããã®ã¯10ã¾ãã¯11ï¼ããä»¥å¤ã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªãããã®ã¯01
+ *  ã¨ããï¼
+ */
+#define TS_DORMANT		0x00U			/* ä¼æ­¢ç¶æ
+ */
+#define TS_RUNNABLE		0x01U			/* å®è¡ã§ããç¶æ
+ */
+#define TS_SUSPENDED	0x02U			/* å¼·å¶å¾
+ã¡ç¶æ
+ */
+
+#define TS_WAITING_SLP	(0x01U << 2)	/* èµ·åºå¾
+ã¡ */
+#define TS_WAITING_DLY	(0x02U << 2)	/* æéçµéå¾
+ã¡ */
+#define TS_WAITING_RDTQ	(0x08U << 2)	/* ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡å¾
+ã¡ */
+#define TS_WAITING_RPDQ	(0x09U << 2)	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡å¾
+ã¡ */
+#define TS_WAITING_SEM	(0x10U << 2)	/* ã»ããã©è³æºã®ç²å¾å¾
+ã¡ */
+#define TS_WAITING_FLG	(0x11U << 2)	/* ã¤ãã³ããã©ã°å¾
+ã¡ */
+#define TS_WAITING_SDTQ	(0x12U << 2)	/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡å¾
+ã¡ */
+#define TS_WAITING_SPDQ	(0x13U << 2)	/* åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡å¾
+ã¡ */
+#define TS_WAITING_MTX	(0x14U << 2)	/* ãã¥ã¼ããã¯ã¹ã®ã­ãã¯å¾
+ã¡ */
+#define TS_WAITING_MPF	(0x15U << 2)	/* åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾å¾
+ã¡ */
+
+#define TS_WAITING_MASK	(0x1fU << 2)	/* å¾
+ã¡ç¶æ
+ã®å¤å¥ç¨ãã¹ã¯ */
+
+/*
+ *  ã¿ã¹ã¯ç¶æ
+å¤å¥ãã¯ã­
+ *
+ *  TSTAT_DORMANTã¯ã¿ã¹ã¯ãä¼æ­¢ç¶æ
+ã§ãããã©ãããï¼TSTAT_RUNNABLEã¯
+ *  ã¿ã¹ã¯ãå®è¡ã§ããç¶æ
+ã§ãããã©ãããå¤å¥ããï¼TSTAT_WAITINGã¯å¾
+
+ *  ã¡ç¶æ
+ã¨äºéå¾
+ã¡ç¶æ
+ã®ããããã§ãããã©ãããï¼TSTAT_SUSPENDEDã¯
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ã¨äºéå¾
+ã¡ç¶æ
+ã®ããããã§ãããã©ãããå¤å¥ããï¼
+ */
+#define TSTAT_DORMANT(tstat)	((tstat) == TS_DORMANT)
+#define TSTAT_RUNNABLE(tstat)	(((tstat) & TS_RUNNABLE) != 0U)
+#define TSTAT_WAITING(tstat)	(((tstat) & TS_WAITING_MASK) != 0U)
+#define TSTAT_SUSPENDED(tstat)	(((tstat) & TS_SUSPENDED) != 0U)
+
+/*
+ *  ã¿ã¹ã¯å¾
+ã¡è¦å å¤å¥ãã¯ã­
+ *
+ *  TSTAT_WAIT_SLPã¯ã¿ã¹ã¯ãèµ·åºå¾
+ã¡ã§ãããã©ãããï¼TSTAT_WAIT_MTXã¯
+ *  ã¿ã¹ã¯ããã¥ã¼ããã¯ã¹å¾
+ã¡ã§ãããã©ãããå¤å¥ããï¼
+ *
+ *  ã¾ãï¼TSTAT_WAIT_WOBJ ã¯ã¿ã¹ã¯ãåæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡
+ *  ã§ãããï¼è¨ãæããã¨ï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªã
+ *  ãã¦ãããï¼ã©ãããï¼TSTAT_WAIT_WOBJCBã¯ã¿ã¹ã¯ãåæã»éä¿¡ãªãã¸ã§
+ *  ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åï¼WOBJCBï¼ã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªããã¦ãã
+ *  ãã©ãããå¤å¥ããï¼
+ */
+#define TSTAT_WAIT_SLP(tstat)	(((tstat) & ~TS_SUSPENDED) == TS_WAITING_SLP)
+#define TSTAT_WAIT_MTX(tstat)	(((tstat) & ~TS_SUSPENDED) == TS_WAITING_MTX)
+
+#define TSTAT_WAIT_WOBJ(tstat)		(((tstat) & (0x18U << 2)) != 0U)
+#define TSTAT_WAIT_WOBJCB(tstat)	(((tstat) & (0x10U << 2)) != 0U)
+
+/*
+ *  å¾
+ã¡æ
+å ±ãã­ãã¯ï¼WINFOï¼ã®å®ç¾©
+ *
+ *  ã¿ã¹ã¯ãå¾
+ã¡ç¶æ
+ã®éã¯ï¼TCBããã³ãã®p_winfoã§æãããWINFOãæ¬¡ã®
+ *  ããã«è¨­å®ããªããã°ãªããªãï¼
+ *
+ *  (a) TCBã®ã¿ã¹ã¯ç¶æ
+ãå¾
+ã¡ç¶æ
+ï¼TS_WAITING_???ï¼ã«ããï¼
+ *
+ *  (b) ã¿ã¤ã ã¢ã¦ããç£è¦ããããã«ï¼ã¿ã¤ã ã¤ãã³ããã­ãã¯ãç»é²ããï¼
+ *  ç»é²ããã¿ã¤ã ã¤ãã³ããã­ãã¯ã¯ï¼å¾
+ã¡ã«å
+¥ããµã¼ãã¹ã³ã¼ã«å¦çé¢æ°
+ *  ã®ã­ã¼ã«ã«å¤æ°ã¨ãã¦ç¢ºä¿ãï¼ããã¸ã®ãã¤ã³ã¿ãWINFOã®p_tmevtbã«è¨
+ *  æ¶ããï¼ã¿ã¤ã ã¢ã¦ãã®ç£è¦ãå¿
+è¦ãªãå ´åï¼æ°¸ä¹
+å¾
+ã¡ã®å ´åï¼ã«ã¯ï¼
+ *  p_tmevtbãNULLã«ããï¼
+ *
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+ã®å ´åã«ã¯ï¼æ¨æºã®WINFOã«
+ *  p_wobjcbãã£ã¼ã«ããè¿½å ããæ§é ä½ï¼WINFO_WOBJï¼wait.hã§å®ç¾©ï¼ã«ï¼
+ *  å¾
+ã¡å¯¾è±¡ã®åæã»éä¿¡ãªãã¸ã§ã¯ãã«ä¾å­ãã¦è¨æ¶ãããã¨ãå¿
+è¦ãªæ
+å ±
+ *  ã®ããã®ãã£ã¼ã«ããè¿½å ããæ§é ä½ï¼WINFO_???ï¼ãå®ç¾©ãï¼WINFOã®ä»£
+ *  ããã«ç¨ããï¼ã¾ãï¼ä»¥ä¸ã®(c)ï½(e)ã®è¨­å®ãè¡ãå¿
+è¦ãããï¼åæã»é
+ *  ä¿¡ãªãã¸ã§ã¯ãã«é¢ä¿ããªãå¾
+ã¡ï¼èµ·åºå¾
+ã¡ï¼æéçµéå¾
+ã¡ï¼ã®å ´åã«ã¯ï¼
+ *  ãããã¯å¿
+è¦ãªãï¼
+ *
+ *  (c) TCBãå¾
+ã¡å¯¾è±¡ã®åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªãï¼å¾
+
+ *  ã¡ã­ã¥ã¼ã«ã¤ãªãããã«ï¼task_queueãä½¿ãï¼
+ *
+ *  (d) å¾
+ã¡å¯¾è±¡ã®åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã¸ã®ãã¤ã³ã¿ãï¼
+ *  WINFO_WOBJã®p_wobjcbã«è¨æ¶ããï¼
+ *
+ *  (e) å¾
+ã¡å¯¾è±¡ã®åæã»éä¿¡ãªãã¸ã§ã¯ãã«ä¾å­ãã¦è¨æ¶ãããã¨ãå¿
+è¦ãª
+ *  æ
+å ±ãããå ´åã«ã¯ï¼WINFO_???å
+ã®ãã£ã¼ã«ãã«è¨æ¶ããï¼
+ *
+ *  å¾
+ã¡ç¶æ
+ãè§£é¤ããéã«ã¯ï¼å¾
+ã¡è§£é¤ããã¿ã¹ã¯ã«å¯¾ããè¿å¤ãWINFOã®
+ *  wercdã«è¨­å®ããï¼wercdãå¿
+è¦ãªã®ã¯å¾
+ã¡è§£é¤ä»¥éã§ããã®ã«å¯¾ãã¦ï¼
+ *  p_tmevtbã¯å¾
+ã¡è§£é¤å¾ã¯å¿
+è¦ãªãããï¼ã¡ã¢ãªç¯ç´ã®ããã«å
+±ç¨ä½ãä½¿ã£
+ *  ã¦ããï¼ãã®ããï¼wercdã¸ã¨ã©ã¼ã³ã¼ããè¨­å®ããã®ã¯ï¼ã¿ã¤ã ã¤ãã³ã
+ *  ãã­ãã¯ãç»é²è§£é¤ããå¾ã«ããªããã°ãªããªãï¼
+ */
+typedef union waiting_information {
+	ER		wercd;			/* å¾
+ã¡è§£é¤æã®ã¨ã©ã¼ã³ã¼ã */
+	TMEVTB	*p_tmevtb;		/* å¾
+ã¡ç¶æ
+ç¨ã®ã¿ã¤ã ã¤ãã³ããã­ãã¯ */
+} WINFO;
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ç®¡çãã­ãã¯ã®åã®åæ¹åç
+§
+ */
+typedef struct mutex_control_block MTXCB;
+
+/*
+ *  ã¿ã¹ã¯åæåãã­ãã¯
+ *
+ *  ã¿ã¹ã¯ã«é¢ããæ
+å ±ãï¼å¤ãå¤ãããªãããã«ROMã«ç½®ããé¨åï¼ã¿ã¹ã¯
+ *  åæåãã­ãã¯ï¼ã¨ï¼å¤ãå¤åããããã«RAMã«ç½®ããªããã°ãªããªãé¨
+ *  åï¼ã¿ã¹ã¯ç®¡çãã­ãã¯ï¼TCBï¼ã«åé¢ãï¼TCBå
+ã«å¯¾å¿ããã¿ã¹ã¯åæå
+ *  ãã­ãã¯ãæããã¤ã³ã¿ãå
+¥ããï¼ã¿ã¹ã¯åæåãã­ãã¯å
+ã«å¯¾å¿ãã
+ *  TCBãæããã¤ã³ã¿ãå
+¥ããæ¹æ³ã®æ¹ãï¼RAMã®ç¯ç´ã®è¦³ç¹ããã¯æã¾ãã
+ *  ãï¼å®è¡å¹çãæªããªãããã«æ¡ç¨ãã¦ããªãï¼ä»ã®ãªãã¸ã§ã¯ãã«ã¤ã
+ *  ã¦ãåæ§ã«æ±ãï¼
+ *
+ *  ã¿ã¹ã¯åæåãã­ãã¯ã«ã¯ï¼DEF_TEXã§å®ç¾©ãããã¿ã¹ã¯ä¾å¤å¦çã«ã¼ã
+ *  ã³ã«é¢ããæ
+å ±ãå«ãï¼
+ */
+typedef struct task_initialization_block {
+	ATR			tskatr;			/* ã¿ã¹ã¯å±æ§ */
+	intptr_t	exinf;			/* ã¿ã¹ã¯ã®æ¡å¼µæ
+å ± */
+	TASK		task;			/* ã¿ã¹ã¯ã®èµ·åçªå° */
+	uint_t		ipriority;		/* ã¿ã¹ã¯ã®èµ·åæåªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼ */
+
+#ifdef USE_TSKINICTXB
+	TSKINICTXB	tskinictxb;		/* ã¿ã¹ã¯åæåã³ã³ãã­ã¹ããã­ãã¯ */
+#else /* USE_TSKINICTXB */
+	size_t		stksz;			/* ã¹ã¿ãã¯é åã®ãµã¤ãºï¼ä¸¸ããå¤ï¼ */
+	void		*stk;			/* ã¹ã¿ãã¯é åã®å
+é ­çªå° */
+#endif /* USE_TSKINICTXB */
+} TINIB;
+
+/*
+ *  ã¿ã¹ã¯ç®¡çãã­ãã¯ï¼TCBï¼
+ *
+ *  ASPã«ã¼ãã«ã§ã¯ï¼ã¿ã¹ã¯ã®èµ·åè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®æå¤§å¤ï¼TMAX_ACTCNTï¼
+ *  ã¨èµ·åºè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®æå¤§å¤ï¼TMAX_WUPCNTï¼ã¯1ã«åºå®ããã¦ãã
+ *  ããï¼ã­ã¥ã¼ã¤ã³ã°ããã¦ãããã©ããã®çå½å¤ã§è¡¨ç¾ãããã¨ãã§ããï¼
+ *  ã¾ãï¼å¼·å¶å¾
+ã¡è¦æ±ãã¹ãæ°ã®æå¤§å¤ï¼TMAX_SUSCNTï¼ã1ã«åºå®ããã¦ã
+ *  ãã®ã§ï¼å¼·å¶å¾
+ã¡è¦æ±ãã¹ãæ°ï¼suscntï¼ã¯å¿
+è¦ãªãï¼
+ *
+ *  TCBã®ããã¤ãã®ãã£ã¼ã«ãã¯ï¼ç¹å®ã®ã¿ã¹ã¯ç¶æ
+ã§ã®ã¿æå¹ãªå¤ãä¿æãï¼
+ *  ããä»¥å¤ã®å ´åã¯å¤ãä¿è¨¼ãããªãï¼ãã£ã¦ï¼åç
+§ãã¦ã¯ãªããªãï¼ï¼å
+ *  ãã£ã¼ã«ããæå¹ãªå¤ãä¿æããæ¡ä»¶ã¯æ¬¡ã®éãï¼
+ *
+ *  ã»åæåå¾ã¯å¸¸ã«æå¹ï¼
+ *  		p_tinibï¼tstatï¼actque, staovr, leftotm
+ *  ã»ä¼æ­¢ç¶æ
+ä»¥å¤ã§æå¹ï¼ä¼æ­¢ç¶æ
+ã§ã¯åæå¤ã«ãªã£ã¦ããï¼ï¼
+ *  		bpriorityï¼priorityï¼wupqueï¼rasterï¼enaterï¼p_lastmtx
+ *  ã»å¾
+ã¡ç¶æ
+ï¼äºéå¾
+ã¡ç¶æ
+ãå«ãï¼ã§æå¹ï¼
+ *  		p_winfo
+ *  ã»å®è¡ã§ããç¶æ
+ã¨åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+ã§æå¹ï¼
+ *  		task_queue
+ *  ã»å®è¡å¯è½ç¶æ
+ï¼å¾
+ã¡ç¶æ
+ï¼å¼·å¶å¾
+ã¡ç¶æ
+ï¼äºéå¾
+ã¡ç¶æ
+ã§æå¹ï¼
+ *  		tskctxb
+ */
+typedef struct task_control_block {
+	QUEUE			task_queue;		/* ã¿ã¹ã¯ã­ã¥ã¼ */
+	const TINIB		*p_tinib;		/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+
+#ifdef UINT8_MAX
+	uint8_t			tstat;			/* ã¿ã¹ã¯ç¶æ
+ï¼å
+é¨è¡¨ç¾ï¼*/
+	uint8_t			bpriority;		/* ãã¼ã¹åªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼*/
+	uint8_t			priority;		/* ç¾å¨ã®åªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼*/
+#else /* UINT8_MAX */
+	BIT_FIELD_UINT	tstat : 8;		/* ã¿ã¹ã¯ç¶æ
+ï¼å
+é¨è¡¨ç¾ï¼*/
+	BIT_FIELD_UINT	bpriority : 8;	/* ãã¼ã¹åªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼*/
+	BIT_FIELD_UINT	priority : 8	/* ç¾å¨ã®åªå
+åº¦ï¼å
+é¨è¡¨ç¾ï¼*/;
+#endif /* UINT8_MAX */
+	BIT_FIELD_BOOL	actque : 1;		/* èµ·åè¦æ±ã­ã¥ã¼ã¤ã³ã° */
+	BIT_FIELD_BOOL	wupque : 1;		/* èµ·åºè¦æ±ã­ã¥ã¼ã¤ã³ã° */
+	BIT_FIELD_BOOL	raster : 1;		/* ã¿ã¹ã¯çµäºè¦æ±ç¶æ
+ */
+	BIT_FIELD_BOOL	enater : 1;		/* ã¿ã¹ã¯çµäºè¨±å¯ç¶æ
+ */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	BIT_FIELD_BOOL	staovr : 1;		/* ãªã¼ãã©ã³ãã³ãã©åä½ç¶æ
+ */
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+	WINFO			*p_winfo;		/* å¾
+ã¡æ
+å ±ãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+	MTXCB			*p_lastmtx;		/* æå¾ã«ã­ãã¯ãããã¥ã¼ããã¯ã¹ */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	PRCTIM			leftotm;		/* æ®ããã­ã»ããµæé */
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	TSKCTXB			tskctxb;		/* ã¿ã¹ã¯ã³ã³ãã­ã¹ããã­ãã¯ */
+} TCB;
+
+/*
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯
+ *
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯ï¼ï¼ãã­ã»ããµãã³ã³ãã­ã¹ããæã£ã¦ããã¿ã¹ã¯ï¼ã®
+ *  TCBãæããã¤ã³ã¿ï¼å®è¡ç¶æ
+ã®ã¿ã¹ã¯ããªãå ´åã¯NULLã«ããï¼
+ *
+ *  ãµã¼ãã¹ã³ã¼ã«ã®å¦çä¸­ã§ï¼èªã¿ã¹ã¯ï¼ãµã¼ãã¹ã³ã¼ã«ãå¼ã³åºããã¿ã¹
+ *  ã¯ï¼ã«é¢ããæ
+å ±ãåç
+§ããå ´åã¯p_runtskãä½¿ãï¼p_runtskãæ¸ãæã
+ *  ãã®ã¯ï¼ãã£ã¹ãããã£ï¼ã¨åæåå¦çï¼ã®ã¿ã§ããï¼
+ */
+extern TCB	*p_runtsk;
+
+/*
+ *  å®è¡ãã¹ãã¿ã¹ã¯
+ *
+ *  å®è¡ãã¹ãã¿ã¹ã¯ã®TCBãæããã¤ã³ã¿ï¼å®è¡ã§ããã¿ã¹ã¯ããªãå ´åã¯
+ *  NULLã«ããï¼
+ *
+ *  p_runtskã¯ï¼éå¸¸ã¯p_schedtskã¨ä¸è´ãã¦ãããï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ã
+ *  å®è¡ä¸­ã¯ï¼ä¸è´ãã¦ããã¨ã¯éããªãï¼å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ã§ãªã
+ *  ç¶æ
+ã®éã¨ãã£ã¹ãããç¦æ­¢ç¶æ
+ã®éï¼ããªãã¡ï¼dspflgãfalseã§ããéï¼
+ *  ã¯ï¼p_schedtskãæ´æ°ããªãï¼
+ */
+extern TCB	*p_schedtsk;
+
+/*
+ *  ãã£ã¹ãããè¨±å¯ç¶æ
+
+ *
+ *  ãã£ã¹ãããè¨±å¯ç¶æ
+ã§ãããã¨ãç¤ºããã©ã°ï¼
+ */
+extern bool_t	enadsp;
+
+/*
+ *  ã¿ã¹ã¯ãã£ã¹ãããå¯è½ç¶æ
+
+ *
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯å
+¨è§£é¤ç¶æ
+ã§ããï¼ãã£ã¹ãããè¨±å¯ç¶æ
+ã§ããï¼ãã£
+ *  ã¹ãããç¦æ­¢ç¶æ
+ã§ãªãï¼ãã¨ãç¤ºããã©ã°ï¼ãã£ã¹ãããä¿çç¶æ
+ã§ãª
+ *  ããã¨ã¯ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãå®è¡ä¸­ã§ï¼CPUã­ãã¯ç¶æ
+ã§ãªãï¼dspflgã
+ *  trueã§ãããã¨ã§å¤å¥ãããã¨ãã§ããï¼
+ */
+extern bool_t	dspflg;
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼
+ *
+ *  ã¬ãã£ã­ã¥ã¼ã¯ï¼å®è¡ã§ããç¶æ
+ã®ã¿ã¹ã¯ãç®¡çããããã®ã­ã¥ã¼ã§ããï¼
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯ãç®¡çãã¦ããããï¼ã¬ãã£ï¼å®è¡å¯è½ï¼ã­ã¥ã¼ã¨ãã
+ *  åç§°ã¯æ­£ç¢ºã§ã¯ãªããï¼ã¬ãã£ã­ã¥ã¼ã¨ããåç§°ãå®çãã¦ããããï¼ã
+ *  ã®åç§°ã§å¼ã¶ãã¨ã«ããï¼
+ *
+ *  ã¬ãã£ã­ã¥ã¼ã¯ï¼åªå
+åº¦ãã¨ã®ã¿ã¹ã¯ã­ã¥ã¼ã§æ§æããã¦ããï¼ã¿ã¹ã¯ã®
+ *  TCBã¯ï¼è©²å½ããåªå
+åº¦ã®ã­ã¥ã¼ã«ç»é²ãããï¼
+ */
+extern QUEUE	ready_queue[TNUM_TPRI];
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼ãµã¼ãã®ããã®ãããããã
+ *
+ *  ã¬ãã£ã­ã¥ã¼ã®ãµã¼ããå¹çããè¡ãããã«ï¼åªå
+åº¦ãã¨ã®ã¿ã¹ã¯ã­ã¥ã¼
+ *  ã«ã¿ã¹ã¯ãå
+¥ã£ã¦ãããã©ãããç¤ºããããããããç¨æãã¦ããï¼ãã
+ *  ãããããä½¿ããã¨ã§ï¼ã¡ã¢ãªã¢ã¯ã»ã¹ã®åæ°ãæ¸ãããã¨ãã§ãããï¼
+ *  ãããæä½å½ä»¤ãå
+
+å®ãã¦ããªããã­ã»ããµã§ï¼åªå
+åº¦ã®æ®µéæ°ãå°ãªã
+ *  å ´åã«ã¯ï¼ããããããæä½ã®ãªã¼ãã¼ãããã®ããã«ï¼éã«å¹çãè½ã¡
+ *  ãå¯è½æ§ãããï¼
+ *
+ *  åªå
+åº¦ã16æ®µéã§ãããã¨ãä»®å®ãã¦ããããï¼uint16_tåã¨ãã¦ããï¼
+ */
+extern uint16_t	ready_primap;
+
+/*
+ *  ä½¿ç¨ãã¦ããªãTCBã®ãªã¹ã
+ */
+extern QUEUE	free_tcb;
+
+/*
+ *  ã¿ã¹ã¯IDã®æå¤§å¤ï¼kernel_cfg.cï¼
+ */
+extern const ID	tmax_tskid;
+extern const ID	tmax_stskid;
+
+/*
+ *  ã¿ã¹ã¯åæåãã­ãã¯ã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern const TINIB	tinib_table[];
+extern TINIB		atinib_table[];
+
+/*
+ *  ã¿ã¹ã¯çæé åºãã¼ãã«ï¼kernel_cfg.cï¼
+ */
+extern const ID	torder_table[];
+
+/*
+ *  TCBã®ã¨ãªã¢ï¼kernel_cfg.cï¼
+ */
+extern TCB	tcb_table[];
+
+/*
+ *  ã¿ã¹ã¯ã®æ°
+ */
+#define tnum_tsk	((uint_t)(tmax_tskid - TMIN_TSKID + 1))
+#define tnum_stsk	((uint_t)(tmax_stskid - TMIN_TSKID + 1))
+
+/*
+ *  ã¿ã¹ã¯IDããTCBãåãåºãããã®ãã¯ã­
+ */
+#define INDEX_TSK(tskid)	((uint_t)((tskid) - TMIN_TSKID))
+#define get_tcb(tskid)		(&(tcb_table[INDEX_TSK(tskid)]))
+
+/*
+ *  TCBããã¿ã¹ã¯IDãåãåºãããã®ãã¯ã­
+ */
+#define	TSKID(p_tcb)	((ID)(((p_tcb) - tcb_table) + TMIN_TSKID))
+
+/*
+ *  ã¿ã¹ã¯ç®¡çã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+extern void	initialize_task(void);
+
+/*
+ *  æé«åªå
+é ä½ã¿ã¹ã¯ã®ãµã¼ã
+ *
+ *  ã¬ãã£ã­ã¥ã¼ä¸­ã®æé«åªå
+é ä½ã®ã¿ã¹ã¯ããµã¼ããï¼ãã®TCBã¸ã®ãã¤ã³ã¿
+ *  ãè¿ãï¼ã¬ãã£ã­ã¥ã¼ãç©ºã®å ´åã«ã¯ï¼ãã®é¢æ°ãå¼ã³åºãã¦ã¯ãªããªãï¼
+ */
+extern TCB	*search_schedtsk(void);
+
+/*
+ *  å®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãã¬ãã£ã­ã¥ã¼ã«æ¿å
+¥ããï¼ã¬ãã£ã­ã¥ã¼ã«æ¿å
+¥
+ *  ããã¿ã¹ã¯ã®åªå
+åº¦ãï¼å®è¡ãã¹ãã¿ã¹ã¯ã®åªå
+åº¦ãããé«ãå ´åã¯ï¼å®
+ *  è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããï¼
+ */
+extern void	make_runnable(TCB *p_tcb);
+
+/*
+ *  å®è¡ã§ããç¶æ
+ããä»ã®ç¶æ
+ã¸ã®é·ç§»
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãã¬ãã£ã­ã¥ã¼ããåé¤ããï¼p_tcbã§æå®ãã
+ *  ã¿ã¹ã¯ãå®è¡ãã¹ãã¿ã¹ã¯ã§ãã£ãå ´åã«ã¯ï¼å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ã
+ *  ãï¼
+ */
+extern void	make_non_runnable(TCB *p_tcb);
+
+/*
+ *  ä¼æ­¢ç¶æ
+ã¸ã®é·ç§»
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®ç¶æ
+ãä¼æ­¢ç¶æ
+ã¨ããï¼ã¾ãï¼ã¿ã¹ã¯ã®èµ·å
+ *  æã«åæåãã¹ãå¤æ°ã®åæåã¨ï¼ã¿ã¹ã¯èµ·åã®ããã®ã³ã³ãã­ã¹ããè¨­
+ *  å®ããï¼
+ */
+extern void	make_dormant(TCB *p_tcb);
+
+/*
+ *  ä¼æ­¢ç¶æ
+ããå®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®ç¶æ
+ãä¼æ­¢ç¶æ
+ããå®è¡ã§ããç¶æ
+ã¨ããï¼
+ */
+extern void	make_active(TCB *p_tcb);
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+åº¦ã®å¤æ´
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®åªå
+åº¦ãnewpriï¼å
+é¨è¡¨ç¾ï¼ã«å¤æ´ããï¼ã¾ãï¼
+ *  å¿
+è¦ãªå ´åã«ã¯ï¼å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããï¼
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®åªå
+é ä½ã¯ï¼åªå
+åº¦ãåãã¿ã¹ã¯ã®ä¸­ã§ï¼
+ *  mtxmodeãfalseã®æã¯æä½ï¼mtxmodeãtrueã®æã¯æé«ã¨ããï¼
+ */
+extern void	change_priority(TCB *p_tcb, uint_t newpri, bool_t mtxmode);
+
+/*
+ *  ã¬ãã£ã­ã¥ã¼ã®åè»¢
+ *
+ *  ã¬ãã£ã­ã¥ã¼ä¸­ã®ï¼p_queueã§æå®ãããã¿ã¹ã¯ã­ã¥ã¼ãåè»¢ãããï¼ã¾ãï¼
+ *  å¿
+è¦ãªå ´åã«ã¯ï¼å®è¡ãã¹ãã¿ã¹ã¯ãæ´æ°ããï¼
+ */
+extern void	rotate_ready_queue(QUEUE *p_queue);
+
+/*
+ *  ã¿ã¹ã¯ã®çµäºå¦ç
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãçµäºãããå¦çãè¡ãï¼ã¿ã¹ã¯ã®èµ·åè¦æ±ã­ã¥ã¼
+ *  ã¤ã³ã°æ°ã0ã§ãªãå ´åã«ã¯ï¼ååº¦èµ·åããããã®å¦çãè¡ãï¼
+ */
+extern void	task_terminate(TCB *p_tcb);
+
+#endif /* TOPPERS_TASK_H */
Index: asp3_gr_sakura/trunk/kernel/task.trb
===================================================================
--- asp3_gr_sakura/trunk/kernel/task.trb	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task.trb	(revision 317)
@@ -0,0 +1,135 @@
+# -*- coding: utf-8 -*-
+#
+#   TOPPERS/ASP Kernel
+#       Toyohashi Open Platform for Embedded Real-Time Systems/
+#       Advanced Standard Profile Kernel
+# 
+#   Copyright (C) 2015 by FUJI SOFT INCORPORATED, JAPAN
+#   Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+#               Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   $Id: task.trb 668 2016-03-03 13:57:53Z ertl-hiro $
+# 
+
+#
+#		ã¿ã¹ã¯ç®¡çã¢ã¸ã¥ã¼ã«ã®çæã¹ã¯ãªãã
+#
+
+class TaskObject < KernelObject
+  def initialize()
+    super("tsk", "task", "t")
+  end
+
+  def prepare(key, params)
+    # ãã©ã¡ã¼ã¿ãçç¥ãããæã®ããã©ã«ãå¤ã®è¨­å®
+    params[:stk] ||= "NULL"
+
+    # tskatrãç¡å¹ã®å ´åï¼E_RSATRï¼ï¼»NGKI1028ï¼½
+    #ï¼TA_ACTï¼TA_NOACTQUEï¼TARGET_TSKATRä»¥å¤ã®ããããã»ããããã¦ããå ´åï¼
+    if (params[:tskatr] & ~($TA_ACT|$TA_NOACTQUE|$TARGET_TSKATR)) != 0
+      error_illegal_id("E_RSATR", params, :tskatr, :tskid)
+    end
+
+    # (TMIN_TPRI <= itskpri && itskpri <= TMAX_TPRI)ã§ãªãå ´åï¼»NGKI1034ï¼½
+    if !($TMIN_TPRI <= params[:itskpri] && params[:itskpri] <= $TMAX_TPRI)
+      error_illegal_id("E_PAR", params, :itskpri, :tskid)
+    end
+
+    # stkszãã¿ã¼ã²ããå®ç¾©ã®æå°å¤ï¼TARGET_MIN_STKSZï¼æªå®ç¾©ã®å ´åã¯1ï¼
+    # ãããå°ããå ´åï¼»NGKI1042ï¼½
+    if params[:stksz] < $TARGET_MIN_STKSZ
+      error_wrong_id("E_PAR", params, :stksz, :tskid, "too small")
+    end
+
+    # ã¹ã¿ãã¯é åã®è¨­å®ï¼»NGKI1041ï¼½
+    if params[:stk] == "NULL"
+      # ã¹ã¿ãã¯é åã®çæï¼»NGKI1049ï¼½
+      stkName = "_kernel_stack_#{params[:tskid]}"
+      params[:tinib_stksz] = AllocStack(stkName, params[:stksz])
+      params[:tinib_stk] = stkName
+    else
+      # stkszãã¹ã¿ãã¯é åã®ãµã¤ãºã¨ãã¦æ­£ãããªãå ´åï¼»NGKI1056ï¼½
+      if (params[:stksz] & ($CHECK_STKSZ_ALIGN - 1)) != 0
+        error_wrong_id("E_PAR", params, :stksz, :tskid, "not aligned")
+      end
+
+      params[:tinib_stksz] = params[:stksz]
+      params[:tinib_stk] = "(void *)(#{params[:stk]})"
+    end
+  end
+
+  def generateInib(key, params)
+    if $USE_TSKINICTXB
+      tskinictxb = GenerateTskinictxb(key, params)
+    else
+      tskinictxb = "#{params[:tinib_stksz]}, #{params[:tinib_stk]}"
+    end
+    return("(#{params[:tskatr]}), (intptr_t)(#{params[:exinf]}), " \
+			"(TASK)(#{params[:task]}), INT_PRIORITY(#{params[:itskpri]}), " \
+			+ tskinictxb)
+  end
+end
+
+#
+#  ã¿ã¹ã¯ç®¡çã«é¢ããæ
+å ±ã®çæ
+#
+$kernelCfgC.comment_header("Task Management Functions")
+if $cfgData[:CRE_TSK].size() == 0
+  error("no task is registered")
+end
+TaskObject.new.generate()
+
+# ã¿ã¹ã¯çæé åºãã¼ãã«ã®çæ
+$kernelCfgC.add("const ID _kernel_torder_table[TNUM_STSKID] = { ")
+$kernelCfgC.append("\t")
+$cfgData[:CRE_TSK].each_with_index do |(key, params), index|
+  $kernelCfgC.append(", ") if index > 0
+  $kernelCfgC.append("#{params[:tskid]}")
+end
+$kernelCfgC.add
+$kernelCfgC.add2("};")
Index: asp3_gr_sakura/trunk/kernel/task_manage.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/task_manage.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task_manage.c	(revision 317)
@@ -0,0 +1,553 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯ç®¡çæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "taskhook.h"
+#include "wait.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_ACRE_TSK_ENTER
+#define LOG_ACRE_TSK_ENTER(pk_ctsk)
+#endif /* LOG_ACRE_TSK_ENTER */
+
+#ifndef LOG_ACRE_TSK_LEAVE
+#define LOG_ACRE_TSK_LEAVE(ercd)
+#endif /* LOG_ACRE_TSK_LEAVE */
+
+#ifndef LOG_DEL_TSK_ENTER
+#define LOG_DEL_TSK_ENTER(tskid)
+#endif /* LOG_DEL_TSK_ENTER */
+
+#ifndef LOG_DEL_TSK_LEAVE
+#define LOG_DEL_TSK_LEAVE(ercd)
+#endif /* LOG_DEL_TSK_LEAVE */
+
+#ifndef LOG_ACT_TSK_ENTER
+#define LOG_ACT_TSK_ENTER(tskid)
+#endif /* LOG_ACT_TSK_ENTER */
+
+#ifndef LOG_ACT_TSK_LEAVE
+#define LOG_ACT_TSK_LEAVE(ercd)
+#endif /* LOG_ACT_TSK_LEAVE */
+
+#ifndef LOG_CAN_ACT_ENTER
+#define LOG_CAN_ACT_ENTER(tskid)
+#endif /* LOG_CAN_ACT_ENTER */
+
+#ifndef LOG_CAN_ACT_LEAVE
+#define LOG_CAN_ACT_LEAVE(ercd)
+#endif /* LOG_CAN_ACT_LEAVE */
+
+#ifndef LOG_GET_TST_ENTER
+#define LOG_GET_TST_ENTER(tskid, p_tskstat)
+#endif /* LOG_GET_TST_ENTER */
+
+#ifndef LOG_GET_TST_LEAVE
+#define LOG_GET_TST_LEAVE(ercd, p_tskstat)
+#endif /* LOG_GET_TST_LEAVE */
+
+#ifndef LOG_CHG_PRI_ENTER
+#define LOG_CHG_PRI_ENTER(tskid, tskpri)
+#endif /* LOG_CHG_PRI_ENTER */
+
+#ifndef LOG_CHG_PRI_LEAVE
+#define LOG_CHG_PRI_LEAVE(ercd)
+#endif /* LOG_CHG_PRI_LEAVE */
+
+#ifndef LOG_GET_PRI_ENTER
+#define LOG_GET_PRI_ENTER(tskid, p_tskpri)
+#endif /* LOG_GET_PRI_ENTER */
+
+#ifndef LOG_GET_PRI_LEAVE
+#define LOG_GET_PRI_LEAVE(ercd, p_tskpri)
+#endif /* LOG_GET_PRI_LEAVE */
+
+#ifndef LOG_GET_INF_ENTER
+#define LOG_GET_INF_ENTER(p_exinf)
+#endif /* LOG_GET_INF_ENTER */
+
+#ifndef LOG_GET_INF_LEAVE
+#define LOG_GET_INF_LEAVE(ercd, p_exinf)
+#endif /* LOG_GET_INF_LEAVE */
+
+/*
+ *  ã¿ã¹ã¯ã®çæ
+ *
+ *  pk_ctsk->exinfã¯ï¼ã¨ã©ã¼ãã§ãã¯ãããï¼ä¸åº¦ããåç
+§ããªãããï¼ã­ã¼
+ *  ã«ã«å¤æ°ã«ã³ãã¼ããå¿
+è¦ããªãï¼éä¸­ã§æ¸ãæãã£ã¦ãæ¯éããªãï¼ï¼
+ */
+#ifdef TOPPERS_acre_tsk
+
+#ifndef TARGET_MIN_STKSZ
+#define TARGET_MIN_STKSZ	1U		/* æªå®ç¾©ã®å ´åã¯0ã§ãªããã¨ããã§ãã¯ */
+#endif /* TARGET_MIN_STKSZ */
+
+ER_UINT
+acre_tsk(const T_CTSK *pk_ctsk)
+{
+	TCB		*p_tcb;
+	TINIB	*p_tinib;
+	ATR		tskatr;
+	TASK	task;
+	PRI		itskpri;
+	size_t	stksz;
+	STK_T	*stk;
+	ER		ercd;
+
+	LOG_ACRE_TSK_ENTER(pk_ctsk);
+	CHECK_TSKCTX_UNL();
+
+	tskatr = pk_ctsk->tskatr;
+	task = pk_ctsk->task;
+	itskpri = pk_ctsk->itskpri;
+	stksz = pk_ctsk->stksz;
+	stk = pk_ctsk->stk;
+
+	CHECK_RSATR(tskatr, TA_ACT|TA_NOACTQUE|TARGET_TSKATR);
+	CHECK_PAR(FUNC_ALIGN(task));
+	CHECK_PAR(FUNC_NONNULL(task));
+	CHECK_PAR(VALID_TPRI(itskpri));
+	CHECK_PAR(stksz >= TARGET_MIN_STKSZ);
+	if (stk != NULL) {
+		CHECK_PAR(STKSZ_ALIGN(stksz));
+		CHECK_PAR(STACK_ALIGN(stk));
+	}
+
+	lock_cpu();
+	if (queue_empty(&free_tcb)) {
+		ercd = E_NOID;
+	}
+	else {
+		if (stk == NULL) {
+			stksz = ROUND_STK_T(stksz);
+			stk = kernel_malloc(stksz);
+			tskatr |= TA_MEMALLOC;
+		}
+		if (stk == NULL) {
+			ercd = E_NOMEM;
+		}
+		else {
+			p_tcb = ((TCB *) queue_delete_next(&free_tcb));
+			p_tinib = (TINIB *)(p_tcb->p_tinib);
+			p_tinib->tskatr = tskatr;
+			p_tinib->exinf = pk_ctsk->exinf;
+			p_tinib->task = task;
+			p_tinib->ipriority = INT_PRIORITY(itskpri);
+#ifdef USE_TSKINICTXB
+			init_tskinictxb(&(p_tinib->tskinictxb), stksz, stk);
+#else /* USE_TSKINICTXB */
+			p_tinib->stksz = stksz;
+			p_tinib->stk = stk;
+#endif /* USE_TSKINICTXB */
+
+			p_tcb->actque = false;
+			make_dormant(p_tcb);
+			if ((p_tcb->p_tinib->tskatr & TA_ACT) != 0U) {
+				make_active(p_tcb);
+				if (p_runtsk != p_schedtsk) {
+					dispatch();
+				}
+			}
+			ercd = TSKID(p_tcb);
+		}
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACRE_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_acre_tsk */
+
+/*
+ *  ã¿ã¹ã¯ã®åé¤ï¼»NGKI1100ï¼½
+ */
+#ifdef TOPPERS_del_tsk
+
+ER
+del_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	TINIB	*p_tinib;
+	ER		ercd;
+
+	LOG_DEL_TSK_ENTER(tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1101ï¼½ï¼»NGKI1102ï¼½*/
+	CHECK_ID(VALID_TSKID(tskid));				/*ï¼»NGKI1103ï¼½*/
+	p_tcb = get_tcb(tskid);
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1104ï¼½*/
+	}
+	else if (tskid <= tmax_stskid || !TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI1106ï¼½ï¼»NGKI1107ï¼½*/
+	}
+	else {
+		p_tinib = (TINIB *)(p_tcb->p_tinib);
+#ifdef USE_TSKINICTXB
+		term_tskinictxb(&(p_tinib->tskinictxb));
+#else /* USE_TSKINICTXB */
+		if ((p_tinib->tskatr & TA_MEMALLOC) != 0U) {	/*ï¼»NGKI1109ï¼½*/
+			kernel_free(p_tinib->stk);
+		}
+#endif /* USE_TSKINICTXB */
+		p_tinib->tskatr = TA_NOEXS;				/*ï¼»NGKI1108ï¼½*/
+		queue_insert_prev(&free_tcb, &(p_tcb->task_queue));
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_DEL_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_del_tsk */
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·åï¼»NGKI3529ï¼½
+ */
+#ifdef TOPPERS_act_tsk
+
+ER
+act_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_ACT_TSK_ENTER(tskid);
+	CHECK_UNL();								/*ï¼»NGKI1114ï¼½*/
+	if (tskid == TSK_SELF && !sense_context()) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI1121ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI1115ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1116ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		make_active(p_tcb);						/*ï¼»NGKI1118ï¼½*/
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	else if ((p_tcb->p_tinib->tskatr & TA_NOACTQUE) != 0U || p_tcb->actque) {
+		ercd = E_QOVR;			   				/*ï¼»NGKI3528ï¼½*/
+	}
+	else {
+		p_tcb->actque = true;					/*ï¼»NGKI3527ï¼½*/
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ACT_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_act_tsk */
+
+/*
+ *  ã¿ã¹ã¯èµ·åè¦æ±ã®ã­ã£ã³ã»ã«ï¼»NGKI1138ï¼½
+ */
+#ifdef TOPPERS_can_act
+
+ER_UINT
+can_act(ID tskid)
+{
+	TCB		*p_tcb;
+	ER_UINT	ercd;
+
+	LOG_CAN_ACT_ENTER(tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1139ï¼½ï¼»NGKI1140ï¼½*/
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI1146ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI1141ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1142ï¼½*/
+	}
+	else {
+		ercd = p_tcb->actque ? 1 : 0;			/*ï¼»NGKI1144ï¼½*/
+		p_tcb->actque = false;					/*ï¼»NGKI1144ï¼½*/
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_CAN_ACT_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_can_act */
+
+/*
+ *  ã¿ã¹ã¯ç¶æ
+ã®åç
+§ï¼»NGKI3613ï¼½
+ */
+#ifdef TOPPERS_get_tst
+
+ER
+get_tst(ID tskid, STAT *p_tskstat)
+{
+	TCB		*p_tcb;
+	uint_t	tstat;
+	ER		ercd;
+
+	LOG_GET_TST_ENTER(tskid, p_tskstat);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3614ï¼½ï¼»NGKI3615ï¼½*/
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI3621ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI3616ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	tstat = p_tcb->tstat;
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI3617ï¼½*/
+	}
+	else {
+		if (TSTAT_DORMANT(tstat)) {				/*ï¼»NGKI3620ï¼½*/
+			*p_tskstat = TTS_DMT;
+		}
+		else if (TSTAT_SUSPENDED(tstat)) {
+			if (TSTAT_WAITING(tstat)) {
+				*p_tskstat = TTS_WAS;
+			}
+			else {
+				*p_tskstat = TTS_SUS;
+			}
+		}
+		else if (TSTAT_WAITING(tstat)) {
+			*p_tskstat = TTS_WAI;
+		}
+		else if (p_tcb == p_runtsk) {
+			*p_tskstat = TTS_RUN;
+		}
+		else {
+			*p_tskstat = TTS_RDY;
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_TST_LEAVE(ercd, p_tskstat);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_tst */
+
+/*
+ *  ã¿ã¹ã¯ã®ãã¼ã¹åªå
+åº¦ã®å¤æ´ï¼»NGKI1183ï¼½
+ */
+#ifdef TOPPERS_chg_pri
+
+ER
+chg_pri(ID tskid, PRI tskpri)
+{
+	TCB		*p_tcb;
+	uint_t	newbpri;
+	ER		ercd;
+
+	LOG_CHG_PRI_ENTER(tskid, tskpri);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1184ï¼½ï¼»NGKI1185ï¼½*/
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI1198ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI1187ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+	if (tskpri == TPRI_INI) {
+		newbpri = p_tcb->p_tinib->ipriority;	/*ï¼»NGKI1199ï¼½*/
+	}
+	else {
+		CHECK_PAR(VALID_TPRI(tskpri));			/*ï¼»NGKI1188ï¼½*/
+		newbpri = INT_PRIORITY(tskpri);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1189ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI1191ï¼½*/
+	}
+	else if ((p_tcb->p_lastmtx != NULL || TSTAT_WAIT_MTX(p_tcb->tstat))
+						&& !((*mtxhook_check_ceilpri)(p_tcb, newbpri))) {
+		ercd = E_ILUSE;							/*ï¼»NGKI1201ï¼½*/
+	}
+	else {
+		p_tcb->bpriority = newbpri;				/*ï¼»NGKI1192ï¼½*/
+		if (p_tcb->p_lastmtx == NULL || !((*mtxhook_scan_ceilmtx)(p_tcb))) {
+			change_priority(p_tcb, newbpri, false);		/*ï¼»NGKI1193ï¼½*/
+			if (p_runtsk != p_schedtsk) {
+				dispatch();
+			}									/*ï¼»NGKI1197ï¼½*/
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_CHG_PRI_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_chg_pri */
+
+/*
+ *  ã¿ã¹ã¯åªå
+åº¦ã®åç
+§ï¼»NGKI1202ï¼½
+ */
+#ifdef TOPPERS_get_pri
+
+ER
+get_pri(ID tskid, PRI *p_tskpri)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_GET_PRI_ENTER(tskid, p_tskpri);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1203ï¼½ï¼»NGKI1204ï¼½*/
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI1211ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI1205ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1206ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI1209ï¼½*/
+	}
+	else {
+		*p_tskpri = EXT_TSKPRI(p_tcb->priority);	/*ï¼»NGKI1210ï¼½*/
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_PRI_LEAVE(ercd, p_tskpri);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_pri */
+
+/*
+ *  èªã¿ã¹ã¯ã®æ¡å¼µæ
+å ±ã®åç
+§ï¼»NGKI1212ï¼½
+ */
+#ifdef TOPPERS_get_inf
+
+ER
+get_inf(intptr_t *p_exinf)
+{
+	ER		ercd;
+
+	LOG_GET_INF_ENTER(p_exinf);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1213ï¼½ï¼»NGKI1214ï¼½*/
+
+	lock_cpu();
+	*p_exinf = p_runtsk->p_tinib->exinf;		/*ï¼»NGKI1216ï¼½*/
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_INF_LEAVE(ercd, p_exinf);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_inf */
Index: asp3_gr_sakura/trunk/kernel/task_refer.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/task_refer.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task_refer.c	(revision 317)
@@ -0,0 +1,251 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯ã®ç¶æ
+åç
+§æ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "semaphore.h"
+#include "eventflag.h"
+#include "dataqueue.h"
+#include "pridataq.h"
+#include "mutex.h"
+#include "mempfix.h"
+#include "time_event.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_REF_TSK_ENTER
+#define LOG_REF_TSK_ENTER(tskid, pk_rtsk)
+#endif /* LOG_REF_TSK_ENTER */
+
+#ifndef LOG_REF_TSK_LEAVE
+#define LOG_REF_TSK_LEAVE(ercd, pk_rtsk)
+#endif /* LOG_REF_TSK_LEAVE */
+
+/*
+ *  ã¿ã¹ã¯ã®ç¶æ
+åç
+§
+ */
+#ifdef TOPPERS_ref_tsk
+
+ER
+ref_tsk(ID tskid, T_RTSK *pk_rtsk)
+{
+	TCB		*p_tcb;
+	uint_t	tstat;
+	ER		ercd;
+
+	LOG_REF_TSK_ENTER(tskid, pk_rtsk);
+	CHECK_TSKCTX_UNL();
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else {
+		tstat = p_tcb->tstat;
+		if (TSTAT_DORMANT(tstat)) {
+			/*
+	 		 *  å¯¾è±¡ã¿ã¹ã¯ãä¼æ­¢ç¶æ
+ã®å ´å
+			 */
+			pk_rtsk->tskstat = TTS_DMT;
+		}
+		else {
+			/*
+	 		 *  ã¿ã¹ã¯ç¶æ
+ã®ååºã
+			 */
+			if (TSTAT_SUSPENDED(tstat)) {
+				if (TSTAT_WAITING(tstat)) {
+					pk_rtsk->tskstat = TTS_WAS;
+				}
+				else {
+					pk_rtsk->tskstat = TTS_SUS;
+				}
+			}
+			else if (TSTAT_WAITING(tstat)) {
+				pk_rtsk->tskstat = TTS_WAI;
+			}
+			else if (p_tcb == p_runtsk) {
+				pk_rtsk->tskstat = TTS_RUN;
+			}
+			else {
+				pk_rtsk->tskstat = TTS_RDY;
+			}
+
+			/*
+	 		 *  ç¾å¨åªå
+åº¦ã¨ãã¼ã¹åªå
+åº¦ã®ååºã
+			 */
+			pk_rtsk->tskpri = EXT_TSKPRI(p_tcb->priority);
+			pk_rtsk->tskbpri = EXT_TSKPRI(p_tcb->bpriority);
+
+			if (TSTAT_WAITING(tstat)) {
+				/*
+		 		 *  å¾
+ã¡è¦å ã¨å¾
+ã¡å¯¾è±¡ã®ãªãã¸ã§ã¯ãã®IDã®ååºã
+				 */
+				switch (tstat) {
+				case TS_WAITING_SLP:
+					pk_rtsk->tskwait = TTW_SLP;
+					break;
+				case TS_WAITING_DLY:
+					pk_rtsk->tskwait = TTW_DLY;
+					break;
+				case TS_WAITING_SEM:
+					pk_rtsk->tskwait = TTW_SEM;
+					pk_rtsk->wobjid = SEMID(((WINFO_SEM *)(p_tcb->p_winfo))
+																->p_semcb);
+					break;
+				case TS_WAITING_FLG:
+					pk_rtsk->tskwait = TTW_FLG;
+					pk_rtsk->wobjid = FLGID(((WINFO_FLG *)(p_tcb->p_winfo))
+																->p_flgcb);
+					break;
+				case TS_WAITING_SDTQ:
+					pk_rtsk->tskwait = TTW_SDTQ;
+					pk_rtsk->wobjid = DTQID(((WINFO_SDTQ *)(p_tcb->p_winfo))
+																->p_dtqcb);
+					break;
+				case TS_WAITING_RDTQ:
+					pk_rtsk->tskwait = TTW_RDTQ;
+					pk_rtsk->wobjid = DTQID(((WINFO_RDTQ *)(p_tcb->p_winfo))
+																->p_dtqcb);
+					break;
+				case TS_WAITING_SPDQ:
+					pk_rtsk->tskwait = TTW_SPDQ;
+					pk_rtsk->wobjid = PDQID(((WINFO_SPDQ *)(p_tcb->p_winfo))
+																->p_pdqcb);
+					break;
+				case TS_WAITING_RPDQ:
+					pk_rtsk->tskwait = TTW_RPDQ;
+					pk_rtsk->wobjid = PDQID(((WINFO_RPDQ *)(p_tcb->p_winfo))
+																->p_pdqcb);
+					break;
+				case TS_WAITING_MTX:
+					pk_rtsk->tskwait = TTW_MTX;
+					pk_rtsk->wobjid = MTXID(((WINFO_MTX *)(p_tcb->p_winfo))
+																->p_mtxcb);
+					break;
+				case TS_WAITING_MPF:
+					pk_rtsk->tskwait = TTW_MPF;
+					pk_rtsk->wobjid = MPFID(((WINFO_MPF *)(p_tcb->p_winfo))
+																->p_mpfcb);
+					break;
+				}
+
+				/*
+		 		 *  ã¿ã¤ã ã¢ã¦ãããã¾ã§ã®æéã®ååºã
+				 */
+				if (p_tcb->p_winfo->p_tmevtb != NULL) {
+					pk_rtsk->lefttmo
+							= (TMO) tmevt_lefttim(p_tcb->p_winfo->p_tmevtb);
+				}
+				else {
+					pk_rtsk->lefttmo = TMO_FEVR;
+				}
+			}
+
+			/*
+	 		 *  èµ·åºè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®ååºã
+			 */
+			pk_rtsk->wupcnt = p_tcb->wupque ? 1U : 0U;
+
+			/*
+			 *  ã¿ã¹ã¯çµäºè¦æ±ç¶æ
+ã®ååºã
+			 */
+			pk_rtsk->raster = p_tcb->raster;
+
+			/*
+			 *  ã¿ã¹ã¯çµäºç¦æ­¢ç¶æ
+ã®ååºã
+			 */
+			pk_rtsk->dister = !(p_tcb->enater);
+		}
+
+		/*
+		 *  èµ·åè¦æ±ã­ã¥ã¼ã¤ã³ã°æ°ã®ååºã
+		 */
+		pk_rtsk->actcnt = p_tcb->actque ? 1U : 0U;
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REF_TSK_LEAVE(ercd, pk_rtsk);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ref_tsk */
Index: asp3_gr_sakura/trunk/kernel/task_sync.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/task_sync.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task_sync.c	(revision 317)
@@ -0,0 +1,539 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯ä»å±åææ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_SLP_TSK_ENTER
+#define LOG_SLP_TSK_ENTER()
+#endif /* LOG_SLP_TSK_ENTER */
+
+#ifndef LOG_SLP_TSK_LEAVE
+#define LOG_SLP_TSK_LEAVE(ercd)
+#endif /* LOG_SLP_TSK_LEAVE */
+
+#ifndef LOG_TSLP_TSK_ENTER
+#define LOG_TSLP_TSK_ENTER(tmout)
+#endif /* LOG_TSLP_TSK_ENTER */
+
+#ifndef LOG_TSLP_TSK_LEAVE
+#define LOG_TSLP_TSK_LEAVE(ercd)
+#endif /* LOG_TSLP_TSK_LEAVE */
+
+#ifndef LOG_WUP_TSK_ENTER
+#define LOG_WUP_TSK_ENTER(tskid)
+#endif /* LOG_WUP_TSK_ENTER */
+
+#ifndef LOG_WUP_TSK_LEAVE
+#define LOG_WUP_TSK_LEAVE(ercd)
+#endif /* LOG_WUP_TSK_LEAVE */
+
+#ifndef LOG_CAN_WUP_ENTER
+#define LOG_CAN_WUP_ENTER(tskid)
+#endif /* LOG_CAN_WUP_ENTER */
+
+#ifndef LOG_CAN_WUP_LEAVE
+#define LOG_CAN_WUP_LEAVE(ercd)
+#endif /* LOG_CAN_WUP_LEAVE */
+
+#ifndef LOG_REL_WAI_ENTER
+#define LOG_REL_WAI_ENTER(tskid)
+#endif /* LOG_REL_WAI_ENTER */
+
+#ifndef LOG_REL_WAI_LEAVE
+#define LOG_REL_WAI_LEAVE(ercd)
+#endif /* LOG_REL_WAI_LEAVE */
+
+#ifndef LOG_SUS_TSK_ENTER
+#define LOG_SUS_TSK_ENTER(tskid)
+#endif /* LOG_SUS_TSK_ENTER */
+
+#ifndef LOG_SUS_TSK_LEAVE
+#define LOG_SUS_TSK_LEAVE(ercd)
+#endif /* LOG_SUS_TSK_LEAVE */
+
+#ifndef LOG_RSM_TSK_ENTER
+#define LOG_RSM_TSK_ENTER(tskid)
+#endif /* LOG_RSM_TSK_ENTER */
+
+#ifndef LOG_RSM_TSK_LEAVE
+#define LOG_RSM_TSK_LEAVE(ercd)
+#endif /* LOG_RSM_TSK_LEAVE */
+
+#ifndef LOG_DLY_TSK_ENTER
+#define LOG_DLY_TSK_ENTER(dlytim)
+#endif /* LOG_DLY_TSK_ENTER */
+
+#ifndef LOG_DLY_TSK_LEAVE
+#define LOG_DLY_TSK_LEAVE(ercd)
+#endif /* LOG_DLY_TSK_LEAVE */
+
+/*
+ *  èµ·åºå¾
+ã¡
+ */
+#ifdef TOPPERS_slp_tsk
+
+ER
+slp_tsk(void)
+{
+	WINFO	winfo;
+	ER		ercd;
+
+	LOG_SLP_TSK_ENTER();
+	CHECK_DISPATCH();
+
+	lock_cpu_dsp();
+	if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_runtsk->wupque) {
+		p_runtsk->wupque = false;
+		ercd = E_OK;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_SLP;
+		make_wait(&winfo);
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_SLP_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_slp_tsk */
+
+/*
+ *  èµ·åºå¾
+ã¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+#ifdef TOPPERS_tslp_tsk
+
+ER
+tslp_tsk(TMO tmout)
+{
+	WINFO	winfo;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_TSLP_TSK_ENTER(tmout);
+	CHECK_DISPATCH();
+	CHECK_PAR(VALID_TMOUT(tmout));
+
+	lock_cpu_dsp();
+	if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else if (p_runtsk->wupque) {
+		p_runtsk->wupque = false;
+		ercd = E_OK;
+	}
+	else if (tmout == TMO_POL) {
+		ercd = E_TMOUT;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_SLP;
+		make_wait_tmout(&winfo, &tmevtb, tmout);
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_TSLP_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_tslp_tsk */
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·åº
+ */
+#ifdef TOPPERS_wup_tsk
+
+ER
+wup_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_WUP_TSK_ENTER(tskid);
+	CHECK_UNL();
+	if (tskid == TSK_SELF && !sense_context()) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;
+	}
+	else if (TSTAT_WAIT_SLP(p_tcb->tstat)) {
+		wait_complete(p_tcb);
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	else if (!(p_tcb->wupque)) {
+		p_tcb->wupque = true;
+		ercd = E_OK;
+	}
+	else {
+		ercd = E_QOVR;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_WUP_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_wup_tsk */
+
+/*
+ *  ã¿ã¹ã¯èµ·åºè¦æ±ã®ã­ã£ã³ã»ã«
+ */
+#ifdef TOPPERS_can_wup
+
+ER_UINT
+can_wup(ID tskid)
+{
+	TCB		*p_tcb;
+	ER_UINT	ercd;
+
+	LOG_CAN_WUP_ENTER(tskid);
+	CHECK_TSKCTX_UNL();
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;
+	}
+	else {
+		ercd = p_tcb->wupque ? 1 : 0;
+		p_tcb->wupque = false;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_CAN_WUP_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_can_wup */
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã®å¼·å¶è§£é¤
+ */
+#ifdef TOPPERS_rel_wai
+
+ER
+rel_wai(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_REL_WAI_ENTER(tskid);
+	CHECK_UNL();
+	CHECK_ID(VALID_TSKID(tskid));
+	p_tcb = get_tcb(tskid);
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (!TSTAT_WAITING(p_tcb->tstat)) {
+		ercd = E_OBJ;
+	}
+	else {
+		wait_dequeue_wobj(p_tcb);
+		wait_dequeue_tmevtb(p_tcb);
+		p_tcb->p_winfo->wercd = E_RLWAI;
+		make_non_wait(p_tcb);
+		if (p_runtsk != p_schedtsk) {
+			if (!sense_context()) {
+				dispatch();
+			}
+			else {
+				request_dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_REL_WAI_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rel_wai */
+
+/*
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ã¸ã®ç§»è¡ï¼»NGKI1298ï¼½
+ */
+#ifdef TOPPERS_sus_tsk
+
+ER
+sus_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_SUS_TSK_ENTER(tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1299ï¼½ï¼»NGKI1300ï¼½*/
+	if (tskid == TSK_SELF) {
+		p_tcb = p_runtsk;						/*ï¼»NGKI1310ï¼½*/
+	}
+	else {
+		CHECK_ID(VALID_TSKID(tskid));			/*ï¼»NGKI1302ï¼½*/
+		p_tcb = get_tcb(tskid);
+	}
+
+	lock_cpu();
+	if (p_tcb == p_runtsk && !dspflg) {			/*ï¼»NGKI1311ï¼½ï¼»NGKI3604ï¼½*/
+		ercd = E_CTX;
+	}
+	else if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1303ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI1305ï¼½*/
+	}
+	else if (p_tcb->raster) {
+		ercd = E_RASTER;						/*ï¼»NGKI3605ï¼½*/
+	}
+	else if (TSTAT_RUNNABLE(p_tcb->tstat)) {
+		/*
+		 *  å®è¡ã§ããç¶æ
+ããå¼·å¶å¾
+ã¡ç¶æ
+ã¸ã®é·ç§»ï¼»NGKI1307ï¼½
+		 */
+		p_tcb->tstat = TS_SUSPENDED;
+		LOG_TSKSTAT(p_tcb);
+		make_non_runnable(p_tcb);
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else if (TSTAT_SUSPENDED(p_tcb->tstat)) {
+		ercd = E_QOVR;							/*ï¼»NGKI1306ï¼½*/
+	}
+	else {
+		/*
+		 *  å¾
+ã¡ç¶æ
+ããäºéå¾
+ã¡ç¶æ
+ã¸ã®é·ç§»ï¼»NGKI1308ï¼½
+		 */
+		p_tcb->tstat |= TS_SUSPENDED;
+		LOG_TSKSTAT(p_tcb);
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_SUS_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_sus_tsk */
+
+/*
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ããã®åé
+ */
+#ifdef TOPPERS_rsm_tsk
+
+ER
+rsm_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_RSM_TSK_ENTER(tskid);
+	CHECK_TSKCTX_UNL();
+	CHECK_ID(VALID_TSKID(tskid));
+	p_tcb = get_tcb(tskid);
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;
+	}
+	else if (!TSTAT_SUSPENDED(p_tcb->tstat)) {
+		ercd = E_OBJ;
+	}
+	else if (!TSTAT_WAITING(p_tcb->tstat)) {
+		/*
+		 *  å¼·å¶å¾
+ã¡ç¶æ
+ããå®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+		 */
+		p_tcb->tstat = TS_RUNNABLE;
+		LOG_TSKSTAT(p_tcb);
+		make_runnable(p_tcb);
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		/*
+		 *  äºéå¾
+ã¡ç¶æ
+ããå¾
+ã¡ç¶æ
+ã¸ã®é·ç§»
+		 */
+		p_tcb->tstat &= ~TS_SUSPENDED;
+		LOG_TSKSTAT(p_tcb);
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_RSM_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_rsm_tsk */
+
+/*
+ *  èªã¿ã¹ã¯ã®é
+å»¶
+ */
+#ifdef TOPPERS_dly_tsk
+
+ER
+dly_tsk(RELTIM dlytim)
+{
+	WINFO	winfo;
+	TMEVTB	tmevtb;
+	ER		ercd;
+
+	LOG_DLY_TSK_ENTER(dlytim);
+	CHECK_DISPATCH();
+	CHECK_PAR(VALID_RELTIM(dlytim));
+
+	lock_cpu_dsp();
+	if (p_runtsk->raster) {
+		ercd = E_RASTER;
+	}
+	else {
+		p_runtsk->tstat = TS_WAITING_DLY;
+		make_non_runnable(p_runtsk);
+		p_runtsk->p_winfo = &winfo;
+		winfo.p_tmevtb = &tmevtb;
+		tmevtb.callback = (CBACK) wait_tmout_ok;
+		tmevtb.arg = (void *) p_runtsk;
+		tmevtb_enqueue(&tmevtb, dlytim);
+		LOG_TSKSTAT(p_runtsk);
+		dispatch();
+		ercd = winfo.wercd;
+	}
+	unlock_cpu_dsp();
+
+  error_exit:
+	LOG_DLY_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_dly_tsk */
Index: asp3_gr_sakura/trunk/kernel/task_term.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/task_term.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/task_term.c	(revision 317)
@@ -0,0 +1,372 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¹ã¯çµäºæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "wait.h"
+#include "overrun.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_EXT_TSK_ENTER
+#define LOG_EXT_TSK_ENTER()
+#endif /* LOG_EXT_TSK_ENTER */
+
+#ifndef LOG_EXT_TSK_LEAVE
+#define LOG_EXT_TSK_LEAVE(ercd)
+#endif /* LOG_EXT_TSK_LEAVE */
+
+#ifndef LOG_RAS_TER_ENTER
+#define LOG_RAS_TER_ENTER(tskid)
+#endif /* LOG_RAS_TER_ENTER */
+
+#ifndef LOG_RAS_TER_LEAVE
+#define LOG_RAS_TER_LEAVE(ercd)
+#endif /* LOG_RAS_TER_LEAVE */
+
+#ifndef LOG_DIS_TER_ENTER
+#define LOG_DIS_TER_ENTER()
+#endif /* LOG_DIS_TER_ENTER */
+
+#ifndef LOG_DIS_TER_LEAVE
+#define LOG_DIS_TER_LEAVE(ercd)
+#endif /* LOG_DIS_TER_LEAVE */
+
+#ifndef LOG_ENA_TER_ENTER
+#define LOG_ENA_TER_ENTER()
+#endif /* LOG_ENA_TER_ENTER */
+
+#ifndef LOG_ENA_TER_LEAVE
+#define LOG_ENA_TER_LEAVE(ercd)
+#endif /* LOG_ENA_TER_LEAVE */
+
+#ifndef LOG_SNS_TER_ENTER
+#define LOG_SNS_TER_ENTER()
+#endif /* LOG_SNS_TER_ENTER */
+
+#ifndef LOG_SNS_TER_LEAVE
+#define LOG_SNS_TER_LEAVE(state)
+#endif /* LOG_SNS_TER_LEAVE */
+
+#ifndef LOG_TER_TSK_ENTER
+#define LOG_TER_TSK_ENTER(tskid)
+#endif /* LOG_TER_TSK_ENTER */
+
+#ifndef LOG_TER_TSK_LEAVE
+#define LOG_TER_TSK_LEAVE(ercd)
+#endif /* LOG_TER_TSK_LEAVE */
+
+/*
+ *  èªã¿ã¹ã¯ã®çµäºï¼»NGKI1162ï¼½
+ */
+#ifdef TOPPERS_ext_tsk
+
+ER
+ext_tsk(void)
+{
+	PRI		intpri;
+	ER		ercd;
+
+	LOG_EXT_TSK_ENTER();
+	CHECK_TSKCTX();							/*ï¼»NGKI1164ï¼½*/
+
+	if (sense_lock()) {
+		/*
+		 *  CPUã­ãã¯ç¶æ
+ã§ext_tskãå¼ã°ããå ´åã¯ï¼CPUã­ãã¯ãè§£é¤ã
+		 *  ã¦ããã¿ã¹ã¯ãçµäºããï¼å®è£
+ä¸ã¯ï¼ãµã¼ãã¹ã³ã¼ã«å
+ã§ã®CPU
+		 *  ã­ãã¯ãçç¥ããã°ããã ãï¼ï¼»NGKI1168ï¼½
+		 */
+	}
+	else {
+		lock_cpu();
+	}
+
+	intpri = t_get_ipm();
+	if (!enadsp || intpri != TIPM_ENAALL) {
+		if (!enadsp) {
+			/*
+			 *  ãã£ã¹ãããç¦æ­¢ç¶æ
+ã§ext_tskãå¼ã°ããå ´åã¯ï¼ãã£ã¹ãã
+			 *  ãè¨±å¯ç¶æ
+ã«ãã¦ããã¿ã¹ã¯ãçµäºããï¼ï¼»NGKI1168ï¼½
+			 */
+			enadsp = true;
+		}
+		if (intpri != TIPM_ENAALL) {
+			/*
+			 *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ï¼IPMï¼ãTIPM_ENAALLä»¥å¤ã®ç¶æ
+ã§
+			 *  ext_tskãå¼ã°ããå ´åã¯ï¼IPMãTIPM_ENAALLã«ãã¦ããã¿ã¹
+			 *  ã¯ãçµäºããï¼ï¼»NGKI1168ï¼½
+			 */
+			t_set_ipm(TIPM_ENAALL);
+		}
+		dspflg = true;
+		p_schedtsk = search_schedtsk();
+	}
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	if (p_runtsk->staovr) {
+		(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+		ovrtimer_flag = false;
+	}
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+	task_terminate(p_runtsk);				/* ï¼»NGKI3449ï¼½*/
+	exit_and_dispatch();					/* ï¼»NGKI1169ï¼½*/
+	ercd = E_SYS;							/* ï¼»NGKI1163ï¼½*/
+
+  error_exit:
+	LOG_EXT_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ext_tsk */
+
+/*
+ *  ã¿ã¹ã¯ã®çµäºè¦æ±ï¼»NGKI3469ï¼½
+ */
+#ifdef TOPPERS_ras_ter
+
+ER
+ras_ter(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_RAS_TER_ENTER(tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3470ï¼½ï¼»NGKI3471ï¼½*/
+	CHECK_ID(VALID_TSKID(tskid));				/*ï¼»NGKI3472ï¼½*/
+	p_tcb = get_tcb(tskid);
+	CHECK_ILUSE(p_tcb != p_runtsk);				/*ï¼»NGKI3475ï¼½*/
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI3473ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI3476ï¼½*/
+	}
+	else if (p_tcb->enater) {
+		task_terminate(p_tcb);					/*ï¼»NGKI3477ï¼½*/
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	else {
+		p_tcb->raster = true;					/*ï¼»NGKI3478ï¼½*/
+		if (!TSTAT_RUNNABLE(p_tcb->tstat)) {
+			if (TSTAT_WAITING(p_tcb->tstat)) {
+				wait_dequeue_wobj(p_tcb);		/*ï¼»NGKI3479ï¼½*/
+				wait_dequeue_tmevtb(p_tcb);
+				p_tcb->p_winfo->wercd = E_RASTER;	/*ï¼»NGKI3480ï¼½*/
+			}
+			p_tcb->tstat = TS_RUNNABLE;			/*ï¼»NGKI3606ï¼½*/
+			LOG_TSKSTAT(p_tcb);
+			make_runnable(p_tcb);
+			if (p_runtsk != p_schedtsk) {
+				dispatch();
+			}
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_RAS_TER_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ras_ter */
+
+/*
+ *  ã¿ã¹ã¯çµäºã®ç¦æ­¢ï¼»NGKI3482ï¼½
+ */
+#ifdef TOPPERS_dis_ter
+
+ER
+dis_ter(void)
+{
+	ER		ercd;
+
+	LOG_DIS_TER_ENTER();
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3483ï¼½ï¼»NGKI3484ï¼½*/
+
+	lock_cpu();
+	p_runtsk->enater = false;					/*ï¼»NGKI3486ï¼½*/
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_DIS_TER_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_dis_ter */
+
+/*
+ *  ã¿ã¹ã¯çµäºã®è¨±å¯ï¼»NGKI3487ï¼½
+ */
+#ifdef TOPPERS_ena_ter
+
+ER
+ena_ter(void)
+{
+	ER		ercd;
+
+	LOG_ENA_TER_ENTER();
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3488ï¼½ï¼»NGKI3489ï¼½*/
+
+	lock_cpu();
+	if (p_runtsk->raster && dspflg) {
+#ifdef TOPPERS_SUPPORT_OVRHDR
+		if (p_runtsk->staovr) {
+			(void) target_ovrtimer_stop(INTNO_DUMMY_TIMER);
+			ovrtimer_flag = false;
+		}
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+		task_terminate(p_runtsk);
+		exit_and_dispatch();
+		ercd = E_SYS;
+	}
+	else {
+		p_runtsk->enater = true;				/*ï¼»NGKI3491ï¼½*/
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ENA_TER_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ena_ter */
+
+/*
+ *  ã¿ã¹ã¯çµäºç¦æ­¢ç¶æ
+ã®åç
+§ï¼»NGKI3494ï¼½
+ */
+#ifdef TOPPERS_sns_ter
+
+bool_t
+sns_ter(void)
+{
+	bool_t	state;
+
+	LOG_SNS_TER_ENTER();
+	/*
+	 *  enaterãå¤æ´ã§ããã®ã¯èªã¿ã¹ã¯ã®ã¿ã§ããããï¼æä»å¶å¾¡ããã«èª­
+	 *  ãã§ãåé¡ãªãï¼
+	 */
+	state = (p_runtsk != NULL && p_runtsk->enater) ? false : true;
+												/*ï¼»NGKI3495ï¼½ï¼»NGKI3496ï¼½*/
+	LOG_SNS_TER_LEAVE(state);
+	return(state);
+}
+
+#endif /* TOPPERS_sns_ter */
+
+/*
+ *  ã¿ã¹ã¯ã®å¼·å¶çµäºï¼»NGKI1170ï¼½
+ */
+#ifdef TOPPERS_ter_tsk
+
+ER
+ter_tsk(ID tskid)
+{
+	TCB		*p_tcb;
+	ER		ercd;
+
+	LOG_TER_TSK_ENTER(tskid);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI1171ï¼½ï¼»NGKI1172ï¼½*/
+	CHECK_ID(VALID_TSKID(tskid));				/*ï¼»NGKI1173ï¼½*/
+	p_tcb = get_tcb(tskid);
+	CHECK_ILUSE(p_tcb != p_runtsk);				/*ï¼»NGKI1176ï¼½*/
+
+	lock_cpu();
+	if (p_tcb->p_tinib->tskatr == TA_NOEXS) {
+		ercd = E_NOEXS;							/*ï¼»NGKI1174ï¼½*/
+	}
+	else if (TSTAT_DORMANT(p_tcb->tstat)) {
+		ercd = E_OBJ;							/*ï¼»NGKI1177ï¼½*/
+	}
+	else {
+		task_terminate(p_tcb);					/*ï¼»NGKI3450ï¼½*/
+		if (p_runtsk != p_schedtsk) {
+			dispatch();
+		}
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_TER_TSK_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_ter_tsk */
Index: asp3_gr_sakura/trunk/kernel/taskhook.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/taskhook.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/taskhook.c	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *  ã¿ã¹ã¯ç®¡çã«é¢é£ããããã¯ã«ã¼ãã³
+ */
+
+#include "kernel_impl.h"
+#include "task.h"
+#include "taskhook.h"
+
+/*
+ *  ãã¥ã¼ããã¯ã¹æ©è½ã®ããã®ããã¯ã«ã¼ãã³
+ */
+#ifdef TOPPERS_mtxhook
+
+bool_t	(*mtxhook_check_ceilpri)(TCB *p_tcb, uint_t bpriority) = NULL;
+bool_t	(*mtxhook_scan_ceilmtx)(TCB *p_tcb) = NULL;
+void	(*mtxhook_release_all)(TCB *p_tcb) = NULL;
+
+#endif /* TOPPERS_mtxhook */
Index: asp3_gr_sakura/trunk/kernel/taskhook.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/taskhook.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/taskhook.h	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *  ã¿ã¹ã¯ç®¡çã«é¢é£ããããã¯ã«ã¼ãã³
+ */
+
+#ifndef TOPPERS_TASKHOOK_H
+#define TOPPERS_TASKHOOK_H
+
+#include "kernel_impl.h"
+#include "task.h"
+
+/*
+ *  ãã¥ã¼ããã¯ã¹æ©è½ã®ããã®ããã¯ã«ã¼ãã³
+ */
+extern bool_t	(*mtxhook_check_ceilpri)(TCB *p_tcb, uint_t bpriority);
+extern bool_t	(*mtxhook_scan_ceilmtx)(TCB *p_tcb);
+extern void		(*mtxhook_release_all)(TCB *p_tcb);
+
+#endif /* TOPPERS_TASKHOOK_H */
Index: asp3_gr_sakura/trunk/kernel/time_event.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/time_event.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/time_event.c	(revision 317)
@@ -0,0 +1,646 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¤ã ã¤ãã³ãç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#include "kernel_impl.h"
+#include "time_event.h"
+
+/*
+ *  TSTEP_HRTCNTã®ç¯å²ãã§ãã¯
+ */
+#if TSTEP_HRTCNT > 4000U
+#error TSTEP_HRTCNT is too large.
+#endif /* TSTEP_HRTCNT > 4000U */
+
+/*
+ *  HRTCNT_BOUNDã®ç¯å²ãã§ãã¯
+ */
+#if HRTCNT_BOUND >= 4294000000U
+#error HRTCNT_BOUND is too large.
+#endif /* HRTCNT_BOUND >= 4294000000U */
+
+#ifdef TCYC_HRTCNT
+#if HRTCNT_BOUND >= TCYC_HRTCNT
+#error HRTCNT_BOUND is too large.
+#endif /* HRTCNT_BOUND >= TCYC_HRTCNT */
+#endif /* TCYC_HRTCNT */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãæä½ãã¯ã­
+ */
+#define PARENT(p_tmevtn)	(tmevt_heap + (((p_tmevtn) - tmevt_heap) >> 1))
+													/* è¦ªãã¼ããæ±ãã */
+#define LCHILD(p_tmevtn)	(tmevt_heap + (((p_tmevtn) - tmevt_heap) << 1))
+													/* å·¦ã®å­ãã¼ããæ±ãã */
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãä¸­ã®å
+é ­ã®ãã¼ã
+ */
+#define p_top_tmevtn	(&(tmevt_heap[1]))
+#define top_evttim		(tmevt_heap[1].p_tmevtb->evttim)
+										/* å
+é ­ã®ã¿ã¤ã ã¤ãã³ãã®çºçæå» */
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãä¸­ã®æå¾ã®ãã¼ã
+ */
+#define p_last_tmevtn	(tmevt_heap[0].p_last)
+
+/*
+ *  ã¤ãã³ãæå»ã®åå¾é¢ä¿ã®å¤å®ï¼»ASPD1009ï¼½
+ *
+ *  ã¤ãã³ãæå»ã¯ï¼boundary_evttimããã®ç¸å¯¾å¤ã§æ¯è¼ããï¼ããªãã¡ï¼
+ *  boundary_evttimãæãæ©ãæå»ï¼boundary_evttim-1ãæãé
+ãæå»ã¨ã¿
+ *  ãªãã¦æ¯è¼ããï¼
+ */
+#define EVTTIM_ADVANCE(t)	((t) - boundary_evttim)
+#define EVTTIM_LT(t1, t2)	(EVTTIM_ADVANCE(t1) < EVTTIM_ADVANCE(t2))
+#define EVTTIM_LE(t1, t2)	(EVTTIM_ADVANCE(t1) <= EVTTIM_ADVANCE(t2))
+
+#ifdef TOPPERS_tmeini
+
+/*
+ *  å¢çã¤ãã³ãæå»ï¼»ASPD1008ï¼½
+ */
+EVTTIM	boundary_evttim;
+
+/*
+ *  æå¾ã«ç¾å¨æå»ãç®åºããæç¹ã§ã®ã¤ãã³ãæå»ï¼»ASPD1012ï¼½
+ */
+EVTTIM	current_evttim;
+
+/*
+ *  æå¾ã«ç¾å¨æå»ãç®åºããæç¹ã§ã®é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ï¼»ASPD1012ï¼½
+ */
+HRTCNT	current_hrtcnt;
+
+/*
+ *  æãé²ãã§ããæã®ã¤ãã³ãæå»ï¼»ASPD1041ï¼½
+ */
+EVTTIM	monotonic_evttim;
+
+/*
+ *  ã·ã¹ãã æå»ã®ãªãã»ããï¼»ASPD1043ï¼½
+ */
+SYSTIM	systim_offset;
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®å¦çä¸­ã§ãããã¨ãç¤ºããã©ã°ï¼»ASPD1032ï¼½
+ */
+bool_t	in_signal_time;
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãç®¡çã¢ã¸ã¥ã¼ã«ã®åæåï¼»ASPD1061ï¼½
+ */
+void
+initialize_tmevt(void)
+{
+	current_evttim = 0U;							/*ï¼»ASPD1047ï¼½*/
+	boundary_evttim = current_evttim - BOUNDARY_MARGIN;
+													/*ï¼»ASPD1048ï¼½*/
+	monotonic_evttim = 0U;							/*ï¼»ASPD1046ï¼½*/
+	systim_offset = 0U;								/*ï¼»ASPD1044ï¼½*/
+	in_signal_time = false;							/*ï¼»ASPD1033ï¼½*/
+	p_last_tmevtn = tmevt_heap;
+}
+
+#endif /* TOPPERS_tmeini */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®æ¿å
+¥ä½ç½®ãä¸åãã«æ¢ç´¢
+ *
+ *  æå»evttimã«çºçããã¿ã¤ã ã¤ãã³ããæ¿å
+¥ãããã¼ããç©ºããããã«ï¼
+ *  ãã¼ãã®ä¸ã«åãã£ã¦ç©ºãã¼ããç§»åãããï¼ç§»ååã®ç©ºãã¼ãã®ä½ç½®ã
+ *  p_tmevtnã«æ¸¡ãã¨ï¼ç§»åå¾ã®ç©ºãã¼ãã®ä½ç½®ï¼ããªãã¡æ¿å
+¥ä½ç½®ï¼ãè¿ãï¼
+ */
+#ifdef TOPPERS_tmeup
+
+TMEVTN *
+tmevt_up(TMEVTN *p_tmevtn, EVTTIM evttim)
+{
+	TMEVTN	*p_parent;
+
+	while (p_tmevtn > p_top_tmevtn) {
+		/*
+		 *  è¦ªãã¼ãã®ã¤ãã³ãçºçæå»ã®æ¹ãæ©ãï¼ã¾ãã¯åãï¼ãªãã°ï¼
+		 *  p_tmevtnãæ¿å
+¥ä½ç½®ãªã®ã§ã«ã¼ããæããï¼
+		 */
+		p_parent = PARENT(p_tmevtn);
+		if (EVTTIM_LE(p_parent->p_tmevtb->evttim, evttim)) {
+			break;
+		}
+
+		/*
+		 *  è¦ªãã¼ããp_tmevtnã®ä½ç½®ã«ç§»åãããï¼
+		 */
+		*p_tmevtn = *p_parent;
+		p_tmevtn->p_tmevtb->p_tmevtn = p_tmevtn;
+
+		/*
+		 *  p_tmevtnãè¦ªãã¼ãã®ä½ç½®ã«æ´æ°ï¼
+		 */
+		p_tmevtn = p_parent;
+	}
+	return(p_tmevtn);
+}
+
+#endif /* TOPPERS_tmeup */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®æ¿å
+¥ä½ç½®ãä¸åãã«æ¢ç´¢
+ *
+ *  æå»evttimã«çºçããã¿ã¤ã ã¤ãã³ããæ¿å
+¥ãããã¼ããç©ºããããã«ï¼
+ *  ãã¼ãã®ä¸ã«åãã£ã¦ç©ºãã¼ããç§»åãããï¼ç§»ååã®ç©ºãã¼ãã®ä½ç½®ã
+ *  p_tmevtnã«æ¸¡ãã¨ï¼ç§»åå¾ã®ç©ºãã¼ãã®ä½ç½®ï¼ããªãã¡æ¿å
+¥ä½ç½®ï¼ãè¿ãï¼
+ */
+#ifdef TOPPERS_tmedown
+
+TMEVTN *
+tmevt_down(TMEVTN *p_tmevtn, EVTTIM evttim)
+{
+	TMEVTN	*p_child;
+
+	while ((p_child = LCHILD(p_tmevtn)) <= p_last_tmevtn) {
+		/*
+		 *  å·¦å³ã®å­ãã¼ãã®ã¤ãã³ãçºçæå»ãæ¯è¼ãï¼æ©ãæ¹ã®å­ãã¼ã
+		 *  ã®ä½ç½®ãp_childã«è¨­å®ããï¼ä»¥ä¸ã®å­ãã¼ãã¯ï¼ããã§é¸ã°ãã
+		 *  æ¹ã®å­ãã¼ãã®ãã¨ï¼
+		 */
+		if (p_child + 1 <= p_last_tmevtn
+					&& EVTTIM_LT((p_child + 1)->p_tmevtb->evttim,
+											p_child->p_tmevtb->evttim)) {
+			p_child = p_child + 1;
+		}
+
+		/*
+		 *  å­ãã¼ãã®ã¤ãã³ãçºçæå»ã®æ¹ãé
+ãï¼ã¾ãã¯åãï¼ãªãã°ï¼
+		 *  p_tmevtnãæ¿å
+¥ä½ç½®ãªã®ã§ã«ã¼ããæããï¼
+		 */
+		if (EVTTIM_LE(evttim, p_child->p_tmevtb->evttim)) {
+			break;
+		}
+
+		/*
+		 *  å­ãã¼ããp_tmevtnã®ä½ç½®ã«ç§»åãããï¼
+		 */
+		*p_tmevtn = *p_child;
+		p_tmevtn->p_tmevtb->p_tmevtn = p_tmevtn;
+
+		/*
+		 *  p_tmevtnãå­ãã¼ãã®ä½ç½®ã«æ´æ°ï¼
+		 */
+		p_tmevtn = p_child;
+	}
+	return(p_tmevtn);
+}
+
+#endif /* TOPPERS_tmedown */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãã¸ã®è¿½å 
+ *
+ *  p_tmevtbã§æå®ããã¿ã¤ã ã¤ãã³ããã­ãã¯ãï¼ã¿ã¤ã ã¤ãã³ããã¼ãã«
+ *  è¿½å ããï¼
+ */
+Inline void
+tmevtb_insert(TMEVTB *p_tmevtb)
+{
+	TMEVTN	*p_tmevtn;
+
+	/*
+	 *  p_last_tmevtnãã¤ã³ã¯ãªã¡ã³ããï¼ããããä¸ã«æ¿å
+¥ä½ç½®ãæ¢ãï¼
+	 */
+	p_tmevtn = tmevt_up(++p_last_tmevtn, p_tmevtb->evttim);
+
+	/*
+	 *  ã¿ã¤ã ã¤ãã³ããp_tmevtnã®ä½ç½®ã«æ¿å
+¥ããï¼
+	 */ 
+	p_tmevtn->p_tmevtb = p_tmevtb;
+	p_tmevtb->p_tmevtn = p_tmevtn;
+}
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãããã®åé¤
+ */
+Inline void
+tmevtb_delete(TMEVTB *p_tmevtb)
+{
+	TMEVTN	*p_tmevtn = p_tmevtb->p_tmevtn;
+	TMEVTN	*p_parent;
+	EVTTIM	event_evttim;
+
+	/*
+	 *  åé¤ã«ããã¿ã¤ã ã¤ãã³ããã¼ããç©ºã«ãªãå ´åã¯ä½ãããªãï¼
+	 */
+	if (--p_last_tmevtn < p_top_tmevtn) {
+		return;
+	}
+
+	/*
+	 *  åé¤ãããã¼ãã®ä½ç½®ã«æå¾ã®ãã¼ãï¼p_last_tmevtn + 1 ã®ä½ç½®ã®
+	 *  ãã¼ãï¼ãæ¿å
+¥ãï¼ãããé©åãªä½ç½®ã¸ç§»åãããï¼å®éã«ã¯ï¼æå¾
+	 *  ã®ãã¼ããå®éã«æ¿å
+¥ããã®ã§ã¯ãªãï¼åé¤ãããã¼ãã®ä½ç½®ãç©ºãã¼
+	 *  ãã«ãªãã®ã§ï¼æå¾ã®ãã¼ããæ¿å
+¥ãã¹ãä½ç½®ã¸åãã¦ç©ºãã¼ããç§»
+	 *  åãããï¼
+	 *
+	 *  æå¾ã®ãã¼ãã®ã¤ãã³ãçºçæå»ãï¼åé¤ãããã¼ãã®è¦ªãã¼ãã®ã¤
+	 *  ãã³ãçºçæå»ããåã®å ´åã«ã¯ï¼ä¸ã«åãã£ã¦æ¿å
+¥ä½ç½®ãæ¢ãï¼ã
+	 *  ãã§ãªãå ´åã«ã¯ï¼ä¸ã«åãã£ã¦æ¢ãï¼
+	 */
+	event_evttim = (p_last_tmevtn + 1)->p_tmevtb->evttim;
+	if (p_tmevtn > p_top_tmevtn
+			&& EVTTIM_LT(event_evttim,
+						(p_parent = PARENT(p_tmevtn))->p_tmevtb->evttim)) {
+		/*
+		 *  è¦ªãã¼ããp_tmevtnã®ä½ç½®ã«ç§»åãããï¼
+		 */
+		*p_tmevtn = *p_parent;
+		p_tmevtn->p_tmevtb->p_tmevtn = p_tmevtn;
+
+		/*
+		 *  åé¤ãããã¼ãã®è¦ªãã¼ãããä¸ã«åãã£ã¦æ¿å
+¥ä½ç½®ãæ¢ãï¼
+		 */
+		p_tmevtn = tmevt_up(p_parent, event_evttim);
+	}
+	else {
+		/*
+		 *  åé¤ãããã¼ãããä¸ã«åãã£ã¦æ¿å
+¥ä½ç½®ãæ¢ãï¼
+		 */
+		p_tmevtn = tmevt_down(p_tmevtn, event_evttim);
+	}
+
+	/*
+	 *  æå¾ã®ãã¼ããp_tmevtnã®ä½ç½®ã«æ¿å
+¥ããï¼
+	 */ 
+	*p_tmevtn = *(p_last_tmevtn + 1);
+	p_tmevtn->p_tmevtb->p_tmevtn = p_tmevtn;
+}
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãã®å
+é ­ã®ãã¼ãã®åé¤
+ */
+Inline TMEVTB *
+tmevtb_delete_top(void)
+{
+	TMEVTN	*p_tmevtn;
+	TMEVTB	*p_top_tmevtb = p_top_tmevtn->p_tmevtb;
+	EVTTIM	event_evttim;
+
+	/*
+	 *  åé¤ã«ããã¿ã¤ã ã¤ãã³ããã¼ããç©ºã«ãªãå ´åã¯ä½ãããªãï¼
+	 */
+	if (--p_last_tmevtn >= p_top_tmevtn) {
+		/*
+		 *  ã«ã¼ããã¼ãã«æå¾ã®ãã¼ãï¼p_last_tmevtn + 1 ã®ä½ç½®ã®ãã¼
+		 *  ãï¼ãæ¿å
+¥ãï¼ãããé©åãªä½ç½®ã¸ç§»åãããï¼å®éã«ã¯ï¼æå¾
+		 *  ã®ãã¼ããå®éã«æ¿å
+¥ããã®ã§ã¯ãªãï¼ã«ã¼ããã¼ããç©ºãã¼ã
+		 *  ã«ãªãã®ã§ï¼æå¾ã®ãã¼ããæ¿å
+¥ãã¹ãä½ç½®ã¸åãã¦ç©ºãã¼ãã
+		 *  ç§»åãããï¼
+		 */
+		event_evttim = (p_last_tmevtn + 1)->p_tmevtb->evttim;
+		p_tmevtn = tmevt_down(p_top_tmevtn, event_evttim);
+
+		/*
+		 *  æå¾ã®ãã¼ããp_tmevtnã®ä½ç½®ã«æ¿å
+¥ããï¼
+		 */ 
+		*p_tmevtn = *(p_last_tmevtn + 1);
+		p_tmevtn->p_tmevtb->p_tmevtn = p_tmevtn;
+	}
+	return(p_top_tmevtb);
+}
+
+/*
+ *  ç¾å¨ã®ã¤ãã³ãæå»ã®æ´æ°
+ */
+#ifdef TOPPERS_tmecur
+
+void
+update_current_evttim(void)
+{
+	HRTCNT	new_hrtcnt, hrtcnt_advance;
+	EVTTIM	previous_evttim;
+
+	new_hrtcnt = target_hrt_get_current();			/*ï¼»ASPD1013ï¼½*/
+	hrtcnt_advance = new_hrtcnt - current_hrtcnt;	/*ï¼»ASPD1014ï¼½*/
+#ifdef TCYC_HRTCNT
+	if (new_hrtcnt < current_hrtcnt) {
+		hrtcnt_advance += TCYC_HRTCNT;
+	}
+#endif /* TCYC_HRTCNT */
+
+	previous_evttim = current_evttim;
+	current_evttim += (EVTTIM) hrtcnt_advance;		/*ï¼»ASPD1015ï¼½*/
+	current_hrtcnt = new_hrtcnt;					/*ï¼»ASPD1016ï¼½*/
+	boundary_evttim = current_evttim - BOUNDARY_MARGIN;	/*ï¼»ASPD1011ï¼½*/
+
+	if (monotonic_evttim - previous_evttim < (EVTTIM) hrtcnt_advance) {
+#ifdef UINT64_MAX
+		if (current_evttim < monotonic_evttim) {
+			systim_offset += 1LLU << 32;			/*ï¼»ASPD1045ï¼½*/
+		}
+#endif /* UINT64_MAX */
+		monotonic_evttim = current_evttim;			/*ï¼»ASPD1042ï¼½*/
+	}
+}
+
+#endif /* TOPPERS_tmecur */
+
+/*
+ *  ç¾å¨ã®ã¤ãã³ãæå»ãé
+ãæ¹ã«ä¸¸ããã¤ãã³ãæå»ã®ç®åºï¼»ASPD1027ï¼½
+ *
+ *  ç¾å¨ã®ã¤ãã³ãæå»ãæ´æ°ããå¾ã«å¼ã¶ãã¨ãæ³å®ãã¦ããï¼
+ */
+Inline EVTTIM
+calc_current_evttim_ub(void)
+{
+	return(current_evttim + ((EVTTIM) TSTEP_HRTCNT));
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®çºçã¿ã¤ãã³ã°ã®è¨­å®
+ */
+#ifdef TOPPERS_tmeset
+
+void
+set_hrt_event(void)
+{
+	HRTCNT	hrtcnt;
+
+	if (p_last_tmevtn < p_top_tmevtn) {
+		target_hrt_set_event(HRTCNT_BOUND);			/*ï¼»ASPD1007ï¼½*/
+	}
+	else if (EVTTIM_LE(top_evttim, current_evttim)) {
+		target_hrt_raise_event();					/*ï¼»ASPD1017ï¼½*/
+	}
+	else {
+		hrtcnt = (HRTCNT)(top_evttim - current_evttim);
+		if (hrtcnt > HRTCNT_BOUND) {
+			target_hrt_set_event(HRTCNT_BOUND);		/*ï¼»ASPD1006ï¼½*/
+		}
+		else {
+			target_hrt_set_event(hrtcnt);			/*ï¼»ASPD1002ï¼½*/
+		}
+	}
+}
+
+#endif /* TOPPERS_tmeset */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã­ãã¯ã®ãã¼ãã¸ã®æ¿å
+¥
+ */
+#ifdef TOPPERS_tmereg
+
+void
+tmevtb_register(TMEVTB *p_tmevtb)
+{
+	tmevtb_insert(p_tmevtb);
+}
+
+#endif /* TOPPERS_tmereg */
+
+/*
+ *  ç¸å¯¾æéæå®ã«ããã¿ã¤ã ã¤ãã³ãã®ç»é²
+ *  
+ */
+#ifdef TOPPERS_tmeenq
+
+void
+tmevtb_enqueue(TMEVTB *p_tmevtb, RELTIM time)
+{
+	/*
+	 *  ç¾å¨ã®ã¤ãã³ãæå»ã¨ã¿ã¤ã ã¤ãã³ãã®çºçæå»ãæ±ããï¼»ASPD1026ï¼½ï¼
+	 */
+	update_current_evttim();
+	p_tmevtb->evttim = calc_current_evttim_ub() + time;
+
+	/*
+	 *  ã¿ã¤ã ã¤ãã³ããã­ãã¯ããã¼ãã«æ¿å
+¥ããï¼»ASPD1030ï¼½ï¼
+	 */
+	tmevtb_insert(p_tmevtb);
+
+	/*
+	 *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®çºçã¿ã¤ãã³ã°ãè¨­å®ããï¼»ASPD1031ï¼½
+	 *  ï¼»ASPD1034ï¼½ï¼
+	 */
+	if (!in_signal_time && p_tmevtb->p_tmevtn == p_top_tmevtn) {
+		set_hrt_event();
+	}
+}
+
+#endif /* TOPPERS_tmeenq */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®ç»é²è§£é¤
+ */
+#ifdef TOPPERS_tmedeq
+
+void
+tmevtb_dequeue(TMEVTB *p_tmevtb)
+{
+	TMEVTN	*p_tmevtn;
+
+	/*
+	 *  ã¿ã¤ã ã¤ãã³ããã­ãã¯ããã¼ãããåé¤ããï¼»ASPD1039ï¼½ï¼
+	 */
+	p_tmevtn = p_tmevtb->p_tmevtn;
+	tmevtb_delete(p_tmevtb);
+
+	/*
+	 *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®çºçã¿ã¤ãã³ã°ãè¨­å®ããï¼»ASPD1040ï¼½ï¼
+	 */
+	if (!in_signal_time && p_tmevtn == p_top_tmevtn) {
+		update_current_evttim();
+		set_hrt_event();
+	}
+}
+
+#endif /* TOPPERS_tmedeq */
+
+/*
+ *  ã·ã¹ãã æå»ã®èª¿æ´æã®ã¨ã©ã¼ãã§ãã¯
+ */
+#ifdef TOPPERS_tmechk
+
+bool_t
+check_adjtim(int_t adjtim)
+{
+	if (adjtim > 0) {
+		return(p_last_tmevtn >= p_top_tmevtn	/*ï¼»NGKI3588ï¼½*/
+					&& EVTTIM_LE(top_evttim, current_evttim - TMAX_ADJTIM));
+	}
+	else if (adjtim < 0) {						/*ï¼»NGKI3589ï¼½*/
+		return(monotonic_evttim - current_evttim >= -TMIN_ADJTIM);
+	}
+	return(false);
+}
+
+#endif /* TOPPERS_tmechk */
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããçºçããã¾ã§ã®æéã®è¨ç®
+ */
+#ifdef TOPPERS_tmeltim
+
+RELTIM
+tmevt_lefttim(TMEVTB *p_tmevtb)
+{
+	EVTTIM	evttim, current_evttim_ub;
+
+	/*
+	 *  ç¾å¨ã®ã¤ãã³ãæå»ãé
+ãæ¹ã«ä¸¸ããæå»ãæ±ããï¼»ASPD1050ï¼½ï¼
+	 */
+	update_current_evttim();
+	current_evttim_ub = calc_current_evttim_ub();
+
+	/*
+	 *  ã¿ã¤ã ã¤ãã³ãçºçã¾ã§ã®ç¸å¯¾æéãæ±ããï¼»ASPD1049ï¼½ï¼
+	 */
+	evttim = p_tmevtb->evttim;
+	if (EVTTIM_LE(evttim, current_evttim_ub)) {
+		/*
+		 *  ã¿ã¤ã ã¤ãã³ãã®çºçæå»ãéãã¦ããå ´åã«ã¯0ãè¿ãï¼»NGKI0552ï¼½ï¼
+		 */
+		return(0U);
+	}
+	else {
+		return((RELTIM)(evttim - current_evttim_ub));
+	}
+}
+
+#endif /* TOPPERS_tmeltim */
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®å¦ç
+ */
+#ifdef TOPPERS_sigtim
+
+void
+signal_time(void)
+{
+	TMEVTB	*p_tmevtb;
+	bool_t	callflag;
+
+	assert(sense_context());
+	assert(!sense_lock());
+
+	lock_cpu();
+	in_signal_time = true;							/*ï¼»ASPD1033ï¼½*/
+
+	do {
+		/*
+		 *  ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºããªããã°ã«ã¼ããæããï¼»ASPD1020ï¼½ï¼
+		 */
+		callflag = false;
+
+		/*
+		 *  ç¾å¨ã®ã¤ãã³ãæå»ãæ±ããï¼»ASPD1022ï¼½ï¼
+		 */
+		update_current_evttim();
+
+		/*
+		 *  çºçæå»ãcurrent_evttimä»¥åã®ã¿ã¤ã ã¤ãã³ããããã°ï¼ã¿ã¤
+		 *  ã ã¤ãã³ããã¼ãããåé¤ãï¼ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºã
+		 *  ï¼»ASPD1018ï¼½ï¼»ASPD1019ï¼½ï¼
+		 */
+		while (p_last_tmevtn >= p_top_tmevtn
+							&& EVTTIM_LE(top_evttim, current_evttim)) {
+			p_tmevtb = tmevtb_delete_top();
+			(*(p_tmevtb->callback))(p_tmevtb->arg);
+			callflag = true;
+		}
+	} while (callflag);								/*ï¼»ASPD1020ï¼½*/
+
+	/*
+	 *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®çºçã¿ã¤ãã³ã°ãè¨­å®ããï¼»ASPD1025ï¼½ï¼
+	 */
+	set_hrt_event();
+
+	in_signal_time = false;							/*ï¼»ASPD1033ï¼½*/
+	unlock_cpu();
+}
+
+#endif /* TOPPERS_sigtim */
Index: asp3_gr_sakura/trunk/kernel/time_event.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/time_event.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/time_event.h	(revision 317)
@@ -0,0 +1,220 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¿ã¤ã ã¤ãã³ãç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#ifndef TOPPERS_TIME_EVENT_H
+#define TOPPERS_TIME_EVENT_H
+
+#include "kernel_impl.h"
+#include "target_timer.h"
+
+/*
+ *  ã¤ãã³ãæå»ã®ãã¼ã¿åã®å®ç¾©ï¼»ASPD1001ï¼½
+ *
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãã«ç»é²ããã¿ã¤ã ã¤ãã³ãã®çºçæå»ãè¡¨ç¾ããã
+ *  ãã®ãã¼ã¿åï¼ãªã¼ããããä½æ¸ã®ããã«ï¼32ãããã§æ±ãï¼
+ */
+typedef uint32_t	EVTTIM;
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãä¸­ã®ãã¼ãã®ãã¼ã¿åã®åæ¹åç
+§
+ */
+typedef union time_event_node TMEVTN;
+
+/* 
+ *  ã¿ã¤ã ã¤ãã³ããã­ãã¯ã®ãã¼ã¿åã®å®ç¾©
+ */
+typedef void	(*CBACK)(void *);	/* ã³ã¼ã«ããã¯é¢æ°ã®å */
+
+typedef struct time_event_block {
+	EVTTIM	evttim;			/* ã¿ã¤ã ã¤ãã³ãã®çºçæå» */
+	TMEVTN	*p_tmevtn;		/* ã¿ã¤ã ã¤ãã³ããã¼ãä¸­ã§ã®ä½ç½® */
+	CBACK	callback;		/* ã³ã¼ã«ããã¯é¢æ° */
+	void	*arg;			/* ã³ã¼ã«ããã¯é¢æ°ã¸æ¸¡ãå¼æ° */
+} TMEVTB;
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãä¸­ã®ãã¼ãã®ãã¼ã¿åã®å®ç¾©
+ *
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãã®å
+é ­ã®ãã¼ãï¼tmevt_heap[0]ï¼ã«ï¼æå¾ã®ä½¿ç¨é 
+ *  åãæããã¤ã³ã¿ï¼p_lastï¼ãæ ¼ç´ãï¼ããä»¥éãã¿ã¤ã ã¤ãã³ããã¼ã
+ *  ã¨ãã¦ä½¿ç¨ããï¼(tmevt_heap[0].p_last - tmevt_heap) ãï¼ã¿ã¤ã ã¤ã
+ *  ã³ããã¼ãã«ç»é²ããã¦ããã¿ã¤ã ã¤ãã³ãã®æ°ã¨ãªãï¼
+ */
+union time_event_node {
+	TMEVTB	*p_tmevtb;		/* å¯¾å¿ããã¿ã¤ã ã¤ãã³ããã­ãã¯ */
+	TMEVTN	*p_last;		/* ã¿ã¤ã ã¤ãã³ããã¼ãã®æå¾ã®ä½¿ç¨é å */
+};
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã¼ãï¼kernel_cfg.cï¼
+ */
+extern TMEVTN	tmevt_heap[];
+
+/*
+ *  å¢çã¤ãã³ãæå»ï¼»ASPD1008ï¼½
+ */
+extern EVTTIM	boundary_evttim;
+
+/*
+ *  ç¾å¨ã®ã¤ãã³ãæå»ã¨å¢çã¤ãã³ãæå»ã®å·®ï¼»ASPD1010ï¼½
+ */
+#define BOUNDARY_MARGIN		(200000000U)
+
+/*
+ *  æå¾ã«ç¾å¨æå»ãç®åºããæç¹ã§ã®ã¤ãã³ãæå»ï¼»ASPD1012ï¼½
+ */
+extern EVTTIM	current_evttim;
+
+/*
+ *  æå¾ã«ç¾å¨æå»ãç®åºããæç¹ã§ã®é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ï¼»ASPD1012ï¼½
+ */
+extern HRTCNT	current_hrtcnt;
+
+/*
+ *  æãé²ãã§ããæã®ã¤ãã³ãæå»ï¼»ASPD1041ï¼½
+ */
+extern EVTTIM	monotonic_evttim;
+
+/*
+ *  ã·ã¹ãã æå»ã®ãªãã»ããï¼»ASPD1043ï¼½
+ *
+ *  get_timã§åç
+§ããã·ã¹ãã æå»ã¨monotonic_evttimã®å·®ãä¿æããï¼
+ */
+extern SYSTIM	systim_offset;
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®å¦çä¸­ã§ãããã¨ãç¤ºããã©ã°ï¼»ASPD1032ï¼½
+ */
+extern bool_t	in_signal_time;
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãç®¡çã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+extern void	initialize_tmevt(void);
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®æ¿å
+¥ä½ç½®ã®æ¢ç´¢
+ */
+extern TMEVTN	*tmevt_up(TMEVTN *p_tmevtn, EVTTIM evttim);
+extern TMEVTN	*tmevt_down(TMEVTN *p_tmevtn, EVTTIM evttim);
+
+/*
+ *  ç¾å¨ã®ã¤ãã³ãæå»ã®æ´æ°
+ *
+ *  current_evttimã¨current_hrtcntãï¼ç¾å¨ã®å¤ã«æ´æ°ããï¼
+ */
+extern void		update_current_evttim(void);
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®çºçã¿ã¤ãã³ã°ã®è¨­å®
+ *
+ *  ç¾å¨ã®ã¤ãã³ãæå»ãåå¾ããå¾ã«å¼ã³åºããã¨ãæ³å®ãã¦ããï¼
+ */
+extern void		set_hrt_event(void);
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®ç»é²
+ *
+ *  p_tmevtbã§æå®ããã¿ã¤ã ã¤ãã³ããã­ãã¯ãç»é²ããï¼ã¿ã¤ã ã¤ãã³ã
+ *  ã®çºçæå»ï¼ã³ã¼ã«ããã¯é¢æ°ï¼ã³ã¼ã«ããã¯é¢æ°ã¸æ¸¡ãå¼æ°ã¯ï¼
+ *  p_tmevtbãæãã¿ã¤ã ã¤ãã³ããã­ãã¯ä¸­ã«è¨­å®ãã¦ããï¼
+ */
+extern void		tmevtb_register(TMEVTB *p_tmevtb);
+
+/*
+ *  ç¸å¯¾æéæå®ã«ããã¿ã¤ã ã¤ãã³ãã®ç»é²
+ *
+ *  timeã§æå®ããç¸å¯¾æéãçµéããå¾ã«ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºããã
+ *  ããã«ï¼p_tmevtbã§æå®ããã¿ã¤ã ã¤ãã³ããã­ãã¯ãç»é²ããï¼ã³ã¼ã«
+ *  ããã¯é¢æ°ï¼ã³ã¼ã«ããã¯é¢æ°ã¸æ¸¡ãå¼æ°ã¯ï¼p_tmevtbãæãã¿ã¤ã ã¤ã
+ *  ã³ããã­ãã¯ä¸­ã«è¨­å®ãã¦ããï¼
+ */
+extern void		tmevtb_enqueue(TMEVTB *p_tmevtb, RELTIM time);
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãã®ç»é²è§£é¤
+ */
+extern void		tmevtb_dequeue(TMEVTB *p_tmevtb);
+
+/*
+ *  ã·ã¹ãã æå»ã®èª¿æ´æã®ã¨ã©ã¼ãã§ãã¯
+ *
+ *  adjtimã§æå®ãããæéã®åï¼ã·ã¹ãã æå»ãèª¿æ´ãã¦ãããå¤å®ããï¼
+ *  èª¿æ´ãã¦ã¯ãªããªãå ´åã«trueï¼ããã§ãªãå ´åã«falseãè¿ãï¼ç¾å¨ã®ã¤
+ *  ãã³ãæå»ãåå¾ããå¾ã«å¼ã³åºããã¨ãæ³å®ãã¦ããï¼
+ */
+extern bool_t	check_adjtim(int_t adjtim);
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããçºçããã¾ã§ã®æéã®è¨ç®
+ */
+extern RELTIM	tmevt_lefttim(TMEVTB *p_tmevtb);
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®å¦ç
+ */
+extern void	signal_time(void);
+
+#endif /* TOPPERS_TIME_EVENT_H */
Index: asp3_gr_sakura/trunk/kernel/time_manage.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/time_manage.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/time_manage.c	(revision 317)
@@ -0,0 +1,396 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã æå»ç®¡çæ©è½
+ */
+
+#include "kernel_impl.h"
+#include "check.h"
+#include "task.h"
+#include "semaphore.h"
+#include "eventflag.h"
+#include "dataqueue.h"
+#include "time_event.h"
+#include "target_timer.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ */
+#ifndef LOG_SET_TIM_ENTER
+#define LOG_SET_TIM_ENTER(systim)
+#endif /* LOG_SET_TIM_ENTER */
+
+#ifndef LOG_SET_TIM_LEAVE
+#define LOG_SET_TIM_LEAVE(ercd)
+#endif /* LOG_SET_TIM_LEAVE */
+
+#ifndef LOG_GET_TIM_ENTER
+#define LOG_GET_TIM_ENTER(p_systim)
+#endif /* LOG_GET_TIM_ENTER */
+
+#ifndef LOG_GET_TIM_LEAVE
+#define LOG_GET_TIM_LEAVE(ercd, p_systim)
+#endif /* LOG_GET_TIM_LEAVE */
+
+#ifndef LOG_ADJ_TIM_ENTER
+#define LOG_ADJ_TIM_ENTER(adjtim)
+#endif /* LOG_ADJ_TIM_ENTER */
+
+#ifndef LOG_ADJ_TIM_LEAVE
+#define LOG_ADJ_TIM_LEAVE(ercd)
+#endif /* LOG_ADJ_TIM_LEAVE */
+
+#ifndef LOG_FCH_HRT_ENTER
+#define LOG_FCH_HRT_ENTER()
+#endif /* LOG_FCH_HRT_ENTER */
+
+#ifndef LOG_FCH_HRT_LEAVE
+#define LOG_FCH_HRT_LEAVE(hrtcnt)
+#endif /* LOG_FCH_HRT_LEAVE */
+
+/*
+ *  ã·ã¹ãã æå»ã®è¨­å®ï¼»NGKI3563ï¼½
+ */
+#ifdef TOPPERS_set_tim
+
+ER
+set_tim(SYSTIM systim)
+{
+	ER		ercd;
+
+	LOG_SET_TIM_ENTER(systim);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI3564ï¼½ï¼»NGKI3565ï¼½*/
+
+	lock_cpu();
+	update_current_evttim();					/*ï¼»ASPD1059ï¼½*/
+	systim_offset = systim - monotonic_evttim;	/*ï¼»ASPD1060ï¼½*/
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_SET_TIM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_set_tim */
+
+/*
+ *  ã·ã¹ãã æå»ã®åç
+§ï¼»NGKI2349ï¼½
+ */
+#ifdef TOPPERS_get_tim
+
+ER
+get_tim(SYSTIM *p_systim)
+{
+	ER		ercd;
+
+	LOG_GET_TIM_ENTER(p_systim);
+	CHECK_TSKCTX_UNL();							/*ï¼»NGKI2350ï¼½ï¼»NGKI2351ï¼½*/
+
+	lock_cpu();
+	update_current_evttim();					/*ï¼»ASPD1057ï¼½*/
+	*p_systim = systim_offset + monotonic_evttim;	/*ï¼»ASPD1058ï¼½*/
+	ercd = E_OK;
+	unlock_cpu();
+
+  error_exit:
+	LOG_GET_TIM_LEAVE(ercd, p_systim);
+	return(ercd);
+}
+
+#endif /* TOPPERS_get_tim */
+
+/*
+ *  ã·ã¹ãã æå»ã®èª¿æ´ï¼»NGKI3581ï¼½
+ */
+#ifdef TOPPERS_adj_tim
+
+ER
+adj_tim(int32_t adjtim)
+{
+	EVTTIM	previous_evttim;
+	ER		ercd;
+
+	LOG_ADJ_TIM_ENTER(adjtim);
+	CHECK_UNL();								/*ï¼»NGKI3583ï¼½*/
+	CHECK_PAR(TMIN_ADJTIM <= adjtim && adjtim <= TMAX_ADJTIM);
+												/*ï¼»NGKI3584ï¼½*/
+	lock_cpu();
+	update_current_evttim();					/*ï¼»ASPD1051ï¼½*/
+	if (check_adjtim(adjtim)) {					/*ï¼»ASPD1052ï¼½*/
+		ercd = E_OBJ;
+	}
+	else {
+		previous_evttim = current_evttim;
+		current_evttim += adjtim;				/*ï¼»ASPD1053ï¼½*/
+		boundary_evttim = current_evttim - BOUNDARY_MARGIN;	/*ï¼»ASPD1055ï¼½*/
+
+		if (adjtim > 0
+				&& monotonic_evttim - previous_evttim < (EVTTIM) adjtim) {
+#ifdef UINT64_MAX
+			if (current_evttim < monotonic_evttim) {
+				systim_offset += 1LLU << 32;
+			}
+#endif /* UINT64_MAX */
+			monotonic_evttim = current_evttim;	/*ï¼»ASPD1054ï¼½*/
+		}
+
+		set_hrt_event();						/*ï¼»ASPD1056ï¼½*/
+		ercd = E_OK;
+	}
+	unlock_cpu();
+
+  error_exit:
+	LOG_ADJ_TIM_LEAVE(ercd);
+	return(ercd);
+}
+
+#endif /* TOPPERS_adj_tim */
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®åç
+§ï¼»NGKI3569ï¼½
+ *
+ *  ä»»æã®ç¶æ
+ããå¼ã³åºããããã«ããããã«ï¼SILã®å
+¨å²è¾¼ã¿ã­ãã¯ç¶æ
+ã®
+ *  å¶å¾¡æ©è½ãç¨ãã¦ï¼æä»å¶å¾¡ãå®ç¾ãã¦ããï¼»NGKI3572ï¼½ï¼
+ */
+#ifdef TOPPERS_fch_hrt
+
+HRTCNT
+fch_hrt(void)
+{
+	HRTCNT	hrtcnt;
+	SIL_PRE_LOC;
+
+	LOG_FCH_HRT_ENTER();
+
+	SIL_LOC_INT();
+	hrtcnt = target_hrt_get_current();			/*ï¼»NGKI3571ï¼½*/
+	SIL_UNL_INT();
+
+	LOG_FCH_HRT_LEAVE(hrtcnt);
+	return(hrtcnt);
+}
+
+#endif /* TOPPERS_fch_hrt */
+
+/*
+ *  éç¥æ¹æ³ã®ã¨ã©ã¼ãã§ãã¯
+ */
+#ifdef TOPPERS_chknfy
+
+ER
+check_nfyinfo(const T_NFYINFO *p_nfyinfo)
+{
+	ER		ercd;
+
+	if (p_nfyinfo->nfymode == TNFY_HANDLER) {
+		CHECK_PAR(FUNC_ALIGN(p_nfyinfo->nfy.handler.tmehdr));
+		CHECK_PAR(FUNC_NONNULL(p_nfyinfo->nfy.handler.tmehdr));
+	}
+	else {
+		switch (p_nfyinfo->nfymode & 0x0fU) {
+		case TNFY_SETVAR:
+			CHECK_PAR((p_nfyinfo->nfymode & ~0x0fU) == 0);
+			CHECK_PAR(INTPTR_ALIGN(p_nfyinfo->nfy.setvar.p_var));
+			CHECK_PAR(INTPTR_NONNULL(p_nfyinfo->nfy.setvar.p_var));
+			break;
+		case TNFY_INCVAR:
+			CHECK_PAR((p_nfyinfo->nfymode & ~0x0fU) == 0);
+			CHECK_PAR(INTPTR_ALIGN(p_nfyinfo->nfy.incvar.p_var));
+			CHECK_PAR(INTPTR_NONNULL(p_nfyinfo->nfy.incvar.p_var));
+			break;
+		case TNFY_ACTTSK:
+			CHECK_ID(VALID_TSKID(p_nfyinfo->nfy.acttsk.tskid));
+			break;
+		case TNFY_WUPTSK:
+			CHECK_ID(VALID_TSKID(p_nfyinfo->nfy.wuptsk.tskid));
+			break;
+		case TNFY_SIGSEM:
+			CHECK_ID(VALID_SEMID(p_nfyinfo->nfy.sigsem.semid));
+			break;
+		case TNFY_SETFLG:
+			CHECK_ID(VALID_FLGID(p_nfyinfo->nfy.setflg.flgid));
+			break;
+		case TNFY_SNDDTQ:
+			CHECK_ID(VALID_DTQID(p_nfyinfo->nfy.snddtq.dtqid));
+			break;
+		default:
+			CHECK_PAR(false);
+			break;
+		}
+		switch (p_nfyinfo->nfymode & ~0x0fU) {
+		case 0:
+			break;
+		case TENFY_SETVAR:
+			CHECK_PAR(INTPTR_ALIGN(p_nfyinfo->enfy.setvar.p_var));
+			CHECK_PAR(INTPTR_NONNULL(p_nfyinfo->enfy.setvar.p_var));
+			break;
+		case TENFY_INCVAR:
+			CHECK_PAR(INTPTR_ALIGN(p_nfyinfo->enfy.incvar.p_var));
+			CHECK_PAR(INTPTR_NONNULL(p_nfyinfo->enfy.incvar.p_var));
+			break;
+		case TENFY_ACTTSK:
+			CHECK_ID(VALID_TSKID(p_nfyinfo->enfy.acttsk.tskid));
+			break;
+		case TENFY_WUPTSK:
+			CHECK_ID(VALID_TSKID(p_nfyinfo->enfy.wuptsk.tskid));
+			break;
+		case TENFY_SIGSEM:
+			CHECK_ID(VALID_SEMID(p_nfyinfo->enfy.sigsem.semid));
+			break;
+		case TENFY_SETFLG:
+			CHECK_ID(VALID_FLGID(p_nfyinfo->enfy.setflg.flgid));
+			break;
+		case TENFY_SNDDTQ:
+			CHECK_ID(VALID_DTQID(p_nfyinfo->enfy.snddtq.dtqid));
+			break;
+		default:
+			CHECK_PAR(false);
+			break;
+		}
+	}
+	ercd = E_OK;
+
+  error_exit:
+	return(ercd);
+}
+
+#endif /* TOPPERS_chknfy */
+
+/*
+ *  éç¥ãã³ãã©
+ */
+#ifdef TOPPERS_nfyhdr
+
+void
+notify_handler(intptr_t exinf)
+{
+	T_NFYINFO	*p_nfyinfo = (T_NFYINFO *) exinf;
+	ER			ercd;
+
+	switch (p_nfyinfo->nfymode & 0x0fU) {
+	case TNFY_SETVAR:
+		*(p_nfyinfo->nfy.setvar.p_var) = p_nfyinfo->nfy.setvar.value;
+		ercd = E_OK;
+		break;
+	case TNFY_INCVAR:
+		(void) loc_cpu();
+		*(p_nfyinfo->nfy.incvar.p_var) += 1;
+		(void) unl_cpu();
+		ercd = E_OK;
+		break;
+	case TNFY_ACTTSK:
+		ercd = act_tsk(p_nfyinfo->nfy.acttsk.tskid);
+		break;
+	case TNFY_WUPTSK:
+		ercd = wup_tsk(p_nfyinfo->nfy.wuptsk.tskid);
+		break;
+	case TNFY_SIGSEM:
+		ercd = sig_sem(p_nfyinfo->nfy.sigsem.semid);
+		break;
+	case TNFY_SETFLG:
+		ercd = set_flg(p_nfyinfo->nfy.setflg.flgid,
+							p_nfyinfo->nfy.setflg.flgptn);
+		break;
+	case TNFY_SNDDTQ:
+		ercd = psnd_dtq(p_nfyinfo->nfy.snddtq.dtqid,
+							p_nfyinfo->nfy.snddtq.data);
+		break;
+	default:
+		ercd = E_SYS;
+		break;
+	}
+
+	if (ercd != E_OK) {
+		switch (p_nfyinfo->nfymode & ~0x0fU) {
+		case TENFY_SETVAR:
+			*(p_nfyinfo->enfy.setvar.p_var) = (intptr_t) ercd;
+			break;
+		case TENFY_INCVAR:
+			(void) loc_cpu();
+			*(p_nfyinfo->enfy.incvar.p_var) += 1;
+			(void) unl_cpu();
+			break;
+		case TENFY_ACTTSK:
+			(void) act_tsk(p_nfyinfo->enfy.acttsk.tskid);
+			break;
+		case TENFY_WUPTSK:
+			(void) wup_tsk(p_nfyinfo->enfy.wuptsk.tskid);
+			break;
+		case TENFY_SIGSEM:
+			(void) sig_sem(p_nfyinfo->enfy.sigsem.semid);
+			break;
+		case TENFY_SETFLG:
+			(void) set_flg(p_nfyinfo->enfy.setflg.flgid,
+							p_nfyinfo->enfy.setflg.flgptn);
+			break;
+		case TENFY_SNDDTQ:
+			(void) psnd_dtq(p_nfyinfo->enfy.snddtq.dtqid, (intptr_t) ercd);
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+#endif /* TOPPERS_nfyhdr */
Index: asp3_gr_sakura/trunk/kernel/wait.c
===================================================================
--- asp3_gr_sakura/trunk/kernel/wait.c	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/wait.c	(revision 317)
@@ -0,0 +1,230 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å¾
+ã¡ç¶æ
+ç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#include "kernel_impl.h"
+#include "wait.h"
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã¸ã®é·ç§»ï¼ã¿ã¤ã ã¢ã¦ãæå®ï¼
+ */
+#ifdef TOPPERS_waimake
+
+void
+make_wait_tmout(WINFO *p_winfo, TMEVTB *p_tmevtb, TMO tmout)
+{
+	make_non_runnable(p_runtsk);
+	p_runtsk->p_winfo = p_winfo;
+	if (tmout == TMO_FEVR) {
+		p_winfo->p_tmevtb = NULL;
+	}
+	else {
+		assert(tmout <= TMAX_RELTIM);
+		p_winfo->p_tmevtb = p_tmevtb;
+		p_tmevtb->callback = (CBACK) wait_tmout;
+		p_tmevtb->arg = (void *) p_runtsk;
+		tmevtb_enqueue(p_tmevtb, (RELTIM) tmout);
+	}
+}
+
+#endif /* TOPPERS_waimake */
+
+/*
+ *  å¾
+ã¡è§£é¤
+ */
+#ifdef TOPPERS_waicmp
+
+void
+wait_complete(TCB *p_tcb)
+{
+	wait_dequeue_tmevtb(p_tcb);
+	p_tcb->p_winfo->wercd = E_OK;
+	make_non_wait(p_tcb);
+}
+
+#endif /* TOPPERS_waicmp */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãã«ä¼´ãå¾
+ã¡è§£é¤
+ */
+#ifdef TOPPERS_waitmo
+
+void
+wait_tmout(TCB *p_tcb)
+{
+	wait_dequeue_wobj(p_tcb);
+	p_tcb->p_winfo->wercd = E_TMOUT;
+	make_non_wait(p_tcb);
+	if (p_runtsk != p_schedtsk) {
+		request_dispatch();
+	}
+
+	/*
+	 *  ããã§åªå
+åº¦ã®é«ãå²è¾¼ã¿ãåãä»ããï¼
+	 */
+	unlock_cpu();
+	delay_for_interrupt();
+	lock_cpu();
+}
+
+#endif /* TOPPERS_waitmo */
+#ifdef TOPPERS_waitmook
+
+void
+wait_tmout_ok(TCB *p_tcb)
+{
+	p_tcb->p_winfo->wercd = E_OK;
+	make_non_wait(p_tcb);
+	if (p_runtsk != p_schedtsk) {
+		request_dispatch();
+	}
+
+	/*
+	 *  ããã§åªå
+åº¦ã®é«ãå²è¾¼ã¿ãåãä»ããï¼
+	 */
+	unlock_cpu();
+	delay_for_interrupt();
+	lock_cpu();
+}
+
+#endif /* TOPPERS_waitmook */
+
+/*
+ *  å®è¡ä¸­ã®ã¿ã¹ã¯ã®åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã¸ã®æ¿å
+¥
+ *
+ *  å®è¡ä¸­ã®ã¿ã¹ã¯ãï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã¸æ¿å
+¥ããï¼ãª
+ *  ãã¸ã§ã¯ãã®å±æ§ã«å¿ãã¦ï¼FIFOé ã¾ãã¯ã¿ã¹ã¯åªå
+åº¦é ã§æ¿å
+¥ããï¼
+ */
+Inline void
+wobj_queue_insert(WOBJCB *p_wobjcb)
+{
+	if ((p_wobjcb->p_wobjinib->wobjatr & TA_TPRI) != 0U) {
+		queue_insert_tpri(&(p_wobjcb->wait_queue), p_runtsk);
+	}
+	else {
+		queue_insert_prev(&(p_wobjcb->wait_queue), &(p_runtsk->task_queue));
+	}
+}
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+ã¸ã®é·ç§»
+ */
+#ifdef TOPPERS_wobjwai
+
+void
+wobj_make_wait(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj)
+{
+	make_wait(&(p_winfo_wobj->winfo));
+	wobj_queue_insert(p_wobjcb);
+	p_winfo_wobj->p_wobjcb = p_wobjcb;
+	LOG_TSKSTAT(p_runtsk);
+}
+
+#endif /* TOPPERS_wobjwai */
+#ifdef TOPPERS_wobjwaitmo
+
+void
+wobj_make_wait_tmout(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo_wobj,
+								TMEVTB *p_tmevtb, TMO tmout)
+{
+	make_wait_tmout(&(p_winfo_wobj->winfo), p_tmevtb, tmout);
+	wobj_queue_insert(p_wobjcb);
+	p_winfo_wobj->p_wobjcb = p_wobjcb;
+	LOG_TSKSTAT(p_runtsk);
+}
+
+#endif /* TOPPERS_wobjwaitmo */
+
+/*
+ *  å¾
+ã¡ã­ã¥ã¼ã®åæå
+ */
+#ifdef TOPPERS_iniwque
+
+void
+init_wait_queue(QUEUE *p_wait_queue)
+{
+	TCB		*p_tcb;
+
+	while (!queue_empty(p_wait_queue)) {
+		p_tcb = (TCB *) queue_delete_next(p_wait_queue);
+		wait_dequeue_tmevtb(p_tcb);
+		p_tcb->p_winfo->wercd = E_DLT;
+		make_non_wait(p_tcb);
+	}
+}
+
+#endif /* TOPPERS_iniwque */
Index: asp3_gr_sakura/trunk/kernel/wait.h
===================================================================
--- asp3_gr_sakura/trunk/kernel/wait.h	(revision 317)
+++ asp3_gr_sakura/trunk/kernel/wait.h	(revision 317)
@@ -0,0 +1,381 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å¾
+ã¡ç¶æ
+ç®¡çã¢ã¸ã¥ã¼ã«
+ */
+
+#ifndef TOPPERS_WAIT_H
+#define TOPPERS_WAIT_H
+
+#include "kernel_impl.h"
+#include <queue.h>
+#include "task.h"
+#include "time_event.h"
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+åº¦é ã®å¾
+ã¡ã­ã¥ã¼ã¸ã®æ¿å
+¥
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãï¼ã¿ã¹ã¯åªå
+åº¦é ã®ã­ã¥ã¼p_queueã«æ¿å
+¥ããï¼
+ *  ã­ã¥ã¼ã®ä¸­ã«åãåªå
+åº¦ã®ã¿ã¹ã¯ãããå ´åã«ã¯ï¼ãã®æå¾ã«æ¿å
+¥ããï¼
+ */
+Inline void
+queue_insert_tpri(QUEUE *p_queue, TCB *p_tcb)
+{
+	QUEUE	*p_entry;
+	uint_t	pri = p_tcb->priority;
+
+	for (p_entry = p_queue->p_next; p_entry != p_queue;
+										p_entry = p_entry->p_next) {
+		if (pri < ((TCB *) p_entry)->priority) {
+			break;
+		}
+	}
+	queue_insert_prev(p_entry, &(p_tcb->task_queue));
+}
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã¸ã®é·ç§»
+ *
+ *  å®è¡ä¸­ã®ã¿ã¹ã¯ãå¾
+ã¡ç¶æ
+ã«é·ç§»ãããï¼å
+·ä½çã«ã¯ï¼å®è¡ä¸­ã®ã¿ã¹ã¯ã
+ *  ã¬ãã£ã­ã¥ã¼ããåé¤ãï¼TCBã®p_winfoãã£ã¼ã«ãï¼WINFOã®p_tmevtbãã£ã¼
+ *  ã«ããè¨­å®ããï¼
+ */
+Inline void
+make_wait(WINFO *p_winfo)
+{
+	make_non_runnable(p_runtsk);
+	p_runtsk->p_winfo = p_winfo;
+	p_winfo->p_tmevtb = NULL;
+}
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã¸ã®é·ç§»ï¼ã¿ã¤ã ã¢ã¦ãæå®ï¼
+ *
+ *  å®è¡ä¸­ã®ã¿ã¹ã¯ãï¼ã¿ã¤ã ã¢ã¦ãæå®ä»ãã§å¾
+ã¡ç¶æ
+ã«é·ç§»ãããï¼å
+·ä½
+ *  çã«ã¯ï¼å®è¡ä¸­ã®ã¿ã¹ã¯ãã¬ãã£ã­ã¥ã¼ããåé¤ãï¼TCBã®p_winfoãã£ã¼
+ *  ã«ãï¼WINFOã®p_tmevtbãã£ã¼ã«ããè¨­å®ããï¼ã¾ãï¼ã¿ã¤ã ã¤ãã³ãã
+ *  ã­ãã¯ãç»é²ããï¼
+ */
+extern void	make_wait_tmout(WINFO *p_winfo, TMEVTB *p_tmevtb, TMO tmout);
+
+/*
+ *  å¾
+ã¡è§£é¤ã®ããã®ã¿ã¹ã¯ç¶æ
+ã®æ´æ°
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãï¼å¾
+ã¡è§£é¤ããããã¿ã¹ã¯ç¶æ
+ãæ´æ°ããï¼
+ *  å¾
+ã¡è§£é¤ããã¿ã¹ã¯ãå®è¡ã§ããç¶æ
+ã«ãªãå ´åã¯ï¼ã¬ãã£ã­ã¥ã¼ã«ã¤ãª
+ *  ãï¼
+ */
+Inline void
+make_non_wait(TCB *p_tcb)
+{
+	assert(TSTAT_WAITING(p_tcb->tstat));
+
+	if (!TSTAT_SUSPENDED(p_tcb->tstat)) {
+		/*
+		 *  å¾
+ã¡ç¶æ
+ããå®è¡ã§ããç¶æ
+ã¸ã®é·ç§»
+		 */
+		p_tcb->tstat = TS_RUNNABLE;
+		LOG_TSKSTAT(p_tcb);
+		make_runnable(p_tcb);
+	}
+	else {
+		/*
+		 *  äºéå¾
+ã¡ç¶æ
+ããå¼·å¶å¾
+ã¡ç¶æ
+ã¸ã®é·ç§»
+		 */
+		p_tcb->tstat = TS_SUSPENDED;
+		LOG_TSKSTAT(p_tcb);
+	}
+}
+
+/*
+ *  ãªãã¸ã§ã¯ãå¾
+ã¡ã­ã¥ã¼ããã®åé¤
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼ã«ã¤
+ *  ãªããã¦ããã°ï¼å¾
+ã¡ã­ã¥ã¼ããåé¤ããï¼
+ */
+Inline void
+wait_dequeue_wobj(TCB *p_tcb)
+{
+	if (TSTAT_WAIT_WOBJ(p_tcb->tstat)) {
+		queue_delete(&(p_tcb->task_queue));
+	}
+}
+
+/*
+ *  æéå¾
+ã¡ã®ããã®ã¿ã¤ã ã¤ãã³ããã­ãã¯ã®ç»é²è§£é¤
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã«å¯¾ãã¦ï¼æéå¾
+ã¡ã®ããã®ã¿ã¤ã ã¤ãã³ãã
+ *  ã­ãã¯ãç»é²ããã¦ããã°ï¼ãããç»é²è§£é¤ããï¼
+ */
+Inline void
+wait_dequeue_tmevtb(TCB *p_tcb)
+{
+	if (p_tcb->p_winfo->p_tmevtb != NULL) {
+		tmevtb_dequeue(p_tcb->p_winfo->p_tmevtb);
+	}
+}
+
+/*
+ *  å¾
+ã¡è§£é¤
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ã®å¾
+ã¡ç¶æ
+ãè§£é¤ããï¼å
+·ä½çã«ã¯ï¼ã¿ã¤ã ã¤
+ *  ãã³ããã­ãã¯ãç»é²ããã¦ããã°ï¼ãããç»é²è§£é¤ããï¼ã¾ãï¼ã¿ã¹ã¯
+ *  ç¶æ
+ãæ´æ°ãï¼å¾
+ã¡è§£é¤ããã¿ã¹ã¯ããã®è¿å¤ãE_OKã¨ããï¼å¾
+ã¡ã­ã¥ã¼
+ *  ããã®åé¤ã¯è¡ããªãï¼
+ */
+extern void	wait_complete(TCB *p_tcb);
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãã«ä¼´ãå¾
+ã¡è§£é¤
+ *
+ *  p_tcbã§æå®ãããã¿ã¹ã¯ãï¼å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªããã¦ããã°å¾
+ã¡ã­ã¥ã¼
+ *  ããåé¤ãï¼ã¿ã¹ã¯ç¶æ
+ãæ´æ°ããï¼ã¾ãï¼å¾
+ã¡è§£é¤ããã¿ã¹ã¯ããã®è¿
+ *  å¤ãï¼wait_tmoutã§ã¯E_TMOUTï¼wait_tmout_okã§ã¯E_OKã¨ããï¼
+ *
+ *  wait_tmout_okã¯ï¼dly_tskã§ä½¿ãããã®ãã®ã§ï¼å¾
+ã¡ã­ã¥ã¼ããåé¤ãã
+ *  å¦çãè¡ããªãï¼
+ *
+ *  ãããã®é¢æ°ãï¼ã¿ã¤ã ã¤ãã³ãã®ã³ã¼ã«ããã¯é¢æ°ã¨ãã¦ç¨ããããã®
+ *  ãã®ã§ï¼å²è¾¼ã¿ãã³ãã©ããå¼ã³åºããããã¨ãæ³å®ãã¦ããï¼
+ */
+extern void	wait_tmout(TCB *p_tcb);
+extern void	wait_tmout_ok(TCB *p_tcb);
+
+/*
+ *  å¾
+ã¡ã­ã¥ã¼ã®å
+é ­ã®ã¿ã¹ã¯ID
+ *
+ *  p_wait_queueã§æå®ããå¾
+ã¡ã­ã¥ã¼ã®å
+é ­ã®ã¿ã¹ã¯IDãè¿ãï¼å¾
+ã¡ã­ã¥ã¼
+ *  ãç©ºã®å ´åã«ã¯ï¼TSK_NONEãè¿ãï¼
+ */
+Inline ID
+wait_tskid(QUEUE *p_wait_queue)
+{
+	if (!queue_empty(p_wait_queue)) {
+		return(TSKID((TCB *) p_wait_queue->p_next));
+	}
+	else {
+		return(TSK_NONE);
+	}
+}
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨åæä½ã«ã¼ãã³
+ *
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã¨ç®¡çãã­ãã¯ã®å
+é ­é¨åã¯å
+±
+ *  éã«ãªã£ã¦ããï¼ä»¥ä¸ã¯ï¼ãã®å
+±éé¨åãæ±ãããã®åããã³ã«ã¼ãã³ç¾¤
+ *  ã§ããï¼
+ *
+ *  è¤æ°ã®å¾
+ã¡ã­ã¥ã¼ãæã¤åæã»éä¿¡ãªãã¸ã§ã¯ãã®å ´åï¼å
+é ­ä»¥å¤ã®å¾
+ã¡
+ *  ã­ã¥ã¼ãæä½ããå ´åã«ã¯ï¼ãããã®ã«ã¼ãã³ã¯ä½¿ããªãï¼ã¾ãï¼ãªãã¸ã§
+ *  ã¯ãå±æ§ã®TA_TPRIããããåç
+§ããã®ã§ï¼ãã®ããããä»ã®ç®çã«ä½¿ã£ã¦
+ *  ããå ´åãï¼ãããã®ã«ã¼ãã³ã¯ä½¿ããªãï¼
+ */
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã®åæåãã­ãã¯ã®å
+±éé¨å
+ */
+typedef struct wait_object_initialization_block {
+	ATR			wobjatr;		/* ãªãã¸ã§ã¯ãå±æ§ */
+} WOBJINIB;
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ã®å
+±éé¨å
+ */
+typedef struct wait_object_control_block {
+	QUEUE		wait_queue;		/* å¾
+ã¡ã­ã¥ã¼ */
+	const WOBJINIB *p_wobjinib;	/* åæåãã­ãã¯ã¸ã®ãã¤ã³ã¿ */
+} WOBJCB;
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡æ
+å ±ãã­ãã¯ã®å
+±éé¨å
+ *
+ *  ãã®æ§é ä½ã¯ï¼å¾
+ã¡æ
+å ±ãã­ãã¯ï¼WINFOï¼ãæ¡å¼µï¼ãªãã¸ã§ã¯ãæåè¨
+ *  èªã®ç¶æ¿ã«ç¸å½ï¼ãããã®ã§ãããï¼WINFOãå
+±ç¨ä½ã§å®ç¾©ããã¦ããã
+ *  ãã«ï¼1ã¤ã®ãã£ã¼ã«ãã¨ãã¦å«ãã¦ããï¼
+ */
+typedef struct wait_object_waiting_information {
+	WINFO	winfo;			/* æ¨æºã®å¾
+ã¡æ
+å ±ãã­ãã¯ */
+	WOBJCB	*p_wobjcb;		/* å¾
+ã¡ãªãã¸ã§ã¯ãã®ç®¡çãã­ãã¯ */
+} WINFO_WOBJ;
+
+/*
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+ã¸ã®é·ç§»
+ *  
+ *  å®è¡ä¸­ã®ã¿ã¹ã¯ãå¾
+ã¡ç¶æ
+ã«é·ç§»ããï¼åæã»éä¿¡ãªãã¸ã§ã¯ãã®å¾
+ã¡ã­ã¥ã¼
+ *  ã«ã¤ãªãï¼ã¾ãï¼å¾
+ã¡æ
+å ±ãã­ãã¯ï¼WINFOï¼ã®p_wobjcbãè¨­å®ããï¼
+ *  wobj_make_wait_tmoutã¯ï¼ã¿ã¤ã ã¤ãã³ããã­ãã¯ã®ç»é²ãè¡ãï¼
+ */
+extern void	wobj_make_wait(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo);
+extern void	wobj_make_wait_tmout(WOBJCB *p_wobjcb, WINFO_WOBJ *p_winfo,
+											TMEVTB *p_tmevtb, TMO tmout);
+
+/*
+ *  ã¿ã¹ã¯åªå
+åº¦å¤æ´æã®å¦ç
+ *
+ *  åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+ã«ããã¿ã¹ã¯ã®åªå
+åº¦ãå¤æ´ã
+ *  ããå ´åã«ï¼å¾
+ã¡ã­ã¥ã¼ã®ä¸­ã§ã®ã¿ã¹ã¯ã®ä½ç½®ãä¿®æ­£ããï¼
+ */
+Inline void
+wobj_change_priority(WOBJCB *p_wobjcb, TCB *p_tcb)
+{
+	if ((p_wobjcb->p_wobjinib->wobjatr & TA_TPRI) != 0U) {
+		queue_delete(&(p_tcb->task_queue));
+		queue_insert_tpri(&(p_wobjcb->wait_queue), p_tcb);
+	}
+}
+
+/*
+ *  å¾
+ã¡ã­ã¥ã¼ã®åæå
+ *
+ *  å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªããã¦ããã¿ã¹ã¯ããã¹ã¦å¾
+ã¡è§£é¤ããï¼å¾
+ã¡è§£é¤ãã
+ *  ã¿ã¹ã¯ããã®è¿å¤ã¯ï¼E_DLTã¨ããï¼
+ */
+extern void	init_wait_queue(QUEUE *p_wait_queue);
+
+#endif /* TOPPERS_WAIT_H */
Index: asp3_gr_sakura/trunk/library/log_output.c
===================================================================
--- asp3_gr_sakura/trunk/library/log_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/library/log_output.c	(revision 317)
@@ -0,0 +1,218 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã®ãã©ã¼ãããåºå
+ */
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+#include <log_output.h>
+
+/*
+ *  æ°å¤ãæå­åã«å¤æ
+ */
+#define CONVERT_BUFLEN	((sizeof(ULOGPAR) * CHAR_BIT + 2) / 3)
+										/* ULOGPARåã®æ°å¤ã®æå¤§æå­æ° */
+static void
+convert(ULOGPAR val, uint_t radix, const char *radchar,
+			uint_t width, bool_t minus, bool_t padzero, void (*putc)(char))
+{
+	char	buf[CONVERT_BUFLEN];
+	uint_t	i, j;
+
+	i = 0U;
+	do {
+		buf[i++] = radchar[val % radix];
+		val /= radix;
+	} while (i < CONVERT_BUFLEN && val != 0);
+
+	if (minus && width > 0) {
+		width -= 1;
+	}
+	if (minus && padzero) {
+		(*putc)('-');
+	}
+	for (j = i; j < width; j++) {
+		(*putc)(padzero ? '0' : ' ');
+	}
+	if (minus && !padzero) {
+		(*putc)('-');
+	}
+	while (i > 0U) {
+		(*putc)(buf[--i]);
+	}
+}
+
+/*
+ *  æå­åæ´å½¢åºå
+ */
+static const char raddec[] = "0123456789";
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+void
+syslog_printf(const char *format, const LOGPAR *p_args, void (*putc)(char))
+{
+	char		c;
+	uint_t		width;
+	bool_t		padzero;
+	LOGPAR	val;
+	const char	*str;
+
+	while ((c = *format++) != '\0') {
+		if (c != '%') {
+			(*putc)(c);
+			continue;
+		}
+
+		width = 0U;
+		padzero = false;
+		if ((c = *format++) == '0') {
+			padzero = true;
+			c = *format++;
+		}
+		while ('0' <= c && c <= '9') {
+			width = width * 10U + c - '0';
+			c = *format++;
+		}
+		if (c == 'l' || c == 't' || c == 'T') {
+			c = *format++;
+		}
+		switch (c) {
+		case 'd':
+			val = (LOGPAR)(*p_args++);
+			if (val >= 0) {
+				convert((ULOGPAR) val, 10U, raddec,
+											width, false, padzero, putc);
+			}
+			else {
+				convert((ULOGPAR)(-val), 10U, raddec,
+											width, true, padzero, putc);
+			}
+			break;
+		case 'u':
+			val = (LOGPAR)(*p_args++);
+			convert((ULOGPAR) val, 10U, raddec, width, false, padzero, putc);
+			break;
+		case 'x':
+		case 'p':
+			val = (LOGPAR)(*p_args++);
+			convert((ULOGPAR) val, 16U, radhex, width, false, padzero, putc);
+			break;
+		case 'X':
+			val = (LOGPAR)(*p_args++);
+			convert((ULOGPAR) val, 16U, radHEX, width, false, padzero, putc);
+			break;
+		case 'c':
+			(*putc)((char)(LOGPAR)(*p_args++));
+			break;
+		case 's':
+			str = (const char *)(*p_args++);
+			while ((c = *str++) != '\0') {
+				(*putc)(c);
+			}
+			break;
+		case '%':
+			(*putc)('%');
+			break;
+		case '\0':
+			format--;
+			break;
+		default:
+			break;
+		}
+	}
+}
+
+/*
+ *  ã­ã°æ
+å ±ã®åºå
+ */
+void
+syslog_print(const SYSLOG *p_syslog, void (*putc)(char))
+{
+	switch (p_syslog->logtype) {
+	case LOG_TYPE_COMMENT:
+		syslog_printf((const char *)(p_syslog->logpar[0]),
+								&(p_syslog->logpar[1]), putc);
+		break;
+	case LOG_TYPE_ASSERT:
+		syslog_printf("%s:%u: Assertion `%s' failed.",
+								&(p_syslog->logpar[0]), putc);
+		break;
+	default:
+		/*
+		 *  ä»ã®ç¨®å¥ã®ã­ã°æ
+å ±ã«ã¯å¯¾å¿ãã¦ããªãï¼
+		 */
+		break;
+	}
+}
+
+/*
+ *  ã­ã°æ
+å ±åªå¤±ã¡ãã»ã¼ã¸ã®åºå
+ */
+void
+syslog_lostmsg(uint_t lostlog, void (*putc)(char))
+{
+	LOGPAR	lostinfo[1];
+
+	lostinfo[0] = (LOGPAR) lostlog;
+	syslog_printf("%d messages are lost.", lostinfo, putc);
+	(*putc)('\n');
+}
Index: asp3_gr_sakura/trunk/library/strerror.c
===================================================================
--- asp3_gr_sakura/trunk/library/strerror.c	(revision 317)
+++ asp3_gr_sakura/trunk/library/strerror.c	(revision 317)
@@ -0,0 +1,130 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¨ã©ã¼ã¡ãã»ã¼ã¸æå­åãè¿ãé¢æ°
+ */
+
+#include <t_stddef.h>
+#include <t_stdlib.h>
+
+const char *
+itron_strerror(ER ercd)
+{
+	switch (MERCD(ercd)) {
+	case E_OK:
+		return("E_OK");
+
+	case E_SYS:
+		return("E_SYS");
+	case E_NOSPT:
+		return("E_NOSPT");
+	case E_RSFN:
+		return("E_RSFN");
+	case E_RSATR:
+		return("E_RSATR");
+
+	case E_PAR:
+		return("E_PAR");
+	case E_ID:
+		return("E_ID");
+
+	case E_CTX:
+		return("E_CTX");
+	case E_MACV:
+		return("E_MACV");
+	case E_OACV:
+		return("E_OACV");
+	case E_ILUSE:
+		return("E_ILUSE");
+
+	case E_NOMEM:
+		return("E_NOMEM");
+	case E_NOID:
+		return("E_NOID");
+	case E_NORES:
+		return("E_NORES");
+
+	case E_OBJ:
+		return("E_OBJ");
+	case E_NOEXS:
+		return("E_NOEXS");
+	case E_QOVR:
+		return("E_QOVR");
+
+	case E_RLWAI:
+		return("E_RLWAI");
+	case E_TMOUT:
+		return("E_TMOUT");
+	case E_DLT:
+		return("E_DLT");
+	case E_CLS:
+		return("E_CLS");
+	case E_RASTER:
+		return("E_RASTER");
+
+	case E_WBLK:
+		return("E_WBLK");
+	case E_BOVR:
+		return("E_BOVR");
+
+	case E_COMM:
+		return("E_COMM");
+
+	default:
+		return("unknown error");
+	}
+}
Index: asp3_gr_sakura/trunk/library/t_perror.c
===================================================================
--- asp3_gr_sakura/trunk/library/t_perror.c	(revision 317)
+++ asp3_gr_sakura/trunk/library/t_perror.c	(revision 317)
@@ -0,0 +1,71 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2006 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã¨ã©ã¼ã¡ãã»ã¼ã¸ã®åºå
+ */
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+
+void
+t_perror(uint_t prio, const char *file, int_t line, const char *expr, ER ercd)
+{
+	syslog_5(prio, "%s (%d) reported by `%s' in line %d of `%s'.",
+						itron_strerror(ercd), SERCD(ercd), expr, line, file);
+
+}
Index: asp3_gr_sakura/trunk/library/vasyslog.c
===================================================================
--- asp3_gr_sakura/trunk/library/vasyslog.c	(revision 317)
+++ asp3_gr_sakura/trunk/library/vasyslog.c	(revision 317)
@@ -0,0 +1,130 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2014 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å¯å¤æ°å¼æ°ã®ã·ã¹ãã ã­ã°ã©ã¤ãã©ãª
+ */
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+#include <stdarg.h>
+
+#ifndef TOPPERS_OMIT_SYSLOG
+
+void
+syslog(uint_t prio, const char *format, ...)
+{
+	SYSLOG	logbuf;
+	va_list	ap;
+	uint_t	i;
+	char	sz;
+	char	c;
+
+	logbuf.logtype = LOG_TYPE_COMMENT;
+	logbuf.logpar[0] = (LOGPAR) format;
+	i = 1U;
+	va_start(ap, format);
+
+	while ((c = *format++) != '\0' && i < TNUM_LOGPAR) {
+		if (c != '%') {
+			continue;
+		}
+
+		sz = '\0';
+		c = *format++;
+		while ('0' <= c && c <= '9') {
+			c = *format++;
+		}
+		if (c == 'l' || c == 't' || c == 'T') {
+			sz = c;
+			c = *format++;
+		}
+		switch (c) {
+		case 'd':
+			logbuf.logpar[i++] = (sz == 'l') ? (LOGPAR) va_arg(ap, long_t)
+							   : (sz == 't') ? (LOGPAR) va_arg(ap, int32_t)
+							   : (sz == 'T') ? (LOGPAR) va_arg(ap, SYSTIM)
+							   : (LOGPAR) va_arg(ap, int_t);
+			break;
+		case 'u':
+		case 'x':
+		case 'X':
+			logbuf.logpar[i++] = (sz == 'l') ? (LOGPAR) va_arg(ap, ulong_t)
+							   : (sz == 't') ? (LOGPAR) va_arg(ap, uint32_t)
+							   : (sz == 'T') ? (LOGPAR) va_arg(ap, SYSTIM)
+							   : (LOGPAR) va_arg(ap, uint_t);
+			break;
+		case 'p':
+			logbuf.logpar[i++] = (LOGPAR) va_arg(ap, void *);
+			break;
+		case 'c':
+			logbuf.logpar[i++] = (LOGPAR) va_arg(ap, int);
+			break;
+		case 's':
+			logbuf.logpar[i++] = (LOGPAR) va_arg(ap, const char *);
+			break;
+		case '\0':
+			format--;
+			break;
+		default:
+			break;
+		}
+	}
+	va_end(ap);
+	(void) tSysLog_eSysLog_write(prio, &logbuf);
+}
+
+#endif /* TOPPERS_OMIT_SYSLOG */
Index: asp3_gr_sakura/trunk/sample/Makefile
===================================================================
--- asp3_gr_sakura/trunk/sample/Makefile	(revision 317)
+++ asp3_gr_sakura/trunk/sample/Makefile	(revision 317)
@@ -0,0 +1,616 @@
+#
+#  TOPPERS/ASP Kernel
+#      Toyohashi Open Platform for Embedded Real-Time Systems/
+#      Advanced Standard Profile Kernel
+# 
+#  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: Makefile 735 2016-04-03 14:11:07Z ertl-hiro $
+# 
+
+#
+#  ã¿ã¼ã²ããã®æå®ï¼Makefile.targetã§ä¸æ¸ããããã®ãé²ãããï¼
+#
+all:
+
+#
+#  ã¿ã¼ã²ããç¥ç§°ã®å®ç¾©
+#
+TARGET = @(TARGET)
+
+#
+#  ãã­ã°ã©ãã³ã°è¨èªã®å®ç¾©
+#
+SRCLANG = @(SRCLANG)
+ifeq ($(SRCLANG),c)
+	LIBS = -lc
+endif
+ifeq ($(SRCLANG),c++)
+	USE_CXX = true
+	CXXLIBS = -lstdc++ -lm -lc
+	CXXRTS = cxxrt.o newlibrt.o
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+SRCDIR = @(SRCDIR)
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®æ¡å¼µå­ã®è¨­å®
+#
+OBJEXT = @(OBJEXT)
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªï¼libkernel.aï¼ã®ãã£ã¬ã¯ããªå
+#  ï¼ã«ã¼ãã«ã©ã¤ãã©ãªãmakeå¯¾è±¡ã«ããæã¯ï¼ç©ºã«å®ç¾©ããï¼
+#
+KERNEL_LIB = @(KERNEL_LIB)
+
+#
+#  ã«ã¼ãã«ãé¢æ°åä½ã§ã³ã³ãã¤ã«ãããã©ããã®å®ç¾©
+#
+KERNEL_FUNCOBJS = @(KERNEL_FUNCOBJS)
+
+#
+#  TECSãå¤ããã©ããã®å®ç¾©
+#
+OMIT_TECS = @(OMIT_TECS)
+
+#
+#  ãã¬ã¼ã¹ã­ã°ãåå¾ãããã©ããã®å®ç¾©
+#
+ENABLE_TRACE = @(ENABLE_TRACE)
+
+#
+#  éçºãã¼ã«ï¼ã³ã³ãã¤ã©ç­ï¼ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+DEVTOOLDIR = @(DEVTOOLDIR)
+
+#
+#  ã¦ã¼ãã£ãªãã£ãã­ã°ã©ã ã®åç§°
+#
+CFG = @(CFG)
+TECSGEN = @(TECSGEN)
+
+#
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«åã®å®ç¾©
+#
+OBJNAME = asp
+ifdef OBJEXT
+	OBJFILE = $(OBJNAME).$(OBJEXT)
+	CFG1_OUT = cfg1_out.$(OBJEXT)
+else
+	OBJFILE = $(OBJNAME)
+	CFG1_OUT = cfg1_out
+endif
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ãç½®ããã£ã¬ã¯ããªã®å®ç¾©
+#
+DEPDIR = @(DEPDIR)
+
+#
+#  ã¿ã¼ã²ããä¾å­é¨ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TARGETDIR = $(SRCDIR)/target/$(TARGET)
+
+#
+#  ã¿ã¼ã²ããä¾å­ã®å®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(TARGETDIR)/Makefile.target
+
+#
+#  TECSçæãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TECSGENDIR = ./gen
+ifndef OMIT_TECS
+	TECSGEN_TIMESTAMP = $(TECSGENDIR)/tecsgen.timestamp
+	INIT_TECS_COBJ = init_tecs.o
+endif
+
+#
+#  TECSãçæããå®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+#
+ifndef OMIT_TECS
+	GEN_DIR = $(TECSGENDIR)
+	-include $(TECSGENDIR)/Makefile.tecsgen
+endif
+
+#
+#  å
+±éã³ã³ãã¤ã«ãªãã·ã§ã³ã®å®ç¾©
+#
+COPTS := -g @(COPTS) $(COPTS)
+ifndef OMIT_WARNING_ALL
+	COPTS := -Wall $(COPTS)
+endif
+ifndef OMIT_OPTIMIZATION
+	COPTS := -O2 $(COPTS)
+endif
+ifdef OMIT_TECS
+	CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
+endif
+CDEFS := $(CDEFS) @(CDEFS)
+INCLUDES := -I. -I$(SRCDIR)/include $(INCLUDES) -I$(SRCDIR)
+LDFLAGS := $(LDFLAGS) @(LDFLAGS)
+LIBS := $(LIBS) $(CXXLIBS)
+CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
+
+#
+#  ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã«é¢ããå®ç¾©
+#
+APPLNAME = @(APPLNAME)
+APPLDIRS = @(APPLDIRS)
+APPL_CFG = @(CFGFILE)
+APPL_CDL = @(CDLFILE)
+
+APPL_DIRS := $(APPLDIRS) $(SRCDIR)/library
+APPL_ASMOBJS :=
+ifdef USE_CXX
+	APPL_CXXOBJS := @(APPLOBJS)
+	APPL_COBJS :=
+else
+	APPL_COBJS := @(APPLOBJS)
+endif
+APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
+APPL_CFLAGS := $(APPL_CFLAGS)
+ifdef APPLDIRS
+	INCLUDES := $(INCLUDES) $(foreach dir,$(APPLDIRS),-I$(dir))
+endif
+
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+#
+
+NO_USE_TINET_LIBRARY = true
+
+#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+NET_IF = ether
+
+#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+NET_DEV = if_mbed
+
+#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+#SUPPORT_INET6 = true
+SUPPORT_INET4 = true
+
+#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+#API_CFG_IP4MAPPED_ADDR = true
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+SUPPORT_TCP = true
+#SUPPORT_UDP = true
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/Makefile.tinet
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã«é¢ããå®ç¾©
+#
+SYSSVC_DIRS := $(TECSGENDIR) $(SRCDIR)/tecs_kernel \
+				$(SYSSVC_DIRS) $(SRCDIR)/syssvc
+SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
+SYSSVC_COBJS := $(INIT_TECS_COBJ) $(TECS_COBJS) $(SYSSVC_COBJS) \
+				@(SYSSVCOBJS) $(CXXRTS)
+SYSSVC_CFLAGS := $(SYSSVC_CFLAGS)
+INCLUDES := $(INCLUDES) -I$(TECSGENDIR) -I$(SRCDIR)/tecs_kernel
+
+#
+#  ã¿ã¼ã²ãããã¡ã¤ã«
+#
+.PHONY: all
+ifndef OMIT_TECS
+all: tecs
+#	@$(MAKE) check
+	@$(MAKE) check $(OBJNAME).bin
+#	@$(MAKE) check $(OBJNAME).srec
+else
+#all: check
+all: check $(OBJNAME).bin
+#all: check $(OBJNAME).srec
+endif
+
+##### ä»¥ä¸ã¯ç·¨éããªããã¨ #####
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã«é¢ããå®ç¾©
+#
+CFG_TABS := --api-table $(SRCDIR)/tinet/tcpip_api.def:tcpip \
+			--api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
+			--symval-table $(SRCDIR)/tinet/tcpip_sym.def \
+			--symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
+CFG_ASMOBJS := $(CFG_ASMOBJS)
+CFG_COBJS := kernel_cfg.o $(CFG_COBJS)
+CFG_OBJS := $(CFG_ASMOBJS) $(CFG_COBJS)
+CFG2_OUT_SRCS := kernel_cfg.h kernel_cfg.c $(CFG2_OUT_SRCS)
+CFG_CFLAGS := -DTOPPERS_CB_TYPE_ONLY $(CFG_CFLAGS)
+
+#
+#  ã«ã¼ãã«ã«é¢ããå®ç¾©
+#
+#  KERNEL_ASMOBJS: ã«ã¼ãã«ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãã¢ã»ã³ããªè¨èªã®
+#				   ãªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_COBJS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããï¼ã½ã¼ã¹ãCè¨èªã§ï¼ã½ã¼ã¹
+#				 ãã¡ã¤ã«ã¨1å¯¾1ã«å¯¾å¿ãããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#  KERNEL_LCSRCS: ã«ã¼ãã«ã®ã©ã¤ãã©ãªã«å«ããCè¨èªã®ã½ã¼ã¹ãã¡ã¤ã«ã§ï¼
+#				  1ã¤ã®ã½ã¼ã¹ãã¡ã¤ã«ããè¤æ°ã®ãªãã¸ã§ã¯ããã¡ã¤ã«ãç
+#				  æãããã®ï¼
+#  KERNEL_LCOBJS: ä¸ã®ã½ã¼ã¹ãã¡ã¤ã«ããçæããããªãã¸ã§ã¯ããã¡ã¤ã«ï¼
+#
+KERNEL_DIRS := $(KERNEL_DIRS) $(SRCDIR)/kernel
+KERNEL_ASMOBJS := $(KERNEL_ASMOBJS)
+KERNEL_COBJS := $(KERNEL_COBJS)
+KERNEL_CFLAGS := $(KERNEL_CFLAGS) -I$(SRCDIR)/kernel
+
+#
+#  ã«ã¼ãã«ã®ãã¡ã¤ã«æ§æã®å®ç¾©
+#
+include $(SRCDIR)/kernel/Makefile.kernel
+ifdef KERNEL_FUNCOBJS
+	KERNEL_LCSRCS := $(KERNEL_FCSRCS)
+	KERNEL_LCOBJS := $(foreach file,$(KERNEL_FCSRCS),$($(file:.c=)))
+else
+	KERNEL_CFLAGS := -DALLFUNC $(KERNEL_CFLAGS)
+	KERNEL_COBJS := $(KERNEL_COBJS) \
+					$(foreach file,$(KERNEL_FCSRCS),$(file:.c=.o))
+endif
+ifdef OMIT_OFFSET_H
+	OFFSET_H =
+else
+	OFFSET_H = offset.h
+endif
+ifndef TARGET_OFFSET_TRB
+	TARGET_OFFSET_TRB := $(TARGETDIR)/target_offset.trb
+endif
+ifndef TARGET_KERNEL_TRB
+	TARGET_KERNEL_TRB := $(TARGETDIR)/target_kernel.trb
+endif
+ifndef TARGET_CHECK_TRB
+	TARGET_CHECK_TRB := $(TARGETDIR)/target_check.trb
+endif
+ifndef TARGET_KERNEL_CFG
+	TARGET_KERNEL_CFG := $(TARGETDIR)/target_kernel.cfg
+endif
+ifndef TARGET_TCPIP_TRB
+	TARGET_TCPIP_TRB := $(SRCDIR)/tinet/tinet.trb
+endif
+
+#
+#  ã½ã¼ã¹ãã¡ã¤ã«ã®ãããã£ã¬ã¯ããªã«é¢ããå®ç¾©
+#
+vpath %.c $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.S $(KERNEL_DIRS) $(SYSSVC_DIRS) $(APPL_DIRS)
+vpath %.cfg $(APPL_DIRS)
+vpath %.cdl $(APPL_DIRS)
+
+#
+#  ã³ã³ãã¤ã«ã®ããã®å¤æ°ã®å®ç¾©
+#
+KERNEL_LIB_OBJS = $(KERNEL_ASMOBJS) $(KERNEL_COBJS) $(KERNEL_LCOBJS)
+SYSSVC_OBJS = $(SYSSVC_ASMOBJS) $(SYSSVC_COBJS)
+APPL_OBJS = $(APPL_ASMOBJS) $(APPL_COBJS) $(APPL_CXXOBJS)
+ALL_OBJS = $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+											$(END_OBJS) $(HIDDEN_OBJS)
+ALL_LIBS = -lkernel $(LIBS)
+ifdef KERNEL_LIB
+	LIBS_DEP = $(KERNEL_LIB)/libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L$(KERNEL_LIB)
+	REALCLEAN_FILES := libkernel.a $(REALCLEAN_FILES)
+else
+	LIBS_DEP = libkernel.a $(filter %.a,$(LIBS))
+	OBJ_LDFLAGS := $(OBJ_LDFLAGS) -L.
+endif
+
+ifdef TEXT_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Ttext,$(TEXT_START_ADDRESS)
+endif
+ifdef DATA_START_ADDRESS
+	LDFLAGS := $(LDFLAGS) -Wl,-Tdata,$(DATA_START_ADDRESS)
+endif
+ifdef LDSCRIPT
+	LDFLAGS := $(LDFLAGS) -Wl,-T,$(LDSCRIPT)
+endif
+
+#
+#  tecsgenããCããªãã­ã»ããµãå¼ã³åºãéã®ãªãã·ã§ã³ã®å®ç¾©
+#
+TECS_CPP = $(CC) $(CDEFS) $(INCLUDES) $(SYSSVC_CFLAGS) -D TECSGEN -E
+
+#
+#  tecsgenã®å¼åºã
+#
+.PHONY: tecs
+tecs $(TECSGEN_SRCS) $(TECS_HEADERS): $(TECSGEN_TIMESTAMP) ;
+$(TECSGEN_TIMESTAMP): $(APPL_CDL) $(TECS_IMPORTS)
+	$(TECSGEN) $< -R $(INCLUDES) --cpp "$(TECS_CPP)" -g $(TECSGENDIR)
+
+#
+#  ã«ã¼ãã«ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®çæ
+#
+cfg1_out.c cfg1_out.db: cfg1_out.timestamp ;
+cfg1_out.timestamp: $(APPL_CFG) $(TECSGEN_TIMESTAMP)
+	$(CFG) --pass 1 --kernel asp $(INCLUDES) $(CFG_TABS) \
+						-M $(DEPDIR)/cfg1_out_c.d $(TARGET_KERNEL_CFG) $<
+
+$(CFG1_OUT): $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS) $(HIDDEN_OBJS)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(CFG1_OUT_LDFLAGS) -o $(CFG1_OUT) \
+						$(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS)
+
+cfg1_out.syms: $(CFG1_OUT)
+	$(NM) -n $(CFG1_OUT) > cfg1_out.syms
+
+cfg1_out.srec: $(CFG1_OUT)
+	$(OBJCOPY) -O srec -S $(CFG1_OUT) cfg1_out.srec
+
+$(CFG2_OUT_SRCS) cfg2_out.db: kernel_cfg.timestamp ;
+kernel_cfg.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 --kernel asp $(INCLUDES) -T $(TARGET_TCPIP_TRB):tcpip -T $(TARGET_KERNEL_TRB):kernel
+
+#
+#  ãªãã»ãããã¡ã¤ã«ï¼offset.hï¼ã®çæè¦å
+#
+$(OFFSET_H): offset.timestamp ;
+offset.timestamp: cfg1_out.db cfg1_out.syms cfg1_out.srec
+	$(CFG) --pass 2 -O --kernel asp $(INCLUDES) -T $(TARGET_OFFSET_TRB) \
+				--rom-symbol cfg1_out.syms --rom-image cfg1_out.srec
+
+#
+#  ã«ã¼ãã«ã©ã¤ãã©ãªãã¡ã¤ã«ã®çæ
+#
+libkernel.a: $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f libkernel.a
+	$(AR) -rcs libkernel.a $(KERNEL_LIB_OBJS)
+	$(RANLIB) libkernel.a
+
+#
+#  ç¹å¥ãªä¾å­é¢ä¿ã®å®ç¾©
+#
+tBannerMain.o: $(filter-out tBannerMain.o,$(ALL_OBJS)) $(LIBS_DEP)
+
+#
+#  å
+¨ä½ã®ãªã³ã¯
+#
+$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
+	$(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
+			$(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
+			$(ALL_LIBS) $(END_OBJS)
+
+#
+#  ã·ã³ãã«ãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).syms: $(OBJFILE)
+	$(NM) -n $(OBJFILE) > $(OBJNAME).syms
+
+#
+#  ãã¤ããªãã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).bin: $(OBJFILE)
+	$(OBJCOPY) -O binary -S $(OBJFILE) $(OBJNAME).bin
+
+#
+#  Sã¬ã³ã¼ããã¡ã¤ã«ã®çæ
+#
+$(OBJNAME).srec: $(OBJFILE)
+	$(OBJCOPY) -O srec -S $(OBJFILE) $(OBJNAME).srec
+
+#
+#  ã¨ã©ã¼ãã§ãã¯å¦ç
+#
+.PHONY: check
+check: check.timestamp ;
+check.timestamp: cfg2_out.db $(OBJNAME).syms $(OBJNAME).srec
+	$(CFG) --pass 3 --kernel asp -O $(INCLUDES) -T $(TARGET_CHECK_TRB) \
+				--rom-symbol $(OBJNAME).syms --rom-image $(OBJNAME).srec
+	@echo "configuration check passed"
+
+#
+#  ã³ã³ãã¤ã«çµæã®æ¶å»
+#
+.PHONY: clean
+clean:
+	rm -f \#* *~ *.o $(DEPDIR)/*.d $(CLEAN_FILES) check.timestamp
+	rm -f $(OBJFILE) $(OBJNAME).syms $(OBJNAME).srec $(OBJNAME).bin
+	rm -f kernel_cfg.timestamp $(CFG2_OUT_SRCS) cfg2_out.db
+	rm -f offset.timestamp $(OFFSET_H)
+	rm -f cfg1_out.syms cfg1_out.srec $(CFG1_OUT)
+	rm -f cfg1_out.timestamp cfg1_out.c cfg1_out.db
+	rm -rf $(TECSGENDIR)
+ifndef KERNEL_LIB
+	rm -f libkernel.a
+endif
+
+.PHONY: cleankernel
+cleankernel:
+	rm -f $(OFFSET_H) $(KERNEL_LIB_OBJS)
+	rm -f $(KERNEL_LIB_OBJS:%.o=$(DEPDIR)/%.d)
+
+.PHONY: realclean
+realclean: clean
+	rm -f $(REALCLEAN_FILES)
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã®ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãçæãããã¡ã¤ã«ã¯ï¼å
+±éã®ã³ã³ãã¤ã«ãªãã·ã§ã³
+#  ã®ã¿ãä»ãã¦ã³ã³ãã¤ã«ããï¼
+#
+ALL_CFG_COBJS = $(CFG_COBJS) cfg1_out.o
+ALL_CFG_ASMOBJS = $(CFG_ASMOBJS)
+
+$(ALL_CFG_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(CFG_CFLAGS) $<
+
+$(ALL_CFG_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(CFG_CFLAGS) $<
+
+#
+#  ä¾å­é¢ä¿ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+#
+-include $(DEPDIR)/*.d
+
+#
+#  éçºãã¼ã«ã®ã³ãã³ãåã®å®ç¾©
+#
+ifeq ($(TOOL),gcc)
+	#
+	#  GNUéçºç°å¢ç¨
+	#
+	ifdef GCC_TARGET
+		GCC_TARGET_PREFIX = $(GCC_TARGET)-
+	else
+		GCC_TARGET_PREFIX =
+	endif
+	CC := $(GCC_TARGET_PREFIX)gcc
+	CXX := $(GCC_TARGET_PREFIX)g++
+	AS := $(GCC_TARGET_PREFIX)as
+	LD := $(GCC_TARGET_PREFIX)ld
+	AR := $(GCC_TARGET_PREFIX)ar
+	NM := $(GCC_TARGET_PREFIX)nm
+	RANLIB := $(GCC_TARGET_PREFIX)ranlib
+	OBJCOPY := $(GCC_TARGET_PREFIX)objcopy
+	OBJDUMP := $(GCC_TARGET_PREFIX)objdump
+endif
+
+ifdef DEVTOOLDIR
+	CC := $(DEVTOOLDIR)/$(CC)
+	CXX := $(DEVTOOLDIR)/$(CXX)
+	AS := $(DEVTOOLDIR)/$(AS)
+	LD := $(DEVTOOLDIR)/$(LD)
+	AR := $(DEVTOOLDIR)/$(AR)
+	NM := $(DEVTOOLDIR)/$(NM)
+	RANLIB := $(DEVTOOLDIR)/$(RANLIB)
+	OBJCOPY := $(DEVTOOLDIR)/$(OBJCOPY)
+	OBJDUMP := $(DEVTOOLDIR)/$(OBJDUMP)
+endif
+
+ifdef USE_CXX
+	LINK = $(CXX)
+else
+	LINK = $(CC)
+endif
+
+#
+#  ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+$(KERNEL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS): %.o:
+	$(CC) -DTOPPERS_$(*F) -o $@ -c -MD -MP -MF $(DEPDIR)/$*.d \
+									$(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_LCOBJS:.o=.s): %.s:
+	$(CC) -DTOPPERS_$(*F) -o $@ -S $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(KERNEL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(SYSSVC_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(SYSSVC_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+$(APPL_COBJS): %.o: %.c
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_COBJS:.o=.s): %.s: %.c
+	$(CC) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS): %.o: %.cpp
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_CXXOBJS:.o=.s): %.s: %.cpp
+	$(CXX) -S $(CFLAGS) $(APPL_CFLAGS) $<
+
+$(APPL_ASMOBJS): %.o: %.S
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
+
+#
+#  ããã©ã«ãã³ã³ãã¤ã«ã«ã¼ã«ãä¸æ¸ã
+#
+%.o: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.c
+	@echo "*** Default compile rules should not be used."
+	$(CC) -S $(CFLAGS) $<
+
+%.o: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
+
+%.s: %.cpp
+	@echo "*** Default compile rules should not be used."
+	$(CXX) -S $(CFLAGS) $<
+
+%.o: %.S
+	@echo "*** Default compile rules should not be used."
+	$(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $<
Index: asp3_gr_sakura/trunk/sample/route_cfg.c
===================================================================
--- asp3_gr_sakura/trunk/sample/route_cfg.c	(revision 317)
+++ asp3_gr_sakura/trunk/sample/route_cfg.c	(revision 317)
@@ -0,0 +1,113 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+#include <kernel.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef _IP6_CFG
+
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+T_IN6_RTENTRY routing6_tbl[NUM_IN6_ROUTE_ENTRY];
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
+
+#endif	/* of #ifdef _IP6_CFG */
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef _IP4_CFG
+
+#ifdef SUPPORT_LOOP
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_PPP
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+
+	/* ç°ãªã LANãdefault gateway ã«ããéæ¥é
+é	*/
+	{ 0,			0,			IPV4_ADDR_DEFAULT_GW	},
+
+	/* åä¸ LAN å
+ãç´æ¥é
+é				*/
+	{ IPV4_ADDR_LOCAL &
+	  IPV4_ADDR_LOCAL_MASK,	IPV4_ADDR_LOCAL_MASK,	0			},
+
+	/* åä¸ LAN å
+ã¸ã®ãã­ã¼ãã­ã£ã¹ããç´æ¥é
+é	*/
+	{ 0xffffffff,		0xffffffff,		0			},
+
+	};
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifdef _IP4_CFG */
Index: asp3_gr_sakura/trunk/sample/sample1.c
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1.c	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1.c	(revision 317)
@@ -0,0 +1,655 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/* 
+ *  ãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+ *
+ *  ASPã«ã¼ãã«ã®åºæ¬çãªåä½ãç¢ºèªããããã®ãµã³ãã«ãã­ã°ã©ã ï¼
+ *
+ *  ãã­ã°ã©ã ã®æ¦è¦:
+ *
+ *  ã¦ã¼ã¶ã¤ã³ã¿ãã§ã¼ã¹ãåãæã¤ã¡ã¤ã³ã¿ã¹ã¯ï¼ã¿ã¹ã¯ID: MAIN_TASKï¼åª
+ *  å
+åº¦: MAIN_PRIORITYï¼ã¨ï¼3ã¤ã®ä¸¦è¡å®è¡ãããã¿ã¹ã¯ï¼ã¿ã¹ã¯ID:
+ *  TASK1ï½TASK3ï¼åæåªå
+åº¦: MID_PRIORITYï¼ã§æ§æãããï¼ã¾ãï¼èµ·åå¨
+ *  æã2ç§ã®å¨æãã³ãã©ï¼å¨æãã³ãã©ID: CYCHDR1ï¼ãç¨ããï¼
+ *
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯ã¯ï¼task_loopåç©ºã«ã¼ããå®è¡ããåº¦ã«ï¼ã¿ã¹ã¯ã
+ *  å®è¡ä¸­ã§ãããã¨ãããããã¡ãã»ã¼ã¸ãè¡¨ç¤ºããï¼ç©ºã«ã¼ããå®è¡ãã
+ *  ã®ã¯ï¼ç©ºã«ã¼ããªãã§ã¡ãã»ã¼ã¸ãåºåããã¨ï¼å¤éã®ã¡ãã»ã¼ã¸ãåºå
+ *  ããï¼ãã­ã°ã©ã ã®åä½ãç¢ºèªãããããªãããã§ããï¼ã¾ãï¼ä½éãªã·
+ *  ãªã¢ã«ãã¼ããç¨ãã¦ã¡ãã»ã¼ã¸ãåºåããå ´åã«ï¼ãã¹ã¦ã®ã¡ãã»ã¼ã¸
+ *  ãåºåã§ããããã«ï¼ã¡ãã»ã¼ã¸ã®éãå¶éããã¨ããçç±ãããï¼
+ *
+ *  å¨æãã³ãã©ã¯ï¼ä¸ã¤ã®åªå
+åº¦ï¼HIGH_PRIORITYï¼MID_PRIORITYï¼
+ *  LOW_PRIORITYï¼ã®ã¬ãã£ã­ã¥ã¼ãåè»¢ãããï¼ãã­ã°ã©ã ã®èµ·åç´å¾ã¯ï¼
+ *  å¨æãã³ãã©ã¯åæ­¢ç¶æ
+ã«ãªã£ã¦ããï¼
+ *
+ *  ã¡ã¤ã³ã¿ã¹ã¯ã¯ï¼ã·ãªã¢ã«I/Oãã¼ãããã®æå­å
+¥åãè¡ãï¼æå­å
+¥åã
+ *  å¾
+ã£ã¦ããéã¯ï¼ä¸¦è¡å®è¡ãããã¿ã¹ã¯ãå®è¡ããã¦ããï¼ï¼å
+¥åããã
+ *  æå­ã«å¯¾å¿ããå¦çãå®è¡ããï¼å
+¥åãããæå­ã¨å¦çã®é¢ä¿ã¯æ¬¡ã®éãï¼
+ *  Control-Cã¾ãã¯'Q'ãå
+¥åãããã¨ï¼ãã­ã°ã©ã ãçµäºããï¼
+ *
+ *  '1' : å¯¾è±¡ã¿ã¹ã¯ãTASK1ã«åãæããï¼åæè¨­å®ï¼ï¼
+ *  '2' : å¯¾è±¡ã¿ã¹ã¯ãTASK2ã«åãæããï¼
+ *  '3' : å¯¾è±¡ã¿ã¹ã¯ãTASK3ã«åãæããï¼
+ *  'a' : å¯¾è±¡ã¿ã¹ã¯ãact_tskã«ããèµ·åããï¼
+ *  'A' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ããèµ·åè¦æ±ãcan_actã«ããã­ã£ã³ã»ã«ããï¼
+ *  'e' : å¯¾è±¡ã¿ã¹ã¯ã«ext_tskãå¼ã³åºããï¼çµäºãããï¼
+ *  't' : å¯¾è±¡ã¿ã¹ã¯ãter_tskã«ããå¼·å¶çµäºããï¼
+ *  '>' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãHIGH_PRIORITYã«ããï¼
+ *  '=' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãMID_PRIORITYã«ããï¼
+ *  '<' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãLOW_PRIORITYã«ããï¼
+ *  'G' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãget_priã§èª­ã¿åºãï¼
+ *  's' : å¯¾è±¡ã¿ã¹ã¯ã«slp_tskãå¼ã³åºããï¼èµ·åºå¾
+ã¡ã«ãããï¼
+ *  'S' : å¯¾è±¡ã¿ã¹ã¯ã«tslp_tsk(10ç§)ãå¼ã³åºããï¼èµ·åºå¾
+ã¡ã«ãããï¼
+ *  'w' : å¯¾è±¡ã¿ã¹ã¯ãwup_tskã«ããèµ·åºããï¼
+ *  'W' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ããèµ·åºè¦æ±ãcan_wupã«ããã­ã£ã³ã»ã«ããï¼
+ *  'l' : å¯¾è±¡ã¿ã¹ã¯ãrel_waiã«ããå¼·å¶çã«å¾
+ã¡è§£é¤ã«ããï¼
+ *  'u' : å¯¾è±¡ã¿ã¹ã¯ãsus_tskã«ããå¼·å¶å¾
+ã¡ç¶æ
+ã«ããï¼
+ *  'm' : å¯¾è±¡ã¿ã¹ã¯ã®å¼·å¶å¾
+ã¡ç¶æ
+ãrsm_tskã«ããè§£é¤ããï¼
+ *  'd' : å¯¾è±¡ã¿ã¹ã¯ã«dly_tsk(10ç§)ãå¼ã³åºããï¼æéçµéå¾
+ã¡ã«ãããï¼
+ *  'x' : å¯¾è±¡ã¿ã¹ã¯ã«ras_terã«ããçµäºè¦æ±ããï¼
+ *  'y' : å¯¾è±¡ã¿ã¹ã¯ã«dis_terãå¼ã³åºããï¼ã¿ã¹ã¯çµäºãç¦æ­¢ããï¼
+ *  'Y' : å¯¾è±¡ã¿ã¹ã¯ã«ena_terãå¼ã³åºããï¼ã¿ã¹ã¯çµäºãè¨±å¯ããï¼
+ *  'r' : 3ã¤ã®åªå
+åº¦ï¼HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITYï¼ã®ã¬
+ *        ãã£ã­ã¥ã¼ãåè»¢ãããï¼
+ *  'c' : å¨æãã³ãã©ãåä½éå§ãããï¼
+ *  'C' : å¨æãã³ãã©ãåä½åæ­¢ãããï¼
+ *  'b' : ã¢ã©ã¼ã ãã³ãã©ã5ç§å¾ã«èµ·åããããåä½éå§ãããï¼
+ *  'B' : ã¢ã©ã¼ã ãã³ãã©ãåä½åæ­¢ãããï¼
+ *  'z' : å¯¾è±¡ã¿ã¹ã¯ã«CPUä¾å¤ãçºçãããï¼ã¿ã¹ã¯ãçµäºãããï¼ï¼
+ *  'Z' : å¯¾è±¡ã¿ã¹ã¯ã«CPUã­ãã¯ç¶æ
+ã§CPUä¾å¤ãçºçãããï¼ãã­ã°ã©ã ã
+ *        çµäºããï¼ï¼
+ *  '@' : ã¿ã¹ã¯3ãacre_tskã«ããçæããï¼
+ *  '!' : å¯¾è±¡ã¿ã¹ã¯ãdel_tskã«ããåé¤ããï¼
+ *  '$' : ã¢ã©ã¼ã ãã³ãã©ãacre_almã«ããçæããï¼
+ *  '#' : ã¢ã©ã¼ã ãã³ãã©ãdel_almã«ããåé¤ããï¼
+ *  'V' : fch_hrtã§é«åè§£è½ã¿ã¤ãã2åèª­ãï¼
+ *  'o' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ãã¦ãªã¼ãã©ã³ãã³ãã©ãåä½éå§ããã
+ *  'O' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ãã¦ãªã¼ãã©ã³ãã³ãã©ãåä½åæ­¢ããã
+ *  'v' : çºè¡ããã·ã¹ãã ã³ã¼ã«ãè¡¨ç¤ºããï¼ããã©ã«ãï¼ï¼
+ *  'q' : çºè¡ããã·ã¹ãã ã³ã¼ã«ãè¡¨ç¤ºããªãï¼
+ */
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include "syssvc/serial.h"
+#include "syssvc/syslog.h"
+#include "kernel_cfg.h"
+#include "sample1.h"
+/*#include "sample1n.h"*/
+
+/*
+ *  ãµã¼ãã¹ã³ã¼ã«ã®ã¨ã©ã¼ã®ã­ã°åºå
+ */
+Inline void
+svc_perror(const char *file, int_t line, const char *expr, ER ercd)
+{
+	if (ercd < 0) {
+		t_perror(LOG_ERROR, file, line, expr, ercd);
+	}
+}
+
+#define	SVC_PERROR(expr)	svc_perror(__FILE__, __LINE__, #expr, (expr))
+
+/*
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯ã¸ã®ã¡ãã»ã¼ã¸é å
+ */
+char	message[3];
+
+/*
+ *  ã«ã¼ãåæ°
+ */
+ulong_t	task_loop;		/* ã¿ã¹ã¯å
+ã§ã®ã«ã¼ãåæ° */
+
+/*
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯
+ */
+void task(intptr_t exinf)
+{
+	volatile ulong_t	i;
+	int_t		n = 0;
+	int_t		tskno = (int_t) exinf;
+	const char	*graph[] = { "|", "  +", "    *" };
+	char		c;
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	T_ROVR		pk_rovr;
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+	while (true) {
+#ifdef TOPPERS_SUPPORT_OVRHDR
+		SVC_PERROR(ref_ovr(TSK_SELF, &pk_rovr));
+		if ((pk_rovr.ovrstat & TOVR_STA) != 0) {
+			syslog(LOG_NOTICE, "task%d is running (%03d).   %s  [%ld]",
+								tskno, ++n, graph[tskno-1], pk_rovr.leftotm);
+		}
+		else {
+			syslog(LOG_NOTICE, "task%d is running (%03d).   %s",
+										tskno, ++n, graph[tskno-1]);
+		}
+#else /* TOPPERS_SUPPORT_OVRHDR */
+		syslog(LOG_NOTICE, "task%d is running (%03d).   %s",
+										tskno, ++n, graph[tskno-1]);
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+		for (i = 0; i < task_loop; i++);
+		c = message[tskno-1];
+		message[tskno-1] = 0;
+		switch (c) {
+		case 'e':
+			syslog(LOG_INFO, "#%d#ext_tsk()", tskno);
+			SVC_PERROR(ext_tsk());
+			assert(0);
+		case 's':
+			syslog(LOG_INFO, "#%d#slp_tsk()", tskno);
+			SVC_PERROR(slp_tsk());
+			break;
+		case 'S':
+			syslog(LOG_INFO, "#%d#tslp_tsk(10000000)", tskno);
+			SVC_PERROR(tslp_tsk(10000000));
+			break;
+		case 'd':
+			syslog(LOG_INFO, "#%d#dly_tsk(10000000)", tskno);
+			SVC_PERROR(dly_tsk(10000000));
+			break;
+		case 'y':
+			syslog(LOG_INFO, "#%d#dis_ter()", tskno);
+			SVC_PERROR(dis_ter());
+			break;
+		case 'Y':
+			syslog(LOG_INFO, "#%d#ena_ter()", tskno);
+			SVC_PERROR(ena_ter());
+			break;
+#ifdef CPUEXC1
+		case 'z':
+			syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno);
+			RAISE_CPU_EXCEPTION;
+			break;
+		case 'Z':
+			SVC_PERROR(loc_cpu());
+			syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno);
+			RAISE_CPU_EXCEPTION;
+			SVC_PERROR(unl_cpu());
+			break;
+#endif /* CPUEXC1 */
+		default:
+			break;
+		}
+	}
+}
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©
+ */
+#ifdef INTNO1
+
+void intno1_isr(intptr_t exinf)
+{
+	intno1_clear();
+	SVC_PERROR(rot_rdq(HIGH_PRIORITY));
+	SVC_PERROR(rot_rdq(MID_PRIORITY));
+	SVC_PERROR(rot_rdq(LOW_PRIORITY));
+}
+
+#endif /* INTNO1 */
+
+/*
+ *  CPUä¾å¤ãã³ãã©
+ */
+ID	cpuexc_tskid;		/* CPUä¾å¤ãèµ·ãããã¿ã¹ã¯ã®ID */
+
+#ifdef CPUEXC1
+
+void
+cpuexc_handler(void *p_excinf)
+{
+	syslog(LOG_NOTICE, "CPU exception handler (p_excinf = %08p).", p_excinf);
+	if (sns_ctx() != true) {
+		syslog(LOG_WARNING,
+					"sns_ctx() is not true in CPU exception handler.");
+	}
+	if (sns_dpn() != true) {
+		syslog(LOG_WARNING,
+					"sns_dpn() is not true in CPU exception handler.");
+	}
+	syslog(LOG_INFO, "sns_loc = %d sns_dsp = %d xsns_dpn = %d",
+								sns_loc(), sns_dsp(), xsns_dpn(p_excinf));
+
+	if (xsns_dpn(p_excinf)) {
+		syslog(LOG_NOTICE, "Sample program ends with exception.");
+		SVC_PERROR(ext_ker());
+		assert(0);
+	}
+
+#ifdef PREPARE_RETURN_CPUEXC
+	PREPARE_RETURN_CPUEXC;
+	SVC_PERROR(get_tid(&cpuexc_tskid));
+	SVC_PERROR(act_tsk(EXC_TASK));
+#else /* PREPARE_RETURN_CPUEXC */
+	syslog(LOG_NOTICE, "Sample program ends with exception.");
+	SVC_PERROR(ext_ker());
+	assert(0);
+#endif /* PREPARE_RETURN_CPUEXC */
+}
+
+#endif /* CPUEXC1 */
+
+/*
+ *  å¨æãã³ãã©
+ *
+ *  HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITY ã®ååªå
+åº¦ã®ã¬ãã£ã­ã¥ã¼
+ *  ãåè»¢ãããï¼
+ */
+void cyclic_handler(intptr_t exinf)
+{
+	SVC_PERROR(rot_rdq(HIGH_PRIORITY));
+	SVC_PERROR(rot_rdq(MID_PRIORITY));
+	SVC_PERROR(rot_rdq(LOW_PRIORITY));
+}
+
+/*
+ *  ã¢ã©ã¼ã ãã³ãã©
+ *
+ *  HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITY ã®ååªå
+åº¦ã®ã¬ãã£ã­ã¥ã¼
+ *  ãåè»¢ãããï¼
+ */
+void alarm_handler(intptr_t exinf)
+{
+	SVC_PERROR(rot_rdq(HIGH_PRIORITY));
+	SVC_PERROR(rot_rdq(MID_PRIORITY));
+	SVC_PERROR(rot_rdq(LOW_PRIORITY));
+}
+
+/*
+ *  ä¾å¤å¦çã¿ã¹ã¯
+ */
+void exc_task(intptr_t exinf)
+{
+	SVC_PERROR(ras_ter(cpuexc_tskid));
+}
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©
+ */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+
+void
+overrun_handler(ID tskid, intptr_t exinf)
+{
+	int_t	tskno = (int_t) exinf;
+
+	syslog(LOG_NOTICE, "Overrun handler for task%d.", tskno);
+}
+
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+/*
+ *  ã¡ã¤ã³ã¿ã¹ã¯
+ */
+void main_task(intptr_t exinf)
+{
+	char	c;
+	ID		tskid = TASK1;
+	int_t	tskno = 1;
+	ER_UINT	ercd;
+	PRI		tskpri;
+#ifndef TASK_LOOP
+	volatile ulong_t	i;
+	SYSTIM	stime1, stime2;
+#endif /* TASK_LOOP */
+	HRTCNT	hrtcnt1, hrtcnt2;
+	T_CTSK	ctsk;
+	ID		TASK3 = -1;
+	T_CALM	calm;
+	ID		ALMHDR1 = -1;
+
+	SVC_PERROR(syslog_msk_log(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_EMERG)));
+	syslog(LOG_NOTICE, "Sample program starts (exinf = %d).", (int_t) exinf);
+
+	/*
+	 *  ã·ãªã¢ã«ãã¼ãã®åæå
+	 *
+	 *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¨åãã·ãªã¢ã«ãã¼ããä½¿ãå ´åãªã©ï¼ã·ãªã¢ã«
+	 *  ãã¼ãããªã¼ãã³æ¸ã¿ã®å ´åã«ã¯ããã§E_OBJã¨ã©ã¼ã«ãªããï¼æ¯éã¯
+	 *  ãªãï¼
+	 */
+	ercd = serial_opn_por(TASK_PORTID);
+	if (ercd < 0 && MERCD(ercd) != E_OBJ) {
+		syslog(LOG_ERROR, "%s (%d) reported by `serial_opn_por'.",
+									itron_strerror(ercd), SERCD(ercd));
+	}
+	SVC_PERROR(serial_ctl_por(TASK_PORTID,
+							(IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV)));
+
+	/*
+ 	 *  ã«ã¼ãåæ°ã®è¨­å®
+	 *
+	 *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯å
+ã§ã®ç©ºã«ã¼ãã®åæ°ï¼task_loopï¼ã¯ï¼ç©ºã«ã¼
+	 *  ãã®å®è¡æéãç´0.4ç§ã«ãªãããã«è¨­å®ããï¼ãã®è¨­å®ã®ããã«ï¼
+	 *  LOOP_REFåã®ç©ºã«ã¼ãã®å®è¡æéãï¼ãã®åå¾ã§get_timãå¼ã¶ãã¨ã§
+	 *  æ¸¬å®ãï¼ãã®æ¸¬å®çµæããç©ºã«ã¼ãã®å®è¡æéã0.4ç§ã«ãªãã«ã¼ãå
+	 *  æ°ãæ±ãï¼task_loopã«è¨­å®ããï¼
+	 *
+	 *  LOOP_REFã¯ï¼ããã©ã«ãã§ã¯1,000,000ã«è¨­å®ãã¦ãããï¼æ³å®ããã
+	 *  ãé
+ããã­ã»ããµã§ã¯ï¼ãµã³ãã«ãã­ã°ã©ã ã®å®è¡éå§ã«æéããã
+	 *  ããããã¨ããåé¡ãçããï¼éã«æ³å®ããããéããã­ã»ããµã§ã¯ï¼
+	 *  LOOP_REFåã®ç©ºã«ã¼ãã®å®è¡æéãç­ããªãï¼task_loopã«è¨­å®ããå¤
+	 *  ã®èª¤å·®ãå¤§ãããªãã¨ããåé¡ãããï¼
+	 *
+	 *  ããã§ï¼ãã®ãããªã¿ã¼ã²ããã§ã¯ï¼target_test.hã§ï¼LOOP_REFãé©
+	 *  åãªå¤ã«å®ç¾©ããã®ãæã¾ããï¼
+	 *
+	 *  ã¾ãï¼task_loopã®å¤ãåºå®ãããå ´åã«ã¯ï¼ãã®å¤ãTASK_LOOPã«ã
+	 *  ã¯ã­å®ç¾©ããï¼TASK_LOOPããã¯ã­å®ç¾©ããã¦ããå ´åï¼ä¸è¨ã®æ¸¬å®ã
+	 *  è¡ããã«ï¼TASK_LOOPã«å®ç¾©ãããå¤ãç©ºã«ã¼ãã®åæ°ã¨ããï¼
+	 *
+	 * ã¿ã¼ã²ããã«ãã£ã¦ã¯ï¼ç©ºã«ã¼ãã®å®è¡æéã®1åç®ã®æ¸¬å®ã§ï¼æ¬æ¥ã
+	 * ããé·ãã«ãªããã®ãããï¼ãã®ãããªã¿ã¼ã²ããã§ã¯ï¼MEASURE_TWICE
+	 * ããã¯ã­å®ç¾©ãããã¨ã§ï¼1åç®ã®æ¸¬å®çµæãæ¨ã¦ã¦ï¼2åç®ã®æ¸¬å®çµæ
+	 * ãä½¿ãï¼
+	 */
+#ifdef TASK_LOOP
+	task_loop = TASK_LOOP;
+#else /* TASK_LOOP */
+
+#ifdef MEASURE_TWICE
+	task_loop = LOOP_REF;
+	SVC_PERROR(get_tim(&stime1));
+	for (i = 0; i < task_loop; i++);
+	SVC_PERROR(get_tim(&stime2));
+#endif /* MEASURE_TWICE */
+
+	task_loop = LOOP_REF;
+	SVC_PERROR(get_tim(&stime1));
+	for (i = 0; i < task_loop; i++);
+	SVC_PERROR(get_tim(&stime2));
+	task_loop = LOOP_REF * 400LU / (ulong_t)(stime2 - stime1) * 1000LU;
+
+#endif /* TASK_LOOP */
+
+	/*
+ 	 *  ã¿ã¹ã¯ã®èµ·å
+	 */
+	SVC_PERROR(act_tsk(TASK1));
+	SVC_PERROR(act_tsk(TASK2));
+
+	/*
+ 	 *  ã¡ã¤ã³ã«ã¼ã
+	 */
+	do {
+		SVC_PERROR(serial_rea_dat(TASK_PORTID, &c, 1));
+		switch (c) {
+		case 'e':
+		case 's':
+		case 'S':
+		case 'd':
+		case 'y':
+		case 'Y':
+		case 'z':
+		case 'Z':
+			message[tskno-1] = c;
+			break;
+		case '1':
+			tskno = 1;
+			tskid = TASK1;
+			break;
+		case '2':
+			tskno = 2;
+			tskid = TASK2;
+			break;
+		case '3':
+			tskno = 3;
+			tskid = TASK3;
+			break;
+		case 'a':
+			syslog(LOG_INFO, "#act_tsk(%d)", tskno);
+			SVC_PERROR(act_tsk(tskid));
+			break;
+		case 'A':
+			syslog(LOG_INFO, "#can_act(%d)", tskno);
+			SVC_PERROR(ercd = can_act(tskid));
+			if (ercd >= 0) {
+				syslog(LOG_NOTICE, "can_act(%d) returns %d", tskno, ercd);
+			}
+			break;
+		case 't':
+			syslog(LOG_INFO, "#ter_tsk(%d)", tskno);
+			SVC_PERROR(ter_tsk(tskid));
+			break;
+		case '>':
+			syslog(LOG_INFO, "#chg_pri(%d, HIGH_PRIORITY)", tskno);
+			SVC_PERROR(chg_pri(tskid, HIGH_PRIORITY));
+			break;
+		case '=':
+			syslog(LOG_INFO, "#chg_pri(%d, MID_PRIORITY)", tskno);
+			SVC_PERROR(chg_pri(tskid, MID_PRIORITY));
+			break;
+		case '<':
+			syslog(LOG_INFO, "#chg_pri(%d, LOW_PRIORITY)", tskno);
+			SVC_PERROR(chg_pri(tskid, LOW_PRIORITY));
+			break;
+		case 'G':
+			syslog(LOG_INFO, "#get_pri(%d, &tskpri)", tskno);
+			SVC_PERROR(ercd = get_pri(tskid, &tskpri));
+			if (ercd >= 0) {
+				syslog(LOG_NOTICE, "priority of task %d is %d", tskno, tskpri);
+			}
+			break;
+		case 'w':
+			syslog(LOG_INFO, "#wup_tsk(%d)", tskno);
+			SVC_PERROR(wup_tsk(tskid));
+			break;
+		case 'W':
+			syslog(LOG_INFO, "#can_wup(%d)", tskno);
+			SVC_PERROR(ercd = can_wup(tskid));
+			if (ercd >= 0) {
+				syslog(LOG_NOTICE, "can_wup(%d) returns %d", tskno, ercd);
+			}
+			break;
+		case 'l':
+			syslog(LOG_INFO, "#rel_wai(%d)", tskno);
+			SVC_PERROR(rel_wai(tskid));
+			break;
+		case 'u':
+			syslog(LOG_INFO, "#sus_tsk(%d)", tskno);
+			SVC_PERROR(sus_tsk(tskid));
+			break;
+		case 'm':
+			syslog(LOG_INFO, "#rsm_tsk(%d)", tskno);
+			SVC_PERROR(rsm_tsk(tskid));
+			break;
+		case 'x':
+			syslog(LOG_INFO, "#ras_ter(%d)", tskno);
+			SVC_PERROR(ras_ter(tskid));
+			break;
+		case 'r':
+			syslog(LOG_INFO, "#rot_rdq(three priorities)");
+			SVC_PERROR(rot_rdq(HIGH_PRIORITY));
+			SVC_PERROR(rot_rdq(MID_PRIORITY));
+			SVC_PERROR(rot_rdq(LOW_PRIORITY));
+			break;
+		case 'c':
+			syslog(LOG_INFO, "#sta_cyc(1)");
+			SVC_PERROR(sta_cyc(CYCHDR1));
+			break;
+		case 'C':
+			syslog(LOG_INFO, "#stp_cyc(1)");
+			SVC_PERROR(stp_cyc(CYCHDR1));
+			break;
+		case 'b':
+			syslog(LOG_INFO, "#sta_alm(1, 5000000)");
+			SVC_PERROR(sta_alm(ALMHDR1, 5000000));
+			break;
+		case 'B':
+			syslog(LOG_INFO, "#stp_alm(1)");
+			SVC_PERROR(stp_alm(ALMHDR1));
+			break;
+		case '@':
+			ctsk.tskatr = TA_NULL;
+			ctsk.exinf = 3;
+			ctsk.task = task;
+			ctsk.itskpri = MID_PRIORITY;
+			ctsk.stksz = STACK_SIZE;
+			ctsk.stk = NULL;
+			SVC_PERROR(TASK3 = acre_tsk(&ctsk));
+			syslog(LOG_NOTICE, "task3 is created with tskid = %d.",
+														(int_t) TASK3);
+			break;
+		case '!':
+			syslog(LOG_INFO, "#del_tsk(%d)", tskno);
+			SVC_PERROR(del_tsk(tskid));
+			break;
+		case '$':
+			calm.almatr = TA_NULL;
+			calm.nfyinfo.nfymode = TNFY_HANDLER;
+			calm.nfyinfo.nfy.handler.exinf = (intptr_t) 0;
+			calm.nfyinfo.nfy.handler.tmehdr = (TMEHDR) alarm_handler;
+			SVC_PERROR(ALMHDR1 = acre_alm(&calm));
+			syslog(LOG_NOTICE, "alarm handler is created with almid = %d.",
+														(int_t) ALMHDR1);
+			break;
+		case '#':
+			syslog(LOG_INFO, "#del_alm(1)");
+			SVC_PERROR(del_alm(ALMHDR1));
+			break;
+
+		case 'V':
+			hrtcnt1 = fch_hrt();
+			hrtcnt2 = fch_hrt();
+			syslog(LOG_NOTICE, "hrtcnt1 = %tu, hrtcnt2 = %tu",
+										hrtcnt1, hrtcnt2);
+			break;
+
+		case 'o':
+#ifdef TOPPERS_SUPPORT_OVRHDR
+			syslog(LOG_INFO, "#sta_ovr(%d, 2000000)", tskno);
+			SVC_PERROR(sta_ovr(tskid, 2000000));
+#else /* TOPPERS_SUPPORT_OVRHDR */
+			syslog(LOG_NOTICE, "sta_ovr is not supported.");
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+			break;
+		case 'O':
+#ifdef TOPPERS_SUPPORT_OVRHDR
+			syslog(LOG_INFO, "#stp_ovr(%d)", tskno);
+			SVC_PERROR(stp_ovr(tskid));
+#else /* TOPPERS_SUPPORT_OVRHDR */
+			syslog(LOG_NOTICE, "stp_ovr is not supported.");
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+			break;
+
+		case 'v':
+			SVC_PERROR(syslog_msk_log(LOG_UPTO(LOG_INFO),
+										LOG_UPTO(LOG_EMERG)));
+			break;
+		case 'q':
+			SVC_PERROR(syslog_msk_log(LOG_UPTO(LOG_NOTICE),
+										LOG_UPTO(LOG_EMERG)));
+			break;
+
+#ifdef BIT_KERNEL
+		case ' ':
+			SVC_PERROR(loc_cpu());
+			{
+				extern ER	bit_kernel(void);
+
+				SVC_PERROR(ercd = bit_kernel());
+				if (ercd >= 0) {
+					syslog(LOG_NOTICE, "bit_kernel passed.");
+				}
+			}
+			SVC_PERROR(unl_cpu());
+			break;
+#endif /* BIT_KERNEL */
+
+		default:
+			break;
+		}
+	} while (c != '\003' && c != 'Q');
+
+	syslog(LOG_NOTICE, "Sample program ends.");
+	SVC_PERROR(ext_ker());
+	assert(0);
+}
Index: asp3_gr_sakura/trunk/sample/sample1.cdl
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1.cdl	(revision 317)
@@ -0,0 +1,125 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+/*
+ *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å®ç¾©
+ */
+import(<kernel.cdl>);
+
+/*
+ *  ã¿ã¼ã²ããéä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
+ */
+import("syssvc/tSerialPort.cdl");
+import("syssvc/tSerialAdapter.cdl");
+import("syssvc/tSysLog.cdl");
+import("syssvc/tSysLogAdapter.cdl");
+import("syssvc/tLogTask.cdl");
+import("syssvc/tBanner.cdl");
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ã®åãè¾¼ã¿
+ */
+import("target.cdl");
+
+/*
+ *  ãã»ã«ã®çµä¸ãè¨è¿°ãã¨ã¯ï¼"cell"ã§å§ã¾ãè¡ããï¼ããã«å¯¾å¿ãã"};"
+ *  ã®è¡ã¾ã§ã®ãã¨ãè¨ãï¼
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãï¼ã³
+ *  ã³ãã¤ã«ãªãã·ã§ã³ã«-DTOPPERS_OMIT_SYSLOGãè¿½å ããã°ããï¼ãã ãï¼
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ã¹ãã ã­ã°æ©è½ãä½¿ç¨ããããï¼ãããå¤ããã¨
+ *  ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ã¹ãã ã­ã°æ©è½ã®ã¢ããã¿ãå¤ããªããã°ãªããª
+ *  ãï¼tecsgenãè­¦åã¡ãã»ã¼ã¸ãåºããï¼ç¡è¦ãã¦ããï¼
+ */
+cell tSysLog SysLog {
+	logBufferSize = 32;					/* ã­ã°ãããã¡ã®ãµã¤ãº */
+	initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
+										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
+									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°æ©è½
+ *  ãå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ãµã¼ãã¹ã³ã¼ã«ï¼syslogé¢æ°ã¨syslog_0é¢æ°ï½syslog_5
+ *  é¢æ°ä»¥å¤ã®ãã®ï¼ã«ãCè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºããª
+ *  ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ããã°ããï¼
+ */
+cell tSysLogAdapter SysLogAdapter {
+	cSysLog = SysLog.eSysLog;
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨
+ *  è¿°ãåé¤ããã°ããï¼ãã ãï¼ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼
+ *  ã¹ãã©ã¤ããä½¿ç¨ããããï¼ãããå¤ããã¨ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ãªã¢
+ *  ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¢ããã¿ãå¤ããªããã°ãªããªãï¼
+ */
+cell tSerialPort SerialPort1 {
+	receiveBufferSize = 256;			/* åä¿¡ãããã¡ã®ãµã¤ãº */
+	sendBufferSize    = 256;			/* éä¿¡ãããã¡ã®ãµã¤ãº */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã¨ã®çµå */
+	cSIOPort = SIOPortTarget1.eSIOPort;
+	eiSIOCBR <= SIOPortTarget1.ciSIOCBR;	/* ã³ã¼ã«ããã¯ */
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³ã¿
+ *  ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ãµã¼ãã¹ã³ã¼ã«ãCè¨èªã§è¨è¿°ãããã¢
+ *  ããªã±ã¼ã·ã§ã³ããå¼ã³åºããªãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãå
+ *  é¤ããã°ããï¼
+ */
+cell tSerialAdapter SerialAdapter {
+	cSerialPort[0] = SerialPort1.eSerialPort;
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãã
+ *  ã°ããï¼
+ */
+cell tLogTask LogTask {
+	priority  = 3;					/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åªå
+åº¦ */
+	stackSize = LogTaskStackSize;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+	/* ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå */
+	cSerialPort        = SerialPort1.eSerialPort;
+	cnSerialPortManage = SerialPort1.enSerialPortManage;
+
+	/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®çµå */
+	cSysLog = SysLog.eSysLog;
+
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®çµä¸ãè¨è¿°
+ *
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°
+ *  ãåé¤ããã°ããï¼
+ */
+cell tBanner Banner {
+	/* å±æ§ã®è¨­å® */
+	targetName      = BannerTargetName;
+	copyrightNotice = BannerCopyrightNotice;
+};
Index: asp3_gr_sakura/trunk/sample/sample1.cfg
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1.cfg	(revision 317)
@@ -0,0 +1,26 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+INCLUDE("tecsgen.cfg");
+
+#include "sample1.h"
+CRE_TSK(TASK1, { TA_NULL, 1, task, MID_PRIORITY, STACK_SIZE, NULL });
+CRE_TSK(TASK2, { TA_NULL, 2, task, MID_PRIORITY, STACK_SIZE, NULL });
+CRE_TSK(MAIN_TASK, { TA_ACT, 0, main_task, MAIN_PRIORITY, STACK_SIZE, NULL });
+CRE_TSK(EXC_TASK, { TA_NULL, 0, exc_task, EXC_PRIORITY, STACK_SIZE, NULL });
+AID_TSK(3);
+CRE_CYC(CYCHDR1, { TA_NULL, { TNFY_HANDLER, 0, cyclic_handler }, 2000000, 0 });
+AID_ALM(1);
+#ifdef TOPPERS_SUPPORT_OVRHDR
+DEF_OVR({ TA_NULL, overrun_handler });
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+#ifdef INTNO1
+CFG_INT(INTNO1, { INTNO1_INTATR, INTNO1_INTPRI });
+CRE_ISR(INTNO1_ISR, { TA_NULL, 0, INTNO1, intno1_isr, 1 });
+#endif /* INTNO1 */
+#ifdef CPUEXC1
+DEF_EXC(CPUEXC1, { TA_NULL, cpuexc_handler });
+#endif /* CPUEXC1 */
+DEF_KMM({ KMM_SIZE, NULL });
Index: asp3_gr_sakura/trunk/sample/sample1.h
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1.h	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1.h	(revision 317)
@@ -0,0 +1,126 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ *
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ *
+ *  $Id$
+ */
+
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ããããã¡ã¤ã«
+ */
+
+#include <kernel.h>
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®å®ç¾©
+ */
+#include "target_test.h"
+
+/*
+ *  åã¿ã¹ã¯ã®åªå
+åº¦ã®å®ç¾©
+ */
+
+#define EXC_PRIORITY	1		/* ä¾å¤å¦çã¿ã¹ã¯ã®åªå
+åº¦ */
+#define MAIN_PRIORITY	5		/* ã¡ã¤ã³ã¿ã¹ã¯ã®åªå
+åº¦ */
+								/* HIGH_PRIORITYããé«ããããã¨ */
+
+#define HIGH_PRIORITY	9		/* ä¸¦è¡å®è¡ãããã¿ã¹ã¯ã®åªå
+åº¦ */
+#define MID_PRIORITY	10
+#define LOW_PRIORITY	11
+
+/*
+ *  ã¿ã¼ã²ããã«ä¾å­ããå¯è½æ§ã®ããå®æ°ã®å®ç¾©
+ */
+
+#ifndef TASK_PORTID
+#define	TASK_PORTID		1			/* æå­å
+¥åããã·ãªã¢ã«ãã¼ãID */
+#endif /* TASK_PORTID */
+
+#ifndef STACK_SIZE
+#define	STACK_SIZE		4096		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+#endif /* STACK_SIZE */
+
+#ifndef KMM_SIZE
+#define	KMM_SIZE		(STACK_SIZE * 16)	/* ã«ã¼ãã«ãå²ãä»ãã   */
+#endif /* KMM_SIZE */						/*     ã¡ã¢ãªé åã®ãµã¤ãº */
+
+#ifndef LOOP_REF
+#define LOOP_REF		ULONG_C(1000000)	/* éåº¦è¨æ¸¬ç¨ã®ã«ã¼ãåæ° */
+#endif /* LOOP_REF */
+
+/*
+ *  é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+extern void	task(intptr_t exinf);
+extern void	main_task(intptr_t exinf);
+extern void exc_task(intptr_t exinf);
+#ifdef INTNO1
+extern void intno1_isr(intptr_t exinf);
+#endif /* INTNO1 */
+#ifdef CPUEXC1
+extern void	cpuexc_handler(void *p_excinf);
+#endif /* CPUEXC1 */
+extern void	cyclic_handler(intptr_t exinf);
+extern void	alarm_handler(intptr_t exinf);
+#ifdef TOPPERS_SUPPORT_OVRHDR
+extern void	overrun_handler(ID tskid, intptr_t exinf);
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+#endif /* TOPPERS_MACRO_ONLY */
Index: asp3_gr_sakura/trunk/sample/sample1n.c
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1n.c	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1n.c	(revision 317)
@@ -0,0 +1,787 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯åãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+ */
+
+#include <stdarg.h>
+
+#include <kernel.h>
+#include "syssvc/syslog.h"
+#include "syssvc/serial.h"
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include "sample1n.h"
+
+/*
+ *  ãã¯ã­å®ç¾©
+ */
+
+/*  ãªãã¼ã ã®è§£é¤  */
+
+#undef syslog
+#undef serial_rea_dat
+#undef serial_ctl_por
+
+#define EOF		(-1)
+
+/*  TELNET ãªãã·ã§ã³ */
+
+#define TELNET_OPT_SE		(240)
+#define TELNET_OPT_NOP		(241)
+#define TELNET_OPT_DM		(242)
+#define TELNET_OPT_BRK		(243)
+#define TELNET_OPT_IP		(244)
+#define TELNET_OPT_AO		(245)
+#define TELNET_OPT_AYT		(246)
+#define TELNET_OPT_EC		(247)
+#define TELNET_OPT_EL		(248)
+#define TELNET_OPT_GA		(249)
+#define TELNET_OPT_SB		(250)
+#define TELNET_OPT_WILL		(251)
+#define TELNET_OPT_WONT		(252)
+#define TELNET_OPT_DO		(253)
+#define TELNET_OPT_DONT		(254)
+#define TELNET_OPT_IAC		(255)
+
+/*
+ *  å¤æ°
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+uint8_t tcp_swbuf[TCP_SWBUF_SIZE];
+uint8_t tcp_rwbuf[TCP_RWBUF_SIZE];
+
+bool_t		connected	= false;	/* ã³ãã¯ã·ã§ã³ã®ç¶æ
+	*/
+bool_t		wait_accept	= false;	/* æ¥ç¶è¦æ±å¾
+ã¡ä¸­	*/
+
+#ifdef SUPPORT_INET6
+
+T_IPV6EP	dst;
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+T_IPV4EP	dst;
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+uint8_t		*snd_buff	= NULL;
+uint8_t		*rcv_buff	= NULL;
+uint_t		snd_off		= 0;
+uint_t		rcv_off		= 0;
+ER_UINT		snd_len		= 0;
+ER_UINT		rcv_len		= 0;
+uint_t		net_ioctl	= IOCTL_NULL;
+uint8_t		addr[sizeof("0123:4567:89ab:cdef:0123:4567:89ab:cdef")];
+
+/*
+ *  ãããã¯ã¼ã¯å±¤ã®é¸æ
+ */
+
+#ifdef SUPPORT_INET6
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ipv62str(s,a)
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ip2str(s,a)
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		IP2STR((char *)addr, &dst.ipaddr);
+		syslog(LOG_NOTICE, "connected:    %s.%d", addr, dst.portno);
+		if (*(ER*)p_parblk == E_OK)
+			connected = true;
+		snd_len = snd_off = rcv_len = rcv_off = 0;
+		wait_accept = false;
+		break;
+
+	case TFN_TCP_CLS_CEP:
+	case TFN_TCP_RCV_BUF:
+	case TFN_TCP_GET_BUF:
+	case TFN_TCP_RCV_DAT:
+	case TFN_TCP_SND_DAT:
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  ã³ãã¯ã·ã§ã³ãåæ­
+ */
+
+ER
+disconnecting (void)
+{
+	ER	error = E_OK;
+
+	if (connected) {
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off > 0)
+			tcp_snd_buf(TCP_CEPID, snd_off);
+		tcp_sht_cep(TCP_CEPID);
+		tcp_cls_cep(TCP_CEPID, TMO_FEVR);
+		connected = false;
+		syscall(sig_sem(SEM_NET_SEND));
+		IP2STR((char *)addr, &dst.ipaddr);
+		syslog(LOG_NOTICE, "disconnected: %s.%d", addr, dst.portno);
+		}
+	return error;
+	}
+
+/*
+ *  éä¿¡ãããã¡ã®ãã©ãã·ã¥
+ */
+
+void
+flush_snd_buff (ID cepid)
+{
+	if (connected) {
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off > 0) {
+			tcp_snd_buf(cepid, snd_off);
+			snd_len = snd_off = 0;
+			}
+		syscall(sig_sem(SEM_NET_SEND));
+		}
+	return;
+	}
+
+/*
+ *  æå­éä¿¡
+ */
+
+void
+put_char (ID cepid, char ch)
+{
+	if (connected) {
+		if (ch == '\n' && (net_ioctl & IOCTL_CRLF) != 0)
+			put_char(cepid, '\r');
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off >= snd_len) {
+			if (tcp_snd_buf(cepid, snd_off) != E_OK) {
+				syscall(sig_sem(SEM_NET_SEND));
+				return;
+				}
+			snd_off = 0;
+			if ((snd_len = tcp_get_buf(cepid, (void**)&snd_buff, TMO_FEVR)) <= 0) {
+				syscall(sig_sem(SEM_NET_SEND));
+				return;
+				}
+			}
+		snd_buff[snd_off ++] = ch;
+		syscall(sig_sem(SEM_NET_SEND));
+		}
+	}
+
+/*
+ *  æå­åä¿¡ï¼å¤æãªãï¼
+ */
+
+int_t
+get_char_raw (ID cepid)
+{
+	if (connected) {
+		if (rcv_off >= rcv_len) {
+			rcv_off = 0;
+			if (tcp_rel_buf(TCP_CEPID, rcv_len) != E_OK) {
+				disconnecting();
+				return EOF;
+				}
+			if ((rcv_len = tcp_rcv_buf(TCP_CEPID, (void**)&rcv_buff, TMO_FEVR)) == 0) {
+				disconnecting();
+				return EOF;
+				}
+			else if (rcv_len < 0) {
+				disconnecting();
+				return EOF;
+				}
+			}
+		return rcv_buff[rcv_off ++];
+		}
+	else
+		return EOF;
+	}
+
+/*
+ *  æå­åä¿¡ï¼TELNET ãªãã·ã§ã³ãã¹ã­ããï¼
+ */
+
+int_t
+get_char (ID cepid)
+{
+	int_t	ch, req;
+
+	while ((ch = get_char_raw(cepid)) == TELNET_OPT_IAC || ch == '\0') {
+		if (ch != '\0') {
+			switch (ch = get_char_raw(cepid)) {
+			case TELNET_OPT_WILL:
+			case TELNET_OPT_WONT:
+			case TELNET_OPT_DO:
+			case TELNET_OPT_DONT:
+				req = get_char_raw(cepid);
+				break;
+			case TELNET_OPT_SB:
+				while ((ch = get_char_raw(cepid)) != EOF && ch != TELNET_OPT_IAC) {
+					if ((ch = get_char_raw(cepid)) == EOF || ch == TELNET_OPT_SE)
+						break;
+					}
+				break;
+			default:
+				break;
+				}
+			}
+		}
+	return ch;
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®èª­åºã
+ */
+
+ER_UINT
+net_serial_rea_dat (ID portid, char *buf, uint_t len)
+{
+	T_SERIAL_RPOR	rpor;
+	uint_t		off;
+	int_t		ch;
+
+	if (!wait_accept && !connected) {
+		wait_accept = true;
+		if (TCP_ACP_CEP(TCP_CEPID, TCP_REPID, &dst, TMO_NBLK) != E_WBLK)
+			return 0;
+		}
+
+	while (true) {
+		if (connected) {
+			off = 0;
+			while (off < len && (ch = get_char(TCP_CEPID)) != EOF) {
+				*(buf + off ++) = ch;
+				if ((net_ioctl & IOCTL_ECHO) != 0) {
+					put_char(TCP_CEPID, ch);
+					flush_snd_buff(TCP_CEPID);
+					}
+				}
+			return off;
+			}
+		else if (serial_ref_por(portid, &rpor) == E_OK && rpor.reacnt > 0) {
+			return serial_rea_dat(portid, buf, len);
+			}
+		dly_tsk(500000);
+		}
+	return off;
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡
+ */
+
+ER
+net_serial_ctl_por (ID portid, uint_t ioctl)
+{
+	net_ioctl = ioctl;
+	return serial_ctl_por(portid, ioctl);
+	}
+
+/*
+ *  ãã£ã¨ãé·ãæ´æ°å (LONGEST) ã¨ç¬¦å·ãªãæ´æ°å (ULONGEST)
+ */
+
+#ifdef LONGLONG_TYPE
+
+typedef LONGLONG_TYPE		LONGEST;
+typedef unsigned LONGLONG_TYPE	ULONGEST;
+
+#else	/* of #ifdef LONGLONG_TYPE */
+
+#ifdef LONG_TYPE
+
+typedef LONG_TYPE		LONGEST;
+typedef unsigned LONG_TYPE	ULONGEST;
+
+#else	/* of #ifdef LONG_TYPE */
+
+typedef int_t			LONGEST;
+typedef uint_t			ULONGEST;
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#endif	/* of #ifdef LONGLONG_TYPE */
+
+/*
+ *  ã­ã°ã®ã·ãã¥ã¬ã¼ã·ã§ã³
+ */
+
+/*  æ°å¤å¤æã®ããã®å¤æè¡¨  */
+
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  put_num -- printf ã®æ°å¤å¤æ
+ */
+
+int_t
+put_num(ID cepid, ULONGEST val, int_t radix, const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+	bool_t	left;
+
+	if (width < 0) {
+		width = -width;
+		left = true;
+		}
+	else
+		left = false;
+
+	ix = 0;
+	do {
+		digits[ix ++] = radchar[val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	pad = ix;
+	if (!left)	/* å³è©°ã */
+		for ( ; pad < width; pad ++)
+			put_char(cepid, padchar);
+
+	while (ix -- > 0)
+		put_char(cepid, digits[ix]);
+
+	if (left)	/* å·¦è©°ã */
+		for ( ; pad < width; pad ++)
+			put_char(cepid, padchar);
+
+	return pchars;
+	}
+
+/*
+ *  ipv6addr -- IPv6 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv6addr (ID cepid, const T_IN6_ADDR *addr, int_t width)
+{
+	int_t	len = 0, ix;
+	bool_t	omit = false, zero = false;
+
+	if (addr == NULL) {
+		put_char(cepid, '0');
+		put_char(cepid, ':');
+		put_char(cepid, ':');
+		put_char(cepid, '0');
+		len = 4;
+		}
+	else {
+		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+			if (omit) {
+				len += put_num(cepid, addr->s6_addr16[ix], 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					put_char(cepid, ':');
+					len ++;
+					}
+				}
+			else if (ix > 0 && ix < 7 && addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					put_char(cepid, ':');
+					len ++;
+					}
+				len += put_num(cepid, addr->s6_addr16[ix], 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					put_char(cepid, ':');
+					len ++;
+					}
+				}
+			}
+
+		for ( ; len < width; len ++)
+			put_char(cepid, ' ');
+		}
+	return len;
+	}
+
+/*
+ *  put_ipv4addr -- IPv4 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv4addr (ID cepid, ULONGEST *addr, int_t width)
+{
+	int_t len = 3;	/* 3 ã¯ '.' ã®æå­æ° */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+	len += put_num(cepid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+
+#else	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	len += put_num(cepid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+
+#endif	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	for ( ; len < width; len ++)
+		put_char(cepid, ' ');
+
+	return len;
+	}
+
+/*
+ *  put_macaddr -- MAC ã¢ãã¬ã¹åºå
+ */
+
+static int_t
+put_macaddr (ID cepid, char *mac, int_t width)
+{
+	int_t oct, len;
+
+	for (oct = 5; oct -- > 0; ) {
+		put_num(cepid, *mac ++, 16, radhex, 2, false, '0'); 
+		put_char(cepid, ':');
+		}
+	put_num(cepid, *mac, 16, radhex, 2, false, '0'); 
+
+	for (len = 17; len < width; len ++)
+		put_char(cepid, ' ');
+
+	return len;
+	}
+
+/*
+ *  å¼æ°ãåãåºãããã®ãã¯ã­
+ */
+
+#ifdef LONGLONG_TYPE
+
+#ifdef LONG_TYPE
+
+#define GET_ARG(ap,lf)	((lf > 1) ? va_arg(ap, LONGLONG_TYPE)	\
+			 (lf      ? va_arg(ap, LONG_TYPE)	\
+			          : va_arg(ap, int_t)))
+
+#else	/* of #ifdef LONG_TYPE */
+
+#define GET_ARG(ap,lf)	((lf > 1) ? va_arg(ap, LONGLONG_TYPE)	\
+			          : va_arg(ap, int_t))
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#else	/* of #ifdef LONGLONG_TYPE */
+
+#ifdef LONG_TYPE
+
+#define GET_ARG(ap,lf)	 (lf      ? va_arg(ap, LONG_TYPE)	\
+			          : va_arg(ap, int_t))
+
+#else	/* of #ifdef LONG_TYPE */
+
+#define GET_ARG(ap,lf)	(va_arg(ap, int_t))
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#endif	/* of #ifdef LONGLONG_TYPE */
+
+/*
+ *  ã­ã°åºå
+ */
+
+void
+net_syslog (uint_t prio, const char *format, ...)
+{
+	LONGEST	val;
+	SYSLOG	log;
+	va_list	ap;
+	char	padchar, *str;
+	int_t	ch, width, longflag, shortflag, left, i, c;
+
+	if (connected) {
+		syscall(wai_sem(SEM_TCP_SYSLOG));
+		va_start(ap, format);
+		while ((ch = *format ++) != '\0') {
+			if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+				put_char(TCP_CEPID, (char)ch);
+				continue;
+				}
+
+			width = longflag = shortflag = 0;
+			padchar = ' ';
+
+			if (ch == '-') {		/* å·¦è©°ã */
+				format ++;
+				left = -1;
+				}
+			else
+				left = 1;
+
+			if ((ch = *format ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+				padchar = '0';
+				ch = *format ++;
+				}
+
+			while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+				width = width * 10 + ch - '0';
+				ch = *format ++;
+				}
+
+			while (ch == 'l') {		/* long (long) ã®æå® */
+				longflag ++;
+				ch = *format ++;
+				}
+
+			while (ch == 'h') {		/* short ã®æå® */
+				shortflag ++;
+				ch = *format ++;
+				}
+
+			switch (ch) {
+			case 'd':
+				val = GET_ARG(ap, longflag);
+				if (val >= 0)
+					put_num(TCP_CEPID,  val, 10, radhex, width * left, false, padchar);
+				else
+					put_num(TCP_CEPID, -val, 10, radhex, width * left, true, padchar);
+				break;
+
+			case 'u':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 10, radhex, width * left, false, padchar);
+				break;
+
+			case 'x':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 16, radhex, width * left, false, padchar);
+				break;
+
+			case 'X':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 16, radHEX, width * left, false, padchar);
+				break;
+
+			case 'c':
+				ch = va_arg(ap, int_t);
+				put_char(TCP_CEPID, (char)ch);
+				break;
+
+			case 's':
+				str = va_arg(ap, char*);
+				while ((ch = *str ++) != '\0') {
+					put_char(TCP_CEPID, (char)ch);
+					width --;
+					}
+				while (width -- > 0)
+					put_char(TCP_CEPID, ' ');
+				break;
+
+			case 'I':
+
+				if (longflag) {
+					str = va_arg(ap, char*);
+					put_ipv6addr(TCP_CEPID, (T_IN6_ADDR *)str, width);
+					}
+				else if (shortflag) {
+					val = GET_ARG(ap, longflag);
+					put_ipv4addr(TCP_CEPID, (ULONGEST *)val, width);
+					}
+				else {
+
+#ifdef SUPPORT_INET6
+
+					str = va_arg(ap, char*);
+					put_ipv6addr(TCP_CEPID, (T_IN6_ADDR *)str, width);
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+					val = GET_ARG(ap, longflag);
+					put_ipv4addr(TCP_CEPID, (ULONGEST *)val, width);
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+					}
+
+				break;
+
+			case 'M':
+				str = va_arg(ap, char*);
+				put_macaddr(TCP_CEPID, str, width);
+				break;
+
+			case '%':
+				put_char(TCP_CEPID, '%');
+				break;
+
+			case '0':
+				format --;
+				break;
+
+			default:
+				break;
+				}
+
+			}
+		va_end(ap);
+		put_char(TCP_CEPID, '\n');
+		flush_snd_buff(TCP_CEPID);
+		syscall(sig_sem(SEM_TCP_SYSLOG));
+		return;
+		}
+	else {
+		log.logtype = LOG_TYPE_COMMENT;
+		log.logpar[0] = (intptr_t)format;
+		i = 1;
+		va_start(ap, format);
+
+		while ((c = *format++) != '\0' && i < TNUM_LOGPAR) {
+			if (c != '%') {
+				continue;
+				}
+
+			longflag = 0;
+			c = *format++;
+			while ('0' <= c && c <= '9') {
+				c = *format++;
+				}
+
+			while (c == 'l') {
+				longflag = 1;
+				c = *format++;
+			}
+
+			switch (c) {
+			case 'd':
+				if(longflag == 1) {
+					log.logpar[i++] = (intptr_t)va_arg(ap, long_t);
+				}
+				else {
+					log.logpar[i++] = (intptr_t)va_arg(ap, int_t);
+				}
+				break;
+			case 'u':
+			case 'x':
+			case 'X':
+				log.logpar[i++] = (intptr_t)va_arg(ap, uint_t);
+				break;
+			case 'p':
+				log.logpar[i++] = (intptr_t)va_arg(ap, void *);
+				break;
+			case 'c':
+				log.logpar[i++] = (intptr_t)va_arg(ap, int_t);
+				break;
+			case 's':
+				log.logpar[i++] = (intptr_t)va_arg(ap, const char *);
+				break;
+			case '\0':
+				format--;
+				break;
+			default:
+				break;
+				}
+			}
+		va_end(ap);
+		syslog_wri_log(prio, &log);
+		return;
+		}
+	}
Index: asp3_gr_sakura/trunk/sample/sample1n.cdl
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1n.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1n.cdl	(revision 317)
@@ -0,0 +1,125 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (1)ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+/*
+ *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å®ç¾©
+ */
+import(<kernel.cdl>);
+
+/*
+ *  ã¿ã¼ã²ããéä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
+ */
+import("syssvc/tSerialPort.cdl");
+import("syssvc/tSerialAdapter.cdl");
+import("syssvc/tSysLog.cdl");
+import("syssvc/tSysLogAdapter.cdl");
+import("syssvc/tLogTask.cdl");
+import("syssvc/tBanner.cdl");
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ã®åãè¾¼ã¿
+ */
+import("target.cdl");
+
+/*
+ *  ãã»ã«ã®çµä¸ãè¨è¿°ãã¨ã¯ï¼"cell"ã§å§ã¾ãè¡ããï¼ããã«å¯¾å¿ãã"};"
+ *  ã®è¡ã¾ã§ã®ãã¨ãè¨ãï¼
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãï¼ã³
+ *  ã³ãã¤ã«ãªãã·ã§ã³ã«-DTOPPERS_OMIT_SYSLOGãè¿½å ããã°ããï¼ãã ãï¼
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ã¹ãã ã­ã°æ©è½ãä½¿ç¨ããããï¼ãããå¤ããã¨
+ *  ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ã¹ãã ã­ã°æ©è½ã®ã¢ããã¿ãå¤ããªããã°ãªããª
+ *  ãï¼tecsgenãè­¦åã¡ãã»ã¼ã¸ãåºããï¼ç¡è¦ãã¦ããï¼
+ */
+cell tSysLog SysLog {
+	logBufferSize = 32;					/* ã­ã°ãããã¡ã®ãµã¤ãº */
+	initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
+										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
+									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°æ©è½
+ *  ãå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ãµã¼ãã¹ã³ã¼ã«ï¼syslogé¢æ°ã¨syslog_0é¢æ°ï½syslog_5
+ *  é¢æ°ä»¥å¤ã®ãã®ï¼ã«ãCè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºããª
+ *  ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ããã°ããï¼
+ */
+cell tSysLogAdapter SysLogAdapter {
+	cSysLog = SysLog.eSysLog;
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨
+ *  è¿°ãåé¤ããã°ããï¼ãã ãï¼ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼
+ *  ã¹ãã©ã¤ããä½¿ç¨ããããï¼ãããå¤ããã¨ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ãªã¢
+ *  ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¢ããã¿ãå¤ããªããã°ãªããªãï¼
+ */
+cell tSerialPort SerialPort1 {
+	receiveBufferSize = 256;			/* åä¿¡ãããã¡ã®ãµã¤ãº */
+	sendBufferSize    = 256;			/* éä¿¡ãããã¡ã®ãµã¤ãº */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã¨ã®çµå */
+	cSIOPort = SIOPortTarget1.eSIOPort;
+	eiSIOCBR <= SIOPortTarget1.ciSIOCBR;	/* ã³ã¼ã«ããã¯ */
+};
+
+/*
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³ã¿
+ *  ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ãµã¼ãã¹ã³ã¼ã«ãCè¨èªã§è¨è¿°ãããã¢
+ *  ããªã±ã¼ã·ã§ã³ããå¼ã³åºããªãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãå
+ *  é¤ããã°ããï¼
+ */
+cell tSerialAdapter SerialAdapter {
+	cSerialPort[0] = SerialPort1.eSerialPort;
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãã
+ *  ã°ããï¼
+ */
+cell tLogTask LogTask {
+	priority  = 3;					/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åªå
+åº¦ */
+	stackSize = LogTaskStackSize;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+	/* ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå */
+	cSerialPort        = SerialPort1.eSerialPort;
+	cnSerialPortManage = SerialPort1.enSerialPortManage;
+
+	/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®çµå */
+	cSysLog = SysLog.eSysLog;
+
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®çµä¸ãè¨è¿°
+ *
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°
+ *  ãåé¤ããã°ããï¼
+ */
+cell tBanner Banner {
+	/* å±æ§ã®è¨­å® */
+	targetName      = BannerTargetName;
+	copyrightNotice = BannerCopyrightNotice;
+};
Index: asp3_gr_sakura/trunk/sample/sample1n.cfg
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1n.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1n.cfg	(revision 317)
@@ -0,0 +1,22 @@
+/*
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ãµã³ãã«ãã­ã°ã©ã (1)ã®
+ *  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+
+#include "sample1n.h"
+
+INCLUDE("sample1.cfg");
+
+INCLUDE("../tinet/tinet_asp.cfg");
+
+INCLUDE("tinet_sample1n.cfg");
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_TCP_SYSLOG, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_NET_SEND,   { TA_TPRI, 1, 1 });
Index: asp3_gr_sakura/trunk/sample/sample1n.h
===================================================================
--- asp3_gr_sakura/trunk/sample/sample1n.h	(revision 317)
+++ asp3_gr_sakura/trunk/sample/sample1n.h	(revision 317)
@@ -0,0 +1,85 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _SAMPLE1N_H_
+#define _SAMPLE1N_H_
+
+#include <tinet_defs.h>
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ãµã³ãã«ãã­ã°ã©ã (1)ã®ããããã¡ã¤ã«
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº  */
+
+#define TCP_SWBUF_SIZE	512
+#define TCP_RWBUF_SIZE	512
+
+/*  ãªãã¼ã   */
+
+#define syslog		net_syslog
+#define serial_rea_dat	net_serial_rea_dat
+#define serial_ctl_por	net_serial_ctl_por
+
+#ifndef _MACRO_ONLY
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+extern uint8_t tcp_swbuf[];
+extern uint8_t tcp_rwbuf[];
+
+/*  ãããã¯ã¼ã¯å¯¾å¿åé¢æ°  */
+
+extern void	net_syslog(uint_t prio, const char *format, ...) throw();
+extern ER_UINT	net_serial_rea_dat(ID portid, char *buf, uint_t len) throw();
+extern ER	net_serial_ctl_por(ID portid, uint_t ioctl) throw();
+
+/*  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°  */
+
+extern ER	callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk);
+
+#endif /* _MACRO_ONLY */
+
+#endif	/* of #ifndef _SAMPLE1N_H_ */
Index: asp3_gr_sakura/trunk/sample/tSample2.c
===================================================================
--- asp3_gr_sakura/trunk/sample/tSample2.c	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tSample2.c	(revision 317)
@@ -0,0 +1,688 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ *
+ *  Copyright (C) 2015-2016 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/* 
+ *  ãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+ *
+ *  ASPã«ã¼ãã«ã®åºæ¬çãªåä½ãç¢ºèªããããã®ãµã³ãã«ãã­ã°ã©ã ï¼
+ *
+ *  ãã­ã°ã©ã ã®æ¦è¦:
+ *
+ *  ã¦ã¼ã¶ã¤ã³ã¿ãã§ã¼ã¹ãåãæã¤ã¡ã¤ã³ã¿ã¹ã¯ï¼ã¿ã¹ã¯ID: MAIN_TASKï¼åª
+ *  å
+åº¦: MAIN_PRIORITYï¼ã¨ï¼3ã¤ã®ä¸¦è¡å®è¡ãããã¿ã¹ã¯ï¼ã¿ã¹ã¯ID:
+ *  TASK1ï½TASK3ï¼åæåªå
+åº¦: MID_PRIORITYï¼ã§æ§æãããï¼ã¾ãï¼èµ·åå¨
+ *  æã2ç§ã®å¨æãã³ãã©ï¼å¨æãã³ãã©ID: CYCHDR1ï¼ãç¨ããï¼
+ *
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯ã¯ï¼task_loopåç©ºã«ã¼ããå®è¡ããåº¦ã«ï¼ã¿ã¹ã¯ã
+ *  å®è¡ä¸­ã§ãããã¨ãããããã¡ãã»ã¼ã¸ãè¡¨ç¤ºããï¼ç©ºã«ã¼ããå®è¡ãã
+ *  ã®ã¯ï¼ç©ºã«ã¼ããªãã§ã¡ãã»ã¼ã¸ãåºåããã¨ï¼å¤éã®ã¡ãã»ã¼ã¸ãåºå
+ *  ããï¼ãã­ã°ã©ã ã®åä½ãç¢ºèªãããããªãããã§ããï¼ã¾ãï¼ä½éãªã·
+ *  ãªã¢ã«ãã¼ããç¨ãã¦ã¡ãã»ã¼ã¸ãåºåããå ´åã«ï¼ãã¹ã¦ã®ã¡ãã»ã¼ã¸
+ *  ãåºåã§ããããã«ï¼ã¡ãã»ã¼ã¸ã®éãå¶éããã¨ããçç±ãããï¼
+ *
+ *  å¨æãã³ãã©ã¯ï¼ä¸ã¤ã®åªå
+åº¦ï¼HIGH_PRIORITYï¼MID_PRIORITYï¼
+ *  LOW_PRIORITYï¼ã®ã¬ãã£ã­ã¥ã¼ãåè»¢ãããï¼ãã­ã°ã©ã ã®èµ·åç´å¾ã¯ï¼
+ *  å¨æãã³ãã©ã¯åæ­¢ç¶æ
+ã«ãªã£ã¦ããï¼
+ *
+ *  ã¡ã¤ã³ã¿ã¹ã¯ã¯ï¼ã·ãªã¢ã«I/Oãã¼ãããã®æå­å
+¥åãè¡ãï¼æå­å
+¥åã
+ *  å¾
+ã£ã¦ããéã¯ï¼ä¸¦åå®è¡ãããã¿ã¹ã¯ãå®è¡ããã¦ããï¼ï¼å
+¥åããã
+ *  æå­ã«å¯¾å¿ããå¦çãå®è¡ããï¼å
+¥åãããæå­ã¨å¦çã®é¢ä¿ã¯æ¬¡ã®éãï¼
+ *  Control-Cã¾ãã¯'Q'ãå
+¥åãããã¨ï¼ãã­ã°ã©ã ãçµäºããï¼
+ *
+ *  '1' : å¯¾è±¡ã¿ã¹ã¯ãTASK1ã«åãæããï¼åæè¨­å®ï¼ï¼
+ *  '2' : å¯¾è±¡ã¿ã¹ã¯ãTASK2ã«åãæããï¼
+ *  '3' : å¯¾è±¡ã¿ã¹ã¯ãTASK3ã«åãæããï¼
+ *  'a' : å¯¾è±¡ã¿ã¹ã¯ãcTask_activateã«ããèµ·åããï¼
+ *  'A' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ããèµ·åè¦æ±ãcTask_cancelActivateã«ããã­ã£ã³ã»ã«ããï¼
+ *  'e' : å¯¾è±¡ã¿ã¹ã¯ã«exitTaskãå¼ã³åºããï¼çµäºãããï¼
+ *  't' : å¯¾è±¡ã¿ã¹ã¯ãcTask_terminateã«ããå¼·å¶çµäºããï¼
+ *  '>' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãHIGH_PRIORITYã«ããï¼
+ *  '=' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãMID_PRIORITYã«ããï¼
+ *  '<' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãLOW_PRIORITYã«ããï¼
+ *  'G' : å¯¾è±¡ã¿ã¹ã¯ã®åªå
+åº¦ãcTask_getPriorityã§èª­ã¿åºãï¼
+ *  's' : å¯¾è±¡ã¿ã¹ã¯ã«sleepãå¼ã³åºããï¼èµ·åºå¾
+ã¡ã«ãããï¼
+ *  'S' : å¯¾è±¡ã¿ã¹ã¯ã«sleepTimeout10ç§)ãå¼ã³åºããï¼èµ·åºå¾
+ã¡ã«ãããï¼
+ *  'w' : å¯¾è±¡ã¿ã¹ã¯ãcTask_wakeupã«ããèµ·åºããï¼
+ *  'W' : å¯¾è±¡ã¿ã¹ã¯ã«å¯¾ããèµ·åºè¦æ±ãcTask_cancelWakeupã«ããã­ã£ã³ã»ã«ããï¼
+ *  'l' : å¯¾è±¡ã¿ã¹ã¯ãcTask_releaseWaitã«ããå¼·å¶çã«å¾
+ã¡è§£é¤ã«ããï¼
+ *  'u' : å¯¾è±¡ã¿ã¹ã¯ãcTask_suspendã«ããå¼·å¶å¾
+ã¡ç¶æ
+ã«ããï¼
+ *  'm' : å¯¾è±¡ã¿ã¹ã¯ã®å¼·å¶å¾
+ã¡ç¶æ
+ãcTask_resumeã«ããè§£é¤ããï¼
+ *  'd' : å¯¾è±¡ã¿ã¹ã¯ã«delay(10ç§)ãå¼ã³åºããï¼æéçµéå¾
+ã¡ã«ãããï¼
+ *  'x' : å¯¾è±¡ã¿ã¹ã¯ã«raiseTerminateã«ããçµäºè¦æ±ããï¼
+ *  'y' : å¯¾è±¡ã¿ã¹ã¯ã«disableTerminateãå¼ã³åºããï¼ã¿ã¹ã¯çµäºãç¦æ­¢ããï¼
+ *  'Y' : å¯¾è±¡ã¿ã¹ã¯ã«enableTerminateãå¼ã³åºããï¼ã¿ã¹ã¯çµäºãè¨±å¯ããï¼
+ *  'r' : 3ã¤ã®åªå
+åº¦ï¼HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITYï¼ã®ã¬
+ *        ãã£ã­ã¥ã¼ãåè»¢ãããï¼
+ *  'c' : å¨æãã³ãã©ãåä½éå§ãããï¼
+ *  'C' : å¨æãã³ãã©ãåä½åæ­¢ãããï¼
+ *  'b' : ã¢ã©ã¼ã ãã³ãã©ã5ç§å¾ã«èµ·åããããåä½éå§ãããï¼
+ *  'B' : ã¢ã©ã¼ã ãã³ãã©ãåä½åæ­¢ãããï¼
+ *  'z' : å¯¾è±¡ã¿ã¹ã¯ã«CPUä¾å¤ãçºçãããï¼ã¿ã¹ã¯ãçµäºãããï¼ï¼
+ *  'Z' : å¯¾è±¡ã¿ã¹ã¯ã«CPUã­ãã¯ç¶æ
+ã§CPUä¾å¤ãçºçãããï¼ãã­ã°ã©ã ã
+ *        çµäºããï¼ï¼
+ *  'V' : fetchHighResolutionTimerã§é«åè§£è½ã¿ã¤ãã2åèª­ãï¼
+ *  'v' : çºè¡ããã·ã¹ãã ã³ã¼ã«ãè¡¨ç¤ºããï¼ããã©ã«ãï¼ï¼
+ *  'q' : çºè¡ããã·ã¹ãã ã³ã¼ã«ãè¡¨ç¤ºããªãï¼
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * require port: signature:sKernel context:task
+ *   ER             getExtendedInformation( intptr_t* p_exinf );
+ *   ER             sleep( );
+ *   ER             sleepTimeout( TMO timeout );
+ *   ER             delay( RELTIM delayTime );
+ *   ER             exit( );
+ *   ER             disableTerminate( );
+ *   ER             enableTerminate( );
+ *   bool_t         senseTerminate( );
+ *   ER             setTime( SYSTIM systemTime );
+ *   ER             getTime( SYSTIM* p_systemTime );
+ *   ER             adjustTime( int32_t adjustTime );
+ *   HRTCNT         fetchHighResolutionTimer( );
+ *   ER             rotateReadyQueue( PRI taskPriority );
+ *   ER             getTaskId( ID* p_taskId );
+ *   ER             getLoad( PRI taskPriority, uint_t* p_load );
+ *   ER             getNthTask( PRI taskPriority, uint_t nth, ID* p_taskID );
+ *   ER             lockCpu( );
+ *   ER             unlockCpu( );
+ *   ER             disableDispatch( );
+ *   ER             enableDispatch( );
+ *   bool_t         senseContext( );
+ *   bool_t         senseLock( );
+ *   bool_t         senseDispatch( );
+ *   bool_t         senseDispatchPendingState( );
+ *   bool_t         senseKernel( );
+ *   ER             exitKernel( );
+ *   ER             changeInterruptPriorityMask( PRI interruptPriority );
+ *   ER             getInterruptPriorityMask( PRI* p_interruptPriority );
+ * require port: signature:siKernel context:non-task
+ *   HRTCNT         ciKernel_fetchHighResolutionTimer( );
+ *   ER             ciKernel_rotateReadyQueue( PRI taskPriority );
+ *   ER             ciKernel_getTaskId( ID* p_taskId );
+ *   ER             ciKernel_lockCpu( );
+ *   ER             ciKernel_unlockCpu( );
+ *   bool_t         ciKernel_senseContext( );
+ *   bool_t         ciKernel_senseLock( );
+ *   bool_t         ciKernel_senseDispatch( );
+ *   bool_t         ciKernel_senseDispatchPendingState( );
+ *   bool_t         ciKernel_senseKernel( );
+ *   ER             ciKernel_exitKernel( );
+ *   bool_t         ciKernel_exceptionSenseDispatchPendingState( const void* p_exceptionInformation );
+ * call port: cTask signature: sTask context:task
+ *   ER             cTask_activate( subscript );
+ *   ER_UINT        cTask_cancelActivate( subscript );
+ *   ER             cTask_getTaskState( subscript, STAT* p_tskstat );
+ *   ER             cTask_changePriority( subscript, PRI priority );
+ *   ER             cTask_getPriority( subscript, PRI* p_priority );
+ *   ER             cTask_refer( subscript, T_RTSK* pk_taskStatus );
+ *   ER             cTask_wakeup( subscript );
+ *   ER_UINT        cTask_cancelWakeup( subscript );
+ *   ER             cTask_releaseWait( subscript );
+ *   ER             cTask_suspend( subscript );
+ *   ER             cTask_resume( subscript );
+ *   ER             cTask_raiseTerminate( subscript );
+ *   ER             cTask_terminate( subscript );
+ *       subscript:  0...(NCP_cTask-1)
+ * call port: cExceptionTask signature: sTask context:task
+ *   ER             cExceptionTask_activate( );
+ *   ER_UINT        cExceptionTask_cancelActivate( );
+ *   ER             cExceptionTask_getTaskState( STAT* p_tskstat );
+ *   ER             cExceptionTask_changePriority( PRI priority );
+ *   ER             cExceptionTask_getPriority( PRI* p_priority );
+ *   ER             cExceptionTask_refer( T_RTSK* pk_taskStatus );
+ *   ER             cExceptionTask_wakeup( );
+ *   ER_UINT        cExceptionTask_cancelWakeup( );
+ *   ER             cExceptionTask_releaseWait( );
+ *   ER             cExceptionTask_suspend( );
+ *   ER             cExceptionTask_resume( );
+ *   ER             cExceptionTask_raiseTerminate( );
+ *   ER             cExceptionTask_terminate( );
+ * call port: cCyclic signature: sCyclic context:task
+ *   ER             cCyclic_start( );
+ *   ER             cCyclic_stop( );
+ *   ER             cCyclic_refer( T_RCYC* pk_cyclicHandlerStatus );
+ * call port: cAlarm signature: sAlarm context:task
+ *   ER             cAlarm_start( RELTIM alarmTime );
+ *   ER             cAlarm_stop( );
+ *   ER             cAlarm_refer( T_RALM* pk_alarmStatus );
+ * call port: cSerialPort signature: sSerialPort context:task optional:true
+ *   bool_t     is_cSerialPort_joined()                     check if joined
+ *   ER             cSerialPort_open( );
+ *   ER             cSerialPort_close( );
+ *   ER_UINT        cSerialPort_read( char* buffer, uint_t length );
+ *   ER_UINT        cSerialPort_write( const char* buffer, uint_t length );
+ *   ER             cSerialPort_control( uint_t ioControl );
+ *   ER             cSerialPort_refer( T_SERIAL_RPOR* pk_rpor );
+ * call port: cSysLog signature: sSysLog context:task
+ *   ER             cSysLog_write( uint_t priority, const SYSLOG* p_syslog );
+ *   ER_UINT        cSysLog_read( SYSLOG* p_syslog );
+ *   ER             cSysLog_mask( uint_t logMask, uint_t lowMask );
+ *   ER             cSysLog_refer( T_SYSLOG_RLOG* pk_rlog );
+ *   ER             cSysLog_flush( );
+ * #[</PREAMBLE>]# */  
+
+#include "tSample2_tecsgen.h"
+#include <kernel.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+#include "kernel_cfg.h"
+#include "tSample2.h"
+
+/*
+ *  ãµã¼ãã¹ã³ã¼ã«ã®ã¨ã©ã¼ã®ã­ã°åºå
+ */
+Inline void
+svc_perror(const char *file, int_t line, const char *expr, ER ercd)
+{
+	if (ercd < 0) {
+		t_perror(LOG_ERROR, file, line, expr, ercd);
+	}
+}
+
+#define	SVC_PERROR(expr)	svc_perror(__FILE__, __LINE__, #expr, (expr))
+
+/*
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯ã¸ã®ã¡ãã»ã¼ã¸é å
+ */
+char	message[3];
+
+/*
+ *  ã«ã¼ãåæ°
+ */
+ulong_t	task_loop;		/* ã¿ã¹ã¯å
+ã§ã®ã«ã¼ãåæ° */
+
+/*
+ *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯
+ */
+void eSampleTask_main(int_t subscript)
+{
+	volatile ulong_t	i;
+	int_t		n = 0;
+	int_t		tskno = subscript + 1; 
+	const char	*graph[] = { "|", "  +", "    *" };
+	char		c;
+
+	while (true) {
+		syslog(LOG_NOTICE, "task%d is running (%03d).   %s",
+										tskno, ++n, graph[tskno-1]);
+		for (i = 0; i < task_loop; i++);
+		c = message[tskno-1];
+		message[tskno-1] = 0;
+		switch (c) {
+		case 'e':
+			syslog(LOG_INFO, "#%d#exit()", tskno);
+			SVC_PERROR(exit());
+			assert(0);
+		case 's':
+			syslog(LOG_INFO, "#%d#sleep()", tskno);
+			SVC_PERROR(sleep());
+			break;
+		case 'S':
+			syslog(LOG_INFO, "#%d#sleepTimeout(10000)", tskno);
+			SVC_PERROR(sleepTimeout(10000));
+			break;
+		case 'd':
+			syslog(LOG_INFO, "#%d#delay(10000)", tskno);
+			SVC_PERROR(delay(10000));
+			break;
+		case 'y':
+			syslog(LOG_INFO, "#%d#disableTerminate()", tskno);
+			SVC_PERROR(disableTerminate());
+			break;
+		case 'Y':
+			syslog(LOG_INFO, "#%d#enableTerminate()", tskno);
+			SVC_PERROR(enableTerminate());
+			break;
+#ifdef CPUEXC1
+		case 'z':
+			syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno);
+			RAISE_CPU_EXCEPTION;
+			break;
+		case 'Z':
+			SVC_PERROR(lockCpu());
+			syslog(LOG_NOTICE, "#%d#raise CPU exception", tskno);
+			RAISE_CPU_EXCEPTION;
+			SVC_PERROR(unlockCpu());
+			break;
+#endif /* CPUEXC1 */
+		default:
+			break;
+		}
+	}
+}
+
+/*
+ *  CPUä¾å¤ãã³ãã©
+ */
+
+ID	cpuexc_tskid;		/* CPUä¾å¤ãèµ·ãããã¿ã¹ã¯ã®ID */
+
+#ifdef CPUEXC1
+
+void
+cpuexc_handler(void *p_excinf)
+{
+	
+	syslog(LOG_NOTICE, "CPU exception handler (p_excinf = %08p).", p_excinf);
+	if (ciKernel_senseContext() != true) {
+		syslog(LOG_WARNING,
+					"ciKernel_senseContext() is not true in CPU exception handler.");
+	}
+	if (ciKernel_senseDispatchPendingState() != true) {
+		syslog(LOG_WARNING,
+					"ciKernel_senseDispatchPendingState() is not true in CPU exception handler.");
+	}
+	syslog(LOG_INFO, "ciKernel_senseLock() = %d ciKernel_senseDispatch() = %d ciKernel_exceptionSenseDispatchPendingState() = %d",
+		   ciKernel_senseLock(), ciKernel_senseDispatch(), ciKernel_exceptionSenseDispatchPendingState(p_excinf));
+
+	if (ciKernel_exceptionSenseDispatchPendingState(p_excinf)) {
+		syslog(LOG_NOTICE, "Sample program ends with exception.");
+		SVC_PERROR(ciKernel_senseKernel());
+		assert(0);
+	}
+
+#ifdef PREPARE_RETURN_CPUEXC
+	PREPARE_RETURN_CPUEXC;
+	SVC_PERROR(ciKernel_getTaskId(&cpuexc_tskid));
+	cExceptionTask_activate();
+#else /* PREPARE_RETURN_CPUEXC */
+	syslog(LOG_NOTICE, "Sample program ends with exception.");
+	SVC_PERROR(ciKernel_exitKernel());
+	assert(0);
+#endif /* PREPARE_RETURN_CPUEXC */
+}
+
+#endif /* CPUEXC1 */
+
+/*
+ *  å¨æãã³ãã©
+ *
+ *  HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITY ã®ååªå
+åº¦ã®ã¬ãã£ã­ã¥ã¼
+ *  ãåè»¢ãããï¼
+ */
+/* #[<ENTRY_FUNC>]# eiCyclicHandler_main
+ * name:         eiCyclicHandler_main
+ * global_name:  tSample2_eiCyclicHandler_main
+ * oneway:       
+ * #[/ENTRY_FUNC>]# */
+void
+eiCyclicHandler_main()
+{
+	SVC_PERROR(ciKernel_rotateReadyQueue(HIGH_PRIORITY));
+	SVC_PERROR(ciKernel_rotateReadyQueue(MID_PRIORITY));
+	SVC_PERROR(ciKernel_rotateReadyQueue(LOW_PRIORITY));
+}
+
+/*
+ *  ã¢ã©ã¼ã ãã³ãã©
+ *
+ *  HIGH_PRIORITYï¼MID_PRIORITYï¼LOW_PRIORITY ã®ååªå
+åº¦ã®ã¬ãã£ã­ã¥ã¼
+ *  ãåè»¢ãããï¼
+ */
+/* #[<ENTRY_FUNC>]# eiAlarmHandler_main
+ * name:         eiAlarmHandler_main
+ * global_name:  tSample2_eiAlarmHandler_main
+ * oneway:       
+ * #[/ENTRY_FUNC>]# */
+void
+eiAlarmHandler_main()
+{
+	SVC_PERROR(ciKernel_rotateReadyQueue(HIGH_PRIORITY));
+	SVC_PERROR(ciKernel_rotateReadyQueue(MID_PRIORITY));
+	SVC_PERROR(ciKernel_rotateReadyQueue(LOW_PRIORITY));
+}
+/*
+ *  ä¾å¤å¦çã¿ã¹ã¯
+ */
+/* #[<ENTRY_FUNC>]# eExceptionTask_main
+ * name:         eExceptionTask_main
+ * global_name:  tSample2_eExceptionTask_main
+ * oneway:       
+ * #[/ENTRY_FUNC>]# */
+void eExceptionTask_main()
+{
+	SVC_PERROR(ras_ter(cpuexc_tskid));
+}
+/*
+ *  ã¡ã¤ã³ã¿ã¹ã¯
+ */
+/* å±æ§ã®è¨­å® *//* #[<ENTRY_FUNC>]# eMainTask_main
+ * name:         eMainTask_main
+ * global_name:  tSample2_eMainTask_main
+ * oneway:       
+ * #[/ENTRY_FUNC>]# */
+void
+eMainTask_main()
+{
+	char	c;
+	volatile ulong_t	i;
+	ulong_t j;
+	int_t	tskno = 1;
+	ER_UINT	ercd;
+	PRI		tskpri;
+	SYSTIM	stime1, stime2;
+	HRTCNT	hrtcnt1, hrtcnt2;
+
+	if (is_cSerialPort_joined()) {
+		SVC_PERROR(cSysLog_mask(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_ERROR)));
+	} else {
+		/*
+		 *  ã·ãªã¢ã«åºåãã§ããªãå ´åãã­ã°ã¡ãã»ã¼ã¸ãå
+¨ã¦
+		 *  ä½ã¬ãã«åºåã«ããåºåããã
+		 */
+		SVC_PERROR(cSysLog_mask(LOG_UPTO(LOG_INFO), LOG_UPTO(LOG_DEBUG)));
+	}
+	syslog(LOG_NOTICE, "Sample program starts.");
+
+	/*
+	 *  ã·ãªã¢ã«ãã¼ãã®åæå
+	 *
+	 *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¨åãã·ãªã¢ã«ãã¼ããä½¿ãå ´åãªã©ï¼ã·ãªã¢ã«
+	 *  ãã¼ãããªã¼ãã³æ¸ã¿ã®å ´åã«ã¯ããã§E_OBJã¨ã©ã¼ã«ãªããï¼æ¯éã¯
+	 *  ãªãï¼
+	 */
+
+	if (is_cSerialPort_joined()) {
+		ercd = cSerialPort_open();
+		if (ercd < 0 && MERCD(ercd) != E_OBJ) {
+			syslog(LOG_ERROR, "%s (%d) reported by `cSerialPort_open'.",
+										itron_strerror(ercd), SERCD(ercd));
+		}
+		SVC_PERROR(cSerialPort_control(IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV));
+	}
+
+	/*
+ 	 *  ã«ã¼ãåæ°ã®è¨­å®
+	 *
+	 *  ä¸¦è¡å®è¡ãããã¿ã¹ã¯å
+ã§ã®ç©ºã«ã¼ãã®åæ°ï¼task_loopï¼ã¯ï¼ç©ºã«ã¼
+	 *  ãã®å®è¡æéãç´0.4ç§ã«ãªãããã«è¨­å®ããï¼ãã®è¨­å®ã®ããã«ï¼
+	 *  LOOP_REFåã®ç©ºã«ã¼ãã®å®è¡æéãï¼ãã®åå¾ã§get_timãå¼ã¶ãã¨ã§
+	 *  æ¸¬å®ãï¼ãã®æ¸¬å®çµæããç©ºã«ã¼ãã®å®è¡æéã0.4ç§ã«ãªãã«ã¼ãå
+	 *  æ°ãæ±ãï¼task_loopã«è¨­å®ããï¼
+	 *
+	 *  LOOP_REFã¯ï¼ããã©ã«ãã§ã¯1,000,000ã«è¨­å®ãã¦ãããï¼æ³å®ããã
+	 *  ãé
+ããã­ã»ããµã§ã¯ï¼ãµã³ãã«ãã­ã°ã©ã ã®å®è¡éå§ã«æéããã
+	 *  ããããã¨ããåé¡ãçããï¼éã«æ³å®ããããéããã­ã»ããµã§ã¯ï¼
+	 *  LOOP_REFåã®ç©ºã«ã¼ãã®å®è¡æéãç­ããªãï¼task_loopã«è¨­å®ããå¤
+	 *  ã®èª¤å·®ãå¤§ãããªãã¨ããåé¡ãããï¼
+	 *
+	 *  ããã§ï¼ãã®ãããªã¿ã¼ã²ããã§ã¯ï¼target_test.hã§ï¼LOOP_REFãé©
+	 *  åãªå¤ã«å®ç¾©ããã®ãæã¾ããï¼
+	 *
+	 *  ã¾ãï¼task_loopã®å¤ãåºå®ãããå ´åã«ã¯ï¼ãã®å¤ãTASK_LOOPã«ã
+	 *  ã¯ã­å®ç¾©ããï¼TASK_LOOPããã¯ã­å®ç¾©ããã¦ããå ´åï¼ä¸è¨ã®æ¸¬å®ã
+	 *  è¡ããã«ï¼TASK_LOOPã«å®ç¾©ãããå¤ãç©ºã«ã¼ãã®åæ°ã¨ããï¼
+	 *
+	 * ã¿ã¼ã²ããã«ãã£ã¦ã¯ï¼ç©ºã«ã¼ãã®å®è¡æéã®1åç®ã®æ¸¬å®ã§ï¼æ¬æ¥ã
+	 * ããé·ãã«ãªããã®ãããï¼ãã®ãããªã¿ã¼ã²ããã§ã¯ï¼MEASURE_TWICE
+	 * ããã¯ã­å®ç¾©ãããã¨ã§ï¼1åç®ã®æ¸¬å®çµæãæ¨ã¦ã¦ï¼2åç®ã®æ¸¬å®çµæ
+	 * ãä½¿ãï¼
+	 */
+#ifdef TASK_LOOP
+	task_loop = TASK_LOOP;
+#else /* TASK_LOOP */
+
+#ifdef MEASURE_TWICE
+	task_loop = LOOP_REF;
+	SVC_PERROR(get_tim(&stime1));
+	for (i = 0; i < task_loop; i++);
+	SVC_PERROR(get_tim(&stime2));
+#endif /* MEASURE_TWICE */
+
+	task_loop = LOOP_REF;
+	SVC_PERROR(get_tim(&stime1));
+	for (i = 0; i < task_loop; i++);
+	SVC_PERROR(get_tim(&stime2));
+	task_loop = LOOP_REF * 400LU / (ulong_t)(stime2 - stime1) * 1000LU;
+
+#endif /* TASK_LOOP */
+
+	/*
+ 	 *  ã¿ã¹ã¯ã®èµ·å
+	 */
+
+	SVC_PERROR(cTask_activate( 1 ));
+	SVC_PERROR(cTask_activate( 2 ));
+	SVC_PERROR(cTask_activate( 3 ));
+
+	/*
+ 	 *  ã¡ã¤ã³ã«ã¼ã
+	 */
+	if (is_cSerialPort_joined()) {
+		do {
+			SVC_PERROR(cSerialPort_read(&c, 1));
+			switch (c) {
+			case 'e':
+			case 's':
+			case 'S':
+			case 'd':
+			case 'y':
+			case 'Y':
+			case 'z':
+			case 'Z':
+				message[tskno-1] = c;
+				break;
+			case '1':
+				tskno = 1;
+				break;
+			case '2':
+				tskno = 2;
+				break;
+			case '3':
+				tskno = 3;
+				break;
+			case 'a':
+				syslog(LOG_INFO, "#cTask_activate(%d)", tskno);
+				SVC_PERROR(cTask_activate(tskno));
+				break;
+			case 'A':
+				syslog(LOG_INFO, "#cTask_cancelActivate(%d)", tskno);
+				SVC_PERROR(cTask_cancelActivate(tskno));
+
+				if (ercd >= 0) {
+					syslog(LOG_NOTICE, "cTask_cancelActivate(%d) returns %d", tskno, ercd);
+				}
+				break;
+			case 't':
+				syslog(LOG_INFO, "#cTask_terminate(%d)", tskno);
+				SVC_PERROR(cTask_terminate(tskno));
+				break;
+			case '>':
+				syslog(LOG_INFO, "#cTask_changePriority(%d, HIGH_PRIORITY)", tskno);
+				SVC_PERROR(cTask_changePriority(tskno, HIGH_PRIORITY));
+				break;
+			case '=':
+				syslog(LOG_INFO, "#cTask_changePriority(%d, MID_PRIORITY)", tskno);
+				SVC_PERROR(cTask_changePriority(tskno, MID_PRIORITY));
+				break;
+			case '<':
+				syslog(LOG_INFO, "#(cTask_changePriority(%d, LOW_PRIORITY)", tskno);
+				SVC_PERROR(cTask_changePriority(tskno, LOW_PRIORITY));
+				break;
+			case 'G':
+				syslog(LOG_INFO, "#cTask_getPriority(%d, &tskpri)", tskno);
+				SVC_PERROR(ercd = cTask_getPriority(tskno, &tskpri));
+				if (ercd >= 0) {
+					syslog(LOG_NOTICE, "priority of task %d is %d", tskno, tskpri);
+				}
+				break;
+			case 'w':
+				syslog(LOG_INFO, "#cTask_wakeup(%d)", tskno);
+				SVC_PERROR(cTask_wakeup(tskno));
+				break;
+			case 'W':
+				syslog(LOG_INFO, "#cTask_cancelWakeup(%d)", tskno);
+				SVC_PERROR(ercd = cTask_cancelWakeup(tskno));
+				if (ercd >= 0) {
+					syslog(LOG_NOTICE, "cTask_cancelWakeup(%d) returns %d", tskno, ercd);
+				}
+				break;
+			case 'l':
+				syslog(LOG_INFO, "#cTask_releaseWait(%d)", tskno);
+				SVC_PERROR(cTask_releaseWait(tskno));
+				break;
+			case 'u':
+				syslog(LOG_INFO, "#cTask_suspend(%d)", tskno);
+				SVC_PERROR(cTask_suspend(tskno));
+				break;
+			case 'm':
+				syslog(LOG_INFO, "#cTask_resume(%d)", tskno);
+				SVC_PERROR(cTask_resume(tskno));
+				break;
+			case 'x':
+				syslog(LOG_INFO, "#cTask_raiseTerminate(%d)", tskno);
+				SVC_PERROR(cTask_raiseTerminate(tskno));
+				break;
+			case 'X':
+				syslog(LOG_INFO, "#cTask_raiseTerminate(%d)", tskno);
+				SVC_PERROR(cTask_raiseTerminate(tskno));
+				break;
+			case 'r':
+				syslog(LOG_INFO, "#rotateReadyQueue(three priorities)");
+				SVC_PERROR(rotateReadyQueue(HIGH_PRIORITY));
+				SVC_PERROR(rotateReadyQueue(MID_PRIORITY));
+				SVC_PERROR(rotateReadyQueue(LOW_PRIORITY));
+				break;
+			case 'c':
+				syslog(LOG_INFO, "#cCyclic_start(1)");
+				SVC_PERROR(cCyclic_start());
+				break;
+			case 'C':
+				syslog(LOG_INFO, "#cCyclic_stop(1)");
+				SVC_PERROR(cCyclic_stop());
+				break;
+			case 'b':
+				syslog(LOG_INFO, "#cAlarm_start(1, 5000000)");
+				SVC_PERROR(cAlarm_start(5000000));
+				break;
+			case 'B':
+				syslog(LOG_INFO, "#cAlarm_stop()(1)");
+				SVC_PERROR(cAlarm_stop());
+				break;
+			case 'V':
+				hrtcnt1 = fetchHighResolutionTimer();
+				hrtcnt2 = fetchHighResolutionTimer();
+				syslog(LOG_NOTICE, "hrtcnt1 = %tu, hrtcnt2 = %tu",
+											hrtcnt1, hrtcnt2);
+				break;
+			case 'v':
+				SVC_PERROR(cSysLog_mask(LOG_UPTO(LOG_INFO),
+											LOG_UPTO(LOG_EMERG)));
+				break;
+			case 'q':
+				SVC_PERROR(cSysLog_mask(LOG_UPTO(LOG_NOTICE),
+											LOG_UPTO(LOG_EMERG)));
+				break;
+#ifdef BIT_KERNEL
+			case ' ':
+				SVC_PERROR(lockCpu());
+				{
+					extern ER	bit_kernel(void);
+
+					SVC_PERROR(ercd = bit_kernel());
+					if (ercd >= 0) {
+						syslog(LOG_NOTICE, "bit_kernel passed.");
+					}
+				}
+				SVC_PERROR(unlockCpu());
+				break;
+#endif /* BIT_KERNEL */
+
+			default:
+				break;
+			}
+		} while (c != '\003' && c != 'Q');
+	} else {
+		syslog(LOG_NOTICE, "cSerialPort of tSample2 is not joined.");
+		syslog(LOG_NOTICE, "Sample program will halt after 40 seconds.");
+		for (j = 0; j < 100; j++) {
+			for (i = 0; i < task_loop; i++);
+		}
+	}
+
+	syslog(LOG_NOTICE, "Sample program ends.");
+	SVC_PERROR(ciKernel_exitKernel());
+	assert(0);
+}
Index: asp3_gr_sakura/trunk/sample/tSample2.cdl
===================================================================
--- asp3_gr_sakura/trunk/sample/tSample2.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tSample2.cdl	(revision 317)
@@ -0,0 +1,203 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (2)ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+/*
+ *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å®ç¾©
+ */
+import("kernel.cdl");
+
+/*
+ *  ã¿ã¼ã²ããéä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
+ */
+import("syssvc/tSerialPort.cdl");
+import("syssvc/tSysLog.cdl");
+import("syssvc/tLogTask.cdl");
+import("syssvc/tBanner.cdl");
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ã®åãè¾¼ã¿
+ */
+import("target.cdl");
+
+/*
+ *  ãã»ã«ã®çµä¸ãè¨è¿°ãã¨ã¯ï¼"cell"ã§å§ã¾ãè¡ããï¼ããã«å¯¾å¿ãã"};"
+ *  ã®è¡ã¾ã§ã®ãã¨ãè¨ãï¼
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°æ©è½ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãï¼ã³
+ *  ã³ãã¤ã«ãªãã·ã§ã³ã«-DTOPPERS_OMIT_SYSLOGãè¿½å ããã°ããï¼ãã ãï¼
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ã¹ãã ã­ã°æ©è½ãä½¿ç¨ããããï¼ãããå¤ããã¨
+ *  ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ã¹ãã ã­ã°æ©è½ã®ã¢ããã¿ãå¤ããªããã°ãªããª
+ *  ãï¼tecsgenãè­¦åã¡ãã»ã¼ã¸ãåºããï¼ç¡è¦ãã¦ããï¼
+ */
+cell tSysLog SysLog {
+	logBufferSize = 32;					/* ã­ã°ãããã¡ã®ãµã¤ãº */
+	initLogMask = C_EXP("LOG_UPTO(LOG_NOTICE)");
+										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
+									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®çµä¸ãè¨è¿°
+ *
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨
+ *  è¿°ãåé¤ããã°ããï¼ãã ãï¼ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã¯ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼
+ *  ã¹ãã©ã¤ããä½¿ç¨ããããï¼ãããå¤ããã¨ãå¿
+è¦ã§ããï¼ã¾ãï¼ã·ãªã¢
+ *  ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¢ããã¿ãå¤ããªããã°ãªããªãï¼
+ */
+cell tSerialPort SerialPort1 {
+	receiveBufferSize = 256;			/* åä¿¡ãããã¡ã®ãµã¤ãº */
+	sendBufferSize    = 256;			/* éä¿¡ãããã¡ã®ãµã¤ãº */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã¨ã®çµå */
+	cSIOPort = SIOPortTarget1.eSIOPort;
+	eiSIOCBR <= SIOPortTarget1.ciSIOCBR;	/* ã³ã¼ã«ããã¯ */
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµä¸ãè¨è¿°
+ *
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°ãåé¤ãã
+ *  ã°ããï¼
+ */
+cell tLogTask LogTask {
+	priority  = 3;					/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åªå
+åº¦ */
+	stackSize = LogTaskStackSize;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+	/* ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå */
+	cSerialPort        = SerialPort1.eSerialPort;
+	cnSerialPortManage = SerialPort1.enSerialPortManage;
+
+	/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®çµå */
+	cSysLog = SysLog.eSysLog;
+
+	/* ä½ã¬ãã«åºåã¨ã®çµå */
+	cPutLog = PutLogTarget.ePutLog;
+};
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®çµä¸ãè¨è¿°
+ *
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåãå¤ãå ´åã«ã¯ï¼ä»¥ä¸ã®ã»ã«ã®çµä¸ãè¨è¿°
+ *  ãåé¤ããã°ããï¼
+ */
+cell tBanner Banner {
+	/* å±æ§ã®è¨­å® */
+	targetName      = BannerTargetName;
+	copyrightNotice = BannerCopyrightNotice;
+};
+
+/*
+ *  ãµã³ãã«ãã­ã°ã©ã ã®å®ç¾©
+ */
+[singleton]
+celltype tSample2 {
+	require tKernel.eKernel;			/* å¼ã³å£åãªãï¼ä¾ï¼delayï¼*/
+	/*require cKernel = tKernel.eKernel;/* å¼ã³å£åããï¼ä¾ï¼cKernel_delayï¼*/
+	require ciKernel = tKernel.eiKernel;/* å¼ã³å£åããï¼ä¾ï¼ciKernel_ï¼*/
+
+	call sTask		    cTask[4];		/* ã¿ã¹ã¯æä½ */
+	call sTask 			cExceptionTask;
+	call sCyclic        cCyclic;
+	call sAlarm         cAlarm;
+
+	[optional] call sSerialPort	cSerialPort;/* ã·ãªã¢ã«ãã©ã¤ãã¨ã®æ¥ç¶ */
+	call sSysLog		cSysLog;		/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®æ¥ç¶ */
+	
+	entry sTaskBody		eMainTask;	  	/* Mainã¿ã¹ã¯ */
+	entry sTaskBody		eSampleTask[3];	/* ä¸¦è¡å®è¡ãããã¿ã¹ã¯ */
+	entry sTaskBody		eExceptionTask;	/* ä¾å¤å¦çã¿ã¹ã¯ */
+	
+	entry siHandlerBody eiCyclicHandler;/* å¨æãã³ãã©*/
+	entry siHandlerBody eiAlarmHandler; /* ã¢ã©ã¼ã ãã³ãã© */
+};
+
+/*
+ *  çµã¿ä¸ãè¨è¿°
+ */
+
+/* Sample2ã®ãã­ãã¿ã¤ãå®£è¨ */
+cell tSample2 Sample2;
+
+cell tKernel ASPKernel{
+};
+
+cell tTask MainTask {
+	/* å¼ã³å£ã®çµå */
+	cTaskBody = Sample2.eMainTask;
+	/* å±æ§ã®è¨­å® */
+	attribute = C_EXP("TA_ACT");
+	priority = C_EXP("MAIN_PRIORITY");
+	stackSize = C_EXP("STACK_SIZE");
+};
+
+cell tTask Task1 {
+	/* å¼ã³å£ã®çµå */
+	cTaskBody = Sample2.eSampleTask[0];
+	  /* å±æ§ã®è¨­å® */
+	priority = C_EXP("MID_PRIORITY");
+	stackSize = C_EXP("STACK_SIZE");
+};
+
+cell tTask Task2 {
+	/* å¼ã³å£ã®çµå */
+	cTaskBody = Sample2.eSampleTask[1];
+	/* å±æ§ã®è¨­å® */
+	priority = C_EXP("MID_PRIORITY");
+	stackSize = C_EXP("STACK_SIZE");
+};
+
+cell tTask Task3 {
+	/* å¼ã³å£ã®çµå */
+	cTaskBody = Sample2.eSampleTask[2];
+	/* å±æ§ã®è¨­å® */
+	priority = C_EXP("MID_PRIORITY");
+	stackSize = C_EXP("STACK_SIZE");
+};
+
+cell tTask ExceptionTask {
+	/* å¼ã³å£ã®çµå */
+	cTaskBody = Sample2.eExceptionTask;
+	/* å±æ§ã®è¨­å® */
+	priority = C_EXP("EXC_PRIORITY");
+	stackSize = C_EXP("STACK_SIZE");
+};
+
+cell tCyclicHandler CyclicHandler {
+	/* å¼ã³å£ã®çµå */
+	ciHandlerBody = Sample2.eiCyclicHandler;
+	/* å±æ§ã®è¨­å® */
+	cycleTime = 2000000;
+};
+
+cell tAlarmHandler AlarmHandler {
+	ciHandlerBody = Sample2.eiAlarmHandler;
+};
+
+cell tSample2 Sample2 {
+	/* å¼ã³å£ã®çµå */
+	cTask[ 0 ] = MainTask.eTask;
+	cTask[ 1 ] = Task1.eTask;
+	cTask[ 2 ] = Task2.eTask;
+	cTask[ 3 ] = Task3.eTask;
+
+	cExceptionTask = ExceptionTask.eTask;
+
+	cCyclic = CyclicHandler.eCyclic;
+	cAlarm  = AlarmHandler.eAlarm;
+
+	cSerialPort = SerialPort1.eSerialPort;
+	cSysLog = SysLog.eSysLog;
+};
Index: asp3_gr_sakura/trunk/sample/tSample2.cfg
===================================================================
--- asp3_gr_sakura/trunk/sample/tSample2.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tSample2.cfg	(revision 317)
@@ -0,0 +1,12 @@
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (2)ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+INCLUDE("gen/tecsgen.cfg");
+
+#include "tSample2.h"
+
+#ifdef CPUEXC1
+DEF_EXC(CPUEXC1, { TA_NULL, cpuexc_handler });
+#endif /* CPUEXC1 */
Index: asp3_gr_sakura/trunk/sample/tSample2.h
===================================================================
--- asp3_gr_sakura/trunk/sample/tSample2.h	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tSample2.h	(revision 317)
@@ -0,0 +1,106 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ *
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2007 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ *
+ *  $Id$
+ */
+
+/*
+ *		ãµã³ãã«ãã­ã°ã©ã (2)ã®ããããã¡ã¤ã«
+ */
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®å®ç¾©
+ */
+#include "target_test.h"
+
+/*
+ *  åã¿ã¹ã¯ã®åªå
+åº¦ã®å®ç¾©
+ */
+
+#define EXC_PRIORITY	1		/* ä¾å¤å¦çã¿ã¹ã¯ã®åªå
+åº¦ */
+#define MAIN_PRIORITY	5		/* ã¡ã¤ã³ã¿ã¹ã¯ã®åªå
+åº¦ */
+								/* HIGH_PRIORITYããé«ããããã¨ */
+
+#define HIGH_PRIORITY	9		/* ä¸¦åã«å®è¡ãããã¿ã¹ã¯ã®åªå
+åº¦ */
+#define MID_PRIORITY	10
+#define LOW_PRIORITY	11
+
+/*
+ *  ã¿ã¼ã²ããã«ä¾å­ããå¯è½æ§ã®ããå®æ°ã®å®ç¾©
+ */
+
+#ifndef STACK_SIZE
+#define	STACK_SIZE		4096		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+#endif /* STACK_SIZE */
+
+#ifndef LOOP_REF
+#define LOOP_REF		ULONG_C(1000000)	/* éåº¦è¨æ¸¬ç¨ã®ã«ã¼ãåæ° */
+#endif /* LOOP_REF */
+
+/*
+ *  é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+//extern void	task(intptr_t exinf);
+extern void	main_task(intptr_t exinf);
+extern void	cyclic_handler(intptr_t exinf);
+extern void	alarm_handler(intptr_t exinf);
+extern void	cpuexc_handler(void *p_excinf);
+
+#endif /* TOPPERS_MACRO_ONLY */
Index: asp3_gr_sakura/trunk/sample/tinet_app_config.h
===================================================================
--- asp3_gr_sakura/trunk/sample/tinet_app_config.h	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tinet_app_config.h	(revision 317)
@@ -0,0 +1,668 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_APP_CONFIG_H_
+#define _TINET_APP_CONFIG_H_
+
+/*
+ *  ã¤ã³ã¿ã¼ããããã­ãã³ã«ãã¡ããªã¼ã®ãµãã¼ã
+ *
+ *    Makefile ã§æå®ãã¦ãè¯ã
+ */
+
+/*#define SUPPORT_INET4		TCP/IP,IPv4		*/
+/*#define SUPPORT_INET6		TCP/IP,IPv6		*/
+/*#define SUPPORT_TCP		TCP			*/
+/*#define SUPPORT_UDP		UDP			*/
+
+/*ãã¼ã¿ãªã³ã¯å±¤ã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãé¸æãã	*/
+/*ããããä¸ã¤ã ãé¸æã§ããã				*/
+
+/*#define SUPPORT_PPP		PointtoPointProtocol	*/
+/*#define SUPPORT_LOOP		LocalLoopBack		*/
+/*#define SUPPORT_ETHER		Ethernet		*/
+
+/*#define SUPPORT_MIB		MIB(SNMP)		*/
+
+/*
+ *  TCP/IP ã«é¢ããå®ç¾©
+ */
+
+/* TCP ã«é¢ããå®ç¾© */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+ *    æ³¨æ: Makefile ã§æå®ãã¦ããã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_RWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
+ *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ã
+ *  ãã ããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
+ *  ã¾ããæå®ããªãã¨å¶éããªãã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_MAX_QUEUES	2*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã§ã
+ *  éä¿¡ã¦ã£ã³ããããã¡ã«ä½¿ç¨ãããããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef SUPPORT_INET6
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IPV6_MMTU)	/* æå¤§ãµã¤ãº */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IP4_MSS)		/* æå¤§ãµã¤ãº */
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	IF_PDU_SIZE			/* æå¤§ãµã¤ãº */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MIN_SIZE	0				/* æå°ãµã¤ãº */
+
+/*
+ *  TCP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_TCP_CFG_NON_BLOCKING
+#undef TCP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
+ *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef MAX_TCP_SND_SEG
+#undef MAX_TCP_SND_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define MAX_TCP_SND_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define MAX_TCP_SND_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef DEF_TCP_RCV_SEG
+#undef DEF_TCP_RCV_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define DEF_TCP_RCV_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define DEF_TCP_RCV_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹åé¢æ©è½
+ *
+ *  Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ã®ã¨ã³ããªæ°ãæå®ããã
+ *  æå®ããªããã0 ãæå®ããã¨ã
+ *  ã¿ã¹ã¯ãã Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ãåé¢ããæ©è½ã¯çµè¾¼ã¾ãªãã
+ */
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_TCP_TW_CEP_ENTRY		3
+#else
+#define NUM_TCP_TW_CEP_ENTRY		6
+#endif
+
+/*
+ *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½
+ */
+//#define TCP_CFG_TRACE
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã® IPv4 ã¢ãã¬ã¹
+ *  IPV4_ADDRANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¹ããå¯¾è±¡ã¨ããã
+ */
+#define TCP_CFG_TRACE_IPV4_RADDR	IPV4_ADDRANY
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_RPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_RPORTNO		UINT_C(7)
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ã­ã¼ã«ã«ãã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_LPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_LPORTNO		UINT_C(7)
+
+/*
+ *  ITRON TCP/IP APIãTCP ã®æ¡å¼µæ©è½
+ */
+//#define TCP_CFG_EXTENTIONS
+
+/*
+ *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
+ *
+ *    -1: BSD ã®å®è£
+ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
+ *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
+ */
+
+//#define TCP_CFG_URG_OFFSET	-1
+//#define TCP_CFG_URG_OFFSET	0
+
+/* UDP ã«é¢ããå®ç¾© */
+
+/*
+ *  UDP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_UDP_CFG_NON_BLOCKING
+#undef UDP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  ITRON TCP/IP APIãUDP ã®æ¡å¼µæ©è½
+ */
+//#define UDP_CFG_EXTENTIONS
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#if 1
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,1,21)
+#else
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#if 1
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(192,168,1,31)
+#else
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+#ifdef DHCP4_CLI_CFG
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(0,0,0,0)
+
+#else	/* of #ifdef DHCP4_CLI_CFG */
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(172,25,129,200)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(255,255,255,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(172,25,129,140)
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	3
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+/*
+ *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ã¤ã¼ãµãããã«é¢ããå®ç¾©
+ */
+
+/*
+ *  PPP ã«é¢ããå®ç¾©
+ */
+
+#define HDLC_PORTID			1	/* HDLC(PPP)ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·	*/
+
+/*#define PPP_IDLE_TIMEOUT		(180*NET_TIMER_HZ)*/
+					/* åæ­ã¾ã§ã®ã¢ã¤ãã«æéã		*/
+					/* åæ­ããªãå ´åã¯ã³ã¡ã³ãã¢ã¦ãããã	*/
+
+/*#define PPP_CFG_MODEM			 ã¢ãã æ¥ç¶ã®å ´åã¯ã³ã¡ã³ããå¤ãã	*/
+
+#define MODEM_CFG_INIT			"ATE1&D0&S0\\V0\\Q1S0=1"
+					/* ã¢ãã åæåæå­å			*/
+					/* NTT DoComo ã¢ãã¤ã«ã¢ããã¿ 96F ç¨	*/
+					/*   E1: ã¨ã³ã¼ããã¯ãã			*/
+					/*  &D0: ERä¿¡å·ç¡è¦			*/
+					/*  &S0: DRä¿¡å·å¸¸æ ON			*/
+					/*  \V0: ãªã¶ã«ãã³ã¼ã TYPE 1		*/
+					/*  \Q1: XON/XOFF ãã­ã¼å¶å¾¡		*/
+					/* S0=1: èªåçä¿¡ãªã³ã°åæ° = 1 å	*/
+
+#define MODEM_CFG_PHONE_NUMBER		"090-xxxx-9242"
+
+					/* èªæ§ææ
+å ±ã®è¦å®å¤			*/
+#define DEF_LCP_LOCAL_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+					/* ç¸æã«è¨±ãæ§ææ
+å ±ã®è¦å®å¤		*/
+#define DEF_LCP_REMOTE_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+/*
+ *  èªè¨¼ã«é¢ããå®ç¾©
+ */
+
+#define AUTH_CFG_CLIENT		   	/* èªè¨¼ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã	*/
+#define AUTH_CFG_SERVER			/* èªè¨¼ãµã¼ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã		*/
+
+#define AUTH_LOCAL_USER			"h8"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å	*/
+#define AUTH_LOCAL_PASSWD		"3048f"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã	*/
+#define AUTH_REMOTE_USER		"pen3"		/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å		*/
+#define AUTH_REMOTE_PASSWD		"600MHz"	/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã		*/
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+/*#define ARP_CFG_CALLBACK_DUPLICATED*/	/* IP ã¢ãã¬ã¹éè¤æ¤åºã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã		*/
+
+/*
+ *  ICMPv4/v6 ã«é¢ããå®ç¾©
+ */
+
+#ifdef USE_PING
+
+#define ICMP_CFG_CALLBACK_ECHO_REPLY	/* ICMP ECHO å¿ç­ãåä¿¡ããã¨ãå¼åºãã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã			*/
+
+#endif	/* of #ifdef USE_PING */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
+ */
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
+ */
+
+/*
+ *  64 ãªã¯ããã
+ *
+ *    IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    IPv6 ã§ã¯ãTCP å¶å¾¡ã»ã°ã¡ã³ãï¼CSEGãSDU ãªãï¼ãµã¤ãºã®
+ *    ãããã¯ã¼ã¯ãããã¡ï¼IF + IPv6 + TCP = 74ï¼ä»¥ä¸ã®
+ *    ãããã¯ã¼ã¯ãããã¡ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_64
+#undef NUM_MPF_NET_BUF_64
+#endif
+
+#ifdef SUPPORT_INET4
+#define NUM_MPF_NET_BUF_64		2
+#else
+#define NUM_MPF_NET_BUF_64		0
+#endif
+
+/*
+ *  CSEGï¼IF + IP + TCPï¼
+ *
+ *    IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    MBED Ethernet Controler ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_mbedï¼ã®æä½å²å½ã¦é·ã¯ã
+ *    ã¤ã¼ãµããããã¬ã¼ã ã®æç­é·ã§ãã 60ï¼CRC ã® 4 ãªã¯ããããé¤ãã
+ *    æ´ã«ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã§ããã
+ *    å¾ã£ã¦ãIPv4 ã§ã¯ãCSEG ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ *   ï¼IF + IPv4 + TCP = 54ï¼ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_CSEG
+#undef NUM_MPF_NET_BUF_CSEG
+#endif
+
+#ifdef SUPPORT_INET6
+#define NUM_MPF_NET_BUF_CSEG		2
+#else
+#define NUM_MPF_NET_BUF_CSEG		0
+#endif
+
+/*
+ *  128 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    128 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_128
+#undef NUM_MPF_NET_BUF_128
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_128		0
+#else
+#define NUM_MPF_NET_BUF_128		1
+#endif
+
+/*
+ *  256 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    256 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_256
+#undef NUM_MPF_NET_BUF_256
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_256		0
+#else
+#define NUM_MPF_NET_BUF_256		1
+#endif
+
+/*
+ *  512 ãªã¯ããã	
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    512 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_512
+#undef NUM_MPF_NET_BUF_512
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_512		0
+#else
+#define NUM_MPF_NET_BUF_512		1
+#endif
+
+/*
+ *  TCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼
+ *
+ *   ã»IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IP_MSS
+#undef NUM_MPF_NET_BUF_IP_MSS
+#endif
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG)
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IP_MSS		3
+#else
+#define NUM_MPF_NET_BUF_IP_MSS		2	/* IF + 576 ãªã¯ããã	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+#define NUM_MPF_NET_BUF_IP_MSS		0	/* IF + 576 ãªã¯ããã	*/
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+/*
+ *  1024 ãªã¯ããã	
+ *
+ *    TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    1024 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_1024
+#undef NUM_MPF_NET_BUF_1024
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_1024		0	/* 1024 ãªã¯ããã	*/
+#else
+#define NUM_MPF_NET_BUF_1024		1	/* 1024 ãªã¯ããã	*/
+#endif
+
+/*
+ *  TCP MSSï¼IPV6 MMTUãIF + 1280 ãªã¯ãããï¼
+ *
+ *   ã»IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IPV6_MMTU
+#undef NUM_MPF_NET_BUF_IPV6_MMTU
+#endif
+
+#if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU))
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IPV6_MMTU	3	/* IF + 1280	*/
+#else
+#define NUM_MPF_NET_BUF_IPV6_MMTU	2	/* IF + 1280	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+/*
+ *  IF æå¤§ PDU ãµã¤ãº
+ *
+ *   ã»TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *     IF æå¤§ PDU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IF_PDU
+#undef NUM_MPF_NET_BUF_IF_PDU
+#endif
+
+#ifdef USE_TCP_MSS_SEG
+
+#define NUM_MPF_NET_BUF_IF_PDU		0
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#if (defined(TCP_CFG_RWBUF_CSAVE) || defined(TCP_CFG_SWBUF_CSAVE)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IF_PDU		9
+#else
+#define NUM_MPF_NET_BUF_IF_PDU		8
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  65536 ãªã¯ããã
+ *
+ *  ã»NET_BUF_CFG_LONG_LEN ãå®ç¾©ããã¨ãã®ã¿å²ãå½ã¦ãã
+ */
+
+#ifdef NET_BUF_CFG_LONG_LEN
+
+/* IPv6 ç¨ */
+
+#ifdef NUM_MPF_NET_BUF6_65536
+#undef NUM_MPF_NET_BUF6_65536
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF6_65536	0
+#else
+#define NUM_MPF_NET_BUF6_65536	2
+#endif
+
+#else	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#define NUM_MPF_NET_BUF6_65536	0
+
+#endif	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  DNS ãµã¼ãã«é¢ããå®ç¾©
+ */
+
+/* DNS ãµã¼ãã® IP ã¢ãã¬ã¹ */
+
+#if !defined(DHCP6_CLI_CFG)
+
+#define IPV6_ADDR_DNS_INIT	\
+	{{{ UINT_C(0xfd), UINT_C(0x90), UINT_C(0xcc), UINT_C(0xe5), \
+	    UINT_C(0x25), UINT_C(0xf6), UINT_C(0xff), UINT_C(0x81), \
+	    UINT_C(0x02), UINT_C(0xa0), UINT_C(0x24), UINT_C(0xff), \
+	    UINT_C(0xfe), UINT_C(0x56), UINT_C(0xc5), UINT_C(0xd6) }}}
+
+#endif	/* of #if !defined(DHCP6_CLI_CFG) */
+
+#if !defined(DHCP4_CLI_CFG)
+#define IPV4_ADDR_DNS		MAKE_IPV4_ADDR(172,25,129,140)
+#endif
+
+/* DOMAIN å */
+
+#if !(defined(DHCP4_CLI_CFG) || defined(DHCP6_CLI_CFG))
+#define RSLV_CFG_DNS_DOMAIN_NAME_STR	"jo.tomakomai-ct.ac.jp"
+#endif
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã«é¢ããå®ç¾©
+ */
+
+/* DHCPv6 ã®åä½ã¢ã¼ãã®è¨­å® */
+
+#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATELESS
+//#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATEFULL
+
+#endif /* _TINET_APP_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/sample/tinet_sample1n.cfg
===================================================================
--- asp3_gr_sakura/trunk/sample/tinet_sample1n.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/sample/tinet_sample1n.cfg	(revision 317)
@@ -0,0 +1,96 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ sample1.c ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "sample1n.h"
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (TCP_REPID, { 0, { IPV6_ADDRANY, 23 } } );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_REP (TCP_REPID,	 { 0, { IPV4_ADDRANY, 23 } } );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_CEP (TCP_CEPID, {
+	0,
+	tcp_swbuf,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_CEP (TCP_CEPID, {
+	0,
+	tcp_swbuf,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
Index: asp3_gr_sakura/trunk/syssvc/histogram.h
===================================================================
--- asp3_gr_sakura/trunk/syssvc/histogram.h	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/histogram.h	(revision 317)
@@ -0,0 +1,92 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å®è¡æéåå¸éè¨ãµã¼ãã¹
+ */
+
+#ifndef TOPPERS_HISTOGRAM_H
+#define TOPPERS_HISTOGRAM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+
+/*
+ *  å®è¡æéåå¸è¨æ¸¬ã®åæå
+ */
+extern void	init_hist(ID histid);
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®éå§
+ */
+extern void	begin_measure(ID histid);
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®çµäº
+ */
+extern void	end_measure(ID histid);
+
+/*
+ *  å®è¡æéåå¸è¨æ¸¬ã®è¡¨ç¤º
+ */
+extern void	print_hist(ID histid);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_HISTOGRAM_H */
Index: asp3_gr_sakura/trunk/syssvc/serial.h
===================================================================
--- asp3_gr_sakura/trunk/syssvc/serial.h	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/serial.h	(revision 317)
@@ -0,0 +1,105 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ã
+ */
+
+#ifndef TOPPERS_SERIAL_H
+#define TOPPERS_SERIAL_H
+
+#include <kernel.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ç¨ãããã±ãã
+ */
+typedef struct {
+	uint_t		reacnt;			/* åä¿¡ãããã¡ä¸­ã®æå­æ° */
+	uint_t		wricnt;			/* éä¿¡ãããã¡ä¸­ã®æå­æ° */
+} T_SERIAL_RPOR;
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ãµã¼ãã¹ã³ã¼ã«
+ */
+extern ER		serial_opn_por(ID portid) throw();
+extern ER		serial_cls_por(ID portid) throw();
+extern ER_UINT	serial_rea_dat(ID portid, char *buf, uint_t len) throw();
+extern ER_UINT	serial_wri_dat(ID portid, const char *buf, uint_t len) throw();
+extern ER		serial_ctl_por(ID portid, uint_t ioctl) throw();
+extern ER		serial_ref_por(ID portid, T_SERIAL_RPOR *pk_rpor) throw();
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®åä½å¶å¾¡ç¨ã®ããã®å®æ°
+ *
+ *  ä»¥ä¸ã®å®æ°ã¯ï¼ãããæ¯ã«è«çåãã¨ã£ã¦ç¨ããï¼
+ */
+#define	IOCTL_NULL	0U			/* æå®ãªã */
+#define	IOCTL_ECHO	0x0001U		/* åä¿¡ããæå­ãã¨ã³ã¼ããã¯ */
+#define	IOCTL_CRLF	0x0010U		/* LFãéä¿¡ããåã«CRãä»å  */
+#define	IOCTL_FCSND	0x0100U		/* éä¿¡ã«å¯¾ãã¦ãã­ã¼å¶å¾¡ãè¡ã */
+#define	IOCTL_FCANY	0x0200U		/* ã©ã®ãããªæå­ã§ãéä¿¡åé */
+#define	IOCTL_FCRCV	0x0400U		/* åä¿¡ã«å¯¾ãã¦ãã­ã¼å¶å¾¡ãè¡ã */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_SERIAL_H */
Index: asp3_gr_sakura/trunk/syssvc/syslog.h
===================================================================
--- asp3_gr_sakura/trunk/syssvc/syslog.h	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/syslog.h	(revision 317)
@@ -0,0 +1,107 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°æ©è½
+ */
+
+#ifndef TOPPERS_SYSLOG_H
+#define TOPPERS_SYSLOG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <t_stddef.h>
+#include <t_syslog.h>
+
+/*
+ *  ã­ã°æ
+å ±ã®åºå
+ */
+extern ER	syslog_wri_log(uint_t prio, const SYSLOG *p_syslog) throw();
+
+/*
+ *  ã­ã°ãããã¡ããã®ã­ã°æ
+å ±ã®èª­åºã
+ */
+extern ER_UINT	syslog_rea_log(SYSLOG *p_syslog) throw();
+
+/*
+ *  åºåãã¹ãã­ã°æ
+å ±ã®éè¦åº¦ã®è¨­å®
+ */
+extern ER	syslog_msk_log(uint_t logmask, uint_t lowmask) throw();
+
+/*
+ *  ã­ã°ãããã¡ã®ç¶æ
+åç
+§
+ */
+extern ER	syslog_ref_log(T_SYSLOG_RLOG *pk_rlog) throw();
+
+/*
+ *  ä½ã¬ãã«åºåã«ãããã¹ã¦ã®ã­ã°æ
+å ±ã®åºå
+ */
+extern ER	syslog_fls_log(void) throw();
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TOPPERS_SYSLOG_H */
Index: asp3_gr_sakura/trunk/syssvc/tBanner.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tBanner.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tBanner.cdl	(revision 317)
@@ -0,0 +1,89 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®æ¬ä½ã®ã»ã«ã¿ã¤ã
+ */
+[singleton]
+celltype tBannerMain {
+	entry	sRoutineBody	eBannerInitialize;
+
+	attr {
+		char	*targetName;			/* ã¿ã¼ã²ããå */
+		char	*copyrightNotice;		/* èä½æ¨©è¡¨ç¤º */
+	};
+};
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåï¼è¤åã³ã³ãã¼ãã³ãï¼ã®ã»ã«ã¿ã¤ã
+ */
+[singleton,active]
+composite tBanner {
+	attr {
+		char	*targetName;			/* ã¿ã¼ã²ããå */
+		char	*copyrightNotice;		/* èä½æ¨©è¡¨ç¤º */
+	};
+
+	cell tBannerMain BannerMain {
+		/* å±æ§ã®ç¶æ¿ */
+		targetName      = composite.targetName;
+		copyrightNotice = composite.copyrightNotice;
+	};
+
+	cell tInitializeRoutine InitializeRoutine {
+		/* å¼ã³å£ */
+		cInitializeRoutineBody = BannerMain.eBannerInitialize;
+	};
+};
Index: asp3_gr_sakura/trunk/syssvc/tBannerMain.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tBannerMain.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tBannerMain.c	(revision 317)
@@ -0,0 +1,89 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2004-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸åºåã®æ¬ä½
+ */
+
+#include "tBannerMain_tecsgen.h"
+#include <t_syslog.h>
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸
+ */
+static const char banner[] = "\n"
+"TOPPERS/ASP3 Kernel Release %d.%X.%d for %s"
+" (" __DATE__ ", " __TIME__ ")\n"
+"Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory\n"
+"                            Toyohashi Univ. of Technology, JAPAN\n"
+"Copyright (C) 2004-2017 by Embedded and Real-Time Systems Laboratory\n"
+"            Graduate School of Information Science, Nagoya Univ., JAPAN\n"
+"%s";
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã®åºåï¼åãå£é¢æ°ï¼
+ */
+void
+eBannerInitialize_main(intptr_t exinf)
+{
+	syslog_5(LOG_NOTICE, banner,
+				(TKERNEL_PRVER >> 12) & 0x0fU,
+				(TKERNEL_PRVER >> 4) & 0xffU,
+				TKERNEL_PRVER & 0x0fU,
+				ATTR_targetName,
+				ATTR_copyrightNotice);
+}
Index: asp3_gr_sakura/trunk/syssvc/tHistogram.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tHistogram.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tHistogram.c	(revision 317)
@@ -0,0 +1,142 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å®è¡æéåå¸éè¨ãµã¼ãã¹
+ */
+
+#include "tHistogram_tecsgen.h"
+#define syslog_write	cSysLog_write
+#include <t_syslog.h>
+#include <log_output.h>
+
+/* 
+ *  å®è¡æéåå¸è¨æ¸¬ã®åæåï¼åãå£é¢æ°ï¼
+ */
+void
+eHistogram_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	uint_t	i;
+
+	for (i = 0; i <= ATTR_maxTime; i++) {
+		VAR_histarea[i] = 0U;
+	}
+	VAR_over = 0U;
+	VAR_under = 0U;
+}
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®éå§ï¼åãå£é¢æ°ï¼
+ */
+void
+eHistogram_beginMeasure(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	HIST_BM_HOOK();
+	HIST_GET_TIM(&VAR_begin_time);
+}
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®çµäºï¼åãå£é¢æ°ï¼
+ */
+void
+eHistogram_endMeasure(CELLIDX idx)
+{
+	CELLCB		*p_cellcb = GET_CELLCB(idx);
+	histtim_t	end_time, timediff;
+	uint_t		val;
+
+	HIST_GET_TIM(&end_time);
+
+	timediff = end_time - VAR_begin_time;
+#ifdef HISTTIM_CYCLE
+	if (end_time < VAR_begin_time) {
+		timediff += HISTTIM_CYCLE;
+	}
+#endif /* HISTTIM_CYCLE */
+	val = HIST_CONV_TIM(timediff);
+	if (val <= ATTR_maxTime) {
+		VAR_histarea[val]++;
+	}
+	else if (val <= ((uint_t) INT_MAX)) {
+		VAR_over++;
+	}
+	else {
+		VAR_under++;
+	}
+}
+
+/*
+ *  å®è¡æéåå¸è¨æ¸¬ã®è¡¨ç¤ºï¼åãå£é¢æ°ï¼
+ */
+void
+eHistogram_print(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	uint_t	i;
+
+	for (i = 0; i <= ATTR_maxTime; i++) {
+		if (VAR_histarea[i] > 0) {
+			syslog_2(LOG_NOTICE, "%d : %d", i, VAR_histarea[i]);
+		}
+	}
+	if (VAR_over > 0) {
+		syslog_2(LOG_NOTICE, "> %d : %d", ATTR_maxTime, VAR_over);
+	}
+	if (VAR_under > 0) {
+		syslog_1(LOG_NOTICE, "> INT_MAX : %d", VAR_under);
+	}
+}
Index: asp3_gr_sakura/trunk/syssvc/tHistogram.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tHistogram.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tHistogram.cdl	(revision 317)
@@ -0,0 +1,103 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å®è¡æéåå¸éè¨ãµã¼ãã¹ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+import_C("syssvc/tHistogram.h");
+
+/*
+ *  å®è¡æéåå¸éè¨ãµã¼ãã¹ã®ã·ã°ããã£
+ */
+signature sHistogram {
+	/*
+	 *  å®è¡æéåå¸è¨æ¸¬ã®åæå
+   	 */
+	void	initialize(void);
+
+	/*
+	 *  å®è¡æéè¨æ¸¬ã®éå§
+	 */
+	void	beginMeasure(void);
+
+	/*
+	 *  å®è¡æéè¨æ¸¬ã®çµäº
+	 */
+	void	endMeasure(void);
+
+	/*
+	 *  å®è¡æéåå¸è¨æ¸¬ã®è¡¨ç¤º
+	 */
+	void	print(void);
+};
+
+/*
+ *  å®è¡æéåå¸éè¨ãµã¼ãã¹ã®ã»ã«ã¿ã¤ã
+ */
+celltype tHistogram {
+	entry	sHistogram		eHistogram;
+
+	attr {
+		uint_t		maxTime = 1000;		/* åå¸ãè¨é²ããæå¤§æé */
+	};
+	var {
+		[size_is(maxTime + 1)] uint_t	*histarea;
+										/* åå¸ãè¨é²ããã¡ã¢ãªé å */
+		histtim_t	begin_time;			/* è¨æ¸¬éå§æå» */
+		uint_t		over;				/* æå¤§æéãè¶
+ããåº¦æ° */
+		uint_t		under;				/* æéã®éè»¢ãçãããåº¦æ° */
+	};
+};
Index: asp3_gr_sakura/trunk/syssvc/tHistogram.h
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tHistogram.h	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tHistogram.h	(revision 317)
@@ -0,0 +1,92 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		å®è¡æéåå¸éè¨ãµã¼ãã¹ã®ããããã¡ã¤ã«
+ */
+
+#ifndef TOPPERS_THISTOGRAM_H
+#define TOPPERS_THISTOGRAM_H
+
+#include "target_syssvc.h"
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ã§è¨­å®å¤æ´ããããã®ãã¯ã­
+ */
+#ifndef HISTTIM						/* å®è¡æéè¨æ¸¬ç¨ã®æå»ã®ãã¼ã¿å */
+#define HISTTIM					HRTCNT
+
+#ifdef TCYC_HRTCNT					/* å®è¡æéè¨æ¸¬ç¨ã®æå»ã®å¨æ */
+#define HISTTIM_CYCLE			TCYC_HRTCNT
+#endif /* TCYC_HRTCNT */
+#endif /* HISTTIM */
+
+#ifndef HIST_GET_TIM				/* å®è¡æéè¨æ¸¬ç¨ã®ç¾å¨æå»ã®åå¾ */
+#define HIST_GET_TIM(p_time)	(*(p_time) = fch_hrt())
+#endif /* HIST_GET_TIM */
+
+#ifndef HIST_CONV_TIM				/* æå»ã®å·®ããå®è¡æéã¸ã®å¤æ */
+#define HIST_CONV_TIM(time)		((uint_t)(time))
+#endif /* HIST_CONV_TIM */
+
+#ifndef HIST_BM_HOOK				/* å®è¡æéè¨æ¸¬ç´åã«è¡ãã¹ãå¦ç */
+#define HIST_BM_HOOK()			((void) 0)
+#endif
+
+/*
+ *  å®è¡æéè¨æ¸¬ç¨ã®æå»ã®ãã¼ã¿åã®å®ç¾©
+ */
+typedef HISTTIM	histtim_t;
+
+#endif /* TOPPERS_THISTOGRAM_H */
Index: asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.c	(revision 317)
@@ -0,0 +1,102 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®å®è¡æéåå¸
+ *		éè¨ãµã¼ãã¹ãå¼ã³åºãããã®ã¢ããã¿
+ */
+
+#include "tHistogramAdapter_tecsgen.h"
+#include "histogram.h"
+
+/*
+ *  å®è¡æéåå¸è¨æ¸¬ã®åæåï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+void
+init_hist(ID histid)
+{
+	assert(1 <= histid && histid <= N_CP_cHistogram);
+	return(cHistogram_initialize(histid - 1));
+}
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®éå§
+ */
+void
+begin_measure(ID histid)
+{
+	assert(1 <= histid && histid <= N_CP_cHistogram);
+	return(cHistogram_beginMeasure(histid - 1));
+}
+
+/*
+ *  å®è¡æéè¨æ¸¬ã®çµäº
+ */
+void
+end_measure(ID histid)
+{
+	assert(1 <= histid && histid <= N_CP_cHistogram);
+	return(cHistogram_endMeasure(histid - 1));
+}
+
+/*
+ *  å®è¡æéåå¸è¨æ¸¬ã®è¡¨ç¤º
+ */
+void
+print_hist(ID histid)
+{
+	assert(1 <= histid && histid <= N_CP_cHistogram);
+	return(cHistogram_print(histid - 1));
+}
Index: asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tHistogramAdapter.cdl	(revision 317)
@@ -0,0 +1,10 @@
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®å®è¡æéåå¸
+ *		éè¨ãµã¼ãã¹ãå¼ã³åºãããã®ã¢ããã¿ç¨ã»ã«ã¿ã¤ãã®å®ç¾©
+ * 
+ *  $Id$
+ */
+[singleton, active]
+celltype tHistogramAdapter {
+	call	sHistogram		cHistogram[];
+};
Index: asp3_gr_sakura/trunk/syssvc/tLogTask.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tLogTask.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tLogTask.cdl	(revision 317)
@@ -0,0 +1,143 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã·ã°ããã£
+ */
+signature sLogTask {
+	ER		flush([in] uint_t count);
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®æ¬ä½ã®ã»ã«ã¿ã¤ã
+ */
+[singleton]
+celltype tLogTaskMain {
+	entry	sTaskBody		eLogTaskBody;
+	entry	sRoutineBody	eLogTaskTerminate;
+	entry	sLogTask		eLogTask;
+
+	call	sSerialPort		cSerialPort;	/* ã·ãªã¢ã«ãã©ã¤ãã¨ã®æ¥ç¶ */
+	call	snSerialPortManage	cnSerialPortManage;
+											/* ã·ãªã¢ã«ãã©ã¤ãç®¡çã¨ã®æ¥ç¶ */
+	call	sSysLog			cSysLog;		/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®æ¥ç¶ */
+	call	sPutLog			cPutLog;		/* ä½ã¬ãã«åºåã¨ã®æ¥ç¶ */
+
+	attr {
+		RELTIM	interval;				/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åä½éé */
+		RELTIM	flushWait;				/* ãã©ãã·ã¥å¾
+ã¡ã®åä½æé */
+	};
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ï¼è¤åã³ã³ãã¼ãã³ãï¼ã®ã»ã«ã¿ã¤ã
+ */
+[singleton, active]
+composite tLogTask {
+	entry	sLogTask	eLogTask;		/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯æä½ */
+	
+	call	sSerialPort	cSerialPort;	/* ã·ãªã¢ã«ãã©ã¤ãã¨ã®æ¥ç¶ */
+	call	snSerialPortManage	cnSerialPortManage;
+										/* ã·ãªã¢ã«ãã©ã¤ãç®¡çã¨ã®æ¥ç¶ */
+	call	sSysLog		cSysLog;		/* ã·ã¹ãã ã­ã°æ©è½ã¨ã®æ¥ç¶ */
+	call	sPutLog		cPutLog;		/* ä½ã¬ãã«åºåã¨ã®æ¥ç¶ */
+
+	attr {
+		[omit] ATR		attribute = C_EXP("TA_ACT");	/* ã¿ã¹ã¯å±æ§ */
+		[omit] PRI  	priority;		/* ã¿ã¹ã¯ã®åæåªå
+åº¦ */
+		[omit] size_t 	stackSize;		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+		RELTIM		interval = 10000;	/* ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®åä½éé */
+		RELTIM		flushWait = 1000;	/* ãã©ãã·ã¥å¾
+ã¡ã®åä½æé */
+	};
+
+	cell tLogTaskMain LogTaskMain {
+		/* å¼ã³å£ã®çµå */
+		cSerialPort        => composite.cSerialPort;
+		cnSerialPortManage => composite.cnSerialPortManage;
+		cSysLog            => composite.cSysLog;
+		cPutLog            => composite.cPutLog;
+
+		/* å±æ§ã®ç¶æ¿ */
+		interval  = composite.interval;
+		flushWait = composite.flushWait;
+	};
+
+	cell tTask Task {
+		/* å¼ã³å£ã®çµå */
+		cTaskBody = LogTaskMain.eLogTaskBody;
+
+		/* å±æ§ã®ç¶æ¿ */
+		attribute = composite.attribute;
+		priority  = composite.priority;
+		stackSize = composite.stackSize;
+	};
+
+	cell tTerminateRoutine TerminateRoutine {
+		/* å¼ã³å£ */
+		cTerminateRoutineBody = LogTaskMain.eLogTaskTerminate;
+	};
+
+	/* åãå£ã®çµå */
+	composite.eLogTask => LogTaskMain.eLogTask;
+};
Index: asp3_gr_sakura/trunk/syssvc/tLogTaskMain.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tLogTaskMain.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tLogTaskMain.c	(revision 317)
@@ -0,0 +1,216 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã¿ã¹ã¯
+ */
+
+#include <kernel.h>
+#include "tLogTaskMain_tecsgen.h"
+#include <t_syslog.h>
+#include <log_output.h>
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ã¸ã®1æå­åºå
+ */
+static void
+logtask_putc(char c)
+{
+	cSerialPort_write(&c, 1);
+}
+
+/*
+ *  ä½ã¬ãã«åºåã¸ã®1æå­åºå
+ */
+static void
+target_fput_log(char c)
+{
+	cPutLog_putChar(c);
+}
+
+/*
+ *  ã·ã¹ãã ã­ã°åºåã®å¾
+ã¡åããï¼åãå£é¢æ°ï¼
+ */
+ER
+eLogTask_flush(uint_t count)
+{
+	T_SYSLOG_RLOG	rlog;
+	T_SERIAL_RPOR	rpor;
+	ER				ercd, rercd;
+
+	if (sns_dpn()) {
+		ercd = E_CTX;
+	}
+	else {
+		for (;;) {
+			if (cSysLog_refer(&rlog) < 0) {
+				ercd = E_SYS;
+				goto error_exit;
+			}
+			if (rlog.count <= count) {
+				if (count == 0U) {
+					/*
+					 *  countã0ã®å ´åã«ã¯ï¼ã·ãªã¢ã«ãããã¡ãç©ºããç¢º
+					 *  èªããï¼
+					 */
+					if (cSerialPort_refer(&rpor) < 0) {
+						ercd = E_SYS;
+						goto error_exit;
+					}
+					if (rpor.wricnt == 0U) {
+						ercd = E_OK;
+						goto error_exit;
+					}
+				}
+				else {
+					ercd = E_OK;
+					goto error_exit;
+				}
+			}
+
+			/*
+			 *  ãã©ãã·ã¥å¾
+ã¡ã®åä½æéï¼ATTR_flushWaitÎ¼ç§ï¼å¾
+ã¤ï¼
+			 */
+			rercd = dly_tsk(ATTR_flushWait);
+			if (rercd < 0) {
+				ercd = (rercd == E_RLWAI) ? rercd : E_SYS;
+				goto error_exit;
+			}
+		}
+	}
+
+  error_exit:
+	return(ercd);
+}
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®æ¬ä½ï¼åãå£é¢æ°ï¼
+ */
+void
+eLogTaskBody_main(void)
+{
+	SYSLOG	syslog;
+	uint_t	lost;
+	ER_UINT	rercd;
+
+	cSerialPort_open();
+	syslog_0(LOG_NOTICE, "System logging task is started.");
+
+	for (;;) {
+		lost = 0U;
+		while ((rercd = cSysLog_read(&syslog)) >= 0) {
+			lost += (uint_t) rercd;
+			if (lost > 0U) {
+				syslog_lostmsg(lost, logtask_putc);
+				lost = 0U;
+			}
+			syslog_print(&syslog, logtask_putc);
+			logtask_putc('\n');
+		}
+		if (lost > 0U) {
+			syslog_lostmsg(lost, logtask_putc);
+		}
+		dly_tsk(ATTR_interval);
+	}
+}
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®çµäºå¦çï¼åãå£é¢æ°ï¼
+ */
+void
+eLogTaskTerminate_main(intptr_t exinf)
+{
+	char	c;
+	SYSLOG	syslog;
+	bool_t	msgflg = false;
+	ER_UINT	rercd;
+
+	/*
+	 *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®éä¿¡ãããã¡ã«èç©ããããã¼ã¿
+	 *  ãï¼ä½ã¬ãã«åºåæ©è½ãç¨ãã¦åºåããï¼
+	 */
+	while (cnSerialPortManage_getChar(&c)) {
+		target_fput_log(c);
+	}
+
+	/*
+	 *  ã­ã°ãããã¡ã«è¨é²ãããã­ã°æ
+å ±ãï¼ä½ã¬ãã«åºåæ©è½ãç¨ãã¦åº
+	 *  åããï¼
+	 */
+	while ((rercd = cSysLog_read(&syslog)) >= 0) {
+		if (!msgflg) {
+			/*
+			 *  ã­ã°ãããã¡ã«æ®ã£ãã­ã°æ
+å ±ã§ãããã¨ãç¤ºãæå­åãåº
+			 *  åããï¼
+			 */
+			syslog_printf("-- buffered messages --\n", NULL, target_fput_log);
+			msgflg = true;
+		}
+		if (rercd > 0) {
+			syslog_lostmsg((uint_t) rercd, target_fput_log);
+		}
+		if (syslog.logtype >= LOG_TYPE_COMMENT) {
+			syslog_print(&syslog, target_fput_log);
+			target_fput_log('\n');
+		}
+	}
+}
Index: asp3_gr_sakura/trunk/syssvc/tSerialAdapter.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSerialAdapter.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSerialAdapter.c	(revision 317)
@@ -0,0 +1,160 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³
+ *		ã¿ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿
+ */
+
+#include "tSerialAdapter_tecsgen.h"
+#include "serial.h"
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®ãªã¼ãã³ï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER
+serial_opn_por(ID portid)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_open(portid - 1));
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®ã¯ã­ã¼ãºï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER
+serial_cls_por(ID portid)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_close(portid - 1));
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®æå­ååä¿¡ï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER_UINT
+serial_rea_dat(ID portid, char *buf, uint_t len)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_read(portid - 1, buf, len));
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®æå­åéä¿¡ï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER_UINT
+serial_wri_dat(ID portid, const char *buf, uint_t len)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_write(portid - 1, buf, len));
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡ï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER
+serial_ctl_por(ID portid, uint_t ioctl)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_control(portid - 1, ioctl));
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãç¶æ
+ã®åç
+§ï¼ãµã¼ãã¹ã³ã¼ã«ï¼
+ */
+ER
+serial_ref_por(ID portid, T_SERIAL_RPOR *pk_rpor)
+{
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!(1 <= portid && portid <= N_CP_cSerialPort)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	return(cSerialPort_refer(portid - 1, pk_rpor));
+}
Index: asp3_gr_sakura/trunk/syssvc/tSerialAdapter.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSerialAdapter.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSerialAdapter.cdl	(revision 317)
@@ -0,0 +1,10 @@
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ãªã¢ã«ã¤ã³
+ *		ã¿ãã§ã¼ã¹ãã©ã¤ããå¼ã³åºãããã®ã¢ããã¿ç¨ã»ã«ã¿ã¤ãã®å®ç¾©
+ * 
+ *  $Id$
+ */
+[singleton, active]
+celltype tSerialAdapter {
+	call	sSerialPort		cSerialPort[];
+};
Index: asp3_gr_sakura/trunk/syssvc/tSerialPort.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSerialPort.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSerialPort.cdl	(revision 317)
@@ -0,0 +1,209 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ããTECSãç¨ããã«å¼ã³åºãããã«ãå¿
+è¦
+ *  ãªå®ç¾©ã®åè¾¼ã¿
+ */
+import_C("syssvc/serial.h");
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã·ã°ããã£
+ */
+signature sSerialPort {
+	ER		open(void);
+	ER		close(void);
+	ER_UINT	read([out,size_is(length)] char *buffer, [in] uint_t length);
+	ER_UINT	write([in,size_is(length)] const char *buffer, [in] uint_t length);
+	ER		control([in] uint_t ioControl);
+	ER		refer([out] T_SERIAL_RPOR *pk_rpor);
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ãæä¾ããé¢æ°
+ */
+signature sSIOPort {
+	void	open(void);
+	void	close(void);
+	bool_t	putChar([in] char c);
+	int_t	getChar(void);
+	void	enableCBR([in] uint_t cbrtn);
+	void	disableCBR([in] uint_t cbrtn);
+};
+
+/*
+ *  ã³ã¼ã«ããã¯ã«ã¼ãã³ã®è­å¥çªå·ï¼cbrtnãã©ã¡ã¼ã¿ã«ç¨ããï¼
+ */
+const uint_t SIOSendReady = 1;		/* éä¿¡å¯è½ã³ã¼ã«ããã¯ */
+const uint_t SIOReceiveReady = 2;	/* åä¿¡éç¥ã³ã¼ã«ããã¯ */
+
+/*
+ *  ã¿ã¼ã²ããä¾å­é¨ããã®ã³ã¼ã«ããã¯
+ */
+[callback]
+signature siSIOCBR {
+	void	readySend(void);
+	void	readyReceive(void);
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãç®¡çç¨ã®ã·ã°ããã£ï¼çµäºå¦çã«ã¼ãã³
+ *  ããã®ä½¿ç¨ãæ³å®ï¼
+ */
+signature snSerialPortManage {
+	bool_t	getChar([out] char *p_char);
+};
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡é¨ã®ã»ã«ã¿ã¤ã
+ */
+celltype tSerialPortMain {
+	entry	sSerialPort			eSerialPort;
+	entry	snSerialPortManage	enSerialPortManage;
+
+	call	sSIOPort	cSIOPort;			/* ç°¡æSIOãã©ã¤ãã¨ã®æ¥ç¶ */
+	entry	siSIOCBR	eiSIOCBR;
+	
+	call	sSemaphore	cSendSemaphore;		/* éä¿¡ç¨ã»ããã©ã¨ã®æ¥ç¶ */
+	call	siSemaphore	ciSendSemaphore;
+	call	sSemaphore	cReceiveSemaphore;	/* åä¿¡ç¨ã»ããã©ã¨ã®æ¥ç¶ */
+	call	siSemaphore	ciReceiveSemaphore;
+	
+	attr {
+		uint_t	receiveBufferSize = 256;	/* åä¿¡ãããã¡ãµã¤ãº */
+		uint_t	sendBufferSize = 256;		/* éä¿¡ãããã¡ãµã¤ãº */
+	};
+	var {
+		bool_t	openFlag = C_EXP("false");	/* ãªã¼ãã³æ¸ã¿ãã©ã° */
+		bool_t	errorFlag;					/* ã¨ã©ã¼ãã©ã° */
+		uint_t	ioControl;					/* åä½å¶å¾¡ã®è¨­å®å¤ */
+
+		[size_is(receiveBufferSize)] char *receiveBuffer;	/* åä¿¡ãããã¡ */
+		uint_t	receiveReadPointer;			/* åä¿¡ãããã¡èª­åºããã¤ã³ã¿ */
+		uint_t	receiveWritePointer;		/* åä¿¡ãããã¡æ¸è¾¼ã¿ãã¤ã³ã¿ */
+		uint_t	receiveCount;				/* åä¿¡ãããã¡ä¸­ã®æå­æ° */
+		char  	receiveFlowControl;			/* éãã¹ãSTART/STOP */
+		bool_t	receiveStopped;				/* STOPãéã£ãç¶æ
+ãï¼ */
+
+		[size_is(sendBufferSize)] char *sendBuffer;		/* éä¿¡ãããã¡ */
+		uint_t	sendReadPointer;			/* éä¿¡ãããã¡èª­åºããã¤ã³ã¿ */
+		uint_t	sendWritePointer;			/* éä¿¡ãããã¡æ¸è¾¼ã¿ãã¤ã³ã¿ */
+		uint_t	sendCount;					/* éä¿¡ãããã¡ä¸­ã®æå­æ° */
+		bool_t	sendStopped;				/* STOPãåãåã£ãç¶æ
+ãï¼ */
+	};
+};
+
+/*
+ *  ã·ãªã¢ã«ãã¼ããã©ã¤ãï¼è¤åã»ã«ï¼ã®ã»ã«ã¿ã¤ã
+ *
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡é¨ã¨ï¼ãããä½¿ç¨ãã2ã¤ã®ã»ããã©ï¼åä¿¡ç¨ã¨é
+ *  ä¿¡ç¨ï¼ãè¤ååãã¦ï¼1ã¤ã®ã³ã³ãã¼ãã³ãã¨ãã¦ããï¼
+ */
+composite tSerialPort {
+	entry	sSerialPort			eSerialPort;
+	entry	snSerialPortManage	enSerialPortManage;
+
+	call	sSIOPort		cSIOPort;		/* ç°¡æSIOãã©ã¤ãã¨ã®æ¥ç¶ */
+	entry	siSIOCBR		eiSIOCBR;
+	
+	attr {
+		uint_t	receiveBufferSize = 256;	/* åä¿¡ãããã¡ãµã¤ãº */
+		uint_t	sendBufferSize = 256;		/* éä¿¡ãããã¡ãµã¤ãº */
+	};
+
+	/* åä¿¡ç¨ã®ã»ããã© */
+	cell tSemaphore ReceiveSemaphore {
+		attribute = C_EXP("TA_NULL");
+		initialCount = 0;
+		maxCount =1;
+	};
+
+	/* éä¿¡ç¨ã®ã»ããã© */
+	cell tSemaphore SendSemaphore {
+		attribute = C_EXP("TA_NULL");
+		initialCount = 1;
+		maxCount =1;
+	};
+
+	/* ã·ãªã¢ã«ãã¼ãã®å¶å¾¡é¨ */
+	cell tSerialPortMain SerialPortMain {
+		/* ã»ããã©ã¨ã®çµå */
+		cReceiveSemaphore  = ReceiveSemaphore.eSemaphore;
+		ciReceiveSemaphore = ReceiveSemaphore.eiSemaphore;
+		cSendSemaphore     = SendSemaphore.eSemaphore;
+		ciSendSemaphore    = SendSemaphore.eiSemaphore;
+
+		/* å¼ã³å£ã®ã¨ã¯ã¹ãã¼ã */
+		cSIOPort          => composite.cSIOPort;
+
+		/* å±æ§ã®ç¶æ¿ */
+		receiveBufferSize = composite.receiveBufferSize;
+		sendBufferSize    = composite.sendBufferSize;
+	};
+
+	/* åãå£ã®ã¨ã¯ã¹ãã¼ã */
+	composite.eSerialPort        => SerialPortMain.eSerialPort;
+	composite.enSerialPortManage => SerialPortMain.enSerialPortManage;
+	composite.eiSIOCBR           => SerialPortMain.eiSIOCBR;
+};
Index: asp3_gr_sakura/trunk/syssvc/tSerialPortMain.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSerialPortMain.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSerialPortMain.c	(revision 317)
@@ -0,0 +1,669 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2006-2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ã
+ */
+
+#include <kernel.h>
+#include "tSerialPortMain_tecsgen.h"
+#include <t_syslog.h>
+
+/*
+ *  ãã­ã¼å¶å¾¡ã«é¢é£ããå®æ°ã¨ãã¯ã­
+ */
+#define	FC_STOP			'\023'		/* ã³ã³ãã­ã¼ã«-S */
+#define	FC_START		'\021'		/* ã³ã³ãã­ã¼ã«-Q */
+
+#define BUFCNT_STOP(bufsz)		((bufsz) * 3 / 4)	/* STOPãéãåºæºæå­æ° */
+#define BUFCNT_START(bufsz)		((bufsz) / 2)		/* STARTãéãåºæºæå­æ° */
+
+/*
+ *  ãã¤ã³ã¿ã®ã¤ã³ã¯ãªã¡ã³ã
+ */
+#define INC_PTR(ptr, bufsz) do {	\
+	if (++(ptr) == (bufsz)) {		\
+		(ptr) = 0;					\
+	 }								\
+} while (false)
+
+/*
+ *  ãµã¼ãã¹ã³ã¼ã«å¼åºããã¯ã­
+ *
+ *  ãµã¼ãã¹ã³ã¼ã«å¼åºããå«ãå¼expãè©ä¾¡ãï¼è¿å¤ãã¨ã©ã¼ï¼è² ã®å¤ï¼ã®å ´
+ *  åã«ã¯ï¼ercã«ercd_expãè©ä¾¡ããå¤ãä»£å
+¥ãï¼error_exitã«gotoããï¼
+ */
+#define SVC(exp, ercd_exp) do {		\
+	if ((exp) < 0) {				\
+		ercd = (ercd_exp);			\
+		goto error_exit;			\
+	}								\
+} while (false)
+
+/*
+ *  E_SYSã¨ã©ã¼ã®çæ
+ */
+static ER
+gen_ercd_sys(CELLCB *p_cellcb)
+{
+	VAR_errorFlag = true;
+	return(E_SYS);
+}
+
+/*
+ *  å¾
+ã¡ã«å
+¥ããµã¼ãã¹ã³ã¼ã«ããã®ã¨ã©ã¼ã®å¤æ
+ */
+static ER
+gen_ercd_wait(ER rercd, CELLCB *p_cellcb)
+{
+	switch (MERCD(rercd)) {
+	case E_RLWAI:
+	case E_DLT:
+	case E_RASTER:
+		return(rercd);
+	default:
+		VAR_errorFlag = true;
+		return(E_SYS);
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®ãªã¼ãã³ï¼åãå£é¢æ°ï¼
+ */
+ER
+eSerialPort_open(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	ER		ercd;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+	p_cellcb = GET_CELLCB(idx);
+
+	SVC(dis_dsp(), gen_ercd_sys(p_cellcb));
+	if (VAR_openFlag) {				/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		ercd = E_OBJ;
+	}
+	else {
+		/*
+		 *  å¤æ°ã®åæå
+		 */
+		VAR_ioControl = (IOCTL_ECHO | IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);
+
+		VAR_receiveReadPointer = 0U;
+		VAR_receiveWritePointer = 0U;
+		VAR_receiveCount = 0U;
+		VAR_receiveFlowControl = '\0';
+		VAR_receiveStopped = false;
+
+		VAR_sendReadPointer = 0U;
+		VAR_sendWritePointer = 0U;
+		VAR_sendCount = 0U;
+		VAR_sendStopped = false;
+
+		/*
+		 *  ããä»¥éï¼å²è¾¼ã¿ãç¦æ­¢ããï¼
+		 */
+		if (loc_cpu() < 0) {
+			ercd = E_SYS;
+			goto error_exit_enadsp;
+		}
+
+		/*
+		 *  ãã¼ãã¦ã§ã¢ä¾å­ã®ãªã¼ãã³å¦ç
+		 */
+		cSIOPort_open();
+
+		/*
+		 *  åä¿¡éç¥ã³ã¼ã«ããã¯ãè¨±å¯ããï¼
+		 */
+		cSIOPort_enableCBR(SIOReceiveReady);
+		VAR_openFlag = true;
+		VAR_errorFlag = false;
+
+		if (unl_cpu() < 0) {
+			VAR_errorFlag = true;
+			ercd = E_SYS;
+			goto error_exit_enadsp;
+		}
+		ercd = E_OK;
+	}
+
+  error_exit_enadsp:
+	SVC(ena_dsp(), gen_ercd_sys(p_cellcb));
+
+  error_exit:
+	return(ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®ã¯ã­ã¼ãºï¼åãå£é¢æ°ï¼
+ */
+ER
+eSerialPort_close(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	ER		ercd;
+	bool_t	eflag = false;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+	p_cellcb = GET_CELLCB(idx);
+
+	SVC(dis_dsp(), gen_ercd_sys(p_cellcb));
+	if (!VAR_openFlag) {			/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		ercd = E_OBJ;
+	}
+	else {
+		/*
+		 *  ãã¼ãã¦ã§ã¢ä¾å­ã®ã¯ã­ã¼ãºå¦ç
+		 */
+		if (loc_cpu() < 0) {
+			eflag = true;
+		}
+		cSIOPort_close();
+		VAR_openFlag = false;
+		if (unl_cpu() < 0) {
+			eflag = true;
+		}
+
+		/*
+		 *  ã»ããã©ã®åæå
+		 */
+		if (cSendSemaphore_initialize() < 0) {
+			eflag = true;
+		}
+		if (cReceiveSemaphore_initialize() < 0) {
+			eflag = true;
+		}
+
+		/*
+		 *  ã¨ã©ã¼ã³ã¼ãã®è¨­å®
+		 */
+		if (eflag) {
+			ercd = gen_ercd_sys(p_cellcb);
+		}
+		else {
+			ercd = E_OK;
+		}
+	}
+	SVC(ena_dsp(), gen_ercd_sys(p_cellcb));
+
+  error_exit:
+	return(ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®æå­éä¿¡
+ *
+ *  p_cellcbã§æå®ãããSIOãã¼ãã«å¯¾ãã¦ï¼æå­cãéä¿¡ããï¼æå­ãéä¿¡
+ *  ã¬ã¸ã¹ã¿ã«ãããå ´åã«ã¯trueãè¿ãï¼ããã§ãªãå ´åã«ã¯ï¼éä¿¡ã¬ã¸ã¹
+ *  ã¿ãç©ºãããã¨ãéç¥ããã³ã¼ã«ããã¯é¢æ°ãè¨±å¯ãï¼falseãè¿ãï¼ãã®
+ *  é¢æ°ã¯ï¼CPUã­ãã¯ç¶æ
+ã§å¼ã³åºãããï¼
+ */
+Inline bool_t
+serialPort_sendChar(CELLCB *p_cellcb, char c)
+{
+	if (cSIOPort_putChar(c)) {
+		return(true);
+	}
+	else {
+		cSIOPort_enableCBR(SIOSendReady);
+		return(false);
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®1æå­éä¿¡
+ */
+static ER_BOOL
+serialPort_writeChar(CELLCB *p_cellcb, char c)
+{
+	bool_t	buffer_full;
+	ER		ercd, rercd;
+
+	/*
+	 *  LFã®åã«CRãéä¿¡ããï¼
+	 */
+	if (c == '\n' && (VAR_ioControl & IOCTL_CRLF) != 0U) {
+		/*
+		 *  ä»¥ä¸ã®ã³ã¼ãã¯åå¸°å¼åºãã«ãªã£ã¦ãããï¼å¼æ°cã'\n'ã®å ´åã«
+		 *  å¼æ°cã'\r'ã¨ãã¦å¼ã³åºããã¨ããï¼ãã®åå¸°å¼åºãã¯2åç®ã®
+		 *  å¼ã³åºãã§å¿
+ãæ­¢ã¾ãï¼
+		 */
+		SVC(rercd = serialPort_writeChar(p_cellcb, '\r'), rercd);
+		if ((bool_t) rercd) {
+			SVC(rercd = cSendSemaphore_wait(),
+										gen_ercd_wait(rercd, p_cellcb));
+		}
+	}
+
+	SVC(loc_cpu(), gen_ercd_sys(p_cellcb));
+	if (VAR_sendCount == 0U && !VAR_sendStopped
+								&& serialPort_sendChar(p_cellcb, c)) {
+		/*
+		 *  SIOã®éä¿¡ã¬ã¸ã¹ã¿ã«æå­ãå
+¥ãããã¨ã«æåããå ´åï¼
+		 */
+		buffer_full = false;
+	}
+	else {
+		/*
+		 *  éä¿¡ãããã¡ã«æå­ãå
+¥ããï¼
+		 */
+		VAR_sendBuffer[VAR_sendWritePointer] = c;
+		INC_PTR(VAR_sendWritePointer, ATTR_sendBufferSize);
+		VAR_sendCount++;
+		buffer_full = (VAR_sendCount == ATTR_sendBufferSize);
+	}
+
+	SVC(unl_cpu(), gen_ercd_sys(p_cellcb));
+	ercd = (ER_BOOL) buffer_full;
+
+  error_exit:
+	return(ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®æå­åéä¿¡ï¼åãå£é¢æ°ï¼
+ */
+ER_UINT
+eSerialPort_write(CELLIDX idx, const char *buffer, uint_t length)
+{
+	CELLCB	*p_cellcb;
+	bool_t	buffer_full;
+	uint_t	wricnt = 0U;
+	ER		ercd, rercd;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {			/* ãã¼ãçªå·ã®ãã§ãã¯ */
+		return(E_ID);
+	}
+
+	p_cellcb = GET_CELLCB(idx);
+	if (!VAR_openFlag) {			/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		return(E_OBJ);
+	}
+	if (VAR_errorFlag) {			/* ã¨ã©ã¼ç¶æ
+ãã®ãã§ãã¯ */
+		return(E_SYS);
+	}
+
+	buffer_full = true;				/* ã«ã¼ãã®1åãã¯wai_semãã */
+	while (wricnt < length) {
+		if (buffer_full) {
+			SVC(rercd = cSendSemaphore_wait(),
+										gen_ercd_wait(rercd, p_cellcb));
+		}
+		SVC(rercd = serialPort_writeChar(p_cellcb, *buffer++), rercd);
+		wricnt++;
+		buffer_full = (bool_t) rercd;
+	}
+	if (!buffer_full) {
+		SVC(cSendSemaphore_signal(), gen_ercd_sys(p_cellcb));
+	}
+	ercd = E_OK;
+
+  error_exit:
+	return(wricnt > 0U ? (ER_UINT) wricnt : ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®1æå­åä¿¡
+ */
+static bool_t
+serialPort_readChar(CELLCB *p_cellcb, char *p_c)
+{
+	bool_t	buffer_empty;
+	ER		ercd;
+
+	SVC(loc_cpu(), gen_ercd_sys(p_cellcb));
+
+	/*
+	 *  åä¿¡ãããã¡ããæå­ãåãåºãï¼
+	 */
+	*p_c = VAR_receiveBuffer[VAR_receiveReadPointer];
+	INC_PTR(VAR_receiveReadPointer, ATTR_receiveBufferSize);
+	VAR_receiveCount--;
+	buffer_empty = (VAR_receiveCount == 0U);
+
+	/*
+	 *  STARTãéä¿¡ããï¼
+	 */
+	if (VAR_receiveStopped && VAR_receiveCount
+								<= BUFCNT_START(ATTR_receiveBufferSize)) {
+		if (!serialPort_sendChar(p_cellcb, FC_START)) {
+			VAR_receiveFlowControl = FC_START;
+		}
+		VAR_receiveStopped = false;
+	}
+
+	SVC(unl_cpu(), gen_ercd_sys(p_cellcb));
+	ercd = (ER_BOOL) buffer_empty;
+
+  error_exit:
+	return(ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®æå­ååä¿¡ï¼åãå£é¢æ°ï¼
+ */
+ER_UINT
+eSerialPort_read(CELLIDX idx, char *buffer, uint_t length)
+{
+	CELLCB	*p_cellcb;
+	bool_t	buffer_empty;
+	uint_t	reacnt = 0U;
+	char	c = '\0';		/* ã³ã³ãã¤ã©ã®è­¦åãææ­¢ããããã«åæåãã */
+	ER		ercd, rercd;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {			/* ãã¼ãçªå·ã®ãã§ãã¯ */
+		return(E_ID);
+	}
+
+	p_cellcb = GET_CELLCB(idx);
+	if (!VAR_openFlag) {			/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		return(E_OBJ);
+	}
+	if (VAR_errorFlag) {			/* ã¨ã©ã¼ç¶æ
+ãã®ãã§ãã¯ */
+		return(E_SYS);
+	}
+
+	buffer_empty = true;			/* ã«ã¼ãã®1åãã¯wai_semãã */
+	while (reacnt < length) {
+		if (buffer_empty) {
+			SVC(rercd = cReceiveSemaphore_wait(),
+										gen_ercd_wait(rercd, p_cellcb));
+		}
+		SVC(rercd = serialPort_readChar(p_cellcb, &c), rercd);
+		*buffer++ = c;
+		reacnt++;
+		buffer_empty = (bool_t) rercd;
+
+		/*
+		 *  ã¨ã³ã¼ããã¯å¦çï¼
+		 */
+		if ((VAR_ioControl & IOCTL_ECHO) != 0U) {
+			SVC(rercd = cSendSemaphore_wait(),
+										gen_ercd_wait(rercd, p_cellcb));
+			SVC(rercd = serialPort_writeChar(p_cellcb, c), rercd);
+			if (!((bool_t) rercd)) {
+				SVC(cSendSemaphore_signal(), gen_ercd_sys(p_cellcb));
+			}
+		}
+	}
+	if (!buffer_empty) {
+		SVC(cReceiveSemaphore_signal(), gen_ercd_sys(p_cellcb));
+	}
+	ercd = E_OK;
+
+  error_exit:
+	return(reacnt > 0U ? (ER_UINT) reacnt : ercd);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡ï¼åãå£é¢æ°ï¼
+ */
+ER
+eSerialPort_control(CELLIDX idx, uint_t ioctl)
+{
+	CELLCB	*p_cellcb;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	p_cellcb = GET_CELLCB(idx);
+	if (!VAR_openFlag) {			/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		return(E_OBJ);
+	}
+	if (VAR_errorFlag) {			/* ã¨ã©ã¼ç¶æ
+ãã®ãã§ãã¯ */
+		return(E_SYS);
+	}
+
+	VAR_ioControl = ioctl;
+	return(E_OK);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãç¶æ
+ã®åç
+§ï¼åãå£é¢æ°ï¼
+ */
+ER
+eSerialPort_refer(CELLIDX idx, T_SERIAL_RPOR* pk_rpor)
+{
+	CELLCB	*p_cellcb;
+
+	if (sns_dpn()) {				/* ã³ã³ãã­ã¹ãã®ãã§ãã¯ */
+		return(E_CTX);
+	}
+	if (!VALID_IDX(idx)) {
+		return(E_ID);				/* ãã¼ãçªå·ã®ãã§ãã¯ */
+	}
+
+	p_cellcb = GET_CELLCB(idx);
+	if (!VAR_openFlag) {			/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+		return(E_OBJ);
+	}
+	if (VAR_errorFlag) {			/* ã¨ã©ã¼ç¶æ
+ãã®ãã§ãã¯ */
+		return(E_SYS);
+	}
+
+	pk_rpor->reacnt = VAR_receiveCount;
+	pk_rpor->wricnt = VAR_sendCount;
+	return(E_OK);
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®éä¿¡å¯è½ã³ã¼ã«ããã¯ï¼åãå£é¢æ°ï¼
+ */
+void
+eiSIOCBR_readySend(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+
+	assert(VALID_IDX(idx));
+	p_cellcb = GET_CELLCB(idx);
+	if (VAR_receiveFlowControl != '\0') {
+		/*
+		 *  START/STOP ãéä¿¡ããï¼
+		 */
+		(void) cSIOPort_putChar(VAR_receiveFlowControl);
+		VAR_receiveFlowControl = '\0';
+	}
+	else if (!VAR_sendStopped && VAR_sendCount > 0U) {
+		/*
+		 *  éä¿¡ãããã¡ä¸­ããæå­ãåãåºãã¦éä¿¡ããï¼
+		 */
+		(void) cSIOPort_putChar(VAR_sendBuffer[VAR_sendReadPointer]);
+		INC_PTR(VAR_sendReadPointer, ATTR_sendBufferSize);
+		if (VAR_sendCount == ATTR_sendBufferSize) {
+			if (ciSendSemaphore_signal() < 0) {
+				VAR_errorFlag = true;
+			}
+		}
+		VAR_sendCount--;
+	}
+	else {
+		/*
+		 *  éä¿¡ãã¹ãæå­ããªãå ´åã¯ï¼éä¿¡å¯è½ã³ã¼ã«ããã¯ãç¦æ­¢ããï¼
+		 */
+		cSIOPort_disableCBR(SIOSendReady);
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®åä¿¡éç¥ã³ã¼ã«ããã¯ï¼åãå£é¢æ°ï¼
+ */
+void
+eiSIOCBR_readyReceive(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	char	c;
+
+	assert(VALID_IDX(idx));
+	p_cellcb = GET_CELLCB(idx);
+	c = (char) cSIOPort_getChar();
+	if ((VAR_ioControl & IOCTL_FCSND) != 0U && c == FC_STOP) {
+		/*
+		 *  éä¿¡ãä¸æåæ­¢ããï¼éä¿¡ä¸­ã®æå­ã¯ãã®ã¾ã¾éä¿¡ããï¼
+		 */
+		VAR_sendStopped = true;
+	}
+	else if (VAR_sendStopped && (c == FC_START
+				|| (VAR_ioControl & IOCTL_FCANY) != 0U)) {
+		/*
+		 *  éä¿¡ãåéããï¼
+		 */
+		VAR_sendStopped = false;
+		if (VAR_sendCount > 0U) {
+			c = VAR_sendBuffer[VAR_sendReadPointer];
+			if (serialPort_sendChar(p_cellcb, c)) {
+				INC_PTR(VAR_sendReadPointer, ATTR_sendBufferSize);
+				if (VAR_sendCount == ATTR_sendBufferSize) {
+					if (ciSendSemaphore_signal() < 0) {
+						VAR_errorFlag = true;
+					}
+				}
+				VAR_sendCount--;
+			}
+		}
+	}
+	else if ((VAR_ioControl & IOCTL_FCSND) != 0U && c == FC_START) {
+		/*
+		 *  éä¿¡ã«å¯¾ãã¦ãã­ã¼å¶å¾¡ãã¦ããå ´åï¼START ã¯æ¨ã¦ãï¼
+		 */
+	}
+	else if (VAR_receiveCount == ATTR_receiveBufferSize) {
+		/*
+		 *  ãããã¡ãã«ã®å ´åï¼åä¿¡ããæå­ãæ¨ã¦ãï¼
+		 */
+	}
+	else {
+		/*
+		 *  åä¿¡ããæå­ãåä¿¡ãããã¡ã«å
+¥ããï¼
+		 */
+		VAR_receiveBuffer[VAR_receiveWritePointer] = c;
+		INC_PTR(VAR_receiveWritePointer, ATTR_receiveBufferSize);
+		if (VAR_receiveCount == 0U) {
+			if (ciReceiveSemaphore_signal() < 0) {
+				VAR_errorFlag = true;
+			}
+		}
+		VAR_receiveCount++;
+
+		/*
+		 *  STOPãéä¿¡ããï¼
+		 */
+		if ((VAR_ioControl & IOCTL_FCRCV) != 0U && !VAR_receiveStopped
+				&& VAR_receiveCount >= BUFCNT_STOP(ATTR_receiveBufferSize)) {
+			if (!serialPort_sendChar(p_cellcb, FC_STOP)) {
+				VAR_receiveFlowControl = FC_STOP;
+			}
+			VAR_receiveStopped = true;
+		}
+	}
+}
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãããã®æªéä¿¡æå­ã®ååºã
+ */
+bool_t
+enSerialPortManage_getChar(CELLIDX idx, char *p_c)
+{
+	CELLCB	*p_cellcb;
+
+	if (VALID_IDX(idx)) {						/* ãã¼ãçªå·ã®ãã§ãã¯ */
+		p_cellcb = GET_CELLCB(idx);
+		if (VAR_openFlag) {						/* ãªã¼ãã³æ¸ã¿ãã®ãã§ãã¯ */
+			if (VAR_sendCount > 0U) {
+				*p_c = VAR_sendBuffer[VAR_sendReadPointer];
+				INC_PTR(VAR_sendReadPointer, ATTR_sendBufferSize);
+				VAR_sendCount--;
+				return(true);
+			}
+		}
+	}
+	return(false);
+}
Index: asp3_gr_sakura/trunk/syssvc/tSysLog.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSysLog.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSysLog.c	(revision 317)
@@ -0,0 +1,251 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°æ©è½
+ */
+
+#include <sil.h>
+#include "tSysLog_tecsgen.h"
+#undef TOPPERS_OMIT_SYSLOG
+#include <t_syslog.h>
+#include <log_output.h>
+#include "target_syssvc.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ãã¯ã­ã®ããã©ã«ãå®ç¾©
+ *
+ *  ã·ã¹ãã ã­ã°ã«åºåãããã­ã°æ
+å ±ããã¬ã¼ã¹ã­ã°ã«ãè¨é²ã§ããããã«ï¼
+ *  eSyslog_writeã®å
+¥å£ã«ãã¬ã¼ã¹ã­ã°ãã¯ã­ãç½®ãï¼
+ */
+#ifndef LOG_TSYSLOG_ESYSLOG_WRITE_ENTER
+#define LOG_TSYSLOG_ESYSLOG_WRITE_ENTER(priority, p_syslog)
+#endif /* LOG_TSYSLOG_ESYSLOG_WRITE_ENTER */
+
+/*
+ *  ã­ã°æå»ã®åãåºã
+ *
+ *  ããã©ã«ãã§ã¯ï¼ã­ã°æå»ã¨ãã¦ï¼é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ãç¨ãã¦
+ *  ããï¼ã¿ã¼ã²ããä¾å­ã§å¤æ´ããå ´åã«ã¯ï¼SYSLOG_GET_LOGTIMã«ï¼ã­ã°æ
+ *  å»ãåãåºããã¯ã­ãå®ç¾©ããï¼
+ */
+#ifndef SYSLOG_GET_LOGTIM
+#define target_hrt_get_current		_kernel_target_hrt_get_current
+#include "target_timer.h"
+#define SYSLOG_GET_LOGTIM(p_logtim) \
+				(*(p_logtim) = _kernel_target_hrt_get_current())
+#endif /* SYSLOG_GET_LOGTIM */
+
+/*
+ *  ä½ã¬ãã«åºåã®å¼åºãé¢æ°
+ */
+static void
+low_putchar(char c)
+{
+	cPutLog_putChar(c);
+}
+
+/*
+ *  ã­ã°æ
+å ±ã®åºåï¼åãå£é¢æ°ï¼
+ *
+ *  CPUã­ãã¯ç¶æ
+ãå®è¡ã³ã³ãã­ã¹ãã«ãããåä½ã§ããããã«å®è£
+ãã¦ããï¼
+ */
+ER
+eSysLog_write(uint_t priority, const SYSLOG *p_syslog)
+{
+	SIL_PRE_LOC;
+
+	LOG_TSYSLOG_ESYSLOG_WRITE_ENTER(priority, p_syslog);
+	SIL_LOC_INT();
+
+	/*
+	 *  ã­ã°æå»ã®è¨­å®
+	 */
+	SYSLOG_GET_LOGTIM(&(((SYSLOG *) p_syslog)->logtim));
+
+	/*
+	 *  ã­ã°ãããã¡ã«è¨é²
+	 */
+	if ((VAR_logMask & LOG_MASK(priority)) != 0U) {
+		VAR_logBuffer[VAR_tail] = *p_syslog;
+		VAR_tail++;
+		if (VAR_tail >= ATTR_logBufferSize) {
+			VAR_tail = 0U;
+		}
+		if (VAR_count < ATTR_logBufferSize) {
+			VAR_count++;
+		}
+		else {
+			VAR_head = VAR_tail;
+			VAR_lost++;
+		}
+	}
+
+	/*
+	 *  ä½ã¬ãã«åºå
+	 */
+	if ((VAR_lowMask & LOG_MASK(priority)) != 0U) {
+		syslog_print(p_syslog, low_putchar);
+		low_putchar('\n');
+	}
+
+	SIL_UNL_INT();
+	return(E_OK);
+}
+
+/*
+ *  ã­ã°ãããã¡ããã®èª­åºãï¼åãå£é¢æ°ï¼
+ *
+ *  CPUã­ãã¯ç¶æ
+ãå®è¡ã³ã³ãã­ã¹ãã«ãããåä½ã§ããããã«å®è£
+ãã¦ããï¼
+ */
+ER_UINT
+eSysLog_read(SYSLOG *p_syslog)
+{
+	ER_UINT	ercd;
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+
+	/*
+	 *  ã­ã°ãããã¡ããã®ååºã
+	 */
+	if (VAR_count > 0U) {
+		*p_syslog = VAR_logBuffer[VAR_head];
+		VAR_count--;
+		VAR_head++;
+		if (VAR_head >= ATTR_logBufferSize) {
+			VAR_head = 0U;
+		}
+		ercd = (ER_UINT) VAR_lost;
+		VAR_lost = 0U;
+	}
+	else {
+		ercd = E_OBJ;
+	}
+
+	SIL_UNL_INT();
+	return(ercd);
+}
+
+/* 
+ *  åºåãã¹ãã­ã°æ
+å ±ã®éè¦åº¦ã®è¨­å®ï¼åãå£é¢æ°ï¼
+ */
+ER
+eSysLog_mask(uint_t logMask, uint_t lowMask)
+{
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+	VAR_logMask = logMask;
+	VAR_lowMask = lowMask;
+	SIL_UNL_INT();
+	return(E_OK);
+}
+
+/*
+ *  ã­ã°ãããã¡ã®ç¶æ
+åç
+§ï¼åãå£é¢æ°ï¼
+ */
+ER_UINT
+eSysLog_refer(T_SYSLOG_RLOG *pk_rlog)
+{
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+	pk_rlog->count = VAR_count;
+	pk_rlog->lost = VAR_lost;
+	pk_rlog->logmask = VAR_logMask;
+	pk_rlog->lowmask = VAR_lowMask;
+	SIL_UNL_INT();
+	return(E_OK);
+}
+
+/* 
+ *  ä½ã¬ãã«åºåã«ãããã¹ã¦ã®ã­ã°æ
+å ±ã®åºåï¼åãå£é¢æ°ï¼
+ */
+ER
+eSysLog_flush(void)
+{
+	SYSLOG	logbuf;
+	ER_UINT	rercd;
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+
+	while ((rercd = eSysLog_read(&logbuf)) >= 0) {
+		if (rercd > 0) {
+			syslog_lostmsg((uint_t) rercd, low_putchar);
+		}
+		if (logbuf.logtype >= LOG_TYPE_COMMENT) {
+			syslog_print(&logbuf, low_putchar);
+			low_putchar('\n');
+		}
+	}
+
+	SIL_UNL_INT();
+	return(E_OK);
+}
Index: asp3_gr_sakura/trunk/syssvc/tSysLog.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSysLog.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSysLog.cdl	(revision 317)
@@ -0,0 +1,134 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°æ©è½ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°åºåã«é¢ããå®ç¾©
+ */
+import_C("t_syslog.h");
+
+/*
+ *  ä½ã¬ãã«åºåã®ã·ã°ããã£
+ */
+signature sPutLog {
+	void	putChar([in] char c);
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ã·ã°ããã£
+ */
+signature sSysLog {
+	/*
+	 *  ã­ã°æ
+å ±ã®åºå
+	 */
+	ER		write([in] uint_t priority, [in] const SYSLOG *p_syslog);
+
+	/*
+	 *  ã­ã°ãããã¡ããã®ã­ã°æ
+å ±ã®èª­åºã
+	 */
+	ER_UINT	read([out] SYSLOG *p_syslog);
+
+	/*
+	 *  åºåãã¹ãã­ã°æ
+å ±ã®éè¦åº¦ã®è¨­å®
+	 */
+	ER		mask([in] uint_t logMask, [in] uint_t lowMask);
+
+	/*
+	 *  ä½ã¬ãã«åºåã«ãããã¹ã¦ã®ã­ã°æ
+å ±ã®åºå
+	 */
+	ER		refer([out] T_SYSLOG_RLOG *pk_rlog);
+
+	/*
+	 *  ä½ã¬ãã«åºåã«ãããã¹ã¦ã®ã­ã°æ
+å ±ã®åºå
+	 */
+	ER		flush(void);
+};
+
+/*
+ *  ã·ã¹ãã ã­ã°æ©è½ã®ã»ã«ã¿ã¤ã
+ */
+[singleton]
+celltype tSysLog {
+	entry	sSysLog		eSysLog;
+	call	sPutLog		cPutLog;		/* ä½ã¬ãã«åºåã¨ã®æ¥ç¶ */
+
+	attr {
+		uint_t	logBufferSize;			/* ã­ã°ãããã¡ãµã¤ãº */
+		uint_t	initLogMask = C_EXP("LOG_UPTO(LOG_DEBUG)");
+										/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+		uint_t	initLowMask = C_EXP("LOG_UPTO(LOG_EMERG)");
+									   	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+	};
+	var {
+		[size_is(logBufferSize)] SYSLOG	*logBuffer;	/* ã­ã°ãããã¡ */
+		uint_t	count = 0;				/* ã­ã°ãããã¡ä¸­ã®ã­ã°ã®æ° */
+		uint_t	head = 0;				/* å
+é ­ã®ã­ã°ã®æ ¼ç´ä½ç½® */
+		uint_t	tail = 0;				/* æ¬¡ã®ã­ã°ã®æ ¼ç´ä½ç½® */
+		uint_t	lost = 0;				/* å¤±ãããã­ã°ã®æ° */
+		uint_t	logMask = initLogMask;	/* ã­ã°ãããã¡ã«è¨é²ãã¹ãéè¦åº¦ */
+		uint_t	lowMask = initLowMask;	/* ä½ã¬ãã«åºåãã¹ãéè¦åº¦ */
+	};
+};
Index: asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.c	(revision 317)
@@ -0,0 +1,113 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°
+ *		æ©è½ãå¼ã³åºãããã®ã¢ããã¿
+ */
+
+#include "tSysLogAdapter_tecsgen.h"
+#include "syslog.h"
+
+/*
+ *  ã­ã°æ
+å ±ã®åºå
+ */
+ER
+syslog_wri_log(uint_t prio, const SYSLOG *p_syslog)
+{
+	return(cSysLog_write(prio, p_syslog));
+}
+
+/*
+ *  ã­ã°ãããã¡ããã®ã­ã°æ
+å ±ã®èª­åºã
+ */
+ER_UINT
+syslog_rea_log(SYSLOG *p_syslog)
+{
+	return(cSysLog_read(p_syslog));
+}
+
+/*
+ *  åºåãã¹ãã­ã°æ
+å ±ã®éè¦åº¦ã®è¨­å®
+ */
+ER
+syslog_msk_log(uint_t logmask, uint_t lowmask)
+{
+	return(cSysLog_mask(logmask, lowmask));
+}
+
+/*
+ *  ã­ã°ãããã¡ã®ç¶æ
+åç
+§
+ */
+ER
+syslog_ref_log(T_SYSLOG_RLOG *pk_rlog)
+{
+	return(cSysLog_refer(pk_rlog));
+}
+
+/*
+ *  ä½ã¬ãã«åºåã«ãããã¹ã¦ã®ã­ã°æ
+å ±ã®åºå
+ */
+ER
+syslog_fls_log(void)
+{
+	return(cSysLog_flush());
+}
Index: asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tSysLogAdapter.cdl	(revision 317)
@@ -0,0 +1,10 @@
+/*
+ *		Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSãã¼ã¹ã®ã·ã¹ãã ã­ã°
+ *		æ©è½ãå¼ã³åºãããã®ã¢ããã¿ç¨ã»ã«ã¿ã¤ãã®å®ç¾©
+ *
+ *  $Id$
+ */
+[singleton, active]
+celltype tSysLogAdapter {
+	call	sSysLog		cSysLog;
+};
Index: asp3_gr_sakura/trunk/syssvc/tTestService.c
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tTestService.c	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tTestService.c	(revision 317)
@@ -0,0 +1,198 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹
+ */
+
+#include "tTestService_tecsgen.h"
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include <t_stdlib.h>
+
+/*
+ *  ãã¹ããã­ã°ã©ã ã®éå§ï¼åãå£é¢æ°ï¼
+ */
+void
+eTestService_start(const char *progname)
+{
+	syslog_1(LOG_NOTICE, "Test program: %s", progname);
+	VAR_check_count = 0U;
+}
+
+/*
+ *	èªå·±è¨ºæ­é¢æ°ã®è¨­å®
+ */
+void
+eTestService_setBuiltInTest(Descriptor(sBuiltInTest) desc)
+{
+	cBuiltInTest_set_descriptor(desc);
+}
+
+/*
+ *	ãã¹ããã­ã°ã©ã ã®çµäº
+ */
+static void
+test_finish(void)
+{
+	SIL_PRE_LOC;
+
+	SIL_LOC_INT();
+	(void) cSysLog_flush();
+	(void) ext_ker();
+
+	/* ããã¸æ¥ããã¨ã¯ãªãã¯ã */
+	SIL_UNL_INT();
+}
+
+/*
+ *	ãã§ãã¯ãã¤ã³ãï¼åãå£é¢æ°ï¼
+ */
+void
+eTestService_checkPoint(uint_t count)
+{
+	bool_t	errorflag = false;
+	ER		rercd;
+	SIL_PRE_LOC;
+
+	/*
+	 *  å²è¾¼ã¿ã­ãã¯ç¶æ
+ã«
+	 */
+	SIL_LOC_INT();
+
+	/*
+	 *  ã·ã¼ã±ã³ã¹ãã§ãã¯
+	 */
+	if (++VAR_check_count == count) {
+		syslog_1(LOG_NOTICE, "Check point %d passed.", count);
+	}
+	else {
+		syslog_1(LOG_ERROR, "## Unexpected check point %d.\007", count);
+		errorflag = true;
+	}
+
+	/*
+	 *  ã«ã¼ãã«ã®å
+é¨ç¶æ
+ã®æ¤æ»
+	 */
+	if (is_cBuiltInTest_joined()) {
+		rercd = cBuiltInTest_builtInTest();
+		if (rercd < 0) {
+			syslog_2(LOG_ERROR, "## Internal inconsistency detected (%s, %d)."
+								"\007", itron_strerror(rercd), SERCD(rercd));
+			errorflag = true;
+		}
+	}
+
+	/*
+	 *  ã¨ã©ã¼ãæ¤åºãããå ´åã¯ï¼ãã¹ããã­ã°ã©ã ãçµäºããï¼
+	 */
+	if (errorflag) {
+		test_finish();
+	}
+
+	/*
+	 *  å²è¾¼ã¿ã­ãã¯ç¶æ
+ãè§£é¤
+	 */
+	SIL_UNL_INT();
+}
+
+/*
+ *	å®äºãã§ãã¯ãã¤ã³ãï¼åãå£é¢æ°ï¼
+ */
+void
+eTestService_finishPoint(uint_t count)
+{
+	if (count > 0U) {
+		eTestService_checkPoint(count);
+		syslog_0(LOG_NOTICE, "All check points passed.");
+	}
+	test_finish();
+}
+
+/*
+ *	æ¡ä»¶ãã§ãã¯ã®ã¨ã©ã¼å¦çï¼åãå£é¢æ°ï¼
+ */
+void
+eTestService_assertError(const char *expr, const char *file, int_t line)
+{
+	syslog_3(LOG_ERROR, "## Assertion `%s' failed at %s:%u.\007",
+												expr, file, line);
+	test_finish();
+}
+
+/*
+ *	ã¨ã©ã¼ã³ã¼ããã§ãã¯ã®ã¨ã©ã¼å¦çï¼åãå£é¢æ°ï¼
+ */
+void
+eTestService_serviceError(ER ercd, const char *file, int_t line)
+{
+	syslog_3(LOG_ERROR, "## Unexpected error %s detected at %s:%u.\007",
+										itron_strerror(ercd), file, line);
+	test_finish();
+}
+
+/*
+ *	ã¨ã©ã¼ã³ã¼ããã§ãã¯ã®ã¨ã©ã¼å¦çï¼åãå£é¢æ°ï¼
+ */
+ER
+eTestService_getInterruptPriorityMask(PRI *p_ipm)
+{
+	return(get_ipm(p_ipm));
+}
Index: asp3_gr_sakura/trunk/syssvc/tTestService.cdl
===================================================================
--- asp3_gr_sakura/trunk/syssvc/tTestService.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/tTestService.cdl	(revision 317)
@@ -0,0 +1,121 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹ã®ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  èªå·±è¨ºæ­ãµã¼ãã¹ã®ã·ã°ããã£
+ */
+signature sBuiltInTest {
+	ER		builtInTest(void);
+};
+
+/*
+ *  ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹ã®ã·ã°ããã£
+ *
+ *  setBuiltInTestã¯ï¼TECSã®ä¸­ã§ã¯åççµåãä½¿ã£ã¦å®ç¾ãã¹ãã§ãããï¼
+ *  Cè¨èªã®ã¢ããªã±ã¼ã·ã§ã³ããå¼ã³åºããããããããã«ï¼TECSã®ä½æ³é
+ *  åã®ã³ã¼ãã¨ãªã£ã¦ããï¼
+ *
+ *  getInterruptPriorityMaskã¯ï¼ãã®ã¾ã¾ã«ã¼ãã«ãå¼ã³åºãã ãã®é¢æ°ã§
+ *  ããï¼ä¿è­·æ©è½å¯¾å¿ã§ãªãã«ã¼ãã«ã§ã¯ãã®ã¾ã¾ã«ã¼ãã«ãå¼ã¹ã°è¯ããï¼
+ *  ä¿è­·æ©è½å¯¾å¿ã«ã¼ãã«ã§ã¯ã«ã¼ãã«ãç´æ¥å¼ã³åºããã¨ã¯éããªãã®ã§ï¼
+ *  ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹ï¼ã«ã¼ãã«ãã¡ã¤ã³ã§åä½ãããã¨ãæ³å®ï¼
+ *  ã¨ãã¦ç¨æãã¦ããï¼
+ */
+signature sTestService {
+	void	start([in, string] const char *progname);
+	void	setBuiltInTest([in] Descriptor(sBuiltInTest) desc);
+	void	checkPoint([in] uint_t count);
+	void	finishPoint([in] uint_t count);
+	void	assertError([in, string] const char *expr,
+							[in, string] const char *file, [in] int_t line);
+	void	serviceError([in] ER ercd,
+							[in, string] const char *file, [in] int_t line);
+	ER		getInterruptPriorityMask([out] PRI *p_ipm);
+};
+
+/*
+ *  ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹ã®ã»ã«ã¿ã¤ã
+ */
+[singleton, active]
+celltype tTestService {
+	entry						sTestService	eTestService;
+	[dynamic, optional] call	sBuiltInTest	cBuiltInTest;
+	call						sSysLog			cSysLog;
+
+	var {
+		uint_t		check_count;	/* æå¾ã«ééãããã§ãã¯ãã¤ã³ã */
+	};
+};
+
+/*
+ *  èªå·±è¨ºæ­ãµã¼ãã¹ã®ãã£ã¹ã¯ãªãã¿ãåå¾ããã·ã°ããã£
+ */
+signature sGetBuiltInTestDescriptor {
+	ER		getDescriptor([out] Descriptor(sBuiltInTest) *p_desc,
+														[in] int_t i);
+};
+
+/*
+ *  èªå·±è¨ºæ­ãµã¼ãã¹ã®ãã£ã¹ã¯ãªãã¿ãåå¾ããã»ã«ã¿ã¤ã
+ */
+[singleton, active]
+celltype tBuiltInTestAdaptor {
+	[ref_desc] call	sBuiltInTest				cBuiltInTest[];
+	entry			sGetBuiltInTestDescriptor	eGetBuiltInTestDescriptor;
+};
Index: asp3_gr_sakura/trunk/syssvc/test_svc.h
===================================================================
--- asp3_gr_sakura/trunk/syssvc/test_svc.h	(revision 317)
+++ asp3_gr_sakura/trunk/syssvc/test_svc.h	(revision 317)
@@ -0,0 +1,206 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/* 
+ *		ãã¹ããã­ã°ã©ã ç¨ãµã¼ãã¹
+ */
+
+#ifndef TOPPERS_TEST_SVC_H
+#define TOPPERS_TEST_SVC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <kernel.h>
+#include "target_test.h"
+
+/*
+ *  TECSã§è¨è¿°ããããã¹ããã­ã°ã©ã ç¨ã®ãµã¼ãã¹ãç´æ¥å¼ã³åºãããã®å®ç¾©
+ *
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSã§è¨è¿°ããããã¹ããã­ã°
+ *  ã©ã ç¨ã®ãµã¼ãã¹ãå¼ã³åºãããã«ã¯ï¼ã¢ããã¿ãç¨ããã®ãæ­£å½ãªæ¹æ³
+ *  ã§ãããï¼ãã¹ããã­ã°ã©ã ç¨ã®ãµã¼ãã¹ãã·ã³ã°ã«ãã³ã§ãããã¨ãå©
+ *  ç¨ãã¦ç´æ¥å¼ã³åºãï¼
+ */
+extern void	tTestService_eTestService_start(const char *progname);
+extern void	tTestService_eTestService_setBuiltInTest(void *desc);
+extern void	tTestService_eTestService_checkPoint(uint_t count);
+extern void	tTestService_eTestService_finishPoint(uint_t count);
+extern void	tTestService_eTestService_assertError(const char *expr,
+											const char *file, int_t line);
+extern void	tTestService_eTestService_serviceError(ER ercd,
+											const char *file, int_t line);
+extern ER	tTestService_eTestService_getInterruptPriorityMask(PRI *p_ipm);
+
+/*
+ *  ãã¹ããã­ã°ã©ã ã®éå§
+ */
+Inline void
+test_start(const char *progname)
+{
+	tTestService_eTestService_start(progname);
+}
+
+/*
+ *	èªå·±è¨ºæ­é¢æ°ã®è¨­å®
+ */
+Inline void
+set_bit_service(void *bit_service)
+{
+	tTestService_eTestService_setBuiltInTest(bit_service);
+}
+
+/*
+ *	ãã§ãã¯ãã¤ã³ã
+ */
+Inline void
+check_point(uint_t count)
+{
+	tTestService_eTestService_checkPoint(count);
+}
+
+/*
+ *	å®äºãã§ãã¯ãã¤ã³ã
+ */
+Inline void
+check_finish(uint_t count)
+{
+	tTestService_eTestService_finishPoint(count);
+}
+
+/*
+ *	æ¡ä»¶ãã§ãã¯
+ */
+Inline void
+check_assert_error(const char *expr, const char *file, int_t line)
+{
+	tTestService_eTestService_assertError(expr, file, line);
+}
+
+#define check_assert(exp) \
+	((void)(!(exp) ? (check_assert_error(#exp, __FILE__, __LINE__), 0) : 0))
+
+/*
+ *	ã¨ã©ã¼ã³ã¼ããã§ãã¯
+ */
+Inline void
+check_ercd_error(ER ercd, const char *file, int_t line)
+{
+	tTestService_eTestService_serviceError(ercd, file, line);
+}
+
+#define check_ercd(ercd, expected_ercd) \
+	((void)((ercd) != (expected_ercd) ? \
+					(check_ercd_error(ercd, __FILE__, __LINE__), 0) : 0))
+
+/*
+ *	ã·ã¹ãã ç¶æ
+ã®ãã§ãã¯
+ */
+#define check_state(ctx, loc, dsp, dpn, ter) do {	\
+	check_assert(sns_ctx() == ctx);					\
+	check_assert(sns_loc() == loc);					\
+	check_assert(sns_dsp() == dsp);					\
+	check_assert(sns_dpn() == dpn);					\
+	check_assert(sns_ter() == ter);					\
+} while (false);
+
+/*
+ *	å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®ãã§ãã¯
+ */
+#define check_ipm(ipm) do {												\
+	PRI		intpri;														\
+	ER		ercd;														\
+																		\
+	ercd = tTestService_eTestService_getInterruptPriorityMask(&intpri);	\
+	check_ercd(ercd, E_OK);												\
+	check_assert(intpri == ipm);										\
+} while (false);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ *  TECSã§è¨è¿°ãããèªå·±è¨ºæ­ãµã¼ãã¹ãç´æ¥å¼ã³åºãããã®å®ç¾©
+ *
+ *  Cè¨èªã§è¨è¿°ãããã¢ããªã±ã¼ã·ã§ã³ããï¼TECSã§è¨è¿°ãããèªå·±è¨ºæ­ãµã¼
+ *  ãã¹ãå¼ã³åºãããã«ã¯ï¼ã¢ããã¿ãç¨ããã®ãæ­£å½ãªæ¹æ³ã§ãããï¼èª
+ *  å·±è¨ºæ­ãµã¼ãã¹ãã·ã³ã°ã«ãã³ã§ãããã¨ãå©ç¨ãã¦ç´æ¥å¼ã³åºãï¼
+ */
+extern ER	tBuiltInTestAdaptor_eGetBuiltInTestDescriptor_getDescriptor
+												(void **p_desc, int_t i);
+
+Inline void *
+get_bit_kernel(void)
+{
+	void	*desc;
+
+	tBuiltInTestAdaptor_eGetBuiltInTestDescriptor_getDescriptor(&desc, 0);
+	return(desc);
+}
+
+Inline void *
+get_bit_mutex(void)
+{
+	void	*desc;
+
+	tBuiltInTestAdaptor_eGetBuiltInTestDescriptor_getDescriptor(&desc, 1);
+	return(desc);
+}
+
+#endif /* TOPPERS_TEST_SVC_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/E_PACKAGE
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/E_PACKAGE	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/E_PACKAGE	(revision 317)
@@ -0,0 +1,7 @@
+E_PACKAGE asp_gr_sakura_gcc
+VERSION %date
+
+INCLUDE ../../MANIFEST
+INCLUDE ../../arch/rx630_gcc/MANIFEST
+#INCLUDE ../../arch/gcc/MANIFEST
+INCLUDE ../../cfg/MANIFEST
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/MANIFEST
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/MANIFEST	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/MANIFEST	(revision 317)
@@ -0,0 +1,34 @@
+PACKAGE asp_target_rsk_rx_hew
+
+E_PACKAGE
+MANIFEST
+asm_config.cfg
+gr_sakura.h
+sectrx.inc
+target.tf
+target_asm_config.tf
+target_ccrx_echonet.tf
+target_cfg1_out.h
+target_check.tf
+target_kernel_impl.c
+target_kernel_impl.h
+target_sym.def
+target_kernel.h
+target_offset.tf
+target_rename.def
+target_rename.h
+target_serial.c
+target_serial.cfg
+target_serial.h
+target_sil.h
+target_stddef.h
+target_support.src
+target_syssvc.h
+target_test.h
+target_timer.c
+target_timer.cfg
+target_timer.h
+target_unrename.h
+tinet_target_config.c
+tinet_target_config.h
+tinet_target_defs.h
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.target
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.target	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.target	(revision 317)
@@ -0,0 +1,84 @@
+#
+#		Makefileã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-SAKURAç¨ï¼
+#
+
+#
+#  ãã¼ãåï¼ãã­ã»ããµåï¼éçºç°å¢åã®å®ç¾©
+#
+BOARD = gr_sakura
+PRC = rx630
+TOOL = gcc
+
+#
+#  ã³ã³ãã¤ã«ãªãã·ã§ã³
+#
+INCLUDES := $(INCLUDES) -I$(TARGETDIR) -I$(SRCDIR)/pdic
+
+#
+#  ã«ã¼ãã«ã«é¢ããå®ç¾©
+#
+KERNEL_DIRS := $(KERNEL_DIRS) $(TARGETDIR)
+KERNEL_ASMOBJS := $(KERNEL_ASMOBJS)
+KERNEL_COBJS := $(KERNEL_COBJS) target_kernel_impl.o target_support.o target_timer.o
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã«é¢ããå®ç¾©
+#
+SYSSVC_DIRS := $(SYSSVC_DIRS)
+SYSSVC_COBJS := $(SYSSVC_COBJS)
+
+#
+#  ã³ã³ãã£ã®ã¥ã¬ã¼ã¿é¢ä¿ã®å¤æ°ã®å®ç¾©
+#
+CFG_TABS := $(CFG_TABS) --symval-table $(TARGETDIR)/target_sym.def
+
+#
+#  ãã¬ã¼ã¹ã­ã°è¨é²ã®ãµã³ãã«ã³ã¼ãã«é¢ããå®ç¾©
+#
+ifeq ($(ENABLE_TRACE),true)
+	COPTS := $(COPTS) -DTOPPERS_ENABLE_TRACE
+	SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/arch/tracelog
+endif
+
+#
+#  åã»ã°ã¡ã³ãã®éå§ã¢ãã¬ã¹ã®å®ç¾©
+#
+#TEXT_START_ADDRESS = 00010000
+#DATA_START_ADDRESS = 00100000
+
+#
+#  ãªã³ã«ã¹ã¯ãªããã®å®ç¾©
+#
+LDSCRIPT = $(TARGETDIR)/gr_sakura.ld
+
+#
+#  ã¹ã¿ã¼ãã¢ããã¢ã¸ã¥ã¼ã«ã«é¢ããå®ç¾©
+#
+#  m68kelf.ldã«ãSTARTUP(start.o)ããè¨è¿°ããããï¼ã¹ã¿ã¼ãã¢ããã¢ã¸ã¥ã¼
+#  ã«ã®ååãHIDDEN_OBJSã«å®ç¾©ããï¼ã¾ãï¼LDFLAGSã«-nostdlibãè¿½å ãã¦ããï¼
+#
+HIDDEN_OBJS = start.o
+
+$(HIDDEN_OBJS): %.o: %.S
+	$(CC) -c $(CFLAGS) $(KERNEL_CFLAGS) $<
+
+$(HIDDEN_OBJS:.o=.d): %.d: %.S
+	@$(PERL) $(SRCDIR)/utils/makedep -C $(CC) $(MAKEDEP_OPTS) \
+		-O "$(CFLAGS) $(KERNEL_CFLAGS)" $< >> Makefile.depend
+
+LDFLAGS := -nostdlib $(LDFLAGS)
+CFG1_OUT_LDFLAGS := -nostdlib $(CFG1_OUT_LDFLAGS)
+LIBS := $(LIBS) -lgcc
+CFG2_OUT_SRCS := $(CFG2_OUT_SRCS) kernel_cfg_asm.S
+
+#
+#  ä¾å­é¢ä¿ã®å®ç¾©
+#
+cfg1_out.c: $(TARGETDIR)/target_sym.def
+kernel_cfg.timestamp: $(TARGETDIR)/target_kernel.trb
+$(OBJFILE): $(TARGETDIR)/target_check.trb
+
+#
+#  ãã­ã»ããµä¾å­é¨ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/arch/$(PRC)_$(TOOL)/Makefile.prc
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.tinet
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.tinet	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/Makefile.tinet	(revision 317)
@@ -0,0 +1,53 @@
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#   Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+#   ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+#   è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+#   ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+#   å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+#   å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+#   æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+#  
+#   @(#) $Id: $
+#
+
+#
+#  Makefile.tinet ã®ã·ã¹ãã ä¾å­é¨åï¼GR-SAKURAç¨ï¼
+
+ifeq ($(NET_IF),ether)
+
+	TINET_COBJS := $(TINET_COBJS) tinet_target_config.o
+
+endif
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.h	(revision 317)
@@ -0,0 +1,87 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* GR-SAKURAç¨ããããã¡ã« */
+
+#ifndef	TOPPERS_GRSAKURA_H
+#define	TOPPERS_GRSAKURA_H
+
+
+/*
+ *  MCUä¾å­æ
+å ±ã®èª­ã¿è¾¼ã¿
+ */
+#include "rx630.h"
+
+/*
+ *  ã¯ã­ãã¯è¨­å®
+ */
+
+/*
+ *  ã·ã¹ãã ã¯ã­ãã¯ICLK(kHz)
+ *
+ *  CPUï¼DTCï¼DMACAï¼ETHERCï¼EDMACï¼ROMï¼RAMç¨
+ *  
+ */
+#define FREQ_ICLK  (96000U)
+
+/*
+ *  ã¯ã­ãã¯PCLK(kHz)
+ *
+ *  ã¿ã¤ãï¼ã·ãªã¢ã«ãªã©å¨è¾ºã¢ã¸ã¥ã¼ã«ç¨
+ */
+#define FREQ_PCLK  (48000U)
+
+#endif	/* TOPPERS_GRSAKURA_H */
+
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.ld
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.ld	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/gr_sakura.ld	(revision 317)
@@ -0,0 +1,135 @@
+MEMORY
+{
+	RAM : ORIGIN = 0x0, LENGTH = 131072
+	ROM : ORIGIN = 0xFFF00000, LENGTH = 1048576
+}
+
+SECTIONS
+{
+	.fvectors 0xFFFFFF80 : AT (0xFFFFFF80)
+	{
+		KEEP(*(.fvectors))
+	} > ROM
+	.text 0xFFF00000 : AT (0xFFF00000)
+	{
+		*(.text)
+		*(.text.*)
+		*(P)
+		etext = .;
+	} > ROM
+	.rvectors : 
+	{
+		_rvectors_start = .;
+		KEEP(*(.rvectors))
+		_rvectors_end = .;
+	} > ROM
+	.init : 
+	{
+		*(.init)
+		__preinit_array_start = .;
+		*(.preinit_array)
+		__preinit_array_end = .;
+		__init_array_start = (. + 3) & ~ 3;
+		*(.init_array)
+		*(SORT(.init_array.*))
+		__init_array_end = .;
+		__fini_array_start = .;
+		*(.fini_array)
+		*(SORT(.fini_array.*))
+		__fini_array_end = .;
+	} > ROM
+	.fini : 
+	{
+		*(.fini)
+	} > ROM
+	.got : 
+	{
+		*(.got)
+		*(.got.plt)
+	} > ROM
+	.rodata : 
+	{
+		_brodata = .;
+		*(.rodata)
+		*(.rodata.*)
+		*(C_1)
+		*(C_2)
+		*(C)
+		_erodata = .;
+	} > ROM
+	.eh_frame_hdr : 
+	{
+		*(.eh_frame_hdr)
+	} > ROM
+	.eh_frame : 
+	{
+		*(.eh_frame)
+	} > ROM
+	.jcr : 
+	{
+		*(.jcr)
+	} > ROM
+	.tors : 
+	{
+		__CTOR_LIST__ = .;
+		. = ALIGN(2);
+		___ctors = .;
+		*(.ctors)
+		___ctors_end = .;
+		__CTOR_END__ = .;
+		__DTOR_LIST__ = .;
+		___dtors = .;
+		*(.dtors)
+		___dtors_end = .;
+		__DTOR_END__ = .;
+		. = ALIGN(2);
+		_mdata = .;
+	} > ROM
+	.istack 0x1FC00 (NOLOAD) : AT (0x1FC00)
+	{
+		*(SI)
+		_istack = .;
+	} > RAM
+	.ustack 0x1C000 (NOLOAD) : AT (0x1C000)
+	{
+		_heap_stop = .;
+		*(SU)
+		_ustack = .;
+	} > RAM
+	.eth_memory 0x400 (NOLOAD) : AT (0x400)
+	{
+		. = ALIGN(32);
+		KEEP(*(ETH_MEMORY))
+	} > RAM
+	.gcc_exc :
+	{
+		*(.gcc_exc)
+	} > RAM
+	.data : AT (_mdata)
+	{
+		_data = .;
+		*(.data)
+		*(.data.*)
+		. = ALIGN(4);
+		*(D)
+		*(D_1)
+		. = ALIGN(2);
+		*(D_2)
+		_edata = .;
+	} > RAM
+	.bss : 
+	{
+		_bss = .;
+		*(.bss)
+		*(.bss.**)
+		*(COMMON)
+		. = ALIGN(4);
+		*(B)
+		*(B_1)
+		. = ALIGN(2);
+		*(B_2)
+		_ebss = .;
+		. = ALIGN(4);
+		_end = .;
+	} > RAM
+}
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/sectrx.inc
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/sectrx.inc	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/sectrx.inc	(revision 317)
@@ -0,0 +1,145 @@
+;*
+;*  TOPPERS/ASP Kernel
+;*      Toyohashi Open Platform for Embedded Real-Time Systems/
+;*      Advanced Standard Profile Kernel
+;* 
+;*  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+;* 
+;*  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+;*  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+;*  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+;*  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+;*      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+;*      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+;*  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+;*      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+;*      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+;*      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+;*      ã¨ï¼
+;*    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+;*        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+;*    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+;*        å ±åãããã¨ï¼
+;*  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+;*      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+;*      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+;*      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+;*      å
+è²¬ãããã¨ï¼
+;* 
+;*  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+;*  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+;*  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+;*  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+;*  ã®è²¬ä»»ãè² ããªãï¼
+;* 
+;*  @(#) $Id$
+;* 
+
+;
+;  ã¿ã¼ã²ããã·ã¹ãã ä¾å­ã»ã¯ã·ã§ã³å®ç¾©ãã¡ã¤ã«(ã¹ã¿ã¼ã¿ã¼ã­ããç¨)
+;
+
+;
+;  ã»ã¯ã·ã§ã³ã®å®ç¾©
+;
+;  ã»ã¯ã·ã§ã³ã®ã¢ãã¬ã¹å®ç¾©ã¯HEWä¸ã®æé©åãªã³ã«ã®
+;  ãªãã·ã§ã³ã«ã¦å®æ½ãã.
+;
+
+	;
+	;  åæå¤æããã¼ã¿é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	.section	D, ROMDATA
+	.section	D_2, ROMDATA, ALIGN = 2
+	.section	D_1, ROMDATA
+
+
+	;
+	;  åæå¤ç¡ããã¼ã¿é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	.section	B, DATA, ALIGN = 4
+	.section	B_2, DATA, ALIGN = 2
+	.section	B_1, DATA
+	.section	W, ROMDATA,ALIGN = 4
+	.section	W_1, ROMDATA
+	.section	W_2, ROMDATA, ALIGN = 2
+
+
+	;
+	;  ã«ã¼ãã«ã¹ã¿ãã¯é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00000000h - 00020000h
+	;
+	;  ä»¥ä¸.blkbå½ä»¤ã§ç¢ºä¿ãã¦ããã«ã¼ãã«ã¹ã¿ãã¯é åã®ãµã¤ãºã
+	;  å¤æ´ããå ´åã¯, target_kernel_impl.hã®DEFAULT_ISTKSZã®å¤ã, åã
+	;  å¤ã«å¤æ´ãããã¨.
+	;
+;	.section	SI, DATA, ALIGN = 4
+;	.global _DEFAULT_ISTACK
+;_DEFAULT_ISTACK:
+;	.blkb		DEFAULT_ISTKSZ
+;	.global DEFAULT_ISTACK_TOP
+;DEFAULT_ISTACK_TOP:
+
+	;
+	;  å®æ°é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	C, ROMDATA, ALIGN = 4
+	.section	C_2, ROMDATA, ALIGN = 2
+	.section	C_1, ROMDATA
+
+	;
+	;  åæå¤æããã¼ã¿é åã®åæå¤
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	R, DATA, ALIGN = 4
+	.section	R_2, DATA, ALIGN = 2
+	.section	R_1, DATA
+
+	;
+	;  å¯å¤ãã¯ã¿ãã¼ãã«é åã®ã»ã¯ã·ã§ã³
+	;
+	;  00100000h - 00107FFFh
+	;
+	.section	.fvectors, ROMDATA, ALIGN = 4
+	.global VVECTOR_TOP
+VVECTOR_TOP:
+
+	;
+	;  ãã­ã°ã©ã é åã®ã»ã¯ã·ã§ã³
+	;
+	;  FFE80000h - FFFFFF7Fh
+	;
+	.section	P, CODE
+
+	;
+	;  åºå®ãã¯ã¿ãã¼ãã«é åã®ã»ã¯ã·ã§ã³
+	;
+	;  FFFFFF80h - FFFFFFFFh
+	;
+	.section	FVECT, ROMDATA, ALIGN = 4
+
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.c
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.c	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.c	(revision 317)
@@ -0,0 +1,86 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2007-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºå
+ */
+
+#include "tPutLogGRSakura_tecsgen.h"
+
+/*
+ *  ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºåã®ããã®åæå
+ *
+ *  åæåã«ã¼ãã³ãå¼ã³åºãããåã«åæåããããã«ï¼ã«ã¼ãã«ã®ã¿ã¼ã²ã
+ *  ãä¾å­é¨ããç´æ¥å¼ã³åºãããã®é¢æ°ï¼
+ */
+void
+tPutLogGRSakura_initialize(void)
+{
+	cSIOPort_open();
+}
+
+/*
+ *  ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºåã®ããã®æå­åºåï¼åãå£é¢æ°ï¼
+ *
+ *  SIOãã¼ãã«æå­ãéä¿¡ã§ããã¾ã§ãã¼ãªã³ã°ããï¼
+ */
+void
+ePutLog_putChar(char c)
+{
+	if(c == '\n'){
+		while(!cSIOPort_putChar('\r'));
+	}
+	while(!cSIOPort_putChar(c));
+}
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.cdl
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tPutLogGRSakura.cdl	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºåã®ã³ã³ãã¼ãã³ãè¨è¿°
+ */
+
+/*
+ *  ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºåã®ã»ã«ã¿ã¤ã
+ */
+[singleton]
+celltype tPutLogGRSakura {
+	entry	sPutLog		ePutLog;
+	call	sSIOPort	cSIOPort;
+};
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakura.cdl
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakura.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakura.cdl	(revision 317)
@@ -0,0 +1,246 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-PEACHç¨ï¼
+ *		ã®ã³ã³ãã¼ãã³ãè¨è¿°
+ */
+
+/*
+ *  GR-PEACHã¨RZ/A1ã«é¢ããå®ç¾©
+ */
+import_C("gr_sakura.h");
+/*import_C("rza1.h");*/
+import_C("rx630.h");
+
+/*
+ *  FIFOå
+èµã·ãªã¢ã«ã³ãã¥ãã±ã¼ã·ã§ã³ã¤ã³ã¿ãã§ã¼ã¹ç¨ ç°¡æSIOãã©ã¤ã
+ */
+import("tSCIF.cdl");
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ã®æ¬ä½ï¼ã·ãªã¢ã«ã¤
+ *  ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨SIOãã©ã¤ããæ¥ç¶ããé¨åï¼ã®ã»ã«ã¿ã¤ã
+ */
+celltype tSIOPortGRSakuraMain {
+	/*
+	 *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå
+	 */
+	[inline] entry		sSIOPort	eSIOPort;
+	[optional] call		siSIOCBR	ciSIOCBR;
+
+	/*
+	 *  SIOãã©ã¤ãã¨ã®çµå
+	 */
+	call			sSIOPort	cSIOPort;
+	[inline] entry	siSIOCBR	eiSIOCBR;
+
+	/*
+	 *  å²è¾¼ã¿è¦æ±ã©ã¤ã³æä½ã®ããã®çµå
+	 */
+	call	sInterruptRequest	cRxInterruptRequest;
+	call	sInterruptRequest	cTxInterruptRequest;
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ï¼è¤åã³ã³ãã¼ãã³
+ *  ãï¼ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+composite tSIOPortGRSakura {
+	/*
+	 *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã¨ã®çµå
+	 */
+	entry				sSIOPort	eSIOPort;
+	[optional] call		siSIOCBR	ciSIOCBR;
+
+	/*
+	 *  å±æ§ã®å®ç¾©
+	 */
+	attr {
+		uintptr_t	baseAddress;				/* ãã¼ã¹ã¢ãã¬ã¹ */
+		INTNO		rxInterruptNumber;			/* åä¿¡å²è¾¼ã¿çªå· */
+		INTNO		txInterruptNumber;			/* éä¿¡å²è¾¼ã¿çªå· */
+		PRI			isrPriority = 1;			/* ISRåªå
+åº¦ */
+		PRI			interruptPriority = -4;		/* å²è¾¼ã¿åªå
+åº¦ */
+		uint32_t	baudRate = 115200;			/* ãã¼ã¬ã¼ãã®è¨­å®å¤ */
+	};
+
+	/*
+	 *  SIOãã©ã¤ã
+	 */
+	cell tSCIF SCIF {
+		baseAddress = composite.baseAddress;
+		baudRate    = composite.baudRate;
+		ciSIOCBR    = SIOPortMain.eiSIOCBR;
+	};
+
+	/*
+	 *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ã®æ¬ä½
+	 */
+	cell tSIOPortGRSakuraMain SIOPortMain {
+		ciSIOCBR            => composite.ciSIOCBR;
+		cSIOPort            = SCIF.eSIOPort;
+		cRxInterruptRequest = RxInterruptRequest.eInterruptRequest;
+		cTxInterruptRequest = TxInterruptRequest.eInterruptRequest;
+	};
+	composite.eSIOPort => SIOPortMain.eSIOPort;
+
+	/*
+	 *  SIOã®åä¿¡å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã¨å²è¾¼ã¿è¦æ±ã©ã¤ã³
+	 */
+	cell tISR RxISRInstance {
+		interruptNumber = composite.rxInterruptNumber;
+		isrPriority     = composite.isrPriority;
+		ciISRBody       = SCIF.eiRxISR;
+	};
+	cell tInterruptRequest RxInterruptRequest {
+		interruptNumber   = composite.rxInterruptNumber;
+		interruptPriority = composite.interruptPriority;
+	};
+
+	/*
+	 *  SIOã®åä¿¡å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã¨å²è¾¼ã¿è¦æ±ã©ã¤ã³
+	 */
+	cell tISR TxISRInstance {
+		interruptNumber = composite.txInterruptNumber;
+		isrPriority     = composite.isrPriority;
+		ciISRBody       = SCIF.eiTxISR;
+	};
+	cell tInterruptRequest TxInterruptRequest {
+		interruptNumber   = composite.txInterruptNumber;
+		interruptPriority = composite.interruptPriority;
+	};
+};
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ã®ãã­ãã¿ã¤ã
+ *
+ *  ãµã³ãã«ãã­ã°ã©ã ãä½¿ããã¼ããï¼SIOPortTarget1ã«åºå®ããã¦ããã
+ *  ãï¼ãã¼ã1ã¨ãã¼ã3ãå
+¥ãæãã¦ããï¼å
+·ä½çã«ã¯ï¼SIOPortTarget1ã¯
+ *  SCIFã®ãã£ãã«2ï¼ãã£ãã«çªå·ã¯0ããå§ã¾ãã®ã§ï¼ãã¼ã3ã®ãã¨ï¼ã«ï¼
+ *  SIOPortTarget3ã¯SCIFã®ãã£ãã«0ã«ã¤ãªãã£ã¦ããï¼
+ */
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget1 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI0_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI0_RXI");
+	txInterruptNumber = C_EXP("INT_SCI0_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget2 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI1_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI1_RXI");
+	txInterruptNumber = C_EXP("INT_SCI1_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget3 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI2_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI2_RXI");
+	txInterruptNumber = C_EXP("INT_SCI2_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget4 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI3_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI3_RXI");
+	txInterruptNumber = C_EXP("INT_SCI3_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget5 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI4_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI4_RXI");
+	txInterruptNumber = C_EXP("INT_SCI4_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget6 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI5_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI5_RXI");
+	txInterruptNumber = C_EXP("INT_SCI5_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget7 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = C_EXP("SCI6_BASE");
+	rxInterruptNumber = C_EXP("INT_SCI6_RXI");
+	txInterruptNumber = C_EXP("INT_SCI6_TEI");
+};
+
+[prototype]
+cell tSIOPortGRSakura SIOPortTarget8 {
+	/* å±æ§ã®è¨­å® */
+	baseAddress       = NULL;
+	rxInterruptNumber = NULL;
+	txInterruptNumber = NULL;
+};
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakuraMain_inline.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakuraMain_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tSIOPortGRSakuraMain_inline.h	(revision 317)
@@ -0,0 +1,170 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-PEACHç¨ï¼
+ */
+
+/*
+ *  SIOãã¼ãã®ãªã¼ãã³
+ */
+Inline void
+eSIOPort_open(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	/*
+	 *  ããã¤ã¹ä¾å­ã®ãªã¼ãã³å¦ç
+	 */
+	cSIOPort_open();
+
+	/*
+	 *  SIOã®å²è¾¼ã¿ãã¹ã¯ãè§£é¤ããï¼
+	 */
+	cRxInterruptRequest_enable();
+	cTxInterruptRequest_enable();
+}
+
+/*
+ *  SIOãã¼ãã®ã¯ã­ã¼ãº
+ */
+Inline void
+eSIOPort_close(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	/*
+	 *  ããã¤ã¹ä¾å­ã®ã¯ã­ã¼ãºå¦ç
+	 */
+	cSIOPort_close();
+
+	/*
+	 *  SIOã®å²è¾¼ã¿ããã¹ã¯ããï¼
+	 */
+	cRxInterruptRequest_disable();
+	cTxInterruptRequest_disable();
+}
+
+/*
+ *  SIOãã¼ãã¸ã®æå­éä¿¡
+ */
+Inline bool_t
+eSIOPort_putChar(CELLIDX idx, char c)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	return(cSIOPort_putChar(c));
+}
+
+/*
+ *  SIOãã¼ãããã®æå­åä¿¡
+ */
+Inline int_t
+eSIOPort_getChar(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	return(cSIOPort_getChar());
+}
+
+/*
+ *  SIOãã¼ãããã®ã³ã¼ã«ããã¯ã®è¨±å¯
+ */
+Inline void
+eSIOPort_enableCBR(CELLIDX idx, uint_t cbrtn)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	cSIOPort_enableCBR(cbrtn);
+}
+
+/*
+ *  SIOãã¼ãããã®ã³ã¼ã«ããã¯ã®ç¦æ­¢
+ */
+Inline void
+eSIOPort_disableCBR(CELLIDX idx, uint_t cbrtn)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	cSIOPort_disableCBR(cbrtn);
+}
+
+/*
+ *  SIOãã¼ãããã®éä¿¡å¯è½ã³ã¼ã«ããã¯
+ */
+Inline void
+eiSIOCBR_readySend(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+
+	if (is_ciSIOCBR_joined()) {
+		ciSIOCBR_readySend();
+	}
+}
+
+/*
+ *  SIOãã¼ãããã®åä¿¡éç¥ã³ã¼ã«ããã¯
+ */
+Inline void
+eiSIOCBR_readyReceive(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	
+	if (is_ciSIOCBR_joined()) {
+		ciSIOCBR_readyReceive();
+	}
+}
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target.cdl
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target.cdl	(revision 317)
@@ -0,0 +1,92 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *  ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãºã®ããã©ã«ã
+ */
+const size_t DefaultTaskStackSize = 4096;		/* ã¹ã¿ãã¯ãµã¤ãºï¼4KBï¼*/
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãºã®å®ç¾©
+ */
+const size_t LogTaskStackSize = DefaultTaskStackSize;
+
+/*
+ *  ã«ã¼ãã«èµ·åã¡ãã»ã¼ã¸ã«é¢ããå®ç¾©
+ */
+const char *const BannerTargetName = "GR-SAKURA";		/* ã¿ã¼ã²ããå */
+const char *const BannerCopyrightNotice = "";			/* èä½æ¨©è¡¨ç¤º */
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®ã»ã«ã¿ã¤ãã®å®ç¾©
+ */
+import("tPutLogGRSakura.cdl");
+import("tSIOPortGRSakura.cdl");
+
+/*
+ *  ã·ãªã¢ã«ã¤ã³ã¿ãã§ã¼ã¹ãã©ã¤ãã®ã¿ã¼ã²ããä¾å­é¨ã®çµã¿ä¸ãè¨è¿°
+ */
+cell tSIOPortGRSakura SIOPortTarget1 {
+};
+
+/*
+ *  ä½ã¬ãã«åºåã®çµã¿ä¸ãè¨è¿°
+ */
+cell tPutLogGRSakura PutLogTarget {
+	/* SIOãã©ã¤ãã¨ã®çµå */
+	cSIOPort = SIOPortTarget1.eSIOPort;
+};
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_cfg1_out.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_cfg1_out.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_cfg1_out.h	(revision 317)
@@ -0,0 +1,7 @@
+/*
+ *		cfg1_out.cã®ãªã³ã¯ã«å¿
+è¦ãªã¹ã¿ãã®å®ç¾©
+ */
+
+#include "prc_cfg1_out.h"
+#include "sil.h"
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_check.trb
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_check.trb	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_check.trb	(revision 317)
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+#
+#		ãã¹3ã®çæã¹ã¯ãªããã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-PEACHç¨ï¼
+#
+
+#
+#  çæã¹ã¯ãªããã®ãã­ã»ããµä¾å­é¨
+#
+IncludeTrb("prc_check.trb")
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.cfg
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.cfg	(revision 317)
@@ -0,0 +1,7 @@
+/*
+ *		ã«ã¼ãã«å®è£
+ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *  $Id$
+ */
+INCLUDE("target_timer.cfg")
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.h	(revision 317)
@@ -0,0 +1,94 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ã«ã¼ãã«ã®ã¿ã¼ã²ããä¾å­å®ç¾©ï¼GR-SAKURAç¨ï¼
+ */
+
+/*
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼kernel.hã§ã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡
+ *  ã¤ã«ããç´æ¥ã¤ã³ã¯ã«ã¼ããããã¨ã¯ãªãï¼ãã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ã
+ *  ããåã«ï¼t_stddef.hãã¤ã³ã¯ã«ã¼ããããã®ã§ï¼ãããã«ä¾å­ãã¦ãã
+ *  ãï¼
+ */
+
+#ifndef TOPPERS_TARGET_KERNEL_H
+#define TOPPERS_TARGET_KERNEL_H
+
+
+/*
+ *  ãã­ã»ããµã§å
+±éãªå®ç¾©
+ */
+#include "prc_kernel.h"
+
+/*
+ *  ãµãã¼ãããæ©è½ã®å®ç¾©
+ */
+#define	TOPPERS_TARGET_SUPPORT_GET_UTM		/* get_utmããµãã¼ããã */
+#define TOPPERS_TARGET_SUPPORT_OVRHDR		/* ãªã¼ãã©ã³ãã³ãã© */
+
+/*
+ *  ã¿ã¤ã ãã£ãã¯ã®å®ç¾©
+ */
+#define	TIC_NUME		( 1U )		/* ã¿ã¤ã ãã£ãã¯ã®å¨æã®åå­ */
+#define	TIC_DENO		( 1U )		/* ã¿ã¤ã ãã£ãã¯ã®å¨æã®åæ¯ */
+
+#endif /* TOPPERS_TARGET_KERNEL_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.trb
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.trb	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel.trb	(revision 317)
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+#
+#		ãã¹2ã®çæã¹ã¯ãªããã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-PEACHç¨ï¼
+#
+
+#
+#  çæã¹ã¯ãªããã®ãã­ã»ããµä¾å­é¨
+#
+IncludeTrb("prc_kernel.trb")
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.c
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.c	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.c	(revision 317)
@@ -0,0 +1,170 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2007 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *	ã¿ã¼ã²ããã·ã¹ãã ä¾å­ã¢ã¸ã¥ã¼ã«ï¼GR-SAKURAç¨ï¼
+ */
+
+#include "kernel_impl.h"
+#include <sil.h>
+#include "gr_sakura.h"
+#include "syssvc/serial.h"
+
+/*
+ *  ã¿ã¼ã²ããã·ã¹ãã ä¾å­ åæåã«ã¼ãã³
+ */
+void
+target_initialize( void )
+{
+	/*
+	 *  ãã­ã»ããµä¾å­ã®åæå
+	 */
+	prc_initialize();
+
+	/* IOãã¼ãåæå */
+	/* P25ãåºåãã¼ãã«ãã */
+	sil_wrb_mem(PORT2_PDR_ADDR, 
+		sil_reb_mem(PORT2_PDR_ADDR) | PORT_PDR_B5_BIT);
+	/* PA0, PA1, PA2, PA6ãåºåãã¼ãã«ãã */
+	sil_wrb_mem(PORTA_PDR_ADDR,
+		sil_reb_mem(PORTA_PDR_ADDR) | PORT_PDR_B0_BIT | PORT_PDR_B1_BIT | PORT_PDR_B2_BIT | PORT_PDR_B6_BIT);
+	/* PA7ãå
+¥åãã¼ãã«ãã */
+	sil_wrb_mem(PORTA_PDR_ADDR,
+		sil_reb_mem(PORTA_PDR_ADDR) & ~PORT_PDR_B7_BIT);
+
+	/*
+	 *  ã·ãªã¢ã«ãã¼ãã®è¨­å®
+	 */
+	serial_opn_por(1);
+
+	/* ãã¼ãP20ãTxD0, ãã¼ãP21ãRxD0ã« */
+	sil_wrb_mem(PORT2_PMR_ADDR, 0x03);
+
+	/* ãã¼ã¿ãã£ã¬ã¯ã·ã§ã³ã¬ã¸ã¹ã¿(PDR)ã®è¨­å® P21(RxD0)ãå
+¥åãã¼ãã«ãã */
+	sil_wrb_mem(PORT2_PDR_ADDR, 
+		sil_reb_mem(PORT2_PDR_ADDR) & ~PORT_PDR_B1_BIT);
+
+	/* ãã¼ã¿ãã£ã¬ã¯ã·ã§ã³ã¬ã¸ã¹ã¿(PDR)ã®è¨­å® P20(TxD0)ãåºåãã¼ãã«ãã */
+	sil_wrb_mem(PORT2_PDR_ADDR, 
+		sil_reb_mem(PORT2_PDR_ADDR) | PORT_PDR_B0_BIT);
+
+	/* ãã¼ãP40ï½P47ãå¨è¾ºæ©å¨ã« */
+	sil_wrb_mem(PORT4_PMR_ADDR, 0xFF);
+
+	/* ãã¼ãP40ï½P47ãå
+¥åãã¼ãã«ãã */
+	sil_wrb_mem(PORT4_PDR_ADDR, 0x00);
+
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® PFSWEãããã¸ã®æ¸ãè¾¼ã¿ãè¨±å¯ */
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x00);
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® PxxFSã¬ã¸ã¹ã¿ã¸ã®æ¸ãè¾¼ã¿ãè¨±å¯ */
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x40);
+
+	/* P21ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ RXD0ã¨ãã */
+	sil_wrb_mem(MPC_P21PFS_ADDR, 0x0a);
+	/* P20ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ TXD0ã¨ãã */
+	sil_wrb_mem(MPC_P20PFS_ADDR, 0x0a);
+
+	/* P40ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN000ã¨ãã */
+	sil_wrb_mem(MPC_P40PFS_ADDR, 0x80);
+	/* P41ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN001ã¨ãã */
+	sil_wrb_mem(MPC_P41PFS_ADDR, 0x80);
+	/* P42ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN002ã¨ãã */
+	sil_wrb_mem(MPC_P42PFS_ADDR, 0x80);
+	/* P43ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN003ã¨ãã */
+	sil_wrb_mem(MPC_P43PFS_ADDR, 0x80);
+	/* P44ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN004ã¨ãã */
+	sil_wrb_mem(MPC_P44PFS_ADDR, 0x80);
+	/* P45ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN005ã¨ãã */
+	sil_wrb_mem(MPC_P45PFS_ADDR, 0x80);
+	/* P46ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN006ã¨ãã */
+	sil_wrb_mem(MPC_P46PFS_ADDR, 0x80);
+	/* P47ç«¯å­æ©è½å¶å¾¡ã¬ã¸ã¹ã¿ ã¢ãã­ã°å
+¥åAN007ã¨ãã */
+	sil_wrb_mem(MPC_P47PFS_ADDR, 0x80);
+
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® æ¸ãè¾¼ã¿ãç¦æ­¢ */
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x80);
+}
+
+
+/*
+ *  ã¿ã¼ã²ããã·ã¹ãã ã®çµäºã«ã¼ãã³
+ */
+void
+target_exit( void )
+{
+	/*
+	 *	ãã­ã»ããµä¾å­ã®çµäºå¦ç
+	 */
+	prc_terminate();
+
+	while ( 1 );
+}
+
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_kernel_impl.h	(revision 317)
@@ -0,0 +1,143 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2005-2007 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ã¿ã¼ã²ããä¾å­ã¢ã¸ã¥ã¼ã«ï¼GR-SAKURAç¨ï¼
+ *
+ *  ã«ã¼ãã«ã®ã¿ã¼ã²ããä¾å­é¨ã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ï¼kernel_impl.hã®ã¿ã¼
+ *  ã²ããä¾å­é¨ã®ä½ç½®ä»ãã¨ãªãï¼
+ */
+
+#ifndef TOPPERS_TARGET_CONFIG_H
+#define TOPPERS_TARGET_CONFIG_H
+
+/*
+ *  ã¿ã¼ã²ããã·ã¹ãã ã®ãã¼ãã¦ã§ã¢è³æºã®å®ç¾©
+ */
+#include "gr_sakura.h"
+
+
+/*
+ *  ããã©ã«ãã®éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ã®ã¹ã¿ãã¯é åã®å®ç¾©
+ *
+ *  ã¹ã¿ãã¯ãµã¤ãºãå¤æ´ããå ´åã¯, sectrx.incã®_DEFAULT_ISTACK
+ *  ã©ãã«ã®ä½ç½®ã«ãã.blkbå½ä»¤ã®ãµã¤ãºã¨, ä»¥ä¸DEFAULT_ISTKSZã®
+ *  ãµã¤ãºãåããã¦åãå¤ã«å¤æ´ãããã¨.
+ */
+#define DEFAULT_ISTKSZ		( 0x400 )
+
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã®æå­åºåã«ä½¿ç¨ãããã¼ãã®å®ç¾©  
+ */
+#define TARGET_PUTC_PORTID	( 1 )
+
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã¿ã¼ã²ããã·ã¹ãã ä¾å­ã®åæå
+ */
+extern void	target_initialize( void );
+
+/*
+ *  ã¿ã¼ã²ããã·ã¹ãã ã®çµäº
+ *
+ *  ã·ã¹ãã ãçµäºããæã«ä½¿ãï¼
+ */
+extern void	target_exit( void )	NoReturn;
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+
+/*
+ *  ãã­ã»ããµä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX630ç¨ï¼
+ */
+#include "rx630_kernel_impl.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã«é¢ããè¨­å®
+ */
+#define TCNT_TRACE_BUFFER	( 32 )
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°åºåããç®æã®é¸æ
+ *    ã­ã°åºåããç®æã1ã§å®ç¾©
+ *    ã­ã°åºåããªãç®æã0ã§å®ç¾©
+ */
+#ifdef TOPPERS_ENABLE_TRACE
+#define LOG_DSP_ENTER	( 1 )
+#define LOG_DSP_LEAVE	( 1 )
+#define LOG_INH_ENTER	( 1 )
+#define LOG_INH_LEAVE	( 1 )
+#define LOG_EXC_ENTER	( 1 )
+#define LOG_EXC_LEAVE	( 1 )
+#else
+#define LOG_DSP_ENTER	( 0 )
+#define LOG_DSP_LEAVE	( 0 )
+#define LOG_INH_ENTER	( 0 )
+#define LOG_INH_LEAVE	( 0 )
+#define LOG_EXC_ENTER	( 0 )
+#define LOG_EXC_LEAVE	( 0 )
+#endif
+
+#ifdef TOPPERS_ENABLE_TRACE
+#include "arch/tracelog/trace_log.h"
+#endif /* TOPPERS_ENABLE_TRACE */
+
+#endif /* TOPPERS_TARGET_CONFIG_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.def
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.def	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.def	(revision 317)
@@ -0,0 +1,13 @@
+# target_kernel_impl.c
+target_initialize
+target_exit
+
+#trace_config.c
+log_dsp_enter
+log_dsp_leave
+log_inh_enter
+log_inh_leave
+log_exc_enter
+log_exc_leave
+
+INCLUDE "rx_rxc/prc"
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_rename.h	(revision 317)
@@ -0,0 +1,49 @@
+/* This file is generated from target_rename.def by genrename. */
+
+#ifndef TOPPERS_TARGET_RENAME_H
+#define TOPPERS_TARGET_RENAME_H
+
+/*
+ *  target_kernel_impl.c
+ */
+#define target_initialize			_kernel_target_initialize
+#define target_exit					_kernel_target_exit
+
+/*
+ *  trace_config.c
+ */
+#define log_dsp_enter				_kernel_log_dsp_enter
+#define log_dsp_leave				_kernel_log_dsp_leave
+#define log_inh_enter				_kernel_log_inh_enter
+#define log_inh_leave				_kernel_log_inh_leave
+#define log_exc_enter				_kernel_log_exc_enter
+#define log_exc_leave				_kernel_log_exc_leave
+
+
+#ifdef TOPPERS_LABEL_ASM
+
+/*
+ *  target_kernel_impl.c
+ */
+#define _board_id					__kernel_board_id
+#define _board_addr					__kernel_board_addr
+#define _target_initialize			__kernel_target_initialize
+#define _target_exit				__kernel_target_exit
+#define _config_int					__kernel_config_int
+
+/*
+ *  trace_config.c
+ */
+#define _log_dsp_enter				__kernel_log_dsp_enter
+#define _log_dsp_leave				__kernel_log_dsp_leave
+#define _log_inh_enter				__kernel_log_inh_enter
+#define _log_inh_leave				__kernel_log_inh_leave
+#define _log_exc_enter				__kernel_log_exc_enter
+#define _log_exc_leave				__kernel_log_exc_leave
+
+
+#endif /* TOPPERS_LABEL_ASM */
+
+#include "prc_rename.h"
+
+#endif /* TOPPERS_TARGET_RENAME_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sil.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sil.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sil.h	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		sil.hã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-SAKURAç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼sil.hã®å
+é ­ã§ã¤ã³ã¯ã«ã¼ããããï¼ä»ã®ãã¡
+ *  ã¤ã«ããã¯ç´æ¥ã¤ã³ã¯ã«ã¼ããããã¨ã¯ãªãï¼ãã®ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼
+ *  ãããåã«ï¼t_stddef.hãã¤ã³ã¯ã«ã¼ããããã®ã§ï¼ãããã«ä¾å­ãã¦ã
+ *  ããï¼
+ */
+
+#ifndef TOPPERS_TARGET_SIL_H
+#define TOPPERS_TARGET_SIL_H
+
+/*
+ *  å¾®å°æéå¾
+ã¡ã®ããã®å®ç¾©
+ */
+#define SIL_DLY_TIM1     69
+#define SIL_DLY_TIM2     50
+
+/*
+ *  ãã­ã»ããµã§å
+±éãªå®ç¾©
+ */
+#include "prc_sil.h"
+
+#endif /* TOPPERS_TARGET_SIL_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_stddef.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_stddef.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_stddef.h	(revision 317)
@@ -0,0 +1,109 @@
+/*
+ *  TOPPERS Software
+ *      Toyohashi Open Platform for Embedded Real-Time Systems
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  t_stddef.hã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-SAKURAç¨ï¼
+ *
+ *  ãã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã¯ï¼t_stddef.hã®å
+é ­ã§ã¤ã³ã¯ã«ã¼ããããï¼
+ *  ä»ã®ãã¡ã¤ã«ããã¯ç´æ¥ã¤ã³ã¯ã«ã¼ããããã¨ã¯ãªãï¼ä»ã®ã¤ã³ã¯ã«ã¼ã
+ *  ãã¡ã¤ã«ã«å
+ç«ã£ã¦å¦çãããããï¼ä»ã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ã«ä¾å­ã
+ *  ã¦ã¯ãªããªãï¼
+ */
+
+#ifndef TOPPERS_TARGET_STDDEF_H
+#define TOPPERS_TARGET_STDDEF_H
+
+/*
+ *  ã¿ã¼ã²ãããè­å¥ããããã®ãã¯ã­ã®å®ç¾©
+ */
+#define TOPPERS_GRSAKURA			/* ã·ã¹ãã ç¥ç§° */
+
+
+/*
+ *  éçºç°å¢ã§å
+±éãªå®ç¾©
+ */
+#ifndef TOPPERS_MACRO_ONLY
+#include <stdint.h>
+#endif /* TOPPERS_MACRO_ONLY */
+
+#include "tool_stddef.h"
+
+
+/*
+ *  ãã­ã»ããµã§å
+±éãªå®ç¾©
+ */
+#include "prc_stddef.h"
+
+/*
+ *  ã¢ãµã¼ã·ã§ã³ã®å¤±ææã®å®è¡ä¸­æ­å¦ç
+ */
+#ifndef TOPPERS_MACRO_ONLY
+
+Inline void
+TOPPERS_assert_abort( void )
+{
+}
+
+#endif /* TOPPERS_MACRO_ONLY */
+
+#endif /* TOPPERS_TARGET_STDDEF_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_support.c
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_support.c	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_support.c	(revision 317)
@@ -0,0 +1,148 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *	ã¿ã¼ã²ããã·ã¹ãã ä¾å­ã¢ã¸ã¥ã¼ã«ï¼GR-SAKURAç¨ï¼
+ */
+
+#include "kernel_impl.h"
+#include <sil.h>
+
+void hardware_init_hook()
+{
+	/*
+	 * åä½ã¢ã¼ãè¨­å®
+	 *
+	 * åä½ã¢ã¼ãã¯ãã¼ãä¸ã®ç«¯å­ã«ãã£ã¦æ±ºå®ããããã,
+	 * ããã§ã¯ç¹å¥è¨­å®ããªã.
+	 * ãã ã, ãªãã«ã¨ã³ãã£ã¢ã³/ã·ã³ã°ã«ãããã¢ã¼ã
+	 * ã§ãããã¨ãåæã¨ãã.
+	 *
+	 * ã¾ããªã»ããå¾, å
+èµROMï¼æå¹, å
+èµRAMï¼æå¹, å¤é¨ãã¹ï¼ç¡å¹
+	 * ã§ãã.
+	 */
+
+	/*
+	 * ã¯ã­ãã¯è¨­å®
+	 *
+	 * å
+¥åï¼12MHz
+	 * PLLåè·¯ï¼12 x 8 = 96MHz
+	 * ã·ã¹ãã ã¯ã­ãã¯ï¼96MHz
+	 * å¨è¾ºã¢ã¸ã¥ã¼ã«ã¯ã­ãã¯ï¼48MHz
+	 * å¤é¨ãã¹ã¯ã­ãã¯ï¼96MHz
+	 * ã¨ãã.
+	 */
+	sil_wrb_mem(PORT3_PDR_ADDR,
+		sil_reb_mem(PORT3_PDR_ADDR) & ~PORT_PDR_B6_BIT);
+	sil_wrb_mem(PORT3_PDR_ADDR,
+		sil_reb_mem(PORT3_PDR_ADDR) & ~PORT_PDR_B7_BIT);
+	sil_wrb_mem(PORT3_PMR_ADDR,
+		sil_reb_mem(PORT3_PMR_ADDR) & ~PORT_PDR_B6_BIT);
+	sil_wrb_mem(PORT3_PMR_ADDR,
+		sil_reb_mem(PORT3_PMR_ADDR) & ~PORT_PDR_B7_BIT);
+
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xa503);
+
+	/* ã¡ã¤ã³ã¯ã­ãã¯çºæ¯å¨å¼·å¶çºæ¯ */
+	while((sil_reb_mem(SYSTEM_MOFCR_ADDR) & SYSTEM_MOFCR_MOFXIN) == 0)
+		sil_wrb_mem(SYSTEM_MOFCR_ADDR,
+			sil_reb_mem(SYSTEM_MOFCR_ADDR) | SYSTEM_MOFCR_MOFXIN);
+
+	/* ã¡ã¤ã³ã¯ã­ãã¯çºæ¯å¨åä½ */
+	while((sil_reb_mem(SYSTEM_MOSCCR_ADDR) & SYSTEM_MOSCCR_MOSTP) != 0)
+		sil_wrb_mem(SYSTEM_MOSCCR_ADDR,
+			sil_reb_mem(SYSTEM_MOSCCR_ADDR) & ~SYSTEM_MOSCCR_MOSTP);
+
+	sil_wrh_mem(SYSTEM_PLLCR_ADDR,
+		(sil_reh_mem(SYSTEM_PLLCR_ADDR) & ~SYSTEM_PLLCR_STC_MASK)
+		| (0x0f << SYSTEM_PLLCR_STC_OFFSET));
+
+	sil_wrb_mem(SYSTEM_PLLCR2_ADDR,
+		sil_reb_mem(SYSTEM_PLLCR2_ADDR) & ~SYSTEM_PLLCR2_PLLEN);
+
+	sil_wrw_mem(SYSTEM_SCKCR_ADDR, 0x21021211);
+
+	sil_wrh_mem(SYSTEM_SCKCR2_ADDR, 0x0033);
+
+	/* PLLåè·¯é¸æ */
+	sil_wrh_mem(SYSTEM_SCKCR3_ADDR,
+		(sil_reh_mem(SYSTEM_SCKCR3_ADDR) & ~SYSTEM_SCKCR3_CKSEL_MASK)
+		| (4 << SYSTEM_SCKCR3_CKSEL_OFFSET));
+
+	/*
+	 * ã¢ã¸ã¥ã¼ã«ã¹ããã
+	 *
+	 * ãªã»ããå¾, åä½ãã¦ããå
+èµå¨è¾ºã¢ã¸ã¥ã¼ã«ã¯DMAC, DTC,
+	 * å
+èµRAMã®ã¿ã§ãã.
+	 * ããä»¥å¤ã®å
+èµå¨è¾ºã¢ã¸ã¥ã¼ã«ã«é¢ãã¦ã¯ä½¿ç¨ããå´ã§
+	 * è¨­å®ãããã¨.
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xa500);
+}
+
+void software_init_hook()
+{
+	/*
+	 * æ¬ã³ã³ãã¤ã©ã§ã¯weak definitionã®æ©è½ãç¡ããã,
+	 * ç¹ã«å¿
+è¦ãªå¦çã¯ãªãã, å¿
+ãå¼ã³åºããã¨ã¨ãã.
+	 */
+}
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sym.def
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sym.def	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_sym.def	(revision 317)
@@ -0,0 +1,10 @@
+LOG_DSP_ENTER
+LOG_DSP_LEAVE
+LOG_INH_ENTER
+LOG_INH_LEAVE
+LOG_EXC_ENTER
+LOG_EXC_LEAVE
+SIL_DLY_TIM1
+SIL_DLY_TIM2
+INTATR_TIMER0
+INTATR_TIMER1
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_syssvc.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_syssvc.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_syssvc.h	(revision 317)
@@ -0,0 +1,137 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ã·ã¹ãã ãµã¼ãã¹ã®ã¿ã¼ã²ããä¾å­é¨ï¼GR-SAKURAç¨ï¼
+ *
+ *  ã·ã¹ãã ãµã¼ãã¹ã®ã¿ã¼ã²ããä¾å­é¨ã®ã¤ã³ã¯ã«ã¼ããã¡ã¤ã«ï¼ãã®ãã¡
+ *  ã¤ã«ã®å
+å®¹ã¯ï¼ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«ã«è¨è¿°ããï¼ãã®ãã¡ã¤ã«ã¯
+ *  ç¡ããªãè¦è¾¼ã¿ï¼
+ */
+
+#ifndef TOPPERS_TARGET_SYSSVC_H
+#define TOPPERS_TARGET_SYSSVC_H
+
+
+/*
+ *  ãã­ã»ããµä¾å­ã®å®ç¾©
+ */
+#include "prc_syssvc.h"
+
+/*
+ *  ãã¬ã¼ã¹ã­ã°ã«é¢ããè¨­å®
+ */
+#ifdef TOPPERS_ENABLE_TRACE
+#include "arch/tracelog/trace_log.h"
+#endif /* TOPPERS_ENABLE_TRACE */
+
+
+/*
+ *  ãã¼ãä¾å­æ
+å ±ã®èª­ã¿è¾¼ã¿
+ */
+#include "gr_sakura.h"
+
+
+/*
+ *  èµ·åã¡ãã»ã¼ã¸ã®ã¿ã¼ã²ããã·ã¹ãã å
+ */
+#define	TARGET_NAME	"GRSAKURA"
+
+
+/*
+ *  ã·ã¹ãã ã­ã°ã®ä½ã¬ãã«åºåã®ããã®æå­åºå
+ *
+ *  ã¿ã¼ã²ããä¾å­ã®æ¹æ³ã§ï¼æå­cãè¡¨ç¤º/åºå/ä¿å­ããï¼
+ */
+extern void	target_fput_log( char c );
+
+
+/*
+ *  èµ·åã¡ãã»ã¼ã¸ã«ã¿ã¼ã²ããä¾å­é¨ã®èä½æ¨©è¡¨ç¤ºã
+ *  è¿½å ããããã®ãã¯ã­ï¼
+ */
+#ifdef PRC_COPYRIGHT
+#define	TARGET_COPYRIGHT	PRC_COPYRIGHT
+#endif /* PRC_COPYRIGHT */
+
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãæ°ã®å®ç¾©
+ */
+#define	TNUM_PORT			UINT_C( 2 )
+
+/*
+ *  ä½¿ç¨ããã·ãªã¢ã«ãã¼ãID
+ */
+#define	SIO_PORTID			UINT_C( 1 )
+
+#define LOGTASK_PORTID		SIO_PORTID
+
+#define STACK_SIZE			(512)
+
+/*
+ *  ã·ã¹ãã ã­ã°ã¿ã¹ã¯é¢é£ã®å®æ°ã®å®ç¾©
+ *
+ *  ããã©ã«ãå¤ã®éãï¼
+ */
+
+#endif /* TOPPERS_TARGET_SYSSVC_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_test.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_test.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_test.h	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ãã¹ããã­ã°ã©ã ã®ã¿ã¼ã²ããä¾å­å®ç¾©ï¼GR-SAKURAç¨ï¼
+ */
+
+#ifndef TOPPERS_TARGET_TEST_H
+#define TOPPERS_TARGET_TEST_H
+
+/*
+ *  ãã­ã»ããµã§å
+±éãªå®ç¾©
+ */
+#include "prc_test.h"
+
+/*
+ *  ã¿ã¹ã¯ã§ä½¿ç¨ããã·ãªã¢ã«ãã¼ãID
+ */
+#define	TASK_PORTID		( 1 )
+
+
+#endif /* TOPPERS_TARGET_TEST_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.c
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.c	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.c	(revision 317)
@@ -0,0 +1,699 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ã¿ã¤ããã©ã¤ãï¼GR-SAKURAç¨ï¼
+ */
+
+#include "kernel_impl.h"
+#include "time_event.h"
+#include <sil.h>
+#include "target_timer.h"
+#ifdef TOPPERS_SUPPORT_OVRHDR
+#include "overrun.h"
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+/*
+ * ä¸ä½ã¿ã¤ãã½ããã«ã¦ã³ã¿
+ */
+static uint16_t elapse_upper_timer = 0;
+
+/*
+ * ä¸ä¸ä½ã¿ã¤ãè¨­å®ã«ã¦ã³ã¿
+ */
+static uint16_t timer_upper_set_count = 0, timer_lower_set_count = 0;
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+
+/* ãªã¼ãã©ã³ä¸ä¸ä½ã¿ã¤ãè¨­å®ã«ã¦ã³ã¿ */
+static uint16_t timer_ovr_upper_set_count = 0, timer_ovr_lower_set_count = 0;
+
+/* ãªã¼ãã©ã³ã¿ã¤ãå®è¡ä¸­ãã©ã° */
+static bool_t timer_ovr_running_flg = false;
+
+/* ãªã¼ãã©ã³ã¿ã¤ãéå§æHRTã¿ã¤ãå¤ */
+static HRTCNT timer_ovr_hrt_backup;
+
+/* ãªã¼ãã©ã³ã¿ã¤ãè¨­å®æé */
+static PRCTIM timer_ovr_ovrtim_backup;
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãå²è¾¼ã¿è¦æ±ã®ã¯ãªã¢
+ */
+Inline void
+target_ovrtimer_int_clear()
+{
+	clear_int(INTNO_TIMER2);
+}
+
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+/*
+ *  ã¿ã¤ãã®åæåå¦ç
+ */
+void
+target_timer_initialize(intptr_t exinf)
+{
+	/*
+	 * ã¢ã¸ã¥ã¼ã«ã¹ãããæ©è½ã®è¨­å®  CMTã¦ããã0 è§£é¤
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
+			sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA15_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+
+	/* 
+	 * ã¿ã¤ãåæ­¢ 
+	 */
+	sil_wrh_mem(CMT_CMSTR0_ADDR,
+			sil_reh_mem(CMT_CMSTR0_ADDR) & ~(CMT_CMSTR0_STR0_BIT | CMT_CMSTR0_STR1_BIT));
+	
+	/*
+ 	 * ã«ã¦ã³ãã¢ããã«ç¨ããããã¯ã­ãã¯è¨­å®
+	 * PCLK/8ãé¸æ
+	 */
+	sil_wrh_mem(CMT0_CMCR_ADDR, CMT_PCLK_DIV_8);
+	sil_wrh_mem(CMT1_CMCR_ADDR, CMT_PCLK_DIV_8);
+
+	/* 
+	 * ã³ã³ãã¢ãããã¿ã¤ãã«ã¦ã³ã¿è¨­å®
+	 */
+	sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);
+	sil_wrh_mem(CMT1_CMCNT_ADDR, 0U);
+
+	/* 
+	 * ã³ã³ãã¢ãããã¿ã¤ãå¨æè¨­å®
+	 */
+	sil_wrh_mem(CMT0_CMCOR_ADDR, 0); /* lower */
+	sil_wrh_mem(CMT1_CMCOR_ADDR, CMCOR_PERIOD - 1); /* upper */
+	elapse_upper_timer = 0;
+
+	/*
+	 * ã³ã³ãã¢ãããã¿ã¤ãå²ãè¾¼ã¿è¦æ±å
+è¨­å®ã¬ã¸ã¹ã¿ï¼28,29ï¼
+	 */
+	sil_wrb_mem(ICU_ISELR028_ADDR, ICU_ISEL_CPU);
+	sil_wrb_mem(ICU_ISELR029_ADDR, ICU_ISEL_CPU);
+
+	/*
+	 *  ã¿ã¤ãåä½éå§åã®å²è¾¼ã¿è¦æ±ãã¯ãªã¢
+	 */
+	clear_int(INTNO_TIMER0);
+	clear_int(INTNO_TIMER1);
+
+	/* 
+	 * ã³ã³ãã¢ãããã¿ã¤ãå²ãè¾¼ã¿ãè¨±å¯
+	 */
+//	sil_wrh_mem(CMT0_CMCR_ADDR,
+//			sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT); /* lower */
+	sil_wrh_mem(CMT1_CMCR_ADDR,
+			sil_reh_mem(CMT1_CMCR_ADDR) | CMT1_CMCR_CMIE_BIT); /* upper */
+
+	/* 
+	 * ã¿ã¤ãåä½éå§
+	 */
+//	sil_wrh_mem(CMT_CMSTR0_ADDR,
+//			sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT); /* lower */
+	sil_wrh_mem(CMT_CMSTR0_ADDR,
+			sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR1_BIT); /* upper */
+}
+
+/*
+ *  ã¿ã¤ãã®åæ­¢å¦ç
+ */
+void
+target_timer_terminate(intptr_t exinf)
+{
+	/* 
+	 * ã¿ã¤ãåæ­¢  lower, upper
+	 */
+	sil_wrh_mem(CMT_CMSTR0_ADDR,
+			sil_reh_mem(CMT_CMSTR0_ADDR) & ~(CMT_CMSTR0_STR0_BIT | CMT_CMSTR0_STR1_BIT));
+
+	/*
+	 * ã¿ã¤ãå²ãè¾¼ã¿ç¦æ­¢ãlower,upper
+	 */
+	sil_wrh_mem(CMT0_CMCR_ADDR,
+			sil_reh_mem(CMT0_CMCR_ADDR) & ~CMT0_CMCR_CMIE_BIT);
+	sil_wrh_mem(CMT1_CMCR_ADDR,
+			sil_reh_mem(CMT1_CMCR_ADDR) & ~CMT1_CMCR_CMIE_BIT);
+
+	/*
+	 *  ã¿ã¤ãå²è¾¼ã¿è¦æ±ãã¯ãªã¢
+	 */
+	clear_int(INTNO_TIMER0);
+	clear_int(INTNO_TIMER1);
+
+	/*
+	 * ã¢ã¸ã¥ã¼ã«ã¹ãããæ©è½ã®è¨­å®  CMTã¦ããã0 åæ­¢
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
+			sil_rew_mem(SYSTEM_MSTPCRA_ADDR) | SYSTEM_MSTPCRA_MSTPA15_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+}
+
+/*
+ *  ä¸ä½ã¿ã¤ãå²è¾¼ã¿ãã³ãã©(CMT0)
+ */
+void target_lower_timer_handler(void)
+{
+	/*
+	 * ã¿ã¤ãåæ­¢
+	 */
+	sil_wrh_mem(CMT_CMSTR0_ADDR,
+		sil_reh_mem(CMT_CMSTR0_ADDR) & ~CMT_CMSTR0_STR0_BIT);
+
+	/*
+	 * ã¿ã¤ãå²ãè¾¼ã¿ç¦æ­¢
+	 */
+	sil_wrh_mem(CMT0_CMCR_ADDR,
+			sil_reh_mem(CMT0_CMCR_ADDR) & ~CMT0_CMCR_CMIE_BIT);
+
+	/*
+	 * å²ãè¾¼ã¿è¦å ã¯ãªã¢
+	 */
+	clear_int(INTNO_TIMER0);
+
+	/*
+	 * ã«ã¦ã³ãè¨­å®ã¯ãªã¢
+	 */
+	timer_lower_set_count = 0;
+
+	/*
+	 * ã¿ã¤ãå²ãè¾¼ã¿å¦ç
+	 */
+	signal_time();
+}
+
+/*
+ *  ä¸ä½ã¿ã¤ãå²è¾¼ã¿ãã³ãã©(CMT1)
+ */
+void target_upper_timer_handler(void)
+{
+	/*
+	 * ä¸ä½ã¿ã¤ãã½ããã«ã¦ã³ã¿æ´æ°
+	 */
+	elapse_upper_timer++;
+
+	/*
+	 * ä¸ä½ã¿ã¤ãè¨­å®å¤æ´æ°
+	 */
+	if(timer_upper_set_count > 0) {
+		timer_upper_set_count--;
+	}
+
+	/*
+	 * ä¸ä½ã¿ã¤ããããå¦ç
+	 */
+	if(timer_upper_set_count == 0){
+		if(timer_lower_set_count > 0){
+			/*
+			 * ä¸ä½ã¿ã¤ãè¨­å®ãéå§
+			 */
+			sil_wrh_mem(CMT0_CMCOR_ADDR, timer_lower_set_count);
+			clear_int(INTNO_TIMER0);
+			sil_wrh_mem(CMT0_CMCR_ADDR,
+					sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
+			sil_wrh_mem(CMT_CMSTR0_ADDR,
+					sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
+		}
+		else{
+			/*
+			 * ä¸ä½ã¿ã¤ãå²ãè¾¼ã¿å¼·å¶èµ·å
+			 */
+			target_hrt_raise_event();
+		}
+	}
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+	if(timer_ovr_running_flg == true) {
+		/*
+		 * ãªã¼ãã©ã³ä¸ä½ã¿ã¤ãè¨­å®å¤æ´æ°
+		 */
+		if(timer_ovr_upper_set_count > 0) {
+			timer_ovr_upper_set_count--;
+		}
+
+		/*
+		 * ãªã¼ãã©ã³ä¸ä½ã¿ã¤ããããå¦ç
+		 */
+		if(timer_ovr_upper_set_count == 0) {
+			if(timer_ovr_lower_set_count > 0){
+				/*
+				 * ãªã¼ãã©ã³ä¸ä½ã¿ã¤ãè¨­å®ãéå§
+				 */
+				sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
+				sil_wrh_mem(CMT2_CMCOR_ADDR, timer_ovr_lower_set_count);
+				target_ovrtimer_int_clear();
+				sil_wrh_mem(CMT2_CMCR_ADDR,
+						sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
+				sil_wrh_mem(CMT_CMSTR1_ADDR,
+						sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
+			}
+			else {
+				/*
+				 * ãªã¼ãã©ã³ä¸ä½ã¿ã¤ãå²ãè¾¼ã¿å¼·å¶èµ·å
+				 */
+				target_ovrtimer_raise_event();
+			}
+		}
+	}
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã¸ã®å²è¾¼ã¿ã¿ã¤ãã³ã°ã®è¨­å®
+ */
+void
+target_hrt_set_event(HRTCNT hrtcnt)
+{
+	uint32_t current_timer_count_work;
+	uint32_t total_timer_count;
+
+	/*
+	 * æé -> ã¿ã¤ãã«ã¦ã³ã¿ å¤æ
+	 */
+	total_timer_count = hrtcnt * USEC_CONVERT_VALUE;
+	timer_upper_set_count = total_timer_count / CMCOR_PERIOD;
+	timer_lower_set_count = total_timer_count % CMCOR_PERIOD;
+
+	/*
+	 * ä¸ä½ã¿ã¤ãã«ã¦ã³ã¿ç¾å¨å¤ã§èª¿æ´
+	 */
+	current_timer_count_work = timer_lower_set_count + sil_reh_mem(CMT1_CMCNT_ADDR);
+	if(current_timer_count_work >= CMCOR_PERIOD) {
+		timer_upper_set_count++;
+		timer_lower_set_count = current_timer_count_work - CMCOR_PERIOD;
+	}
+
+	/*
+	 * ä¸ä½ã¿ã¤ãè¨­å®
+	 */
+	if(timer_upper_set_count == 0 && timer_lower_set_count > 0) {
+		/*
+		 * ã³ã³ãã¢ãããã¿ã¤ãã«ã¦ã³ã¿è¨­å®
+		 */
+		sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);
+
+		/*
+		 * å²ãè¾¼ã¿è¦å ã¯ãªã¢
+		 */
+		clear_int(INTNO_TIMER0);
+
+		/*
+		 * ã³ã³ãã¢ãããã¿ã¤ãå¨æè¨­å®
+		 */
+		sil_wrh_mem(CMT0_CMCOR_ADDR, timer_lower_set_count);
+
+		/*
+		 *  ã¿ã¤ãå²ãè¾¼ã¿è¨±å¯
+		 */
+		sil_wrh_mem(CMT0_CMCR_ADDR,
+				sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
+
+		/*
+		 * ã¿ã¤ãéå§
+		 */
+		sil_wrh_mem(CMT_CMSTR0_ADDR,
+				sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
+	}
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®è¦æ±
+ */
+void
+target_hrt_raise_event(void)
+{
+	/*
+	 * ä¸ä½ã¿ã¤ãå¼·å¶å²ãè¾¼ã¿èµ·å
+	 * æ³¨æï¼åæ­¢ããã¾ã§å²ãè¾¼ã¿ãç¹°ãè¿ãçºçãã
+	 */
+	sil_wrh_mem(CMT0_CMCNT_ADDR, 0U);	/* ã«ã¦ã³ã¿åæå	*/
+	clear_int(INTNO_TIMER0);			/* è¦æ±ã¯ãªã¢		*/
+	sil_wrh_mem(CMT0_CMCOR_ADDR, 0U);	/* ãããå¨æè¨­å®	*/
+	sil_wrh_mem(CMT0_CMCR_ADDR,			/* å²ãè¾¼ã¿è¨±å¯	*/
+			sil_reh_mem(CMT0_CMCR_ADDR) | CMT0_CMCR_CMIE_BIT);
+	sil_wrh_mem(CMT_CMSTR0_ADDR,		/* ã¿ã¤ãèµ·å		*/
+			sil_reh_mem(CMT_CMSTR0_ADDR) | CMT_CMSTR0_STR0_BIT);
+}
+
+/*
+ * é«åè§£è½ã¿ã¤ãã®ç¾å¨ã®ã«ã¦ã³ãå¤ã®èª­åºããå
+é¨å¦ç
+ */
+HRTCNT target_hrt_get_current_convert(void)
+{
+	uint16_t local_cnt, local_eut;
+	HRTCNT time;
+
+	local_eut = elapse_upper_timer;
+	local_cnt = sil_reh_mem(CMT1_CMCNT_ADDR);
+
+	/*
+	 * ä¸ä½ã¿ã¤ã ã³ã³ãã¢ããããã§ãã¯
+	 */
+	if (probe_int(INTNO_TIMER1)) {
+		if(local_cnt < 0x8000)
+			local_eut += 1;
+	}
+
+	time = (((HRTCNT)local_eut * CMCOR_PERIOD) + (HRTCNT)local_cnt) / USEC_CONVERT_VALUE;
+
+	return time;
+}
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ããã©ã¤ã
+ */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæåå¦ç
+ */
+void
+target_ovrtimer_initialize(intptr_t exinf)
+{
+	/*
+	 * ã¢ã¸ã¥ã¼ã«ã¹ãããæ©è½ã®è¨­å®  CMTã¦ããã1 è§£é¤
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
+			sil_rew_mem(SYSTEM_MSTPCRA_ADDR) & ~SYSTEM_MSTPCRA_MSTPA14_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+
+	/*
+	 * ã¿ã¤ãåæ­¢ CMT2
+	 */
+	sil_wrh_mem(CMT_CMSTR1_ADDR,
+			sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
+
+	/*
+ 	 * ã«ã¦ã³ãã¢ããã«ç¨ããããã¯ã­ãã¯è¨­å® CMT2
+	 * PCLK/8ãé¸æ
+	 */
+	sil_wrh_mem(CMT2_CMCR_ADDR, CMT_PCLK_DIV_8);
+
+	/*
+	 * ã³ã³ãã¢ãããã¿ã¤ãã«ã¦ã³ã¿è¨­å® CMT2
+	 */
+	sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
+
+	/*
+	 * ã³ã³ãã¢ãããã¿ã¤ãå¨æè¨­å® CMT2
+	 */
+	sil_wrh_mem(CMT2_CMCOR_ADDR, 0U);
+
+	/*
+	 * ã³ã³ãã¢ãããã¿ã¤ãå²ãè¾¼ã¿è¦æ±å
+è¨­å®ã¬ã¸ã¹ã¿ï¼30ï¼
+	 */
+	sil_wrb_mem(ICU_ISELR030_ADDR, ICU_ISEL_CPU);
+
+	/*
+	 *  ã¿ã¤ãåä½éå§åã®å²è¾¼ã¿è¦æ±ãã¯ãªã¢
+	 */
+	target_ovrtimer_int_clear();
+}
+
+void
+target_ovrtimer_start(PRCTIM ovrtim)
+{
+	uint32_t current_timer_count_work;
+	uint32_t total_timer_count;
+
+	/*
+	 * æé -> ã¿ã¤ãã«ã¦ã³ã¿ å¤æ
+	 */
+	total_timer_count = ovrtim * USEC_CONVERT_VALUE;
+	timer_ovr_upper_set_count = total_timer_count / CMCOR_PERIOD;
+	timer_ovr_lower_set_count = total_timer_count % CMCOR_PERIOD;
+
+	/*
+	 * é«åè§£è½ä¸ä½ã¿ã¤ãã«ã¦ã³ã¿ç¾å¨å¤ã§èª¿æ´
+	 */
+	timer_ovr_ovrtim_backup = ovrtim;
+	timer_ovr_hrt_backup = target_hrt_get_current();
+	current_timer_count_work = timer_ovr_lower_set_count + sil_reh_mem(CMT1_CMCNT_ADDR);
+	if(current_timer_count_work >= CMCOR_PERIOD) {
+		timer_ovr_upper_set_count++;
+		timer_ovr_lower_set_count = current_timer_count_work - CMCOR_PERIOD;
+	}
+
+	/*
+	 * ãªã¼ãã©ã³ã¿ã¤ãåä½ä¸­ãã©ã°
+	 */
+	timer_ovr_running_flg = true;
+
+	/*
+	 * ä¸ä½ã¿ã¤ãè¨­å®
+	 */
+	if(timer_ovr_upper_set_count == 0) {
+		if(timer_ovr_lower_set_count == 0) {
+			target_ovrtimer_raise_event();
+		}
+		else {
+			/*
+			 * ã³ã³ãã¢ãããã¿ã¤ãã«ã¦ã³ã¿ã¯ãªã¢ CMT2
+			 */
+			sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);
+
+			/*
+			 * ã³ã³ãã¢ãããã¿ã¤ãå¨æè¨­å® CMT2
+			 */
+			sil_wrh_mem(CMT2_CMCOR_ADDR, timer_ovr_lower_set_count);
+
+			/*
+			 *  ã¿ã¤ãåä½éå§åã®å²è¾¼ã¿è¦æ±ãã¯ãªã¢
+			 */
+			target_ovrtimer_int_clear();
+
+			/*
+			 * ã³ã³ãã¢ãããã¿ã¤ãå²ãè¾¼ã¿ãè¨±å¯ CMT2
+			 */
+			sil_wrh_mem(CMT2_CMCR_ADDR,
+					sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
+
+			/*
+			 * ã¿ã¤ãåä½éå§ CMT2
+			 */
+			sil_wrh_mem(CMT_CMSTR1_ADDR,
+					sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
+		}
+	}
+}
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæ­¢å¦ç
+ */
+void
+target_ovrtimer_terminate(intptr_t exinf)
+{
+	/*
+	 * ã¿ã¤ãåæ­¢
+	 */
+	sil_wrh_mem(CMT_CMSTR1_ADDR,
+			sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
+
+	/*
+	 * ã¿ã¤ãå²ãè¾¼ã¿ç¦æ­¢
+	 */
+	sil_wrh_mem(CMT2_CMCR_ADDR,
+			sil_reh_mem(CMT2_CMCR_ADDR) & ~CMT2_CMCR_CMIE_BIT);
+
+	/*
+	 *  ã¿ã¤ãå²è¾¼ã¿è¦æ±ãã¯ãªã¢
+	 */
+	target_ovrtimer_int_clear();
+
+	/*
+	 * ãªã¼ãã©ã³ã¿ã¤ãåä½ä¸­ãã©ã°
+	 */
+	timer_ovr_running_flg = false;
+
+	/*
+	 * ã¢ã¸ã¥ã¼ã«ã¹ãããæ©è½ã®è¨­å®  CMTã¦ããã0 åæ­¢
+	 */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRA_ADDR,
+			sil_rew_mem(SYSTEM_MSTPCRA_ADDR) | SYSTEM_MSTPCRA_MSTPA14_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+}
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæ­¢
+ */
+PRCTIM
+target_ovrtimer_stop(uint_t int_num)
+{
+	uint32_t	cnt;
+
+	/*
+	 * ã¿ã¤ãåæ­¢
+	 */
+	sil_wrh_mem(CMT_CMSTR1_ADDR,
+			sil_reh_mem(CMT_CMSTR1_ADDR) & ~CMT_CMSTR1_STR2_BIT);
+
+	/*
+	 * ãªã¼ãã©ã³ã¿ã¤ãåä½ä¸­ãã©ã°
+	 */
+	timer_ovr_running_flg = false;
+
+	if(int_num == INTNO_TIMER2) {
+		/*
+		 *  ãªã¼ãã©ã³å²è¾¼ã¿ã®å ´å
+		 */
+		target_ovrtimer_int_clear();
+		return(0U);
+	}
+	else {
+		HRTCNT timer_ovr_hrt_current = target_hrt_get_current();
+		if((timer_ovr_hrt_current < timer_ovr_hrt_backup) && (int_num == INTNO_OVR_BASE_TIMER)) {
+			timer_ovr_hrt_current += (CMCOR_PERIOD / USEC_CONVERT_VALUE);
+		}
+
+		cnt = timer_ovr_ovrtim_backup - (timer_ovr_hrt_current - timer_ovr_hrt_backup);
+		if(timer_ovr_hrt_current < timer_ovr_hrt_backup) {
+			cnt += TCYC_HRTCNT;
+		}
+
+		if(cnt > timer_ovr_ovrtim_backup) { /* è¨­å®æéãéãã */
+			cnt = 0;
+		}
+		return (PRCTIM)cnt;
+	}
+}
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®ç¾å¨å¤ã®èª­åºã
+ */
+PRCTIM
+target_ovrtimer_get_current(void)
+{
+	uint32_t	cnt;
+
+	if (probe_int(INTNO_TIMER2)) {
+		/*
+		 *  å²è¾¼ã¿è¦æ±ãçºçãã¦ããå ´å
+		 */
+		return(0U);
+	}
+	else {
+		HRTCNT timer_ovr_hrt_current = target_hrt_get_current();
+		cnt = timer_ovr_ovrtim_backup - (timer_ovr_hrt_current - timer_ovr_hrt_backup);
+		if(timer_ovr_hrt_current < timer_ovr_hrt_backup) {
+			cnt += TCYC_HRTCNT;
+		}
+
+		if(cnt > timer_ovr_ovrtim_backup) { /* è¨­å®æéãéãã */
+			cnt = 0;
+		}
+		return (PRCTIM)cnt;
+	}
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®è¦æ±
+ */
+void
+target_ovrtimer_raise_event(void)
+{
+	/*
+	 * ãªã¼ãã©ã³ä¸ä½ã¿ã¤ãå¼·å¶å²ãè¾¼ã¿èµ·å
+	 * æ³¨æï¼åæ­¢ããã¾ã§å²ãè¾¼ã¿ãç¹°ãè¿ãçºçãã
+	 */
+	sil_wrh_mem(CMT2_CMCNT_ADDR, 0U);	/* ã«ã¦ã³ã¿åæå	*/
+	clear_int(INTNO_TIMER2);			/* è¦æ±ã¯ãªã¢		*/
+	sil_wrh_mem(CMT2_CMCOR_ADDR, 0U);	/* ãããå¨æè¨­å®	*/
+	sil_wrh_mem(CMT2_CMCR_ADDR,			/* å²ãè¾¼ã¿è¨±å¯	*/
+			sil_reh_mem(CMT2_CMCR_ADDR) | CMT2_CMCR_CMIE_BIT);
+	sil_wrh_mem(CMT_CMSTR1_ADDR,		/* ã¿ã¤ãèµ·å		*/
+			sil_reh_mem(CMT_CMSTR1_ADDR) | CMT_CMSTR1_STR2_BIT);
+}
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãå²è¾¼ã¿ãã³ãã©
+ *
+ *  ãã®ã«ã¼ãã³ã«æ¥ãã¾ã§ã«ï¼target_ovrtimer_stopãå¼ã°ãã¦ããããï¼
+ *  OSã¿ã¤ããåæ­¢ããå¿
+è¦ã¯ãªãï¼
+ */
+void
+target_ovrtimer_handler(void)
+{
+	/*
+	 * ã¿ã¤ãå²ãè¾¼ã¿ç¦æ­¢
+	 */
+	sil_wrh_mem(CMT2_CMCR_ADDR,
+			sil_reh_mem(CMT2_CMCR_ADDR) & ~CMT2_CMCR_CMIE_BIT);
+
+	/*
+	 * ä¸ä¸ä½ã¿ã¤ãã«ã¦ã³ã¿ã¯ãªã¢
+	 */
+	timer_ovr_upper_set_count = 0;
+	timer_ovr_lower_set_count = 0;
+
+	call_ovrhdr();	/* ãªã¼ãã©ã³ãã³ãã©ã®èµ·åå¦ç */
+}
+
+#endif /* TOPPERS_SUPPORT_OVRHDR */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.cfg
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.cfg	(revision 317)
@@ -0,0 +1,22 @@
+/*
+ *  ã¿ã¤ããã©ã¤ãï¼GR-SAKURAç¨ï¼ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "target_timer.h"
+
+ATT_INI({ TA_NULL, 0, target_timer_initialize });
+ATT_TER({ TA_NULL, 0, target_timer_terminate });
+DEF_INH(INHNO_TIMER0, { TA_NULL, target_lower_timer_handler });
+CFG_INT(INTNO_TIMER0, { INTATR_TIMER0, INTPRI_TIMER0 });
+DEF_INH(INHNO_TIMER1, { TA_NULL, target_upper_timer_handler });
+CFG_INT(INTNO_TIMER1, { INTATR_TIMER1, INTPRI_TIMER1 });
+
+/*
+ *  ãªã¼ãã©ã³ãã³ãã©ç¨ã¿ã¤ããã©ã¤ãï¼RX630ç¨ï¼ã®ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+#ifdef TOPPERS_SUPPORT_OVRHDR
+ATT_INI({ TA_NULL, 0, target_ovrtimer_initialize });
+ATT_TER({ TA_NULL, 0, target_ovrtimer_terminate }); 
+DEF_INH(INHNO_TIMER2, { TA_NULL, target_ovrtimer_handler });
+CFG_INT(INTNO_TIMER2, { INTATR_TIMER2, INTPRI_TIMER2 });
+#endif /* TOPPERS_SUPPORT_OVRHDR */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_timer.h	(revision 317)
@@ -0,0 +1,303 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
+ *                              Toyohashi Univ. of Technology, JAPAN
+ *  Copyright (C) 2003-2004 by Naoki Saito
+ *             Nagoya Municipal Industrial Research Institute, JAPAN
+ *  Copyright (C) 2003-2004 by Platform Development Center
+ *                                          RICOH COMPANY,LTD. JAPAN
+ *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
+ *  Copyright (C) 2013      by Mitsuhiro Matsuura
+ *  Copyright (C) 2017      by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *		ã¿ã¤ããã©ã¤ãï¼GR-SAKURAç¨ï¼
+ */
+ 
+#ifndef TOPPERS_TARGET_TIMER_H
+#define TOPPERS_TARGET_TIMER_H
+
+#include "gr_sakura.h"
+#include "rx630_kernel_impl.h"
+#include "target_syssvc.h"
+
+/*
+ *  ã¿ã¤ãå²è¾¼ã¿ãã³ãã©ç»é²ã®ããã®å®æ°
+ */
+#define INHNO_TIMER0	INT_CMT0_CMI				/* å²è¾¼ã¿ãã³ãã©çªå· */
+#define INTNO_TIMER0	INT_CMT0_CMI				/* å²è¾¼ã¿çªå· */
+#define INTPRI_TIMER0	-5							/* å²è¾¼ã¿åªå
+åº¦ */
+#define INTATR_TIMER0	(TA_ENAINT | TA_EDGE)		/* å²è¾¼ã¿å±æ§ */
+
+#define INHNO_TIMER1	INT_CMT1_CMI				/* å²è¾¼ã¿ãã³ãã©çªå· */
+#define INTNO_TIMER1	INT_CMT1_CMI				/* å²è¾¼ã¿çªå· */
+#define INTPRI_TIMER1	-5							/* å²è¾¼ã¿åªå
+åº¦ */
+#define INTATR_TIMER1	(TA_ENAINT | TA_EDGE)		/* å²è¾¼ã¿å±æ§ */
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãå²è¾¼ã¿ãã³ãã©ç»é²ã®ããã®å®æ°
+ */
+#define INHNO_TIMER2	INT_CMT2_CMI				/* å²è¾¼ã¿ãã³ãã©çªå· */
+#define INTNO_TIMER2	INT_CMT2_CMI				/* å²è¾¼ã¿çªå· */
+#define INTPRI_TIMER2	-5							/* å²è¾¼ã¿åªå
+åº¦ */
+#define INTATR_TIMER2	(TA_ENAINT | TA_EDGE)		/* å²è¾¼ã¿å±æ§ */
+#define INTNO_OVR_BASE_TIMER	INTNO_TIMER1		/* åºæ¬ã¿ã¤ãã«ä½¿ãã¿ã¤ãå²è¾¼ã¿çªå· */
+#define INTNO_DUMMY_TIMER		255					/* ããã¼ã¿ã¤ãå²è¾¼ã¿çªå· */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  ã¿ã¤ãå¤ã®å
+é¨è¡¨ç¾ã®å
+ */
+typedef uint16_t	CLOCK;
+
+/*
+ *  ã¿ã¤ãå¤ã®å
+é¨è¡¨ç¾ã¨ããªç§åä½ã¨ã®å¤æ
+ *
+ *  1msã®ã¿ã¤ãã¼å²ãè¾¼ã¿ãä½¿ç¨ããã®ã§ãã®ã¯ã­ãã¯ãå®ç¾©ããï¼
+ */
+#define TIMER_CLOCK				(FREQ_PCLK / 8U)		/* PCLK/æä½åå¨æ¯8 = 6MHz */
+#define TO_CLOCK(nume, deno)	((CLOCK)(TIMER_CLOCK * (nume) / (deno)))
+#define	TO_USEC(clock)			((SYSUTM)((clock) * 1000U / TIMER_CLOCK))
+
+/*
+ *  ã³ã³ãã¢ãããã¿ã¤ãã³ã³ã¹ã¿ã³ãã¬ã¸ã¹ã¿ï¼CMCORï¼
+ *
+ *  ã³ã³ãã¢ãããå¨æ
+ *  å¨è¾ºã¢ã¸ã¥ã¼ã«ã¯ã­ãã¯ï¼PCLKï¼48MHzã8åå¨ããã®ã§ï¼
+ *  6ã«ã¦ã³ã = 1us : max 10922.667us
+ */
+#define CMCOR_PERIOD	(0x10000U)
+
+/*
+ * ã«ã¦ã³ã < - > ãã¤ã¯ã­ç§ å¤æå¤
+ * 48MHz / 8 / 1000
+ */
+#define USEC_CONVERT_VALUE	6U
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®ã¿ã¤ãå¨æ
+ *
+ *  2^32 / 6
+ */
+#define TCYC_HRTCNT		715827882U	/* (0x100000000 / 6) = 715827882.667usec */
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®ã«ã¦ã³ãå¤ã®é²ã¿å¹
+
+ */
+#define TSTEP_HRTCNT	1U
+
+/*
+ *  æ§è½è©ä¾¡ç¨ã·ã¹ãã æå»ãåãåºãéã®å¦çæéã®è¦ç©ãå¤ï¼åä½ã¯å
+é¨è¡¨ç¾ï¼
+ */
+#define	GET_TOLERANCE	(100U)	/* å¦çé
+ãã®è¦ç©ãå¤ï¼åä½ã¯å
+é¨è¡¨ç¾ï¼*/
+#define	BEFORE_IREQ(clock) \
+		((clock) >= (TO_CLOCK(TIC_NUME, TIC_DENO) - GET_TOLERANCE))
+
+/*
+ *  ã³ã³ãã¢ãããã¿ã¤ãã³ã³ãã­ã¼ã«ã¬ã¸ã¹ã¿ã®è¨­å®å¤
+ */
+/*
+ *  ã¯ã­ãã¯é¸æããã
+ *
+ *  bit7ã¯äºç´é åã§ãã, æ¸è¾¼ã¿ã¯1åºå®
+ */
+#define CMT_PCLK_DIV_8			(0x0080U)
+#define CMT_PCLK_DIV_32			(0x0081U)
+#define CMT_PCLK_DIV_128		(0x0082U)
+#define CMT_PCLK_DIV_512		(0x0083U)
+
+/*
+ * ã³ã³ãã¢ãããã¿ã¤ãå²ãè¾¼ã¿è¦æ±å
+è¨­å®ã¬ã¸ã¹ã¿iï¼ISELRiï¼ï¼i= å²ãè¾¼ã¿ãã¯ã¿çªå·ï¼
+ */
+#define ICU_ISEL_CPU			(0x00U)
+
+/*
+ *  ã¿ã¤ãã®èµ·åå¦ç
+ *
+ *  ã¿ã¤ããåæåãï¼å¨æçãªã¿ã¤ãå²è¾¼ã¿è¦æ±ãçºçãããï¼
+ */
+extern void	target_timer_initialize(intptr_t exinf);
+
+/*
+ *  ã¿ã¤ãã®åæ­¢å¦ç
+ *
+ *  ã¿ã¤ãã®åä½ãåæ­¢ãããï¼
+ */
+extern void	target_timer_terminate(intptr_t exinf);
+
+/*
+ *  ã¿ã¤ãã¬ã¸ã¹ã¿å¤ã®èª­ã¿åºã
+ */
+Inline uint16_t rx630_cmt_getcount(void)
+{
+	return sil_reh_mem((uint16_t *)CMT0_CMCNT_ADDR);
+}
+
+/*
+ *  ã¿ã¤ãã¬ã¸ã¹ã¿å¤ã®æ¸ãè¾¼ã¿
+ */
+Inline void rx630_cmt_setcount(uint16_t count)
+{
+	sil_wrh_mem(CMT0_CMCNT_ADDR, count);
+}
+
+/*
+ *  ã¿ã¤ãã®ç¾å¨å¤ã®èª­åºã
+ */
+Inline CLOCK
+target_timer_get_current(void)
+{
+	/* ã¢ããã«ã¦ã³ãã®ããã¿ã¤ãã¬ã¸ã¹ã¿å¤ããã®ã¾ã¾è¿ã	*/
+	return (rx630_cmt_getcount());
+}
+
+/*
+ *  ã¿ã¤ãå²è¾¼ã¿è¦æ±ã®ãã§ãã¯
+ */
+Inline bool_t
+target_timer_probe_int(void)
+{
+	return(probe_int(INTNO_TIMER0));
+}
+
+/*
+ *  ã¿ã¤ãå²è¾¼ã¿ãã³ãã©
+ */
+extern void	target_lower_timer_handler(void);
+extern void	target_upper_timer_handler(void);
+
+/*
+ *  å²è¾¼ã¿ã¿ã¤ãã³ã°ã«æå®ããæå¤§å¤
+ */
+#define HRTCNT_BOUND	100000002U
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã¸ã®å²è¾¼ã¿ã¿ã¤ãã³ã°ã®è¨­å®
+ *
+ *  é«åè§£è½ã¿ã¤ããï¼hrtcntã§æå®ããå¤ã«ã¦ã³ãã¢ãããããå²è¾¼ã¿ãçº
+ *  çãããããã«è¨­å®ããï¼
+ */
+extern void target_hrt_set_event(HRTCNT hrtcnt);
+
+/*
+ *  é«åè§£è½ã¿ã¤ãå²è¾¼ã¿ã®è¦æ±
+ */
+extern  void target_hrt_raise_event(void);
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®ç¾å¨ã®ã«ã¦ã³ãå¤ã®èª­åºããå
+é¨å¦ç
+ */
+extern HRTCNT target_hrt_get_current_convert(void);
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®ç¾å¨ã®ã«ã¦ã³ãå¤ã®èª­åºã
+ */
+Inline HRTCNT
+target_hrt_get_current(void)
+{
+	return (target_hrt_get_current_convert());
+}
+
+#ifdef TOPPERS_SUPPORT_OVRHDR
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæåå¦ç
+ */
+extern void target_ovrtimer_initialize(intptr_t exinf);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæ­¢å¦ç
+ */
+extern void target_ovrtimer_terminate(intptr_t exinf);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åä½éå§
+ */
+extern void target_ovrtimer_start(PRCTIM ovrtim);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®åæ­¢
+ */
+extern PRCTIM target_ovrtimer_stop(uint_t int_num);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®ç¾å¨å¤ã®èª­åºã
+ */
+extern PRCTIM target_ovrtimer_get_current(void);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãã®å²è¾¼ã¿ã®è¦æ±
+ */
+extern  void target_ovrtimer_raise_event(void);
+
+/*
+ *  ãªã¼ãã©ã³ã¿ã¤ãå²è¾¼ã¿ãã³ãã©
+ */
+extern void	target_ovrtimer_handler(void);
+
+#endif /* TOPPERS_SUPPORT_OVRHDR */
+
+#endif /* TOPPERS_MACRO_ONLY */
+#endif /* TOPPERS_TARGET_TIMER_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_unrename.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_unrename.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/target_unrename.h	(revision 317)
@@ -0,0 +1,46 @@
+/* This file is generated from target_rename.def by genrename. */
+
+#ifndef TOPPERS_TARGET_RENAME_H
+#define TOPPERS_TARGET_RENAME_H
+
+/*
+ *  target_kernel_impl.c
+ */
+#undef target_initialize
+#undef target_exit
+
+/*
+ *  trace_config.c
+ */
+#undef log_dsp_enter
+#undef log_dsp_leave
+#undef log_inh_enter
+#undef log_inh_leave
+#undef log_exc_enter
+#undef log_exc_leave
+
+
+#ifdef TOPPERS_LABEL_ASM
+
+/*
+ *  target_kernel_impl.c
+ */
+#undef _target_initialize
+#undef _target_exit
+
+/*
+ *  trace_config.c
+ */
+#undef _log_dsp_enter
+#undef _log_dsp_leave
+#undef _log_inh_enter
+#undef _log_inh_leave
+#undef _log_exc_enter
+#undef _log_exc_leave
+
+
+#endif /* TOPPERS_LABEL_ASM */
+
+#include "rx630_gcc/prc_unrename.h"
+
+#endif /* TOPPERS_TARGET_RENAME_H */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.c
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.c	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.c	(revision 317)
@@ -0,0 +1,129 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ã¿ã¼ã²ããä¾å­ã¢ã¸ã¥ã¼ã«ï¼RX63Nç¨ï¼
+ */
+
+#include <sil.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+#include <rx630.h>
+
+#if defined(SUPPORT_ETHER)
+
+/*
+ *  rx62n_bus_init -- ã¿ã¼ã²ããä¾å­é¨ã®ãã¹ã®åæå
+ */
+
+void
+rx62n_bus_init (void)
+{
+	/* ã¤ã¼ãµãããã»ã³ã³ãã­ã¼ã©ã®åä½ãè¨±å¯ */
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA502);	/* æ¸è¾¼ã¿è¨±å¯ */
+	sil_wrw_mem(SYSTEM_MSTPCRB_ADDR,
+		sil_rew_mem(SYSTEM_MSTPCRB_ADDR) & ~SYSTEM_MSTPCRB_MSTPB15_BIT);
+	sil_wrh_mem(SYSTEM_PRCR_ADDR, 0xA500);	/* æ¸è¾¼ã¿ç¦æ­¢ */
+
+	/* EtherNETæå¹ */
+	/* PA3ï½5 RMII_MDIO, RMII_MDC, RMII_LINKSTA */
+	sil_wrb_mem(PORTA_PMR_ADDR,
+		sil_reb_mem(PORTA_PMR_ADDR) | (1 << 3) | (1 << 4) | (1 << 5));
+	/* PB0ï½7 RXD1, RXD0, REF50CK, RX-ER, TXD-EN, TXD0, TXD1, CRS */
+	sil_wrb_mem(PORTB_PMR_ADDR,
+		sil_reb_mem(PORTB_PMR_ADDR) | 0xFF);
+
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® PFSWEãããã¸ã®æ¸ãè¾¼ã¿ãè¨±å¯ */
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x00);
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® PxxFSã¬ã¸ã¹ã¿ã¸ã®æ¸ãè¾¼ã¿ãè¨±å¯ */
+	sil_wrb_mem(MPC_PWPR_ADDR, 0x40);
+
+	/* PA3ãET_MDIOã¨ãã */
+	sil_wrb_mem(MPC_PA3PFS_ADDR, 0x11); 
+	/* PA4ãET_MDCã¨ãã */
+	sil_wrb_mem(MPC_PA4PFS_ADDR, 0x11); 
+	/* PA5ãET_LINKSTAã¨ãã */
+	sil_wrb_mem(MPC_PA5PFS_ADDR, 0x11); 
+
+	/* PB0ãRXD1ã¨ãã */
+	sil_wrb_mem(MPC_PB0PFS_ADDR, 0x12);
+	/* PB1ãRXD0ã¨ãã */
+	sil_wrb_mem(MPC_PB1PFS_ADDR, 0x12);
+	/* PB2ãREF50CKã¨ãã */
+	sil_wrb_mem(MPC_PB2PFS_ADDR, 0x12);
+	/* PB3ãRX-ERã¨ãã */
+	sil_wrb_mem(MPC_PB3PFS_ADDR, 0x12);
+	/* PB4ãTXD-ENã¨ãã */
+	sil_wrb_mem(MPC_PB4PFS_ADDR, 0x12);
+	/* PB5ãTXD0ã¨ãã */
+	sil_wrb_mem(MPC_PB5PFS_ADDR, 0x12);
+	/* PB6ãTXD1ã¨ãã */
+	sil_wrb_mem(MPC_PB6PFS_ADDR, 0x12);
+	/* PB7ãCRSã¨ãã */
+	sil_wrb_mem(MPC_PB7PFS_ADDR, 0x12);
+
+	/* æ¸ãè¾¼ã¿ãã­ãã¯ãã¬ã¸ã¹ã¿ã®è¨­å® æ¸ãè¾¼ã¿ãç¦æ­¢ */
+	sil_wrb_mem(MPC_PWPR_ADDR , 0x80);
+}
+
+/*
+ *  rx62n_inter_init -- ã¿ã¼ã²ããä¾å­é¨ã®å²è¾¼ã¿ã®åæå
+ */
+
+void
+rx62n_inter_init (void)
+{
+}
+
+#endif	/* of #if defined(SUPPORT_ETHER) */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_config.h	(revision 317)
@@ -0,0 +1,548 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_TARGET_CONFIG_H_
+#define _TINET_TARGET_CONFIG_H_
+
+/*
+ *  TCP/IP ã«é¢ããå®ç¾©
+ */
+
+/* TCP ã«é¢ããå®ç¾© */
+
+/*
+ *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
+ *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
+ */
+
+#ifndef MAX_TCP_SND_SEG
+#define MAX_TCP_SND_SEG		(IF_MTU - (IP_HDR_SIZE + TCP_HDR_SIZE))
+#endif	/* of #ifndef MAX_TCP_SND_SEG */
+
+/*
+ *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifndef DEF_TCP_RCV_SEG
+#define DEF_TCP_RCV_SEG		(IF_MTU - (IP_HDR_SIZE + TCP_HDR_SIZE))
+#endif	/* of #ifndef DEF_TCP_RCV_SEG */
+
+/* 
+ *  ã»ã°ã¡ã³ãã®é çªãå
+¥ãæ¿ããã¨ãã«æ°ãã«ãããã¯ã¼ã¯ãããã¡ãå²å½ã¦ã¦ã
+ *  ãã¼ã¿ãã³ãã¼ãããµã¤ãºã®ãããå¤
+ */
+#define MAX_TCP_REALLOC_SIZE	1024	
+
+#define TCP_CFG_OPT_MSS		/* ã³ãã¯ã·ã§ã³éè¨­æã«ãã»ã°ã¡ã³ããµã¤ãºãªãã·ã§ã³ãã¤ãã¦éä¿¡ããã*/
+#define TCP_CFG_DELAY_ACK	/* ACK ãé
+ãããã¨ãã¯ã³ã¡ã³ããå¤ãã			*/
+#define TCP_CFG_ALWAYS_KEEP	/* å¸¸ã«ã­ã¼ãã¢ã©ã¤ãããæã¯ã³ã¡ã³ããå¤ãã		*/
+
+/* UDP ã«é¢ããå®ç¾© */
+
+#define UDP_CFG_IN_CHECKSUM	/* UDP ã®å
+¥åãã§ãã¯ãµã ãè¡ãå ´åã¯ã³ã¡ã³ããå¤ãã	*/
+#define UDP_CFG_OUT_CHECKSUM	/* UDP ã®åºåãã§ãã¯ãµã ãè¡ãå ´åã¯ã³ã¡ã³ããå¤ãã	*/
+
+/* ICMPv4/v6 ã«é¢ããå®ç¾© */
+
+#define ICMP_REPLY_ERROR		/* ICMP ã¨ã©ã¼ã¡ãã»ã¼ã¸ãéä¿¡ããå ´åã¯ã³ã¡ã³ããå¤ãã*/
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+//#define IP4_CFG_FRAGMENT		/* ãã¼ã¿ã°ã©ã ã®åå²ã»åæ§æè¡ãå ´åã¯ã³ã¡ã³ããå¤ãã	*/
+#define NUM_IP4_FRAG_QUEUE	2	/* ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãµã¤ãº			*/
+#define IP4_CFG_FRAG_REASSM_SIZE	4096	/* IPv4 åæ§æãããã¡ãµã¤ãº			*/
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#define NUM_IP6_DAD_COUNT	1	/* éè¤ã¢ãã¬ã¹æ¤åºã§éä¿¡ããè¿é£è¦è«ã®åæ°ã		*/
+					/*  0 ãæå®ããã¨ãéè¤ã¢ãã¬ã¹æ¤åºãè¡ããªãã	*/
+#define NUM_ND6_CACHE_ENTRY	10	/* è¿é£ã­ã£ãã·ã¥ã®ã¨ã³ããªæ°			*/
+
+/*
+ *  IPv6 ç¨ãã¹ãã­ã£ãã·ã¥ã®ã¨ã³ããªæ°ã
+ *  0 ãæå®ããã¨IPv6 ç¨ãã¹ãã­ã£ãã·ã¥ãçµè¾¼ã¾ãªãã
+ */
+#define NUM_IN6_HOSTCACHE_ENTRY	4
+
+#ifdef SUPPORT_ETHER
+
+#define IP6_CFG_AUTO_LINKLOCAL		/* ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã®èªåè¨­å®ãè¡ãå ´åã¯ã³ã¡ã³ããå¤ãã*/
+
+/*
+ *  ãã£ãã©ã«ãã«ã¼ã¿ãªã¹ãã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ãã£ãã©ã«ãã«ã¼ã¿ãªã¹ãã®ã¨ã³ããªæ°ã
+ *  æå¤§å¤ã¯ 16ã0 ãæå®ããã¨ã«ã¼ã¿éç¥ãåä¿¡ããªãã
+ */
+#define NUM_ND6_DEF_RTR_ENTRY		4
+
+/*
+ *  ãã¬ãã£ãã¯ã¹ãªã¹ãã«é¢ããå®ç¾©ã
+ *  æå¤§å¤ã¯ 16ã
+ */
+#define NUM_ND6_PREFIX_ENTRY		4	/*  ãã¬ãã£ãã¯ã¹ãªã¹ãã®ã¨ã³ããªæ°			*/
+
+/*
+ *  èµ·åæã®ã«ã¼ã¿è¦è«åºååæ°ã
+ *  0 ãæå®ããã¨ã«ã¼ã¿è¦è«ãåºåããªãã
+ */
+#define NUM_ND6_RTR_SOL_RETRY	3	
+
+#define IP6_CFG_FRAGMENT		/* ãã¼ã¿ã°ã©ã ã®åå²ã»åæ§æè¡ãå ´åã¯ã³ã¡ã³ããå¤ãã	*/
+#define NUM_IP6_FRAG_QUEUE	2	/* ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãµã¤ãº			*/
+#define IP6_CFG_FRAG_REASSM_SIZE	4096	/* IPv6 åæ§æãããã¡ãµã¤ãº			*/
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  PPPãã¢ãã ã«é¢ããå®ç¾©
+ */
+
+#define MODEM_CFG_DIAL		"ATD"	/* ãã¤ã¢ã«ã³ãã³ãæå­å			*/
+#define MODEM_CFG_RETRY_CNT	3	/* ãã¤ã¢ã«ãªãã©ã¤åæ°			*/
+#define MODEM_CFG_RETRY_WAIT	10000	/* ãã¤ã¢ã«ãªãã©ã¤ã¾ã§ã®å¾
+ã¡æé [ms]	*/
+
+/*
+ *  PPPãHDLC ã«é¢ããå®ç¾©
+ */
+
+#define DEF_LOCAL_ACCM		ULONG_C(0x000a0000)	/* èªåã® ACCMãXON ã¨ XOFF ã®ã¿å¤æ	*/
+#define DEF_REMOTE_ACCM		ULONG_C(0xffffffff)	/* ç¸æã® ACCMãåæå¤ã¯å
+¨ã¦å¤æ		*/
+
+/*
+ *  PPPãLCP ã«é¢ããå®ç¾©
+ */
+
+#define LCP_CFG_MRU		UINT_C(0x0001)	/* MRU					*/
+#define LCP_CFG_ACCM		UINT_C(0x0002)	/* ACCM					*/
+#define LCP_CFG_MAGIC		UINT_C(0x0004)	/* ãã¸ãã¯çªå·				*/
+#define LCP_CFG_PCOMP		UINT_C(0x0008)	/* ãã­ãã³ã«é¨å§ç¸®æ©è½			*/
+#define LCP_CFG_ACCOMP		UINT_C(0x0010)	/* ã¢ãã¬ã¹ã»å¶å¾¡é¨å§ç¸®			*/
+#define LCP_CFG_PAP		UINT_C(0x0020)	/* PAP					*/
+/*#define LCP_CFG_CHAP		UINT_C(0x0040)	   CHAP ã¯å®è£
+äºå®			*/
+
+#ifdef LCP_CFG_MAGIC
+
+#define LCP_ECHO_INTERVAL	(20*NET_TIMER_HZ)	/* ã¤ã³ã¿ã¼ãã«æé		*/
+#define LCP_ECHO_FAILS		9			/* å¤±æé¾å¤			*/
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+/*
+ *  PPPãPAP ã«é¢ããå®ç¾©
+ */
+
+#define DEF_PAP_TIMEOUT		(3*NET_TIMER_HZ)
+#define DEF_PAP_REQTIME		(30*NET_TIMER_HZ)	/* ã¿ã¤ã ã¢ã¦ãå¦çãè¡ãã¨ãã¯ã³ã¡ã³ããå¤ãã*/
+#define MAX_PAP_REXMT		10			/* èªè¨¼è¦æ±ã®æå¤§åéåæ°	*/
+
+/*
+ *  RX63N Ethernet Controler ã«é¢ããå®ç¾©
+ */
+
+#define NUM_IF_RX62N_TXBUF		2	/* éä¿¡ãããã¡æ°			*/
+#define NUM_IF_RX62N_RXBUF		2	/* åä¿¡ãããã¡æ°			*/
+#define IF_RX62N_BUF_PAGE_SIZE	1518	/* ãããã¡ãµã¤ãº */
+
+#define TMO_IF_RX62N_GET_NET_BUF	1	/* [ms]ãåä¿¡ç¨ net_buf ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+					/* [s]ã éä¿¡ã¿ã¤ã ã¢ã¦ã			*/
+#define TMO_IF_RX62N_XMIT		(2*IF_TIMER_HZ)
+
+/*#define IF_RX62N_CFG_ACCEPT_ALL		 ãã«ãã­ã£ã¹ããã¨ã©ã¼ãã¬ã¼ã ãåä¿¡ããã¨ãã¯ã³ã¡ã³ããå¤ãã*/
+
+/*
+ *  ã¤ã¼ãµãããåºåæã«ãNIC ã§ net_buf ãéæ¾ããå ´åã«æå®ããã
+ *
+ *  æ³¨æ: ä»¥ä¸ã®æå®ã¯ãæå®ä¾ã§ãããif_rx62n ã§ã¯ã
+ *        éæ¾ããªãã®ã§ãä»¥ä¸ã®ã³ã¡ã³ããå¤ãã¦ã¯ãªããªãã
+ */
+
+/*#define ETHER_NIC_CFG_RELEASE_NET_BUF*/
+
+/*
+ *  RX63N Ethernet Controller ã«é¢ããå®ç¾©
+ */
+
+#define RX63N_BASE_ADDRESS		ULONG_C(0x00200000)	/* NIC ã®ã¬ã¸ã¹ã¿ãã¼ã¹ã¢ãã¬ã¹ */
+
+#define INHNO_IF_RX62N_TRX	INT_ETH_EINT	/* ãã±ããéåä¿¡ */
+#define INTNO_IF_RX62N_TRX	INT_ETH_EINT	/* ãã±ããéåä¿¡ */
+#define INTATR_IF_RX62N_TRX	(TA_NULL)	/* å²è¾¼ã¿å±æ§	*/
+#define INTPRI_IF_RX62N_TRX	(-1)		/* å²è¾¼ã¿åªå
+åº¦	*/
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+#define NUM_ARP_ENTRY		10			/* ARP ã­ã£ãã·ã¥ã¨ã³ããªæ°	*/
+
+/*
+ *  DHCP ã«é¢ããå®ç¾©
+ *
+ *    ã»æ³¨æ: TINET ã¯ãDHCP ãå®è£
+ãã¦ããªããå¿ç¨ãã­ã°ã©ã ã§ã
+ *            DHCP ã¡ãã»ã¼ã¸ãåä¿¡ããããã®å®ç¾©ã§ããã
+ *            ã¾ããç¾å¨ã¯ IPv4 ã®ã¿æå¹ã§ããã
+ */
+
+/*#define DHCP_CFG					 DHCP ãå¦çããå ´åã¯ã³ã¡ã³ããå¤ãã*/
+
+/*
+ *  Ethernet ã«é¢ããå®ç¾©
+ */
+
+/*#define ETHER_CFG_ACCEPT_ALL		 ãã«ãã­ã£ã¹ããã¨ã©ã¼ãã¬ã¼ã ãåä¿¡ããã¨ãã¯ã³ã¡ã³ããå¤ãã	*/
+/*#define ETHER_CFG_UNEXP_WARNING	 éãµãã¼ããã¬ã¼ã ã®è­¦åãè¡¨ç¤ºããã¨ãã¯ã³ã¡ã³ããå¤ãã		*/
+/*#define ETHER_CFG_802_WARNING		 IEEE 802.3 ãã¬ã¼ã ã®è­¦åãè¡¨ç¤ºããã¨ãã¯ã³ã¡ã³ããå¤ãã		*/
+/*#define ETHER_CFG_MCAST_WARNING	 ãã«ãã­ã£ã¹ãã®è­¦åãè¡¨ç¤ºããã¨ãã¯ã³ã¡ã³ããå¤ãã		*/
+#define ETHER_CFG_MULTICAST			/* ãã«ãã­ã£ã¹ããéåä¿¡ */
+
+/*
+ *  ã¢ãã¬ã¹ãªã¹ãã«é¢ããå®ç¾©ã
+ */
+#define NUM_IN6_IFADDR_ENTRY		5	/*  ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ãªã¹ãã®ã¨ã³ããªæ°		*/
+
+/*
+ *  æ±ç¨ãããã¯ã¼ã¯ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
+ */
+
+/* ãããã¯ã¼ã¯ãããã¡æ° */
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  PPP ã§ã¯ãåä¿¡ç¨ã® ãããã¯ã¼ã¯ãããã¡ã¯ PDU (1502) ãµã¤ãºãå¸¸ã«
+ *  å²ãå½ã¦ãªããã°ãªããªãã®ã§ PDU ãµã¤ãºãå¤ãã«ç¢ºä¿ããã
+ */
+
+#ifndef NUM_MPF_NET_BUF_CSEG
+#define NUM_MPF_NET_BUF_CSEG	2	/* IF + IP + TCPã2 ä»¥ä¸*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_CSEG */
+
+#ifndef NUM_MPF_NET_BUF_64
+#define NUM_MPF_NET_BUF_64	0	/* 64 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_64 */
+
+#ifndef NUM_MPF_NET_BUF_128
+#define NUM_MPF_NET_BUF_128	0	/* 128 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_128 */
+
+#ifndef NUM_MPF_NET_BUF_256
+#define NUM_MPF_NET_BUF_256	0	/* 256 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_256 */
+
+#ifndef NUM_MPF_NET_BUF_512
+#define NUM_MPF_NET_BUF_512	0	/* 512 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_512 */
+
+#ifndef NUM_MPF_NET_BUF_1024
+#define NUM_MPF_NET_BUF_1024	0	/* 1024 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_1024 */
+
+#ifndef NUM_MPF_NET_BUF_IF_PDU
+#define NUM_MPF_NET_BUF_IF_PDU	2	/* IF æå¤§ PDU ãµã¤ãº	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_IF_PDU */
+
+#ifndef NUM_MPF_NET_BUF4_REASSM
+
+#if defined(SUPPORT_INET4) && defined(IP4_CFG_FRAGMENT)
+#define NUM_MPF_NET_BUF4_REASSM	2	/* IPv4 åæ§æãããã¡ãµã¤ãº	*/
+#else
+#define NUM_MPF_NET_BUF4_REASSM	0	/* IPv4 åæ§æãããã¡ãµã¤ãº	*/
+#endif
+
+#endif	/* of #ifndef NUM_MPF_NET_BUF4_REASSM */
+
+#ifndef NUM_MPF_NET_BUF6_REASSM
+
+#if defined(SUPPORT_INET6) && defined(IP6_CFG_FRAGMENT)
+#define NUM_MPF_NET_BUF6_REASSM	2	/* IPv6 åæ§æãããã¡ãµã¤ãº	*/
+#else
+#define NUM_MPF_NET_BUF6_REASSM	0	/* IPv6 åæ§æãããã¡ãµã¤ãº	*/
+#endif
+
+#endif	/* of #ifndef NUM_MPF_NET_BUF6_REASSM */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
+ */
+
+/*
+ *  æ³¨æ!!
+ *
+ *  RX63N Ethernet Controler ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_rx62nï¼ã®æä½å²å½ã¦é·ã¯
+ *  60ï¼ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã®ãã IF + IP +TCP ããã¯
+ *  64 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã®æ¹ãæé©ã§ããã
+ */
+
+#ifndef NUM_MPF_NET_BUF_CSEG
+#define NUM_MPF_NET_BUF_CSEG	0	/* IF + IP + TCP	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_CSEG */
+
+#ifndef NUM_MPF_NET_BUF_64
+#define NUM_MPF_NET_BUF_64	2	/* 64 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_64 */
+
+#ifndef NUM_MPF_NET_BUF_128
+#define NUM_MPF_NET_BUF_128	0	/* 128 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_128 */
+
+#ifndef NUM_MPF_NET_BUF_256
+#define NUM_MPF_NET_BUF_256	0	/* 256 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_256 */
+
+#ifndef NUM_MPF_NET_BUF_512
+#define NUM_MPF_NET_BUF_512	0	/* 512 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_512 */
+
+#if defined(SUPPORT_INET4)
+
+#ifndef NUM_MPF_NET_BUF_IP_MSS
+#define NUM_MPF_NET_BUF_IP_MSS	0	/* IF + 576 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_IP_MSS */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#ifndef NUM_MPF_NET_BUF_1024
+#define NUM_MPF_NET_BUF_1024	0	/* 1024 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_1024 */
+
+#if defined(SUPPORT_INET6)
+
+#ifndef NUM_MPF_NET_BUF_IPV6_MMTU
+#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_IPV6_MMTU */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#ifndef NUM_MPF_NET_BUF_IF_PDU
+#define NUM_MPF_NET_BUF_IF_PDU	4	/* IF æå¤§ PDU ãµã¤ãº	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_IF_PDU */
+
+#ifndef NUM_MPF_NET_BUF4_REASSM
+
+#if defined(SUPPORT_INET4) && defined(IP4_CFG_FRAGMENT)
+#define NUM_MPF_NET_BUF4_REASSM	2	/* IPv4 åæ§æãããã¡ãµã¤ãº	*/
+#else
+#define NUM_MPF_NET_BUF4_REASSM	0	/* IPv4 åæ§æãããã¡ãµã¤ãº	*/
+#endif
+
+#endif	/* of #ifndef NUM_MPF_NET_BUF4_REASSM */
+
+#ifndef NUM_MPF_NET_BUF6_REASSM
+
+#if defined(SUPPORT_INET6) && defined(IP6_CFG_FRAGMENT)
+#define NUM_MPF_NET_BUF6_REASSM	2	/* IPv6 åæ§æãããã¡ãµã¤ãº	*/
+#else
+#define NUM_MPF_NET_BUF6_REASSM	0	/* IPv6 åæ§æãããã¡ãµã¤ãº	*/
+#endif
+
+#endif	/* of #ifndef NUM_MPF_NET_BUF6_REASSM */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_LOOP
+
+#ifndef NUM_MPF_NET_BUF_CSEG
+#define NUM_MPF_NET_BUF_CSEG	2	/* IF + IP + TCP	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_CSEG */
+
+#ifndef NUM_MPF_NET_BUF_64
+#define NUM_MPF_NET_BUF_64	0	/* 64 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_64 */
+
+#ifndef NUM_MPF_NET_BUF_128
+#define NUM_MPF_NET_BUF_128	0	/* 128 ãªã¯ãããã2 ä»¥ä¸	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_128 */
+
+#ifndef NUM_MPF_NET_BUF_256
+#define NUM_MPF_NET_BUF_256	0	/* 256 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_256 */
+
+#ifndef NUM_MPF_NET_BUF_512
+#define NUM_MPF_NET_BUF_512	0	/* 512 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_512 */
+
+#ifndef NUM_MPF_NET_BUF_1024
+#define NUM_MPF_NET_BUF_1024	0	/* 1024 ãªã¯ããã	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_1024 */
+
+#ifndef NUM_MPF_NET_BUF_IF_PDU
+#define NUM_MPF_NET_BUF_IF_PDU	4	/* IF æå¤§ PDU ãµã¤ãº	*/
+#endif	/* of #ifndef NUM_MPF_NET_BUF_IF_PDU */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+/*
+ *  ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬
+ *
+ *  ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬ãè¡ãå ´åã¯ãtinet/include/net/net.h
+ *  ã§å®ç¾©ããã¦ãããã­ãã³ã«è­å¥ãã©ã°ãæå®ããã
+ */
+
+#if 1
+
+#ifdef SUPPORT_INET6
+
+#ifdef SUPPORT_INET4
+
+#define NET_COUNT_ENABLE	(0			\
+				| PROTO_FLG_PPP_HDLC	\
+				| PROTO_FLG_PPP_PAP	\
+				| PROTO_FLG_PPP_LCP	\
+				| PROTO_FLG_PPP_IPCP	\
+				| PROTO_FLG_PPP		\
+				| PROTO_FLG_LOOP	\
+				| PROTO_FLG_ETHER_NIC	\
+				| PROTO_FLG_ETHER	\
+				| PROTO_FLG_IP6		\
+				| PROTO_FLG_ICMP6	\
+				| PROTO_FLG_ND6		\
+				| PROTO_FLG_ARP		\
+				| PROTO_FLG_IP4		\
+				| PROTO_FLG_ICMP4	\
+				| PROTO_FLG_TCP		\
+				| PROTO_FLG_UDP		\
+				| PROTO_FLG_NET_BUF	\
+				)
+
+#else	/* of #ifdef SUPPORT_INET4 */
+
+#define NET_COUNT_ENABLE	(0			\
+				| PROTO_FLG_PPP_HDLC	\
+				| PROTO_FLG_PPP_PAP	\
+				| PROTO_FLG_PPP_LCP	\
+				| PROTO_FLG_PPP_IPCP	\
+				| PROTO_FLG_PPP		\
+				| PROTO_FLG_LOOP	\
+				| PROTO_FLG_ETHER_NIC	\
+				| PROTO_FLG_ETHER	\
+				| PROTO_FLG_IP6		\
+				| PROTO_FLG_ICMP6	\
+				| PROTO_FLG_ND6		\
+				| PROTO_FLG_TCP		\
+				| PROTO_FLG_UDP		\
+				| PROTO_FLG_NET_BUF	\
+				)
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#define NET_COUNT_ENABLE	(0			\
+				| PROTO_FLG_PPP_HDLC	\
+				| PROTO_FLG_PPP_PAP	\
+				| PROTO_FLG_PPP_LCP	\
+				| PROTO_FLG_PPP_IPCP	\
+				| PROTO_FLG_PPP		\
+				| PROTO_FLG_LOOP	\
+				| PROTO_FLG_ETHER_NIC	\
+				| PROTO_FLG_ETHER	\
+				| PROTO_FLG_ARP		\
+				| PROTO_FLG_IP4		\
+				| PROTO_FLG_ICMP4	\
+				| PROTO_FLG_TCP		\
+				| PROTO_FLG_UDP		\
+				| PROTO_FLG_NET_BUF	\
+				)
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#else	/* of #if 0 */
+
+#define NET_COUNT_ENABLE	(0			\
+				)
+
+#endif	/* of #if 0 */
+
+#ifndef TOPPERS_MACRO_ONLY
+
+/*
+ *  é¢æ°
+ */
+
+extern void rx62n_bus_init (void);
+extern void rx62n_inter_init (void);
+
+#endif	/* of #ifndef TOPPERS_MACRO_ONLY */
+
+#endif /* _TINET_TARGET_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_defs.h
===================================================================
--- asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_defs.h	(revision 317)
+++ asp3_gr_sakura/trunk/target/gr_sakura_gcc/tinet_target_defs.h	(revision 317)
@@ -0,0 +1,70 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_TARGET_DEFS_H_
+#define _TINET_TARGET_DEFS_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  CPU ã®ã¢ã©ã¤ã¡ã³ãã«é¢ããå®ç¾©
+ *
+ *  4 ãªã¯ãããåä½ã§ãã¢ã©ã¤ã³ããå¿
+è¦ãããå ´åã¯ 4 ãæå®ããã
+ */
+
+#define CPU_NET_ALIGN		2
+
+#endif /* _TINET_TARGET_DEFS_H_ */
Index: asp3_gr_sakura/trunk/tecs_kernel/init_tecs.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/init_tecs.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/init_tecs.c	(revision 317)
@@ -0,0 +1,13 @@
+/*
+ *		TECSã®åæåå¦ç
+ *
+ *  $Id$
+ */
+
+#include "global_tecsgen.h"
+
+void
+initialize_tecs(void)
+{
+	INITIALIZE_TECS();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/kernel.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/kernel.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/kernel.cdl	(revision 317)
@@ -0,0 +1,818 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015,2016 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		TOPPERS/ASPã«ã¼ãã«ãªãã¸ã§ã¯ã ã³ã³ãã¼ãã³ãè¨è¿°ãã¡ã¤ã«
+ */
+
+/*
+ *  ã«ã¼ãã«ãªãã¸ã§ã¯ãã®ã³ã³ãã¼ãã³ãåã®ããã®ããããã¡ã¤ã«
+ */
+import_C("tecs_kernel.h");
+
+/*
+ *  ã«ã¼ãã«æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sKernel {
+	ER		getExtendedInformation([out] intptr_t *p_exinf);
+
+	ER		sleep(void);
+	ER		sleepTimeout([in] TMO timeout);
+	ER		delay([in] RELTIM delayTime);
+
+	ER		exit(void);
+	ER		disableTerminate(void);
+	ER		enableTerminate(void);
+	bool_t	senseTerminate(void);
+
+	ER		setTime([in] SYSTIM systemTime);
+	ER		getTime([out] SYSTIM *p_systemTime);
+	ER		adjustTime([in] int32_t adjustTime);
+	HRTCNT	fetchHighResolutionTimer(void);
+
+	ER		rotateReadyQueue([in] PRI taskPriority);
+	ER		getTaskId([out] ID *p_taskId);
+	ER		getLoad([in] PRI taskPriority, [out] uint_t *p_load);
+	ER		getNthTask([in] PRI taskPriority, [in] uint_t nth,
+												[out] ID *p_taskID);
+	ER		lockCpu(void);
+	ER		unlockCpu(void);
+	ER		disableDispatch(void);
+	ER		enableDispatch(void);
+	bool_t	senseContext(void);
+	bool_t	senseLock(void);
+	bool_t	senseDispatch(void);
+	bool_t	senseDispatchPendingState(void);
+	bool_t	senseKernel(void);
+	ER		exitKernel(void);
+
+	ER		changeInterruptPriorityMask([in] PRI interruptPriority);
+	ER		getInterruptPriorityMask([out] PRI *p_interruptPriority);
+};
+
+/*
+ *  ã«ã¼ãã«æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siKernel {
+	HRTCNT	fetchHighResolutionTimer(void);
+
+	ER		rotateReadyQueue([in] PRI taskPriority);
+	ER		getTaskId([out]ID *p_taskId);
+	ER		lockCpu(void);
+	ER		unlockCpu(void);
+	bool_t	senseContext(void);
+	bool_t	senseLock(void);
+	bool_t	senseDispatch(void);
+	bool_t	senseDispatchPendingState(void);
+	bool_t	senseKernel(void);
+	ER		exitKernel(void);
+
+	/* CPUä¾å¤ãã³ãã©ä¸­ã§ä½¿ç¨ãã */
+	bool_t	exceptionSenseDispatchPendingState
+						([in] const void *p_exceptionInformation);
+};
+
+/*
+ *  ã«ã¼ãã«ã®ã»ã«ã¿ã¤ã
+ */
+[singleton]
+celltype tKernel {
+	[inline] entry	sKernel		eKernel;
+	[inline] entry	siKernel	eiKernel;
+};
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ãéç¥ãåãåãããã®ã·ã°ããã£
+ */
+[context("non-task")]
+signature siNotificationHandler {
+};
+
+/*
+ *  ã¿ã¹ã¯æ¬ä½ã®ã·ã°ããã£
+ */
+signature sTaskBody {
+	void	main(void);
+};
+
+/*
+ *  ã¿ã¹ã¯æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sTask {
+	ER		activate(void);
+	ER_UINT	cancelActivate(void);
+	ER		getTaskState([out] STAT *p_tskstat);
+	ER		changePriority([in] PRI priority);
+	ER		getPriority([out] PRI *p_priority);
+	ER		refer([out] T_RTSK *pk_taskStatus);
+
+	ER		wakeup(void);
+	ER_UINT	cancelWakeup(void);
+	ER		releaseWait(void);
+	ER		suspend(void);
+	ER		resume(void);
+
+	ER		raiseTerminate(void);
+	ER		terminate(void);
+};
+
+/*
+ *  ã¿ã¹ã¯æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siTask {
+	ER		activate(void);
+	ER		wakeup(void);
+	ER		releaseWait(void);
+};
+
+/*
+ *  ã¿ã¹ã¯ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tTask {
+	[inline] entry	sTask	eTask;
+	[inline] entry	siTask	eiTask;
+	call	sTaskBody	cTaskBody;
+
+	[inline] entry	siNotificationHandler	eiActivateNotificationHandler;
+	[inline] entry	siNotificationHandler	eiWakeUpNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("TSKID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] PRI		priority;
+		[omit] size_t	stackSize;
+	};
+
+	factory {
+		write("tecsgen.cfg",
+				"CRE_TSK(%s, { %s, $cbp$, tTask_start, %s, %s, NULL });",
+									id, attribute, priority, stackSize);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ã»ããã©æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sSemaphore {
+	ER		signal(void);
+	ER		wait(void);
+	ER		waitPolling(void);
+	ER		waitTimeout([in] TMO timeout);
+	ER		initialize(void);
+	ER		refer([out] T_RSEM *pk_semaphoreStatus);
+};
+
+/*
+ *  ã»ããã©æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siSemaphore {
+	ER		signal(void);
+};
+
+/*
+ *  ã»ããã©ã®ã»ã«ã¿ã¤ã
+ */
+celltype tSemaphore {
+	[inline] entry	sSemaphore	eSemaphore;
+	[inline] entry	siSemaphore	eiSemaphore;
+
+	[inline] entry	siNotificationHandler	eiNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("SEMID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] uint_t	initialCount;
+		[omit] uint_t	maxCount = 1;
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_SEM(%s, { %s, %s, %s });",
+								id, attribute, initialCount, maxCount);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ã¤ãã³ããã©ã°æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sEventflag {
+	ER		set([in] FLGPTN setPattern);
+	ER		clear([in] FLGPTN clearPattern);
+	ER		wait([in] FLGPTN waitPattern, [in] MODE waitMode,
+											[out] FLGPTN *p_flagPattern);
+	ER		waitPolling([in] FLGPTN waitPattern, [in] MODE waitMode,
+											[out] FLGPTN *p_flagPattern);
+	ER		waitTimeout([in] FLGPTN waitPattern, [in] MODE waitMode,
+							[out] FLGPTN *p_flagPattern, [in] TMO timeout);
+	ER		initialize(void);
+	ER		refer([out] T_RFLG *pk_eventflagStatus);
+};
+
+/*
+ *  ã¤ãã³ããã©ã°æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siEventflag {
+	ER		set([in] FLGPTN setPattern);
+};
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã»ã«ã¿ã¤ã
+ */
+celltype tEventflag {
+	[inline] entry	sEventflag	eEventflag;
+	[inline] entry	siEventflag	eiEventflag;
+
+	[inline] entry	siNotificationHandler	eiNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("FLGID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] FLGPTN	flagPattern;
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_FLG(%s, { %s, %s });",
+									id, attribute, flagPattern);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sDataqueue {
+	ER 		send([in] intptr_t data);
+	ER 		sendPolling([in] intptr_t data);
+	ER 		sendTimeout([in] intptr_t data, [in] TMO timeout);
+	ER 		sendForce([in] intptr_t data);
+	ER 		receive([out] intptr_t *p_data);
+	ER 		receivePolling([out] intptr_t *p_Data);
+	ER 		receiveTimeout([out] intptr_t *p_data, [in] TMO timeout);
+	ER 		initialize(void);
+	ER 		refer([out] T_RDTQ *pk_dataqueueStatus);
+};
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siDataqueue {
+	ER		sendPolling([in] intptr_t data);
+	ER		sendForce([in] intptr_t data);
+};
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®ã»ã«ã¿ã¤ã
+ */
+celltype tDataqueue {
+	[inline] entry	sDataqueue	eDataqueue;
+	[inline] entry	siDataqueue	eiDataqueue;
+
+	[inline] entry	siNotificationHandler	eiNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("DTQID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] uint_t	dataCount = 1;
+		[omit] void		*dataqueueManagementBuffer = C_EXP("NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_DTQ(%s, { %s, %s, %s });",
+						id, attribute, dataCount, dataqueueManagementBuffer);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sPriorityDataqueue {
+	ER 		send([in] intptr_t data, [in] PRI dataPriority);
+	ER 		sendPolling([in] intptr_t data, [in] PRI dataPriority);
+	ER 		sendTimeout([in] intptr_t data, [in] PRI dataPriority,
+													[in] TMO timeout);
+	ER 		receive([out] intptr_t *p_data, [out] PRI *p_dataPriority);
+	ER 		receivePolling([out] intptr_t *p_data, [out] PRI *p_dataPriority);
+ 	ER 		receiveTimeout([out] intptr_t *p_data, [out] PRI *p_dataPriority,
+													[in] TMO timeout);
+	ER 		initialize(void);
+	ER 		refer([out] T_RPDQ *pk_priorityDataqueueStatus);
+};
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼æä½ã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siPriorityDataqueue {
+	ER		sendPolling([in] intptr_t data, [in] PRI dataPriority);
+};
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ã»ã«ã¿ã¤ã
+ */
+celltype tPriorityDataqueue {
+	[inline] entry	sPriorityDataqueue	ePriorityDataqueue;
+	[inline] entry	siPriorityDataqueue	eiPriorityDataqueue;
+
+	attr {
+		ID				id = C_EXP("PDTQID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] uint_t	dataCount = 1;
+		[omit] PRI		maxDataPriority;
+		[omit] void		*priorityDataqueueManagementBuffer = C_EXP("NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_PDQ(%s, { %s, %s, %s, %s});",
+								id, attribute, dataCount, maxDataPriority,
+								priorityDataqueueManagementBuffer);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ãã¥ã¼ããã¯ã¹æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sMutex {
+	ER		lock(void);
+	ER		lockPolling(void);
+	ER		lockTimeout([in] TMO timeout);
+	ER		unlock(void);
+	ER		initialize(void);
+	ER		refer([out] T_RSEM *pk_mutexStatus);
+};
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã»ã«ã¿ã¤ã
+ */
+celltype tMutex {
+	[inline] entry	sMutex	eMutex;
+
+	attr {
+		ID				id = C_EXP("MTXID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] PRI		ceilingPriority;
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_MTX(%s, { %s, %s });",
+								id, attribute, ceilingPriority);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  åºå®é·ã¡ã¢ãªã¡ã¢ãªãã¼ã«æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[deviate]
+signature sFixedSizeMemoryPool {
+	ER 		get([out] void **p_block);
+	ER 		getPolling([out] void **p_block);
+	ER 		getTimeout([out] void **p_block, [in] TMO timeout);
+	ER 		release([in] const void *block);
+	ER 		initialize(void);
+	ER 		refer([out] T_RMPF *pk_fixedSizeMemoryPoolStatus);
+};
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®ã»ã«ã¿ã¤ã
+ */
+celltype tFixedSizeMemoryPool {
+	[inline] entry	sFixedSizeMemoryPool	eFixedSizeMemoryPool;
+
+	attr {
+		ID				id = C_EXP("MPFID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] uint_t	blockCount;
+		[omit] uint_t	blockSize;
+		[omit] MPF_T	*memoryPool = C_EXP("NULL");
+		[omit] void 	*memoryPoolManagementBuffer = C_EXP("NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_MPF(%s, {%s, %s, %s, %s, %s});",
+								id, attribute, blockCount, blockSize,
+								memoryPool, memoryPoolManagementBuffer);
+	};
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ãã³ãã©æ¬ä½ã®ã·ã°ããã£
+ */
+[context("non-task")]
+signature siHandlerBody {
+	void	main(void);
+};
+
+/*
+ *  ã¿ã¤ã ã¤ãã³ããã³ãã©ãæå®ããããã®ã»ã«ã¿ã¤ã
+ */
+celltype tTimeEventHandler {
+	entry		siNotificationHandler	eiNotificationHandler;
+	[omit] call	siHandlerBody			ciHandlerBody;
+
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+	};
+};
+
+/*
+ *  å¨æéç¥ãæä½ããããã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sCyclic {
+	ER		start(void);
+	ER		stop(void);
+	ER		refer([out]T_RCYC *pk_cyclicHandlerStatus);
+};
+
+/*
+ *  å¨æéç¥ã®ã»ã«ã¿ã¤ã
+ */
+[active, generate(NotifierPlugin,
+	"factory=\"CRE_CYC({{id}}, { {{attribute}}, { {{_handler_params_}} }, "
+	"{{cycleTime}}, {{cyclePhase}} });\", output_file=tecsgen.cfg")]
+celltype tCyclicNotifier {
+	[inline] entry	sCyclic		eCyclic;
+
+	call			siNotificationHandler	ciNotificationHandler;
+	[optional] call siNotificationHandler	ciErrorNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("ALMID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] bool_t	ignoreErrors = false;
+		[omit] RELTIM	cycleTime;
+		[omit] RELTIM	cyclePhase = 0;
+
+		/* å¤æ°ã®è¨­å®ã«ããéç¥ï¼TNFY_SETVARï¼*/
+		[omit] intptr_t *setVariableAddress = 0;
+		[omit] intptr_t setVariableValue = 0;
+
+		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ãã«ããéç¥ï¼TNFY_INCVARï¼*/
+		[omit] intptr_t *incrementedVariableAddress = 0;
+
+		/* ã¤ãã³ããã©ã°ã®ã»ããã«ããéç¥ï¼TNFY_SETFLGï¼*/
+		[omit] FLGPTN flagPattern = 0;
+
+		/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ã«ããéç¥ï¼TNFY_SNDDTQï¼*/
+		[omit] intptr_t dataqueueSentValue = 0;
+
+		/* å¤æ°ã®è¨­å®ã«ããã¨ã©ã¼éç¥ï¼TENFY_SETVARï¼*/
+		[omit] intptr_t *setVariableAddressForError = 0;
+
+		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ãã«ããã¨ã©ã¼éç¥ï¼TENFY_INCVARï¼*/
+		[omit] intptr_t *incrementedVariableAddressForError = 0;
+
+		/* ã¤ãã³ããã©ã°ã®ã»ããã«ããã¨ã©ã¼éç¥ï¼TENFY_SETFLGï¼*/
+		[omit] FLGPTN flagPatternForError = 0;
+	};
+
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  å¨æéç¥ã«ã¦ã¼ã¶ã¼ãã³ãã©ãæå®ããããã®è¤åã»ã«ã¿ã¤ã
+ */
+[active]
+composite tCyclicHandler {
+	entry		sCyclic			eCyclic;
+	[omit] call	siHandlerBody	ciHandlerBody;
+
+	attr {
+		ID				id = C_EXP("ALMID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] RELTIM	cycleTime;
+		[omit] RELTIM	cyclePhase = 0;
+	};
+
+	cell tCyclicNotifier CyclicNotifier {
+		id = composite.id;
+		attribute = composite.attribute;
+		ciNotificationHandler = TimeEventHandler.eiNotificationHandler;
+		cycleTime = composite.cycleTime;
+		cyclePhase = composite.cyclePhase;
+	};
+
+	cell tTimeEventHandler TimeEventHandler {
+		ciHandlerBody => composite.ciHandlerBody;
+	};
+
+	eCyclic => CyclicNotifier.eCyclic;
+};
+
+/*
+ *  ã¢ã©ã¼ã éç¥ãæä½ããããã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sAlarm {
+	ER		start([in] RELTIM alarmTime);
+	ER		stop(void);
+	ER		refer([out]T_RALM *pk_alarmStatus);
+};
+
+/*
+ *  ã¢ã©ã¼ã éç¥ãæä½ããããã®ã·ã°ããã£ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+[context("non-task")]
+signature siAlarm {
+	ER		start([in] RELTIM alarmTime);
+	ER		stop(void);
+};
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®ã»ã«ã¿ã¤ã
+ */
+[active, generate(NotifierPlugin,
+	"factory=\"CRE_ALM({{id}}, { {{attribute}}, {{{_handler_params_}}} });\", "
+	"output_file=tecsgen.cfg")]
+celltype tAlarmNotifier {
+	[inline] entry	sAlarm		eAlarm;
+	[inline] entry	siAlarm		eiAlarm;
+
+	call			siNotificationHandler	ciNotificationHandler;
+	[optional] call	siNotificationHandler	ciErrorNotificationHandler;
+
+	attr {
+		ID				id = C_EXP("ALMID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] bool_t	ignoreErrors = false;
+
+		/* å¤æ°ã®è¨­å®ã«ããéç¥ï¼TNFY_SETVARï¼*/
+		[omit] intptr_t *setVariableAddress = 0;
+		[omit] intptr_t setVariableValue = 0;
+
+		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ãã«ããéç¥ï¼TNFY_INCVARï¼*/
+		[omit] intptr_t *incrementedVariableAddress = 0;
+
+		/* ã¤ãã³ããã©ã°ã®ã»ããã«ããéç¥ï¼TNFY_SETFLGï¼*/
+		[omit] FLGPTN flagPattern = 0;
+
+		/* ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ã«ããéç¥ï¼TNFY_SNDDTQï¼*/
+		[omit] intptr_t dataqueueSentValue = 0;
+
+		/* å¤æ°ã®è¨­å®ã«ããã¨ã©ã¼éç¥ï¼TENFY_SETVARï¼*/
+		[omit] intptr_t *setVariableAddressForError = 0;
+
+		/* å¤æ°ã®ã¤ã³ã¯ãªã¡ã³ãã«ããã¨ã©ã¼éç¥ï¼TENFY_INCVARï¼*/
+		[omit] intptr_t *incrementedVariableAddressForError = 0;
+
+		/* ã¤ãã³ããã©ã°ã®ã»ããã«ããã¨ã©ã¼éç¥ï¼TENFY_SETFLGï¼*/
+		[omit] FLGPTN flagPatternForError = 0;
+	};
+
+	FACTORY {
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã«ã¦ã¼ã¶ã¼ãã³ãã©ãæå®ããããã®è¤åã»ã«ã¿ã¤ã
+ */
+[active]
+composite tAlarmHandler {
+	entry		sAlarm			eAlarm;
+	entry		siAlarm			eiAlarm;
+	[omit] call	siHandlerBody	ciHandlerBody;
+
+	attr {
+		ID			id = C_EXP("ALMID_$id$");
+		[omit] ATR	attribute = C_EXP("TA_NULL");
+	};
+
+	cell tAlarmNotifier AlarmNotifier {
+		id = composite.id;
+		attribute = composite.attribute;
+		ciNotificationHandler = TimeEventHandler.eiNotificationHandler;
+	};
+
+	cell tTimeEventHandler TimeEventHandler {
+		ciHandlerBody => composite.ciHandlerBody;
+	};
+
+	eAlarm => AlarmNotifier.eAlarm;
+	eiAlarm => AlarmNotifier.eiAlarm;
+};
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³æä½ã®ã·ã°ããã£ï¼ã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+signature sInterruptRequest {
+	ER		disable(void);
+	ER		enable(void);
+	ER		clear(void);
+	ER		raise(void);
+	ER_BOOL	probe(void);
+};
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã©ã¤ã³ã®ã»ã«ã¿ã¤ã
+ */
+celltype tInterruptRequest {
+	[inline] entry	sInterruptRequest	eInterruptRequest;
+
+	attr {
+		INTNO			interruptNumber;
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] PRI		interruptPriority;
+	};
+
+	factory {
+		write("tecsgen.cfg", "CFG_INT(%s, { %s, %s });",
+							interruptNumber, attribute, interruptPriority);
+	};
+};
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã¹ã«ã¼ãã³ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tISR {
+	call	siHandlerBody	ciISRBody;
+
+	attr {
+		ID				id = C_EXP("ISRID_$id$");
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+		[omit] INTNO	interruptNumber;
+		[omit] PRI		isrPriority = 1;
+	};
+
+	factory {
+		write("tecsgen.cfg", "CRE_ISR(%s, { %s, $cbp$, %s, tISR_start, %s });",
+								id, attribute, interruptNumber, isrPriority);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+		write("$ct$_factory.h", "#include \"kernel_cfg.h\"");
+	};
+};
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tInterruptHandler {
+	call	siHandlerBody	ciInterruptHandlerBody;
+
+	attr {
+		INHNO			interruptHandlerNumber;
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg",
+				"DEF_INH(%s, { %s, tInterruptHandler_start });", attribute);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+	};
+};
+
+/*
+ *  CPUä¾å¤ãã³ãã©ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tCpuExceptionHandler {
+	call	siHandlerBody	ciCpuExceptionHandlerBody;
+
+	attr {
+		EXCNO			cpuExceptionHandlerNumber;
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg",
+				"DEF_EXC(%s, { %s, tCpuExceptionHandler_start });", attribute);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+	};
+};
+
+/*
+ *  åæåï¼çµäºå¦çã«ã¼ãã³æ¬ä½ã®ã·ã°ããã£
+ */
+signature sRoutineBody {
+	void	main(void);
+};
+
+/*
+ *  åæåã«ã¼ãã³ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tInitializeRoutine {
+	call	sRoutineBody	cInitializeRoutineBody;
+
+	attr {
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg",
+				"ATT_INI({ %s, $cbp$, tInitializeRoutine_start });",
+															attribute);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+	};
+};
+
+/*
+ *  çµäºå¦çã«ã¼ãã³ã®ã»ã«ã¿ã¤ã
+ */
+[active]
+celltype tTerminateRoutine {
+	call	sRoutineBody	cTerminateRoutineBody;
+
+	attr {
+		[omit] ATR		attribute = C_EXP("TA_NULL");
+	};
+
+	factory {
+		write("tecsgen.cfg",
+				"ATT_TER({ %s, $cbp$, tTerminateRoutine_start });", attribute);
+	};
+	FACTORY {
+		write("tecsgen.cfg", "#include \"$ct$_tecsgen.h\"");
+	};
+};
Index: asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier.c	(revision 317)
@@ -0,0 +1,58 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tAlarmNotifier_tecsgen.h"
Index: asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tAlarmNotifier_inline.h	(revision 317)
@@ -0,0 +1,113 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TALARMHANDLER_INLINE_H
+#define TOPPERS_TALARMHANDLER_INLINE_H
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½éå§
+ */
+Inline ER
+eAlarm_start(CELLIDX idx, RELTIM alarmTime)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(sta_alm(ATTR_id, alarmTime));
+}
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½åæ­¢
+ */
+Inline ER
+eAlarm_stop(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(stp_alm(ATTR_id));
+}
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eAlarm_refer(CELLIDX idx, T_RALM* pk_alarmStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_alm(ATTR_id, pk_alarmStatus));
+}
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½éå§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiAlarm_start(CELLIDX idx, RELTIM alarmTime)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ista_alm(ATTR_id, alarmTime));
+}
+
+/*
+ *  ã¢ã©ã¼ã éç¥ã®åä½åæ­¢ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiAlarm_stop(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(istp_alm(ATTR_id));
+}
+
+#endif /* TOPPERS_TALARMHANDLER_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tCpuExceptionHandler.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tCpuExceptionHandler.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tCpuExceptionHandler.c	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tCpuExceptionHandler_tecsgen.h"
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©æ¬ä½ã®å¼åºã
+ */
+void
+tCpuExceptionHandler_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	ciCpuExceptionHandlerBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier.c	(revision 317)
@@ -0,0 +1,58 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tCyclicNotifier_tecsgen.h"
Index: asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tCyclicNotifier_inline.h	(revision 317)
@@ -0,0 +1,93 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TCYCLICHANDLER_INLINE_H
+#define TOPPERS_TCYCLICHANDLER_INLINE_H
+
+/*
+ *  å¨æéç¥ã®åä½éå§
+ */
+Inline ER
+eCyclic_start(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(sta_cyc(ATTR_id));
+}
+
+/*
+ *  å¨æéç¥ã®åä½åæ­¢
+ */
+Inline ER
+eCyclic_stop(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(stp_cyc(ATTR_id));
+}
+
+/*
+ *  å¨æéç¥ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eCyclic_refer(CELLIDX idx, T_RCYC* pk_cyclicHandlerStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_cyc(ATTR_id, pk_cyclicHandlerStatus));
+}
+
+#endif /* TOPPERS_TCYCLICHANDLER_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tDataqueue_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tDataqueue_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tDataqueue_inline.h	(revision 317)
@@ -0,0 +1,173 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TDATAQUEUE_INLINE_H
+#define TOPPERS_TDATAQUEUE_INLINE_H
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+ */
+Inline ER
+eDataqueue_send(CELLIDX idx, intptr_t data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(snd_dtq(ATTR_id, data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eDataqueue_sendPolling(CELLIDX idx, intptr_t data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(psnd_dtq(ATTR_id, data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eDataqueue_sendTimeout(CELLIDX idx, intptr_t data, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(tsnd_dtq(ATTR_id, data, timeout));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®å¼·å¶éä¿¡
+ */
+Inline ER
+eDataqueue_sendForce(CELLIDX idx, intptr_t data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(fsnd_dtq(ATTR_id, data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡
+ */
+Inline ER
+eDataqueue_receive(CELLIDX idx, intptr_t* p_data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(rcv_dtq(ATTR_id, p_data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eDataqueue_receivePolling(CELLIDX idx, intptr_t* p_data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(prcv_dtq(ATTR_id, p_data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eDataqueue_receiveTimeout(CELLIDX idx, intptr_t* p_data, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(trcv_dtq(ATTR_id, p_data, timeout));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®ååæå
+ */
+Inline ER
+eDataqueue_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_dtq(ATTR_id));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eDataqueue_refer(CELLIDX idx, T_RDTQ* pk_dataqueueStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_dtq(ATTR_id, pk_dataqueueStatus));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiDataqueue_sendPolling(CELLIDX idx, intptr_t data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(psnd_dtq(ATTR_id, data));
+}
+
+/*
+ *  ãã¼ã¿ã­ã¥ã¼ã¸ã®å¼·å¶éä¿¡ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiDataqueue_sendForce(CELLIDX idx, intptr_t data)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(fsnd_dtq(ATTR_id,  data));
+}
+
+#endif /* TOPPERS_TDATAQUEUE_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tEventflag_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tEventflag_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tEventflag_inline.h	(revision 317)
@@ -0,0 +1,150 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TEVENTFLAG_INLINE_H
+#define TOPPERS_TEVENTFLAG_INLINE_H
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã»ãã
+ */
+Inline ER
+eEventflag_set(CELLIDX idx, FLGPTN setPattern)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(set_flg(ATTR_id, setPattern));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã¯ãªã¢
+ */
+Inline ER
+eEventflag_clear(CELLIDX idx, FLGPTN clearPattern)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(clr_flg(ATTR_id, clearPattern));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡
+ */
+Inline ER
+eEventflag_wait(CELLIDX idx, FLGPTN waitPattern,
+							MODE waitFlagMode, FLGPTN* p_flagPattern)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(wai_flg(ATTR_id, waitPattern, waitFlagMode, p_flagPattern));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eEventflag_waitPolling(CELLIDX idx, FLGPTN waitPattern,
+							MODE waitFlagMode, FLGPTN* p_flagPattern)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(pol_flg(ATTR_id, waitPattern, waitFlagMode, p_flagPattern));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°å¾
+ã¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eEventflag_waitTimeout(CELLIDX idx, FLGPTN waitPattern,
+				MODE waitFlagMode, FLGPTN* p_flagPattern, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(twai_flg(ATTR_id, waitPattern, waitFlagMode,
+											p_flagPattern, timeout));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ååæå
+ */
+Inline ER
+eEventflag_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_flg(ATTR_id));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eEventflag_refer(CELLIDX idx, T_RFLG* pk_eventflagStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_flg(ATTR_id, pk_eventflagStatus));
+}
+
+/*
+ *  ã¤ãã³ããã©ã°ã®ã»ããï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiEventflag_set(CELLIDX idx, FLGPTN setPattern)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(set_flg(ATTR_id, setPattern));
+}
+
+#endif /* TOPPERS_TEVENTFLAG_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tFixedSizeMemoryPool_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tFixedSizeMemoryPool_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tFixedSizeMemoryPool_inline.h	(revision 317)
@@ -0,0 +1,123 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TFIXEDSIZEMEMORYPOOL_INLINE_H
+#define TOPPERS_TFIXEDSIZEMEMORYPOOL_INLINE_H
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾
+ */
+Inline ER
+eFixedSizeMemoryPool_get(CELLIDX idx, void **p_block)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(get_mpf( ATTR_id, p_block));
+}
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eFixedSizeMemoryPool_getPolling(CELLIDX idx, void **p_block)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(pget_mpf(ATTR_id, p_block));
+}
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®ç²å¾ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eFixedSizeMemoryPool_getTimeout(CELLIDX idx, void **p_block, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(tget_mpf(ATTR_id, p_block, timeout));
+}
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã­ãã¯ã®è¿å´
+ */
+Inline ER
+eFixedSizeMemoryPool_release(CELLIDX idx, const void *block)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(rel_mpf(ATTR_id, (void *) block));
+}
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®ååæå
+ */
+Inline ER
+eFixedSizeMemoryPool_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_mpf(ATTR_id));
+}
+
+/*
+ *  åºå®é·ã¡ã¢ãªãã¼ã«ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eFixedSizeMemoryPool_refer(CELLIDX idx, T_RMPF *pk_fixedSizeMemoryPoolStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_mpf(ATTR_id, pk_memoryPoolFixedSizeStatus));
+}
+
+#endif /* TOPPERS_TFIXEDSIZEMEMORYPOOL_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tISR.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tISR.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tISR.c	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tISR_tecsgen.h"
+
+/*
+ *  å²è¾¼ã¿ãµã¼ãã«ã«ã¼ãã³æ¬ä½ã®å¼åºã
+ */
+void
+tISR_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	ciISRBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tInitializeRoutine.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tInitializeRoutine.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tInitializeRoutine.c	(revision 317)
@@ -0,0 +1,68 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tInitializeRoutine_tecsgen.h"
+
+/*
+ *  åæåã«ã¼ãã³æ¬ä½ã®å¼åºã
+ */
+void  tInitializeRoutine_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	cInitializeRoutineBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tInterruptHandler.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tInterruptHandler.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tInterruptHandler.c	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tInterruptHandler_tecsgen.h"
+
+/*
+ *  å²è¾¼ã¿ãã³ãã©æ¬ä½ã®å¼åºã
+ */
+void
+tInterruptHandler_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	ciInterruptHandlerBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tInterruptRequest_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tInterruptRequest_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tInterruptRequest_inline.h	(revision 317)
@@ -0,0 +1,111 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015-2017 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ *
+ *  $Id$  
+ */
+
+#ifndef TOPPERS_TINTERRUPTREQUEST_INLINE_H
+#define TOPPERS_TINTERRUPTREQUEST_INLINE_H
+
+/*
+ *  å²è¾¼ã¿ã®ç¦æ­¢
+ */
+Inline ER
+eInterruptRequest_disable(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(dis_int(ATTR_interruptNumber));
+}
+
+/*
+ *  å²è¾¼ã¿ã®è¨±å¯
+ */
+Inline ER
+eInterruptRequest_enable(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ena_int(ATTR_interruptNumber));
+}
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ã¯ãªã¢
+ */
+Inline ER
+eInterruptRequest_clear(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(clr_int(ATTR_interruptNumber));
+}
+
+/*
+ *  å²è¾¼ã¿ã®è¦æ±
+ */
+Inline ER
+eInterruptRequest_raise(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ras_int(ATTR_interruptNumber));
+}
+
+/*
+ *  å²è¾¼ã¿è¦æ±ã®ãã§ãã¯
+ */
+Inline ER_BOOL
+eInterruptRequest_probe(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(prb_int(ATTR_interruptNumber));
+}
+
+#endif /* TOPPERS_TINTERRUPTREQUEST_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tKernel_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tKernel_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tKernel_inline.h	(revision 317)
@@ -0,0 +1,466 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TKERNEL_INLINE_H
+#define TOPPERS_TKERNEL_INLINE_H
+
+/*
+ *  èªã¿ã¹ã¯ã®æ¡å¼µæ
+å ±ã®åç
+§
+ */
+Inline ER
+eKernel_getExtendedInformation(intptr_t* p_exinf)
+{
+	return(get_inf(p_exinf));
+}
+
+/*
+ *  èµ·åºå¾
+ã¡
+ */
+Inline ER
+eKernel_sleep(void)
+{
+	return(slp_tsk());
+}
+
+/*
+ *  èµ·åºå¾
+ã¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eKernel_sleepTimeout(TMO timeout)
+{
+	return(tslp_tsk(timeout));
+}
+
+/*
+ *  èªã¿ã¹ã¯ã®é
+å»¶
+ */
+Inline ER
+eKernel_delay(RELTIM delayTime)
+{
+	return(dly_tsk(delayTime));
+}
+
+/*
+ *  èªã¿ã¹ã¯ã®çµäº
+ */
+Inline ER
+eKernel_exit(void)
+{
+	return(ext_tsk());
+}
+
+/*
+ *  ã¿ã¹ã¯çµäºã®ç¦æ­¢
+ */
+Inline ER
+eKernel_disableTerminate(void)
+{
+	return(dis_ter());
+}
+
+/*
+ *  ã¿ã¹ã¯çµäºã®è¨±å¯
+ */
+Inline ER
+eKernel_enableTerminate(void)
+{
+	return(ena_ter());
+}
+
+/*
+ *  ã¿ã¹ã¯çµäºç¦æ­¢ç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eKernel_senseTerminate(void)
+{
+	return(sns_ter());
+}
+
+/*
+ *  ã·ã¹ãã æå»ã®è¨­å®
+ */
+Inline ER
+eKernel_setTime(SYSTIM systemTime)
+{
+	return(set_tim(systemTime));
+}
+
+/*
+ *  ã·ã¹ãã æå»ã®åç
+§
+ */
+Inline ER
+eKernel_getTime(SYSTIM* p_systemTime)
+{
+	return(get_tim(p_systemTime));
+}
+
+/*
+ *  ã·ã¹ãã æå»ã®èª¿æ´
+ */
+Inline ER
+eKernel_adjustTime(int32_t adjustTime)
+{
+	return(adj_tim(adjustTime));
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®åç
+§
+ */
+Inline HRTCNT
+eKernel_fetchHighResolutionTimer(void)
+{
+	return(fch_hrt());
+}
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+é ä½ã®åè»¢
+ */
+Inline ER
+eKernel_rotateReadyQueue(PRI taskPriority)
+{
+	return(rot_rdq(taskPriority));
+}
+
+/*
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯IDã®åç
+§
+ */
+Inline ER
+eKernel_getTaskId(ID *p_taskId)
+{
+	return(get_tid(p_taskId));
+}
+
+/*
+ *  å®è¡ã§ããã¿ã¹ã¯ã®æ°ã®åç
+§
+ */
+Inline ER
+eKernel_getLoad(PRI taskPriority, uint_t* p_load)
+{
+	return(get_lod(taskPriority, p_load));
+}
+
+/*
+ *  æå®ããåªå
+é ä½ã®ã¿ã¹ã¯IDã®åç
+§
+ */
+Inline ER
+eKernel_getNthTask(PRI taskPriority, uint_t nth, ID* p_taskID)
+{
+	return (get_nth(taskPriority, nth, p_taskID));
+}
+/*
+ *  CPUã­ãã¯ç¶æ
+ã¸ã®é·ç§»
+ */
+Inline ER
+eKernel_lockCpu()
+{
+	return(loc_cpu());
+}
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®è§£é¤
+ */
+Inline ER
+eKernel_unlockCpu()
+{
+	return(unl_cpu());
+}
+
+/*
+ *  ãã£ã¹ãããã®ç¦æ­¢
+ */
+Inline ER
+eKernel_disableDispatch()
+{
+	return(dis_dsp());
+}
+
+/*
+ *  ãã£ã¹ãããã®è¨±å¯
+ */
+Inline ER
+eKernel_enableDispatch()
+{
+	return(ena_dsp());
+}
+
+/*
+ *  ã³ã³ãã­ã¹ãã®åç
+§
+ */
+Inline bool_t
+eKernel_senseContext()
+{
+	return(sns_ctx());
+}
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eKernel_senseLock()
+{
+	return(sns_loc());
+}
+
+/*
+ *  ãã£ã¹ãããç¦æ­¢ç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eKernel_senseDispatch()
+{
+	return(sns_dsp());
+}
+
+/*
+ *  ãã£ã¹ãããä¿çç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eKernel_senseDispatchPendingState()
+{
+	return(sns_dpn());
+}
+
+/*
+ *  ã«ã¼ãã«éåä½ç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eKernel_senseKernel()
+{
+	return(sns_ker());
+}
+
+/*
+ *  ã«ã¼ãã«ã®çµäº
+ */
+Inline ER
+eKernel_exitKernel()
+{
+	return(ext_ker());
+}
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®å¤æ´
+ */
+Inline ER
+eKernel_changeInterruptPriorityMask(PRI interruptPriority)
+{
+	return(chg_ipm(interruptPriority));
+}
+
+/*
+ *  å²è¾¼ã¿åªå
+åº¦ãã¹ã¯ã®åç
+§
+ */
+Inline ER
+eKernel_getInterruptPriorityMask(PRI* p_interruptPriority)
+{
+	return(get_ipm(p_interruptPriority));
+}
+
+/*
+ *  é«åè§£è½ã¿ã¤ãã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline HRTCNT
+eiKernel_fetchHighResolutionTimer(void)
+{
+	return(fch_hrt());
+}
+
+/*
+ *  ã¿ã¹ã¯ã®åªå
+é ä½ã®åè»¢ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiKernel_rotateReadyQueue(PRI taskPriority)
+{
+	return(rot_rdq(taskPriority));
+}
+
+/*
+ *  å®è¡ç¶æ
+ã®ã¿ã¹ã¯IDã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiKernel_getTaskId(ID* p_taskId)
+{
+	return(get_tid(p_taskId));
+}
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã¸ã®é·ç§»ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiKernel_lockCpu()
+{
+	return(loc_cpu());
+}
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®è§£é¤ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiKernel_unlockCpu()
+{
+	return(unl_cpu());
+}
+
+/*
+ *  ã³ã³ãã­ã¹ãã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline bool_t
+eiKernel_senseContext()
+{
+	return(sns_ctx());
+}
+
+/*
+ *  CPUã­ãã¯ç¶æ
+ã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline bool_t
+eiKernel_senseLock()
+{
+	return(sns_loc());
+}
+
+/*
+ *  ãã£ã¹ãããç¦æ­¢ç¶æ
+ã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline bool_t
+eiKernel_senseDispatch()
+{
+	return(sns_dsp());
+}
+
+/*
+ *  ãã£ã¹ãããä¿çç¶æ
+ã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline bool_t
+eiKernel_senseDispatchPendingState()
+{
+	return(sns_dpn());
+}
+
+/*
+ *  ã«ã¼ãã«éåä½ç¶æ
+ã®åç
+§ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline bool_t
+eiKernel_senseKernel()
+{
+	return(sns_ker());
+}
+
+/*
+ *  ã«ã¼ãã«ã®çµäºï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiKernel_exitKernel()
+{
+	return(ext_ker());
+}
+
+/*
+ *  CPUä¾å¤çºçæã®ãã£ã¹ãããä¿çç¶æ
+ã®åç
+§
+ */
+Inline bool_t
+eiKernel_exceptionSenseDispatchPendingState(const void *p_exceptionInformation)
+{
+	return(xsns_dpn((void *) p_exceptionInformation));
+}
+
+#endif /* TOPPERS_TKERNEL_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tMutex_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tMutex_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tMutex_inline.h	(revision 317)
@@ -0,0 +1,123 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TMUTEX_INLINE_H
+#define TOPPERS_TMUTEX_INLINE_H
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯
+ */
+Inline ER
+eMutex_lock(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(loc_mtx(ATTR_id));
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eMutex_lockPolling(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ploc_mtx(ATTR_id));
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eMutex_lockTimeout(CELLIDX idx, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ploc_mtx(ATTR_id, timeout));
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ã­ãã¯è§£é¤
+ */
+Inline ER
+eMutex_unlock(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(unl_mtx(ATTR_id));
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ååæå
+ */
+Inline ER
+eMutex_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_mtx(ATTR_id));
+}
+
+/*
+ *  ãã¥ã¼ããã¯ã¹ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eMutex_refer(CELLIDX idx, T_RMTX *pk_mutexStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_mtx(ATTR_id, pk_mutexStatus));
+}
+
+#endif /* TOPPERS_TMUTEX_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tPriorityDataqueue_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tPriorityDataqueue_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tPriorityDataqueue_inline.h	(revision 317)
@@ -0,0 +1,165 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TPRIORITYDATAQUEUE_INLINE_H
+#define TOPPERS_TPRIORITYDATAQUEUE_INLINE_H
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡
+ */
+Inline ER
+ePriorityDataqueue_send(CELLIDX idx, intptr_t data, PRI dataPriority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(snd_pdq(ATTR_id, data, dataPriority));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+ePriorityDataqueue_sendPolling(CELLIDX idx, intptr_t data, PRI dataPriority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(psnd_pdq(ATTR_id, data, dataPriority));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+ePriorityDataqueue_sendTimeout(CELLIDX idx, intptr_t data,
+									PRI dataPriority, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(tsnd_pdq(ATTR_id, data, dataPriority, timeout));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡
+ */
+Inline ER
+ePriorityDataqueue_receive(CELLIDX idx, intptr_t *p_data, PRI *p_dataPriority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(rcv_pdq(ATTR_id, p_data, p_dataPriority));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+ePriorityDataqueue_receivePolling(CELLIDX idx, intptr_t *p_data,
+														PRI *p_dataPriority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(prcv_pdq(ATTR_id, p_data, p_dataPriority));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ããã®åä¿¡ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+ePriorityDataqueue_receiveTimeout(CELLIDX idx, intptr_t *p_data,
+											PRI *p_dataPriority, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(trcv_pdq(ATTR_id, p_data, p_dataPriority, timeout));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ååæå
+ */
+Inline ER
+ePriorityDataqueue_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_pdq(ATTR_id));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã®ç¶æ
+åç
+§
+ */
+Inline ER
+ePriorityDataqueue_refer(CELLIDX idx, T_RPDQ* pk_priorityDataqueueStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_pdq(ATTR_id, pk_priorityDataqueueStatus));
+}
+
+/*
+ *  åªå
+åº¦ãã¼ã¿ã­ã¥ã¼ã¸ã®éä¿¡ï¼ãã¼ãªã³ã°ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiPriorityDataqueue_sendPolling(CELLIDX idx, intptr_t data, PRI dataPriority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(psnd_pdq(ATTR_id, data, dataPriority));
+}
+
+#endif /* TOPPERS_TPRIORITYDATAQUEUE_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tSemaphore_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tSemaphore_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tSemaphore_inline.h	(revision 317)
@@ -0,0 +1,133 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TSEMAPHORE_INLINE_H
+#define TOPPERS_TSEMAPHORE_INLINE_H
+
+/*
+ *  ã»ããã©è³æºã®è¿å´
+ */
+Inline ER
+eSemaphore_signal(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(sig_sem(ATTR_id));
+}
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾
+ */
+Inline ER
+eSemaphore_wait(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(wai_sem(ATTR_id));
+}
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾ï¼ãã¼ãªã³ã°ï¼
+ */
+Inline ER
+eSemaphore_waitPolling(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(pol_sem(ATTR_id));
+}
+
+/*
+ *  ã»ããã©è³æºã®ç²å¾ï¼ã¿ã¤ã ã¢ã¦ãããï¼
+ */
+Inline ER
+eSemaphore_waitTimeout(CELLIDX idx, TMO timeout)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(twai_sem(ATTR_id, timeout));
+}
+
+/*
+ *  ã»ããã©ã®ååæå
+ */
+Inline ER
+eSemaphore_initialize(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ini_sem(ATTR_id));
+}
+
+/*
+ *  ã»ããã©ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eSemaphore_refer(CELLIDX idx, T_RSEM *pk_semaphoreStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_sem(ATTR_id, pk_semaphoreStatus));
+}
+
+/*
+ *  ã»ããã©è³æºã®è¿å´ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiSemaphore_signal(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(sig_sem(ATTR_id));
+}
+
+#endif /* TOPPERS_TSEMAPHORE_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tTask.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tTask.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tTask.c	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tTask_tecsgen.h"
+
+/*
+ *  ã¿ã¹ã¯æ¬ä½ã®å¼åºã
+ */
+void
+tTask_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	cTaskBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tTask_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tTask_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tTask_inline.h	(revision 317)
@@ -0,0 +1,236 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#ifndef TOPPERS_TTASK_INLINE_H
+#define TOPPERS_TTASK_INLINE_H
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·å
+ */
+Inline ER
+eTask_activate(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(act_tsk(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯èµ·åè¦æ±ã®ã­ã£ã³ã»ã«
+ */
+Inline ER_UINT
+eTask_cancelActivate(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(can_act(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯ç¶æ
+ã®åç
+§
+ */
+Inline ER
+eTask_getTaskState(CELLIDX idx, STAT *p_tskstat)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(get_tst(ATTR_id, p_tskstat));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®ãã¼ã¹åªå
+åº¦ã®å¤æ´
+ */
+Inline ER
+eTask_changePriority(CELLIDX idx, PRI priority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(chg_pri(ATTR_id, priority));
+}
+
+/*
+ *  ã¿ã¹ã¯åªå
+åº¦ã®åç
+§
+ */
+Inline ER
+eTask_getPriority(CELLIDX idx, PRI *p_priority)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(get_pri(ATTR_id, p_priority));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®ç¶æ
+åç
+§
+ */
+Inline ER
+eTask_refer(CELLIDX idx, T_RTSK *pk_taskStatus)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ref_tsk(ATTR_id, pk_taskStatus));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·åº
+ */
+Inline ER
+eTask_wakeup(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(wup_tsk(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯èµ·åºè¦æ±ã®ã­ã£ã³ã»ã«
+ */
+Inline ER_UINT
+eTask_cancelWakeup(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(can_wup(ATTR_id));
+}
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã®å¼·å¶è§£é¤
+ */
+Inline ER
+eTask_releaseWait(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(rel_wai(ATTR_id));
+}
+
+/*
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ã¸ã®ç§»è¡
+ */
+Inline ER
+eTask_suspend(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(sus_tsk(ATTR_id));
+}
+
+/*
+ *  å¼·å¶å¾
+ã¡ç¶æ
+ããã®åé
+ */
+Inline ER
+eTask_resume(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(rsm_tsk(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®çµäºè¦æ±ï¼»NGKI3469ï¼½
+ */
+Inline ER
+eTask_raiseTerminate(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ras_ter(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®å¼·å¶çµäº
+ */
+Inline ER
+eTask_terminate(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(ter_tsk(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·åï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiTask_activate(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(act_tsk(ATTR_id));
+}
+
+/*
+ *  ã¿ã¹ã¯ã®èµ·åºï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiTask_wakeup(CELLIDX idx)
+{
+	CELLCB	*p_cellcb= GET_CELLCB(idx);
+	return(iwup_tsk(ATTR_id));
+}
+
+/*
+ *  å¾
+ã¡ç¶æ
+ã®å¼·å¶è§£é¤ï¼éã¿ã¹ã¯ã³ã³ãã­ã¹ãç¨ï¼
+ */
+Inline ER
+eiTask_releaseWait(CELLIDX idx)
+{
+	CELLCB	*p_cellcb = GET_CELLCB(idx);
+	return(irel_wai(ATTR_id));
+}
+
+#endif /* TOPPERS_TTASK_INLINE_H */
Index: asp3_gr_sakura/trunk/tecs_kernel/tTerminateRoutine.c
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tTerminateRoutine.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tTerminateRoutine.c	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+#include "tTerminateRoutine_tecsgen.h"
+
+/*
+ *  çµäºå¦çã«ã¼ãã³æ¬ä½ã®å¼åºã
+ */
+
+void  tTerminateRoutine_start(intptr_t exinf)
+{
+	CELLCB	*p_cellcb = (CELLCB *) exinf;
+
+	cTerminateRoutineBody_main();
+}
Index: asp3_gr_sakura/trunk/tecs_kernel/tecs_kernel.h
===================================================================
--- asp3_gr_sakura/trunk/tecs_kernel/tecs_kernel.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecs_kernel/tecs_kernel.h	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TOPPERS/ASP Kernel
+ *      Toyohashi Open Platform for Embedded Real-Time Systems/
+ *      Advanced Standard Profile Kernel
+ * 
+ *  Copyright (C) 2015 by Ushio Laboratory
+ *              Graduate School of Engineering Science, Osaka Univ., JAPAN
+ *  Copyright (C) 2015,2016 by Embedded and Real-Time Systems Laboratory
+ *              Graduate School of Information Science, Nagoya Univ., JAPAN
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  $Id$
+ */
+
+/*
+ *		ã«ã¼ãã«ãªãã¸ã§ã¯ãã®ã³ã³ãã¼ãã³ãåã®ããã®ããããã¡ã¤ã«
+ */
+
+#include <kernel.h>
+
+extern void	tTask_start(intptr_t exinf);
+
+extern void tTimeEventHandler_start(intptr_t exinf);
+
+extern void tISR_start(intptr_t exinf);
+extern void tInterruptHandler_start(void);
+extern void tCpuExceptionHandler_start(void *p_excinf);
+
+extern void tInitializeRoutine_start(intptr_t exinf);
+extern void tTerminateRoutine_start(intptr_t exinf);
Index: asp3_gr_sakura/trunk/tecsgen/MANIFEST_for_asp3
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/MANIFEST_for_asp3	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/MANIFEST_for_asp3	(revision 317)
@@ -0,0 +1,98 @@
+MANIFEST_for_asp3
+
+tecsgen
+tecsgen.rb
+tecsmerge
+tecsmerge.rb
+
+tecslib/version.rb
+
+tecslib/core/C_parser.tab.rb
+tecslib/core/C_parser.y.rb
+tecslib/core/bnf.tab.rb
+tecslib/core/bnf.y.rb
+tecslib/core/componentobj.rb
+tecslib/core/ctypes.rb
+tecslib/core/expression.rb
+tecslib/core/gen_xml.rb
+tecslib/core/generate.rb
+tecslib/core/location.rb
+tecslib/core/messages.rb
+tecslib/core/optimize.rb
+tecslib/core/plugin.rb
+tecslib/core/pluginModule.rb
+tecslib/core/syntaxobj.rb
+tecslib/core/tecs_lang.rb
+tecslib/core/tecsgen.rb
+tecslib/core/types.rb
+tecslib/core/value.rb
+
+tecslib/messages/messages_console_en_US.rb
+tecslib/messages/messages_console_ja_JP.rb
+tecslib/messages/messages_file_en_US.rb
+tecslib/messages/messages_file_ja_JP.rb
+
+tecslib/plugin/C2TECSBridgePlugin.rb
+tecslib/plugin/CellPlugin.rb
+tecslib/plugin/CelltypePlugin.rb
+tecslib/plugin/DomainPlugin.rb
+tecslib/plugin/Mruby2CBridgePlugin.rb
+tecslib/plugin/MrubyBridgePlugin.rb
+tecslib/plugin/NotifierPlugin.rb
+tecslib/plugin/RPCPlugin.rb
+tecslib/plugin/SignaturePlugin.rb
+tecslib/plugin/TECS2CBridgePlugin.rb
+tecslib/plugin/ThroughPlugin.rb
+tecslib/plugin/TracePlugin.rb
+tecslib/plugin/lib/GenParamCopy.rb
+tecslib/plugin/lib/GenTransparentMarshaler.rb
+
+tecs/tecs.h
+tecs/tecs.xsd
+
+tecs/mruby/TECSPointer.h
+tecs/mruby/TECSStruct.h
+tecs/mruby/mruby.cdl
+tecs/mruby/mrubyInitializer.cdl
+tecs/mruby/mrubyPointers.cdl
+tecs/mruby/mrubyVMs.cdl
+tecs/mruby/nMruby_tBoolPointer.c
+tecs/mruby/nMruby_tCharPointer.c
+tecs/mruby/nMruby_tDouble64Pointer.c
+tecs/mruby/nMruby_tFloat32Pointer.c
+tecs/mruby/nMruby_tInt16Pointer.c
+tecs/mruby/nMruby_tInt32Pointer.c
+tecs/mruby/nMruby_tInt64Pointer.c
+tecs/mruby/nMruby_tInt8Pointer.c
+tecs/mruby/nMruby_tIntPointer.c
+tecs/mruby/nMruby_tLongPointer.c
+tecs/mruby/nMruby_tMruby.c
+tecs/mruby/nMruby_tSCharPointer.c
+tecs/mruby/nMruby_tShortPointer.c
+tecs/mruby/nMruby_tTECSInitializer.c
+tecs/mruby/nMruby_tUCharPointer.c
+tecs/mruby/nMruby_tUInt16Pointer.c
+tecs/mruby/nMruby_tUInt32Pointer.c
+tecs/mruby/nMruby_tUInt64Pointer.c
+tecs/mruby/nMruby_tUInt8Pointer.c
+tecs/mruby/nMruby_tUIntPointer.c
+tecs/mruby/nMruby_tULongPointer.c
+tecs/mruby/nMruby_tUShortPointer.c
+tecs/mruby/tMruby.cdl
+tecs/mruby/tecs_mruby.h
+
+tecs/posix/posix.cdl
+
+tecs/rpc/PPAllocator.cdl
+tecs/rpc/RPCTask.cdl
+tecs/rpc/TDR.cdl
+tecs/rpc/rpc.cdl
+tecs/rpc/rpc_string.h
+tecs/rpc/sChannel.cdl
+tecs/rpc/sRPCErrorHandler.cdl
+tecs/rpc/tDataqueueAdaptor_inline.h
+tecs/rpc/tDataqueueOWChannel.cdl
+tecs/rpc/tPPAllocator.c
+tecs/rpc/tRPCDedicatedTaskMain.c
+tecs/rpc/tTDR_inline.h
+tecs/rpc/tecs_rpc.h
Index: asp3_gr_sakura/trunk/tecsgen/MANIFEST_tecsgen_body
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/MANIFEST_tecsgen_body	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/MANIFEST_tecsgen_body	(revision 317)
@@ -0,0 +1,138 @@
+MANIFEST_tecsgen_body
+
+Makefile
+
+tecsgen
+tecsgen.rb
+tecsmerge
+tecsmerge.rb
+tecslib/version.rb
+
+tecslib/core/C_parser.tab.rb
+tecslib/core/C_parser.y.rb
+tecslib/core/bnf.tab.rb
+tecslib/core/bnf.y.rb
+tecslib/core/componentobj.rb
+tecslib/core/ctypes.rb
+tecslib/core/expression.rb
+tecslib/core/gen_xml.rb
+tecslib/core/generate.rb
+tecslib/core/location.rb
+tecslib/core/messages.rb
+tecslib/core/optimize.rb
+tecslib/core/plugin.rb
+tecslib/core/pluginModule.rb
+tecslib/core/syntaxobj.rb
+tecslib/core/tecs_lang.rb
+tecslib/core/tecsgen.rb
+tecslib/core/types.rb
+tecslib/core/value.rb
+
+tecslib/messages/messages_console_en_US.rb
+tecslib/messages/messages_console_ja_JP.rb
+tecslib/messages/messages_file_en_US.rb
+tecslib/messages/messages_file_ja_JP.rb
+
+tecslib/plugin/ATK1AlarmPlugin.rb
+tecslib/plugin/ATK1DelayTaskPlugin.rb
+tecslib/plugin/ATK1EventPlugin.rb
+tecslib/plugin/ATK1ISRPlugin.rb
+tecslib/plugin/ATK1KernelPlugin.rb
+tecslib/plugin/ATK1ResourcePlugin.rb
+tecslib/plugin/ATK1TaskPlugin.rb
+tecslib/plugin/C2TECSBridgePlugin.rb
+tecslib/plugin/CellPlugin.rb
+tecslib/plugin/CelltypePlugin.rb
+tecslib/plugin/DomainPlugin.rb
+tecslib/plugin/HRP2AlarmHandlerPlugin.rb
+tecslib/plugin/HRP2Cache.rb
+tecslib/plugin/HRP2CyclicHandlerPlugin.rb
+tecslib/plugin/HRP2DataqueuePlugin.rb
+tecslib/plugin/HRP2EventflagPlugin.rb
+tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb
+tecslib/plugin/HRP2HandlerPlugin.rb
+tecslib/plugin/HRP2KernelObjectPlugin.rb
+tecslib/plugin/HRP2ObjectPlugin.rb
+tecslib/plugin/HRP2Plugin.rb
+tecslib/plugin/HRP2PostHook.rb
+tecslib/plugin/HRP2PriorityDataqueuePlugin.rb
+tecslib/plugin/HRP2RPCPlugin.rb
+tecslib/plugin/HRP2SVCPlugin.rb
+tecslib/plugin/HRP2SemaphorePlugin.rb
+tecslib/plugin/HRP2TaskPlugin.rb
+tecslib/plugin/Mruby2CBridgePlugin.rb
+tecslib/plugin/MrubyBridgePlugin.rb
+tecslib/plugin/NotifierPlugin.rb
+tecslib/plugin/OpaqueMarshalerPlugin.rb
+tecslib/plugin/OpaqueRPCPlugin.rb
+tecslib/plugin/RPCPlugin.rb
+tecslib/plugin/SharedOpaqueRPCPlugin.rb
+tecslib/plugin/SharedRPCPlugin.rb
+tecslib/plugin/SignaturePlugin.rb
+tecslib/plugin/TECS2CBridgePlugin.rb
+tecslib/plugin/ThroughPlugin.rb
+tecslib/plugin/TracePlugin.rb
+tecslib/plugin/lib/GenHRP2Marshaler.rb
+tecslib/plugin/lib/GenOpaqueMarshaler.rb
+tecslib/plugin/lib/GenParamCopy.rb
+tecslib/plugin/lib/GenTransparentMarshaler.rb
+
+tecs/mruby/TECSPointer.h
+tecs/mruby/TECSStruct.h
+tecs/mruby/mruby.cdl
+tecs/mruby/mrubyInitializer.cdl
+tecs/mruby/mrubyPointers.cdl
+tecs/mruby/mrubyVMs.cdl
+tecs/mruby/nMruby_tBoolPointer.c
+tecs/mruby/nMruby_tCharPointer.c
+tecs/mruby/nMruby_tDouble64Pointer.c
+tecs/mruby/nMruby_tFloat32Pointer.c
+tecs/mruby/nMruby_tInt16Pointer.c
+tecs/mruby/nMruby_tInt32Pointer.c
+tecs/mruby/nMruby_tInt64Pointer.c
+tecs/mruby/nMruby_tInt8Pointer.c
+tecs/mruby/nMruby_tIntPointer.c
+tecs/mruby/nMruby_tLongPointer.c
+tecs/mruby/nMruby_tMruby.c
+tecs/mruby/nMruby_tMrubyProc.c
+tecs/mruby/nMruby_tMrubyProc_1_0.c
+tecs/mruby/nMruby_tSCharPointer.c
+tecs/mruby/nMruby_tShortPointer.c
+tecs/mruby/nMruby_tTECSInitializer.c
+tecs/mruby/nMruby_tUCharPointer.c
+tecs/mruby/nMruby_tUInt16Pointer.c
+tecs/mruby/nMruby_tUInt32Pointer.c
+tecs/mruby/nMruby_tUInt64Pointer.c
+tecs/mruby/nMruby_tUInt8Pointer.c
+tecs/mruby/nMruby_tUIntPointer.c
+tecs/mruby/nMruby_tULongPointer.c
+tecs/mruby/nMruby_tUShortPointer.c
+tecs/mruby/tMruby.cdl
+tecs/mruby/tecs_mruby.h
+tecs/posix/posix.cdl
+tecs/rpc/PPAllocator.cdl
+tecs/rpc/RPCTask.cdl
+tecs/rpc/TDR.cdl
+tecs/rpc/rpc.cdl
+tecs/rpc/rpc_string.h
+tecs/rpc/sChannel.cdl
+tecs/rpc/sRPCErrorHandler.cdl
+tecs/rpc/tDataqueueAdaptor_inline.h
+tecs/rpc/tDataqueueOWChannel.cdl
+tecs/rpc/tNBOTDR_inline.h
+tecs/rpc/tPPAllocator.c
+tecs/rpc/tRPCDedicatedTaskMain.c
+tecs/rpc/tRPCDedicatedTaskMainWithOpener.c
+tecs/rpc/tRPCSharedChannelMan.c
+tecs/rpc/tRPCSharedTaskMain.c
+tecs/rpc/tRPCSharedTaskMainWithOpener.c
+tecs/rpc/tSocketChannel.cdl
+tecs/rpc/tSocketClient.c
+tecs/rpc/tSocketServer.c
+tecs/rpc/tTDR_inline.h
+tecs/rpc/tTINETChannel.cdl
+tecs/rpc/tTINETClient.c
+tecs/rpc/tTINETServer.c
+tecs/rpc/tecs_rpc.h
+tecs/tecs.h
+tecs/tecs.xsd
Index: asp3_gr_sakura/trunk/tecsgen/Makefile
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/Makefile	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/Makefile	(revision 317)
@@ -0,0 +1,169 @@
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2013 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: Makefile 84 2008-05-04 14:19:09Z okuma-top $
+#++
+
+LIB_PATH= tecslib/core
+PLUGIN_PATH= tecslib/plugin
+GEN_SRC =   tecsgen.rb\
+  $(LIB_PATH)/bnf.tab.rb\
+  $(LIB_PATH)/bnf.y.rb\
+  $(LIB_PATH)/componentobj.rb\
+  $(LIB_PATH)/ctypes.rb\
+  $(LIB_PATH)/C_parser.tab.rb\
+  $(LIB_PATH)/C_parser.y.rb\
+  $(LIB_PATH)/expression.rb\
+  $(LIB_PATH)/generate.rb\
+  $(LIB_PATH)/messages.rb\
+  $(LIB_PATH)/optimize.rb\
+  $(LIB_PATH)/pluginModule.rb\
+  $(LIB_PATH)/syntaxobj.rb\
+  $(LIB_PATH)/types.rb\
+  $(LIB_PATH)/value.rb\
+  tecslib/version.rb
+
+PLUGIN_SRC = \
+  $(PLUGIN_PATH)/CellPlugin.rb\
+  $(PLUGIN_PATH)/CelltypePlugin.rb\
+  $(PLUGIN_PATH)/lib/GenTransparentMarshaler.rb\
+  $(PLUGIN_PATH)/lib/GenOpaqueMarshaler.rb\
+  $(PLUGIN_PATH)/lib/GenParamCopy.rb\
+  $(PLUGIN_PATH)/OpaqueRPCPlugin.rb\
+  $(PLUGIN_PATH)/RPCPlugin.rb\
+  $(PLUGIN_PATH)/SharedRPCPlugin.rb\
+  $(PLUGIN_PATH)/SignaturePlugin.rb\
+  $(PLUGIN_PATH)/ThroughPlugin.rb\
+  $(PLUGIN_PATH)/TracePlugin.rb
+
+
+BNF = $(LIB_PATH)/bnf.y.rb
+GEN_TAB =  $(LIB_PATH)/bnf.tab.rb
+GEN_TAB_DEB =  $(LIB_PATH)/bnf-deb.tab.rb
+C_PARSER = $(LIB_PATH)/C_parser.y.rb
+C_TAB = $(LIB_PATH)/C_parser.tab.rb
+EXERB_EXE = tecsgen.exe
+EXERB_EXY = tecsgen.exy
+
+all: generator
+
+debug : yydebug
+
+generator : $(GEN_TAB) $(GEN_SRC) $(PLUGIN_SRC) $(C_TAB)
+
+clean : clean2
+	rm -f $(GEN_TAB) $(GEN_TAB_DEB) $(C_TAB)
+
+clean2 :
+	rm -f $(LIB_PATH)/bnf.output $(LIB_PATH)/C_parser.output
+	rm -rf rdoc
+
+real_clean : clean
+	rm -f $(EXERB_EXE)
+
+$(GEN_TAB) : $(BNF)
+	racc -O -v $(BNF)
+
+$(C_TAB) : $(C_PARSER)
+	racc -O -v $(C_PARSER)
+
+yydebug : $(GEN_TAB_DEB)
+
+$(GEN_TAB_DEB) : $(BNF) $(GEN_SRC) $(PLUGIN_SRC)
+	racc -v -g -o $(GEN_TAB_DEB) $(BNF)	# yydebug ãæå¹ã«ãã
+
+# exerb : $(EXERB_EXE)
+exerb :
+	@echo "!!! please build using ActiveScriptRuby !!!"
+	exit 1
+
+# $(EXERB_EXE) : $(EXERB_EXY) $(GEN_SRC) $(PLUGIN_SRC)
+#	exerb  $(EXERB_EXY)
+# tecsgen.exy.ini ãã tecsgen.exy ãçæããã®ã¯ util/release.sh ã«ããè¡ããã
+# MANIFEST ã«è¨è¼ã®ãã¼ã¸ã§ã³çªå·ããtecsgen.exy.ini ã®æå­åç½®æã«ãããåãè¾¼ã¾ãã
+
+exerb_check : $(EXERB_EXE)
+
+$(EXERB_EXE) : $(EXERB_EXY) $(GEN_SRC) $(PLUGIN_SRC)
+	@echo "### Need make_tecsgen_exerb on ActiveScriptRuby to update tecsgen.exerb ###"
+
+print_error :	# ã¨ã©ã¼ã¡ãã»ã¼ã¸ãæ¾ãåºã
+	grep -e "Generator\.error" -e cdl_error $(LIB_PATH)/*.rb \
+		| grep -v bnf.tab.rb \
+		| sed -e "s/\s*Generator\.error(/  /" -e "s/\s*cdl_error(//" -e "s/).*$$//"
+
+print_error2 :	# ã¨ã©ã¼ã¡ãã»ã¼ã¸ãæ¾ãåºã
+	grep '[^A-Z][A-VXYZ][0-9][0-9][0-9][0-9]' $(LIB_PATH)/*.rb \
+		| grep -v bnf.tab.rb \
+		| grep -v '^Makefile' \
+		| sed -e "s/.*\([A-Z][0-9][0-9][0-9][0-9].*\)/\1/" \
+		| sed -e 's/\(.*\)".*/\1/'
+
+print_warning : # ã¦ã©ã¼ãã³ã°ã¡ãã»ã¼ã¸ãæ¾ãåºã
+	grep -e 'Generator\.warning' -e cdl_warning $(LIB_PATH)/*.rb \
+		| grep -v bnf.tab.rb \
+		| sed -e "s/\s*Generator\.warning(/  /" -e "s/).*$$//"
+
+print_expr_token :
+	# Expression ã«å«ã¾ãããã¼ã¯ã³ãæ¾ãåºã
+	# OP_... ããå¾ãã¯å¼ã¨ã¯é¢ä¿ãªããã¼ã¯ã³
+	grep ':[A-Z]' bnf.y.rb | sed -e 's/.*\(:[A-Z]\w*\).*/\1/'
+
+print_mikan : # è¨­è¨æªå®é¨åãæ¾ãåºã
+	grep mikan $(LIB_PATH)/*.rb 
+
+print_def :
+	grep -e '^ *def' -e '^ *class' $(LIB_PATH)/*.rb | grep -v bnf.tab.rb
+
+print_class :
+	grep '^ *class' $(LIB_PATH)/*.rb | grep -v bnf.tab.rb
+
+rdoc :
+	rdoc --charset euc --op rdoc $(GEN_SRC) $(PLUGIN_SRC)
Index: asp3_gr_sakura/trunk/tecsgen/in_exerb.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/in_exerb.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/in_exerb.rb	(revision 317)
@@ -0,0 +1,131 @@
+# coding: utf-8
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2015 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: in_exerb.rb 2509 2016-01-13 11:04:38Z okuma-top $
+#++
+
+# exerb çã§æåã«èª­ã¿ãã¾ãããã¡ã¤ã«
+# ãã®ãã¡ã¤ã«ãã generate.rb ãèª­ã¿ãã¾ãã
+
+$IN_EXERB=true
+
+# ãã®å¤æ°ã¯ exerb çã®ã¿
+$path = ENV[ 'PATH' ]
+
+#=== cygwin ã®ãã¹ã Windows ãã¹ã«å¤æ
+# cygpath ã³ãã³ããæ¢ãã¦ãè¦ã¤ããã°å¤æãã
+# å¤æã§ããªãã£ããã¾ãã¯å¤æå¾ã®ãã¹ãè¦ã¤ãããªãå ´åãdefault ãè¿ã
+def cygpath( path, default = nil )
+  if ! $IN_EXERB then
+    return default
+  end
+  if File.exist? path then
+    return default
+  end
+
+  found = false
+  $path.split( ";" ).each{ |path2|
+    cygpath_path = "#{path2}\\cygpath.exe"
+    if File.exist?( cygpath_path )  then
+      path3 = nil
+      dbgPrint "in_exerb: cygpath: found\n"
+      IO.popen( "cygpath -m #{path}", "r"){ |io|
+        path3 = io.gets.chomp!
+      }
+      dbgPrint "in_exerb: cygpath: '#{path}' => '#{path3}'\n"
+      # File.stat( path3.to_s )
+
+      if File.exist?( path3 )
+        dbgPrint "in_exerb: cygpath: '#{path3}' found\n"
+        return path3
+      else
+        break
+      end
+    end
+  }
+  dbgPrint "cygpath '#{path}' not found\n"
+  return default
+end
+
+# gcc ã®ãã¹ãè¨­å®ãã
+#  cygwin ã®ãããã¼ã¸ã§ã³ã§ã¯ gcc ã¯ gcc-3.exe ã¾ãã¯ gcc-4.exe ã¸ã®ã·ã³ããªãã¯ãªã³ã¯ã¨ãªã£ã¦ãã
+#  exerb çã§ã¯ã·ã³ããªãã¯ãªã³ã¯ãè¾¿ããªããã gcc ã® exe ãæ¢ã
+#  cygwin ã®ãªã³ã¯ã¯ãã·ã¹ãã å±æ§ãä»ããããã³ãã³ããã­ã³ããä¸ã§ã¯ dir /A:S ãæå®ããªãã¨è¡¨ç¤ºãããªã
+#  (cygwin ã®ãã¼ã¸ã§ã³ã§å®è£
+ãç°ãªããããããªã)
+#  ãã¡ã¤ã«ã®å
+é ­2ãã¤ããèª­åºã PE ãã©ã¼ãããã®ãã¸ãã¯ã«ä¸è´ãããèª¿ã¹ã
+$gcc = "gcc"
+$path.split( ";" ).each{ |path|
+  found = false
+  [ "gcc.exe", "gcc-3.exe", "gcc-4.exe" ].each{ |gcc|
+    gcc_path = "#{path}\\#{gcc}"
+    if File.exist?( gcc_path )  then
+      begin
+        magic = File.read( gcc_path, 2 )
+        if magic == "MZ"                  # ãã¸ãã¯ããã§ãã¯
+          $gcc = gcc
+          found = true
+          break
+        end
+      rescue
+        # magic ã®èª­åºãã«å¤±æãç¡è¦
+      end
+    end
+  }
+  break if found
+}
+
+# cpp ã³ãã³ããè¨­å®ãã
+$cpp = "#{$gcc} -E -D TECSGEN"
+
+# exerb ç TECS ã¸ã§ãã¬ã¼ã¿ã®å®è¡ãéå§
+require "tecsgen.rb"
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSPointer.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSPointer.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSPointer.h	(revision 317)
@@ -0,0 +1,600 @@
+/*
+ *  mruby => TECS brige
+ *  
+ *   Copyright (C) 2008-2012 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$ 
+ */
+
+#ifndef TECSPointer_h__
+#define TECSPointer_h__
+
+#include <string.h>
+#include <stdint.h>
+#include <limits.h>
+
+#ifndef CHAR_T_DEFINED
+typedef	int		bool_t;
+typedef	char	char_t;
+typedef	double	double64_t;
+typedef	float	float32_t;
+#endif /* CHAR_T_DEFINED */
+
+////  define Pointer classes ////
+#define POINTER_BODY( Type, TYPE )										\
+																		\
+	struct Type ## PointerBody {										\
+		uint32_t	length;												\
+		TYPE 		buf[ /* length */ ];								\
+	};
+
+
+// struct TypePointerBody
+POINTER_BODY( Bool,  bool_t )		/* struct BoolPointerBody */
+POINTER_BODY( Double64, double64_t )/* struct Double64PointerBody */
+POINTER_BODY( Float32, float32_t )	/* struct Float32PointerBody */
+
+POINTER_BODY( Int8,  int8_t )		/* struct Int8PointerBody */
+POINTER_BODY( Int16, int16_t )		/* struct Int16PointerBody */
+POINTER_BODY( Int32, int32_t )		/* struct Int32PointerBody */
+POINTER_BODY( Int64, int64_t )		/* struct Int64PointerBody */
+POINTER_BODY( Char,  char_t )		/* struct CharPointerBody */
+POINTER_BODY( Int,   int )			/* struct IntPointerBody */
+POINTER_BODY( Short, short )		/* struct ShortPointerBody */
+POINTER_BODY( Long,  long )			/* struct LongPointerBody */
+
+POINTER_BODY( UInt8,  uint8_t )		/* struct UInt8PointerBody */
+POINTER_BODY( UInt16, uint16_t )	/* struct UInt16PointerBody */
+POINTER_BODY( UInt32, uint32_t )	/* struct UInt32PointerBody */
+POINTER_BODY( UInt64, uint64_t )	/* struct UInt64PointerBody */
+POINTER_BODY( UChar,  uint8_t )		/* struct UCharPointerBody */
+POINTER_BODY( UInt,   unsigned int )	/* struct UIntPointerBody */
+POINTER_BODY( UShort, unsigned short )	/* struct UShortPointerBody */
+POINTER_BODY( ULong,  unsigned long )	/* struct ULongPointerBody */
+
+POINTER_BODY( SChar,  char_t )		/* struct SCharPointerBody */
+
+// â  TECS_NO_VAL_CHECK ã define ããã¨ãå¤ãã§ãã¯ãçç¥ãã
+#ifndef TECS_NO_VAL_CHECK
+#define	VALCHECK_INT(Type, TYPE, type )									\
+	/*  check before assigning mrb_int val to intN_t */					\
+	static inline void													\
+	VALCHECK_ ## Type( mrb_state *mrb, mrb_int val )					\
+	{																	\
+		if( sizeof( mrb_int ) > sizeof( type ) ){						\
+			if( val > TYPE ## _MAX || val < TYPE ## _MIN ) 				\
+				mrb_raise(mrb, E_ARGUMENT_ERROR, "too large or too small for "  #type "_t"); \
+		}																\
+	}
+#define	VALCHECK_MRB_INT(Type, TYPE, type )								\
+	/*  check before assigning val (intN_t) to mrb_int */				\
+	static inline void													\
+	VALCHECK_MRB_ ## Type( mrb_state *mrb, type val )					\
+	{																	\
+		if( sizeof( type ) > sizeof( mrb_int ) ){						\
+			if( val >= (((type)1) << (sizeof(mrb_int)*8-1))				\
+				|| val < -(((type)1) << (sizeof(mrb_int)*8-1)) )		\
+				/* '=' unecessary for negative value	*/				\
+				/* ignore warning on int32_t */							\
+				mrb_raise(mrb, E_ARGUMENT_ERROR, "too large or too small for mrb_int"); \
+		}																\
+	}
+
+#define	VALCHECK_UINT(Type, TYPE, type )								\
+	/*  check before assigning mrb_int val to intN_t */					\
+	static inline void													\
+	VALCHECK_ ## Type( mrb_state *mrb, mrb_int  val )					\
+	{																	\
+		if( sizeof( mrb_int ) > sizeof( type ) ){						\
+			if( val > TYPE ## _MAX || val < 0 ) 						\
+				mrb_raise(mrb, E_ARGUMENT_ERROR, "too large or too small for "  #type "_t"); \
+		}																\
+	}
+#define	VALCHECK_MRB_UINT(Type, TYPE, type )							\
+	/*  check before assigning val (intN_t) to mrb_int */				\
+	static inline void													\
+	VALCHECK_MRB_ ## Type( mrb_state *mrb, type val )					\
+	{																	\
+		if( sizeof( type ) > sizeof( mrb_int ) ){						\
+			if( val >= (((type)1) << (sizeof(mrb_int)*8)))				\
+				/* '=' unecessary for negative value	*/				\
+				/* ignore warning on int32_t */							\
+				mrb_raise(mrb, E_ARGUMENT_ERROR, "too large or too small for mrb_int"); \
+		}																\
+	}
+#else // TECS_NO_VAL_CHECK
+
+#define	VALCHECK_INT(Type, TYPE, type )
+#define	VALCHECK_UINT(Type, TYPE, type )
+
+#endif // TECS_NO_VAL_CHECK
+
+// define VALCHECK function
+#define VALCHECK_Bool( mrb, val )
+#define	VALCHECK_MRB_Bool( mrb, val )
+
+VALCHECK_INT( Int8, INT8, int8_t )
+VALCHECK_MRB_INT( Int8, INT8, int8_t )
+VALCHECK_INT( Int16, INT16, int16_t )
+VALCHECK_MRB_INT( Int16, INT16, int16_t )
+VALCHECK_UINT( UInt8, UINT8, uint8_t )
+#define	VALCHECK_MRB_UInt8
+VALCHECK_UINT( UInt16, UINT16, uint16_t )
+#define	VALCHECK_MRB_UInt16
+VALCHECK_INT( Int32, INT32, int32_t )
+#define VALCHECK_MRB_Int32
+VALCHECK_UINT( UInt32, UINT32, uint32_t )
+#define VALCHECK_MRB_UInt32
+
+VALCHECK_INT( Int64, INT64, int64_t )
+VALCHECK_UINT( UInt64, UINT64, uint64_t )
+#ifndef mrb_int_IS_int64
+	 // â  int 32 bit ãä»®å®ãã¦ãã. 64 bit ã§ããã° mrb_int_IS_64 ã define ãã
+VALCHECK_MRB_INT( Int64, INT64, int64_t )
+VALCHECK_MRB_UINT( UInt64, UINT64, uint64_t )
+#else
+#define VALCHECK_MRB_Int64      // ç¯å²ãã§ãã¯ãç¡æå³ã§ãããããè­¦åãåºãã®ãåé¿ãã
+#define VALCHECK_MRB_UInt64      // ç¯å²ãã§ãã¯ãç¡æå³ã§ãããããè­¦åãåºãã®ãåé¿ãã
+#endif
+
+#ifndef TECS_NO_VAL_CHECK
+	 // â  char_t ã¯ unsigned ã¨ã¿ãªã
+static inline void
+VALCHECK_Char( mrb_state *mrb, mrb_int  val )
+{
+	if( val > 0xff || val < 0 )	
+		mrb_raise(mrb, E_ARGUMENT_ERROR, "too large or too small for char_t");
+}
+#define	VALCHECK_MRB_Char( mrb, val )
+
+VALCHECK_INT( Short, SHRT, short )
+#define	VALCHECK_MRB_Short( mrb, val )
+
+VALCHECK_INT( Int, INT, int )
+#define	VALCHECK_MRB_Int( mrb, val )
+
+VALCHECK_INT( Long, LONG, long )
+#define	VALCHECK_MRB_Long( mrb, val )
+
+VALCHECK_INT( SChar, SCHAR, signed char )
+#define	VALCHECK_MRB_SChar( mrb, val )
+
+VALCHECK_UINT( UChar, UCHAR, unsigned char )
+#define	VALCHECK_MRB_UChar( mrb, val )
+
+VALCHECK_UINT( UInt, UINT, unsigned int )
+#define	VALCHECK_MRB_UInt( mrb, val )
+
+VALCHECK_UINT( UShort, USHRT, unsigned short )
+#define	VALCHECK_MRB_UShort( mrb, val )
+
+VALCHECK_UINT( ULong, ULONG, unsigned long )
+#define	VALCHECK_MRB_ULong( mrb, val )
+
+#else // TECS_NO_VAL_CHECK
+
+#define VALCHECK_Char( mrb, val )
+#define	VALCHECK_MRB_Char( mrb, val )
+#define VALCHECK_Int( mrb, val )
+#define	VALCHECK_MRB_Int( mrb, val )
+#define	VALCHECK_Short( mrb, val )
+#define	VALCHECK_MRB_Short( mrb, val )
+#define	VALCHECK_Long( mrb, val )
+#define	VALCHECK_MRB_Long( mrb, val )
+#define	VALCHECK_SChar( mrb, val )
+#define	VALCHECK_MRB_SChar( mrb, val )
+#define	VALCHECK_UChar( mrb, val )
+#define	VALCHECK_MRB_UChar( mrb, val )
+#define	VALCHECK_UInt( mrb, val )
+#define	VALCHECK_MRB_UInt( mrb, val )
+#define	VALCHECK_UShort( mrb, val )
+#define	VALCHECK_MRB_UShort( mrb, val )
+#define	VALCHECK_ULong( mrb, val )
+#define	VALCHECK_MRB_ULong( mrb, val )
+
+#endif // TECS_NO_VAL_CHECK
+
+#define CHECK_AND_GET_POINTER( Type, type )								\
+	type *CheckAndGet ## Type ## Pointer( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		if( mrb_type(value) != MRB_TT_DATA								\
+			|| DATA_TYPE( value ) == 0									\
+			|| strcmp( DATA_TYPE( value )->struct_name,  "TECS::" #Type "Pointer" ) ) \
+			mrb_raise(mrb, E_TYPE_ERROR, "not PointerType or unexpected PointerType"); \
+		if( len != -1 && ((struct Type ## PointerBody *)DATA_PTR( value ))->length < len ) \
+			mrb_raise(mrb, E_ARGUMENT_ERROR, "size_is too short");		\
+		return ((struct Type##PointerBody*)(DATA_PTR(value)))->buf;		\
+	}																	\
+																		\
+	type *CheckAndGet ## Type ## PointerNullable( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		if( mrb_nil_p(value) )											\
+			return NULL;												\
+		return CheckAndGet ## Type ## Pointer( mrb, value, len );		\
+	}
+
+
+/*
+ * CHECK_AND_GET_CHAR_POINTER & CHECK_AND_GET_CHAR_POINTER_MOD are used 
+ * in case that the macro TECS_Use_MrbString_for_CharPointer is defined.
+ * This does not work as str_modify is static funcion.
+ */
+#define CHECK_AND_GET_CHAR_POINTER( Type, type )								\
+	type *CheckAndGet ## Type ## Pointer( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		if( mrb_type(value) != MRB_TT_STRING )							\
+			mrb_raise(mrb, E_TYPE_ERROR, "not String Type");			\
+		if( len != -1 && RSTRING_LEN(value) < len )						\
+			mrb_raise(mrb, E_ARGUMENT_ERROR, "size_is too short");		\
+		return RSTRING_PTR(value);										\
+	}																	\
+																		\
+	type *CheckAndGet ## Type ## PointerNullable( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		if( mrb_nil_p(value) )											\
+			return NULL;												\
+		return CheckAndGet ## Type ## Pointer( mrb, value, len );		\
+	}
+
+#define CHECK_AND_GET_CHAR_POINTER_MOD( Type, type )					\
+	type *CheckAndGet ## Type ## PointerMod( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		char *ptr;														\
+		if( mrb_type(value) != MRB_TT_STRING )							\
+			mrb_raise(mrb, E_TYPE_ERROR, "not String Type");			\
+		str_modify(mrb,RSTRING(value));									\
+		if( len == -1 || RSTRING_LEN(value) < len )						\
+			mrb_raise(mrb, E_ARGUMENT_ERROR, "size_is too short");		\
+		ptr = RSTRING_PTR(value);										\
+		ptr[len] = '\0';												\
+		return (type *)ptr;												\
+	}																	\
+																		\
+	type *CheckAndGet ## Type ## PointerModNullable( mrb_state *mrb, mrb_value value, int32_t len ) \
+	{																	\
+		if( mrb_nil_p(value) )											\
+			return NULL;												\
+		return CheckAndGet ## Type ## Pointer( mrb, value, len );		\
+	}
+
+#define CHECK_AND_GET_POINTER_PROTO( Type, type )						\
+	type *CheckAndGet ## Type ## Pointer( mrb_state *mrb, mrb_value value, int32_t len ); \
+	type *CheckAndGet ## Type ## PointerNullable( mrb_state *mrb, mrb_value value, int32_t len )
+#define CHECK_AND_GET_POINTER_MOD_PROTO( Type, type )					\
+	type *CheckAndGet ## Type ## PointerMod( mrb_state *mrb, mrb_value value, int32_t len ); \
+	type *CheckAndGet ## Type ## PointerModNullable( mrb_state *mrb, mrb_value value, int32_t len )
+
+CHECK_AND_GET_POINTER_PROTO( Bool,  bool_t );		/* Bool pointer */
+CHECK_AND_GET_POINTER_PROTO( Double64, double64_t );/* Double64 pointer */
+CHECK_AND_GET_POINTER_PROTO( Float32, float32_t );	/* Float32 pointer */
+
+CHECK_AND_GET_POINTER_PROTO( Int8,  int8_t );		/* Int8 pointer */
+CHECK_AND_GET_POINTER_PROTO( Int16, int16_t );		/* Int16 pointer */
+CHECK_AND_GET_POINTER_PROTO( Int32, int32_t );		/* Int32 pointer */
+CHECK_AND_GET_POINTER_PROTO( Int64, int64_t );		/* Int64 pointer */
+CHECK_AND_GET_POINTER_PROTO( Int,   int );			/* Int pointer */
+CHECK_AND_GET_POINTER_PROTO( Short, short );		/* Short pointer */
+CHECK_AND_GET_POINTER_PROTO( Long,  long );			/* Long pointer */
+
+CHECK_AND_GET_POINTER_PROTO( UInt8,  uint8_t );		/* UInt8 pointer */
+CHECK_AND_GET_POINTER_PROTO( UInt16, uint16_t );	/* UInt16 pointer */
+CHECK_AND_GET_POINTER_PROTO( UInt32, uint32_t );	/* UInt32 pointer */
+CHECK_AND_GET_POINTER_PROTO( UInt64, uint64_t );	/* UInt64 pointer */
+CHECK_AND_GET_POINTER_PROTO( UInt,   unsigned int );/* UInt pointer */
+CHECK_AND_GET_POINTER_PROTO( UShort, unsigned short );	/* UShort pointer */
+CHECK_AND_GET_POINTER_PROTO( ULong,  unsigned long );	/* ULong pointer */
+
+#ifndef TECS_Use_MrbString_for_CharPointer
+CHECK_AND_GET_POINTER_PROTO( Char,  char_t );		/* Char pointer */
+CHECK_AND_GET_POINTER_PROTO( SChar,  char_t );		/* SChar pointer */
+//CHECK_AND_GET_POINTER_PROTO( SChar,  schar_t );		/* SChar pointer */
+CHECK_AND_GET_POINTER_PROTO( UChar,  uint8_t );		/* UChar pointer */
+//CHECK_AND_GET_POINTER_PROTO( UChar,  uchar_t );		/* UChar pointer */
+#define CheckAndGetCharPointerMod	CheckAndGetCharPointer
+#define CheckAndGetSCharPointerMod	CheckAndGetSCharPointer
+#define CheckAndGetUCharPointerMod	CheckAndGetUCharPointer
+#define CheckAndGetCharPointerModNullable	CheckAndGetCharPointerNullable
+#define CheckAndGetSCharPointerModNullable	CheckAndGetSCharPointerNullable
+#define CheckAndGetUCharPointerModNullable	CheckAndGetUCharPointerNullable
+#else
+CHECK_AND_GET_POINTER_PROTO( Char,  char_t );		/* Char pointer */
+CHECK_AND_GET_POINTER_PROTO( SChar,  char_t );		/* SChar pointer */
+CHECK_AND_GET_POINTER_PROTO( UChar,  uint8_t );		/* UChar pointer */
+CHECK_AND_GET_POINTER_MOD_PROTO( Char,  char_t );	/* Char pointer */
+CHECK_AND_GET_POINTER_MOD_PROTO( SChar,  char_t );	/* SChar pointer */
+CHECK_AND_GET_POINTER_MOD_PROTO( UChar,  uint8_t );	/* UChar pointer */
+#endif /* TECS_Use_MrbString_for_CharPointer */
+
+#define GET_SET_BOOL( Type, TYPE )										\
+	static mrb_value													\
+	Type ## Pointer_aget(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+		mrb_int	subscript;												\
+		TYPE	val;													\
+																		\
+		mrb_get_args(mrb, "i", &subscript );							\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (get)"); \
+		val = pointerBody->buf[ subscript ];							\
+		VALCHECK_MRB_ ## Type( mrb, val );								\
+		return val ? mrb_true_value() : mrb_false_value();				\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_aset(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_int	subscript;												\
+		mrb_value	val;													\
+																		\
+		mrb_get_args(mrb, "io", &subscript, &val );						\
+																		\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (set)"); \
+		pointerBody->buf[ subscript ] = mrb_test( val );				\
+																		\
+		return self;													\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_get_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+		TYPE	val;													\
+																		\
+		val = *pointerBody->buf;										\
+		VALCHECK_MRB_ ## Type( mrb, val );								\
+		return val ? mrb_true_value() : mrb_false_value();				\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_set_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_value	val;												\
+																		\
+		mrb_get_args(mrb, "o", &val );									\
+																		\
+		*pointerBody->buf = mrb_test( val );							\
+		return self;													\
+	}
+
+#define GET_SET_CHAR( Type, TYPE )		GET_SET_INT( Type, TYPE )
+#define GET_SET_INT( Type, TYPE )										\
+	static mrb_value													\
+	Type ## Pointer_aget(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+		mrb_int	subscript;												\
+		TYPE	val;													\
+																		\
+		mrb_get_args(mrb, "i", &subscript );							\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (get)"); \
+		val = pointerBody->buf[ subscript ];							\
+		VALCHECK_MRB_ ## Type( mrb, val );								\
+		return mrb_fixnum_value( val );									\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_aset(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_int	subscript;												\
+		mrb_int	val;													\
+																		\
+		mrb_get_args(mrb, "ii", &subscript, &val );						\
+																		\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (set)"); \
+		VALCHECK_ ## Type ( mrb, val );									\
+		pointerBody->buf[ subscript ] = val;							\
+																		\
+		return self;													\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_get_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+		TYPE	val;													\
+																		\
+		val = *pointerBody->buf;										\
+		VALCHECK_MRB_ ## Type( mrb, val );								\
+		return mrb_fixnum_value( val );									\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_set_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_int	val;													\
+																		\
+		mrb_get_args(mrb, "i", &val );									\
+																		\
+		VALCHECK_ ## Type ( mrb, val );									\
+		*pointerBody->buf = val;										\
+																		\
+		return self;													\
+	}
+
+#define GET_SET_FLOAT( Type, TYPE )										\
+	static mrb_value													\
+	Type ## Pointer_aget(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+		mrb_int	subscript;												\
+																		\
+		mrb_get_args(mrb, "i", &subscript );							\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (get)"); \
+		return mrb_float_value( mrb, pointerBody->buf[ subscript ] );   \
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_aset(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_int	subscript;												\
+		mrb_float	val;												\
+																		\
+		mrb_get_args(mrb, "if", &subscript, &val );						\
+																		\
+		if( subscript < 0 || subscript >= pointerBody->length )			\
+			mrb_raise(mrb, E_INDEX_ERROR, "index is out of array (set)"); \
+		pointerBody->buf[ subscript ] = val;							\
+																		\
+		return self;													\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_get_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+																		\
+		return mrb_float_value( mrb, *pointerBody->buf );               \
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_set_val(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self ); 	\
+		mrb_float	val;												\
+																		\
+		mrb_get_args(mrb, "f", &val );									\
+																		\
+		*pointerBody->buf = val;										\
+																		\
+		return self;													\
+	}
+
+////  define Pointer classes ////
+#define POINTER_CLASS( Type, TYPE )										\
+																		\
+	static void															\
+	Type ## PointerBody_free( mrb_state *mrb, void *p )					\
+	{																	\
+		(void)mrb_free( mrb, p );										\
+	}																	\
+																		\
+	struct mrb_data_type Type ## PointerBody_mrb_data_type =			\
+		{																\
+			"TECS::" #Type "Pointer",									\
+			Type ## PointerBody_free									\
+		};																\
+																		\
+	static mrb_value													\
+	Type ## Pointer_initialize( mrb_state *mrb, mrb_value self)			\
+	{																	\
+		mrb_int	length;													\
+		struct Type ## PointerBody *pointerBody;						\
+																		\
+		mrb_get_args(mrb, "i", &length );								\
+		if( length < 0 )												\
+			mrb_raise(mrb, E_INDEX_ERROR, "negative length");			\
+		DATA_TYPE( self ) = &Type ## PointerBody_mrb_data_type;			\
+		pointerBody = (struct Type ## PointerBody *)mrb_malloc(mrb, sizeof(struct Type ## PointerBody) + length * sizeof( TYPE ) ); \
+		pointerBody->length = length;									\
+		DATA_PTR( self ) = (void *)pointerBody;							\
+						 												\
+		return self;													\
+	}																	\
+																		\
+	static mrb_value													\
+	Type ## Pointer_size(mrb_state *mrb, mrb_value self)				\
+	{																	\
+		struct Type ## PointerBody *pointerBody = DATA_PTR( self );		\
+																		\
+		return mrb_fixnum_value( pointerBody->length );					\
+	}																	\
+																		\
+	struct RClass *														\
+	tecs_init_## Type ## Pointer(mrb_state *mrb, struct RClass *TECS)	\
+	{																	\
+		struct RClass *a;												\
+																		\
+		a = mrb_define_class_under(mrb, TECS, #Type "Pointer", mrb->object_class); \
+		MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);							\
+																		\
+		mrb_define_method(mrb, a, "initialize",      Type ## Pointer_initialize,   MRB_ARGS_REQ(1)); \
+		mrb_define_method(mrb, a, "[]",              Type ## Pointer_aget,         MRB_ARGS_REQ(1)); \
+		mrb_define_method(mrb, a, "value",           Type ## Pointer_get_val,      MRB_ARGS_NONE()); \
+		mrb_define_method(mrb, a, "[]=",             Type ## Pointer_aset,         MRB_ARGS_REQ(2)); \
+		mrb_define_method(mrb, a, "value=",          Type ## Pointer_set_val,      MRB_ARGS_REQ(1)); \
+		mrb_define_method(mrb, a, "size",            Type ## Pointer_size,         MRB_ARGS_NONE()); \
+		mrb_define_method(mrb, a, "length",          Type ## Pointer_size,         MRB_ARGS_NONE()); \
+		return	a;														\
+	}
+
+static inline mrb_value
+CharPointer_to_s( mrb_state *mrb, mrb_value self )
+{
+	struct CharPointerBody *pointerBody = DATA_PTR( self );
+	return mrb_str_new( mrb, pointerBody->buf, strnlen( pointerBody->buf, pointerBody->length ) );
+}
+
+static inline mrb_value
+CharPointer_from_s( mrb_state *mrb, mrb_value self )
+{
+	mrb_value str;
+	struct CharPointerBody *pointerBody = DATA_PTR( self );
+
+	mrb_get_args(mrb, "o", &str );
+	if( mrb_type( str ) != MRB_TT_STRING ){
+		mrb_raise(mrb, E_ARGUMENT_ERROR, "Not String");
+	}
+
+	strncpy( pointerBody->buf, RSTRING_PTR(str), pointerBody->length );
+	return self;
+}
+
+/* Initialize TECSPointer classes */
+void	init_TECSPointer( mrb_state *mrb, struct RClass *TECS );
+
+#endif /* TECSPointer_h__ */
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSStruct.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSStruct.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/TECSStruct.h	(revision 317)
@@ -0,0 +1,158 @@
+/*
+ *  mruby => TECS brige
+ *  
+ *   Copyright (C) 2008-2012 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$ 
+ */
+
+#ifndef TECSStruct_h__
+#define TECSStruct_h__
+
+#define MEMBER_GET_SET_INT( TAG, MEMBER, Type, TYPE )					\
+	static mrb_value													\
+	Struct_ ## TAG ## _ ## MEMBER ## _aget(mrb_state *mrb, mrb_value self)	\
+	{																	\
+		struct TAG *st = DATA_PTR( self );								\
+		TYPE ## _t	val;												\
+																		\
+		val = st->MEMBER;												\
+		VALCHECK_MRB_ ## Type( mrb, val );								\
+		return mrb_fixnum_value( val );									\
+	}																	\
+																		\
+	static mrb_value													\
+	Struct_ ## TAG ## _ ## MEMBER ## _aset(mrb_state *mrb, mrb_value self)	\
+	{																	\
+		struct TAG *st = DATA_PTR( self );								\
+		mrb_int	val;													\
+																		\
+		mrb_get_args(mrb, "i", &val );									\
+																		\
+		VALCHECK_ ## Type ( mrb, val );									\
+		st->MEMBER = val;												\
+																		\
+		return self;													\
+	}
+
+#define MEMBER_GET_SET_FLOAT( TAG, MEMBER )								\
+	static mrb_value													\
+	Struct_ ## TAG ## _ ## MEMBER ## _aget(mrb_state *mrb, mrb_value self)	\
+	{																	\
+		struct TAG *st = DATA_PTR( self );								\
+																		\
+		return mrb_float_value( mrb, st->MEMBER );                      \
+	}																	\
+																		\
+	static mrb_value													\
+	Struct_ ## TAG ## _ ## MEMBER ## _aset(mrb_state *mrb, mrb_value self)	\
+	{																	\
+		struct TAG *st = DATA_PTR( self );								\
+		mrb_float	val;												\
+																		\
+		mrb_get_args(mrb, "f", &val );									\
+																		\
+		st->MEMBER = val;												\
+																		\
+		return self;													\
+	}
+
+////  define Struct class ////
+#define STRUCT_CLASS( TAG )												\
+																		\
+	static void															\
+	Struct ## TAG ## Body_free( mrb_state *mrb, void *p )				\
+	{																	\
+		(void)mrb_free( mrb, p );										\
+	}																	\
+																		\
+	struct mrb_data_type Struct ## TAG ## Body_mrb_data_type =			\
+		{																\
+			"TECS::Struct" #TAG,										\
+			Struct ## TAG ## Body_free									\
+		};																\
+																		\
+	static mrb_value													\
+	Struct_ ## TAG ## _initialize( mrb_state *mrb, mrb_value self)		\
+	{																	\
+		mrb_int	length;													\
+		struct  TAG *structBody;										\
+																		\
+		DATA_TYPE( self ) = &Struct ## TAG ## Body_mrb_data_type;		\
+		DATA_PTR( self ) = mrb_malloc(mrb, sizeof(struct TAG)); 		\
+						 												\
+		return self;													\
+	}
+
+#define  STRUCT_INIT_BEGIN( TAG )										\
+	struct RClass *														\
+	tecs_init_Struct_## TAG(mrb_state *mrb, struct RClass *TECS)		\
+	{																	\
+		struct RClass *a;												\
+																		\
+		a = mrb_define_class_under(mrb, TECS, "Struct" #TAG, mrb->object_class); \
+		MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);							\
+																		\
+		mrb_define_method(mrb, a, "initialize", Struct_ ## TAG ## _initialize,            MRB_ARGS_NONE());
+
+#define  STRUCT_INIT_MEMBER( TAG, MEMBER )								\
+		mrb_define_method(mrb, a, #MEMBER,      Struct_ ## TAG ## _ ## MEMBER ## _aget,   MRB_ARGS_NONE()); \
+		mrb_define_method(mrb, a, #MEMBER "=",  Struct_ ## TAG ## _ ## MEMBER ## _aset,   MRB_ARGS_REQ(1));
+
+
+#define  STRUCT_INIT_END( TAG )											\
+	}
+
+#define CHECK_STRUCT( tag, value )										\
+	do {																\
+		if( mrb_type(value) != MRB_TT_DATA								\
+			|| DATA_TYPE( value ) == 0									\
+			|| strcmp( DATA_TYPE( value )->struct_name, "TECS::Struct" #tag ) ) \
+			mrb_raise(mrb, E_TYPE_ERROR, "not Struct or tag mismatch"); \
+	}while(0)
+
+#endif /* TECSStruct_h__ */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mruby.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mruby.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mruby.cdl	(revision 317)
@@ -0,0 +1,5 @@
+import_C( "tecs_mruby.h" );
+
+import( <mrubyInitializer.cdl> );
+import( <mrubyPointers.cdl> );
+import( <mrubyVMs.cdl> );
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyInitializer.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyInitializer.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyInitializer.cdl	(revision 317)
@@ -0,0 +1,20 @@
+
+namespace nMruby{
+
+	signature sInitializeBridge {
+		void initializeBridge( [in]const mrb_state *mrb );
+	};
+
+	signature sInitializeTECSBridge {
+		void initializeBridge( [inout]mrb_state *mrb, [inout]struct RClass *TECS );
+	};
+
+	// tTECSInitializer creates classes under "TECS" module in mruby VM
+	celltype tTECSInitializer {
+		entry sInitializeBridge eInitialize;
+		call  sInitializeTECSBridge cInitialize[];
+		var{
+			struct RClass *TECS = 0;
+		};
+	};
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyPointers.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyPointers.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyPointers.cdl	(revision 317)
@@ -0,0 +1,35 @@
+// Pointer celltypes
+
+namespace nMruby {
+	// Pointer to Bool
+	[singleton]celltype tBoolPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+
+	// Pointer to Chars
+	[singleton]celltype tCharPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tSCharPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUCharPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+
+	// Pointer to Signed Integers
+	[singleton]celltype tInt8Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tInt16Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tInt32Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tInt64Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+
+	// Pointer to Unsigned Integers
+	[singleton]celltype tUInt8Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUInt16Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUInt32Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUInt64Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+
+	// Pointer to Floating types
+	[singleton]celltype tFloat32Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tDouble64Pointer	 {	entry  sInitializeTECSBridge eInitialize; };
+
+	// Pointer to Integers (unrecommended)
+	[singleton]celltype tIntPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tShortPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tLongPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUIntPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tUShortPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+	[singleton]celltype tULongPointer	 {	entry  sInitializeTECSBridge eInitialize; };
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyVMs.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyVMs.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/mrubyVMs.cdl	(revision 317)
@@ -0,0 +1,17 @@
+import( <posix.cdl> );
+
+/*
+ * tools/mruby/mruby.c ãã cInit_initializeBridge( mrb ) ãå¼ã³åºãããã«å¤æ´ãããã®
+ */
+namespace nMruby{
+	[active]
+	celltype tMrubyProc {
+	    entry nPosix::sMain eMain;
+
+		[optional]
+			call sInitializeBridge cInit;
+		var {
+			mrb_state *mrb;
+		};
+	};
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tBoolPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tBoolPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tBoolPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tBoolPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_BOOL( Bool, bool_t )
+POINTER_CLASS( Bool, bool_t )
+CHECK_AND_GET_POINTER( Bool, bool_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tBoolPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_BoolPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tCharPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tCharPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tCharPointer.c	(revision 317)
@@ -0,0 +1,50 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tCharPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Char, char_t )
+POINTER_CLASS( Char, char_t )
+#ifndef  TECS_Use_MrbString_for_CharPointer
+CHECK_AND_GET_POINTER( Char, char_t )
+#else
+CHECK_AND_GET_CHAR_POINTER( Char, char_t )
+CHECK_AND_GET_CHAR_POINTER_MOD( Char, char_t )
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tCharPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	struct  RClass *c;
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	c = tecs_init_CharPointer( mrb, TECS );
+	mrb_define_method(mrb, c, "to_s", CharPointer_to_s, MRB_ARGS_NONE());
+	mrb_define_method(mrb, c, "from_s", CharPointer_from_s, MRB_ARGS_REQ(1));
+
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tDouble64Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tDouble64Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tDouble64Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tDouble64Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_FLOAT( Double64, double64_t )
+POINTER_CLASS( Double64, double64_t )
+CHECK_AND_GET_POINTER( Double64, double64_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tDouble64Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Double64Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tFloat32Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tFloat32Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tFloat32Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tFloat32Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_FLOAT( Float32, float32_t )
+POINTER_CLASS( Float32, float32_t )
+CHECK_AND_GET_POINTER( Float32, float32_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tFloat32Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Float32Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt16Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt16Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt16Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tInt16Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Int16, int16_t )
+POINTER_CLASS( Int16, int16_t )
+CHECK_AND_GET_POINTER( Int16, int16_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tInt16Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Int16Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt32Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt32Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt32Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tInt32Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Int32, int32_t )
+POINTER_CLASS( Int32, int32_t )
+CHECK_AND_GET_POINTER( Int32, int32_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tInt32Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Int32Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt64Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt64Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt64Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tInt64Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Int64, int64_t )
+POINTER_CLASS( Int64, int64_t )
+CHECK_AND_GET_POINTER( Int64, int64_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tInt64Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Int64Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt8Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt8Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tInt8Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tInt8Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Int8, int8_t )
+POINTER_CLASS( Int8, int8_t )
+CHECK_AND_GET_POINTER( Int8, int8_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tInt8Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_Int8Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tIntPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tIntPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tIntPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tIntPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Int, int )
+POINTER_CLASS( Int, int )
+CHECK_AND_GET_POINTER( Int, int )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tIntPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_IntPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tLongPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tLongPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tLongPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tLongPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Long, long )
+POINTER_CLASS( Long, long )
+CHECK_AND_GET_POINTER( Long, long )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tLongPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_LongPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMruby.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMruby.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMruby.c	(revision 317)
@@ -0,0 +1,193 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cSerialPort  signature: sSerialPort context: task
+ *   ER             cSerialPort_open( );
+ *   ER             cSerialPort_close( );
+ *   ER_UINT        cSerialPort_read( char_t* buffer, uint_t length );
+ *   ER_UINT        cSerialPort_write( const char_t* buffer, uint_t length );
+ *   ER             cSerialPort_control( uint_t ioControl );
+ *   ER             cSerialPort_refer( T_SERIAL_RPOR* pk_rpor );
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tMruby_tecsgen.h"
+#include <string.h>
+
+#include <mruby.h>
+#include <mruby/proc.h>
+#include <mruby/data.h>
+#include <mruby/compile.h>
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+#define MEM_SIZE 1024*1024 // 1MB
+//#define VM_EVAL
+//#define MALLOC_EVAL
+
+#include <t_syslog.h>
+
+void mrb_init_mrb(CELLCB *p_cellcb, mrb_state *mrb);
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eMrubyBody
+ * entry port: eMrubyBody
+ * signature:  sMrubyBody
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eMrubyBody_main
+ * name:         eMrubyBody_main
+ * global_name:  nMruby_tMruby_eMrubyBody_main
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eMrubyBody_main(CELLIDX idx)
+{
+#ifdef VM_EVAL
+  SYSUTM tstart, tend;
+#endif
+  
+  CELLCB	*p_cellcb;
+  mrb_state *mrb;
+  
+  if (VALID_IDX(idx)) {
+    p_cellcb = GET_CELLCB(idx);
+  }
+#ifdef VM_EVAL
+  get_utm(&tstart);
+#endif
+
+  /* new interpreter instance */
+  mrb = mrb_open();
+  if (mrb == NULL) {
+    syslog(LOG_EMERG, "Invalid mrb_state, exiting test driver");
+//    cSerialPort_write("Invalid mrb_state, exiting test driver\n", 39);
+    return;
+  }
+
+#ifdef VM_EVAL
+  get_utm(&tend);
+  syslog(LOG_EMERG, "mrb_open time = %d micro sec", tend - tstart);
+#endif
+  if(is_cInit_joined()){
+    // TECS Bridge
+    cInit_initializeBridge( mrb );
+  }
+  mrb_init_mrb(p_cellcb, mrb);
+	syslog(LOG_EMERG, "end of mruby program");
+#ifdef VM_EVAL
+  get_utm(&tstart);
+#endif
+  mrb_close(mrb);
+#ifdef VM_EVAL
+  get_utm(&tend);
+  syslog(LOG_EMERG, "mrb_close time = %d micro sec", tend - tstart);
+#endif
+}
+
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
+
+void
+mrb_init_mrb(CELLCB	*p_cellcb, mrb_state *mrb)
+{
+  mrb_irep *irep = mrb_read_irep(mrb, ATTR_irep);
+  
+  mrb_run(mrb, mrb_proc_new(mrb, irep), mrb_top_self(mrb));
+  if (mrb->exc) {
+    mrb_p(mrb, mrb_obj_value(mrb->exc));
+    exit(0);
+  }
+}
+
+/*
+extern void debug_print(char * str);
+extern void debug_print_address(char * str, int address);
+extern void debug_print_int(char * str, int data);
+#include <errno.h>
+void *
+_sbrk(size_t incr)
+{
+  // TODO: æ­£ãããã¼ããµã¤ãºãæå®ãããã¨ (EV3ã¯RAM 64MB)
+  extern char __heap_start;
+  static uint32_t cs3_heap_end = &__heap_start + MEM_SIZE; // ãã¼ãã®æå¾ã¢ãã¬ã¹
+  static char *heap_end = &__heap_start;
+  char *prev_heap_end;
+  uint16_t incr2;
+  
+  char str[20];
+  
+#ifdef MALLOC_EVAL
+  syslog(LOG_EMERG, "heap_start = %x", &__heap_start);
+#endif
+
+  prev_heap_end = heap_end;
+  incr2 = (uint16_t)incr;
+  
+  if (heap_end + incr2 > cs3_heap_end) {
+    errno = ENOMEM;
+    return (void *)-1;
+  }
+  heap_end += incr2;
+
+#ifdef MALLOC_EVAL
+  syslog(LOG_EMERG, "heap_end = %x", heap_end);
+#endif
+
+#ifdef DEBUG_MALLOC	
+  debug_print_int("incr",incr);
+  debug_print_address("prev_heap_end",(int) prev_heap_end);
+  dly_tsk(50);
+#endif
+  return (void *) prev_heap_end;
+}
+*/
+extern intptr_t bt_snd_chr(intptr_t c);
+extern intptr_t uart_snd_chr(intptr_t c) ;
+extern void initialize_lcd_dri();
+#define UART1	(*(volatile struct st_uart *)0x01D0C000)
+size_t fwrite(const void *buf, size_t size, size_t n, FILE *fp){
+  intptr_t intp;
+  char *cp;
+  cp = (char*)buf;
+  /* ã·ãªã¢ã«ãã¼ããçµåããã¦ããå ´åã®ã¿å¼ã³åºã
+  if(is_cSerialPort_joined()){
+    //cSerialPort_write(buf, size);
+   
+  }*/
+    
+  for(int i = 0;i < size; i++){
+    intp = *cp++;
+    if (intp == '\n') {
+	    bt_snd_chr('\r');
+	    while(!uart_send(&UART1, '\r'));
+    } 
+	bt_snd_chr(intp);
+    while(!uart_send(&UART1, intp));
+
+  }
+    return size;
+};
+
+#ifndef EV3_SOUND
+void _write(){}
+void _close(){}
+void _lseek(){}
+void _read(){}
+//void _fstat(){}
+//void _isatty(){}
+#endif
+
+//void _exit(){}
+//void _getpid(){}
+//void _kill(){}
+void _gettimeofday(){}
+void _fini(){}
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc.c	(revision 317)
@@ -0,0 +1,266 @@
+/*
+ * This file comes from mruby. (renamed from tools/mruby/mruby.c)
+ * This file is distributed under ruby's license. (not under TOPPERS license)
+ *   see https://github.com/mruby/mruby
+ * A little modification is done to to call initializer registering TECS components.
+ *
+ * ãã®ãã¡ã¤ã«ã¯ãmruby ã®ãã®ã§ãã
+ * mruby ã®ã©ã¤ã»ã³ã¹ã®ãã¨ã§ãé
+å¸ããã¾ãã(TOPPERS ã©ã¤ã»ã³ã¹ã§ã¯ããã¾ãã)
+ *  åç
+§ï¼  https://github.com/mruby/mruby
+ * TECS ã³ã³ãã¼ãã³ããç»é²ããåæåå­ãå¼ã¶ãããå°ãã®ä¿®æ­£ããªããã¦ãã¾ãã
+ */
+
+#include "nMruby_tMrubyProc_tecsgen.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mruby.h"
+#include "mruby/array.h"
+#include "mruby/compile.h"
+#include "mruby/dump.h"
+#include "mruby/variable.h"
+
+#ifndef ENABLE_STDIO
+static void
+p(mrb_state *mrb, mrb_value obj)
+{
+  obj = mrb_funcall(mrb, obj, "inspect", 0);
+  fwrite(RSTRING_PTR(obj), RSTRING_LEN(obj), 1, stdout);
+  putc('\n', stdout);
+}
+#else
+#define p(mrb,obj) mrb_p(mrb,obj)
+#endif
+
+void mrb_show_version(mrb_state *);
+void mrb_show_copyright(mrb_state *);
+
+struct _args {
+  FILE *rfp;
+  char* cmdline;
+  mrb_bool fname        : 1;
+  mrb_bool mrbfile      : 1;
+  mrb_bool check_syntax : 1;
+  mrb_bool verbose      : 1;
+  int argc;
+  char** argv;
+};
+
+static void
+usage(const char *name)
+{
+  static const char *const usage_msg[] = {
+  "switches:",
+  "-b           load and execute RiteBinary (mrb) file",
+  "-c           check syntax only",
+  "-e 'command' one line of script",
+  "-v           print version number, then run in verbose mode",
+  "--verbose    run in verbose mode",
+  "--version    print the version",
+  "--copyright  print the copyright",
+  NULL
+  };
+  const char *const *p = usage_msg;
+
+  printf("Usage: %s [switches] programfile\n", name);
+  while (*p)
+    printf("  %s\n", *p++);
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
+{
+  char **origargv = argv;
+  static const struct _args args_zero = { 0 };
+
+  *args = args_zero;
+
+  for (argc--,argv++; argc > 0; argc--,argv++) {
+    char *item;
+    if (argv[0][0] != '-') break;
+
+    if (strlen(*argv) <= 1) {
+      argc--; argv++;
+      args->rfp = stdin;
+      break;
+    }
+
+    item = argv[0] + 1;
+    switch (*item++) {
+    case 'b':
+      args->mrbfile = TRUE;
+      break;
+    case 'c':
+      args->check_syntax = TRUE;
+      break;
+    case 'e':
+      if (item[0]) {
+        goto append_cmdline;
+      }
+      else if (argc > 1) {
+        argc--; argv++;
+        item = argv[0];
+append_cmdline:
+        if (!args->cmdline) {
+          size_t buflen;
+          char *buf;
+
+          buflen = strlen(item) + 1;
+          buf = (char *)mrb_malloc(mrb, buflen);
+          memcpy(buf, item, buflen);
+          args->cmdline = buf;
+        }
+        else {
+          size_t cmdlinelen;
+          size_t itemlen;
+
+          cmdlinelen = strlen(args->cmdline);
+          itemlen = strlen(item);
+          args->cmdline =
+            (char *)mrb_realloc(mrb, args->cmdline, cmdlinelen + itemlen + 2);
+          args->cmdline[cmdlinelen] = '\n';
+          memcpy(args->cmdline + cmdlinelen + 1, item, itemlen + 1);
+        }
+      }
+      else {
+        printf("%s: No code specified for -e\n", *origargv);
+        return EXIT_SUCCESS;
+      }
+      break;
+    case 'v':
+      if (!args->verbose) mrb_show_version(mrb);
+      args->verbose = TRUE;
+      break;
+    case '-':
+      if (strcmp((*argv) + 2, "version") == 0) {
+        mrb_show_version(mrb);
+        exit(EXIT_SUCCESS);
+      }
+      else if (strcmp((*argv) + 2, "verbose") == 0) {
+        args->verbose = TRUE;
+        break;
+      }
+      else if (strcmp((*argv) + 2, "copyright") == 0) {
+        mrb_show_copyright(mrb);
+        exit(EXIT_SUCCESS);
+      }
+    default:
+      return EXIT_FAILURE;
+    }
+  }
+
+  if (args->rfp == NULL && args->cmdline == NULL) {
+    if (*argv == NULL) args->rfp = stdin;
+    else {
+      args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r");
+      if (args->rfp == NULL) {
+        printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
+        return EXIT_FAILURE;
+      }
+      args->fname = TRUE;
+      args->cmdline = argv[0];
+      argc--; argv++;
+    }
+  }
+  args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
+  memcpy(args->argv, argv, (argc+1) * sizeof(char*));
+  args->argc = argc;
+
+  return EXIT_SUCCESS;
+}
+
+static void
+cleanup(mrb_state *mrb, struct _args *args)
+{
+  if (args->rfp && args->rfp != stdin)
+    fclose(args->rfp);
+  if (args->cmdline && !args->fname)
+    mrb_free(mrb, args->cmdline);
+  if (args->argv)
+    mrb_free(mrb, args->argv);
+  mrb_close(mrb);
+}
+
+int
+// main(int argc, char **argv)
+eMain_main( CELLIDX idx, int argc, const char **argv)
+
+{
+  CELLCB   *p_cellcb = GET_CELLCB( idx );
+  mrb_state *mrb = mrb_open();
+  int n = -1;
+  int i;
+  struct _args args;
+  mrb_value ARGV;
+  mrbc_context *c;
+  mrb_value v;
+  mrb_sym zero_sym;
+
+  cInit_initializeBridge( mrb );    // TECS
+
+
+  if (mrb == NULL) {
+    fputs("Invalid mrb_state, exiting mruby\n", stderr);
+    return EXIT_FAILURE;
+  }
+
+  n = parse_args(mrb, argc, (char **)argv, &args);
+  if (n == EXIT_FAILURE || (args.cmdline == NULL && args.rfp == NULL)) {
+    cleanup(mrb, &args);
+    usage(argv[0]);
+    return n;
+  }
+
+  ARGV = mrb_ary_new_capa(mrb, args.argc);
+  for (i = 0; i < args.argc; i++) {
+    mrb_ary_push(mrb, ARGV, mrb_str_new_cstr(mrb, args.argv[i]));
+  }
+  mrb_define_global_const(mrb, "ARGV", ARGV);
+
+  c = mrbc_context_new(mrb);
+  if (args.verbose)
+    c->dump_result = TRUE;
+  if (args.check_syntax)
+    c->no_exec = TRUE;
+
+  /* Set $0 */
+  zero_sym = mrb_intern_lit(mrb, "$0");
+  if (args.rfp) {
+    char *cmdline;
+    cmdline = args.cmdline ? args.cmdline : "-";
+    mrbc_filename(mrb, c, cmdline);
+    mrb_gv_set(mrb, zero_sym, mrb_str_new_cstr(mrb, cmdline));
+  }
+  else {
+    mrbc_filename(mrb, c, "-e");
+    mrb_gv_set(mrb, zero_sym, mrb_str_new_lit(mrb, "-e"));
+  }
+
+  /* Load program */
+  if (args.mrbfile) {
+    v = mrb_load_irep_file_cxt(mrb, args.rfp, c);
+  }
+  else if (args.rfp) {
+    v = mrb_load_file_cxt(mrb, args.rfp, c);
+  }
+  else {
+    v = mrb_load_string_cxt(mrb, args.cmdline, c);
+  }
+
+  mrbc_context_free(mrb, c);
+  if (mrb->exc) {
+    if (!mrb_undef_p(v)) {
+      mrb_print_error(mrb);
+    }
+    n = -1;
+  }
+  else if (args.check_syntax) {
+    printf("Syntax OK\n");
+  }
+  cleanup(mrb, &args);
+
+  return n == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc_1_0.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc_1_0.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tMrubyProc_1_0.c	(revision 317)
@@ -0,0 +1,306 @@
+/*
+ * This file comes from mruby. (renamed from tools/mruby/mruby.c)
+ * This file is distributed under ruby's license. (not under TOPPERS license)
+ *   see https://github.com/mruby/mruby
+ * A little modification is done to to call initializer registering TECS components.
+ *
+ * ãã®ãã¡ã¤ã«ã¯ãmruby ã®ãã®ã§ãã
+ * mruby ã®ã©ã¤ã»ã³ã¹ã®ãã¨ã§ãé
+å¸ããã¾ãã(TOPPERS ã©ã¤ã»ã³ã¹ã§ã¯ããã¾ãã)
+ *  åç
+§ï¼  https://github.com/mruby/mruby
+ * TECS ã³ã³ãã¼ãã³ããç»é²ããåæåå­ãå¼ã¶ãããå°ãã®ä¿®æ­£ããªããã¦ãã¾ãã
+ */
+
+#include "nMruby_tMrubyProc_tecsgen.h"
+
+#include "mruby.h"
+#include "mruby/proc.h"
+#include "mruby/array.h"
+#include "mruby/string.h"
+#include "mruby/compile.h"
+#include "mruby/dump.h"
+#include "mruby/variable.h"
+#include <stdio.h>
+#include <string.h>
+
+#ifndef ENABLE_STDIO
+static void
+p(mrb_state *mrb, mrb_value obj)
+{
+  obj = mrb_funcall(mrb, obj, "inspect", 0);
+  fwrite(RSTRING_PTR(obj), RSTRING_LEN(obj), 1, stdout);
+  putc('\n', stdout);
+}
+#else
+#define p(mrb,obj) mrb_p(mrb,obj)
+#endif
+
+void mrb_show_version(mrb_state *);
+void mrb_show_copyright(mrb_state *);
+
+struct _args {
+  FILE *rfp;
+  char* cmdline;
+  int fname        : 1;
+  int mrbfile      : 1;
+  int check_syntax : 1;
+  int verbose      : 1;
+  int argc;
+  char** argv;
+};
+
+static void
+usage(const char *name)
+{
+  static const char *const usage_msg[] = {
+  "switches:",
+  "-b           load and execute RiteBinary (mrb) file",
+  "-c           check syntax only",
+  "-e 'command' one line of script",
+  "-v           print version number, then run in verbose mode",
+  "--verbose    run in verbose mode",
+  "--version    print the version",
+  "--copyright  print the copyright",
+  NULL
+  };
+  const char *const *p = usage_msg;
+
+  printf("Usage: %s [switches] programfile\n", name);
+  while(*p)
+  printf("  %s\n", *p++);
+}
+
+static int
+parse_args(mrb_state *mrb, int argc, char **argv, struct _args *args)
+{
+  char **origargv = argv;
+  static const struct _args args_zero = { 0 };
+
+  *args = args_zero;
+
+  for (argc--,argv++; argc > 0; argc--,argv++) {
+    char *item;
+    if (argv[0][0] != '-') break;
+
+    if (strlen(*argv) <= 1) {
+      argc--; argv++;
+      args->rfp = stdin;
+      break;
+    }
+
+    item = argv[0] + 1;
+    switch (*item++) {
+    case 'b':
+      args->mrbfile = 1;
+      break;
+    case 'c':
+      args->check_syntax = 1;
+      break;
+    case 'e':
+      if (item[0]) {
+        goto append_cmdline;
+      }
+      else if (argc > 1) {
+        argc--; argv++;
+        item = argv[0];
+append_cmdline:
+        if (!args->cmdline) {
+          char *buf;
+
+          buf = (char *)mrb_malloc(mrb, strlen(item)+1);
+          strcpy(buf, item);
+          args->cmdline = buf;
+        }
+        else {
+          args->cmdline = (char *)mrb_realloc(mrb, args->cmdline, strlen(args->cmdline)+strlen(item)+2);
+          strcat(args->cmdline, "\n");
+          strcat(args->cmdline, item);
+        }
+      }
+      else {
+        printf("%s: No code specified for -e\n", *origargv);
+        return 0;
+      }
+      break;
+    case 'v':
+      mrb_show_version(mrb);
+      args->verbose = 1;
+      break;
+    case '-':
+      if (strcmp((*argv) + 2, "version") == 0) {
+        mrb_show_version(mrb);
+        exit(0);
+      }
+      else if (strcmp((*argv) + 2, "verbose") == 0) {
+        args->verbose = 1;
+        break;
+      }
+      else if (strcmp((*argv) + 2, "copyright") == 0) {
+        mrb_show_copyright(mrb);
+        exit(0);
+      }
+      else return -3;
+      return 0;
+    default:
+      return -4;
+    }
+  }
+
+  if (args->rfp == NULL && args->cmdline == NULL) {
+    if (*argv == NULL) args->rfp = stdin;
+    else {
+      args->rfp = fopen(argv[0], args->mrbfile ? "rb" : "r");
+      if (args->rfp == NULL) {
+        printf("%s: Cannot open program file. (%s)\n", *origargv, *argv);
+        return 0;
+      }
+      args->fname = 1;
+      args->cmdline = argv[0];
+      argc--; argv++;
+    }
+  }
+  args->argv = (char **)mrb_realloc(mrb, args->argv, sizeof(char*) * (argc + 1));
+  memcpy(args->argv, argv, (argc+1) * sizeof(char*));
+  args->argc = argc;
+
+  return 0;
+}
+
+static void
+cleanup(mrb_state *mrb, struct _args *args)
+{
+  if (args->rfp && args->rfp != stdin)
+    fclose(args->rfp);
+  if (args->cmdline && !args->fname)
+    mrb_free(mrb, args->cmdline);
+  if (args->argv)
+    mrb_free(mrb, args->argv);
+  mrb_close(mrb);
+}
+
+static void
+showcallinfo(mrb_state *mrb)
+{
+  mrb_callinfo *ci;
+  mrb_int ciidx;
+  const char *filename, *method, *sep;
+  int i, line;
+
+  printf("trace:\n");
+  ciidx = mrb_fixnum(mrb_obj_iv_get(mrb, mrb->exc, mrb_intern(mrb, "ciidx")));
+  if (ciidx >= mrb->ciend - mrb->cibase)
+    ciidx = 10; /* ciidx is broken... */
+
+  for (i = ciidx; i >= 0; i--) {
+    ci = &mrb->cibase[i];
+    filename = "(unknown)";
+    line = -1;
+
+    if (MRB_PROC_CFUNC_P(ci->proc)) {
+      continue;
+    }
+    else {
+      mrb_irep *irep = ci->proc->body.irep;
+      if (irep->filename != NULL)
+        filename = irep->filename;
+      if (irep->lines != NULL && i+1 <= ciidx) {
+        mrb_code *pc = mrb->cibase[i+1].pc;
+        if (irep->iseq <= pc && pc < irep->iseq + irep->ilen) {
+          line = irep->lines[pc - irep->iseq - 1];
+        }
+      }
+    }
+    if (ci->target_class == ci->proc->target_class)
+      sep = ".";
+    else
+      sep = "#";
+
+    method = mrb_sym2name(mrb, ci->mid);
+    printf("\t[%d] %s:%d%s%s%s%s\n",
+    	   i, filename, line,
+	   method ? ":in " : "",
+	   method ? mrb_class_name(mrb, ci->proc->target_class) : "",
+	   method ? sep : "",
+	   method ? method : "");
+  }
+}
+
+int
+eMain_main( CELLIDX idx, int argc, const char **argv)
+{
+  CELLCB   *p_cellcb = GET_CELLCB( idx );
+  mrb_state *mrb = mrb_open();
+  int n = -1;
+  int i;
+  struct _args args;
+  mrb_value ARGV;
+
+  cInit_initializeBridge( mrb );
+
+  if (mrb == NULL) {
+    fprintf(stderr, "Invalid mrb_state, exiting mruby\n");
+    return EXIT_FAILURE;
+  }
+
+  n = parse_args(mrb, argc, (char **)argv, &args);
+  if (n < 0 || (args.cmdline == NULL && args.rfp == NULL)) {
+    cleanup(mrb, &args);
+    usage(argv[0]);
+    return n;
+  }
+
+  ARGV = mrb_ary_new_capa(mrb, args.argc);
+  for (i = 0; i < args.argc; i++) {
+    mrb_ary_push(mrb, ARGV, mrb_str_new(mrb, args.argv[i], strlen(args.argv[i])));
+  }
+  mrb_define_global_const(mrb, "ARGV", ARGV);
+
+  if (args.mrbfile) {
+    n = mrb_load_irep(mrb, args.rfp);
+    if (n < 0) {
+      fprintf(stderr, "failed to load mrb file: %s\n", args.cmdline);
+    }
+    else if (!args.check_syntax) {
+      mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_top_self(mrb));
+      n = 0;
+      if (mrb->exc) {
+        showcallinfo(mrb);
+        p(mrb, mrb_obj_value(mrb->exc));
+        n = -1;
+      }
+    }
+  }
+  else {
+    mrbc_context *c = mrbc_context_new(mrb);
+    mrb_value v;
+
+    if (args.verbose)
+      c->dump_result = 1;
+    if (args.check_syntax)
+      c->no_exec = 1;
+
+    if (args.rfp) {
+      mrbc_filename(mrb, c, args.cmdline ? args.cmdline : "-");
+      v = mrb_load_file_cxt(mrb, args.rfp, c);
+    }
+    else {
+      mrbc_filename(mrb, c, "-e");
+      v = mrb_load_string_cxt(mrb, args.cmdline, c);
+    }
+    mrbc_context_free(mrb, c);
+    if (mrb->exc) {
+      if (!mrb_undef_p(v)) {
+        showcallinfo(mrb);
+        p(mrb, mrb_obj_value(mrb->exc));
+      }
+      n = -1;
+    }
+    else if (args.check_syntax) {
+      printf("Syntax OK\n");
+    }
+  }
+  cleanup(mrb, &args);
+
+  return n == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
+}
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tSCharPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tSCharPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tSCharPointer.c	(revision 317)
@@ -0,0 +1,52 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tSCharPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+//GET_SET_INT( SChar, schar_t )
+//POINTER_CLASS( SChar, schar_t )
+GET_SET_INT( SChar, char_t )
+POINTER_CLASS( SChar, char_t )
+#ifndef  TECS_Use_MrbString_for_CharPointer
+//CHECK_AND_GET_POINTER( SChar, schar_t )
+CHECK_AND_GET_POINTER( SChar, char_t )
+#else
+CHECK_AND_GET_CHAR_POINTER( SChar, schar_t )
+CHECK_AND_GET_CHAR_POINTER_MOD( SChar, schar_t )
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tSCharPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	struct RClass *c;
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	c=tecs_init_SCharPointer( mrb, TECS );
+	mrb_define_method(mrb, c, "to_s", CharPointer_to_s, MRB_ARGS_NONE());
+	mrb_define_method(mrb, c, "from_s", CharPointer_from_s, MRB_ARGS_REQ(1));
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tShortPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tShortPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tShortPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tShortPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( Short, short )
+POINTER_CLASS( Short, short )
+CHECK_AND_GET_POINTER( Short, short )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tShortPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_ShortPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tTECSInitializer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tTECSInitializer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tTECSInitializer.c	(revision 317)
@@ -0,0 +1,60 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * TECS             struct RClass *  VAR_TECS        
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cInitialize  signature: nMruby_sInitializeTECSBridge context: task
+ *   void           cInitialize_initializeBridge( subscript, const mrb_state* mrb, const struct RClass * TECS );
+ *       subscript:  0...(NCP_cInitialize-1)
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tTECSInitializer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tTECSInitializer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(CELLIDX idx, const mrb_state* mrb)
+{
+	CELLCB	*p_cellcb;
+	int      i;
+	struct RClass *TECS;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	TECS = mrb_define_module( (mrb_state *)mrb, "TECS" );
+	// mrb: const mrb_state * => mrb_state *
+    VAR_TECS = TECS;
+
+	for( i = 0; i < NCP_cInitialize; i++ )
+		cInitialize_initializeBridge( i, (mrb_state*)mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUCharPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUCharPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUCharPointer.c	(revision 317)
@@ -0,0 +1,49 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUCharPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UChar, uchar_t )
+POINTER_CLASS( UChar, uchar_t )
+#ifndef  TECS_Use_MrbString_for_CharPointer
+CHECK_AND_GET_POINTER( UChar, uchar_t )
+#else
+CHECK_AND_GET_CHAR_POINTER( UChar, uchar_t )
+CHECK_AND_GET_CHAR_POINTER_MOD( UChar, uchar_t )
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUCharPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	struct RClass *c;
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	c=tecs_init_UCharPointer( mrb, TECS );
+	mrb_define_method(mrb, c, "to_s", CharPointer_to_s, MRB_ARGS_NONE());
+	mrb_define_method(mrb, c, "from_s", CharPointer_from_s, MRB_ARGS_REQ(1));
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt16Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt16Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt16Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUInt16Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UInt16, uint16_t )
+POINTER_CLASS( UInt16, uint16_t )
+CHECK_AND_GET_POINTER( UInt16, uint16_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUInt16Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UInt16Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt32Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt32Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt32Pointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUInt32Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UInt32, uint32_t )
+POINTER_CLASS( UInt32, uint32_t )
+CHECK_AND_GET_POINTER( UInt32, uint32_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUInt32Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UInt32Pointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt64Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt64Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt64Pointer.c	(revision 317)
@@ -0,0 +1,41 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUInt64Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UInt64, uint64_t )
+POINTER_CLASS( UInt64, uint64_t )
+CHECK_AND_GET_POINTER( UInt64, uint64_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUInt64Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UInt64Pointer( mrb, TECS );
+
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt8Pointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt8Pointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUInt8Pointer.c	(revision 317)
@@ -0,0 +1,41 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUInt8Pointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UInt8, uint8_t )
+POINTER_CLASS( UInt8, uint8_t )
+CHECK_AND_GET_POINTER( UInt8, uint8_t )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUInt8Pointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UInt8Pointer( mrb, TECS );
+
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUIntPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUIntPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUIntPointer.c	(revision 317)
@@ -0,0 +1,41 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUIntPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UInt, unsigned int )
+POINTER_CLASS( UInt, unsigned int )
+CHECK_AND_GET_POINTER( UInt, unsigned int )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUIntPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UIntPointer( mrb, TECS );
+
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tULongPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tULongPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tULongPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tULongPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( ULong, unsigned long )
+POINTER_CLASS( ULong, unsigned long )
+CHECK_AND_GET_POINTER( ULong, unsigned long )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tULongPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_ULongPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUShortPointer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUShortPointer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/nMruby_tUShortPointer.c	(revision 317)
@@ -0,0 +1,40 @@
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+#include "nMruby_tUShortPointer_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+GET_SET_INT( UShort, unsigned short )
+POINTER_CLASS( UShort, unsigned short )
+CHECK_AND_GET_POINTER( UShort, unsigned short )
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eInitialize
+ * entry port: eInitialize
+ * signature:  nMruby_sInitializeTECSBridge
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eInitialize_initializeBridge
+ * name:         eInitialize_initializeBridge
+ * global_name:  nMruby_tUShortPointer_eInitialize_initializeBridge
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eInitialize_initializeBridge(mrb_state* mrb, struct RClass * TECS)
+{
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	(void)tecs_init_UShortPointer( mrb, TECS );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tMruby.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tMruby.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tMruby.cdl	(revision 317)
@@ -0,0 +1,82 @@
+
+/*
+ *  Copyright (C) 2012 by Ubiquitous Computing and Networking Laboratory
+ *                Ritsumeikan Univ., JAPAN
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+//import(<syssvc/tSerialPort.cdl>);
+//import(<kernel.cdl>);
+
+import(<mruby.cdl>);
+
+namespace nMruby{
+  celltype tMruby{
+    entry sTaskBody eMrubyBody;
+    attr{
+      [omit]char_t *mrubyFile;
+      char_t *irep=C_EXP("&$cell_global$_irep");
+    };
+    
+    /* writeé¢æ°ã®æ¥ç¶å
+ */
+//    [optional] 	call sSerialPort cSerialPort;
+    [optional]  call sInitializeBridge cInit;
+    
+    FACTORY{
+      write("Makefile.tecsgen", "clean_mrb_c :");
+      write("Makefile.tecsgen", "	rm -f $(MRB_C)"); 
+    };
+    factory{
+      write("Makefile.tecsgen", "POST_TECSGEN_TARGET := $(POST_TECSGEN_TARGET) $cell_global$_mrb.c");
+      write("Makefile.tecsgen", "$cell_global$_mrb.c : %s tecs.timestamp Makefile", mrubyFile);
+      write("Makefile.tecsgen", "	$(MRBC) -B$cell_global$_irep -o$cell_global$_mrb.c %s", mrubyFile);
+      write("Makefile.tecsgen", "TECS_COBJS := $(TECS_COBJS) $cell_global$_mrb.o");
+      write("Makefile.tecsgen", "MRB_C := $(MRB_C) $cell_global$_mrb.c");
+      write("$ct_global$_factory.h","extern const char_t *$cell_global$_irep;");
+    };
+  };
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tecs_mruby.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tecs_mruby.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/mruby/tecs_mruby.h	(revision 317)
@@ -0,0 +1,47 @@
+#ifndef tecs_mruby_h__
+#define tecs_mruby_h__
+
+#ifndef TECSGEN
+
+// tecsgen doesn't include actual mruby.h
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+
+#include "TECSPointer.h"
+#include "TECSStruct.h"
+
+#if  ! defined( MRUBY_RELEASE_MAJOR ) || MRUBY_RELEASE_MAJOR == 1 && MRUBY_RELEASE_MINOR < 2
+#ifndef MRB_ARGS_REQ
+#define MRB_ARGS_REQ(n)     ARGS_REQ(n)
+#define MRB_ARGS_OPT(n)     ARGS_OPT(n)
+#define MRB_ARGS_ARG(n1,n2) ARGS_ARG(n1,n2)
+#define MRB_ARGS_REST()     ARGS_REST()
+#define MRB_ARGS_POST(n)    ARGS_POST(n)
+#define MRB_ARGS_KEY(n1,n2) ARGS_KEY(n1,n2)
+#define MRB_ARGS_BLOCK()    ARGS_BLOCK()
+#define MRB_ARGS_ANY()      ARGS_ANY()
+#define MRB_ARGS_NONE()     ARGS_NONE()
+#endif /* MRB_ARGS_REQ */
+#endif
+
+#if  ! defined( MRUBY_RELEASE_MAJOR )
+#define mrb_float_value( mrb, val )  mrb_float_value( val )
+#endif
+
+#else
+
+/*
+ * fake tecsgen because tecsgen cannot accept actual mruby.h in case of below.
+ *   types:   long long, long long int
+ *   special keyword __attribute__(x), __extension__
+ */
+typedef int mrb_state;
+struct  RClass {int dummy;};
+
+typedef int CELLCB;
+
+#endif /* TECSGEN */
+
+#endif /* tecs_mruby_h__ */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/posix/posix.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/posix/posix.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/posix/posix.cdl	(revision 317)
@@ -0,0 +1,7 @@
+
+namespace nPosix {
+	signature sMain{
+		int  main( [in]int argc, [in,size_is(argc),string]const char **argv );
+	};
+};
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/PPAllocator.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/PPAllocator.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/PPAllocator.cdl	(revision 317)
@@ -0,0 +1,103 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/*
+ * PPAlloc: Push Pop Allocator
+ *
+ * allocate ããéé ã§ deallocate ããªãã¦ã¯ãªããªã
+ * deallocate ã¯ãã¾ã¨ãã¦è¡ããã¨ãã§ãã
+ * ä¾ãã°æåã« allocate ãããé åã deallocate ããã¨ããã¹ã¦ã® allocate ãããé åã deallocate ãããã¨ã«ãªã
+ * æä»å¶å¾¡ãã¦ããªãããåä¸ã®ã¿ã¹ã¯ã«å²ä»ãã¦ä½¿ç¨ãã
+ */
+
+[deviate]   // alloc ãé¸è±ã«ãªã
+signature sPPAllocator {
+	/*
+	 * size ã§æå®ãããå¤§ããã®ã¡ã¢ãªé åãã¢ã­ã±ã¼ããã
+	 * ã¡ã¢ãªé åãç¢ºä¿ãããå ´å *ptr ã«ã¡ã¢ãªé åã®ã¢ãã¬ã¹ãæ ¼ç´ãã¦ E_OK ãè¿ã
+	 * ååãªç©ºãé åããªãå ´å E_NOMEM ãè¿ã
+	 */
+	ER  alloc( [in]uint32_t size, [out]void **ptr );
+	/*
+	 * ã¡ã¢ãªããã¢ã­ã±ã¼ããã
+	 * alloc ã§ç²å¾ãããã¤ã³ã¿ãå¼ãæ° ptr ã«æå®ãã
+	 * alloc ã§ç²å¾ããã¡ã¢ãªé åã alloc ããã®ã¨ã¯éé ã« dealloc ããªãã¦ã¯ãªããªã
+	 * ãã¹ã¦ã dealloc ããã«ã¯ãæåã« alloc ãããã¡ã¢ãªé åã dealloc ãããã¨ã§è¡ããã¨ãã§ãã
+	 * alloc ãç²å¾ããã¡ã¢ãªé åããã¹ã¦ dealloc ããåã«ãåã³ alloc ãããã¨ã¯ã§ãã
+	 * ãã®å ´åã§ããdealloc ãã¦ããªãã¡ã¢ãªé åã alloc ããã®ã¨ã¯éé ã« dealloc ããªãã¦ã¯ãªããªã
+	 *
+	 * ptr ã®å¤ã buf <= ptr < buf+allocated_size ãæºãããã©ããæ¤æ»ããã
+	 * ptr ã®å¤ãä¸æ­£ã®å ´å E_PAR ãè¿ã
+	 */
+	ER  dealloc( [in]const void *ptr );
+
+    /*
+	 * PPAllocator ã»ã«ã®å²ä»ãæ¸ã¿ã¡ã¢ãªããã¹ã¦è§£æ¾ãã
+	 * ãã®é¢æ°ã¯å¿
+ãæåãã
+	 */
+    ER  dealloc_all(void);
+};
+
+celltype tPPAllocator {
+	entry  sPPAllocator ePPAllocator;
+	attr {
+		uint32_t   heapSize;
+	};
+	var {
+		[size_is(heapSize)]
+			int8_t  *buf;
+		uint32_t   allocatedSize;
+	};
+};
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/RPCTask.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/RPCTask.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/RPCTask.cdl	(revision 317)
@@ -0,0 +1,142 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/*
+ * unmarshaler ã® main ã®ã·ã°ããã£
+ */
+signature sUnmarshalerMain {
+	ER	main(void);
+};
+
+///////////////// å°æãã£ã³ãã«ç¨ã®å®ç¾© ////////////////
+/*
+ * CELLTYPE: å°æãã£ã³ãã«ç¨ã®ã¿ã¹ã¯ã¡ã¤ã³
+ */
+celltype tRPCDedicatedTaskMain {			// Transparent RPC ã§ç¨ãã
+	entry	sTaskBody			eMain;
+	call	sUnmarshalerMain	cMain;
+};
+
+celltype tRPCDedicatedTaskMainWithOpener {	// Opaque RPC ã§ç¨ãã
+	entry	sTaskBody				eMain;
+	call	sUnmarshalerMain		cMain;
+	call	sServerChannelOpener	cOpener;
+	attr {
+		RELTIM	initialDelay = 0;	// sec
+		RELTIM	reopenDelay = 1;	// sec
+	};
+	require tKernel.eKernel;
+};
+
+///////////////// å
+±æãã£ã³ãã«ç¨ã®å®ç¾© ////////////////
+/*
+ * CONST: å
+±æãã£ã³ãã«ãããã®ãã¸ãã¯
+ */
+const uint16_t RPC_CHANNEL_MAN_SOP_MAGIC   = (0x3141);  // Beginning of using shared channel
+const uint16_t RPC_CHANNEL_MAN_EOP_MAGIC   = (0x2718);  // End of using shared channel
+
+/*
+ * CELLTYPE: å
+±æãã£ã³ãã«ããã¼ã¸ã£
+ * REM:      å¼ã³å
+å´ã«ç½®ããã£ã³ãã«ããã¼ã¸ã£
+ *           eSemaphore ãå¼ã³åºãããã¨ããã£ã³ãã«ãã­ãã¯ããã¨ã¨ãã«ã
+ *           ãã£ã³ãã«çªå·ãéåºãã
+ */
+celltype tRPCSharedChannelMan {
+	entry	sSemaphore	eSemaphore[];
+	call	sSemaphore	cSemaphore;
+	call	sTDR		cClientSideTDR;
+};
+
+
+/*
+ * CELLTYPE: å
+±æãã£ã³ãã«ç¨ã®ã¿ã¹ã¯ã¡ã¤ã³
+ * REM:      å¼ã³å
+å´ã«ç½®ãã¿ã¹ã¯
+ *           ãã£ã³ãã«çªå·ãåãåºãããã£ã³ãã«çªå·ã® cTaskBody ãå¼ã³åºã
+ */
+celltype tRPCSharedTaskMain {
+	entry	sTaskBody	eMain;
+
+	call	sUnmarshalerMain	cUnmarshalAndCallFunction[];
+	call	sTDR		cServerSideTDR;
+
+	require	tSysLog.eSysLog;
+
+	var {
+		int16_t	channelNo;	/* é
+åæ·»æ° + 1 */
+	};
+};
+
+celltype tRPCSharedTaskMainWithOpener {	// Opaque RPC ã§ç¨ãã
+	entry	sTaskBody			eMain;
+	call	sUnmarshalerMain	cUnmarshalAndCallFunction[];
+	call	sTDR				cServerSideTDR;
+	call	sServerChannelOpener cOpener;
+	require	tSysLog.eSysLog;
+	require tKernel.eKernel;
+
+	attr {
+		RELTIM	initialDelay = 0;	// sec
+		RELTIM	reopenDelay = 1;	// sec
+	};
+	var {
+		int16_t	channelNo;	/* é
+åæ·»æ° + 1 */
+	};
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/TDR.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/TDR.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/TDR.cdl	(revision 317)
@@ -0,0 +1,193 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+import_C( "tecs_rpc.h" );
+
+// Straight Order TDR
+const uint32_t TDR_SOP_MAGIC1   = (0x672A);  // Client to Server
+const uint32_t TDR_SOP_MAGIC2   = (0x561E);  // Server to Client
+const uint32_t TDR_EOP_MAGIC1   = (0x5A3C);  // è¿ä¿¡ãå¾
+ã¤ (åæå¼åºã)
+const uint32_t TDR_EOP_MAGIC2   = (0x6D5E);  // è¿ä¿¡ãå¾
+ããªã(éåæå¼åºãã¾ãã¯ãªã¿ã¼ã³)
+
+// Straight Order TDR for SharedChannel
+const uint32_t TDR_SHSOP_MAGIC1   = (0x98D5);  // Client to Server
+const uint32_t TDR_SHSOP_MAGIC2   = (0xA9E1);  // Server to Client
+const uint32_t TDR_SHEOP_MAGIC1   = (0xB5C3);  // è¿ä¿¡ãå¾
+ã¤ (åæå¼åºã)
+const uint32_t TDR_SHEOP_MAGIC2   = (0x92A1);  // è¿ä¿¡ãå¾
+ããªã(éåæå¼åºãã¾ãã¯ãªã¿ã¼ã³)
+
+/*
+ * TDR: TECS Data Representation layer
+ */
+[deviate]         /* get_intptr ãé¸è±ã«ãªã */
+signature sTDR {  /* TECS Data Representation */
+
+	/* å¶å¾¡é¢æ° */
+
+	/* ãã£ã³ãã«ã®ãªã»ãã */
+	ER	reset( void );	/* éä¿¡ãã£ã³ãã«ã®ãªã»ãã */
+						/* éä¸­ã§ã¨ã©ã¼ãçºçããéä¿¡ã¾ãã¯åä¿¡ãç¶è¡ã§ããªãã£ãã¨ãã¯ãªã»ãããã */
+						/* ä¸æ¹ããªã»ããããããã¨ãä»æ¹ã¯ RESET ã¨ã©ã¼ãè¿ã */
+						/* ç¢ºèªã§ããªãã¨ãã¯ããã®ãã£ãã«ã¯æ¾æ£ãããããªã */
+
+	/* ãã¸ãã¯ã³ã¼ãã®éåä¿¡ */
+	ER	sendSOP( [in]bool_t b_client );     /* StartOfPacket magic ãéä¿¡ */
+	ER	receiveSOP( [in]bool_t b_client );  /* StartOfPacket magic ãåä¿¡ */
+						 /* b_client: ã¯ã©ã¤ã¢ã³ãå´ãªã true, ãµã¼ãã¼å´ãªã false */
+
+	/* ãã¸ãã¯ã³ã¼ãã®éåä¿¡ */
+	//	ER	sendSHSOP( [in]bool_t b_client );     /* StartOfPacket magic ãéä¿¡ */
+	//	ER	receiveSHSOP( [in]bool_t b_client );  /* StartOfPacket magic ãåä¿¡ */
+						 /* b_client: ã¯ã©ã¤ã¢ã³ãå´ãªã true, ãµã¼ãã¼å´ãªã false */
+
+	ER	sendEOP( [in]bool_t b_continue );   /* EndOfPacket magic ãéä¿¡ï¼ãã±ããã®æãã ããè¡ãï¼ */
+	ER	receiveEOP( [in]bool_t b_continue );/* EndOfPacket magic ãåä¿¡ */
+                        /* b_continue: åæå¼ã³åºãã®ã¯ã©ã¤ã¢ã³ãå´ãªã true,
+                           éåæå¼ã³åºãã®ã¯ã©ã¤ã¢ã³ãå´ã¾ãã¯ãµã¼ãã¼å´ãªã false */
+
+	/* ãã¼ã¿éåä¿¡é¢æ° */
+
+	/* æ´æ°å (æ¨å¥¨) */
+	ER	putInt8( [in]int8_t in ); 
+	ER	putInt16( [in]int16_t in ); 
+	ER	putInt32( [in]int32_t in ); 
+	ER	putInt64( [in]int64_t in ); 
+	ER	putInt128( [in]int128_t in ); 
+  
+	ER	getInt8( [out]int8_t *out );
+	ER	getInt16( [out]int16_t *out );
+	ER	getInt32( [out]int32_t *out );
+	ER	getInt64( [out]int64_t *out );
+	ER	getInt128( [out]int128_t *out );
+
+	/* ç¡ç¬¦å·æ´æ°å (æ¨å¥¨) */
+	ER	putUInt8( [in]uint8_t in ); 
+	ER	putUInt16( [in]uint16_t in ); 
+	ER	putUInt32( [in]uint32_t in ); 
+	ER	putUInt64( [in]uint64_t in ); 
+	ER	putUInt128( [in]uint128_t in ); 
+  
+	ER	getUInt8( [out]uint8_t *out );
+	ER	getUInt16( [out]uint16_t *out );
+	ER	getUInt32( [out]uint32_t *out );
+	ER	getUInt64( [out]uint64_t *out );
+	ER	getUInt128( [out]uint128_t *out );
+
+	/* æå­åï¼æ¨å¥¨ã8bitï¼ */
+	ER	putChar( [in]char_t in ); 
+	ER	getChar( [out]char_t *out ); 
+
+	/* Bool å */
+	ER	putBool( [in]bool_t in ); 
+	ER	getBool( [out]bool_t *out ); 
+
+	/* æµ®åå°æ°å */
+	ER	putFloat32( [in]float32_t in );
+	ER	putDouble64( [in]double64_t in );
+	ER	getFloat32( [out]float32_t *out );
+	ER	getDouble64( [out]double64_t *out );
+
+
+	/* éæ¨å¥¨ã®å(æç¬¦å·) */
+	ER	putSChar( [in]schar_t in );
+	ER	putShort( [in]short_t in ); 
+	ER	putInt( [in]int_t in ); 
+	ER	putLong( [in]long_t in ); 
+
+	ER	getSChar( [out]schar_t *out ); 
+	ER	getShort( [out]short_t *out ); 
+	ER	getInt( [out]int_t *out ); 
+	ER	getLong( [out]long_t *out ); 
+
+
+	/* éæ¨å¥¨ã®å(ç¡ç¬¦å·) */
+	ER	putUChar( [in]uchar_t in ); 
+	ER	putUShort( [in]ushort_t in ); 
+	ER	putUInt( [in]uint_t in ); 
+	ER	putULong( [in]ulong_t in ); 
+
+	ER	getUChar( [out]unsigned char *out ); 
+	ER	getUShort( [out]ushort_t *out ); 
+	ER	getUInt( [out]uint_t *out ); 
+	ER	getULong( [out]ulong_t *out ); 
+
+	ER	putIntptr( [in]const intptr_t ptr );
+	ER	getIntptr( [out]intptr_t *ptr );
+};
+
+// Straight Order TECS Data Representation (Straight means no endian-conversion is done)
+celltype tTDR {
+	call	sChannel	cChannel;
+	[inline]
+		entry	sTDR	eTDR;
+
+	var {
+		TMO	tmo = C_EXP( "TMO_FEVR" );
+	};
+	require tSysLog.eSysLog;
+};
+
+// Network Byte Order (Big-endian) TECS Data Representation (Data are always sent in big-endian)
+celltype tNBOTDR {
+	call	sChannel	cChannel;
+	[inline]
+		entry	sTDR	eTDR;
+
+	var {
+		TMO	tmo = C_EXP( "TMO_FEVR" );
+	};
+	require tSysLog.eSysLog;
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc.cdl	(revision 317)
@@ -0,0 +1,75 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/*
+ * TECS RPC ã«é¢ããå®ç¾©
+ */
+
+/* ãã£ã³ãã« ã·ã°ããã£ */
+import( <sChannel.cdl> );
+
+/* TDR ã·ã°ããã£ & ã»ã«ã¿ã¤ã */
+import( <TDR.cdl> );
+
+/* ãã£ã³ãã«ã»ã«ã¿ã¤ã */
+/* ãã£ã³ãã«ã»ã«ã¿ã¤ãã¯ãå¿
+è¦ãªãã®ãåã¢ããªã±ã¼ã·ã§ã³ã§ import ãã */
+// import( <tDataqueueOWChannel.cdl> );
+// import( <tSocketChannel.cdl> );
+// import( <tTINETChannel.cdl> );
+
+/* ã¿ã¹ã¯ ã»ã«ã¿ã¤ã */
+import( <RPCTask.cdl> );
+import( <PPAllocator.cdl> );
+
+import( <sRPCErrorHandler.cdl> );
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc_string.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc_string.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/rpc_string.h	(revision 317)
@@ -0,0 +1,173 @@
+/*
+ *
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+#ifndef RPC_STRING_H
+#define RPC_STRING_H
+
+#include <string.h>
+
+/* GenParamCopy.rb ã§çæãã STRLEN, STRNLEN é¢æ°ã®å®ç¾© */
+/* ç¾ç¶ã§ã¯ short, int, long, int128_t ããµãã¼ãããªã */
+
+#define   STRLEN8( str )    strlen( (char *)str )
+
+/*
+ * STRNLEN
+ *  marshaler, unmarshaler ã¯ strnlen ãä½¿ãï¼
+ *  ãããã¡ãªã¼ãã¼ã©ã³ã¸ã®èæ§ãæç¢ºã«ããããï¼
+ *  ããããstrnlen ã¯ ANSI-C æ¨æºã®ã©ã¤ãã©ãªé¢æ°ã§ã¯ãªããããå®è£
+ããã¦ããªãã±ã¼ã¹ããã
+ *  GNU (Linux), VC++ ã§ã¯ä½¿ç¨ã§ããããMacOS ã§ã¯ä½¿ç¨ã§ããªã
+ *  ï¼ä»ã®çµè¾¼ã¿ç¨ OS ã§ã®å®è£
+ç¶æ³ãä¸æï¼
+ *  å°ããªé¢æ°ã§ããã®ã§ inline é¢æ°ã¨ãã¦å®è£
+ãã¦ãã
+ */
+
+#ifndef USE_STRNLEN_LIB
+#define   STRNLEN8( str, n )    strnlen( (char *)str, n )
+
+#else
+
+Inline size_t
+#define   STRNLEN8( str, n )    STRNLEN8_( (uint8_t *)str, n )
+STRNLEN8_(const uint8_t *s, size_t maxlen)
+{
+    size_t  i;
+    for( i = 0; i < maxlen; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+#endif
+
+#define	STRLEN16( s )			STRLEN16_( (uint16_t *)s )
+#define	STRLEN32( s )			STRLEN32_( (uint32_t *)s )
+#define	STRLEN64( s )			STRLEN64_( (uint64_t *)s )
+
+#define	STRNLEN16( s, maxlen )	STRLEN16_( (uint16_t *)s, maxlen )
+#define	STRNLEN32( s, maxlen )	STRLEN32_( (uint32_t *)s, maxlen )
+#define	STRNLEN64( s, maxlen )	STRLEN64_( (uint64_t *)s, maxlen )
+
+/** STRLENnn_ nn:16,32,64**/
+Inline size_t
+STRLEN16_(const uint16_t *s )
+{
+    size_t  i;
+    for( i = 0; ; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+Inline size_t
+STRLEN32_(const uint32_t *s )
+{
+    size_t  i;
+    for( i = 0; ; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+Inline size_t
+STRLEN64_(const uint64_t *s )
+{
+    size_t  i;
+    for( i = 0; ; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+/** STRNLENnn_ nn:16,32,64**/
+Inline size_t
+STRNLEN16_(const uint16_t *s, size_t maxlen)
+{
+    size_t  i;
+    for( i = 0; i < maxlen; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+Inline size_t
+STRNLEN32_(const uint32_t *s, size_t maxlen)
+{
+    size_t  i;
+    for( i = 0; i < maxlen; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+Inline size_t
+STRNLEN64_(const uint64_t *s, size_t maxlen)
+{
+    size_t  i;
+    for( i = 0; i < maxlen; i++ )
+        if( *s++ == 0 )
+            break;
+
+    return  i;
+}
+
+
+#endif /* RPC_STRING_H */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sChannel.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sChannel.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sChannel.cdl	(revision 317)
@@ -0,0 +1,74 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+signature	sServerChannelOpener {
+	ER		open( void );
+	ER		close( void );
+};
+
+signature	sChannel {
+	/* éã */
+	ER		send( [in,size_is(size)] const int8_t  *buf, [in]int16_t  size, [in]TMO tmo );
+	/* éä¿¡çµããã®æãåºãï¼ãã±ããã®çµããã§ä¸åã ãå¼åºã */
+	ER		flush( [in]TMO tmo );       /* ãããã¡ãªã³ã°ãã¦ããå ´åã®æãã ã */
+
+	/* åãåã */
+	ER_UINT	receive( [out,size_is(size)] int8_t  *buf, [in]int16_t  size, [in]TMO tmo );
+
+	/* ãã±ããã®çµããã¾ã§åä¿¡ãã (flush ã®é)ãçµããã«éãã¦ããªãå ´å E_ILUSE */
+	ER		end_receive( void );
+
+	/* ãªã»ãã */
+	ER		reset( void );       /* ãã£ã³ãã«ããªã»ãã */
+};
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sRPCErrorHandler.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sRPCErrorHandler.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/sRPCErrorHandler.cdl	(revision 317)
@@ -0,0 +1,92 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+
+/* client side state */
+const	int16_t	RPCSTATE_CLIENT_GET_SEM		= 1;
+const	int16_t	RPCSTATE_CLIENT_SEND_SOP	= 2;
+const	int16_t	RPCSTATE_CLIENT_SEND_BODY	= 3;
+const	int16_t	RPCSTATE_CLIENT_SEND_EOP	= 4;
+const	int16_t	RPCSTATE_CLIENT_EXEC		= 5;
+const	int16_t	RPCSTATE_CLIENT_RECV_SOP	= 6;
+const	int16_t	RPCSTATE_CLIENT_RECV_BODY	= 7;
+const	int16_t	RPCSTATE_CLIENT_RECV_EOP	= 8;
+const	int16_t	RPCSTATE_CLIENT_RELEASE_SEM	= 9;
+
+/* server side state */
+const	int16_t	RPCSTATE_SERVER_GET_SEM		= 11;
+const	int16_t	RPCSTATE_SERVER_RECV_SOP	= 12;
+const	int16_t	RPCSTATE_SERVER_RECV_BODY	= 13;
+const	int16_t	RPCSTATE_SERVER_RECV_EOP	= 14;
+const	int16_t	RPCSTATE_SERVER_EXEC		= 15;
+const	int16_t	RPCSTATE_SERVER_SEND_SOP	= 16;
+const	int16_t	RPCSTATE_SERVER_SEND_BODY	= 17;
+const	int16_t	RPCSTATE_SERVER_SEND_EOP	= 18;
+const	int16_t	RPCSTATE_SERVER_RELEASE_SEM	= 19;
+
+/* error hadler */
+signature sRPCErrorHandler {
+	ER	errorOccured( [in]int16_t func_id, [in]ER er, [in]int16_t state );
+};
+
+/*
+ * å¼ã³å
+å´ã§ã¯ state ã RPCSTATE_CLIENT_EXEC ã¨ç­ãããå¤§ããå ´åã
+ * å¼ã³å
+å´ã§ã¯ state ã RPCSTATE_SERVER_EXEC ã¨ç­ãããå¤§ããå ´åã
+ * å¼ã³å
+é¢æ°ã®å¼ã³åºãã«ã¯æåãã¦ããã
+ *
+ * RPCErrorHandler ãå¼ã³åºãããæç¹ã§ãsend/receive å¼æ°ã®è§£æ¾ã¯çµãã£ã¦ããã
+ * ãã®ãããRPCErrorHandler ã®ä¸­ã§å¦çãæã¡åã£ã¦ã(ã¿ã¹ã¯ã®åèµ·åãªã©ãè¡ã£ã¦ã)ããããã«ããã¡ã¢ãªãªã¼ã¯ãèµ·ããªãã
+ */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueAdaptor_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueAdaptor_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueAdaptor_inline.h	(revision 317)
@@ -0,0 +1,236 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * #[</PREAMBLE>]# */
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eChannel
+ * entry port: eChannel
+ * signature:  sChannel
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eChannel_open
+ * name:         eChannel_open
+ * global_name:  tDataqueueAdaptor_eChannel_open
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_open(CELLIDX idx, const int8_t* arg, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_close
+ * name:         eChannel_close
+ * global_name:  tDataqueueAdaptor_eChannel_close
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_close(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_reset
+ * name:         eChannel_reset
+ * global_name:  tDataqueueAdaptor_eChannel_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	cEventflag_clear( 0 );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_send
+ * name:         eChannel_send
+ * global_name:  tDataqueueAdaptor_eChannel_send
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int     i;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = 0;
+	for( i = 0; i < size; i++ )
+		ercd |= cDataqueue_send( (intptr_t)((uint8_t)buf[ i ]) );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_flush
+ * name:         eChannel_flush
+ * global_name:  tDataqueueAdaptor_eChannel_flush
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_flush(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_receive
+ * name:         eChannel_receive
+ * global_name:  tDataqueueAdaptor_eChannel_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER_UINT
+eChannel_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
+{
+	ER_UINT ercd = E_OK;
+	CELLCB	*p_cellcb;
+	intptr_t data;
+	int     i;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	/* printf( "DQA: receive(%d) ", size ); */
+	for( i = 0; i < size; i++ ){
+		ercd = cDataqueue_receive( &data );
+		buf[i] = (int8_t)data;
+		if( ercd != E_OK )
+			break;
+	}
+	if( ercd != E_OK )
+		return(ercd);
+	else
+		return i;
+}
+
+/* #[<ENTRY_FUNC>]# eChannel_end_receive
+ * name:         eChannel_end_receive
+ * global_name:  tDataqueueAdaptor_eChannel_end_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eChannel_end_receive(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueOWChannel.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueOWChannel.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tDataqueueOWChannel.cdl	(revision 317)
@@ -0,0 +1,95 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+
+/*
+ *celltype::tDataqueueAdaptor
+ */
+celltype tDataqueueAdaptor {
+	[inline]
+		entry sChannel   eChannel;
+	call  sDataqueue cDataqueue;
+	call  sEventflag cEventflag;
+};
+
+/*
+ *composite::tDataqueueOWChannel
+ */
+composite tDataqueueOWChannel {
+	entry sTDR       eTDR;
+	entry sDataqueue eDataqueue;
+	entry sEventflag eEventflag;
+	attr {
+		// Queue ã®ããã©ã«ãã®ãµã¤ãº
+		uint_t	queueSize = 64;
+	};
+
+	cell  tDataqueue Dataqueue{
+		count = composite.queueSize;
+
+	};
+	cell  tEventflag Eventflag{
+		flagPattern = 0;
+	};
+	cell  tDataqueueAdaptor DataqueueAdaptor{
+		cDataqueue = Dataqueue.eDataqueue;
+		cEventflag = Eventflag.eEventflag;
+	};
+	cell  tTDR TDR {
+		cChannel = DataqueueAdaptor.eChannel;
+	};
+
+	composite.eTDR       => TDR.eTDR;
+	composite.eDataqueue => Dataqueue.eDataqueue;
+	composite.eEventflag => Eventflag.eEventflag;
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tNBOTDR_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tNBOTDR_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tNBOTDR_inline.h	(revision 317)
@@ -0,0 +1,1668 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * tmo              TMO              VAR_tmo         
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port: cChannel signature: sChannel context:task 
+ *   ER             cChannel_send( const int8_t* buf, int16_t size, TMO tmo );
+ *   ER             cChannel_flush( TMO tmo );
+ *   ER_UINT        cChannel_receive( int8_t* buf, int16_t size, TMO tmo );
+ *   ER             cChannel_end_receive( );
+ *   ER             cChannel_reset( );
+ * require port: signature:sSysLog context:task
+ *   ER             write( uint_t prio, const SYSLOG* p_syslog );
+ *   ER_UINT        read( SYSLOG* p_syslog );
+ *   ER             mask( uint_t logmask, uint_t lowmask );
+ *   ER             refer( T_SYSLOG_RLOG* pk_rlog );
+ *
+ * #[</PREAMBLE>]# */
+
+/*
+ * marhaler, unmarshaler ãä½¿ç¨ãã STRLEN é¢æ°ãå®ç¾©ãã
+ *  marshaler, unmarshaler ã¯å¿
+ã TDR ã¯ ã«çµåããããã
+ */
+#include	"rpc_string.h"
+
+/*
+ * Network Byte Order TECS Data Representation
+ *
+ *  NBOTDR is one of sTDR implementation and is default TDR for OpaqueRPC.
+ *  NBOTDR always sends and receives data in Big Endian (Network Byte Order).
+ *  So NBOTDR is useful with distributed hybrid systems.
+ */
+
+/*
+ * Macro Symbols:
+ * 1) endian
+ *  NBOTDR_BIGENDIAN
+ *  NBOTDR_LITTLEENDIAN
+ *   if these macros are not specified, endian is automatically decided.
+ * 2) size of each type in bits.
+ *  NBOTDR_LONG_BIT (32)
+ *  NBOTDR_SHORT_BIT (16)
+ *  NBOTDR_INT_BIT (32)
+ *  NBOTDR_INTPTR_BIT (32)
+ *   default value in parenthesises
+ *   normally use default value
+ */
+
+/*
+ * ç¡èª¿æ´åã ããããããæ«å®çãªå®è£
+ã«ãªã£ã¦ãã
+ * ã»ntohX(), htonX() ã¯ int64_t åã«å®ç¾©ããã¦ãã (32bitãªããªã¼ããããå¤§)
+ * ã»int128_t, uint128_t ã¯ tecs.h ã§ typedef ãããåã§ãã
+ * ã»BIGENDIAN å¤å®ã¯åçã«ãªã£ã¦ãã (æããæé©åã§å®æ°å¤å®ã«ããããã¨ã¯ãªã)
+ */
+
+#if defined( NBOTDR_BIGENDIAN )
+#define	IS_BIGENDIAN()	(1)
+# if defined( NBOTDR_LITTLEENDIAN )
+#   error  "Don't specify both NBOTDR_LITTLEENDIAN and NBOTDR_BIGENDIAN"
+# endif
+#elif defined( NBOTDR_LITTLEENDIAN )
+#define	IS_BIGENDIAN()	(0)
+#else
+/* BIGENDIAN ãã©ããèªåå¤å® */
+static const uint16_t	endian_check = 0xff00;
+#define	IS_BIGENDIAN()	(*(uint8_t *)&endian_check)
+#warning "it is better to specify -D NBOTDR_BIGENDIAN or -D NBOTDR_LITTLEENDIAN"
+#endif
+
+#if ! defined( NBOTDR_LONG_BIT )
+#define	NBOTDR_LONG_BIT	32
+#endif
+#if NBOTDR_LONG_BIT == 32
+#  define  NTOHL( d, sz )	ntoh32( d )
+#  define  HTONL( d, sz )	hton32( d )
+typedef		int32_t		TDR_LONG;
+typedef		uint32_t	TDR_ULONG;
+#elif NBOTDR_LONG_BIT == 64
+#  define  NTOHL( d, sz )	ntoh64( d )
+#  define  HTONL( d, sz )	hton64( d )
+typedef		int64_t		TDR_LONG;
+typedef		uint64_t	TDR_ULONG;
+#elif NBOTDR_LONG_BIT == 128
+#  define  NTOHL( d, sz )	ntoh128( d )
+#  define  HTONL( d, sz )	hton128( d )
+typedef		int128_t	TDR_LONG;
+typedef		uint128_t	TDR_ULONG;
+#elif ! defined( NBOTDR_LONG_BIT )
+#  define  NTOHL	ntohX
+#  define  HTONL	htonX
+#  warning "it is better to specify -D NBOTDR_LONG_BIT=N  N: 32, 64, 128"
+#else
+#  error  "NBOTDR_LONG_BIT must be 32, 64 or 128"
+#endif
+
+#if ! defined( NBOTDR_SHORT_BIT )
+#define	NBOTDR_SHORT_BIT	16
+#endif
+#if NBOTDR_SHORT_BIT == 16
+#  define  NTOHS( d, sz )	ntoh16( d )
+#  define  HTONS( d, sz )	hton16( d )
+typedef		int16_t		TDR_SHORT;
+typedef		uint16_t	TDR_USHORT;
+#elif NBOTDR_SHORT_BIT == 32
+#  define  NTOHS( d, sz )	ntoh32( d )
+#  define  HTONS( d, sz )	hton32( d )
+typedef		int32_t		TDR_SHORT;
+typedef		uint32_t	TDR_USHORT;
+#elif NBOTDR_SHORT_BIT == 64
+#  define  NTOHS( d, sz )	ntoh64( d )
+#  define  HTONS( d, sz )	hton64( d )
+typedef		int64_t		TDR_SHORT;
+typedef		uint64_t	TDR_USHORT;
+#elif ! defined( NBOTDR_SHORT_BIT )
+#  define  NTOHS( d, sz )	ntohX( d, sz )
+#  define  HTONS( d, sz )	htonX( d, sz )
+#  warning "it is better to specify -D NBOTDR_SHORT_BIT=N  N: 16, 32, 64"
+#else
+#  error  "NBOTDR_SHORT_BIT must be 16, 32 or 64"
+#endif
+
+#if ! defined( NBOTDR_INT_BIT )
+#define	NBOTDR_INT_BIT	32
+#endif
+#if NBOTDR_INT_BIT == 16
+#  define  NTOHI( d, sz )	ntoh16( d )
+#  define  HTONI( d, sz )	hton16( d )
+typedef		int16_t		TDR_INT;
+typedef		uint16_t	TDR_UINT;
+#elif NBOTDR_INT_BIT == 32
+#  define  NTOHI( d, sz )	ntoh32( d )
+#  define  HTONI( d, sz )	hton32( d )
+typedef		int32_t		TDR_INT;
+typedef		uint32_t	TDR_UINT;
+#elif NBOTDR_INT_BIT == 64
+#  define  NTOHI( d, sz )	ntoh64( d )
+#  define  HTONI( d, sz )	hton64( d )
+typedef		int64_t		TDR_INT;
+typedef		uint64_t	TDR_UINT;
+#elif NBOTDR_INT_BIT == 128
+#  define  NTOHI( d, sz )	ntoh128( d )
+#  define  HTONI( d, sz )	hton128( d )
+typedef		int128_t	TDR_INT;
+typedef		uint128_t	TDR_UINT;
+#elif ! defined( NBOTDR_INT_BIT )
+#  define  NTOHI( d, sz )	ntohX( d, sz )
+#  define  HTONI( d, sz )	htonX( d, sz )
+#  warning "it is better to specify -D NBOTDR_INT_BIT=N  N: 16, 32, 64, 128"
+#else
+#  error  "NBOTDR_INT_BIT must be 16, 32, 64 or 128"
+#endif
+
+#if ! defined( NBOTDR_INTPTR_BIT )
+#define	NBOTDR_INTPTR_BIT	32
+#endif
+#if NBOTDR_INTPTR_BIT == 16
+#  define  NTOHIP( d, sz )	ntoh16( d )
+#  define  HTONIP( d, sz )	hton16( d )
+typedef		int16_t		TDR_INTPTR;
+#elif NBOTDR_INTPTR_BIT == 32
+#  define  NTOHIP( d, sz )	ntoh32( d )
+#  define  HTONIP( d, sz )	hton32( d )
+typedef		int32_t		TDR_INTPTR;
+#elif NBOTDR_INTPTR_BIT == 64
+#  define  NTOHIP( d, sz )	ntoh64( d )
+#  define  HTONIP( d, sz )	hton64( d )
+typedef		int64_t		TDR_INTPTR;
+#elif NBOTDR_INTPTR_BIT == 128
+#  define  NTOHIP( d, sz )	ntoh128( d )
+#  define  HTONIP( d, sz )	hton128( d )
+typedef		int128_t	TDR_INTPTR;
+#elif ! defined( NBOTDR_INTPTR_BIT )
+#  define  NTOHIP( d, sz )		ntohX( d, sz )
+#  define  HTONIP( d, sz )		htonX( d, sz )
+#  warning "it is better to specify -D NBOTDR_INTPTR_BIT=N  N: 16, 32, 64, 128"
+#else
+#  error  "NBOTDR_INTPTR_BIT must be 16, 32, 64 or 128 "
+#endif
+
+Inline int16_t
+hton16( int16_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;		// big endian
+	else{
+		union  {
+			int8_t	by[2];
+			int16_t	d;
+		} d0, d1;
+		// syslog( LOG_INFO, "### little endian ###" );
+		d0.d = d;
+		d1.by[0] = d0.by[1];
+		d1.by[1] = d0.by[0];
+		return d1.d;
+	}
+}
+
+Inline int32_t
+hton32( int32_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		union  {
+			int8_t	by[4];
+			int32_t	d;
+		} d0, d1;
+		d0.d = d;
+		d1.by[0] = d0.by[3];
+		d1.by[1] = d0.by[2];
+		d1.by[2] = d0.by[1];
+		d1.by[3] = d0.by[0];
+		return d1.d;
+	}
+}
+
+Inline int64_t
+hton64( int64_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		union  {
+			int8_t	by[8];
+			int64_t	d;
+		} d0, d1;
+		d0.d = d;
+		d1.by[0] = d0.by[7];
+		d1.by[1] = d0.by[6];
+		d1.by[2] = d0.by[5];
+		d1.by[3] = d0.by[4];
+		d1.by[4] = d0.by[3];
+		d1.by[5] = d0.by[2];
+		d1.by[6] = d0.by[1];
+		d1.by[7] = d0.by[0];
+		return d1.d;
+	}
+}
+
+Inline int128_t
+hton128( int128_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		/* ãã®å®è£
+ã¯ tecs.h ã§ typedef ãã int128_t ã«é©å */
+		int128_t d1;
+		d1.hi = hton64( d.lo );
+		d1.lo = hton64( d.hi );
+		return	d1;
+	}
+}
+
+Inline int16_t
+ntoh16( int16_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		union  {
+			int8_t	by[2];
+			int16_t	d;
+		} d0, d1;
+		d0.d = d;
+		d1.by[0] = d0.by[1];
+		d1.by[1] = d0.by[0];
+		return d1.d;
+	}
+}
+
+Inline int32_t
+ntoh32( int32_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		union  {
+			int8_t	by[4];
+			int32_t	d;
+		} d0, d1;
+		d0.d = d;
+		d1.by[0] = d0.by[3];
+		d1.by[1] = d0.by[2];
+		d1.by[2] = d0.by[1];
+		d1.by[3] = d0.by[0];
+		return d1.d;
+	}
+}
+
+Inline int64_t
+ntoh64( int64_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		union  {
+			int8_t	by[8];
+			int64_t	d;
+		} d0, d1;
+		d0.d = d;
+		d1.by[0] = d0.by[7];
+		d1.by[1] = d0.by[6];
+		d1.by[2] = d0.by[5];
+		d1.by[3] = d0.by[4];
+		d1.by[4] = d0.by[3];
+		d1.by[5] = d0.by[2];
+		d1.by[6] = d0.by[1];
+		d1.by[7] = d0.by[0];
+		return d1.d;
+	}
+}
+
+/*** unsigned ç¨ã®é¢æ° (128 bit çã®ã¿ç¨æ) ***/
+Inline int128_t
+ntoh128( int128_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		/* ãã®å®è£
+ã¯ tecs.h ã§ typedef ãã int128_t ã«é©å */
+		int128_t d1;
+		d1.hi = ntoh64( d.lo );
+		d1.lo = ntoh64( d.hi );
+		return	d1;
+	}
+}
+
+Inline uint128_t
+hton128u( uint128_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		/* ãã®å®è£
+ã¯ tecs.h ã§ typedef ãã int128_t ã«é©å */
+		uint128_t d1;
+		d1.hi = hton64( d.lo );
+		d1.lo = hton64( d.hi );
+		return	d1;
+	}
+}
+
+Inline uint128_t
+ntoh128u( uint128_t d )
+{
+	if( IS_BIGENDIAN() )
+		return d;
+	else{
+		/* ãã®å®è£
+ã¯ tecs.h ã§ typedef ãã int128_t ã«é©å */
+		uint128_t d1;
+		d1.hi = ntoh64( d.lo );
+		d1.lo = ntoh64( d.hi );
+		return	d1;
+	}
+}
+
+/************************************************
+ *  htonX, ntohX ã¯ 16, 32, 64 ã«ã®ã¿å¯¾å¿ã§ãã *
+ ************************************************/
+Inline int64_t
+htonX( int64_t d, int_t sz )
+{
+	switch( sz ){
+	case	2:	return	hton16( d );
+	case	4:	return	hton32( d );
+	case	8:	return	hton64( d );
+	default:	return	0;			// # mikan
+	};
+}
+
+Inline int64_t
+ntohX( int64_t d, int_t sz )
+{
+	switch( sz ){
+	case	2:	return	ntoh16( d );
+	case	4:	return	ntoh32( d );
+	case	8:	return	ntoh64( d );
+	default:	return	0;			// # mikan
+	};
+}
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eTDR
+ * entry port: eTDR
+ * signature:  sTDR
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eTDR_reset
+ * name:         eTDR_reset
+ * global_name:  tNBOTDR_eTDR_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	syslog( LOG_INFO, "TDR: resetting channel" );
+	ercd = cChannel_reset();
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_sendSOP
+ * name:         eTDR_sendSOP
+ * global_name:  tNBOTDR_eTDR_sendSOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_sendSOP(CELLIDX idx, bool_t b_client )
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint16_t sopMagic;
+	uint8_t	val;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_sendSOP(b_client=%d)", b_client);
+#endif
+    if( b_client )
+		sopMagic = TDR_SOP_MAGIC1;
+	else
+		sopMagic = TDR_SOP_MAGIC2;
+
+	/*
+	 * SOP ãã±ããã®éä¿¡
+	 * ãã±ããã·ã¼ã±ã³ã¹ãå¤å°å´©ãã¦ãåå¾©ã§ããããã«ããã¤ãåä½ã§éã
+	 * ä¸ä½ãã¤ããä¸ä½ãã¤ãã®é ã«éã
+	 */
+
+	val = (uint8_t)(sopMagic>>8);
+	ercd = eTDR_putUInt8( idx, val );		/* ä¸ä½8ããã */
+	if( ercd != E_OK )
+		return	ercd;
+
+	val = (uint8_t)(sopMagic&0xff);			/* ä¸ä½8ããã */
+	ercd = eTDR_putUInt8( idx, val );
+
+	return	ercd;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_receiveSOP
+ * name:         eTDR_receiveSOP
+ * global_name:  tNBOTDR_eTDR_receiveSOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_receiveSOP(CELLIDX idx, bool_t b_client )
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint16_t sopMagic;
+	uint8_t val;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_receiveSOP(b_client=%d)", b_client);
+#endif
+
+    if( b_client )
+		sopMagic = TDR_SOP_MAGIC2;
+	else
+		sopMagic = TDR_SOP_MAGIC1;
+
+	if( (ercd=eTDR_getUInt8( idx, &val )) != E_OK )
+		;
+	else if( val != (uint8_t)(sopMagic>>8) ){
+		ercd = E_MAGIC;
+	}
+	else if((ercd=eTDR_getUInt8( idx, &val )) != E_OK )
+		;
+	else if( val != (uint8_t)sopMagic ){
+		ercd = E_MAGIC;
+	}
+
+	if( ercd != E_OK )
+		syslog( LOG_INFO, "receiveSOP: ERCD=%d", ercd );
+
+	return ercd;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_sendEOP
+ * name:         eTDR_sendEOP
+ * global_name:  tNBOTDR_eTDR_sendEOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_sendEOP(CELLIDX idx, bool_t b_continue )
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint16_t magic;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_sendEOP(b_continue=%d)", b_continue);
+#endif
+
+	if( b_continue )
+		magic = TDR_EOP_MAGIC1;
+	else
+		magic = TDR_EOP_MAGIC2;
+
+	/* EOP magic ã®éä¿¡ */
+	if( (ercd = eTDR_putUInt16( idx, magic )) != E_OK )
+		return ercd;
+
+	return cChannel_flush(VAR_tmo);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_receiveEOP
+ * name:         eTDR_receiveEOP
+ * global_name:  tNBOTDR_eTDR_receiveEOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_receiveEOP(CELLIDX idx, bool_t b_continue)
+{
+	ER		ercd = E_OK, er2;
+	CELLCB	*p_cellcb;
+	uint16_t magic;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_receiveEOP(b_continue=%d)",b_continue);
+#endif
+/* mikan cChannel EOF get_* */
+/* mikan magic EOF */
+
+	if( (ercd=eTDR_getUInt16( idx, &magic )) == E_OK ){
+		if( (b_continue && magic == TDR_EOP_MAGIC1) || (!b_continue && magic == TDR_EOP_MAGIC2) ){
+		} else {
+			ercd = E_MAGIC;
+		}
+	}
+	er2 = cChannel_end_receive();
+	return ercd != E_OK ? ercd : er2;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt8
+ * name:         eTDR_putInt8
+ * global_name:  tNBOTDR_eTDR_putInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt8(CELLIDX idx, int8_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt16
+ * name:         eTDR_putInt16
+ * global_name:  tNBOTDR_eTDR_putInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt16(CELLIDX idx, int16_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton16( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt32
+ * name:         eTDR_putInt32
+ * global_name:  tNBOTDR_eTDR_putInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt32(CELLIDX idx, int32_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton32( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt64
+ * name:         eTDR_putInt64
+ * global_name:  tNBOTDR_eTDR_putInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt64(CELLIDX idx, int64_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton64( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt128
+ * name:         eTDR_putInt128
+ * global_name:  tNBOTDR_eTDR_putInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt128(CELLIDX idx, int128_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton128( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt8
+ * name:         eTDR_getInt8
+ * global_name:  tNBOTDR_eTDR_getInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt8(CELLIDX idx, int8_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	 *p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt16
+ * name:         eTDR_getInt16
+ * global_name:  tNBOTDR_eTDR_getInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt16(CELLIDX idx, int16_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh16( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt32
+ * name:         eTDR_getInt32
+ * global_name:  tNBOTDR_eTDR_getInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt32(CELLIDX idx, int32_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh32( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt64
+ * name:         eTDR_getInt64
+ * global_name:  tNBOTDR_eTDR_getInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt64(CELLIDX idx, int64_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh64( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt128
+ * name:         eTDR_getInt128
+ * global_name:  tNBOTDR_eTDR_getInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt128(CELLIDX idx, int128_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh128( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt8
+ * name:         eTDR_putUInt8
+ * global_name:  tNBOTDR_eTDR_putUInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt8(CELLIDX idx, uint8_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt16
+ * name:         eTDR_putUInt16
+ * global_name:  tNBOTDR_eTDR_putUInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt16(CELLIDX idx, uint16_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton16( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt32
+ * name:         eTDR_putUInt32
+ * global_name:  tNBOTDR_eTDR_putUInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt32(CELLIDX idx, uint32_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton32( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt64
+ * name:         eTDR_putUInt64
+ * global_name:  tNBOTDR_eTDR_putUInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt64(CELLIDX idx, uint64_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton64( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt128
+ * name:         eTDR_putUInt128
+ * global_name:  tNBOTDR_eTDR_putUInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt128(CELLIDX idx, uint128_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	in = hton128u( in );
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt8
+ * name:         eTDR_getUInt8
+ * global_name:  tNBOTDR_eTDR_getUInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt8(CELLIDX idx, uint8_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt16
+ * name:         eTDR_getUInt16
+ * global_name:  tNBOTDR_eTDR_getUInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt16(CELLIDX idx, uint16_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh16( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt32
+ * name:         eTDR_getUInt32
+ * global_name:  tNBOTDR_eTDR_getUInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt32(CELLIDX idx, uint32_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh32( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt64
+ * name:         eTDR_getUInt64
+ * global_name:  tNBOTDR_eTDR_getUInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt64(CELLIDX idx, uint64_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh64( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt128
+ * name:         eTDR_getUInt128
+ * global_name:  tNBOTDR_eTDR_getUInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt128(CELLIDX idx, uint128_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	*out = ntoh128u( *out );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putChar
+ * name:         eTDR_putChar
+ * global_name:  tNBOTDR_eTDR_putChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putChar(CELLIDX idx, char_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getChar
+ * name:         eTDR_getChar
+ * global_name:  tNBOTDR_eTDR_getChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getChar(CELLIDX idx, char_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putBool
+ * name:         eTDR_putBool
+ * global_name:  tNBOTDR_eTDR_putBool
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putBool(CELLIDX idx, bool_t in)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	eTDR_putUInt8(idx, (uint8_t)(in != 0) );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getBool
+ * name:         eTDR_getBool
+ * global_name:  tNBOTDR_eTDR_getBool
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getBool(CELLIDX idx, bool_t* out)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint8_t	val;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = eTDR_getUInt8(idx, &val );
+	if( ercd != E_OK )
+		return ercd;
+	*out = (val != 0);
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putFloat32
+ * name:         eTDR_putFloat32
+ * global_name:  tNBOTDR_eTDR_putFloat32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putFloat32(CELLIDX idx, float32_t in)
+{
+	CELLCB	*p_cellcb;
+    int32_t val;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	val = hton32( *(int32_t*)&in );
+	return cChannel_send( (int8_t *)&val, (int16_t)sizeof( val ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putDouble64
+ * name:         eTDR_putDouble64
+ * global_name:  tNBOTDR_eTDR_putDouble64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putDouble64(CELLIDX idx, double64_t in)
+{
+    int64_t val;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+    val = *(int64_t *)&in;
+	val = hton64( val );
+	return cChannel_send( (int8_t *)&val, (int16_t)sizeof( val ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getFloat32
+ * name:         eTDR_getFloat32
+ * global_name:  tNBOTDR_eTDR_getFloat32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getFloat32(CELLIDX idx, float32_t* out)
+{
+	ER_UINT		er_sz = E_OK;
+    int32_t   val;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&val, (int16_t)sizeof( val ), VAR_tmo );
+	val = ntoh32( val );
+    *out = *(float32_t *)&val;
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getDouble64
+ * name:         eTDR_getDouble64
+ * global_name:  tNBOTDR_eTDR_getDouble64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getDouble64(CELLIDX idx, double64_t* out)
+{
+	ER_UINT		er_sz = E_OK;
+    int64_t     val;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&val, (int16_t)sizeof( val ), VAR_tmo );
+	val = ntoh64( val );
+    *out = *(double64_t *)&val;
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putSChar
+ * name:         eTDR_putSChar
+ * global_name:  tNBOTDR_eTDR_putSChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putSChar(CELLIDX idx, signed char in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putShort
+ * name:         eTDR_putShort
+ * global_name:  tNBOTDR_eTDR_putShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putShort(CELLIDX idx, short_t in)
+{
+	CELLCB	*p_cellcb;
+	TDR_SHORT	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONS( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt
+ * name:         eTDR_putInt
+ * global_name:  tNBOTDR_eTDR_putInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt(CELLIDX idx, int_t in)
+{
+	CELLCB	*p_cellcb;
+	TDR_INT	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONI( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putLong
+ * name:         eTDR_putLong
+ * global_name:  tNBOTDR_eTDR_putLong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putLong(CELLIDX idx, long_t in)
+{
+	CELLCB	*p_cellcb;
+	TDR_LONG	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONL( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getSChar
+ * name:         eTDR_getSChar
+ * global_name:  tNBOTDR_eTDR_getSChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getSChar(CELLIDX idx, signed char* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getShort
+ * name:         eTDR_getShort
+ * global_name:  tNBOTDR_eTDR_getShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getShort(CELLIDX idx, short* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_SHORT	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHS( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt
+ * name:         eTDR_getInt
+ * global_name:  tNBOTDR_eTDR_getInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt(CELLIDX idx, int_t* out)
+{
+	ER_UINT		 er_sz;
+	CELLCB		*p_cellcb;
+	TDR_INT	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHI( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getLong
+ * name:         eTDR_getLong
+ * global_name:  tNBOTDR_eTDR_getLong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getLong(CELLIDX idx, long_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_LONG	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHL( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUChar
+ * name:         eTDR_putUChar
+ * global_name:  tNBOTDR_eTDR_putUChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUChar(CELLIDX idx, unsigned char in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUShort
+ * name:         eTDR_putUShort
+ * global_name:  tNBOTDR_eTDR_putUShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUShort(CELLIDX idx, ushort_t in)
+{
+	CELLCB	*p_cellcb;
+	TDR_USHORT	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONS( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt
+ * name:         eTDR_putUInt
+ * global_name:  tNBOTDR_eTDR_putUInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt(CELLIDX idx, uint_t in)
+{
+	CELLCB		*p_cellcb;
+	TDR_UINT	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONI( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putULong
+ * name:         eTDR_putULong
+ * global_name:  tNBOTDR_eTDR_putULong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putULong(CELLIDX idx, ulong_t in)
+{
+	CELLCB	*p_cellcb;
+	TDR_ULONG	IN = in;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONL( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUChar
+ * name:         eTDR_getUChar
+ * global_name:  tNBOTDR_eTDR_getUChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUChar(CELLIDX idx, unsigned char* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUShort
+ * name:         eTDR_getUShort
+ * global_name:  tNBOTDR_eTDR_getUShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUShort(CELLIDX idx, unsigned short* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_USHORT	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHS( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt
+ * name:         eTDR_getUInt
+ * global_name:  tNBOTDR_eTDR_getUInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt(CELLIDX idx, uint_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_UINT	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHI( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getULong
+ * name:         eTDR_getULong
+ * global_name:  tNBOTDR_eTDR_getULong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getULong(CELLIDX idx, ulong_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_ULONG	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*out = NTOHL( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putIntptr
+ * name:         eTDR_putIntptr
+ * global_name:  tNBOTDR_eTDR_putIntptr
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putIntptr(CELLIDX idx, const intptr_t ptr)
+{
+	CELLCB	*p_cellcb;
+	TDR_INTPTR	IN = ptr;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	IN = HTONIP( IN, sizeof IN );
+	return cChannel_send( (int8_t *)&IN, (int16_t)sizeof( IN ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getIntptr
+ * name:         eTDR_getIntptr
+ * global_name:  tNBOTDR_eTDR_getIntptr
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getIntptr(CELLIDX idx, intptr_t* ptr)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	TDR_INTPTR	OUT;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)&OUT, (int16_t)sizeof( OUT ), VAR_tmo );
+	*ptr = NTOHIP( OUT, sizeof OUT );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( OUT ) ? E_OK : E_BOVR );
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tPPAllocator.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tPPAllocator.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tPPAllocator.c	(revision 317)
@@ -0,0 +1,161 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * heap_size        uint32_t         ATTR_heap_size  
+ * buf              int8_t*          VAR_buf         
+ * allocated_size   uint32_t         VAR_allocated_size
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tPPAllocator_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# ePPAllocator
+ * entry port: ePPAllocator
+ * signature:  sPPAllocator
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# ePPAllocator_alloc
+ * name:         ePPAllocator_alloc
+ * global_name:  tPPAllocator_ePPAllocator_alloc
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+ePPAllocator_alloc(CELLIDX idx, uint32_t size, void** ptr)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	if( size + VAR_allocatedSize > ATTR_heapSize ){
+		ercd = E_NOMEM;
+	}
+	else {
+		*ptr = (void *)(VAR_buf+VAR_allocatedSize);
+		VAR_allocatedSize += size;
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# ePPAllocator_dealloc
+ * name:         ePPAllocator_dealloc
+ * global_name:  tPPAllocator_ePPAllocator_dealloc
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+ePPAllocator_dealloc(CELLIDX idx, const void* ptr)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	if( (uintptr_t)ptr < (uintptr_t)VAR_buf || (uintptr_t)ptr >= (uintptr_t)(VAR_buf+VAR_allocatedSize) ){
+		ercd = E_PAR;
+	}
+	else {
+		VAR_allocatedSize = (uintptr_t)ptr - (uintptr_t)VAR_buf;
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# ePPAllocator_dealloc_all
+ * name:         ePPAllocator_dealloc_all
+ * global_name:  tPPAllocator_ePPAllocator_dealloc_all
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+ePPAllocator_dealloc_all(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	VAR_allocatedSize = 0;
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMain.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMain.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMain.c	(revision 317)
@@ -0,0 +1,101 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cMain  signature: sTaskBody context: task
+ *   void           cMain_main( );
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tRPCDedicatedTaskMain_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eMain
+ * entry port: eMain
+ * signature:  sTaskBody
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eMain_main
+ * name:         eMain_main
+ * global_name:  tRPCDedicatedTaskMain_eMain_main
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eMain_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	while( cMain_main() == E_OK ){
+	}
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMainWithOpener.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMainWithOpener.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCDedicatedTaskMainWithOpener.c	(revision 317)
@@ -0,0 +1,114 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cMain  signature: sTaskBody context: task
+ *   void           cMain_main( );
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tRPCDedicatedTaskMainWithOpener_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eMain
+ * entry port: eMain
+ * signature:  sTaskBody
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eMain_main
+ * name:         eMain_main
+ * global_name:  tRPCDedicatedTaskMain_eMain_main
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eMain_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	ER		er;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	while(1){
+#ifdef RPC_DEBUG
+		syslog(LOG_INFO, "begin RPC unmarshaler task" );
+		syslog(LOG_INFO, "Opening RPC server channel" );
+#endif
+		delay( ATTR_initialDelay );
+		er = cOpener_open();
+		syslog(LOG_INFO, "opened" );
+		while( cMain_main() == E_OK ){
+		}
+		delay( ATTR_reopenDelay );
+		er = cOpener_close();
+	}
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedChannelMan.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedChannelMan.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedChannelMan.c	(revision 317)
@@ -0,0 +1,269 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cSemaphore  signature: sSemaphore context: task
+ *   ER             cSemaphore_signal( );
+ *   ER             cSemaphore_wait( );
+ *   ER             cSemaphore_waitPolling( );
+ *   ER             cSemaphore_waitTimeout( TMO timeout );
+ *   ER             cSemaphore_initialize( );
+ *   ER             cSemaphore_refer( T_RSEM* pk_semaphore_status );
+ * call port : cClientSideTDR  signature: sTDR context: task
+ *   ER             cClientSideTDR_open( const int8_t* arg, int16_t size, TMO tmo );
+ *   ER             cClientSideTDR_close( );
+ *   ER             cClientSideTDR_reset( );
+ *   ER             cClientSideTDR_sop( int_t no );
+ *   ER             cClientSideTDR_is_sop( int_t no );
+ *   ER             cClientSideTDR_eop( int_t no );
+ *   ER             cClientSideTDR_is_eop( int_t no );
+ *   ER             cClientSideTDR_set_tmo( TMO tmo );
+ *   ER             cClientSideTDR_put_int8( int8_t in );
+ *   ER             cClientSideTDR_put_int16( int16_t in );
+ *   ER             cClientSideTDR_put_int32( int32_t in );
+ *   ER             cClientSideTDR_put_int64( int64_t in );
+ *   ER             cClientSideTDR_put_int128( int128_t in );
+ *   ER             cClientSideTDR_get_int8( int8_t* out );
+ *   ER             cClientSideTDR_get_int16( int16_t* out );
+ *   ER             cClientSideTDR_get_int32( int32_t* out );
+ *   ER             cClientSideTDR_get_int64( int64_t* out );
+ *   ER             cClientSideTDR_get_int128( int128_t* out );
+ *   ER             cClientSideTDR_put_char( char_t in );
+ *   ER             cClientSideTDR_put_short( short in );
+ *   ER             cClientSideTDR_put_int( int_t in );
+ *   ER             cClientSideTDR_put_long( long_t in );
+ *   ER             cClientSideTDR_get_char( char_t* out );
+ *   ER             cClientSideTDR_get_short( short* out );
+ *   ER             cClientSideTDR_get_int( int_t* out );
+ *   ER             cClientSideTDR_get_long( long_t* out );
+ *   ER             cClientSideTDR_put_intptr( const void* ptr );
+ *   ER             cClientSideTDR_get_intptr( void** ptr );
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tRPCSharedChannelMan_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eSemaphore
+ * entry port: eSemaphore
+ * signature:  sSemaphore
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eSemaphore_signal
+ * name:         eSemaphore_signal
+ * global_name:  tRPCSharedTaskMain_eSemaphore_signal
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_signal(CELLIDX idx, int_t subscript)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	cClientSideTDR_putInt16( RPC_CHANNEL_MAN_EOP_MAGIC );
+	ercd = cSemaphore_signal();
+	// syslog( LOG_INFO, "tRPCSharedTaskMain: cSemaphore_signal" );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eSemaphore_wait
+ * name:         eSemaphore_wait
+ * global_name:  tRPCSharedTaskMain_eSemaphore_wait
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_wait(CELLIDX idx, int_t subscript)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = cSemaphore_wait();
+	if( ercd == E_OK ){
+		// syslog( LOG_INFO, "tRPCSharedTaskMain: cSemaphore_wait" );
+
+		cClientSideTDR_putInt16( RPC_CHANNEL_MAN_SOP_MAGIC );
+		cClientSideTDR_putInt16( subscript );
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eSemaphore_waitPolling
+ * name:         eSemaphore_waitPolling
+ * global_name:  tRPCSharedTaskMain_eSemaphore_waitPolling
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_waitPolling(CELLIDX idx, int_t subscript)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = cSemaphore_waitPolling();
+	if( ercd == E_OK ){
+		cClientSideTDR_putInt16( RPC_CHANNEL_MAN_SOP_MAGIC );
+		cClientSideTDR_putInt16( subscript );
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eSemaphore_waitTimeout
+ * name:         eSemaphore_waitTimeout
+ * global_name:  tRPCSharedTaskMain_eSemaphore_waitTimeout
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_waitTimeout(CELLIDX idx, int_t subscript, TMO timeout)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = cSemaphore_waitTimeout(timeout);
+	if( ercd == E_OK ){
+		// syslog( LOG_INFO, "tRPCSharedTaskMain: cSemaphore_waitTimeout" );
+
+		cClientSideTDR_putInt16( RPC_CHANNEL_MAN_SOP_MAGIC );
+		cClientSideTDR_putInt16( subscript );
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eSemaphore_initialize
+ * name:         eSemaphore_initialize
+ * global_name:  tRPCSharedTaskMain_eSemaphore_initialize
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_initialize(CELLIDX idx, int_t subscript)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eSemaphore_refer
+ * name:         eSemaphore_refer
+ * global_name:  tRPCSharedTaskMain_eSemaphore_refer
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eSemaphore_refer(CELLIDX idx, int_t subscript, T_RSEM* pk_semaphore_status)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMain.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMain.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMain.c	(revision 317)
@@ -0,0 +1,175 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * channelNo        int16_t          VAR_channelNo   
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cUnmarshalAndCallFunction  signature: sTaskBody context: task
+ *   void           cUnmarshalAndCallFunction_main( subscript );
+ * call port : cServerSideTDR  signature: sTDR context: task
+ *   ER             cServerSideTDR_reset( );
+ *   ER             cServerSideTDR_sendSOP( bool_t b_client );
+ *   ER             cServerSideTDR_receiveSOP( bool_t b_client );
+ *   ER             cServerSideTDR_sendEOP( bool_t b_continue );
+ *   ER             cServerSideTDR_receiveEOP( bool_t b_continue );
+ *   ER             cServerSideTDR_putInt8( int8_t in );
+ *   ER             cServerSideTDR_putInt16( int16_t in );
+ *   ER             cServerSideTDR_putInt32( int32_t in );
+ *   ER             cServerSideTDR_putInt64( int64_t in );
+ *   ER             cServerSideTDR_putInt128( int128_t in );
+ *   ER             cServerSideTDR_getInt8( int8_t* out );
+ *   ER             cServerSideTDR_getInt16( int16_t* out );
+ *   ER             cServerSideTDR_getInt32( int32_t* out );
+ *   ER             cServerSideTDR_getInt64( int64_t* out );
+ *   ER             cServerSideTDR_getInt128( int128_t* out );
+ *   ER             cServerSideTDR_putFloat32( float32_t in );
+ *   ER             cServerSideTDR_putDouble64( double64_t in );
+ *   ER             cServerSideTDR_getFloat32( float32_t* out );
+ *   ER             cServerSideTDR_getDouble64( double64_t* out );
+ *   ER             cServerSideTDR_putChar( char_t in );
+ *   ER             cServerSideTDR_putShort( short in );
+ *   ER             cServerSideTDR_putInt( int_t in );
+ *   ER             cServerSideTDR_putLong( long_t in );
+ *   ER             cServerSideTDR_getChar( char_t* out );
+ *   ER             cServerSideTDR_getShort( short* out );
+ *   ER             cServerSideTDR_getInt( int_t* out );
+ *   ER             cServerSideTDR_getLong( long_t* out );
+ *   ER             cServerSideTDR_putIntptr( const intptr_t ptr );
+ *   ER             cServerSideTDR_getIntptr( intptr_t* ptr );
+ * require port : signature: sSysLog context: task
+ *   ER             write( uint_t prio, const SYSLOG* p_syslog );
+ *   ER_UINT        read( SYSLOG* p_syslog );
+ *   ER             mask( uint_t logmask, uint_t lowmask );
+ *   ER             refer( T_SYSLOG_RLOG* pk_rlog );
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tRPCSharedTaskMain_tecsgen.h"
+#include "t_syslog.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eMain
+ * entry port: eMain
+ * signature:  sTaskBody
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eMain_main
+ * name:         eMain_main
+ * global_name:  tRPCSharedTaskMain_eMain_main
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eMain_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	syslog( LOG_INFO, "Shared RPC server task started." );
+	while(1){
+		int16_t magic;
+		ER      er;
+
+		er = cServerSideTDR_getInt16( &magic );
+		if( er != E_OK ){
+			syslog( LOG_INFO, "err: getInt16 for SOP_MAGIC(%X)", er );
+			continue;
+		}
+		if( magic != RPC_CHANNEL_MAN_SOP_MAGIC ){
+			syslog( LOG_INFO, "illegal SOP magic(%X): retrying", (uint16_t)magic );
+			continue;
+		}
+		er = cServerSideTDR_getInt16( &VAR_channelNo );
+		if( er != E_OK ){
+			syslog( LOG_INFO, "err: getInt16 for channelNo(%X)", er );
+			continue;
+		}
+		if( VAR_channelNo < 0 || VAR_channelNo >= N_CP_cUnmarshalAndCallFunction(p_cellcb) ){
+			syslog( LOG_INFO, "illegal channel number(%X): retrying", (uint16_t)VAR_channelNo );
+			continue;
+		}
+		syslog( LOG_INFO, "Shared Channel: servicing channel No. %d", VAR_channelNo );
+		
+		cUnmarshalAndCallFunction_main( VAR_channelNo );
+
+		er = cServerSideTDR_getInt16( &magic );
+		if( er != E_OK ){
+			syslog( LOG_INFO, "err: getInt16 for EOP_MAGIC(%X)", er );
+			continue;
+		}
+		if( magic != RPC_CHANNEL_MAN_EOP_MAGIC ){
+			syslog( LOG_INFO, "illegal EOP magic(%X): retrying", (uint16_t)magic );
+			continue;
+		}
+	}
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMainWithOpener.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMainWithOpener.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tRPCSharedTaskMainWithOpener.c	(revision 317)
@@ -0,0 +1,205 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/*
+ * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ãããã³ãã¬ã¼ãã¨ãã¦èªåçæããã¾ãã
+ * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ãæå³ããã¦ãã¾ãã
+ * tecsgen ã®åå®è¡ã«ããä¸æ¸ãããã¦ãã¾ããããéå¸¸
+ *   gen/tRPCSharedTaskMainWithOpener_template.c => src/tRPCSharedTaskMainWithOpener.c
+ * ã®ããã«åå, ãã©ã«ããå¤æ´ãã¦ããä¿®æ­£ãã¾ã
+ */
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * initialDelay     RELTIM           ATTR_initialDelay
+ * reopenDelay      RELTIM           ATTR_reopenDelay
+ * channelNo        int16_t          VAR_channelNo   
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cUnmarshalAndCallFunction  signature: sTaskBody context: task
+ *   void           cUnmarshalAndCallFunction_main( subscript );
+ * call port : cServerSideTDR  signature: sTDR context: task
+ *   ER             cServerSideTDR_reset( );
+ *   ER             cServerSideTDR_sendSOP( bool_t b_client );
+ *   ER             cServerSideTDR_receiveSOP( bool_t b_client );
+ *   ER             cServerSideTDR_sendEOP( bool_t b_continue );
+ *   ER             cServerSideTDR_receiveEOP( bool_t b_continue );
+ *   ER             cServerSideTDR_putInt8( int8_t in );
+ *   ER             cServerSideTDR_putInt16( int16_t in );
+ *   ER             cServerSideTDR_putInt32( int32_t in );
+ *   ER             cServerSideTDR_putInt64( int64_t in );
+ *   ER             cServerSideTDR_putInt128( int128_t in );
+ *   ER             cServerSideTDR_getInt8( int8_t* out );
+ *   ER             cServerSideTDR_getInt16( int16_t* out );
+ *   ER             cServerSideTDR_getInt32( int32_t* out );
+ *   ER             cServerSideTDR_getInt64( int64_t* out );
+ *   ER             cServerSideTDR_getInt128( int128_t* out );
+ *   ER             cServerSideTDR_putFloat32( float32_t in );
+ *   ER             cServerSideTDR_putDouble64( double64_t in );
+ *   ER             cServerSideTDR_getFloat32( float32_t* out );
+ *   ER             cServerSideTDR_getDouble64( double64_t* out );
+ *   ER             cServerSideTDR_putChar( char_t in );
+ *   ER             cServerSideTDR_putShort( short in );
+ *   ER             cServerSideTDR_putInt( int_t in );
+ *   ER             cServerSideTDR_putLong( long_t in );
+ *   ER             cServerSideTDR_getChar( char_t* out );
+ *   ER             cServerSideTDR_getShort( short* out );
+ *   ER             cServerSideTDR_getInt( int_t* out );
+ *   ER             cServerSideTDR_getLong( long_t* out );
+ *   ER             cServerSideTDR_putIntptr( const intptr_t ptr );
+ *   ER             cServerSideTDR_getIntptr( intptr_t* ptr );
+ * call port : cOpener  signature: sServerChannelOpener context: task
+ *   ER             cOpener_open( );
+ *   ER             cOpener_close( );
+ * require port : signature: sSysLog context: task
+ *   ER             write( uint_t prio, const SYSLOG* p_syslog );
+ *   ER_UINT        read( SYSLOG* p_syslog );
+ *   ER             mask( uint_t logmask, uint_t lowmask );
+ *   ER             refer( T_SYSLOG_RLOG* pk_rlog );
+ * require port : signature: sKernel context: task
+ *   ER             delay( RELTIM delay_time );
+ *   ER             exitTask( );
+ *   ER             getTime( SYSTIM* p_system_time );
+ *   ER             getMicroTime( SYSUTM* p_system_micro_time );
+ *   ER             exitKernel( );
+ *
+ * #[</PREAMBLE>]# */
+
+/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã */
+#include "tRPCSharedTaskMainWithOpener_tecsgen.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eMain
+ * entry port: eMain
+ * signature:  sTaskBody
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eMain_main
+ * name:         eMain_main
+ * global_name:  tRPCSharedTaskMainWithOpener_eMain_main
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+void
+eMain_main(CELLIDX idx)
+{
+	CELLCB	*p_cellcb;
+	ER		er;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	delay( ATTR_initialDelay );
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	while(1){
+#ifdef RPC_DEBUG
+		syslog(LOG_INFO, "begin RPC unmarshaler task" );
+		syslog(LOG_INFO, "Opening RPC server channel" );
+#endif
+
+		er = cOpener_open();
+		syslog(LOG_INFO, "opened" );
+		while(1){
+			int16_t magic;
+
+			er = cServerSideTDR_getInt16( &magic );
+			if( er != E_OK ){
+				syslog( LOG_INFO, "err: getInt16 for SOP_MAGIC(%X)", er );
+				continue;
+			}
+			if( magic != RPC_CHANNEL_MAN_SOP_MAGIC ){
+				syslog( LOG_INFO, "illegal SOP magic(%X): retrying", (uint16_t)magic );
+				continue;
+			}
+			er = cServerSideTDR_getInt16( &VAR_channelNo );
+			if( er != E_OK ){
+				syslog( LOG_INFO, "err: getInt16 for channelNo(%X)", er );
+				continue;
+			}
+			if( VAR_channelNo < 0 || VAR_channelNo >= N_CP_cUnmarshalAndCallFunction(p_cellcb) ){
+				syslog( LOG_INFO, "illegal channel number(%X): retrying", (uint16_t)VAR_channelNo );
+				continue;
+			}
+			syslog( LOG_INFO, "Shared Channel: servicing channel No. %d", VAR_channelNo );
+		
+			cUnmarshalAndCallFunction_main( VAR_channelNo );
+
+			er = cServerSideTDR_getInt16( &magic );
+			if( er != E_OK ){
+				syslog( LOG_INFO, "err: getInt16 for EOP_MAGIC(%X)", er );
+				continue;
+			}
+			if( magic != RPC_CHANNEL_MAN_EOP_MAGIC ){
+				syslog( LOG_INFO, "illegal EOP magic(%X): retrying", (uint16_t)magic );
+				continue;
+			}
+		}
+		er = cOpener_close();
+		delay( ATTR_reopenDelay );
+	}
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketChannel.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketChannel.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketChannel.cdl	(revision 317)
@@ -0,0 +1,84 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+const	uint16_t	SOCKET_DEFAULT_PORT_NO  = 8931;
+
+signature sSocketClientOpener {
+	ER		open( [in,string]const char_t *serverAddr, [in]uint16_t portNo, [in]TMO tmo );
+	ER		simpleOpen( [in]TMO tmo );      // attr ã®è¨­å®ã«å¾ã£ã¦éã
+	ER		close( [in]TMO tmo );
+};
+
+celltype tSocketClient {
+	entry	sChannel			eC0;
+	entry	sSocketClientOpener	eOpener;
+	attr {
+		// simpleOpen ã§ç¨ããããã¢ãã¬ã¹ããã³ãã¼ãçªå·
+		int16_t	portNo = SOCKET_DEFAULT_PORT_NO;
+		char_t  *serverAddr = "127.0.0.1";       // Loop back address
+	};
+	var {
+		int_t	sd;
+	};
+};
+
+celltype tSocketServer {
+	entry	sChannel				eC1;
+	entry	sServerChannelOpener	eOpener;
+	attr {
+		int16_t	portNo = SOCKET_DEFAULT_PORT_NO;
+	};
+	var {
+		int_t    sd;
+	};
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketClient.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketClient.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketClient.c	(revision 317)
@@ -0,0 +1,367 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * Don't edit the comments between #[<...>]# and #[</...>]#
+ * These comment are used by tecsmerege when merging.
+ *
+ * attr access macro #_CAAM_#
+ * portNo           int16_t          ATTR_portNo    
+ * serverAddr       char_t*          ATTR_serverAddr
+ * sd               int_t            VAR_sd          
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tSocketClient_tecsgen.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include "errno2ER.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* æ­£å¸¸çµäº */
+#define	E_ID	(-18)	/* ä¸æ­£IDçªå· */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eC0
+ * entry port: eC0
+ * signature:  sChannel
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eC0_send
+ * name:         eC0_send
+ * global_name:  tSocketClient_eC0_send
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	ssize_t sz;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	// mikan BUG  buf ã®ä½ç½®ãæ´æ°ãã¦ããªã
+	while(size>0){
+		if((sz=write( VAR_sd, buf, (ssize_t)size )) < 0 ){
+#ifdef RPC_DEBUG
+			perror( "eC0_send" );
+			syslog( LOG_INFO, "eC0_send: sd %d, writing %d bytes, ercd=%d", VAR_sd, size, ercd );
+#endif
+			ercd = errno2ER( errno );
+			break;
+		}
+		else{
+			size -= sz;
+		}
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_flush
+ * name:         eC0_flush
+ * global_name:  tSocketClient_eC0_flush
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_flush(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	/* write ã¯ãããã¡ãªã³ã°ãªããªã®ã§ flush ããªã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_receive
+ * name:         eC0_receive
+ * global_name:  tSocketClient_eC0_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER_UINT
+eC0_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	ssize_t  sz;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	sz = read( VAR_sd, buf, (ssize_t)size );
+	ercd = errno2ER( errno );
+#ifdef DEBUG
+	{
+		int i;
+		for( i = 0; i < sz; i++ ){
+			printf( "%02X ", (unsigned char)buf[i] );
+			if( i % 8 == 7 )
+				putchar( '\n' );
+		}
+		putchar( '\n' );
+	}
+#endif
+	/* mikan ä¸çºã§å
+¨ã¦èª­ããã¨ä»®å® */
+	if( sz >= 0 )
+		ercd = sz;
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_end_receive
+ * name:         eC0_end_receive
+ * global_name:  tSocketClient_eC0_end_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_end_receive(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_reset
+ * name:         eC0_reset
+ * global_name:  tSocketClient_eC0_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_PORT>]# eOpener
+ * entry port: eOpener
+ * signature:  sSocketClientOpener
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eOpener_open
+ * name:         eOpener_open
+ * global_name:  tSocketClient_eOpener_open
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_open(CELLIDX idx, const char_t* serverAddr, uint16_t portNo, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int		soc;
+	struct sockaddr_in addr={AF_INET};
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	soc=socket(AF_INET, SOCK_STREAM, 0);
+	if(soc<0){
+		ercd = errno2ER( errno );
+		syslog( LOG_INFO, "SocketClient: socket failed");
+		return ercd;
+	}
+
+#if 0
+/* ãã³ãã­ãã¯ã«å¤æ´ */
+	int flag=fcntl(soc, F_GETFL, 0);
+	if(flag<0) perror("fcntl(GET) error");
+	if(fcntl(soc, F_SETFL, flag|O_NONBLOCK)<0) perror("fcntl(NONBLOCK) error");
+#endif /* 0 */
+
+	puts( "connecting" );
+	inet_aton( serverAddr, &addr.sin_addr );
+	addr.sin_port=htons(portNo);
+	if(connect(soc, (struct sockaddr*)&addr, sizeof(addr))<0){
+		ercd = errno2ER( errno );
+		close( soc );
+		printf( "connect fail errno=%d, ercd=%d\n", errno, ercd );
+		syslog( LOG_INFO, "SocketClient: connect" );
+		return ercd;
+	}
+	VAR_sd = soc;
+
+#if 0
+	if(errno!=EINPROGRESS)
+		perror("connect error");
+	//EINPROGRESS:ã³ãã¯ã·ã§ã³è¦æ±ã¯å§ã¾ã£ãããã¾ã å®äºãã¦ããªã
+
+	fd_set rmask,wmask;FD_ZERO(&rmask);FD_SET(soc,&rmask);wmask=rmask;
+	struct timeval tv={ ã¿ã¤ã ã¢ã¦ãæé[ç§],[Î¼ç§] };
+	int rc=select(soc+1, &rmask, &wmask, NULL, &tv);
+	if(rc<0) perror("connect-select error");
+	if(rc==0){ ã¿ã¤ã ã¢ã¦ãå¦ç }
+	if(rc==2){ //èª­ã¿æ¸ããåæã«åºæ¥ãå ´å
+#if Solaris
+		int val;
+		socklen_t len=sizeof(val);
+		if(getsockopt(soc,SOL_SOCKET,SO_ERROR, &val,&len)>=0) {
+#elif Linux
+			struct sockaddr_in name;
+			socklen_t len=sizeof(name);
+			if(getpeername(soc,(struct sockaddr*)&name,&len)>=0) {
+#endif
+				// æ¢ã«ãã¼ã¿ãæ¥ã¦ãã
+			}else{
+				// ã³ãã¯ãå¤±æ
+			}
+		}
+	}
+//ãã©ã°ãå
+ã«æ»ã
+	if(fcntl(soc, F_SETFL, flag)<0) perror("fcntl(END) error");
+#endif /* 0 */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eOpener_simpleOpen
+ * name:         eOpener_simpleOpen
+ * global_name:  tSocketClient_eOpener_simpleOpen
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_simpleOpen(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* Put statements here #_TEFB_# */
+	ercd = eOpener_open(idx, ATTR_serverAddr, ATTR_portNo, tmo);
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eOpener_close
+ * name:         eOpener_close
+ * global_name:  tSocketClient_eOpener_close
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_close(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	close( VAR_sd );       /* mikan ã¨ã©ã¼å¦ç */
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   Put non-entry functions below.
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketServer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketServer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tSocketServer.c	(revision 317)
@@ -0,0 +1,318 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * portNo           int16_t          ATTR_portNo    
+ * sd               int_t            VAR_sd          
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tSocketServer_tecsgen.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include "errno2ER.h"
+
+#ifndef E_OK
+#define	E_OK	0		/* æ­£å¸¸çµäº */
+#define	E_ID	(-18)	/* ä¸æ­£IDçªå· */
+#endif
+
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eC1
+ * entry port: eC1
+ * signature:  sChannel
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eC1_send
+ * name:         eC1_send
+ * global_name:  tSocketServer_eC1_send
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int     sz;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+#ifdef DEBUG
+	syslog( LOG_INFO, "tSocketServer: send" );
+	{
+		int i;
+		for( i = 0; i < size; i++ ){
+			printf( "%02X ", (unsigned char)buf[i] );
+			if( i % 8 == 7 )
+				putchar( '\n' );
+		}
+		putchar( '\n' );
+	}
+#endif
+	while(size>0){
+		if((sz=write( VAR_sd, buf, (size_t)size )) < 0 ){
+			ercd = errno2ER( errno );
+			break;
+		}
+		else{
+			size -= sz;
+		}
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_flush
+ * name:         eC1_flush
+ * global_name:  tSocketServer_eC1_flush
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_flush(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_receive
+ * name:         eC1_receive
+ * global_name:  tSocketServer_eC1_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER_UINT
+eC1_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	ER_UINT sz;
+	CELLCB	*p_cellcb;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	if( (sz=read( VAR_sd, buf, (size_t)size )) < 0 )
+		ercd = errno2ER( errno );
+	else
+		ercd = sz;
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_end_receive
+ * name:         eC1_end_receive
+ * global_name:  tSocketServer_eC1_end_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_end_receive(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_reset
+ * name:         eC1_reset
+ * global_name:  tSocketServer_eC1_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	syslog( LOG_INFO, "tSocketServer: reset" );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_PORT>]# eOpener
+ * entry port: eOpener
+ * signature:  sServerChannelOpener
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eOpener_open
+ * name:         eOpener_open
+ * global_name:  tSocketServer_eOpener_open
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_open(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int		ssoc, soc;
+	struct sockaddr_in addr={ AF_INET };
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	syslog( LOG_INFO, "tSocketServer: open" );
+
+	ssoc=socket(AF_INET,SOCK_STREAM,0);
+	if(ssoc<0){
+		ercd = errno2ER( errno );
+		syslog( LOG_INFO, "tSocketServer: socket failed" );
+		return ercd;
+	}
+
+	addr.sin_port = htons(ATTR_portNo);
+	addr.sin_addr.s_addr = INADDR_ANY;
+	if(bind(ssoc,(struct sockaddr*)&addr,sizeof(addr))<0){
+		ercd = errno2ER( errno );
+		syslog( LOG_INFO, "tSocketServer: bind failed" );
+		return ercd;
+	}
+
+	if(listen(ssoc, 1 )<0){
+		ercd = errno2ER( errno );
+		syslog( LOG_INFO, "tSocketServer: listen failed" );
+		return ercd;
+	}
+
+    soc=accept(ssoc, NULL, NULL);
+    if(soc<0){
+		ercd = errno2ER( errno );
+		syslog( LOG_INFO, "tSocketServer: accept failed" );
+		return ercd;
+	}
+	syslog( LOG_INFO, "tSocketServer: accepted" );
+
+	close( ssoc );
+	VAR_sd = soc;
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eOpener_close
+ * name:         eOpener_close
+ * global_name:  tSocketServer_eOpener_close
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_close(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	syslog( LOG_INFO, "tSocketServer: close" );
+	if( close( VAR_sd ) < 0 )
+		ercd = errno2ER( errno );
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTDR_inline.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTDR_inline.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTDR_inline.h	(revision 317)
@@ -0,0 +1,1244 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * tmo              TMO              VAR_tmo         
+ *
+ * #[</PREAMBLE>]# */
+
+/*
+ * marhaler, unmarshaler ãä½¿ç¨ãã STRLEN é¢æ°ãå®ç¾©ãã
+ *  marshaler, unmarshaler ã¯å¿
+ã TDR ã¯ ã«çµåããããã
+ */
+#include	"rpc_string.h"
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eTDR
+ * entry port: eTDR
+ * signature:  sTDR
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eTDR_reset
+ * name:         eTDR_reset
+ * global_name:  tTDR_eTDR_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	syslog( LOG_INFO, "TDR: resetting channel" );
+	ercd = cChannel_reset();
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_sendSOP
+ * name:         eTDR_sendSOP
+ * global_name:  tTDR_eTDR_sendSOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_sendSOP(CELLIDX idx, bool_t b_client )
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	const uint16_t *p_sopMagic;
+	const uint16_t SOP_MAGIC1 = TDR_SOP_MAGIC1;
+	const uint16_t SOP_MAGIC2 = TDR_SOP_MAGIC2;
+	uint8_t		   val;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_sendSOP(b_client=%d)", b_client);
+#endif
+    if( b_client )
+		p_sopMagic = &SOP_MAGIC1;
+	else
+		p_sopMagic = &SOP_MAGIC2;
+
+	/*
+	 * SOP ãã±ããã®éä¿¡
+	 * ãã±ããã·ã¼ã±ã³ã¹ãå¤å°å´©ãã¦ãåå¾©ã§ããããã«ããã¤ãåä½ã§éã
+	 * ä¸ä½ã¢ãã¬ã¹ãä¸ä½ã¢ãã¬ã¹ã®é ã«éã
+	 */
+
+	val = (uint8_t)(*((uint8_t *)p_sopMagic));
+	ercd = eTDR_putUInt8( idx, val );
+	// syslog( LOG_INFO, "sendSOP:1 %02X", val );
+	if( ercd != E_OK )
+		return	ercd;
+	val = (uint8_t)*(((uint8_t *)p_sopMagic)+1);
+	ercd = eTDR_putUInt8( idx, val );
+	// syslog( LOG_INFO, "sendSOP:2 %02X", val );
+
+	return	ercd;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_receiveSOP
+ * name:         eTDR_receiveSOP
+ * global_name:  tTDR_eTDR_receiveSOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_receiveSOP(CELLIDX idx, bool_t b_client)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	const uint16_t SOP_MAGIC1 = TDR_SOP_MAGIC1;
+	const uint16_t SOP_MAGIC2 = TDR_SOP_MAGIC2;
+	const uint16_t *p_sopMagic;
+	uint16_t magic;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_receiveSOP(b_client=%d)", b_client);
+#endif
+
+    if( b_client )
+		p_sopMagic = &SOP_MAGIC2;
+	else
+		p_sopMagic = &SOP_MAGIC1;
+
+	if( (ercd=eTDR_getUInt8( idx, (uint8_t *)&magic )) != E_OK )
+		;
+	else if( (uint8_t)magic != (uint8_t)(*((uint8_t *)p_sopMagic)) ){
+		// syslog( LOG_INFO, "receiveSOP:1 %02X expecting=%02X", (uint8_t)magic, (int8_t)(*((int8_t *)p_sopMagic)) );
+		ercd = E_MAGIC;
+	}
+	else if((ercd=eTDR_getUInt8( idx, ((uint8_t *)&magic)+1 )) != E_OK )
+		;
+	else if( magic != *p_sopMagic){
+		// syslog( LOG_INFO, "receiveSOP:2 %04X expecting=%04X", magic, *p_sopMagic );
+		ercd = E_MAGIC;
+	}
+
+	if( ercd != E_OK )
+		syslog( LOG_INFO, "receiveSOP: ERCD=%d", ercd );
+
+	return ercd;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_sendEOP
+ * name:         eTDR_sendEOP
+ * global_name:  tTDR_eTDR_sendEOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_sendEOP(CELLIDX idx, bool_t b_continue )
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint16_t magic;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_sendEOP(b_continue=%d)", b_continue);
+#endif
+
+	if( b_continue )
+		magic = TDR_EOP_MAGIC1;
+	else
+		magic = TDR_EOP_MAGIC2;
+
+	/* EOP magic ã®éä¿¡ */
+	if( (ercd = eTDR_putInt16( idx, (int16_t)magic )) != E_OK )
+		return ercd;
+
+	return cChannel_flush(VAR_tmo);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_receiveEOP
+ * name:         eTDR_receiveEOP
+ * global_name:  tTDR_eTDR_receiveEOP
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_receiveEOP(CELLIDX idx, bool_t b_continue)
+{
+	ER		ercd = E_OK, er2;
+	CELLCB	*p_cellcb;
+	uint16_t magic;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "eTDR_receiveEOP(b_continue=%d)",b_continue);
+#endif
+/* mikan cChannel EOF get_* */
+/* mikan magic EOF */
+
+	if( (ercd=eTDR_getInt16( idx, (int16_t *)&magic )) == E_OK ){
+		if( (b_continue && magic == TDR_EOP_MAGIC1) || (!b_continue && magic == TDR_EOP_MAGIC2) ){
+		} else {
+			ercd = E_MAGIC;
+		}
+	}
+	er2 = cChannel_end_receive();
+	return ercd != E_OK ? ercd : er2;
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt8
+ * name:         eTDR_putInt8
+ * global_name:  tTDR_eTDR_putInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt8(CELLIDX idx, int8_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt16
+ * name:         eTDR_putInt16
+ * global_name:  tTDR_eTDR_putInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt16(CELLIDX idx, int16_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt32
+ * name:         eTDR_putInt32
+ * global_name:  tTDR_eTDR_putInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt32(CELLIDX idx, int32_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt64
+ * name:         eTDR_putInt64
+ * global_name:  tTDR_eTDR_putInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt64(CELLIDX idx, int64_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt128
+ * name:         eTDR_putInt128
+ * global_name:  tTDR_eTDR_putInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt128(CELLIDX idx, int128_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt8
+ * name:         eTDR_getInt8
+ * global_name:  tTDR_eTDR_getInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt8(CELLIDX idx, int8_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	 *p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt16
+ * name:         eTDR_getInt16
+ * global_name:  tTDR_eTDR_getInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt16(CELLIDX idx, int16_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt32
+ * name:         eTDR_getInt32
+ * global_name:  tTDR_eTDR_getInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt32(CELLIDX idx, int32_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt64
+ * name:         eTDR_getInt64
+ * global_name:  tTDR_eTDR_getInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt64(CELLIDX idx, int64_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt128
+ * name:         eTDR_getInt128
+ * global_name:  tTDR_eTDR_getInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt128(CELLIDX idx, int128_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt8
+ * name:         eTDR_putUInt8
+ * global_name:  tTDR_eTDR_putUInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt8(CELLIDX idx, uint8_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt16
+ * name:         eTDR_putUInt16
+ * global_name:  tTDR_eTDR_putUInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt16(CELLIDX idx, uint16_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt32
+ * name:         eTDR_putUInt32
+ * global_name:  tTDR_eTDR_putUInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt32(CELLIDX idx, uint32_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt64
+ * name:         eTDR_putUInt64
+ * global_name:  tTDR_eTDR_putUInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt64(CELLIDX idx, uint64_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt128
+ * name:         eTDR_putUInt128
+ * global_name:  tTDR_eTDR_putUInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt128(CELLIDX idx, uint128_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt8
+ * name:         eTDR_getUInt8
+ * global_name:  tTDR_eTDR_getUInt8
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt8(CELLIDX idx, uint8_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt16
+ * name:         eTDR_getUInt16
+ * global_name:  tTDR_eTDR_getUInt16
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt16(CELLIDX idx, uint16_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt32
+ * name:         eTDR_getUInt32
+ * global_name:  tTDR_eTDR_getUInt32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt32(CELLIDX idx, uint32_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt64
+ * name:         eTDR_getUInt64
+ * global_name:  tTDR_eTDR_getUInt64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt64(CELLIDX idx, uint64_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt128
+ * name:         eTDR_getUInt128
+ * global_name:  tTDR_eTDR_getUInt128
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt128(CELLIDX idx, uint128_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putBool
+ * name:         eTDR_putBool
+ * global_name:  tNBOTDR_eTDR_putBool
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putBool(CELLIDX idx, bool_t in)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	eTDR_putUInt8(idx, (uint8_t)(in != 0) );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getBool
+ * name:         eTDR_getBool
+ * global_name:  tNBOTDR_eTDR_getBool
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getBool(CELLIDX idx, bool_t* out)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	uint8_t	val;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = eTDR_getUInt8(idx, &val );
+	if( ercd != E_OK )
+		return ercd;
+	*out = (val != 0);
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putFloat32
+ * name:         eTDR_putFloat32
+ * global_name:  tTDR_eTDR_putFloat32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putFloat32(CELLIDX idx, float32_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putDouble64
+ * name:         eTDR_putDouble64
+ * global_name:  tTDR_eTDR_putDouble64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putDouble64(CELLIDX idx, double64_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getFloat32
+ * name:         eTDR_getFloat32
+ * global_name:  tTDR_eTDR_getFloat32
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getFloat32(CELLIDX idx, float32_t* out)
+{
+	ER_UINT		er_sz = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getDouble64
+ * name:         eTDR_getDouble64
+ * global_name:  tTDR_eTDR_getDouble64
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getDouble64(CELLIDX idx, double64_t* out)
+{
+	ER_UINT		er_sz = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putChar
+ * name:         eTDR_putChar
+ * global_name:  tTDR_eTDR_putChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putChar(CELLIDX idx, char_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getChar
+ * name:         eTDR_getChar
+ * global_name:  tTDR_eTDR_getChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getChar(CELLIDX idx, char_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putSChar
+ * name:         eTDR_putSChar
+ * global_name:  tTDR_eTDR_putSChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putSChar(CELLIDX idx, signed char in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putShort
+ * name:         eTDR_putShort
+ * global_name:  tTDR_eTDR_putShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putShort(CELLIDX idx, short_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putInt
+ * name:         eTDR_putInt
+ * global_name:  tTDR_eTDR_putInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putInt(CELLIDX idx, int_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putLong
+ * name:         eTDR_putLong
+ * global_name:  tTDR_eTDR_putLong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putLong(CELLIDX idx, long_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getSChar
+ * name:         eTDR_getSChar
+ * global_name:  tTDR_eTDR_getSChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getSChar(CELLIDX idx, signed char* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getShort
+ * name:         eTDR_getShort
+ * global_name:  tTDR_eTDR_getShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getShort(CELLIDX idx, short* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getInt
+ * name:         eTDR_getInt
+ * global_name:  tTDR_eTDR_getInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getInt(CELLIDX idx, int_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getLong
+ * name:         eTDR_getLong
+ * global_name:  tTDR_eTDR_getLong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getLong(CELLIDX idx, long_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUChar
+ * name:         eTDR_putUChar
+ * global_name:  tTDR_eTDR_putUChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUChar(CELLIDX idx, unsigned char in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUShort
+ * name:         eTDR_putUShort
+ * global_name:  tTDR_eTDR_putUShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUShort(CELLIDX idx, ushort_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putUInt
+ * name:         eTDR_putUInt
+ * global_name:  tTDR_eTDR_putUInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putUInt(CELLIDX idx, uint_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putULong
+ * name:         eTDR_putULong
+ * global_name:  tTDR_eTDR_putULong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putULong(CELLIDX idx, ulong_t in)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&in, (int16_t)sizeof( in ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUChar
+ * name:         eTDR_getUChar
+ * global_name:  tTDR_eTDR_getUChar
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUChar(CELLIDX idx, unsigned char* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUShort
+ * name:         eTDR_getUShort
+ * global_name:  tTDR_eTDR_getUShort
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUShort(CELLIDX idx, unsigned short* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getUInt
+ * name:         eTDR_getUInt
+ * global_name:  tTDR_eTDR_getUInt
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getUInt(CELLIDX idx, uint_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getULong
+ * name:         eTDR_getULong
+ * global_name:  tTDR_eTDR_getULong
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getULong(CELLIDX idx, ulong_t* out)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	} /* end if VALID_IDX(idx) */
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)out, (int16_t)sizeof( *out ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *out ) ? E_OK : E_BOVR );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_putIntptr
+ * name:         eTDR_putIntptr
+ * global_name:  tTDR_eTDR_putIntptr
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_putIntptr(CELLIDX idx, const intptr_t ptr)
+{
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	return cChannel_send( (int8_t *)&ptr, (int16_t)sizeof( ptr ), VAR_tmo );
+}
+
+/* #[<ENTRY_FUNC>]# eTDR_getIntptr
+ * name:         eTDR_getIntptr
+ * global_name:  tTDR_eTDR_getIntptr
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+Inline ER
+eTDR_getIntptr(CELLIDX idx, intptr_t* ptr)
+{
+	ER_UINT	 er_sz;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	er_sz = cChannel_receive( (int8_t *)ptr, (int16_t)sizeof( *ptr ), VAR_tmo );
+	return  er_sz < 0 ? er_sz : ( er_sz == sizeof( *ptr ) ? E_OK : E_BOVR );
+}
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETChannel.cdl
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETChannel.cdl	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETChannel.cdl	(revision 317)
@@ -0,0 +1,125 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+import_C( "netinet/in.h" );
+
+const	uint16_t	TINETIPV4_DEFAULT_PORT_NO  = 8931;
+
+signature sTINETClientOpenerIPV4 {
+	ER		open( [in]const T_IPV4EP *clientAddr, [in]TMO tmo );
+	ER		close( [in]TMO tmo );
+};
+
+signature sIPV4AcceptCheck {
+	bool_t	check( [in]const T_IPV4EP *clientAddr );
+};
+
+celltype tTINETClient {
+	entry	sChannel				eC0;
+	entry	sTINETClientOpenerIPV4	eOpener;
+	attr {
+		ID				cep_id = C_EXP( "$id$_CEPID" );
+		[omit]
+			uint16_t	recv_buf_size = C_EXP( "TCP_MSS" );
+		[omit]
+			uint16_t	send_buf_size = C_EXP( "TCP_MSS" );
+	};
+	FACTORY {
+		write( "$ct$_factory.h", "#include \"netinet/tcp.h\"\n" );
+		write( "$ct$_tecsgen.h", "#include \"tinet_cfg.h\"\n" );
+		write( "tinet_tecsgen.cfg", "#include \"$ct$_factory.h\"\n" );
+	};
+	factory {
+		write( "$ct$_factory.h", "int8_t $id$_recv_buf[%s];\n", recv_buf_size );
+		write( "$ct$_factory.h", "int8_t $id$_send_buf[%s];\n", send_buf_size );
+		write( "tinet_tecsgen.cfg", "TCP_CRE_CEP ($id$_CEPID, {\n"
+								"	0,\n"
+								"	$id$_send_buf,\n"
+								"	%s,\n"
+								"	$id$_recv_buf,\n"
+								"	%s,\n"
+								"	NULL \n"
+								"	} );\n",
+			   send_buf_size, recv_buf_size );
+	};
+};
+
+celltype tTINETServer {
+
+	entry	sChannel				eC1;
+	entry	sServerChannelOpener	eOpener;
+	[optional]
+		call  sIPV4AcceptCheck  cCheck;
+	attr {
+		ID				cep_id = C_EXP( "$id$_CEPID" );
+		ID				rep_id = C_EXP( "$id$_REPID" );
+		[omit]
+			int16_t		portNo  = TINETIPV4_DEFAULT_PORT_NO;
+		[omit]
+			uint16_t	recv_buf_size = C_EXP( "TCP_MSS" );
+		[omit]
+			uint16_t	send_buf_size = C_EXP( "TCP_MSS" );
+	};
+	FACTORY {
+		write( "$ct$_factory.h", "#include \"netinet/tcp.h\"\n" );
+		write( "$ct$_tecsgen.h", "#include \"tinet_cfg.h\"\n" );
+		write( "tinet_tecsgen.cfg", "#include \"$ct$_factory.h\"\n" );
+	};
+	factory {
+		write( "$ct$_factory.h", "int8_t $id$_recv_buf[%s];\n", recv_buf_size );
+		write( "$ct$_factory.h", "int8_t $id$_send_buf[%s];\n", send_buf_size );
+		write( "tinet_tecsgen.cfg", "TCP_CRE_REP ($id$_REPID,	{ 0, { IPV4_ADDRANY, %s } } );\n", portNo );
+		write( "tinet_tecsgen.cfg", "TCP_CRE_CEP ($id$_CEPID, {0, $id$_send_buf, %s, $id$_recv_buf, %s, NULL } );\n",
+				   send_buf_size, recv_buf_size );
+	};
+};
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETClient.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETClient.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETClient.c	(revision 317)
@@ -0,0 +1,279 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * cep_id           ID               ATTR_cep_id     
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tTINETClient_tecsgen.h"
+#include "tTINETClient_factory.h"
+
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/tcp.h>
+
+#ifndef E_OK
+#define	E_OK	0		/* æ­£å¸¸çµäº */
+#define	E_ID	(-18)	/* ä¸æ­£IDçªå· */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eC0
+ * entry port: eC0
+ * signature:  sChannel
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eC0_send
+ * name:         eC0_send
+ * global_name:  tTINETClient_eC0_send
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int     sz;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+#ifdef DEBUG
+	syslog( LOG_INFO, "tTINETServer: send" );
+	{
+		int i;
+		for( i = 0; i < size; i++ ){
+			printf( "%02X ", (unsigned char)buf[i] );
+			if( i % 8 == 7 )
+				putchar( '\n' );
+		}
+		putchar( '\n' );
+	}
+#endif
+	while(size>0){
+		if((sz=tcp_snd_dat( ATTR_cep_id, (intptr_t *)buf, (size_t)size, tmo )) < 0 ){
+			ercd = sz;
+			break;
+		}
+		else{
+			size -= sz;
+		}
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_flush
+ * name:         eC0_flush
+ * global_name:  tTINETClient_eC0_flush
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_flush(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	/* write ã¯ãããã¡ãªã³ã°ãªããªã®ã§ flush ããªã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_receive
+ * name:         eC0_receive
+ * global_name:  tTINETClient_eC0_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER_UINT
+eC0_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	ercd = tcp_rcv_dat( ATTR_cep_id, buf, (size_t)size, tmo );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_end_receive
+ * name:         eC0_end_receive
+ * global_name:  tTINETClient_eC0_end_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_end_receive(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC0_reset
+ * name:         eC0_reset
+ * global_name:  tTINETClient_eC0_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC0_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_PORT>]# eOpener
+ * entry port: eOpener
+ * signature:  sTINETClientOpenerIPV4
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eOpener_open
+ * name:         eOpener_open
+ * global_name:  tTINETClient_eOpener_open
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_open(CELLIDX idx, const T_IPV4EP* clientAddr, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	puts("opening");
+	ercd=tcp_con_cep(ATTR_cep_id, NADR, clientAddr, tmo);
+	if(ercd<0){
+		puts("failed");
+		syslog( LOG_INFO, "TINETClient: connect failed");
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eOpener_close
+ * name:         eOpener_close
+ * global_name:  tTINETClient_eOpener_close
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_close(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	ercd = tcp_cls_cep( ATTR_cep_id, 0 );       /* mikan ã¨ã©ã¼å¦ç */
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETServer.c
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETServer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tTINETServer.c	(revision 317)
@@ -0,0 +1,290 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+ *
+ * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ #_CAAM_#
+ * cep_id           ID               ATTR_cep_id     
+ * rep_id           ID               ATTR_rep_id     
+ *
+ * å¼ã³å£é¢æ° #_TCPF_#
+ * call port : cCheck  signature: sIPV4AcceptCheck context: task
+ *   bool_t         cCheck_check( const T_IPV4EP* clientAddr );
+ *
+ * #[</PREAMBLE>]# */
+
+#include "tTINETServer_tecsgen.h"
+#include "tTINETServer_factory.h"
+
+#include <string.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/tcp.h>
+
+
+#ifndef E_OK
+#define	E_OK	0		/* æ­£å¸¸çµäº */
+#define	E_ID	(-18)	/* ä¸æ­£IDçªå· */
+#endif
+
+/* åãå£é¢æ° #_TEPF_# */
+/* #[<ENTRY_PORT>]# eC1
+ * entry port: eC1
+ * signature:  sChannel
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eC1_send
+ * name:         eC1_send
+ * global_name:  tTINETServer_eC1_send
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	int     sz;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+#ifdef DEBUG
+	syslog( LOG_INFO, "tTINETServer: send" );
+	{
+		int i;
+		for( i = 0; i < size; i++ ){
+			printf( "%02X ", (unsigned char)buf[i] );
+			if( i % 8 == 7 )
+				putchar( '\n' );
+		}
+		putchar( '\n' );
+	}
+#endif
+	while(size>0){
+		if((sz=tcp_snd_dat( ATTR_cep_id, buf, (size_t)size, tmo )) < 0 ){
+			ercd = sz;
+			break;
+		}
+		else{
+			size -= sz;
+		}
+	}
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_flush
+ * name:         eC1_flush
+ * global_name:  tTINETServer_eC1_flush
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_flush(CELLIDX idx, TMO tmo)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_receive
+ * name:         eC1_receive
+ * global_name:  tTINETServer_eC1_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER_UINT
+eC1_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
+{
+	ER		ercd = E_OK;
+	ER_UINT sz;
+	CELLCB	*p_cellcb;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	ercd = tcp_rcv_dat( ATTR_cep_id, buf, (size_t)size, tmo );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_end_receive
+ * name:         eC1_end_receive
+ * global_name:  tTINETServer_eC1_end_receive
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_end_receive(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eC1_reset
+ * name:         eC1_reset
+ * global_name:  tTINETServer_eC1_reset
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eC1_reset(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã */
+	syslog( LOG_INFO, "tTINETServer: reset" );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_PORT>]# eOpener
+ * entry port: eOpener
+ * signature:  sServerChannelOpener
+ * context:    task
+ * #[</ENTRY_PORT>]# */
+
+/* #[<ENTRY_FUNC>]# eOpener_open
+ * name:         eOpener_open
+ * global_name:  tTINETServer_eOpener_open
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_open(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	T_IPV4EP		dst;
+
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	syslog( LOG_INFO, "tTINETServer: open" );
+	if( (ercd=tcp_acp_cep(ATTR_cep_id, ATTR_rep_id, &dst, TMO_FEVR)) != E_OK ){
+		syslog( LOG_INFO, "tTINETServer: accept failed" );
+		return ercd;
+	}
+
+	syslog( LOG_INFO, "tTINETServer: accepted" );
+
+	return(ercd);
+}
+
+/* #[<ENTRY_FUNC>]# eOpener_close
+ * name:         eOpener_close
+ * global_name:  tTINETServer_eOpener_close
+ * oneway:       false
+ * #[</ENTRY_FUNC>]# */
+ER
+eOpener_close(CELLIDX idx)
+{
+	ER		ercd = E_OK;
+	CELLCB	*p_cellcb;
+	if (VALID_IDX(idx)) {
+		p_cellcb = GET_CELLCB(idx);
+	}
+	else {
+		return(E_ID);
+	}
+
+	/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã #_TEFB_# */
+	syslog( LOG_INFO, "tTINETServer: close" );
+	ercd = tcp_cls_cep( ATTR_cep_id, TMO_FEVR );
+
+	return(ercd);
+}
+
+/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
Index: asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tecs_rpc.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tecs_rpc.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/rpc/tecs_rpc.h	(revision 317)
@@ -0,0 +1,82 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+#ifndef  tecs_rpc_h__
+#define  tecs_rpc_h__
+
+#include "tecs.h"
+
+#ifndef E_RPC
+
+#define E_RPC    (-68)
+
+/* minor error code */
+#define E_RESET  (-101)
+#define E_MAGIC  (-102)
+
+#endif /* E_RPC */
+
+
+/*
+ * marshaler, unmarshaler å
+ã®ç¶æ
+å¤ãè¨­å®ãããã¯ã­
+ * val ã¯ sRPCErrorHandler.cdl ã§å®ç¾©ãã
+ */
+#if ! defined( NO_NEED_RPC_STATE ) && ! defined( NO_NEED_RPC_ERROR_HANDLER )
+#define SET_RPC_STATE( state, val )		(state)=(val)
+#else
+#define SET_RPC_STATE( state, val )
+#endif /* NO_NEED_RPC_STATE */
+
+#endif /* tecs_rpc_h__ */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/tecs.h
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/tecs.h	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/tecs.h	(revision 317)
@@ -0,0 +1,79 @@
+/*
+ *  TECS Generator
+ *      Generator for TOPPERS Embedded Component System
+ *  
+ *   Copyright (C) 2008-2013 by TOPPERS Project
+ *--
+ *   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *       ã¨ï¼
+ *     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *         å ±åãããã¨ï¼
+ *   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *       å
+è²¬ãããã¨ï¼
+ *  
+ *   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *   ã®è²¬ä»»ãè² ããªãï¼
+ *  
+ *   $Id$
+ */
+
+#ifndef  tecs_h__
+#define  tecs_h__
+
+#include "t_stddef.h"
+
+#ifndef INT128_DEFINED
+#define INT128_DEFINED
+typedef struct tag_int128_t { int64_t  hi; int64_t  lo; } int128_t;
+typedef struct tag_uint128_t { int64_t  hi; int64_t  lo; } uint128_t;
+#endif /* end INT128_T_DEFINED */
+
+#ifndef SHORT_T_DEFINED
+#define SHORT_T_DEFINED
+typedef short short_t;
+typedef unsigned short ushort_t;
+#endif /* end SHORT_T_DEFINED */
+
+#ifndef CHAR_T_DEFINED				/* t_stddef.h ASP 1.7.0 ä»¥åã§ã¯éè¤ãã */
+#define CHAR_T_DEFINED
+typedef char  char_t;				/* signed, unsigned æªå® */
+#endif /* end CHAR_T_DEFINED */
+
+typedef signed char		schar_t;	/* signed */
+typedef unsigned char	uchar_t;	/* unsigned */
+
+#endif /* end tecs_h__ */
Index: asp3_gr_sakura/trunk/tecsgen/tecs/tecs.xsd
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecs/tecs.xsd	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecs/tecs.xsd	(revision 317)
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="utf-8"?>
+<xsd:schema
+    xmlns="http://www.toppers.jp/tecs.html"
+    targetNamespace="http://www.toppers.jp/tecs.html"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" >
+
+  <!-- 1st element -->
+  <xsd:element name="GUI_Tool">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="import" />
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="namespace" />
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="signature" />
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="celltype"  />
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="cell" />
+          <xsd:element minOccurs="0" maxOccurs="unbounded" ref="region" />
+        </xsd:choice>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <!--
+    * All elements MUST BE TOP LEVEL to assign global name.
+	* In XML file, all names are treated as global name.
+    * Note: inner elements have local name.
+	 -->
+
+  <!-- elements of statement -->
+  <xsd:element name="import"    type="importType" />
+  <xsd:element name="signature" type="signatureType" />
+  <xsd:element name="celltype"  type="celltypeType" />
+  <xsd:element name="cell"      type="cellType" />
+  <xsd:element name="namespace" type="namespaceType" />
+  <xsd:element name="region"    type="regionType" />
+
+  <!-- elements of name, type, expression(rhs, initializer, subscript)  -->
+  <xsd:element name="name"      type="xsd:string" />
+  <xsd:element name="signame"   type="xsd:string" />
+  <xsd:element name="rettype"   type="xsd:string" />
+  <xsd:element name="type"      type="xsd:string" />
+  <xsd:element name="subscript" type="xsd:string" />
+  <xsd:element name="rhs"       type="xsd:string" />
+  <xsd:element name="initializer" type="xsd:string" />
+  <xsd:element name="choiceElement" type="xsd:string" />
+  <xsd:element name="composite" />                       <!-- treat composite as celltype with 'composite' specifier -->
+  <xsd:element name="singleton" />
+  <xsd:element name="active" />
+
+  <!-- elements for signature -->
+  <xsd:element name="param">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="type"/>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="func">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="rettype" />
+        <xsd:element minOccurs="0" maxOccurs="unbounded" ref="param" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <!-- elements for celltype -->
+  <xsd:element name="attr">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="type" />
+        <xsd:element minOccurs="0" ref="initializer" />
+        <xsd:element minOccurs="0" maxOccurs="1" ref="choice" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="choice">
+    <xsd:complexType>
+      <xsd:sequence>
+      <xsd:element minOccurs="1" maxOccurs="unbounded" ref="choiceElement"/>
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="call">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="signame" />
+        <xsd:element minOccurs="0" ref="subscript" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="entry">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="signame" />
+        <xsd:element minOccurs="0" ref="subscript" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <!-- elements for cell -->
+  <xsd:element name="attr_join">
+    <xsd:complexType>
+      <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element ref="rhs" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <xsd:element name="call_join">
+    <xsd:complexType>
+     <xsd:sequence>
+        <xsd:element ref="name"/>
+        <xsd:element minOccurs="0" ref="subscript" />
+        <xsd:element ref="rhs" />
+      </xsd:sequence>
+    </xsd:complexType>
+  </xsd:element>
+
+  <!-- ***** complex types ***** -->
+  <xsd:complexType name="signatureType">
+    <xsd:sequence>
+      <xsd:element ref="name"/>
+      <xsd:element minOccurs="1" maxOccurs="unbounded" ref="func" />
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="celltypeType">
+    <xsd:sequence>
+      <xsd:choice maxOccurs="unbounded">
+        <xsd:element ref="name"/>
+        <xsd:element maxOccurs="1" ref="composite" />
+        <xsd:element maxOccurs="1" ref="singleton" />
+        <xsd:element maxOccurs="1" ref="active" />
+        <xsd:element maxOccurs="unbounded" ref="attr" />
+        <xsd:element maxOccurs="unbounded" ref="call" />
+        <xsd:element maxOccurs="unbounded" ref="entry" />
+      </xsd:choice>
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="cellType">
+    <xsd:sequence>
+      <xsd:choice maxOccurs="unbounded">
+        <xsd:element ref="name"/>
+        <xsd:element maxOccurs="unbounded" ref="attr_join" />
+        <xsd:element maxOccurs="unbounded" ref="call_join" />
+      </xsd:choice>
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="namespaceType">
+    <xsd:sequence maxOccurs="unbounded" >
+      <xsd:element ref="name"/>
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="signature" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="celltype" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="namespace" />
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="regionType">
+    <xsd:sequence maxOccurs="unbounded" >
+      <xsd:element ref="name"/>
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="cell" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="import" />  <!-- inner: cell, region only -->
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="region" />
+    </xsd:sequence>
+  </xsd:complexType>
+
+  <xsd:complexType name="importType">
+  	<xsd:sequence>
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="import" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="signature" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="celltype"  />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="cell" />
+      <xsd:element minOccurs="0" maxOccurs="unbounded" ref="region" />
+    </xsd:sequence>
+    <xsd:attribute name="path" type="xsd:string" use="required" />
+  </xsd:complexType>
+
+</xsd:schema>
Index: asp3_gr_sakura/trunk/tecsgen/tecsgen
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsgen	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsgen	(revision 317)
@@ -0,0 +1,58 @@
+#! /bin/sh
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2013 by TOPPERS Project
+#
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecsgen 2027 2014-01-20 08:36:17Z okuma-top $
+
+#ruby -w $TECSPATH/../tecsgen/tecsgen.rb "$@"
+tecsgen.rb "$@"
+exit $?
+
+# ç´æ¥ tecsgen.rb ãå¼åºãã±ã¼ã¹ãããããããããã®ã¹ã¯ãªããã§å¦çãè¡ãã¹ãã§ãªã
Index: asp3_gr_sakura/trunk/tecsgen/tecsgen.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsgen.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsgen.rb	(revision 317)
@@ -0,0 +1,634 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecsgen.rb 2554 2016-02-27 06:11:34Z okuma-top $
+#++
+
+#= tecsgen  : TECS ã®ã¸ã§ãã¬ã¼ã¿
+#
+#Authors::    ç³å·ãæä¹(HRP2Plugin)
+#Authors::    åããæ(åççµåä»æ§)
+#Authors::    æ²³ç°ãæºæ(NotifierPlugin)
+#Authors::    é«ç°ãåºç« (ASP3 ã¸ã® TECS çµè¾¼ã¿)
+#Authors::    é«æ¨ãä¿¡å°(ã©ã³ã¿ã¤ã ããã)
+#Authors::    æç¬ãæç¾(TECS flow å®è£
+)
+#Authors::    éµé£¼ãæ¬å¹¸(ATK1Plugin)
+#Authors::    å¤§å±±ãåå¸(ã¸ã§ãã¬ã¼ã¿å®è£
+, RPCPlugin, TracePlugin, MrubyBridgePlugin)
+#Authors::    å±±æ¬ãå°ä¹(ã¸ã§ãã¬ã¼ã¿åæãã­ãã¿ã¤ãå®è£
+)
+#Authors::    å°åãéé(ãã¹ãã³ã¼ãã®ä¸é¨)
+#Authors::    å®ç©ãåä¹(ASP+TECS, EV3RT+TECS, mruby on TECSç­å®è£
+)
+#  Authors list is in i-ro-ha order.
+#Version::   see version.rb
+$Copyright = "Copyright(c) 2008-2016, TOPPERS project. All rights reserved."
+$License   = "TOPPERS License"
+
+# This doesn't work as expected in exerb version (Ruby 1.8.7?)
+$tecsgen_base_path = File.dirname( File.expand_path __FILE__ )
+
+
+###
+#= Array  initializer ã® '{', '}' ã§å²ã¾ããå ´å
+# mikan AggregateInitializer ãªã©ãã¯ã©ã¹ãå¤æ´ãã¹ãã§ãã
+class Array
+  #=== CDL ã®æå­åãçæãã
+  def to_CDL_str
+    str = '{ '
+    delim = ''
+    self.each{ |v|
+      str += delim + v.to_CDL_str
+      delim = ', '
+    }
+    str += ' }'
+    return str
+  end
+
+  def show_tree( indent )
+    indent.times{ print "  " }
+    print( "Array\n" )
+    self.each{ |m|
+      m.show_tree( indent+1 )
+    }
+  end
+end
+
+#=== RUBY ã©ã¤ãã©ãªãã­ã¼ããã
+#
+# -L, $RUBYLIB, ã·ã¹ãã (/usr/lib/rub..ãªã©) ã®é ã«ãµã¼ããè¡ããã
+# exerb å¯¾å¿ã®ãããä¸è¨ãã¹ã«ãã¡ã¤ã«ãè¦ã¤ãããªãå ´å require ãå®è¡ãã¦ã¿ã
+#
+# ãã©ã°ã¤ã³ã®å ´åã¯ b_fatal = false ãæå®ããã¡ã¤ã«ããªãã¦ãã¨ã©ã¼åºåå¾ãå¦çç¶è¡
+# b_fatal = false ã®å ´å tecslib/core ããµã¼ããã¹ã«è¿½å ããã
+#RETURN::Bool   : true=æåã false=å¤±æ   å¤±æããå ´åãGenerator.error ã¯å¼ã³å
+ã§åºåãã
+def require_tecsgen_lib( fname, b_fatal = true )
+  dbgPrint( "require_lib: #{fname}\n")
+  set_kcode $KCODE_TECSGEN
+  begin  
+    b_require = false
+    b_exception = false
+
+    # -L ã $RUBYLIB ã§æå®ããããã¹ããã³ã·ã¹ãã ã®ãã¹ãããµã¼ã
+    #   exerb ã§ã¯ $LOAD_PATH ã¯ ["."] ã®ã¿å
+¥ã£ã¦ããããã 
+    ($library_path+$LOAD_PATH).each{ |path|
+      [ "", "tecslib/plugin/" ].each { |lp|
+        lib = File.expand_path( path ) + '/' + lp + fname
+        
+        if File.exist? lib then  # ãã¡ã¤ã«å­å¦ã¨ä»ã®ã¨ã©ã¼ãåºå¥ããããå­å¨ç¢ºèªããã
+          begin
+            require( lib )
+            b_require = true
+          rescue Exception => evar
+            b_exception = true
+            print_exception( evar )
+          end
+          break
+        end
+      }
+      if b_require then
+        break
+      end
+    }
+
+    if b_require == false && b_exception == false then
+      # exerb å¯¾å¿ "." ããµã¼ããã¹ã®æåã«å ãã
+      #   "tecslib/" ã¯ RPCPlugin.rb, TracePlugin.rb ã®ããã«ç¨æãã¦ãã
+      #   RPCPlugin.rb, TracePlugin.rb ã tecslib ä¸ã§ãªããã°ä¸è¦ã«ãªããããã®ããã«ãã¦ãã
+      ["","tecslib/plugin/"].each{ |lp|
+        path = lp + fname
+        begin
+          require path
+          return true
+        rescue LoadError => e
+          # p "LoadError to load #{fname}"
+          # 2015.12.18 exerb çã§ãã©ã°ã¤ã³ã®ã­ã¼ãã§ã¨ã©ã¼ãåºãã®ã§ãç¡è¦ãã. ããããæããã¨ã©ã¼ã¯åºã¦ãã
+          # print_exception( e )
+        rescue Exception => e
+          b_exception = true
+          # ææ³ã¨ã©ã¼ãªã©ãçºç
+          print_exception( e )
+          break
+        end
+      }
+    end
+
+    if b_require == false then
+      # è¦ã¤ãããªãã£ã
+      if b_exception == false then
+        STDERR << "tecsgen: Fail to load #{fname}. Check $RUBYLIB environment variable or -L option\n"
+      end
+      # tecsgen ãæ§æãããã¡ã¤ã«ã®å ´åã¯ä¸­æ­¢ãã
+      if b_fatal then
+        STDERR << "tecsgen: Exit because of unrecoverble error\n"
+        exit 1
+      end
+      return false
+    end
+    return true
+  ensure
+    # $KCODE ã CDL ã®æå­ã³ã¼ãã«æ»ãã¦ãã
+    set_kcode $KCODE_CDL
+  end
+end
+
+#=== ä¾å¤ã®è¡¨ç¤º
+#evar:: Exception
+def print_exception( evar )
+# ããã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãã¾ã§ãæéãããããããªãã°ãæ¬¡ãã³ã¡ã³ãã¢ã¦ããã¦ã¿ãã¹ã
+  print "*** Begin Ruby exception message ***\n"
+  puts( evar.to_s )
+
+  if $debug then
+    puts "#### stack trace ####"
+    pp evar.backtrace
+  end
+  print "*** End Ruby exception message ***\n"
+end
+
+def dbgPrint( str )
+  if $debug then
+    print str
+  end
+end
+
+def dbgPrintf( *param )
+  if $debug then
+    printf *param
+  end
+end
+
+#=== ã¨ã©ã¼ããã³è­¦åã®ã¬ãã¼ã
+def print_report
+  msg = nil
+
+  if Generator.get_n_error != 0 then
+    msg = "#{Generator.get_n_error} error"
+    msg = "#{msg}s" if Generator.get_n_error >= 2
+  end
+
+  if Generator.get_n_warning != 0 then
+    msg = "#{msg}  " if msg
+    msg = "#{msg}#{Generator.get_n_warning} warning"
+    msg = "#{msg}s" if Generator.get_n_warning >= 2
+  end
+
+  puts msg if msg
+end
+
+#=== $KCODE ãè¨­å®
+def set_kcode kcode
+  if ! $b_no_kcode then
+    $KCODE = kcode
+  end
+end
+#----- class TECSGEN -------#
+class TECSGEN
+
+  @@current_tecsgen = nil
+
+  def self.init( addtional_option_parser = nil )
+    initialize_global_var
+    analyze_option addtional_option_parser
+    load_modules
+    setup
+        
+    dbgPrint  "tecspath: #{$tecsgen_base_path}, __FILE__=#{__FILE__}\n"
+    dbgPrint  "ARGV(remained): #{ARGV}, argments=#{$arguments}\n"
+  end
+
+  #----- initialize -------#
+  def initialize
+    @cell_list = nil
+    @cell_list2 = nil
+    @celltype_list = nil
+    @root_namespace = nil
+
+    #--- obsolete ---#   replaced to TOOL_INFO
+    @cell_location_list = []
+    @join_location_list = []
+  end
+
+  def run1
+    @@current_tecsgen = self
+
+    syntax_analisys ARGV
+    semantics_analisys_1
+    semantics_analisys_2
+
+    @celltype_list = Celltype.get_celltype_list
+    @cell_list = Cell.get_cell_list
+    @cell_list2 = Cell.get_cell_list2
+
+    @@current_tecsgen = nil
+  end
+
+  def run2
+    @@current_tecsgen = self
+
+    optimize_and_generate
+    finalize
+
+    @@current_tecsgen = nil
+  end
+
+  #-----  initialize_global_var -----#
+  def self.initialize_global_var
+
+    require 'optparse'
+    #2.0 require 'runit/assert.rb'
+    require 'kconv'
+    $b_no_kcode = RUBY_VERSION >= "1.9.0" ? true : false
+	       # Use Ruby 1.9 M17N code (use Ruby 1.8 code if false).
+    if ! $b_no_kcode then
+      require 'jcode'
+    end
+    require 'pp'
+    # include RUNIT::Assert
+
+    ### ã°ã­ã¼ãã«å¤æ°å®ç¾© ###
+
+    # ã³ãã³ãã©ã¤ã³å¼æ°ã (Makefile.templ ã¸åºå)
+    $arguments = ""
+    ARGV.each { |a| $arguments += " " + a }
+
+    $unopt     = false     # bool:   disable optimizing
+    $gen_base  = "gen"     # string: folder path to place generated files
+    $gen       = $gen_base # string: folder path to place generated files
+    $generate_all_template = false   # bool:   generarete template files for all celltypes (if non cell exist or system celltypes)
+    $generate_no_template = false    # bool:   generarete no template file (neither celltype code nor Makefile)
+    $idx_is_id = false     # bool:   all components are idx_is_id
+    $unique_id = false     # bool:   assign unique id to each cell (otherwise begin from 1 for each celltype)
+    $debug     = false     # bool:   tecsgen debug message
+    $dryrun    = false     # bool:   dryrun mode: syntax is checked, but not generate any files
+    $show_tree = false     # bool:   show parsing tree
+    $verbose   = false     # bool:   verbose mode: show some messages
+    $yydebug   = false     # bool:   yydebug: parser debug mode (need bnf-deb.tab.rb)
+    $run_dir   = Dir.pwd   # string: tecsgen/tecscde start up directory
+    $base_dir  = {  }      # string=>bool: base dir for import_path (key:base_dir, val:actually used or specified directly)
+    $import_path = [ "." ] # string array : import/import_C path
+    $import_path_opt = []  # [String]
+    $library_path = [ $tecsgen_base_path ] # string array : path to dir where tecsgen.rb placed
+    $define    = [ ]       # string array : define
+    $ram_initializer = false # bool: generate ram initializer
+    $region_list = {}      #string array : region path which is generated
+    $generating_region = nil # Region:  Region to optimisze & generate code   # ã³ãã³ãã©ã¤ã³ãªãã·ã§ã³ã§ã¯ãªã
+		 #           Cell#is_generate? ã«ã¦åç
+§ããã
+    $unit_test = false     # bool:   unit test verification
+    $kcode     = nil       # nil | String: Kanji code type "euc"|"sjis"|"none"|"utf8"
+    $force_overwrite = false # bool:  force overwrite all files if file contents not differ
+    $no_banner = false     # bool:   not print banner
+    $print_version = false # bool:   print version
+    $target    = "tecs"    # String: target name, ARGV[0] ããåè¨­å®ããï¼"tecs" ã¯ä»®ã®ã¿ã¼ã²ãã)
+    $no_default_import_path = false  # bool: no default import path
+    $c_suffix  = "c"       # suffix for C progorams (for C++ source)
+    $h_suffix  = "h"       # suffix for C progoram headers (for C++ source)
+
+    if ENV['TECSGEN_DEFAULT_RAM'] then
+      rom_ram_defalult = "ram"
+    else
+      rom_ram_defalult = "rom"
+    end
+    if rom_ram_defalult == "rom" then
+      $rom       = true      # bool:   ROM support : generate CB separately
+    else
+      $rom       = false     # bool:   ROM support : generate CB separately
+    end
+    $b_cpp_specified = false
+    if $cpp == nil then
+      $cpp       = "gcc -E -DTECSGEN"
+    end
+    if ENV[ 'TECS_CPP' ]then
+      $cpp = ENV[ 'TECS_CPP' ]
+      $b_cpp_specified = true
+    end
+    if ENV[ 'TECSPATH' ] then
+      $tecspath = ENV[ 'TECSPATH' ]
+    else
+      $tecspath = "#{$tecsgen_base_path}/tecs"
+    end
+
+    # # æå­ã³ã¼ãã®è¨­å®
+    if $IN_EXERB then
+      # KCODE_CDL, $KCONV_CDL ãä»®ã«è¨­å®ãã (tecs_lang.rb ã§ããã«åè¨­å®ããã)
+      $KCODE_CDL = "SJIS"          # string: "EUC" | "SJIS" | "NONE" | "UTF8"
+      $KCONV_CDL = Kconv::SJIS     # const: NONE ã«ã¯ ASCII ãå¯¾å¿ããã
+    else
+      $KCODE_CDL = "EUC"           # string: "EUC" | "SJIS" | "NONE" | "UTF8"
+      $KCONV_CDL = Kconv::EUC      # const: NONE ã«ã¯ ASCII ãå¯¾å¿ããã
+    end
+    # $KCODE_TECSGEN, $KCONV_TECSGEN ãä»®ã«è¨­å®ãã (tecs_lang.rb ã§ããã«åè¨­å®ããã)
+    $KCODE_TECSGEN = "UTF8"      # string: "EUC"  ãã®ãã¡ã¤ã«ã®æå­ã³ã¼ãï¼ãªãã·ã§ã³ã§ã¯ãªãå®æ°ï¼
+    $KCONV_TECSGEN = Kconv::UTF8 # const: 
+    set_kcode( $KCODE_TECSGEN )  # ãã®ãã¡ã¤ã«ã®æå­ã³ã¼ããè¨­å®
+
+  end # initialize_global_var
+
+  def self.analyze_option( additional_option_parser )
+
+    ###  tecsgen ã³ãã³ããªãã·ã§ã³è§£æ  ###
+    ARGV.options {|parser|
+      parser.banner = "Usage: tecsgen [options] files"
+      parser.on('-D', '--define=def', 'define cpp symbol for import_C') { |define|
+        $define << define
+      }
+      parser.on('-G', '--generate-region=path', 'generate region') { |path|
+        if path =~ /^::/ then
+          gen_path = path
+        else
+          gen_path = "::" + path
+        end
+        $region_list[ gen_path ] = true
+      }
+      parser.on('-I', '--import-path=path', 'imoprt/import_C path') { |path|
+        $import_path << path
+        $import_path_opt << path
+      }
+      parser.on('-L', '--library-path=path', 'path to dir where tecsgen.rb (obsolete, unnecessary to specify -L, those passes are gotten from tecsgen.rb') { |path|
+        $library_path << path
+      }
+      parser.on('-R', '--RAM-initializer',   'generate RAM initializer. INITIALIZE_TECS() must be called before running any TECS code.' ){
+        $ram_initializer = true
+      }
+      parser.on('-U', '--unoptimize', 'unoptimize') {
+        $unopt = true
+      }
+      parser.on('-c', '--cpp=cpp_cmd', 'C pre-processor command used import_C (default: gcc -E -DTECSGEN), you can also specify by environment variable TECS_CPP' ){
+        |arg|
+        $cpp = arg
+        $b_cpp_specified = true
+      }
+      parser.on('-d', '--dryrun',      'dryrun' ){
+        $dryrun = true
+      }
+      parser.on('-f', '--force-overwrite', 'force overwrite all files') {
+        $force_overwrite = true
+      }
+      parser.on('-g', '--gen=dir',     'generate dir') { |dir|
+        $gen = $gen_base = dir
+      }
+      parser.on('-i', '--idx_is_id',   'set idx_is_id to all celltypes') {
+        $idx_is_id = true
+      }
+      #  parser.on('-k', '--kcode=code',  'set kanji code: euc|sjis|none|utf8, none is default') { |code|
+      parser.on('-k', '--kcode=code',  "set kanji code: euc|sjis|none|utf8") { |code|
+        $kcode = code
+      }
+      #  old_mode ã¯ V1.0.C.22 ã§å»æ­¢
+      #  parser.on('-o', '--old-mode',    'old mode' ){
+      #    $old_mode = true
+      #  }
+      parser.on('-r', '--ram',     'RAM only' ){
+        $rom = false
+      }
+      parser.on('-s', '--show-tree',   'show parsing tree' ){
+        $show_tree = true
+      }
+      parser.on('-t', '--generator-debug', 'generator debug' ){
+        $debug = true
+        $verbose = true
+      }
+      parser.on('-u', '--unique-id', 'assign unique id for each cell' ){
+        $unique_id = true
+      }
+      parser.on('-v', '--verbose',     'verbose mode' ){
+        $verbose = true
+      }
+      parser.on('-y', '--yydebug',     'yydebug' ){
+        $yydebug = true
+      }
+      parser.on( '--no-banner', 'not display banner') {
+        $no_banner = true
+      }
+      parser.on( '--version', 'print version') {
+        $print_version = true
+      }
+      parser.on( '--unit-test', 'unit verification (test tecsgen itself)') {
+        $unit_test = true
+      }
+      parser.on( '--generate-all-template', 'generate all celltypes\' templates') {
+        $generate_all_template = true
+      }
+      parser.on( '--generate-no-template',  'generate no template') {
+        $generate_no_template = true
+      }
+      parser.on( '--no-default-import-path', 'no default import path' ){
+        $no_default_import_path = true
+      }
+      parser.on( '--c-suffix=c', 'C program suffix (default: c)' ){
+        | suffix |
+        $c_suffix = suffix
+      }
+      parser.on( '--h-suffix=h', 'C program header suffix (default: h)' ){
+        | suffix |
+        $h_suffix = suffix
+      }
+      #  parser.on(  '--include_path_opt_format',  'cpp include path option format, default: "-I %s"' ){
+      #  }
+      parser.version = #{$version}
+      parser.release = nil
+      if additional_option_parser
+        additional_option_parser.call( parser )
+      end
+      parser.parse!
+    }
+
+    if ARGV.empty? && ! $print_version && ! $unit_test
+      ARGV.options{|parser|
+        puts parser.help
+        exit 1
+      }
+    end
+
+  end # analyze_option
+
+  def self.load_modules
+    ### tecsgen ã¢ã¸ã¥ã¼ã«ã®ã­ã¼ã ####
+    # -L ã§ãã¹æå®å¯è½ã¨ãããããããããã­ã¼ããéå§ãã
+
+    #  tecsgen ãã¼ã¸ã§ã³ãã¡ã¤ã«ã®ã­ã¼ã
+    # ãããå®è¡ããã¾ã§ tecsgen ã®ãã¼ã¸ã§ã³ãè¡¨ç¤ºã§ããªã
+    # ãã®ãã¡ã¤ã«ãèª¤ã£ã¦èª­ã¿è¾¼ãã¨ãç°ãªããã¼ã¸ã§ã³åãè¡¨ç¤ºãã¦ãã¾ã
+    require_tecsgen_lib 'tecslib/version.rb'
+    if ! $no_banner || $print_version
+      STDERR << "tecsgen  version #{$version}  #{$Copyright}\n"
+    end
+    if $verbose then
+      STDERR << "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} patchlevel #{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]\n"
+    end
+    if $print_version && ARGV.empty?
+      exit
+    end
+
+    # æå­ã³ã¼ãæ±ºå®ã®ããæåã«èª­ã¿ãã
+    require_tecsgen_lib 'tecslib/core/tecs_lang.rb'
+
+    unless $yydebug then
+      require_tecsgen_lib 'tecslib/core/bnf.tab.rb'
+    else
+      require_tecsgen_lib 'tecslib/core/bnf-deb.tab.rb'
+    end
+
+    # syntaxobj.rb ã«ã¯ Node ãå®ç¾©ããã¦ããã®ã§ãæ©ãæ®µéã§ require 
+    require_tecsgen_lib 'tecslib/core/syntaxobj.rb'
+    require_tecsgen_lib 'tecslib/core/pluginModule.rb'
+    require_tecsgen_lib 'tecslib/core/plugin.rb'
+    require_tecsgen_lib 'tecslib/core/messages.rb'
+    require_tecsgen_lib 'tecslib/core/types.rb'
+    require_tecsgen_lib 'tecslib/core/value.rb'
+    require_tecsgen_lib 'tecslib/core/componentobj.rb'
+    require_tecsgen_lib 'tecslib/core/expression.rb'
+    require_tecsgen_lib 'tecslib/core/optimize.rb'
+    require_tecsgen_lib 'tecslib/core/tecsgen.rb'
+    require_tecsgen_lib 'tecslib/core/generate.rb'
+    require_tecsgen_lib 'tecslib/core/gen_xml.rb'
+#    require_tecsgen_lib 'tecslib/core/tool_info.rb'
+    require_tecsgen_lib 'tecslib/plugin/CelltypePlugin.rb'
+    require_tecsgen_lib 'tecslib/plugin/CellPlugin.rb'
+    require_tecsgen_lib 'tecslib/plugin/SignaturePlugin.rb'
+    require_tecsgen_lib 'tecslib/plugin/ThroughPlugin.rb'
+    require_tecsgen_lib 'tecslib/plugin/DomainPlugin.rb'
+
+    # C è¨èªãã¼ãµ
+    require_tecsgen_lib 'tecslib/core/C_parser.tab.rb'
+    require_tecsgen_lib 'tecslib/core/ctypes.rb'
+
+    if $unit_test then
+      exit 1
+    end
+
+  end # load_modules
+
+  def self.setup
+    # $import_path, $tecspath ãèª¿æ´
+    TECSGEN.adjust_exerb_path
+
+    # $import_path ã«ç°å¢å¤æ° $TECSGEN ããã³ãã®ç´ä¸ãè¿½å 
+    if $no_default_import_path == false then
+      # $TECSGEN ããã³ããã®ç´ä¸ã®ãã£ã¬ã¯ããªããã¹ã«è¿½å 
+      if $tecspath != "." then
+        TECSGEN.add_import_path $tecspath
+        dir = nil
+        begin
+          Dir.foreach( $tecspath ){ |f|
+            if f != "." && f != ".." && File.directory?( $tecspath + '/' + f ) then
+              TECSGEN.add_import_path( $tecspath + '/' + f )
+            end
+          }
+        rescue
+          # ç¡è¦
+        end
+      end
+    end
+
+    # ããã©ã«ãè¨­å®
+    TECSGEN.set_default_config
+
+    # $target ã®è¨­å®
+    $target = ARGV[0]
+    pos = $target.rindex( /[:\\\/]/ )
+    if pos then
+      $target = $target[pos+1..-1]  # ãã£ã¬ã¯ããªåºåããé¤ããæå­å
+    end
+    pos = $target.rindex( /\./ )
+    if pos then
+      $target = $target[0..pos-1]   # æ¡å¼µå­ãåãé¤ããæå­å
+    end
+
+    # gen ãã£ã¬ã¯ããªã®ä½æ
+    begin
+      if ! File.directory?( $gen_base ) then
+        Dir.mkdir( $gen_base )
+      end
+    rescue
+      print( "Cannot mkdir #{$gen_base}. If the path has hierarchy, please create directory by manual.\n" )
+      exit 1
+    end
+  end # setup
+
+  #=== TECSGEN#get_celltype_list
+  def get_celltype_list
+    @celltype_list
+  end
+
+  #=== TECSGEN#get_cell_list
+  def get_cell_list
+    @cell_list
+  end
+
+  def get_root_namespace
+    @root_namespace
+  end
+end # TECSGEN
+
+# è¤æ°ã®ã¸ã§ãã¬ã¼ã¿ã¤ã³ã¹ã¿ã³ã¹ãçæãããã¨ã¯ãå¯è½ã ããä»¥ä¸ã®åé¡ããã
+#  ã¯ã©ã¹å¤æ°ã®ãªã»ãããç¢ºå®ã«è¡ãå¿
+è¦ããã
+
+if $TECSCDE != true then
+  begin
+    TECSGEN.init
+    tecsgen = TECSGEN.new
+    tecsgen.run1
+    tecsgen.run2
+  rescue => evar
+    print_exception( evar )
+    STDERR << "tecsgen: exit because of unrecoverble error.\n"
+    STDERR << "   please retry after resolve early error.\n"
+    STDERR << "   if no error has occured, please report to TOPPERS TECS WG (users@toppers.jp or com-wg@toppers.jp).\n"
+    exit 1
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov	(revision 317)
@@ -0,0 +1,13 @@
+#! /bin/sh
+# å¼æ°ã¯ "$@" ã¨ãã¦ãªãã¨ãå
+ã®å¼æ°ã« "--cpp=gcc-3 -E -DTECS" ã®ãããª '"' ã§å²ã¾ãããã®ãæå¾
+ããã¨ããã«æ±ããªã
+# --aggregate ã®å¼æ°ã¯ test/Makefile ã¨ä¸è´ãããå¿
+è¦ããã
+# rcov å®è¡æ pretty.rb ã§ ruby ä¾å¤çºçãããTrac #601 åç
+§ã
+
+do="rcov -t --no-html --aggregate $TECSPATH/../test/coverage.data $TECSPATH/../tecsgen/tecsgen.rb --"
+echo $do "$@"
+$do "$@"
+
Index: asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsgen_rcov.rb	(revision 317)
@@ -0,0 +1,77 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecsgen_rcov.rb 2554 2016-02-27 06:11:34Z okuma-top $
+#++
+
+# ã«ãã¬ãã¸ãåãããã® tecsgen ã³ãã³ã
+# SimpleCov ãä½¿ç¨ãããããruby V1.9 ä»¥éãå¿
+è¦
+#
+# Usage: tecsgen_rcov.rb [options] CDL-file.cdl
+#
+require 'simplecov'
+SimpleCov.command_name "tecsgen#{$$}"
+SimpleCov.root File.dirname( File.expand_path __FILE__ )
+SimpleCov.at_exit do
+  SimpleCov.result.format!
+end
+SimpleCov.start
+# SimpleCov.start do
+#    # add_filter "//"
+# end
+
+print "simplecov begin\n"
+
+require 'tecsgen'
+
+print "simplecov end\n"
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.tab.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.tab.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.tab.rb	(revision 317)
@@ -0,0 +1,2407 @@
+#
+# DO NOT MODIFY!!!!
+# This file is automatically generated by Racc 1.4.12
+# from Racc grammer file "".
+#
+
+require 'racc/parser.rb'
+class C_parser < Racc::Parser
+
+module_eval(<<'...end C_parser.y.rb/module_eval...', 'C_parser.y.rb', 715)
+
+  RESERVED = {
+    # keyword
+    'typedef' => :TYPEDEF,
+    'struct' => :STRUCT,
+    'union' => :UNION,
+    'sizeof' => :SIZEOF,
+    'throw' => :THROW,
+
+    # specifier
+    # types
+    'void'    => :VOID,
+    'char'    => :CHAR,
+    'short'   => :SHORT,
+
+    'volatile'=> :VOLATILE,
+    'const'   => :CONST,
+    'extern'   => :EXTERN,
+
+    'long'    => :LONG,
+    'float'   => :FLOAT,
+    'double'  => :DOUBLE,
+    'signed'  => :SIGNED,
+    'unsigned'=> :UNSIGNED,
+
+    'int'     => :INT,
+    'enum'    => :ENUM,
+
+    'if'      => :IF,
+    'else'    => :ELSE,
+    'while'   => :WHILE,
+    'do'      => :DO,
+    'for'     => :FOR,
+    'case'    => :CASE,
+    'default' => :DEFAULT,
+    'goto'    => :GOTO,
+    'continue' => :CONTINUE,
+    'break'   => :BREAK,
+    'return'  => :RETURN,
+    '__inline__'  => :__INLINE__,
+    'inline'  => :INLINE,
+    '__inline'  => :__INLINE,
+    'Inline'  => :CINLINE,        # inline starting with Capital letter
+    'static'  => :STATIC,
+    'register' => :REGISTER,
+    'auto'    => :AUTO,
+    '__extension__'    => :EXTENSION,
+
+  }
+
+  @@generator_nest = -1
+  @@generator_stack = []
+  @@current_locale = []
+
+  def finalize
+
+    # mikan Namespace.pop
+    Celltype.pop
+    Cell.pop
+    CompositeCelltype.pop
+    Region.pop
+
+  end
+
+  def set_plugin( plugin )
+    @plugin = plugin
+  end
+
+  def self.get_plugin
+    @@generator_stack[@@generator_nest].get_plugin
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def parse(files)
+
+    # mikan Namespace.push
+    Celltype.push
+    Cell.push
+    CompositeCelltype.push
+    Region.push
+
+    @@generator_nest += 1
+    @@generator_stack[@@generator_nest] = self
+    @b_no_type_name = false
+
+   begin
+
+    @q = []
+    comment = false
+
+    # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµãããèª¤ãåé¡ã®å¯¾ç­
+    TECS_LANG::set_kcode_binary
+
+    # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å
+±éã®ä¿®é£¾å­)
+    integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
+
+    files.each {|file|
+      lineno = 1
+     begin
+#2.0       IO.foreach(file) {|line|
+       TECSIO.foreach(file) {|line|
+        col = 1
+        line.rstrip!
+
+        until line.empty?
+
+          if comment
+            case line
+            # ã³ã¡ã³ãçµäº
+            when /\A\*\//
+              comment = false
+            when /\A./
+              ;
+            end
+          else
+            case line
+            # ç©ºç½ãããªãã­ã»ã¹ãã£ã¬ã¯ãã£ã
+            when /\A\s+/
+              ;
+            # è­å¥å­
+            when /\A[a-zA-Z_]\w*/
+              word = $&
+              @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
+            # 16 é²æ°å®æ°
+            when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
+              @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
+            # 8 é²æ°å®æ°
+            when /\A0[0-7]+#{integer_qualifier}/
+              @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
+            # æµ®åå°æ°å®æ°
+            when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
+              @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
+            # æ´æ°å®æ°
+            when /\A\d+#{integer_qualifier}/
+            # when /\A\d+/
+              @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
+            # æå­
+            when /\A'(?:[^'\\]|\\.)'/
+              @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
+            # æå­å
+#              "#include  #include #include \"../systask/logtask.cfg\"       æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã
+#            when /\A"(?:[^"\\]+|\\.)*"/
+            when /\A"(?:[^"\\]|\\.)*"/   # ããã¯ãã¾ãè¡ãããã 
+              @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
+            # è¡ã³ã¡ã³ã
+            when /\A\/\/.*$/
+              # èª­ã¿é£ã°ãã ã
+            # ã³ã¡ã³ãéå§
+            when /\A\/\*/
+              comment = true
+            when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A./
+              @q << [$&, Token.new($&, file, lineno, col)]
+            else
+              raise
+            end
+          end
+
+          line = $'
+          col += $&.length
+        end
+
+        lineno += 1
+      }
+
+     rescue => evar
+       Generator.error( "B1002 while open or reading \'$1\'" , file )
+       print_exception( evar )
+     end
+    }
+
+    # çµäºã®å°
+    @q << nil
+
+    @yydebug = true
+    do_parse
+
+   ensure
+    @@generator_nest -= 1
+    TECS_LANG::reset_kcode
+   end
+
+  end
+
+
+  def next_token
+    token = @q.shift
+
+    if token then
+      @@current_locale[@@generator_nest] = token[1].locale
+
+      case token[1].val
+      when ";", ":", ",", "(", ")", "{", "}"
+        set_no_type_name false
+      when ".", "->"
+        set_no_type_name true
+      end
+
+      # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã
+      if @b_no_type_name == false
+        if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
+          token[0] = :TYPE_NAME
+        end
+      end
+
+      if $debug then     # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç) 
+        locale = @@current_locale[@@generator_nest]
+        if token then
+          print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
+        else
+          print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
+        end
+      end
+    end
+
+    token
+  end
+
+  def on_error(t, v, vstack)
+    if v == "$" then
+     Generator.error( "B1003 Unexpected EOF"  )
+    else
+     Generator.error( "B1004 syntax error near \'$1\'" , v.val )
+    end
+
+  end
+
+  def self.current_locale
+    @@current_locale[ @@generator_nest ]
+  end
+
+  @@n_error = 0
+  @@n_warning = 0
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼
+  def self.error( msg )
+    @@n_error += 1
+    locale = @@current_locale[ @@generator_nest ]
+
+    if locale then
+      Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
+    else
+      Console.puts "error: #{msg}"
+    end
+  end
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼
+  def self.warning( msg )
+    @@n_warning += 1
+    locale = @@current_locale[ @@generator_nest ]
+    Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
+  end
+
+  def self.get_n_error
+    @@n_error
+  end
+
+  def self.get_n_warning
+    @@n_warning
+  end
+
+  def self.get_nest
+    @@generator_nest
+  end
+
+  def set_no_type_name b_no_type_name
+    # print "b_no_type_name=#{b_no_type_name}\n"
+    @b_no_type_name = b_no_type_name
+  end
+
+...end C_parser.y.rb/module_eval...
+##### State transition tables begin ###
+
+clist = [
+'104,105,106,107,108,110,68,111,66,179,300,141,53,116,117,206,115,118',
+'119,120,121,122,123,104,105,106,107,108,110,168,111,203,204,207,141',
+'74,116,117,168,115,118,119,120,121,122,123,303,208,67,299,65,26,27,104',
+'105,106,107,108,110,73,111,26,27,75,141,348,116,117,167,115,118,119',
+'120,121,122,123,77,265,195,196,160,304,305,306,307,308,309,310,311,312',
+'313,262,351,142,8,9,10,11,15,16,17,18,19,20,21,22,53,192,23,25,26,27',
+'193,194,343,261,142,104,105,106,107,108,110,344,111,172,340,151,141',
+'272,116,117,251,115,118,119,120,121,122,123,104,105,106,107,108,110',
+'142,111,355,171,339,141,81,116,117,80,115,118,119,120,121,122,123,104',
+'105,106,107,108,110,52,111,195,196,3,141,51,116,117,359,115,118,119',
+'120,121,122,123,104,105,106,107,108,110,373,111,96,335,361,141,334,116',
+'117,344,115,118,119,120,121,122,123,79,142,247,335,272,251,334,251,51',
+'104,105,106,107,108,110,81,111,53,80,362,234,363,116,117,142,115,118',
+'119,120,121,122,123,247,52,364,251,197,198,51,51,197,198,79,197,198',
+'53,53,142,228,365,8,9,10,11,15,16,17,18,19,20,21,22,77,192,23,25,26',
+'27,193,194,142,229,95,230,231,232,233,87,235,236,238,239,240,241,192',
+'199,200,201,202,193,194,197,198,370,37,38,39,40,41,42,43,44,142,104',
+'105,106,107,108,110,86,111,203,204,85,141,375,116,117,376,115,118,119',
+'120,121,122,123,104,105,106,107,108,110,377,111,195,196,378,141,379',
+'116,117,380,115,118,119,120,121,122,123,104,105,106,107,108,110,382',
+'111,383,35,384,141,63,116,117,60,115,118,119,120,121,122,123,104,105',
+'106,107,108,110,389,111,209,210,390,141,391,116,117,392,115,118,119',
+'120,121,122,123,59,142,394,34,396,8,9,10,11,15,16,17,18,19,20,21,22',
+'52,278,23,25,26,27,51,142,36,52,52,52,35,53,52,51,51,51,197,198,51,45',
+'53,53,53,277,275,53,269,268,142,267,37,38,39,40,41,42,43,44,181,95,182',
+'254,183,184,185,199,200,201,202,253,34,142,8,9,10,11,15,16,17,18,19',
+'20,21,22,245,244,23,25,26,27,243,30,36,104,105,106,107,108,110,214,111',
+'213,208,207,141,206,116,117,205,115,118,119,120,121,122,123,37,38,39',
+'40,41,42,43,44,301,104,105,106,107,108,110,314,111,315,317,318,234,319',
+'116,117,321,115,118,119,120,121,122,123,52,52,52,322,52,323,51,51,51',
+'324,51,327,174,53,53,53,228,53,8,9,10,11,15,16,17,18,19,20,21,22,77',
+'173,23,25,26,27,75,95,142,229,169,230,231,232,233,161,235,236,238,239',
+'240,241,199,200,201,202,346,347,205,,,,37,38,39,40,41,42,43,44,142,104',
+'105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123',
+',,104,105,106,107,108,110,,111,,,,234,,116,117,,115,118,119,120,121',
+'122,123,,,,,,,,,,,,,,,,,228,,8,9,10,11,15,16,17,18,19,20,21,22,77,,23',
+'25,26,27,,,,229,,230,231,232,233,142,235,236,238,239,240,241,,,,,,,',
+',,,37,38,39,40,41,42,43,44,142,104,105,106,107,108,110,,111,,,,234,',
+'116,117,,115,118,119,120,121,122,123,,,,,,,,,,,,,,,,,228,,8,9,10,11',
+'15,16,17,18,19,20,21,22,77,,23,25,26,27,,,,229,,230,231,232,233,,235',
+'236,238,239,240,241,,,,,,,,,,,37,38,39,40,41,42,43,44,142,104,105,106',
+'107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123,104,105',
+'106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123,104',
+'105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123',
+'104,105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122',
+'123,,142,,,,,,,,104,105,106,107,108,110,,111,,,,141,,116,117,142,115',
+'118,119,120,121,122,123,104,105,106,107,108,110,,111,,366,,141,,116',
+'117,142,115,118,119,120,121,122,123,,,,,,,,104,105,106,107,108,110,',
+'111,142,,,234,,116,117,,115,118,119,120,121,122,123,,,,,,,,,,,,,,,,',
+'228,142,8,9,10,11,15,16,17,18,19,20,21,22,77,,23,25,26,27,,,,229,142',
+'230,231,232,233,,235,236,238,239,240,241,,,,,,,,,,,37,38,39,40,41,42',
+'43,44,142,104,105,106,107,108,110,,111,,,,234,,116,117,,115,118,119',
+'120,121,122,123,,,,,,,,,,,,,,,,,228,,8,9,10,11,15,16,17,18,19,20,21',
+'22,77,,23,25,26,27,,,,229,,230,231,232,233,,235,236,238,239,240,241',
+',,,,,,,,,,37,38,39,40,41,42,43,44,142,104,105,106,107,108,110,,111,',
+',,234,,116,117,,115,118,119,120,121,122,123,,,,,,,,,,,,,,,,,228,,8,9',
+'10,11,15,16,17,18,19,20,21,22,77,,23,25,26,27,,,,229,,230,231,232,233',
+',235,236,238,239,240,241,,,,,,,,,,,37,38,39,40,41,42,43,44,142,104,105',
+'106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123,104',
+'105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123',
+'104,105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122',
+'123,104,105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121',
+'122,123,,142,,,,,,139,,,,,,140,104,105,106,107,108,110,,111,,145,142',
+'141,,116,117,,115,118,119,120,121,122,123,104,105,106,107,108,110,,111',
+',,142,141,,116,117,,115,118,119,120,121,122,123,104,105,106,107,108',
+'110,,111,,,142,141,,116,117,,115,118,119,120,121,122,123,104,105,106',
+'107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123,,142,',
+',,,,,,104,105,106,107,108,110,,111,,,,141,,116,117,142,115,118,119,120',
+'121,122,123,104,105,106,107,108,110,,111,,,,141,,116,117,142,115,118',
+'119,120,121,122,123,104,105,106,107,108,110,,111,,,,141,,116,117,142',
+'115,118,119,120,121,122,123,104,105,106,107,108,110,,111,,,,141,,116',
+'117,,115,118,119,120,121,122,123,,142,,,,,,139,349,,,,,140,104,105,106',
+'107,108,110,,111,,,142,141,,116,117,,115,118,119,120,121,122,123,104',
+'105,106,107,108,110,,111,,,142,141,,116,117,,115,118,119,120,121,122',
+'123,104,105,106,107,108,110,,111,,,142,141,,116,117,,115,118,119,120',
+'121,122,123,104,105,106,107,108,110,,111,,,,141,,116,117,,115,118,119',
+'120,121,122,123,,142,,,,,,,,104,105,106,107,108,110,,111,,,,141,,116',
+'117,142,115,118,119,120,121,122,123,104,105,106,107,108,110,,111,,,',
+'141,,116,117,142,115,118,119,120,121,122,123,104,105,106,107,108,110',
+',111,,,,141,,116,117,142,115,118,119,120,121,122,123,,,,,,,,,,104,105',
+'106,107,108,110,,111,,,,234,,116,117,142,115,118,119,120,121,122,123',
+',,,,,,,,,,,,,,,142,228,,8,9,10,11,15,16,17,18,19,20,21,22,77,237,23',
+'25,26,27,,,142,229,,230,231,232,233,,235,236,238,239,240,241,,,,,,,',
+',,,37,38,39,40,41,42,43,44,142,104,105,106,107,108,110,,111,,336,,141',
+',116,117,,115,118,119,120,121,122,123,104,105,106,107,108,110,,111,',
+',,141,,116,117,,115,118,119,120,121,122,123,8,9,10,11,15,16,17,18,19',
+'20,21,22,,,23,25,26,27,8,9,10,11,15,16,17,18,19,20,21,22,,,23,25,26',
+'27,,104,105,106,107,108,110,,111,,,142,141,,116,117,,115,118,119,120',
+'121,122,123,104,105,106,107,108,110,,111,,,142,141,,116,117,,115,118',
+'119,120,121,122,123,104,105,106,107,108,110,,111,,,,141,,116,117,,115',
+'118,119,120,121,122,123,104,105,106,107,108,187,,111,,,,141,,116,117',
+',115,118,119,120,121,122,123,,142,,,,,,,,104,105,106,107,108,189,,111',
+',,,141,,116,117,142,115,118,119,120,121,122,123,104,105,106,107,108',
+'189,,111,,,,141,,116,117,142,115,118,119,120,121,122,123,104,105,106',
+'107,108,110,,111,,,,141,,116,117,142,115,118,119,120,121,122,123,104',
+'105,106,107,108,110,,111,,,,141,,116,117,,115,118,119,120,121,122,123',
+',142,,,,,,139,,,,,,140,272,332,326,251,104,105,106,107,108,110,142,111',
+',53,,141,,116,117,,115,118,119,120,121,122,123,,,,,,,142,,,8,9,10,11',
+'15,16,17,18,19,20,21,22,,,23,25,26,27,,,142,104,105,106,107,108,110',
+',111,,,,234,,116,117,,115,118,119,120,121,122,123,37,38,39,40,41,42',
+'43,44,,,,,,,,,228,142,8,9,10,11,15,16,17,18,19,20,21,22,77,,23,25,26',
+'27,,,,229,,230,231,232,233,,235,236,238,239,240,241,368,,,,,,,,,,37',
+'38,39,40,41,42,43,44,142,247,332,,251,,,51,,,,,,,53,,,8,9,10,11,15,16',
+'17,18,19,20,21,22,,,23,25,26,27,,,8,9,10,11,15,16,17,18,19,20,21,22',
+',,23,25,26,27,147,,,,,,37,38,39,40,41,42,43,44,,,,,,,,,328,,,,37,38',
+'39,40,41,42,43,44,,8,9,10,11,15,16,17,18,19,20,21,22,,,23,25,26,27,8',
+'9,10,11,15,16,17,18,19,20,21,22,,,23,25,26,27,,,,,,,,,37,38,39,40,41',
+'42,43,44,,,,,,,,,,,37,38,39,40,41,42,43,44,8,9,10,11,15,16,17,18,19',
+'20,21,22,,,23,25,26,27,8,9,10,11,15,16,17,18,19,20,21,22,,338,23,25',
+'26,27,,,,,,,,,37,38,39,40,41,42,43,44,,,,,,,,,,,37,38,39,40,41,42,43',
+'44,8,9,10,11,15,16,17,18,19,20,21,22,,162,23,25,26,27,8,9,10,11,15,16',
+'17,18,19,20,21,22,,,23,25,26,27,,,,,,,,,37,38,39,40,41,42,43,44,,,,',
+',,,,,,37,38,39,40,41,42,43,44,8,9,10,11,15,16,17,18,19,20,21,22,,,23',
+'25,26,27,8,9,10,11,15,16,17,18,19,20,21,22,,,23,25,26,27,,,,,,,,,37',
+'38,39,40,41,42,43,44,,,,,,,,,,,37,38,39,40,41,42,43,44,8,9,10,11,15',
+'16,17,18,19,20,21,22,,255,23,25,26,27,8,9,10,11,15,16,17,18,19,20,21',
+'22,,,23,25,26,27,,,,,,,,,37,38,39,40,41,42,43,44,,,,,,,,,,,37,38,39',
+'40,41,42,43,44,8,9,10,11,15,16,17,18,19,20,21,22,,260,23,25,26,27,8',
+'9,10,11,15,16,17,18,19,20,21,22,,,23,25,26,27,,,,,,,,,37,38,39,40,41',
+'42,43,44,,,,,,,,,,,37,38,39,40,41,42,43,44,8,9,10,11,15,16,17,18,19',
+'20,21,22,,,23,25,26,27,8,9,10,11,15,16,17,18,19,20,21,22,,,23,25,26',
+'27,,,,,,,,,37,38,39,40,41,42,43,44,8,9,10,11,15,16,17,18,19,20,21,22',
+',,23,25,26,27' ]
+        racc_action_table = arr = ::Array.new(2877, nil)
+        idx = 0
+        clist.each do |str|
+          str.split(',', -1).each do |i|
+            arr[idx] = i.to_i unless i.empty?
+            idx += 1
+          end
+        end
+
+clist = [
+'208,208,208,208,208,208,24,208,23,112,211,208,53,208,208,295,208,208',
+'208,208,208,208,208,209,209,209,209,209,209,93,209,130,130,296,209,46',
+'209,209,170,209,209,209,209,209,209,209,215,297,24,211,23,53,53,187',
+'187,187,187,187,187,46,187,112,112,48,187,298,187,187,93,187,187,187',
+'187,187,187,187,48,170,285,285,88,215,215,215,215,215,215,215,215,215',
+'215,164,301,208,187,187,187,187,187,187,187,187,187,187,187,187,83,283',
+'187,187,187,187,283,283,273,164,209,392,392,392,392,392,392,273,392',
+'99,257,82,392,271,392,392,271,392,392,392,392,392,392,392,179,179,179',
+'179,179,179,187,179,316,99,257,179,50,179,179,50,179,179,179,179,179',
+'179,179,192,192,192,192,192,192,49,192,286,286,1,192,49,192,192,320',
+'192,192,192,192,192,192,192,193,193,193,193,193,193,345,193,68,250,322',
+'193,250,193,193,345,193,193,193,193,193,193,193,49,392,246,330,178,246',
+'330,178,246,390,390,390,390,390,390,78,390,178,78,325,390,328,390,390',
+'179,390,390,390,390,390,390,390,150,158,331,150,287,287,150,158,288',
+'288,246,289,289,150,158,192,390,333,390,390,390,390,390,390,390,390',
+'390,390,390,390,390,284,390,390,390,390,284,284,193,390,67,390,390,390',
+'390,64,390,390,390,390,390,390,126,129,129,129,129,126,126,290,290,337',
+'390,390,390,390,390,390,390,390,390,379,379,379,379,379,379,62,379,293',
+'293,61,379,352,379,379,353,379,379,379,379,379,379,379,378,378,378,378',
+'378,378,354,378,127,127,355,378,356,378,378,357,378,378,378,378,378',
+'378,378,194,194,194,194,194,194,363,194,367,30,369,194,22,194,194,14',
+'194,194,194,194,194,194,194,195,195,195,195,195,195,380,195,135,135',
+'385,195,387,195,195,388,195,195,195,195,195,195,195,12,379,391,30,395',
+'30,30,30,30,30,30,30,30,30,30,30,30,92,183,30,30,30,30,92,378,30,262',
+'74,4,2,92,72,262,74,4,128,128,72,3,262,74,4,182,180,72,176,175,194,173',
+'30,30,30,30,30,30,30,30,113,168,113,155,113,113,113,291,291,291,291',
+'154,2,195,2,2,2,2,2,2,2,2,2,2,2,2,148,146,2,2,2,2,144,2,2,196,196,196',
+'196,196,196,142,196,140,134,133,196,132,196,196,131,196,196,196,196',
+'196,196,196,2,2,2,2,2,2,2,2,213,377,377,377,377,377,377,229,377,230',
+'232,233,377,234,377,377,236,377,377,377,377,377,377,377,340,216,172',
+'238,52,239,340,216,172,240,52,242,109,340,216,172,377,52,377,377,377',
+'377,377,377,377,377,377,377,377,377,377,103,377,377,377,377,102,96,196',
+'377,95,377,377,377,377,89,377,377,377,377,377,377,292,292,292,292,276',
+'279,294,,,,377,377,377,377,377,377,377,377,377,169,169,169,169,169,169',
+',169,,,,169,,169,169,,169,169,169,169,169,169,169,,,376,376,376,376',
+'376,376,,376,,,,376,,376,376,,376,376,376,376,376,376,376,,,,,,,,,,',
+',,,,,,376,,376,376,376,376,376,376,376,376,376,376,376,376,376,,376',
+'376,376,376,,,,376,,376,376,376,376,169,376,376,376,376,376,376,,,,',
+',,,,,,376,376,376,376,376,376,376,376,376,359,359,359,359,359,359,,359',
+',,,359,,359,359,,359,359,359,359,359,359,359,,,,,,,,,,,,,,,,,359,,359',
+'359,359,359,359,359,359,359,359,359,359,359,359,,359,359,359,359,,,',
+'359,,359,359,359,359,,359,359,359,359,359,359,,,,,,,,,,,359,359,359',
+'359,359,359,359,359,359,197,197,197,197,197,197,,197,,,,197,,197,197',
+',197,197,197,197,197,197,197,348,348,348,348,348,348,,348,,,,348,,348',
+'348,,348,348,348,348,348,348,348,344,344,344,344,344,344,,344,,,,344',
+',344,344,,344,344,344,344,344,344,344,189,189,189,189,189,189,,189,',
+',,189,,189,189,,189,189,189,189,189,189,189,,197,,,,,,,,198,198,198',
+'198,198,198,,198,,,,198,,198,198,348,198,198,198,198,198,198,198,334',
+'334,334,334,334,334,,334,,334,,334,,334,334,344,334,334,334,334,334',
+'334,334,,,,,,,,321,321,321,321,321,321,,321,189,,,321,,321,321,,321',
+'321,321,321,321,321,321,,,,,,,,,,,,,,,,,321,198,321,321,321,321,321',
+'321,321,321,321,321,321,321,321,,321,321,321,321,,,,321,334,321,321',
+'321,321,,321,321,321,321,321,321,,,,,,,,,,,321,321,321,321,321,321,321',
+'321,321,319,319,319,319,319,319,,319,,,,319,,319,319,,319,319,319,319',
+'319,319,319,,,,,,,,,,,,,,,,,319,,319,319,319,319,319,319,319,319,319',
+'319,319,319,319,,319,319,319,319,,,,319,,319,319,319,319,,319,319,319',
+'319,319,319,,,,,,,,,,,319,319,319,319,319,319,319,319,319,396,396,396',
+'396,396,396,,396,,,,396,,396,396,,396,396,396,396,396,396,396,,,,,,',
+',,,,,,,,,,396,,396,396,396,396,396,396,396,396,396,396,396,396,396,',
+'396,396,396,396,,,,396,,396,396,396,396,,396,396,396,396,396,396,,,',
+',,,,,,,396,396,396,396,396,396,396,396,396,318,318,318,318,318,318,',
+'318,,,,318,,318,318,,318,318,318,318,318,318,318,317,317,317,317,317',
+'317,,317,,,,317,,317,317,,317,317,317,317,317,317,317,75,75,75,75,75',
+'75,,75,,,,75,,75,75,,75,75,75,75,75,75,75,315,315,315,315,315,315,,315',
+',,,315,,315,315,,315,315,315,315,315,315,315,,318,,,,,,75,,,,,,75,80',
+'80,80,80,80,80,,80,,80,317,80,,80,80,,80,80,80,80,80,80,80,181,181,181',
+'181,181,181,,181,,,75,181,,181,181,,181,181,181,181,181,181,181,314',
+'314,314,314,314,314,,314,,,315,314,,314,314,,314,314,314,314,314,314',
+'314,302,302,302,302,302,302,,302,,,,302,,302,302,,302,302,302,302,302',
+'302,302,,80,,,,,,,,199,199,199,199,199,199,,199,,,,199,,199,199,181',
+'199,199,199,199,199,199,199,200,200,200,200,200,200,,200,,,,200,,200',
+'200,314,200,200,200,200,200,200,200,300,300,300,300,300,300,,300,,,',
+'300,,300,300,302,300,300,300,300,300,300,300,275,275,275,275,275,275',
+',275,,,,275,,275,275,,275,275,275,275,275,275,275,,199,,,,,,300,300',
+',,,,300,201,201,201,201,201,201,,201,,,200,201,,201,201,,201,201,201',
+'201,201,201,201,207,207,207,207,207,207,,207,,,300,207,,207,207,,207',
+'207,207,207,207,207,207,210,210,210,210,210,210,,210,,,275,210,,210',
+'210,,210,210,210,210,210,210,210,202,202,202,202,202,202,,202,,,,202',
+',202,202,,202,202,202,202,202,202,202,,201,,,,,,,,269,269,269,269,269',
+'269,,269,,,,269,,269,269,207,269,269,269,269,269,269,269,203,203,203',
+'203,203,203,,203,,,,203,,203,203,210,203,203,203,203,203,203,203,204',
+'204,204,204,204,204,,204,,,,204,,204,204,202,204,204,204,204,204,204',
+'204,,,,,,,,,,143,143,143,143,143,143,,143,,,,143,,143,143,269,143,143',
+'143,143,143,143,143,,,,,,,,,,,,,,,,203,143,,143,143,143,143,143,143',
+'143,143,143,143,143,143,143,143,143,143,143,143,,,204,143,,143,143,143',
+'143,,143,143,143,143,143,143,,,,,,,,,,,143,143,143,143,143,143,143,143',
+'143,251,251,251,251,251,251,,251,,251,,251,,251,251,,251,251,251,251',
+'251,251,251,110,110,110,110,110,110,,110,,,,110,,110,110,,110,110,110',
+'110,110,110,110,70,70,70,70,70,70,70,70,70,70,70,70,,,70,70,70,70,110',
+'110,110,110,110,110,110,110,110,110,110,110,,,110,110,110,110,,205,205',
+'205,205,205,205,,205,,,251,205,,205,205,,205,205,205,205,205,205,205',
+'206,206,206,206,206,206,,206,,,110,206,,206,206,,206,206,206,206,206',
+'206,206,114,114,114,114,114,114,,114,,,,114,,114,114,,114,114,114,114',
+'114,114,114,115,115,115,115,115,115,,115,,,,115,,115,115,,115,115,115',
+'115,115,115,115,,205,,,,,,,,116,116,116,116,116,116,,116,,,,116,,116',
+'116,206,116,116,116,116,116,116,116,117,117,117,117,117,117,,117,,,',
+'117,,117,117,114,117,117,117,117,117,117,117,139,139,139,139,139,139',
+',139,,,,139,,139,139,115,139,139,139,139,139,139,139,241,241,241,241',
+'241,241,,241,,,,241,,241,241,,241,241,241,241,241,241,241,,116,,,,,',
+'139,,,,,,139,272,272,241,272,235,235,235,235,235,235,117,235,,272,,235',
+',235,235,,235,235,235,235,235,235,235,,,,,,,139,,,272,272,272,272,272',
+'272,272,272,272,272,272,272,,,272,272,272,272,,,241,231,231,231,231',
+'231,231,,231,,,,231,,231,231,,231,231,231,231,231,231,231,272,272,272',
+'272,272,272,272,272,,,,,,,,,231,235,231,231,231,231,231,231,231,231',
+'231,231,231,231,231,,231,231,231,231,,,,231,,231,231,231,231,,231,231',
+'231,231,231,231,335,,,,,,,,,,231,231,231,231,231,231,231,231,231,247',
+'247,,247,,,247,,,,,,,247,,,335,335,335,335,335,335,335,335,335,335,335',
+'335,,,335,335,335,335,,,247,247,247,247,247,247,247,247,247,247,247',
+'247,,,247,247,247,247,81,,,,,,335,335,335,335,335,335,335,335,,,,,,',
+',,245,,,,247,247,247,247,247,247,247,247,,81,81,81,81,81,81,81,81,81',
+'81,81,81,,,81,81,81,81,245,245,245,245,245,245,245,245,245,245,245,245',
+',,245,245,245,245,,,,,,,,,81,81,81,81,81,81,81,81,,,,,,,,,,,245,245',
+'245,245,245,245,245,245,5,5,5,5,5,5,5,5,5,5,5,5,,,5,5,5,5,252,252,252',
+'252,252,252,252,252,252,252,252,252,,252,252,252,252,252,,,,,,,,,5,5',
+'5,5,5,5,5,5,,,,,,,,,,,252,252,252,252,252,252,252,252,90,90,90,90,90',
+'90,90,90,90,90,90,90,,90,90,90,90,90,153,153,153,153,153,153,153,153',
+'153,153,153,153,,,153,153,153,153,,,,,,,,,90,90,90,90,90,90,90,90,,',
+',,,,,,,,153,153,153,153,153,153,153,153,87,87,87,87,87,87,87,87,87,87',
+'87,87,,,87,87,87,87,86,86,86,86,86,86,86,86,86,86,86,86,,,86,86,86,86',
+',,,,,,,,87,87,87,87,87,87,87,87,,,,,,,,,,,86,86,86,86,86,86,86,86,156',
+'156,156,156,156,156,156,156,156,156,156,156,,156,156,156,156,156,65',
+'65,65,65,65,65,65,65,65,65,65,65,,,65,65,65,65,,,,,,,,,156,156,156,156',
+'156,156,156,156,,,,,,,,,,,65,65,65,65,65,65,65,65,159,159,159,159,159',
+'159,159,159,159,159,159,159,,159,159,159,159,159,7,7,7,7,7,7,7,7,7,7',
+'7,7,,,7,7,7,7,,,,,,,,,159,159,159,159,159,159,159,159,,,,,,,,,,,7,7',
+'7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,,,6,6,6,6,36,36,36,36,36,36,36,36',
+'36,36,36,36,,,36,36,36,36,,,,,,,,,6,6,6,6,6,6,6,6,71,71,71,71,71,71',
+'71,71,71,71,71,71,,,71,71,71,71' ]
+        racc_action_check = arr = ::Array.new(2877, nil)
+        idx = 0
+        clist.each do |str|
+          str.split(',', -1).each do |i|
+            arr[idx] = i.to_i unless i.empty?
+            idx += 1
+          end
+        end
+
+racc_action_pointer = [
+   nil,   173,   432,   442,   425,  2414,  2764,  2712,   nil,   nil,
+   nil,   nil,   363,   nil,   332,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   357,    -5,    -7,   nil,   nil,   nil,   nil,   nil,
+   366,   nil,   nil,   nil,   nil,   nil,  2782,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,    18,   nil,    21,   162,
+   145,   nil,   548,    -8,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   267,   263,   nil,   231,  2642,   nil,   268,   139,   nil,
+  1860,  2816,   428,   nil,   424,  1315,   nil,   nil,   217,   nil,
+  1375,  2344,   119,    86,   nil,   nil,  2572,  2554,    39,   555,
+  2484,   nil,   414,    12,   nil,   549,   575,   nil,   nil,   108,
+   nil,   nil,   545,   487,   nil,   nil,   nil,   nil,   nil,   554,
+  1878,   nil,     2,   451,  1984,  2007,  2039,  2062,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   273,   322,   412,   265,
+    -2,   492,   473,   470,   468,   351,   nil,   nil,   nil,  2085,
+   497,   nil,   489,  1761,   482,   nil,   480,   nil,   470,   nil,
+   234,   nil,   nil,  2502,   431,   423,  2624,   nil,   235,  2694,
+   nil,   nil,   nil,   nil,    74,   nil,   nil,   nil,   449,   620,
+    21,   nil,   546,   439,   nil,   442,   441,   nil,   206,   138,
+   440,  1398,   433,   409,   nil,   nil,   nil,    51,   nil,   902,
+   nil,   nil,   161,   184,   356,   379,   494,   833,   934,  1476,
+  1499,  1582,  1651,  1706,  1729,  1938,  1961,  1605,    -2,    21,
+  1628,    -7,   nil,   518,   nil,     4,   545,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   527,
+   529,  2202,   530,   531,   500,  2149,   503,   nil,   541,   515,
+   519,  2108,   521,   nil,   nil,  2362,   204,  2291,   nil,   nil,
+   188,  1855,  2432,   nil,   nil,   nil,   nil,   109,   nil,   nil,
+   nil,   nil,   423,   nil,   nil,   nil,   nil,   nil,   nil,  1683,
+   nil,   122,  2140,   106,   nil,  1545,   596,   nil,   nil,   600,
+   nil,   nil,   nil,    87,   252,    57,   150,   218,   222,   225,
+   273,   439,   574,   287,   590,   -20,    -3,    10,    25,   nil,
+  1522,    84,  1444,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,  1421,  1338,    82,  1292,  1269,  1081,
+   138,   987,   155,   nil,   nil,   187,   nil,   nil,   218,   nil,
+   205,   235,   nil,   250,   957,  2271,   nil,   291,   nil,   nil,
+   544,   nil,   nil,   nil,   879,   184,   nil,   nil,   856,   nil,
+   nil,   nil,   283,   319,   333,   338,   306,   342,   nil,   739,
+   nil,   nil,   nil,   352,   nil,   nil,   nil,   355,   nil,   360,
+   nil,   nil,   nil,   nil,   nil,   nil,   645,   526,   333,   310,
+   317,   nil,   nil,   nil,   nil,   326,   nil,   385,   355,   nil,
+   216,   365,   115,   nil,   nil,   400,  1175,   nil ]
+
+racc_action_default = [
+  -174,  -241,    -1,  -241,  -241,   -70,   -71,   -72,   -80,   -81,
+   -82,   -83,   -84,   -85,   -86,   -87,   -88,   -89,   -90,   -91,
+   -92,   -93,   -96,  -241,  -241,  -127,  -132,  -133,  -175,  -176,
+  -241,  -178,  -179,  -182,  -183,  -184,  -241,  -230,  -231,  -232,
+  -233,  -234,  -235,  -236,  -237,   398,  -241,   -76,   -78,  -241,
+  -135,  -137,  -241,  -143,   -73,   -84,   -86,   -74,   -75,  -181,
+  -180,   -98,  -241,  -101,  -114,  -241,  -117,  -241,  -126,  -177,
+  -105,  -107,  -241,   -69,  -241,  -241,  -188,  -189,  -134,  -136,
+  -241,  -241,  -241,  -144,  -145,   -94,  -241,  -241,   -84,   -85,
+  -241,  -115,  -241,  -241,  -128,  -130,  -241,  -106,  -108,  -241,
+  -186,   -77,   -78,    -2,    -3,    -4,    -5,    -6,    -7,    -8,
+  -241,   -10,   -12,   -23,  -241,  -241,  -241,  -241,   -29,   -30,
+   -31,   -32,   -33,   -34,   -35,   -37,   -41,   -44,   -47,   -52,
+   -55,   -57,   -59,   -61,   -63,   -65,   -68,   -79,  -168,  -241,
+  -241,  -238,  -241,  -241,  -241,  -140,  -241,  -142,  -147,  -149,
+  -153,  -138,  -146,  -241,   -84,   -85,  -241,   -99,  -241,  -241,
+  -120,  -119,  -113,  -116,  -241,  -121,  -123,  -124,  -241,  -241,
+  -241,  -185,  -241,  -241,   -11,  -241,  -241,   -67,  -154,   -20,
+  -241,  -241,  -241,  -241,   -18,   -19,   -24,  -241,   -25,  -241,
+   -27,   -28,  -241,  -241,  -241,  -241,  -241,  -241,  -241,  -241,
+  -241,  -241,  -241,  -241,  -241,  -241,  -241,  -241,  -241,  -241,
+  -241,  -241,  -172,  -241,  -239,   -35,  -241,  -190,  -191,  -192,
+  -193,  -194,  -195,  -196,  -197,  -198,  -199,  -200,  -201,  -241,
+  -241,  -241,  -241,  -241,  -238,  -241,  -241,  -211,  -241,  -241,
+  -241,  -241,  -241,  -139,  -141,  -241,  -156,  -241,  -151,  -152,
+  -157,  -241,  -241,  -104,  -103,   -97,  -100,  -241,  -109,  -111,
+  -112,  -118,  -241,  -129,  -131,  -125,  -187,  -240,    -9,  -241,
+  -155,  -156,  -241,  -241,   -21,   -20,  -241,   -16,   -17,  -241,
+   -38,   -39,   -40,   -42,   -43,   -45,   -46,   -48,   -49,   -50,
+   -51,   -53,   -54,   -56,   -58,   -60,   -62,   -64,  -241,  -169,
+  -241,  -241,  -241,  -219,  -220,  -221,  -222,  -223,  -224,  -225,
+  -226,  -227,  -228,  -229,  -241,  -241,  -241,  -241,  -241,  -241,
+  -241,  -241,  -241,  -213,  -214,  -241,  -216,  -217,  -241,  -150,
+  -158,  -241,  -164,  -241,  -241,  -241,  -160,  -241,   -95,  -102,
+  -241,  -122,   -36,   -13,  -241,  -241,   -15,   -26,  -241,  -170,
+  -173,  -171,  -241,  -241,  -241,  -241,  -241,  -241,  -208,  -241,
+  -210,  -212,  -215,  -241,  -159,  -165,  -162,  -241,  -166,  -241,
+  -161,  -110,   -22,   -14,   -66,  -218,  -241,  -241,  -241,  -241,
+  -241,  -209,  -148,  -163,  -167,  -202,  -204,  -241,  -241,  -207,
+  -241,  -241,  -241,  -203,  -205,  -241,  -241,  -206 ]
+
+racc_goto_table = [
+    48,     4,   144,   146,    54,    57,    58,   217,    84,    12,
+   136,   137,    78,   175,   258,   136,   273,   165,   188,   190,
+   191,   186,    72,    89,   256,    93,   176,   163,    70,     4,
+    33,   156,   249,    29,   283,   284,   302,    12,   152,    14,
+   330,     2,    71,   293,   155,    89,   215,    90,    89,   287,
+   288,   289,   290,   294,   170,   295,    97,    98,    33,    83,
+   270,    69,    70,    70,    92,   330,   296,    14,   100,   159,
+   102,   297,    88,   101,   136,   212,    71,    71,   285,   286,
+   150,    61,   274,   153,   276,   158,    92,    62,   166,    92,
+   175,   264,   175,   154,    88,   316,   163,    88,   252,   280,
+   281,   282,    70,   279,   136,   246,   291,   292,   257,    64,
+   164,   155,   345,   298,   155,   263,    71,    89,   180,   329,
+   256,   211,    28,    99,    76,   143,     1,   nil,   nil,   nil,
+   nil,   nil,   nil,   271,   215,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   325,   nil,   248,   nil,   nil,   nil,
+   nil,   nil,   158,   nil,   259,   158,   nil,   320,    92,   nil,
+   154,   nil,   nil,   154,   nil,   nil,    88,   nil,   266,   nil,
+   136,   nil,   nil,   337,   nil,   nil,   342,   nil,   274,    70,
+   nil,   nil,   nil,   358,   nil,   360,   136,   341,   nil,   nil,
+   nil,   nil,   nil,    71,   nil,   nil,   371,   nil,   nil,   nil,
+   nil,   nil,   246,   nil,   nil,   352,   nil,   nil,   nil,    78,
+   155,   nil,   102,   nil,   nil,   nil,   nil,   353,   354,   nil,
+   356,   357,   215,   381,   215,   nil,   nil,   271,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   136,   350,   nil,   nil,   nil,
+   385,   386,   nil,   nil,   150,   nil,   150,   372,   nil,   nil,
+   nil,   158,   nil,   nil,   393,   nil,   367,   369,   166,   154,
+   397,   nil,   215,   nil,   nil,   nil,   nil,   nil,   nil,   136,
+   nil,   150,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   215,
+   215,   387,   388,   374,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   215,   nil,   395,   nil,   nil,   nil,   215,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   150,   nil,   259 ]
+
+racc_goto_check = [
+    32,    27,    25,    55,    27,    27,    27,    68,    53,    34,
+    24,    33,    54,     6,    44,    24,     8,    49,    10,    10,
+    10,    12,    43,    35,    41,    51,    13,    47,    30,    27,
+    26,    38,    58,    62,    14,    14,    77,    34,    53,    36,
+    59,     2,     9,    18,    35,    35,    10,    46,    35,    16,
+    16,    16,    16,    19,    51,    20,    43,    43,    26,     9,
+    58,    62,    30,    30,    27,    59,    21,    36,    32,    46,
+    32,    22,    34,    31,    24,    33,     9,     9,    15,    15,
+    27,    37,     6,    39,     6,    27,    27,    40,    32,    27,
+     6,    25,     6,    34,    34,    68,    47,    34,    38,    12,
+    12,    12,    30,    13,    24,    53,    17,    17,    42,    45,
+    48,    35,     8,     6,    35,    52,     9,    35,     9,    57,
+    41,    60,    61,    65,    66,    67,     1,   nil,   nil,   nil,
+   nil,   nil,   nil,    53,    10,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,     6,   nil,    32,   nil,   nil,   nil,
+   nil,   nil,    27,   nil,    32,    27,   nil,    25,    27,   nil,
+    34,   nil,   nil,    34,   nil,   nil,    34,   nil,    32,   nil,
+    24,   nil,   nil,    25,   nil,   nil,    12,   nil,     6,    30,
+   nil,   nil,   nil,    68,   nil,    68,    24,    49,   nil,   nil,
+   nil,   nil,   nil,     9,   nil,   nil,    44,   nil,   nil,   nil,
+   nil,   nil,    53,   nil,   nil,     6,   nil,   nil,   nil,    54,
+    35,   nil,    32,   nil,   nil,   nil,   nil,     6,     6,   nil,
+     6,     6,    10,    68,    10,   nil,   nil,    53,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,    24,    33,   nil,   nil,   nil,
+    68,    68,   nil,   nil,    27,   nil,    27,     6,   nil,   nil,
+   nil,    27,   nil,   nil,    68,   nil,    25,    55,    32,    34,
+    68,   nil,    10,   nil,   nil,   nil,   nil,   nil,   nil,    24,
+   nil,    27,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    10,
+    10,     6,     6,    24,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,    10,   nil,     6,   nil,   nil,   nil,    10,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,    27,   nil,    32 ]
+
+racc_goto_pointer = [
+   nil,   126,    41,   nil,   nil,   nil,   -97,   nil,  -163,     6,
+   -97,   nil,   -93,   -84,  -161,  -119,  -150,   -97,  -162,  -153,
+  -152,  -142,  -138,   nil,   -65,   -78,    28,    -1,   nil,   nil,
+    -8,    -1,    -4,   -64,     7,   -42,    37,    59,   -55,    -2,
+    65,  -132,   -50,   -14,  -144,    86,   -18,   -63,    18,   -75,
+   nil,   -42,   -53,   -45,   -37,   -78,   nil,  -126,  -118,  -206,
+   -18,   120,    31,   nil,   nil,    51,    76,    48,  -136,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,  -179 ]
+
+racc_goto_default = [
+   nil,   nil,   nil,   112,   103,   109,   242,   113,   nil,     7,
+   124,   114,   125,   nil,   126,   127,   128,   129,   130,   131,
+   132,   133,   134,   135,   177,   138,   218,   216,    46,     5,
+     6,    47,    82,   nil,    55,    13,    56,   nil,   nil,   nil,
+   nil,   157,   nil,   178,   nil,   nil,   nil,    91,   nil,   nil,
+    24,   nil,    94,    49,    50,   333,   148,   149,   331,   250,
+   nil,   nil,   nil,    31,    32,   nil,   225,   nil,   nil,   219,
+   220,   221,   222,   223,   224,   226,   227,   nil ]
+
+racc_reduce_table = [
+  0, 0, :racc_error,
+  1, 97, :_reduce_none,
+  1, 99, :_reduce_2,
+  1, 99, :_reduce_3,
+  1, 99, :_reduce_4,
+  1, 99, :_reduce_5,
+  1, 99, :_reduce_6,
+  1, 99, :_reduce_7,
+  1, 99, :_reduce_8,
+  3, 99, :_reduce_9,
+  1, 101, :_reduce_10,
+  2, 101, :_reduce_11,
+  1, 103, :_reduce_none,
+  4, 103, :_reduce_none,
+  5, 103, :_reduce_none,
+  4, 103, :_reduce_15,
+  3, 103, :_reduce_16,
+  3, 103, :_reduce_17,
+  2, 103, :_reduce_18,
+  2, 103, :_reduce_19,
+  0, 104, :_reduce_none,
+  1, 104, :_reduce_none,
+  3, 104, :_reduce_none,
+  1, 106, :_reduce_none,
+  2, 106, :_reduce_24,
+  2, 106, :_reduce_25,
+  4, 106, :_reduce_26,
+  2, 106, :_reduce_27,
+  2, 106, :_reduce_28,
+  1, 107, :_reduce_29,
+  1, 107, :_reduce_30,
+  1, 107, :_reduce_31,
+  1, 107, :_reduce_32,
+  1, 107, :_reduce_33,
+  1, 107, :_reduce_34,
+  1, 108, :_reduce_none,
+  4, 108, :_reduce_36,
+  1, 110, :_reduce_none,
+  3, 110, :_reduce_38,
+  3, 110, :_reduce_39,
+  3, 110, :_reduce_40,
+  1, 111, :_reduce_none,
+  3, 111, :_reduce_42,
+  3, 111, :_reduce_43,
+  1, 112, :_reduce_none,
+  3, 112, :_reduce_45,
+  3, 112, :_reduce_46,
+  1, 113, :_reduce_none,
+  3, 113, :_reduce_48,
+  3, 113, :_reduce_49,
+  3, 113, :_reduce_50,
+  3, 113, :_reduce_51,
+  1, 114, :_reduce_none,
+  3, 114, :_reduce_53,
+  3, 114, :_reduce_54,
+  1, 115, :_reduce_none,
+  3, 115, :_reduce_56,
+  1, 116, :_reduce_none,
+  3, 116, :_reduce_58,
+  1, 117, :_reduce_none,
+  3, 117, :_reduce_60,
+  1, 118, :_reduce_none,
+  3, 118, :_reduce_62,
+  1, 119, :_reduce_none,
+  3, 119, :_reduce_64,
+  1, 120, :_reduce_none,
+  5, 120, :_reduce_66,
+  1, 102, :_reduce_67,
+  1, 121, :_reduce_68,
+  3, 122, :_reduce_none,
+  1, 123, :_reduce_70,
+  1, 123, :_reduce_none,
+  1, 123, :_reduce_72,
+  2, 123, :_reduce_73,
+  2, 123, :_reduce_74,
+  2, 123, :_reduce_75,
+  1, 124, :_reduce_76,
+  3, 124, :_reduce_77,
+  1, 127, :_reduce_none,
+  3, 127, :_reduce_79,
+  1, 126, :_reduce_80,
+  1, 126, :_reduce_81,
+  1, 126, :_reduce_82,
+  1, 126, :_reduce_83,
+  1, 126, :_reduce_84,
+  1, 126, :_reduce_85,
+  1, 126, :_reduce_86,
+  1, 126, :_reduce_87,
+  1, 126, :_reduce_88,
+  1, 126, :_reduce_89,
+  1, 126, :_reduce_90,
+  1, 126, :_reduce_91,
+  1, 126, :_reduce_92,
+  1, 126, :_reduce_93,
+  0, 135, :_reduce_94,
+  6, 130, :_reduce_95,
+  0, 136, :_reduce_96,
+  5, 130, :_reduce_97,
+  2, 130, :_reduce_98,
+  1, 134, :_reduce_none,
+  2, 134, :_reduce_none,
+  1, 133, :_reduce_101,
+  3, 137, :_reduce_102,
+  2, 137, :_reduce_none,
+  2, 137, :_reduce_none,
+  1, 139, :_reduce_none,
+  2, 139, :_reduce_106,
+  1, 139, :_reduce_107,
+  2, 139, :_reduce_108,
+  1, 138, :_reduce_109,
+  3, 138, :_reduce_110,
+  1, 140, :_reduce_none,
+  5, 131, :_reduce_none,
+  4, 131, :_reduce_none,
+  2, 131, :_reduce_none,
+  1, 142, :_reduce_none,
+  2, 142, :_reduce_none,
+  1, 141, :_reduce_none,
+  3, 143, :_reduce_none,
+  2, 143, :_reduce_none,
+  2, 143, :_reduce_none,
+  1, 144, :_reduce_none,
+  3, 144, :_reduce_none,
+  1, 145, :_reduce_none,
+  4, 132, :_reduce_none,
+  5, 132, :_reduce_none,
+  2, 132, :_reduce_none,
+  1, 146, :_reduce_127,
+  1, 147, :_reduce_none,
+  3, 147, :_reduce_none,
+  1, 148, :_reduce_none,
+  3, 148, :_reduce_none,
+  1, 105, :_reduce_132,
+  1, 105, :_reduce_133,
+  2, 128, :_reduce_134,
+  1, 128, :_reduce_none,
+  2, 128, :_reduce_136,
+  1, 150, :_reduce_137,
+  3, 150, :_reduce_138,
+  4, 150, :_reduce_139,
+  3, 150, :_reduce_140,
+  4, 150, :_reduce_141,
+  3, 150, :_reduce_142,
+  1, 149, :_reduce_143,
+  2, 149, :_reduce_144,
+  2, 149, :_reduce_145,
+  3, 149, :_reduce_146,
+  1, 151, :_reduce_none,
+  5, 151, :_reduce_none,
+  1, 152, :_reduce_none,
+  3, 152, :_reduce_none,
+  2, 153, :_reduce_none,
+  2, 153, :_reduce_none,
+  1, 153, :_reduce_none,
+  1, 109, :_reduce_none,
+  2, 109, :_reduce_none,
+  1, 154, :_reduce_none,
+  1, 154, :_reduce_none,
+  2, 154, :_reduce_none,
+  3, 155, :_reduce_none,
+  2, 155, :_reduce_none,
+  3, 155, :_reduce_none,
+  3, 155, :_reduce_none,
+  4, 155, :_reduce_none,
+  2, 155, :_reduce_164,
+  3, 155, :_reduce_none,
+  3, 155, :_reduce_166,
+  4, 155, :_reduce_none,
+  1, 129, :_reduce_168,
+  3, 129, :_reduce_169,
+  4, 129, :_reduce_170,
+  4, 129, :_reduce_171,
+  1, 156, :_reduce_172,
+  3, 156, :_reduce_173,
+  0, 98, :_reduce_none,
+  2, 98, :_reduce_none,
+  1, 157, :_reduce_none,
+  2, 157, :_reduce_none,
+  1, 158, :_reduce_none,
+  1, 158, :_reduce_none,
+  2, 158, :_reduce_none,
+  2, 158, :_reduce_none,
+  1, 158, :_reduce_none,
+  1, 158, :_reduce_none,
+  1, 158, :_reduce_none,
+  4, 159, :_reduce_185,
+  1, 161, :_reduce_186,
+  3, 161, :_reduce_187,
+  3, 160, :_reduce_none,
+  0, 163, :_reduce_none,
+  2, 163, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  1, 164, :_reduce_none,
+  5, 165, :_reduce_none,
+  7, 165, :_reduce_none,
+  5, 166, :_reduce_none,
+  7, 167, :_reduce_none,
+  9, 168, :_reduce_none,
+  5, 169, :_reduce_none,
+  3, 170, :_reduce_none,
+  4, 170, :_reduce_none,
+  3, 170, :_reduce_none,
+  3, 162, :_reduce_none,
+  3, 171, :_reduce_none,
+  2, 171, :_reduce_none,
+  2, 171, :_reduce_none,
+  3, 171, :_reduce_none,
+  2, 171, :_reduce_none,
+  2, 172, :_reduce_none,
+  4, 172, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 173, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 125, :_reduce_none,
+  1, 100, :_reduce_238,
+  2, 100, :_reduce_239,
+  3, 100, :_reduce_240 ]
+
+racc_reduce_n = 241
+
+racc_shift_n = 398
+
+racc_token_table = {
+  false => 0,
+  :error => 1,
+  :INTEGER_CONSTANT => 2,
+  :FLOATING_CONSTANT => 3,
+  :OCTAL_CONSTANT => 4,
+  :HEX_CONSTANT => 5,
+  :CHARACTER_LITERAL => 6,
+  "(" => 7,
+  ")" => 8,
+  :STRING_LITERAL => 9,
+  "[" => 10,
+  "]" => 11,
+  "." => 12,
+  :IDENTIFIER => 13,
+  "->" => 14,
+  "++" => 15,
+  "--" => 16,
+  "," => 17,
+  :SIZEOF => 18,
+  "&" => 19,
+  "*" => 20,
+  "+" => 21,
+  "-" => 22,
+  "~" => 23,
+  "!" => 24,
+  "/" => 25,
+  "%" => 26,
+  "<<" => 27,
+  ">>" => 28,
+  "<" => 29,
+  ">" => 30,
+  "<=" => 31,
+  ">=" => 32,
+  "==" => 33,
+  "!=" => 34,
+  "^" => 35,
+  "|" => 36,
+  "&&" => 37,
+  "||" => 38,
+  "?" => 39,
+  ":" => 40,
+  ";" => 41,
+  "=" => 42,
+  :VOID => 43,
+  :FLOAT => 44,
+  :DOUBLE => 45,
+  :BOOL => 46,
+  :TYPE_NAME => 47,
+  :CHAR => 48,
+  :SHORT => 49,
+  :INT => 50,
+  :LONG => 51,
+  :SIGNED => 52,
+  :UNSIGNED => 53,
+  :STRUCT => 54,
+  "{" => 55,
+  "}" => 56,
+  :UNION => 57,
+  :ENUM => 58,
+  :CONST => 59,
+  :VOLATILE => 60,
+  :C_EXP => 61,
+  :EXTENSION => 62,
+  :TYPEDEF => 63,
+  :IF => 64,
+  :ELSE => 65,
+  :WHILE => 66,
+  :DO => 67,
+  :FOR => 68,
+  :SWITCH => 69,
+  :infunc_statment => 70,
+  :CASE => 71,
+  :DEFAULT => 72,
+  :GOTO => 73,
+  :CONTINUE => 74,
+  :BREAK => 75,
+  :RETURN => 76,
+  "+=" => 77,
+  "-=" => 78,
+  "*=" => 79,
+  "/=" => 80,
+  "%=" => 81,
+  "<<=" => 82,
+  ">>=" => 83,
+  "&=" => 84,
+  "|=" => 85,
+  "^=" => 86,
+  :__INLINE__ => 87,
+  :INLINE => 88,
+  :__INLINE => 89,
+  :CINLINE => 90,
+  :EXTERN => 91,
+  :STATIC => 92,
+  :AUTO => 93,
+  :REGISTER => 94,
+  "::" => 95 }
+
+racc_nt_base = 96
+
+racc_use_result_var = true
+
+Racc_arg = [
+  racc_action_table,
+  racc_action_check,
+  racc_action_default,
+  racc_action_pointer,
+  racc_goto_table,
+  racc_goto_check,
+  racc_goto_default,
+  racc_goto_pointer,
+  racc_nt_base,
+  racc_reduce_table,
+  racc_token_table,
+  racc_shift_n,
+  racc_reduce_n,
+  racc_use_result_var ]
+
+Racc_token_to_s_table = [
+  "$end",
+  "error",
+  "INTEGER_CONSTANT",
+  "FLOATING_CONSTANT",
+  "OCTAL_CONSTANT",
+  "HEX_CONSTANT",
+  "CHARACTER_LITERAL",
+  "\"(\"",
+  "\")\"",
+  "STRING_LITERAL",
+  "\"[\"",
+  "\"]\"",
+  "\".\"",
+  "IDENTIFIER",
+  "\"->\"",
+  "\"++\"",
+  "\"--\"",
+  "\",\"",
+  "SIZEOF",
+  "\"&\"",
+  "\"*\"",
+  "\"+\"",
+  "\"-\"",
+  "\"~\"",
+  "\"!\"",
+  "\"/\"",
+  "\"%\"",
+  "\"<<\"",
+  "\">>\"",
+  "\"<\"",
+  "\">\"",
+  "\"<=\"",
+  "\">=\"",
+  "\"==\"",
+  "\"!=\"",
+  "\"^\"",
+  "\"|\"",
+  "\"&&\"",
+  "\"||\"",
+  "\"?\"",
+  "\":\"",
+  "\";\"",
+  "\"=\"",
+  "VOID",
+  "FLOAT",
+  "DOUBLE",
+  "BOOL",
+  "TYPE_NAME",
+  "CHAR",
+  "SHORT",
+  "INT",
+  "LONG",
+  "SIGNED",
+  "UNSIGNED",
+  "STRUCT",
+  "\"{\"",
+  "\"}\"",
+  "UNION",
+  "ENUM",
+  "CONST",
+  "VOLATILE",
+  "C_EXP",
+  "EXTENSION",
+  "TYPEDEF",
+  "IF",
+  "ELSE",
+  "WHILE",
+  "DO",
+  "FOR",
+  "SWITCH",
+  "infunc_statment",
+  "CASE",
+  "DEFAULT",
+  "GOTO",
+  "CONTINUE",
+  "BREAK",
+  "RETURN",
+  "\"+=\"",
+  "\"-=\"",
+  "\"*=\"",
+  "\"/=\"",
+  "\"%=\"",
+  "\"<<=\"",
+  "\">>=\"",
+  "\"&=\"",
+  "\"|=\"",
+  "\"^=\"",
+  "__INLINE__",
+  "INLINE",
+  "__INLINE",
+  "CINLINE",
+  "EXTERN",
+  "STATIC",
+  "AUTO",
+  "REGISTER",
+  "\"::\"",
+  "$start",
+  "all",
+  "C_parser",
+  "primary_expression",
+  "namespace_identifier",
+  "string_literal_list",
+  "expression",
+  "postfix_expression",
+  "argument_list",
+  "type_qualifier",
+  "unary_expression",
+  "unary_operator",
+  "cast_expression",
+  "type_name",
+  "multiplicative_expression",
+  "additive_expression",
+  "shift_expression",
+  "relational_expression",
+  "equality_expression",
+  "and_expression",
+  "exclusive_or_expression",
+  "inclusive_or_expression",
+  "logical_and_expression",
+  "logical_or_expression",
+  "conditional_expression",
+  "constant_expression",
+  "declaration",
+  "declaration_specifiers",
+  "init_declarator_list",
+  "storage_class",
+  "type_specifier",
+  "init_declarator",
+  "declarator",
+  "initializer",
+  "struct_specifier",
+  "union_specifier",
+  "enum_specifier",
+  "struct_tag",
+  "struct_declaration_list",
+  "@1",
+  "@2",
+  "struct_declaration",
+  "struct_declarator_list",
+  "type_specifier_qualifier_list",
+  "struct_declarator",
+  "union_tag",
+  "union_declaration_list",
+  "union_declaration",
+  "union_declarator_list",
+  "union_declarator",
+  "enum_type",
+  "enumerator_list",
+  "enumerator",
+  "pointer",
+  "direct_declarator",
+  "parameter_type_list",
+  "parameter_list",
+  "parameter_declaration",
+  "abstract_declarator",
+  "direct_abstract_declarator",
+  "initializer_list",
+  "extension_statement",
+  "statement",
+  "typedef",
+  "func_def",
+  "declarator_list",
+  "compoundstatement",
+  "infunc_statement_list",
+  "infunc_statement",
+  "ifstatement",
+  "whilestatement",
+  "dowhilestatement",
+  "forstatement",
+  "switchstatement",
+  "labelstatement",
+  "gotostatement",
+  "expressionstatement",
+  "assignment_operator" ]
+
+Racc_debug_parser = false
+
+##### State transition tables end #####
+
+# reduce 0 omitted
+
+# reduce 1 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 52)
+  def _reduce_2(val, _values, result)
+     result = [ :IDENTIFIER, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 60)
+  def _reduce_3(val, _values, result)
+     result = [ :INTEGER_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 62)
+  def _reduce_4(val, _values, result)
+     result = [ :FLOATING_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 64)
+  def _reduce_5(val, _values, result)
+     result = [ :OCTAL_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 66)
+  def _reduce_6(val, _values, result)
+     result = [ :HEX_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 68)
+  def _reduce_7(val, _values, result)
+     result = [ :CHARACTER_LITERAL, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 70)
+  def _reduce_8(val, _values, result)
+     result = [ :STRING_LITERAL_LIST, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 72)
+  def _reduce_9(val, _values, result)
+     result = [ :PARENTHESES, val[1].get_elements ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 76)
+  def _reduce_10(val, _values, result)
+     result = [val[0]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 78)
+  def _reduce_11(val, _values, result)
+     result << val[1] 
+    result
+  end
+.,.,
+
+# reduce 12 omitted
+
+# reduce 13 omitted
+
+# reduce 14 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 86)
+  def _reduce_15(val, _values, result)
+     result = [ :OP_SUBSC, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 88)
+  def _reduce_16(val, _values, result)
+     result = [ :OP_DOT, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 90)
+  def _reduce_17(val, _values, result)
+     result = [ :OP_REF, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 91)
+  def _reduce_18(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 92)
+  def _reduce_19(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+# reduce 20 omitted
+
+# reduce 21 omitted
+
+# reduce 22 omitted
+
+# reduce 23 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 104)
+  def _reduce_24(val, _values, result)
+     result = [ val[0], val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 106)
+  def _reduce_25(val, _values, result)
+     result = [ :OP_SIZEOF_EXPR, val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 108)
+  def _reduce_26(val, _values, result)
+     result = [ :OP_SIZEOF_TYPE, val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 109)
+  def _reduce_27(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 110)
+  def _reduce_28(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 113)
+  def _reduce_29(val, _values, result)
+     result = :OP_U_AMP 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 114)
+  def _reduce_30(val, _values, result)
+     result = :OP_U_ASTER 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 115)
+  def _reduce_31(val, _values, result)
+     result = :OP_U_PLUS 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 116)
+  def _reduce_32(val, _values, result)
+     result = :OP_U_MINUS 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 117)
+  def _reduce_33(val, _values, result)
+     result = :OP_U_TILDE 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 118)
+  def _reduce_34(val, _values, result)
+     result = :OP_U_EXCLAM 
+    result
+  end
+.,.,
+
+# reduce 35 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 123)
+  def _reduce_36(val, _values, result)
+      result = [ :CAST, val[1], val[3] ] 
+    result
+  end
+.,.,
+
+# reduce 37 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 128)
+  def _reduce_38(val, _values, result)
+     result = [ :OP_MULT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 130)
+  def _reduce_39(val, _values, result)
+     result = [ :OP_DIV, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 132)
+  def _reduce_40(val, _values, result)
+     result = [ :OP_REMAIN, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 41 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 137)
+  def _reduce_42(val, _values, result)
+     result = [ :OP_ADD, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 139)
+  def _reduce_43(val, _values, result)
+     result = [ :OP_SUB, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 44 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 144)
+  def _reduce_45(val, _values, result)
+     result = [ :OP_LSFT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 146)
+  def _reduce_46(val, _values, result)
+     result = [ :OP_RSFT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 47 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 151)
+  def _reduce_48(val, _values, result)
+     result = [ :OP_LT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 153)
+  def _reduce_49(val, _values, result)
+     result = [ :OP_GT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 155)
+  def _reduce_50(val, _values, result)
+     result = [ :OP_LE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 157)
+  def _reduce_51(val, _values, result)
+     result = [ :OP_GE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 52 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 162)
+  def _reduce_53(val, _values, result)
+     result = [ :OP_EQ, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 164)
+  def _reduce_54(val, _values, result)
+     result = [ :OP_NE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 55 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 169)
+  def _reduce_56(val, _values, result)
+     result = [ :OP_AND, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 57 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 174)
+  def _reduce_58(val, _values, result)
+     result = [ :OP_EOR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 59 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 179)
+  def _reduce_60(val, _values, result)
+     result = [ :OP_OR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 61 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 184)
+  def _reduce_62(val, _values, result)
+     result = [ :OP_LAND, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 63 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 189)
+  def _reduce_64(val, _values, result)
+     result = [ :OP_LOR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 65 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 194)
+  def _reduce_66(val, _values, result)
+     result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 201)
+  def _reduce_67(val, _values, result)
+    			result = Expression.new( val[0] )
+			# result.print
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 208)
+  def _reduce_68(val, _values, result)
+    			result = Expression.new( val[0] )
+			# result.print
+#			res = result.eval_const( nil )
+
+			# if res then
+			#   puts "val: #{res}"
+			# else
+			#   puts "val: nil"
+			# end
+		
+    result
+  end
+.,.,
+
+# reduce 69 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 237)
+  def _reduce_70(val, _values, result)
+    			result = CIntType.new( -3 )    # storage class ã¯ç¡è¦
+		
+    result
+  end
+.,.,
+
+# reduce 71 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 242)
+  def _reduce_72(val, _values, result)
+    			result = CIntType.new( -3 )
+			result.set_qualifier val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 247)
+  def _reduce_73(val, _values, result)
+    			result = val[1]                # storage class ã¯ç¡è¦
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 251)
+  def _reduce_74(val, _values, result)
+    			result = val[1].merge val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 255)
+  def _reduce_75(val, _values, result)
+    			val[1].set_qualifier val[0]
+                        result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 262)
+  def _reduce_76(val, _values, result)
+     result = [val[0]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 264)
+  def _reduce_77(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+# reduce 78 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 269)
+  def _reduce_79(val, _values, result)
+     val[0].set_initializer( val[2] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 272)
+  def _reduce_80(val, _values, result)
+     set_no_type_name true; result = CVoidType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 273)
+  def _reduce_81(val, _values, result)
+     set_no_type_name true; result = CFloatType.new(-32) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 274)
+  def _reduce_82(val, _values, result)
+     set_no_type_name true; result = CFloatType.new(-64) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 275)
+  def _reduce_83(val, _values, result)
+     set_no_type_name true; result = CBoolType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 276)
+  def _reduce_84(val, _values, result)
+     set_no_type_name true; result = val[0] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 277)
+  def _reduce_85(val, _values, result)
+     set_no_type_name true; result = CVoidType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 278)
+  def _reduce_86(val, _values, result)
+     set_no_type_name true; result = CVoidType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 279)
+  def _reduce_87(val, _values, result)
+     set_no_type_name true; result = CDefinedType.new( val[0].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 281)
+  def _reduce_88(val, _values, result)
+     set_no_type_name true; result = CIntType.new(-11 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 282)
+  def _reduce_89(val, _values, result)
+     set_no_type_name true; result = CIntType.new( -2 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 283)
+  def _reduce_90(val, _values, result)
+     set_no_type_name true; result = CIntType.new( -3 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 284)
+  def _reduce_91(val, _values, result)
+     set_no_type_name true; result = CIntType.new( -4 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 287)
+  def _reduce_92(val, _values, result)
+    			set_no_type_name true
+			result = CIntType.new( -3 )
+			result.set_sign :SIGNED
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 293)
+  def _reduce_93(val, _values, result)
+    			set_no_type_name true
+			result = CIntType.new( -3 )
+			result.set_sign :UNSIGNED
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 301)
+  def _reduce_94(val, _values, result)
+     StructType.set_define( true )  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 304)
+  def _reduce_95(val, _values, result)
+    			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 309)
+  def _reduce_96(val, _values, result)
+    			result = CStructType.new()
+			StructType.set_define( true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 314)
+  def _reduce_97(val, _values, result)
+    			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 319)
+  def _reduce_98(val, _values, result)
+    			StructType.set_define( false )
+			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 99 omitted
+
+# reduce 100 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 331)
+  def _reduce_101(val, _values, result)
+    			result = CStructType.new( val[0].val )
+			set_no_type_name true
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 340)
+  def _reduce_102(val, _values, result)
+    			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+				i.set_kind( :MEMBER )
+				i.check
+				CStructType.new_member( i )
+			}
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 103 omitted
+
+# reduce 104 omitted
+
+# reduce 105 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 359)
+  def _reduce_106(val, _values, result)
+    			result = val[1].merge val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 363)
+  def _reduce_107(val, _values, result)
+    			result = CIntType.new( -3 )
+			result.set_qualifier val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 368)
+  def _reduce_108(val, _values, result)
+    			val[1].set_qualifier val[0]
+                        result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 374)
+  def _reduce_109(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 376)
+  def _reduce_110(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+# reduce 111 omitted
+
+# reduce 112 omitted
+
+# reduce 113 omitted
+
+# reduce 114 omitted
+
+# reduce 115 omitted
+
+# reduce 116 omitted
+
+# reduce 117 omitted
+
+# reduce 118 omitted
+
+# reduce 119 omitted
+
+# reduce 120 omitted
+
+# reduce 121 omitted
+
+# reduce 122 omitted
+
+# reduce 123 omitted
+
+# reduce 124 omitted
+
+# reduce 125 omitted
+
+# reduce 126 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 418)
+  def _reduce_127(val, _values, result)
+     result = CEnumType.new( -1 ) 
+    result
+  end
+.,.,
+
+# reduce 128 omitted
+
+# reduce 129 omitted
+
+# reduce 130 omitted
+
+# reduce 131 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 434)
+  def _reduce_132(val, _values, result)
+     result = :CONST 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 435)
+  def _reduce_133(val, _values, result)
+     result = :VOLATILE 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 440)
+  def _reduce_134(val, _values, result)
+    			val[1].set_type( val[0] )
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 135 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 446)
+  def _reduce_136(val, _values, result)
+    			result = Decl.new( val[1].val )
+			result.set_type( val[0] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 452)
+  def _reduce_137(val, _values, result)
+     result = Decl.new( val[0].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 454)
+  def _reduce_138(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 457)
+  def _reduce_139(val, _values, result)
+    			val[0].set_type( CArrayType.new( val[2] ) )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 462)
+  def _reduce_140(val, _values, result)
+    			val[0].set_type( CArrayType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 467)
+  def _reduce_141(val, _values, result)
+    		# 	Generator.warning( "W6001 need 'void' for no parameter"  )
+			val[0].set_type( CFuncType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 475)
+  def _reduce_142(val, _values, result)
+    		# 	Generator.warning( "W6002 need 'void' for no parameter"  )
+			val[0].set_type( CFuncType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 482)
+  def _reduce_143(val, _values, result)
+     result = CPtrType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 485)
+  def _reduce_144(val, _values, result)
+    			result = CPtrType.new
+			result.set_qualifier( val[1] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 490)
+  def _reduce_145(val, _values, result)
+    			val[1].set_type(CPtrType.new)
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 495)
+  def _reduce_146(val, _values, result)
+    			ptrtype = CPtrType.new
+			ptrtype.set_qualifier( val[1] )
+			val[2].set_type( ptrtype )
+			result = val[2]
+		
+    result
+  end
+.,.,
+
+# reduce 147 omitted
+
+# reduce 148 omitted
+
+# reduce 149 omitted
+
+# reduce 150 omitted
+
+# reduce 151 omitted
+
+# reduce 152 omitted
+
+# reduce 153 omitted
+
+# reduce 154 omitted
+
+# reduce 155 omitted
+
+# reduce 156 omitted
+
+# reduce 157 omitted
+
+# reduce 158 omitted
+
+# reduce 159 omitted
+
+# reduce 160 omitted
+
+# reduce 161 omitted
+
+# reduce 162 omitted
+
+# reduce 163 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 559)
+  def _reduce_164(val, _values, result)
+    			Generator.warning( "W6003 need 'void' for no parameter"  )
+		
+    result
+  end
+.,.,
+
+# reduce 165 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 564)
+  def _reduce_166(val, _values, result)
+    			Generator.warning( "W6004 need 'void' for no parameter"  )
+		
+    result
+  end
+.,.,
+
+# reduce 167 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 571)
+  def _reduce_168(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 573)
+  def _reduce_169(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 575)
+  def _reduce_170(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 577)
+  def _reduce_171(val, _values, result)
+     result = C_EXP.new( val[2] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 582)
+  def _reduce_172(val, _values, result)
+    			result = [ val[0] ]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 586)
+  def _reduce_173(val, _values, result)
+    			val[0] << val[2]
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+# reduce 174 omitted
+
+# reduce 175 omitted
+
+# reduce 176 omitted
+
+# reduce 177 omitted
+
+# reduce 178 omitted
+
+# reduce 179 omitted
+
+# reduce 180 omitted
+
+# reduce 181 omitted
+
+# reduce 182 omitted
+
+# reduce 183 omitted
+
+# reduce 184 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 614)
+  def _reduce_185(val, _values, result)
+    			val[2].each{ |i|
+			   i.set_kind( :TYPEDEF )
+			}
+			Typedef.new_decl_list( val[1], val[2] )
+                        # val[1].show_tree 0
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 623)
+  def _reduce_186(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 625)
+  def _reduce_187(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+# reduce 188 omitted
+
+# reduce 189 omitted
+
+# reduce 190 omitted
+
+# reduce 191 omitted
+
+# reduce 192 omitted
+
+# reduce 193 omitted
+
+# reduce 194 omitted
+
+# reduce 195 omitted
+
+# reduce 196 omitted
+
+# reduce 197 omitted
+
+# reduce 198 omitted
+
+# reduce 199 omitted
+
+# reduce 200 omitted
+
+# reduce 201 omitted
+
+# reduce 202 omitted
+
+# reduce 203 omitted
+
+# reduce 204 omitted
+
+# reduce 205 omitted
+
+# reduce 206 omitted
+
+# reduce 207 omitted
+
+# reduce 208 omitted
+
+# reduce 209 omitted
+
+# reduce 210 omitted
+
+# reduce 211 omitted
+
+# reduce 212 omitted
+
+# reduce 213 omitted
+
+# reduce 214 omitted
+
+# reduce 215 omitted
+
+# reduce 216 omitted
+
+# reduce 217 omitted
+
+# reduce 218 omitted
+
+# reduce 219 omitted
+
+# reduce 220 omitted
+
+# reduce 221 omitted
+
+# reduce 222 omitted
+
+# reduce 223 omitted
+
+# reduce 224 omitted
+
+# reduce 225 omitted
+
+# reduce 226 omitted
+
+# reduce 227 omitted
+
+# reduce 228 omitted
+
+# reduce 229 omitted
+
+# reduce 230 omitted
+
+# reduce 231 omitted
+
+# reduce 232 omitted
+
+# reduce 233 omitted
+
+# reduce 234 omitted
+
+# reduce 235 omitted
+
+# reduce 236 omitted
+
+# reduce 237 omitted
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 706)
+  def _reduce_238(val, _values, result)
+     result = NamespacePath.new( val[0].val, false ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 707)
+  def _reduce_239(val, _values, result)
+     result = NamespacePath.new( val[1].val, true ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'C_parser.y.rb', 709)
+  def _reduce_240(val, _values, result)
+     result = val[0].append!( val[2].val ) 
+    result
+  end
+.,.,
+
+def _reduce_none(val, _values, result)
+  val[0]
+end
+
+end   # class C_parser
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.y.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.y.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/C_parser.y.rb	(revision 317)
@@ -0,0 +1,1015 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: C_parser.y.rb 2562 2016-03-21 11:48:59Z okuma-top $
+#++
+
+class C_parser
+rule
+# ãããã¬ãã«ã®æ§æè¦ç´ ã¯ C_parser
+all: C_parser
+
+# Expr
+##########################  å¼  ##########################
+# K&Rã®ææ³(ãã­ã°ã©ãã³ã°è¨èªC ç¬¬2ç ä»é²)ã¨ä¸é¨ç°ãªã
+# argument_expression_list(é¢æ°å¼æ°), assignment_expression(ä»£å
+¥)ããªã
+# å¼ã® result ã¯ããã¹ã¦é
+åã§ç¬¬ä¸è¦ç´ ãè­å¥ã·ã³ãã«ãç¬¬äºè¦ç´ ä»¥ä¸ãå¼æ°
+
+primary_expression
+        : namespace_identifier
+		{ result = [ :IDENTIFIER, val[0] ] }     #1ok
+#        : IDENTIFIER	# mikan namespace ã¸ã®å¯¾å¿
+#		{ result = [ :IDENTIFIER, val[0] ] }
+#        | TRUE
+#		{ result = [ :BOOL_CONSTANT, true ] }
+#        | FALSE
+#		{ result = [ :BOOL_CONSTANT, false ] }
+        | INTEGER_CONSTANT
+		{ result = [ :INTEGER_CONSTANT, val[0] ] }
+        | FLOATING_CONSTANT
+		{ result = [ :FLOATING_CONSTANT, val[0] ] }
+        | OCTAL_CONSTANT
+		{ result = [ :OCTAL_CONSTANT, val[0] ] }
+        | HEX_CONSTANT
+		{ result = [ :HEX_CONSTANT, val[0] ] }
+        | CHARACTER_LITERAL
+		{ result = [ :CHARACTER_LITERAL, val[0] ] }
+        | string_literal_list
+		{ result = [ :STRING_LITERAL_LIST, val[0] ] }
+        | '(' expression ')'
+		{ result = [ :PARENTHESES, val[1].get_elements ] }
+
+string_literal_list
+        : STRING_LITERAL
+		{ result = [val[0]] }
+        | string_literal_list STRING_LITERAL
+		{ result << val[1] }
+
+# é¢æ°å¼ã³åºãã¨å¾ç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®å­ããªã
+postfix_expression
+        : primary_expression
+        | primary_expression '(' argument_list ')'
+        | primary_expression type_qualifier '(' argument_list ')'    # intended __asm volatile ( "   MNEMONIC  OPERAND" );
+        | postfix_expression '[' expression ']'
+		{ result = [ :OP_SUBSC, val[0], val[2] ] }
+        | postfix_expression '.' IDENTIFIER
+		{ result = [ :OP_DOT, val[0], val[2] ] }
+        | postfix_expression '->' IDENTIFIER
+		{ result = [ :OP_REF, val[0], val[2] ] }
+        | postfix_expression '++'	{ result = val[0] }   # ++, -- ã¯ç¡è¦ãã
+        | postfix_expression '--'	{ result = val[0] }
+
+argument_list
+        :
+        | expression
+        | argument_list ',' expression
+
+
+# åç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®å­ããªã
+unary_expression
+        : postfix_expression
+        | unary_operator cast_expression
+		{ result = [ val[0], val[1] ] }
+        | SIZEOF unary_expression
+		{ result = [ :OP_SIZEOF_EXPR, val[1] ] }
+        | SIZEOF '(' type_name ')'
+		{ result = [ :OP_SIZEOF_TYPE, val[1] ] }
+		| '++' unary_expression			{ result = val[1] }   # ++, -- ã¯ç¡è¦ãã
+		| '--' unary_expression			{ result = val[1] }
+
+unary_operator
+        : '&'	{ result = :OP_U_AMP }
+        | '*'	{ result = :OP_U_ASTER }
+        | '+'	{ result = :OP_U_PLUS }
+        | '-'	{ result = :OP_U_MINUS }
+        | '~'	{ result = :OP_U_TILDE }
+        | '!'	{ result = :OP_U_EXCLAM }
+
+cast_expression
+        : unary_expression
+        | '(' type_name ')' cast_expression
+		{  result = [ :CAST, val[1], val[3] ] }
+
+multiplicative_expression
+        : cast_expression
+        | multiplicative_expression '*' cast_expression
+		{ result = [ :OP_MULT, val[0], val[2] ]  }
+        | multiplicative_expression '/' cast_expression
+		{ result = [ :OP_DIV, val[0], val[2] ]  }
+        | multiplicative_expression '%' cast_expression
+		{ result = [ :OP_REMAIN, val[0], val[2] ]  }
+
+additive_expression
+        : multiplicative_expression
+        | additive_expression '+' multiplicative_expression
+		{ result = [ :OP_ADD, val[0], val[2] ]  }
+        | additive_expression '-' multiplicative_expression
+		{ result = [ :OP_SUB, val[0], val[2] ]  }
+
+shift_expression
+        : additive_expression
+        | shift_expression '<<' additive_expression
+		{ result = [ :OP_LSFT, val[0], val[2] ]  }
+        | shift_expression '>>' additive_expression
+		{ result = [ :OP_RSFT, val[0], val[2] ]  }
+
+relational_expression
+        : shift_expression
+        | relational_expression '<' shift_expression
+		{ result = [ :OP_LT, val[0], val[2] ]  }
+        | relational_expression '>' shift_expression
+		{ result = [ :OP_GT, val[0], val[2] ]  }
+        | relational_expression '<=' shift_expression
+		{ result = [ :OP_LE, val[0], val[2] ]  }
+        | relational_expression '>=' shift_expression
+		{ result = [ :OP_GE, val[0], val[2] ]  }
+
+equality_expression
+        : relational_expression
+        | equality_expression '==' relational_expression
+		{ result = [ :OP_EQ, val[0], val[2] ]  }
+        | equality_expression '!=' relational_expression
+		{ result = [ :OP_NE, val[0], val[2] ]  }
+
+and_expression
+        : equality_expression
+        | and_expression '&' equality_expression
+		{ result = [ :OP_AND, val[0], val[2] ]  }
+
+exclusive_or_expression
+        : and_expression
+        | exclusive_or_expression '^' and_expression
+		{ result = [ :OP_EOR, val[0], val[2] ]  }
+
+inclusive_or_expression
+        : exclusive_or_expression
+        | inclusive_or_expression '|' exclusive_or_expression
+		{ result = [ :OP_OR, val[0], val[2] ]  }
+
+logical_and_expression
+        : inclusive_or_expression
+        | logical_and_expression '&&' inclusive_or_expression
+		{ result = [ :OP_LAND, val[0], val[2] ]  }
+
+logical_or_expression
+        : logical_and_expression
+        | logical_or_expression '||' logical_and_expression
+		{ result = [ :OP_LOR, val[0], val[2] ]  }
+
+conditional_expression
+        : logical_or_expression
+        | logical_or_expression '?' expression ':' conditional_expression
+		{ result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ]  }
+
+
+# ã³ã³ãæ¼ç®å­ãä½¿ããªã
+expression
+        : conditional_expression
+		{
+			result = Expression.new( val[0] )
+			# result.print
+		}
+
+constant_expression
+        : conditional_expression
+		{
+			result = Expression.new( val[0] )
+			# result.print
+#			res = result.eval_const( nil )
+
+			# if res then
+			#   puts "val: #{res}"
+			# else
+			#   puts "val: nil"
+			# end
+		}
+
+
+
+# Types
+##########################  å®£è¨  ##########################
+# å®£è¨ãK&Rã¨ä¸é¨ç°ãªã
+
+# declarationã¯ã»ã«ã®å±æ§ã§ä½¿ããã
+# K&Rã¨ã®éã: storage classãæå®ã§ããªããåãçç¥ã§ããªã
+declaration
+        : declaration_specifiers init_declarator_list ';'
+#        : type_specifier_qualifier_list init_declarator_list ';'
+
+# declaration_specifiersã¯é¢æ°ã®ãã©ã¡ã¼ã¿ã§ä½¿ããããã
+# type_specifier_qualifier_listã§ååãããããªã
+
+declaration_specifiers
+        : storage_class
+		{
+			result = CIntType.new( -3 )    # storage class ã¯ç¡è¦
+		}
+        | type_specifier
+        | type_qualifier
+		{
+			result = CIntType.new( -3 )
+			result.set_qualifier val[0]
+		}
+        | storage_class declaration_specifiers
+		{
+			result = val[1]                # storage class ã¯ç¡è¦
+		}
+        | type_specifier declaration_specifiers
+		{
+			result = val[1].merge val[0]
+		}
+        | type_qualifier declaration_specifiers
+		{
+			val[1].set_qualifier val[0]
+                        result = val[1]
+		}
+
+
+init_declarator_list
+        : init_declarator
+		{ result = [val[0]] }
+        | init_declarator_list ',' init_declarator
+		{ result << val[2] }
+
+init_declarator
+        : declarator
+        | declarator '=' initializer
+		{ val[0].set_initializer( val[2] ) }
+
+type_specifier
+        : VOID	{ set_no_type_name true; result = CVoidType.new }
+        | FLOAT	{ set_no_type_name true; result = CFloatType.new(-32) }
+        | DOUBLE	{ set_no_type_name true; result = CFloatType.new(-64) }
+        | BOOL	{ set_no_type_name true; result = CBoolType.new }
+        | struct_specifier	{ set_no_type_name true; result = val[0] } # set_no_type_name true ã¯ struct_tag ã§ãå¼ã°ãã
+        | union_specifier	{ set_no_type_name true; result = CVoidType.new }  # void ãå®£è¨ãããã¨ãã
+        | enum_specifier	{ set_no_type_name true; result = CVoidType.new }  # void ãå®£è¨ãããã¨ãã
+        | TYPE_NAME	{ set_no_type_name true; result = CDefinedType.new( val[0].val ) }
+
+        | CHAR	{ set_no_type_name true; result = CIntType.new(-11 ) }
+        | SHORT	{ set_no_type_name true; result = CIntType.new( -2 ) }
+        | INT		{ set_no_type_name true; result = CIntType.new( -3 ) }
+        | LONG	{ set_no_type_name true; result = CIntType.new( -4 ) }
+        | SIGNED
+		{
+			set_no_type_name true
+			result = CIntType.new( -3 )
+			result.set_sign :SIGNED
+		}
+        | UNSIGNED
+		{
+			set_no_type_name true
+			result = CIntType.new( -3 )
+			result.set_sign :UNSIGNED
+		}
+
+# mikan K&Rã®struct_or_union_specifierã«ç¸å½ããããunionã¯ä½¿ããªã, bit field ã«ãå¯¾å¿ããªã
+struct_specifier		# mikan
+        : STRUCT struct_tag '{'
+		{ StructType.set_define( true )  }
+	   struct_declaration_list '}'
+		{
+			StructType.end_of_parse
+			result = val[1]
+		}
+        | STRUCT
+		{
+			result = CStructType.new()
+			StructType.set_define( true )
+		}
+	   '{' struct_declaration_list '}'
+		{
+			StructType.end_of_parse
+			result = val[1]
+		}
+        | STRUCT struct_tag   # mikan struct_tag ã¯ namespace å¯¾å¿ãå¿
+è¦
+		{
+			StructType.set_define( false )
+			StructType.end_of_parse
+			result = val[1]
+		}
+
+struct_declaration_list
+        : struct_declaration
+        | struct_declaration_list struct_declaration
+
+struct_tag:
+        IDENTIFIER
+		{
+			result = CStructType.new( val[0].val )
+			set_no_type_name true
+		}
+
+# ãã¤ã³ã¿ä¿®é£¾å­ãè¿½å 
+struct_declaration
+        : declaration_specifiers struct_declarator_list ';'
+#        :                                type_specifier_qualifier_list struct_declarator_list ';'
+		{
+			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+				i.set_kind( :MEMBER )
+				i.check
+				CStructType.new_member( i )
+			}
+			result = val[1]
+		}
+        | union_specifier ';'                       # ç¡å
+        | struct_specifier ';'                       # ç¡å
+
+
+
+# K&Rã®specifier_qualifier_listã¨åã
+# ååãã¾ãããããã£ãã®ã§type_ãä»ãã
+type_specifier_qualifier_list
+        : type_specifier
+        | type_specifier type_specifier_qualifier_list
+		{
+			result = val[1].merge val[0]
+		}
+        | type_qualifier
+		{
+			result = CIntType.new( -3 )
+			result.set_qualifier val[0]
+		}
+        | type_qualifier type_specifier_qualifier_list
+		{
+			val[1].set_qualifier val[0]
+                        result = val[1]
+		}
+
+struct_declarator_list
+        : struct_declarator
+		{ result = [ val[0] ] }
+        | struct_declarator_list ',' struct_declarator
+		{ result << val[2] }
+
+# ããããã£ã¼ã«ãã¯ä½¿ããªã
+struct_declarator
+        : declarator
+
+
+
+union_specifier
+        : UNION union_tag '{' union_declaration_list '}'
+        | UNION '{' union_declaration_list '}'
+        | UNION union_tag   # mikan struct_tag ã¯ namespace å¯¾å¿ãå¿
+è¦
+
+union_declaration_list
+        : union_declaration
+        | union_declaration_list union_declaration
+
+union_tag:
+	IDENTIFIER
+
+union_declaration
+        : declaration_specifiers union_declarator_list ';'
+		| union_specifier ';'                       # ç¡å
+		| struct_specifier ';'                      # ç¡å
+
+union_declarator_list
+        : union_declarator
+        | union_declarator_list ',' union_declarator
+
+# ããããã£ã¼ã«ãã¯ä½¿ããªã
+union_declarator
+        : declarator
+
+
+
+# enumã®ç¨®é¡ãè¿½å 
+enum_specifier		# mikan
+        : enum_type            '{' enumerator_list '}'
+        | enum_type IDENTIFIER '{' enumerator_list '}'
+        | enum_type IDENTIFIER
+
+enum_type
+        : ENUM	{ result = CEnumType.new( -1 ) }
+#        | ENUM8	{ result = CEnumType.new( 8 ) }
+#        | ENUM16	{ result = CEnumType.new( 16 ) }
+#        | ENUM32	{ result = CEnumType.new( 32 ) }
+#        | ENUM64	{ result = CEnumType.new( 64 ) }
+#        | ENUM128	{ result = CEnumType.new( 128 ) }
+
+enumerator_list
+        : enumerator
+        | enumerator_list ',' enumerator
+
+enumerator
+        : IDENTIFIER
+        | IDENTIFIER '=' constant_expression
+
+type_qualifier
+        : CONST	{ result = :CONST }
+        | VOLATILE	{ result = :VOLATILE }
+
+declarator
+        : pointer direct_declarator
+		{
+			val[1].set_type( val[0] )
+			result = val[1]
+		}
+        | direct_declarator
+        | pointer TYPE_NAME     # é¢æ°ãã¤ã³ã¿ã® typedef ãäºéå®ç¾©ã®å ´å
+		{
+			result = Decl.new( val[1].val )
+			result.set_type( val[0] )
+		}
+
+direct_declarator		# mikan
+        : IDENTIFIER
+		{ result = Decl.new( val[0].val ) }
+        | '(' declarator ')'
+		{ result = val[1] }
+        | direct_declarator '[' constant_expression ']'
+		{
+			val[0].set_type( CArrayType.new( val[2] ) )
+			result = val[0]
+		}
+        | direct_declarator '[' ']'
+		{
+			val[0].set_type( CArrayType.new )
+			result = val[0]
+		}
+        | direct_declarator '(' parameter_type_list ')'
+		{
+		# 	Generator.warning( "W6001 need 'void' for no parameter"  )
+			val[0].set_type( CFuncType.new )
+			result = val[0]
+		}
+
+#        | direct_declarator '(' identifier_list ')'  # ããã¯ä½ã®ããã«å¿
+è¦ï¼ 060211
+        | direct_declarator '(' ')'
+		{
+		# 	Generator.warning( "W6002 need 'void' for no parameter"  )
+			val[0].set_type( CFuncType.new )
+			result = val[0]
+		}
+
+pointer
+        : '*'
+		{ result = CPtrType.new }
+        | '*' type_qualifier
+		{
+			result = CPtrType.new
+			result.set_qualifier( val[1] )
+		}
+        | '*' pointer
+		{
+			val[1].set_type(CPtrType.new)
+			result = val[1]
+		}
+        | '*' type_qualifier pointer
+		{
+			ptrtype = CPtrType.new
+			ptrtype.set_qualifier( val[1] )
+			val[2].set_type( ptrtype )
+			result = val[2]
+		}
+
+
+parameter_type_list
+        : parameter_list
+        | parameter_list ',' '.' '.' '.'
+		# mikan å¯å¤é·ãã©ã¡ã¼ã¿,  ... ã®éã®ã¹ãã¼ã¹ãè¨±ãããï¼ææãï¼
+
+parameter_list
+        : parameter_declaration
+#		{ result = ParamList.new( val[0] ) }
+        | parameter_list ',' parameter_declaration
+#		{
+#			val[0].add_param( val[2] )
+#			# result = val[0] ä¸è¦
+#		}
+
+
+# ãã©ã¡ã¼ã¿ä¿®é£¾å­ãè¿½å 
+parameter_declaration
+        : declaration_specifiers declarator
+#		{
+#			decl = ParamDecl.new( val[1], val[0], [] )
+#			val[1].set_kind( :PARAMETER )
+#			result = decl
+#		}
+
+	# ä»¥ä¸ã¯ã¨ã©ã¼ã¨ãã
+#        | declaration_specifiers	# ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã 060210
+#		{
+#			unless val[0].kind_of?( VoidType ) then
+#				Generator.error( "B1001 need parameter name"  )
+#			end
+#			result = nil
+#		}
+        | declaration_specifiers abstract_declarator	# ä»®å¼æ°ãªã
+        | declaration_specifiers						# ä»®å¼æ°ãªã
+
+
+#identifier_list       # 060211  ä¸ç¨ã«ãªã£ã
+#        : IDENTIFIER
+#        | identifier_list ',' IDENTIFIER
+
+type_name
+        : type_specifier_qualifier_list
+        | type_specifier_qualifier_list abstract_declarator
+
+abstract_declarator		# mikan
+        : pointer
+        | direct_abstract_declarator
+        | pointer direct_abstract_declarator
+
+direct_abstract_declarator
+        : '(' abstract_declarator ')'
+        | '[' ']'
+        | '[' constant_expression ']'
+        | direct_abstract_declarator '[' ']'
+        | direct_abstract_declarator '[' constant_expression ']'
+        | '(' ')'
+		{
+			Generator.warning( "W6003 need 'void' for no parameter"  )
+		}
+        | '(' parameter_type_list ')'
+        | direct_abstract_declarator '(' ')'
+		{
+			Generator.warning( "W6004 need 'void' for no parameter"  )
+		}
+        | direct_abstract_declarator '(' parameter_type_list ')'
+
+# assignment_expressionãconstant_expressionã«å¤æ´
+initializer			# mikan
+        : constant_expression
+		{ result = val[0] }
+        | '{' initializer_list '}'
+		{ result = val[1] }
+        | '{' initializer_list ',' '}'
+		{ result = val[1] }
+	| C_EXP '(' STRING_LITERAL ')'
+		{ result = C_EXP.new( val[2] ) }
+
+initializer_list
+        : initializer
+		{
+			result = [ val[0] ]
+		}
+        | initializer_list ',' initializer
+		{
+			val[0] << val[2]
+			result = val[0]
+		}
+
+
+##########################  ããããã¯CDLç¬èª  ##########################
+
+#ãããã¬ãã«ã®æ§æè¦å
+C_parser
+        :
+        | C_parser extension_statement
+
+extension_statement
+        : statement
+        | EXTENSION statement
+
+statement
+        : typedef
+        | func_def
+        | enum_specifier ';'
+        | struct_specifier ';'
+        | declaration
+        | ';'
+        | error   # ã¨ã©ã¼åå¾©ãã¤ã³ã
+
+typedef
+        : TYPEDEF type_specifier_qualifier_list declarator_list ';'
+		{
+			val[2].each{ |i|
+			   i.set_kind( :TYPEDEF )
+			}
+			Typedef.new_decl_list( val[1], val[2] )
+                        # val[1].show_tree 0
+		}
+
+declarator_list
+        : declarator
+		{ result = [ val[0] ] }
+        | declarator_list ',' declarator
+		{ result << val[2] }
+
+func_def
+        : declaration_specifiers declarator compoundstatement
+
+infunc_statement_list
+        :
+        | infunc_statement_list infunc_statement
+
+infunc_statement
+        : declaration
+        | ifstatement
+        | whilestatement
+        | dowhilestatement
+        | forstatement
+        | switchstatement
+        | labelstatement
+        | compoundstatement
+        | gotostatement
+        | expressionstatement
+        | ';'
+
+ifstatement
+        : IF '(' expression ')' infunc_statement
+        | IF '(' expression ')' infunc_statement ELSE infunc_statement
+
+whilestatement
+        : WHILE '(' expression ')' infunc_statement
+
+dowhilestatement
+        : DO infunc_statement WHILE '(' expression ')' ';'
+
+forstatement
+        : FOR '(' expression ';' expression ';' expression ')' infunc_statement
+
+switchstatement
+        : SWITCH '(' expression ')'  infunc_statment
+
+labelstatement
+        : IDENTIFIER ':' infunc_statement
+        | CASE constant_expression ':' infunc_statement
+        | DEFAULT ':' infunc_statement
+
+compoundstatement
+        : '{' infunc_statement_list '}'
+
+gotostatement
+        : GOTO IDENTIFIER ';'
+        | CONTINUE ';'
+        | BREAK ';'
+        | RETURN expression ';'
+        | RETURN ';'
+
+expressionstatement
+        : expression ';'
+        | unary_expression assignment_operator expression ';'
+
+assignment_operator
+        : '='
+        | '+='
+        | '-='
+        | '*='
+        | '/='
+        | '%='
+        | '<<='
+        | '>>='
+        | '&='
+        | '|='
+        | '^='
+
+storage_class
+        : __INLINE__
+        | INLINE
+        | __INLINE
+        | CINLINE
+        | EXTERN
+        | STATIC
+        | AUTO
+        | REGISTER
+
+namespace_identifier
+        : IDENTIFIER		{ result = NamespacePath.new( val[0].val, false ) }
+        | '::' IDENTIFIER	{ result = NamespacePath.new( val[1].val, true ) }
+        | namespace_identifier '::' IDENTIFIER
+		{ result = val[0].append!( val[2].val ) }
+
+end
+
+---- inner
+
+  RESERVED = {
+    # keyword
+    'typedef' => :TYPEDEF,
+    'struct' => :STRUCT,
+    'union' => :UNION,
+    'sizeof' => :SIZEOF,
+    'throw' => :THROW,
+
+    # specifier
+    # types
+    'void'    => :VOID,
+    'char'    => :CHAR,
+    'short'   => :SHORT,
+
+    'volatile'=> :VOLATILE,
+    'const'   => :CONST,
+    'extern'   => :EXTERN,
+
+    'long'    => :LONG,
+    'float'   => :FLOAT,
+    'double'  => :DOUBLE,
+    'signed'  => :SIGNED,
+    'unsigned'=> :UNSIGNED,
+
+    'int'     => :INT,
+    'enum'    => :ENUM,
+
+    'if'      => :IF,
+    'else'    => :ELSE,
+    'while'   => :WHILE,
+    'do'      => :DO,
+    'for'     => :FOR,
+    'case'    => :CASE,
+    'default' => :DEFAULT,
+    'goto'    => :GOTO,
+    'continue' => :CONTINUE,
+    'break'   => :BREAK,
+    'return'  => :RETURN,
+    '__inline__'  => :__INLINE__,
+    'inline'  => :INLINE,
+    '__inline'  => :__INLINE,
+    'Inline'  => :CINLINE,        # inline starting with Capital letter
+    'static'  => :STATIC,
+    'register' => :REGISTER,
+    'auto'    => :AUTO,
+    '__extension__'    => :EXTENSION,
+
+  }
+
+  @@generator_nest = -1
+  @@generator_stack = []
+  @@current_locale = []
+
+  def finalize
+
+    # mikan Namespace.pop
+    Celltype.pop
+    Cell.pop
+    CompositeCelltype.pop
+    Region.pop
+
+  end
+
+  def set_plugin( plugin )
+    @plugin = plugin
+  end
+
+  def self.get_plugin
+    @@generator_stack[@@generator_nest].get_plugin
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def parse(files)
+
+    # mikan Namespace.push
+    Celltype.push
+    Cell.push
+    CompositeCelltype.push
+    Region.push
+
+    @@generator_nest += 1
+    @@generator_stack[@@generator_nest] = self
+    @b_no_type_name = false
+
+   begin
+
+    @q = []
+    comment = false
+
+    # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµãããèª¤ãåé¡ã®å¯¾ç­
+    TECS_LANG::set_kcode_binary
+
+    # 800U, 0xffLL ãªã© (æ´æ°ãªãã©ã«ã«å
+±éã®ä¿®é£¾å­)
+    integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
+
+    files.each {|file|
+      lineno = 1
+     begin
+#2.0       IO.foreach(file) {|line|
+       TECSIO.foreach(file) {|line|
+        col = 1
+        line.rstrip!
+
+        until line.empty?
+
+          if comment
+            case line
+            # ã³ã¡ã³ãçµäº
+            when /\A\*\//
+              comment = false
+            when /\A./
+              ;
+            end
+          else
+            case line
+            # ç©ºç½ãããªãã­ã»ã¹ãã£ã¬ã¯ãã£ã
+            when /\A\s+/
+              ;
+            # è­å¥å­
+            when /\A[a-zA-Z_]\w*/
+              word = $&
+              @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
+            # 16 é²æ°å®æ°
+            when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
+              @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
+            # 8 é²æ°å®æ°
+            when /\A0[0-7]+#{integer_qualifier}/
+              @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
+            # æµ®åå°æ°å®æ°
+            when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
+              @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
+            # æ´æ°å®æ°
+            when /\A\d+#{integer_qualifier}/
+            # when /\A\d+/
+              @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
+            # æå­
+            when /\A'(?:[^'\\]|\\.)'/
+              @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
+            # æå­å
+#              "#include  #include #include \"../systask/logtask.cfg\"       æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã
+#            when /\A"(?:[^"\\]+|\\.)*"/
+            when /\A"(?:[^"\\]|\\.)*"/   # ããã¯ãã¾ãè¡ãããã 
+              @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
+            # è¡ã³ã¡ã³ã
+            when /\A\/\/.*$/
+              # èª­ã¿é£ã°ãã ã
+            # ã³ã¡ã³ãéå§
+            when /\A\/\*/
+              comment = true
+            when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
+              @q << [$&, Token.new($&, file, lineno, col)]
+            when /\A./
+              @q << [$&, Token.new($&, file, lineno, col)]
+            else
+              raise
+            end
+          end
+
+          line = $'
+          col += $&.length
+        end
+
+        lineno += 1
+      }
+
+     rescue => evar
+       Generator.error( "B1002 while open or reading \'$1\'" , file )
+       print_exception( evar )
+     end
+    }
+
+    # çµäºã®å°
+    @q << nil
+
+    @yydebug = true
+    do_parse
+
+   ensure
+    @@generator_nest -= 1
+    TECS_LANG::reset_kcode
+   end
+
+  end
+
+
+  def next_token
+    token = @q.shift
+
+    if token then
+      @@current_locale[@@generator_nest] = token[1].locale
+
+      case token[1].val
+      when ";", ":", ",", "(", ")", "{", "}"
+        set_no_type_name false
+      when ".", "->"
+        set_no_type_name true
+      end
+
+      # TYPE_NAME ãã¼ã¯ã³ã¸ç½®ãæã
+      if @b_no_type_name == false
+        if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
+          token[0] = :TYPE_NAME
+        end
+      end
+
+      if $debug then     # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç) 
+        locale = @@current_locale[@@generator_nest]
+        if token then
+          print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
+        else
+          print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
+        end
+      end
+    end
+
+    token
+  end
+
+  def on_error(t, v, vstack)
+    if v == "$" then
+     Generator.error( "B1003 Unexpected EOF"  )
+    else
+     Generator.error( "B1004 syntax error near \'$1\'" , v.val )
+    end
+
+  end
+
+  def self.current_locale
+    @@current_locale[ @@generator_nest ]
+  end
+
+  @@n_error = 0
+  @@n_warning = 0
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼
+  def self.error( msg )
+    @@n_error += 1
+    locale = @@current_locale[ @@generator_nest ]
+
+    if locale then
+      Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
+    else
+      Console.puts "error: #{msg}"
+    end
+  end
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼
+  def self.warning( msg )
+    @@n_warning += 1
+    locale = @@current_locale[ @@generator_nest ]
+    Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
+  end
+
+  def self.get_n_error
+    @@n_error
+  end
+
+  def self.get_n_warning
+    @@n_warning
+  end
+
+  def self.get_nest
+    @@generator_nest
+  end
+
+  def set_no_type_name b_no_type_name
+    # print "b_no_type_name=#{b_no_type_name}\n"
+    @b_no_type_name = b_no_type_name
+  end
+
+---- footer
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.tab.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.tab.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.tab.rb	(revision 317)
@@ -0,0 +1,4971 @@
+#
+# DO NOT MODIFY!!!!
+# This file is automatically generated by Racc 1.4.12
+# from Racc grammer file "".
+#
+
+require 'racc/parser.rb'
+class Generator < Racc::Parser
+
+module_eval(<<'...end bnf.y.rb/module_eval...', 'bnf.y.rb', 1504)
+
+  RESERVED = {
+    # keyword
+    'namespace' => :NAMESPACE,
+    'signature' => :SIGNATURE,
+    'celltype' => :CELLTYPE,
+    'cell' => :CELL,
+    'attr' => :ATTRIBUTE,
+    'var' => :VAR,
+    'call' => :CALL,
+    'entry' => :ENTRY,
+    'composite' => :COMPOSITE,
+    'require' => :REQUIRE,
+    'factory' => :FACTORY,
+    'FACTORY' => :CTFACTORY,
+    'typedef' => :TYPEDEF,
+    'struct' => :STRUCT,
+    'region' => :REGION,
+    'import' => :IMPORT,
+    'import_C' => :IMPORT_C,
+    'generate' => :GENERATE,
+
+    # types
+    'void'    => :VOID,
+
+    'volatile'=> :VOLATILE,
+    'const'   => :CONST,
+
+    'signed'  => :SIGNED,
+    'unsigned'=> :UNSIGNED,
+
+    'int8_t'    => :INT8_T,
+    'int16_t'   => :INT16_T,
+    'int32_t'   => :INT32_T,
+    'int64_t'   => :INT64_T,
+    'int128_t'  => :INT128_T,
+    'uint8_t'   => :UINT8_T,
+    'uint16_t'  => :UINT16_T,
+    'uint32_t'  => :UINT32_T,
+    'uint64_t'  => :UINT64_T,
+    'uint128_t' => :UINT128_T,
+
+    'float32_t'   => :FLOAT32_T,
+    'double64_t'  => :DOUBLE64_T,
+    'bool_t'      => :BOOL_T,
+    'char_t'  => :CHAR_T,
+    'schar_t'  => :SCHAR_T,
+    'uchar_t'  => :UCHAR_T,
+
+    # unrecommened types
+    'int'     => :INT,
+#   'intptr'  => :INTPTR,
+    'short'   => :SHORT,
+    'long'    => :LONG,
+
+    # obsolete types
+    'char'    => :CHAR,
+#    'int8'    => :INT8,
+#    'int16'   => :INT16,
+#    'int32'   => :INT32,
+#    'int64'   => :INT64,
+#    'int128'  => :INT128,
+#    'float'   => :FLOAT,
+#    'double'  => :DOUBLE,
+#    'bool'    => :BOOL,
+
+    'enum'    => :ENUM,
+    'enum8'   => :ENUM8,
+    'enum16'  => :ENUM16,
+    'enum32'  => :ENUM32,
+    'enum64'  => :ENUM64,
+
+    'true'    => :TRUE,
+    'false'   => :FALSE,
+
+    'C_EXP'   => :C_EXP,
+
+    'Descriptor'   => :DESCRIPTOR,
+
+    # location information for TECSCDE
+    '__location_information__' => :__LOCATION_INFORMATION__,
+    '__cell__' => :__CELL__,
+    '__join__' => :__JOIN__,
+  }
+
+  # æå®å­ '[]' å
+ã§ã®ã¿ä½¿ç¨ã§ããã­ã¼ã¯ã¼ã
+  RESERVED2 = {
+    # specifier
+    'id' => :ID,
+
+    # signature
+    'callback' => :CALLBACK,
+    'context' => :CONTEXT,
+    'deviate' => :DEVIATE,
+
+    # celltype
+    'singleton' => :SINGLETON,
+    'idx_is_id' => :IDX_IS_ID,
+    'active' => :ACTIVE,
+
+    # port (entry)
+    'inline' => :INLINE,
+    'ref_desc' => :REF_DESC,   # call ãå¯
+
+    # port (call)
+    'optional' => :OPTIONAL,
+    'dynamic' => :DYNAMIC,
+
+    # port (call), attribute
+    'omit' => :OMIT,
+
+    # attribute
+    'choice' => :CHOICE,
+
+    # cell
+    'allocator' => :ALLOCATOR,
+    'prototype' => :PROTOTYPE,
+    'restrict'  => :RESTRICT,
+
+    # FuncType
+    'oneway' => :ONEWAY,
+
+    # parameter (basic)
+    'in' => :IN,
+    'out' => :OUT,
+    'inout' => :INOUT,
+    'send' => :SEND,
+    'receive' => :RECEIVE,
+
+    # parameter 
+    'size_is' => :SIZE_IS,
+    'count_is' => :COUNT_IS,
+    'string' => :STRING,
+    'nullable' => :NULLABLE,
+
+    'through' => :THROUGH,
+    'in_through' => :IN_THROUGH,
+    'out_through' => :OUT_THROUGH,
+    'to_through' => :TO_THROUGH,
+
+    'node' => :NODE,
+    'linkunit' => :LINKUNIT ,
+    'domain' => :DOMAIN,
+    'class' => :CLASS,
+  }
+
+  # åå¸°çãªãã¼ãµã®ããã®ã¹ã¿ãã¯
+  @@generator_nest = -1
+  @@generator_stack = []
+  @@current_locale = []
+
+  # import_C ä¸­ã§ãã
+  @@import_C = false
+
+  # ãã¹ã¦ã®æ§æè§£æãå®äºãã
+  @@b_end_all_parse = false
+
+  def self.parse( file_name, plugin = nil, b_reuse = false )
+    # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èª­ã¿è¾¼ã)
+    parser = Generator.new
+
+    # plugin ãã import ããã¦ããå ´åã® plugin è¨­å®
+    parser.set_plugin plugin
+
+    # reuse ãã©ã°ãè¨­å®
+    parser.set_reuse b_reuse
+
+    # cdl ããã¼ã¹
+    parser.parse( [file_name] )
+
+    # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã
+    parser.finalize
+  end
+
+  def finalize
+
+    # mikan Namespace.pop
+    Namespace.pop
+    Signature.pop
+    Celltype.pop
+    Cell.pop
+    CompositeCelltype.pop
+  end
+
+  def set_plugin( plugin )
+    @plugin = plugin
+  end
+
+  def self.get_plugin
+    if @@generator_stack[@@generator_nest] then
+      # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯ nil
+      return @@generator_stack[@@generator_nest].get_plugin
+    else
+      return nil
+    end
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def set_reuse( b_reuse )
+    @b_reuse = b_reuse
+  end
+
+  def self.is_reuse?
+    if @@generator_stack[@@generator_nest] then
+      # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯ nil
+      return @@generator_stack[@@generator_nest].is_reuse?
+    else
+      return false
+    end
+  end
+
+  def is_reuse?
+    @b_reuse
+  end
+
+  def parse(files)
+
+    # mikan Namespace.push
+    Namespace.push
+    Signature.push
+    Celltype.push
+    Cell.push
+    CompositeCelltype.push
+
+    @@generator_nest += 1
+    @@generator_stack[@@generator_nest] = self
+    @in_specifier = false
+
+    begin
+
+      @q = []
+      b_in_comment = false
+      b_in_string = false
+
+      # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµãããèª¤ãåé¡ã®å¯¾ç­
+      TECS_LANG::set_kcode_binary
+
+      files.each {|file|
+        lineno = 1
+        begin
+          string = ""
+#2.0          IO.foreach(file) {|line|
+          TECSIO.foreach(file) {|line|
+            col = 1
+#            line.rstrip!         æ¹è¡å«ãæå­åãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã
+
+            until line.empty?
+
+              if b_in_comment
+                case line
+                  # ã³ã¡ã³ãçµäº
+                when /\A\*\//
+                  b_in_comment = false
+                when /\A./
+                  ;
+                when /\s+/     # line.rstrip! ãæ­¢ãããã \n ãªã©ã®ç©ºç½æå­ã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿
+è¦ã«ãªã£ã
+                  ;
+                end
+              elsif b_in_string
+                if line =~ /\A(?:[^"\\]|\\.)*"/
+                  string = "#{string}#{$&}"
+                  @q <<  [:STRING_LITERAL, Token.new(string, file, lineno, col)]
+                  b_in_string = false
+                elsif line =~ /\A.*\\\n/     # æ¹è¡ \n ã¯ '.' ã«ãããããªã
+                  string += $&
+                elsif line =~ /\A.*\n/     # æ¹è¡ \n ã¯ '.' ã«ãããããªã
+                  string += line
+                  # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èª­åºãå)
+                  puts "error: #{file} line #{lineno}: string literal has newline without escape"
+                  @@n_error += 1
+                end
+              else
+                case line
+                # ç©ºç½ãããªãã­ã»ã¹ãã£ã¬ã¯ãã£ã
+                when /\A\s+/
+                  ;
+                # è­å¥å­
+                when /\A[a-zA-Z_]\w*/
+                  word = $&
+                  @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
+                # 16 é²æ°å®æ°
+                when /\A0x[0-9A-Fa-f]+/
+                  @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
+                # 8 é²æ°å®æ°
+                when /\A0[0-7]+/
+                  @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
+                # æµ®åå°æ°å®æ°
+                when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
+                  @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
+                # æ´æ°å®æ°
+                when /\A\d+/
+                  @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
+                # æå­å®æ°
+                when /\A'(?:[^'\\]|\\.)'/
+                  @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
+                # æå­å
+#                "#include  #include #include \"../systask/logtask.cfg\"       æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã
+#                when /\A"(?:[^"\\]+|\\.)*"/
+                when /\A"(?:[^"\\]|\\.)*"/   # ããã¯ãã¾ãè¡ãããã 
+                  @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
+                # æå­å (æ¹è¡ãã)
+                when /\A"(?:[^"\\]|\\.)*\\\n$/
+                  string = $&
+                  b_in_string = true
+                # æå­å (æ¹è¡ãã, escape ãªã)
+                when /\A("(?:[^"\\]|\e\.)*)\n$/
+                  string = $1 + "\\\n"
+                  b_in_string = true
+                  # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èª­åºãå) # mikan cdl_error ã§ã¯ãªã
+                  puts "error: #{file} line #{lineno}: string literal has newline without escape"
+                  @@n_error += 1
+                # å±±æ¬å¼§ã§å²ã¾ããæå­å
+                when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
+                  @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)]
+                # è¡ã³ã¡ã³ã
+                when /\A\/\/.*$/
+                  # èª­ã¿é£ã°ãã ã
+                # ã³ã¡ã³ãéå§
+                when /\A\/\*/
+                  b_in_comment = true
+                # '>>', '<<' ãªã©
+                when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                when /\A::/, /\A=>/, /\A<=/, /\A>=/
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                # '(', ')' ãªã©ä¸æå­ã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·
+                when /\A./
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                else
+                  raise
+                end
+              end
+
+              line = $'
+              col += $&.length
+            end
+
+            lineno += 1
+          }
+
+        rescue => evar
+          Generator.error( "G1014 while open or reading \'$1\'" , file )
+          if $debug then
+            p puts( evar )
+            pp $@
+          end
+        end
+      }
+
+      # çµäºã®å°
+      @q << nil
+
+      @yydebug = true
+      do_parse
+
+    ensure
+      @@generator_nest -= 1
+      TECS_LANG::reset_kcode
+    end
+
+  end
+
+  def next_token
+    token = @q.shift
+
+    if token then
+      @@current_locale[@@generator_nest] = token[1].locale
+
+      if token[0] == :IDENTIFIER then
+        # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã
+        if Namespace.is_typename?( token[1].val ) then
+          token[0] = :TYPE_NAME
+        elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then
+          # æå®å­ã­ã¼ã¯ã¼ãï¼ '[', ']' å
+ã§ã®ã¿æå¹)
+          token[0] = RESERVED2[ token[1].val.to_s ]
+        end
+      end
+
+      if $debug then     # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç) 
+        locale = @@current_locale[@@generator_nest]
+        if token then
+          print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
+        else
+          print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
+        end
+      end
+    else
+      token = [ false, false ]
+    end
+
+    token
+  end
+
+  def on_error(t, v, vstack)
+    # p t, token_to_str(t), vstack
+    if token_to_str(t) == "$end" then
+      Generator.error( "G1015 Unexpected EOF"  )
+    else
+      Generator.error( "G1016 syntax error near \'$1\'" , v.val )
+    end
+  end
+
+  def self.current_locale
+    @@current_locale[ @@generator_nest ]
+  end
+
+  @@n_error = 0
+  @@n_warning = 0
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼
+  def self.error( msg, *arg )
+    locale = nil
+    self.error2( locale, msg, *arg )
+  end
+
+  def self.error2( locale, msg, *arg )
+    @@n_error += 1
+
+    msg = TECSMsg.get_error_message( msg )
+    # $1, $2, ... ã arg ã§ç½®æ
+    count = 1
+    arg.each{ |a|
+      str = TECSIO.str_code_convert( msg, a.to_s )
+      msg.sub!( /\$#{count}/, str )
+      count += 1
+    }
+
+    # import_C ã®ä¸­ã§ã®ã¨ã©ã¼ï¼
+    if @@import_C then
+      C_parser.error( msg )
+    else
+
+      # Node ã®è¨æ¶ãã ä½ç½® (locale) ãä½¿ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã
+      # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æè§£æä¸­ã®ã¨ã©ã¼
+      # ã¯ãè§£æä¸­ã®ä½ç½®ãåºåããï¼(new_XXX ã§ owner ãå­è¦ç´ ã®ãã§ã
+      # ã¯ãããã¨ owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)
+
+      if @@b_end_all_parse == false || locale == nil then
+        locale = @@current_locale[ @@generator_nest ]
+      end
+      if locale then
+        Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
+      else
+        Console.puts "error: #{msg}"
+      end
+    end
+  end
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼
+  def self.warning( msg, *arg )
+    locale = nil
+    self.warning2( locale, msg, *arg )
+  end
+
+  def self.warning2( locale, msg, *arg )
+    @@n_warning += 1
+
+    msg = TECSMsg.get_warning_message( msg )
+    # $1, $2, ... ã arg ã§ç½®æ
+    count = 1
+    arg.each{ |a|
+      str = TECSIO.str_code_convert( msg, a.to_s )
+      msg.sub!( /\$#{count}/, str )
+      count += 1
+    }
+
+    # import_C ã®ä¸­ã§ã®ã¦ã©ã¼ãã³ã°ï¼
+    if @@import_C then
+      C_parser.warning( msg )
+    else
+      if @@b_end_all_parse == false || locale == nil then
+        locale = @@current_locale[ @@generator_nest ]
+      end
+      if locale then
+        Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
+      else
+        Console.puts "warning: #{msg}"
+      end
+    end
+  end
+
+  def self.get_n_error
+    @@n_error
+  end
+
+  def self.get_n_warning
+    @@n_warning
+  end
+
+  def self.get_nest
+    @@generator_nest
+  end
+
+  #===  '[' specifier å§ã
+  def set_in_specifier
+    # p "set_in_specifier"
+    @in_specifier = true
+  end
+
+  #=== ']' specifier çµãã
+  def unset_in_specifier
+    # p "unset_in_specifier"
+    @in_specifier = false
+  end
+
+  # statement_specifier ã¯æ§æè§£ééä¸­ã§åç
+§ããããã
+  @@statement_specifier_stack = []
+  def self.add_statement_specifier( ss )
+    if( @@statement_specifier_stack[ @@generator_nest ] == nil )then
+      @@statement_specifier_stack[ @@generator_nest ] = [ ss ]
+    else
+      @@statement_specifier_stack[ @@generator_nest ] << ss
+    end
+  end
+
+
+  def self.get_statement_specifier
+    spec_list = @@statement_specifier_stack[ @@generator_nest ]
+    @@statement_specifier_stack[ @@generator_nest ] = nil
+    return spec_list
+  end
+
+  #=== ãã¹ã¦ã®æ§æè§£æãå®äºãããã¨ãå ±å
+  def self.end_all_parse
+    @@b_end_all_parse = true
+  end
+
+...end bnf.y.rb/module_eval...
+##### State transition tables begin ###
+
+clist = [
+'65,566,323,779,733,806,77,346,347,323,77,77,77,160,194,195,196,197,198',
+'199,200,202,174,203,664,133,860,133,99,207,208,209,210,211,212,213,663',
+'244,831,551,394,512,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25',
+'26,27,28,29,30,31,32,33,34,35,38,678,395,459,309,696,42,43,44,45,46',
+'47,48,49,858,98,654,827,440,133,133,826,133,133,133,133,133,65,186,186',
+'186,186,69,67,68,308,70,71,77,72,323,73,299,300,319,819,133,175,133',
+'134,320,134,322,186,74,74,74,75,76,76,76,133,86,186,186,186,186,78,85',
+'5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32',
+'33,34,35,38,77,420,186,358,359,42,43,44,45,46,47,48,49,186,134,134,134',
+'65,134,134,134,134,134,133,133,87,571,77,77,570,323,69,67,68,325,70',
+'71,133,72,799,73,530,134,341,134,299,300,319,342,343,397,798,682,320',
+'74,322,75,134,76,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
+'27,28,29,30,31,32,33,34,35,38,444,48,49,352,353,42,43,44,45,46,47,48',
+'49,328,329,509,510,65,299,300,301,186,302,303,305,306,683,606,77,134',
+'134,69,67,68,856,70,71,272,72,607,73,77,177,134,643,299,300,319,77,77',
+'636,203,780,320,74,322,75,684,76,5,6,7,10,13,14,15,16,17,18,19,20,21',
+'22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,795,160,610,676,855,42',
+'43,44,45,46,47,48,49,160,637,403,470,86,160,471,633,426,781,85,793,470',
+'87,87,471,502,705,69,67,68,758,70,71,397,72,396,73,159,625,402,194,195',
+'196,197,198,199,200,202,614,203,74,792,75,133,76,207,208,209,210,211',
+'212,213,299,300,301,160,302,303,305,306,194,195,196,197,198,199,200',
+'202,160,203,624,609,283,133,626,207,208,209,210,211,212,213,867,742',
+'809,194,195,196,197,198,199,200,202,335,203,336,159,337,133,229,207',
+'208,209,210,211,212,213,194,195,196,197,198,199,200,202,810,203,251',
+'160,230,133,409,207,208,209,210,211,212,213,229,649,707,666,400,837',
+'79,134,496,277,676,251,571,704,846,570,160,539,845,393,230,848,596,408',
+'818,229,748,147,619,630,146,706,648,684,667,401,838,134,761,495,278',
+'675,250,705,167,230,620,229,86,847,760,86,817,86,85,177,618,85,87,85',
+'341,87,134,87,270,342,343,230,632,177,194,195,196,197,198,199,200,202',
+'173,203,614,744,869,133,134,207,208,209,210,211,212,213,194,195,196',
+'197,198,199,200,202,147,203,650,146,651,133,172,207,208,209,210,211',
+'212,213,194,195,196,197,198,199,200,202,171,203,388,389,390,133,170',
+'207,208,209,210,211,212,213,194,195,196,197,198,199,200,202,169,203',
+'388,389,390,133,659,207,208,209,210,211,212,213,348,349,350,351,194',
+'195,196,197,198,199,200,202,168,203,583,330,660,133,134,207,208,209',
+'210,211,212,213,194,195,196,197,198,199,200,202,661,203,344,345,165',
+'133,134,207,208,209,210,211,212,213,194,195,196,197,198,199,200,202',
+'164,203,282,283,665,133,134,207,208,209,210,211,212,213,194,195,196',
+'197,198,199,200,202,668,203,352,353,670,133,134,207,208,209,210,211',
+'212,213,348,349,350,351,194,195,196,197,198,199,200,202,431,203,346',
+'347,671,133,134,207,208,209,210,211,212,213,672,448,673,376,377,378',
+'430,432,433,434,435,431,346,347,134,371,372,373,374,375,379,229,450',
+'451,452,449,348,349,350,351,674,430,432,433,434,435,134,341,142,143',
+'677,230,342,343,194,195,196,197,198,199,200,202,163,203,346,347,203',
+'133,134,207,208,209,210,211,212,213,346,347,344,345,194,195,196,197',
+'198,199,200,202,680,203,344,345,162,133,134,207,208,209,210,211,212',
+'213,194,195,196,197,198,199,200,202,161,203,398,330,689,133,160,207',
+'208,209,210,211,212,213,194,195,196,197,198,199,200,202,691,203,719',
+'510,692,133,693,207,208,209,210,211,212,213,194,195,196,197,198,199',
+'200,202,160,203,376,377,378,133,134,207,208,209,210,211,212,213,371',
+'372,373,374,375,379,102,103,104,105,106,107,108,109,110,111,112,695',
+'134,697,698,699,700,703,708,229,20,21,22,23,24,25,26,27,28,29,30,31',
+'32,33,134,711,562,74,714,230,715,716,194,195,196,197,198,199,200,202',
+'717,203,157,744,720,133,134,207,208,209,210,211,212,213,194,195,196',
+'197,198,199,200,202,721,203,722,599,724,133,134,207,208,209,210,211',
+'212,213,194,195,196,197,198,199,200,202,725,203,726,728,614,133,731',
+'207,208,209,210,211,212,213,194,195,196,197,198,199,200,202,732,203',
+'156,153,736,133,152,207,208,209,210,211,212,213,739,743,751,752,194',
+'195,196,197,198,199,200,202,144,203,754,576,755,133,134,207,208,209',
+'210,211,212,213,194,195,196,197,198,199,200,202,757,203,759,762,763',
+'133,134,207,208,209,210,211,212,213,194,195,196,197,198,199,200,202',
+'764,203,767,768,769,133,134,207,208,209,210,211,212,213,194,195,196',
+'197,198,199,200,202,770,203,643,232,703,133,134,207,208,209,210,211',
+'212,213,86,86,86,229,177,775,85,85,85,86,87,87,87,776,86,85,777,778',
+'134,87,85,141,711,230,87,786,194,195,196,197,198,199,200,202,140,203',
+'788,138,132,133,134,207,208,209,210,211,212,213,194,195,196,197,198',
+'199,200,202,791,203,130,796,128,133,134,207,208,209,210,211,212,213',
+'194,195,196,197,198,199,200,202,800,203,801,-383,802,133,134,207,208',
+'209,210,211,212,213,194,195,196,197,198,199,200,202,803,203,804,124',
+'123,133,807,207,208,209,210,211,212,213,767,203,813,816,194,195,196',
+'197,198,199,200,202,821,203,822,94,824,133,134,207,208,209,210,211,212',
+'213,194,195,196,197,198,199,200,202,828,203,829,830,90,133,134,207,208',
+'209,210,211,212,213,194,195,196,197,198,199,200,202,833,203,834,89,836',
+'133,134,207,208,209,210,211,212,213,194,195,196,197,198,199,200,202',
+'798,203,839,840,323,133,134,207,208,209,210,211,212,213,842,843,844',
+'849,194,195,196,197,198,199,200,202,850,203,851,88,857,133,134,207,208',
+'209,210,211,212,213,194,195,196,197,198,199,200,202,357,203,356,362',
+'363,133,134,207,208,209,210,211,212,213,194,195,196,197,198,199,200',
+'202,365,203,366,122,861,133,134,207,208,209,210,211,212,213,194,195',
+'196,197,198,199,200,202,3,203,156,355,399,133,134,207,208,209,210,211',
+'212,213,404,140,406,407,194,195,196,197,198,199,200,202,410,203,411',
+'412,413,133,134,207,208,209,210,211,212,213,194,195,196,197,198,199',
+'200,202,414,203,415,354,862,133,134,207,208,209,210,211,212,213,194',
+'195,196,197,198,199,200,202,438,203,439,442,453,133,134,207,208,209',
+'210,211,212,213,194,195,196,197,198,199,200,202,330,203,456,457,186',
+'133,134,207,208,209,210,211,212,213,464,465,466,473,194,195,196,197',
+'198,199,200,202,474,203,307,285,284,133,134,207,208,209,210,211,212',
+'213,194,195,196,197,198,199,200,202,281,203,280,279,276,133,134,207',
+'208,209,210,211,212,213,194,195,196,197,198,199,200,202,275,203,274',
+'267,177,133,134,207,208,209,210,211,212,213,194,195,196,197,198,199',
+'200,202,265,203,203,259,203,133,134,207,208,209,210,211,212,213,156',
+'503,504,505,194,195,196,197,198,199,200,202,506,203,507,863,513,133',
+'134,207,208,209,210,211,212,213,194,195,196,197,198,199,200,202,514',
+'203,515,259,517,133,134,207,208,209,210,211,212,213,86,86,86,86,252',
+'265,85,85,85,85,87,87,87,87,134,299,300,301,520,302,303,305,306,521',
+'194,195,196,197,198,199,200,202,203,203,524,203,134,133,203,207,208',
+'209,210,211,212,213,177,528,194,195,196,197,198,199,200,202,529,203',
+'532,533,534,133,134,207,208,209,210,211,212,213,115,116,117,118,119',
+'120,121,115,116,117,118,119,120,121,134,536,537,540,186,5,6,7,10,13',
+'14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38',
+'265,865,550,554,160,42,43,44,45,46,47,48,49,134,194,195,196,197,198',
+'199,200,202,556,203,866,186,560,133,562,207,208,209,210,211,212,213',
+'323,134,565,87,242,190,578,579,354,355,356,357,580,189,188,186,185,184',
+'183,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
+'32,33,34,35,38,182,181,596,597,599,42,43,44,45,46,47,48,49,194,195,196',
+'197,198,199,200,202,600,203,330,601,603,133,604,207,208,209,210,211',
+'212,213,605,,134,194,195,196,197,198,199,200,339,,203,,,,133,,207,208',
+'209,210,211,212,213,194,195,196,197,198,199,200,202,,203,,685,,133,',
+'207,208,209,210,211,212,213,194,195,196,197,198,199,200,202,,203,,,',
+'133,,207,208,209,210,211,212,213,,194,195,196,197,198,199,200,202,,203',
+',576,,133,134,207,208,209,210,211,212,213,,,,194,195,196,197,198,199',
+'200,202,,203,,655,,133,134,207,208,209,210,211,212,213,194,195,196,197',
+'198,199,200,202,,203,,,,133,134,207,208,209,210,211,212,213,194,195',
+'196,197,198,199,200,202,,203,,,,133,134,207,208,209,210,211,212,213',
+',194,195,196,197,198,199,200,202,,203,,,,133,134,207,208,209,210,211',
+'212,213,,,,194,195,196,197,198,199,200,202,,203,,,,133,134,207,208,209',
+'210,211,212,213,194,195,196,197,198,199,200,202,,203,,,,133,134,207',
+'208,209,210,211,212,213,194,195,196,197,198,199,200,202,,203,,,,133',
+'134,207,208,209,210,211,212,213,,194,195,196,197,198,199,200,202,,203',
+',,,133,134,207,208,209,210,211,212,213,,,,194,195,196,197,198,199,200',
+'202,,203,,,,133,134,207,208,209,210,211,212,213,102,103,104,105,106',
+'107,108,109,110,111,112,,,,134,,,,,,,,,,,,,,,,,,,,,,134,,115,116,117',
+'118,119,120,121,,,229,581,,,470,574,,573,,,,,134,,87,,,,,,230,,,,,,',
+',,,,,,,,,,134,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
+'28,29,30,31,32,33,34,35,38,236,,77,,,42,43,44,45,46,47,48,49,,,,,,,',
+',,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
+'29,30,31,32,33,34,35,38,657,,77,,,42,43,44,45,46,47,48,49,,,,,,,,,,',
+',,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29',
+'30,31,32,33,34,35,38,77,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,',
+',,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
+'32,33,34,35,38,77,,,,,42,43,44,45,46,47,48,49,498,,,,,,,,,,,,,,,,,,5',
+'6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33',
+'34,35,38,126,381,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7',
+'10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34',
+'35,38,77,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14',
+'15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,77',
+',,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17',
+'18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,77,,,,,42,43',
+'44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20',
+'21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,77,422,,,,42,43,44,45',
+'46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22',
+'23,24,25,26,27,28,29,30,31,32,33,34,35,38,77,508,,,,42,43,44,45,46,47',
+'48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
+'25,26,27,28,29,30,31,32,33,34,35,38,77,,,,,42,43,44,45,46,47,48,49,',
+',,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
+'27,28,29,30,31,32,33,34,35,38,77,,,,,42,43,44,45,46,47,48,49,,,,,,,',
+',,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
+'29,30,31,32,33,34,35,38,77,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,',
+',,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30',
+'31,32,33,34,35,38,77,621,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,',
+',,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
+'32,33,34,35,38,77,627,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5',
+'6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33',
+'34,35,38,,646,,,,42,43,44,45,46,47,48,49,102,103,104,105,106,107,108',
+'109,110,111,112,,,,,,,,,,,,,,,,,,,,,,,,,,,,115,116,117,118,119,120,121',
+'5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32',
+'33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18',
+'19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44',
+'45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
+'28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13',
+'14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38',
+',,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22',
+'23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48',
+'49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
+'32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17',
+'18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43',
+'44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
+'27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47' ]
+        racc_action_table = arr = ::Array.new(3597, nil)
+        idx = 0
+        clist.each do |str|
+          str.split(',', -1).each do |i|
+            arr[idx] = i.to_i unless i.empty?
+            idx += 1
+          end
+        end
+
+clist = [
+'2,463,803,749,688,787,189,218,218,189,602,2,324,386,714,714,714,714',
+'714,714,714,714,123,714,586,754,854,714,41,714,714,714,714,714,714,714',
+'585,151,815,441,257,386,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2',
+'2,2,2,2,2,2,602,257,324,187,631,2,2,2,2,2,2,2,2,854,41,567,810,303,298',
+'550,810,90,620,328,74,320,286,749,688,787,463,2,2,2,187,2,2,286,2,555',
+'2,189,189,189,803,799,123,504,754,189,714,189,586,602,2,324,2,602,2',
+'324,503,83,815,441,585,151,2,83,286,286,286,286,286,286,286,286,286',
+'286,286,286,286,286,286,286,286,286,286,286,286,286,286,286,286,286',
+'286,286,184,286,631,225,225,286,286,286,286,286,286,286,286,567,303',
+'298,550,158,90,620,328,74,320,281,706,87,469,310,158,469,310,286,286',
+'286,191,286,286,464,286,776,286,416,799,480,504,555,555,555,480,480',
+'614,776,614,555,286,555,286,503,286,158,158,158,158,158,158,158,158',
+'158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158,158',
+'158,158,158,310,87,87,220,220,158,158,158,158,158,158,158,158,191,191',
+'383,383,182,184,184,184,416,184,184,184,184,615,528,182,281,706,158',
+'158,158,852,158,158,169,158,529,158,553,169,464,553,310,310,310,289',
+'750,552,530,750,310,158,310,158,615,158,182,182,182,182,182,182,182',
+'182,182,182,182,182,182,182,182,182,182,182,182,182,182,182,182,182',
+'182,182,182,182,772,369,535,723,852,182,182,182,182,182,182,182,182',
+'100,553,264,334,125,536,334,552,289,750,125,765,468,334,125,468,369',
+'772,182,182,182,723,182,182,259,182,259,182,100,545,264,705,705,705',
+'705,705,705,705,705,540,705,182,765,182,705,182,705,705,705,705,705',
+'705,705,289,289,289,701,289,289,289,289,761,761,761,761,761,761,761',
+'761,564,761,545,531,531,761,545,761,761,761,761,761,761,761,865,701',
+'794,760,760,760,760,760,760,760,760,205,760,205,564,205,760,705,760',
+'760,760,760,760,760,760,720,720,720,720,720,720,720,720,794,720,253',
+'428,705,720,273,720,720,720,720,720,720,720,761,559,645,588,262,825',
+'3,705,360,173,598,154,569,642,838,569,113,428,838,253,761,839,728,273',
+'801,760,705,145,541,549,145,642,559,645,588,262,825,761,728,360,173',
+'598,154,642,113,760,541,720,681,839,728,510,801,283,681,124,541,510',
+'681,283,479,510,760,283,168,479,479,720,551,168,704,704,704,704,704',
+'704,704,704,122,704,556,704,868,704,720,704,704,704,704,704,704,704',
+'699,699,699,699,699,699,699,699,84,699,561,84,563,699,121,699,699,699',
+'699,699,699,699,695,695,695,695,695,695,695,695,120,695,512,512,512',
+'695,117,695,695,695,695,695,695,695,691,691,691,691,691,691,691,691',
+'116,691,249,249,249,691,572,691,691,691,691,691,691,691,219,219,219',
+'219,667,667,667,667,667,667,667,667,115,667,497,497,575,667,704,667',
+'667,667,667,667,667,667,285,285,285,285,285,285,285,285,577,285,217',
+'217,112,285,699,285,285,285,285,285,285,285,252,252,252,252,252,252',
+'252,252,108,252,178,178,587,252,695,252,252,252,252,252,252,252,229',
+'229,229,229,229,229,229,229,589,229,489,489,593,229,691,229,229,229',
+'229,229,229,229,488,488,488,488,861,861,861,861,861,861,861,861,539',
+'861,486,486,594,861,667,861,861,861,861,861,861,861,595,313,596,241',
+'241,241,539,539,539,539,539,292,485,485,285,241,241,241,241,241,241',
+'229,313,313,313,313,487,487,487,487,597,292,292,292,292,292,252,216',
+'80,80,600,229,216,216,848,848,848,848,848,848,848,848,106,848,484,484',
+'605,848,229,848,848,848,848,848,848,848,483,483,482,482,821,821,821',
+'821,821,821,821,821,608,821,481,481,104,821,861,821,821,821,821,821',
+'821,821,818,818,818,818,818,818,818,818,102,818,260,260,621,818,623',
+'818,818,818,818,818,818,818,807,807,807,807,807,807,807,807,625,807',
+'669,669,626,807,627,807,807,807,807,807,807,807,798,798,798,798,798',
+'798,798,798,629,798,502,502,502,798,848,798,798,798,798,798,798,798',
+'502,502,502,502,502,502,159,159,159,159,159,159,159,159,159,159,159',
+'630,821,632,633,635,637,640,646,807,36,36,36,36,36,36,36,36,36,36,36',
+'36,36,36,818,650,651,652,653,807,654,656,795,795,795,795,795,795,795',
+'795,658,795,99,795,673,795,807,795,795,795,795,795,795,795,786,786,786',
+'786,786,786,786,786,674,786,676,677,678,786,798,786,786,786,786,786',
+'786,786,775,775,775,775,775,775,775,775,679,775,680,682,684,775,685',
+'775,775,775,775,775,775,775,770,770,770,770,770,770,770,770,686,770',
+'98,93,692,770,92,770,770,770,770,770,770,770,696,703,710,712,471,471',
+'471,471,471,471,471,471,82,471,715,471,718,471,795,471,471,471,471,471',
+'471,471,144,144,144,144,144,144,144,144,721,144,727,732,733,144,786',
+'144,144,144,144,144,144,144,466,466,466,466,466,466,466,466,735,466',
+'736,738,739,466,775,466,466,466,466,466,466,466,146,146,146,146,146',
+'146,146,146,740,146,741,146,742,146,770,146,146,146,146,146,146,146',
+'240,86,4,144,743,744,240,86,4,591,240,86,4,745,418,591,747,748,471,591',
+'418,78,752,144,418,753,867,867,867,867,867,867,867,867,76,867,757,75',
+'73,867,144,867,867,867,867,867,867,867,397,397,397,397,397,397,397,397',
+'763,397,72,774,71,397,466,397,397,397,397,397,397,397,359,359,359,359',
+'359,359,359,359,778,359,779,780,781,359,146,359,359,359,359,359,359',
+'359,358,358,358,358,358,358,358,358,784,358,785,69,68,358,788,358,358',
+'358,358,358,358,358,793,796,797,800,357,357,357,357,357,357,357,357',
+'805,357,806,38,809,357,867,357,357,357,357,357,357,357,163,163,163,163',
+'163,163,163,163,811,163,812,814,16,163,397,163,163,163,163,163,163,163',
+'356,356,356,356,356,356,356,356,819,356,820,9,822,356,359,356,356,356',
+'356,356,356,356,355,355,355,355,355,355,355,355,828,355,831,832,833',
+'355,358,355,355,355,355,355,355,355,835,836,837,840,354,354,354,354',
+'354,354,354,354,841,354,842,8,853,354,357,354,354,354,354,354,354,354',
+'353,353,353,353,353,353,353,353,224,353,223,230,231,353,163,353,353',
+'353,353,353,353,353,352,352,352,352,352,352,352,352,235,352,237,67,856',
+'352,356,352,352,352,352,352,352,352,351,351,351,351,351,351,351,351',
+'1,351,251,222,261,351,355,351,351,351,351,351,351,351,266,267,269,271',
+'350,350,350,350,350,350,350,350,275,350,276,277,278,350,354,350,350',
+'350,350,350,350,350,349,349,349,349,349,349,349,349,279,349,280,221',
+'857,349,353,349,349,349,349,349,349,349,348,348,348,348,348,348,348',
+'348,301,348,302,304,319,348,352,348,348,348,348,348,348,348,347,347',
+'347,347,347,347,347,347,201,347,321,322,193,347,351,347,347,347,347',
+'347,347,347,329,331,332,336,346,346,346,346,346,346,346,346,337,346',
+'186,181,180,346,350,346,346,346,346,346,346,346,345,345,345,345,345',
+'345,345,345,176,345,175,174,172,345,349,345,345,345,345,345,345,345',
+'344,344,344,344,344,344,344,344,171,344,170,166,165,344,348,344,344',
+'344,344,344,344,344,343,343,343,343,343,343,343,343,164,343,162,161',
+'362,343,347,343,343,343,343,343,343,343,157,374,375,376,342,342,342',
+'342,342,342,342,342,377,342,378,860,388,342,346,342,342,342,342,342',
+'342,342,341,341,341,341,341,341,341,341,389,341,390,395,396,341,345',
+'341,341,341,341,341,341,341,424,367,248,143,156,401,424,367,248,143',
+'424,367,248,143,344,538,538,538,402,538,538,538,538,403,335,335,335',
+'335,335,335,335,335,404,335,405,406,343,335,407,335,335,335,335,335',
+'335,335,408,410,339,339,339,339,339,339,339,339,413,339,419,420,422',
+'339,342,339,339,339,339,339,339,339,255,255,255,255,255,255,255,167',
+'167,167,167,167,167,167,341,425,426,431,436,339,339,339,339,339,339',
+'339,339,339,339,339,339,339,339,339,339,339,339,339,339,339,339,339',
+'339,339,339,339,339,437,863,440,444,446,339,339,339,339,339,339,339',
+'339,335,202,202,202,202,202,202,202,202,448,202,864,454,455,202,456',
+'202,202,202,202,202,202,202,457,339,459,149,148,139,472,475,490,491',
+'492,493,494,137,136,135,134,131,129,202,202,202,202,202,202,202,202',
+'202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202',
+'202,202,202,127,126,517,518,520,202,202,202,202,202,202,202,202,206',
+'206,206,206,206,206,206,206,521,206,522,523,525,206,526,206,206,206',
+'206,206,206,206,527,,202,207,207,207,207,207,207,207,207,,207,,,,207',
+',207,207,207,207,207,207,207,619,619,619,619,619,619,619,619,,619,,619',
+',619,,619,619,619,619,619,619,619,580,580,580,580,580,580,580,580,,580',
+',,,580,,580,580,580,580,580,580,580,,573,573,573,573,573,573,573,573',
+',573,,573,,573,206,573,573,573,573,573,573,573,,,,570,570,570,570,570',
+'570,570,570,,570,,570,,570,207,570,570,570,570,570,570,570,566,566,566',
+'566,566,566,566,566,,566,,,,566,619,566,566,566,566,566,566,566,515',
+'515,515,515,515,515,515,515,,515,,,,515,580,515,515,515,515,515,515',
+'515,,514,514,514,514,514,514,514,514,,514,,,,514,573,514,514,514,514',
+'514,514,514,,,,513,513,513,513,513,513,513,513,,513,,,,513,570,513,513',
+'513,513,513,513,513,507,507,507,507,507,507,507,507,,507,,,,507,566',
+'507,507,507,507,507,507,507,506,506,506,506,506,506,506,506,,506,,,',
+'506,515,506,506,506,506,506,506,506,,505,505,505,505,505,505,505,505',
+',505,,,,505,514,505,505,505,505,505,505,505,,,,496,496,496,496,496,496',
+'496,496,,496,,,,496,513,496,496,496,496,496,496,496,458,458,458,458',
+'458,458,458,458,458,458,458,,,,507,,,,,,,,,,,,,,,,,,,,,,506,,458,458',
+'458,458,458,458,458,,,496,496,,,470,470,,470,,,,,505,,470,,,,,,496,',
+',,,,,,,,,,,,,,,496,470,470,470,470,470,470,470,470,470,470,470,470,470',
+'470,470,470,470,470,470,470,470,470,470,470,470,470,470,470,147,,147',
+',,470,470,470,470,470,470,470,470,,,,,,,,,,,,,,,,,,,,,147,147,147,147',
+'147,147,147,147,147,147,147,147,147,147,147,147,147,147,147,147,147',
+'147,147,147,147,147,147,147,571,,571,,,147,147,147,147,147,147,147,147',
+',,,,,,,,,,,,,,,,,,,,571,571,571,571,571,571,571,571,571,571,571,571',
+'571,571,571,571,571,571,571,571,571,571,571,571,571,571,571,571,366',
+',,,,571,571,571,571,571,571,571,571,,,,,,,,,,,,,,,,,,,366,366,366,366',
+'366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366,366',
+'366,366,366,366,366,366,366,246,,,,,366,366,366,366,366,366,366,366',
+'366,,,,,,,,,,,,,,,,,,246,246,246,246,246,246,246,246,246,246,246,246',
+'246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,246,70,246',
+',,,246,246,246,246,246,246,246,246,,,,,,,,,,,,,,,,,,,70,70,70,70,70',
+'70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70',
+'153,,,,,70,70,70,70,70,70,70,70,,,,,,,,,,,,,,,,,,,153,153,153,153,153',
+'153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153,153',
+'153,153,153,153,153,153,245,,,,,153,153,153,153,153,153,153,153,,,,',
+',,,,,,,,,,,,,,245,245,245,245,245,245,245,245,245,245,245,245,245,245',
+'245,245,245,245,245,245,245,245,245,245,245,245,245,245,288,,,,,245',
+'245,245,245,245,245,245,245,,,,,,,,,,,,,,,,,,,288,288,288,288,288,288',
+'288,288,288,288,288,288,288,288,288,288,288,288,288,288,288,288,288',
+'288,288,288,288,288,380,288,,,,288,288,288,288,288,288,288,288,,,,,',
+',,,,,,,,,,,,,380,380,380,380,380,380,380,380,380,380,380,380,380,380',
+'380,380,380,380,380,380,380,380,380,380,380,380,380,380,438,380,,,,380',
+'380,380,380,380,380,380,380,,,,,,,,,,,,,,,,,,,438,438,438,438,438,438',
+'438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438,438',
+'438,438,438,438,438,439,,,,,438,438,438,438,438,438,438,438,,,,,,,,',
+',,,,,,,,,,439,439,439,439,439,439,439,439,439,439,439,439,439,439,439',
+'439,439,439,439,439,439,439,439,439,439,439,439,439,453,,,,,439,439',
+'439,439,439,439,439,439,,,,,,,,,,,,,,,,,,,453,453,453,453,453,453,453',
+'453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453,453',
+'453,453,453,453,542,,,,,453,453,453,453,453,453,453,453,,,,,,,,,,,,',
+',,,,,,542,542,542,542,542,542,542,542,542,542,542,542,542,542,542,542',
+'542,542,542,542,542,542,542,542,542,542,542,542,546,542,,,,542,542,542',
+'542,542,542,542,542,,,,,,,,,,,,,,,,,,,546,546,546,546,546,546,546,546',
+'546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546,546',
+'546,546,546,557,546,,,,546,546,546,546,546,546,546,546,,,,,,,,,,,,,',
+',,,,,557,557,557,557,557,557,557,557,557,557,557,557,557,557,557,557',
+'557,557,557,557,557,557,557,557,557,557,557,557,,557,,,,557,557,557',
+'557,557,557,557,557,53,53,53,53,53,53,53,53,53,53,53,,,,,,,,,,,,,,,',
+',,,,,,,,,,,,53,53,53,53,53,53,53,694,694,694,694,694,694,694,694,694',
+'694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694,694',
+'694,694,,,,,,694,694,694,694,694,694,694,694,690,690,690,690,690,690',
+'690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690,690',
+'690,690,690,690,690,,,,,,690,690,690,690,690,690,690,690,239,239,239',
+'239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239',
+'239,239,239,239,239,239,239,239,,,,,,239,239,239,239,239,239,239,239',
+'40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40',
+'40,40,40,40,40,,,,,,40,40,40,40,40,40,40,40,284,284,284,284,284,284',
+'284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284',
+'284,284,284,284,284,,,,,,284,284,284,284,284,284,284,284,511,511,511',
+'511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511,511',
+'511,511,511,511,511,511,511,511,,,,,,511,511,511,511,511,511,511,511',
+'611,611,611,611,611,611,611,611,611,611,611,611,611,611,611,611,611',
+'611,611,611,611,611,611,611,611,611,611,611,,,,,,611,611,611,611,611',
+'611,611,611,234,234,234,234,234,234,234,234,234,234,234,234,234,234',
+'234,234,234,234,234,234,234,234,234,234,234,234,234,234,,,,,,234,234',
+'234,234,234,234' ]
+        racc_action_check = arr = ::Array.new(3597, nil)
+        idx = 0
+        clist.each do |str|
+          str.split(',', -1).each do |i|
+            arr[idx] = i.to_i unless i.empty?
+            idx += 1
+          end
+        end
+
+racc_action_pointer = [
+   nil,  1429,    -1,   489,  1138,   nil,   nil,   nil,  1326,  1278,
+   nil,   nil,   nil,   nil,   nil,   nil,  1288,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   889,   nil,  1259,   nil,
+  3351,    13,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,  3134,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,  1401,  1240,  1239,
+  2552,  1190,  1188,  1168,    79,  1167,  1164,   nil,  1095,   nil,
+   757,   nil,  1023,   122,   574,   nil,  1137,   172,   nil,   nil,
+    76,   nil,   974,   971,   nil,   nil,   nil,   nil,  1026,   904,
+   340,   nil,   850,   nil,   832,   nil,   802,   nil,   688,   nil,
+   nil,   nil,   670,   486,   nil,   644,   618,   602,   nil,   nil,
+   596,   580,   550,    11,   523,   348,  1803,  1804,   nil,  1775,
+   nil,  1774,   nil,   nil,  1829,  1735,  1827,  1770,   nil,  1762,
+   nil,   nil,   nil,  1669,  1077,   501,  1121,  2314,  1822,  1812,
+   nil,    27,   nil,  2611,   453,   nil,  1637,  1612,   182,   831,
+   nil,  1601,  1604,  1283,  1598,  1580,  1465,  1622,   537,   280,
+  1578,  1576,  1558,   482,  1562,  1561,  1528,   nil,   659,   nil,
+  1538,  1541,   269,   nil,   154,   nil,  1534,    33,   nil,    -6,
+   nil,   128,   nil,  1417,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,  1510,  1804,   nil,   nil,   435,  1886,  1911,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   777,   657,   -19,   613,
+   224,  1462,  1398,  1352,  1349,   132,   nil,   nil,   nil,   709,
+  1379,  1376,   nil,   nil,  3515,  1397,   nil,  1368,   nil,  3310,
+  1136,   689,   nil,   nil,   nil,  2670,  2493,   nil,  1668,   556,
+   nil,  1416,   687,   430,   nil,  1615,   nil,    30,   nil,   365,
+   851,  1423,   477,   nil,   341,   nil,  1402,  1429,   nil,  1404,
+   nil,  1405,   nil,   465,   nil,  1414,  1447,  1418,  1448,  1437,
+  1439,   174,   nil,   527,  3392,   665,    95,   nil,  2729,   289,
+   nil,   nil,   678,   nil,   nil,   nil,   nil,   nil,    73,   nil,
+   nil,  1428,  1430,    72,  1431,   nil,   nil,   nil,   nil,   nil,
+   181,   nil,   nil,   668,   nil,   nil,   nil,   nil,   nil,  1432,
+    80,  1395,  1510,   nil,     0,   nil,   nil,   nil,    78,  1526,
+   nil,  1526,  1527,   nil,   347,  1697,  1523,  1532,   nil,  1721,
+   nil,  1651,  1629,  1603,  1581,  1559,  1537,  1511,  1489,  1467,
+  1445,  1419,  1397,  1375,  1353,  1327,  1305,  1261,  1235,  1213,
+   450,   nil,  1606,   nil,   nil,   nil,  2434,  1667,   nil,   328,
+   nil,   nil,   nil,   nil,  1619,  1620,  1621,  1630,  1632,   nil,
+  2788,   nil,   nil,   228,   nil,   nil,     0,   nil,  1634,  1652,
+  1654,   nil,   nil,   nil,   nil,  1649,  1650,  1191,   nil,   nil,
+   nil,  1665,  1622,  1683,  1696,  1638,  1699,  1702,  1706,   nil,
+  1711,   nil,   nil,  1721,   nil,   nil,   166,   nil,  1150,  1723,
+  1694,   nil,  1695,   nil,  1666,  1650,  1721,   nil,   459,   nil,
+   nil,  1753,   nil,   nil,   nil,   nil,  1655,  1777,  2847,  2906,
+  1752,    25,   nil,   nil,  1755,   nil,  1783,   nil,  1805,   nil,
+   nil,   nil,   nil,  2965,  1709,  1803,  1805,  1813,  2119,  1790,
+   nil,   nil,   nil,    -8,   188,   nil,  1099,   nil,   356,   183,
+  2253,  1055,  1821,   nil,   nil,  1825,   nil,   nil,   nil,   524,
+   190,   819,   807,   799,   787,   745,   721,   757,   705,   689,
+  1818,  1803,  1803,  1803,  1801,   nil,  2187,   645,   nil,   nil,
+   nil,   nil,   832,   115,   102,  2162,  2139,  2117,   nil,   nil,
+   525,  3433,   534,  2095,  2070,  2047,   nil,  1863,  1865,   nil,
+  1864,  1854,  1887,  1889,   nil,  1890,  1892,  1869,   270,   252,
+   293,   385,   nil,   nil,   nil,   302,   345,   nil,  1573,   653,
+   377,   499,  3024,   nil,   nil,   308,  3083,   nil,   nil,   438,
+    74,   536,   288,   282,   nil,    94,   548,  3142,   nil,   444,
+   nil,   571,   nil,   459,   409,   nil,  2025,    71,   nil,   486,
+  2003,  2375,   623,  1978,   nil,   647,   nil,   662,   nil,   nil,
+  1955,   nil,   nil,   nil,   nil,    26,    14,   691,   476,   709,
+   nil,  1145,   nil,   713,   739,   749,   746,   775,   452,   nil,
+   728,   nil,    -2,   nil,   nil,   804,   nil,   nil,   827,   nil,
+   nil,  3474,   nil,   nil,   204,   269,   nil,   nil,   nil,  1933,
+    77,   823,   nil,   852,   nil,   872,   843,   847,   nil,   890,
+   925,    60,   896,   897,   nil,   929,   nil,   899,   nil,   nil,
+   814,   nil,   484,   nil,   nil,   475,   901,   nil,   nil,   nil,
+   943,   944,   835,   920,   948,   nil,   951,   nil,   963,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   643,   nil,   843,
+   nil,   nil,   nil,   935,   980,   nil,   982,   983,   959,  1007,
+   979,   522,  1005,   nil,  1006,   983,  1026,   nil,   -10,   nil,
+  3269,   617,   972,   nil,  3228,   595,  1038,   nil,   nil,   573,
+   nil,   396,   nil,  1045,   551,   382,   175,   nil,   nil,   nil,
+  1015,   nil,  1042,   nil,    12,   939,   nil,   nil,  1059,   nil,
+   459,  1073,   nil,   302,   nil,   nil,   nil,  1049,   491,   nil,
+   nil,   nil,  1050,  1076,   nil,  1099,  1100,   nil,  1102,  1073,
+  1090,  1118,  1009,  1134,  1108,  1145,   nil,  1121,  1148,   -11,
+   290,   nil,  1152,  1129,    10,   nil,   nil,  1166,   nil,   nil,
+   437,   412,   nil,  1161,   nil,   323,   nil,   nil,   nil,   nil,
+  1029,   nil,   328,   nil,  1163,  1007,   175,   nil,  1208,  1210,
+  1098,  1187,   nil,   nil,  1117,  1207,   985,    -9,  1209,   nil,
+   nil,   nil,   nil,  1248,   428,   963,  1249,  1221,   893,   100,
+  1222,   495,   nil,   -13,   nil,  1230,  1258,   871,   nil,  1235,
+    75,  1280,  1285,   nil,  1256,    24,   nil,   nil,   849,  1301,
+  1277,   827,  1309,   nil,   nil,   478,   nil,   nil,  1295,   nil,
+   nil,  1324,  1327,  1326,   nil,  1341,  1281,  1313,   486,   492,
+  1314,  1323,  1294,   nil,   nil,   nil,   nil,   nil,   801,   nil,
+   nil,   nil,   272,  1354,    11,   nil,  1402,  1441,   nil,   nil,
+  1633,   735,   nil,  1778,  1806,   395,   nil,  1169,   555,   nil ]
+
+racc_action_default = [
+  -194,  -418,    -1,  -418,  -418,   -69,   -70,   -71,   -72,   -73,
+   -74,   -75,   -76,   -77,   -78,   -79,  -418,   -81,   -82,   -83,
+   -84,   -85,   -86,   -87,   -88,   -89,   -90,   -91,   -92,   -93,
+   -94,   -95,   -96,   -97,   -98,   -99,  -418,  -101,  -104,  -118,
+  -418,  -418,  -126,  -127,  -128,  -129,  -130,  -131,  -136,  -137,
+  -192,  -193,  -195,  -418,  -197,  -198,  -199,  -200,  -201,  -202,
+  -203,  -206,  -207,  -208,  -209,  -210,  -234,  -418,  -418,  -418,
+  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -405,  -418,   870,
+  -418,   -65,   -67,  -418,  -139,  -140,  -418,  -146,  -205,  -204,
+  -418,  -100,  -106,  -418,  -109,   -72,   -73,  -119,  -418,  -125,
+  -418,  -211,  -418,  -214,  -418,  -216,  -418,  -218,  -418,  -220,
+  -221,  -222,  -418,  -418,  -386,  -418,  -418,  -418,  -394,  -395,
+  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -247,  -418,
+  -254,  -418,  -260,  -250,  -418,  -327,  -418,  -418,  -350,  -418,
+  -398,  -410,   -62,  -418,  -418,  -138,  -418,  -418,  -418,  -147,
+  -148,  -418,  -102,  -418,  -418,  -132,  -134,  -418,  -418,  -418,
+  -406,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -337,  -418,  -244,
+  -418,  -242,  -418,  -255,  -418,  -251,  -418,  -418,  -328,  -418,
+  -399,  -418,   -66,    -2,    -3,    -4,    -5,    -6,    -7,    -8,
+    -9,   -10,  -418,   -12,   -14,   -18,  -418,  -418,   -22,   -23,
+   -24,   -25,   -26,   -27,   -28,   -30,   -34,   -37,   -40,   -45,
+   -48,   -50,   -52,   -54,   -56,   -58,   -61,   -68,  -186,  -418,
+  -418,  -418,  -143,   -63,  -418,  -418,  -145,  -150,  -152,  -418,
+  -156,  -418,  -141,  -149,   -80,  -418,  -418,  -107,  -418,  -418,
+  -123,  -418,  -418,  -418,  -196,  -418,  -212,  -418,  -224,  -418,
+  -418,  -418,  -418,  -228,  -418,  -291,  -418,  -418,  -387,  -418,
+  -389,  -418,  -391,  -418,  -404,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -240,  -418,  -418,  -418,  -418,  -248,  -418,  -418,
+  -261,  -263,  -418,  -265,  -266,  -267,  -268,  -269,  -418,  -288,
+  -289,  -418,  -418,  -418,  -418,  -313,  -314,  -252,  -324,  -326,
+  -418,  -351,  -353,  -418,  -355,  -356,  -357,  -358,  -365,  -418,
+  -418,  -418,  -418,  -381,  -418,  -407,  -408,  -409,  -418,  -418,
+   -13,  -418,  -418,   -60,  -172,  -418,  -418,  -418,   -19,  -418,
+   -20,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,
+  -418,  -190,  -418,  -142,   -64,  -144,  -418,  -157,  -155,  -418,
+  -159,  -161,  -162,  -163,  -418,  -418,  -166,  -418,  -418,  -171,
+  -418,  -105,  -108,  -418,  -120,  -122,  -418,  -112,  -114,  -418,
+  -418,  -133,  -135,  -124,  -213,  -418,  -418,  -418,  -215,  -217,
+  -219,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -418,  -393,
+  -418,  -397,  -235,  -418,  -237,  -238,  -418,  -245,  -418,  -418,
+  -418,  -249,  -418,  -256,  -418,  -418,  -418,  -262,  -418,  -270,
+  -272,  -418,  -274,  -275,  -276,  -277,  -290,  -418,  -418,  -418,
+  -250,  -418,  -315,  -329,  -418,  -352,  -418,  -359,  -418,  -361,
+  -362,  -363,  -364,  -418,  -372,  -418,  -418,  -418,  -418,  -418,
+  -400,  -401,  -402,  -418,  -418,   -11,  -418,  -173,  -174,  -175,
+  -418,  -418,  -418,   -16,   -17,  -418,   -31,   -32,   -33,   -35,
+   -36,   -38,   -39,   -41,   -42,   -43,   -44,   -46,   -47,   -49,
+   -51,   -53,   -55,   -57,  -418,  -187,  -418,  -418,  -151,  -153,
+  -154,  -158,  -418,  -418,  -418,  -418,  -418,  -418,  -103,  -110,
+  -418,  -418,  -418,  -418,  -418,  -418,  -225,  -418,  -418,  -229,
+  -418,  -418,  -338,  -418,  -399,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -243,  -246,  -253,  -418,  -418,  -259,  -418,  -418,
+  -418,  -418,  -418,  -294,  -296,  -418,  -418,  -305,  -307,  -418,
+  -418,  -418,  -418,  -418,  -349,  -418,  -418,  -418,  -367,  -418,
+  -373,  -418,  -382,  -418,  -418,  -385,  -418,  -418,   -29,  -176,
+  -418,  -418,  -418,  -405,  -182,  -418,  -178,  -418,   -15,   -21,
+  -418,  -188,  -191,  -189,  -160,  -418,  -418,  -418,  -418,  -418,
+  -121,  -418,  -113,  -418,  -418,  -418,  -418,  -418,  -418,  -232,
+  -418,  -223,  -418,  -388,  -390,  -418,  -396,  -236,  -418,  -241,
+  -257,  -418,  -264,  -271,  -418,  -418,  -278,  -279,  -284,  -418,
+  -418,  -418,  -295,  -418,  -298,  -418,  -418,  -418,  -306,  -418,
+  -418,  -418,  -418,  -418,  -316,  -418,  -319,  -418,  -330,  -331,
+  -418,  -333,  -418,  -343,  -354,  -418,  -418,  -368,  -369,  -371,
+  -418,  -418,  -418,  -418,  -418,  -180,  -418,  -184,  -418,  -177,
+  -183,  -179,   -59,  -164,  -165,  -167,  -168,  -418,  -170,  -418,
+  -115,  -116,  -117,  -418,  -418,  -230,  -418,  -418,  -418,  -418,
+  -418,  -418,  -418,  -273,  -418,  -418,  -418,  -292,  -418,  -293,
+  -418,  -418,  -418,  -304,  -418,  -418,  -418,  -310,  -312,  -418,
+  -325,  -418,  -335,  -418,  -418,  -418,  -418,  -360,  -366,  -374,
+  -418,  -383,  -418,  -403,  -418,  -418,  -181,  -185,  -418,  -111,
+  -418,  -418,  -233,  -418,  -384,  -392,  -239,  -418,  -418,  -280,
+  -281,  -285,  -418,  -418,  -297,  -418,  -418,  -308,  -418,  -418,
+  -418,  -418,  -418,  -418,  -418,  -418,  -348,  -418,  -418,  -418,
+  -418,  -379,  -418,  -418,  -418,  -169,  -226,  -418,  -231,  -258,
+  -418,  -418,  -286,  -418,  -299,  -418,  -302,  -303,  -309,  -311,
+  -418,  -332,  -418,  -334,  -418,  -418,  -418,  -341,  -418,  -418,
+  -343,  -418,  -375,  -376,  -418,  -418,  -418,  -418,  -418,  -282,
+  -283,  -287,  -300,  -418,  -418,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -370,  -418,  -380,  -418,  -418,  -418,  -301,  -418,
+  -418,  -418,  -418,  -339,  -418,  -418,  -342,  -344,  -418,  -418,
+  -418,  -418,  -418,  -227,  -317,  -418,  -320,  -322,  -418,  -336,
+  -340,  -418,  -418,  -418,  -378,  -418,  -418,  -418,  -418,  -418,
+  -418,  -418,  -418,  -417,  -318,  -321,  -323,  -346,  -418,  -345,
+  -377,  -413,  -418,  -418,  -418,  -415,  -418,  -418,  -411,  -412,
+  -418,  -418,  -347,  -418,  -418,  -418,  -416,  -418,  -418,  -414 ]
+
+racc_goto_table = [
+    53,   135,    82,   227,   260,   176,   149,   333,   231,   233,
+   158,   258,   100,   150,    97,   318,   235,   151,   563,   383,
+   462,   178,    50,   166,   324,   261,   523,   461,   525,   526,
+   387,   370,     9,     8,   338,   429,   263,   638,   561,    81,
+   139,   598,   311,   382,   125,   467,   266,   332,   547,   269,
+   271,   702,   290,   246,   154,   543,   745,   615,   766,   642,
+   710,   483,   484,   485,   486,   137,   234,   487,   488,   310,
+   558,   544,   548,   645,   644,   243,   479,   480,   481,   482,
+   446,   447,   557,   455,   148,   559,   544,   750,   361,   709,
+   333,   783,   268,   273,   191,   326,   364,   327,   854,   859,
+     1,   233,   852,     2,   340,   489,   490,   491,   492,   493,
+    80,   367,    91,   253,   392,   808,    92,   245,    93,   386,
+   590,   391,   419,   179,   145,   499,   369,   248,   569,   360,
+    51,   254,   256,   257,   262,   541,   318,   180,   127,   286,
+   333,    82,   129,   288,   333,   380,   423,   811,   131,   289,
+   612,   249,   608,   773,   428,   628,   255,   427,   234,   622,
+   784,   729,   785,   445,   333,   437,   686,   542,   623,   476,
+   477,   478,   472,   765,   647,   544,   334,   382,   192,   548,
+    53,   572,   292,   546,   475,   629,   552,   313,     9,     8,
+   544,   634,   635,   825,   136,   187,   494,   553,   723,   443,
+   639,   701,   287,   771,   497,   nil,   nil,   nil,   416,   nil,
+   nil,   nil,     9,     8,   nil,   nil,   nil,   nil,   nil,   248,
+   248,   nil,   nil,   nil,   nil,   436,   nil,   679,   233,   nil,
+   441,   405,   nil,   712,   782,   nil,   nil,   nil,   368,   nil,
+   nil,   nil,   nil,   249,   249,   516,   522,   454,   522,   522,
+   nil,   nil,   nil,   nil,   nil,   463,   nil,   nil,   418,   518,
+   468,   nil,   424,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   519,   nil,   nil,   nil,   nil,   nil,   501,
+   nil,   417,   613,   nil,    53,   234,   425,   292,   nil,   527,
+   nil,   nil,   584,   592,   568,   nil,   511,   nil,   462,   nil,
+   nil,   nil,   nil,   nil,   nil,   461,   421,   nil,   313,   nil,
+   333,   333,   333,   334,   531,   nil,     9,     8,   333,   333,
+   333,   nil,   458,   734,   nil,   nil,   nil,   737,   nil,   nil,
+   nil,   nil,   233,   577,   nil,   nil,   nil,   nil,   538,   575,
+   nil,   nil,   587,   588,   589,   nil,   nil,   nil,   713,   nil,
+   593,   594,   595,   nil,   248,   582,   555,   nil,   602,   nil,
+   nil,   nil,   669,   nil,   820,   500,   nil,   nil,   nil,   nil,
+   nil,   nil,   522,   nil,   nil,   nil,   nil,   nil,   249,   nil,
+   nil,   318,   nil,   nil,   nil,   662,   nil,   nil,   nil,   234,
+   nil,   567,   nil,   nil,   841,   nil,   468,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   179,   564,   812,   nil,
+   nil,   nil,   535,   nil,   nil,   nil,   nil,   nil,   653,   nil,
+   585,   586,   656,   233,   nil,   577,   545,   549,   nil,   nil,
+   658,   nil,   nil,   nil,   nil,   nil,   611,   522,   nil,   nil,
+   nil,   545,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   652,   nil,   nil,   631,   nil,   nil,
+   nil,   687,   nil,   nil,   nil,   591,   nil,   nil,   nil,   nil,
+   234,   nil,   nil,   nil,   nil,   nil,   333,   nil,   nil,   nil,
+   333,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   735,   718,
+   nil,   nil,   738,   690,   730,   nil,   nil,   nil,   nil,   694,
+   545,   nil,   nil,   nil,   549,   nil,   nil,   688,   nil,   nil,
+   nil,   640,   nil,   nil,   nil,   545,   nil,   nil,   nil,   nil,
+   nil,   740,   nil,   nil,   747,   nil,   746,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   753,   nil,   nil,   756,
+   333,   nil,   nil,   nil,   nil,   681,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   458,   nil,   nil,   333,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   741,   797,   nil,   nil,   nil,   nil,   nil,   nil,   789,
+   790,   nil,   nil,   333,   774,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   794,   749,   nil,   814,   nil,   nil,   522,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   805,   nil,
+   nil,   nil,   nil,   333,   nil,   832,   nil,   746,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   823,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   727,
+   nil,   787,   nil,   835,   nil,   853,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   864,   nil,   nil,   815,   nil,   nil,   868,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   640 ]
+
+racc_goto_check = [
+    45,     4,    31,    32,     5,    82,    29,    22,    23,    28,
+    47,    84,    67,    53,    25,   100,    55,     4,   152,    44,
+    73,    88,    64,    47,   156,    23,    83,    75,    83,    83,
+    48,    60,    34,    33,    10,   105,    85,   128,   153,    30,
+   155,    87,   137,    43,    25,    61,    82,    11,   117,    82,
+    82,   132,    97,    40,    51,   112,   134,   106,   115,   133,
+   151,    14,    14,    14,    14,   135,    29,    15,    15,   136,
+   112,    24,    24,   106,   138,    53,    12,    12,    13,    13,
+   139,   144,   145,   146,    31,   147,    24,   148,    32,   149,
+    22,   150,   157,   158,   160,   161,    28,   162,   163,   164,
+     1,    28,   165,     2,     8,    16,    17,    18,    19,    20,
+    26,    27,    37,    51,    23,   115,    39,    41,    42,    46,
+    49,    52,     6,    31,    54,    57,    59,    25,    62,    63,
+    65,    66,    79,    80,    81,    86,   100,    89,    90,    91,
+    22,    31,    92,    93,    22,    40,    94,   134,    95,    96,
+    98,    45,    83,   132,    99,   117,    45,    97,    29,   112,
+   151,   107,   151,   137,    22,   109,   110,   111,   113,    10,
+    10,    10,     6,   114,   112,    24,    25,    43,    30,    24,
+    45,    61,    45,   116,    11,   118,   120,    45,    34,    33,
+    24,   121,   122,   123,   124,   125,     6,   126,    87,   127,
+   129,   130,    64,   131,     5,   nil,   nil,   nil,     4,   nil,
+   nil,   nil,    34,    33,   nil,   nil,   nil,   nil,   nil,    25,
+    25,   nil,   nil,   nil,   nil,     4,   nil,    83,    28,   nil,
+     4,   155,   nil,   153,   128,   nil,   nil,   nil,    31,   nil,
+   nil,   nil,   nil,    45,    45,    84,     5,     4,     5,     5,
+   nil,   nil,   nil,   nil,   nil,     4,   nil,   nil,    25,    23,
+    53,   nil,    25,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,    85,   nil,   nil,   nil,   nil,   nil,    47,
+   nil,    31,   105,   nil,    45,    29,    45,    45,   nil,    82,
+   nil,   nil,    60,    48,    10,   nil,    47,   nil,    73,   nil,
+   nil,   nil,   nil,   nil,   nil,    75,    64,   nil,    45,   nil,
+    22,    22,    22,    25,    88,   nil,    34,    33,    22,    22,
+    22,   nil,    45,    24,   nil,   nil,   nil,    24,   nil,   nil,
+   nil,   nil,    28,    23,   nil,   nil,   nil,   nil,    47,    55,
+   nil,   nil,     6,     6,     6,   nil,   nil,   nil,    73,   nil,
+     6,     6,     6,   nil,    25,    32,    47,   nil,   156,   nil,
+   nil,   nil,    44,   nil,   152,    31,   nil,   nil,   nil,   nil,
+   nil,   nil,     5,   nil,   nil,   nil,   nil,   nil,    45,   nil,
+   nil,   100,   nil,   nil,   nil,    22,   nil,   nil,   nil,    29,
+   nil,     4,   nil,   nil,   152,   nil,    53,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,    31,    67,    83,   nil,
+   nil,   nil,    31,   nil,   nil,   nil,   nil,   nil,    23,   nil,
+     4,     4,    23,    28,   nil,    23,    45,    45,   nil,   nil,
+    55,   nil,   nil,   nil,   nil,   nil,    47,     5,   nil,   nil,
+   nil,    45,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,    47,   nil,   nil,     4,   nil,   nil,
+   nil,    23,   nil,   nil,   nil,    25,   nil,   nil,   nil,   nil,
+    29,   nil,   nil,   nil,   nil,   nil,    22,   nil,   nil,   nil,
+    22,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,     6,    23,
+   nil,   nil,     6,    47,    84,   nil,   nil,   nil,   nil,    47,
+    45,   nil,   nil,   nil,    45,   nil,   nil,     4,   nil,   nil,
+   nil,    45,   nil,   nil,   nil,    45,   nil,   nil,   nil,   nil,
+   nil,    23,   nil,   nil,    32,   nil,    23,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,    23,   nil,   nil,    32,
+    22,   nil,   nil,   nil,   nil,    25,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+    45,   nil,   nil,    22,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,    47,     6,   nil,   nil,   nil,   nil,   nil,   nil,    32,
+    32,   nil,   nil,    22,    82,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,    23,     4,   nil,     6,   nil,   nil,     5,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    23,   nil,
+   nil,   nil,   nil,    22,   nil,     6,   nil,    23,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,    32,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    31,
+   nil,     4,   nil,    23,   nil,     6,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,    23,   nil,   nil,     4,   nil,   nil,    23,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    45 ]
+
+racc_goto_pointer = [
+   nil,   100,   103,   nil,   -73,  -158,  -163,   nil,  -103,   nil,
+  -172,  -155,  -268,  -268,  -287,  -285,  -249,  -249,  -249,  -249,
+  -249,   nil,  -195,  -138,  -367,   -26,   106,  -128,  -138,   -81,
+    35,    -2,  -141,    31,    30,   nil,   nil,    76,   nil,    78,
+  -100,   -35,    80,  -203,  -229,    -2,  -130,   -90,  -219,  -390,
+   nil,   -44,  -130,   -74,    41,  -131,   nil,  -241,   nil,  -115,
+  -210,  -289,  -340,  -100,    20,   128,   -27,   -41,   nil,   nil,
+   nil,   nil,   nil,  -304,   nil,  -297,   nil,   nil,   nil,   -27,
+   -28,   -30,  -119,  -378,  -150,  -128,  -302,  -479,  -104,    11,
+    67,   -43,    70,   -40,  -142,    75,   -35,  -132,  -388,  -138,
+  -174,   nil,   nil,   nil,   nil,  -257,  -483,  -523,   nil,  -133,
+  -453,  -271,  -383,  -377,  -563,  -678,  -256,  -391,  -364,   nil,
+  -256,  -361,  -360,  -617,   120,    59,  -246,  -109,  -516,  -353,
+  -439,  -538,  -589,  -494,  -648,   -10,  -120,  -147,  -481,  -233,
+   nil,   nil,   nil,   nil,  -232,  -371,  -237,  -370,  -622,  -559,
+  -659,  -590,  -439,  -418,   nil,   -36,  -166,   -75,   -77,   nil,
+   -47,   -96,   -94,  -753,  -755,  -741 ]
+
+racc_goto_default = [
+   nil,   nil,   nil,   204,   193,   201,   331,   205,   214,   206,
+   215,   nil,   216,   217,   218,   219,   220,   221,   222,   223,
+   224,   225,   226,   228,    66,     4,   nil,   240,    39,    40,
+   nil,   385,   nil,    95,    96,    11,    12,    37,    36,   nil,
+   nil,   nil,   nil,   247,   nil,   241,   nil,   nil,   nil,   384,
+    41,   nil,   155,    83,    84,   nil,   237,   238,   239,   nil,
+   nil,   nil,   469,   nil,   nil,   nil,    52,   nil,    54,    55,
+    56,    57,    58,    59,    60,    61,    62,    63,    64,   101,
+   nil,   nil,   nil,   nil,   617,   nil,   264,   nil,   nil,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   291,   nil,
+   293,   294,   295,   296,   297,   nil,   nil,   616,   298,   nil,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   304,
+   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   641,   nil,   772,   nil,   nil,   nil,   nil,   312,   nil,
+   314,   315,   316,   317,   nil,   nil,   nil,   nil,   nil,   nil,
+   nil,   nil,   321,   nil,   113,   nil,   nil,   114,   nil,   460,
+   nil,   nil,   nil,   nil,   nil,   nil ]
+
+racc_reduce_table = [
+  0, 0, :racc_error,
+  1, 141, :_reduce_none,
+  1, 143, :_reduce_2,
+  1, 143, :_reduce_3,
+  1, 143, :_reduce_4,
+  1, 143, :_reduce_5,
+  1, 143, :_reduce_6,
+  1, 143, :_reduce_7,
+  1, 143, :_reduce_8,
+  1, 143, :_reduce_9,
+  1, 143, :_reduce_10,
+  3, 143, :_reduce_11,
+  1, 145, :_reduce_none,
+  2, 145, :_reduce_13,
+  1, 147, :_reduce_none,
+  4, 147, :_reduce_15,
+  3, 147, :_reduce_16,
+  3, 147, :_reduce_17,
+  1, 148, :_reduce_none,
+  2, 148, :_reduce_19,
+  2, 148, :_reduce_20,
+  4, 148, :_reduce_21,
+  1, 149, :_reduce_22,
+  1, 149, :_reduce_23,
+  1, 149, :_reduce_24,
+  1, 149, :_reduce_25,
+  1, 149, :_reduce_26,
+  1, 149, :_reduce_27,
+  1, 150, :_reduce_none,
+  4, 150, :_reduce_29,
+  1, 152, :_reduce_none,
+  3, 152, :_reduce_31,
+  3, 152, :_reduce_32,
+  3, 152, :_reduce_33,
+  1, 153, :_reduce_none,
+  3, 153, :_reduce_35,
+  3, 153, :_reduce_36,
+  1, 154, :_reduce_none,
+  3, 154, :_reduce_38,
+  3, 154, :_reduce_39,
+  1, 155, :_reduce_none,
+  3, 155, :_reduce_41,
+  3, 155, :_reduce_42,
+  3, 155, :_reduce_43,
+  3, 155, :_reduce_44,
+  1, 156, :_reduce_none,
+  3, 156, :_reduce_46,
+  3, 156, :_reduce_47,
+  1, 157, :_reduce_none,
+  3, 157, :_reduce_49,
+  1, 158, :_reduce_none,
+  3, 158, :_reduce_51,
+  1, 159, :_reduce_none,
+  3, 159, :_reduce_53,
+  1, 160, :_reduce_none,
+  3, 160, :_reduce_55,
+  1, 161, :_reduce_none,
+  3, 161, :_reduce_57,
+  1, 162, :_reduce_none,
+  5, 162, :_reduce_59,
+  1, 146, :_reduce_60,
+  1, 163, :_reduce_61,
+  3, 164, :_reduce_62,
+  1, 167, :_reduce_none,
+  2, 167, :_reduce_64,
+  1, 166, :_reduce_65,
+  3, 166, :_reduce_66,
+  1, 170, :_reduce_none,
+  3, 170, :_reduce_68,
+  1, 168, :_reduce_69,
+  1, 168, :_reduce_70,
+  1, 168, :_reduce_71,
+  1, 168, :_reduce_none,
+  1, 168, :_reduce_none,
+  1, 168, :_reduce_74,
+  1, 168, :_reduce_none,
+  1, 168, :_reduce_none,
+  1, 168, :_reduce_77,
+  1, 168, :_reduce_78,
+  1, 168, :_reduce_79,
+  4, 168, :_reduce_80,
+  1, 176, :_reduce_81,
+  1, 176, :_reduce_82,
+  1, 176, :_reduce_83,
+  1, 177, :_reduce_84,
+  1, 177, :_reduce_85,
+  1, 177, :_reduce_86,
+  1, 177, :_reduce_87,
+  1, 177, :_reduce_88,
+  1, 177, :_reduce_89,
+  1, 177, :_reduce_90,
+  1, 177, :_reduce_91,
+  1, 177, :_reduce_92,
+  1, 177, :_reduce_93,
+  1, 177, :_reduce_94,
+  1, 177, :_reduce_95,
+  1, 177, :_reduce_96,
+  1, 177, :_reduce_97,
+  1, 178, :_reduce_98,
+  1, 178, :_reduce_99,
+  2, 175, :_reduce_100,
+  1, 175, :_reduce_none,
+  0, 181, :_reduce_102,
+  6, 173, :_reduce_103,
+  0, 182, :_reduce_104,
+  5, 173, :_reduce_105,
+  2, 173, :_reduce_106,
+  1, 180, :_reduce_none,
+  2, 180, :_reduce_none,
+  1, 179, :_reduce_109,
+  3, 183, :_reduce_110,
+  6, 183, :_reduce_111,
+  1, 186, :_reduce_112,
+  3, 186, :_reduce_113,
+  1, 188, :_reduce_114,
+  4, 188, :_reduce_115,
+  4, 188, :_reduce_116,
+  4, 188, :_reduce_117,
+  1, 165, :_reduce_none,
+  2, 165, :_reduce_119,
+  1, 184, :_reduce_120,
+  3, 184, :_reduce_121,
+  1, 189, :_reduce_none,
+  4, 174, :_reduce_none,
+  5, 174, :_reduce_none,
+  2, 174, :_reduce_none,
+  1, 190, :_reduce_126,
+  1, 190, :_reduce_127,
+  1, 190, :_reduce_128,
+  1, 190, :_reduce_129,
+  1, 190, :_reduce_130,
+  1, 190, :_reduce_131,
+  1, 191, :_reduce_none,
+  3, 191, :_reduce_none,
+  1, 192, :_reduce_none,
+  3, 192, :_reduce_none,
+  1, 169, :_reduce_136,
+  1, 169, :_reduce_137,
+  2, 171, :_reduce_138,
+  1, 171, :_reduce_none,
+  1, 194, :_reduce_140,
+  3, 194, :_reduce_141,
+  4, 194, :_reduce_142,
+  3, 194, :_reduce_143,
+  4, 194, :_reduce_144,
+  3, 194, :_reduce_145,
+  1, 193, :_reduce_146,
+  2, 193, :_reduce_147,
+  2, 193, :_reduce_148,
+  3, 193, :_reduce_149,
+  1, 195, :_reduce_none,
+  3, 195, :_reduce_none,
+  1, 196, :_reduce_152,
+  3, 196, :_reduce_153,
+  3, 197, :_reduce_154,
+  2, 197, :_reduce_155,
+  1, 197, :_reduce_156,
+  2, 197, :_reduce_157,
+  3, 198, :_reduce_158,
+  1, 199, :_reduce_159,
+  3, 199, :_reduce_160,
+  1, 200, :_reduce_161,
+  1, 200, :_reduce_162,
+  1, 200, :_reduce_163,
+  4, 200, :_reduce_164,
+  4, 200, :_reduce_165,
+  1, 200, :_reduce_166,
+  4, 200, :_reduce_167,
+  4, 200, :_reduce_168,
+  6, 200, :_reduce_169,
+  4, 200, :_reduce_170,
+  1, 200, :_reduce_171,
+  1, 151, :_reduce_none,
+  2, 151, :_reduce_173,
+  1, 201, :_reduce_none,
+  1, 201, :_reduce_none,
+  2, 201, :_reduce_none,
+  3, 202, :_reduce_177,
+  2, 202, :_reduce_178,
+  3, 202, :_reduce_179,
+  3, 202, :_reduce_180,
+  4, 202, :_reduce_181,
+  2, 202, :_reduce_182,
+  3, 202, :_reduce_none,
+  3, 202, :_reduce_184,
+  4, 202, :_reduce_185,
+  1, 172, :_reduce_186,
+  3, 172, :_reduce_187,
+  4, 172, :_reduce_188,
+  4, 172, :_reduce_189,
+  1, 203, :_reduce_190,
+  3, 203, :_reduce_191,
+  2, 142, :_reduce_none,
+  2, 142, :_reduce_none,
+  0, 142, :_reduce_none,
+  1, 204, :_reduce_none,
+  4, 204, :_reduce_196,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  2, 206, :_reduce_none,
+  2, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 206, :_reduce_none,
+  1, 207, :_reduce_211,
+  3, 207, :_reduce_212,
+  4, 219, :_reduce_213,
+  1, 219, :_reduce_214,
+  4, 219, :_reduce_215,
+  1, 219, :_reduce_216,
+  4, 219, :_reduce_217,
+  1, 219, :_reduce_218,
+  4, 219, :_reduce_219,
+  1, 219, :_reduce_220,
+  1, 219, :_reduce_221,
+  1, 219, :_reduce_222,
+  6, 219, :_reduce_223,
+  1, 220, :_reduce_224,
+  3, 220, :_reduce_225,
+  7, 224, :_reduce_226,
+  10, 224, :_reduce_227,
+  1, 221, :_reduce_228,
+  3, 221, :_reduce_229,
+  5, 225, :_reduce_230,
+  7, 225, :_reduce_231,
+  1, 227, :_reduce_232,
+  3, 227, :_reduce_233,
+  1, 209, :_reduce_234,
+  5, 217, :_reduce_235,
+  7, 217, :_reduce_236,
+  5, 216, :_reduce_237,
+  5, 216, :_reduce_238,
+  9, 218, :_reduce_239,
+  4, 208, :_reduce_240,
+  7, 208, :_reduce_241,
+  1, 229, :_reduce_none,
+  4, 229, :_reduce_none,
+  1, 228, :_reduce_244,
+  3, 228, :_reduce_245,
+  6, 210, :_reduce_246,
+  1, 230, :_reduce_247,
+  1, 231, :_reduce_none,
+  2, 231, :_reduce_none,
+  1, 144, :_reduce_250,
+  2, 144, :_reduce_251,
+  3, 144, :_reduce_252,
+  6, 211, :_reduce_253,
+  1, 232, :_reduce_254,
+  0, 233, :_reduce_255,
+  2, 233, :_reduce_256,
+  3, 234, :_reduce_257,
+  6, 234, :_reduce_258,
+  6, 212, :_reduce_259,
+  1, 235, :_reduce_260,
+  1, 236, :_reduce_none,
+  2, 236, :_reduce_none,
+  1, 237, :_reduce_263,
+  4, 237, :_reduce_264,
+  1, 238, :_reduce_none,
+  1, 238, :_reduce_none,
+  1, 238, :_reduce_none,
+  1, 238, :_reduce_none,
+  1, 238, :_reduce_none,
+  1, 239, :_reduce_270,
+  3, 239, :_reduce_271,
+  1, 245, :_reduce_272,
+  4, 245, :_reduce_273,
+  1, 245, :_reduce_274,
+  1, 245, :_reduce_275,
+  1, 245, :_reduce_276,
+  1, 245, :_reduce_277,
+  1, 246, :_reduce_278,
+  1, 246, :_reduce_279,
+  3, 246, :_reduce_280,
+  3, 246, :_reduce_281,
+  5, 247, :_reduce_282,
+  5, 247, :_reduce_283,
+  4, 240, :_reduce_284,
+  6, 240, :_reduce_285,
+  7, 240, :_reduce_286,
+  8, 240, :_reduce_287,
+  1, 248, :_reduce_288,
+  1, 248, :_reduce_289,
+  1, 249, :_reduce_290,
+  1, 226, :_reduce_none,
+  1, 250, :_reduce_none,
+  5, 241, :_reduce_293,
+  1, 251, :_reduce_294,
+  2, 251, :_reduce_295,
+  1, 252, :_reduce_296,
+  4, 252, :_reduce_297,
+  1, 253, :_reduce_298,
+  4, 253, :_reduce_299,
+  5, 253, :_reduce_300,
+  3, 254, :_reduce_301,
+  1, 254, :_reduce_302,
+  1, 255, :_reduce_none,
+  5, 242, :_reduce_304,
+  1, 256, :_reduce_305,
+  2, 256, :_reduce_306,
+  1, 257, :_reduce_307,
+  4, 257, :_reduce_308,
+  4, 258, :_reduce_309,
+  5, 243, :_reduce_310,
+  7, 243, :_reduce_311,
+  5, 244, :_reduce_none,
+  1, 259, :_reduce_313,
+  1, 259, :_reduce_314,
+  0, 260, :_reduce_none,
+  2, 260, :_reduce_none,
+  7, 261, :_reduce_317,
+  9, 261, :_reduce_318,
+  1, 262, :_reduce_none,
+  1, 263, :_reduce_320,
+  3, 263, :_reduce_321,
+  1, 263, :_reduce_322,
+  3, 263, :_reduce_323,
+  0, 267, :_reduce_324,
+  8, 213, :_reduce_325,
+  4, 213, :_reduce_326,
+  1, 264, :_reduce_327,
+  1, 265, :_reduce_328,
+  0, 266, :_reduce_none,
+  2, 266, :_reduce_none,
+  2, 266, :_reduce_none,
+  4, 268, :_reduce_332,
+  1, 268, :_reduce_333,
+  3, 270, :_reduce_334,
+  1, 270, :_reduce_335,
+  6, 272, :_reduce_336,
+  1, 222, :_reduce_337,
+  1, 223, :_reduce_none,
+  6, 271, :_reduce_339,
+  7, 271, :_reduce_340,
+  4, 271, :_reduce_341,
+  6, 271, :_reduce_342,
+  1, 273, :_reduce_none,
+  6, 269, :_reduce_344,
+  9, 269, :_reduce_345,
+  9, 269, :_reduce_346,
+  12, 269, :_reduce_347,
+  1, 274, :_reduce_none,
+  6, 214, :_reduce_349,
+  1, 275, :_reduce_350,
+  1, 276, :_reduce_none,
+  2, 276, :_reduce_none,
+  1, 277, :_reduce_353,
+  4, 277, :_reduce_354,
+  1, 278, :_reduce_none,
+  1, 278, :_reduce_none,
+  1, 278, :_reduce_none,
+  1, 278, :_reduce_none,
+  1, 279, :_reduce_359,
+  4, 284, :_reduce_360,
+  1, 284, :_reduce_361,
+  1, 284, :_reduce_362,
+  1, 284, :_reduce_363,
+  1, 284, :_reduce_364,
+  1, 280, :_reduce_365,
+  5, 281, :_reduce_366,
+  1, 285, :_reduce_367,
+  2, 285, :_reduce_368,
+  0, 289, :_reduce_369,
+  8, 282, :_reduce_370,
+  4, 282, :_reduce_371,
+  1, 286, :_reduce_372,
+  1, 287, :_reduce_373,
+  0, 288, :_reduce_none,
+  2, 288, :_reduce_none,
+  2, 288, :_reduce_none,
+  6, 290, :_reduce_377,
+  4, 290, :_reduce_378,
+  6, 283, :_reduce_379,
+  8, 283, :_reduce_380,
+  1, 292, :_reduce_none,
+  1, 293, :_reduce_none,
+  1, 291, :_reduce_none,
+  9, 215, :_reduce_384,
+  6, 215, :_reduce_385,
+  1, 294, :_reduce_none,
+  3, 294, :_reduce_none,
+  6, 297, :_reduce_388,
+  3, 297, :_reduce_389,
+  6, 297, :_reduce_390,
+  3, 297, :_reduce_391,
+  8, 297, :_reduce_392,
+  4, 297, :_reduce_393,
+  1, 297, :_reduce_394,
+  1, 297, :_reduce_395,
+  6, 297, :_reduce_396,
+  4, 297, :_reduce_397,
+  1, 295, :_reduce_398,
+  0, 296, :_reduce_none,
+  2, 296, :_reduce_none,
+  2, 296, :_reduce_none,
+  1, 299, :_reduce_none,
+  4, 299, :_reduce_403,
+  1, 298, :_reduce_404,
+  1, 185, :_reduce_405,
+  1, 187, :_reduce_406,
+  4, 205, :_reduce_none,
+  2, 300, :_reduce_none,
+  2, 300, :_reduce_none,
+  0, 300, :_reduce_none,
+  14, 301, :_reduce_411,
+  2, 303, :_reduce_412,
+  0, 303, :_reduce_413,
+  6, 304, :_reduce_414,
+  13, 302, :_reduce_415,
+  5, 305, :_reduce_416,
+  0, 305, :_reduce_417 ]
+
+racc_reduce_n = 418
+
+racc_shift_n = 870
+
+racc_token_table = {
+  false => 0,
+  :error => 1,
+  :TRUE => 2,
+  :FALSE => 3,
+  :INTEGER_CONSTANT => 4,
+  :FLOATING_CONSTANT => 5,
+  :OCTAL_CONSTANT => 6,
+  :HEX_CONSTANT => 7,
+  :CHARACTER_LITERAL => 8,
+  "(" => 9,
+  ")" => 10,
+  :STRING_LITERAL => 11,
+  "[" => 12,
+  "]" => 13,
+  "." => 14,
+  :IDENTIFIER => 15,
+  "->" => 16,
+  :SIZEOF => 17,
+  "&" => 18,
+  "*" => 19,
+  "+" => 20,
+  "-" => 21,
+  "~" => 22,
+  "!" => 23,
+  "/" => 24,
+  "%" => 25,
+  "<<" => 26,
+  ">>" => 27,
+  "<" => 28,
+  ">" => 29,
+  "<=" => 30,
+  ">=" => 31,
+  "==" => 32,
+  "!=" => 33,
+  "^" => 34,
+  "|" => 35,
+  "&&" => 36,
+  "||" => 37,
+  "?" => 38,
+  ":" => 39,
+  ";" => 40,
+  "," => 41,
+  "=" => 42,
+  :VOID => 43,
+  :FLOAT32_T => 44,
+  :DOUBLE64_T => 45,
+  :TYPE_NAME => 46,
+  :BOOL_T => 47,
+  :FLOAT => 48,
+  :DOUBLE => 49,
+  :DESCRIPTOR => 50,
+  :CHAR_T => 51,
+  :SCHAR_T => 52,
+  :UCHAR_T => 53,
+  :CHAR => 54,
+  :SHORT => 55,
+  :INT => 56,
+  :LONG => 57,
+  :INT8_T => 58,
+  :INT16_T => 59,
+  :INT32_T => 60,
+  :INT64_T => 61,
+  :INT128_T => 62,
+  :UINT8_T => 63,
+  :UINT16_T => 64,
+  :UINT32_T => 65,
+  :UINT64_T => 66,
+  :UINT128_T => 67,
+  :SIGNED => 68,
+  :UNSIGNED => 69,
+  :STRUCT => 70,
+  "{" => 71,
+  "}" => 72,
+  :STRING => 73,
+  :SIZE_IS => 74,
+  :COUNT_IS => 75,
+  :ENUM => 76,
+  :ENUM8 => 77,
+  :ENUM16 => 78,
+  :ENUM32 => 79,
+  :ENUM64 => 80,
+  :ENUM128 => 81,
+  :CONST => 82,
+  :VOLATILE => 83,
+  "..." => 84,
+  :IN => 85,
+  :OUT => 86,
+  :INOUT => 87,
+  :SEND => 88,
+  :RECEIVE => 89,
+  :NULLABLE => 90,
+  :C_EXP => 91,
+  :ALLOCATOR => 92,
+  :CALLBACK => 93,
+  :CONTEXT => 94,
+  :DEVIATE => 95,
+  :ID => 96,
+  :PROTOTYPE => 97,
+  :RESTRICT => 98,
+  :SINGLETON => 99,
+  :IDX_IS_ID => 100,
+  :ACTIVE => 101,
+  :GENERATE => 102,
+  :IMPORT_C => 103,
+  :IMPORT => 104,
+  :AB_STRING_LITERAL => 105,
+  :TYPEDEF => 106,
+  :NAMESPACE => 107,
+  "::" => 108,
+  :SIGNATURE => 109,
+  :ONEWAY => 110,
+  :CELLTYPE => 111,
+  :INLINE => 112,
+  :OPTIONAL => 113,
+  :REF_DESC => 114,
+  :DYNAMIC => 115,
+  :OMIT => 116,
+  :CALL => 117,
+  :ENTRY => 118,
+  :ATTRIBUTE => 119,
+  :CHOICE => 120,
+  :VAR => 121,
+  :REQUIRE => 122,
+  :FACTORY => 123,
+  :CTFACTORY => 124,
+  :CELL => 125,
+  :THROUGH => 126,
+  :COMPOSITE => 127,
+  "=>" => 128,
+  :REGION => 129,
+  :IN_THROUGH => 130,
+  :OUT_THROUGH => 131,
+  :TO_THROUGH => 132,
+  :NODE => 133,
+  :LINKUNIT => 134,
+  :DOMAIN => 135,
+  :CLASS => 136,
+  :__LOCATION_INFORMATION__ => 137,
+  :__CELL__ => 138,
+  :__JOIN__ => 139 }
+
+racc_nt_base = 140
+
+racc_use_result_var = true
+
+Racc_arg = [
+  racc_action_table,
+  racc_action_check,
+  racc_action_default,
+  racc_action_pointer,
+  racc_goto_table,
+  racc_goto_check,
+  racc_goto_default,
+  racc_goto_pointer,
+  racc_nt_base,
+  racc_reduce_table,
+  racc_token_table,
+  racc_shift_n,
+  racc_reduce_n,
+  racc_use_result_var ]
+
+Racc_token_to_s_table = [
+  "$end",
+  "error",
+  "TRUE",
+  "FALSE",
+  "INTEGER_CONSTANT",
+  "FLOATING_CONSTANT",
+  "OCTAL_CONSTANT",
+  "HEX_CONSTANT",
+  "CHARACTER_LITERAL",
+  "\"(\"",
+  "\")\"",
+  "STRING_LITERAL",
+  "\"[\"",
+  "\"]\"",
+  "\".\"",
+  "IDENTIFIER",
+  "\"->\"",
+  "SIZEOF",
+  "\"&\"",
+  "\"*\"",
+  "\"+\"",
+  "\"-\"",
+  "\"~\"",
+  "\"!\"",
+  "\"/\"",
+  "\"%\"",
+  "\"<<\"",
+  "\">>\"",
+  "\"<\"",
+  "\">\"",
+  "\"<=\"",
+  "\">=\"",
+  "\"==\"",
+  "\"!=\"",
+  "\"^\"",
+  "\"|\"",
+  "\"&&\"",
+  "\"||\"",
+  "\"?\"",
+  "\":\"",
+  "\";\"",
+  "\",\"",
+  "\"=\"",
+  "VOID",
+  "FLOAT32_T",
+  "DOUBLE64_T",
+  "TYPE_NAME",
+  "BOOL_T",
+  "FLOAT",
+  "DOUBLE",
+  "DESCRIPTOR",
+  "CHAR_T",
+  "SCHAR_T",
+  "UCHAR_T",
+  "CHAR",
+  "SHORT",
+  "INT",
+  "LONG",
+  "INT8_T",
+  "INT16_T",
+  "INT32_T",
+  "INT64_T",
+  "INT128_T",
+  "UINT8_T",
+  "UINT16_T",
+  "UINT32_T",
+  "UINT64_T",
+  "UINT128_T",
+  "SIGNED",
+  "UNSIGNED",
+  "STRUCT",
+  "\"{\"",
+  "\"}\"",
+  "STRING",
+  "SIZE_IS",
+  "COUNT_IS",
+  "ENUM",
+  "ENUM8",
+  "ENUM16",
+  "ENUM32",
+  "ENUM64",
+  "ENUM128",
+  "CONST",
+  "VOLATILE",
+  "\"...\"",
+  "IN",
+  "OUT",
+  "INOUT",
+  "SEND",
+  "RECEIVE",
+  "NULLABLE",
+  "C_EXP",
+  "ALLOCATOR",
+  "CALLBACK",
+  "CONTEXT",
+  "DEVIATE",
+  "ID",
+  "PROTOTYPE",
+  "RESTRICT",
+  "SINGLETON",
+  "IDX_IS_ID",
+  "ACTIVE",
+  "GENERATE",
+  "IMPORT_C",
+  "IMPORT",
+  "AB_STRING_LITERAL",
+  "TYPEDEF",
+  "NAMESPACE",
+  "\"::\"",
+  "SIGNATURE",
+  "ONEWAY",
+  "CELLTYPE",
+  "INLINE",
+  "OPTIONAL",
+  "REF_DESC",
+  "DYNAMIC",
+  "OMIT",
+  "CALL",
+  "ENTRY",
+  "ATTRIBUTE",
+  "CHOICE",
+  "VAR",
+  "REQUIRE",
+  "FACTORY",
+  "CTFACTORY",
+  "CELL",
+  "THROUGH",
+  "COMPOSITE",
+  "\"=>\"",
+  "REGION",
+  "IN_THROUGH",
+  "OUT_THROUGH",
+  "TO_THROUGH",
+  "NODE",
+  "LINKUNIT",
+  "DOMAIN",
+  "CLASS",
+  "__LOCATION_INFORMATION__",
+  "__CELL__",
+  "__JOIN__",
+  "$start",
+  "all",
+  "component_description",
+  "primary_expression",
+  "namespace_identifier",
+  "string_literal_list",
+  "expression",
+  "postfix_expression",
+  "unary_expression",
+  "unary_operator",
+  "cast_expression",
+  "type_name",
+  "multiplicative_expression",
+  "additive_expression",
+  "shift_expression",
+  "relational_expression",
+  "equality_expression",
+  "and_expression",
+  "exclusive_or_expression",
+  "inclusive_or_expression",
+  "logical_and_expression",
+  "logical_or_expression",
+  "conditional_expression",
+  "constant_expression",
+  "declaration",
+  "type_specifier_qualifier_list",
+  "init_declarator_list",
+  "declaration_specifiers",
+  "type_specifier",
+  "type_qualifier",
+  "init_declarator",
+  "declarator",
+  "initializer",
+  "struct_specifier",
+  "enum_specifier",
+  "sign_int_type",
+  "char_type",
+  "int_type",
+  "sign",
+  "struct_tag",
+  "struct_declaration_list",
+  "@1",
+  "@2",
+  "struct_declaration",
+  "struct_declarator_list",
+  "spec_L",
+  "pointer_specifier_list",
+  "spec_R",
+  "pointer_specifier",
+  "struct_declarator",
+  "enum_type",
+  "enumerator_list",
+  "enumerator",
+  "pointer",
+  "direct_declarator",
+  "parameter_type_list",
+  "parameter_list",
+  "parameter_declaration",
+  "parameter_specifier_list_bracket",
+  "parameter_specifier_list",
+  "parameter_specifier",
+  "abstract_declarator",
+  "direct_abstract_declarator",
+  "initializer_list",
+  "specified_statement",
+  "location_information",
+  "statement",
+  "statement_specifier_list",
+  "typedef",
+  "const_statement",
+  "namespace",
+  "signature",
+  "celltype",
+  "cell",
+  "composite_celltype",
+  "region",
+  "import",
+  "import_C",
+  "signature_plugin",
+  "statement_specifier",
+  "alloc_list",
+  "restrict_list",
+  "plugin_name",
+  "plugin_arg",
+  "alloc",
+  "restrict",
+  "port_name",
+  "region_name_list",
+  "declarator_list",
+  "typedef_specifier",
+  "namespace_name",
+  "statement_list",
+  "signature_name",
+  "function_head_list",
+  "function_head",
+  "celltype_name",
+  "celltype_statement_list",
+  "specified_celltype_statement",
+  "celltype_statement",
+  "celltype_statement_specifier_list",
+  "port",
+  "attribute",
+  "var",
+  "require",
+  "factory",
+  "celltype_statement_specifier",
+  "alloc_list2",
+  "alloc2",
+  "port_type",
+  "namespace_signature_name",
+  "array_size",
+  "attribute_declaration_list",
+  "attribute_declaration",
+  "attribute_specifier",
+  "choice_list",
+  "choice_element",
+  "var_declaration_list",
+  "var_declaration",
+  "var_specifier",
+  "factory_head",
+  "factory_function_list",
+  "factory_function",
+  "factory_function_name",
+  "arg_list",
+  "namespace_celltype_name",
+  "cell_name",
+  "join_list",
+  "@3",
+  "specified_join",
+  "reverse_join",
+  "join_specifier_list",
+  "join",
+  "join_specifier",
+  "cae_name",
+  "array_index",
+  "composite_celltype_name",
+  "composite_celltype_statement_list",
+  "specified_composite_celltype_statement",
+  "composite_celltype_statement",
+  "composite_celltype_statement_specifier_list",
+  "composite_port",
+  "composite_attribute",
+  "internal_cell",
+  "export_join",
+  "composite_celltype_statement_specifier",
+  "composite_attribute_declaration_list",
+  "internal_namespace_celltype_name",
+  "internal_cell_name",
+  "internal_join_list",
+  "@4",
+  "external_join",
+  "internal_cell_elem_name",
+  "export_name",
+  "internal_ref_cell_name",
+  "region_specifier_list",
+  "region_name",
+  "region_statement",
+  "region_specifier",
+  "namespace_region_name",
+  "region_cell",
+  "cell_location_join_location_list",
+  "cell_location",
+  "join_location",
+  "port_location_list",
+  "port_location",
+  "bar_list" ]
+
+Racc_debug_parser = false
+
+##### State transition tables end #####
+
+# reduce 0 omitted
+
+# reduce 1 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 52)
+  def _reduce_2(val, _values, result)
+     result = [ :IDENTIFIER, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 54)
+  def _reduce_3(val, _values, result)
+     result = [ :BOOL_CONSTANT, true ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 56)
+  def _reduce_4(val, _values, result)
+     result = [ :BOOL_CONSTANT, false ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 58)
+  def _reduce_5(val, _values, result)
+     result = [ :INTEGER_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 60)
+  def _reduce_6(val, _values, result)
+     result = [ :FLOATING_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 62)
+  def _reduce_7(val, _values, result)
+     result = [ :OCTAL_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 64)
+  def _reduce_8(val, _values, result)
+     result = [ :HEX_CONSTANT, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 66)
+  def _reduce_9(val, _values, result)
+     result = [ :CHARACTER_LITERAL, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 68)
+  def _reduce_10(val, _values, result)
+     result = [ :STRING_LITERAL_LIST, val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 70)
+  def _reduce_11(val, _values, result)
+     result = [ :PARENTHESES, val[1].get_elements ] 
+    result
+  end
+.,.,
+
+# reduce 12 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 76)
+  def _reduce_13(val, _values, result)
+    			# é£æ¥ããæå­åã1ã¤ã®æå­åã«ã¾ã¨ãã
+			str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\""
+			result = Token.new( str, val[0].file, val[0].lineno, val[0].col )
+		
+    result
+  end
+.,.,
+
+# reduce 14 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 85)
+  def _reduce_15(val, _values, result)
+     result = [ :OP_SUBSC, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 87)
+  def _reduce_16(val, _values, result)
+     result = [ :OP_DOT, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 89)
+  def _reduce_17(val, _values, result)
+     result = [ :OP_REF, val[0], val[2] ] 
+    result
+  end
+.,.,
+
+# reduce 18 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 95)
+  def _reduce_19(val, _values, result)
+     result = [ val[0], val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 97)
+  def _reduce_20(val, _values, result)
+     result = [ :OP_SIZEOF_EXPR, val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 99)
+  def _reduce_21(val, _values, result)
+     result = [ :OP_SIZEOF_TYPE, val[1] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 102)
+  def _reduce_22(val, _values, result)
+     result = :OP_U_AMP 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 103)
+  def _reduce_23(val, _values, result)
+     result = :OP_U_ASTER 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 104)
+  def _reduce_24(val, _values, result)
+     result = :OP_U_PLUS 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 105)
+  def _reduce_25(val, _values, result)
+     result = :OP_U_MINUS 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 106)
+  def _reduce_26(val, _values, result)
+     result = :OP_U_TILDE 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 107)
+  def _reduce_27(val, _values, result)
+     result = :OP_U_EXCLAM 
+    result
+  end
+.,.,
+
+# reduce 28 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 112)
+  def _reduce_29(val, _values, result)
+      result = [ :CAST, val[1], val[3] ] 
+    result
+  end
+.,.,
+
+# reduce 30 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 117)
+  def _reduce_31(val, _values, result)
+     result = [ :OP_MULT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 119)
+  def _reduce_32(val, _values, result)
+     result = [ :OP_DIV, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 121)
+  def _reduce_33(val, _values, result)
+     result = [ :OP_REMAIN, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 34 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 126)
+  def _reduce_35(val, _values, result)
+     result = [ :OP_ADD, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 128)
+  def _reduce_36(val, _values, result)
+     result = [ :OP_SUB, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 37 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 133)
+  def _reduce_38(val, _values, result)
+     result = [ :OP_LSFT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 135)
+  def _reduce_39(val, _values, result)
+     result = [ :OP_RSFT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 40 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 140)
+  def _reduce_41(val, _values, result)
+     result = [ :OP_LT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 142)
+  def _reduce_42(val, _values, result)
+     result = [ :OP_GT, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 144)
+  def _reduce_43(val, _values, result)
+     result = [ :OP_LE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 146)
+  def _reduce_44(val, _values, result)
+     result = [ :OP_GE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 45 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 151)
+  def _reduce_46(val, _values, result)
+     result = [ :OP_EQ, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 153)
+  def _reduce_47(val, _values, result)
+     result = [ :OP_NE, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 48 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 158)
+  def _reduce_49(val, _values, result)
+     result = [ :OP_AND, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 50 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 163)
+  def _reduce_51(val, _values, result)
+     result = [ :OP_EOR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 52 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 168)
+  def _reduce_53(val, _values, result)
+     result = [ :OP_OR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 54 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 173)
+  def _reduce_55(val, _values, result)
+     result = [ :OP_LAND, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 56 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 178)
+  def _reduce_57(val, _values, result)
+     result = [ :OP_LOR, val[0], val[2] ]  
+    result
+  end
+.,.,
+
+# reduce 58 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 183)
+  def _reduce_59(val, _values, result)
+     result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ]  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 190)
+  def _reduce_60(val, _values, result)
+    			result = Expression.new( val[0] )
+			# result.print
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 197)
+  def _reduce_61(val, _values, result)
+    			result = Expression.new( val[0] )
+			# result.print
+
+			# res = result.eval_const( nil )
+			# if res then
+			#   puts "val: #{res}"
+			# else
+			#   puts "val: nil"
+			# end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 219)
+  def _reduce_62(val, _values, result)
+    			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+			}
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 63 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 235)
+  def _reduce_64(val, _values, result)
+    			val[1].set_qualifier( val[0] )
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 241)
+  def _reduce_65(val, _values, result)
+     result = [val[0]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 243)
+  def _reduce_66(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+# reduce 67 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 248)
+  def _reduce_68(val, _values, result)
+     val[0].set_initializer( val[2] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 254)
+  def _reduce_69(val, _values, result)
+     result = VoidType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 255)
+  def _reduce_70(val, _values, result)
+     result = FloatType.new(32) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 256)
+  def _reduce_71(val, _values, result)
+     result = FloatType.new(64) 
+    result
+  end
+.,.,
+
+# reduce 72 omitted
+
+# reduce 73 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 259)
+  def _reduce_74(val, _values, result)
+     result = DefinedType.new( val[0].val ) 
+    result
+  end
+.,.,
+
+# reduce 75 omitted
+
+# reduce 76 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 263)
+  def _reduce_77(val, _values, result)
+     result = BoolType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 269)
+  def _reduce_78(val, _values, result)
+    			Generator.warning( "W5002 float: obsolete type. use float32_t"  )
+			result = FloatType.new(32)
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 273)
+  def _reduce_79(val, _values, result)
+    			Generator.warning( "W5003 double: obsolete type. use double64_t"  )
+			result = FloatType.new(64)
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 276)
+  def _reduce_80(val, _values, result)
+              # namespace_identifier: signature name
+			result = DescriptorType.new( val[2] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 281)
+  def _reduce_81(val, _values, result)
+     result = IntType.new( -1 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 284)
+  def _reduce_82(val, _values, result)
+    			result = IntType.new( -1 )
+			result.set_sign( :SIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 289)
+  def _reduce_83(val, _values, result)
+    			result = IntType.new( -1 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 295)
+  def _reduce_84(val, _values, result)
+    			# Generator.warning( "W5004 char: obsolete type. use char_t"  )
+			result = IntType.new( -11 )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 298)
+  def _reduce_85(val, _values, result)
+     result = IntType.new( -2 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 299)
+  def _reduce_86(val, _values, result)
+     result = IntType.new( -3 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 300)
+  def _reduce_87(val, _values, result)
+     result = IntType.new( -4 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 324)
+  def _reduce_88(val, _values, result)
+     result = IntType.new( 8 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 325)
+  def _reduce_89(val, _values, result)
+     result = IntType.new( 16 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 326)
+  def _reduce_90(val, _values, result)
+     result = IntType.new( 32 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 327)
+  def _reduce_91(val, _values, result)
+     result = IntType.new( 64 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 328)
+  def _reduce_92(val, _values, result)
+     result = IntType.new( 128 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 331)
+  def _reduce_93(val, _values, result)
+    			result = IntType.new( 8 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 336)
+  def _reduce_94(val, _values, result)
+    			result = IntType.new( 16 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 341)
+  def _reduce_95(val, _values, result)
+    			result = IntType.new( 32 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 346)
+  def _reduce_96(val, _values, result)
+    			result = IntType.new( 64 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 351)
+  def _reduce_97(val, _values, result)
+    			result = IntType.new( 128 )
+			result.set_sign( :UNSIGNED, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 356)
+  def _reduce_98(val, _values, result)
+     result = :SIGNED 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 357)
+  def _reduce_99(val, _values, result)
+     result = :UNSIGNED 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 363)
+  def _reduce_100(val, _values, result)
+    			val[1].set_sign( val[0] )
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 101 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 371)
+  def _reduce_102(val, _values, result)
+     StructType.set_define( true )  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 374)
+  def _reduce_103(val, _values, result)
+    			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 379)
+  def _reduce_104(val, _values, result)
+    			result = StructType.new()
+			StructType.set_define( true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 384)
+  def _reduce_105(val, _values, result)
+    			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 389)
+  def _reduce_106(val, _values, result)
+    			StructType.set_define( false )
+			StructType.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 107 omitted
+
+# reduce 108 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 400)
+  def _reduce_109(val, _values, result)
+     result = StructType.new( val[0].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 406)
+  def _reduce_110(val, _values, result)
+    			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+				i.set_kind( :MEMBER )
+				i.check
+				StructType.new_member( i )
+			}
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 416)
+  def _reduce_111(val, _values, result)
+    			val[4].each { |i|	# i: Decl
+				i.set_type( val[3] )
+				i.set_kind( :MEMBER )
+  				i.set_specifier_list val[1]
+				i.check
+				StructType.new_member( i )
+			}
+			result = val[4]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 427)
+  def _reduce_112(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 428)
+  def _reduce_113(val, _values, result)
+     result <<  val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 431)
+  def _reduce_114(val, _values, result)
+     result = [:STRING,-1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 432)
+  def _reduce_115(val, _values, result)
+     result = [:STRING,val[2]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 433)
+  def _reduce_116(val, _values, result)
+     result = [:SIZE_IS,val[2]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 434)
+  def _reduce_117(val, _values, result)
+     result = [:COUNT_IS,val[2]] 
+    result
+  end
+.,.,
+
+# reduce 118 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 445)
+  def _reduce_119(val, _values, result)
+    			val[1].set_qualifier( val[0] )
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 454)
+  def _reduce_120(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 456)
+  def _reduce_121(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+# reduce 122 omitted
+
+# reduce 123 omitted
+
+# reduce 124 omitted
+
+# reduce 125 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 469)
+  def _reduce_126(val, _values, result)
+     result = EnumType.new( -1 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 470)
+  def _reduce_127(val, _values, result)
+     result = EnumType.new( 8 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 471)
+  def _reduce_128(val, _values, result)
+     result = EnumType.new( 16 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 472)
+  def _reduce_129(val, _values, result)
+     result = EnumType.new( 32 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 473)
+  def _reduce_130(val, _values, result)
+     result = EnumType.new( 64 ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 474)
+  def _reduce_131(val, _values, result)
+     result = EnumType.new( 128 ) 
+    result
+  end
+.,.,
+
+# reduce 132 omitted
+
+# reduce 133 omitted
+
+# reduce 134 omitted
+
+# reduce 135 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 485)
+  def _reduce_136(val, _values, result)
+     result = :CONST 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 486)
+  def _reduce_137(val, _values, result)
+     result = :VOLATILE 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 491)
+  def _reduce_138(val, _values, result)
+    			val[1].set_type( val[0] )
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+# reduce 139 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 498)
+  def _reduce_140(val, _values, result)
+     result = Decl.new( val[0].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 500)
+  def _reduce_141(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 503)
+  def _reduce_142(val, _values, result)
+    			val[0].set_type( ArrayType.new( val[2] ) )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 508)
+  def _reduce_143(val, _values, result)
+    			val[0].set_type( ArrayType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 513)
+  def _reduce_144(val, _values, result)
+    			val[0].set_type( FuncType.new( val[2] ) )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 519)
+  def _reduce_145(val, _values, result)
+    			Generator.warning( "W5010 need 'void' for no parameter"  )
+			val[0].set_type( FuncType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 526)
+  def _reduce_146(val, _values, result)
+     result = PtrType.new 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 529)
+  def _reduce_147(val, _values, result)
+    			result = PtrType.new
+			result.set_qualifier( val[1] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 534)
+  def _reduce_148(val, _values, result)
+    			val[1].set_type(PtrType.new)
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 539)
+  def _reduce_149(val, _values, result)
+    			ptrtype = PtrType.new
+			ptrtype.set_qualifier( val[1] )
+			val[2].set_type( ptrtype )
+			result = val[2]
+		
+    result
+  end
+.,.,
+
+# reduce 150 omitted
+
+# reduce 151 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 553)
+  def _reduce_152(val, _values, result)
+     result = ParamList.new( val[0] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 556)
+  def _reduce_153(val, _values, result)
+    			val[0].add_param( val[2] )
+			# result = val[0] ä¸è¦
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 566)
+  def _reduce_154(val, _values, result)
+    			val[2].set_kind( :PARAMETER )
+			paramdecl = ParamDecl.new( val[2], val[1], val[0] )
+			val[2].check
+			result = paramdecl
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 575)
+  def _reduce_155(val, _values, result)
+    			Generator.error( "G1001 need specifier for \'$1\'" , val[1].get_name )
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 580)
+  def _reduce_156(val, _values, result)
+    			unless val[0].instance_of?( VoidType ) then
+				Generator.error( "G1002 need parameter name"  )
+			end
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 588)
+  def _reduce_157(val, _values, result)
+    			unless val[1].instance_of?( VoidType ) then
+				Generator.error( "G1003 need parameter name"  )
+			end
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 595)
+  def _reduce_158(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 599)
+  def _reduce_159(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 601)
+  def _reduce_160(val, _values, result)
+     result = result + val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 604)
+  def _reduce_161(val, _values, result)
+     result = [ [:IN]  ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 605)
+  def _reduce_162(val, _values, result)
+     result = [ [:OUT] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 606)
+  def _reduce_163(val, _values, result)
+     result = [ [:INOUT] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 607)
+  def _reduce_164(val, _values, result)
+     result = [ [:SEND,   val[2]] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 608)
+  def _reduce_165(val, _values, result)
+     result = [ [:RECEIVE,val[2]] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 609)
+  def _reduce_166(val, _values, result)
+     result = [ [:STRING,nil] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 610)
+  def _reduce_167(val, _values, result)
+     result = [ [:STRING,  val[2]] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 611)
+  def _reduce_168(val, _values, result)
+     result = [ [:SIZE_IS, val[2]] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 614)
+  def _reduce_169(val, _values, result)
+    			result = [ [:SIZE_IS,val[2]], [:MAX_IS, val[4]] ]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 616)
+  def _reduce_170(val, _values, result)
+     result = [ [:COUNT_IS,val[2]] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 617)
+  def _reduce_171(val, _values, result)
+     result = [ [:NULLABLE] ] 
+    result
+  end
+.,.,
+
+# reduce 172 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 623)
+  def _reduce_173(val, _values, result)
+    			if val[1] then
+				val[1].set_type( val[0] )
+				result = val[1]
+			else
+				# ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã
+				result = val[0]
+			end
+		
+    result
+  end
+.,.,
+
+# reduce 174 omitted
+
+# reduce 175 omitted
+
+# reduce 176 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 640)
+  def _reduce_177(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 643)
+  def _reduce_178(val, _values, result)
+    			Generator.error( "G1004 impossible array type"  )
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 648)
+  def _reduce_179(val, _values, result)
+    			Generator.error( "G1005 impossible array type"  )
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 653)
+  def _reduce_180(val, _values, result)
+    			Generator.error( "G1006 impossible array type"  )
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 658)
+  def _reduce_181(val, _values, result)
+    			Generator.error( "G1007 impossible array type"  )
+			result = nil
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 663)
+  def _reduce_182(val, _values, result)
+    			Generator.error( "G1008 impossible function type"  )
+			result = nil
+		
+    result
+  end
+.,.,
+
+# reduce 183 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 669)
+  def _reduce_184(val, _values, result)
+    			Generator.warning( "W5011 need 'void' for no parameter"  )
+			val[0].set_type( FuncType.new )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 675)
+  def _reduce_185(val, _values, result)
+    			val[0].set_type( FuncType.new( val[2] ) )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 682)
+  def _reduce_186(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 684)
+  def _reduce_187(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 686)
+  def _reduce_188(val, _values, result)
+     result = val[1] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 689)
+  def _reduce_189(val, _values, result)
+     result = C_EXP.new( val[2] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 694)
+  def _reduce_190(val, _values, result)
+    			result = [ val[0] ]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 698)
+  def _reduce_191(val, _values, result)
+    			val[0] << val[2]
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+# reduce 192 omitted
+
+# reduce 193 omitted
+
+# reduce 194 omitted
+
+# reduce 195 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 716)
+  def _reduce_196(val, _values, result)
+    			obj = val[3]
+			if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then
+                                # cell, signature ä»¥å¤ã¯ãæå®å­ãç½®ããªã
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G1009 unexpected specifier"  )
+			end
+		
+    result
+  end
+.,.,
+
+# reduce 197 omitted
+
+# reduce 198 omitted
+
+# reduce 199 omitted
+
+# reduce 200 omitted
+
+# reduce 201 omitted
+
+# reduce 202 omitted
+
+# reduce 203 omitted
+
+# reduce 204 omitted
+
+# reduce 205 omitted
+
+# reduce 206 omitted
+
+# reduce 207 omitted
+
+# reduce 208 omitted
+
+# reduce 209 omitted
+
+# reduce 210 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 745)
+  def _reduce_211(val, _values, result)
+     Generator.add_statement_specifier val[0]	
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 747)
+  def _reduce_212(val, _values, result)
+     Generator.add_statement_specifier val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 751)
+  def _reduce_213(val, _values, result)
+     result = [ :ALLOCATOR, val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 753)
+  def _reduce_214(val, _values, result)
+     result = [ :CALLBACK ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 755)
+  def _reduce_215(val, _values, result)
+     result = [ :CONTEXT, val[2].val ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 757)
+  def _reduce_216(val, _values, result)
+     result = [ :DEVIATE ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 759)
+  def _reduce_217(val, _values, result)
+     result = [ :ID, val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 761)
+  def _reduce_218(val, _values, result)
+     result = [ :PROTOTYPE ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 763)
+  def _reduce_219(val, _values, result)
+     result = [ :RESTRICT, val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 764)
+  def _reduce_220(val, _values, result)
+     result = [:SINGLETON] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 765)
+  def _reduce_221(val, _values, result)
+     result = [:IDX_IS_ID] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 766)
+  def _reduce_222(val, _values, result)
+     result = [:ACTIVE] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 768)
+  def _reduce_223(val, _values, result)
+     result = [:GENERATE, val[2].val, val[4].val] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 771)
+  def _reduce_224(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 772)
+  def _reduce_225(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 776)
+  def _reduce_226(val, _values, result)
+      result = [ :NORMAL_ALLOC, val[0], nil, val[2], val[4], val[6] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 778)
+  def _reduce_227(val, _values, result)
+      result = [ :NORMAL_ALLOC, val[0], val[2], val[5], val[7], val[9] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 787)
+  def _reduce_228(val, _values, result)
+    	result = [val[0]]		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 789)
+  def _reduce_229(val, _values, result)
+    	result << val[2]		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 793)
+  def _reduce_230(val, _values, result)
+    	result = [ val[0].val, nil, val[3] ]		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 795)
+  def _reduce_231(val, _values, result)
+    	result = [ val[0].val, val[2].val, val[5] ]		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 799)
+  def _reduce_232(val, _values, result)
+    	result = [val[0].val]		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 801)
+  def _reduce_233(val, _values, result)
+    	result << val[2].val		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 806)
+  def _reduce_234(val, _values, result)
+    			val[0].each { |decl|
+				decl.set_kind( :CONSTANT )
+				Namespace.new_const_decl( decl )
+				decl.check
+			}
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 816)
+  def _reduce_235(val, _values, result)
+    			@@import_C = true
+			Import_C.new( val[2] )
+			@@import_C = false
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 822)
+  def _reduce_236(val, _values, result)
+    			@@import_C = true
+			Import_C.new( val[2], val[4] )
+			@@import_C = false
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 829)
+  def _reduce_237(val, _values, result)
+     Import.new( val[2] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 831)
+  def _reduce_238(val, _values, result)
+     Import.new( val[2], true ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 836)
+  def _reduce_239(val, _values, result)
+     Generate.new( val[2].val, val[4], val[6] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 841)
+  def _reduce_240(val, _values, result)
+    			val[2].each{ |i|       # i:Decl
+				i.set_kind( :TYPEDEF )
+    		}
+			Typedef.new_decl_list( val[1], val[2] )
+			val[2].each{ |i|       # i:Decl
+				i.check
+			}
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 851)
+  def _reduce_241(val, _values, result)
+    			val[5].each{ |i|       # i:Decl
+				i.set_kind( :TYPEDEF )
+			}
+			Typedef.new_decl_list( val[4], val[5] )
+			val[5].each{ |i|       # i:Decl
+				i.check
+			}
+		
+    result
+  end
+.,.,
+
+# reduce 242 omitted
+
+# reduce 243 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 868)
+  def _reduce_244(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 870)
+  def _reduce_245(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 874)
+  def _reduce_246(val, _values, result)
+    val[1].end_of_parse
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 878)
+  def _reduce_247(val, _values, result)
+    result = Namespace.new(val[0].val)
+    result
+  end
+.,.,
+
+# reduce 248 omitted
+
+# reduce 249 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 886)
+  def _reduce_250(val, _values, result)
+     result = NamespacePath.new( val[0].val, false ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 887)
+  def _reduce_251(val, _values, result)
+     result = NamespacePath.new( val[1].val, true ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 889)
+  def _reduce_252(val, _values, result)
+     result = val[0].append!( val[2].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 894)
+  def _reduce_253(val, _values, result)
+     result = val[1].end_of_parse( val[3] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 898)
+  def _reduce_254(val, _values, result)
+    result = Signature.new( val[0].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 904)
+  def _reduce_255(val, _values, result)
+     result = NamedList.new( nil, "function" ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 906)
+  def _reduce_256(val, _values, result)
+     result = val[0].add_item( val[1] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 911)
+  def _reduce_257(val, _values, result)
+    			# val[1]: Decl
+			if val[1].is_function? then
+				result = FuncHead.new( val[1], val[0], false )
+				val[1].set_kind :FUNCHEAD
+				val[1].check
+			else
+				# mikan é¢æ°ã®é
+åãä»¥ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã
+				Generator.error( "G1010 Not function"  )
+				result = nil
+			end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 924)
+  def _reduce_258(val, _values, result)
+    			if val[4].is_function? then
+				result = FuncHead.new( val[4], val[3], true )
+			else
+				Generator.error( "G1011 Not function"  )
+				result = nil
+			end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 937)
+  def _reduce_259(val, _values, result)
+    			val[1].end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 943)
+  def _reduce_260(val, _values, result)
+     result = Celltype.new(val[0].val) 
+    result
+  end
+.,.,
+
+# reduce 261 omitted
+
+# reduce 262 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 952)
+  def _reduce_263(val, _values, result)
+    			if val[0].kind_of? Port then
+				Celltype.new_port( val[0] )
+			end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 958)
+  def _reduce_264(val, _values, result)
+    			if val[3].kind_of? Port then
+				val[3].set_specifier val[1]  # è¨­å®é åºãã
+				Celltype.new_port( val[3] )
+			else
+				# Port ä»¥å¤ã§ã¯æå®å­ã¯ã¨ã©ã¼
+				Generator.error( "G1012 $1 : cannot put specifier here" , val[1] )
+			end
+		
+    result
+  end
+.,.,
+
+# reduce 265 omitted
+
+# reduce 266 omitted
+
+# reduce 267 omitted
+
+# reduce 268 omitted
+
+# reduce 269 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 977)
+  def _reduce_270(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 979)
+  def _reduce_271(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 982)
+  def _reduce_272(val, _values, result)
+     result = [ :INLINE ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 983)
+  def _reduce_273(val, _values, result)
+     result = [ :ALLOCATOR, val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 984)
+  def _reduce_274(val, _values, result)
+     result = [ :OPTIONAL ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 985)
+  def _reduce_275(val, _values, result)
+     result = [ :REF_DESC ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 986)
+  def _reduce_276(val, _values, result)
+     result = [ :DYNAMIC ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 987)
+  def _reduce_277(val, _values, result)
+     result = [ :OMIT ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 990)
+  def _reduce_278(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 991)
+  def _reduce_279(val, _values, result)
+     result = [ val[0] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 992)
+  def _reduce_280(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 993)
+  def _reduce_281(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 997)
+  def _reduce_282(val, _values, result)
+      result = [ :INTERNAL_ALLOC, val[0].val, val[2].val, val[4] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 999)
+  def _reduce_283(val, _values, result)
+      result = [ :RELAY_ALLOC, val[0].val, val[2].val, val[4] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1005)
+  def _reduce_284(val, _values, result)
+     result = Port.new( val[2].val, val[1], val[0] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1007)
+  def _reduce_285(val, _values, result)
+     result = Port.new( val[2].val, val[1], val[0], "[]" ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1009)
+  def _reduce_286(val, _values, result)
+     result = Port.new(val[2].val, val[1], val[0], val[4]) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1011)
+  def _reduce_287(val, _values, result)
+     result = Port.new( val[2].val, val[1], val[0], nil, val[4], val[ 6 ].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1014)
+  def _reduce_288(val, _values, result)
+     result = :CALL 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1015)
+  def _reduce_289(val, _values, result)
+     result = :ENTRY 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1019)
+  def _reduce_290(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+# reduce 291 omitted
+
+# reduce 292 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1031)
+  def _reduce_293(val, _values, result)
+     result = nil 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1035)
+  def _reduce_294(val, _values, result)
+     Celltype.new_attribute( val[0] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1037)
+  def _reduce_295(val, _values, result)
+     Celltype.new_attribute( val[1] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1043)
+  def _reduce_296(val, _values, result)
+    			val[0].each{ |i|       # i:Decl
+				i.set_kind( :ATTRIBUTE )
+				i.check
+			}
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1051)
+  def _reduce_297(val, _values, result)
+    			val[3].each{ |i|       # i:Decl
+				i.set_kind( :ATTRIBUTE )   # è¨­å®é åºãã
+				i.set_specifier_list( [val[1]] )
+				i.check
+			}
+			result = val[3]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1060)
+  def _reduce_298(val, _values, result)
+     result = [:OMIT] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1061)
+  def _reduce_299(val, _values, result)
+     result = [:SIZE_IS,val[2]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1062)
+  def _reduce_300(val, _values, result)
+      result = [:CHOICE,val[3]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1065)
+  def _reduce_301(val, _values, result)
+      result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1066)
+  def _reduce_302(val, _values, result)
+      result = [ val[0] ] 
+    result
+  end
+.,.,
+
+# reduce 303 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1074)
+  def _reduce_304(val, _values, result)
+     result = nil 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1078)
+  def _reduce_305(val, _values, result)
+     Celltype.new_var( val[0] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1080)
+  def _reduce_306(val, _values, result)
+     Celltype.new_var( val[1] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1085)
+  def _reduce_307(val, _values, result)
+    			val[0].each{ |i|       # i:Decl
+				i.set_kind( :VAR )
+				i.check
+			}
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1092)
+  def _reduce_308(val, _values, result)
+    			val[3].each{ |i|       # i:Decl
+				i.set_kind( :VAR )   # è¨­å®é åºãã
+				i.set_specifier_list( [val[1]] )
+				i.check
+			}
+			result = val[3]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1101)
+  def _reduce_309(val, _values, result)
+     result = [:SIZE_IS,val[2]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1107)
+  def _reduce_310(val, _values, result)
+    			Celltype.new_require( val[1], val[3] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1111)
+  def _reduce_311(val, _values, result)
+    			Celltype.new_require( val[3], val[5], val[1].val )
+		
+    result
+  end
+.,.,
+
+# reduce 312 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1119)
+  def _reduce_313(val, _values, result)
+     Factory.set_f_celltype( false ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1120)
+  def _reduce_314(val, _values, result)
+     Factory.set_f_celltype( true ) 
+    result
+  end
+.,.,
+
+# reduce 315 omitted
+
+# reduce 316 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1128)
+  def _reduce_317(val, _values, result)
+     Factory.new( val[0].val, val[2], val[4], nil    ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1130)
+  def _reduce_318(val, _values, result)
+     Factory.new( val[0].val, val[2], val[4], val[6] ) 
+    result
+  end
+.,.,
+
+# reduce 319 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1137)
+  def _reduce_320(val, _values, result)
+     result = [ [ :IDENTIFIER, val[0].val ] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1139)
+  def _reduce_321(val, _values, result)
+     result << [ :IDENTIFIER, val[2].val ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1141)
+  def _reduce_322(val, _values, result)
+     result = [ [ :STRING_LITERAL, val[0].val ] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1143)
+  def _reduce_323(val, _values, result)
+     result << [ :STRING_LITERAL, val[2].val ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1148)
+  def _reduce_324(val, _values, result)
+     Cell.new_def 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1150)
+  def _reduce_325(val, _values, result)
+     result = Cell.end_of_parse true 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1152)
+  def _reduce_326(val, _values, result)
+     result = Cell.end_of_parse false 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1156)
+  def _reduce_327(val, _values, result)
+     result = Cell.new(val[0]) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1160)
+  def _reduce_328(val, _values, result)
+     result = Cell.set_name(val[0].val) 
+    result
+  end
+.,.,
+
+# reduce 329 omitted
+
+# reduce 330 omitted
+
+# reduce 331 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1169)
+  def _reduce_332(val, _values, result)
+     val[3].set_specifier_list( val[1] )  
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1171)
+  def _reduce_333(val, _values, result)
+     val[0].set_specifier_list( [] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1175)
+  def _reduce_334(val, _values, result)
+     result << val[2] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1177)
+  def _reduce_335(val, _values, result)
+     result = [val[0]] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1181)
+  def _reduce_336(val, _values, result)
+     result = [ :THROUGH, val[2], val[4] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1184)
+  def _reduce_337(val, _values, result)
+     result = val[0] 
+    result
+  end
+.,.,
+
+# reduce 338 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1198)
+  def _reduce_339(val, _values, result)
+    			result = Join.new( val[0].val,  -1, val[4] )
+			Cell.new_join( result, true )
+		 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1203)
+  def _reduce_340(val, _values, result)
+    			result = Join.new( val[0].val, val[2], val[5] )
+			Cell.new_join( result, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1208)
+  def _reduce_341(val, _values, result)
+    			result = Join.new( val[0].val, nil, val[2] )
+			Cell.new_join( result, true )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1213)
+  def _reduce_342(val, _values, result)
+    			result = Join.new( val[0].val, nil, [ :COMPOSITE, val[4] ] )
+			Cell.new_join( result, true )
+		
+    result
+  end
+.,.,
+
+# reduce 343 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1224)
+  def _reduce_344(val, _values, result)
+    			rj = ReverseJoin.new( val[0].val, nil, val[2], val[4].val )
+			Cell.new_reverse_join( rj )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1230)
+  def _reduce_345(val, _values, result)
+    			rj = ReverseJoin.new( val[0].val, nil, val[2], val[4].val, val[6] )
+			Cell.new_reverse_join( rj )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1236)
+  def _reduce_346(val, _values, result)
+    			rj = ReverseJoin.new( val[0].val, val[2], val[5], val[7].val )
+			Cell.new_reverse_join( rj )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1242)
+  def _reduce_347(val, _values, result)
+    			rj = ReverseJoin.new( val[0].val, val[2], val[5], val[7].val, val[9] )
+			Cell.new_reverse_join( rj )
+		
+    result
+  end
+.,.,
+
+# reduce 348 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1254)
+  def _reduce_349(val, _values, result)
+    			CompositeCelltype.end_of_parse
+			result = val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1260)
+  def _reduce_350(val, _values, result)
+     result = CompositeCelltype.new(val[0].val) 
+    result
+  end
+.,.,
+
+# reduce 351 omitted
+
+# reduce 352 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1269)
+  def _reduce_353(val, _values, result)
+    			if val[0].kind_of?( Port ) then
+				CompositeCelltype.new_port( val[0] )   # é
+å»¶ãã¦ç»é²
+			end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1275)
+  def _reduce_354(val, _values, result)
+    			if val[3].kind_of?( Port ) then
+				# port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå
+¥ã£ã¦ããªãã®ã§ãä»¥ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã
+				# ç¾ç¶ port, cell ä»¥å¤ã¯æå®å­ãåãä»ããªã
+				# ï¼ãããå°æ¥ä»ã®æãæå®å­ãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼
+				val[3].set_specifier( Generator.get_statement_specifier )
+				CompositeCelltype.new_port( val[3] )   # é
+å»¶ãã¦ç»é² (set_specifier å¾)
+			elsif val[3].kind_of?( Cell ) then
+				# Cell.end_of_parse ã«ã¦è¨­å®
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G1013 unexpected specifier"  )
+			end
+		
+    result
+  end
+.,.,
+
+# reduce 355 omitted
+
+# reduce 356 omitted
+
+# reduce 357 omitted
+
+# reduce 358 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1299)
+  def _reduce_359(val, _values, result)
+    			Generator.add_statement_specifier val[0]
+			result = [ val[0] ]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1304)
+  def _reduce_360(val, _values, result)
+     result = [ :ALLOCATOR, val[2] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1305)
+  def _reduce_361(val, _values, result)
+     result = [ :OMIT ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1306)
+  def _reduce_362(val, _values, result)
+     result = [ :OPTIONAL ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1307)
+  def _reduce_363(val, _values, result)
+     result = [ :REF_DESC ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1308)
+  def _reduce_364(val, _values, result)
+     result = [ :DYNAMIC ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1313)
+  def _reduce_365(val, _values, result)
+    			# CompositeCelltype.new_port( val[0] )
+			result = val[0]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1320)
+  def _reduce_366(val, _values, result)
+     result = nil 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1324)
+  def _reduce_367(val, _values, result)
+     CompositeCelltype.new_attribute( val[0] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1326)
+  def _reduce_368(val, _values, result)
+     CompositeCelltype.new_attribute( val[1] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1331)
+  def _reduce_369(val, _values, result)
+     Cell.new_def 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1333)
+  def _reduce_370(val, _values, result)
+     result = Cell.end_of_parse true 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1335)
+  def _reduce_371(val, _values, result)
+     result = Cell.end_of_parse false 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1340)
+  def _reduce_372(val, _values, result)
+     Cell.new(val[0],true) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1344)
+  def _reduce_373(val, _values, result)
+     Cell.set_name(val[0].val) 
+    result
+  end
+.,.,
+
+# reduce 374 omitted
+
+# reduce 375 omitted
+
+# reduce 376 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1354)
+  def _reduce_377(val, _values, result)
+    	Cell.external_join( val[0].val, val[4].val, true )	
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1356)
+  def _reduce_378(val, _values, result)
+    	Cell.external_join( val[0].val, val[2].val, false )	
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1363)
+  def _reduce_379(val, _values, result)
+    			CompositeCelltype.new_join( val[0].val,
+						val[2].val, val[4].val, :ENTRY )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1368)
+  def _reduce_380(val, _values, result)
+    			CompositeCelltype.new_join( val[2].val,
+						val[4].val, val[6].val, :ENTRY )
+		
+    result
+  end
+.,.,
+
+# reduce 381 omitted
+
+# reduce 382 omitted
+
+# reduce 383 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1384)
+  def _reduce_384(val, _values, result)
+     Region.end_of_parse 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1386)
+  def _reduce_385(val, _values, result)
+     Region.end_of_parse 
+    result
+  end
+.,.,
+
+# reduce 386 omitted
+
+# reduce 387 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1395)
+  def _reduce_388(val, _values, result)
+     Region.new_in_through( val[2].val, val[4].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1397)
+  def _reduce_389(val, _values, result)
+     Region.new_in_through 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1399)
+  def _reduce_390(val, _values, result)
+     Region.new_out_through( val[2].val, val[4].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1401)
+  def _reduce_391(val, _values, result)
+     Region.new_out_through() 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1403)
+  def _reduce_392(val, _values, result)
+     Region.new_to_through( val[2], val[4].val, val[6].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1405)
+  def _reduce_393(val, _values, result)
+     Region.new_to_through( val[2], nil, nil ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1407)
+  def _reduce_394(val, _values, result)
+     Region.set_type( :NODE ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1409)
+  def _reduce_395(val, _values, result)
+     Region.set_type( :LINKUNIT ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1411)
+  def _reduce_396(val, _values, result)
+     Region.set_domain( val[2].val, val[4] ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1413)
+  def _reduce_397(val, _values, result)
+     Region.set_type( :CLASS, val[2].val ) 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1417)
+  def _reduce_398(val, _values, result)
+     result = Region.new( val[0].val ) 
+    result
+  end
+.,.,
+
+# reduce 399 omitted
+
+# reduce 400 omitted
+
+# reduce 401 omitted
+
+# reduce 402 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1428)
+  def _reduce_403(val, _values, result)
+    			obj = val[3]
+			if obj.kind_of?( Cell ) then
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G9999 unexpected specifier"  )
+			end
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1450)
+  def _reduce_404(val, _values, result)
+     result = [ val[0].val ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1455)
+  def _reduce_405(val, _values, result)
+     set_in_specifier 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1457)
+  def _reduce_406(val, _values, result)
+     unset_in_specifier 
+    result
+  end
+.,.,
+
+# reduce 407 omitted
+
+# reduce 408 omitted
+
+# reduce 409 omitted
+
+# reduce 410 omitted
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1471)
+  def _reduce_411(val, _values, result)
+    			TECSGEN::Cell_location.new( val[1], val[3], val[5], val[7], val[9], val[12] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1477)
+  def _reduce_412(val, _values, result)
+    			result = val[0] << val[1]
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1480)
+  def _reduce_413(val, _values, result)
+     result = [] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1484)
+  def _reduce_414(val, _values, result)
+     result = [ val[0], val[2], val[3] ] 
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1489)
+  def _reduce_415(val, _values, result)
+                TECSGEN::Join_location.new( val[2], val[4], val[6], val[8], val[11] )
+		
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1495)
+  def _reduce_416(val, _values, result)
+                result = val[0] << [ val[1], val[3] ]
+          
+    result
+  end
+.,.,
+
+module_eval(<<'.,.,', 'bnf.y.rb', 1497)
+  def _reduce_417(val, _values, result)
+     result = [] 
+    result
+  end
+.,.,
+
+def _reduce_none(val, _values, result)
+  val[0]
+end
+
+end   # class Generator
+
+
+
+# ãã¡ã¤ã« => INCLUDE("header")ã®é
+å
+Include = Hash.new {|hash, key| hash[key] = []}
+
+
+class Token
+
+  attr_accessor :val, :file, :lineno, :col
+
+  def initialize(val, file, lineno, col)
+    @val = val
+    @file = file
+    @lineno = lineno
+    @col = col
+
+  end
+
+  def to_s
+    @val.to_s
+  end
+
+  def to_sym
+    @val.to_sym
+  end
+
+  def get_name
+    @val
+  end
+
+  def locale
+    [@file, @lineno, @col]
+  end
+
+  def eql?(other)
+    if other.is_a? Symbol
+      @val == other
+    elsif other.is_a? Token
+      @val == other.val
+    elsif other.is_a? String
+      @val.to_s == other
+    else
+      raise ArgumentError
+    end
+  end
+
+  alias == eql?
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    print "#{@val}\n"
+  end
+
+end
+
+#= TECSIO
+#  Ruby2.0(1.9) å¯¾å¿ã«ä¼´ãå°å
+¥ããã¯ã©ã¹
+#  SJIS ä»¥å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å
+¥åãã
+class TECSIO
+  def self.foreach(file) # ãã­ãã¯å¼æ° { |line| }
+    pr = Proc.new   # ãã®ã¡ã½ããã®ãã­ãã¯å¼æ°ã pr ã«ä»£å
+¥
+    if $b_no_kcode then
+	  msg = "E".encode $Ruby19_File_Encode
+      if( $Ruby19_File_Encode == "Shift_JIS" )
+
+        # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èª­ã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼
+        # ã³ã¡ã³ãç­ã«å«ã¾ãã SJIS ã«ä¸é©åãªæå­ã³ã¼ãã¯ '?' ã¾ãã¯ REPLACEMENT CHARACTER ã«å¤æãããï¼
+        # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼
+        # æå­ã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæå­åãªãã©ã«ã®ä¸­ã«ãæå­ã³ã¼ããSJIS ä»¥å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã
+        # Ruby 1.8 ã® tecsgen ã§ã¯æå­ã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 ä»¥éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼
+
+        mode = "r:Windows-31J"
+      else
+        mode = "r:#{$Ruby19_File_Encode}"
+      end
+      # mode = "r"
+    else
+	  msg = "E"
+      mode = "r"
+    end
+
+    f = File.open( file, mode )
+    begin
+      f.each{ |line|
+        # dbgPrint line
+        line = str_code_convert( msg, line )
+        pr.call( line )
+      }
+    ensure
+      f.close
+    end
+  end
+
+  #=== æå­ã³ã¼ããç¸éããå ´åä¸è´ããã
+  # msg ã¨ str ã®æå­ã³ã¼ããç¸éããå ´åãstr ã msg ã®æå­ã³ã¼ãã«å¤æãã
+  # å¤æä¸å¯ã®æå­ã³ã¼ãã¯ '?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ
+  #
+  # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ãä½¿ç¨ããã¦ãããã¨ã«æ³¨æï¼
+  #
+  #msg_enc::Encode | String
+  def self.str_code_convert( msg, str )
+    if $b_no_kcode == false then
+      return str                          # Ruby V1.8 ã¾ã§
+    end
+    if msg.encoding != str.encoding then
+      option = { :invalid => :replace, :undef => :replace }   # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯ 0xfffd)
+      # return str.encode( msg.encoding, option )
+      str = str.encode( "utf-8", option )
+      return str.encode( msg.encoding, option )
+    else
+      return str
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.y.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.y.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/bnf.y.rb	(revision 317)
@@ -0,0 +1,2189 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: bnf.y.rb 2562 2016-03-21 11:48:59Z okuma-top $
+#++
+
+class Generator
+rule
+# ãããã¬ãã«ã®æ§æè¦ç´ ã¯component_description
+all: component_description
+
+# Expr
+##########################  å¼  ##########################
+# K&Rã®ææ³(ãã­ã°ã©ãã³ã°è¨èªC ç¬¬2ç ä»é²)ã¨ä¸é¨ç°ãªã
+# argument_expression_list(é¢æ°å¼æ°), assignment_expression(ä»£å
+¥)ããªã
+# å¼ã® result ã¯ããã¹ã¦é
+åã§ç¬¬ä¸è¦ç´ ãè­å¥ã·ã³ãã«ãç¬¬äºè¦ç´ ä»¥ä¸ãå¼æ°
+
+primary_expression
+        : namespace_identifier
+		{ result = [ :IDENTIFIER, val[0] ] }     #1ok
+        | TRUE
+		{ result = [ :BOOL_CONSTANT, true ] }
+        | FALSE
+		{ result = [ :BOOL_CONSTANT, false ] }
+        | INTEGER_CONSTANT
+		{ result = [ :INTEGER_CONSTANT, val[0] ] }
+        | FLOATING_CONSTANT
+		{ result = [ :FLOATING_CONSTANT, val[0] ] }
+        | OCTAL_CONSTANT
+		{ result = [ :OCTAL_CONSTANT, val[0] ] }
+        | HEX_CONSTANT
+		{ result = [ :HEX_CONSTANT, val[0] ] }
+        | CHARACTER_LITERAL
+		{ result = [ :CHARACTER_LITERAL, val[0] ] }
+        | string_literal_list
+		{ result = [ :STRING_LITERAL_LIST, val[0] ] }
+        | '(' expression ')'
+		{ result = [ :PARENTHESES, val[1].get_elements ] }
+
+string_literal_list
+        : STRING_LITERAL
+        | string_literal_list STRING_LITERAL
+		{
+			# é£æ¥ããæå­åã1ã¤ã®æå­åã«ã¾ã¨ãã
+			str = "\"" + val[0].val.gsub( /\"(.*)\"/, "\\1" ) + val[1].val.gsub( /\"(.*)\"/, "\\1" ) + "\""
+			result = Token.new( str, val[0].file, val[0].lineno, val[0].col )
+		}
+
+# é¢æ°å¼ã³åºãã¨å¾ç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®å­ããªã
+postfix_expression
+        : primary_expression
+        | postfix_expression '[' expression ']'
+		{ result = [ :OP_SUBSC, val[0], val[2] ] }
+        | postfix_expression '.' IDENTIFIER
+		{ result = [ :OP_DOT, val[0], val[2] ] }
+        | postfix_expression '->' IDENTIFIER
+		{ result = [ :OP_REF, val[0], val[2] ] }
+
+# åç½®ã¤ã³ã¯ãªã¡ã³ãããã¯ãªã¡ã³ãæ¼ç®å­ããªã
+unary_expression
+        : postfix_expression
+        | unary_operator cast_expression
+		{ result = [ val[0], val[1] ] }
+        | SIZEOF unary_expression
+		{ result = [ :OP_SIZEOF_EXPR, val[1] ] }
+        | SIZEOF '(' type_name ')'
+		{ result = [ :OP_SIZEOF_TYPE, val[1] ] }
+
+unary_operator
+        : '&'	{ result = :OP_U_AMP }
+        | '*'	{ result = :OP_U_ASTER }
+        | '+'	{ result = :OP_U_PLUS }
+        | '-'	{ result = :OP_U_MINUS }
+        | '~'	{ result = :OP_U_TILDE }
+        | '!'	{ result = :OP_U_EXCLAM }
+
+cast_expression
+        : unary_expression
+        | '(' type_name ')' cast_expression
+		{  result = [ :CAST, val[1], val[3] ] }
+
+multiplicative_expression
+        : cast_expression
+        | multiplicative_expression '*' cast_expression
+		{ result = [ :OP_MULT, val[0], val[2] ]  }
+        | multiplicative_expression '/' cast_expression
+		{ result = [ :OP_DIV, val[0], val[2] ]  }
+        | multiplicative_expression '%' cast_expression
+		{ result = [ :OP_REMAIN, val[0], val[2] ]  }
+
+additive_expression
+        : multiplicative_expression
+        | additive_expression '+' multiplicative_expression
+		{ result = [ :OP_ADD, val[0], val[2] ]  }
+        | additive_expression '-' multiplicative_expression
+		{ result = [ :OP_SUB, val[0], val[2] ]  }
+
+shift_expression
+        : additive_expression
+        | shift_expression '<<' additive_expression
+		{ result = [ :OP_LSFT, val[0], val[2] ]  }
+        | shift_expression '>>' additive_expression
+		{ result = [ :OP_RSFT, val[0], val[2] ]  }
+
+relational_expression
+        : shift_expression
+        | relational_expression '<' shift_expression
+		{ result = [ :OP_LT, val[0], val[2] ]  }
+        | relational_expression '>' shift_expression
+		{ result = [ :OP_GT, val[0], val[2] ]  }
+        | relational_expression '<=' shift_expression
+		{ result = [ :OP_LE, val[0], val[2] ]  }
+        | relational_expression '>=' shift_expression
+		{ result = [ :OP_GE, val[0], val[2] ]  }
+
+equality_expression
+        : relational_expression
+        | equality_expression '==' relational_expression
+		{ result = [ :OP_EQ, val[0], val[2] ]  }
+        | equality_expression '!=' relational_expression
+		{ result = [ :OP_NE, val[0], val[2] ]  }
+
+and_expression
+        : equality_expression
+        | and_expression '&' equality_expression
+		{ result = [ :OP_AND, val[0], val[2] ]  }
+
+exclusive_or_expression
+        : and_expression
+        | exclusive_or_expression '^' and_expression
+		{ result = [ :OP_EOR, val[0], val[2] ]  }
+
+inclusive_or_expression
+        : exclusive_or_expression
+        | inclusive_or_expression '|' exclusive_or_expression
+		{ result = [ :OP_OR, val[0], val[2] ]  }
+
+logical_and_expression
+        : inclusive_or_expression
+        | logical_and_expression '&&' inclusive_or_expression
+		{ result = [ :OP_LAND, val[0], val[2] ]  }
+
+logical_or_expression
+        : logical_and_expression
+        | logical_or_expression '||' logical_and_expression
+		{ result = [ :OP_LOR, val[0], val[2] ]  }
+
+conditional_expression
+        : logical_or_expression
+        | logical_or_expression '?' expression ':' conditional_expression
+		{ result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ]  }
+
+
+# ã³ã³ãæ¼ç®å­ãä½¿ããªã
+expression
+        : conditional_expression
+		{
+			result = Expression.new( val[0] )
+			# result.print
+		}
+
+constant_expression
+        : conditional_expression
+		{
+			result = Expression.new( val[0] )
+			# result.print
+
+			# res = result.eval_const( nil )
+			# if res then
+			#   puts "val: #{res}"
+			# else
+			#   puts "val: nil"
+			# end
+		}
+
+
+
+# Types
+##########################  å®£è¨  ##########################
+# å®£è¨ãK&Rã¨ä¸é¨ç°ãªã
+
+# declarationã¯ã»ã«ã®å±æ§ã§ä½¿ããã
+# K&Rã¨ã®éã: storage classãæå®ã§ããªããåãçç¥ã§ããªã
+declaration
+        : type_specifier_qualifier_list init_declarator_list ';'
+		{
+			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+			}
+			result = val[1]
+		}
+
+# declaration_specifiersã¯é¢æ°ã®ãã©ã¡ã¼ã¿ã§ä½¿ããããã
+# type_specifier_qualifier_listã§ååãããããªã
+# Oyama
+# const, volatile ã¯åç¬ã§åã«ãªããªãã®ã§å¤å½¢
+# const ã¨ volatile ãåå±
+ãããã¨ã¯ãªãã®ã§ãç¹°è¿ãæå®ã§ããªãããã«ãã
+# type_specifier ãç¹°è¿ãæå®ã§ããå¿
+è¦ã¯ãªã (singed ãªã©åç¬ã§åã«ã¯ãªããªã)
+declaration_specifiers
+        : type_specifier
+        | type_qualifier type_specifier
+		{
+			val[1].set_qualifier( val[0] )
+			result = val[1]
+		}
+
+init_declarator_list
+        : init_declarator
+		{ result = [val[0]] }
+        | init_declarator_list ',' init_declarator
+		{ result << val[2] }
+
+init_declarator
+        : declarator
+        | declarator '=' initializer
+		{ val[0].set_initializer( val[2] ) }
+
+# INT8ããä¸ã¯K&Rã«ãªã
+# Oyama
+# signed, unsigned ã¯åç¬ã§åã«ãªããªãã®ã§ãæ§æè¦ç´ ã¨ãã¦åé¢
+type_specifier
+        : VOID	{ result = VoidType.new }
+        | FLOAT32_T	{ result = FloatType.new(32) }
+        | DOUBLE64_T	{ result = FloatType.new(64) }
+        | struct_specifier
+        | enum_specifier
+        | TYPE_NAME	{ result = DefinedType.new( val[0].val ) }
+#        | IDENTIFIER	{ result = DefinedType.new( val[0].val ) }   # reduce/reduce conflict ãèµ·ãã£ã¦ãã¾ã
+        | sign_int_type
+        | char_type
+        | BOOL_T	{ result = BoolType.new }
+#        | BOOL	{
+#			Generator.warning( "W5001 bool: obsolete type. use bool_t"  )
+#			result = BoolType.new
+#		}
+        | FLOAT	{
+			Generator.warning( "W5002 float: obsolete type. use float32_t"  )
+			result = FloatType.new(32)
+		}
+        | DOUBLE {
+			Generator.warning( "W5003 double: obsolete type. use double64_t"  )
+			result = FloatType.new(64)
+		}
+        | DESCRIPTOR '(' namespace_identifier ')' {          # namespace_identifier: signature name
+			result = DescriptorType.new( val[2] )
+		}
+
+char_type
+        : CHAR_T	{ result = IntType.new( -1 ) }
+        | SCHAR_T
+		{
+			result = IntType.new( -1 )
+			result.set_sign( :SIGNED, true )
+		}
+        | UCHAR_T
+		{
+			result = IntType.new( -1 )
+			result.set_sign( :UNSIGNED, true )
+		}
+
+int_type
+        : CHAR	{
+			# Generator.warning( "W5004 char: obsolete type. use char_t"  )
+			result = IntType.new( -11 )
+		}
+        | SHORT	{ result = IntType.new( -2 ) }
+        | INT		{ result = IntType.new( -3 ) }
+        | LONG	{ result = IntType.new( -4 ) }
+#        | INTPTR	{ result = IntType.new( -5 ) }
+#        | INT8	{
+#			Generator.warning( "W5005 int8: obsolete. use int8_t"  )
+#			result = IntType.new(  8 )
+#		}
+#        | INT16	{
+#			Generator.warning( "W5006 int16: obsolete. use int16_t"  )
+#			result = IntType.new( 16 )
+#		}
+#        | INT32	{
+#			Generator.warning( "W5007 int32: obsolete. use int32_t"  )
+#			result = IntType.new( 32 )
+#		}
+#        | INT64
+#		{
+#			Generator.warning( "W5008 int64: obsolete. use int64_t"  )
+#			result = IntType.new( 64 )
+#		}
+#        | INT128
+#		{
+#			Generator.warning( "W5009 int64: obsolete. use int64_t"  )
+#			result = IntType.new( 128 )
+#		}
+        | INT8_T	{ result = IntType.new( 8 ) }
+        | INT16_T	{ result = IntType.new( 16 ) }
+        | INT32_T	{ result = IntType.new( 32 ) }
+        | INT64_T	{ result = IntType.new( 64 ) }
+        | INT128_T	{ result = IntType.new( 128 ) }
+        | UINT8_T
+		{
+			result = IntType.new( 8 )
+			result.set_sign( :UNSIGNED, true )
+		}
+        | UINT16_T
+		{
+			result = IntType.new( 16 )
+			result.set_sign( :UNSIGNED, true )
+		}
+        | UINT32_T
+		{
+			result = IntType.new( 32 )
+			result.set_sign( :UNSIGNED, true )
+		}
+        | UINT64_T
+		{
+			result = IntType.new( 64 )
+			result.set_sign( :UNSIGNED, true )
+		}
+        | UINT128_T
+		{
+			result = IntType.new( 128 )
+			result.set_sign( :UNSIGNED, true )
+		}
+
+sign    # TECS ã§ã¯ signed, unsigned åç¬ã§ã¯åã«ã§ããªã
+        : SIGNED	{ result = :SIGNED }
+        | UNSIGNED	{ result = :UNSIGNED }
+
+# result[0] :CHAR ãªã©ã®ãã¼ã¯ã³ãresult[1] :CONST, :VOLATILE ãªã©
+sign_int_type
+        : sign int_type
+		{
+			val[1].set_sign( val[0] )
+			result = val[1]
+		}
+        | int_type
+
+# K&Rã®struct_or_union_specifierã«ç¸å½ããããunionã¯ä½¿ããªã
+struct_specifier		# mikan
+        : STRUCT struct_tag '{'
+		{ StructType.set_define( true )  }
+	   struct_declaration_list '}'
+		{
+			StructType.end_of_parse
+			result = val[1]
+		}
+        | STRUCT
+		{
+			result = StructType.new()
+			StructType.set_define( true )
+		}
+	   '{' struct_declaration_list '}'
+		{
+			StructType.end_of_parse
+			result = val[1]
+		}
+        | STRUCT struct_tag   # mikan struct_tag ã¯ namespace å¯¾å¿ãå¿
+è¦
+		{
+			StructType.set_define( false )
+			StructType.end_of_parse
+			result = val[1]
+		}
+
+struct_declaration_list
+        : struct_declaration
+        | struct_declaration_list struct_declaration
+
+struct_tag:
+	IDENTIFIER
+		{ result = StructType.new( val[0].val ) }
+
+# ãã¤ã³ã¿ä¿®é£¾å­ãè¿½å 
+struct_declaration
+        :                                type_specifier_qualifier_list struct_declarator_list ';'
+		{
+			val[1].each { |i|	# i: Decl
+				i.set_type( val[0] )
+				i.set_kind( :MEMBER )
+				i.check
+				StructType.new_member( i )
+			}
+			result = val[1]
+		}
+        | spec_L pointer_specifier_list spec_R type_specifier_qualifier_list struct_declarator_list ';'
+		{
+			val[4].each { |i|	# i: Decl
+				i.set_type( val[3] )
+				i.set_kind( :MEMBER )
+  				i.set_specifier_list val[1]
+				i.check
+				StructType.new_member( i )
+			}
+			result = val[4]
+		}
+
+pointer_specifier_list
+        : pointer_specifier                               { result = [ val[0] ] }
+        | pointer_specifier_list ',' pointer_specifier    { result <<  val[2] }
+
+pointer_specifier
+        : STRING				{ result = [:STRING,-1] }
+        | STRING   '(' expression ')'	{ result = [:STRING,val[2]] }
+        | SIZE_IS  '(' expression ')'	{ result = [:SIZE_IS,val[2]] }
+        | COUNT_IS '(' expression ')'	{ result = [:COUNT_IS,val[2]] }
+
+
+# K&Rã®specifier_qualifier_listã¨åã
+# ååãã¾ãããããã£ãã®ã§type_ãä»ãã
+type_specifier_qualifier_list
+# Oyama type_specifier ãç¹°ãè¿ãã¦æå®ãããã¨ã¯ãªããªã£ã (sign_int_type ã¨ããããï¼
+#        : type_specifier type_specifier_qualifier_list
+        : type_specifier
+        | type_qualifier type_specifier_qualifier_list
+		{
+			val[1].set_qualifier( val[0] )
+			result = val[1]
+		}
+# mikan Oyama type_qualifier ã ãã§ã¯åæå®ã«ãªããªã : æ§æã¨ã©ã¼ã¨ãããããæå³ã¨ã©ã¼ã¨ããæ¹ãè¦ªå
+#        | type_qualifier
+
+
+struct_declarator_list
+        : struct_declarator
+		{ result = [ val[0] ] }
+        | struct_declarator_list ',' struct_declarator
+		{ result << val[2] }
+
+# ããããã£ã¼ã«ãã¯ä½¿ããªã
+struct_declarator
+        : declarator
+
+# enumã®ç¨®é¡ãè¿½å 
+enum_specifier		# mikan
+        : enum_type            '{' enumerator_list '}'
+        | enum_type IDENTIFIER '{' enumerator_list '}'
+        | enum_type IDENTIFIER
+
+enum_type
+        : ENUM	{ result = EnumType.new( -1 ) }
+        | ENUM8	{ result = EnumType.new( 8 ) }
+        | ENUM16	{ result = EnumType.new( 16 ) }
+        | ENUM32	{ result = EnumType.new( 32 ) }
+        | ENUM64	{ result = EnumType.new( 64 ) }
+        | ENUM128	{ result = EnumType.new( 128 ) }
+
+enumerator_list
+        : enumerator
+        | enumerator_list ',' enumerator
+
+enumerator
+        : IDENTIFIER
+        | IDENTIFIER '=' constant_expression
+
+type_qualifier
+        : CONST	{ result = :CONST }
+        | VOLATILE	{ result = :VOLATILE }
+
+declarator
+        : pointer direct_declarator
+		{
+			val[1].set_type( val[0] )
+			result = val[1]
+		}
+        | direct_declarator
+
+direct_declarator		# mikan
+        : IDENTIFIER
+		{ result = Decl.new( val[0].val ) }
+        | '(' declarator ')'
+		{ result = val[1] }
+        | direct_declarator '[' constant_expression ']'
+		{
+			val[0].set_type( ArrayType.new( val[2] ) )
+			result = val[0]
+		}
+        | direct_declarator '[' ']'
+		{
+			val[0].set_type( ArrayType.new )
+			result = val[0]
+		}
+        | direct_declarator '(' parameter_type_list ')'
+		{
+			val[0].set_type( FuncType.new( val[2] ) )
+			result = val[0]
+		}
+#        | direct_declarator '(' identifier_list ')'  # ããã¯ä½ã®ããã«å¿
+è¦ï¼ 060211
+        | direct_declarator '(' ')'
+		{
+			Generator.warning( "W5010 need 'void' for no parameter"  )
+			val[0].set_type( FuncType.new )
+			result = val[0]
+		}
+
+pointer
+        : '*'
+		{ result = PtrType.new }
+        | '*' type_qualifier
+		{
+			result = PtrType.new
+			result.set_qualifier( val[1] )
+		}
+        | '*' pointer
+		{
+			val[1].set_type(PtrType.new)
+			result = val[1]
+		}
+        | '*' type_qualifier pointer
+		{
+			ptrtype = PtrType.new
+			ptrtype.set_qualifier( val[1] )
+			val[2].set_type( ptrtype )
+			result = val[2]
+		}
+
+
+parameter_type_list
+        : parameter_list
+        | parameter_list ',' '...'
+		# mikan å¯å¤é·ãã©ã¡ã¼ã¿
+
+parameter_list
+        : parameter_declaration
+		{ result = ParamList.new( val[0] ) }
+        | parameter_list ',' parameter_declaration
+		{
+			val[0].add_param( val[2] )
+			# result = val[0] ä¸è¦
+		}
+
+
+# ãã©ã¡ã¼ã¿ä¿®é£¾å­ãè¿½å 
+parameter_declaration
+#        : spec_L parameter_specifier_list spec_R declaration_specifiers declarator
+        : parameter_specifier_list_bracket declaration_specifiers  declarator
+		{
+			val[2].set_kind( :PARAMETER )
+			paramdecl = ParamDecl.new( val[2], val[1], val[0] )
+			val[2].check
+			result = paramdecl
+		}
+
+	# ä»¥ä¸ã¯ã¨ã©ã¼ã¨ãã
+        | declaration_specifiers declarator # parameter_specifier ãªãã¯æ±ããªã
+		{
+			Generator.error( "G1001 need specifier for \'$1\'" , val[1].get_name )
+			result = nil
+		}
+        | declaration_specifiers	# ä»®å¼æ°ãªãã¯ãã¨ããããæ±ããªã 060210
+		{
+			unless val[0].instance_of?( VoidType ) then
+				Generator.error( "G1002 need parameter name"  )
+			end
+			result = nil
+		}
+#        | '[' parameter_specifier_list ']' declaration_specifiers # å 060210
+        | parameter_specifier_list_bracket declaration_specifiers # å 060210
+		{
+			unless val[1].instance_of?( VoidType ) then
+				Generator.error( "G1003 need parameter name"  )
+			end
+			result = nil
+		}
+
+parameter_specifier_list_bracket
+        :  spec_L parameter_specifier_list spec_R { result = val[1] }
+#        :  '[' parameter_specifier_list  ']'  { result = val[1] }
+
+parameter_specifier_list
+        : parameter_specifier	{ result = val[0] }
+        | parameter_specifier_list ',' parameter_specifier
+		{ result = result + val[2] }
+
+parameter_specifier
+        : IN					{ result = [ [:IN]  ] }
+        | OUT					{ result = [ [:OUT] ] }
+        | INOUT					{ result = [ [:INOUT] ] }
+        | SEND     '(' namespace_identifier ')'	{ result = [ [:SEND,   val[2]] ] }   #1ok allocator
+        | RECEIVE  '(' namespace_identifier ')'	{ result = [ [:RECEIVE,val[2]] ] }   #1ok allocator
+        | STRING				{ result = [ [:STRING,nil] ] }
+        | STRING   '(' expression ')'	{ result = [ [:STRING,  val[2]] ] }
+        | SIZE_IS  '(' expression ')'	{ result = [ [:SIZE_IS, val[2]] ] }
+        | SIZE_IS  '(' expression ',' constant_expression ')'
+		{
+			result = [ [:SIZE_IS,val[2]], [:MAX_IS, val[4]] ]
+		}
+        | COUNT_IS '(' expression ')'	{ result = [ [:COUNT_IS,val[2]] ] }
+        | NULLABLE		{ result = [ [:NULLABLE] ] }
+
+type_name
+        : type_specifier_qualifier_list
+        | type_specifier_qualifier_list abstract_declarator
+		{
+			if val[1] then
+				val[1].set_type( val[0] )
+				result = val[1]
+			else
+				# ã¨ã©ã¼ï¼ä»®ã§ val[0] ãè¿ã
+				result = val[0]
+			end
+		}
+		# mikan abstract_declarator ã pointer ä»¥å¤ã§ã¯ãã¾ãåããªããã¨ãããã '*' CAST ã®ã¿æã£ã
+
+abstract_declarator		# mikan
+        : pointer
+        | direct_abstract_declarator
+        | pointer direct_abstract_declarator
+
+direct_abstract_declarator
+        : '(' abstract_declarator ')'
+		{ result = val[1] }  # é¢æ°ãã¤ã³ã¿åãæã
+        | '[' ']'
+		{
+			Generator.error( "G1004 impossible array type"  )
+			result = nil
+		}
+        | '[' constant_expression ']'
+		{
+			Generator.error( "G1005 impossible array type"  )
+			result = nil
+		}
+        | direct_abstract_declarator '[' ']'
+		{
+			Generator.error( "G1006 impossible array type"  )
+			result = nil
+		}
+        | direct_abstract_declarator '[' constant_expression ']'
+		{
+			Generator.error( "G1007 impossible array type"  )
+			result = nil
+		}
+        | '(' ')'
+		{
+			Generator.error( "G1008 impossible function type"  )
+			result = nil
+		}
+        | '(' parameter_type_list ')'
+        | direct_abstract_declarator '(' ')'
+		{
+			Generator.warning( "W5011 need 'void' for no parameter"  )
+			val[0].set_type( FuncType.new )
+			result = val[0]
+		}
+        | direct_abstract_declarator '(' parameter_type_list ')'
+		{
+			val[0].set_type( FuncType.new( val[2] ) )
+			result = val[0]
+		}
+
+# assignment_expressionãconstant_expressionã«å¤æ´
+initializer			# mikan
+        : constant_expression
+		{ result = val[0] }
+        | '{' initializer_list '}'
+		{ result = val[1] }
+        | '{' initializer_list ',' '}'
+		{ result = val[1] }
+#        | C_EXP '(' STRING_LITERAL ')'
+        | C_EXP '(' string_literal_list ')'
+		{ result = C_EXP.new( val[2] ) }
+
+initializer_list
+        : initializer
+		{
+			result = [ val[0] ]
+		}
+        | initializer_list ',' initializer
+		{
+			val[0] << val[2]
+			result = val[0]
+		}
+
+
+##########################  ããããã¯CDLç¬èª  ##########################
+
+#ãããã¬ãã«ã®æ§æè¦å
+#ã³ã³ãã¼ãã³ãè¨è¿°
+component_description
+        : component_description specified_statement
+        | component_description location_information
+        | 
+
+specified_statement
+        : statement
+        | spec_L statement_specifier_list spec_R statement
+		{
+			obj = val[3]
+			if obj.kind_of?( Cell ) || obj.kind_of?( Signature ) || obj.kind_of?( Celltype ) || obj.kind_of?( CompositeCelltype )then
+                                # cell, signature ä»¥å¤ã¯ãæå®å­ãç½®ããªã
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G1009 unexpected specifier"  )
+			end
+		}
+		# ããã¨åãè¨è¿°ã composite_celltype ã«ããã
+
+statement
+        : typedef
+        | const_statement
+        | namespace
+        | signature
+        | celltype
+        | cell
+        | composite_celltype
+        | enum_specifier ';'
+        | struct_specifier ';'
+        | region
+        | import
+        | import_C
+        | signature_plugin
+        | error   # ã¨ã©ã¼åå¾©ãã¤ã³ã
+
+	
+statement_specifier_list
+        : statement_specifier
+		{ Generator.add_statement_specifier val[0]	}
+        | statement_specifier_list ',' statement_specifier
+		{ Generator.add_statement_specifier val[2] }
+
+statement_specifier
+        : ALLOCATOR '(' alloc_list ')'                       # cell
+		{ result = [ :ALLOCATOR, val[2] ] }
+        | CALLBACK                                           # signature
+		{ result = [ :CALLBACK ] }
+        | CONTEXT '(' string_literal_list ')'                # signature
+		{ result = [ :CONTEXT, val[2].val ] }
+        | DEVIATE                                            # signature
+		{ result = [ :DEVIATE ] }
+        | ID '(' constant_expression ')'                     # cell
+		{ result = [ :ID, val[2] ] }
+        | PROTOTYPE                                          # cell
+		{ result = [ :PROTOTYPE ] }
+        | RESTRICT  '(' restrict_list ')'                    # cell
+		{ result = [ :RESTRICT, val[2] ] }
+        | SINGLETON  { result = [:SINGLETON] }               # celltype, composite
+        | IDX_IS_ID  { result = [:IDX_IS_ID] }               # celltype, composite (composite: no-effective)
+        | ACTIVE     { result = [:ACTIVE] }                  # celltype, composite
+        | GENERATE '(' plugin_name ',' plugin_arg  ')'       # celltype, cell
+		{ result = [:GENERATE, val[2].val, val[4].val] }
+
+alloc_list
+        : alloc			{ result = [ val[0] ] }
+        | alloc_list ',' alloc	{ result << val[2] }
+
+alloc
+        : IDENTIFIER '.' IDENTIFIER '.' IDENTIFIER '=' initializer
+		{  result = [ :NORMAL_ALLOC, val[0], nil, val[2], val[4], val[6] ] }
+        | IDENTIFIER '[' constant_expression ']' '.' IDENTIFIER '.' IDENTIFIER '=' initializer
+		{  result = [ :NORMAL_ALLOC, val[0], val[2], val[5], val[7], val[9] ] }
+# mikan å°æ¥çãªæ¡å¼µ ('*' ã§ã¾ã¨ãã¦æå®å¯è½ã¨ãã)
+#        | IDENTIFIER '.' IDENTIFIER '.' '*'        '=' initializer
+#		{  result = [ val[0], val[ ], val[ ], val[ ] ] }
+#        | IDENTIFIER '.' '*' '.' '*'               '=' initializer
+#		{  result = [ val[0], val[ ], val[ ], val[ ] ] }
+
+restrict_list
+        : restrict
+		{	result = [val[0]]		}
+        | restrict_list ',' restrict
+		{	result << val[2]		}
+
+restrict
+        : port_name '=' '{' region_name_list '}'
+		{	result = [ val[0].val, nil, val[3] ]		}
+        | port_name '.' IDENTIFIER '=' '{' region_name_list '}'
+		{	result = [ val[0].val, val[2].val, val[5] ]		}
+
+region_name_list
+        : IDENTIFIER
+		{	result = [val[0].val]		}
+        | region_name_list ',' IDENTIFIER
+		{	result << val[2].val		}
+
+const_statement
+        : declaration   # å®æ°å®ç¾©
+		{
+			val[0].each { |decl|
+				decl.set_kind( :CONSTANT )
+				Namespace.new_const_decl( decl )
+				decl.check
+			}
+		}
+
+import_C
+        : IMPORT_C '(' STRING_LITERAL ')' ';'
+		{
+			@@import_C = true
+			Import_C.new( val[2] )
+			@@import_C = false
+		}
+        | IMPORT_C '(' STRING_LITERAL ',' STRING_LITERAL ')' ';'
+		{
+			@@import_C = true
+			Import_C.new( val[2], val[4] )
+			@@import_C = false
+		}
+
+import
+        : IMPORT '(' STRING_LITERAL ')' ';'
+		{ Import.new( val[2] ) }
+        | IMPORT '(' AB_STRING_LITERAL ')' ';'
+		{ Import.new( val[2], true ) }
+
+signature_plugin
+#        : GENERATE '(' plugin_name ',' namespace_identifier ',' STRING_LITERAL ')' ';'  #1ok signature plugin
+        : GENERATE '(' plugin_name ',' namespace_identifier ',' plugin_arg ')' ';'  #1ok signature plugin
+		{ Generate.new( val[2].val, val[4], val[6] ) }
+
+typedef
+        : TYPEDEF type_specifier_qualifier_list declarator_list ';'
+		{
+			val[2].each{ |i|       # i:Decl
+				i.set_kind( :TYPEDEF )
+    		}
+			Typedef.new_decl_list( val[1], val[2] )
+			val[2].each{ |i|       # i:Decl
+				i.check
+			}
+		}
+        | TYPEDEF '[' typedef_specifier ']' type_specifier_qualifier_list declarator_list ';'
+		{
+			val[5].each{ |i|       # i:Decl
+				i.set_kind( :TYPEDEF )
+			}
+			Typedef.new_decl_list( val[4], val[5] )
+			val[5].each{ |i|       # i:Decl
+				i.check
+			}
+		}
+		# mikan   typedef_specifier æªå¦ç½®
+
+
+typedef_specifier
+        : STRING
+        | STRING '(' expression ')'
+
+declarator_list
+        : declarator
+		{ result = [ val[0] ] }
+        | declarator_list ',' declarator
+		{ result << val[2] }
+
+namespace
+        : NAMESPACE namespace_name '{' statement_list '}' ';'
+		{val[1].end_of_parse}
+
+namespace_name
+        : IDENTIFIER
+		{result = Namespace.new(val[0].val)}
+		# namespace ã¤ã³ã¹ã¿ã³ã¹ã« statement ãè¨æ¶ãããããããã§çæ
+
+statement_list
+        : specified_statement
+        | statement_list specified_statement
+
+namespace_identifier
+        : IDENTIFIER		{ result = NamespacePath.new( val[0].val, false ) }
+        | '::' IDENTIFIER	{ result = NamespacePath.new( val[1].val, true ) }
+        | namespace_identifier '::' IDENTIFIER
+		{ result = val[0].append!( val[2].val ) }
+
+#ã·ã°ããã£
+signature
+        : SIGNATURE signature_name '{' function_head_list '}' ';'
+		{ result = val[1].end_of_parse( val[3] ) }
+
+signature_name
+        : IDENTIFIER
+		{result = Signature.new( val[0].val ) }
+
+function_head_list     # result:  function_head ã®é
+å
+#        : function_head
+#		{ result = NamedList.new( val[0], "function" ) }
+        :
+		{ result = NamedList.new( nil, "function" ) }
+        | function_head_list function_head
+		{ result = val[0].add_item( val[1] ) }
+
+function_head
+        :               type_specifier_qualifier_list declarator ';'
+		{
+			# val[1]: Decl
+			if val[1].is_function? then
+				result = FuncHead.new( val[1], val[0], false )
+				val[1].set_kind :FUNCHEAD
+				val[1].check
+			else
+				# mikan é¢æ°ã®é
+åãä»¥ä¸ã®ã¡ãã»ã¼ã¸ã«ãªã
+				Generator.error( "G1010 Not function"  )
+				result = nil
+			end
+		}
+        | spec_L ONEWAY spec_R type_specifier_qualifier_list declarator ';'
+		{
+			if val[4].is_function? then
+				result = FuncHead.new( val[4], val[3], true )
+			else
+				Generator.error( "G1011 Not function"  )
+				result = nil
+			end
+		}
+
+
+#ã»ã«ã¿ã¤ã
+celltype
+        : CELLTYPE celltype_name '{' celltype_statement_list '}' ';'
+		{
+			val[1].end_of_parse
+			result = val[1]
+		}
+
+celltype_name
+        : IDENTIFIER
+		{ result = Celltype.new(val[0].val) }
+
+celltype_statement_list
+        : specified_celltype_statement
+        | celltype_statement_list specified_celltype_statement
+
+specified_celltype_statement
+        : celltype_statement
+		{
+			if val[0].kind_of? Port then
+				Celltype.new_port( val[0] )
+			end
+		}
+        | spec_L celltype_statement_specifier_list spec_R celltype_statement
+		{
+			if val[3].kind_of? Port then
+				val[3].set_specifier val[1]  # è¨­å®é åºãã
+				Celltype.new_port( val[3] )
+			else
+				# Port ä»¥å¤ã§ã¯æå®å­ã¯ã¨ã©ã¼
+				Generator.error( "G1012 $1 : cannot put specifier here" , val[1] )
+			end
+		}
+
+celltype_statement
+        : port
+        | attribute
+        | var
+        | require
+        | factory
+#        | error       # ã¨ã©ã¼åå¾©ãã¤ã³ã  (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼åå¾©ã¯åããã)
+
+celltype_statement_specifier_list
+        : celltype_statement_specifier
+		{ result = [ val[0] ] }
+        | celltype_statement_specifier_list ',' celltype_statement_specifier
+		{ result << val[2] }
+
+celltype_statement_specifier
+        : INLINE { result = [ :INLINE ] }
+        | ALLOCATOR '(' alloc_list2 ')'    { result = [ :ALLOCATOR, val[2] ] }
+        | OPTIONAL { result = [ :OPTIONAL ] }
+        | REF_DESC { result = [ :REF_DESC ] }
+        | DYNAMIC { result = [ :DYNAMIC ] }
+        | OMIT { result = [ :OMIT ] }
+
+alloc_list2
+        : alloc2			{ result = [ val[0] ] }    # åãå£ã®ã¢ã­ã±ã¼ã¿æå®
+        | alloc				{ result = [ val[0] ] }    # å
+é¨ã»ã«ã®ã¢ã­ã±ã¼ã¿æå®
+        | alloc_list2 ',' alloc2	{ result << val[2] }
+        | alloc_list2 ',' alloc		{ result << val[2] }
+
+alloc2
+        : IDENTIFIER '.' IDENTIFIER '=' initializer    # å
+é¨ã¢ã­ã±ã¼ã¿ (ãããã©åãã¢ã­ã±ã¼ã¿)æå®
+		{  result = [ :INTERNAL_ALLOC, val[0].val, val[2].val, val[4] ] }
+        | IDENTIFIER '.' IDENTIFIER '<=' initializer   # å¤æ®µãªã¬ã¼ã¢ãã«åãã¢ã­ã±ã¼ã¿æå®
+		{  result = [ :RELAY_ALLOC, val[0].val, val[2].val, val[4] ] }
+
+
+#å¼ã³å£ãåãå£
+port
+        : port_type namespace_signature_name port_name ';'
+		{ result = Port.new( val[2].val, val[1], val[0] ) }
+        | port_type namespace_signature_name port_name '[' ']' ';'
+		{ result = Port.new( val[2].val, val[1], val[0], "[]" ) }
+        | port_type namespace_signature_name port_name '[' array_size ']' ';'
+		{ result = Port.new(val[2].val, val[1], val[0], val[4]) }
+        | port_type namespace_signature_name port_name '<=' namespace_identifier '.' IDENTIFIER ';'    #1ok reverse require
+		{ result = Port.new( val[2].val, val[1], val[0], nil, val[4], val[ 6 ].val ) }
+
+port_type
+        : CALL	{ result = :CALL }
+        | ENTRY	{ result = :ENTRY }
+
+namespace_signature_name
+        : namespace_identifier  #1ok
+		{ result = val[0] }
+
+port_name
+        : IDENTIFIER
+
+array_size
+        : constant_expression
+
+
+#å±æ§
+attribute
+        : ATTRIBUTE '{' attribute_declaration_list '}' ';'
+		{ result = nil }
+
+attribute_declaration_list
+        : attribute_declaration
+		{ Celltype.new_attribute( val[0] ) }
+        | attribute_declaration_list attribute_declaration
+		{ Celltype.new_attribute( val[1] ) }
+
+
+attribute_declaration
+        :                             declaration
+		{
+			val[0].each{ |i|       # i:Decl
+				i.set_kind( :ATTRIBUTE )
+				i.check
+			}
+			result = val[0]
+		}
+        | spec_L attribute_specifier spec_R declaration
+		{
+			val[3].each{ |i|       # i:Decl
+				i.set_kind( :ATTRIBUTE )   # è¨­å®é åºãã
+				i.set_specifier_list( [val[1]] )
+				i.check
+			}
+			result = val[3]
+		}
+
+attribute_specifier
+        : OMIT     { result = [:OMIT] }
+        | SIZE_IS  '(' expression ')'	{ result = [:SIZE_IS,val[2]] }
+        | CHOICE '=' '{' choice_list '}' {  result = [:CHOICE,val[3]] }
+
+choice_list
+        : choice_list ',' choice_element {  result << val[2] }
+        | choice_element                 {  result = [ val[0] ] }
+
+choice_element
+        : STRING_LITERAL
+
+#å
+é¨å¤æ°
+var
+        : VAR '{' var_declaration_list '}' ';'
+		{ result = nil }
+
+var_declaration_list
+        : var_declaration
+   		{ Celltype.new_var( val[0] ) }
+        | var_declaration_list var_declaration
+   		{ Celltype.new_var( val[1] ) }
+
+var_declaration
+        : declaration
+		{
+			val[0].each{ |i|       # i:Decl
+				i.set_kind( :VAR )
+				i.check
+			}
+		}
+        | spec_L var_specifier spec_R declaration
+		{
+			val[3].each{ |i|       # i:Decl
+				i.set_kind( :VAR )   # è¨­å®é åºãã
+				i.set_specifier_list( [val[1]] )
+				i.check
+			}
+			result = val[3]
+		}
+
+var_specifier
+        : SIZE_IS  '(' expression ')'	{ result = [:SIZE_IS,val[2]] }
+
+# ãªã¯ã¯ã¤ã¢
+require
+        : REQUIRE namespace_identifier '.' IDENTIFIER';'                            # mikan namespace #1
+		{
+			Celltype.new_require( val[1], val[3] )
+		}
+        | REQUIRE IDENTIFIER '=' namespace_identifier '.' IDENTIFIER';'             #1
+		{
+			Celltype.new_require( val[3], val[5], val[1].val )
+		}
+
+#ãã¡ã¯ããª
+factory
+        : factory_head '{' factory_function_list '}' ';'
+
+factory_head
+        : FACTORY     { Factory.set_f_celltype( false ) }
+        | CTFACTORY   { Factory.set_f_celltype( true ) }
+
+factory_function_list
+        :                                         # ç©º
+        | factory_function_list factory_function
+
+factory_function
+        : factory_function_name '(' constant_expression ',' constant_expression  ')' ';'
+		{ Factory.new( val[0].val, val[2], val[4], nil    ) }
+        | factory_function_name '(' constant_expression ',' constant_expression ',' arg_list ')' ';'
+		{ Factory.new( val[0].val, val[2], val[4], val[6] ) }
+
+factory_function_name
+        : IDENTIFIER
+
+arg_list     # factory ã® write é¢æ°ã®ç¬¬ä¸å¼æ°ä»¥é
+        : IDENTIFIER
+		{ result = [ [ :IDENTIFIER, val[0].val ] ] }
+        | arg_list ',' IDENTIFIER
+		{ result << [ :IDENTIFIER, val[2].val ] }
+        | STRING_LITERAL
+		{ result = [ [ :STRING_LITERAL, val[0].val ] ] }
+        | arg_list ',' STRING_LITERAL
+		{ result << [ :STRING_LITERAL, val[2].val ] }
+
+#ã»ã«çæ
+cell
+        : CELL namespace_celltype_name cell_name '{'
+		{ Cell.new_def }
+          join_list '}' ';'
+		{ result = Cell.end_of_parse true }
+        | CELL namespace_celltype_name cell_name ';'   # oyama ãã­ãã¿ã¤ãå®£è¨
+			{ result = Cell.end_of_parse false }
+
+namespace_celltype_name
+        : namespace_identifier
+		{ result = Cell.new(val[0]) }
+
+cell_name
+        : IDENTIFIER
+		{ result = Cell.set_name(val[0].val) }
+
+join_list
+        :   # ç©ºè¡  061007
+        | join_list specified_join
+        | join_list reverse_join
+
+specified_join
+        :  spec_L join_specifier_list spec_R join
+		{ val[3].set_specifier_list( val[1] )  }
+	|  join
+		{ val[0].set_specifier_list( [] ) }
+
+join_specifier_list
+        : join_specifier_list ',' join_specifier
+		{ result << val[2] }
+        | join_specifier
+		{ result = [val[0]] }
+
+join_specifier
+        : THROUGH '(' plugin_name ',' plugin_arg ')'
+		{ result = [ :THROUGH, val[2], val[4] ] }
+
+plugin_name
+        : IDENTIFIER   { result = val[0] }
+
+plugin_arg
+        : string_literal_list
+
+join
+#        : cae_name                     '=' expression ';'
+#		{
+#			result = Join.new( val[0].val, nil, val[2] )
+#			Cell.new_join( result, true )
+#		}
+#        | cae_name '[' ']'             '=' expression ';'
+        : cae_name '[' ']'             '=' expression ';'
+		{
+			result = Join.new( val[0].val,  -1, val[4] )
+			Cell.new_join( result, true )
+		 }
+        | cae_name '[' array_index ']' '=' expression ';'
+		{
+			result = Join.new( val[0].val, val[2], val[5] )
+			Cell.new_join( result, true )
+		}
+        | cae_name '=' initializer ';'     # åæåå­ï¼ '{', '}' ãå¯
+		{
+			result = Join.new( val[0].val, nil, val[2] )
+			Cell.new_join( result, true )
+		}
+        | cae_name '=' COMPOSITE '.' IDENTIFIER ';'
+		{
+			result = Join.new( val[0].val, nil, [ :COMPOSITE, val[4] ] )
+			Cell.new_join( result, true )
+		}
+
+cae_name #  cae: callport, attribute, entryport
+        : IDENTIFIER
+
+reverse_join
+        # non-array <= non-array
+        : cae_name '<=' namespace_identifier '.' IDENTIFIER ';'
+		{
+			rj = ReverseJoin.new( val[0].val, nil, val[2], val[4].val )
+			Cell.new_reverse_join( rj )
+		}
+        # non-array <= array
+        | cae_name '<=' namespace_identifier '.' IDENTIFIER '[' expression ']' ';'
+		{
+			rj = ReverseJoin.new( val[0].val, nil, val[2], val[4].val, val[6] )
+			Cell.new_reverse_join( rj )
+		}
+        # array <= non-array
+        | cae_name '[' array_index ']' '<=' namespace_identifier '.' IDENTIFIER ';'
+		{
+			rj = ReverseJoin.new( val[0].val, val[2], val[5], val[7].val )
+			Cell.new_reverse_join( rj )
+		}
+        # array <= array
+        | cae_name '[' array_index ']' '<=' namespace_identifier '.' IDENTIFIER '[' expression ']' ';'
+		{
+			rj = ReverseJoin.new( val[0].val, val[2], val[5], val[7].val, val[9] )
+			Cell.new_reverse_join( rj )
+		}
+
+
+array_index
+        : constant_expression
+
+#è¤åç¨®
+composite_celltype
+        : COMPOSITE composite_celltype_name '{' composite_celltype_statement_list '}' ';'
+		{
+			CompositeCelltype.end_of_parse
+			result = val[1]
+		}
+
+composite_celltype_name
+        : IDENTIFIER
+		{ result = CompositeCelltype.new(val[0].val) }
+
+composite_celltype_statement_list
+        : specified_composite_celltype_statement
+        | composite_celltype_statement_list specified_composite_celltype_statement
+
+specified_composite_celltype_statement
+        : composite_celltype_statement
+		{
+			if val[0].kind_of?( Port ) then
+				CompositeCelltype.new_port( val[0] )   # é
+å»¶ãã¦ç»é²
+			end
+		}
+        | spec_L composite_celltype_statement_specifier_list spec_R composite_celltype_statement
+		{
+			if val[3].kind_of?( Port ) then
+				# port ä»¥å¤ val[3] ã«æå¹ãªå¤ãå
+¥ã£ã¦ããªãã®ã§ãä»¥ä¸ã®ã¡ã½ãããé©ç¨ã§ããªã
+				# ç¾ç¶ port, cell ä»¥å¤ã¯æå®å­ãåãä»ããªã
+				# ï¼ãããå°æ¥ä»ã®æãæå®å­ãåãä»ããå¯è½æ§ãããã®ã§ããã®ä½ç½®ã«è¨è¿°ããï¼
+				val[3].set_specifier( Generator.get_statement_specifier )
+				CompositeCelltype.new_port( val[3] )   # é
+å»¶ãã¦ç»é² (set_specifier å¾)
+			elsif val[3].kind_of?( Cell ) then
+				# Cell.end_of_parse ã«ã¦è¨­å®
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G1013 unexpected specifier"  )
+			end
+		}
+
+composite_celltype_statement
+        : composite_port
+        | composite_attribute
+        | internal_cell
+        | export_join
+#        | error       # ã¨ã©ã¼åå¾©ãã¤ã³ã  (#513 ç¡éã«ã¼ãã«é¥ãã±ã¼ã¹ãããã®ã§ãããã§ã®ã¨ã©ã¼åå¾©ã¯åããã)
+
+composite_celltype_statement_specifier_list
+        : composite_celltype_statement_specifier
+		{
+			Generator.add_statement_specifier val[0]
+			result = [ val[0] ]
+		}
+
+composite_celltype_statement_specifier
+        : ALLOCATOR '(' alloc_list2 ')'		{ result = [ :ALLOCATOR, val[2] ] }
+        | OMIT	{ result = [ :OMIT ] }
+        | OPTIONAL	{ result = [ :OPTIONAL ] }
+        | REF_DESC	{ result = [ :REF_DESC ] }
+        | DYNAMIC	{ result = [ :DYNAMIC ] }
+
+composite_port
+        : port
+		{
+			# CompositeCelltype.new_port( val[0] )
+			result = val[0]
+		}
+
+#å±æ§
+composite_attribute
+        : ATTRIBUTE '{' composite_attribute_declaration_list '}' ';'
+		{ result = nil }
+
+composite_attribute_declaration_list
+        : attribute_declaration
+		{ CompositeCelltype.new_attribute( val[0] ) }
+        | composite_attribute_declaration_list attribute_declaration
+		{ CompositeCelltype.new_attribute( val[1] ) }
+
+internal_cell
+        : CELL internal_namespace_celltype_name
+             internal_cell_name '{'
+		{ Cell.new_def }
+             internal_join_list '}' ';'
+		{ result = Cell.end_of_parse true }
+        | CELL internal_namespace_celltype_name	internal_cell_name ';'
+		{ result = Cell.end_of_parse false }
+
+
+internal_namespace_celltype_name
+        : namespace_identifier
+		{ Cell.new(val[0],true) }
+
+internal_cell_name
+        : IDENTIFIER
+		{ Cell.set_name(val[0].val) }
+
+
+internal_join_list
+        :   # ç©ºè¡  061007
+        | internal_join_list specified_join
+        | internal_join_list external_join
+
+external_join  # cell å
+ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå
+        : internal_cell_elem_name '=>' COMPOSITE '.' export_name ';'
+		{	Cell.external_join( val[0].val, val[4].val, true )	}
+        | internal_cell_elem_name '=>' export_name ';'
+		{	Cell.external_join( val[0].val, val[2].val, false )	}
+        # ä»¥åã®ææ³ã§ã¯ãå¼ã³å£å´ã cell ã®å¤ã«è¨è¿°ãã¦ãã
+        # ãã®æã®å®è£
+ã
+
+export_join    # cell å¤ã«è¨è¿°ããåãå£ã®å¤é¨çµå
+        : export_name '=>' internal_ref_cell_name '.' internal_cell_elem_name ';'
+		{
+			CompositeCelltype.new_join( val[0].val,
+						val[2].val, val[4].val, :ENTRY )
+		}
+        | COMPOSITE '.' export_name '=>' internal_ref_cell_name '.' internal_cell_elem_name ';'
+		{
+			CompositeCelltype.new_join( val[2].val,
+						val[4].val, val[6].val, :ENTRY )
+		}
+
+export_name
+        : IDENTIFIER
+
+internal_ref_cell_name
+        : IDENTIFIER
+
+internal_cell_elem_name
+        : IDENTIFIER
+
+# ãªã¼ã¸ã§ã³
+region
+        : spec_L region_specifier_list spec_R REGION region_name '{'  region_statement '}' ';'
+		{ Region.end_of_parse }
+        |                  REGION region_name '{'  region_statement '}' ';'
+		{ Region.end_of_parse }
+
+
+region_specifier_list
+        : region_specifier
+        | region_specifier_list ',' region_specifier
+
+region_specifier
+        : IN_THROUGH '(' plugin_name ',' plugin_arg ')'
+		{ Region.new_in_through( val[2].val, val[4].val ) }
+        | IN_THROUGH '(' ')'   # in è¨±å¯
+		{ Region.new_in_through }
+        | OUT_THROUGH '(' plugin_name ',' plugin_arg ')'
+		{ Region.new_out_through( val[2].val, val[4].val ) }
+        | OUT_THROUGH '(' ')'  # out è¨±å¯
+		{ Region.new_out_through() }
+        | TO_THROUGH '(' namespace_region_name ',' plugin_name ',' plugin_arg ')'
+		{ Region.new_to_through( val[2], val[4].val, val[6].val ) }
+        | TO_THROUGH '('namespace_region_name ')'  # to è¨±å¯
+		{ Region.new_to_through( val[2], nil, nil ) }
+        | NODE
+		{ Region.set_type( :NODE ) }
+        | LINKUNIT
+		{ Region.set_type( :LINKUNIT ) }
+        | DOMAIN '(' IDENTIFIER ',' STRING_LITERAL ')'
+		{ Region.set_domain( val[2].val, val[4] ) }
+        | CLASS '(' IDENTIFIER ')'
+		{ Region.set_type( :CLASS, val[2].val ) }
+
+region_name
+        : IDENTIFIER
+		{ result = Region.new( val[0].val ) }
+
+region_statement
+        :
+        | region_statement region_cell
+        | region_statement region
+
+region_cell
+        : cell
+        | spec_L statement_specifier_list spec_R cell
+		{
+			obj = val[3]
+			if obj.kind_of?( Cell ) then
+			else
+              Generator.get_statement_specifier   # ã¯ãªã¢
+              Generator.error( "G9999 unexpected specifier"  )
+			end
+		}
+#        | spec_L region_cell_specifier_list spec_R cell
+
+# region_cell_specifier_list
+#         : region_cell_specifier
+# 		{ Generator.add_statement_specifier val[0] }
+#         | region_cell_specifier_list region_cell_specifier
+# 		{ Generator.add_statement_specifier val[2] }
+
+# region_cell_specifier
+#         : ALLOCATOR '(' alloc_list ')'
+# 		{ result = [ :ALLOCATOR, val[2] ] }
+
+
+namespace_region_name
+         : :IDENTIFIER
+		{ result = [ val[0].val ] }  # mikan é
+åã§ããå¿
+è¦ã¯ãªã
+#        : namespace_identifier
+
+# æå®å­ã®æ¬å¼§ (in, out ãªã©ã®ã­ã¼ã¯ã¼ãåãæ¿ãã®ããåé¢)
+spec_L
+        : '['  { set_in_specifier }
+spec_R
+        : ']'  { unset_in_specifier }
+
+# location information
+location_information
+        :  __LOCATION_INFORMATION__ '{'  cell_location_join_location_list '}'
+
+cell_location_join_location_list
+        : cell_location_join_location_list cell_location
+        | cell_location_join_location_list join_location
+        |
+
+cell_location
+        : __CELL__ namespace_identifier '(' constant_expression ',' constant_expression ','  constant_expression ','  constant_expression ')' '{' port_location_list '}'
+		{
+			TECSGEN::Cell_location.new( val[1], val[3], val[5], val[7], val[9], val[12] )
+		}
+
+port_location_list
+        : port_location_list port_location
+		{
+			result = val[0] << val[1]
+		}
+        |
+		{ result = [] }
+
+port_location
+        : IDENTIFIER '(' IDENTIFIER ',' constant_expression ')'
+		{ result = [ val[0], val[2], val[3] ] }
+
+join_location    # mikan port array
+        : __JOIN__ '(' namespace_identifier '.' IDENTIFIER '=>' namespace_identifier '.' IDENTIFIER ')'  '{' bar_list '}'
+		{
+            TECSGEN::Join_location.new( val[2], val[4], val[6], val[8], val[11] )
+		}
+
+bar_list
+        : bar_list IDENTIFIER '(' constant_expression ')'
+          {
+            result = val[0] << [ val[1], val[3] ]
+          }
+        | { result = [] }
+
+
+end
+
+---- inner
+
+  RESERVED = {
+    # keyword
+    'namespace' => :NAMESPACE,
+    'signature' => :SIGNATURE,
+    'celltype' => :CELLTYPE,
+    'cell' => :CELL,
+    'attr' => :ATTRIBUTE,
+    'var' => :VAR,
+    'call' => :CALL,
+    'entry' => :ENTRY,
+    'composite' => :COMPOSITE,
+    'require' => :REQUIRE,
+    'factory' => :FACTORY,
+    'FACTORY' => :CTFACTORY,
+    'typedef' => :TYPEDEF,
+    'struct' => :STRUCT,
+    'region' => :REGION,
+    'import' => :IMPORT,
+    'import_C' => :IMPORT_C,
+    'generate' => :GENERATE,
+
+    # types
+    'void'    => :VOID,
+
+    'volatile'=> :VOLATILE,
+    'const'   => :CONST,
+
+    'signed'  => :SIGNED,
+    'unsigned'=> :UNSIGNED,
+
+    'int8_t'    => :INT8_T,
+    'int16_t'   => :INT16_T,
+    'int32_t'   => :INT32_T,
+    'int64_t'   => :INT64_T,
+    'int128_t'  => :INT128_T,
+    'uint8_t'   => :UINT8_T,
+    'uint16_t'  => :UINT16_T,
+    'uint32_t'  => :UINT32_T,
+    'uint64_t'  => :UINT64_T,
+    'uint128_t' => :UINT128_T,
+
+    'float32_t'   => :FLOAT32_T,
+    'double64_t'  => :DOUBLE64_T,
+    'bool_t'      => :BOOL_T,
+    'char_t'  => :CHAR_T,
+    'schar_t'  => :SCHAR_T,
+    'uchar_t'  => :UCHAR_T,
+
+    # unrecommened types
+    'int'     => :INT,
+#   'intptr'  => :INTPTR,
+    'short'   => :SHORT,
+    'long'    => :LONG,
+
+    # obsolete types
+    'char'    => :CHAR,
+#    'int8'    => :INT8,
+#    'int16'   => :INT16,
+#    'int32'   => :INT32,
+#    'int64'   => :INT64,
+#    'int128'  => :INT128,
+#    'float'   => :FLOAT,
+#    'double'  => :DOUBLE,
+#    'bool'    => :BOOL,
+
+    'enum'    => :ENUM,
+    'enum8'   => :ENUM8,
+    'enum16'  => :ENUM16,
+    'enum32'  => :ENUM32,
+    'enum64'  => :ENUM64,
+
+    'true'    => :TRUE,
+    'false'   => :FALSE,
+
+    'C_EXP'   => :C_EXP,
+
+    'Descriptor'   => :DESCRIPTOR,
+
+    # location information for TECSCDE
+    '__location_information__' => :__LOCATION_INFORMATION__,
+    '__cell__' => :__CELL__,
+    '__join__' => :__JOIN__,
+  }
+
+  # æå®å­ '[]' å
+ã§ã®ã¿ä½¿ç¨ã§ããã­ã¼ã¯ã¼ã
+  RESERVED2 = {
+    # specifier
+    'id' => :ID,
+
+    # signature
+    'callback' => :CALLBACK,
+    'context' => :CONTEXT,
+    'deviate' => :DEVIATE,
+
+    # celltype
+    'singleton' => :SINGLETON,
+    'idx_is_id' => :IDX_IS_ID,
+    'active' => :ACTIVE,
+
+    # port (entry)
+    'inline' => :INLINE,
+    'ref_desc' => :REF_DESC,   # call ãå¯
+
+    # port (call)
+    'optional' => :OPTIONAL,
+    'dynamic' => :DYNAMIC,
+
+    # port (call), attribute
+    'omit' => :OMIT,
+
+    # attribute
+    'choice' => :CHOICE,
+
+    # cell
+    'allocator' => :ALLOCATOR,
+    'prototype' => :PROTOTYPE,
+    'restrict'  => :RESTRICT,
+
+    # FuncType
+    'oneway' => :ONEWAY,
+
+    # parameter (basic)
+    'in' => :IN,
+    'out' => :OUT,
+    'inout' => :INOUT,
+    'send' => :SEND,
+    'receive' => :RECEIVE,
+
+    # parameter 
+    'size_is' => :SIZE_IS,
+    'count_is' => :COUNT_IS,
+    'string' => :STRING,
+    'nullable' => :NULLABLE,
+
+    'through' => :THROUGH,
+    'in_through' => :IN_THROUGH,
+    'out_through' => :OUT_THROUGH,
+    'to_through' => :TO_THROUGH,
+
+    'node' => :NODE,
+    'linkunit' => :LINKUNIT ,
+    'domain' => :DOMAIN,
+    'class' => :CLASS,
+  }
+
+  # åå¸°çãªãã¼ãµã®ããã®ã¹ã¿ãã¯
+  @@generator_nest = -1
+  @@generator_stack = []
+  @@current_locale = []
+
+  # import_C ä¸­ã§ãã
+  @@import_C = false
+
+  # ãã¹ã¦ã®æ§æè§£æãå®äºãã
+  @@b_end_all_parse = false
+
+  def self.parse( file_name, plugin = nil, b_reuse = false )
+    # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èª­ã¿è¾¼ã)
+    parser = Generator.new
+
+    # plugin ãã import ããã¦ããå ´åã® plugin è¨­å®
+    parser.set_plugin plugin
+
+    # reuse ãã©ã°ãè¨­å®
+    parser.set_reuse b_reuse
+
+    # cdl ããã¼ã¹
+    parser.parse( [file_name] )
+
+    # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã
+    parser.finalize
+  end
+
+  def finalize
+
+    # mikan Namespace.pop
+    Namespace.pop
+    Signature.pop
+    Celltype.pop
+    Cell.pop
+    CompositeCelltype.pop
+  end
+
+  def set_plugin( plugin )
+    @plugin = plugin
+  end
+
+  def self.get_plugin
+    if @@generator_stack[@@generator_nest] then
+      # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯ nil
+      return @@generator_stack[@@generator_nest].get_plugin
+    else
+      return nil
+    end
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def set_reuse( b_reuse )
+    @b_reuse = b_reuse
+  end
+
+  def self.is_reuse?
+    if @@generator_stack[@@generator_nest] then
+      # tecsgen å¼æ°ã® cdl ã import ãããå ´åã¯ nil
+      return @@generator_stack[@@generator_nest].is_reuse?
+    else
+      return false
+    end
+  end
+
+  def is_reuse?
+    @b_reuse
+  end
+
+  def parse(files)
+
+    # mikan Namespace.push
+    Namespace.push
+    Signature.push
+    Celltype.push
+    Cell.push
+    CompositeCelltype.push
+
+    @@generator_nest += 1
+    @@generator_stack[@@generator_nest] = self
+    @in_specifier = false
+
+    begin
+
+      @q = []
+      b_in_comment = false
+      b_in_string = false
+
+      # euc ã®ã³ã¡ã³ãã utf8 ã¨ãã¦æ±ãã¨ãã³ã¡ã³ãã®çµãããèª¤ãåé¡ã®å¯¾ç­
+      TECS_LANG::set_kcode_binary
+
+      files.each {|file|
+        lineno = 1
+        begin
+          string = ""
+#2.0          IO.foreach(file) {|line|
+          TECSIO.foreach(file) {|line|
+            col = 1
+#            line.rstrip!         æ¹è¡å«ãæå­åãæ±ãããã«ãªã£ãã®ã§ãããã§ç©ºç½ãåãé¤ããªããªã£ã
+
+            until line.empty?
+
+              if b_in_comment
+                case line
+                  # ã³ã¡ã³ãçµäº
+                when /\A\*\//
+                  b_in_comment = false
+                when /\A./
+                  ;
+                when /\s+/     # line.rstrip! ãæ­¢ãããã \n ãªã©ã®ç©ºç½æå­ã¨ã¾ã£ã¡ããã«ã¼ã«ãå¿
+è¦ã«ãªã£ã
+                  ;
+                end
+              elsif b_in_string
+                if line =~ /\A(?:[^"\\]|\\.)*"/
+                  string = "#{string}#{$&}"
+                  @q <<  [:STRING_LITERAL, Token.new(string, file, lineno, col)]
+                  b_in_string = false
+                elsif line =~ /\A.*\\\n/     # æ¹è¡ \n ã¯ '.' ã«ãããããªã
+                  string += $&
+                elsif line =~ /\A.*\n/     # æ¹è¡ \n ã¯ '.' ã«ãããããªã
+                  string += line
+                  # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èª­åºãå)
+                  puts "error: #{file} line #{lineno}: string literal has newline without escape"
+                  @@n_error += 1
+                end
+              else
+                case line
+                # ç©ºç½ãããªãã­ã»ã¹ãã£ã¬ã¯ãã£ã
+                when /\A\s+/
+                  ;
+                # è­å¥å­
+                when /\A[a-zA-Z_]\w*/
+                  word = $&
+                  @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
+                # 16 é²æ°å®æ°
+                when /\A0x[0-9A-Fa-f]+/
+                  @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
+                # 8 é²æ°å®æ°
+                when /\A0[0-7]+/
+                  @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
+                # æµ®åå°æ°å®æ°
+                when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
+                  @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
+                # æ´æ°å®æ°
+                when /\A\d+/
+                  @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
+                # æå­å®æ°
+                when /\A'(?:[^'\\]|\\.)'/
+                  @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
+                # æå­å
+#                "#include  #include #include \"../systask/logtask.cfg\"       æå¾ã® " å¿ã)ã§ç¡éã«ã¼ã
+#                when /\A"(?:[^"\\]+|\\.)*"/
+                when /\A"(?:[^"\\]|\\.)*"/   # ããã¯ãã¾ãè¡ãããã 
+                  @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
+                # æå­å (æ¹è¡ãã)
+                when /\A"(?:[^"\\]|\\.)*\\\n$/
+                  string = $&
+                  b_in_string = true
+                # æå­å (æ¹è¡ãã, escape ãªã)
+                when /\A("(?:[^"\\]|\e\.)*)\n$/
+                  string = $1 + "\\\n"
+                  b_in_string = true
+                  # ãã®ä½ç½®ã§ã¯ error ã¡ã½ããã¯ä½¿ããªã (token èª­åºãå) # mikan cdl_error ã§ã¯ãªã
+                  puts "error: #{file} line #{lineno}: string literal has newline without escape"
+                  @@n_error += 1
+                # å±±æ¬å¼§ã§å²ã¾ããæå­å
+                when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
+                  @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)]
+                # è¡ã³ã¡ã³ã
+                when /\A\/\/.*$/
+                  # èª­ã¿é£ã°ãã ã
+                # ã³ã¡ã³ãéå§
+                when /\A\/\*/
+                  b_in_comment = true
+                # '>>', '<<' ãªã©
+                when /\A>>/, /\A<</, /\A==/, /\A!=/, /\A\&\&/, /\A\|\|/
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                when /\A::/, /\A=>/, /\A<=/, /\A>=/
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                # '(', ')' ãªã©ä¸æå­ã®è¨å·ãã¾ãã¯æªç¥ã®è¨å·
+                when /\A./
+                  @q << [$&, Token.new($&, file, lineno, col)]
+                else
+                  raise
+                end
+              end
+
+              line = $'
+              col += $&.length
+            end
+
+            lineno += 1
+          }
+
+        rescue => evar
+          Generator.error( "G1014 while open or reading \'$1\'" , file )
+          if $debug then
+            p puts( evar )
+            pp $@
+          end
+        end
+      }
+
+      # çµäºã®å°
+      @q << nil
+
+      @yydebug = true
+      do_parse
+
+    ensure
+      @@generator_nest -= 1
+      TECS_LANG::reset_kcode
+    end
+
+  end
+
+  def next_token
+    token = @q.shift
+
+    if token then
+      @@current_locale[@@generator_nest] = token[1].locale
+
+      if token[0] == :IDENTIFIER then
+        # TYPE_NAME ãã¼ã¯ã³ã¸ç½®æã
+        if Namespace.is_typename?( token[1].val ) then
+          token[0] = :TYPE_NAME
+        elsif @in_specifier && RESERVED2[ token[1].val.to_s ] then
+          # æå®å­ã­ã¼ã¯ã¼ãï¼ '[', ']' å
+ã§ã®ã¿æå¹)
+          token[0] = RESERVED2[ token[1].val.to_s ]
+        end
+      end
+
+      if $debug then     # 070107 token ç¡å¹æãããéããªããããã (through å¯¾å¿ -d ã®æã«ä¾å¤çºç) 
+        locale = @@current_locale[@@generator_nest]
+        if token then
+          print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
+        else
+          print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
+        end
+      end
+    else
+      token = [ false, false ]
+    end
+
+    token
+  end
+
+  def on_error(t, v, vstack)
+    # p t, token_to_str(t), vstack
+    if token_to_str(t) == "$end" then
+      Generator.error( "G1015 Unexpected EOF"  )
+    else
+      Generator.error( "G1016 syntax error near \'$1\'" , v.val )
+    end
+  end
+
+  def self.current_locale
+    @@current_locale[ @@generator_nest ]
+  end
+
+  @@n_error = 0
+  @@n_warning = 0
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¨ã©ã¼çºçã¯ä¸é©åï¼
+  def self.error( msg, *arg )
+    locale = nil
+    self.error2( locale, msg, *arg )
+  end
+
+  def self.error2( locale, msg, *arg )
+    @@n_error += 1
+
+    msg = TECSMsg.get_error_message( msg )
+    # $1, $2, ... ã arg ã§ç½®æ
+    count = 1
+    arg.each{ |a|
+      str = TECSIO.str_code_convert( msg, a.to_s )
+      msg.sub!( /\$#{count}/, str )
+      count += 1
+    }
+
+    # import_C ã®ä¸­ã§ã®ã¨ã©ã¼ï¼
+    if @@import_C then
+      C_parser.error( msg )
+    else
+
+      # Node ã®è¨æ¶ãã ä½ç½® (locale) ãä½¿ç¨ããå ´åãå¤æ´ä»¥åã«æ¯ã¹ã
+      # åé¡çºçç®æã¨ç°ãªãä½ç½®ã«ã¨ã©ã¼ãåºããããæ§æè§£æä¸­ã®ã¨ã©ã¼
+      # ã¯ãè§£æä¸­ã®ä½ç½®ãåºåããï¼(new_XXX ã§ owner ãå­è¦ç´ ã®ãã§ã
+      # ã¯ãããã¨ owner ã®è¡çªå·ãåºã¦ãã¾ãç¹ã§ããããçãã¦ãã)
+
+      if @@b_end_all_parse == false || locale == nil then
+        locale = @@current_locale[ @@generator_nest ]
+      end
+      if locale then
+        Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
+      else
+        Console.puts "error: #{msg}"
+      end
+    end
+  end
+
+  # ãã®ã¡ã½ããã¯æ§æè§£æãæå³è§£æããã®ã¿å¼åºãå¯ï¼ã³ã¼ãçæã§ã¦ã©ã¼ãã³ã°çºçã¯ä¸é©åï¼
+  def self.warning( msg, *arg )
+    locale = nil
+    self.warning2( locale, msg, *arg )
+  end
+
+  def self.warning2( locale, msg, *arg )
+    @@n_warning += 1
+
+    msg = TECSMsg.get_warning_message( msg )
+    # $1, $2, ... ã arg ã§ç½®æ
+    count = 1
+    arg.each{ |a|
+      str = TECSIO.str_code_convert( msg, a.to_s )
+      msg.sub!( /\$#{count}/, str )
+      count += 1
+    }
+
+    # import_C ã®ä¸­ã§ã®ã¦ã©ã¼ãã³ã°ï¼
+    if @@import_C then
+      C_parser.warning( msg )
+    else
+      if @@b_end_all_parse == false || locale == nil then
+        locale = @@current_locale[ @@generator_nest ]
+      end
+      if locale then
+        Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
+      else
+        Console.puts "warning: #{msg}"
+      end
+    end
+  end
+
+  def self.get_n_error
+    @@n_error
+  end
+
+  def self.get_n_warning
+    @@n_warning
+  end
+
+  def self.get_nest
+    @@generator_nest
+  end
+
+  #===  '[' specifier å§ã
+  def set_in_specifier
+    # p "set_in_specifier"
+    @in_specifier = true
+  end
+
+  #=== ']' specifier çµãã
+  def unset_in_specifier
+    # p "unset_in_specifier"
+    @in_specifier = false
+  end
+
+  # statement_specifier ã¯æ§æè§£ééä¸­ã§åç
+§ããããã
+  @@statement_specifier_stack = []
+  def self.add_statement_specifier( ss )
+    if( @@statement_specifier_stack[ @@generator_nest ] == nil )then
+      @@statement_specifier_stack[ @@generator_nest ] = [ ss ]
+    else
+      @@statement_specifier_stack[ @@generator_nest ] << ss
+    end
+  end
+
+
+  def self.get_statement_specifier
+    spec_list = @@statement_specifier_stack[ @@generator_nest ]
+    @@statement_specifier_stack[ @@generator_nest ] = nil
+    return spec_list
+  end
+
+  #=== ãã¹ã¦ã®æ§æè§£æãå®äºãããã¨ãå ±å
+  def self.end_all_parse
+    @@b_end_all_parse = true
+  end
+
+---- footer
+
+
+# ãã¡ã¤ã« => INCLUDE("header")ã®é
+å
+Include = Hash.new {|hash, key| hash[key] = []}
+
+
+class Token
+
+  attr_accessor :val, :file, :lineno, :col
+
+  def initialize(val, file, lineno, col)
+    @val = val
+    @file = file
+    @lineno = lineno
+    @col = col
+
+  end
+
+  def to_s
+    @val.to_s
+  end
+
+  def to_sym
+    @val.to_sym
+  end
+
+  def get_name
+    @val
+  end
+
+  def locale
+    [@file, @lineno, @col]
+  end
+
+  def eql?(other)
+    if other.is_a? Symbol
+      @val == other
+    elsif other.is_a? Token
+      @val == other.val
+    elsif other.is_a? String
+      @val.to_s == other
+    else
+      raise ArgumentError
+    end
+  end
+
+  alias == eql?
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    print "#{@val}\n"
+  end
+
+end
+
+#= TECSIO
+#  Ruby2.0(1.9) å¯¾å¿ã«ä¼´ãå°å
+¥ããã¯ã©ã¹
+#  SJIS ä»¥å¤ã§ã¯ãASCII-8BIT ã¨ãã¦å
+¥åãã
+class TECSIO
+  def self.foreach(file) # ãã­ãã¯å¼æ° { |line| }
+    pr = Proc.new   # ãã®ã¡ã½ããã®ãã­ãã¯å¼æ°ã pr ã«ä»£å
+¥
+    if $b_no_kcode then
+	  msg = "E".encode $Ruby19_File_Encode
+      if( $Ruby19_File_Encode == "Shift_JIS" )
+
+        # Shift JIS ã¯ããã£ãã Windows-31J ã¨ãã¦èª­ã¿è¾¼ã¾ããShift_JIS ã«å¤æãããï¼
+        # ã³ã¡ã³ãç­ã«å«ã¾ãã SJIS ã«ä¸é©åãªæå­ã³ã¼ãã¯ '?' ã¾ãã¯ REPLACEMENT CHARACTER ã«å¤æãããï¼
+        # EUC ã UTF-8 ã§è¨è¿°ããã CDL ãæ··å¨ãã¦ãã¦ããRuby ä¾å¤ãçºçãããã¨ãªãå¦çãé²ãããã¨ãã§ããï¼
+        # æå­ã³ã¼ãæå®ã SJIS ã§ãã£ã¦ãæå­åãªãã©ã«ã®ä¸­ã«ãæå­ã³ã¼ããSJIS ä»¥å¤ã®é ASCII ãå«ã¾ãã¦ããå ´åã
+        # Ruby 1.8 ã® tecsgen ã§ã¯æå­ã³ã¼ãæå®ã«å½±é¿ãªãå¦çããããã®ããRuby 1.9 ä»¥éã§ã¯ '?' ã«ç½®ãæããå¯è½æ§ãããï¼
+
+        mode = "r:Windows-31J"
+      else
+        mode = "r:#{$Ruby19_File_Encode}"
+      end
+      # mode = "r"
+    else
+	  msg = "E"
+      mode = "r"
+    end
+
+    f = File.open( file, mode )
+    begin
+      f.each{ |line|
+        # dbgPrint line
+        line = str_code_convert( msg, line )
+        pr.call( line )
+      }
+    ensure
+      f.close
+    end
+  end
+
+  #=== æå­ã³ã¼ããç¸éããå ´åä¸è´ããã
+  # msg ã¨ str ã®æå­ã³ã¼ããç¸éããå ´åãstr ã msg ã®æå­ã³ã¼ãã«å¤æãã
+  # å¤æä¸å¯ã®æå­ã³ã¼ãã¯ '?' (utf-8 ã®å ´å U+FFFD (REPLACEMENT CHARACTER )) ã«å¤æ
+  #
+  # ãã®ã¡ã½ããã¯ãã¨ã©ã¼ã¡ãã»ã¼ã¸åºåã§ãä½¿ç¨ããã¦ãããã¨ã«æ³¨æï¼
+  #
+  #msg_enc::Encode | String
+  def self.str_code_convert( msg, str )
+    if $b_no_kcode == false then
+      return str                          # Ruby V1.8 ã¾ã§
+    end
+    if msg.encoding != str.encoding then
+      option = { :invalid => :replace, :undef => :replace }   # ä¾å¤ãçºçãããã'?' ã«å¤æãã(utf-8 ã¯ 0xfffd)
+      # return str.encode( msg.encoding, option )
+      str = str.encode( "utf-8", option )
+      return str.encode( msg.encoding, option )
+    else
+      return str
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/componentobj.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/componentobj.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/componentobj.rb	(revision 317)
@@ -0,0 +1,7745 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: componentobj.rb 2569 2016-03-27 12:58:00Z okuma-top $
+#++
+
+# STAGE:
+# ãã®ã¡ã³ããã³ã¹ç¶æ³ã¯ãããããªã
+#  B    bnf.y.rb ããå¼åºããã
+#  P    parse æ®µéã§å¼åºãããï¼bnf.y.rb ããç´æ¥å¼åºãããããã§ã¯ãªãããæ§ææ¨çæãè¡ãï¼
+#  S    P ã®ä¸­ããå¼åºãããããæ§ææ¨çæããããã§ã¯ãªãæå³ãã§ãã¯ãã
+#  G    ã³ã¼ãçæï¼ãã®æ®µéã§ãæ§ææ¨ã¯å®å
+¨ã§ããï¼ä¸å®å
+¨ãªãã¨ã©ã¼ã§æã¡ãããã¦ããï¼
+#                                                   factory ã®ç¬¬ä¸å¼æ° "format" ã®å¾ãã®å¼æ°
+
+# mikan ä»¥ä¸ã¯ ruby ã® mix in ã§å®ç¾ã§ãããããããªã
+# Nestable ãç¶æ¿ããå ´åãã¯ã©ã¹å¤æ°ã¯ Nestable ã®ãã®ãå
+±æãããï¼å¥ã«ãããã£ãï¼
+# class Nestable
+#   @@nest_stack_index = -1
+#   @@nest_stack = []
+#   @@current_object = nil
+# 
+#   def self.push
+#     @@nest_stack_index += 1
+#     @@nest_stack[ @nest_stack_index ] = @@current_object
+#     @@current_object = nil
+#   end
+# 
+#   def pop
+#     @@current_object = @@nest_stack[ @@nest_stack_index ]
+#     @nest_stack_index -= 1
+#     if @@nest_stack_index < -1 then
+#       raise TooManyRestore
+#     end
+#   end
+# end
+#
+
+class Signature < NSBDNode  # < Nestable
+#  @name:: Symbol
+#  @global_name:: Symbol
+#  @function_head_list:: NamedList : FuncHead ã®ã¤ã³ã¹ã¿ã³ã¹ãè¦ç´ 
+#  @func_name_to_id::  {String}  :  é¢æ°åãæ·»å­ã¨ããé
+åã§ id ãè¨æ¶ããï¼id ã¯ signature ã®åºç¾é çª (1ããå§ã¾ã)
+#  @context:: string : ã³ã³ãã­ã¹ãå
+#  @b_callback:: bool: callback : ã³ã¼ã«ããã¯ç¨ã®ã·ã°ããã£
+#  @b_deviate:: bool: deviate : é¸è±ï¼pointer level mismatch ãåºããªãï¼
+#  @b_checked_as_allocator_signature:: bool:  ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã¨ãã¦ãã§ãã¯æ¸ã¿
+#  @b_empty:: Bool: ç©º(é¢æ°ãä¸ã¤ããªãç¶æ
+)
+
+  @@nest_stack_index = -1
+  @@nest_stack = []
+  @@current_object = nil
+
+  def self.push
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = @@current_object
+    @@current_object = nil
+  end
+
+  def self.pop
+    @@current_object = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+  # STAGE: P
+  # ãã®ã¡ã½ããã¯ parse ä¸­ã®ã¿å¼ã³åºããã
+  def self.get_current
+    @@current_object
+  end
+
+  #
+  # STAGE: B
+  def initialize( name )
+    super()
+    @name = name
+    Namespace.new_signature( self )
+    set_namespace_path # @NamespacePath ã®è¨­å®
+    if "#{Namespace.get_global_name}" == "" then
+      @global_name = @name
+    else
+      @global_name = :"#{Namespace.get_global_name}_#{@name}"
+    end
+
+    @func_name_to_id = {}
+    @context = nil
+    @b_callback = false
+    @b_deviate = false
+    @b_empty = false
+    @b_checked_as_allocator_signature = false
+    @@current_object = self
+    set_specifier_list( Generator.get_statement_specifier )
+  end
+
+  #
+  # STAGE: B
+  def end_of_parse( function_head_list )
+    @function_head_list = function_head_list
+
+    # id ãå²ä»ãã
+    id = 1
+    function_head_list.get_items.each{ |f|
+      @func_name_to_id[ f.get_name ] = id
+      id += 1
+    }
+    if id == 1 then
+      @b_empty = true
+    end
+
+    @@current_object = nil
+    return self
+  end
+
+  #=== Signature# signature ã®æå®å­ãè¨­å®
+  # STAGE: B
+  #spec_list::      [ [ :CONTEXT,  String ], ... ]
+  #                     s[0]        s[1]
+  def set_specifier_list( spec_list )
+    return if spec_list == nil  # ç©ºãªãã°ä½ãããªã
+
+    spec_list.each { |s|
+      case s[0]     # statement_specifier
+      when :CALLBACK
+        @b_callback = true
+      when :CONTEXT         # [context("non-task")] etc
+        if @context then
+          cdl_error( "S1001 context specifier duplicate"  )
+        end
+        # @context = s[1].gsub( /\A\"(.*)\"$/, "\\1" )
+        @context = CDLString.remove_dquote s[1]
+        case @context
+        when "non-task", "task", "any"
+        else
+          cdl_warning( "W1001 \'$1\': unknown context type. usually specifiy task, non-task or any" , @context )
+        end
+      when :DEVIATE
+        @b_deviate = true
+      else
+        cdl_error( "S1002 \'$1\': unknown specifier for signature" , s[0] )
+      end
+    }
+  end
+
+  def get_name
+    @name
+  end
+
+  def get_global_name
+    @global_name
+  end
+
+  def get_function_head_array
+    if @function_head_list then
+      return @function_head_list.get_items
+    else
+      return nil
+    end
+  end
+
+  def get_function_head( func_name )
+    return @function_head_list.get_item( func_name.to_sym )
+  end
+
+  #=== Signature# é¢æ°åãã signature å
+ã® id ãå¾ã
+  def get_id_from_func_name func_name
+    @func_name_to_id[ func_name ]
+  end
+
+  #=== Signature# context ãå¾ã
+  # context æå­åãè¿ã "task", "non-task", "any"
+  # æªæå®æã®ããã©ã«ãã¨ãã¦ task ãè¿ã
+  def get_context
+    if @context then
+      return @context
+    else
+      return "task"
+    end
+  end
+
+  #=== Signature# signaure ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã
+  #block:: ãã­ãã¯ãå¼æ°ã«åã
+  # ãã­ãã¯ã¯2ã¤ã®å¼æ°ãåãåã  Decl, ParamDecl     ( Decl: é¢æ°ããã )
+  # Port ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼
+  def each_param # ãã­ãã¯å¼æ° { |func_decl, param_decl| }
+    fha = get_function_head_array                       # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    return if fha == nil                                # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨­å®ãããªãã£ã
+
+    pr = Proc.new   # ãã®ã¡ã½ããã®ãã­ãã¯å¼æ°ã pr ã«ä»£å
+¥
+    fha.each{ |fh|  # fh: FuncHead                      # é¢æ°é
+åä¸­ã®åé¢æ°é ­é¨
+      fd = fh.get_declarator                            # fd: Decl  (é¢æ°é ­é¨ããDeclarotorãå¾ã)
+      if fd.is_function? then                           # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼
+        fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ãã¦
+          pr.call( fd, par )
+        }
+      end
+    }
+  end
+
+  #=== Signature# æ­£å½ãªã¢ã­ã±ã¼ã¿ ã·ã°ããã£ããã¹ããã
+  # alloc, dealloc é¢æ°ãæã¤ãã©ãããç¬¬ä¸å¼ãæ°ããããããæ´æ°ããã¤ã³ã¿ãç¬¬äºå¼ãæ°ãããã¤ã³ã¿ã¸ã®ãã¤ã³ã¿ããªã
+  def is_allocator?
+
+    # ä¸åã ããã§ãã¯ãã
+    if @b_checked_as_allocator_signature == true then
+      return true
+    end
+    @b_checked_as_allocator_signature = true
+
+    fha = get_function_head_array                       # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    if fha == nil then                                  # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨­å®ãããªãã£ã
+      return false
+    end
+
+    found_alloc = false; found_dealloc = false
+    fha.each{ |fh|  # fh: FuncHead                      # é¢æ°é
+åä¸­ã®åé¢æ°é ­é¨
+      fd = fh.get_declarator                            # fd: Decl  (é¢æ°é ­é¨ããDeclarotorãå¾ã)
+      if fd.is_function? then                           # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼
+        func_name = fd.get_name.to_sym 
+        if func_name == :alloc then
+          found_alloc = true
+          params = fd.get_type.get_paramlist.get_items
+          if params then
+            if ! params[0].instance_of?( ParamDecl ) ||
+                ! params[0].get_type.get_original_type.kind_of?( IntType ) ||
+                params[0].get_direction != :IN then
+              # ç¬¬ä¸å¼æ°ã int åã§ãªã
+              if ! params[0].instance_of?( ParamDecl ) ||
+                  ! params[0].get_type.kind_of?( PtrType ) ||
+                  ! params[0].get_type.get_type.kind_of?( PtrType ) ||
+                  params[0].get_type.get_type.get_type.kind_of?( PtrType ) ||
+                  params[0].get_direction != :OUT then
+                # ç¬¬ä¸å¼æ°ããã¤ã³ã¿åã§ããªã
+                cdl_error3( @locale, "S1003 $1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type", @name )
+              end
+            elsif ! params[1].instance_of?( ParamDecl ) ||
+                ! params[1].get_type.kind_of?( PtrType ) ||
+                ! params[1].get_type.get_type.kind_of?( PtrType ) ||
+                params[1].get_type.get_type.get_type.kind_of?( PtrType ) ||
+                params[0].get_direction != :IN then
+              # (ç¬¬ä¸å¼æ°ãæ´æ°ã§) ç¬¬äºå¼æ°ããã¤ã³ã¿ã§ãªã
+              cdl_error3( @locale, "S1004 $1: \'alloc\' 2nd parameter not [in] double pointer" , @name )
+            end
+          else
+            cdl_error3( @locale, "S1005 $1: \'alloc\' has no parameter, unsuitable for allocator signature" , @name )
+          end
+        elsif func_name == :dealloc then
+          found_dealloc = true
+          params = fd.get_type.get_paramlist.get_items
+          if params then
+            if ! params[0].instance_of?( ParamDecl ) ||
+                ! params[0].get_type.kind_of?( PtrType ) ||
+                params[0].get_type.get_type.kind_of?( PtrType ) ||
+                params[0].get_direction != :IN then
+              cdl_error3( @locale, "S1006 $1: \'dealloc\' 1st parameter not [in] pointer type" , @name )
+#            elsif params[1] != nil then    # ç¬¬äºå¼ãæ°ã¯ãã§ãã¯ããªã
+#              cdl_error3( @locale, "S1007 Error message is changed to empty" )
+#                 cdl_error3( @locale, "S1007 $1: \'dealloc\' cannot has 2nd parameter" , @name )
+            end
+          else
+            cdl_error3( @locale, "S1008 $1: \'dealloc\' has no parameter, unsuitable for allocator signature" , @name )
+          end
+        end
+        if found_alloc && found_dealloc then
+          return true
+        end
+      end
+    }
+    if ! found_alloc then
+      cdl_error3( @locale, "S1009 $1: \'alloc\' function not found, unsuitable for allocator signature" , @name )
+    end
+    if ! found_dealloc then
+      cdl_error3( @locale, "S1010 $1: \'dealloc\' function not found, unsuitable for allocator signature" , @name )
+    end
+    return false
+  end
+
+  #== Signature# å¼æ°ã§åç
+§ããã¦ãã Descriptor åã®ãªã¹ããä½æãã
+  #RETURN:: Hash { Signature => ParamDecl }:  è¤æ°ã® ParamDecl ããåç
+§ããã¦ããå ´åãæå¾ã®ãã®ããè¿ããªã
+  def get_descriptor_list
+    desc_list = { }
+    # p "has_desc #{@name}"
+    fha = get_function_head_array                       # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    if fha == nil then                                  # nil ã®å ´åãèªå·±åç
+§ã«ããã±ã¼ã¹ã¨ä»®å®
+      return desc_list
+    end
+    fha.each{ |fh|
+      fd = fh.get_declarator                            # fd: Decl  (é¢æ°é ­é¨ããDeclarotorãå¾ã)
+      if fd.is_function? then                           # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼
+        params = fd.get_type.get_paramlist.get_items
+        if params then
+          params.each{ |param|
+            t = param.get_type.get_original_type
+            while( t.kind_of? PtrType )
+              t = t.get_referto
+            end
+            # p "has_desc #{param.get_name} #{t}"
+            if t.kind_of? DescriptorType then
+              desc_list[t] = param
+            end
+          }
+        end
+      end
+    }
+    return desc_list
+  end
+
+  #=== Signature# å¼æ°ã« Descriptor ããããï¼
+  def has_descriptor?
+    # p "has_desc #{@name}"
+    fha = get_function_head_array                       # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    if fha == nil then                                  # nil ã®å ´åãèªå·±åç
+§ã«ããã±ã¼ã¹ã¨ä»®å®
+      return true
+    end
+    fha.each{ |fh|
+      fd = fh.get_declarator                            # fd: Decl  (é¢æ°é ­é¨ããDeclarotorãå¾ã)
+      if fd.is_function? then                           # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼
+        params = fd.get_type.get_paramlist.get_items
+        if params then
+          params.each{ |param|
+            t = param.get_type.get_original_type
+            while( t.kind_of? PtrType )
+              t = t.get_referto
+            end
+            # p "has_desc #{param.get_name} #{t}"
+            if t.kind_of? DescriptorType then
+              return true
+            end
+          }
+        end
+      end
+    }
+    return false
+  end
+
+  #=== Signature# ã³ã¼ã«ããã¯ãï¼
+  # æå®å­ callback ãæå®ããã¦ããã° true 
+  def is_callback?
+    @b_callback
+  end
+
+  #=== Signature# é¸è±ãï¼
+  # æå®å­ deviate ãæå®ããã¦ããã° true 
+  def is_deviate?
+    @b_deviate
+  end
+
+  #=== Signature# ç©ºãï¼
+  def is_empty?
+    @b_empty
+  end
+
+  #=== Signature# Push Pop Allocator ãå¿
+è¦ãï¼
+  # Transparent RPC ã®å ´å oneway ãã¤ in ã®é
+å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã
+  def need_PPAllocator?( b_opaque = false )
+    fha = get_function_head_array                       # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    fha.each{ |fh|
+      fd = fh.get_declarator
+      if fd.get_type.need_PPAllocator?( b_opaque ) then
+        # p "#{fd.get_name} need_PPAllocator: true"
+        @b_need_PPAllocator = true
+        return true
+      end
+      # p "#{fd.get_name} need_PPAllocator: false"
+    }
+    return false
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Signature: name: #{@name} context: #{@context} deviate : #{@b_deviate} PPAllocator: #{@b_PPAllocator} #{self}"
+    (indent+1).times { print "  " }
+    puts "namespace_path: #{@NamespacePath}"
+    (indent+1).times { print "  " }
+    puts "function head list:"
+    @function_head_list.show_tree( indent + 2 )
+  end
+
+end
+
+class Celltype < NSBDNode # < Nestable
+# @name:: Symbol
+# @global_name:: Symbol
+# @name_list:: NamedList item: Decl (attribute, var), Port
+# @port:: Port[]
+# @attribute:: Decl[]
+# @var:: Decl[]
+# @require:: [[cp_name,Celltype|Cell,Port],...]
+# @factory_list::   Factory[]
+# @ct_factory_list::    Factory[] :    celltype factory
+# @cell_list:: Cell[] : å®ç¾©ã®ã¿ (V1.0.0.2 ä»¥é)
+# @singleton:: bool
+# @idx_is_id:: bool
+# @idx_is_id_act:: bool: actual value
+# @active:: bool
+# @b_reuse:: bool :  reuse æå®ããã¦ import ããã(template ä¸è¦)
+# @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã
+#
+# @n_attribute_ro:: int >= 0    none specified
+# @n_attribute_rw:: int >= 0    # of [rw] specified attributes (obsolete)
+# @n_attribute_omit : int >= 0  # of [omit] specified attributes
+# @n_var:: int >= 0
+# @n_var_size_is:: int >= 0     # of [size_is] specified vars # mikan count_is
+# @n_var_omit:: int >= 0        # of [omit] specified vars # mikan var ã® omit ã¯æï¼
+# @n_var_init:: int >= 0        # of vars with initializer
+# @n_call_port:: int >= 0
+# @n_call_port_array:: int >= 0
+# @n_call_port_omitted_in_CB:: int >= 0   æé©åã§çç¥ãããå¼ã³å£
+# @n_entry_port:: int >= 0
+# @n_entry_port_array:: int >= 0
+# @n_entry_port_inline:: int >= 0
+# @n_cell_gen:: int >= 0  çæããã»ã«ã®æ°ï¼ã³ã¼ãçæã®é ­ã§ç®åºããï¼æå³è§£ææ®µéã§ã¯åç
+§ä¸å¯
+# @id_base:: Integer : cell ã® ID ã®æå°å¤(æå¤§å¤ã¯ @id_base + @n_cell)
+#
+# @b_cp_optimized:: bool : å¼ã³å£æé©åå®æ½
+# @plugin:: PluginObject      ãã®ã»ã«ã¿ã¤ãããã©ã°ã¤ã³ã«ããçæããã CDL ããçæãããå ´åã«æå¹ã
+#                              generate ã®æå®ã¯ @generate ã«ãã©ã°ã¤ã³ãä¿æããã
+#
+# @included_header:: Hash :  include ãããããããã¡ã¤ã«
+# @domain_roots::Hash { DomainTypeName(Symbol) => [ Region ] }  ãã¡ã¤ã³ã¿ã¤ãåã¨ Region ã®é
+å (optimize.rb ã§è¨­å®)
+#                                               ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã¡ã¤ã³åããnil
+
+  include PluginModule
+
+  @@nest_stack_index = -1
+  @@nest_stack = []
+  @@current_object = nil
+  @@celltype_list = []
+
+  def self.push
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = @@current_object
+    @@current_object = nil
+  end
+
+  def self.pop
+    @@current_object = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+  def initialize( name )
+    super()
+    @@current_object = self
+    @name = name
+    if "#{Namespace.get_global_name}" != "" then
+      @global_name = :"#{Namespace.get_global_name}_#{@name}"
+    else
+      @global_name = name
+    end
+
+    @name_list = NamedList.new( nil, "symbol in celltype #{name}" )
+    @port = []
+    @attribute = []
+    @var = []
+    @require = []
+    @factory_list = []
+    @ct_factory_list = []
+    @cell_list = []
+    @singleton = false
+    @active = false
+    @generate = nil
+
+    @n_attribute_ro = 0
+    @n_attribute_rw = 0
+    @n_attribute_omit = 0
+    @n_var = 0
+    @n_var_omit = 0
+    @n_var_size_is = 0
+    @n_var_init = 0
+    @n_call_port = 0
+    @n_call_port_array = 0
+    @n_call_port_omitted_in_CB = 0
+    @n_entry_port = 0
+    @n_entry_port_array = 0
+    @n_entry_port_array_ns = 0
+    @n_entry_port_inline = 0
+    @n_cell_gen = 0
+
+    @b_cp_optimized = false
+
+    @plugin = Generator.get_plugin
+      # plugin ã®å ´å PluginObject ãè¿ããã
+    # å
+ã® Generator ããå¼åºããã Generator ã®ä¸­ã§ãã¼ã¹ããã³æå³ãã§ãã¯ããã¦ãã
+
+    # if @plugin then
+    #  # plugin çæãããã»ã«ã¿ã¤ãã¯åå©ç¨ã§ã¯ãªã   #833 ä¸å
+·åä¿®æ­£
+    #  @b_reuse = false
+    # else
+      @b_reuse = Generator.is_reuse?
+    # end
+
+    if $idx_is_id then
+      @idx_is_id = true
+    else
+      @idx_is_id = false
+    end
+    @idx_is_id_act = @idx_is_id
+
+    Namespace.new_celltype( self )
+    set_namespace_path # @NamespacePath ã®è¨­å®
+    set_specifier_list( Generator.get_statement_specifier )
+
+    if @singleton then
+      @idx_is_id_act = false
+    end
+
+    @included_header = {}
+    @domain_roots = {}
+    @@celltype_list << self
+  end
+
+  def get_name
+    @name
+  end
+
+  #== Celltype#ãã¡ã¤ã³ã«ã¼ããè¿ã
+  # @domain_roots ã®èª¬æãåç
+§
+  def get_domain_roots
+    @domain_roots
+  end
+
+  # Celltype# end_of_parse
+  def end_of_parse
+    # å±æ§ã»å¤æ°ã®ãã§ãã¯
+    check_attribute
+
+    # ã¢ã­ã±ã¼ã¿å¼ã³å£ãå
+é¨çæ
+    generate_allocator_port
+
+    # ãªã¬ã¼ã¢ã­ã±ã¼ã¿ãå
+é¨ã¢ã­ã±ã¼ã¿ã®è¨­å®
+    @port.each { |p|
+      p.set_allocator_instance
+    }
+
+    if @n_entry_port == 0 && @active == false && @factory_list.length == 0 &&
+        ( @singleton && @ct_factory_list.length == 0 || ! @singleton )then
+      cdl_warning( "W1002 $1: non-active celltype has no entry port & factory" , @name )
+    end
+
+    if @generate then
+      celltype_plugin
+    end
+
+    @@current_object = nil
+  end
+
+  def self.new_port( port )
+    @@current_object.new_port( port )
+  end
+
+  def new_port( port )
+    port.set_owner self
+    @port << port
+    @name_list.add_item( port )
+    if port.get_port_type == :CALL then
+      @n_call_port += 1
+      @n_call_port_array += 1 if port.get_array_size != nil
+    else
+      @n_entry_port += 1
+      @n_entry_port_array += 1 if port.get_array_size != nil
+      @n_entry_port_array_ns += 1 if port.get_array_size == "[]"
+      @n_entry_port_inline += 1 if port.is_inline?
+    end
+    port.set_celltype self
+  end
+
+  def get_port_list
+    @port
+  end
+
+  def self.new_attribute( attribute )
+    @@current_object.new_attribute( attribute )
+  end
+
+  #=== Celltype# new_attribute for Celltype
+  #attribute:: [Decl]
+  def new_attribute( attribute )
+    @attribute += attribute
+    attribute.each { |a|
+      a.set_owner self
+      @name_list.add_item( a )
+      if( a.is_omit? )then
+        @n_attribute_omit += 1
+      elsif( a.is_rw? )then
+        @n_attribute_rw += 1
+      else
+        @n_attribute_ro += 1
+      end
+      if a.get_initializer then
+        # ç»é²å¾ã«ãã§ãã¯ãã¦ãåé¡ãªãï¼attr ãåç
+§ã§ããªãã®ã§ãèªå·±åç
+§ããªãï¼
+        a.get_type.check_init( @locale, a.get_identifier, a.get_initializer, :ATTRIBUTE )
+      end
+    }
+  end
+
+  #=== Celltype# celltype ã® attribute/var ã®ãã§ãã¯
+  # STAGE:  S
+  #
+  # ãã®ã¡ã½ããã¯ celltype ã®ãã¼ã¹ãå®äºããæç¹ã§å¼åºãããï¼
+  def check_attribute
+    # attribute ã® size_is æå®ãå¦¥å½ããã§ãã¯
+    (@attribute+@var).each{ |a|
+      if a.get_size_is then
+        if ! a.get_type.kind_of?( PtrType ) then
+          # size_is ããã¤ã³ã¿åä»¥å¤ã«æå®ããã
+          cdl_error( "S1011 $1: size_is specified for non-pointer type" , a.get_identifier )
+        else
+
+          # åç
+§ããå¤æ°ãå­å¨ããè¨ç®å¯è½ãªåããã§ãã¯ãã
+          size = a.get_size_is.eval_const( @name_list )  # C_EXP ã®å¯è½æ§ãã
+          init = a.get_initializer
+          if init then
+            if ! init.instance_of?( Array ) then
+              # åæåå­ãé
+åã§ã¯ãªã
+              cdl_error( "S1012 $1: unsuitable initializer, need array initializer" , a.get_identifier )
+            elsif size.kind_of?( Integer ) && size < init.length then
+              # size_is æå®ãããåæ°ãããåæåå­ã®é
+åè¦ç´ ãå¤ã
+              cdl_error( "S1013 $1: too many initializer, $2 for $3" , a.get_identifier, init.length, size )
+            # elsif a.get_size_is.eval_const( nil ) == nil  # C_EXP ã®å¯è½æ§ãã
+            end
+
+          end
+        end
+      else
+        if a.get_type.kind_of?( PtrType ) then
+          if a.get_initializer.instance_of?( Array ) ||
+              ( a.get_initializer.instance_of?( Expression ) &&
+                a.get_initializer.eval_const2(@name_list).instance_of?( Array ) ) then
+            # size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼
+            cdl_error( "S1159 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier )
+          end
+        end
+      end
+    }
+  end
+
+  def get_attribute_list
+    @attribute
+  end
+
+  #=== Celltype# ã¢ã­ã±ã¼ã¿å¼ã³å£ãçæ
+  #    send, receive å¼æ°ã®ã¢ã­ã±ã¼ã¿ãå¼åºãããã®å¼ã³å£ãçæ
+  def generate_allocator_port
+    @port.each { |port|
+      # ãã¼ãã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ãè¾¿ã
+      port.each_param { |port, fd, par|
+        case par.get_direction                        # å¼æ°ã®æ¹åæå®å­ (in, out, inout, send, receive )
+        when :SEND, :RECEIVE
+          if par.get_allocator then
+            cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}"     # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®åå
+            #           ãã¼ãå          é¢æ°å         ãã©ã¡ã¼ã¿å
+            # alloc_sig_path = [ par.get_allocator.get_name ]  # mikan Namespace ã¢ã­ã±ã¼ã¿å¼ã³å£ã®ã·ã°ããã£ #1
+            alloc_sig_path = par.get_allocator.get_namespace_path
+            array_size = port.get_array_size            # å¼ã³å£ã¾ãã¯åãå£é
+åã®ãµã¤ãº
+            created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ
+            created_port.set_allocator_port( port, fd, par )
+            if port.is_optional? then
+              created_port.set_optional
+            end
+            if port.is_omit? then
+              created_port.set_omit
+            end
+            new_port( created_port )                    # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ãè¿½å 
+          # else
+          #  already error "not found or not signature" in class ParamDecl
+          end
+        end
+      }
+    }
+  end
+
+  def get_name_list
+    @name_list
+  end
+
+  def self.new_var( var )
+    @@current_object.new_var( var )
+  end
+
+  #=== Celltype# æ°ããå
+é¨å¤æ°
+  #var:: [Decl]
+  def new_var( var )
+    @var += var
+    var.each { |i|     # i: Decl
+      i.set_owner self
+      if i.is_omit? then
+        @n_var_omit += 1
+      else
+        @n_var += 1
+      end
+      @name_list.add_item( i )
+
+      # size_is æå®ãããé
+å? mikan  count_is
+      if i.get_size_is then
+        @n_var_size_is += 1
+      end
+
+      if i.get_initializer then
+        i.get_type.check_init( @locale, i.get_identifier, i.get_initializer, :VAR, @name_list )
+        @n_var_init += 1
+      end
+    }
+  end
+
+  def get_var_list
+    @var
+  end
+
+  #=== Celltype# celltype ã®æå®å­ãè¨­å®
+  def set_specifier_list( spec_list )
+    return if spec_list == nil
+
+    spec_list.each { |s|
+      case s[0]
+      when :SINGLETON
+        @singleton = true
+      when :IDX_IS_ID
+        @idx_is_id = true
+      when :ACTIVE
+        @active = true
+      when :GENERATE
+        if @generate then
+          cdl_error( "S1014 generate specifier duplicate"  )
+        end
+        @generate = [ s[1], s[2] ] # [ PluginName, "option" ]
+      else
+        cdl_error( "S1015 $1 cannot be specified for composite" , s[0] )
+      end
+    }
+  end
+
+  #
+  def self.new_require( ct_or_cell_nsp, ep_name, cp_name = nil )
+    @@current_object.new_require( ct_or_cell_nsp, ep_name.to_sym, cp_name )
+  end
+
+  def new_require( ct_or_cell_nsp, ep_name, cp_name )
+    # Require: set_owner ãããã®ããªã
+    obj = Namespace.find( ct_or_cell_nsp )    #1
+    if obj.instance_of? Celltype then
+      # Celltype åã§æå®
+      ct = obj
+    elsif obj.instance_of? Cell then
+      # Cell åã§æå®
+      ct = obj.get_celltype
+    elsif obj == nil then
+      cdl_error( "S1016 $1 not found" , ct_or_cell_nsp.get_path_str )
+      return
+    else
+      cdl_error( "S1017 $1 : neither celltype nor cell" , ct_or_cell_nsp.get_path_str )
+      return
+    end
+
+    if( ! ct.is_singleton? ) then
+      # ã·ã³ã°ã«ãã³ã§ã¯ãªã
+      cdl_error( "S1018 $1 : not singleton cell" , obj.get_name )
+    end
+
+    # åãå£ãæ¢ã
+    obj2 = ct.find( ep_name )
+    if( ( ! obj2.instance_of? Port ) || obj2.get_port_type != :ENTRY ) then
+      cdl_error( "S1019 \'$1\' : not entry port" , ep_name )
+      return
+    elsif obj2.get_array_size then
+      cdl_error( "S1020 \'$1\' : required port cannot be array" , ep_name )
+      return
+    end
+
+    if obj2.get_signature == nil then
+      # signature ãæªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼
+      return
+    end
+
+    require_call_port_prefix = :_require_call_port
+    if cp_name == nil then
+      # é¢æ°åéè¤ãã§ãã¯
+      @require.each{ |req|
+        unless req[0].to_s =~ /^#{require_call_port_prefix}/ then
+          next     # ååããã® require ã¯é¢æ°åéè¤ãã§ãã¯ããªã
+        end
+        port = req[2]
+        if port.get_signature == obj2.get_signature then
+          # åã signature ï¼ãã¹ã¦åãé¢æ°åãæã¤ï¼åå¥ã«åºãã®ã§ã¯ãªããã¾ã¨ãã¦ã¨ã©ã¼ã¨ãã
+          cdl_error( "S1021 $1 : require cannot have same signature with \'$2\'" , obj2.get_name, port.get_name )
+          next
+        end
+        port.get_signature.get_function_head_array.each{ |f|
+          # mikan ããã¯ãnamedList ããã®æ¤ç´¢ã«ãªããªãã®ï¼ï¼å¹çãæªãï¼
+          obj2.get_signature.get_function_head_array.each{ |f2|
+            if( f.get_name == f2.get_name ) then
+              cdl_error( "S1022 $1.$2 : \'$3\' conflict function name in $4.$5" , obj.get_name, obj2.get_name, f.get_name, req[1].get_name, req[2].get_name )
+            end
+          }
+        }
+      }
+    end
+
+    if cp_name == nil then
+      b_has_name = false
+      cp_name = :"#{require_call_port_prefix}_#{ct.get_name}_#{obj2.get_name}"
+    else
+      b_has_name = true
+    end
+    # require ãè¿½å 
+    @require << [ cp_name, obj, obj2 ]  # [ lhs:cp_name, rhs:Celltype, rhs:Port ]
+
+    # require port ãè¿½å  (å¼ã³å£ã¨ãã¦è¿½å ããããã ã require ãã»ãããã¦ãã)
+    port = Port.new( cp_name, obj2.get_signature.get_namespace_path, :CALL )
+    port.set_require( b_has_name )
+    self.new_port port
+  end
+
+  def self.new_factory( factory )
+    @@current_object.new_factory( factory )
+  end
+
+  def new_factory( factory )
+    factory.set_owner self
+    if factory.get_f_celltype then
+      @ct_factory_list << factory
+    else
+      @factory_list << factory
+    end
+
+    factory.check_arg( self )
+
+  end
+
+  #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ (generate æå®å­)
+  def celltype_plugin
+
+    load_plugin( @generate[0], CelltypePlugin )
+
+    plugin_name = @generate[0]
+    option = @generate[1]
+    plugin_object = nil
+    eval_str = "plugin_object = #{plugin_name}.new( self, option )"
+    if $verbose then
+      print "new celltype : #{eval_str}\n"
+    end
+
+    begin
+      eval( eval_str )     # plugin ãçæ
+      plugin_object.set_locale @locale
+      @generate[ 2 ] = plugin_object
+      generate_and_parse plugin_object
+    rescue Exception => evar
+      cdl_error( "S1023 $1: fail to new" , plugin_name )
+      print "eval( #{eval_str} )\n"
+
+      print_exception( evar )
+    end
+  end
+
+  #=== Celltype# celltype ã«æ°ãã cell ãè¿½å 
+  #cell:: Cell
+  # æ°ããã»ã«ãã»ã«ã¿ã¤ãã«è¿½å ï¼
+  # ã»ã«ã®æ§æè§£éã®æå¾ã§ãã®ã¡ã½ããå¼åºãããï¼
+  # ã·ã³ã°ã«ãã³ã»ã«ãåã linkunit ã«è¤æ°ãªãããã§ãã¯
+  def new_cell( cell )
+    # Celltype ã§ã¯ Cell ã® set_owner ããªã
+    # ã·ã³ã°ã«ãã³ã§ããã­ãã¿ã¤ãå®£è¨ã§ãªãå ´åãã³ã¼ãçæå¯¾è±¡ãªã¼ã¸ã§ã³ã®å ´å
+    if @singleton  then
+      @cell_list.each{ |c|
+        if c.get_region.get_link_root == cell.get_region.get_link_root then
+          cdl_error( "S1024 $1: multiple cell for singleton celltype" , @name )
+        end
+      }
+    end
+    @cell_list << cell
+    if @plugin then
+      @plugin.new_cell cell
+    end
+  end
+
+  #=== Celltype# ã»ã«ã¿ã¤ãã¯ INIB ãæã¤ãï¼
+  # ã»ã«ã¿ã¤ãã INIB ãæã¤ãã©ãããå¤å®ãã
+  # $rom == false ã®ã¨ã:  INIB ãæããªãï¼ ï¼ãã¹ã¦ã¯ CB ã«ç½®ãããï¼
+  # $rom == true ã®ã¨ããINIB ã«ç½®ããããã®ãä¸ã¤ã§ãå­å¨ããã° INIB ãæã¤
+  #   INIB ã«ç½®ããããã®ã¯
+  #     attribute (omit ã®ãã®ã¯é¤ãï¼ç¾ä»æ§ã§ã¯ rw ã®ãã®ã¯ãªã)
+  #     size_is ãä¼´ã var
+  #     å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼
+  def has_INIB?
+#    print "name=#{@name} @n_attribute_ro=#{@n_attribute_ro}  @n_var_size_is=#{@n_var_size_is} @n_call_port=#{@n_call_port} @n_call_port_omitted_in_CB=#{@n_call_port_omitted_in_CB} @n_entry_port_array_ns=#{@n_entry_port_array_ns}\n"
+    return $rom && (@n_attribute_ro > 0 || @n_var_size_is > 0 || ( @n_call_port - @n_call_port_omitted_in_CB ) > 0 || @n_entry_port_array_ns > 0)
+#    return $rom && (@n_attribute_ro > 0 || ( @n_call_port - @n_call_port_omitted_in_CB ) > 0)
+  end
+
+  #=== Celltype# ã»ã«ã¿ã¤ãã¯ CB ãæã¤ãï¼
+  # $rom == true ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãå­å¨ããã° CB ãæã¤
+  #   size_is ãæå®ããã¦ããªã var
+  #   rw æå®ããã attribute (ç¾ä»æ§ã§ã¯å­å¨ããªã)
+  # $rom == false ã®ã¨ããããã®ãã®ãç½®ãããï¼ãããã®ä¸ã¤ã§ãå­å¨ããã° CB ãæã¤
+  #   attribute
+  #   var
+  #   å¼ã³å£ï¼ãã ããæé©åã§ä¸è¦ã¨ãªããã®ã¯é¤ãï¼
+  def has_CB?
+    if $rom then
+      return @n_attribute_rw > 0 || (@n_var-@n_var_size_is) > 0
+      # return @n_attribute_rw > 0 || @n_var > 0
+    else
+      return @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0 || (@n_call_port-@n_call_port_omitted_in_CB) > 0 || @n_entry_port_array_ns > 0
+    end
+  end
+
+  #=== Celltype# SET_CB_INIB_POINTER, INITIALIZE_CB ãå¿
+è¦ã
+  def need_CB_initializer?
+    @n_var_init > 0 || has_CB?
+  end
+
+  #=== Celltype# érequire ã®çµåãçæãã
+  def create_reverse_require_join cell
+    @port.each{ |p|
+      p.create_reverse_require_join cell
+    }
+  end
+
+  #=== Celltype# singleton ã»ã«ãå¾ã
+  #region:: Region   : singleton ãæ¢ã Region
+  # è·é¢ãæãè¿ããã®ãè¿ã
+  # mikan æ¬å½ã¯ region ã®ç¯å²ã® singleton ãæ¢ãå¿
+è¦ããã
+  def get_singleton_cell region
+    cell = nil
+    dist = 999999999 # mikan å¶éå¤ï¼ããã¯ååãããã»ã©ãã«ã¤ãï¼
+    # require: celltype ã§æå®
+    @cell_list.each{ |c|
+      # å°éå¯è½ã§æãè¿ãã»ã«ãæ¢ãï¼è¤æ°ã® singleton ããããããããªãï¼
+      d = region.distance( c.get_region )
+      #debug
+      dbgPrint "distance #{d} from #{region.get_name} to #{c.get_name} in #{c.get_region.get_name}\n"
+      # print "DOMAIN: distance #{d} from #{region.get_name} to #{c.get_name} in #{c.get_region.get_name}\n"
+      if d != nil then
+        if d < dist then
+          cell = c
+          dist = d
+        end
+      end
+    }
+    return cell
+  end
+
+  def find( name )
+    @name_list.get_item( name )
+  end
+
+  #=== Celltype# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãå¾ã
+  def get_celltype_plugin
+    if @generate then
+      return @generate[2]
+    end
+  end
+
+  def get_global_name
+    @global_name
+  end
+
+  def is_singleton?
+    @singleton
+  end
+
+  def is_active?
+    @active
+  end
+
+  #=== Celltype# ã¢ã¯ãã£ãã§ã¯ãªãã
+  # ãã®ã¡ã½ããã§ã¯ active ã®ä»ã« factory (singleton ã«ããã¦ã¯ FACTORYãå«ã)ããªããã° inactive ã¨ãã
+  def is_inactive?
+    if @active == false && @factory_list.length == 0 &&
+        ( @singleton && @ct_factory_list.length == 0 || ! @singleton )then
+      return true
+    end
+    return false
+  end
+
+  def get_id_base
+    @id_base
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def get_require
+    @require
+  end
+
+  #=== Celltype# ã³ã¼ãçæããå¿
+è¦ããããå¤å®
+  # ã»ã«ã®åæ°ã 0 ãªãã»ã«ã¿ã¤ãã³ã¼ãã¯çæä¸è¦
+  def need_generate?
+    @n_cell_gen > 0
+  end
+
+  #=== Celltype# require å¼ã³å£ã®çµåãè¡ã
+  # STAGE: S
+  # ã»ã«ã¿ã¤ãã® require å¼ã³å£ã«ã¤ãã¦ãçµåãè¡ã
+  # ã»ã«ãçæãããªãããã§ãã¯ãè¡ã
+  def set_require_join
+    @require.each{ |req|
+      cp_name = req[0]
+      cell_or_ct = req[1]
+      port = req[2]
+      @cell_list.each{ |c|
+        c.set_require_join( cp_name, cell_or_ct, port )
+      }
+    }
+  end
+
+  def get_cell_list
+    @cell_list
+  end
+
+  #=== Celltype# inline åãå£ãããªããï¼
+  # åãå£ãç¡ãå ´åããã¹ã¦ã®åãå£ã inline ã¨ã¯ããªã
+  def is_all_entry_inline?
+    @n_entry_port == @n_entry_port_inline && @n_entry_port > 0
+  end
+
+  #=== Celltype.get_celltype_list
+  def self.get_celltype_list
+    @@celltype_list
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Celltype: name=#{@name} global_name=#{@global_name}"  
+    (indent+1).times { print "  " }
+    puts "active=#{@active}, singleton=#{@singleton}, idx_is_id=#{@idx_is_id} plugin=#{@plugin.class} reuse=#{@b_reuse}"
+    (indent+1).times { print "  " }
+    puts "namespace_path: #{@NamespacePath}"
+    (indent+1).times { print "  " }
+    puts "port:"
+    @port.each { |i| i.show_tree( indent + 2 ) }
+    (indent+1).times { print "  " }
+    puts "attribute:"
+    @attribute.each { |i| i.show_tree( indent + 2 ) }
+    (indent+1).times { print "  " }
+    puts "var:"
+    @var.each { |i| i.show_tree( indent + 2 ) }
+#    (indent+1).times { print "  " }
+#    puts "require:"   mikan
+#    @require.each { |i| i.show_tree( indent + 2 ) }
+    (indent+1).times { print "  " }
+    puts "factory:"
+    @factory_list.each { |i| i.show_tree( indent + 2 ) }
+    (indent+1).times { print "  " }
+    puts "@n_attribute_ro #{@n_attribute_ro}"
+    (indent+1).times { print "  " }
+    puts "@n_attribute_rw #{@n_attribute_rw}"
+# @n_attribute_omit : int >= 0  # of [omit] specified cells
+# @n_var:: int >= 0
+# @n_var_size_is:: int >= 0     # of [size_is] specified cells # mikan count_is
+# @n_var_omit:: int >= 0        # of [omit] specified  cells # mikan var ã® omit ã¯æï¼
+# @n_call_port:: int >= 0
+# @n_call_port_array:: int >= 0
+# @n_call_port_omitted_in_CB:: int >= 0   æé©åã§çç¥ãããå¼ã³å£
+# @n_entry_port:: int >= 0
+# @n_entry_port_array:: int >= 0
+    (indent+1).times { print "  " }
+    puts "@n_entry_port_inline #{@n_entry_port_inline}"
+# @n_cell:: int >= 0  ã³ã¼ãçæã®é ­ã§ç®åºããï¼æå³è§£ææ®µéã§ã¯åç
+§ä¸å¯
+# @id_base:: Integer : cell ã® ID ã®æå°å¤(æå¤§å¤ã¯ @id_base + @n_cell)
+
+  end
+end
+
+class Cell < NSBDNode # < Nestable
+# @name:: Symbol : composite celltype ã®å
+å´ã®ã¤ã³ã¹ã¿ã³ã¹ã§ã¯å¤ã®ã»ã«
+# @global_name:: Symbol : C ã§ä½¿ããååï¼namespace ãå«ãï¼
+# @local_name:: str : cell celltype name { ... } ã® name
+# @celltype:: Celltype | CompositeCelltype
+# @join_list:: NamedList
+# @reverse_join_list:: NamedList
+# @b_defined:: definition flag (false if only prototype )
+# @b_prototype:: bool:  prototype specified in current parsing cell. (@b_defined is used to determine whether definition done)
+# @b_duplicate:: bool:  definition duplicate
+# @b_checked::   bool:  set_definition_join ãæ¸ãã§ããå ´å true
+# @require_joined_list:: {cp_name=>true}:  set_require_join ãæ¸ãã§ããå¼ã³å£ã¯ true
+# @f_ref:: refercenced from others
+# @entry_array_max_subscript:: { @port=>Integer } : åãå£é
+åã®é
+åæ·»æ°ã®æå¤§å¤ï¼æ·»æ°ç¡ãåãå£é
+åå¯¾å¿ï¼
+# @plugin::     Plugin: avialble if cell is generated by plugin generated cdl code.
+# @referenced_port_list:: { Port => Integer } : åãå£ã®åç
+§æ°
+#                                               ãã¹ã¦ã®æå³è§£æ(through, compositeå±é)ãçµãã£ãå¾ã«è¨­å®ãã
+#                                               érequire ãã¼ãã«å¯¾ãã¦è¤æ°ã®çµåããªãããã§ãã¯ãã
+# @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin ã¯çæå¾ã«è¿½å ããã
+#
+# composite ã®ããã¤ã³ã¹ã¿ã³ã¹å¤æ°
+# @in_composite:: bool : true if in composite celltype
+# @compositecelltypejoin_list:: NamedList : item= CompositeCelltypeJoin ( if @in_composite )
+# @f_cloned:: bool : true if cloned (instantiate of composite consist cell)
+# @my_clone:: Cell : Composite cell ã§ in_composite = true ã®å ´åã®ã¿æå¹ï¼ç´åã® clone ãä¸æè¨æ¶ï¼
+# @cell_list:: Cell[local_name] : Composite cell ã§ clone ããå¾ã®ãªã¹ã cell_list
+# @cell_list2:: [ Cell ] : Composite cell ã§ clone ããå¾ã®ãªã¹ã cell_list
+#                          @cell_list2 ã¯ composite å
+ã§ã®åºç¾é   
+#
+# region ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°
+# @region:: Region (å±ããregion)
+#
+# allocator ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°
+# @alloc_list::  [ [ NORMAL_ALLOC, ep_name, func_name, param_name, expr ], ... ]
+#   åãå£å´ã®ã¢ã­ã±ã¼ã¿ã¸ã®çµåãè¨æ¶ãä»¥ä¸ã®ã¡ã½ããã§è¿½å ããã
+#      set_specifier â¦ cell å®ç¾©æã«ã¢ã­ã±ã¼ã¿æå®ããã¦ããå ´å
+#      create_relay_allocator_join â¦ ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã®å ´å
+#
+# ID ã®ããã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ï¼optimize.rb ã«ã¦è¨­å®ï¼
+# @id:: Integer : ã³ã¼ãçæç´åã«è¨­å®  (ãã­ãã¿ã¤ãå®£è¨ã®å ´åã¯ -1 ã®ã¾ã¾æ¾ç½®)
+# @id_specified::Integer : æå®ããã id
+# @restrict_list::{ entry_name => { func_name, [ region_name, ... ] } }
+
+=begin
+# Cell ã¯ã©ã¹ã¯ãä»¥ä¸ã®ãã®ãæ±ã
+# 1)æ®éã®ã»ã«
+# 2)composite ã»ã«ã¿ã¤ãã®ã»ã«
+# 3)composite ã»ã«ã¿ã¤ãã®å
+å´ã®ã»ã« (@in_composite)   # composite ã®å
+å´ã® composite ã»ã«ã¿ã¤ãã®ã»ã«ããã
+#
+# 2) ã¯ CellOfComposite ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã
+#    expand (composite ã»ã«ã®å±é) ã¯ CellOfComposite ã«ã®ã¿å¿
+è¦ãªã¡ã½ããã§ãã
+#    get_real_cell, get_real_port ãªã© @celltype.instance_of?( CompositeCelltype ) ã®å¤å®ããªããã£ãããã
+#    ãã ãåé¢ãã¦ããã¡ã³ããã³ã¹ãã¹ãç¯å²ãåãé¢ããã¦ãã¾ããå¿ãããããªãåé¡ã¨ã®ãã¬ã¼ããªããã
+#
+# 3) ã¯ CellInCompoiste ã¯ã©ã¹ã¨ãã¦åããã»ãããããããããªã
+#    @in_composite ã§å¤å®ãã¦ããå¦çãåãé¢ãã (ä¸è¨ 2) ãããåé¢ã¯å®¹æã§ã¯ãªã)
+#    clone_for_composite ã¯ CellInCompoiste ã«ã®ã¿å¿
+è¦ãªã¡ã½ããã§ãã
+#    ãã ããclone å¾ã« Cell, CellOfComposite ã«å¤åããå¿
+è¦ãããã®ã§ãclone ã§ã¯ãªã new ããå®è£
+ã«å¤æ´ããå¿
+è¦ããã
+#
+=end
+
+  include PluginModule
+
+  @@nest_stack_index = -1
+  @@nest_stack = []
+  @@current_object = nil
+
+  # å®ç¾©ããããã¹ã¦ã®ã»ã«ï¼åºç¾é . namespace ã«å½±é¿ãããªãï¼
+  @@cell_list = []     # composite ã®å
+é¨ã®ã»ã«ãå«ã¾ãªã
+  @@cell_list2 = []    # composite ã®å
+é¨ã®ã»ã«ãå«ã (å
+ã®ã»ã«ãå«ã)
+                       # æå³è§£æå¾ make_cell_list2 ã«ã¦è¨­å®ããã
+
+  def self.push
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = @@current_object
+    @@current_object = nil
+  end
+
+  def self.pop
+    @@current_object = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+
+  # composite ã§ clone ããããã®ï¼å­å­«ã¾ã§å«ãï¼
+  # Join.change_rhs_port ã«ã¦ CompoisteCelltype å
+ã® Join ã®çµåå
+ãå¤æ´ããéã«ä½¿ç¨
+  @@cloned_cell_list = {}
+  ### mikan BUG @@cloned_cell_list ã¯ composite ã®éå±¤ãã¨ã«è¨æ¶ãã¦ããªããããåãååãå
+é¨ã«ç¾ããã¨ããã¾ãåä½ããªã
+  # change_rhs_port ã®å®è£
+ã¯ããããªåããã©ããã¨ãããå¿
+è¦ã¯ãªãã£ããå³è¾ºã«ç¾ããã»ã«åã«ã¯ãcomposite ã®ã»ã«åãåã«ã¤ãªããã ãã§ããã£ã
+
+  def initialize( ct_path, in_composite = false )
+    super()
+    @region = Region.get_current
+
+    # celltype ã®plugin/å­å¨ããã§ãã¯
+    object = Namespace.find( ct_path )    #1
+    if object == nil then
+      # mikan celltype ã®ååãä¸å®å
+¨ "::ct1ct2" ã«ãªã
+      cdl_error( "S1027 \'$1\' celltype not found" , ct_path.get_path_str )
+    elsif ! object.instance_of?( Celltype ) && ! object.instance_of?( CompositeCelltype ) then
+      # mikan celltype ã®ååãä¸å®å
+¨
+      cdl_error( "S1028 \'$1\' not celltype" , ct_path.get_path_str )
+    else
+      @celltype = object
+    end
+
+    @in_composite = in_composite
+    if @in_composite then
+      @compositecelltypejoin_list = NamedList.new( nil, "in cell '#{@name}'" )
+      @plugin = nil
+    else
+      @compositecelltypejoin_list = nil
+      @plugin = Generator.get_plugin
+    end
+
+    @@current_object = self
+    @b_defined = false
+    @b_prototype = false
+    @f_ref     = false
+    @f_cloned  = false
+    @alloc_list = []
+    @id = -1
+    @id_specified = nil
+    @b_duplicate = false
+    @b_checked = false
+    @require_joined_list = {}
+    @entry_array_max_subscript = {}
+    @referenced_port_list = {}
+    @restrict_list = {}
+
+    @cell_list = {}
+    @cell_list2 = []
+  end
+
+  def self.set_name( name )
+    @@current_object.set_name( name )
+  end
+
+  def set_name( name )
+
+    @name = name
+    @local_name = name
+    if "#{Namespace.get_global_name}" != "" then
+      @global_name = :"#{Namespace.get_global_name}_#{name}"
+    else
+      @global_name = name
+    end
+
+    # ãã®æç¹ã§ã¯ãã­ãã¿ã¤ãããå®ç¾©ãåããªãããèªå·±åç
+§ã®ããã«ç»é²
+    # set_f_def ã§ååº¦ç»é²ããªãã
+    # Celltype ã¸ã®ç»é²ã¯ãend_of_parse ã§è¡ã
+    if @in_composite then
+      cell_prev = CompositeCelltype.find( name )
+      if cell_prev == nil then
+        CompositeCelltype.new_cell( self )
+      end
+    else
+      # cell_prev = Namespace.find( [ name ] )   # è¦ªã¾ã§æãã«ãã
+      cell_prev = Namespace.get_current.find( name )
+      if cell_prev == nil then
+        Namespace.new_cell( self )
+        set_namespace_path # @NamespacePath ã®è¨­å®
+      end
+    end
+
+    if cell_prev then
+      if ! cell_prev.instance_of?( Cell ) then
+        cdl_error( "S1029 $1 mismatch with previous one" , name )
+        # celltype ãä¸è´ãã¦ããã ?
+      elsif get_celltype != cell_prev.get_celltype then
+        cdl_error( "S1030 $1: celltype mismatch with previous one" , name )
+      else
+        # region ãä¸è´ãã¦ããã?
+        if ! cell_prev.get_region.equal? get_region then
+          cdl_error( "S1031 $1 region \'$2\' mismatch  with previous one \'$3\'" , name, @region.get_name, cell_prev.get_region.get_name )
+        end
+
+        @@current_object = cell_prev
+        # ãã®æç¹ã§ã¯ãã¾ã ãã­ãã¿ã¤ãå®£è¨ãå®ç¾©ãåããªã
+        # ä»¥åãå®ç¾©ã§ãã£ã¦ãä»åãå®ç¾©ã®å ´åãéè¤ã¨ã©ã¼ã§ãã
+      end
+    end
+
+    @join_list = NamedList.new( nil, "in cell '#{@name}'" )
+    @reverse_join_list = nil
+
+    # debug
+    dbgPrint "Cell new_cell: #{@global_name} #{@in_composite} #{self}\n"
+
+    # å
+é¨ã¢ã­ã±ã¼ã¿ã @alloc_list ã«è¿½å 
+    if @celltype.instance_of? CompositeCelltype then
+      @celltype.get_internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent|
+        nsp = NamespacePath.new( @name, false )
+        rhs = Expression.new( [:OP_DOT, [:IDENTIFIER, nsp], Token.new( ext_alloc_ent.to_s.to_sym, nil, nil, nil ) ] )  #1 æ§æè§£ææ®µéãªã®ã§ locale ä¸è¦
+
+        @alloc_list << [:NORMAL_ALLOC,port_name,nil,fd_name,par_name,rhs]
+# print "add alloc_list: #{port_name}.#{fd_name}.#{par_name}=#{rhs.to_s}\n"
+      }
+    end
+  end
+
+  #=== Cell# cell ã®å®ç¾©
+  # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã
+  def self.new_def
+    @@current_object.new_def
+  end
+
+  #=== Cell# cell ã®å®ç¾©
+  # æ¬ä½(join)ã®å®ç¾©ã®ç´åã«å¼ã³åºããã
+  # ãã®ã¡ã½ããã¯ cell tCelltype Cell { };  '{', '}' ã®é¨åãããå ´åã«å¼åºããã
+  def new_def
+    set_specifier_list( Generator.get_statement_specifier )
+
+    # prototype æå®å­ãªãã
+    if ! @b_prototype then
+      # äºéå®ç¾©ã®ãã§ãã¯
+      if @b_defined == true then
+        cdl_error( "S1032 $1: duplicate cell" , @name )
+        dbgPrint "previous: #{@prev_locale[0]}: line #{@prev_locale[1]} '#{@name}' defined here\n"
+
+        # ã»ã«ã®éè¤å®ç¾©ã¨ã©ã¼ã®å¦ç½®
+        # åã®å®ç¾©ã¯æ¨ã¦ã
+        @join_list = NamedList.new( nil, "in cell '#{@name}'" )
+      end
+
+      @b_defined = true
+      @prev_locale = @locale
+    end
+  end
+
+  def self.new_join( join, b_regular = false )
+    @@current_object.new_join( join, b_regular )
+  end
+
+  #===  Cell# æ°ããçµåããã§ãã¯
+  # STAGE:   P
+  #
+  #join::  Join : æ°ããçµå
+  #b_regular:: bool : éå¸¸ã®å ´æ (bnf.y.rb)ãããªãã° true, ããä»¥å¤(allocator, require) ã§ã¯ false
+  def new_join( join, b_regular = false )
+    join.set_owner self
+
+    # composite ã®æ°ææ³å¯¾å¿ï¼
+    # composite ã®ä¸­ã®ã»ã«ã§ãattribute ã®å®ç¾©ã§ããå ´å
+    # cell å
+ã® attr_ext = composite.attr; æ§æãå¦ç
+    if @in_composite then
+      if @celltype then
+        if @celltype.find(join.get_name).instance_of?( Decl ) then # mikan a::b ã§æå®ããã¦ãããã®ãã¨ã©ã¼ã«ãªããªããã
+          rhs = join.get_rhs
+          if rhs.instance_of? Expression then
+            ele = rhs.get_elements
+            if( ele[0]==:IDENTIFIER )then    #  attr = attr_ext ï¼å³è¾ºåé 
+ï¼ãï¼ #1
+              if( CompositeCelltype.has_attribute?(ele[1].get_name ) )then    # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã
+                ident = ele[1].get_name   # å³è¾ºã¯ attributeï¼
+              else
+                # å³è¾ºã¯ attribute ã«ãªãã®ã§ããã°ãå®æ°ã®ã¯ã
+                # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)
+                ident = nil
+              end
+            else
+              if join.get_rhs.eval_const2(nil) == nil then   # å®æ°å¼ã§ã¯ãªããï¼
+                # å³è¾ºããåä¸ã®ã·ã³ãã«ã§ãªãå ´åãç¾ç¶ã¯æ±ããªã
+                cdl_error( "S1033 rhs expression is not supported. Only attribute is permitted on current version."  )
+                return
+              else
+                # å®æ°ã¯ä¸ã¸æ¸¡ã (cell ã® join ã«ãã)
+                ident = nil
+              end
+            end
+
+            if ident then
+              # attr = attr; ã®ãããªåç
+§ã¯ã¨ã©ã¼ (a = composite.a ã¨ããå¿
+è¦ããã)
+              if @celltype.find( ident ) then
+                cdl_error( "S1034 $1 : cannot refer to $2\'s attribute here. Use \'composite.$3\' to refer to composite celltype\'s" , ident, @celltype.get_name, ident )
+              end
+            end
+          elsif rhs.instance_of? Array then
+            if rhs[0] == :COMPOSITE then   # å³è¾ºã¯ composite.attr ã®å½¢å¼
+              ident = rhs[1].to_sym
+            else
+              ident = nil    # å³è¾ºã¯ { 10, -10 } ã®å½¢å¼
+            end
+          else
+            ident = nil      # å³è¾ºã¯ C_EXP ã®å½¢å¼
+          end
+
+          # ident ãè¦ã¤ãã£ãï¼å³è¾ºã¯åä¸ã® identï¼
+          if ident then
+            # composite ã®æ§ææ³ã®æ§æå¦çã¸æ¸¡ãï¼ã»ã«å¤ã® attr_ext = Cell.attr; æ§æã®å¦çã«æ¸¡ã
+            #                        export_name, internal_cell_name, internal_cell_elem_name
+            decl = CompositeCelltype.new_join( ident, @name, join.get_name, :ATTRIBUTE )  # mikan a::b.ePort ãã¨ã©ã¼ã«ãªããªããã
+            if ! decl.instance_of? Decl then
+              return
+            end
+            ini = decl.get_initializer
+            if ini == nil then
+              return
+            end
+            # ä»¥ä¸ã®æ§ææ³å®è£
+ã«æ¸¡ãï¼
+            # æ§ææ³ã§ã¯ cell ã«åæå¤ãä¸ãããã¨ã§ãcomposite ã§å±æ§ã®åæå¤ãæå®ãããã¨ãã§ãã
+            # attribute ã§æå®ãããåæå¤ã cell ã®å±æ§ã¨ãã¦å¦çããã
+            join.change_rhs( ini )
+          else
+            # ident ããªãï¼å®æ°å¼
+          end
+        else
+          # celltype ã®å±æ§ã¨ãã¦ããã® join ã®ååããªã
+          # ä»¥ä¸ã® join.set_definition ã®ä¸­ã§ã¨ã©ã¼ã¨ãªã
+        end
+      else
+        return    # celltype ããªãï¼ãã§ã«ã¨ã©ã¼
+      end
+    elsif join.get_rhs.instance_of? Array then
+      rhs = join.get_rhs
+      if rhs[0] == :COMPOSITE then
+        # composite ã®ä¸­ã§ãªãã®ã« attr = composite.attr ãä½¿ããã
+        cdl_error( "S1035 composite : cannot specify out of composite celltype definition"  )
+        return
+      end
+    end
+
+    # ä»¥ä¸ composite ææ³å¤æ´åããããå¦ç
+
+    # æ¢ã«å·¦è¾ºãåãååã®åæåãå­å¨ãããï¼
+    j = @join_list.get_item( join.get_name )   # mikan NamespacePath ããã¹ãæã£ã¦ãã
+    if j.instance_of? Join then    # mikan ããã§ã¯ j ã Join or Nil ä»¥å¤ã¯ããªãã¯ã
+
+      # debug
+      dbgPrint "add_array_member: #{@name} port: #{j.get_port_name} rhs: #{j.get_rhs}, #{join.get_port_name} #{join.get_rhs}\n"
+      # å¼ã³å£é
+åï¼ã§ããã¨ä»®å®ãã¦ï¼è¦ç´ ãè¿½å 
+      j.add_array_member join
+
+    else
+      # join
+      @join_list.add_item( join )
+    end
+
+    # if get_owner then   # error S1030 çºçæ get_owner ãè¦ã¤ãããªãã¦ä¾å¤ã«ãªã
+    #   dbgPrint "Cell#new_join: #{get_owner.get_name}.#{@name}\n"
+    # else
+    #   dbgPrint "Cell#new_join: \"owner not fund\".#{@name}\n"
+    # end
+    if ! @in_composite then
+     if join.get_cell
+       dbgPrint "new_join: #{@name} #{@region.get_name} => #{join.get_cell.get_name} #{join.get_cell.get_region.get_path_string}\n"
+     end
+#     p "region: generate? #{@region.is_generate?}"
+    end
+
+  end
+
+  #=== Cell.æ°ããéçµå
+  def self.new_reverse_join( reverse_join )
+    @@current_object.new_reverse_join( reverse_join )
+  end
+
+  #=== Cell#æ°ããéçµå
+  def new_reverse_join( reverse_join )
+    dbgPrint( "new_reverse_join name=#{reverse_join.get_name}\n")
+    b_cb = false
+    if @celltype then
+      ep_name = reverse_join.get_name
+      port = @celltype.find ep_name
+      if port && port.get_signature
+        if port.get_signature.is_callback? then
+          b_cb = true
+        end
+      end
+    end
+    if ! @b_prototype && ! b_cb then
+      cdl_error( "S9999 '$1': reverse join can be used in prototype cell, or with callback signature", @name )
+    end
+    if @reverse_join_list == nil then
+#      @reverse_join_list = NamedList.new( reverse_join, "in cell '#{@name}'" )
+      @reverse_join_list = [ reverse_join ]
+    else
+#      @reverse_join_list.add_item( reverse_join )
+      @reverse_join_list << reverse_join
+    end
+  end
+
+  #=== Cell#éçµåããçµåãçæ
+  # STAGE: S
+  def create_reverse_join
+    if @b_checked then
+      return
+    end
+
+    if @reverse_join_list then
+#      @reverse_join_list.get_items.each{ |rj|
+      @reverse_join_list.each{ |rj|
+        # éçµåã®æ
+å ±ãå¾ã
+        ep_name = rj.get_name
+        ep_subscript, cp_cell_nsp, cp_name, cp_subscript = rj.get_rhs_cell_and_port
+
+        # å¼ã³å£å´ã®ã»ã«ã¨ããã®ã»ã«ã¿ã¤ã
+        cell = Namespace.find cp_cell_nsp
+        if ! cell.instance_of? Cell then
+          cdl_error( "S9999 '$1': not cell for reverse join", cp_cell_nsp.get_path_str )
+          next
+        end
+        ct = cell.get_celltype
+        if ct == nil then
+          next
+        end
+
+        ep_cell_nsp = get_namespace_path
+        ep_subscript_val = ep_subscript ? ep_subscript.eval_const( nil ) : nil
+        rhs = Expression.create_cell_join_expression( ep_cell_nsp, ep_subscript_val, ep_name, rj.get_locale )
+        join = Join.new( cp_name, cp_subscript, rhs, rj.get_locale )
+        cell.new_join( join )
+        # join.set_definition( ct.find(join.get_name) )
+        if cp_subscript then
+          ss_str = "[#{cp_subscript}]"
+        else
+          ss_str = ""
+        end
+        dbgPrint "create_reverse_join: #{cell.get_name}.#{cp_name}#{ss_str} => #{ep_cell_nsp.get_path_str}.ep_name\n"
+      }
+    end
+  end
+
+  def self.external_join( internal_cell_elem_name, export_name, b_composite )
+    @@current_object.external_join( internal_cell_elem_name, export_name, b_composite )
+  end
+
+  #=== Cell# cell å
+ã«è¨è¿°ããå¼ã³å£ã®å¤é¨çµå
+  # internal_cell_elem_name:: string : å¼ã³å£å
+  # export_name:: string: composite ã®å¤é¨ã«å
+¬éããå¼ã³å£å
+  #  å¼ã³å£ãå¤é¨çµåããï¼
+  #  ãã®ã¡ã½ããã¯ãcomposite ã®ä¸­ã® cell ã§ããå¼ã°ããªãï¼
+  def external_join( internal_cell_elem_name, export_name, b_composite )
+
+    # cCall => composite.cCall; ã§ã¯ãªããï¼
+    if( b_composite == false )then
+      # cCall => cCall; ã®ãããªå ´å
+      if @celltype.find( export_name ) then
+        cdl_error( "S1036 $1 : cannot refer to $2\'s here. Use \'composite.$3\' to refer to composite celltype\'s" , export_name, @celltype.get_name, export_name )
+      end
+    end
+    # composite ã®æ§ææ³ã«ããããcell å¤ã® cCall = Cell.cCall; ã®æ§æå¦çã«æ¸¡ã
+    CompositeCelltype.new_join( export_name, @name,  internal_cell_elem_name, :CALL )
+  end
+
+  def self.end_of_parse f_def
+    cell = @@current_object
+    cell.end_of_parse f_def
+    @@current_object = nil
+    return cell
+  end
+
+  def end_of_parse f_def
+    if @b_prototype then  # prototype æå®å­ãã£ãã?
+      f_def = false       # ãã­ãã¿ã¤ãå®£è¨ã¨ãã
+      @b_prototype = false
+    end
+    if f_def == false then
+      # cell tCelltype Cell; ã®å½¢å¼ã®å ´å
+      # f_def == true ã®å ´å new_def ã§ãå¼åºããã
+      set_specifier_list( Generator.get_statement_specifier )
+    end
+    set_f_def f_def
+
+    if @generate then
+      cell_plugin
+    end
+  end
+
+  #=== Cell# ãã­ãã¿ã¤ãå®£è¨(false)ãå®ç¾©(true)ããè¨­å®
+  #    ãã®ã¡ã½ããã¯æ§æè§£éã®æå¾ã«å¼åºããã
+  #f_def::     bool     false if prototype, true if definition
+  def set_f_def f_def
+    if ! f_def then
+      return
+    end
+
+    if ! @in_composite then
+      if @celltype.instance_of? Celltype then
+        @celltype.new_cell self
+      end
+      @@cell_list << self
+    end
+  end
+
+  def set_f_ref
+    dbgPrint "set_f_ref: #{@global_name}\n"
+    @f_ref = true
+
+    # composite ã®å
+é¨ã»ã«ãåç
+§ããããã¨ã«ãã
+    # ä»ã®ã¨ããåé¡ãªãããæªåç
+§ã§ããã¹ããã®ã¾ã§åç
+§ããããã¨ã«ãªã
+    if @cell_list then
+      @cell_list.each{ |cn,cell|
+        cell.set_f_ref
+      }
+    end
+  end
+
+  #=== Cell# cell ã®æå®å­ãè¨­å®
+  # STAGE:  B
+  #
+  #    bnf.y.rb ã® statement_specifiler_list
+  #spec_list::      [ :ALLOCATOR, [ [ :NORMAL_ALLOC, ep_name, subscript, func_name, param_name, expr ], ... ] ]
+  #                     s[0]      s[1]   a[0]        a[1]       a[2]        a[3]     a[4]       a[5]
+  #    ã»ã«ã«æå®ãããã¢ã­ã±ã¼ã¿æå®å­
+  #    a[1] ã® subscript ã¯ãã®ã¡ã½ããã®ä¸­ã§ Expression ãã Integer ã«è©ä¾¡ããã
+  #    åãå£å´ã«çæãããã¢ã­ã±ã¼ã¿å¼ã³å£ã®çµåãå
+é¨çæãã
+  #    å¼ã³å£å´ã¯ Port ã® create_allocator_join ã«ã¦çæ
+  #    ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã®å ´å create_relay_allocator_join ã«ã¦çæã
+  def set_specifier_list( spec_list )
+    return if spec_list == nil  # ç©ºãªãã°ä½ãããªã
+
+    dbgPrint( "set_spec_list: #{@name}\n" )
+    b_generate = false   # generate ãæå®ããã
+
+    spec_list.each{ |s|
+      case s[0]             # statement_specifier
+      when :ALLOCATOR       # [allocator(ePort.func.param=allocCell.eA,ePort.func2.param=allocCell.eA)]
+        s[1].each { |a|     # alloc_list : allocator ã®å
+é¨ã® ',' ã§åºåãããé¨åã®é
+å
+          cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}"    # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®ååï¼'=' ã®å·¦è¾ºã '.' ã«å¤ãã¦ '_' ã§é£çµ
+          # p "#{a[0]} #{a[0+1]} #{a[2+1]} #{a[3+1]} #{cp_name}"
+          if a[1+1] then
+            subscript = a[1+1].eval_const nil
+            a[1+1] = subscript
+          else
+            subscript = nil
+          end
+          # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®çµåãçæ
+          join = Join.new( cp_name, subscript, a[4+1] )   # æ§æè§£ææ®µéãªã®ã§ locale ä¸è¦
+          dbgPrint( "new allocator join #{cp_name} #{subscript} #{a[4+1]}\n" )
+          Cell.new_join( join )
+          @alloc_list << a 
+        }
+      when :ID          # [id(0)]
+        if ! s[1].instance_of? Expression then
+          cdl_error( "S1160 $1 must be constant for id", s[1].to_s )
+        else
+          id = s[1].eval_const nil
+          if id == nil || Integer(id) != id then
+            cdl_error( "S1161 $1 must be constant for id", s[1].to_s )
+          elsif id == 0 then
+            cdl_error( "S1162 $1: id cannot be 0", s[1].to_s )
+          else
+            @id_specified = id
+          end
+        end
+      when :GENERATE      # [generate(CellPlugin,"option")]
+        if @generate then
+          cdl_error( "S1163 generate specifier duplicate"  )
+        end
+        @generate = [ s[1], s[2] ] # [ PluginName, "option" ]
+        b_generate = true
+      when :PROTOTYPE     # [prototype]
+        @b_prototype = true
+      when :RESTRICT      # [restrict]
+        s[1].each{ |re|
+          add_restrict re[0], re[1], re[2]
+        }
+      else
+          cdl_error( "S1039 \'$1\': unknown specifier for cell" , s[0] )
+      end
+    }
+    if @b_prototype then
+      if b_generate then
+         cdl_error( "S9999 '$1': generate and prototype specified simultaneously" , @name )
+      end
+      if @b_defined then
+         cdl_error( "S9999 '$1': prototype specified after definition" , @name )
+      end
+    end
+  end
+
+  def get_allocator_list
+
+    # æå³ãã§ãã¯(set_definition)ããã¦ããªãï¼
+    # relay ã¢ã­ã±ã¼ã¿ã®å ´åãã»ã«ã®æå³ãã§ãã¯ãè¡ããã¦ããªãã¨ã@alloc_list ãå®æããªã
+    if @b_checked == false then
+      set_definition_join
+    end
+    @alloc_list
+  end
+
+  def get_specified_id
+    @id_specified
+  end
+
+  #=== id æå®å­ã®å¤ãè¨­å®
+  # ãã®ã¡ã½ããã¯ããã©ã°ã¤ã³ã§ cell ã®çæé åºãå¶å¾¡ãããå ´åã®ããã«è¨­ãã
+  # éå¸¸ã® id æå®å­ã§ã¯ä½¿ã£ã¦ããªã
+  def set_specified_id id
+    if Integer( id ) != id || id <= 0 then
+      cdl_error( "S1164 '$1' set_specified_id: id not positive integer '$2'", @name, id )
+    elsif @id_specified then
+      cdl_error( "S1165 '$1' set_specified_id: id duplicate", @name )
+    else
+      @id_specified = id
+    end
+  end
+
+  #=== Cell# ã»ã«ã¿ã¤ããã©ã°ã¤ã³ (generate æå®å­)
+  def cell_plugin
+
+    load_plugin( @generate[0], CellPlugin )
+
+    plugin_name = @generate[0]
+    option = @generate[1]
+    plugin_object = nil
+    eval_str = "plugin_object = #{plugin_name}.new( self, option )"
+    if $verbose then
+      print "new cell : #{eval_str}\n"
+    end
+
+    begin
+      eval( eval_str )     # plugin ãçæ
+      plugin_object.set_locale @locale
+      @generate[ 2 ] = plugin_object
+      generate_and_parse plugin_object
+    rescue Exception => evar
+      cdl_error( "S1166 $1: fail to new", plugin_name )
+      print "eval( #{eval_str} )\n"
+
+      print_exception( evar )
+    end
+  end
+
+  def add_compositecelltypejoin join
+    @compositecelltypejoin_list.add_item join
+  end
+
+  #=== Cell# cell ã composite ã»ã«ã¿ã¤ãã®ã»ã«ç¨ã« clone ãã
+  #name::        string : è¦ª cell ã®åå  (cell tComposite cell1 ã§ã® cell1)
+  #global_name:: string : è¦ª cell ã® global_name 
+  #join_array::  Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã®
+  #ct_name::     string : è¦ªã»ã«ã®ã»ã«ã¿ã¤ãå
+  #region::      Region : å
+ã®ã»ã«ãå±ãã region
+  #ãã®ã¡ã½ããã¯ CompositeCelltype ã® expand ããå¼åºããã
+  def clone_for_composite( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale )
+
+    # debug
+    dbgPrint "Cell#clone_for_composite : cloning: #{@name} #{global_name}  b_defined=#{@b_defined}\n"
+
+    @my_clone = self.clone
+    @@cloned_cell_list[ self ] = @my_clone
+
+    # clone ããã»ã«ã®å
+é¨ã«æã¤ååæ
+å ±ãèª¿æ´ãã
+
+    @my_clone.set_cloned( name, global_name, namespacePath, join_array, ct_name, region, plugin, locale )
+
+    # @celltype == nil ã¯ä»¥åã«ã»ã«ã¿ã¤ãæªå®ç¾©ã¨ã©ã¼
+    if @b_defined == true && @celltype != nil then
+      if @celltype.instance_of?( Celltype ) then
+        # celltype ã«ç»é²ï¼ã³ã¼ãçæã®å¯¾è±¡ã¨ãªãï¼
+        @celltype.new_cell( @my_clone )
+      end
+    end
+
+    return @my_clone
+  end
+
+  #=== Cell# clone ãããã»ã«ã®å
+é¨ã«æã¤ååæ
+å ±ãèª¿æ´ãã
+  #name::        string : è¦ª cell ã®åå  (cell tComposite cell1 ã§ã® cell1)
+  #global_name:: string : è¦ª cell ã® global_name
+  #join_array::  Join[] : composite ã® cell ã® join ã§ããã® cell ã«å¯¾å¿ãããã®
+  #parent_ct_name:: string : è¦ªã»ã«ã®ã»ã«ã¿ã¤ãåï¼composite ã»ã«ã¿ã¤ãï¼
+  #  ãã®ã¡ã½ããã¯ããä¸ã® clone_for_composite ããå¼åºãããclone ãããã»ã«ãæ´ãã
+  def set_cloned( name, global_name, namespacePath, join_array, parent_ct_name, region, plugin, locale )
+
+    # debug
+    dbgPrint "cell.set_cloned : global_name: #{global_name}  name: #{name}  @name: #{@name}\n"
+
+    @global_name = :"#{global_name}_#{@name}"
+    @name = :"#{name}_#{@name}"
+    @NamespacePath = namespacePath.change_name @name
+    @region = region
+    @plugin = plugin
+    @locale = locale
+
+    @in_composite = false
+    @b_checked = false
+    @f_cloned = true
+
+    # Namespace.new_cell( self )  # mikan namespace å¯¾å¿
+    region.new_cell( self )  # mikan  namespace ã« cell ãç½®ããªããã¨ãä»®å®
+
+    # join_list : NamedList ã® clone ãä½ã
+    if @celltype then
+      dbgPrint "set_cloned: #{@celltype.get_name} #{@name} #{region.get_name}\n"
+    end
+    @join_list = @join_list.clone_for_composite( parent_ct_name, name, locale )
+    @referenced_port_list = {}
+
+    @alloc_list = []
+    @require_joined_list = {}
+    @entry_array_max_subscript = {}
+    @cell_list = {}
+    @cell_list2 = []
+
+    # ãã®ã»ã«ã®ã°ã­ã¼ãã«åãä¸ãã
+    # C_EXP ã®$id$ ç½®æã¯ãã®ã»ã«ã®ååã«ãªã
+    join_array.each { |j|
+      @join_list.change_item j
+    }
+
+    # clone ãããã¨ããã»ã«ã composit ã»ã«ã¿ã¤ãï¼
+    if @celltype.instance_of?( CompositeCelltype ) then
+      # composite cell ãåå¸°çã«å±é
+      @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale )
+    end
+
+  end
+
+  #=== Cell# clone ããã cell ã® join_list ã®å³è¾ºã®å¤æ´
+  #  å¼ã³å£ã®å³è¾ºã® cell ãä»ã® clone ããã cell ã«ç½®æã
+  def change_rhs_port
+
+    # debug
+    dbgPrint "Cell change_rhs_port: global_name: #{@global_name}\n"
+
+    @join_list.get_items.each { |j|
+      j.change_rhs_port( @@cloned_cell_list, @celltype )
+    }
+
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # å
+¥ãå­ã®ã»ã«ã«ã¤ãã¦ãå¤æ´
+      @cell_list.each{ |name,c|
+        c.change_rhs_port
+      }
+    end
+  end
+
+  def get_f_def
+    @b_defined
+  end
+
+  def get_f_ref
+    if @f_ref then
+      return true
+    else
+      return false
+    end
+  end
+
+  def get_name
+    @name
+  end
+
+  def get_local_name
+    @local_name
+  end
+
+  def get_global_name
+    @global_name
+  end
+
+  def get_region
+    @region
+  end
+
+  def self.get_current
+    @@current_object
+  end
+
+  #=== Cell# çæãããã»ã«ãï¼
+  # æé©åãã³ã¼ãçæä¸­ã«ãå¯¾è±¡ã¨ãªã region ã«å±ããå ´å true ãè¿ã
+  def is_generate?
+    if $generating_region == nil then
+      # æ§æè§£éãæå³è§£ææ®µéã§å¼ã°ããã¨ä¾å¤çºç
+      raise "is_generate? called before optimizing"
+    end
+
+    # print "Cell#is_generate?: #{@name} #{@region.get_name} #{$generating_region.get_name}\n"
+    if $generating_region == @region.get_link_root then
+      return true
+    else
+      return false
+    end
+  end
+
+  #=== Cell# composite å
+é¨ã®è¤è£½ãããã»ã«ãï¼
+  # composite å®ç¾©ã®å
+é¨ã®ã»ã« (@in_composite = true) ã§ã¯ãªã
+  def is_cloned?
+    @f_cloned
+  end
+
+  #=== Cell# composite å
+é¨ã®ã»ã«ãï¼
+  def is_in_composite?
+    @in_composite
+  end
+
+  # composite cell ã® port ã«å¯¾å¿ããå
+é¨ã® cell ã® port ã®ååï¼ãªã³ã¯æã«å¿
+è¦ãªååï¼
+  def get_real_global_name port_name
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # debug
+      dbgPrint "get_real_global_name: cell name: #{@name} #{@local_name} #{@global_name} #{port_name}\n"
+      @cell_list.each{ |n,c|
+        dbgPrint "   name: #{n}\n"
+        dbgPrint " get_name: #{c.get_name} local_name: #{c.get_local_name}\n"  if c
+        dbgPrint "\n\n"
+      }
+
+      cj = @celltype.find_export( port_name )
+
+      # debug
+      dbgPrint " composite join name: #{cj.get_name}  cell: #{cj.get_cell_name}  cell elem: #{cj.get_cell_elem_name}\n"
+
+      name = @cell_list[ "#{cj.get_cell_name}" ].get_real_global_name( cj.get_cell_elem_name )
+      return name
+
+    else
+      # debug
+      dbgPrint "  get_real_global_name: cell name: #{@global_name}\n"
+
+      return @global_name
+    end
+  end
+
+  #=== Cell# ã»ã«ã®åãå£ port_name ã«å¯¾ããå®éã®ã»ã«åãåãå£åã '_' ã§é£çµ
+  #    namespace å + '_' + ã»ã«å + '_' + åãå£å   ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼
+  def get_real_global_port_name port_name
+
+    # composite ãï¼
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # debug
+      dbgPrint "get_real_global_port_name: cell name: #{@name} #{@local_name} #{@global_name} #{port_name}\n"
+      @cell_list.each{ |n,c|
+        dbgPrint "   name: #{n}\n"
+        dbgPrint " get_name: #{c.get_name} local_name: #{c.get_local_name}\n"  if c
+        dbgPrint "\n"
+      }
+
+      # ã»ã«ã¿ã¤ãå
+ã§ port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçææ®µéã§ã¯å¿
+ãè¦ã¤ããï¼
+      cj = @celltype.find_export( port_name )
+
+      # debug
+      dbgPrint "   composite join name: #{cj.get_name}  cell: #{cj.get_cell_name}  cell elem: #{cj.get_cell_elem_name}\n"
+
+      # composite ã®å
+é¨ã®ã»ã«ã«å¯¾ãåå¸°çã« get_real_global_port_name ãé©ç¨
+      name = @cell_list[ "#{cj.get_cell_name}" ].get_real_global_port_name( cj.get_cell_elem_name )
+      return name
+
+    else
+      # debug
+      dbgPrint "get_real_global_port_name:  cell name: #{@global_name}\n"
+
+      return "#{@global_name}_#{port_name}"
+    end
+  end
+
+  #=== Cell# PORT (celltype ã®å®ç¾©) ãå¾ã
+  def get_real_port( port_name )
+
+    # composite ãï¼
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # ã»ã«ã¿ã¤ãå
+ã§ port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçææ®µéã§ã¯å¿
+ãè¦ã¤ããï¼
+      cj = @celltype.find_export( port_name )
+
+      # composite ã®å
+é¨ã®ã»ã«ã«å¯¾ãåå¸°çã« get_real_port ãé©ç¨
+      port = @cell_list[ "#{cj.get_cell_name}" ].get_real_port( cj.get_cell_elem_name )
+      return port
+    else
+
+      return @celltype.find( port_name )
+    end
+  end
+
+  #=== Cell# cell ãå¾ã
+  #    composite ã§ãªããã°èªåèªèº«ãè¿ã
+  def get_real_cell( port_name )
+
+    # composite ãï¼
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # ã»ã«ã¿ã¤ãå
+ã§ port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçææ®µéã§ã¯å¿
+ãè¦ã¤ããï¼
+      cj = @celltype.find_export( port_name )
+
+      # composite ã®å
+é¨ã®ã»ã«ã«å¯¾ãåå¸°çã« get_real_port ãé©ç¨
+      cell = @cell_list[ "#{cj.get_cell_name}" ].get_real_cell( cj.get_cell_elem_name )
+      return cell
+    else
+
+      return self
+    end
+  end
+
+
+  #=== Cell# åãå£ã®port ã®åç
+§ã«ã¦ã³ããã¢ãããã
+  #port_name:: Symbol  : ãã¼ãå
+  def port_referenced port
+    if @referenced_port_list[ port ] then
+      @referenced_port_list[ port ] += 1
+    else
+      @referenced_port_list[ port ] = 1
+    end
+
+    # composite ãï¼
+    if @celltype.instance_of?( CompositeCelltype ) then
+
+      # ã»ã«ã¿ã¤ãå
+ã§ port_name ã® CompositeCelltypeJoin ãæ¢ãï¼ã³ã¼ãçææ®µéã§ã¯å¿
+ãè¦ã¤ããï¼
+      cj = @celltype.find_export( port.get_name )
+
+      dbgPrint " port_referenced: #{@celltype.get_name} #{@name} cj=#{cj&&(cj.get_name)||"nil"}\n"
+
+      if cj then  # æ¢ã«ã¨ã©ã¼
+        # composite ã®å
+é¨ã®ã»ã«ã«å¯¾ãåå¸°çã« get_real_port ãé©ç¨
+        cell = @cell_list[ "#{cj.get_cell_name}" ]
+        if cell && cell.get_celltype then
+          cell.port_referenced( cell.get_celltype.find( cj.get_cell_elem_name ) )
+        end
+      end
+    end
+  end
+
+  def get_internal_port_name port_name
+    if @celltype.instance_of?( CompositeCelltype ) then
+      cj = @celltype.find_export( port_name )
+#      return "#{@name}_#{cj.get_cell.get_internal_port_name cj.get_cell_elem_name}"
+      return cj.get_cell.get_internal_port_name( cj.get_cell_elem_name )
+    else
+
+      # debug
+      dbgPrint "  get_global_port_name: cell port: #{@global_name}_#{port_name}\n"
+
+      return "#{@global_name}_#{port_name}"
+    end
+  end
+
+  def get_celltype
+    @celltype
+  end
+
+  def get_join_list
+    @join_list
+  end
+
+  def set_id id
+    @id = id
+  end
+
+  def get_id
+    @id
+  end
+
+  def get_plugin
+    @plugin
+  end
+
+  def get_cell_list2
+    list = []
+    @cell_list2.each{ |cell|
+      list << cell
+      list += cell.get_cell_list2
+    }
+    return list
+  end
+
+  #=== Cell# åãå£é
+åã®æ·»æ°ã®æå¤§å¤ãè¨­å®
+  def set_entry_port_max_subscript( port, num )
+    dbgPrint( "set_entry_port_max_subscript: #{@name}.#{port.get_name}: #{num}\n" )
+    subscript = @entry_array_max_subscript[port]
+
+    if subscript == nil || num > subscript then
+      @entry_array_max_subscript[port] = num
+      set_entry_inner_port_max_subscript( port, num )
+    end
+  end
+
+  #=== Cell# composite ã®å
+å´ã»ã«ã®åãå£é
+åã®æ·»æ°ã®æå¤§å¤ãè¨­å®
+  def set_entry_inner_port_max_subscript( port, num )
+    if @cell_list == nil then   # mikan ããã£ã¦åé¡ãªãï¼
+      return    # ãã­ãã¿ã¤ãå®£è¨ããããã¦ããªãã¦ãå
+å´ã»ã«ãå±éããã¦ããªã
+    end
+
+    # composite ã®å
+å´ã®ã»ã«ã«ä¼æ­
+    if @celltype.instance_of? CompositeCelltype then
+      cj = @celltype.find_export port.get_name
+      if cj && @cell_list[ cj.get_cell_name.to_s ] then
+        inner_cell = @cell_list[ cj.get_cell_name.to_s ]
+        ct = inner_cell.get_celltype
+        if ct then
+          inner_port = ct.find( cj.get_cell_elem_name )
+          inner_cell.set_entry_port_max_subscript( inner_port, num )
+        end
+      end
+    end
+  end
+
+  #=== Cell# åãå£é
+åã®æ·»æ°ã®æå¤§å¤ãè¿ã
+  # é·ãã¯ +1 ãã
+  # 1ã¤ããªãå ´åã¯ -1 ãè¿ã
+  def get_entry_port_max_subscript( port )
+    subscript = @entry_array_max_subscript[port]
+    if subscript == nil then
+      subscript = -1
+    end
+    return subscript
+  end
+
+  #=== Cell# ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã®çµåãçæ
+  # STAGE: S
+  # å¼ã³å£å´ã®çµåãå
+ã«åãå£å´ã®çµåãçæ
+  def create_relay_allocator_join
+
+    # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼
+    return if @celltype == nil
+
+    # relay allocator ãçæ
+    @celltype.get_port_list.each { |p|
+      ail = p.get_allocator_instance
+      if ail then
+        dbgPrint "create_relay_allocator_join: #{@name}, #{p.get_name}\n"
+        if p.get_array_size then
+          # mikan relay allocator ã array ã«å¯¾å¿ã§ãã¦ãããã®ã§ã¯ï¼
+          cdl_error( "S1040 array not supported for relay allocator"  )
+          next
+        end
+        ail.each{ |name,ai2|
+          # ai2 = [ :INTERNAL_ALLOC|:RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ]
+          if ai2[0] == :RELAY_ALLOC then
+            dbgPrint "create_relay_allocator_join: #{@name}, #{name}\n"
+            # å¼ã³å£å´ã®çµåãåãåºã
+            ja = @join_list.get_item( :"#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" )
+            if ja == nil then
+              # è¦ã¤ãããªãå ´å
+              found = false
+              
+              # composite å
+ã§å¤é¨ã«çµåããã¦ããã
+              if @in_composite then
+                @compositecelltypejoin_list.get_items.each { |cj|
+                  dbgPrint( "create relay_allocator in_composite\n" )
+                  dbgPrint("    #{cj.get_cell_name} #{@name} #{cj.get_cell_elem_name} #{ai2[3]}_#{ai2[4]}_#{ai2[5]}\n")
+                  if cj.get_cell_name == @name &&
+                      cj.get_cell_elem_name == :"#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" then
+                    found = true
+                    dbgPrint "create_relay_allocator: found #{cj.get_cell_elem_name}\n"
+                    break
+                  end
+                }
+              end
+
+              if found == false then
+                cdl_error( "S1041 \'$1_$2_$3\': not joined. cannot create internal join for relay allocator" , ai2[3], ai2[4], ai2[5] )
+                print( "      In cell #{get_name}\n" )
+                # join ãæªçµåã§ãããã¨ã®ã¨ã©ã¼ã¯äºåº¦ã§ã (S1043)
+              end
+              next    # æã¡åã
+            end
+
+            b_export = false
+            # composite å
+ã®ã»ã«ã§ã¨ã¯ã¹ãã¼ãããã¦ããããã§ãã¯
+            #  mikan ã¨ã¯ã¹ãã¼ãå´ã¨ããã¡ãå´ã§ããªã¬ã¼å
+ãä¸è´ããããã§ãã¯ãå¿
+è¦
+            if @compositecelltypejoin_list then
+              # export ããã¦ãããèª¿ã¹ã
+              @compositecelltypejoin_list.get_items.each{ |cj|
+                # å±æ§åã¨ composite ã® export ããååã¯ä¸è´ããã
+                if p.get_name == cj.get_cell_elem_name then
+                  print "export : #{p.get_name}\n"
+                  b_export = true    # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã
+                  break
+                end
+              }
+              # 
+            end
+
+            # mikan é
+å
+            am = nil
+            if am then
+              am.each{ |ja2|
+                rhs = ja2.get_rhs
+                subscript = ja2.get_subscript
+                if b_export == false then
+                  # CompositeCelltype ã®å ´åãå
+å´ã®ã»ã«ã§çæããã
+                  join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs, @loacle )
+                  # p ( "#{p.get_name}_#{ai2[1]}_#{ai2[2]}", subscript, rhs )
+                  new_join( join )
+                  join.set_definition( @celltype.find(join.get_name) )
+                  # mikan relay mismatch ãã§ãã¯ãã§ãã¦ããªãï¼ä¸æ¹ãåç
+§ï¼
+                end
+                @alloc_list << [ :NORMAL_ALLOC, p.get_name, subscript, ai2[1], ai2[2], rhs ]
+              }
+            else
+              if b_export == false then
+                # CompositeCelltype ã®å ´åãå
+å´ã®ã»ã«ã§çæããã
+                join = Join.new( :"#{p.get_name}_#{ai2[1]}_#{ai2[2]}", nil, ja.get_rhs, @locale )
+                new_join( join )
+                join.set_definition( @celltype.find(join.get_name) )
+                if @celltype.instance_of? CompositeCelltype then
+                  jr = @join_list.get_item( :"#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" )
+                  if jr.get_rhs_cell2 != join.get_rhs_cell2 || jr.get_rhs_port2 != join.get_rhs_port2 then
+                    cdl_error( "S1167 \'$1\': relay mismatch \'$2\'",
+                                      "#{p.get_name}_#{ai2[1]}_#{ai2[2]}",
+                                      "#{ai2[3]}_#{ai2[4]}_#{ai2[5]}" )
+                    # æ¬å½ã¯ composite ã®å¼ã³å£ã¨åãå£ã®éã§è¡ãã¹ãã ããå
+é¨ã§å¤æ®µæ¥ç¶ããã¦ããå ´å
+                  else
+                    dbgPrint "relay success:  #{p.get_name}_#{ai2[1]}_#{ai2[2]}=>#{ai2[3]}_#{ai2[4]}_#{ai2[5]} #{jr.get_rhs_cell2.get_name}.#{jr.get_rhs_port2} \n"
+                  end
+                end
+              end
+              @alloc_list << [ :NORMAL_ALLOC, p.get_name, nil, ai2[1], ai2[2], ja.get_rhs ]
+            end
+            dbgPrint "create_relay_allocator_join: #{p.get_name}_#{ai2[1]}_#{ai2[2]} #{ai2[3]}_#{ai2[4]}_#{ai2[5]}\n"
+          end
+        }
+      end
+    }
+  end
+
+  #=== Cell# @@cell_list2 ãä½ã
+  # @@cell_list2 ã¯ãåºç¾é ã« composite å
+ãå«ãã»ã«ã®ãªã¹ã
+  def self.make_cell_list2
+    @@cell_list.each{ |c|
+      @@cell_list2 << c
+      @@cell_list2 += c.get_cell_list2
+    }
+  end
+
+  #=== Cell# @@cell_list2 ãå¾ã
+  # composite å
+ãå«ã (compositeãå«ã)
+  # æå³è§£æå¾ã«ä½æããã
+  def self.get_cell_list2
+    @@cell_list2
+  end
+
+  #=== Cell# @@cell_list ãå¾ã
+  #composite ã®ä¸­ãå«ã¾ãªã
+  def self.get_cell_list
+    @@cell_list
+  end
+
+  #=== Cell# reverse_join ãçæãã
+  def self.create_reverse_join
+    @@cell_list.each{ |c|
+      ct = c.get_celltype
+      # if c.is_generate? then
+      if ct then
+        c.create_reverse_join
+      end
+      # end
+    }
+  end
+
+  #=== Cell# reverse_require_join ãçæãã
+  def self.create_reverse_require_join
+    @@cell_list2.each{ |c|
+      ct = c.get_celltype
+      # if c.is_generate? then
+        if ct then
+          # self ã¸ã®å¼ã³å£å´ã®çµåãçæ
+          ct.create_reverse_require_join c
+        end
+      # end
+    }
+  end
+
+  #=== Cell# åãå£ã®port ã®åç
+§ã«ã¦ã³ããè¨­å®ãã
+  # self ã¯å¼ã³å
+ã®ã»ã«
+  # å¼ã³å
+ã»ã«ã®åãå£ã®åç
+§ã«ã¦ã³ããã¢ãããã
+  def set_port_reference_count
+    @join_list.get_items.each { |j|
+      if j.get_definition.instance_of? Port then
+        am = j.get_array_member2
+        if am then             # å¼ã³å£é
+å
+          am.each { |j2|
+            next if j2 == nil    # optional ã§ä¸é¨ãæ¬ è½ãã¦ããã±ã¼ã¹
+            cell = j2.get_rhs_cell2
+            next if cell == nil     # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼
+            port = cell.get_celltype.find( j2.get_rhs_port2 )
+            dbgPrint( "set_port_reference_count: #{@name}.#{j2.get_name} => #{cell.get_name}.#{port.get_name}\n")
+            cell.port_referenced port
+          }
+        else
+          cell = j.get_rhs_cell2
+          next if cell == nil     # å³è¾ºãè¦ã¤ãããªãã£ãï¼æ¢ã«ã¨ã©ã¼
+          port = cell.get_celltype.find( j.get_rhs_port2 )
+          dbgPrint( "set_port_reference_count: #{@name}.#{j.get_name} => #{cell.get_name}.#{port.get_name}\n")
+          cell.port_referenced port
+        end
+      end
+    }
+  end
+
+  #=== Cell# çµå(Join)ã®ãã§ãã¯
+  #     Join ã¯å¼ã³å£ã®çµåã¾ãã¯ attribute ã®åæå
+  #
+  #  mikan ãã®ã¡ã½ããã¯ãä»¥ä¸ã®ï¼ã¤ã®ãã§ãã¯ãããªãããåå²ããã»ããããé©åãªé·ãã®ã¡ã½ããã«ãªã
+  #  ã»ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã®çæ => create_relay_allocator_join
+  #  ã»æªçµåã®å¼ã³å£ã®ãã§ãã¯
+  #  ã»ãã¤ã³ã¿åãé
+åã§åæåãããå ´åã®ãã§ãã¯
+  #  ã»æªåæåã®å±æ§ã®ãã§ãã¯
+  def check_join
+
+    # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼
+    return if @celltype == nil
+    return if @b_defined == false
+    return if @f_cloned == true    # å
+é¨ã»ã«ã«ã¤ãã¦ã¯ãcomposite ã®å®ç¾©æã«ãã§ãã¯ããã¦ãã
+
+    # debug
+    # if @compositecelltypejoin_list then
+    #   p "check_join"
+    #   @compositecelltypejoin_list.get_items.each { |cj| p "#{cj.get_name} #{cj.get_name.object_id}" }
+    # end
+
+    # æªçµåã®å¼ã³å£ã®ãã§ãã¯
+    @celltype.get_port_list.each { |p|
+
+      # å¼ã³å£ã§ãªããã°ããã§ãã¯ããªã
+      next if p.get_port_type != :CALL
+
+      # debug
+      dbgPrint "check_join: #{@name} #{get_celltype.get_name} #{p.get_name}\n"
+
+      # çµåãªã¹ãã®ä¸­ããå¼ã³å£åã«ä¸è´ãããã®ãåãã ã
+      j = @join_list.get_item( p.get_name )
+
+      if j == nil then
+        # æªçµåã®å¼ã³å£
+
+        # composite celltype ã®å
+é¨ã®å ´åãcomposite celltype ã export ããå¼ã³å£ã«çµåããã¦ãããæ¢ã
+        found = false
+        if @in_composite then
+          # composite celltype ã® export ãããã®ãã¹ã¦ããæ¢ã
+          # ï¼export ãããã®ã®å³è¾ºå¤ããæ¢ãããã« get_item ã§ã¯ãã¡ï¼
+          @compositecelltypejoin_list.get_items.each{ |cj|
+            # å¼ã³å£åã¨ composite ã® export ããååã¯ä¸è´ããã
+            if p.get_name == cj.get_cell_elem_name then
+              found = true
+            end
+          }
+        end
+
+        # å¼ã³å£é
+åã®å ´å optional ã§å
+¨ã¦ã®è¦ç´ ãåæåãããªãå ´åã«ãããã¸æ¥ã
+        if ! found && ! p.is_require? && ! p.is_optional? then
+          if ! p.is_allocator_port? then
+            cdl_error( "S1042 call port \'$1\' not initialized in cell \'$2\'" , p.get_name, @name )
+          else
+            cdl_error( "S1043 call port \'$1\' not initialized in cell \'$2\'. this call port is created by tecsgen. check allocator specifier" , p.get_name, @name )
+          end
+        end
+      elsif p.get_array_size.kind_of? Integer then
+        # æ·»æ°ããå¼ã³å£é
+åã®å ´åããã¹ã¦ã®æ·»æ°è¦ç´ ãåæåããã¦ããããã§ãã¯ãã
+
+        am = j.get_array_member2
+        if( am )then
+          # join ã¯é
+å
+
+          # å¼ã³å£é
+åå®ç¾©ã§ã®é
+åã®å¤§ãã
+          length = p.get_array_size
+
+          # é
+åã®å¤§ãããå¼ã³å£é
+åå®ç¾©ã¨çµåå®ç¾©ã§ä¸è´ãããï¼
+          if am.length != length then
+            if ! p.is_optional? || am.length >= length then
+              # optional ã®å ´åãè¦ç´ æ°ãå°ãªãããã®ã¯ OK
+              cdl_error( "S1044 $1: array initializer too many or few, $2 for $3" , p.get_name, am.length, length )
+            end
+
+            # am ã®è¦ç´ ã« nil ãè¿½å ãã¦ãã (#_CPA_# ã®ã³ã¼ãçææããã®é
+åè¦ç´ æ°åçæ)
+            i = am.length
+            while i < length
+              am << nil
+              i += 1
+            end
+          end
+
+#          # é
+åè¦ç´ ã®æãããªãããã§ãã¯
+#          if am.length < length then  # æºããªãå ´åæ¢ã«ã¨ã©ã¼ã ãè¦ç´ ã®ããç¯å²ã§ãã§ãã¯
+#            length = am.length
+#          end
+          i = 0
+          while( i < length )
+            if am[i] == nil then
+              if ! p.is_optional? then
+                cdl_error( "S1045 $1[$2]: not initialized" , p.get_name, i )
+              end
+            else
+              # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯
+              if ! @in_composite then
+                am[i].check_region2
+              end
+            end
+            i += 1
+          end
+
+        # else
+        # join ãéé
+åã§ããã°ãæ¢ã«ã¨ã©ã¼
+        end
+      elsif j.get_array_member then
+        # æ·»æ°ãªãå¼ã³å£é
+åã®å ´å
+        am = j.get_array_member2
+        length = am.length
+        i = 0
+        while i < length
+          if am[i] == nil then
+            if ! p.is_optional? then
+              cdl_error( "S1046 $1[$2]: not initialized" , p.get_name, i )
+            end
+          end
+          i += 1
+        end
+
+        # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯
+        if ! @in_composite then
+          am.each { |join|
+            if join then
+              join.check_region2
+            end
+          }
+        end
+      else
+        # å¼ã³å£ï¼»é
+åãã§ãªãå ´å
+
+        # çæãããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯
+        if ! @in_composite then
+          j.check_region2
+        end
+
+      end # j != nil
+    }
+
+    # ãã¤ã³ã¿åãé
+åã§åæåãããå ´åã®ãã§ãã¯
+    (@celltype.get_attribute_list+@celltype.get_var_list).each { |a|
+      if a.get_size_is then
+
+        if a.instance_of? CompositeCelltypeJoin then
+          # æ¢ã«ã¨ã©ã¼ã«ãªã£ã¦ãã
+          # cdl_error( "S1047 size_is pointer cannot be exposed for composite attribute"  )
+          next
+        end
+
+        if( ! a.get_type.kind_of?( PtrType ) ) then
+          cdl_error( "S1048 $1: size_is specified for non-pointer type" , a.get_name )
+        else
+          size = a.get_size_is.eval_const( @join_list, @celltype.get_name_list )
+          a.get_type.set_scs( a.get_size_is, nil, nil, nil, false )
+          if( ! size.kind_of? Integer )then               # C_EXP ã®å¯è½æ§ãã
+            # mikan å¤åããã§ã®ã¨ã©ã¼çºçã¯ä¸è¦ãeval_const ã®ä¸­ã§å¤æ°ãå­å¨ããªããåãä¸é©åãªã©ã®ã¨ã©ã¼ã«ãªãã¯ã
+            cdl_error( "S1049 $1: size_is arg not constant" , a.get_name )
+          else
+            j = @join_list.get_item( a.get_identifier )
+            if j then
+              ini = j.get_rhs
+              if ini then
+                if ! ini.instance_of?( Array ) then
+                  cdl_error( "S1050 unsuitable initializer, need array initializer"  )
+                elsif size < ini.length then
+                  cdl_error( "S1051 too many initializer for array, $1 for $2" , ini.length, size )
+                else
+                  # a.get_type.set_scs( a.get_size_is, nil, nil )
+                end
+              end
+            else
+              # size_is å¼æ°ãã»ã«ã§æå®ããã¦ãã¦ãåæåå­ãã»ã«ã¿ã¤ãã§æå®ããã¦ããã±ã¼ã¹ã®ãã§ãã¯
+              ini = a.get_initializer
+              if ini.instance_of? Expression
+                ini = ini.eval_const( @celltype.get_name_list )
+              end
+              if ini.instance_of? Array then
+                if( ini.length > size )then
+                  cdl_error( "S1168 too many initializer for array, $1 for $2", ini.length, size )
+                end
+              end
+            end
+          end
+        end
+      else
+        if ! a.instance_of? CompositeCelltypeJoin then
+          # composite ã¯ size_is æå®ã§ããªã
+          if a.get_type.kind_of?( PtrType ) then
+            j = @join_list.get_item( a.get_identifier )
+            if j && j.get_rhs.instance_of?( Array ) then
+              ## size_is æå®ããã¦ããªããã¤ã³ã¿ã Array ã§åæåããã¦ããããã¨ã©ã¼ã¨ãã
+              cdl_error( "S1169 $1: non-size_is pointer cannot be initialized with array initializer" , a.get_identifier )
+            end
+          end
+        end
+      end
+    }
+
+    # æªåæåã®å±æ§ããã§ãã¯
+    @celltype.get_attribute_list.each { |a|
+      b_init = false
+      # self.show_tree 1
+      if a.get_initializer then                               # ã»ã«ã¿ã¤ãã§åæåããã¦ãã
+        b_init = true
+        # @in_composite ã§ export ããã¦ããå ´åã«ã¯ããã®åæå¤ã¯ä½¿ãããªã
+        # export ããã¦ãããããªãã«é¢ããããåæåããã¦ãããã¨ãä¿è¨¼ããã
+      elsif @join_list.get_item( a.get_name ) then            # ã»ã«ã§åæåããã¦ãã
+        b_init = true
+      elsif @in_composite && @compositecelltypejoin_list then
+        # å±æ§ã export ããã¦ãããèª¿ã¹ããexport ããã¦ããã°æªåæåã¨ã¯ããªã
+        # mikan ãªãã¢ãµã¼ã
+        @compositecelltypejoin_list.get_items.each{ |cj|
+          # å±æ§åã¨ composite ã® export ããååã¯ä¸è´ããã
+          if a.get_name.to_sym == cj.get_cell_elem_name.to_sym then
+            b_init = true    # å±æ§ã¯ export ããã¦ããã®ã§ãã¨ããããæªåæåã¨ã¯ããªã
+          end
+        }
+        if b_init then
+          # size_is ã®å¼æ°ããããããããã§ãã¯ãã
+          # å
+é¨ã»ã«ã® size_is ãã¨ã¯ã¹ãã¼ããã size_is ã¨ãããããããã§ãã¯ãã
+          # å
+é¨ã»ã«ã¨ã¨ã¯ã¹ãã¼ãã§ååãå¤ãã¦ããå¯è½æ§ãããã®ã§ãå
+é¨ã»ã«ã® size_is ã®ååãå¤æããä¸ã§ãã§ãã¯ãã
+          if a.get_size_is then
+            ### p "attr: get_size_is"
+            cj = @compositecelltypejoin_list.get_item a.get_name.to_sym
+            if cj.get_port_decl.instance_of? Decl then
+              ### p "attr: get_size_is 2"
+              # cj_size_is ã¯ãå¤é¨å
+¬éããã attr ã® size_is
+              cj_size_is = cj.get_port_decl.get_size_is
+              if cj_size_is == nil then
+                cdl_error( "S1170 \'$1\' has size_is but export attr \'$2\' doesn't have", a.get_name, cj.get_name )
+              end
+              exprs = a.get_size_is.to_s
+              ### p "exprs : ", exprs
+              remain = exprs
+              inner_to_export = {}
+			  ### exprs ã«å«ã¾ããè­å¥å­ãæãåºããå¯¾å¿ãã export ãããååãæ¢ã
+              while remain != "" && remain != nil
+                ### p "remain ", remain
+                remain =~ /([^\w]*)([_A-Za-z][\w\d]*)/   # å¤æ°åæå­åãåãåºã 
+				if $2 == nil then
+						break
+				end
+                arg_name = $2.to_sym
+                remain = $'
+                ### p exprs, $1, $2, $'
+                # size_is ã«å«ã¾ããå¤æ°ã¯ãcomposite ã§ export ããã¦ããã
+                cj2 = nil
+                @compositecelltypejoin_list.get_items.each{ |cj2t|
+                  if cj2t.get_cell_elem_name == arg_name then
+                    cj2 = cj2t
+                  end
+                }
+                if cj2 == nil then
+                  cdl_error( "S1171 \'$1\' size_is argument of \'$2\' not exported", a.get_name, cj.get_name )
+                  next
+                end
+                if cj2.get_port_decl.instance_of? Decl then
+                   decl2 = cj2.get_port_decl
+                   # å
+é¨ã®ååã¨å¤é¨ã®ååã®å¯¾å¿é¢ä¿ãè¨æ¶
+                   inner_to_export[arg_name] = decl2.get_name
+                # else cj2 ã¯ Port (æ¢ã«ã¨ã©ã¼)
+                end
+              end
+              # å
+é¨ã®ååãå¤é¨ã®ååã§ç½®æ
+              inner_to_export.each{ |arg_name, exp_name|
+                ### p "changing #{arg_name}=>#{exp_name}"
+                # exprs.gsub!( Regexp.new("#{arg_name}[^0-9A-Za-z_]"), exp_name.to_s )
+                exprs.gsub!( Regexp.new("#{arg_name}(\\W)"), exp_name.to_s+"\\1" )  # æå­åæ«å°¾ã«ãªãã±ã¼ã¹
+                exprs.gsub!( Regexp.new("#{arg_name}\\Z"), exp_name.to_s )          # æå­åæ«å°¾ã«ããã±ã¼ã¹
+              }
+              ### p "changed: #{exprs} #{cj_size_is.to_s}"
+              if exprs != cj_size_is.to_s then
+                cdl_error( "S1172 \'$1\' size_is argument mismatch with exporting one \'$2\'", a.get_name, cj.get_name )
+              end
+            # else cj ã¯ Port (æ¢ã«ã¨ã©ã¼)
+            end
+          end
+        end    
+      end
+
+      if b_init == false then
+          cdl_error( "S1052 attribute \'$1\' not initialized in cell \'$2\'" , a.get_name, @name )
+      end
+   
+    }
+  end
+
+  #=== Cell# é require ããã§ãã¯ãã
+  # é require æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯ãã
+  # composite ã®å
+é¨ã»ã« (f_cloned=true) ããã§ãã¯ãã
+  def check_reverse_require
+    # celltype ããªããã°ãã§ãã¯ããªãï¼æ¢ã«ã¨ã©ã¼ï¼
+    return if @celltype == nil
+    return if @b_defined == false
+
+    # p "check reverse require   #{@name}"
+    # érequire æå®ãããåãå£ã«è¤æ°ã®çµåããªãããã§ãã¯
+    @referenced_port_list.each{ |port,count|
+      # p port.class, count
+      # p port.get_name, port.get_port_type, port.get_signature.get_name
+      if port.is_reverse_required? && count > 1 then
+        cdl_warning( "W1009 $1: fixed join entry port has multi join", port.get_name )
+      end
+    }
+  end
+
+  #=== Cell# require å¼ã³å£ã®çµåãè¡ã
+  # STAGE: S
+  #cp_name:: Symbol           : å¼ã³å£å
+  #cell_or_t:: Celltype|Cell  : celltype ã® require ã®å³è¾ºã§æå®ãããã»ã«ã¿ã¤ãã¾ãã¯ã»ã«
+  #port::  Port               : celltype ã® Port ãªãã¸ã§ã¯ã
+  def set_require_join( cp_name, cell_or_ct, port )
+
+    # set_require_join ã¯2åº¦å¼ã³åºããã
+    # 2åº¦ç®ã¯ post ã³ã¼ããçæããå¾       #####  ãã£ããè¦åããï¼éè¤ã¨ã©ã¼ãè¦éãï¼
+    # if @require_joined_list[ cp_name ] then
+    #   return
+    # else
+    #   @require_joined_list[ cp_name ] = true
+    # end
+
+    dbgPrint "set_require_join: #{@name}.#{cp_name} = #{cell_or_ct.get_name}.#{port.get_name}\n"
+
+    if cell_or_ct.instance_of? Celltype then
+      # print "DOMAIN: not considered\n"
+      cell = cell_or_ct.get_singleton_cell @region
+      if cell == nil then
+        cdl_error( "S1025 not found reachable cell for require \'$1\' in celltype \'$2\'" , port.get_name, cell_or_ct.get_name )
+        return
+      end
+    else
+      # require: cell ã§æå®
+      cell = cell_or_ct
+      if @region.distance( cell.get_region ) == nil then
+        cdl_error( "S1026 required cell \'$1\' not reachable" , cell.get_name )
+      end
+    end
+
+    if @join_list.get_item( cp_name ) then
+      cdl_warning( "W1003 $1 : require call port overridden in $2" , cp_name, @name )
+    else
+      # require ã® join ãçæ(å¼ã³å£ã®çµå)
+#      rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, Token.new( cell.get_name, nil, nil, nil ) ],
+      nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace )
+      nsp.set_locale @locale
+      rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, nsp ],
+                              Token.new( port.get_name, nil, nil, nil ) ], @locale )   #1
+      join = Join.new( cp_name, nil, rhs, @locale )
+      self.new_join( join )
+
+      join.set_definition( @celltype.find(join.get_name) )
+    end
+  end
+
+  #=== Cell# Join ã® definition ã®è¨­å®ã¨ãã§ãã¯
+  # STAGE: S
+  def set_definition_join
+    return if @celltype == nil    # æ¢ã«ã¨ã©ã¼ï¼æã¡åã
+    return if @b_defined == false # ãã­ãã¿ã¤ãå®£è¨ã®ã¿
+    return if @b_checked == true  # æ¢ã«è¨­å®ï¼ãã§ãã¯ï¼æ¸ã¿
+
+    dbgPrint "set_definition_join in #{@name}\n"
+
+    # relay allocator ããã©ã£ã¦åå
+¥ããªããããå
+é ­ã§ @b_checked ã true ã«ãã
+    @b_checked = true
+
+    if ! @f_cloned then
+      check_restrict_list
+      
+      # compoiste ã»ã«ã®ã¯ã­ã¼ã³ããããã®ã¯ãset_definition ä¸è¦
+      # å
+ã® join ã¯æ¢ã« definition ããã¦ãã
+      # å
+ã®ã»ã«ã«ããã¦ãä»£å
+¥ãã§ãã¯ããã¦ããã®ã§ãäºéã«ãã§ãã¯(throughé©ç¨)ããã¦ãã¾ã
+      @join_list.get_items.each{ |join|
+        dbgPrint " set_definition_join: checking #{@name}.#{join.get_name}\n"
+        if join.get_array_member then
+          port = @celltype.find(join.get_name)
+          join.get_array_member2.each { |am|
+            if am == nil then   # æªçµåã®å ´åãã¨ã©ã¼ãã§ãã¯ã¯ check_join
+              if port && ! port.is_optional? then
+                # ãã¹ãç¨ã«ã¨ã©ã¼ã¡ãã»ã¼ã¸åºå
+                # cdl_error( "TEMPORAL set_definition_join: uninitialized array member"  )
+              end
+              next
+            end
+            am.set_definition( port )
+          }
+        else
+          join.set_definition( @celltype.find(join.get_name) )
+        end
+      }
+    end
+
+    # ãªã¬ã¼ join ã¯ through ãã©ã°ã¤ã³çæå¾ã«ããã§ããªã
+    # through å¾ã«çµåå
+ãå
+¥ãæ¿ãããã 
+    create_relay_allocator_join
+
+    # composite ã»ã«ã®å±é
+    if ! @in_composite && ! @f_cloned && @celltype.instance_of?( CompositeCelltype ) then
+      # composite ã»ã«ã¿ã¤ãå
+ã® composite ã¯å±éããªã
+      # compoiste ã»ã«å±éä¸­ã® composite ã¯å±éããªã (CompositeCelltype::expand å
+ã§åå¸°çã« expnad)
+      expand
+    end
+
+    # celltype ã« generate ãæå®ããããã¦ããã
+    celltype_plugin = @celltype.get_celltype_plugin
+    if celltype_plugin then
+      begin
+        celltype_plugin.new_cell self
+      rescue Exception => evar
+        cdl_error( "S1037 $1: celltype plugin fail to new_cell" , celltype_plugin.class.name )
+        print_exception( evar )
+      end
+    end
+  end
+
+  #=== Cell# composite ã»ã«ã®å±é
+  # ãã®ã»ã«ã composite ã»ã«ã¿ã¤ã
+  def expand
+
+    #debug
+    dbgPrint "expanding #{@name} #{@celltype.get_name}\n"
+
+    # å±éãããã»ã«ã®ãªã¹ã
+    @@cloned_cell_list = {}
+
+    # composite celltype ã® cell ãå±é
+    @cell_list, @cell_list2 = @celltype.expand( @name, @global_name, @NamespacePath, @join_list, @region, @plugin, @locale )
+
+    # ãã­ãã¿ã¤ããåç
+§ããã¦ããå ´åãå­ãåç
+§ããã¦ãããã¨ã«ãã
+    if @f_ref then
+      dbgPrint "expand: set_f_ref\n"
+      set_f_ref
+    end
+
+    # å¼ã³å£ã®å³è¾ºã®ã»ã«ã clone ãããã®ã«å¤æ´
+    self.change_rhs_port
+
+    # ãã­ãã¿ã¤ãå®£è¨ã§è¨­å®ããã¦ãããã®ãåæ ãã
+    @entry_array_max_subscript.each{ |port,name|
+      set_entry_inner_port_max_subscript( port, name )
+    }
+  end
+
+  #=== Cell#restrict ãè¿½å 
+  def add_restrict( entry_name, func_name, region_name_list )
+    if @restrict_list[ entry_name ] then
+      if @restrict_list[ entry_name ][ func_name ] then
+        @restrict_list[ entry_name ][ func_name ].each{ |rn|
+          if region_name_list.include? rn then
+            # p func_name
+            name = func_name ? entry_name : entry_name+"."+func_name
+            cdl_warning( "W9999 $1 restrict region duplicate $2", name, rn )
+          end
+        }
+      else
+        @restrict_list[ entry_name ][ func_name ] = region_name_list
+      end
+    else
+      func_list = { }
+      func_list[ func_name ] = region_name_list
+      @restrict_list[ entry_name ] = func_list
+    end
+    # pp @restrict_list
+  end
+
+  #=== Cell#check_restrict_list
+  def check_restrict_list
+    @restrict_list.each{ |entry_name, func_hash|
+      func_hash.each{ |func_name, region_list|
+        region_list.each{ |rn|
+          obj = Namespace.find [ rn ]
+          if ( obj.kind_of? Region ) then
+            if obj.get_domain_root != @region.get_domain_root then
+            else
+              cdl_warning( "W9999 $1 in same domain", rn )
+            end
+          else
+            cdl_error( "S9999 $1 not region", region )
+          end
+        }
+      }
+    }
+  end
+
+  #=== Cell#callable?
+  def callable?( callee_cell, entry_name, func_name )
+    res = callee_cell.callable_from?( entry_name, func_name, self )
+    dbgPrint "callable? #{callee_cell.get_namespace_path}.#{entry_name}.#{func_name} from #{@NamespacePath} is #{res}\n"
+    return res
+  end
+
+  #=== Cell#callable_from? (private)
+  def callable_from?( entry_name, func_name, caller_cell )
+    if @restrict_list.length == 0 then
+      return true
+    end
+
+    if @restrict_list[entry_name] then
+      if @restrict_list[entry_name][nil] &&
+         @restrict_list[entry_name][nil].include?( caller_cell.get_region.get_domain_root.get_name )then
+        return true
+      end
+      if @restrict_list[entry_name][func_name] &&
+         @restrict_list[entry_name][func_name].include?( caller_cell.get_region.get_domain_root.get_name )then
+        return true
+      else
+        return false
+      end
+    else
+      return true
+    end
+  end
+  
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Cell: name: #{@name} in_composite: #{@in_composite} def: #{@b_defined} ref: #{@f_ref} cloned: #{@f_cloned}"
+    (indent+1).times { print "  " }
+    puts "Cell locale: #{@name}@#{@locale[0]}##{@locale[1]}"
+    (indent+1).times { print "  " }
+    puts "id: #{@id}  global_name: #{@global_name}  region: #{@region.get_name} plugin: #{@plugin.class.name} #{self}"
+    (indent+1).times { print "  " }
+    puts "namespace_path: #{@NamespacePath}"
+
+    if @celltype then
+      (indent+1).times { print "  " }
+      puts "celltype: #{@celltype.get_name}"
+    end
+    @join_list.show_tree( indent + 1 )
+    @entry_array_max_subscript.each{ |port, num|
+      (indent+1).times { print "  " }
+      puts "entry array #{port.get_name}: max subscript=#{num}"
+    }
+    if @cell_list then   # ããã§ @cell_list ã nil ãªã®ã¯ Bug
+      (indent+1).times { print "  " }
+      puts "cloned cell list:"
+      @cell_list.each { |n,c|
+        (indent+2).times { print "  " }
+        puts "inner cell : #{n} = #{c.get_name}"
+      }
+    end
+    if @compositecelltypejoin_list then
+      @compositecelltypejoin_list.get_items.each{ |cj|
+        cj.show_tree( indent+1 )
+      }
+    end
+    if @alloc_list.length > 0 then
+      (indent+1).times { print "  " }
+      puts "allocator list: "
+      @alloc_list.each { |a|
+        cp_name = :"#{a[0+1]}_#{a[2+1]}_#{a[3+1]}"
+        if a[1+1] then
+          # subscript = "[#{a[1+1].eval_const nil}]"
+          subscript = "[#{a[1+1]}]"
+        else
+          subscript = ""
+        end
+        # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®çµåãçæ
+        (indent+2).times { print "  " }
+        puts "#{cp_name}#{subscript} = #{a[4+1]}"
+      }
+    end
+    @referenced_port_list.each{ |port,count|
+      (indent+1).times { print "  " }
+      puts( "#{port.get_name} : #{count} times referenced" )
+    }
+  end
+
+end
+
+class CompositeCelltype < NSBDNode # < Nestable
+# @name:: str
+# @global_name:: str
+# @cell_list:: NamedList   Cell
+# @export_name_list:: NamedList : CompositeCelltypeJoin
+# @port_list:: CompositeCelltypeJoin[]
+# @attr_list:: CompositeCelltypeJoin[]
+# @b_singleton:: bool : 'singleton' specified
+# @b_active:: bool : 'active' specified
+# @real_singleton:: bool : has singleton cell in this composite celltype
+# @real_active:: bool : has active cell in this composite celltype
+# @name_list:: NamedList item: Decl (attribute), Port ã¨ã¯ã¹ãã¼ãå®ç¾©
+# @internal_allocator_list:: [ [cell, internal_cp_name, port_name, func_name, param_name, ext_alloc_ent], ... ]
+
+  @@nest_stack_index = -1
+  @@nest_stack = []
+  @@current_object = nil
+
+  def self.push
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = @@current_object
+    @@current_object = nil
+  end
+
+  def self.pop
+    @@current_object = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+  def initialize( name )
+    super()
+    @name = name
+    @cell_list = NamedList.new( nil, "in composite celltype #{name}" )
+    @export_name_list = NamedList.new( nil, "export in composite celltype #{name}" )
+    @name_list = NamedList.new( nil, "in composite celltype #{name}" )
+    @@current_object = self
+
+    @b_singleton = false
+    @real_singleton = nil
+    @b_active = false
+    @real_active = nil
+    if "#{Namespace.get_global_name}" == "" then
+      @global_name = @name
+    else
+      @global_name = :"#{Namespace.get_global_name}_#{@name}"
+    end
+
+    Namespace.new_compositecelltype( self )
+    set_namespace_path # @NamespacePath ã®è¨­å®
+
+    @port_list = []
+    @attr_list = []
+    @internal_allocator_list = []
+    set_specifier_list( Generator.get_statement_specifier )
+  end
+
+  def self.end_of_parse
+    @@current_object.end_of_parse
+    @@current_object = nil
+  end
+
+  # CompositeCelltype#end_of_parse
+  def end_of_parse
+
+    # singleton ã«é¢ãããã§ãã¯
+    if @b_singleton && @real_singleton == nil then
+      cdl_warning( "W1004 $1 : specified singleton but has no singleton in this celltype" , @name )
+    elsif ! @b_singleton && @real_singleton != nil then
+      if ! @b_singleton then
+        cdl_error( "S1053 $1 must be singleton. inner cell \'$2\' is singleton" , @name, @real_singleton.get_name )
+      end
+    end
+
+    # active ã«é¢ãããã§ãã¯
+    if @b_active && @real_active == nil then
+      cdl_error( "S1054 $1 : specified active but has no active in this celltype" , @name )
+    elsif ! @b_active && @real_active != nil then
+      cdl_error( "S1055 $1 must be active. inner cell \'$2\' is active" , @name, @real_active.get_name )
+    end
+
+    # @allocator_instance ãè¨­å®ãã
+    @name_list.get_items.each{ |n|
+      if n.instance_of? Port then
+        n.set_allocator_instance
+      end
+    }
+
+    # ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã® entry å´
+    @port_list.each{ |p|
+      if p.get_port_type == :ENTRY then
+        if p.get_allocator_instance == nil then
+          next
+        end
+
+        p.get_allocator_instance.each{ |name,ai|
+          if ai[0] == :RELAY_ALLOC then
+            self.new_join( :"#{p.get_name}_#{ai[4]}_#{ai[5]}", p.get_cell_name, :"#{p.get_cell_elem_name}_#{ai[4]}_#{ai[5]}", :CALL )
+          end
+        }
+      end
+    }
+    # mikan relay ãæ­£ããæãã¦ããããã§ãã¯ããã¦ããªã
+
+    # æå³è§£æ
+    @cell_list.get_items.each{ |c|
+      c.set_definition_join
+    }
+
+    # cell ã®æªçµåã®å¼ã³å£ããªãããã§ãã¯
+    @cell_list.get_items.each{ |c|
+      c.check_join
+      c.check_reverse_require
+    }
+
+    # å¼ã³å£ã®çµåã«ã¤ãã¦ãexport ã¨å
+é¨çµåã®ä¸¡æ¹ããªãããã§ãã¯
+    # ãªã¬ã¼ã¢ã­ã±ã¼ã¿ãå
+é¨ã¢ã­ã±ã¼ã¿ã®è¨­å®
+    @port_list.each{ |p|
+      p.check_dup_init
+    }
+
+    # ãã¹ã¦ã®ã¨ã¯ã¹ãã¼ãå®ç¾©ã«å¯¾å¿ããå¼ã³å£ãåãå£ãå±æ§ãå­å¨ããããã§ãã¯
+    @name_list.get_items.each{ |n|
+      if( @export_name_list.get_item( n.get_name ) == nil )then
+        cdl_error( "S1056 $1 : cannot export, nothing designated" , n.get_name )
+      end
+    }
+
+    # å
+é¨ã¢ã­ã±ã¼ã¿ãè¨­å®ãã
+    @internal_allocator_list.each{ |cell, cp_internal_name, port_name, fd_name, par_name, ext_alloc_ent|
+      res = ext_alloc_ent.get_allocator_rhs_elements( :INTERNAL_ALLOC )
+      ep_name = res[0]
+      cj = @export_name_list.get_item( ep_name )
+      internal_alloc_name_from_port_def = cj.get_cell_name
+      internal_alloc_ep_name_from_port_def = cj.get_cell_elem_name
+
+      # puts "internal_allocator #{cell.get_name} #{cp_internal_name} #{port_name}.#{fd_name}.#{par_name}"
+      cell.get_allocator_list.each{ |a|
+        # puts "allocator_list of #{cell.get_name} #{a[0]} #{a[1]}.#{a[2]}.#{a[3]}.#{a[4]} #{a[5].to_s}"
+        if cp_internal_name == :"#{a[1]}_#{a[3]}_#{a[4]}" then
+          dbgPrint "internal_allocator {cp_internal_name} #{a[1]}_#{a[3]}_#{a[4]}\n"
+          dbgPrint "internal_allocator: #{a[5]}, #{internal_alloc_name_from_port_def}.#{internal_alloc_ep_name_from_port_def}\n"
+          if a[5].to_s != "#{internal_alloc_name_from_port_def}.#{internal_alloc_ep_name_from_port_def}" then
+            cdl_error( "S1173 $1: allocator mismatch from $2's allocator", "#{port_name}.#{fd_name}.#{par_name}", cell.get_name  )
+          end
+        end
+      }
+    }
+  end
+
+ ### cell (CompositeCelltype)
+  def self.new_cell( cell )
+    @@current_object.new_cell( cell )
+
+  end
+
+  def new_cell( cell )
+    cell.set_owner self  # Cell (in_omposite)
+    @cell_list.add_item( cell )
+    if cell.get_celltype then    # nil ãªãã°ããã§ã«ã»ã«ã¿ã¤ããªãã¨ã©ã¼
+      if cell.get_celltype.is_singleton? then
+        @real_singleton = cell
+      end
+      if cell.get_celltype.is_active? then
+        @real_active = cell
+      end
+    end
+  end
+
+ ### join
+  def self.new_join( export_name, internal_cell_name,
+			 internal_cell_elem_name, type )
+    @@current_object.new_join( export_name, internal_cell_name,
+					 internal_cell_elem_name, type )
+    
+  end
+
+  #=== CompositeCelltype# CompositeCelltypeJoin ãä½æ
+  # STAGE: B
+  #export_name:: Symbol : å¤é¨ã«å
+¬éããåå
+  #internal_cell_name:: Symbol : å
+é¨ã»ã«å
+  #internal_cell_elem_name:: Symbol : å
+é¨ã»ã«ã®è¦ç´ åï¼å¼ã³å£åãåãå£åãå±æ§åã®ããããï¼
+  #type::  :CALL, :ENTRY, :ATTRIBUTE ã®ããããï¼æ§æè¦ç´ ã¨ãã¦ããã¹ããã®ï¼
+  #RETURN:: Decl | Port : ã¨ã¯ã¹ãã¼ãå®ç¾©
+  # new_join ã¯
+  #   cCall => composite.cCall;     (ã»ã«å
+)
+  #   attr = composite.attr;        (ã»ã«å
+)
+  #   composite.eEnt => cell2.eEnt; (ã»ã«å¤)
+  # ã®æ§æè¦ç´ ã®åºç¾ã«å¯¾ãã¦å¼ã³åºããã
+  def new_join( export_name, internal_cell_name,
+		 internal_cell_elem_name, type )
+
+    dbgPrint "new_join: #{export_name} #{internal_cell_name} #{internal_cell_elem_name}\n"
+
+    cell = @cell_list.get_item( internal_cell_name )
+    if cell == nil then
+      cdl_error( "S1057 $1 not found in $2" , internal_cell_name, @name )
+      return
+    end
+
+    celltype = cell.get_celltype
+    return if celltype == nil	# celltype == nil ãªããã§ã«ã¨ã©ã¼
+
+    # å
+é¨ã»ã«ã®ã»ã«ã¿ã¤ãããå¯¾å¿è¦ç´ ãæ¢ã
+    # ãã®ã¡ã½ããã¯ãæ§æä¸ãå¼ã³å£ãåãå£ãå±æ§ãè¨è¿°ã§ããç®æããå¼åºããã
+    # æ§æä¸ã®å¼åºãä½ç½®ï¼è¨è¿°ä½ç½®ï¼ã¨ãè¦ç´ ãå¯¾å¿ãããã®ããã§ãã¯
+    obj = celltype.find( internal_cell_elem_name )
+    if obj.instance_of?( Decl ) then
+      if obj.get_kind == :VAR then
+        cdl_error( "S1058 \'$1\' : cannot export var" , internal_cell_elem_name )
+        return
+      elsif type != :ATTRIBUTE then
+        cdl_error( "S1059 \'$1\' : exporting attribute. write in cell or use \'=\' to export attribute" , export_name )
+        # return æ¬¡ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã
+      end
+    elsif obj.instance_of?( Port ) then
+      if obj.get_port_type != type then
+        cdl_error( "S1060 \'$1\' : port type mismatch. $2 type is allowed here." , export_name, type )
+        # return æ¬¡ã®ã¨ã©ã¼ãé¿ããããã«å¦çç¶è¡ããä»ãå ãã¦ã¿ã
+      end
+    else
+      cdl_error( "S1061 \'$1\' : not defined" , internal_cell_elem_name )
+      dbgPrint "S1061 CompositeCelltypeJoin#new_join: #{export_name} => #{internal_cell_name}.#{internal_cell_elem_name} #{type}\n"
+      return
+    end
+
+    # ã¨ã¯ã¹ãã¼ãå®ç¾©ã¨ä¸è´ãããã©ãããã§ãã¯
+    obj2 = @name_list.get_item( export_name )
+    if( obj2 == nil )then
+      cdl_error( "S1062 $1 has no export definition" , export_name )
+    elsif obj2.instance_of?( Decl ) then
+      if( ! obj.instance_of? Decl )then
+        cdl_error( "S1063 $1 is port but previously defined as an attribute" , export_name )
+      elsif ! obj.get_type.equal? obj2.get_type then
+        cdl_error( "S1064 $1 : type \'$2$3\' mismatch with pprevious definition\'$4$5\'" , export_name, obj.get_type.get_type_str, obj.get_type.get_type_str_post, obj2.get_type.get_type_str, obj2.get_type.get_type_str_post )
+      end
+    elsif obj2.instance_of?( Port ) then
+      if( obj.instance_of? Port )then
+        if( obj.get_port_type != obj2.get_port_type )then
+          cdl_error( "S1065 $1 : port type $2 mismatch with previous definition $3" , export_name, obj.get_port_type, obj2.get_port_type )
+        elsif obj.get_signature != obj2.get_signature then
+          if obj.get_signature != nil && obj2.get_signature != nil then
+            # nil ãªãã°æ¢ã«ã¨ã©ã¼ãªã®ã§å ±åããªã
+            cdl_error( "S1066 $1 : signature \'$2\' mismatch with previous definition \'$3\'" , export_name, obj.get_signature.get_name, obj2.get_signature.get_name )
+          end
+        elsif obj.get_array_size != obj2.get_array_size then
+          cdl_error( "S1067 $1 : array size mismatch with previous definition" , export_name )
+        elsif obj.is_optional? != obj2.is_optional? then
+          cdl_error( "S1068 $1 : optional specifier mismatch with previous definition" , export_name )
+        elsif obj.is_omit? != obj2.is_omit? then
+          cdl_error( "S9999 $1 : omit specifier mismatch with previous definition" , export_name )
+        end
+      else
+        cdl_error( "S1069 $1 is an attribute but previously defined as a port" , export_name )
+      end
+    end
+
+    join = CompositeCelltypeJoin.new( export_name, internal_cell_name,
+				 internal_cell_elem_name, cell, obj2 )
+    join.set_owner self   # CompositeCelltypeJoin
+    cell.add_compositecelltypejoin join
+
+    # debug
+    dbgPrint "compositecelltype join: add #{cell.get_name} #{export_name} = #{internal_cell_name}.#{internal_cell_elem_name}\n"
+
+    if obj.instance_of?( Decl ) then
+      # attribute
+#      # å
+é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ãã¯
+#      found = false
+#      @attr_list.each{ |a|
+#        if a.get_name == join.get_name then
+#          found = true
+#          break
+#        end
+#      }
+#      if found == false then
+        @attr_list << join
+#      end
+    else
+      # call/entry port
+#      # å
+é¨ããå¤é¨ã¸è¤æ°ã®çµåããªãããã§ãã¯
+#      found = false
+#      @port_list.each{ |port|
+#        if port.get_name == join.get_name then
+#          found = true
+#          break
+#        end
+#      }
+#      if found == false then
+        @port_list << join
+#      end
+    end
+
+    # join ã @export_name_list ã«ç»é²ï¼éè¤ãã§ãã¯ã¨ã¨ãã«ï¼å¾ã§è¡ããã CompositeCelltypeJoin ã® clone ã«åããï¼
+    if obj.instance_of?( Decl ) && @export_name_list.get_item( export_name ) then
+      # æ¢ã«å­å¨ãããè¿½å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã
+    elsif obj.instance_of?( Port ) && obj.get_port_type == :CALL && @export_name_list.get_item( export_name ) then
+      # æ¢ã«å­å¨ãããè¿½å ããªããæ°ä»æ§ã§ã¯ã@export_name_list ã«åãååãå«ã¾ãããã¨ãããã
+    else
+      @export_name_list.add_item( join )
+    end
+
+    # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ã­ã±ã¼ã¿(allocator)å¼ã³å£ãã»ã«ã¨çµå
+    if obj2.instance_of? Port then
+      obj2.each_param{ |port, fd, par|
+        case par.get_direction                        # å¼æ°ã®æ¹åæå®å­ (in, out, inout, send, receive )
+        when :SEND, :RECEIVE
+          cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}"     # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®åå
+          #            ãã¼ãå         é¢æ°å         ãã©ã¡ã¼ã¿å
+          cp_internal_name = :"#{internal_cell_elem_name}_#{fd.get_name}_#{par.get_name}"
+
+          # ãªã¬ã¼ã¢ã­ã±ã¼ã¿ or å
+é¨ã¢ã­ã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ã­ã±ã¼ã¿å¼ã³å£ãè¿½å ããªã
+          # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã
+          if port.get_allocator_instance_tmp then
+            found = false
+            port.get_allocator_instance_tmp.each { |s|
+              if s[1] == fd.get_name && s[2] == par.get_name then
+                found = true
+
+                if s[0] == :INTERNAL_ALLOC then
+                  # å
+é¨ã¢ã­ã±ã¼ã¿ã®å ´å    # mikan ããã¯å
+é¨ã®ã»ã«ã«ç´çµãããå¤é¨ã®ãã¼ãã«æ¹ããã¹ã
+                  @internal_allocator_list << [ cell, cp_internal_name, port.get_name, fd.get_name, par.get_name, s[3] ]
+                end
+              end
+            }
+            if found == true
+              next
+            end
+          end
+
+          # å¤é¨ã¢ã­ã±ã¼ã¿ã®å ´å
+          new_join( cp_name, internal_cell_name, cp_internal_name, :CALL )
+        end
+      }
+    end
+
+    # ã¨ã¯ã¹ãã¼ãå®ç¾©ãè¿ã
+    return obj2
+  end
+
+  def self.has_attribute? attr
+    @@current_object.has_attribute? attr
+  end
+
+  def has_attribute? attr
+    @name_list.get_item( attr ) != nil
+  end
+
+  def self.new_port port
+    @@current_object.new_port port
+  end
+
+  #=== CompositeCelltype# new_port
+  def new_port port
+    port.set_owner self   # Port (CompositeCelltype)
+    dbgPrint "new_port: #{@owner.get_name}.#{port.get_name}\n"
+    @name_list.add_item port
+
+    # export ãããã¼ãã«å«ã¾ãã send/receive ãã©ã¡ã¼ã¿ã®ã¢ã­ã±ã¼ã¿å¼ã³å£ã® export ãçæãã¦ãã¼ãã«è¿½å 
+    # ãã®æç¹ã§ã¯å
+é¨ã¢ã­ã±ã¼ã¿ãã©ããå¤æ­ã§ããªãã®ã§ãã¨ããããçæãã¦ãã
+    port.each_param { |port, fd, par|
+      case par.get_direction                        # å¼æ°ã®æ¹åæå®å­ (in, out, inout, send, receive )
+      when :SEND, :RECEIVE
+        #### ãªã¬ã¼ã¢ã­ã±ã¼ã¿ or å
+é¨ã¢ã­ã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ã­ã±ã¼ã¿å¼ã³å£ãè¿½å ããªã
+        # å
+é¨ã¢ã­ã±ã¼ã¿æå®ããªããã¦ããå ´åãã¢ã­ã±ã¼ã¿å¼ã³å£ãè¿½å ããªã
+        # ãã®æç¹ã§ã¯ get_allocator_instance ã§ã¯å¾ãããªããã tmp ãå¾ã
+        if port.get_allocator_instance_tmp then
+          found = false
+          port.get_allocator_instance_tmp.each { |s|
+            if s[0] == :INTERNAL_ALLOC && s[1] == fd.get_name && s[2] == par.get_name then
+              found = true
+              break
+            end
+          }
+          if found == true
+            next
+          end
+        end
+
+        if par.get_allocator then
+          cp_name = :"#{port.get_name}_#{fd.get_name}_#{par.get_name}"     # ã¢ã­ã±ã¼ã¿å¼ã³å£ã®åå
+          #           ãã¼ãå          é¢æ°å         ãã©ã¡ã¼ã¿å
+          alloc_sig_path = [ par.get_allocator.get_name ]  # mikan Namespace ã¢ã­ã±ã¼ã¿å¼ã³å£ã®ã·ã°ããã£
+          array_size = port.get_array_size            # å¼ã³å£ã¾ãã¯åãå£é
+åã®ãµã¤ãº
+          created_port = Port.new( cp_name, alloc_sig_path, :CALL, array_size ) # å¼ã³å£ãçæ
+          created_port.set_allocator_port( port, fd, par )
+          if port.is_omit? then
+            created_port.set_omit
+          end
+          new_port( created_port )           # ã»ã«ã¿ã¤ãã«æ°ããå¼ã³å£ãè¿½å 
+        # else
+        #   already error
+        end
+      end
+    }
+  end
+
+  def self.new_attribute attr
+    @@current_object.new_attribute attr
+  end
+
+  #=== CompositeCelltype# new_attribute for CompositeCelltype
+  #attribute:: [Decl]
+  def new_attribute( attribute )
+    attribute.each { |a|
+      a.set_owner self   # Decl (CompositeCelltype)
+      # V1.1.0.10 composite ã® attr ã® size_is ã¯å¯ã¨ãªã£ã
+      # if a.get_size_is then
+      #  cdl_error( "S1070 $1: size_is pointer cannot be exposed for composite attribute" , a.get_name )
+      # end
+      @name_list.add_item( a )
+      if a.get_initializer then
+        a.get_type.check_init( @locale, a.get_identifier, a.get_initializer, :ATTRIBUTE )
+      end
+    }
+  end
+
+  #=== CompositeCelltype# érequire ã®çµåãçæãã
+  def create_reverse_require_join cell
+    @name_list.get_items.each{ |n|
+      if n.instance_of? Port then
+        n.create_reverse_require_join cell
+      end
+    }
+  end
+
+  # false : if not in celltype definition, nil : if not found in celltype
+  def self.find( name )
+    if @@current_object == nil then
+      return false
+    end
+    @@current_object.find name
+  end
+
+  def find name
+    dbgPrint "CompositeCelltype: find in composite: #{name}\n"
+    cell = @cell_list.get_item( name )
+    return cell if cell
+
+    dbgPrint "CompositeCelltype: #{name}, #{@name_list.get_item( name )}\n"
+    return @name_list.get_item( name )
+
+    # å¾æ¥ä»æ§
+#    cj = @export_name_list.get_item( name )
+#p "#{name}, #{cj.get_port_decl}"
+#    if cj then
+#      return cj.get_port_decl
+#    else
+#      return nil
+#    end
+  end
+
+  #=== CompositeCelltype# export ãã CompositeCelltypeJoin ãå¾ã
+  #name:: string:
+  # attribute ã®å ´åãåãååã«å¯¾ãè¤æ°å­å¨ããå¯è½æ§ãããããæåã®ãã®ããè¿ããªã
+  def find_export name
+    return @export_name_list.get_item( name )
+  end
+
+  #=== CompositeCelltype# composite celltype ã® cell ãå±é
+  #name:: string: Composite cell ã®åå
+  #global_name:: string: Composite cell ã® global name (C è¨èªå)
+  #join_list:: NamedList : Composite cell ã«å¯¾ãã Join ã® NamedList
+  #RETURN:
+  # [ { name => cell }, [ cell, ... ] ]
+  #  æ»ãå¤ åã¯ ååâcloneãããå
+é¨ã»ã«ãå¾ãã¯ composite ã®åºç¾é ã®ãªã¹ã
+  def expand( name, global_name, namespacePath, join_list, region, plugin, locale )
+
+    # debug
+    dbgPrint "expand composite: #{@name} name: #{name}  global_name: #{global_name}\njoin_list:\n"
+    join_list.get_items.each{ |j|
+      dbgPrint "   #{j.get_name} #{j}\n"
+    }
+  
+    # å±éã§ clone ãããã»ã«ã®ãªã¹ããå³è¾ºã¯ Cell (composite ã®å ´å composite ãª cell ã® clone)
+    clone_cell_list = {}
+    clone_cell_list2 = []
+
+    #  composite å
+é¨ã®ãã¹ã¦ã® cell ã«ã¤ãã¦
+    @cell_list.get_items.each { |c|
+
+      # debug
+      dbgPrint "expand : cell #{c.get_name}\n"
+
+      # Join ã®é
+å
+      ja = []
+
+      # CompositeCelltype ã export ããå¼ã³å£ãåãå£ãå±æ§ã®ãªã¹ãã«ã¤ãã¦
+      # @export_name_list.get_items.each{ |cj|	# cj: CompositeCelltypeJoin
+      # æ°ä»æ§ã§ã¯ã@export_name_list ã«å
+¥ã£ã¦ããªã attr ããããã
+      (@port_list+@attr_list).each{ |cj|	# cj: CompositeCelltypeJoin
+
+        # debug
+        dbgPrint "        cj : #{cj.get_name}\n"
+
+        # CompositeCelltypeJoin (export) ã®å¯¾è±¡ã»ã«ãï¼
+        if cj.match?( c ) then
+
+          # å¯¾è±¡ã»ã«å
+ã® CompositeCelltype ã® export ãã Join (attribute ã¾ãã¯ call port)
+          j = join_list.get_item( cj.get_name )
+
+          # debug
+          if j then
+            dbgPrint "expand : parent cell: #{name} child cell: #{c.get_name}:  parent's export port: #{cj.get_name}  join: #{j.get_name} #{j}\n"
+          else
+            dbgPrint "expand : parent cell: #{name} child cell: #{c.get_name}:  parent's export port: #{cj.get_name}  join: nil\n"
+          end
+
+          if j then
+            # å¼ã³å£ãå±æ§ã®å ´å
+            #  ComositeCell ç¨ã®ãã®(j) ãå¯¾è±¡ã»ã«ç¨ã« clone (@through_list ãã³ãã¼ããã)
+            # p "expand: cloning Join #{j.get_name} #{@name} #{name}"
+            jc = j.clone_for_composite( @name, name, locale )
+                                        # celltype_name, cell_name
+
+            # debug
+            # p "cn #{jc.get_name} #{cj.get_cell_elem_name}"
+
+            # å¯¾è±¡ã»ã«ã®å¼ã³å£ã¾ãã¯å±æ§ã®ååã«å¤æ´
+            jc.change_name( cj.get_cell_elem_name )
+
+            # å¯¾è±¡ã»ã«ã«å¯¾ãã Join ã®é
+å
+            ja << jc
+          end
+
+          # debug
+          dbgPrint "\n"
+        end
+      }
+
+      # debug
+      dbgPrint "expand : clone #{name}_#{c.get_name}\n"
+
+      # ã»ã«ã® clone ãçæ
+#      clone_cell_list[ "#{name}_#{c.get_name}" ] =  c.clone_for_composite( name, global_name, ja )
+      c2 =  c.clone_for_composite( name, global_name, namespacePath, ja, @name, region, plugin, locale )
+      clone_cell_list[ "#{c.get_local_name}" ] = c2
+      clone_cell_list2 << c2
+
+    }
+
+    clone_cell_list.each { |nm,c|
+      dbgPrint "  cloned: #{nm} = #{c.get_global_name}\n"
+      # join ã® owner ã clone ãããã»ã«ã«å¤æ´ãã V1.1.0.25
+      c.get_join_list.get_items.each{ |j|
+        j.set_cloned( clone_cell_list[ "#{c.get_local_name}" ] )
+      }
+    }
+    return [ clone_cell_list, clone_cell_list2 ]
+  end
+
+  #=== CompositeCelltype æå®å­ãªã¹ãã®è¨­å®
+  def set_specifier_list( spec_list )
+    return if spec_list == nil
+
+    spec_list.each { |s|
+      case s[0]
+      when :SINGLETON
+        @b_singleton = true
+      when :IDX_IS_ID
+        cdl_warning( "W1005 $1 : idx_is_id is ineffective for composite celltype" , @name )
+      when :ACTIVE
+        @b_active = true
+      else
+        cdl_error( "S1071 $1 cannot be specified for composite" , s[0] )
+      end
+    }
+  end
+
+  def get_name
+    @name
+  end
+
+  def get_port_list
+    @port_list
+  end
+
+  def get_attribute_list
+    @attr_list
+  end
+
+  def get_var_list
+    []   # ç©ºã®é
+åãè¿ã
+  end
+
+  def get_internal_allocator_list
+    @internal_allocator_list
+  end
+
+  #== CompositeCelltype# generate æå®å­ã®æ
+å ±
+  # CompositeCelltype ã«ã¯ generate ãæå®ã§ããªãã®ã§ nil ãè¿ã
+  # Celltype::@generate ãåç
+§ã®ãã¨
+  def get_celltype_plugin
+    nil
+  end
+
+  def is_singleton?
+    @b_singleton
+  end
+
+  def is_active?
+    @b_active
+  end
+
+  #=== CompositeCelltype# ã¢ã¯ãã£ãã§ã¯ãªã
+  # active ã§ã¯ãªãã«å ããå
+¨ã¦ã®å
+é¨ã»ã«ã®ã»ã«ã¿ã¤ãã inactive ã®å ´åã« inactive
+  # ï¼å
+é¨ã®ã»ã«ã active ã¾ãã¯ factory ãæã£ã¦ããï¼
+  def is_inactive?
+    if @b_active == false then
+      @cell_list.get_items.each{ |c|
+        if c.get_celltype && c.get_celltype.is_inactive? == false then
+          # c.get_celltype == nil ã®å ´åã¯ã»ã«ã¿ã¤ãæªå®ç¾©ã§ãã§ã«ã¨ã©ã¼
+          return false
+        end
+      }
+      return true
+    else
+      return false
+    end
+  end
+
+  def get_id_base
+    raise "get_id_base"
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "CompositeCelltype: name: #{@name}"
+    (indent+1).times { print "  " }
+    puts "active: #{@b_active}, singleton: #{@b_singleton}"
+    @cell_list.show_tree( indent + 1 )
+    (indent+1).times { print "  " }
+    puts "name_list"
+    @name_list.show_tree( indent + 2 )
+    (indent+1).times { print "  " }
+    puts "export_name_list"
+    @export_name_list.show_tree( indent + 2 )
+    if @internal_allocator_list.length > 0 then
+      (indent+1).times { print "  " }
+      puts "internal_allocator_list:"
+      @internal_allocator_list.each{  |a|
+        (indent+1).times { print "  " }
+        puts "  #{a[0].get_name} #{a[1]} #{a[2]} #{a[3]} #{a[4]}"
+      }
+    end
+  end
+
+end
+
+
+
+#== æ§æè¦ç´ ï¼å£ãè¡¨ãã¯ã©ã¹ï¼ã»ã«ã¿ã¤ãã®å¼ã³å£ãåãå£ï¼
+class Port < BDNode
+# @name::  str
+# @signature:: Signature
+# @port_type::  :CALL, :ENTRY
+# @array_size:: nil: not array, "[]": sizeless, Integer: sized array
+# @reverse_require_cell_path:: NamespacePath :     érequireå¼ã³å
+ã»ã«  mikan namespace (å¼ã³å£ã®ã¿æå®å¯è½)
+# @reverse_require_callport_name:: Symbol:  érequireå¼ã³å
+ã»ã«ã®å¼ã³å£å
+#
+# set_allocator_port ã«ãã£ã¦è¨­å®ãããï¼è¨­å®ãããå ´åããã®ãã¼ãã¯ã¢ã­ã±ã¼ã¿ãã¼ãã§ããã
+# @allocator_port:: Port : ãã®å¼ã³å£ãã§ããå
+ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£
+# @allocator_func_decl:: Decl : ãã®å¼ã³å£ãã§ããå
+ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®é¢æ°
+# @allocator_param_decl:: ParamDecl : ãã®å¼ã³å£ãã§ããå
+ã¨ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®ãã©ã¡ã¼ã¿
+#
+# set_specifier ã«ãã£ã¦è¨­å®ããã(
+# @allocator_instance:: Hash : {"func_param" => [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ]}
+#                                               [:INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ]
+# @allocator_instance_tmp:: Hash : {"func_param" => [:INTERNAL_ALLOC|:RELAY_ALLOC,  IDENTIFIER, IDENTIFIER, expression ],..}
+#                                                                                    function    parameter   rhs
+#
+# @b_require:: bool : require ã«ããçæããã call port ã®å ´å true
+# @b_has_name:: bool : require : ååããã®ãªã¯ã¯ã¤ã¢å¼ã³å£
+# @b_inline:: bool : entry port ã®ã¿
+# @b_omit:: bool : omit æå®å­ãæå®ããã (call port ã®ã¿)
+# @b_optional:: bool : call port ã®ã¿
+# @b_ref_des:: bool :  ref_desc ã­ã¼ã¯ã¼ããæå®ããã
+# @b_dynamic:: bool :  dynamic ã­ã¼ã¯ã¼ããæå®ããã (å¼ã³å£ã®ã¿)
+#
+# optimize::
+# @celltype:: å±ããã»ã«ã¿ã¤ã
+#
+# :CALL ã®å ´åã®æé©å
+# @b_VMT_useless:: bool                     # VMT é¢æ°ãã¼ãã«ãä½¿ç¨ããªã
+# @b_skelton_useless:: bool                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+# @b_cell_unique:: bool                     # å¼ã³å
+ã¯å¯ä¸ã®ã»ã«
+# @only_callee_port:: Port                  # å¯ä¸ã®å¼ã³å
+ãã¼ã
+# @only_callee_cell:: Cell                  # å¯ä¸ã®å¼ã³å
+ã»ã« (@b_PEPDES_in_CB_useless = true ã®ææå¹)
+#
+# :ENTRY ã®å ´åã®æé©åï¼å¼ã³å£æé©åã¨åãå¤æ°åãä½¿ç¨ï¼
+# @b_VMT_useless:: bool                     # VMT é¢æ°ãã¼ãã«ãä¸è¦
+# @b_skelton_useless:: bool                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦
+
+  def initialize( name, sig_path, port_type, array_size = nil, reverse_require_cell_path = nil, reverse_require_entry_port_name = nil )
+    super()
+    @name = name
+    @port_type = port_type
+
+    if array_size == "[]" then
+#      if port_type == :ENTRY then
+#        cdl_error( "S1072 $1: entry port: sizeless array not supported in current version" , name )
+#      end
+      @array_size = array_size
+    elsif array_size then
+      if array_size.kind_of? Expression then
+        @array_size = array_size.eval_const(nil)
+      else
+        @array_size = array_size   # ããã¯ã¢ã­ã±ã¼ã¿å¼ã³å£ã®å ´åï¼å
+ã®å¼ã³å£ã§æ¢ã«è©ä¾¡æ¸ã¿ï¼
+      end
+      if @array_size == nil then
+        cdl_error( "S1073 Not constant expression $1" , array_size.to_s )
+      end
+
+      #if Integer( @array_size ) != @array_size || @array_size <= 0 then
+      if ! @array_size.kind_of? Integer then
+        cdl_error( "S1074 Not Integer $1" , array_size.to_s )
+      end
+
+    end
+
+    object = Namespace.find( sig_path )    #1
+    if object == nil then
+      # mikan signature ã®ååãä¸å®å
+¨
+      cdl_error( "S1075 \'$1\' signature not found" , sig_path )
+    elsif ! object.instance_of?( Signature ) then
+      # mikan signature ã®ååãä¸å®å
+¨
+      cdl_error( "S1076 \'$1\' not signature" , sig_path )
+    else
+      @signature = object
+
+    end
+
+    # érequire
+    @reverse_require_cell_path       = nil
+    @reverse_require_entry_port_name = nil
+    if reverse_require_cell_path then
+      if port_type == :CALL then
+        cdl_error( "S1152 $1 call port cannot have fixed join", @name )
+      else
+        @reverse_require_cell_path       = reverse_require_cell_path
+        @reverse_require_entry_port_name = reverse_require_entry_port_name
+
+        # åãå£é
+åãï¼
+        if array_size then
+          cdl_error( "S1153 $1: cannot be entry port array for fixed join port", @name )
+        end
+
+        # å¼ã³å£ã®ã»ã«ã¿ã¤ããæ¢ã
+        ct_or_cell = Namespace.find( @reverse_require_cell_path )  #1
+        if ct_or_cell.instance_of? Cell then
+          ct = ct_or_cell.get_celltype
+        elsif ct_or_cell.instance_of? Celltype then
+          ct = ct_or_cell
+          if ! ct.is_singleton? then
+            cdl_error( "S1154 $1: must be singleton celltype for fixed join", @reverse_require_cell_path.to_s )
+          end
+        else
+          ct = nil
+          cdl_error( "S1155 $1: not celltype or not found", @reverse_require_cell_path.get_path_str)
+        end
+
+        if ct == nil then
+          return    # æ¢ã«ã¨ã©ã¼
+        end
+
+        # æ·»ãå­ãªãã®å¼ã³å£é
+åãï¼
+        port = ct.find( @reverse_require_entry_port_name )
+        if port == nil || port.get_port_type != :CALL
+          cdl_error( "S1156 $1: not call port or not found", @reverse_require_entry_port_name )
+        else
+          if port.get_array_size != "[]" then
+            cdl_error( "S1157 $1: sized array or not array", @reverse_require_entry_port_name )
+          end
+        end
+
+      end
+    end
+
+    @b_require = false
+    @b_has_name = false
+    @b_inline = false
+    @b_optional = false
+    @b_ref_desc = false
+    @b_dynamic = false
+    reset_optimize
+  end
+
+  #=== Port#æé©åã«é¢ããå¤æ°ããªã»ãããã
+  # Region ãã¨ã«æé©åã®ãããªãããããããããªã»ãããã
+  def reset_optimize
+    if @port_type == :CALL then
+      # call port optimize
+      @b_VMT_useless = false                     # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)
+      @b_skelton_useless = false                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+      @b_cell_unique = false                     # å¯ä¸ã®å¼ã³å
+ã»ã«
+      @only_callee_port = nil                    # å¯ä¸ã®å¼ã³å
+ãã¼ã
+      @only_callee_cell = nil                    # å¯ä¸ã®å¼ã³å
+ã»ã«
+    else
+      # entry port optimize
+      if $unopt then
+        # æé©åãªã
+        @b_VMT_useless = false                     # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)
+        @b_skelton_useless = false                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+      else
+        # æé©åãã
+        @b_VMT_useless = true                      # VMT ä¸è¦ (true ã®æ VMT ãä»ãããã¨ãªãå¼åºã)
+        @b_skelton_useless = true                  # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+      end
+    end
+end
+
+  def set_celltype celltype
+    @celltype = celltype
+  end
+
+  def get_name
+    @name
+  end
+
+  def get_port_type
+    @port_type
+  end
+
+  def get_signature
+    @signature
+  end
+
+  def get_array_size
+    @array_size
+  end
+
+  def get_celltype
+    @celltype
+  end
+
+  #=== Port# ã¢ã­ã±ã¼ã¿ãã¼ãã®è¨­å®
+  #port:: Port : send/receive ã®ãã£ãå¼ã³å£ã¾ãã¯åãå£
+  #fd:: Decl : é¢æ°ã® declarator
+  #par:: ParamDecl : send/receive ã®ãã£ãå¼æ°
+  # ãã®å¼ã³å£ãçæããããã¨ã«ãªã£ãå¼ã³å£ã¾ãã¯åãå£ã®æ
+å ±ãè¨­å®
+  def set_allocator_port( port, fd, par )
+    @allocator_port = port
+    @allocator_func_decl = fd
+    @allocator_param_decl = par
+  end
+
+  def is_allocator_port?
+    @allocator_port != nil
+  end
+
+  def get_allocator_port
+    @allocator_port
+  end
+
+  def get_allocator_func_decl
+    @allocator_func_decl
+  end
+
+  def get_allocator_param_decl
+    @allocator_param_decl
+  end
+
+  def set_require( b_has_name )
+    @b_require = true
+    @b_has_name = b_has_name
+  end
+
+  def is_require?
+    @b_require
+  end
+
+  #=== Port# require å¼ã³å£ãååãæã¤ï¼
+  # require éå®
+  def has_name?
+    @b_has_name
+  end
+
+  def is_optional?
+    @b_optional
+  end
+
+  def set_optional
+    @b_optional = true
+  end
+
+  #=== Port# omit æå®ããã¦ãã?
+  def is_omit?
+    @b_omit || ( @signature && @signature.is_empty? )
+  end
+
+  def set_omit
+    @b_omit = true
+  end
+
+  def set_VMT_useless                     # VMT é¢æ°ãã¼ãã«ãä½¿ç¨ããªã
+   @b_VMT_useless = true
+  end
+
+  def set_skelton_useless                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+    @b_skelton_useless = true
+  end
+
+  def set_cell_unique                     # å¼ã³å
+ã»ã«ã¯ä¸ã¤ã ã
+    @b_cell_unique = true
+  end
+
+  #=== Port# å¼ã³å£/åãå£ã®æå®å­ã®è¨­å®
+  # inline, allocator ã®æå®
+  def set_specifier spec_list
+    spec_list.each { |s|
+      case s[0]
+      when :INLINE
+        if @port_type == :CALL then
+          cdl_error( "S1077 inline: cannot be specified for call port"  )
+          next
+        end
+        @b_inline = true
+      when :OMIT
+        if @port_type == :ENTRY then
+          cdl_error( "S9999 omit: cannot be specified for entry port"  )
+          next
+        end
+        @b_omit = true
+      when :OPTIONAL
+        if @port_type == :ENTRY then
+          cdl_error( "S1078 optional: cannot be specified for entry port"  )
+          next
+        end
+        @b_optional = true
+      when :REF_DESC
+        @b_ref_desc = true
+      when :DYNAMIC
+        if @port_type == :ENTRY then
+          cdl_error( "S9999 dynamic: cannnot be specified for entry port" )
+          next
+        end
+        @b_dynamic = true
+      when :ALLOCATOR
+        if @port_type == :CALL then
+          cdl_error( "S1079 allocator: cannot be specified for call port"  )
+        end
+        if @allocator_instance_tmp then
+          cdl_error( "S1080 duplicate allocator specifier"  )
+          next
+        end
+        @allocator_instance_tmp = s[1]
+      else
+        raise "unknown specifier #{s[0]}"
+      end
+    }
+  end
+
+  #=== Port# ãªã¬ã¼ã¢ã­ã±ã¼ã¿ãå
+é¨ã¢ã­ã±ã¼ã¿ã®ã¤ã³ã¹ã¿ã³ã¹ãè¨­å®
+  # å¼ã³å£ã®åæ¹åç
+§å¯è½ãªããã«ãã»ã«ã¿ã¤ãã®è§£éã®æå¾ã§è¡ã
+  def set_allocator_instance
+    if @allocator_instance_tmp == nil then
+      return
+    end
+
+    @allocator_instance = {}
+    @allocator_instance_tmp.each { |ai|
+      direction = nil
+      alloc_type = ai[0]
+      # ai = [ :INTERNAL_ALLOC|:RELAY_ALLOC, func_name, param_name, rhs ]
+      case alloc_type
+      when :INTERNAL_ALLOC
+        if ! @owner.instance_of? CompositeCelltype then # ãã¹ãé²ãããã« composite ã§ãªããã°ã¨ãã
+          cdl_error( "S1081 self allocator not supported yet"  )   # mikan ããã¯ãµãã¼ãããã¦ããã¯ããè¦èª¿æ» 12/1/15
+          next
+        end
+        # OK
+      when :RELAY_ALLOC
+        # OK
+      when :NORMAL_ALLOC
+        # ããã¸æ¥ãã®ã¯ composite ã®åãå£ã§å³è¾ºã "eEnt.func.param" å½¢å¼ã§æå®ããã¦ããå ´å
+        cdl_error( "S1174 $1 not suitable for lhs, suitable lhs: 'func.param'", "#{ai[1]}.#{ai[3]}.#{ai[4]}" )
+        next
+      else
+        raise "Unknown allocator type #{ai[1]}"
+      end
+
+      # '=' å·¦è¾º(func_name,param_name)ã¯å®å¨ããã?
+      if @signature then       # signature = nil ãªãæ¢ã«ã¨ã©ã¼
+        fh = @signature.get_function_head( ai[1] )
+        if fh == nil then
+          cdl_error( "S1082 function \'$1\' not found in signature" , ai[1] )
+          next
+        end
+        decl = fh.get_declarator
+        if ! decl.is_function? then
+          next   # æ¢ã«ã¨ã©ã¼
+        end
+        paramdecl = decl.get_type.get_paramlist.find( ai[2] )
+        if paramdecl == nil then
+          cdl_error( "S1083 \'$1\' not found in function \'$2\'" , ai[2], ai[1] )
+          next
+        end
+        case paramdecl.get_direction
+        when :SEND, :RECEIVE
+          # OK
+          direction = paramdecl.get_direction
+        else
+          cdl_error( "S1084 \'$1\' in function \'$2\' is not send or receive" , ai[2], ai[1] )
+          next
+        end
+      end
+
+      # éè¤æå®ããªãã?
+      if @allocator_instance[ "#{@name}_#{ai[1]}_#{ai[2]}" ] then
+        cdl_error( "S1085 duplicate allocator specifier for \'$1_$2\'" , ai[1], ai[2] )
+      end
+
+      # å³è¾ºã®ãã§ãã¯
+      case alloc_type
+      when :INTERNAL_ALLOC
+
+        ele = ai[3].get_elements
+        if( ele[0] != :IDENTIFIER )then
+          cdl_error( "S1086 $1: rhs not in 'allocator_entry_port' form", ai[3].to_s )
+          next
+        end
+
+        ep_name = ele[1]   # ã¢ã­ã±ã¼ã¿åãå£å
+        ep = @owner.find ep_name.get_path[0]  # mikan "a::b"
+        if ep == nil || ! ep.instance_of?( Port ) || ep.get_port_type != :ENTRY || ! ep.get_signature.is_allocator? then
+          cdl_error( "S1175 $1 not found or not allocator entry port for $2" , ep_name, ai[1] )
+        end
+        # å³è¾ºãã§ãã¯çµãã
+        # ai2 = [ :INTERNAL_ALLOC, func_name, param_name, rhs_ep_name ]
+        ai2 = [ ai[0], ai[1], ai[2], ep_name ]
+
+      when :RELAY_ALLOC
+        ele = ai[3].get_elements
+        if( ele[0] != :OP_DOT ||
+            ele[1][0] != :OP_DOT || ele[1][1][0] != :IDENTIFIER || ! ele[1][1][1].is_name_only? ||
+            ! ele[1][2].instance_of?( Token ) || ! ele[2].instance_of?( Token ) )then   #1
+          # [ :OP_DOT, [ :OP_DOT, [ :IDENTIFIER,  name_space_path ],  Token(1) ],  Token(2) ]
+          #    ele[0]    ele[1][0]  ele[1][1][0]  ele[1][1][1]        ele[1][2]    ele[2]
+          #      name_space_path.Token(1).Token(2) === call_port.func.param
+          #  mikan Expression#analyze_cell_join_expression ã®å¤ç¨®ãä½æãã¦ç½®ãæããã¹ã
+
+          cdl_error( "S1176 rhs not in 'call_port.func.param' form for for $1_$2" , ai[1], ai[2] )   # S1086
+          next
+        end
+        func_name = ele[1][2]; cp_name = ele[1][1][1].get_name; param_name = ele[2].to_sym
+        cp = @owner.find cp_name    # ãªã¬ã¼ããå
+ã®å¼ã³å£
+        if cp then
+# mikan cp ãå¼ã³å£ã§ãããã¨ã®ãã§ãã¯ï¼å±æ§ã®å ´åãããï¼
+# mikan åãå£ããåãå£ã¸ã®ãªã¬ã¼ã¸ã®å¯¾å¿ (å¼ã³å£ããå¼ã³å£ã¸ã®ãªã¬ã¼ã¯ããããªã)  <=== ææ³ã«ããããäºé 
+ï¼å¼ã³å£å´ã§ã¢ã­ã±ã¼ã¿ãæ±ºå®ãããï¼
+          sig = cp.get_signature
+          if sig && @signature then
+            fh = @signature.get_function_head( func_name )
+            if fh == nil then
+              cdl_error( "S1087 function \'$1\' not found in signature \'$2\'" , func_name, sig.get_name )
+              next
+            end
+            decl = fh.get_declarator
+            if ! decl.is_function? then
+              next   # æ¢ã«ã¨ã©ã¼
+            end
+            paramdecl = decl.get_type.get_paramlist.find( param_name )
+            if paramdecl == nil then
+              cdl_error( "S1088 \'$1\' not found in function \'$2\'" , param_name, func_name )
+              next
+            end
+            case paramdecl.get_direction
+            when :SEND, :RECEIVE
+              # OK
+              if alloc_type == :RELAY_ALLOC && direction != paramdecl.get_direction then
+                cdl_error( "S1089 relay allocator send/receive mismatch between $1.$2 and $3_$4.$5" , ai[1], ai[2], cp_name, func_name, param_name )
+              end
+            else
+              cdl_error( "S1090 \'$1\' in function \'$2\' is not send or receive" , param_name, func_name )
+              next
+            end
+
+            # else
+            # sig == nil ãªãã°æ¢ã«ã¨ã©ã¼
+          end
+        else
+          if @celltype then
+            ct_name = @celltype.get_name
+          else
+            ct_name = "(None)"
+          end
+          cdl_error( "S1091 call port \'$1\' not found in celltype $2" , cp_name, ct_name )
+          next
+        end
+        # å³è¾ºãã§ãã¯çµãã
+        # ai2 = [ :RELAY_ALLOC, func_name, param_name, rhs_cp_name, rhs_func_name, rhs_param_name ]
+        ai2 = [ ai[0], ai[1], ai[2], cp_name, func_name, param_name ]
+      end # case alloc_type
+
+      @allocator_instance[ "#{@name}_#{ai[1]}_#{ai[2]}" ] = ai2
+    }
+  end
+
+  def is_inline?
+    @b_inline
+  end
+
+  def is_VMT_useless?                     # VMT é¢æ°ãã¼ãã«ãä½¿ç¨ããªã
+   @b_VMT_useless
+  end
+
+  def is_skelton_useless?                 # ã¹ã±ã«ãã³é¢æ°ä¸è¦   (true ã®æãåãå£é¢æ°ãå¼åºã)
+    @b_skelton_useless
+  end
+
+  def is_cell_unique?                     # å¼ã³å
+ã®ã»ã«ã¯ä¸ã¤ï¼
+    @b_cell_unique
+  end
+
+  #=== Port# åãå£æé©åã®è¨­å®
+  # ãã®åãå£ãåç
+§ããå¼ã³å£ã VMT, skelton ãå¿
+è¦ã¨ãã¦ãããã©ãããè¨­å®
+  # ä¸ã¤ã§ãå¼ã³å£ãå¿
+è¦ã¨ãã¦ããï¼ããªãã¡ b_*_useless ã falseï¼å ´åã¯ã
+  # ãã®åãå£ã®æé©åã false ã¨ãã
+  def set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless )
+    if ! b_VMT_useless then
+      @b_VMT_useless = false
+    end
+    if ! b_skelton_useless then
+      @b_skelton_useless = false
+    end
+  end
+
+  #=== Port# å¯ä¸ã®çµåå
+ãè¨­å®
+  # æé©åã§ä½¿ç¨
+  #  b_VMT_useless == true || b_skelton_useless == true ã®æã«è¨­å®ããã
+  #  optional ã®å ´å callee_cell, callee_port ã nil ã¨ãªã
+  def set_only_callee( callee_port, callee_cell )
+    @only_callee_port = callee_port
+    @only_callee_cell = callee_cell
+  end
+
+  #=== Port# å¯ä¸ã®çµåå
+ãã¼ããè¿ã(compositeã®å ´åå®ã»ã«)
+  # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã
+  def get_real_callee_port
+    if @only_callee_cell then
+      return @only_callee_cell.get_real_port( @only_callee_port.get_name )
+    end
+  end
+
+  #=== Port# å¯ä¸ã®çµåå
+ã»ã«ãè¿ã(compositeã®å ´åå®ã»ã«)
+  # optional å¼ã³å£ã§æªçµåã®å ´å nil ãè¿ã
+  def get_real_callee_cell
+    if @only_callee_cell then
+      return @only_callee_cell.get_real_cell( @only_callee_port.get_name )
+    end
+  end
+
+  def get_allocator_instance
+    return @allocator_instance
+  end
+
+  def get_allocator_instance_tmp
+    return @allocator_instance_tmp
+  end
+
+  #=== Port# érequire ã®çµåãçæãã
+  # STAGE: S
+  def create_reverse_require_join cell
+    if @reverse_require_cell_path == nil then
+      return
+    end
+
+    # å¼ã³å
+ã»ã«ãæ¢ã
+    ct_or_cell = Namespace.find( @reverse_require_cell_path )   # mikan namespace    #1
+    if ct_or_cell.instance_of? Cell then
+      cell2 = ct_or_cell
+      ct = cell2.get_celltype
+      if ct == nil then
+        return    # æ¢ã«ã¨ã©ã¼
+      end
+    elsif ct_or_cell.instance_of? Celltype then
+      cell2 = ct_or_cell.get_singleton_cell( cell.get_region )
+      if cell2 == nil then
+        cdl_error( "S1158 $1: singleton cell not found for fixed join", ct_or_cell.get_name )
+        return
+      end
+      ct = ct_or_cell
+    else
+      # æ¢ã«ã¨ã©ã¼ï¼ç¡è¦
+      return
+    end
+
+    # çµåãçæãã
+    dbgPrint "create_reverse_require_join #{cell2.get_name}.#{@reverse_require_entry_port_name}[] = #{cell.get_name}.#{@name}"
+    nsp = NamespacePath.new( cell.get_name, false, cell.get_namespace )
+#    rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, Token.new( cell.get_name, nil, nil, nil ) ],
+    rhs = Expression.new( [ :OP_DOT, [ :IDENTIFIER, nsp ],
+                            Token.new( @name, nil, nil, nil ) ], cell.get_locale )   #1
+    join = Join.new( @reverse_require_entry_port_name, -1, rhs, cell.get_locale )
+    cell2.new_join( join )
+    join.set_definition( ct.find(join.get_name) )
+
+  end
+
+  #=== Port# signature ã®ãã¹ã¦ã®é¢æ°ã®ãã¹ã¦ã®ãã©ã¡ã¼ã¿ããã©ã
+  #block:: ãã­ãã¯ãå¼æ°ã¨ãã¦åã(ruby ã®ææ³ã§æ¸ããªã)
+  #  ãã­ãã¯ã¯3ã¤ã®å¼æ°ãåãåã(Port, Decl,      ParamDecl)    Decl: é¢æ°ããã
+  # Signature ã¯ã©ã¹ã«ã each_param ãããï¼åãåãï¼
+  def each_param # ãã­ãã¯å¼æ°{  |port, func_decl, param_decl| }
+    return if @signature == nil                         # signature æªå®ç¾©ï¼æ¢ã«ã¨ã©ã¼ï¼
+    fha = @signature.get_function_head_array            # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®é¢æ°é
+å
+    return if fha == nil                                # nil ãªãææ³ã¨ã©ã¼ã§æå¹å¤ãè¨­å®ãããªãã£ã
+
+    pr = Proc.new   # ãã®ã¡ã½ããã®ãã­ãã¯å¼æ°ã pr ã«ä»£å
+¥
+    port = self
+    fha.each{ |fh|  # fh: FuncHead                      # é¢æ°é
+åä¸­ã®åé¢æ°é ­é¨
+      fd = fh.get_declarator                            # fd: Decl  (é¢æ°é ­é¨ããDeclarotorãå¾ã)
+      if fd.is_function? then                           # fd ãé¢æ°ã§ãªããã°ããã§ã«ã¨ã©ã¼
+        fd.get_type.get_paramlist.get_items.each{ |par| # ãã¹ã¦ã®ãã©ã¡ã¼ã¿ã«ã¤ãã¦
+          pr.call( port, fd, par )
+        }
+      end
+    }
+  end
+
+  #=== Port# érequireæå®ããã¦ããï¼
+  def is_reverse_required?
+    @reverse_require_cell_path != nil
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Port: name:#{@name} port_type:#{@port_type} require:#{@b_require} inline:#{@b_inline} omit:#{@b_omit} optional:#{@b_optional} ref_desc:#{@b_ref_desc} dynamic:#{@b_dynamic}"
+    (indent+1).times { print "  " }
+    if @signature then
+      puts "signature: #{@signature.get_name} #{@signature}"
+    else
+      puts "signature: NOT defined"
+    end
+    if @array_size == "[]" then
+      (indent+1).times { print "  " }
+      puts "array_size: not specified"
+    elsif @array_size then
+      (indent+1).times { print "  " }
+      puts "array_size: #{@array_size}"
+    end
+    if @allocator_instance then
+      (indent+1).times { print "  " }
+      puts "allocator instance:"
+      @allocator_instance.each { |b,a|
+        (indent+2).times { print "  " }
+        puts "#{a[0]} #{a[1]} #{b} "
+        # a[3].show_tree( indent+3 )
+      }
+    end
+    (indent+1).times { print "  " }
+    if @port_type == :CALL then
+      puts "VMT_useless : #{@b_VMT_useless}  skelton_useless : #{@b_skelton_useless}  cell_unique : #{@b_cell_unique}"
+    else
+      puts "VMT_useless : #{@b_VMT_useless}  skelton_useless : #{@b_skelton_useless}"
+    end
+  end
+
+end
+
+#== Namespace
+#
+# root namespace ã ããRegion ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¨ãã¦çæããã
+# root namespace ã¯ãroot region ãå
+¼ã­ããã
+#
+# @cell_list ã¯ Region ã®å ´åã«ã®ã¿æã¤ (mikan @cell_list é¢é£ã¯ Region ã«ç§»ãã¹ã)
+#
+class Namespace < NSBDNode
+# @name::  Symbol     # root ã®å ´å "::" (String)
+# @global_name:: str
+# @name_list:: NamedList   Signature,Celltype,CompositeCelltype,Cell,Typedef,Namespace
+# @struct_tag_list:: NamedList : StructType
+# @namespace_list:: Namespace[] : Region ã¯ Namespace ã®å­ã¯ã©ã¹ã§ãããå«ã¾ãã
+# @signature_list:: Sginature[]
+# @celltype_list:: Celltype[]
+# @compositecelltype_list:: CompositeCelltype[]
+# @cell_list:: Cell[]
+# @typedef_list:: Typedef[]
+# @decl_list:: ( Typedef | StructType | EnumType )[]   ä¾å­é¢ä¿ãããå ´åã«åãã¦ãé çªã©ããã«é
+åã«æ ¼ç´ mikan enum
+# @const_decl_list:: Decl[]
+# @cache_n_cells:: Integer :  get_n_cells ã®çµæãã­ã£ãã·ã¥ãã
+# @cache_generating_region:: Region :  get_n_cells ã®çµæãã­ã£ãã·ã¥ãããã¦ãããªã¼ã¸ã§ã³
+
+  # mikan namespace ã® push, pop
+
+  # namespace éå±¤ç¨ã®ã¹ã¿ãã¯
+  @@namespace_stack = []      # @@namespace_stack[0] = "::" (generator.rb)
+  @@namespace_sp = -1
+
+  # Generator ãã¹ãç¨ã®ã¹ã¿ãã¯ (namespace éå±¤ç¨ã®ã¹ã¿ãã¯ãå¯¾æ¯ãã)
+  @@nest_stack_index = -1
+  @@nest_stack = []
+
+  @@root_namespace = nil
+
+  # Generator ãã¹ãç¨ã¹ã¿ãã¯ã® push, pop (ã¯ã©ã¹ã¡ã½ãã)
+  def self.push
+    dbgPrint "push Namespace\n"
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = [ @@namespace_stack, @@namespace_sp ]
+    if @@root_namespace then
+      @@namespace_sp = 0
+      @@namespace_stack[ @@namespace_sp ] = @@root_namespace
+    end
+  end
+
+  def self.pop
+    dbgPrint "pop Namespace\n"
+    @@namespace_stack, @@namespace_sp = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+  # namespace éå±¤ç¨ã¹ã¿ãã¯ã® push, pop (ã¤ã³ã¹ã¿ã³ã¹ã¡ã½ãã)
+  def push ns
+    @@namespace_sp += 1
+    @@namespace_stack[ @@namespace_sp ] = self
+    dbgPrint "Namespace.PUSH #{@@namespace_sp} #{@name}\n"
+  end
+
+  def pop
+    dbgPrint "Namespace.POP #{@@namespace_sp} #{@name}\n"
+    @@namespace_sp -= 1
+    if @@namespace_sp < 0 then
+      raise "StackUnderflow"
+    end
+  end
+
+  def initialize( name )
+
+    super()
+    @name = name
+
+    if( name == "::" )then
+      if( @@root_namespace != nil )then
+        # root ã¯ä¸åã®ã¿çæã§ãã
+        raise "try to re-create root namespace"
+      end
+      @@root_namespace = self
+      @NamespacePath = NamespacePath.new( name, true )
+    else
+      ns = @@namespace_stack[ @@namespace_sp ].find( name )
+      if ns.kind_of? Namespace then
+        dbgPrint "namespace: re-appear #{@name}\n"
+        # ç»é²æ¸ã¿ namespace ã®åç»é²
+        ns.push ns
+        return
+      elsif ns then
+        cdl_error( "S1151 $1: not namespace", @name )
+        prev_locale = ns.get_locale
+        puts "previous: #{prev_locale[0]}: line #{prev_locale[1]} \'#{name}\' defined here"
+      end
+      dbgPrint "namespace: 1st-appear #{@name}\n"
+    end
+
+    if @@namespace_sp >= 0 then   # root ã¯é¤å¤
+      @@namespace_stack[@@namespace_sp].new_namespace( self )
+    end
+    push self
+
+    @global_name = Namespace.get_global_name    # stack ç»é²å¾åã
+    @name_list = NamedList.new( nil, "symbol in namespace '#{@name}'" )
+    @struct_tag_list = NamedList.new( nil, "struct tag" )
+
+    @namespace_list = []
+    @signature_list = []
+    @celltype_list = []
+    @compositecelltype_list = []
+    @cell_list = []
+    @typedef_list = []
+    @decl_list = []
+    @const_decl_list = []
+    @cache_n_cells = nil
+    @cache_generating_region = nil
+    if @NamespacePath == nil then
+      # root namespace ã®å ´åã¯è¨­å®æ¸ (è¦ª namespace ãè¦ã¤ãããä¾å¤ã«ãªã)
+      set_namespace_path # @NamespacePath ã®è¨­å®
+    end
+  end
+
+  def end_of_parse
+    pop
+  end
+
+  def get_name
+    @name
+  end
+
+  #=== Namespace:: global_name ãå¾ã
+  # parse ä¸­ã®ã¿ãã®ã¡ã½ããã¯ä½¿ãã
+  # STAGE: P
+  def self.get_global_name    # parse ä¸­æå¹
+    if @@namespace_sp <= 0 then
+      return ""
+    end
+
+    path = @@namespace_stack[1].get_name.to_s
+    i = 2
+    while i <= @@namespace_sp
+      path = path+"_"+@@namespace_stack[i].get_name.to_s
+      i += 1
+    end
+
+    path
+  end
+
+  def get_global_name
+    @global_name
+  end
+
+  #=== Namespace#ã»ã«ã®åæ°ãå¾ã
+  # å­ region ã linkunit, node æå®ããã¦ããã°ãå«ããªãï¼å¥ã®ãªã³ã¯åä½ï¼
+  # ãã­ãã¿ã¤ãå®£è¨ã®ãã®ã®ã¿ã®åæ°ãå«ããªã
+  # mikan namespace ä¸ã« cell ãç½®ããªãä»æ§ã«ãªãã¨ããã®ã¡ã½ããã¯ Region ã®ãã®ã§ãã
+  # mikan ä¸è¨ã®å ´å instance_of? Namespace ã®æ¡ä»¶å¤å®ã¯ä¸è¦ã¨ãªã
+  def get_n_cells
+    if @cache_generating_region == $generating_region then
+      # ãã®ã¡ã½ããã¯ç¹°ãè¿ãå¼ã³åºããããããçµæãã­ã£ãã·ã¥ãã
+      return @cache_n_cells
+    end
+
+    count = 0
+    @cell_list.each{ |c|
+      # å®ç¾©ããã­ãã¿ã¤ãå®£è¨ã ããã¯ãnew_cell ã®æ®µéã§å¤æ­ã§ããªããããã«ã¦ã³ãããªãã
+      if c.get_f_def == true then
+        # print "get_n_cells: cell: #{c.get_name}\n"
+        count += 1
+      end
+    }
+
+    @namespace_list.each{ |ns|
+      if ns.instance_of? Namespace then
+        count += ns.get_n_cells
+      else
+        # ns ã¯ Region ã§ãã
+        rt = ns.get_region_type
+        # print "get_n_cells: region: #{ns.get_name}: #{rt}\n"
+        if rt == :NODE || rt == :LINKUNIT then
+          # å¥ã® linkunit ãªã®ã§å ç®ããªã
+        else
+          count += ns.get_n_cells
+        end
+      end
+    }
+
+    @cache_generating_region = $generating_region
+    @cache_n_cells = count
+    return count
+  end
+
+  #=== Namespace.find : in_path ã§ç¤ºããããªãã¸ã§ã¯ããæ¢ã
+  #in_path:: NamespacePath
+  #in_path:: Array : å¤ãå½¢å¼
+  #  path [ "::", "ns1", "ns2" ]   absolute
+  #  path [ "ns1", "ns2" ]         relative
+  def self.find( in_path )
+
+    if in_path.instance_of? Array then
+      # raise "Namespace.find: old fashion"
+
+      path = in_path
+      length = path.length
+      return self.find_one( path[0] ) if length == 1
+
+      name = path[0]
+      if name == "::" then
+        i = 1
+        name = path[i]   # æ§æçã«å¿
+ãå­å¨
+        object = @@root_namespace.find( name )  # root
+      else
+        # ç¸å¯¾ãã¹
+        i = 0
+        object = @@namespace_stack[@@namespace_sp].find_one( name ) # crrent
+      end
+
+    elsif in_path.instance_of? NamespacePath then
+      path = in_path.get_path
+      length = path.length
+
+      if length == 0 then
+        if in_path.is_absolute? then
+          return @@root_namespace
+        else
+          raise "path length 0, not absolute"
+        end
+      end
+
+      i = 0
+      name = path[0]
+      if in_path.is_absolute? then
+        object = @@root_namespace.find( name )  # root
+      else
+        bns = in_path.get_base_namespace
+        object = bns.find_one( name )           # crrent
+      end
+    else
+      raise "unexpected path"
+    end
+
+    i += 1
+    while i < length
+
+      unless object.kind_of?( Namespace ) then
+        # ã¯ã©ã¹ã¡ã½ããå
+ã§ cdl_error ãå¼ã³åºããã¨ã¯ã§ããªã
+        # ã¾ããåæ¹åç
+§å¯¾å¿å¾ãæ­£ç¢ºãªè¡çªå·ãåºãªãåé¡ãçãã
+        # cdl_error( "S1092 \'$1\' not namespace" , name )
+        # ãã®ã¡ã½ãããã nil ãå¸°ã£ãå ´å "not found" ãåºãã®ã§ãããã§ã¯åºããªã
+        return nil
+      end
+
+      object = object.find( path[i] )
+      i += 1
+    end
+
+    return object
+  end
+
+
+  def find( name )
+    @name_list.get_item(name)
+  end
+
+  #=== Namespace# namespace ããæ¢ããè¦ã¤ãããªããã°è¦ª namespace ããæ¢ã
+  def self.find_one( name )
+    return @@namespace_stack[@@namespace_sp].find_one( name )
+  end
+
+  def find_one( name )
+
+    object = find( name )
+    # ããã¯åºãã
+    # dbgPrint "in '#{@name}' find '#{name}' object #{object ? object.class : "Not found"}\n"
+
+    if object != nil then
+      return object
+    elsif @name != "::" then
+      return @owner.find_one( name )
+    else
+      return nil
+    end
+  end
+
+  def self.get_current
+    @@namespace_stack[@@namespace_sp]
+  end
+
+  def self.find_tag( name )
+    # mikan tag : namespace ã® path ã«å¯¾å¿ããªã
+    # namespace ã®ä¸­ã«ãã£ã¦ããroot namespace ã«ãããã®ã¨è¦ãªããã
+    # ãã£ã¦ ã«ã¬ã³ã namespace ããæ ¹ã«åãã£ã¦æ¢ã
+    i = @@namespace_sp
+    while i >= 0
+      res = @@namespace_stack[i].find_tag( name )
+      if res then
+        return res
+      end
+      i -= 1
+    end
+  end
+
+  def find_tag( name )
+    @struct_tag_list.get_item( name )
+  end
+
+ ### namespace
+  def self.new_namespace( namespace )
+    @@namespace_stack[@@namespace_sp].new_namespace( namespace )
+  end
+
+  def new_namespace( namespace )
+    dbgPrint "new_namespace: #{@name}:#{self} #{namespace.get_name}:#{namespace} \n"
+    namespace.set_owner self   # Namespace (Namespace)
+
+    @name_list.add_item( namespace )
+    @namespace_list << namespace
+  end
+
+ ### signature
+  def self.new_signature( signature )
+    @@namespace_stack[@@namespace_sp].new_signature( signature )
+  end
+
+  def new_signature( signature )
+    signature.set_owner self   # Signature (Namespace)
+    @name_list.add_item( signature )
+    @signature_list << signature
+  end
+
+ ### celltype
+  def self.new_celltype( celltype )
+    @@namespace_stack[@@namespace_sp].new_celltype( celltype )
+  end
+
+  def new_celltype( celltype )
+    celltype.set_owner self   # Celltype (Namespace)
+    @name_list.add_item( celltype )
+    @celltype_list << celltype
+  end
+
+ ### compositecelltype
+  def self.new_compositecelltype( compositecelltype )
+    @@namespace_stack[@@namespace_sp].new_compositecelltype( compositecelltype )
+  end
+
+  def new_compositecelltype( compositecelltype )
+    compositecelltype.set_owner self   # CompositeCelltype (Namespace)
+    @name_list.add_item( compositecelltype )
+    @compositecelltype_list << compositecelltype
+  end
+
+ ### cell (Namespace)
+  def self.new_cell( cell )
+    @@namespace_stack[@@namespace_sp].new_cell( cell )
+  end
+
+  def new_cell( cell )
+    dbgPrint "Namespace.new_cell: #{@NamespacePath.get_path_str}::#{cell.get_name}\n"
+    if ! is_root? && ! ( instance_of? Region ) then
+      cdl_error( "S9999 '$1' cell cannot be placed under namespace", cell.get_name )
+    end
+    cell.set_owner self   # Cell (Namespace)
+    @name_list.add_item( cell )
+    @cell_list << cell
+  end
+
+  #=== Namespace# åç
+§ããã¦ããããæªå®ç¾©ã®ã»ã«ãæ¢ã
+  # ãã­ãã¿ã¤ãå®£è¨ã ãã§å®ç¾©ããã¦ããªãã±ã¼ã¹ãã¨ã©ã¼ã¨ãã
+  # ååã®æªçµåã»ã«ã«ã¤ãã¦è­¦åãã
+  def check_ref_but_undef
+    @cell_list.each { |c|
+      if ! c.get_f_def then   # Namespace ã® @cell_list ã«ã¯ãã­ãã¿ã¤ããå«ã¾ããã±ã¼ã¹ãã
+        if c.get_f_ref then
+          cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str )
+        elsif $verbose then
+          cdl_warning( "W1006 $1 : only prototype, unused and undefined cell" , c.get_namespace_path.get_path_str )
+        end
+      else
+        dbgPrint "check_ref_but_undef: #{c.get_global_name}\n"
+        ct = c.get_celltype
+        # if c.get_f_ref == false && c.is_generate? && ct && ct.is_inactive? then
+        if c.get_f_ref == false && ct && ct.is_inactive? then
+          cdl_warning( "W1007 $1 : non-active cell has no entry join and no factory" , c.get_namespace_path.get_path_str )
+        end
+      end
+    }
+    @namespace_list.each { |n|
+      n.check_ref_but_undef
+    }
+  end
+
+  #=== Namespace# ã»ã«ã®åãå£ã®åç
+§ã«ã¦ã³ããè¨­å®ãã
+  def set_port_reference_count
+    @cell_list.each { |c|
+      c.set_port_reference_count
+    }
+    @namespace_list.each { |n|
+      n.set_port_reference_count
+    }
+  end
+
+ ### struct
+  def self.new_structtype( struct )
+    @@namespace_stack[@@namespace_sp].new_structtype( struct )
+  end
+
+  def new_structtype( struct )
+    # struct.set_owner self   # StructType (Namespace) # StructType ã¯ BDNode ã§ã¯ãªã
+    dup = @struct_tag_list.get_item(struct.get_name)
+    if dup != nil then
+      if struct.same? dup then
+        # åããã®ã typedef ããã
+        # p "#{struct.get_name}"
+        return
+      end
+    end
+
+    @struct_tag_list.add_item( struct )
+    @decl_list << struct
+  end
+
+ ### typedef
+  def self.new_typedef( typedef )
+    @@namespace_stack[@@namespace_sp].new_typedef( typedef )
+  end
+
+  def new_typedef( typedef )
+    typedef.set_owner self   # TypeDef (Namespace)
+    dup = @name_list.get_item(typedef.get_name)
+    if dup != nil then
+      typedef_type = typedef.get_declarator.get_type.get_original_type
+      dup_type = dup.get_declarator.get_type.get_original_type
+      # print "typedef: #{typedef.get_name} = #{typedef_type.get_type_str} #{typedef_type.get_type_str_post}\n"
+      if typedef_type.get_type_str == dup_type.get_type_str &&
+          typedef_type.get_type_str_post == dup_type.get_type_str_post then
+        # åããã®ã typedef ããã
+        # ããã¸æ¥ãã®ã¯ C ã§é¢æ°ãã¤ã³ã¿ã typedef ãã¦ããã±ã¼ã¹
+        # ä»¥ä¸ã®ããã«äºéã«å®ç¾©ããã¦ããå ´åã¯ type_specifier_qualifier_list ã¨ãã¦æ±ããã
+        #    typedef long LONG; 
+        #    typedef long LONG;
+        # bnf.y.rb ã§ã¯ declarator ã« TYPE_NAME ãè¨±ããªãã®ã§ãããã¸æ¥ããã¨ã¯ãªã
+        # p "#{typedef.get_declarator.get_type.get_type_str} #{typedef.get_name} #{typedef.get_declarator.get_type.get_type_str_post}"
+        return
+      end
+      # p "prev: #{dup.get_declarator.get_type.get_type_str}#{dup.get_declarator.get_type.get_type_str_post} current:#{typedef.get_declarator.get_type.get_type_str} #{typedef.get_declarator.get_type.get_type_str_post}"
+    end
+
+    # p "typedef: #{typedef.get_name}  #{typedef.get_declarator.get_type.get_original_type.get_type_str}#{typedef.get_declarator.get_type.get_original_type.get_type_str_post}"
+    # typedef.show_tree 0
+
+    @name_list.add_item( typedef )
+    @typedef_list << typedef
+    @decl_list << typedef
+  end
+
+  def self.is_typename?( str )
+    i = @@namespace_sp
+    while i >= 0
+      if @@namespace_stack[i].is_typename?( str ) then
+        return true
+      end
+      i -= 1
+    end
+    false
+  end
+
+  def is_typename?( str )
+    if @name_list.get_item( str ).instance_of?( Typedef ) then
+      true
+    else
+      false
+    end
+  end
+
+ ### const_decl
+  def self.new_const_decl( decl )
+    @@namespace_stack[@@namespace_sp].new_const_decl( decl )
+  end
+
+  def new_const_decl( decl )
+    decl.set_owner self   # Decl (Namespace:const)
+    if ! decl.is_const? then			# const ä¿®é£¾ãã¦ãããã¨
+      if decl.is_type?( PtrType ) then
+        cdl_error( "S1094 $1: pointer is not constant. check \'const\'" , decl.get_name )
+      else
+        cdl_error( "S1095 $1: not constant" , decl.get_name )
+      end
+    elsif ! decl.is_type?( IntType ) && ! decl.is_type?( FloatType ) &&
+        ! decl.is_type?( BoolType ) && ! decl.is_type?( PtrType ) then
+                                            # IntType, FloatType ã§ãããã¨
+      cdl_error( "S1096 $1: should be int, float, bool or pointer type" , decl.get_name )
+    elsif decl.get_initializer == nil then   # åæå¤ãæã¤ãã¨
+      cdl_error( "S1097 $1: has no initializer" , decl.get_name )
+#    elsif decl.get_initializer.eval_const(nil) == nil then  #eval_const ã¯ check_init ã§å¼åºãããã®ã§äºéãã§ãã¯
+#                                            # mikan åæå¤ãåã«å¯¾ãé©åã§ãããã¨
+#      cdl_error( "S1098 $1: has unsuitable initializer" , decl.get_name )
+    else
+      decl.get_type.check_init( @locale, decl.get_name, decl.get_initializer, :CONSTANT )
+      @name_list.add_item( decl )
+      @const_decl_list << decl
+    end
+
+  end
+
+ ### region
+  # def self.new_region( region )
+  #   @@namespace_stack[@@namespace_sp].new_region( region )
+  # end
+# 
+  # def new_region( region )
+  #   region.set_owner self   # Rgion (Namespace)
+  #   @name_list.add_item( region )
+  # end
+
+ ###
+
+  #=== Namespace# ãã¹ã¦ã®ã»ã«ã® require ãã¼ããè¨­å®
+  # STAGE: S
+  def set_require_join
+    @celltype_list.each{ |ct|
+      ct.set_require_join
+    }
+    # ãã¹ã¦ã® namespace ã«ã¤ãã¦ require ãã¼ããã»ãã
+    @namespace_list.each{ |ns|
+      ns.set_require_join
+    }
+  end
+
+  #=== Namespace# Join ã¸ã® definition ã®è¨­å®ã¨ãã§ãã¯
+  # ã»ã«ã¿ã¤ãã«å±ãããã¹ã¦ã®ã»ã«ã«å¯¾ãã¦å®æ½
+  def set_definition_join
+    # celltype ã®ã³ã¼ããçæ
+    @cell_list.each { |c|
+      dbgPrint "set_definition_join #{c.get_name}\n"
+      c.set_definition_join
+    }
+    @namespace_list.each{ |ns|
+      ns.set_definition_join
+    }
+  end
+
+  #=== Namespace# ã»ã«ã®çµåããã§ãã¯ãã
+  def check_join
+    @cell_list.each { |c|
+      dbgPrint "check_join #{c.get_name}\n"
+      c.check_join
+      c.check_reverse_require
+    }
+    @namespace_list.each{ |ns|
+      ns.check_join
+    }
+  end
+
+  #== Namespace# ã«ã¼ãã?
+  # ã«ã¼ããã¼ã ã¹ãã¼ã¹ ã¨ ã«ã¼ããªã¼ã¸ã§ã³ã¯åã
+  def is_root?
+    @name == "::"
+  end
+
+  #== Namespace# ã«ã¼ããå¾ã
+  # ã«ã¼ããªã¼ã¸ã§ã³ã¨ã«ã¼ããã¼ã ã¹ãã¼ã¹ã¯åããªãã¸ã§ã¯ã
+  def self.get_root
+    @@root_namespace
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "#{self.class}: name: #{@name} path: #{get_namespace_path.get_path_str}"
+    @struct_tag_list.show_tree( indent + 1 )
+    @name_list.show_tree( indent + 1 )
+  end
+
+end
+
+
+class Join < BDNode
+# @name:: string
+# @subscript:: nil: not array, -1: subscript not specified, >=0: array_subscript
+# @rhs:: Expression | initializer ( array of Expression | initializer (Expression | C_EXP) )
+# @definition:: Port, Decl(attribute or var)
+#
+# available if definition is Port
+# @cell_name:: string : å³è¾ºã®ã»ã«ã®åå
+# @cell:: Cell  : å³è¾ºã®ã»ã«
+# @celltype:: Celltype : å³è¾ºã®ã»ã«ã¿ã¤ã
+# @port_name:: string : å³è¾ºã®åãå£å
+# @port:: Port : å³è¾ºã®åãå£
+# @array_member:: rhs array : available only for first appear in the same name
+# @array_member2:: Join array : available only for first appear in the same name
+# @rhs_subscript:: nil : not array, >=0: å³è¾ºã®æ·»æ°
+#
+
+# @through_list::  @cp_through_list + @region_through_list
+#  ä»¥ä¸ã®æ§é ãæã¤ï¼@cp_through_list ã®æ§é ã¯å
+±éï¼
+# @cp_through_list::  å¼ã³å£ã«æå®ããã through
+#   [ [plugin_name, cell_name, plugin_arg], [plugin_name2, cell_name2, plugin_arg], ... ]
+# @region_through_list::  region ã«æå®ããã through
+#   [ [plugin_name, cell_name, plugin_arg, region], [plugin_name2, cell_name2, plugin_arg, region2], ... ]
+#
+# @through_generated_list:: [Plugin_class object, ...]: @through_list ã«å¯¾å¿
+# @region_through_generated_list:: [Plugin_class object, ...]: @region_through_list ã«å¯¾å¿
+#
+
+  include PluginModule
+
+  #=== Join# åæå
+  #name:: string: ååï¼å±æ§åãå¼ã³å£åï¼
+  #subscript:: Nil=éé
+å, -1="[]", N="[N]"
+  #rhs:: Expression: å³è¾ºã®å¼
+  def initialize( name, subscript, rhs, locale = nil )
+    # dbgPrint "Join#new: #{name}, #{subscript} #{rhs.eval_const(nil)}\n"
+    dbgPrint "Join#new: #{name}, #{subscript}\n"
+
+    super()
+    if locale then
+      @locale = locale
+    end
+
+    @name = name
+    if subscript.instance_of?( Expression ) then
+       #mikan é
+åæ·»æ°ãæ´æ°ã§ãããã¨ãæªãã§ãã¯
+       @subscript = subscript.eval_const(nil)
+       if @subscript == nil then
+         cdl_error( "S1099 array subscript not constant"  )
+       end
+    else
+       @subscript = subscript
+    end
+
+    @rhs = rhs
+    @definition = nil
+
+    # é
+åè¦ç´ ãè¨­å®
+    # æ¬å½ã¯ãååºã®è¦ç´ ã®ã¿è¨­å®ããã®ãé©å½
+    # new_join ã§ add_array_member ã®ä¸­ã§ååºè¦ç´ ã® array_member ã«å¯¾ãè¨­å®ãã
+    if @subscript == -1 then
+      @array_member  = [self]
+      @array_member2 = [self]
+    elsif @subscript != nil then
+      @array_member = []
+      @array_member2 = []
+      @array_member[@subscript]  = self
+      @array_member2[@subscript] = self
+    end
+
+    @through_list = []
+    @cp_through_list = []
+    @region_through_list = []
+    @through_generated_list = []
+    @region_through_generated_list = []
+  end
+
+  #===  Join# å·¦è¾ºã«å¯¾å¿ãã celltype ã®å®ç¾©ãè¨­å®ããã¨ã¨ãã«ãã§ãã¯ãã
+  # STAGE:   S
+  #
+  #     ä»£å
+¥å¯è½ããã§ãã¯ãã
+  #definition:: Decl (attribute,varã®æ) ã¾ãã¯ Port (callã®æ) ã¾ãã¯ nil (definition ãè¦ã¤ãããªãã£ãæ)
+
+  def set_definition( definition )
+
+    dbgPrint "set_definition: #{@owner.get_name}.#{@name} = #{definition.class}\n"
+
+    # äºéãã§ãã¯ã®é²æ­¢
+    if @definition then
+      # set_definition ãåå¥ã«è¡ãã±ã¼ã¹ã§ãäºéã«è¡ãããå¯è½æ§ãããï¼ç°å¸¸ã§ã¯ãªãï¼
+      # äºéã« set_definition ãå®è¡ãããã¨ through ãäºéã«é©ç¨ããã¦ãã¾ã
+      # cdl_warning( "W9999 $1, internal error: set_definition duplicate", @name )
+      return
+    end
+
+    @definition = definition
+
+    # mikan å·¦è¾ºå¤ãå³è¾ºå¤ã®åãã§ãã¯ãªã©
+    if @definition.instance_of?( Decl ) then
+      check_var_init
+    elsif @definition.instance_of?( Port ) then
+      check_call_port_init
+      if @definition.get_port_type == :CALL then   # :ENTRY ãªãã¨ã©ã¼ãç¡è¦ããªã
+        check_and_gen_through
+        create_allocator_join  # through ãã©ã°ã¤ã³çæããå¾ã§ãªãã¨ãæ¿å
+¥åã®ã»ã«ã®ã¢ã­ã±ã¼ã¿ãçµåãã¦ãã¾ã
+      end
+    elsif @definition == nil then
+      cdl_error( "S1117 \'$1\' not in celltype", @name )
+    else
+      raise "UnknownToken"
+    end
+  end
+
+  #=== Join# å¤æ°ã®åæåãã§ãã¯
+  def check_var_init
+    # attribute, var ã®å ´å
+    if @definition.get_kind == :ATTRIBUTE then
+#        check_cell_cb_init( definition.get_type, @rhs )
+      # å³è¾ºã§åæåå¯è½ããã§ãã¯
+      @definition.get_type.check_init( @locale, @definition.get_identifier, @rhs, :ATTRIBUTE )
+    elsif @definition.get_kind == :VAR then
+      # var ã¯åæåã§ããªã
+      cdl_error( "S1100 $1: cannot initialize var" , @name )
+    else
+      # Bug trap
+      raise "UnknownDeclKind"
+    end
+  end
+
+  #=== Join# å¼ã³å£ã®åæåãã§ãã¯
+  def check_call_port_init
+    ### Port
+
+    # å·¦è¾ºã¯åãå£ãï¼åãå£ãåæåãããã¨ãã¦ããï¼ï¼
+    if @definition.get_port_type == :ENTRY then
+      cdl_error( "S1101 \'$1\' cannot initialize entry port" , @name )
+      return
+    end
+
+#      # é
+åæ·»æ°ã®æ´åæ§ãã§ãã¯
+#      # å¼ã³å£ã®å®ç¾©ã§ãéé
+åãªãæ·»æ°ãªããæ·»æ°ãªãé
+åãªãæ·»æ°ãªããæ·»æ°ããé
+åãªãæ·»æ°ãã
+    as = @definition.get_array_size
+    if ( @subscript == nil && as != nil ) then
+      cdl_error( "S1102 $1: must specify array subscript here" , @name )
+    elsif ( @subscript != nil && as == nil ) then
+      cdl_error( "S1103 $1: cannot specify array subscript here" , @name )
+    end
+#    if @subscript == nil then
+#      if as != nil then
+#        cdl_error( "S1103 $1: need array subscript" , @name )
+#      end
+#    elsif @subscript == -1 then
+#      if as != "[]" then
+#        cdl_error( "S1104 $1: need array subscript number. ex. \'[0]\'" , @name )
+#      end
+#    else # @subscript >0
+#      if as == nil then
+#        cdl_error( "S1105 $1: cannot specify array subscript here" , @name )
+#      elsif as == "[]" then
+#        cdl_error( "S1106 $1: cannot specify array subscript number. use \'[]\'" , @name )
+#      end
+#    end
+
+    # mikan Expression ã® get_type ã§åå°åºãããæ¹ãã¹ãã¼ã
+    # mikan '=' ã®å·¦è¾ºãé
+åãã©ããæªãã§ãã¯
+    #(1) '=' ã®å³è¾ºã¯ "Cell.ePort" ã®å½¢å¼ãï¼
+    #     æ¼ç®å­ã¯ "."  ãã¤ "." ã®å·¦è¾ºã :IDENTIFIER
+    #     "." ã®å³è¾ºã¯ãã§ãã¯ä¸è¦ (synatax çã« :IDENTIFIER)
+    #(2) "Cell" ã¯å­å¨ãããï¼ï¼ååãä¸è´ãããã®ã¯ãããï¼
+    #(3) "Cell" ã¯ cell ãï¼
+    #(4) "Cell" ã® celltype ã¯æå¹ãï¼ (ç¡å¹ãªãæ¢ã«ã¨ã©ã¼ï¼
+    #(5) "ePort" ã¯ "Cell" ã® celltype å
+ã«å­å¨ãããï¼
+    #(6) "ePort" ã¯ entry port ãï¼
+    #(7) signature ã¯ä¸è´ããã
+
+    # å³è¾ºããªãï¼ä»¥åã®æ®µéã§ã¨ã©ã¼ï¼
+    return unless @rhs
+
+    # cCall = composite.cCall; ã®ãã§ãã¯ï¼ãã®å½¢å¼ã¯å±æ§ç¨
+    # å¼ã³å£ã export ããã«ã¯ cCall => composite.cCall; ã®å½¢å¼ãç¨ãã
+    if @rhs.instance_of?( Array ) == true && @rhs[0] == :COMPOSITE then
+      cdl_error( "S1107 to export port, use \'cCall => composite.cCall\'"  )
+      return
+    elsif ! @rhs.instance_of?( Expression ) then
+      raise "Unknown bug. specify -t to find problem in source"
+    end
+
+    # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã
+    ret = @rhs.analyze_cell_join_expression
+    if ret == nil then   #1
+      cdl_error( "S1108 $1: rhs not \'Cell.ePort\' form" , @name )
+      return
+    end
+
+    nsp, @rhs_subscript, @port_name = ret[0], ret[1], ret[2]
+    @cell_name = nsp.get_name     # mikan ns::cellname ã®å½¢å¼ã®èæ
+®
+
+    # composite ã®å®ç¾©ã®ä¸­ãªã object ã¯çµåå
+ cell ããè¦ã¤ãããªããã° nil ãè¿ã
+    # composite ã®å®ç¾©å¤ãªã false ãè¿ã
+    object = CompositeCelltype.find( @cell_name )
+    if object == false then
+#     mikan å·¦è¾ºã namespace ã«å¯¾å¿ãã¦ããªãããã path ã«ãã¦ find
+      # p nsp.get_path_str, nsp.get_path
+      object = Namespace.find( nsp )    #1
+      in_composite = false
+    else
+      if nsp.get_path.length != 1 then
+        cdl_error( "$1 cannot have path", nsp.get_path_str )
+      end
+      in_composite = true
+    end
+
+    if object == nil then                                             # (2)
+      cdl_error( "S1109 \'$1\' not found" , @cell_name )
+    elsif ! object.instance_of?( Cell ) then                          # (3)
+      cdl_error( "S1110 \'$1\' not cell" , @cell_name )
+    else
+      dbgPrint "set_definition: set_f_ref #{@owner.get_name}.#{@name} => #{object.get_name}\n"
+      object.set_f_ref
+
+      # å³è¾ºã®ã»ã«ã®ã»ã«ã¿ã¤ã
+      celltype = object.get_celltype
+
+      if celltype then                                                # (4)
+        object2 = celltype.find( @port_name )
+        if object2 == nil then                                        # (5)
+          cdl_error( "S1111 \'$1\' not found" , @port_name )
+        elsif ! object2.instance_of? Port \
+             || object2.get_port_type != :ENTRY then                  # (6)
+          cdl_error( "S1112 \'$1\' not entry port" , @port_name )
+        elsif @definition.get_signature != object2.get_signature then # (7)
+          cdl_error( "S1113 \'$1\' signature mismatch" , @port_name )
+        elsif object2.get_array_size then
+          # åãå£é
+å
+
+          unless @rhs_subscript then
+            # å³è¾ºã«æ·»æ°æå®ããªãã£ã
+            cdl_error( "S1114 \'$1\' should be array" , @port_name )
+          else
+
+            as = object2.get_array_size
+            if( as.kind_of?( Integer ) && as <= @rhs_subscript )then
+              # åãå£é
+åã®å¤§ããã«å¯¾ããå³è¾ºã®æ·»æ°ãåããå¤§ãã
+              cdl_error( "S1115 $1[$2]: subscript out of range (< $3)" , @port_name, @rhs_subscript, as )
+            else
+              dbgPrint "Join OK #{@owner.get_name}.#{@name}[#{@rhs_subscript}] = #{object.get_name}.#{@port_name} #{self}\n"
+              @cell = object
+              @celltype = celltype
+              @port = object2
+              # å³è¾ºã®ã»ã«ã®åãå£ object2 ãåç
+§æ¸ã¿ã«ãã
+              # object2: Port, @definition: Port
+              @cell.set_entry_port_max_subscript( @port, @rhs_subscript )
+            end
+
+            # debug
+            dbgPrint "Join set_definition: rhs: #{@cell}  #{@cell.get_name if @cell}\n"
+
+          end
+        elsif @rhs_subscript then
+          # åãå£é
+åã§ãªãã®ã«å³è¾ºã§æ·»æ°æå®ããã¦ãã
+          cdl_error( "S1116 \'$1\' entry port is not array" , @port_name )
+        else
+          dbgPrint "Join OK #{@owner.get_name}.#{@name} = #{object.get_name}.#{@port_name} #{self}\n"
+          @cell = object
+          @port = object2
+          @celltype = celltype
+
+          # å³è¾ºã®ã»ã« object ã®åãå£ object2 ãåç
+§æ¸ã¿ã«ãã
+          # object2: Port, @definition: Port
+
+          # debug
+          # p "rhs:  #{@cell}  #{@cell.get_name}"
+        end  # end of port (object2) ãã§ãã¯
+
+        #else
+        #  celltype == nil (ãã§ã«ã¨ã©ã¼)
+      end  # end of celltyep ãã§ãã¯
+
+
+      check_region( object )
+
+    end  # end of cell (object) ãã§ãã¯
+
+  end
+
+  #=== Join# ã¢ã­ã±ã¼ã¿ã®çµåãçæ
+  # STAGE: S
+  #cell::  å¼ã³å£ã®çµåå
+ã®ã»ã«
+  #
+  # ããã§ã¯å¼ã³å£å´ã«çæãããã¢ã­ã±ã¼ã¿å¼ã³å£ã®çµåãçæ
+  # åãå£å´ã¯ Cell ã® set_specifier_list ã§çæ
+  #  a[*] ã®å
+å®¹ã¯ Cell ã® set_specifier_list ãåç
+§
+  def create_allocator_join
+
+    cell = get_rhs_cell2   # å³è¾ºã®ã»ã«ãå¾ã
+    port = get_rhs_port2
+
+    if( cell && cell.get_allocator_list ) then      # cell == nil ãªãæ¢ã«ã¨ã©ã¼
+
+      dbgPrint "create_allocator_join: #{@owner.get_name}.#{@name}=>#{cell ? cell.get_name : "nil"}\n"
+
+      cell.get_allocator_list.each { |a|
+
+        if( a[0+1] == port && a[1+1] == @rhs_subscript )then
+          # ååã®ä¸è´ãããã®ã®çµåãçæãã
+          # éä¸è¶³ã¯ãå¥éãã§ãã¯ããã
+          cp_name = :"#{@name}_#{a[2+1]}_#{a[3+1]}"
+          # p "creating allocator join #{cp_name} #{@subscript} #{a[1+1]}"
+          join = Join.new( cp_name, @subscript, a[4+1], @locale )
+
+          #debug
+          dbgPrint "create_allocator_join: #{@owner.get_name}.#{cp_name} [#{@subscript}] #{@name}\n"
+          @owner.new_join join
+        else
+          dbgPrint "create_allocator_join:3 not #{@owner.get_name}.#{a[0+1]} #{@name}\n"
+        end
+      }
+    end
+  end
+
+  #=== Join# ãªã¼ã¸ã§ã³éã®çµåããã§ãã¯
+  # ãªã¼ã¸ã§ã³éã® through ã«ãã @region_through_list ã®ä½æ
+  # å®éã®çæã¯ check_and_gen_through ã§è¡ã
+  # mikan Cell#distance ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å
+±éé¨åãå¤ã
+  def check_region( object )
+
+    #debug
+    dbgPrint "check_region #{@owner.get_name}.#{@name} => #{object.get_name}\n"
+    # print "DOMAIN: check_region #{@owner.get_name}.#{@name} => #{object.get_name}\n"
+
+    # ãã©ã°ã¤ã³ã§çæããããªãã§ã¯çæããªã
+    # ãããªãã¨ãã©ã°ã¤ã³çæããããã®ã¨ã®éã§ãç¡éã«çæããã
+##    if Generator.get_nest >= 1 then
+##    if Generator.get_plugin then     # mikan ããã¯å¿
+è¦ï¼ (æå³è§£ææ®µéã§ã®å®è¡ã«ãªãã®ã§ä¸é©å)
+    if @owner.get_plugin.kind_of?( ThroughPlugin ) then
+      # ãã©ã°ã¤ã³çæãããã»ã«ã®å ´åãçµåãã§ãã¯ã®ã¿
+      return
+    end
+
+    # region ã®ãã§ãã¯
+    r1 = @owner.get_region      # å¼ã³å£ã»ã«ã® region
+    r2 = object.get_region      # åãå£ã»ã«ã® region
+
+    if ! r1.equal? r2 then      # åä¸ region ãªãå¼åºãå¯è½
+
+      f1 = r1.get_family_line
+      len1 = f1.length
+      f2 = r2.get_family_line
+      len2 = f2.length
+
+      # ä¸ä¸è´ã«ãªãã¨ããï¼å
+å¼ï¼ãæ¢ã
+      i = 1  # i = 0 ã¯ :RootRegion ãªã®ã§å¿
+ãä¸è´
+      while( i < len1 && i < len2 )
+        if( f1[i] != f2[i] )then
+          break
+        end
+        i += 1
+      end
+
+      sibling_level = i     # å
+å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã«
+
+      dbgPrint "sibling_level: #{i}\n"
+      dbgPrint "from: #{f1[i].get_name}\n" if f1[i]
+      dbgPrint "to: #{f2[i].get_name}\n" if f2[i]
+
+      if f1[sibling_level] && f2[sibling_level] then
+        b_to_through = true
+      else
+        b_to_through = false
+      end
+
+
+      # å¼ã³å´ã«ã¤ãã¦å¼ã³å
+ã®ã¬ãã«ããå
+å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      i = len1 -1
+      if b_to_through then
+        end_level = sibling_level
+      else
+        end_level = sibling_level - 1
+      end
+      while i > end_level
+      # while i > sibling_level
+      # while i >= sibling_level
+        dbgPrint "going out from #{f1[i].get_name} level=#{i}\n"
+        region_count = f1[i].next_out_through_count
+        out_through_list = f1[i].get_out_through_list   # [ plugin_name, plugin_arg ]
+        domain = f1[i].get_domain_type
+        if domain then
+          domain_through = f1[i].get_domain_type.add_through_plugin( self, f1[i], f1[i-1], :OUT_THROUGH )
+          if domain_through == nil then
+            cdl_error( "S9999 $1: going out from regin '$2' not permitted by domain '$3'" , @name, f1[i].get_name, f1[i].get_domain_type.get_name )
+          end
+        elsif out_through_list.length == 0 then
+          cdl_error( "S1118 $1: going out from region \'$2\' not permitted" , @name, f1[i].get_name )
+        end
+
+        out_through_list.each { |ol|
+          if ol[0] then    # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã
+            plugin_arg = CDLString.remove_dquote ol[1]
+            through = [ ol[0], :"Join_out_through_", plugin_arg, f1[i], f1[i-1], :OUT_THROUGH, region_count]
+            @region_through_list << through
+          end
+        }
+        if domain_through && domain_through.length > 0 then
+          through = [ domain_through[0], :"Join_domain_out_through_", domain_through[1], f1[i], f1[i-1], :OUT_THROUGH, region_count ]
+          @region_through_list << through
+        end
+        i -= 1
+      end
+
+      # å
+å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      if f1[sibling_level] && f2[sibling_level] then
+        dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n"
+        found = 0
+        region_count = f1[i].next_to_through_count( f2[sibling_level].get_name )   # to_through ã® region ã«ã¦ã³ã
+        f1[sibling_level].get_to_through_list.each { |t|
+          if t[0][0] == f2[sibling_level].get_name then   # region åãä¸è´ããã ?
+            if t[1] then    # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã
+              plugin_arg = CDLString.remove_dquote t[2]
+              through = [ t[1], :"Join_to_through__", plugin_arg, f1[sibling_level], f2[sibling_level], :TO_THROUGH, region_count ]
+              @region_through_list << through
+            end
+            found = 1
+          end
+        }
+        domain = f1[sibling_level].get_domain_type
+        if domain then
+          domain_through = f1[sibling_level].get_domain_type.add_through_plugin( self, f1[sibling_level], f2[sibling_level], :TO_THROUGH )
+          if domain_through == nil then
+            cdl_error( "S9999 $1: going from regin '$2' not permitted by domain'$3'" , @name, f1[sibling_level].get_name, f2[sibling_level].get_domain_type.get_name )
+          end
+          if domain_through && domain_through.length > 0 then
+            through = [ domain_through[0], :"Join_domain_to_through_", domain_through[1], f1[sibling_level], f2[sibling_level], :TO_THROUGH, region_count ]
+            @region_through_list << through
+          end
+        elsif found == 0 then
+          cdl_error( "S1119 $1: going from region \'$2\' to \'$3\' not permitted" , @name, f1[sibling_level].get_name, f2[sibling_level].get_name )
+        end
+      end
+
+      # åãå´ã«ã¤ãã¦å
+å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      if b_to_through then
+        i = sibling_level + 1      # to_through ãçµãå ´åãæåã® in_through ã¯é©ç¨ããªã
+      else
+        i = sibling_level
+      end
+      while i < len2
+        dbgPrint "going in to #{f2[i].get_name} level=#{i}\n"
+        region_count = f2[i].next_in_through_count
+        in_through_list = f2[i].get_in_through_list   # [ plugin_name, plugin_arg ]
+        domain = f2[i].get_domain_type
+        if domain then
+          domain_through = f2[i].get_domain_type.add_through_plugin( self, f2[i-1], f2[i], :IN_THROUGH )
+          if domain_through == nil then
+            cdl_error( "S9999 $1: going in from regin '$2' to '$3' not permitted by domain '$4'",
+                        @name, f2[i-1].get_name, f2[i].get_name, f2[i].get_domain_type.get_name )
+          end
+          if domain_through && domain_through.length > 0 then
+            through = [ domain_through[0], :"Join_domain_in_through_", domain_through[1], f2[i-1], f2[i], :IN_THROUGH, region_count ]
+            @region_through_list << through
+          end
+        elsif in_through_list.length == 0 then
+          cdl_error( "S1120 $1: going in to region \'$2\' not permitted" , @name, f2[i].get_name )
+        end
+        in_through_list.each { |il|
+          if il[0] then    # plugin_name ãæå®ããã¦ããªããã°ç»é²ããªã
+            plugin_arg = CDLString.remove_dquote il[1]
+            through = [ il[0], :"Join_in_through_", plugin_arg, f2[i-1], f2[i],:IN_THROUGH, region_count ]
+            @region_through_list << through
+          end
+        }
+        i += 1
+      end
+
+    end
+  end
+
+
+  #=== Join# çæããªããªã¼ã¸ã§ã³ã¸ã®çµåããã§ãã¯
+  # å³è¾ºã®ã»ã«ããçæãããªããªã¼ã¸ã§ã³ã«ããã°ã¨ã©ã¼
+  # å³è¾ºã¯ããã©ã°ã¤ã³çæãããã»ã«ãããã°ããããå¯¾è±¡ã¨ãã
+  def check_region2
+    lhs_cell = @owner
+
+    # çæããªããªã¼ã¸ã§ã³ã®ã»ã«ã¸ã®çµåãï¼
+    # if join.get_cell && ! join.get_cell.is_generate? then
+    # if get_rhs_cell && ! get_rhs_cell.is_generate? then # composite ã»ã«ããã­ã¿ã¤ãå®£è¨ã®å ´åä¾å¤
+    # print "Link root: (caller #{@owner.get_name}) '#{@owner.get_region.get_link_root.get_name}'"
+    # print " #{@owner.get_region.get_link_root == get_rhs_region.get_link_root ? "==" : "!="} "
+    # print "'#{get_rhs_region.get_link_root.get_name}'  (callee #{@cell_name})\n"
+
+    if get_rhs_region then
+      dbgPrint "check_region2 #{lhs_cell.get_name} => #{get_rhs_region.get_path_string}#{@rhs.to_s}\n"
+
+      # if get_rhs_region.is_generate? != true then  #3
+      if @owner.get_region.get_link_root != get_rhs_region.get_link_root then
+        cdl_error( "S1121 \'$1\' in region \'$2\' cannot be directly joined $3 in  $4" , lhs_cell.get_name, lhs_cell.get_region.get_namespace_path.get_path_str, @rhs.to_s, get_rhs_region.get_namespace_path.get_path_str )
+      end
+    else
+      # rhs ã®ã»ã«ãå­å¨ããªãã£ã (æ¢ã«ã¨ã©ã¼)
+    end
+  end
+
+  def get_definition
+    @definition
+  end
+
+  #=== Join# specifier ãè¨­å®
+  # STAGE: B
+  # set_specifier_list ã¯ãjoin ã®è§£æã®æå¾ã§å¼ã³åºããã
+  # through æå®å­ãè¨­å®
+  #  check_and_gen_through ãå¼åºãã¦ãthrough çæ
+  def set_specifier_list( specifier_list )
+
+    specifier_list.each { |s|
+      case s[0]
+      when :THROUGH
+        # set plugin_name
+        plugin_name = s[1].to_s
+        plugin_name[0] = "#{plugin_name[/^./].upcase}"     # å
+é ­æå­ãå¤§æå­ã« : ruby ã®ã¯ã©ã¹åã®å¶ç´
+
+        # set cell_name
+        cell_name = :"#{s[1].to_s}_"
+
+        # set plugin_arg
+        plugin_arg = CDLString.remove_dquote s[2].to_s
+        # plugin_arg = s[2].to_s.gsub( /\A"(.*)/, '\1' )   # åå¾ã® "" ãåãé¤ã
+        # plugin_arg.sub!( /(.*)"\z/, '\1' )
+
+        @cp_through_list << [ plugin_name, cell_name, plugin_arg ]
+      end
+    }
+
+  end
+
+  #=== Join# through ã®ãã§ãã¯ã¨çæ
+  # new_join ã®ä¸­ã® check_region ã§ region éã® through ã @region_through ã«è¨­å®ããã
+  # set_specifier ã§å¼ã³å£ã®çµåã§æå®ããã through ã @cp_through è¨­å®ããã
+  # ãã®å¾ããã®ã¡ã½ãããå¼ã°ãã
+  def check_and_gen_through
+
+    dbgPrint "check_and_gen_through #{@owner.get_name}.#{@name}\n"
+
+    if ! @definition.instance_of? Port then
+      cdl_error( "S1123 $1 : not port: \'through\' can be specified only for port" , @name )
+      return
+    end
+    if @cp_through_list.length > 0 then
+      # is_empty? must check before is_omit?
+      if @definition.get_signature && @definition.get_signature.is_empty? then
+        cdl_warning( "W9999 'through' is specified for empty signature, ignored"  )
+        return
+      elsif @definition.is_omit? then
+        cdl_warning( "W9999 'through' is specified for omitted port, ignored"  )
+        return
+      end
+    end
+
+    @through_list = @cp_through_list + @region_through_list
+      # å¾ãã @cp_through_list ã¨ @region_through_list ã«åããããããã®ãããªå®è£
+ã«ãªã£ã
+
+    if @through_list then           # nil when the join is not Port
+      len = @through_list.length    # through ãé£æ¥ãã¦ããæ°
+    else
+      len = 0
+    end
+    cp_len = @cp_through_list.length
+
+    if @owner.is_in_composite? && len > 0 then
+      cdl_error( "S1177 cannot specify 'through' in composite in current version" )
+      return
+    end
+
+    # é£ç¶ãã through ã«ã¤ãã¦ãåãå£å´ããé ã«ã»ã«ãçæãè§£éãã
+    i = len - 1
+    while i >= 0
+
+      through = @through_list[ i ]
+      plugin_name           = through[ 0 ]
+      generating_cell_name  = through[ 1 ]
+      plugin_arg            = through[ 2 ]
+
+      if i != len - 1 then
+
+        begin
+          next_cell_nsp       = @through_generated_list[ i + 1 ].get_cell_namespace_path
+          next_port_name      = @through_generated_list[ i + 1 ].get_through_entry_port_name
+        rescue Exception => evar
+          cdl_error( "S1124 $1: plugin function failed: \'get_through_entry_port_name\'" , plugin_name )
+          print_exception( evar )
+          i -= 1
+          next
+        end
+
+        next_cell = Namespace.find( next_cell_nsp )    #1
+        if next_cell == nil then
+          # p "next_cell_path: #{next_cell_nsp.get_path_str}"
+          cdl_error( "S1125 $1: not generated cell \'$2\'" , @through_generated_list[ i + 1 ].class, next_cell_nsp.get_path_str )
+          return
+        end
+
+      else
+        # æå¾ã®ã»ã«ã®å ´åãæ¬¡ã®ã»ã«ã®ååããã¼ãå
+        next_cell      = @cell
+        next_port_name = @port_name
+
+        if next_cell == nil then
+          # çµåå
+ããªã
+          return
+        end
+      end
+
+      if i >= cp_len then
+        # region_through_list é¨å
+        # region ãã @cell_name.@port_name ã¸ã® through ããªããæ¢ã
+        # rp = @through_list[i][3].find_cell_port_through_plugin( @cell_name, @port_name ) #762
+        rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name )
+           # @through_list[i] ã¨ @region_through_list[i-cp_len] ã¯åã
+        # å
+±ç¨ããªãããã«ããã«ã¯ãè¦ã¤ãããªãã£ããã¨ã«ããã°ãã
+        # rp = nil
+      else
+        # region ä»¥å¤ã®ãã®ã¯å
+±æããªã
+        # å¼ã³å£å´ã«æå®ããã¦ããããplugin_arg ãç°ãªããããããªã
+        rp = nil
+      end
+
+      if rp == nil then
+        if( load_plugin( plugin_name, ThroughPlugin ) ) then
+          gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name )
+        end
+      else
+        # è¦ã¤ãã£ããã®ãå
+±ç¨ãã
+        @through_generated_list[ i ] = rp
+      end
+
+      if i >= cp_len then
+        # @through_generated_list ã®ãã¡ @region_through_listã«å¯¾å¿ããé¨å
+        @region_through_generated_list[ i - cp_len ] = @through_generated_list[ i ]
+        if rp == nil then
+          # çæãããã®ã region(@through_list[i][3]) ã®ãªã¹ãã«è¿½å 
+          # @through_list[i][3].add_cell_port_through_plugin( @cell_name, @port_name, @through_generated_list[i] ) #762
+          @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @through_generated_list[i] )
+        end
+      end
+
+      if i == 0 then
+        # æãå¼ã³å£å´ã®ã»ã«ã¯ãCDL ä¸ã®çµåããªããããåç
+§ããããã¨ã«ãªããªã
+        # mikan namespace å¯¾å¿
+        # cell = Namespace.find( [ @through_generated_list[0].get_cell_name] )    #1
+        if @through_generated_list[0] == nil then
+          return  # plugin_object ã®çæã«å¤±æãã¦ãã
+        end
+        cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+        if cell.instance_of? Cell then
+          cell.set_f_ref
+        end
+      end
+
+      i -= 1
+    end
+
+  end
+
+  @@through_count = { }
+  def get_through_count name
+    sym = name.to_sym
+    if @@through_count[ sym ] then
+      @@through_count[ sym ] += 1
+    else
+      @@through_count[ sym ] = 0
+    end
+    return @@through_count[ sym ]
+  end
+
+  #=== Join# through ãã©ã°ã¤ã³ãå¼ã³åºãã¦ CDL çæãããã¨ã¨ãã«ãimport ãã
+  def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name )
+
+    through = @through_list[ i ]
+    plugin_name           = through[ 0 ]
+    generating_cell_name  = :"#{through[ 1 ]}_#{get_through_count through[ 1 ]}"
+    plugin_arg            = through[ 2 ]
+    if through[ 3 ] then
+      # region éã® through ã®å ´å
+      @@start_region      = through[ 3 ]
+      if next_cell.get_region.equal? @@start_region then
+        @@end_region      = @@start_region
+      else
+        @@end_region      = through[ 4 ]
+      end
+      @@through_type      = through[ 5 ]
+      @@region_count      = through[ 6 ]
+    else
+      # å¼ã³å£ã® through ã®å ´å
+      @@start_region      = @owner.get_region    # å¼ã³å£å´ã»ã«ã® region
+      @@end_region        = next_cell.get_region # æ¬¡ã®ã»ã«ã® region
+      @@through_type      = :THROUGH             # å¼ã³å£ã® through æå®
+      @@region_count      = 0
+    end
+    @@plugin_creating_join = self
+
+    caller_cell = @owner
+
+    plugin_object = nil
+    eval_str = "plugin_object = #{plugin_name}.new( '#{generating_cell_name}'.to_sym, plugin_arg.to_s, next_cell, '#{next_port_name}'.to_sym, @definition.get_signature, @celltype, caller_cell )"
+    if $verbose then
+      print "new through: #{eval_str}\n"
+    end
+
+    begin
+      eval( eval_str )     # plugin ãçæ
+      plugin_object.set_locale @locale
+    rescue Exception => evar
+      cdl_error( "S1126 $1: fail to new" , plugin_name )
+      if @celltype && @definition.get_signature && caller_cell && next_cell then
+        print "signature: #{@definition.get_signature.get_name} from: #{caller_cell.get_name} to: #{next_cell.get_name} of celltype: #{@celltype.get_name}\n"
+      end
+      print "eval( #{eval_str} )\n"
+
+      print_exception( evar )
+      return 
+    end
+
+    @through_generated_list[ i ] = plugin_object
+
+    # Region ã«é¢ããæ
+å ±ãè¨­å®
+    # å¾ããè¿½å ããã®ã§ãnew ã®å¼æ°å¤ã§è¨­å®
+    # plugin_object.set_through_info( start_region, end_region, through_type )
+
+    generate_and_parse plugin_object
+  end
+
+  #ãã©ã°ã¤ã³ã¸ã®å¼æ°ã§æ¸¡ããªããã®ããä¸æçã«è¨æ¶ãã¦ãã
+  # ãã©ã°ã¤ã³ã® initialize ã®ä¸­ã§ã³ã¼ã«ããã¯ãã¦è¨­å®ãã
+  @@plugin_creating_join = nil
+  @@start_region = nil
+  @@end_region = nil
+  @@through_type = nil
+  @@region_count = nil
+
+  #=== Join# ThroughPlugin ã®è¿½å æ
+å ±ãè¨­å®ãã
+  # ãã®ã¡ã½ããã¯ ThroughPlugin#initialize ããå¼ã³åºããã
+  # plugin_object ãçæããéã®å¼æ°ã§ã¯ä¸è¶³ããæ
+å ±ãè¿½å ãã
+  def self.set_through_info plugin_object
+    plugin_object.set_through_info( @@start_region, @@end_region, @@through_type,
+                                    @@plugin_creating_join,
+                                    @@plugin_creating_join.get_cell,
+                                    @@region_count )
+  end
+
+  def get_name
+    @name
+  end
+
+  #=== Join#é
+åæ·»æ°ãå¾ã
+  # @subscript ã®èª¬æãåç
+§ã®ãã¨
+  def get_subscript
+    @subscript
+  end
+
+  def get_cell_name         # åãå£ã»ã«å
+    @cell_name
+  end
+
+  def get_celltype
+    @celltype
+  end
+
+  def get_cell
+    @cell
+  end
+
+  #=== Join# å³è¾ºã®å®ã»ã«ãå¾ã
+  #    å®ã»ã«ã¨ã¯ through ã§æ¿å
+¥ããããã®ãcomposite ã®å
+é¨ãªã©å®éã«çµåãããå
+
+  #    ãã®ã¡ã½ããã¯ãget_rhs_port ã¨å¯¾ã«ãªã£ã¦ãã
+  #    ãã®ã¡ã½ããã¯ãæå³è§£ææ®µéã§ã¯å¼ã³åºãã¦ã¯ãªããªã (å¯¾è±¡ã»ã«ã®æå³è§£æãæ¸ãåã«ã¯æ­£ããçµæãè¿ããªã)
+  def get_rhs_cell
+    # through æå®ããï¼
+    if @through_list[0] then
+      # mikan through ã§çæãããã®ã root namespace éå®
+      if @through_generated_list[0] then
+        # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
+        cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+        # cell ã nil ã«ãªãã®ã¯ãã©ã°ã¤ã³ã® get_cell_namespace_path ãæ­£ãããªããã
+        # ãã©ã°ã¤ã³çæã³ã¼ããã¨ã©ã¼ã«ãªã£ã¦ããã
+        # ã§ãã®æªããã©ã°ã¤ã³ãå¤ããã°ãcell == nil ãã¯ãããæ¹ãããã
+        return cell.get_real_cell( @through_generated_list[0].get_through_entry_port_name )
+      else
+        return nil            # generate ã«å¤±æãã¦ãã
+      end
+    elsif @cell then
+      return @cell.get_real_cell( @port_name )
+    else
+      # å³è¾ºãæªå®ç¾©ã®å ´å @cell ã¯ nil (æ¢ã«ã¨ã©ã¼)
+      return nil
+    end
+  end
+
+  #=== Join# å³è¾ºã®ã»ã«ãå¾ã
+  # å³è¾ºã®ã»ã«ãå¾ãããã ããcomposite å±éããã¦ããªã
+  # composite å±éããããã®ãå¾ãã«ã¯ get_rhs_cell ãä½¿ã
+  # ãã­ãã¿ã¤ãå®£è¨ããããã¦ããªãå ´åã«ã¯ããã¡ãããä½¿ããªã
+  # ãã®ã¡ã½ããã¯ get_rhs_port2 ã¨å¯¾ã«ãªã£ã¦ãã
+  def get_rhs_cell2
+    # through æå®ããï¼
+    if @through_list[0] then
+      # mikan through ã§çæãããã®ã root namespace éå®
+      # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name ] )
+      if @through_generated_list[0] then
+        # cell = Namespace.find( [ @through_generated_list[0].get_cell_name ] )    #1
+        cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+      else
+        cell = @cell            # generate ã«å¤±æãã¦ãã
+      end
+    else
+      cell = @cell
+    end
+
+    return cell
+  end
+
+  #=== Join# å³è¾ºã®ã»ã«ãå¾ã
+  # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«
+  # (æå³è§£æãçµãã£ã¦ããªãã¨ãcomposite å±éãçµãã£ã¦ããªã)
+  # ãã®ã¡ã½ããã¯ get_rhs_port3 ã¨å¯¾ã«ãªã£ã¦ãã
+  def get_rhs_cell3
+    if @cell then
+      return @cell.get_real_cell( @port_name )
+    end
+  end
+
+  #=== Join# å³è¾ºã®ã»ã«ã®ãªã¼ã¸ã§ã³ãå¾ã
+  # å³è¾ºãæªå®ç¾©ã®å ´åãnil ãè¿ã
+  # composite ã®å ´åãå®ã»ã«ã§ã¯ãªã composite cell ã® region ãè¿ã(composite ã¯ãã¹ã¦åã region ã«å±ãã)
+  # composite ã® cell ããã­ãã¿ã¤ãå®£è¨ããã¦ããã¨ã get_rhs_cell/get_real_cell ã¯ ruby ã®ä¾å¤ã¨ãªã
+  def get_rhs_region
+    # through æå®ããï¼
+    if @through_list[0] then
+      if @through_generated_list[0] then
+        # mikan through ã§çæãããã®ã root namespace éå®
+        # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
+        cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+        if cell then
+          return cell.get_region
+        end
+      else
+        return nil       # generate ã«å¤±æãã¦ãã
+      end
+    elsif @cell then
+      return @cell.get_region
+    end
+    # å³è¾ºãæªå®ç¾©ã®å ´å @cell ã¯ nil (æ¢ã«ã¨ã©ã¼)
+    return nil
+  end
+
+  def get_cell_global_name  # åãå£ã»ã«åï¼ã³ã³ãã¸ãããªãå±éããå
+å´ã®ã»ã«ï¼
+
+    # debug
+    dbgPrint "cell get_cell_global_name:  #{@cell_name}\n"
+    # @cell.show_tree( 1 )
+
+    if @cell then
+      return @cell.get_real_global_name( @port_name )
+    else
+      return "NonDefinedCell?"
+    end
+
+  end
+
+  #===  Join# çµåã®å³è¾ºã®åãå£ã®åå
+  #     namespace å + '_' + ã»ã«å + '_' + åãå£å   ï¼ãã®ã»ã«ã composite ãªãã°å±éå¾ã®ã»ã«åãåãå£åï¼
+  #subscript:: Integer  å¼ã³å£é
+åã®ææ·»æ° ã¾ãã¯ nil å¼ã³å£é
+åã§ãªãæ
+  def get_port_global_name( subscript = nil )  # åãå£åï¼ã³ã³ãã¸ãããªãå±éããå
+å´ã®ã»ã«ï¼
+
+    # debug
+    dbgPrint "Cell get_port_global_name:  #{@cell_name}\n"
+
+    # through æå®ããï¼
+    if @through_list[0] then
+
+      # mikan through ã§çæãããã®ã root namespace éå®
+      # cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
+      cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+
+      # through ã§æ¿å
+¥ãããã»ã«ã§ãå®éã«æ¥ç¶ãããã»ã«ï¼compositeã®å ´åå
+é¨ã®)ã®åãå£ã® C è¨èªåå
+      return cell.get_real_global_port_name( @through_generated_list[0].get_through_entry_port_name )
+    else
+
+      # å®éã«æ¥ç¶ãããã»ã«ã®åãå£ã® C è¨èªåå
+      if @cell then
+        return @cell.get_real_global_port_name( @port_name )
+      else
+        return "UndefinedCellsPort?"
+      end
+
+    end
+
+  end
+
+  def get_port_name
+    @port_name
+  end
+
+  def get_rhs
+    @rhs
+  end
+
+  def get_rhs_subscript
+    @rhs_subscript
+  end
+
+  #=== Join# å³è¾ºã®ãã¼ããå¾ã
+  #    å³è¾ºã composite ã®å ´åã¯ãå
+é¨ã®ç¹ããã»ã«ã®ãã¼ã, through ã®å ´åã¯æ¿å
+¥ãããã»ã«ã®ãã¼ã
+  #    ãã®ã¡ã½ããã¯ get_rhs_cell ã¨å¯¾ã«ãªã£ã¦ãã
+  def get_rhs_port
+    # through æå®ããï¼
+    if @through_list[0] then
+      # mikan through ã§çæãããã®ã root namespace éå®
+      # through ã§çæãããã»ã«ãæ¢ã
+#      cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
+      cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
+      # cell ã®ãã©ã°ã¤ã³ã§çæããããã¼ãåã®ãã¼ããæ¢ã (composite ãªãå
+é¨ã®ç¹ãããã¼ã)
+      return cell.get_real_port( @through_generated_list[0].get_through_entry_port_name )
+    else
+      # ãã¼ããè¿ã(composite ãªãå
+é¨ã®ç¹ãããã¼ããè¿ã)
+      return @cell.get_real_port( @port_name )
+    end
+  end
+
+  #=== Join# å³è¾ºã®ãã¼ããå¾ã
+  # å³è¾ºã®ãã¼ããå¾ãã
+  # ããã¯ãã­ãã¿ã¤ãå®£è¨ããããã¦ããªãå ´åã«ã¯ããã¡ãããä½¿ããªã
+  def get_rhs_port2
+    # through æå®ããï¼
+    if @through_list[0] then
+      if @through_generated_list[0] then
+        port = @through_generated_list[0].get_through_entry_port_name.to_sym
+      else
+        port = @port_name    # generate ã«å¤±æãã¦ãã
+      end
+    else
+      port = @port_name
+    end
+
+    return port
+  end
+
+  #=== Join# å³è¾ºã®ãã¼ããå¾ã
+  # through ã¯é©ç¨ããªãããcomposite ã¯å±éããå¾ã®ã»ã«ã®å¯¾å¿ãããã¼ã
+  def get_rhs_port3
+    if @cell then
+      return @cell.get_real_port( @port_name )
+    end
+  end
+
+  #=== Join# å¼ã³å£é
+åã®2çªç®ä»¥éã®è¦ç´ ãè¿½å ãã
+  #     ä¸çªæåã«å®ç¾©ãããé
+åè¦ç´ ãå
+¨è¦ç´ ã®åæå¤ã®é
+åãæã¤
+  #     ãã®ã¡ã½ããã¯éé
+åã®å ´åãå¼åºãããï¼join éè¤ã¨ã©ã¼ã®å ´åï¼
+  #join2:: Join  å¼ã³å£é
+åè¦ç´ ã® Join
+  def add_array_member join2
+
+    # subscript2: join2 ã®å·¦è¾ºæ·»æ°
+    subscript2 = join2.get_subscript
+
+    if @subscript == nil then		# not array : initialize duplicate
+      # éé
+åã®å ´åãjoin ãéè¤ãã¦ãã
+      cdl_error( "S1127 \'$1\' duplicate", @name )
+      # print "add_array_member2: #{@owner.get_name}\n"
+
+    elsif @subscript >= 0 then
+      # æ·»æ°æå®ããã®å ´å
+      if( subscript2 == nil || subscript2 < 0 ) then
+        # join2 å·¦è¾ºã¯éé
+åã¾ãã¯æ·»æ°ãªã
+        # é
+åãä¸ä¸è´
+        cdl_error( "S1128 \'$1\' inconsistent array definition", @name )
+      elsif @array_member[subscript2] != nil then
+        # åãæ·»æ°ãæ¢ã«å®ç¾©æ¸ã¿
+        cdl_error( "S1129 \'$1\' redefinition of subscript $2" ,@name, subscript2 )
+      else
+        # æ·»æ°ã®ä½ç½®ã«è¦ç´ ãè¿½å 
+        @array_member[subscript2] = join2.get_rhs
+        @array_member2[subscript2] = join2
+#        p "0:#{join2.get_rhs}"
+      end
+
+    else
+      # æ·»æ°æå®ãªãã®å ´å
+      if( subscript2 == nil || subscript2 >= 0 ) then
+        # join2 å·¦è¾ºã¯éé
+åã¾ãã¯æ·»æ°æ
+        # é
+åãä¸ä¸è´
+        cdl_error( "S1130 \'R1\' inconsistent array definition", @name )
+      end
+
+      # æ·»æ°ãªãé
+åã®å ´åãé
+åè¦ç´ ãè¿½å 
+      @array_member  << join2.get_rhs
+      @array_member2 << join2
+    end
+  end
+
+  def get_array_member
+    @array_member
+  end
+
+  def get_array_member2
+    @array_member2
+  end
+
+  def change_name name
+    # debug
+    dbgPrint "change_name: #{@name} to #{name}\n"
+
+    @name = name
+
+    if @array_member2 then
+      i = 0
+      while i < @array_member2.length
+        if @array_member2[i] != self && @array_member[i] != nil then
+          # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã
+          # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨­å®ããã¦ããå ´å
+          # ç¡é§ã«è¨­å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãåå¸°çã«å¼ã³åºãå¿
+è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾ç­ãã¦ããï¼
+          @array_member2[i].change_name( name )
+        end
+        i += 1
+      end
+    end
+  end
+
+  # composite cell ãå±éããã»ã«ã®çµåã clone ããã»ã«ã®ååã«å¤æ´
+  def change_rhs_port( clone_cell_list, celltype )
+
+    # debug
+    if $debug then
+      dbgPrint "change_rhs name: #{@name}  cell_name: #{@cell_name} #{@cell} #{self}\n"
+
+      clone_cell_list.each{ |cell, ce|
+        dbgPrint "change_rhs:  #{cell.get_name}=#{cell} : #{ce.get_name}\n"
+      }
+    end
+
+    c = clone_cell_list[@cell]
+    return if c == nil
+
+    # debug
+    dbgPrint "  cell_name:   #{@cell_name} => #{c.get_global_name}, #{c.get_name}\n"
+
+    # @rhs ã®å
+å®¹ãèª¿æ´ãã¦ããï¼ãã®å
+å®¹ã¯ãsubscript ãé¤ãã¦ãå¾ããä½¿ããã¦ããªãï¼
+    elements = @rhs.get_elements
+    if elements[0] == :OP_SUBSC then  # å³è¾ºï¼åãå£é
+åï¼
+      elements  = elements[1]
+    end
+
+    # å³è¾ºããcell.ePort ã®å½¢å¼ã§ãªã
+    if elements[0] != :OP_DOT || elements[1][0] != :IDENTIFIER then   #1
+      return
+    else
+      # ã»ã«åã composite å
+é¨ã®ååãããå¤é¨ã®ååã«å
+¥ãæ¿ãã
+      # elements[1][1] = Token.new( c.get_name, nil, nil, nil )
+      elements[1][1] = NamespacePath.new( c.get_name, false, c.get_namespace )
+    end
+
+    @cell_name = c.get_name
+    @cell = c
+    # @definition = nil          # @definition ãæå¹ï¼ ãã§ãã¯æ¸ã¿ï¼ã¨ã¯ãããªãï¼
+
+    if @array_member2 then
+
+      # debug
+      # p "array_member2.len : #{@array_member.length}"
+
+      i = 0
+      while i < @array_member2.length
+        # @array_member2[i] ã nil ã«ãªãã®ã¯ optional ã®æã¨ã
+        # Join ã® initialize ã§ç¡é§ã« @array_member2 ãè¨­å®ããã¦ããå ´å
+        # ç¡é§ã«è¨­å®ããã¦ãããã®ã«ã¤ãã¦ã¯ãåå¸°çã«å¼ã³åºãå¿
+è¦ã¯ãªãï¼clone_for_composite ã§ã¯å¯¾ç­ãã¦ããï¼
+        if @array_member2[i] != self && @array_member[i] != nil then
+          @array_member2[i].change_rhs_port( clone_cell_list, celltype )
+        end
+        i += 1
+      end
+    end
+
+  end
+
+  #=== Join# composite ã»ã«ç¨ã«ã¯ã­ã¼ã³
+  #cell_global_name:: string : è¦ªã»ã«ã®ã°ã­ã¼ãã«å
+  # å³è¾ºã® C_EXP ã«å«ã¾ãã $id$, $cell$, $ct$ ãç½®æ
+  # ããã§ç½®æããã®ã¯ composite ã® attribute ã® C_EXP ã composite ã»ã«ã¿ã¤ãããã³ã»ã«åã«ç½®æãããã
+  # ï¼å
+é¨ã»ã«ã® C_EXP ãããã§ç½®æãããï¼
+  # @through_list ãªã©ãã³ãã¼ãããã®ã§ããããå¼ã³åºãããåã«ç¢ºå®ããå¿
+è¦ããã
+  def clone_for_composite( ct_name, cell_name, locale, b_need_recursive = true )
+
+    # debug
+    dbgPrint "join.clone_for_composite : #{@name} #{@cell_name} #{self}\n"
+    cl = self.clone
+
+    if @array_member2 && b_need_recursive then
+      cl.clone_array_member( @array_member, @array_member2, ct_name, cell_name, self, locale )
+    end
+
+    rhs = CDLInitializer.clone_for_composite( @rhs, ct_name, cell_name, locale )
+    cl.change_rhs rhs
+
+    # debug
+    dbgPrint "join cloned : #{cl}\n"
+    return cl
+  end
+
+  def clone_array_member( array_member, array_member2, ct_name, cell_name, prev, locale )
+    # é
+åã®ã³ãã¼ãä½ã
+    am  = array_member.clone
+    am2 = array_member2.clone
+
+    # é
+åè¦ç´ ã®ã³ãã¼ãä½ã
+    i = 0
+    while i < am2.length
+      if array_member2[i] == prev then
+        # èªåèªèº«ã§ããï¼ã®ã§ãå¼åºãã¨ç¡éåå¸°å¼åºãã¨ãªãï¼
+        am2[i] = self
+      elsif array_member2[i] then
+        am2[i] = array_member2[i].clone_for_composite( ct_name, cell_name, locale, false )
+      else
+        # ä»¥åã®ã¨ã©ã¼ã§ array_member2[i] ã¯ nil ã«ãªã£ã¦ãã
+      end
+
+      # debug
+      dbgPrint "clone_array_member: #{@name} #{am2[i]} #{array_member2[i]}\n"
+
+      i += 1
+    end
+
+    # i = 0 ã¯ãããã§èªåèªèº«ãè¨­å®
+    # am2[0] = self
+
+    @array_member  = am
+    @array_member2 = am2
+
+  end
+
+  #=== Join# rhs ãå
+¥ãæãã
+  #rhs:: Expression | initializer
+  # å³è¾ºãå
+¥ãæããï¼
+  # ãã®ã¡ã½ããã¯ãcomposite ã§ cell ã®å±æ§ã®åæå¤ã attribute ã®å¤ã§ç½®ãæããã®ã«ä½¿ããã
+  # ãã®ã¡ã½ããã¯ composite å
+ã® cell ã®å±æ§ã®åæå¤ãå®æ°ã§ã¯ãªãå¼ã«ãªã£ãå ´åãä¸è¦ã«ãªã
+  def change_rhs rhs
+    @rhs = rhs
+  end
+
+  #=== Join# clone ããã join ã® owner ãå¤æ´
+  def set_cloned( owner )
+    dbgPrint "Join#set_cloned: #{@name}  prev owner: #{@owner.get_name} new owner: #{owner.get_name}\n"
+    @owner = owner
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Join: name: #{@name} owner: #{@owner.get_name} id: #{self}"
+    if @subscript == nil then
+    elsif @subscript >= 0 then
+      (indent+1).times { print "  " }
+      puts "subscript: #{@subscript}"
+    else
+      (indent+1).times { print "  " }
+      puts "subscript: not specified"
+    end
+    (indent+1).times { print "  " }
+    puts "rhs: "
+    if @rhs.instance_of?( Array )then
+      @rhs.each{ |i|
+        if i.instance_of?( Array )then
+          i.each{ |j|
+            j.show_tree( indent + 3 )
+          }
+        elsif i.instance_of? Symbol then
+          (indent+2).times { print "  " }
+          print i
+          print "\n"
+        else
+          i.show_tree( indent + 2 )
+        end
+      }
+    else
+      @rhs.show_tree( indent + 2 )
+      (indent+1).times { print "  " }
+      if @definition then
+        puts "definition:"
+        @definition.show_tree( indent + 2 )
+      else
+        puts "definition: not found"
+      end
+    end
+    if @definition.instance_of?( Port ) then
+      (indent+2).times { print "  " }
+      if @cell then
+        puts "cell: #{@cell_name} #{@cell}  port: #{@port_name}  cell_global_name: #{@cell.get_global_name}"
+      else
+        puts "cell: #{@cell_name} port: #{@port_name}  (cell not found)"
+      end
+    end
+    if @through_list then
+      i = 0
+      @through_list.each { |t|
+        (indent+2).times { print "  " }
+        puts "through: plugin name :  '#{t[0]}' arg : '#{t[2]}'"
+        if @through_generated_list[i] then
+          @through_generated_list[i].show_tree( indent+3 )
+        end
+        i += 1
+      }
+    end
+    if @array_member2 then
+      (indent+1).times { print "  " }
+      puts "array member:"
+      i = 0
+      @array_member2.each { |j|
+        if j then
+          (indent+2).times { print "  " }
+          puts "[#{i}]: #{j.get_name}  id: #{j}"
+          j.get_rhs.show_tree(indent+3)
+          (indent+3).times { print "  " }
+          puts "cell global name: #{j.get_cell_global_name}"
+          (indent+3).times { print "  " }
+          puts "port global name: #{j.get_port_global_name}"
+        else
+          (indent+2).times { print "  " }
+          puts "[#{i}]: [optional]  id: #{j}"
+        end
+        i += 1
+      }
+    end
+  end
+
+end
+
+#== éçµå
+class ReverseJoin < BDNode
+#@ep_name:: Symbol
+#@ep_subscript:: Expression or nil
+#@cell_nsp: NamespacePath
+#@cp_name:: Symbol
+#@cp_subscript:: Expression or nil
+  def initialize( ep_name, ep_subscript, cell_nsp, cp_name, cp_subscript = nil )
+    super()
+    @ep_name = ep_name
+    @ep_subscript = ep_subscript
+    @cell_nsp = cell_nsp
+    @cp_name = cp_name
+    @cp_subscript = cp_subscript
+  end
+
+  def get_name
+    @ep_name
+  end
+
+  def get_rhs_cell_and_port
+    [ @ep_subscript, @cell_nsp, @cp_name, @cp_subscript ]
+  end
+end
+
+# CLASS: CompositeCelltype ç¨ã® Join
+# REM:   CompositeCelltype ã export ãããã®
+class CompositeCelltypeJoin < BDNode
+# @export_name:: string     :  CompositeCelltype ã export ããååï¼å¼ã³å£ãåãå£ãå±æ§ï¼
+# @internal_cell_name:: string : CompositeCelltype å
+é¨ã®ã»ã«ã®åå
+# @internal_cell_elem_name:: string : CompositeCelltype å
+é¨ã®ã»ã«ã®å¼ã³å£ãåãå£ãå±æ§ã®åå
+# @cell : Cell : Cell::  internal cell  : CompositeCelltyep å
+é¨ã®ã»ã«ï¼in_compositeã»ã«ï¼
+# @port_decl:: Port | Decl
+# @b_pseudo: bool : 
+
+  def initialize( export_name, internal_cell_name,
+		 internal_cell_elem_name, cell, port_decl )
+    super()
+    @export_name = export_name
+    @internal_cell_name = internal_cell_name
+    @internal_cell_elem_name = internal_cell_elem_name
+    @cell = cell
+    @port_decl = port_decl
+
+  end
+
+  #=== CompositeCelltypeJoin# CompositeCelltypeJoin ã®å¯¾è±¡ã»ã«ãï¼
+  #cell::  Cell å¯¾è±¡ãã©ãããã§ãã¯ããã»ã«
+  #
+  #     CompositeCelltypeJoin ã¨ cell ã®ååãä¸è´ããããã§ãã¯ãã
+  #     port_decl ãæå®ãããå ´åã¯ãç¾ç¶ä½¿ããã¦ããªã
+  def match?( cell, port_decl = nil )
+
+    #debug
+    if port_decl
+      dbgPrint(  "match?"  )
+      dbgPrintf( "  @cell:      %-20s      %08x\n", @cell.get_name, @cell.object_id )
+      dbgPrintf( "  @port_decl: %-20s      %08x\n", @port_decl.get_name, @port_decl.object_id )
+      dbgPrintf( "  cell:       %-20s      %08x\n", cell.get_name, cell.object_id )
+      dbgPrintf( "  port_decl:  %-20s      %08x\n", port_decl.get_name, port_decl.object_id )
+      dbgPrint(  "  cell_name: #{cell.get_name.class}=#{cell.get_name} cell_elem_name: #{port_decl.get_name.class}=#{port_decl.get_name}\n" )
+      dbgPrint(  "  @cell_name: #{@cell.get_name.class}=#{@cell.get_name} cell_elem_name: #{@port_decl.get_name.class}=#{@port_decl.get_name}\n" )
+
+    end
+
+#    if @cell.equal?( cell ) && ( port_decl == nil || @port_decl.equal?( port_decl ) ) then
+    # ãªã port_decl ãä¸è´ããªããã°ãªããªãã£ããå¿ããã
+    # recursive_composite ã§ååã®ä¸è´ã«å¤æ´   060917
+    if((@cell.get_name == cell.get_name) && (port_decl == nil || @port_decl.get_name == port_decl.get_name))then
+      true
+    else
+      false
+    end
+  end
+
+  def check_dup_init
+    return if get_port_type != :CALL
+
+    if @cell.get_join_list.get_item @internal_cell_elem_name then
+      cdl_error( "S1131 \'$1.$2\' has duplicate initializer" , @internal_cell_name, @internal_cell_elem_name )
+    end
+  end
+
+  def get_name
+    @export_name
+  end
+
+  def get_cell_name
+    @internal_cell_name
+  end
+
+  def get_cell
+    @cell
+  end
+
+  def get_cell_elem_name
+    @internal_cell_elem_name
+  end
+
+  # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã
+  def get_port_type
+    if @port_decl then
+      @port_decl.get_port_type
+    end
+  end
+
+  def get_port_decl
+    @port_decl
+  end
+
+  #=== CompositeCelltypeJoin#get_allocator_instance
+  def get_allocator_instance
+    if @port_decl.instance_of? Port then
+      return @port_decl.get_allocator_instance
+    elsif @port_decl
+      raise "CompositeCelltypeJoin#get_allocator_instance: not port"
+    else
+      return nil
+    end
+  end
+
+  # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã
+  def is_require?
+    if @port_decl then
+      @port_decl.is_require?
+    end
+  end
+
+  # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã
+  def is_allocator_port?
+    if @port_decl then
+      @port_decl.is_allocator_port?
+    end
+  end
+
+  # @port_decl ã Port ã®å ´åã®ã¿å¼ã³åºãã¦ãã
+  def is_optional?
+    if @port_decl then
+      @port_decl.is_optional?
+    end
+  end
+
+  #=== CompositeCelltypeJoin# å³è¾ºã Decl ãªãã°åæåå­ï¼å¼ï¼ãè¿ã
+  # ãã®ã¡ã½ããã¯ Cell ã® check_join ããåæå¤ãã§ãã¯ã®ããã«å¼ã³åºããã
+  def get_initializer
+    if @port_decl.instance_of? Decl then
+      @port_decl.get_initializer
+    end
+  end
+
+  def get_size_is
+    if @port_decl.instance_of? Decl then
+      @port_decl.get_size_is
+    end
+  end
+
+  #=== CompositeCelltypeJoin# é
+åãµã¤ãºãå¾ã
+  #RETURN:: nil: not array, "[]": å¤§ããæå®ãªã, Integer: å¤§ããæå®ãã
+  def get_array_size
+    @port_decl.get_array_size
+  end
+
+  #=== CompositeCelltypeJoin# signature ãå¾ã
+  # @port_decl ã Port ã®æã®ã¿å¼ã³åºãã¦ããã
+  def get_signature
+    @port_decl.get_signature
+  end
+
+  #=== CompositeCelltypeJoin# get_type
+  def get_type
+    if @port_decl.instance_of? Decl
+      @port_decl.get_type
+    end
+  end
+
+  #=== CompositeCelltypeJoin# get_initializer
+  def get_initializer
+    if @port_decl.instance_of? Decl
+      @port_decl.get_initializer
+    end
+  end
+
+  #=== CompositeCelltypeJoin# get_choice_list
+  def get_choice_list
+    if @port_decl.instance_of? Decl
+      @port_decl.get_choice_list
+    end
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "CompositeCelltypeJoin: export_name: #{@export_name} #{self}"
+    (indent+1).times { print "  " }
+    puts "internal_cell_name: #{@internal_cell_name}"
+    (indent+1).times { print "  " }
+    puts "internal_cell_elem_name: #{@internal_cell_elem_name}"
+    if @port_decl then
+      @port_decl.show_tree( indent + 1 )
+    end
+  end
+end
+
+class Factory < BDNode
+# @name:: string
+# @file_name:: string
+# @format:: string
+# @arg_list:: Expression ã® elements ã¨åãå½¢å¼ [ [:IDENTIFIER, String], ... ]
+# @f_celltype:: bool : true: celltype factory, false: cell factory
+
+  @@f_celltype = false
+
+  def initialize( name, file_name, format, arg_list )
+    super()
+    @f_celltype = @@f_celltype
+
+    case name
+    when :write
+      # write é¢æ°
+      @name = name
+
+      # write é¢æ°ã®ç¬¬ä¸å¼æ°ï¼åºåå
+ãã¡ã¤ã«å
+        # å¼ãè©ä¾¡ããï¼éå¸¸åä¸ã®æå­åã§ãããããåä¸ã®æå­åãè¿ãããï¼
+      @file_name = file_name.eval_const(nil).val  # file_name : Expression
+      if ! @file_name.instance_of?( String ) then
+        # æå­åå®æ°ã§ã¯ãªãã£ã
+        cdl_error( "S1132 $1: 1st parameter is not string(file name)" , @name )
+        @file_name = nil
+      end
+
+      # write é¢æ°ã®ç¬¬äºå¼æ°ï¼ãã©ã¼ãããæå­å
+      @format    = format.eval_const(nil).val     # format : Expression
+        # å¼ãè©ä¾¡ããï¼éå¸¸åä¸ã®æå­åã§ãããããåä¸ã®æå­åãè¿ãããï¼
+      if ! @format.instance_of?( String ) then
+        # æå­åå®æ°ã§ã¯ãªãã£ã
+        cdl_error( "S1133 $1: 2nd parameter is not string(fromat)" , @name )
+        @format = nil
+      end
+
+      # ç¬¬ä¸å¼æ°ä»¥éãå¼æ°ãªã¹ãã¨ãã mikan å¼æ°ã®ãã§ãã¯
+      @arg_list = arg_list
+
+    else
+      cdl_error( "S1134 $1: unknown factory function" , name )
+    end
+    Celltype.new_factory( self )
+  end
+
+  def check_arg( celltype )
+    if ! @arg_list then
+      return
+    end
+
+    if @f_celltype then
+      cdl_error( "S1135 celltype factory can\'t have parameter(s)"  )
+      return
+    end
+
+    @arg_list.each{ |elements|
+
+      case elements[0]
+      when :IDENTIFIER  #1
+        obj = celltype.find( elements[1] )
+        if obj == nil then
+          cdl_error( "S1136 \'$1\': not found" , elements[1] )
+        elsif ! obj.instance_of?( Decl ) || obj.get_kind != :ATTRIBUTE then
+          cdl_error( "S1137 \'$1\': not attribute" , elements[1] )
+        end
+      when :STRING_LITERAL
+      else
+        cdl_error( "S1138 internal error Factory.check_arg()"  )
+      end
+
+    }
+  end
+
+  def self.set_f_celltype( f_celltype )
+    @@f_celltype = f_celltype
+  end
+
+  def get_f_celltype
+    @f_celltype
+  end
+
+  def get_name
+    @name
+  end
+
+  def get_file_name
+    @file_name
+  end
+
+  def get_format
+    @format
+  end
+
+  def get_arg_list
+    @arg_list
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Factory: name: #{@name}"
+    if @arg_list then
+      (indent+1).times { print "  " }
+      puts "argument(s):"
+      @arg_list.each { |l|
+        (indent+2).times { print "  " }
+        print "\"#{l}\"\n"
+      }
+    end
+  end
+end
+
+#== Domain
+#
+# region ã® domain ãè¨æ¶ããã¯ã©ã¹
+class DomainType < Node
+#@name::Symbol : ãã¡ã¤ã³ã¿ã¤ãã®åå ex) HRP2
+#@region::Region
+#@plugin_name::Symbol : ex) HRP2Plugin
+#@option::String : ex) "trusted", "nontrusted"
+#@plugin::DomainPlugin ã®å­ã¯ã©ã¹
+
+  include PluginModule
+
+  # ãã¡ã¤ã³ã«å±ãã region ã® Hash
+  # domain æå®ãä¸åº¦ãè¡ãããªãå ´åããã®ãªã¹ãã¯ç©ºã§ãã
+  # ã«ã¼ããªã¼ã¸ã§ã³ã¯ option = "OutOfDomain" ã§ç»é²ããã (domain æå®ãç¡ããã°ç»é²ãããªã)
+  @@domain_regions = { }  # { :domain_type => [ region, ... ] }
+
+  def initialize( region, name, option )
+    super()
+    @name = name
+    @plugin_name = (name.to_s + "Plugin").to_sym
+    load_plugin( @plugin_name, DomainPlugin )
+    @region = region
+    @option = option
+
+    if @@domain_regions[ name ] then
+      if ! @@domain_regions[ name ].include?( region ) then
+        @@domain_regions[ name ] << region
+      end
+    else
+      @@domain_regions[ name ] = [ region ]
+    end
+  end
+
+  def create_domain_plugin
+    if ! @plugin then
+      pluginClass = Object.const_get @plugin_name
+      @plugin = pluginClass.new( @region, @name, @option )
+    end
+  end
+
+  def add_through_plugin( join, from_region, to_region, through_type )
+    # print( "DOMAIN: add_through_plugin: from=#{from_region.get_name}#{join.get_owner.get_name}.#{join.get_name} to=#{to_region}#{join.get_cell.get_name}.#{join.get_port_name} through_type=#{through_type}\n" )
+    return @plugin.add_through_plugin( join, from_region, to_region, through_type )
+  end
+
+  def joinable?( from_region, to_region, through_type )
+    # print( "DOMAIN: joinable? from_region=#{from_region.get_name} to_region=#{to_region} through_type=#{through_type}\n" )
+    return @plugin.joinable?( from_region, to_region, through_type )
+  end
+
+  def get_name
+    @name
+  end
+
+  #== Domain ãªã¼ã¸ã§ã³ã® Hash ãå¾ã
+  # @@domain_regions ã®èª¬æåç
+§
+  def self.get_domain_regions
+    return @@domain_regions
+  end
+
+  def get_regions
+    return @@domain_regions[ @name ]
+  end
+
+  def get_option
+    @option
+  end
+
+  def show_tree( indent )
+    (indent+1).times { print( "  " ) }
+    puts "domain: name=#{@name} plugin=#{@plugin_name} option=#{@option}"
+  end
+end
+
+#== Region ã¯ã©ã¹
+# 
+# Region ã¯ Namespace ãç¶æ¿ãã¦ãã
+# root region ã¯ç¹æ®ã§ãroot namespace ã¨åãã§ãã
+#
+# cell ã¯ region ã«å±ãã
+# region ã«å±ãã cell ã®ãªã¹ãã¯ Namespace ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ãã¦è¨æ¶ããã
+#
+class Region < Namespace
+# @name:: string
+# @in_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ in ç¦æ­¢
+# @out_through_list:: [ [ plugin_name, plugin_arg ], ... ] : plungin_name = nil ã®æ out ç¦æ­¢
+# @to_through_list:: [ [ dst_region, plugin_name, plugin_arg ], ... ]
+# @cell_port_throug_plugin_list:: { "#{cell_name}.#{port_name}" => through_generated_list ã®è¦ç´  }
+#    ãã® region ãã cell_name.port_name ã¸ã® through ãã©ã°ã¤ã³ã§çæããããªãã¸ã§ã¯ã
+# @region_type::Symbol : :NODE, :LINKUNIT, :DOMAIN, :CLASS
+# @region_type_param::Symbol : domain, class ã®åå. node, linkunit ã§ã¯ nil
+# @link_root:: Region : linkUnit ã®æ ¹ã£ãã¨ãªã region (node, linkunit ãæå®ããã region)
+# @family_line:: [ @region_root, ...,@region_me ]  å®¶ç³»
+# @in_through_count:: Integer :  n çªç®ã® in_through çµå (n>=0)
+# @out_through_count:: Integer : n çªç®ã® out_through çµå (n>=0)
+# @to_through_count:: { :RegionName => Integer }: RegionName ã¸ã® n çªç®ã® to_through çµå (n>=0)
+# @domain_type::DomainType : domain æå®ããã¦ããªãå ´åãnil
+# @domain_root::Region : domain æå®ããã¦ããªã Region (root ã®å ´å nil)
+
+  @@in_through_list  = []
+  @@out_through_list = []
+  @@to_through_list  = []
+  @@region_type = nil
+  @@region_type_param = nil
+  @@domain_name = nil
+  @@domain_option = nil    # Token ãå
+¥ã
+
+  @@link_roots = []
+
+  def initialize( name )
+    # mikan name ã® Namespace ä¿®é£¾
+    # object = Namespace.find( [ name ] )   # è¦ªã¾ã§æãã«ãã
+    if name != "::" then
+      object = Namespace.get_current.find( name )    #1
+    else
+      # root ãªã¼ã¸ã§ã³
+      object = nil
+      @@region_type = :NODE
+    end
+
+    @in_through_list    = @@in_through_list
+    @out_through_list   = @@out_through_list
+    @to_through_list    = @@to_through_list
+    @region_type        = @@region_type
+    @region_type_param  = @@region_type_param
+
+    if @@domain_name then
+      domain_option = CDLString.remove_dquote @@domain_option.to_s
+      @domain_type = DomainType.new( self, @@domain_name, domain_option )
+      @@domain_name       = nil
+      @@domain_option     = nil
+    else
+      @domain_type = nil
+    end
+
+    @@in_through_list   = []
+    @@out_through_list  = []
+    @@to_through_list   = []
+    @@region_type       = nil
+    @@region_type_param = nil
+
+    @in_through_count = -1
+    @out_through_count = -1
+    @to_through_count = {}
+
+    super( name )
+    if object then
+
+      if object.instance_of?( Region ) then
+        dbgPrint "Region.new: re-appear #{@name}\n"
+
+        # # Region path ãåååºç¾ã¨ä¸è´ãããï¼
+        # if @@region_stack[ @@region_stack_sp - 1 ] then
+        #   my_path = @@region_stack[ @@region_stack_sp - 1 ].get_path_string.to_s + "." + @name.to_s
+        # else
+        #   my_path = @name.to_s
+        # end
+        # if my_path != object.get_path_string then
+        #   cdl_error( "S1139 $1: region path mismatch. previous path: $2" , my_path, object.get_path_string )
+        # end
+
+        # ååºç¾
+        # @@region_stack[@@region_stack_sp] = object
+
+        # ååºç¾æã« specifier ãæå®ããã¦ãããï¼
+        if( @in_through_list.length != 0 || @out_through_list.length != 0 || @to_through_list.length != 0 || @region_type != nil )then
+          cdl_error( "S1140 $1: region specifier must place at first appearence" , name )
+        end
+        return
+
+      else
+        # ã¨ã©ã¼ç¨ããã¼å®ç¾©
+
+        # ç°ãªãååã®ãªãã¸ã§ã¯ããå®ç¾©æ¸ã¿
+        cdl_error( "S1141 $1 duplication, previous one : $2" , name, object.class )
+        # @@region_stack[@@region_stack_sp] = self    # ã¨ã©ã¼ææ«å® region
+      end
+    else
+      # ååºç¾
+      dbgPrint "Region.new: #{@name}\n"
+      set_region_family_line
+
+      if @region_type == :NODE || @region_type == :LINKUNIT then
+        dbgPrint "new LinkRoot: #{@name}\n"
+        @@link_roots << self
+      end
+    end
+
+    @cell_port_throug_plugin_list = {}
+
+# p @name
+# p @in_through_list
+# p @out_through_list
+# p @to_through_list
+
+  end
+
+  def self.end_of_parse
+    Namespace.get_current.create_domain_plugin
+    Namespace.get_current.end_of_parse
+  end
+
+  def self.new_in_through( plugin_name = nil, plugin_arg = nil )
+    @@in_through_list << [ plugin_name, plugin_arg ]
+  end
+
+  def self.new_out_through( plugin_name = nil, plugin_arg = nil )
+    @@out_through_list << [ plugin_name, plugin_arg ]
+  end
+
+  def self.new_to_through( dst_region, plugin_name, plugin_arg )
+    # p "New to_through #{dst_region}"
+    @@to_through_list  << [ dst_region, plugin_name, plugin_arg ]
+  end
+
+  def self.set_type( type, param = nil )
+    if @@region_type then
+      Generator.error( "S1178 $1 region type specifier duplicate, previous $2", type, @@region_type )
+    end
+    @@region_type = type
+    @@region_type_param = param
+  end
+
+  def self.set_domain( name, option )
+    if @@domain_name then
+      Generator.error( "S9999 $1 domain specifier duplicate, previous $2", type, @@region_type )
+    end
+    @@domain_name = name
+    @@domain_option = option
+  end
+
+  #== Region ã«ã¼ããªã¼ã¸ã§ã³ãå¾ã
+  # ã«ã¼ããªã¼ã¸ã§ã³ã¯ãã«ã¼ããã¼ã ã¹ãã¼ã¹ã¨åãã§ãã
+  def self.get_root
+    Namespace.get_root
+  end
+
+  def set_region_family_line
+
+    dbgPrint  "set_region_family_line: Region: #{@name}  \n"
+    # root namespace (root region) ã® region type ã¯ :NODE
+    if @name == "::" then
+      @region_type = :NODE
+    end
+
+    if @region_type == :NODE || @region_type == :LINKUNIT then
+      @link_root = self
+    else
+      @link_root = @owner.get_link_root
+    end
+
+    if @domain_type != nil || @owner == nil then
+      @domain_root = self
+    else
+      @domain_root = @owner.get_domain_root
+    end
+
+    if @domain_type then
+      # ã«ã¼ããªã¼ã¸ã§ã³ãæåãã @domain_type è¨­å®ããããã¨ã¯ãªãã®
+      # ã§ @owner == nil ãèª¿ã¹ãå¿
+è¦ã¯ãªã
+      @owner.set_domain_type @domain_type
+    end
+
+    if @owner then
+      @family_line = ( @owner.get_family_line.dup ) << self
+    else
+      @family_line = [ self ]    # root region
+    end
+
+=begin
+    @family_line = []
+    @link_root = nil
+
+    # @family_line ãä½æãã
+    # @link_root ãã¿ã¤ãã
+    # (ä¸ä½ã«ãã©ã£ã¦ãã£ã¦ Region ã§ node ã¾ãã¯ linkunit ã®ããããå
+ã«è¦ã¤ãã£ããã®ã @link_root ã¨ãªã)
+    # root namespace ã¯ Region ãã¤ node ãªã®ã§å¿
+ã @link_root ã¯è¦ã¤ãã
+    # mikan: self ã node, linkUnit ã®å ´åãããã§æå¾
+ããã¨ããã«è¨­å®ãããªããããRegion#initialize ã§åè¨­å®
+    obj = self
+    while 1
+      if obj.instance_of? Region then
+        @family_line << obj
+        if @link_root == nil then
+          if obj.get_region_type == :NODE || obj.get_region_type == :LINKUNIT then
+            @link_root = obj
+          end
+        end
+      else
+        # ãããªããã° Namespace
+        # namespace ã®ä¸ã« region ãããå ´å
+      end
+
+      # root namespace ã«ãã©ãçãã°çµã
+      break if obj.get_name == "::"
+
+      obj = obj.get_owner
+    end
+    # print "#{@name}: linkRoot: #{@link_root.get_name}  (this can be wrong if #{@name} is node or linkunit, and corret later\n"
+    @family_line.reverse!
+=end
+
+  end
+
+  #== Region#ãã¡ã¤ã³ãè¨­å®ãã
+  def set_domain_type domain_type
+    if @region_type == :NODE then
+      if @domain_type then
+        if @domain_type.get_name != domain_type.get_name then
+          cdl_error( "S9999 '$1' node root cannot belong to both $2 and $3", @name, @domain_type.get_name, domain_type.get_name )
+        end
+      else
+        @domain_type = DomainType.new( self, domain_type.get_name, "OutOfDomain" )
+        @domain_type.create_domain_plugin
+      end
+    elsif @domain_type == nil then
+      @owner.set_domain_type domain_type
+    end
+  end
+
+  def self.get_link_roots
+    @@link_roots
+  end
+
+  def get_family_line
+    @family_line
+  end
+
+  def get_in_through_list
+    @in_through_list
+  end
+
+  def get_out_through_list
+    @out_through_list
+  end
+
+  def get_to_through_list
+    @to_through_list
+  end
+
+  def get_link_root
+    @link_root
+  end
+
+  def get_domain_type
+    @domain_type
+  end
+
+  #== Region# domain ã®æ ¹ã£ãã¨ãªã region ãå¾ã
+  # Region ã®ã¤ã³ã¹ã¿ã³ã¹ãè¿ã
+  # domain æå®å­ãããã°ããã®ãªã¼ã¸ã§ã³ããã¡ã¤ã³ã«ã¼ãã§ãã
+  # ãªããã°ãè¦ªãªã¼ã¸ã§ã³ã®ãã¡ã¤ã³ã«ã¼ãã¨ãã
+  def get_domain_root
+    @domain_root
+  end
+
+  def get_path_string
+    pstring = ""
+    delim = ""
+    @family_line.each{ |p|
+      pstring = "#{pstring}#{delim}#{p.get_name}"
+      delim = "."
+    }
+    dbgPrint "get_path_string: #{pstring}\n"
+    pstring
+  end
+
+  def get_region_type
+    @region_type
+  end
+
+  def get_name
+    @name
+  end
+
+  def next_in_through_count
+    @in_through_count += 1
+  end
+
+  def next_out_through_count
+    @out_through_count += 1
+  end
+
+  def next_to_through_count( symRegionName )
+    if @to_through_count[ symRegionName ] == nil then
+      @to_through_count[ symRegionName ] = 0
+    else
+      @to_through_count[ symRegionName ] += 1
+    end
+  end
+
+  #=== Region# æ§æè§£æä¸­ã® region ãå¾ã
+  # æ§æè§£æä¸­ Namespace (ãããã¯å­ã¯ã©ã¹ã® Region) ã®ä¸ä½ããã©ã£ã¦ Region ãè¦ã¤ãã
+  # cell ã namespace ä¸ã«ãããã¨ãã§ããªããã°ãã«ã¼ããã¾ããå¿
+è¦ã¯ãªã
+  def self.get_current
+    # @@region_stack[@@region_stack_sp]
+    region = Namespace.get_current
+    while 1
+      if region.instance_of? Region
+        break
+      end
+      region = region.get_owner
+    end
+    return region
+  end
+
+  #=== Region# through ãã©ã°ã¤ã³ã§ããã® region ãã cell_name.port_name ã¸ã®ãã©ã°ã¤ã³ãªãã¸ã§ã¯ããç»é²
+  # mikan namesppace å¯¾å¿ (cell_name)
+  def add_cell_port_through_plugin( cell_name, port_name, through_plugin_object )
+    @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ] = through_plugin_object
+  end
+
+  def find_cell_port_through_plugin( cell_name, port_name )
+    return @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ]
+  end
+
+  def create_domain_plugin
+    if @domain_type then
+      @domain_type.create_domain_plugin
+    end
+  end
+
+  #=== Region# to_region ã¸ã®è·é¢ï¼unreachable ãªå ´å nil)
+  # mikan Cell#check_region ã¨Region ã¸ãã©ãçãã¾ã§ããã®å¦çã«å
+±éæ§ãé«ã
+  # region#distance ã¯ require ã§ç¨ãããã
+  def distance( to_region )
+
+    r1 = self                   # åºçº region
+    r2 = to_region              # ç®ç region
+    dist = 0
+
+    if ! r1.equal? r2 then      # åä¸ region ãªãå¼åºãå¯è½
+
+      # mikan namespace å¯¾å¿
+      f1 = r1.get_family_line
+      len1 = f1.length
+      f2 = r2.get_family_line
+      len2 = f2.length
+
+      # ä¸ä¸è´ã«ãªãã¨ããï¼å
+å¼ï¼ãæ¢ã
+      i = 1  # i = 0 ã¯ :RootRegion ãªã®ã§å¿
+ãä¸è´
+      while( i < len1 && i < len2 )
+        if( f1[i] != f2[i] )then
+          break
+        end
+        i += 1
+      end
+
+      sibling_level = i     # å
+å¼ã¨ãªãã¬ãã«ããããã¯ã©ã¡ããä¸æ¹ãçµãã£ãã¬ãã«
+
+      # p "sibling_level: #{i}"
+      # p "from: #{f1[i].get_name}" if f1[i]
+      # p "to: #{f2[i].get_name}" if f2[i]
+
+      # å¼ã³å´ã«ã¤ãã¦å¼ã³å
+ã®ã¬ãã«ããå
+å¼ã¬ãã«ã¾ã§ï¼out_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      i = len1 -1
+      while i >= sibling_level
+        dbgPrint "going out from #{f1[i].get_name} level=#{i}\n"
+        # print "DOMAIN: going out from #{f1[i].get_name} level=#{i}\n"
+        domain = f1[i].get_domain_type
+        domain_ok = false
+        if domain then
+          if ! f1[i].get_domain_type.joinable?( f1[i], f1[i-1], :OUT_THROUGH ) then
+            return nil
+          end
+          domain_ok = true
+        end
+        if ! domain_ok then
+          out_through_list = f1[i].get_out_through_list   # [ plugin_name, plugin_arg ]
+          if out_through_list.length == 0 then
+            return nil
+          end
+        end
+        i -= 1
+        dist += 1
+      end
+
+      # å
+å¼ã¬ãã«ã«ããã¦ï¼to_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      if f1[sibling_level] && f2[sibling_level] then
+        dbgPrint "going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n"
+        # print "DOMAIN: going from #{f1[sibling_level].get_name} to #{f2[sibling_level].get_name}\n"
+        domain = f1[sibling_level].get_domain_type
+        domain_ok = false
+        if domain then
+          if ! f1[i].get_domain_type.joinable?( f1[i], f1[i-1], :TO_THROUGH ) then
+            return nil
+          end
+          domain_ok = true
+        end
+        if ! domain_ok then
+          found = 0
+          f1[sibling_level].get_to_through_list.each { |t|
+            if t[0][0] == f2[sibling_level].get_name then   # region åãä¸è´ããã ?
+              found = 1
+            end
+          }
+          if found == 0 then
+            return nil
+          end
+        end
+        dist += 1
+      end
+
+      # åãå´ã«ã¤ãã¦å
+å¼ã¬ãã«ããåãå´ã®ã¬ãã«ã¾ã§ï¼in_through ããã§ãã¯ããã³æ¿å
+¥ï¼
+      i = sibling_level
+      while i < len2
+        dbgPrint "going in to #{f2[i].get_name} level=#{i}\n"
+        # print "DOMAIN: going in to #{f2[i].get_name} level=#{i}\n"
+        domain = f2[i].get_domain_type
+        domain_ok = false
+        if domain then
+          if ! f2[i].get_domain_type.joinable?( f2[i-1], f2[i], :IN_THROUGH ) then
+            return nil
+          end
+          domain_ok = true
+        end
+        if ! domain_ok then
+          in_through_list = f2[i].get_in_through_list   # [ plugin_name, plugin_arg ]
+          if in_through_list.length == 0 then
+            return nil
+          end
+        end
+        i += 1
+        dist += 1
+      end
+    end
+
+    dbgPrint "dsitance=#{dist} from #{r1.get_name} to #{r2.get_name}\n"
+
+    return dist
+  end
+
+  def show_tree( indent )
+    super
+    (indent+1).times { print( "  " ) }
+    puts "path: #{get_path_string}"
+    (indent+1).times { print( "  " ) }
+    puts "namespace: #{@namespace ? @namespace.get_name : "nil"}  owner: #{@owner.class}.#{@owner ? @owner.get_name : "nil"}"
+    if @domain
+      @domain.show_tree( indent+1 )
+    end
+  end
+end
+
+class Import_C < Node
+
+  # ãããã®ååæå­åã®ãªã¹ã
+  @@header_list = {}
+  @@header_list2 = []
+  @@define_list = {}
+
+  #=== Import_C# import_C ã®çæï¼ããããã¡ã¤ã«ãåè¾¼ãï¼
+  #header:: Token : import_C ã®ç¬¬ä¸å¼æ°æå­åãªãã©ã«ãã¼ã¯ã³
+  #define:: Token : import_C ã®ç¬¬äºå¼æ°æå­åãªãã©ã«ãã¼ã¯ã³
+  def initialize( header, define = nil )
+    super()
+    # ããããã¡ã¤ã«åæå­åããåå¾ã® "" ãåãé¤ã
+    # header = header.to_s.gsub( /\A"(.*)"\z/, '\1' )
+    header = CDLString.remove_dquote header.to_s
+
+    if define then
+      # åå¾ã® "" ãåãé¤ã
+      # def_opt = define.to_s.gsub( /\A"(.*)/, '\1' )
+      # def_opt.sub!( /(.*)"\z/, '\1' )
+      def_opt = CDLString.remove_dquote define.to_s
+
+      # "," ã -D ã«ç½®ãæã
+      def_opt = def_opt.gsub( /,/, " -D " )
+
+      # å
+é ­ã« -D ãæ¿å
+¥ # mikan ä¸é©åãª define å
+¥åããã£ãå ´åãCPP æã«ã¨ã©ã¼
+      def_opt = def_opt.gsub( /^/, "-D " )
+
+    end
+
+    # ã³ãã³ãã©ã¤ã³æå®ããã DEFINE 
+    $define.each{ |define|
+      if $IN_EXERB then
+        q = ""
+      else
+        if define =~ /'/ then
+          q = '"'
+        else
+          q = "'"
+        end
+      end
+      def_opt = "#{def_opt} -D #{q}#{define}#{q}"
+    }
+
+    include_opt = ""
+    found = false
+    header_path = ""
+    $import_path.each{ |path|
+      include_opt = "#{include_opt} -I #{path}"
+      if found == false then
+        begin
+          # ãã¡ã¤ã«ã® stat ãåã£ã¦ã¿ã(ãªããã°ä¾å¤çºç)
+          File.stat( "#{path}/#{header}" )
+
+          # cdl ãè¦ã¤ãã£ããã¡ã¤ã«ãã¹ã«åè¨­å®
+          header_path = "#{path}/#{header}"
+          found = true
+        rescue => evar
+          found = false
+          # print_exception( evar )
+        end
+      end
+    }
+
+    if found == false then
+      cdl_error( "S1142 $1 not found in search path" , header )
+      return
+    end
+
+    # èª­è¾¼ã¿æ¸ã¿ï¼
+    if( @@header_list[ header ] ) then
+      # ç¬¬äºå¼æ° define ãä»¥åã¨ç°ãªã
+      if @@define_list[ header ].to_s != define.to_s then
+        cdl_error( "S1143 import_C: arg2: mismatch with previous one"  )
+      end
+      # ãããã«ããèª­ã¿è¾¼ã¾ãªã
+      return
+    end
+
+    # ãããã®ãªã¹ããè¨é²
+    @@header_list[ header ] = header_path
+    @@header_list2 << header
+    @@define_list[ header ] = define
+
+    begin
+      tmp_C = "#{$gen}/tmp_C_src.c"
+      file = File.open( tmp_C, "w" )
+    rescue => evar
+      cdl_error( "S1144 $1: temporary C source: open error" , tmp_C )
+      print_exception( evar )
+    end
+
+    begin
+      print_defines file
+
+      file.print( "#include \"#{header}\"\n" )
+    rescue => evar
+      cdl_error( "S1145 $1: temporary C source: writing error" , tmp_C )
+      print_exception( evar )
+    ensure
+      file.close
+    end
+
+    # CPP åºåç¨ tmp ãã¡ã¤ã«å
+    tmp_header = header.gsub( /\//, "_" )
+    tmp_header = "#{$gen}/tmp_#{tmp_header}"
+
+    # CPP ã³ãã³ãã©ã¤ã³ãä½æ
+    cmd = "#{$cpp} #{def_opt} #{include_opt} #{tmp_C}"
+
+    begin
+      if( $verbose )then
+        puts "CPP: #{cmd}"
+      end
+
+      # ããªãã­ã»ããµã³ãã³ãã pipe ã¨ãã¦éã
+          # cmd ã¯ cygwin/Linux ã§ã¯ bash(sh) çµç±ã§å®è¡ããã
+          # Exerb çã§ã¯ cmd.exe çµç±ã§å®è¡ããã
+          # ãã®å·®ã¯å¼ãæ°ã® (), $, % ãªã©ã·ã§ã«ã®ç¹å¥ãªæå­ã®è©ä¾¡ã«ç¾ããã®ã§æ³¨æ
+          cpp = IO.popen( cmd, "r:ASCII-8BIT" )
+      begin
+        tmp_file = nil
+        tmp_file = File.open( tmp_header, "w:ASCII-8BIT" )
+        cpp.each { |line|
+          line = line.gsub( /^#(.*)$/, '/* \1 */' )
+          tmp_file.puts( line )
+        }
+      rescue => evar
+        cdl_error( "S1146 $1: error occured while CPP" , header )
+        print_exception( evar )
+      ensure
+        tmp_file.close if tmp_file    # mikan File.open ã«å¤±æããæ tmp_file == nil ã¯ä¿è¨¼ããã¦ãã ?
+        cpp.close
+      end
+    rescue => evar
+      cdl_error( "S1147 $1: popen for CPP failed" , header )
+      print_exception( evar )
+    end
+
+    # C è¨èªã®ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ
+    c_parser = C_parser.new
+
+    # tmp_header ããã¼ã¹
+    c_parser.parse( [tmp_header] )
+
+    # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã
+    c_parser.finalize
+
+  end
+
+  def print_defines file
+    if ! $b_no_gcc_extension_support then
+      
+    file.print <<EOT
+
+#ifndef TECS_NO_GCC_EXTENSION_SUPPORT
+
+/*
+ * these extension can be eliminated also by spefcifying option
+ * --no-gcc-extension-support for tecsgen.
+ */
+#ifndef __attribute__
+#define __attribute__(x)
+#endif
+
+#ifndef __extension__
+#define __extension__
+#endif
+
+#ifndef __builtin_va_list
+#define __builtin_va_list va_list
+#endif
+
+#ifndef __asm__
+#define __asm__(x)
+#endif
+
+#endif /* TECS_NO_GCC_EXTENSION_SUPPORT */
+EOT
+    end
+
+    file.print <<EOT
+
+/* va_list is not supported in C_parser.y.rb */
+typedef struct { int dummy; } va_list;
+
+EOT
+  end
+
+  def self.get_header_list
+    @@header_list
+  end
+  def self.get_header_list2
+    @@header_list2
+  end
+
+end
+
+class Import < Node
+# @b_reuse::bool:       åå©ç¨ï¼ã»ã«ã¿ã¤ãã® template çæä¸è¦
+# @b_reuse_real::bool:  å®éã«åå©ç¨
+# @cdl::      string:   import ãã CDL
+# @cdl_path:: string:   CDL ã®ãã¹
+# @b_imported:: bool:   import ããã(ã³ãã³ãã©ã¤ã³æå®ããã¦ããªã)
+
+  # ãããã®ååæå­åã®ãªã¹ã  æ·»å­ï¼expand ãããã¹ãå¤ï¼Import
+  @@import_list = {}
+
+  @@nest_stack_index = -1
+  @@nest_stack = []
+  @@current_object = nil
+
+  def self.push object
+    @@nest_stack_index += 1
+    @@nest_stack[ @@nest_stack_index ] = @@current_object
+    @@current_object = object
+  end
+
+  def self.pop
+    @@current_object = @@nest_stack[ @@nest_stack_index ]
+    @@nest_stack_index -= 1
+    if @@nest_stack_index < -1 then
+      raise "TooManyRestore"
+    end
+  end
+
+  #=== Import# import ãè¡ã
+  #cdl::      string   cdl ã¸ã®ãã¹ï¼"" ã§å²ã¾ãã¦ãããã¨ãä»®å®
+  #b_reuse::  bool     true: template ãçæããªã
+  def initialize( cdl, b_reuse = false, b_imported = true )
+    Import.push self
+    @b_imported = b_imported
+    super()
+    @@current_import = self
+    # ããããã¡ã¤ã«åæå­åããåå¾ã® "", <> ãåãé¤ãn
+    @cdl = cdl.to_s.gsub( /\A["<](.*)[">]\z/, '\1' )
+
+    # ãµã¼ããã¹ããæ¢ã
+    found = false
+    @cdl_path = ""
+
+    @b_reuse = b_reuse
+    @b_reuse_real = @b_reuse || Generator.is_reuse?
+
+    if Generator.get_plugin then
+      # plugin ãã import ããã¦ããå ´å gen ããµã¼ããã¹ã®å
+é ­ã«å ãã
+      search_path = [ $gen ] + $import_path
+    else
+      search_path = $import_path
+    end
+
+    search_path.each{ |path|
+      dbgPrint "import: searching #{path}/#{@cdl}"
+      begin
+        if path == "."
+          cdl_path =  @cdl
+        else
+          cdl_path = "#{path}/#{@cdl}"
+        end
+
+        # ãã¡ã¤ã«ã® stat ãåã£ã¦ã¿ã(ãªããã°ä¾å¤çºç)
+        File.stat( cdl_path )
+
+        # cdl ãè¦ã¤ãã£ããã¡ã¤ã«ãã¹ã«åè¨­å®
+        @cdl_path = cdl_path
+        found = true
+        dbgPrint ": found\n"
+        break
+      rescue => evar
+        found = false
+        dbgPrint ": not found\n"
+        # print_exception( evar )
+      end
+    }
+
+    if found == false then
+      cdl_error( "S1148 $1 not found in search path" , @cdl )
+      return
+    end
+
+    # èª­è¾¼ã¿æ¸ã¿ãªããèª­è¾¼ã¾ãªã
+    prev = @@import_list[ File.expand_path( @cdl_path ) ]
+    if( prev ) then
+      if prev.is_reuse_real? != @b_reuse_real then
+        cdl_warning( "W1008 $1: reuse designation mismatch with previous import" , @cdl )
+      end
+      return
+    end
+
+    # import ãªã¹ããè¨é²
+    @@import_list[ File.expand_path( @cdl_path ) ] = self
+
+    # plugin ãã import ããã¦ããå ´å
+    plugin = Generator.get_plugin
+
+    # ãã¼ãµã¤ã³ã¹ã¿ã³ã¹ãçæ(å¥ãã¼ãµã§èª­ã¿è¾¼ã)
+    parser = Generator.new
+
+    # plugin ãã import ããã¦ããå ´åã® plugin è¨­å®
+    parser.set_plugin plugin
+
+    # reuse ãã©ã°ãè¨­å®
+    parser.set_reuse @b_reuse_real
+
+    # cdl ããã¼ã¹
+    parser.parse( [@cdl_path] )
+
+    # çµæåããã¼ãµã¹ã¿ãã¯ãæ»ã
+    parser.finalize
+    Import.pop
+  end
+
+  def self.get_list
+    @@import_list
+  end
+
+  def get_cdl_path
+    @cdl_path
+  end
+
+  def is_reuse_real?
+    @b_reuse_real
+  end
+
+  def self.get_current
+    @@current_object
+  end
+
+  def is_imported?
+    @b_imported
+  end
+
+  #=== cdl ã®ååãè¿ã
+  # å¼æ°ã§æå®ããã¦ãã cdl åãä¸é¨ãã¹ãå«ãå¯è½æ§ããã
+  def get_cdl_name
+    @cdl
+  end
+end
+
+#== generate: signature ãã©ã°ã¤ã³ã®ã­ã¼ãã¨å®è¡
+class Generate < Node
+#@plugin_name:: Symbol
+#@signature_nsp:: NamespacePath
+#@option::         String '"', '"' ã§å²ã¾ãã¦ãã
+
+  include PluginModule
+
+  def initialize( plugin_name, signature_nsp, option )
+    super()
+    @plugin_name = plugin_name
+    @signature_nsp = signature_nsp
+    option = option.to_s    # option ã¯ Token
+    @option = option
+
+    signature = Namespace.find( signature_nsp ) #mikan Namespace   #1
+    if ! signature.instance_of? Signature then
+      cdl_error( "S1149 $1 not signature" , signature_nsp )
+      return
+    elsif signature.is_empty? then
+      cdl_warning( "S9999 $1 is empty. cannot apply signature plugin. ignored" , signature_nsp )
+      return
+    end
+
+    load_plugin( plugin_name, SignaturePlugin )
+
+    plugin_object = nil
+    eval_str = "plugin_object = #{plugin_name}.new( signature, option )"
+    if $verbose then
+      print "new through: #{eval_str}\n"
+    end
+
+    begin
+      eval( eval_str )     # plugin ãçæ
+      plugin_object.set_locale @locale
+    rescue Exception => evar
+      cdl_error( "S1150 $1: fail to new" , plugin_name )
+      print "eval( #{eval_str} )\n"
+
+      print_exception( evar )
+    end
+    generate_and_parse plugin_object
+  end
+end
+
+#== ååç©ºéãã¹
+class NamespacePath < Node
+#@b_absolute::Bool
+#@path::[ Symbol,... ]
+#@namespace::Namespace:  @b_absolute == false ã®ã¨ããåºç¹ã¨ãªã namespace
+
+  #=== NamespacePath# initialize
+  #ident::Symbol           æåã®åå, ãã ã "::" ã®ã¿ã®å ´åã¯ String
+  #b_absolute:Bool         "::" ã§å§ã¾ã£ã¦ããå ´å true
+  #namespace::Namespace    b_absolute = false ãã¤ãæ§æè§£éæ®µéä»¥å¤ã§å¼ã³åºãå ´åã¯ãå¿
+ãæå®ãããã¨ 
+  def initialize( ident, b_absolute, namespace = nil )
+    super()
+
+    if ident == "::" then   # RootNamespace
+      @path = []
+      @b_absolute = true
+    else
+      @path = [ ident ]
+      @b_absolute = b_absolute
+    end
+
+    if namespace then
+      @namespace = namespace
+      if b_absolute == true then
+        raise "NamespacePath#initialize: naamespace specified for absolute path"
+      end
+    else
+      if b_absolute == false then
+        @namespace = Namespace.get_current
+      else
+        @namespace = nil
+      end
+    end
+  end
+
+  #=== NamespacePath# append ãã
+  #RETURN self
+  # ãã®ã¡ã½ããã¯ãå
+ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ãã¦è¿ã
+  def append!( ident )
+    @path << ident
+    return self
+  end
+  #=== NamespacePath# append ãã
+  # ãã®ã¡ã½ããã¯ãå
+ã® NamespacePath ãªãã¸ã§ã¯ããå¤å½¢ããªã
+  #RETURN:: è¤è£½ãã NamespacePath
+  def append( ident )
+    cl = self.clone
+    cl.set_clone
+    cl.append!( ident )
+    return cl
+  end
+
+  def set_clone
+    @path = @path.clone
+  end
+
+  def get_name
+    @path[ @path.length - 1 ]
+  end
+
+  #=== NamespacePath#ã¯ã­ã¼ã³ãä½æãã¦ååãå¤æ´ãã
+  def change_name name
+    cl = self.clone
+    cl.set_clone
+    cl.change_name_no_clone name
+    return cl
+  end
+  alias :change_name_clone :change_name
+
+  #=== NamespacePath#ååãå¤æ´ãã
+  # ãã®ã¤ã³ã¹ã¿ã³ã¹ãåç
+§ãããã¹ã¦ã«å½±é¿ãä¸ãããã¨ã«æ³¨æ
+  def change_name_no_clone name
+    @path[ @path.length - 1 ] = name
+    nil
+  end
+
+  #=== NamespacePath:: path æå­åãå¾ã
+  # CDL ç¨ã® path æå­åãçæ
+  def to_s
+    get_path_str
+  end
+  def get_path_str
+    first = true
+    if @b_absolute then
+      path = "::"
+    else
+      path = ""
+    end
+    @path.each{ |n|
+      if first then
+        path = "#{path}#{n}"
+        first = false
+      else
+        path += "::#{n}"
+      end
+    }
+    return path
+  end
+
+  def is_absolute?
+    @b_absolute
+  end
+  def is_name_only?
+    @path.length == 1 && @b_absolute == false
+  end
+
+  #=== NamespacePath:: ãã¹ã®é
+åãè¿ã
+  # is_absolute? true ã®å ´åãã«ã¼ãããã®ãã¹
+  #              false ã®å ´åãbase_namespace ããã®ç¸å¯¾
+  # ã«ã¼ã namespace ã®å ´åãé·ãï¼ã®é
+åãè¿ã
+  #
+  def get_path
+    @path
+  end
+
+  #=== NamespacePath#ãã«ãã¹ã®é
+åãè¿ã
+  # è¿ãããé
+åãæ¸ãæãã¦ã¯ãªããªã
+  def get_full_path
+    if @b_absolute then
+      return @path
+    else
+      return @namespace.get_namespace_path.get_full_path.clone + @path
+    end
+  end
+
+  #=== NamespacePath:: ç¸å¯¾ãã¹ã®ãã¼ã¹ã¨ãªã namespace
+  # is_absolute? == false ã®æã®ã¿æå¹ãªå¤ãè¿ã (true ãªã nil)
+  def get_base_namespace
+    @namespace
+  end
+
+  #=== NamespacePath:: C è¨èªã°ã­ã¼ãã«åãå¾ã
+  def get_global_name
+    if @b_absolute then
+      global_name = ""
+    else
+      global_name = @namespace.get_global_name
+    end
+
+    @path.each{ |n|
+      if global_name != "" then
+        global_name = "#{global_name}_#{n}"
+      else
+        global_name = n.to_s
+      end
+    }
+    global_name
+  end
+
+  #=== NamespacePath:: åè§£ãã¦ NamespacePath ã¤ã³ã¹ã¿ã³ã¹ãçæãã
+  #path_str:: String       : namespace ã¾ãã¯ region ã®ãã¹ ex) "::path::A" , "::", "ident"
+  #b_force_absolute:: Bool : "::" ã§å§ã¾ã£ã¦ããªãå ´åã§ãçµ¶å¯¾ãã¹ã«æ±ã
+  #
+  # NamespacePath ã¯éå¸¸æ§æè§£æããã¦ä½æããã
+  # ãã®ã¡ã½ããã¯ããªãã·ã§ã³ãªã©ã§æå®ãããæå­åãåè§£ãã¦ NamespacePath ãçæããã®ã«ç¨ãã
+  # ãã§ãã¯ã¯ããããä¸é©åãªãã¹æå®ã¯ãä¸é©åãª NamespacePath ãçæããã
+  def self.analyze( path_str, b_force_absolute = false )
+
+    if path_str == "::" then
+      return self.new( "::", true )
+    end
+
+    pa = path_str.split( "::" )
+    if pa[0] == "" then
+      pa.shift
+      b_absolute = true
+    else
+      if b_force_absolute then
+        b_absolute = true
+      else
+        b_absolute = false
+      end
+    end
+
+    if pa[0] then
+      nsp = self.new( pa[0].to_sym, b_absolute )
+    else
+      nsp = self.new( "::", b_absolute )
+    end
+    pa.shift
+
+    pa.each{ |a|
+      if a then
+        nsp.append! a.to_sym
+      else
+        nsp.append! "::"
+      end
+    }
+
+    return nsp
+  end
+
+end
+
+# ä»¥ä¸åä½ãã¹ãã³ã¼ã
+if $unit_test then
+  root_namespace = Namespace.new("::")
+
+  puts( "===== Unit Test: NamespacePath ===== (componentobj.rb)")
+  a = NamespacePath.new( :"ABC", true )
+  printf( "Path: %-10s global_name: %s\n", a.get_path_str, a.get_global_name )
+
+  a.append( :"DEF" )
+  printf( "Path: %-10s global_name: %s\n", a.get_path_str, a.get_global_name )
+
+  a = NamespacePath.new( :"abc", false )
+  printf( "Path: %-10s global_name: %s\n", a.get_path_str, a.get_global_name )
+
+  a.append( :"def" )
+  printf( "Path: %-10s global_name: %s\n", a.get_path_str, a.get_global_name )
+
+  puts ""
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/ctypes.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/ctypes.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/ctypes.rb	(revision 317)
@@ -0,0 +1,250 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: ctypes.rb 2296 2015-11-29 11:57:33Z okuma-top $
+#++
+
+# CType ã¯ C_parser ã§å®ç¾©ãããåãæ±ã CIntType, CFloatType ãªã©ã« include ãããã®
+# CIntType ã¯ IntType ãç¶æ¿ãããªã©ãC ã®åã§ã¯ TECS ã®åãç¶æ¿ãã
+module CType
+
+  #=== æ§æè¦ç´  type_specifier ãè¤æ°æå®ããã¦ããå ´åã« merge ãã
+  # merge ã¯ const(CIntType) unsigned(CIntTtype), long(CIntType), ãªã©ã¨ä»ã®åããã¼ã¸ãã
+  # const, unsigned, long ãªã©ã¯ãåä½ã§ int (CIntType) åã«ãªããã
+  #
+  # mikan C ã®ææ³ãå³å¯ã«ã¯ãã§ãã¯ãã¦ããªã  long struct ç­ãã§ãã¦ãã¾ã
+  def merge another
+
+    # p "self: #{self.class} kind_of( IntType ): #{self.kind_of?( IntType )}  another: #{another.class}"
+
+    # signed, unsigned ã Symbol ã¨ãã¦æ¥ãäºã¯ç¡ããªã£ã
+    # if another.instance_of? Symbol then
+    #   # ããã§ Symbol ã¯ :SIGNED, :UNSIGNED ã®ãããã
+    # 
+    #   # CIntType ãï¼
+    #   if self.instance_of? CIntType then
+    #     self.set_sign another
+    #     return self
+    #   else
+    #     cdl_error( "C1001 $1: mismatch, suitable for int types" , another )
+    #     return self
+    #   end
+    # elsif self.instance_of?( CIntType ) && another.instance_of?( CIntType )then
+    if self.instance_of?( CIntType ) && another.instance_of?( CIntType )then
+      if another.get_bit_size != -3 then
+        if @bit_size == -4 && another.get_bit_size == -4 then
+          @bit_size = -5  # long long
+        else
+          # self ã¯ int åãanother ã® bit_size ã (int ä»¥å¤ã§ããã°)ãã¡ãã«ãã
+          # mikan ä¸è¨ä»¥å¤ã§ ä¸¡æ¹ -3 ã§ãªããã°ãæ¬æ¥ã¨ã©ã¼
+          @bit_size = another.get_bit_size
+        end
+      end
+
+      if another.get_sign then
+        # another ã§ sign ãæå®ããã¦ããã°ããã¡ãã®ãã®ãæ¡ç¨ãã mikan çç¾ã®ãã§ãã¯
+        @sign = another.get_sign
+      end
+
+#      if another.get_qualifier then
+#        # another ã§ qualifier ãæå®ããã¦ããã°ããã¡ãã®ãã®ãæ¡ç¨ãã mikan çç¾ã®ãã§ãã¯
+#        @qualifier = another.get_qualifier
+#      end
+      if another.is_const? then
+        @b_const = true
+      end
+      if another.is_volatile? then
+        @b_volatile = true
+      end
+
+      return self
+    elsif self.instance_of?( CIntType ) then
+      return another.merge self
+    elsif self.instance_of?( CDefinedType ) then
+      # mikan unsigned ãªã©ã¨ã® merge ã®ä¸æ­£æ¤åº
+      if another.is_const? then
+        @b_const = true
+      end
+      if another.is_volatile? then
+        @b_volatile = true
+      end
+
+#      if self.get_type.get_type_str == another.get_type_str &&
+#          self.get_type.get_type_str_post == another.get_type_str_post
+#        # p "typedef #{another.get_type_str} #{self.get_type_str}#{another.get_type_str_post} ;"
+#      else
+#        cdl_error( "C1002 $1 not compatible with previous one $2" , self.get_type_str, another.get_type_str )
+#      end
+      return self
+    elsif self.instance_of?( CStructType ) then
+      if another.is_const? then
+        @b_const = true
+      end
+      if another.is_volatile? then
+        @b_volatile = true
+      end
+      return self
+    else
+      # mikan long double
+      #   TECS ã«ã¯ long double ãè¡¨ç¾ããææ®µããªã (double80_t ãå®ç¾©ããã°ããã?)
+#      cdl_warning( "C1003 $1 & $2 incompatible (\'long double\' is not supported.). Treated as $3." , self.class, another.class, self.class )
+      cdl_warning( "W9999 $1 & $2 incompatible (\'long double\' is not supported.). Treated as $3." , self.get_type_str, another.get_type_str, self.get_type_str )
+      return self
+    end
+  end
+
+  #=== qualifier ãè¨­å®ãã
+  #     å
+ã® Type ã¯ã©ã¹ã§ã¯çç¾ãã§ãã¯ããªãï¼TECSã®æ¬æ¥ã®ææ³ã§ã¯éè¤æå®ã§ããªãããï¼
+  def set_qualifier( qual )
+
+    if @qualifier then
+      cdl_error( "C1004 $1: qualifier redefined. previous one: $2" , qual, @qualifier )
+    end
+    super( qual )
+  end
+
+end
+
+class CDefinedType < DefinedType
+
+  include CType
+
+  def initialize( type_name )
+    super( type_name )
+  end
+end
+
+class CVoidType < VoidType
+
+  include CType
+
+end
+
+class CBoolType < BoolType
+
+  include CType
+
+end
+
+class CIntType < IntType
+
+  include CType
+
+  def initialize( bit_size )
+    #p super.class   mikan super.class ã Symbol ã ããªãï¼
+    super( bit_size )
+  end
+
+  def set_sign( sign, b_uint = false )
+    super( sign, b_uint )
+    # p "CInt: set_sign: #{get_type_str} #{sign}"
+  end
+end
+
+class CFloatType < FloatType
+
+  include CType
+
+  def initialize( bit_size )
+    super
+  end
+
+end
+
+class CEnumType < EnumType # mikan
+
+  include CType
+
+  def initialize( bit_size )
+    super( bit_size )
+  end
+
+end
+
+class CStructType < StructType
+
+  include CType
+
+
+  def initialize( tag = nil )
+    super( tag )
+  end
+end
+
+class CFuncType < FuncType
+
+  include CType
+
+  def initialize( paramlist = nil )
+    super( paramlist )
+  end
+
+end
+
+class CArrayType < ArrayType
+
+  include CType
+
+  def initialize( subscript = nil )
+    super( subscript )
+  end
+end
+
+class CPtrType < PtrType
+
+  include CType
+
+  def initialize( referto = nil )
+    super( referto )
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/expression.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/expression.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/expression.rb	(revision 317)
@@ -0,0 +1,953 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: expression.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+class Expression < Node
+#  @elements   # array
+
+  def initialize( elements, locale = nil )
+    super()
+    if locale then
+      @locale = locale
+    end
+
+    @elements = elements
+  end
+
+  def print
+    # puts "expr: #{@elements}"
+    puts "expr_string: #{to_s}"
+  end
+
+  #=== Expression# to_s
+  # C è¨èªã½ã¼ã¹åãã®æå­åãçæ (globa_name)
+  def to_s
+    elements_to_s( @elements )
+  end
+
+  #=== Expression# to_str
+  # C è¨èªã½ã¼ã¹åãã®æå­åãçæ (globa_name)
+  def to_str( name_list, pre, post )
+    elements_to_s( @elements, name_list, pre, post )
+  end
+
+  #=== Expression#to_CDL_str
+  # CDL è¡¨ç¾ã®æå­åãçæ
+  def to_CDL_str
+    return to_s
+  end
+
+  #=== å®æ°å¼ã¨ãã¦è©ä¾¡ãã(ãã©ã¤ãã¦ã¿ã)
+  #
+  # ãã®ã¡ã½ããã¯ãå®æ°å¼ãè©ä¾¡ãã
+  # ã»attribute, var ã®åæåå­
+  # ã»size_is, count_is å¼æ°
+  # ã»é
+åã®æ·»æ°
+  #
+  # name_list(NamedList|Nil): å¼ããåç
+§å¯è½ãªãªã¹ãï¼
+  # NamedList ã®è¦ç´ ã¯  size_is, count_is ã®å¼æ°è©ä¾¡ã®å ´å ParamDecl (é¢æ°ä»®å¼æ°)
+  #
+  # name_list2(NamedList|Nil) : NamedList ã®è¦ç´ ã¯ Decl (attribute, var) ã§ããï¼çç¥æ nil
+  # 
+  # RETURN: è©ä¾¡ããå®æ°ï¼è©ä¾¡ã§ããªãã£ãå ´åã¯ nil ãè¿ã
+  #
+  # åã¯ get_type ã§ãè©ä¾¡ããï¼å®æ°ã¨ãã¦æ±ããããªãã¨ãã«ä½¿ç¨ã§ããï¼
+  # Array ãè¿ãã®ã¯ attr{ int *a = {1, 2, 3}; int *b = a; }; ã® b ã®å³è¾ºãè©ä¾¡ããå ´å
+
+  def eval_const( name_list, name_list2 = nil )
+    val = elements_eval_const( @elements, name_list, name_list2, 0 )
+    if val.kind_of? IntegerVal then
+      return val.to_i
+    elsif val.kind_of? FloatVal then
+      return val.to_f
+    elsif val.kind_of? BoolVal then
+      return val.to_i
+    elsif val.kind_of? PointerVal then
+      return val.to_i           # mikan ã¨ã©ã¼ V1008 ãçºçãã¦ãã¾ã
+      # elsif val.kind_of? EnumVal then
+      # enum mikan
+    else
+      # C_EXP, Array ã¾ãã¯ nil ï¼ãã®ã¾ã¾è¿ã
+      return val
+    end
+  end
+
+  #=== å®æ°å¼ã¨ãã¦è©ä¾¡ãã2(ãã©ã¤ãã¦ã¿ã)
+  #
+  # IntegerVal, FloatVal ããã®ã¾ã¾è¿ãï¼eval_const ã§ã¯ Integer, Float ã«å¤æï¼
+  def eval_const2( name_list, name_list2 = nil, nest = 0 )
+    val = elements_eval_const( @elements, name_list, name_list2, nest )
+  end
+
+  #=== å¼ã®åãè©ä¾¡ãã
+  #
+  # eval_const ã§å¤ãå¾ãããªãå ´åãåãå°åºå¯è½ã§ããã°åãå¾ã
+  # param ãå«ãã å¼ã¯å®æ°å¤ãæ±ããããªãããåãå¾ããã¨ã¯ã§ãã
+  # æªå®ç¾©å¤æ°ãå«ãã åã¯ãå¾ããã¨ãã§ããªã (ããã¼åå®ç¾©ãè¿ã)
+  def get_type( namedList )        # ååç©ºéã® NamedList ãæå®
+    elements_get_type( @elements, namedList )
+  end
+
+  def check_dir_for_param( namedList, dir, spec )
+    elements_check_dir_for_param( @elements, namedList, dir, spec )
+  end
+
+  def get_elements
+    @elements
+  end
+
+  def show_tree( indent )
+    # mikan override ãã¦ãã¾ã£ã print ãå¼åºãæ¹æ³ãããããªãã®ã§ãããã
+    str = ""
+    indent.times { str += "  " }
+    puts "#{str}#{to_s}"
+  end
+
+## private
+
+  #=== å¼ãæå­åã«å¤æ
+  #name_list:: attribute (Celltype::@attribute_list), struct ã® @member_list ãä»®å®ãã¦ãã
+  def elements_to_s( elements, name_list = nil, pre = nil, post = nil )
+    if elements.instance_of? Token then
+      return elements.to_s    # OP_DOT, OP_REF ã®å³è¾º
+    end
+
+    case elements[0]
+    when :IDENTIFIER
+      nsp = elements[1]
+      if nsp.is_name_only? && name_list && name_list.get_item( nsp.get_name ) then
+        return "#{pre}#{nsp.get_name}#{post}"
+      else
+        # return  elements[1].get_global_name
+        return nsp.get_path_str
+      end
+    when :INTEGER_CONSTANT, :FLOATING_CONSTANT, :OCTAL_CONSTANT, :HEX_CONSTANT, :CHARACTER_LITERAL, :STRING_LITERAL_LIST, :BOOL_CONSTANT
+      return  elements[1].to_s
+    when :PARENTHESES
+      return "(#{elements_to_s(elements[1],name_list,pre,post)})"
+    when :OP_SUBSC
+      return "#{elements_to_s(elements[1],name_list,pre,post)}[#{elements[2].to_s}]"
+    when :OP_DOT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}.#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_REF
+      return "#{elements_to_s(elements[1],name_list,pre,post)}->#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_SIZEOF_EXPR
+      return "sizeof(#{elements_to_s(elements[1],name_list,pre,post)})"
+    when :OP_SIZEOF_TYPE
+      return "sizeof(#{elements[1]}) mikan"
+    when :OP_U_AMP
+      return "&#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :OP_U_ASTER
+      return "*#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :OP_U_PLUS
+      return "+#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :OP_U_MINUS
+      return "-#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :OP_U_TILDE
+      return "~#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :OP_U_EXCLAM
+      return "!#{elements_to_s(elements[1],name_list,pre,post)}"
+    when :CAST
+      return "(#{elements[1].get_type_str})#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_MULT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}*#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_DIV
+      return "#{elements_to_s(elements[1],name_list,pre,post)}/#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_REMAIN
+      return "#{elements_to_s(elements[1],name_list,pre,post)}%#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_ADD
+      return "#{elements_to_s(elements[1],name_list,pre,post)}+#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_SUB
+      return "#{elements_to_s(elements[1],name_list,pre,post)}-#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_LSFT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}<<#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_RSFT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}>>#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_LT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}<#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_GT
+      return "#{elements_to_s(elements[1],name_list,pre,post)}>#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_LE
+      return "#{elements_to_s(elements[1],name_list,pre,post)}<=#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_GE
+      return "#{elements_to_s(elements[1],name_list,pre,post)}>=#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_EQ
+      return "#{elements_to_s(elements[1],name_list,pre,post)}==#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_NE
+      return "#{elements_to_s(elements[1],name_list,pre,post)}!=#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_AND
+      return "#{elements_to_s(elements[1],name_list,pre,post)}&#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_EOR
+      return "#{elements_to_s(elements[1],name_list,pre,post)}^#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_OR
+      return "#{elements_to_s(elements[1],name_list,pre,post)}|#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_LAND
+      return "#{elements_to_s(elements[1],name_list,pre,post)}&&#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_LOR
+      return "#{elements_to_s(elements[1],name_list,pre,post)}||#{elements_to_s(elements[2],name_list,pre,post)}"
+    when :OP_CEX
+      return "#{elements_to_s(elements[1],name_list,pre,post)}?#{elements_to_s(elements[2],name_list,pre,post)}:#{elements_to_s(elements[3],name_list,pre,post)}"
+    else
+      raise "Unknown expression element: #{elemets[0]}. try -t and please report"
+    end
+    return ""
+  end
+
+  # å®æ°å¼(elements)ãè©ä¾¡ãã
+  #
+  # ãã®ã¡ã½ããã¯ Expression ã¯ã©ã¹ã®ã¡ã½ããã§ããå¿
+è¦ã¯ãªãï¼é¢æ°åã§ããï¼
+  #
+  # elements ã¯å¼ã®è¦ç´ 
+  #
+  # name_list, name_list2 ã¯ eval_const ãåç
+§
+  #
+  # RETURN: è©ä¾¡ããå®æ°ãè©ä¾¡ã§ããªãã£ãå ´åã¯ nil ãè¿ã
+
+  MAX_NEST_LEVEL = 64    # ç°¡æã®ã«ã¼ãæ¤åºï¼åç
+§ã®ãã¹ãã 64 ã¾ã§è¨±å¯ããï¼
+  def elements_eval_const( elements, name_list, name_list2 = nil, nest = nil )
+
+    case elements[0]
+    when :IDENTIFIER
+      nsp = elements[1]
+
+      # #809 ã®ä¿®æ­£ããã (å¥ã®åé¡ãè§£æ±ºãããã¦ããªã)
+      # nest += 1     # åç
+§ãã«ã¼ãã«ãªã£ã¦ããªããã®ãã§ãã¯
+      #               # mikan æ¬å½ã«ã«ã¼ããã¦ãããã©ããã§ã¯ãªããåç´ã«å¤æ°ã®åç
+§ãç¹°ãè¿ãã¦ãããã¨ã§å¤å®ãã¦ãã
+      # if nest > MAX_NEST_LEVEL then
+      #   cdl_error( "E9999: '$1' too many reference (maybe loop) max=$1" , nsp.to_s, MAX_NEST_LEVEL )
+      #   return
+      # end
+      if nsp.is_name_only? then
+        if name_list then
+          object = name_list.get_item( nsp.get_name )
+        end
+
+        if object == nil && name_list2 then
+          object = name_list2.get_item( nsp.get_name )
+        end
+      end
+
+      # è¦ã¤ãããªããã°å®æ°å®ç¾©ããæ¢ã
+      if object == nil then
+        object = Namespace.find( nsp )# mikan namespace ã®å¯¾å¿ #1
+      end
+
+# ãã®å®è£
+ã¯ãããå°ãæ´çãããã¹ã
+# ãããå¼åºãããã®ã¯ãä»¥ä¸ã®å ´å
+#   ã»attribute, var ã®å³è¾ºå¼ã®è©ä¾¡
+#   ã»size_is å¼æ°ã®è©ä¾¡ï¼é¢æ°ãã©ã¡ã¼ã¿ã®å ´åã¨attribute, var ã®å ´åããã
+# ä»¥ä¸ã®ã¨ã©ã¼ãã§ãã¯ã§ã¯ããããããã£ã¡ãã«ãªã£ã¦èª¤ããæ¤åºãããã¨ãã¦ãã
+
+      # IDENTIFIER ã¯è¦ã¤ãããªãã£ãï¼
+      if object == nil then
+        cdl_error( "E1001 $1: not found" , nsp.get_path_str )
+        # raise  "E1001"  # bug trap
+        return nil
+      elsif object.instance_of?( Join ) then
+        # Join ã®å ´åï¼ cell ã®ä¸­ã® attribute, var, call ã®ã©ãããè¦ã¤ãã£ã
+        # Decl (attribute, var) ã§ãªãï¼
+        if ! object.get_definition.instance_of?( Decl ) then
+          cdl_error( "E1002 $1: not constant (port)" , nsp.get_path_str )
+          return nil
+        end
+        return object.get_rhs.eval_const2( name_list, name_list2, nest )
+      elsif ! object.instance_of?( Decl ) then
+        # Decl ã§ãªãå ´åï¼ å®æ°ã§ããªã
+        if ( ! object.instance_of?( ParamDecl ) ) then
+                                                      # mikan paramdecl ã¯ç¡è¦ãã
+                                                      # ParamList ããå¼ã°ããã¨ã
+          cdl_error( "E1003 $1: not constant" , nsp.get_path_str )
+        else
+          # ParamDecl
+          object.referenced
+        end
+        return nil
+      else # Decl
+        object.referenced
+        if object.get_initializer == nil then
+          # åæåå­ã®å­å¨ããªãå¤æ°   # mikan ããã¸ããã®ã¯ãéå¸¸ããããªãã¯ãï¼æªæ¤è¨¼ï¼
+          return IntegerVal.new( 0 )
+        else
+          # Decl ã®å³è¾ºã®è©ä¾¡
+          # mikan size_is å¼æ°ã«ç¾ããå¤æ°ã®åãé©åãã®ãã§ãã¯ãã
+          if object.get_initializer.instance_of?( Expression ) || object.get_initializer.instance_of?( C_EXP ) then
+            return object.get_initializer.eval_const2( name_list, name_list2, nest )
+          else
+            # Array ã®å ´å
+            return object.get_initializer
+          end
+        end
+      end
+    when :BOOL_CONSTANT
+      if( elements[1].instance_of?( TrueClass ) )then
+        return BoolVal.new( true )
+      elsif( elements[1].instance_of?( FalseClass ) )then
+        return  BoolVal.new( false )
+      else
+        throw( "BOOL constant error" )
+      end
+    when :INTEGER_CONSTANT
+      return IntegerVal.new( elements[1].val )
+    when :FLOATING_CONSTANT
+      return FloatVal.new( elements[1].val )
+    when :OCTAL_CONSTANT
+      return IntegerVal.new( elements[1].val.oct, elements[1].val )
+    when :HEX_CONSTANT
+      return IntegerVal.new( elements[1].val.hex, elements[1].val )
+    when :CHARACTER_LITERAL
+      str =  elements[1].val.gsub(/'/, "" )
+#2.0      if str.jlength == 1
+      if $b_no_kcode then
+        len = str.length
+      else
+        len = str.jlength
+      end
+      if len == 1 then
+        sum = 0
+        str.each_byte { |b| sum = sum * 256 + b }
+        return IntegerVal.new( sum, elements[1].val )
+      else
+#2.0        if str[0] == 92 then
+        if str[0] == 92 || str[0] == "\\" then
+          case str[1]
+#2.0          when 48 # '0'
+          when 48, "0" # '0'
+            return IntegerVal.new( 0, elements[1].val )
+#2.0          when 110 # 'n'
+          when 110, "n" # 'n'
+            return IntegerVal.new( 10, elements[1].val )
+#2.0          when 114 # 'r'
+          when 114, "r" # 'r'
+            return IntegerVal.new( 13, elements[1].val )
+#2.0          when 116 # 't'
+          when 116, "t" # 't'
+            return IntegerVal.new( 15, elements[1].val )
+#2.0          when 92 # '\\'
+          when 92, '\\' # '\\'
+            return IntegerVal.new( 92, elements[1].val )
+          end
+        end
+      end
+#2.0      printf( "c=%c\n", str[1] )
+      printf( "len=%d c=%c\n", len, str[1] )
+      raise Error
+
+    when :STRING_LITERAL_LIST
+      return  StringVal.new( elements[1] )
+    when :PARENTHESES
+      return elements_eval_const( elements[1], name_list, name_list2, nest );
+    when :OP_SUBSC
+      cdl_error( "E1004 cannot evaluate \'[]\' operator"  )
+      return nil
+    when :OP_DOT
+      cdl_error( "E1005 cannot evaluate \'.\' operator"  )
+      return nil
+    when :OP_REF
+      cdl_error( "E1006 cannot evaluate \'->\' operator"  )
+      return nil
+    when :OP_SIZEOF_EXPR
+      cdl_error( "E1007 cannot evaluate \'sizeof\' operator"  )
+      return nil
+    when :OP_SIZEOF_TYPE
+      cdl_error( "E1008 cannot evaluate \'sizeof\' operator"  )
+      return nil
+    when :OP_U_AMP
+      cdl_error( "E1009 cannot evaluate \'&\' operator"  )
+      return nil
+    when :OP_U_ASTER
+      # cdl_error( "E1010 cannot evaluate \'*\' operator"  )
+      val = elements_eval_const(elements[1], name_list, name_list2, nest)
+      return nil if ! evaluable?( val )
+      return val
+    when :OP_U_PLUS
+      val = elements_eval_const(elements[1], name_list, name_list2, nest)
+      return nil if ! evaluable?( val )
+      if val.respond_to?( "+@" ) then
+        return + val
+      else
+        cdl_error( "E1011 cannot evaluate unary + for $1" , val.class )
+        return nil
+      end
+    when :OP_U_MINUS
+      val = elements_eval_const(elements[1], name_list, name_list2, nest)
+      return nil if ! evaluable?( val )
+      if val.respond_to?( "-@" ) then
+        return - val
+      else
+        return nil
+      end
+    when :OP_U_TILDE
+      val = elements_eval_const(elements[1], name_list, name_list2, nest)
+      return nil if ! evaluable?( val )
+# p "val.respond_to?( \"-@\" )=#{val.respond_to?( "-@" )} #{val.class}"
+# p "val.respond_to?( \"~@\" )=#{val.respond_to?( "~@" )}"
+#2.0      if val.respond_to?( "~@" ) then  # Ruby 1.9, 2.0 preview çã§ã¯ä¾å¤ãçºçãã¦ãã¾ã
+      if val.kind_of? IntegerVal then
+        return ~ val
+      else
+        return nil
+      end
+    when :OP_U_EXCLAM
+      val = elements_eval_const(elements[1], name_list, name_list2, nest)
+      return nil if ! evaluable?( val )
+      val = val.cast( BoolType.new )
+      if val.respond_to?( "not" ) then
+        return val.not
+      else
+        return nil
+      end
+      return nil
+    when :CAST
+      val = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if val == nil
+      return nil if ! evaluable?( val )
+      return val.cast( elements[1] )
+    when :OP_MULT
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs * rhs
+    when :OP_DIV
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs / rhs
+    when :OP_REMAIN
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs % rhs
+    when :OP_ADD
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs + rhs
+    when :OP_SUB
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs - rhs
+    when :OP_LSFT
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs << rhs
+    when :OP_RSFT
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs >> rhs
+    when :OP_LT
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs < rhs
+    when :OP_GT
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs > rhs
+    when :OP_LE
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs <= rhs
+    when :OP_GE
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs >= rhs
+    when :OP_EQ
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs.eq( rhs )
+    when :OP_NE
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs.neq( rhs )
+    when :OP_AND
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs & rhs
+    when :OP_EOR
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs ^ rhs
+    when :OP_OR
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs | rhs
+    when :OP_LAND
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs.lAND( rhs )
+    when :OP_LOR
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      # return nil if( rhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, lhs )
+      return lhs.lOR( rhs )
+    when :OP_CEX
+      lhs = elements_eval_const(elements[1], name_list, name_list2, nest)
+      mhs = elements_eval_const(elements[2], name_list, name_list2, nest)
+      rhs = elements_eval_const(elements[3], name_list, name_list2, nest)
+      # return nil if( rhs == nil || mhs == nil || lhs == nil )
+      return nil if ! evaluable?( rhs, mhs, lhs )
+      if lhs.cast( BoolType.new ).val then
+          return mhs
+      else
+          return rhs
+      end
+    end
+    return nil
+  end
+
+  def elements_get_type( elements, namedList )
+    type = elements_get_type_sub( elements, namedList )
+    # è¿ãããæ¹ã DefinedType ã®å ´å å
+ã®åãè¿ã
+    if type.kind_of?( DefinedType ) then
+      type = type.get_type
+    end
+    return type
+  end
+
+  def elements_get_type_sub( elements, namedList )
+    case elements[0]
+    when :IDENTIFIER
+      nsp = elements[1]
+      if nsp.is_name_only? then
+        paramdecl = namedList.get_item( nsp.get_name )
+      else
+        paramdecl = nil
+      end
+      unless paramdecl then
+        cdl_error( "E1012 $1: not found in parameter list" , nsp.get_path_str )
+        return IntType.new(32)        # dummy result
+      end
+      return paramdecl.get_type
+# mikan get_type
+#    when :INTEGER_CONSTANT
+#    when :FLOATING_CONSTANT
+#    when :OCTAL_CONSTANT
+#    when :HEX_CONSTANT
+#    when :CHARACTER_LITERAL
+#    when :STRING_LITERAL_LIST
+#    when :PARENTHESES
+#    when :OP_SUBSC
+#    when :OP_DOT
+#    when :OP_REF
+#    when :OP_SIZEOF_EXPR
+#    when :OP_SIZEOF_TYPE
+#    when :OP_U_AMP
+    when :OP_U_ASTER
+      type = elements_get_type( elements[1], namedList )
+      unless type.kind_of?( PtrType ) then
+        cdl_error( "E1013 \'*\': operand is not pointer value"  )
+        return IntType.new( 8 )    # IntType ãè¿ãã¦ãã
+      end
+      return type.get_referto
+
+    when :OP_U_PLUS, :OP_U_MINUS
+      # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªã
+      return elements_get_type( elements[1], namedList )
+
+    when :OP_ADD, :OP_SUB, :OP_MULT, :OP_DIV, :OP_REMAIN
+      # mikan operand ãé©åãªåããã§ãã¯ãã¦ããªãï¼å·¦è¾ºã®åãæ¡ç¨ãã¦ãã
+      return elements_get_type( elements[1], namedList )
+
+    when :OP_U_TILDE
+      # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã
+      return elements_get_type( elements[1], namedList )
+    when :OP_AND, :OP_EOR, :OP_OR, :OP_LSFT, :OP_RSFT
+      # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã
+      return BoolType.new
+    when :OP_U_EXCLAM
+      # mikan operand ãæ´æ°ããã§ãã¯ãã¦ããªã
+      return BoolType.new
+
+    when :OP_LT, :OP_GT, :OP_LE, :OP_GE, :OP_EQ, :OP_NE, :OP_LAND, :OP_LOR, :OP_CEX, :CAST
+      cdl_error( "E1014 $1: elements_get_type: sorry not supported" , elements[0] )
+    end
+
+    return nil
+  end
+
+  # å¼ã size_is, count_is, string ã®å¼æ°ã§ããå ´åã®æ¹åã®ãã§ãã¯
+  def elements_check_dir_for_param( elements, namedList, dir, spec )
+   # dir ï¼ å
+ã®å¼æ°ã®æ¹å
+   # direct: size_is ãªã©ã®å¼æ°ã®å¤æ°ã®æ¹å
+
+    case elements[0]
+    when :IDENTIFIER
+      nsp = elements[1]
+      if nsp.is_name_only? then
+        paramdecl = namedList.get_item( nsp.get_name )
+      else
+        paramdecl = nil
+      end
+
+      return unless paramdecl      # if nil already error in element_get_type
+
+      direct = paramdecl.get_direction
+      judge = false
+      case spec
+      when "size_is", "string"
+        case dir
+        when :IN, :OUT, :INOUT, :SEND
+          judge = true if ( direct == :IN || direct == :INOUT )
+          req_direct = "in or inout"
+        when :RECEIVE
+          judge = true if ( direct == :OUT || direct == :INOUT )
+          req_direct = "out or inout"
+        end
+
+      when "count_is"
+        case dir
+        when :IN, :SEND
+          judge = true if ( direct == :IN || direct == :INOUT )
+          req_direct = "in or inout"
+        when :OUT, :RECEIVE     # mikan out ã§ count_is ã®ã¿æå®ããã¦ããå ´å in ã§ãªãã¦ã¯ãªããªã
+          judge = true if ( direct == :OUT || direct == :INOUT )
+          req_direct = "out or inout"
+        when :INOUT
+          judge = true if ( direct == :INOUT )
+          req_direct = "inout"
+        end
+      end
+
+      if judge == false then
+        cdl_error( "E1015 \'$1\': direction mismatch for $2, $3 required" , nsp.get_path_str, spec, req_direct )
+      end
+
+    when :INTEGER_CONSTANT, :FLOATING_CONSTANT, :OCTAL_CONSTANT, :HEX_CONSTANT, :CHARACTER_LITERAL, :STRING_LITERAL_LIST
+      return true
+
+    # åé 
+æ¼ç®å­
+    when :OP_U_ASTER, :OP_SIZEOF_EXPR, :OP_SIZEOF_TYPE, :OP_U_PLUS, :OP_U_MINUS, :OP_U_TILDE, :OP_U_EXCLAM, :CAST, :OP_U_AMP, :PARENTHESES,
+      elements_check_dir_for_param( elements[1], namedList, dir, spec )
+
+    # 2é 
+æ¼ç®å­
+    when :OP_SUBSC, :OP_DOT, :OP_REF, :OP_MULT, :OP_DIV, :OP_REMAIN, :OP_ADD, :OP_SUB, :OP_LSFT, :OP_RSFT, :OP_LT, :OP_GT, :OP_LE, :OP_GE, :OP_EQ, :OP_NE, :OP_AND, :OP_EOR, :OP_OR, :OP_LAND, :OP_LOR
+      return elements_check_dir_for_param( elements[1], namedList, dir, spec ) && elements_check_dir_for_param( elements[2], namedList, dir, spec )
+
+    # 3é 
+æ¼ç®å­
+    when :OP_CEX
+      return elements_check_dir_for_param( elements[1], namedList, dir, spec ) && elements_check_dir_for_param( elements[2], namedList, dir, spec ) && elements_check_dir_for_param( elements[3], namedList, dir, spec )
+
+    else
+      cdl_error( "E1016 $1: elements_check_dir_for_param: sorry not supported" , elements[0] )
+    end
+
+  end
+
+  #Express# get_allocator_rhs_elem
+  #alloc_type::Symbol  :NORMAL_ALLOC|:INTERNAL_ALLOC|:RELAY_ALLOC
+  #å¼ãã¢ã­ã±ã¼ã¿æå®å­ã®å³è¾ºã¨ãã¦å¦¥å½ããã§ãã¯ããæ­£ãããã°åè§£ããå¤ãè¿ã
+  #return:
+  #  :NORMAL_ALLOC      [ cell_nsp, ep_name ]               # rhs = cell_nsp.ep_name    ex) Alloc.eAlloc
+  #  :INTERNAL_ALLOC    [ ep_name ]                         # rhs = ep_name             ex) eAlloc
+  #  :RELAY_ALLOC       [ cp_name, func_name, param_name ]  # rhs = cp_name.func_name.param_name
+  def get_allocator_rhs_elements( alloc_type )
+    ele = @elements
+    case alloc_type 
+    when :NORMAL_ALLOC
+      if ele[0] != :OP_DOT || ele[1][0] != :IDENTIFIER then   #1
+        cdl_error( "E1017 $1: rhs not \'Cell.ePort\' form" , ele[0].to_s )
+        return nil
+      end
+      cell_nsp  = elements[1][1]
+      port_name = elements[2].val
+      return [ cell_nsp, port_name ]
+    when :INTERNAL_ALLOC
+      if( ele[0] == :IDENTIFIER )then
+        if ele[1].is_name_only? then
+          return [ ele[1].get_path[0] ]  # mikan a::b
+        else
+          cdl_error( "E1018 $1: namespace cannot be specified", ele[1].to_s )
+        end
+      else
+        cdl_error( "E1019 $1: rhs not in 'allocator_entry_port' form", ele[1].to_s )
+      end
+    when :RELAY_ALLOC
+      if( ele[0] != :OP_DOT ||
+          ele[1][0] != :OP_DOT || ele[1][1][0] != :IDENTIFIER || ! ele[1][1][1].is_name_only? ||
+          ! ele[1][2].instance_of?( Token ) || ! ele[2].instance_of?( Token ) )then   #1
+        cdl_error( "E1020 rhs not in 'call_port.func.param' form ($1)" , ele[0].to_s )   # S1086
+      end
+      func_name = ele[1][2]; cp_name = ele[1][1][1].get_name; param_name = ele[2].to_sym
+      return [ cp_name, func_name, param_name ]
+    end
+    return  nil
+  end
+
+  #Expression#Expression ã®ã¯ã­ã¼ã³ãä½æãã
+  def clone_for_composite
+    cl = self.clone
+    elements = clone_elements @elements
+    cl.set_elements elements
+    return cl
+  end
+
+  #Expression#elements ã®ã¯ã­ã¼ã³ãä½æ
+  #elements::Array
+  # ãã®ã¡ã½ããã¯ãArray ã®ãã£ã¼ãã³ãã¼ãè¡ã
+  def clone_elements elements
+    elements = elements.clone
+    elements.map!{ |ele|
+      if ele.instance_of? Array
+        clone_elements ele
+      else
+        ele
+      end
+    }
+    return elements
+  end
+
+  def set_elements elements
+    @elements = elements
+  end
+
+  #=== Expression#ã»ã«çµåã®å¼ãè§£æãã
+  # Cell.eEntry  => [ :OP_DOT, [ :IDENTIFIER, token ], token ]
+  # Cell.eEntry[expression] => [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ]
+  # Return: [ NamespacePath(cell_name), Integer(subscript) or nil, Token(port_name)]
+  def analyze_cell_join_expression
+    # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã
+    elements = @elements
+    if elements[0] == :OP_SUBSC then  # å³è¾ºï¼åãå£é
+åï¼
+      # elements = [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, token ], token ], expression ]
+      subscript = elements[2].eval_const(nil)  # åãå£é
+åã®æ·»æ°
+      elements  = elements[1]          # mikan é
+åã ã£ãå ´å
+    else
+      subscript = nil
+    end
+
+    # elements = [ :OP_DOT, [ :IDENTIFIER, token ], token ]
+    if elements[0] != :OP_DOT || elements[1][0] != :IDENTIFIER then   #1
+      return nil
+    end
+
+    nsp = elements[1][1]         # NamespacePath
+    port_name = elements[2].val
+
+    return [ nsp, subscript, port_name]
+  end
+
+  #=== Expression# ã»ã«ã¸ã®çµåã®å¼ãçæãã
+  #nsp:: NamespacePath
+  #subscript:: Integer
+  #port_name:: Symbol
+  # analyze_cell_join_expression ã¨å¯¾ã«ãªã£ã¦ãã
+  def self.create_cell_join_expression( nsp, subscript, port_name, locale = nil )
+    if ! port_name.instance_of?( Symbol ) then
+      raise "port_name: not Symbol"
+    end
+
+    if subscript then
+      elements = [ :OP_SUBSC, [ :OP_DOT, [ :IDENTIFIER, nsp ],
+                                Token.new( port_name, nil, nil, nil ) ],
+                   Expression.create_integer_constant( subscript, @locale ) ]
+    else
+      elements = [ :OP_DOT, [ :IDENTIFIER, nsp ], Token.new( port_name, nil, nil, nil ) ]
+    end
+    return Expression.new( elements, locale )
+  end
+
+  #=== Expression#æ´æ°å®æ°ã®å¼ãçæãã
+  #val:: Integer : å¤ï¼ æ´æ°
+  def self.create_integer_constant( val, locale = nil )
+    if val != Integer( val ) || val < 0 then
+      raise "create_integer_constant: not integer or negative: #{val}"
+    end
+    Expression.new( [ :INTEGER_CONSTANT, Token.new( val, nil, nil, nil ) ], locale )
+  end
+
+  #=== Expression#åä¸ã®è­å¥å­ã®å¼ãè§£æãã
+  # Identifier  => [ :IDENTIFIER, token ]
+  # Return: NamespacePath(Identifier)
+  def analyze_single_identifier
+    # å³è¾ºã® Expression ã®è¦ç´ ãåãåºã
+    elements = @elements
+    if elements[0] == :IDENTIFIER
+      return elements[1]
+    else
+      return nil
+    end
+  end
+
+  #=== Expression#
+  #nsp:: NamespacePath :  åç
+§ãããã®è­å¥å­
+  def self.create_single_identifier( nsp, locale )
+    if ! nsp.instance_of?( NamespacePath ) then
+      raise "create_single_identifier: not NamespacePath: #{nsp.to_s}"
+    end
+    Expression.new( [ :IDENTIFIER, nsp ] )
+  end
+
+  #=== è©ä¾¡å¯è½ããã§ãã¯ãã
+  #*v:: å¯å¤åå¼æ°ï¼ä»»æã®åï¼
+  # ãã¹ã¦ã BaseVal ã®å­ã¯ã©ã¹ï¼å¤ï¼ã§ããã°ãè©ä¾¡å¯è½ã¨å¤æ­ãã
+  def evaluable?( *v )
+    v.each{ |val|
+      if ! val.kind_of?( BaseVal ) then
+        return false
+      end
+    }
+    return true
+  end
+
+  private :elements_to_s, :elements_eval_const,  :elements_get_type
+
+end
+
+
+class C_EXP < Node
+# @c_exp_string : string
+
+  #c_exp_string::String
+  #b_renew::Bool  : true ãªã C_EXP ã® clone ä½æï¼ã¨ã¹ã±ã¼ãå¦çç­ãããªãï¼
+  def initialize( c_exp_string, b_renew = false )
+    if b_renew then
+      @c_exp_string = c_exp_string
+    else
+      # åå¾ã® " ãåãé¤ã
+      # str = c_exp_string.to_s.sub( /^\"(.*)\"$/, "\\1" )
+      str = CDLString.remove_dquote c_exp_string.to_s
+      @c_exp_string = CDLString.escape str
+    end
+  end
+
+  #=== composite ç¨ã« C_EXP ã clone ãã
+  #ct_name::
+  #cell_name::
+  # composite ã® attribute ã«ç¾ãã C_EXP ãæå­åç½®æãã¦çæããªããï¼
+  # ãã®æå­åç½®æã¯ãæå³è§£éæ®µéã§è¡ãï¼
+  # ä»ã® C_EXP ã®æå­åç½®æã¯ãã³ã¼ãçææ®µéã§è¡ãï¼
+  def clone_for_composite( ct_name, cell_name, locale )
+    dbgPrint "C_EXP: #{ct_name} #{cell_name} #{@c_exp_string}\n"
+
+    @locale = locale
+    str = @c_exp_string.gsub( /(^|[^\$])\$ct\$/, "\\1#{ct_name}" )
+    str = str.          gsub( /(^|[^\$])\$cell\$/, "\\1#{cell_name}" )
+    str = str.          gsub( /(^|[^\$])\$id\$/, "\\1#{ct_name}_#{cell_name}" )
+    return C_EXP.new( str, true )
+  end
+
+  def get_c_exp_string
+    @c_exp_string
+  end
+
+  #=== C_EXP ãè©ä¾¡ãã
+  # C_EXP ã®å¼ãæ°æå­åãè¿ã
+  # æ¬æ¥ C_EXP ã¯ eval_const ããå¯¾è±¡ã§ã¯ãªãããä¾¿å®ä¸ eval_const ã§å¯¾å¿
+  def eval_const( name_list, name_list2 = nil )
+     return self
+  end
+  def eval_const2( name_list, name_list2 = nil, nest = nil )
+     return self
+  end
+
+  def to_s
+    @c_exp_string
+  end
+
+  def to_CDL_str
+    return "C_EXP( \"#{to_s}\" )"
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "C_EXP: #{@c_exp_string}"
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/gen_xml.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/gen_xml.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/gen_xml.rb	(revision 317)
@@ -0,0 +1,394 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: gen_xml.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+XML_INDENT = "    "
+
+class Namespace
+  def self.gen_XML root_namespace
+    begin
+      file_name = $gen_base + "/" + $target + ".xml"
+      dbgPrint "generating XML file:#{file_name}\n"
+      file = AppFile.open( file_name )
+
+      file.print <<EOT
+<?xml version="1.0" encoding="UTF-8"?>
+<GUI_Tool xmlns="http://www.toppers.jp/tecs.html">
+EOT
+      root_namespace.gen_XML file, 1
+
+      file.print <<EOT
+</GUI_Tool>
+EOT
+
+      file.close
+    rescue => evar
+      Generator.error( "T2001 fail to create XML file $1", file_name)
+      print_exception( evar )
+    end
+  end
+
+  def gen_XML( file, nest )
+    # signature ã®ã³ã¼ããçæ
+    @signature_list.each { |s|
+      s.gen_XML file, nest
+    }
+
+    # celltype ã®ã³ã¼ããçæ
+    @celltype_list.each { |t|
+      t.gen_XML( file, nest )
+    }
+
+    # composite ã®ã³ã¼ããçæ
+    @compositecelltype_list.each { |t|
+      t.gen_XML( file, nest )
+    }
+
+    # cell ã®ã³ã¼ããçæ
+    @cell_list.each { |t|
+      t.gen_XML( file, nest )
+    }
+
+    # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ
+    @namespace_list.each { |n|
+      kind = n.instance_of?( Namespace ) ? "namespace" : "region"
+      file.print <<EOT
+#{XML_INDENT * nest}<#{kind}>
+#{XML_INDENT * (nest+1)}<name> #{n.get_name} </name>
+EOT
+      n.gen_XML( file, nest + 1 )
+      file.print <<EOT
+#{XML_INDENT * nest}</#{kind}>
+EOT
+    }
+  end
+end
+
+class Signature
+  def gen_XML file, nest
+    indent = XML_INDENT * nest
+    if is_imported? then
+      file.print <<EOT
+#{indent}<import path='#{@import.get_cdl_name}'>
+EOT
+      nest += 1
+      indent = XML_INDENT * nest
+    end
+
+    file.print <<EOT
+#{indent}<signature>
+#{indent}#{XML_INDENT}<name> #{@name} </name>
+EOT
+    @function_head_list.get_items.each{ |fh|
+      file.print <<EOT
+#{indent}#{XML_INDENT}<func>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{fh.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<rettype> #{fh.get_return_type.get_type_str}#{fh.get_return_type.get_type_str_post} </rettype>
+EOT
+      fh.get_paramlist.get_items.each{ |pd|
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<param>
+#{indent}#{XML_INDENT}#{XML_INDENT}#{XML_INDENT}<name> #{pd.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}#{XML_INDENT}<type> #{pd.get_type.get_type_str}#{pd.get_type.get_type_str_post} </type>
+#{indent}#{XML_INDENT}#{XML_INDENT}</param>
+EOT
+      }
+      file.print <<EOT
+#{indent}#{XML_INDENT}</func>
+EOT
+    }
+    file.print <<EOT
+#{indent}</signature>
+EOT
+    if is_imported? then
+      nest -= 1
+      indent = XML_INDENT * nest
+      file.print <<EOT
+#{indent}</import>
+EOT
+    end
+  end
+end
+
+class Celltype
+  def gen_XML file, nest
+    indent = XML_INDENT * nest
+    if is_imported? then
+      file.print <<EOT
+#{indent}<import path='#{@import.get_cdl_name}'>
+EOT
+      nest += 1
+      indent = XML_INDENT * nest
+    end
+
+    file.print <<EOT
+#{indent}<celltype>
+#{indent}#{XML_INDENT}<name> #{@name} </name>
+EOT
+    if @active then
+      file.print <<EOT
+#{indent}#{XML_INDENT}<active />
+EOT
+    end
+    if @singleton then
+      file.print <<EOT
+#{indent}#{XML_INDENT}<singleton />
+EOT
+    end
+
+    @attribute.each{ |attr|
+      file.print <<EOT
+#{indent}#{XML_INDENT}<attr>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{attr.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<type> #{attr.get_type.get_type_str}#{attr.get_type.get_type_str_post} </type>
+EOT
+      if attr.get_initializer then
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<initializer> #{attr.get_initializer.to_CDL_str} </initializer>
+EOT
+      end
+
+      if attr.get_choice_list then
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<choice>
+EOT
+
+        attr.get_choice_list.each { |choiceElement|
+          file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}#{XML_INDENT}<choiceElement>#{choiceElement}</choiceElement>
+EOT
+        }
+
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}</choice>
+EOT
+      end
+
+      file.print <<EOT
+#{indent}#{XML_INDENT}</attr>
+EOT
+    }
+    @port.each{ |port|
+      port_type = port.get_port_type == :CALL ? "call" : "entry"
+      file.print <<EOT
+#{indent}#{XML_INDENT}<#{port_type}>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{port.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<signame> #{port.get_signature.get_name} </signame>
+EOT
+      if port.get_array_size then
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<subscript> #{port.get_array_size} </subscript>
+EOT
+      end
+      file.print <<EOT
+#{indent}#{XML_INDENT}</#{port_type}>
+EOT
+    }
+    file.print <<EOT
+#{indent}</celltype>
+EOT
+    if is_imported? then
+      nest -= 1
+      indent = XML_INDENT * nest
+      file.print <<EOT
+#{indent}</import>
+EOT
+    end
+  end
+
+end
+
+#
+# Celltype ã¨å
+±ç¨å¯è½ãªã¯ãã ããä»¥ä¸ã®ç¹ã®å¤æ´ãå¿
+è¦
+#  @active â @b_active
+#  @singleton â @b_singleton
+#  @attribute â @name_list (Decl)
+#  @port â @name_list (Port)
+class CompositeCelltype
+  def gen_XML file, nest
+    indent = XML_INDENT * nest
+    if is_imported? then
+      file.print <<EOT
+#{indent}<import path='#{@import.get_cdl_name}'>
+EOT
+      nest += 1
+      indent = XML_INDENT * nest
+    end
+
+    file.print <<EOT
+#{indent}<celltype>
+#{indent}#{XML_INDENT}<name> #{@name} </name>
+EOT
+    file.print <<EOT
+#{indent}#{XML_INDENT}<composite />
+EOT
+
+    if @b_active then
+      file.print <<EOT
+#{indent}#{XML_INDENT}<active />
+EOT
+    end
+    if @b_singleton then
+      file.print <<EOT
+#{indent}#{XML_INDENT}<singleton />
+EOT
+    end
+
+    @name_list.get_items.each{ |attr|
+      if ! attr.instance_of? Decl then
+        next
+      end
+      file.print <<EOT
+#{indent}#{XML_INDENT}<attr>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{attr.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<type> #{attr.get_type.get_type_str}#{attr.get_type.get_type_str_post} </type>
+EOT
+      if attr.get_initializer then
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<initializer> #{attr.get_initializer.to_CDL_str} </initializer>
+EOT
+      end
+      file.print <<EOT
+#{indent}#{XML_INDENT}</attr>
+EOT
+    }
+    @name_list.get_items.each{ |port|
+      if ! port.instance_of? Port then
+        next
+      end
+      port_type = port.get_port_type == :CALL ? "call" : "entry"
+      file.print <<EOT
+#{indent}#{XML_INDENT}<#{port_type}>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{port.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<signame> #{port.get_signature.get_name} </signame>
+EOT
+      if port.get_array_size then
+        file.print <<EOT
+#{indent}#{XML_INDENT}#{XML_INDENT}<subscript> #{port.get_array_size} </subscript>
+EOT
+      end
+      file.print <<EOT
+#{indent}#{XML_INDENT}</#{port_type}>
+EOT
+    }
+    file.print <<EOT
+#{indent}</celltype>
+EOT
+    if is_imported? then
+      nest -= 1
+      indent = XML_INDENT * nest
+      file.print <<EOT
+#{indent}</import>
+EOT
+    end
+  end
+
+end
+
+class Cell
+  def gen_XML file, nest
+    indent = XML_INDENT * nest
+
+    if is_imported? then
+      file.print <<EOT
+#{indent}<import path='#{@import.get_cdl_name}'>
+EOT
+      nest += 1
+      indent = XML_INDENT * nest
+    end
+
+    file.print <<EOT
+#{indent}<cell>
+#{indent}#{XML_INDENT}<name> #{@name} </name>
+EOT
+    @join_list.get_items.each{ |join|
+      if join.get_definition.kind_of? Port then
+        kind = "call_join"
+      elsif join.get_definition.kind_of? Decl then
+        kind = "attr_join"
+      else
+        raise "Unknown"
+      end
+      if join.get_array_member2 then
+        join.get_array_member2.each { |j2|
+          file.print <<EOT
+#{indent}#{XML_INDENT}<#{kind}>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{join.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<subscript> #{join.get_subscript} </subscript>
+#{indent}#{XML_INDENT}#{XML_INDENT}<rhs> #{join.get_rhs.to_CDL_str} </rhs>
+#{indent}#{XML_INDENT}</#{kind}>
+EOT
+        }
+      else
+        file.print <<EOT
+#{indent}#{XML_INDENT}<#{kind}>
+#{indent}#{XML_INDENT}#{XML_INDENT}<name> #{join.get_name} </name>
+#{indent}#{XML_INDENT}#{XML_INDENT}<rhs> #{join.get_rhs.to_CDL_str} </rhs>
+#{indent}#{XML_INDENT}</#{kind}>
+EOT
+      end
+    }
+    file.print <<EOT
+#{indent}</cell>
+EOT
+    if is_imported? then
+      nest -= 1
+      indent = XML_INDENT * nest
+      file.print <<EOT
+#{indent}</import>
+EOT
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/generate.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/generate.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/generate.rb	(revision 317)
@@ -0,0 +1,4733 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: generate.rb 2507 2016-01-12 13:37:41Z okuma-top $
+#++
+
+def ifdef_macro_only f
+  f.print <<EOT
+#ifndef TOPPERS_MACRO_ONLY
+
+EOT
+end
+
+def ifndef_macro_only f
+  f.print <<EOT
+#ifndef TOPPERS_MACRO_ONLY
+
+EOT
+end
+
+def endif_macro_only f
+  f.print <<EOT
+#endif /* TOPPERS_MACRO_ONLY */
+
+EOT
+end
+
+def ifndef_cb_type_only f
+  f.print <<EOT
+#ifndef TOPPERS_CB_TYPE_ONLY
+
+EOT
+end
+
+def ifdef_cb_type_only f
+  f.print <<EOT
+#ifdef TOPPERS_CB_TYPE_ONLY
+
+EOT
+end
+
+def endif_cb_type_only f
+  f.print <<EOT
+#endif /* TOPPERS_CB_TYPE_ONLY */
+
+EOT
+end
+
+def begin_extern_C f
+  f.print  <<EOT
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+EOT
+end
+
+def end_extern_C f
+  f.print  <<EOT
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+EOT
+end
+
+def print_note( f, b_complete = true )
+  if b_complete
+    f.print "/*\n"
+  else
+    f.print " *\n"
+  end
+  f.print TECSMsg.get( :note )
+  if b_complete
+    f.print " */\n"
+  else
+    f.print " *\n"
+  end
+end
+
+def print_Makefile_note f
+  f.print TECSMsg.get( :Makefile_note )
+end
+
+
+def print_indent( f, n )
+  f.print "    " * n
+end
+
+# celltype_private.h ãçæ
+
+class Namespace
+  def generate
+
+    begin
+      # root namespace ãªãã° makefile ãåºåãã(å
+¨ã»ã«ã¿ã¤ãã«é¢ãããã®ã ã)
+      # å
+ã«åºåãã
+      if @name == "::" then
+
+        gen_makefile_template
+        gen_makefile_tecsgen
+        if $generating_region.get_n_cells == 0 then
+          dbgPrint "only makefile_template #{@name}\n"
+          return
+        end
+      end
+
+      dbgPrint "generating region: #{$generating_region.get_name} namespace=#{@name} gen_dir=#{$gen}\n"
+      # global_tecsgen.h (typedef, struct, const) ã®çæ
+      gen_global_header
+
+      # signature ã®ã³ã¼ããçæ
+      @signature_list.each { |s|
+        s.generate
+      }
+
+      # celltype ã®ã³ã¼ããçæ
+      @celltype_list.each { |t|
+        t.generate
+      }
+
+      # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ
+      @namespace_list.each { |n|
+        n.generate
+      }
+
+    rescue => evar
+      # ããã¹ã¿ãã¯ãã¬ã¼ã¹ãåºãã¾ã§ãæéãããããããªãã°ãæ¬¡ãã³ã¡ã³ãã¢ã¦ããã¦ã¿ãã¹ã
+      cdl_error( "H1001 tecsgen: fatal internal error during code generation"  )
+      print_exception( evar )
+    end
+  end
+
+  def generate_post
+
+    if $generating_region.get_n_cells == 0 then
+      return
+    end
+
+    begin
+      # global_tecsgen.h (typedef, struct, const) ã®çµããã®ã¬ã¼ãã³ã¼ãçæ
+      gen_global_header_post
+
+      # signature ã®ã³ã¼ããçæ
+      @signature_list.each { |s|
+        s.generate_post
+      }
+
+      # celltype ã®ã³ã¼ããçæ
+      @celltype_list.each { |t|
+        t.generate_post
+      }
+
+      # ãµããã¼ã ã¹ãã¼ã¹ã®ã³ã¼ããçæ
+      @namespace_list.each { |n|
+        n.generate_post
+      }
+
+    rescue => evar
+      cdl_error( "H1002 tecsgen: fatal internal error during post code generation"  )
+      print_exception( evar )
+    end
+  end
+
+###  
+  def gen_global_header
+
+    # global_tecs.h ã®çæ
+    f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" )
+
+    if @name == "::" then
+      print_note f
+
+      # ã¬ã¼ãã³ã¼ããåºå
+      f.print <<EOT
+#ifndef GLOBAL_TECSGEN_H
+#define GLOBAL_TECSGEN_H
+
+EOT
+
+      # import_C ã§æå®ãããããããã¡ã¤ã«ã® #include ãåºå
+      if Import_C.get_header_list2.length > 0 then
+        # ããã include ã®åºå
+        f.printf TECSMsg.get( :IMP_comment ), "#_IMP_#"
+        Import_C.get_header_list2.each{ |h|
+          f.printf( "#include \"#{h}\"\n" )
+        }
+        f.printf( "/**/\n\n" )
+      end
+
+      ifndef_macro_only f
+    end
+
+    # typedef, struct, enum ãçæ
+    @decl_list.each { |d|
+
+      # d ã¯ Typedef, StructType, EnumType ã®ãããã
+      if d.instance_of?( Typedef ) then
+
+        # Typedef ã®å ´åãdeclarator ã® @type ããCType ã§ãªãã
+        if ! d.get_declarator.get_type.kind_of?( CType ) then
+          d.gen_gh f
+        end
+      elsif ! d.kind_of?( CType ) then
+
+        # CType ã§ã¯ãªã (StructType ã¾ãã¯ EnumType)
+        d.gen_gh f
+#     else
+#       ããã«è©²å½ããã®ã¯ CStructType, CEnumType
+      end
+    }
+
+    if @name == "::" then
+
+      if $ram_initializer then
+        # Proc to judge the necessity of CB initializer
+        b_inline_only_or_proc = Proc.new{ |ct|
+          # print ct.get_name, ": ",  ct.need_CB_initializer?, "\n"
+          ct.need_CB_initializer?
+        }
+        gen_celltype_names( f, "extern void ", "_CB_initialize();\n", true, b_inline_only_or_proc )
+        gen_celltype_names( f, "extern void ", "_CB_initialize();\n", false, b_inline_only_or_proc )
+        f.print "\n#define INITIALIZE_TECS() \\\n"
+        gen_celltype_names( f, "\t", "_CB_initialize();\\\n", true, b_inline_only_or_proc )
+        gen_celltype_names( f, "\t", "_CB_initialize();\\\n", false, b_inline_only_or_proc )
+        f.print( "/* INITIALIZE_TECS terminator */\n\n" )
+      else
+        f.print "\n#define INITIALIZE_TECS() \n"
+      end
+      f.print "#define INITIALZE_TECSGEN() INITIALIZE_TECS()  /* for backward compatibility */\n\n"
+
+      f.print( "/* Descriptor for dynamic join */\n" )
+      f.print( "#define Descriptor( signature_global_name )  DynDesc__ ## signature_global_name\n\n" )
+      endif_macro_only f
+    end
+
+    # const ãçæ  mikan
+    @const_decl_list.each { |d|
+      f.printf( "#define %-14s ((%s%s)%s)\n", d.get_global_name,
+                d.get_type.get_type_str, d.get_type.get_type_str_post,
+                d.get_initializer.eval_const2(nil) )
+    }
+
+    f.close
+
+  end
+
+  def gen_global_header_post
+
+    # global_tecs.h ãéã
+    f = AppFile.open( "#{$gen}/global_tecsgen.#{$h_suffix}" )
+
+    if @name == "::" then
+      f.print <<EOT
+
+#endif /* GLOBAL_TECSGEN_H */
+EOT
+    end
+
+    f.close
+
+  end
+
+  #=== Makefile.tecsgen, Makefile.templ ã®åºå
+  # å
+¨ã»ã«ã¿ã¤ãåãåºåããé¨åãåºå
+  #    ï¼æ¬ã¡ã½ããã¯ root namespace ã«å¯¾ãã¦å¼åºãï¼
+  #     åã
+ã®ã»ã«ã¿ã¤ãã®ã¡ã¼ã¯ã«ã¼ã«ã¯ Celltype ã¯ã©ã¹ã§åºå
+  def gen_makefile
+    gen_makefile_template
+    gen_makefile_tecsgen
+  end
+
+  def gen_makefile_template
+
+    return if $generate_no_template
+
+    ### Makefile.templ ã®çæ
+    f = AppFile.open( "#{$gen}/Makefile.templ" )
+
+    print_Makefile_note f
+
+    # Makefile ã®å¤æ°ã®åºå
+    f.printf TECSMsg.get( :MVAR_comment ), "#_MVAR_#"
+    f.printf "# fixed variable (unchangeable by config or plugin)\n"
+
+    # TARGET ã®åºå (ç¬¬ä¸å¼æ° $target ã« region åããã³ .exe ãä»å )
+    target = $target
+    if $generating_region != @@root_namespace then
+      # å­ region ã®ãªã³ã¯ã¿ã¼ã²ããã®å ´å
+      target += "-#{$generating_region.get_global_name}"
+    end
+    f.print "TARGET_BASE = #{target}\n"
+
+    if $generating_region == @@root_namespace then
+      f.print "BASE_DIR = .\n"
+      vpath_lead = ""
+    else
+      f.print "BASE_DIR = ..\n"
+      vpath_lead = "../"
+    end
+
+    f.print "GEN_DIR = $(BASE_DIR)/#{$gen}\n"
+
+    f.print "INCLUDES ="
+    search_path = $import_path + TECSGEN::Makefile.get_search_path
+    search_path.each{ |path|
+      if TECSGEN.is_absolute_path? path then
+        f.print( TECSGEN.subst_tecspath " -I #{path}" )
+      else
+        f.print " -I $(BASE_DIR)/#{path}"
+      end
+    }
+    f.print " -I $(GEN_DIR)\n"
+    f.print "DEFINES ="
+    $define.each{ |define| f.print " -D #{define}" }
+    f.print "\n\n"
+    f.printf "# end of fixed variable (unchangeable by config or plugin)\n"
+
+
+    vpath_add = ""
+    search_path.each{ |path|
+      if path != "." then
+        if TECSGEN.is_absolute_path? path then
+          vpath_add += " " + TECSGEN.subst_tecspath( path )
+        else
+          vpath_add += " " + vpath_lead + path
+        end
+      end
+    }
+    objs_add = ""
+    TECSGEN::Makefile.get_objs.each{ |obj| objs_add += " " + obj }
+    ld_flag_add = TECSGEN::Makefile.get_ldflags
+    var_add = ""
+    TECSGEN::Makefile.get_vars.each{ |var|
+      var_add += "#" + TECSGEN::Makefile.get_var_comment( var ) + "\n"
+      a = TECSGEN::Makefile.get_var_val( var ).to_s
+      b = var.to_s
+      c = var_add.to_s
+      var_add += var.to_s + " =" + " " + TECSGEN::Makefile.get_var_val( var ).to_s + "\n\n"
+    }
+    pre_tecsgen_target = ""
+    TECSGEN::Makefile.get_pre_tecsgen_target{ |target| pre_tecsgen_target += " " + target }
+    post_tecsgen_target = ""
+    TECSGEN::Makefile.get_post_tecsgen_target{ |target| post_tecsgen_target += " " + target }
+
+#
+# LD = gcc
+# LDFLAGS =#{ld_flag_add}
+# SRC_DIR = $(BASE_DIR)/src
+# _TECS_OBJ_DIR = $(GEN_DIR)/
+# #   _TECS_OBJ_DIR   # should end with '/'
+
+    f.print <<EOT
+#{var_add}
+
+# Pre-tecsgen target
+PRE_TECSGEN_TARGET =#{pre_tecsgen_target}
+
+# Post-tecsgen target
+POST_TECSGEN_TARGET =#{post_tecsgen_target}
+
+# vpath for C sources and headers
+vpath %.#{$c_suffix} $(SRC_DIR) $(GEN_DIR) #{vpath_add}
+vpath %.#{$h_suffix} $(SRC_DIR) $(GEN_DIR) #{vpath_add}
+
+# Other objects (out of tecsgen)
+OTHER_OBJS =#{objs_add}                      # Add objects out of tecs care.
+# OTHER_OBJS = $(_TECS_OBJ_DIR)vasyslog.o
+EOT
+
+    # make ã«ã¼ã«ã®åºå
+    f.printf( TECSMsg.get( :MRUL_comment), "#_MRUL_#" )
+
+    f.print <<EOT
+allall: tecs
+\tmake all     # in order to include generated Makefile.tecsgen & Makefile.depend
+
+EOT
+
+    if $generating_region.get_n_cells != 0 then
+      all_target = "$(TARGET)"
+    else
+      all_target = ""
+    end
+
+    if $generating_region == @@root_namespace then
+      if Region.get_link_roots.length > 1 then
+        all_target += " sub_regions"
+      end
+      timestamp = " $(TIMESTAMP)"
+    else
+      timestamp = ""
+    end
+
+    f.print "all : #{all_target}\n\n"
+    f.printf TECSMsg.get( :MDEP_comment ), "#_MDEP_#"
+    f.print "-include $(GEN_DIR)/Makefile.tecsgen\n"
+    if $generating_region.get_n_cells != 0 then
+      # Makefile.depend ã® include
+      f.print "-include $(GEN_DIR)/Makefile.depend\n\n"
+
+      f.print "$(TARGET) :#{timestamp} $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS)\n"
+      f.print "	$(LD) -o $(TARGET) $(TECSGEN_COBJS) $(CELLTYPE_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(LDFLAGS)\n\n"
+    end
+
+    if Region.get_link_roots.length > 1 && $generating_region == @@root_namespace then
+      f.print "\nsub_regions:$(TIMESTAMP)\n"
+      Region.get_link_roots.each {|region|
+        if region.get_global_name != "" then  # Root region: ãã® Makefile èªèº«
+          f.print "\tcd #{region.get_global_name}; make all\n"
+        end
+      }
+      f.print "\n"
+    end
+
+    # clean: ã¿ã¼ã²ãã
+    f.print "clean :\n"
+    if $generating_region == @@root_namespace then
+      Region.get_link_roots.each {|region|
+        if region.get_global_name != "" then  # Root region: ãã® Makefile èªèº«
+          f.print "\tcd #{region.get_global_name}; make clean\n"
+        end
+      }
+    end
+	f.print "	rm -f $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(TARGET) #{timestamp}\n"
+    if $generating_region == @@root_namespace then
+      f.print "	rm -rf $(GEN_DIR)\n"
+    end
+    f.print "\n"
+
+    # tecs: ã¿ã¼ã²ãã
+    if $generating_region == @@root_namespace then
+      f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n"
+      f.print "$(TIMESTAMP) : $(TECS_IMPORTS)\n"
+      f.print "	$(TECSGEN) #{TECSGEN.subst_tecspath( $arguments, true )}\n"
+      # f.print "	touch $(TIMESTAMP)\n\n"
+
+    else
+      f.print "tecs:\n"
+      f.print "\t@echo \"run 'make tecs' in root region\"\n\n"
+    end
+
+    f.print "# generic target for objs\n"
+    f.print "$(_TECS_OBJ_DIR)%.o : %.#{$c_suffix}\n"
+    f.print "	$(CC) -c $(CFLAGS) -o $@ $<\n\n"
+
+    lines = TECSGEN::Makefile.get_lines
+    if lines.length > 0 then
+      f.print( "# additional lines\n" )
+      lines.each{ |line|
+        f.print  line, "\n"
+      }
+      f.print( "# end additional lines\n\n" )
+    end
+
+    f.close
+  end
+
+  def gen_makefile_tecsgen
+    ### Makefile.tecsgen ã®çæ
+    f = AppFile.open( "#{$gen}/Makefile.tecsgen" )
+
+    f.print( "TECS_IMPORT_CDLS =" )
+    Import.get_list.each{ |cdl_expand_path, import|
+      path = import.get_cdl_path
+      if TECSGEN.is_absolute_path? path then
+        path = TECSGEN.subst_tecspath path
+      end
+      f.print " "
+      f.print( path )
+    }
+    f.print( "\n" )
+    f.print( "TECS_IMPORT_HEADERS =" )
+    Import_C.get_header_list.each{ |header,path|
+      if TECSGEN.is_absolute_path? path then
+        path = TECSGEN.subst_tecspath path
+      end
+      f.print " "
+      f.print path
+    }
+    f.print "\n"
+    f.print "TECS_IMPORTS = $(TECS_IMPORT_CDLS) $(TECS_IMPORT_HEADERS)\n\n"
+
+    f.print "SIGNATURE_HEADERS = \\\n"
+    if $generating_region.get_n_cells != 0 then
+      @signature_list.each{ |s|
+        f.print "\t$(GEN_DIR)/#{s.get_global_name}_tecsgen.#{$h_suffix} \\\n"
+      }
+    end
+    f.print "# SIGNATURE_HEADERS terminator\n\n"
+
+    b_inline_only_or_proc = Proc.new { |ct|  true    }
+    f.print "CELLTYPE_TECSGEN_HEADERS = \\\n"
+    gen_celltype_names( f, "\t$(GEN_DIR)/", "_tecsgen.h \\\n", true, b_inline_only_or_proc )
+    gen_celltype_names( f, "\t$(GEN_DIR)/", "_tecsgen.h \\\n", false, b_inline_only_or_proc )
+    f.print "# CELLTYPE_TECSGEN_HEADERS terminator\n\n"
+    f.print "CELLTYPE_FACTORY_HEADERS = \\\n"
+    gen_celltype_names( f, "\t$(GEN_DIR)/", "_factory.h \\\n", true, b_inline_only_or_proc )
+    gen_celltype_names( f, "\t$(GEN_DIR)/", "_factory.h \\\n", false, b_inline_only_or_proc )
+    f.print "# CELLTYPE_FACTORY_HEADERS terminator\n\n"
+    f.print "# TECS_HEADERS:  headers generated by tecsgen\n"
+    f.print "TECS_HEADERS = $(SIGNATURE_HEADERS) $(CELLTYPE_TECSGEN_HEADERS) $(CELLTYPE_FACTORY_HEADERS)\n\n"
+    b_inline_only_or_proc = true
+    f.print "TECS_INLINE_HEADERS = \\\n"
+    gen_celltype_names( f, "\t", "_tecsgen.h \\\n", false, b_inline_only_or_proc )
+    f.print "# TECS_INLINE_HEADERS terminator\n\n"
+    f.print "PLUGIN_INLINE_HEADERS = \\\n"
+    gen_celltype_names( f, "\t", "_tecsgen.h \\\n", true, b_inline_only_or_proc )
+    f.print "# PLUGIN_INLINE_HEADERS terminator\n\n"
+
+    ### set domain variables ###
+    domain_type = nil
+    domain_regions = nil
+    DomainType.get_domain_regions.each{ |dt, regions|
+      # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ã¯ãä¸ã¤ãããªãã®ã§ããã®ã«ã¼ãã¯ãå¿
+ãä¸åããåããªã
+      domain_regions = regions
+      domain_type = dt
+    }
+    if domain_regions == nil then
+      # in case no 'domain' specified at region
+      domain_regions = [ Region.get_root ]
+    end
+
+    hasDomainProc = Proc.new{
+      if domain_regions.length > 1 || domain_regions[0] != Region.get_root then
+        true
+      else
+        false
+      end
+    }
+    decideDomainNameProc = Proc.new { |region|
+      if region.is_root? then
+        if hasDomainProc.call then
+          dn = "_Root_"
+        else
+          dn = ""
+        end
+      else
+        dn = "_#{region.get_namespace_path.get_global_name}"
+      end
+    }
+
+    f.print( "# TECS_COBJS: all objects of TECS, include both user written code and tecsgen automatically generated code\n" )
+    f.print( "TECS_COBJS = $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(CELLTYPE_COBJS)\n\n" )
+
+    ### in case domain is used ###
+    if hasDomainProc.call then
+
+      f.print( "# TECS_DOMAINS: list of domain names (names of 'domain' spacified region)\n" )
+      f.print( "TECS_DOMAINS = " )
+      domain_regions.each{ |r|
+        if r.get_domain_type.get_option != "OutOfDomain" then
+          f.print( " #{r.get_namespace_path.get_global_name}" )
+        end
+      }
+      f.print( "\n\n" )
+
+      f.print( "# TECS_COBJS: objects from sources which are automatically generated by tecsgen\n" )
+      f.print( "TECSGEN_COBJS = \\\n" )
+      domain_regions.each{ |r|
+        f.print( "	$(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" )
+      }
+      f.print( "# TECSGEN_COBJS terminator\n\n" )
+
+      f.print( "# PLUGIN_COBJS: objects from sources which are automatically generated by plugin(s)\n" )
+      f.print( "PLUGIN_COBJS = \\\n" )
+      domain_regions.each{ |r|
+        f.print( "	$(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" )
+      }
+      f.print( "# PLUGIN_COBJS terminator\n\n" )
+
+      f.print( "CELLTYPE_COBJS = \\\n" )
+      domain_regions.each{ |r|
+        f.print( "	$(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" )
+      }
+      f.print( "# CELLTYPE_COBJS terminator\n\n" )
+
+      f.print( "TECSGEN_SRCS = \\\n" )
+      domain_regions.each{ |r|
+        f.print( "	$(TECSGEN#{decideDomainNameProc.call r}_SRCS) \\\n" )
+      }
+      f.print( "# TECSGEN_SRCS terminator\n\n" )
+
+      f.print( "PLUGIN_SRCS = \\\n" )
+      domain_regions.each{ |r|
+        f.print( "	$(PLUGIN#{decideDomainNameProc.call r}_SRCS) \\\n" )
+      }
+      f.print( "# PLUGIN#_SRCS terminator\n\n" )
+    end
+
+    ###
+    f.print( "# TECS_COBJS: objects from sources which are automatically generated by tecsgen\n" )
+    domain_regions.each{ |r|
+      nsp = decideDomainNameProc.call( r )
+      f.print( "TECSGEN#{nsp}_COBJS = \\\n" )
+      gen_celltype_names_domain( f, "	$(_TECS_OBJ_DIR)", "_tecsgen.o \\\n", domain_type, r, false )
+      f.print( "# TECSGEN#{nsp}_COBJS terminator\n\n" )
+    }
+
+    f.print( "# PLUGIN_COBJS: objects from sources which are automatically generated by plugin(s)\n" )
+    domain_regions.each{ |r|
+      nsp = decideDomainNameProc.call( r )
+      f.print( "PLUGIN#{nsp}_COBJS = \\\n" )
+      gen_celltype_names_domain( f, "	$(_TECS_OBJ_DIR)", "_tecsgen.o \\\n", domain_type, r, true )
+      gen_celltype_names_domain2( f, "	$(_TECS_OBJ_DIR)", ".o \\\n", domain_type, r, true, false )
+      f.print( "# PLUGIN#{nsp}_COBJS terminator\n\n" )
+    }
+
+    f.print( "# CELLTYPE_COBJS: objects of celltype code written by user\n" )
+    domain_regions.each{ |r|
+      nsp = decideDomainNameProc.call( r )
+      f.print( "CELLTYPE#{nsp}_COBJS = \\\n" )
+      gen_celltype_names_domain2( f, "	$(_TECS_OBJ_DIR)", ".o \\\n", domain_type, r, false, false )
+      f.print( "# CELLTYPE#{nsp}_COBJS terminator\n\n" )
+    }
+
+    f.print( "# TECSGEN_SRCS: sources automatically generated by tecsgen\n" )
+    domain_regions.each{ |r|
+      nsp = decideDomainNameProc.call( r )
+      f.print( "TECSGEN#{nsp}_SRCS = \\\n" )
+      gen_celltype_names_domain( f, "	$(GEN_DIR)/", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, false )
+      f.print( "# TECSGEN#{nsp}_SRCS terminator\n\n" )
+    }
+
+    f.print( "# PLUGIN_SRCS: sources automatically generated by plugin\n" )
+    domain_regions.each{ |r|
+      nsp = decideDomainNameProc.call( r )
+      f.print( "PLUGIN#{nsp}_SRCS = \\\n" )
+      gen_celltype_names_domain( f, "	$(GEN_DIR)/", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, true )
+      gen_celltype_names_domain2( f, "	$(GEN_DIR)/", ".#{$c_suffix} \\\n", domain_type, r, true, false )
+      f.print( "# PLUGIN#{nsp}_SRCS terminator\n\n" )
+    }
+
+    f.close
+
+  end
+
+  #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå
+  #f::       FILE:   åºåå
+ãã¡ã¤ã«
+  #prepend:: string: åç½®æå­å
+  #append::  string: å¾ç½®æå­å
+  #b_plguin::  bool:   plugin ã«ããçæãããã»ã«ã¿ã¤ããåºå
+  ##b_inline_only::  bool:   true ãªãã° inline ã® entry port ã®ã¿ã®ã»ã«ã¿ã¤ããå«ãã
+  #b_inline_only_or_proc::  bool|Proc:   true ãªãã° inline ã® entry port ã®ã¿ããã¤ã¤ã³ã¢ã¯ãã£ããªã»ã«ã¿ã¤ããå«ãã
+  #                                      Proc ãªãã° Proc ãå®è¡ããçµæ true ãªãã°å«ãã
+  #  namespace "::" ããå¼åºããã
+  def gen_celltype_names( f, prepend, append, b_plugin, b_inline_only_or_proc = true )
+    dbgPrint "gen_celltype_names #{@name}\n"
+
+    @celltype_list.each { |ct|
+      next if ! ct.need_generate?
+#      next if b_inline_only == false && ct.is_all_entry_inline?
+      next if b_inline_only_or_proc == false && ct.is_all_entry_inline? && ! ct.is_active?
+      # print "Proc:", b_inline_only_or_proc.kind_of?( Proc ), b_inline_only_or_proc.class, "\n"
+      next if b_inline_only_or_proc.kind_of?( Proc ) && ( b_inline_only_or_proc.call( ct ) == false )
+      if ( b_plugin && ct.get_plugin ) || ( ! b_plugin && ! ct.get_plugin ) then
+        f.print " #{prepend}#{ct.get_global_name}#{append}"
+      end
+    }
+    @namespace_list.each { |ns|
+      ns.gen_celltype_names( f, prepend, append, b_plugin, b_inline_only_or_proc )
+    }
+
+  end
+
+  #=== ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå
+  #region:: Region:
+  # gen_celltype_names ã¨gen_celltype_names_domain ã®ç¸éï¼
+  #   region ã domain_roots ã«å«ãå ´åãåºåããï¼
+  #   ã¾ãã¯ãregion ãå«ã¾ãªãããdomain_roots ãè¤æ°ãã¤ã«ã¼ããªã¼ã¸ã§ã³ã®å ´åãåºåããï¼
+  # ããä»¥å¤ã¯ãgen_celltype_names ã®èª¬æãåç
+§
+  def gen_celltype_names_domain( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true )
+    dbgPrint "gen_celltype_names #{@name}\n"
+
+    @celltype_list.each { |ct|
+      next if ! ct.need_generate?
+#      next if b_inline_only == false && ct.is_all_entry_inline?
+      next if b_inline_only == false && ct.is_all_entry_inline? && ! ct.is_active?
+      if ( b_plugin && ct.get_plugin ) || ( ! b_plugin && ! ct.get_plugin ) then
+        regions = ct.get_domain_roots[ domain_type ]
+        if regions.include?( region ) then
+          # p "BBB celltype:#{ct.get_name} domain:#{domain_type} append:#{append}"
+          if region.is_root? then
+            nsp = ""
+          else
+            nsp = "_#{region.get_namespace_path.get_global_name}"
+          end
+          f.print " #{prepend}#{ct.get_global_name}#{nsp}#{append}"
+        elsif region.is_root? then
+          # the case of domain_roots >= 2 && no cell in root region
+          if regions.length > 1 then
+            f.print " #{prepend}#{ct.get_global_name}#{append}"
+          end
+        end
+      end
+    }
+    @namespace_list.each { |ns|
+      ns.gen_celltype_names_domain( f, prepend, append, domain_type, region, b_plugin, b_inline_only )
+    }
+  end
+  #== Namespace#ãã¹ã¦ã®ã»ã«ã¿ã¤ãã®ååãåºå
+  # ã»ã«ã¿ã¤ãã³ã¼ãã®ããã®åååºå
+  # gen_celltype_names_domain ã¨ gen_celltype_names_domain2 ã®ç¸é
+  # ã»ã©ããä¸ã¤ã®ãªã¼ã¸ã§ã³ã«ããåºããªã
+  #     domain_roots ã1ã¤ã ãã§ãæå®ãªã¼ã¸ã§ã³ãå«ã
+  #     domain_roots ã2ã¤ä»¥ä¸ã§ãæå®ãªã¼ã¸ã§ã³ãã«ã¼ããªã¼ã¸ã§ã³ 
+  # ã»ãã¡ã¤ã³åãä»å ããªã
+  def gen_celltype_names_domain2( f, prepend, append, domain_type, region, b_plugin, b_inline_only = true )
+    dbgPrint "gen_celltype_names #{@name}\n"
+
+    @celltype_list.each { |ct|
+      next if ! ct.need_generate?
+#      next if b_inline_only == false && ct.is_all_entry_inline?
+      next if b_inline_only == false && ct.is_all_entry_inline? && ! ct.is_active?
+      if ( b_plugin && ct.get_plugin ) || ( ! b_plugin && ! ct.get_plugin ) then
+        # p "BBB celltype:#{ct.get_name} domain:#{domain_type} append:#{append}"
+        regions = ct.get_domain_roots[ domain_type ]
+        if regions.include?( region ) && regions.length == 1 then
+          f.print " #{prepend}#{ct.get_global_name}#{append}"
+        elsif region.is_root? then
+          # the case of domain_roots >= 2 && no cell in root region
+          if regions.length > 1 then
+            f.print " #{prepend}#{ct.get_global_name}#{append}"
+          end
+        end
+      end
+    }
+    @namespace_list.each { |ns|
+      ns.gen_celltype_names_domain2( f, prepend, append, domain_type, region, b_plugin, b_inline_only )
+    }
+  end
+
+end
+
+class Typedef
+  def gen_gh f
+
+#    print "Typedef.gen_gh\n"
+#    show_tree 1
+
+    f.printf( "typedef %-14s %s%s;\n",
+		"#{@declarator.get_type.get_type_str}",
+		"#{@declarator.get_name}",
+		"#{@declarator.get_type.get_type_str_post}")
+  end
+end
+
+class StructType < Type
+  def gen_gh f
+
+#    print "StructType.gen_gh\n"
+#    show_tree 1
+
+    if ! @b_define then
+      return
+    end
+
+    f.print "struct #{@tag} {\n"
+
+    @members_decl.get_items.each{ |i|
+      f.printf( "                %-14s %s%s;\n", "#{i.get_type.get_type_str}", "#{i.get_name}", "#{i.get_type.get_type_str_post}" )
+    }
+
+    f.print "};\n"
+
+  end
+end
+
+class Signature
+
+  def generate
+    generate_signature_header
+  end
+
+  def generate_post
+    generate_signature_header_post
+  end
+
+  def generate_signature_header
+    f = AppFile.open("#{$gen}/#{@global_name}_tecsgen.#{$h_suffix}")
+
+    print_note f
+    gen_sh_guard f
+    gen_sh_info f
+    gen_sh_include f
+
+    ifndef_macro_only f
+    gen_sh_func_tab f
+    endif_macro_only f
+    gen_sh_func_id f
+
+    f.close
+  end
+
+  def generate_signature_header_post
+    f = AppFile.open("#{$gen}/#{@global_name}_tecsgen.#{$h_suffix}")
+    gen_sh_endif f
+    f.close
+  end
+
+
+#####  signature header
+
+  def gen_sh_guard f
+    f.print("#ifndef #{@global_name}_TECSGEN_H\n")
+    f.print("#define #{@global_name}_TECSGEN_H\n\n")
+  end
+
+  def gen_sh_info f
+    f.print <<EOT
+/*
+ * signature   :  #{@name}
+ * global name :  #{@global_name}
+ * context     :  #{get_context}
+ */
+
+EOT
+  end
+
+  def gen_sh_include f
+    dl = get_descriptor_list
+    if dl.length > 0 then
+      f.printf TECSMsg.get(:SDI_comment), "#_SDI_#"
+      dl.each{ |dt,param|
+        f.print "#include \"#{dt.get_signature.get_global_name}_tecsgen.#{$h_suffix}\"\n"
+      }
+      f.print "\n"
+    end
+
+  end
+
+  def gen_sh_func_tab f
+
+    # ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ã®åºå
+    f.printf TECSMsg.get(:SD_comment), "#_SD_#"
+    f.print "struct tag_#{@global_name}_VDES {\n"
+    f.print "    struct tag_#{@global_name}_VMT *VMT;\n"
+    f.print "};\n\n"
+
+    # ã·ã°ããã£é¢æ°ãã¼ãã«ã®åºå
+    f.printf TECSMsg.get(:SFT_comment), "#_SFT_#"
+    f.print( "struct tag_#{@global_name}_VMT {\n" )
+    get_function_head_array.each{ |fun|
+      f.print "    "
+      functype = fun.get_declarator.get_type
+      f.printf( "%-14s", functype.get_type_str )
+
+      f.print( " (*#{fun.get_name}__T)(" )
+      f.print( " const struct tag_#{@global_name}_VDES *edp" ) unless @singleton
+
+      if functype.get_paramlist then
+        items = functype.get_paramlist.get_items
+        len = items.length
+      else
+        # ããã§ nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å
+        items = []
+        len = 0
+      end
+
+      i = 0
+      items.each{ |param|
+        f.print ", "
+        f.print( param.get_type.get_type_str )
+        f.print( " " )
+        f.print( param.get_name )
+        f.print( param.get_type.get_type_str_post )
+        i += 1
+      }
+      f.print " );\n"
+    }
+    if get_function_head_array.length == 0 then
+      f.print( "    void   (*dummy__)(void);\n" )
+    end
+
+    f.print "};\n"
+    f.printf "\n"
+    f.printf TECSMsg.get(:SDES_comment), "#_SDES_#"
+    f.print( "typedef struct { struct tag_#{@global_name}_VDES *vdes; } Descriptor( #{@global_name} );\n" )
+  end
+
+  #=== Signature# é¢æ°ã® ID ã® define ãåºå
+  def gen_sh_func_id f
+    f.print "/* function id */\n"
+    get_function_head_array.each{ |fun|
+      f.printf( "#define\tFUNCID_%-31s (%d)\n", "#{@global_name}_#{fun.get_name}".upcase, get_id_from_func_name( fun.get_name ) )
+    }
+    f.print "\n"
+  end
+
+  def gen_sh_endif f
+    f.print("#endif /* #{@global_name}_TECSGEN_H */\n")
+  end
+
+end
+
+class Celltype
+
+  def generate
+
+    if need_generate?    # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã
+
+      generate_private_header
+      generate_factory_header
+      generate_cell_code
+      generate_template_code
+      generate_inline_template_code
+      generate_celltype_factory_code
+      generate_cell_factory_code
+      generate_makefile
+
+    elsif $generate_all_template   # ãã³ãã¬ã¼ãã³ã¼ãçæãªãã·ã§ã³
+
+      generate_template_code
+      generate_inline_template_code
+
+      # generate_makefile_template ã¯ Makefile ã«è¿½è¨ãããã®ã ãããå¼ã³åºããªã
+
+    end
+
+  end
+
+  def generate_post
+    return if ! need_generate?    # ã»ã«ã®ãªãã»ã«ã¿ã¤ãã¯çæããªã
+
+    generate_private_header_post
+    generate_factory_header_post
+  end
+
+  def generate_private_header
+
+    f = AppFile.open("#{$gen}/#{@global_name}_tecsgen.#{$h_suffix}")
+
+    print_note f
+
+    gen_ph_guard f
+    gen_ph_info f
+    gen_ph_include f
+    #
+    ifndef_macro_only f
+    begin_extern_C f
+    gen_ph_cell_cb_type f
+    gen_ph_INIB_as_CB f
+    gen_ph_extern_cell f          # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ãä»¥å¤ã¯åç
+§ããªã
+    gen_ph_typedef_idx f          # mikan åç
+§ãããã®ãã§ãã¦ããªã
+    gen_ph_ep_fun_prototype f
+    end_extern_C f
+    endif_macro_only f
+	#
+    gen_ph_include_cb_type f
+
+    if @n_entry_port_inline == 0 then
+      # inline ããªããã° CB_TYPE_ONLY ã¨ãã
+      # inline ããã®å ´åããã£ãã define ãã¦ããã¦ãå¾ã§ãã¹ã¦ undef ãã
+      ifndef_cb_type_only f
+    end
+
+    gen_ph_base f
+    gen_ph_valid_idx f
+    gen_ph_n_cp f                 if @n_call_port_array > 0
+    gen_ph_n_ep f                 if @n_entry_port_array > 0
+    gen_ph_test_optional_call_port f
+    gen_ph_get_cellcb f
+    gen_ph_attr_access f          if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0
+    gen_ph_cp_fun_macro f         if @n_call_port > 0
+#    gen_ph_abstract_ep_des_type f
+
+    if @n_entry_port_inline == 0 then
+      endif_cb_type_only f
+    end
+
+    ifndef_macro_only f
+    begin_extern_C f
+#    gen_ph_cell_cb_type f
+#    gen_ph_INIB_as_CB f
+#    gen_ph_extern_cell f          # ã»ã«ã¿ã¤ãã°ã«ã³ã¼ãä»¥å¤ã¯åç
+§ããªã
+    # gen_ph_typedef_idx f          # mikan åç
+§ãããã®ãã§ãã¦ããªã
+#    gen_ph_ep_fun_prototype f
+    gen_ph_ep_skel_prototype f
+    end_extern_C f
+    endif_macro_only f
+
+    # ç­ç¸®å½¢ãªã©ã®ãã¯ã­åºå
+    if @n_entry_port_inline == 0 then
+      ifndef_cb_type_only f
+    end
+    gen_ph_valid_idx_abbrev f
+    gen_ph_get_cellcb_abbrev f
+    gen_ph_attr_access_abbrev f   if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0
+    gen_ph_cp_fun_macro_abbrev f  if @n_call_port > 0
+    gen_ph_test_optional_call_port_abbrev f
+    gen_ph_ep_fun_macro f         if @n_entry_port > 0
+    gen_ph_foreach_cell f         # FOREACH ãã¯ã­ã®åºå
+    gen_ph_cb_initialize_macro f   # CB åæåãã¯ã­ã®åºåï¼æ¶è²»ããªãã®ã§ ram_initializer ãã©ã°ã«é¢ãããåºå
+    gen_ph_dealloc_code f, ""
+    gen_ph_dealloc_code f, "_RESET"
+    if @n_entry_port_inline == 0 then
+      endif_cb_type_only f
+    end
+
+    f.close
+  end
+
+  def generate_private_header_post
+
+    f = AppFile.open("#{$gen}/#{@global_name}_tecsgen.#{$h_suffix}")
+
+    ifndef_macro_only f
+    gen_ph_inline f
+    endif_macro_only f
+
+    if @n_entry_port_inline > 0 then
+      ifdef_cb_type_only f
+      f.printf TECSMsg.get( :UDF_comment ), "#_UDF_#"
+      f.print "#undef VALID_IDX\n"
+      f.print "#undef GET_CELLCB\n"
+      f.print "#undef CELLCB\n"
+      f.print "#undef CELLIDX\n"
+      f.print "#undef #{@name}_IDX\n"
+
+      f.print "#undef FOREACH_CELL\n"
+      f.print "#undef END_FOREACH_CELL\n"
+      f.print "#undef INITIALIZE_CB\n"
+      f.print "#undef SET_CB_INIB_POINTER\n"
+
+      @attribute.each { |a|
+        f.print( "#undef ATTR_#{a.get_name}\n" )
+        f.print( "#undef #{@global_name}_ATTR_#{a.get_name}\n" )
+        f.print( "#undef #{@global_name}_GET_#{a.get_name}\n" )
+      }
+      @var.each { |v|
+        f.print( "#undef VAR_#{v.get_name}\n" )
+        f.print( "#undef VAR_#{v.get_name}\n" )
+        f.print( "#undef #{@global_name}_VAR_#{v.get_name}\n" )
+        f.print( "#undef #{@global_name}_GET_#{v.get_name}\n" )
+        f.print( "#undef #{@global_name}_SET_#{v.get_name}\n" )
+      }
+      @port.each { |p|
+        next if p.get_port_type != :CALL
+
+        # is_...joined ã¯ omit ããã±ã¼ã¹ã§ãåºåããããããomit ãæ¤æ»ããåã«åºå
+        if p.is_optional? then
+          f.print( "#undef is_#{p.get_name}_joined\n" )
+        end
+
+        next if p.is_omit?
+
+        p.get_signature.get_function_head_array.each{ |fun|
+          f.print( "#undef #{@global_name}_#{p.get_name}_#{fun.get_name}\n" )
+          if ! p.is_require? || p.has_name? then
+            f.print( "#undef #{p.get_name}_#{fun.get_name}\n" )
+          else
+            f.print( "#undef #{fun.get_name}\n" )
+          end
+        }
+      }
+      @port.each { |p|
+        next if p.get_port_type != :ENTRY
+        next if p.is_omit?
+        p.get_signature.get_function_head_array.each{ |fun|
+          f.print( "#undef #{p.get_name}_#{fun.get_name}\n" )
+        }
+      }
+
+      gen_ph_dealloc_code( f, "", true )
+      gen_ph_dealloc_code( f, "_RESET", true )
+
+      endif_cb_type_only f
+    end
+
+    gen_ph_endif f
+
+    f.close
+  end
+
+  #=== CELLTYPE_tecsgen.c ãçæ
+  def generate_cell_code
+    fs = { }
+    f = nil
+    @domain_roots.each{ |domain_type_name, regions|
+      regions.each{ |r|
+        if r.is_root? then
+          nsp = ""
+        else
+          nsp = "_#{r.get_namespace_path.get_global_name}"
+        end
+        # p "celltype:#{@name} dn:#{domain_type_name} nsp:#{nsp}"
+        fs[r] = AppFile.open("#{$gen}/#{@global_name}#{nsp}_tecsgen.#{$c_suffix}")
+        if r.is_root? then
+          f = fs[r]
+        end
+      }
+    }
+
+    # in case that domain_roots does not include root region
+    if f == nil then
+      regions = nil
+      @domain_roots.each{ |domain_type_name, regions_|
+        regions = regions_   # domain_type_name is unique
+      }
+      if regions.length > 1 then 
+        # if domain_roots.length >= 2 && no cell in root region
+        # shared code are placed in root region
+        f = AppFile.open("#{$gen}/#{@global_name}_tecsgen.#{$c_suffix}")
+      else
+        # shared code are placed in unique region
+        f = fs[ regions[0] ]
+      end
+    end
+
+    # ãã¹ã¦ã® _tecsgen.c ã«åºå
+    print_note f
+    gen_cell_private_header f
+    gen_cell_factory_header f
+    gen_cell_ep_des_type f
+
+    # ãã¹ã¦ã® _tecsgen.c ã«åºå
+    fs.each{ |r,f2|
+      if f == f2 then
+        next
+      end
+      print_note f2
+      gen_cell_private_header f2
+      gen_cell_factory_header f2
+      gen_cell_ep_des_type f2
+    }
+
+    # ä¸ã¤ã® _tecsgen.c ã«åºå
+    gen_cell_skel_fun f
+    gen_cell_fun_table f
+    gen_cell_var_init f
+
+    # ã»ã«ãã¨ã« _tecsgen.c ã«åºå
+    gen_cell_ep_vdes fs
+    gen_cell_ep_vdes_array fs
+    gen_cell_cb_out_init fs         # INITIALIZE_CB ã§åç
+§ããããã ram_initializer=false ã§ãæ¶ããªã
+    gen_cell_cb fs
+    gen_cell_extern_mt fs
+    gen_cell_ep_des fs
+
+    # ä¸ã¤ã® _tecsgen.c ã«åºå
+    gen_cell_cb_tab f
+    if $ram_initializer then
+      gen_cell_cb_initialize_code f
+    end
+
+    fs.each{ |r,f2|
+      f2.close
+      if f == f2 then
+        f = nil
+      end
+    }
+    if f then
+      f.close
+    end
+
+  end
+
+#####  celltype header
+
+  def gen_ph_guard( f, post = "TECSGEN" )
+    f.print("#ifndef #{@global_name}_#{post}_H\n")
+    f.print("#define #{@global_name}_#{post}_H\n\n")
+  end
+
+  def gen_ph_info f
+
+    yn_idx_is_id = "no"
+    yn_idx_is_id = "yes"  if @idx_is_id
+    yn_idx_is_id_act = "no"
+    yn_idx_is_id_act = "yes"  if @idx_is_id_act
+    yn_singleton = "no"
+    yn_singleton = "yes"  if @singleton
+    yn_rom       = "no"
+    yn_rom       = "yes"  if $rom
+    yn_cb_init   = "no"
+    yn_cb_init   = "yes"  if need_CB_initializer?
+    # @singleton = false    # mikan singleton  060827
+
+    f.print <<EOT
+/*
+ * celltype          :  #{@name}
+ * global name       :  #{@global_name}
+ * idx_is_id(actual) :  #{yn_idx_is_id}(#{yn_idx_is_id_act})
+ * singleton         :  #{yn_singleton}
+ * has_CB            :  #{has_CB?}
+ * has_INIB          :  #{has_INIB?}
+ * rom               :  #{yn_rom}
+ * CB initializer    :  #{yn_cb_init}
+ */
+
+EOT
+  end
+
+  def gen_ph_include f
+    # ã©ã³ã¿ã¤ã ãããã® include
+#    f.printf TECSMsg.get( :IRTH_comment), "#_IRTH_#"
+#    f.print "#include \"tecs.#{$h_suffix}\"\n\n"
+
+    # ã°ã­ã¼ãã«ãããã® include
+    f.printf TECSMsg.get( :IGH_comment ), "#_IGH_#"
+    f.print "#include \"global_tecsgen.#{$h_suffix}\"\n\n"
+
+    # ã·ã°ããã£ãããã® include
+    f.printf TECSMsg.get( :ISH_comment ), "#_ISH_#"
+    @port.each { |p|
+      next if p.is_omit?
+      hname = "#{p.get_signature.get_global_name}_tecsgen.#{$h_suffix}".to_sym
+      if header_included?( hname ) == false then
+        f.print "#include \"#{hname}\"\n"
+      end
+    }
+    f.print "\n"
+  end
+
+  def gen_ph_include_cb_type f
+
+    if ! @b_cp_optimized then
+      return
+    end
+
+    # æé©åã®ããåç
+§ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã
+    # _CB_TYPE_ONLY ãå®ç¾©ããä¸ã§ include ãã
+    f.printf( TECSMsg.get( :ICT_comment ), "#_ICT_#" )
+
+    f.print( "#ifndef  TOPPERS_CB_TYPE_ONLY\n" )
+    f.print( "#define  #{@global_name}_CB_TYPE_ONLY\n" )
+    f.print( "#define TOPPERS_CB_TYPE_ONLY\n" )
+    f.print( "#endif  /* TOPPERS_CB_TYPE_ONLY */\n" )
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if p.is_omit?
+
+      if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then
+        # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©
+        p2 = p.get_real_callee_port
+        if p2 then
+          ct = p2.get_celltype
+          hname = "#{ct.get_global_name}_tecsgen.#{$h_suffix}".to_sym
+          if header_included?( hname ) == false then
+            f.print( "#include \"#{hname}\"\n" )
+          end
+        # else
+          # optional ã§æªçµå
+        end
+      end
+
+    }
+    f.print( "#ifdef  #{@global_name}_CB_TYPE_ONLY\n" )
+    f.print( "#undef TOPPERS_CB_TYPE_ONLY\n" )
+    f.print( "#endif /* #{@global_name}_CB_TYPE_ONLY */\n" )
+
+#    @port.each { |p|
+#      next if p.get_port_type != :CALL
+#      if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then
+#        # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©
+#        p2 = p.get_real_callee_port
+#        ct = p2.get_celltype
+#        ct.gen_ph_typedef_idx f
+#        ct.gen_ph_INIB_as_CB f
+#        ct.gen_ph_extern_cell f
+#        f.print "\n"
+#      end
+#    }
+
+  end
+
+
+  def gen_ph_base f
+    return if @singleton
+
+    # ID ã®åºæ°ããã³åæ°ã® define ãåºå
+    f.printf("#define %-20s %10s  /* %s #_NIDB_# */\n", "#{@global_name}_ID_BASE", "(#{@id_base})", TECSMsg.get(:NIDB_comment))
+    f.printf("#define %-20s %10s  /* %s  #_NCEL_# */\n\n", "#{@global_name}_N_CELL", "(#{@n_cell_gen})", TECSMsg.get(:NCEL_comment))
+  end
+
+  def gen_ph_valid_idx f
+    return if @singleton
+
+    # mikan  æé©å
+    # IDX æ­£å½æ§ãã§ãã¯ãã¯ã­ã®åºå
+    f.printf( TECSMsg.get( :CVI_comment ), "#_CVI_#" )
+    if @idx_is_id_act then
+      f.print("#define #{@global_name}_VALID_IDX(IDX) (#{@global_name}_ID_BASE <= (IDX) && (IDX) < #{@global_name}_ID_BASE+#{@global_name}_N_CELL)\n\n")
+    else
+      f.print("#define #{@global_name}_VALID_IDX(IDX) (1)\n\n")
+    end
+
+  end
+
+  def gen_ph_valid_idx_abbrev f
+    return if @singleton
+
+    # IDX æ­£å½æ§ãã§ãã¯ãã¯ã­ï¼ç­ç¸®å½¢ï¼ã®åºå
+    f.printf( TECSMsg.get( :CVIA_comment ), "#_CVIA_#")
+    f.print("#define VALID_IDX(IDX)  #{@global_name}_VALID_IDX(IDX)\n\n")
+
+  end
+
+  #=== å¼ã³å£é
+åã®å¤§ãããå¾ããã¯ã­ã®åºå
+  #
+  #ã»ã«ã¿ã¤ããããã¸å¼ã³å£ã®åæ°ãåºå
+  def gen_ph_n_cp f
+
+    b_comment = false
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if p.is_omit?
+      next if p.get_array_size == nil
+
+      if ! b_comment then
+        f.printf( TECSMsg.get( :NCPA_comment ), "#_NCPA_#" )
+        b_comment = true
+      end
+
+      if p.get_array_size != "[]" then       # åºå®é·é
+å
+        f.print( "#define N_CP_#{p.get_name}    (#{p.get_array_size})\n" )
+        f.print( "#define NCP_#{p.get_name}     (#{p.get_array_size})\n" )
+      else                                   # å¯å¤é·é
+å
+        if @singleton then
+          if has_INIB? then
+            inib = "INIB"
+          else
+            inib = "CB"
+          end
+          f.print( "#define N_CP_#{p.get_name}  (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" )
+          f.print( "#define NCP_#{p.get_name}   (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" )
+          # mikan singleton ãªãã°ãåºå®é·åã§ãã
+        else
+          if has_CB? && has_INIB? then
+            inib = "->_inib"
+          else
+            inib = ""
+          end
+          f.print( "#define N_CP_#{p.get_name}(p_that)  ((p_that)#{inib}->n_#{p.get_name})\n" )
+          f.print( "#define NCP_#{p.get_name}           (N_CP_#{p.get_name}(p_cellcb))\n" )
+        end
+      end
+    }
+  end
+
+  #=== åãå£é
+åã®å¤§ãããå¾ããã¯ã­ã®åºå
+  #
+  #ã»ã«ã¿ã¤ããããã¸åãå£ã®åæ°ãåºå
+  def gen_ph_n_ep f
+
+    b_comment = false
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      # next if p.is_omit?                       # åãå£é
+åã®åæ°ã¯çç¥ããªã
+      next if p.get_array_size == nil
+
+      if ! b_comment then
+        f.printf( TECSMsg.get( :NEPA_comment ), "#_NEPA_#" )
+        b_comment = true
+      end
+
+      if p.get_array_size != "[]" then       # åºå®é·é
+å
+        f.print( "#define NEP_#{p.get_name}     (#{p.get_array_size})\n" )
+      else                                   # å¯å¤é·é
+å
+        if @singleton then
+          if has_INIB? then
+            inib = "INIB"
+          else
+            inib = "CB"
+          end
+          f.print( "#define NEP_#{p.get_name}   (#{@global_name}_SINGLE_CELL_#{inib}.n_#{p.get_name})\n" )
+          # mikan singleton ãªãã°ãåºå®é·åã§ãã
+        else
+          if has_CB? && has_INIB? then
+            inib = "->_inib"
+          else
+            inib = ""
+          end
+          f.print( "#define NEP_#{p.get_name}           ((p_cellcb)#{inib}->n_#{p.get_name})\n" )
+        end
+      end
+    }
+  end
+
+  #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæ
+  def gen_ph_test_optional_call_port f
+    b_comment = false
+
+    if @singleton then
+      if has_INIB? then
+        inib = "INIB"
+      else
+        inib = "CB"
+      end
+    else
+      if has_CB? && has_INIB? then
+        inib = "->_inib"
+      else
+        inib = ""
+      end
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if ! p.is_optional?
+      # next if p.is_omit?  # omit ã§ã test ã³ã¼ãã¯çæãã
+
+      if b_comment == false then
+        f.printf( TECSMsg.get( :TOCP_comment ), "#_TOCP_#" )
+        b_comment = true
+      end
+
+      if p.get_array_size == nil then
+        f.print( "#define #{@global_name}_is_#{p.get_name}_joined(p_that) \\\n" )
+      else
+        f.print( "#define #{@global_name}_is_#{p.get_name}_joined(p_that,subscript) \\\n" )
+      end
+
+      if p.is_omit? then
+        f.print( "   omit  is_#{p.get_name}_joined\n" )
+        next
+      end
+
+      # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿)
+      # mikan  å
+¨é¨ã¤ãªãã£ã¦ãããã©ããã§ (1) ãå¤å®ãã
+      if ! p.is_VMT_useless? then
+        # æ¨æºã³ã¼ã
+        if p.get_array_size == nil then
+          if @singleton then
+            f.print( "\t  (#{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}!=0)\n" )
+          else
+            f.print( "\t  ((p_that)#{inib}->#{p.get_name}!=0)\n" )
+          end
+        else
+          # é
+åã®å ´å
+          if @singleton then
+            f.print( "\t  ((#{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}!=0) \\\n" )
+            f.print( "\t  &&(#{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}[subscript]!=0))\n" )
+          else
+            f.print( "\t  (((p_that)#{inib}->#{p.get_name}!=0)\\\n" )
+            f.print( "\t  &&((p_that)#{inib}->#{p.get_name}[subscript]!=0))\n" )
+          end
+        end
+      else
+        # æé©åã³ã¼ã (optimize) # VMT ä¸è¦ï¼é
+åè¦ç´ ãã¹ã¦åãï¼
+        p2 = p.get_real_callee_port
+        if p2 then
+          ct = p2.get_celltype
+          if p.is_skelton_useless? then
+            # åãå£é¢æ°ãç´æ¥å¼åºã
+            f.print( "\t  (1)\n" )
+          else
+            # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã
+            f.print( "\t  (1)\n" )
+          end
+        else
+          # optional ã§æªçµå
+          f.print( "\t  (0)    /* not joined */\n" )
+        end
+      end
+    }
+  end
+
+  #=== optional ãªå¼ã³å£ãçµåããã¦ããããã¹ãããã³ã¼ãã®çæï¼ç­ç¸®å½¢ï¼
+  def gen_ph_test_optional_call_port_abbrev f
+    b_comment = false
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if ! p.is_optional?
+      # next if p.is_omit?  # omit ã§ã test ã³ã¼ãã¯çæãã
+
+      if b_comment == false then
+        f.printf( TECSMsg.get( :TOCPA_comment ), "#_TOCPA_#" )
+        b_comment = true
+      end
+
+      if p.get_array_size == nil then
+        f.print( "#define is_#{p.get_name}_joined()\\\n\t\t#{@global_name}_is_#{p.get_name}_joined(p_cellcb)\n" )
+      else
+        f.print( "#define is_#{p.get_name}_joined(subscript)\\\n" )
+        f.print( "\t\t#{@global_name}_is_#{p.get_name}_joined(p_cellcb,subscript)\n" )
+      end
+    }
+  end
+
+  #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ã­ãåºå
+  #   ã»ã«ã¿ã¤ããããã¸åºå
+  def gen_ph_get_cellcb f
+    f.printf( TECSMsg.get( :GCB_comment ), "#_GCB_#" )
+    if ( ! has_CB? && ! has_INIB? ) || @singleton then
+      f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" )
+    elsif @idx_is_id_act then   # mikan åä¸ã®ã»ã«ã®å ´åã®æé©å, idx_is_id ã§ãªãå ´å
+      f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_tab[(idx) - #{@global_name}_ID_BASE])\n" )
+    else
+      f.print( "#define #{@global_name}_GET_CELLCB(idx) (idx)\n" )
+    end
+  end
+
+  #=== CELLCB ã¸ã®ãã¤ã³ã¿ãå¾ããã¯ã­ï¼ç­ç¸®å½¢ï¼ãåºå
+  #  ã»ã«ã¿ã¤ããããã¸åºå
+  def gen_ph_get_cellcb_abbrev f
+    f.printf( TECSMsg.get( :GCBA_comment ), "#_GCBA_#" )
+    f.print("#define GET_CELLCB(idx)  #{@global_name}_GET_CELLCB(idx)\n\n")
+
+    f.printf( TECSMsg.get( :CCT_comment ), "#_CCT_#" )
+    f.print( "#define CELLCB\t#{@global_name}_CB\n\n" )
+
+    f.printf( TECSMsg.get( :CTIXA_comment ), "#_CTIXA_#" )
+    f.print( "#define CELLIDX\t#{@global_name}_IDX\n\n" )
+
+    if @name != @global_name then
+      f.print( "#define #{@name}_IDX  #{@global_name}_IDX\n" )
+    end
+  end
+
+  #===  attribute, var ãã¢ã¯ã»ã¹ãããã¯ã­ãåºå
+  #    ã»ã«ã¿ã¤ããããã¸åºå
+  def gen_ph_attr_access f
+    if @n_attribute_rw > 0 || @n_attribute_ro > 0 then
+      f.printf( TECSMsg.get( :AAM_comment ), "#_AAM_#" )
+    end
+
+    @attribute.each { |a|
+
+      next if a.is_omit?
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      if @singleton then
+        if has_INIB? then
+          inib = "INIB"
+        else
+          inib = "CB"
+        end
+        f.printf( "%-20s", "#{@global_name}_ATTR_#{a.get_name}" )
+        f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" )
+        # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+      else
+        if ! a.is_rw? && has_CB? && has_INIB? then
+          inib = "->_inib"
+        else
+          inib = ""
+        end
+        f.printf( "%-20s", "#{@global_name}_ATTR_#{a.get_name}( p_that )" )
+        f.print( "\t((p_that)#{inib}->#{a.get_name})\n" )
+      end
+    }
+    f.print( "\n" )
+
+    @attribute.each { |a|
+
+      next if a.is_omit?
+
+      if @singleton then
+        if has_INIB? then
+          inib = "INIB"
+        else
+          inib = "CB"
+        end
+      else
+        if ! a.is_rw? && has_CB? && has_INIB? then
+          inib = "->_inib"
+        else
+          inib = ""
+        end
+      end
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      if @singleton then
+        f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}()" )
+        f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name})\n" )
+        # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+      else
+        f.printf( "%-20s", "#{@global_name}_GET_#{a.get_name}(p_that)" )
+        f.print( "\t((p_that)#{inib}->#{a.get_name})\n" )
+      end
+
+      if a.is_rw? then
+        f.print( "#define " )
+        if @singleton then
+          f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(val)" )
+          f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{a.get_name} = (val))\n" )
+          # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+        else
+          f.printf( "%-20s", "#{@global_name}_SET_#{a.get_name}(p_that,val)" )
+          f.print( "\t((p_that)#{inib}->#{a.get_name}=(val))\n" )
+        end
+      end
+
+    }
+    f.print( "\n" )
+
+    if @n_var > 0 then
+      f.printf( TECSMsg.get( :VAM_comment ), "#_VAM_#" )
+    end
+
+    @var.each { |v|
+
+      next if v.is_omit?
+
+      if @singleton then
+        if v.get_size_is && has_INIB? then
+          inib = "INIB"
+        else
+          inib = "CB"
+        end
+      else
+        if v.get_size_is && has_CB? && has_INIB? then
+          inib = "->_inib"
+        else
+          inib = ""
+        end
+      end
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      if @singleton then
+        f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}" )
+        f.print( "\t(#{@global_name}_SINGLE_CELL_#{inib}.#{v.get_name})\n" )
+        # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+      else
+        f.printf( "%-20s", "#{@global_name}_VAR_#{v.get_name}(p_that)" )
+        f.print( "\t((p_that)#{inib}->#{v.get_name})\n" )
+      end
+    }
+    f.print( "\n" )
+    @var.each { |v|
+
+      next if v.is_omit?
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      if @singleton then
+        f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}()" )
+        f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name})\n" )
+        # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+      else
+        f.printf( "%-20s", "#{@global_name}_GET_#{v.get_name}(p_that)" )
+        f.print( "\t((p_that)->#{v.get_name})\n" )
+      end
+
+      f.print( "#define " )
+      if @singleton then
+        f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(val)" )
+        f.print( "\t(#{@global_name}_SINGLE_CELL_CB.#{v.get_name}=(val))\n" )
+        # mikan ããã§ã¯ cell ã§ã¯ãªã celltype ã®åå
+      else
+        f.printf( "%-20s", "#{@global_name}_SET_#{v.get_name}(p_that,val)" )
+        f.print( "\t((p_that)->#{v.get_name}=(val))\n" )
+      end
+    }
+    f.print( "\n" )
+
+  end
+
+  #===  attribute/var ã¢ã¯ã»ã¹ãã¯ã­ï¼ç­ç¸®å½¢ï¼ã³ã¼ãã®çæ
+  def gen_ph_attr_access_abbrev f
+    if @n_attribute_rw > 0 || @n_attribute_ro > 0 then
+      f.printf( TECSMsg.get( :AAMA_comment ), "#_AAMA_#" )
+    end
+
+    @attribute.each { |a|
+      next if a.is_omit?
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      f.printf( "%-20s", "ATTR_#{a.get_name}" )
+      f.print( " #{@global_name}_ATTR_#{a.get_name}" )
+      if ! @singleton then
+        f.print( "( p_cellcb )" )
+      end
+      f.print "\n"
+    }
+    f.print( "\n" )
+
+    if @n_var > 0 then
+      f.printf( TECSMsg.get( :VAMA_comment ), "#_VAMA_#" )
+    end
+
+    @var.each { |v|
+      next if v.is_omit?
+
+      # mikan const_value ã®å ´å
+      f.print( "#define " )
+      f.printf( "%-20s", "VAR_#{v.get_name}" )
+      f.print( " #{@global_name}_VAR_#{v.get_name}" )
+      if ! @singleton then
+        f.print( "( p_cellcb )" )
+      end
+      f.print( "\n" )
+    }
+    f.print( "\n" )
+
+  end
+
+  def gen_ph_cp_fun_macro f
+    if @n_call_port >0 then
+      f.printf( TECSMsg.get( :CPM_comment ) , "#_CPM_#" )
+    end
+
+    if @singleton then
+      if has_INIB? then
+        inib = "INIB"
+      else
+        inib = "CB"
+      end
+    else
+      if has_CB? && has_INIB? then
+        inib = "->_inib"
+      else
+        inib = ""
+      end
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if p.is_omit?
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        f.print( "#define #{@global_name}_#{p.get_name}_#{fun.get_name}(" )
+        ft = fun.get_declarator.get_type
+        delim = ""
+
+        if ! @singleton then
+          f.print( "#{delim} p_that" )
+          delim = ","
+        end
+
+        if p.get_array_size then
+          f.print( "#{delim} subscript" )
+          delim = ","
+        end
+
+        ft.get_paramlist.get_items.each{ |param|
+          f.print( "#{delim} #{param.get_name}" )
+          delim = ","
+        }
+        f.print( " ) \\\n" )
+
+        subsc = ""
+        subsc = "[subscript]" if p.get_array_size
+        delim = ""
+
+        # é¢æ°åã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãã VMT ã®é¢æ°åãæé©åï¼åãå£é¢æ° or åãå£ãã£ã¹ã¯ãªãã¿)
+        if ! p.is_VMT_useless? then
+          # æ¨æºã³ã¼ã
+          if @singleton then
+            f.print( "\t  #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}" )
+          else
+            f.print( "\t  (p_that)#{inib}->#{p.get_name}" )
+          end
+          f.print( "#{subsc}->VMT->#{fun.get_name}__T( \\\n" )
+        else
+          # æé©åã³ã¼ã (optimize) # VMT ä¸è¦
+          p2 = p.get_real_callee_port
+          if p2 then
+            ct = p2.get_celltype
+            if p.is_skelton_useless? then
+              # åãå£é¢æ°ãç´æ¥å¼åºã
+              f.print( "\t  #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}( \\\n" )
+            else
+              # åãå£ã¹ã±ã«ãã³é¢æ°ãç´æ¥å¼åºã
+              f.print( "\t  #{ct.get_global_name}_#{p2.get_name}_#{fun.get_name}_skel( \\\n" )
+              # print "skelton: #{@name} #{ct.get_global_name}_#{p2.get_name}\n"
+            end
+          else
+            # optional ã§æªçµå
+            f.print( "\t  ((#{fun.get_declarator.get_type.get_type.get_type_str} (*)()" )
+            f.print( "#{fun.get_declarator.get_type.get_type.get_type_str_post})0)()\n" )
+            f.print( "\t  /* optional no entry port joined */\n" )
+            if ! p.is_optional? then
+              raise "unjoined but not optional celltype: #{@name} #{p.get_name}"
+            end
+          end
+        end
+
+        b_join = true    # optional ã§çµåãã¦ããªãå ´å false
+
+        # åãå£æ
+å ±ã®åºå(æ¨æºï¼åãå£ãã£ã¹ã¯ãªãã¿ãæé©åï¼IDX ãªã©)
+        if ! p.is_skelton_useless? && ! p.is_cell_unique? then
+          # æ¨æºã³ã¼ã
+          if @singleton then
+            f.print( "\t  #{@global_name}_SINGLE_CELL_#{inib}.#{p.get_name}#{subsc}" )
+            delim = ","
+          else
+            f.print( "\t   (p_that)#{inib}->#{p.get_name}#{subsc}" )
+            delim = ","
+          end
+        else
+          # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦
+          c2 = p.get_real_callee_cell               # å¯ä¸ã®ã»ã«(ã§ãªãå ´åããããè¤æ°ã»ã«ãããå ´å)
+          p2 = p.get_real_callee_port               # å¯ä¸ã®ãã¼ã(ã§ãªãå ´åã¯ããªã)
+          if p2 then
+            ct = p2.get_celltype                    # å¼ã³å
+ã®ã»ã«ã¿ã¤ã
+            if ! ct.is_singleton? then
+              if ct.has_CB? || ct.has_INIB? then
+                if p.is_cell_unique? then
+                  name_array = ct.get_name_array( c2 )
+                  f.print( "\t   #{name_array[7]}" )
+                else
+                  # CELLCB IDX ãæ¸¡ã (æ¨æºã³ã¼ãã¨åãã ããæ±ãåã¯ç°ãªã)
+                  # p.is_skelton_useless? == true/false ã¨ãã«åã
+                  f.print( "\t   (p_that)#{inib}->#{p.get_name}#{subsc}" )
+                end
+              else
+                f.print( "\t   (#{ct.get_global_name}_IDX)0" )
+              end
+              delim = ","
+            else
+              f.print( "\t   " )
+            end
+          else
+            # optional ã§æªçµå
+            b_join = false
+          end
+        end
+
+        if b_join then
+          ft.get_paramlist.get_items.each{ |param|
+            f.print( "#{delim} (#{param.get_name})" )
+            delim = ","
+          }
+          f.print( " )\n" )
+        end
+      }
+    }
+    f.print( "\n" )
+  end
+
+  #=== send/receive ã§åãåã£ãã¡ã¢ãªé åã dealloc ãããã¯ã­ã³ã¼ã
+  #f:: File
+  #b_undef:: bool : true = #undef ã³ã¼ãã®çæ,  false = #define ã³ã¼ãã®çæ
+  def  gen_ph_dealloc_code( f, append_name, b_undef = false )
+    b_msg = false
+    @port.each{ |p|
+      next if p.is_omit?
+
+      p.each_param{ |port, fd, par|
+        case par.get_direction                        # å¼æ°ã®æ¹åæå®å­ (in, out, inout, send, receive )
+        when :SEND
+          # next if port.get_port_type == :CALL
+          type = par.get_declarator.get_type
+          pre = "("
+          post = ")"
+        when :RECEIVE
+          # next if port.get_port_type == :ENTRY
+          type = par.get_declarator.get_type.get_type
+#          pre = "(*"
+#          post = ")"
+          pre = "("
+          post = ")"
+        else
+          next
+        end
+
+        #                      ãã¼ãå         é¢æ°å         ãã©ã¡ã¼ã¿å
+        dealloc_func_name = "#{port.get_name}_#{fd.get_name}_#{par.get_name}_dealloc"
+        dealloc_macro_name = dealloc_func_name.upcase
+        name = par.get_name
+
+        if b_undef == false
+          if (type.get_size || type.get_count) && type.get_type.has_pointer?
+            count_str = "count__"
+            count_str2 = ", count__"
+          else
+            count_str = nil
+            count_str2 = nil
+          end
+          if ! b_msg
+            f.print "\n"
+            f.printf TECSMsg.get( :DAL_comment ), "#_DAL_#  #{append_name}"
+            b_msg = true
+          end
+          f.print "#define #{dealloc_macro_name}#{append_name}(#{name}#{count_str2})"
+          if append_name == "_RESET" then
+            gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, 0, true, count_str )
+          else
+            gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, 0, false, count_str )
+          end
+          f.print "\n"
+        else
+          f.print "#undef #{dealloc_macro_name}#{append_name}\n"
+        end
+      }
+    }
+  end
+
+  def gen_ph_cp_fun_macro_abbrev f
+    if @n_call_port >0 then
+      f.printf( TECSMsg.get( :CPMA_comment ), "#_CPMA_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      # next if p.is_omit?  å¼ã³åºãã¨ã¨ã©ã¼ãèµ·ããã³ã¼ããçæ
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        if p.is_VMT_useless? && ! @singleton then
+          dummy_p_cell_access_pre = "((void)p_cellcb, "
+          dummy_p_cell_access_post = ")"
+        else
+          dummy_p_cell_access_pre = ""
+          dummy_p_cell_access_post = ""
+        end
+ 
+        if ! p.is_require? || p.has_name? then
+          f.print( "#define #{p.get_name}_#{fun.get_name}(" )
+        else
+          f.print( "#define #{fun.get_name}(" )
+        end
+        ft = fun.get_declarator.get_type
+        delim = ""
+
+#        if ! @singleton then
+#          f.print( "#{delim} p_that" )
+#          delim = ","
+#        end
+
+        if p.get_array_size then
+          f.print( "#{delim} subscript" )
+          delim = ","
+        end
+
+        ft.get_paramlist.get_items.each{ |param|
+          f.print( "#{delim} #{param.get_name}" )
+          delim = ","
+        }
+        f.print( " ) \\\n" )
+
+        if p.is_omit? then
+          f.print( "                      #{dummy_p_cell_access_pre}omitted #{p.get_name}_#{fun.get_name}(" )
+        else
+          f.print( "                      #{dummy_p_cell_access_pre}#{@global_name}_#{p.get_name}_#{fun.get_name}(" )
+        end
+        ft = fun.get_declarator.get_type
+        delim = ""
+
+        if ! @singleton then
+          f.print( "#{delim} p_cellcb" )
+          delim = ","
+        end
+
+        if p.get_array_size then
+          f.print( "#{delim} subscript" )
+          delim = ","
+        end
+
+        ft.get_paramlist.get_items.each{ |param|
+          f.print( "#{delim} #{param.get_name}" )
+          delim = ","
+        }
+        f.print( " )#{dummy_p_cell_access_post}\n" )
+      }
+    }
+    f.print( "\n" )
+  end
+
+  def gen_ph_ep_fun_macro f
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :EPM_comment ), "#_EPM_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        f.printf( "#define %-16s %s\n",
+                  "#{p.get_name}_#{fun.get_name}",
+                  "#{@global_name}_#{p.get_name}_#{fun.get_name}" )
+      }
+    }
+    f.print( "\n" )
+
+  end
+
+  def gen_ph_typedef_idx f
+    f.printf( TECSMsg.get( :CTIX_comment ), "#_CTIX_#" )
+    if @idx_is_id_act then
+      f.print( "typedef ID #{@global_name}_IDX;\n" )
+    else
+      if has_CB? then
+        f.print( "typedef struct tag_#{@global_name}_CB *#{@global_name}_IDX;\n" )
+      elsif has_INIB? then
+        f.print( "typedef const struct tag_#{@global_name}_INIB *#{@global_name}_IDX;\n" )
+      else
+        f.print( "typedef int   #{@global_name}_IDX;\n" )
+      end
+    end
+
+  end
+
+  def gen_ph_idx_type f
+    if @idx_is_id_act then
+      f.print( "ID" )
+    else
+      if has_CB? then
+        f.print( "struct tag_#{@global_name}_CB *" )
+      elsif has_INIB? then
+        # f.print( "struct tag_#{@global_name}_INIB *" )  # const ãåºåãã¦ããªã
+        f.print( "const struct tag_#{@global_name}_INIB *" )
+      else
+        f.print( "int" )
+      end
+    end
+
+  end
+
+  def gen_ph_ep_fun_prototype f
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :EPP_comment ), "#_EPP_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+
+      f.print( "/* #{p.get_signature.get_global_name} */\n" )
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        if p.is_inline? then
+          f.print( "Inline " )
+        end
+        functype = fun.get_declarator.get_type
+        f.printf( "%-12s", functype.get_type_str )
+
+        f.print( " #{@global_name}_#{p.get_name}_#{fun.get_name}(" )
+        if @singleton then
+           delim = ""
+        else
+          f.print( "#{@global_name}_IDX idx" )
+          delim = ","
+        end
+
+        if p.get_array_size then
+          f.print( "#{delim} int_t subscript" )     # mikan singleton æã® ',' ã®å§æ«
+          delim = ","
+        end
+
+        if functype.get_paramlist then
+          items = functype.get_paramlist.get_items
+          len = items.length
+        else
+          # ããã§ nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å
+          items = []
+          len = 0
+        end
+        i = 0
+        items.each{ |param|
+          f.print "#{delim} "
+          delim = ","
+          f.print( param.get_type.get_type_str )
+          f.print( " " )
+          f.print( param.get_name )
+          f.print( param.get_type.get_type_str_post )
+          i += 1
+        }
+        f.print( ");\n" )
+
+      }
+    }
+  end
+
+  def gen_ph_ep_skel_prototype f
+    # åãå£ã¹ã±ã«ãã³é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ãåºå
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :EPSP_comment ), "#_EPSP_#" )
+    end
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+#      if p.is_skelton_useless? || ! p.is_VMT_useless? then    # åãå£æé©å
+      if p.is_skelton_useless? then    # åãå£æé©å
+#        f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" )
+        next
+      end
+
+      f.print( "/* #{p.get_name} */\n" )
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        functype = fun.get_declarator.get_type
+        f.printf "%-14s", functype.get_type_str
+
+        f.print " #{@global_name}_#{p.get_name}_#{fun.get_name}_skel("
+        f.print " const struct tag_#{p.get_signature.get_global_name}_VDES *epd"
+        delim = ","
+
+        if functype.get_paramlist then
+          items = functype.get_paramlist.get_items
+          len = items.length
+        else
+          # ããã§ nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å
+          items = []
+          len = 0
+        end
+        i = 0
+        items.each{ |param|
+          f.print "#{delim} "
+          delim = ","
+          f.print param.get_type.get_type_str
+          f.print " "
+          f.print param.get_name
+          f.print param.get_type.get_type_str_post
+          i += 1
+        }
+        f.print ");\n"
+      }
+    }
+    f.print( "\n" )
+  end
+
+  def gen_ph_cell_cb_type f
+
+    if ( $rom )then
+      # å®æ°é¨ã¯ ROM, å¤æ°é¨ã¯ RAM
+
+      if has_INIB? then
+
+        f.printf( TECSMsg.get( :CIP_comment ), "#_CIP_#" )
+        f.print( "typedef const struct tag_#{@global_name}_INIB {\n" )
+
+        gen_cell_cb_type_port f
+        gen_cell_cb_type_attribute( f, :INIB )
+
+        f.print( "}  #{@global_name}_INIB;\n" )
+
+      end
+
+      if has_CB? then
+        f.printf( TECSMsg.get( :CCTPA_comment ), "#_CCTPA_#" )
+        f.print( "typedef struct tag_#{@global_name}_CB {\n" )
+        if has_INIB? then
+          f.print "    #{@global_name}_INIB  *_inib;\n"
+        end
+        gen_cell_cb_type_attribute( f, :CB )
+        gen_cell_cb_type_var f
+        f.print( "}  #{@global_name}_CB;\n" )
+      end
+
+      if ! has_CB? && ! has_INIB? then
+        f.printf( TECSMsg.get( :CCDP_comment ), "#_CCDP_#" )
+        f.print( "typedef struct tag_#{@global_name}_CB {\n" )
+        f.print( "    int  dummy;\n" )
+        f.print( "} #{@global_name}_CB;\n" )
+     end
+
+    else
+      # å
+¨ã¦ RAM
+      f.printf( TECSMsg.get( :CCTPO_comment ), "#_CCTPO_#" )
+
+      f.print( "typedef struct tag_#{@global_name}_CB {\n" )
+
+      gen_cell_cb_type_port f
+      gen_cell_cb_type_attribute( f, :CB )
+      gen_cell_cb_type_var f
+
+      f.print( "}  #{@global_name}_CB;\n" )
+    end
+  end
+
+
+  #===   attribute ã®åå®£è¨åºå
+  #inib_cb::  :INIB ã¾ãã¯ :CB
+  def gen_cell_cb_type_attribute( f, inib_cb )
+    if inib_cb == :INIB && @n_attribute_ro > 0 then
+      f.print "    /* attribute(RO) #_ATO_# */ \n"
+    elsif inib_cb == :CB then
+      if $rom then
+        if @n_attribute_rw > 0 then
+          f.print "    /* attribute(RW) #_ATW_# */ \n"
+        end
+      else
+        if @n_attribute_rw > 0 || @n_attribute_ro > 0 then
+          f.print "    /* attribute #_AT_# */ \n"
+        end
+      end
+    end
+
+    @attribute.each{ |a|
+      next if a.is_omit?
+      next if inib_cb == :INIB && a.is_rw?
+      next if has_INIB? && inib_cb == :CB && ! a.is_rw?
+
+      if a.get_type.kind_of?( PtrType ) && ! a.get_type.is_const? && a.get_size_is then
+        const_str = "const "
+      else
+        const_str = ""
+      end
+      f.print "    "
+      f.printf( "#{const_str}%-14s", a.get_type.get_type_str )
+      f.print " #{a.get_name}#{a.get_type.get_type_str_post};\n"
+    }
+    @var.each { |v|
+      next if v.is_omit?
+      next if v.get_size_is == nil
+      next if $rom && inib_cb == :CB      # size_is æå®ããããã®ã¯ INIB ã«ã®ã¿åºåãã
+
+      f.print "    "
+      f.printf( "%-14s", v.get_type.get_type_str )
+      f.print " #{v.get_name}#{v.get_type.get_type_str_post};\n"
+    }
+  end
+
+  def gen_cell_cb_type_var f
+    # å¤æ°ã®åºå
+    if @n_var > 0 then
+      f.print "    /* var #_VA_# */ \n"
+    end
+
+    @var.each{ |v|
+
+      next if v.is_omit?
+      next if v.get_size_is != nil    # size_is æå®ããã var ã¯ attribute ã¸åºåãã
+
+      f.print "    "
+      f.printf( "%-14s", v.get_type.get_type_str )
+      f.print " #{v.get_name}#{v.get_type.get_type_str_post};\n"
+    }
+  end
+
+  def gen_cell_cb_type_port f
+    gen_cell_cb_type_call_port f
+    gen_cell_cb_type_entry_port f
+  end
+
+  def gen_cell_cb_type_call_port f
+    # å¼ã³å£
+    if @n_call_port >0 then
+      f.print "    /* call port #_TCP_# */ \n"
+    end
+
+    @port.each{ |p|
+      next if p.get_port_type != :CALL
+      next if p.is_omit?
+      ptr = ''
+      ptr = '*' if p.get_array_size
+
+      if ! p.is_cell_unique? then
+        if ! p.is_skelton_useless? then
+          # æ¨æºå½¢
+          f.print( "    struct tag_#{p.get_signature.get_global_name}_VDES #{ptr}const*#{p.get_name;};\n" )
+          if p.get_array_size == "[]" then
+            f.print( "    int_t n_#{p.get_name};\n" )
+          end
+        else
+          # æé©å skelton é¢æ°ãå¼åºããªã(åãå£é¢æ°ãç´æ¥å¼åºã)
+          # å¼ã³å
+ã»ã«ã¿ã¤ãã® CB ã® IDX å
+          if p.get_real_callee_cell then
+            f.print( "    " )
+            p.get_real_callee_cell.get_celltype.gen_ph_idx_type f
+            f.print( " #{ptr}#{p.get_name;};\n" )
+            # ç¸äºåç
+§ã«åãã¦ãtypedef ããåãä½¿ããªã
+            # f.print( "    #{p.get_real_callee_cell.get_celltype.get_global_name}_IDX #{ptr}#{p.get_name;};\n" )
+            if p.get_array_size == "[]" then
+              f.print( "    int_t n_#{p.get_name};\n" )
+            end
+          #else
+          #  optional ã§æªçµå
+          end
+        end
+      # else
+        # æé©å ä¸ã¤ããã»ã«ããªãå ´åãåãå£ãã£ã¹ã¯ãªãã¿ã¾ãã¯åãå´ã® IDX ã¯å¼ã³å£é¢æ°ãã¯ã­ã«åãè¾¼ã¾ãã
+      end
+    }
+  end
+
+  #=== Celltype#åãå£é
+åæ·»æ°ãè¨æ¶ããå¤æ°ã®å®ç¾©
+  def gen_cell_cb_type_entry_port f
+    # å¼ã³å£
+    if @n_entry_port >0 then
+      f.print "    /* call port #_NEP_# */ \n"
+    end
+
+    @port.each{ |p|
+      # next if p.is_omit?                       # åãå£é
+åã®åæ°ã¯çç¥ããªã
+      if p.get_port_type == :ENTRY && p.get_array_size == "[]"
+        f.print( "    int_t n_#{p.get_name};\n" )
+      end
+    }
+  end
+
+  def gen_ph_extern_cell f
+    if @singleton then
+      f.printf( TECSMsg.get( :SCP_comment ),  "#_SCP_#" )
+      if has_CB? then
+        f.print "extern  #{@global_name}_CB  #{@global_name}_SINGLE_CELL_CB;\n"
+      end
+      if has_INIB? then
+        f.print "extern  #{@global_name}_INIB  #{@global_name}_SINGLE_CELL_INIB;\n"
+      end
+
+#     @ordered_cell_list.each{ |c|
+#        f.print "extern  #{@global_name}_CB  #{@global_name}_#{c.get_name}_CB;\n"
+#      }
+
+      f.print "\n"
+    elsif @idx_is_id_act then
+      f.print "extern #{@global_name}_CB  *#{@global_name}_CB_tab[];\n"
+    else
+      f.print "extern #{@global_name}_CB  #{@global_name}_CB_tab[];\n"
+    end
+  end
+
+  def gen_ph_INIB_as_CB f
+
+    if ! has_CB? && has_INIB? then
+      f.printf( TECSMsg.get( :DCI_comment ),  "#_DCI_#" )
+      f.print "#define #{@global_name}_CB_tab           #{@global_name}_INIB_tab\n"
+      f.print "#define #{@global_name}_SINGLE_CELL_CB   #{@global_name}_SINGLE_CELL_INIB\n"
+      f.print "#define #{@global_name}_CB               #{@global_name}_INIB\n"
+      f.print "#define tag_#{@global_name}_CB           tag_#{@global_name}_INIB\n"
+      f.print "\n"
+    end
+
+  end
+
+  #===  ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ
+  #      singleton ã§ã¯åºåããªã
+  def gen_ph_foreach_cell f
+
+    return if @singleton
+
+    if has_CB? || has_INIB? then
+
+      if need_CB_initializer?
+        necessity = ""
+      else
+        necessity = "//"
+      end
+
+      f.printf( TECSMsg.get( :FEC_comment ), "#_FEC_#" )
+
+      if @idx_is_id_act then
+        amp = ''
+      else
+        amp = '&'
+      end
+      f.print <<EOT
+#define FOREACH_CELL(i,p_cb)   \\
+    for( (i) = 0; (i) < #{@global_name}_N_CELL; (i)++ ){ \\
+       #{necessity}(p_cb) = #{amp}#{@global_name}_CB_tab[i];
+
+#define END_FOREACH_CELL   }
+
+EOT
+    else
+      f.printf( TECSMsg.get( :NFEC_comment ), "#_NFEC_#" )
+      f.print <<EOT
+#define FOREACH_CELL(i,p_cb)   \\
+    for((i)=0;(i)<0;(i)++){
+
+#define END_FOREACH_CELL   }
+
+EOT
+    end
+  end
+
+
+  #===  å¤æ°varåæåã³ã¼ã
+  #
+  def gen_ph_cb_initialize_macro f
+
+    f.printf( TECSMsg.get( :CIM_comment ), "#_CIM_#" )
+
+    @var.each { |v|
+      init = v.get_initializer
+      if init.instance_of? Array then
+        type = v.get_type
+        if( type.kind_of? PtrType )then
+          # PtrType ã¯ ArrayType ã«ããæ¿ãã
+
+          # åæåå­ã®è¦ç´ æ°ã¨ãã (å¾ã¯ 0 ã§ãã)
+          t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) )
+          t2.set_type( type.get_type )
+          type = t2
+        end
+        f.print "extern const #{type.get_type_str} #{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post};\n"
+      end
+    }
+    if @singleton then
+      arg = "()"
+      p_that = ""
+      that = "#{@global_name}_SINGLE_CELL_CB."
+    else
+      arg = "(p_that)"
+      p_that = "(p_that)"
+      that = "(p_that)->"
+    end
+
+    if @n_cell_gen > 0 && need_CB_initializer? then
+      f.print "#define INITIALIZE_CB#{arg}"
+      @var.each { |v|
+        init = v.get_initializer
+        next if init == nil
+
+        type = v.get_type.get_original_type
+        f.print "\\\n"
+#        print v.get_name, type.class, "\n"
+#        if init.instance_of? Array || type.kind_of?( StructType ) then
+        if init.instance_of? Array then
+          if(type.kind_of?( ArrayType ) || type.kind_of?( PtrType ))then
+            pre = "&"
+            post = "[0]"
+          elsif type.kind_of? StructType then
+            pre = "&"
+            post = ""
+#          elsif type.kind_of? PtrType then
+#            pre = ""
+#            post = ""
+          end
+          f.print "\tmemcpy((void*)#{pre}#{@global_name}_VAR_#{v.get_name}#{p_that}#{post}, (void*)#{pre}#{@global_name}_#{v.get_name}_VAR_INIT#{post}, sizeof(#{@global_name}_#{v.get_name}_VAR_INIT));"
+        elsif init.instance_of? C_EXP then
+          f.print "\t#{that}#{v.get_name} = #{init.get_c_exp_string};"
+        else
+          pre = "#{get_global_name}_ATTR_"
+          if @singleton then
+            post = ""
+          else
+            post = "#{p_that}"
+          end
+          f.print "\t#{that}#{v.get_name} = #{init.to_str( @name_list, pre, post )};"
+        end
+      }
+      f.print "\n"
+
+      f.print "#define SET_CB_INIB_POINTER(i,p_that)\\\n"
+      if has_CB? && has_INIB? then
+        if @singleton then
+          f.print "\t#{that}_inib = &#{@global_name}_SINGLE_CELL_INIB;\n\n"
+        elsif @idx_is_id_act
+          f.print "\t#{that}_inib = #{@global_name}_INIB_tab[(i)];\n\n"
+        else
+          f.print "\t#{that}_inib = &#{@global_name}_INIB_tab[(i)];\n\n"
+        end
+      else
+        f.print "\t/* empty */\n"
+      end
+
+    # else
+    #   ã»ã«ãä¸ã¤ããªããã°åºåããªã
+    end
+
+  end
+
+
+  def gen_ph_inline f
+    # inline ãã¼ããä¸ã¤ã§ãããã°ãinline.h ã® include
+    if @n_entry_port_inline > 0 then
+      f.printf( TECSMsg.get( :INL_comment ), "#_INL_#" )
+      f.print( "#include \"#{@global_name}_inline.#{$h_suffix}\"\n\n" )
+    end
+  end
+
+  def gen_ph_endif( f, post = "TECSGEN" )
+    f.print("#endif /* #{@global_name}_#{post}H */\n")
+  end
+
+
+##### celltype factory header
+  def generate_factory_header
+
+    f = AppFile.open("#{$gen}/#{@global_name}_factory.#{$h_suffix}")
+    f.print("#ifndef #{@name}_FACTORY_H\n")
+    f.print("#define #{@name}_FACTORY_H\n")
+    f.close
+  end
+
+  def generate_factory_header_post
+
+    f = AppFile.open("#{$gen}/#{@global_name}_factory.#{$h_suffix}")
+
+    plugin_obj = get_celltype_plugin
+    if plugin_obj
+      plugin_obj.gen_factory f
+    end
+
+    f.print("#endif /* #{@name}_FACTORY_H */\n")
+    f.close
+  end
+
+
+#####  celltype glue code
+  def gen_cell_private_header f
+    f.print "#include \"#{@global_name}_tecsgen.#{$h_suffix}\"\n"
+  end
+
+  def gen_cell_factory_header f
+    f.print "#include \"#{@global_name}_factory.#{$h_suffix}\"\n\n"
+  end
+
+  def gen_cell_ep_des_type f
+    if @n_entry_port > 0 then
+      f.printf( TECSMsg.get( :EDT_comment ), "#_EDT_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+      if p.is_skelton_useless?    # åãå£æé©å
+        f.print( "/* #{p.get_name} : omitted by entry port optimize */\n\n" )
+        next
+      end
+
+      f.print( "/* #{p.get_name} */\n" )
+      f.print( "struct tag_#{@global_name}_#{p.get_name}_DES {\n" )
+      f.print( "    const struct tag_#{p.get_signature.get_global_name}_VMT *vmt;\n" )
+      if has_CB? || has_INIB? then
+        f.print( "    #{@name}_IDX  idx;\n" )
+      else
+        # CB ã INIB ãå­å¨ããªã (ã®ã§ãidx ã¨ãã¦æ´æ°ã§åæåãã¦ãã)
+        f.print( "    int           idx;\n" )
+      end
+      if p.get_array_size then
+        f.print( "    int_t  subscript;\n" )
+      end
+      f.print( "};\n\n" )
+    }
+  end
+
+  def gen_cell_skel_fun f
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :EPSF_comment ), "#_EPSF_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+      if p.is_skelton_useless? then    # åãå£æé©å
+        f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" )
+        next
+      end
+
+      f.print( "/* #{p.get_name} */\n" )
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        functype = fun.get_declarator.get_type
+        f.printf "%-14s", functype.get_type_str
+
+        f.print " #{@global_name}_#{p.get_name}_#{fun.get_name}_skel("
+        f.print " const struct tag_#{p.get_signature.get_global_name}_VDES *epd"
+        delim = ","
+
+        if functype.get_paramlist then
+          items = functype.get_paramlist.get_items
+          len = items.length
+        else
+          # ããã§ nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å
+          items = []
+          len = 0
+        end
+        i = 0
+        items.each{ |param|
+          f.print "#{delim} "
+          delim = ","
+          f.print param.get_type.get_type_str
+          f.print " "
+          f.print param.get_name
+          f.print param.get_type.get_type_str_post
+          i += 1
+        }
+        f.print ")\n"
+
+        f.print "{\n"
+        if ( ! @singleton || p.get_array_size != nil ) then
+          f.print "    struct tag_#{@global_name}_#{p.get_name}_DES *lepd\n"
+          f.print "        = (struct tag_#{@global_name}_#{p.get_name}_DES *)epd;\n"
+        end
+
+        if functype.get_type_str == "void" then # mikan "void" ã® typedef ã«æªå¯¾å¿
+          f.print "    "
+        else
+          f.print "    return "
+        end
+
+        f.print "#{@global_name}_#{p.get_name}_#{fun.get_name}("
+        if @singleton then
+          delim = ""
+        else
+          f.print " lepd->idx"
+          delim = ","
+        end
+
+        if p.get_array_size then
+          f.print "#{delim} lepd->subscript"
+          delim = ","
+        end
+
+        items.each{ |param|
+          f.print "#{delim} "
+          delim = ","
+          f.print param.get_name
+          i += 1
+        }
+        f.print " );\n"
+
+        f.print "}\n"
+      }
+    }
+    if @n_entry_port >0 then
+      f.print( "\n" )
+    end
+  end
+
+  def gen_cell_fun_table f
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :EPSFT_comment ), "#_EPSFT_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+      if p.is_VMT_useless? then    # åãå£æé©å
+        f.print "/* #{p.get_name} : omitted by entry port optimize */\n"
+        next
+      end
+
+      f.print "/* #{p.get_name} */\n"
+
+      # f.print "static const struct tag_#{p.get_signature.get_global_name}_VMT"
+      f.print "const struct tag_#{p.get_signature.get_global_name}_VMT"
+      f.print " #{@global_name}_#{p.get_name}_MT_ = {\n"
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        f.print "    #{@global_name}_#{p.get_name}_#{fun.get_name}_skel,\n"
+      }
+
+      f.print "};\n"
+    }
+    f.print "\n"
+
+  end
+
+  def gen_cell_ep_vdes fs
+    if @n_cell_gen  >0 then
+      fs.each{ |r,f| f.printf( TECSMsg.get( :CPEPD_comment ), "#_CPEPD_#" ) }
+    end
+
+    # ãã®ã»ã«ã¿ã¤ãã®ãã¹ã¦ã®ã»ã«ã«ã¤ãã¦
+    @ordered_cell_list.each{ |c|
+      if c.is_generate? then                           # çæå¯¾è±¡ãï¼
+
+        f = fs[ c.get_region.get_domain_root ]
+
+        # çµåã®ãªã¹ã (NamedList)
+        jl = c.get_join_list
+
+        # å
+¨ã¦ã®çµåãªã¹ãã«ã¤ãã¦
+        jl.get_items.each{ |j|
+
+          # å·¦è¾ºã®å®ç¾©ãå¾ã
+          definition = j.get_definition
+
+          # å¼ã³å£ã§ã¯ãªãï¼ãï¼å±æ§ï¼
+          next unless definition.instance_of? Port
+
+          port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ
+å ±ããã)
+          # port = definition    # definition ã¯ composite ã® Port ãå¾ããããã¨ããã
+          next if port.is_cell_unique?
+          next if port.is_omit?
+
+          # é
+åè¦ç´ ãå¾ãï¼åãå£é
+åã§ãªããã° nil ãè¿ãï¼
+          am = j.get_array_member2
+
+          # å¼ã³å£é
+åã?
+          if am  then
+            i = 0
+            while( i < am.length )
+              j = am[i]
+              if j then
+                if am[i].get_cell.get_celltype == self then
+                  # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)
+                  p = am[i].get_rhs_port
+                  des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES"
+                else
+                  des_type = "struct tag_#{definition.get_signature.get_global_name}_VDES"
+                end
+
+                # å³è¾ºã¯åãå£é
+åãï¼
+                if j.get_rhs_subscript then
+
+                  # åãå£ã®é
+åæ·»æ°
+                  subscript = j.get_rhs_subscript
+
+                  f.printf( "extern %s %s%d;\n",
+                            des_type,
+                            "#{j.get_port_global_name(i)}_des",
+                            subscript)
+                else
+                  f.printf( "extern %s %s;\n",
+                            des_type,
+                            "#{j.get_port_global_name(i)}_des")
+                end
+              #else if j == nil
+              #  optioanl ã§é
+åè¦ç´ ãåæåããã¦ããªã
+              end
+              i += 1
+            end
+          else
+            if j.get_cell.get_celltype == self then
+              # åãã»ã«ã¿ã¤ãã¸çµåãã¦ããå ´å(VDES ã§ã¯ type conflict ã«ãªã)
+              p = j.get_rhs_port
+              des_type = "const struct tag_#{@global_name}_#{p.get_name}_DES"
+            else
+              des_type = "struct tag_#{definition.get_signature.get_global_name}_VDES"
+            end
+
+            if j.get_rhs_subscript then
+              # åãå£é
+å
+              subscript = j.get_rhs_subscript
+              f.printf( "extern %s %s%d;\n",
+                        des_type,
+                        "#{j.get_port_global_name}_des",
+                        subscript)
+            else
+              f.printf( "extern %s %s;\n",
+                        des_type,
+                        "#{j.get_port_global_name}_des" )
+            end
+          end
+          # mikan   cell ã® namespace æªå¯¾å¿ãJoin ã§ Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿
+è¦ãã
+        }
+
+        f.print "\n"
+      end
+    }
+  end
+
+  def gen_cell_ep_vdes_array fs
+    if @n_cell_gen >0 then
+      fs.each{ |r, f| f.printf( TECSMsg.get( :CPA_comment ), "#_CPA_#" ) }  # mikan å¼ã³å£é
+åãç¡ãå ´åãåºã¦ãã¾ã
+    end
+
+    @ordered_cell_list.each{ |c|
+      if c.is_generate? then
+        f = fs[ c.get_region.get_domain_root ]
+
+        jl = c.get_join_list
+        jl.get_items.each{ |j|
+          definition = j.get_definition
+          next unless definition.instance_of? Port
+          # port = definition    # definition ã¯ composite ã® Port ãå¾ããããã¨ããã
+          port = find j.get_name # celltype ã® Port (ãã¡ãã«æé©åæ
+å ±ããã)
+          next if port.is_cell_unique?
+          next if port.is_omit?
+
+          am = j.get_array_member2
+          if am  then
+            # å·¦è¾ºã¯é
+å
+
+            if ! port.is_skelton_useless? then
+              f.printf( "struct %s * const %s_%s[] = {\n",
+                        "tag_#{port.get_signature.get_global_name}_VDES",
+                        "#{c.get_global_name}",
+                        "#{j.get_name}" )
+            else
+
+#              ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©åã®å ´åããã®é
+åã¯åç
+§ãããªã
+              # mikan ãã®ã±ã¼ã¹ããã¹ãããã¦ããªã
+              f.printf( "const %s_IDX  %s_%s[] = {\n",
+#                        "#{j.get_celltype.get_global_name}",   # å³è¾º composite ã«å¯¾å¿ã§ããªã
+                        "#{j.get_rhs_cell.get_celltype.get_global_name}",
+                        "#{c.get_global_name}",
+                        "#{j.get_name}" )
+            end
+            if port.get_array_size == "[]" then
+              length = am.length
+            else
+              length = port.get_array_size
+            end
+            # am.each { |j|
+            i = 0
+            while i < length
+              j = am[i]
+              i += 1
+
+              if j then
+                # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ã­ã£ã¹ããå¿
+è¦
+                if j.get_rhs_cell.get_celltype == self then
+                  definition = j.get_definition
+                  des_type_cast = "(struct tag_#{definition.get_signature.get_global_name}_VDES *)"
+                else
+                  des_type_cast = ""
+                end
+
+                
+                if j.get_rhs_subscript then
+                  # å³è¾ºé
+åã®å ´å(æé©åã¯ãªã)
+                  subscript = j.get_rhs_subscript
+                  f.printf( "    %s%d,\n",
+                            "#{des_type_cast}&#{j.get_port_global_name}_des",
+                            subscript)
+                  # p "1: #{j.get_port_global_name}_des"
+                  # p "2: #{j.get_cell_global_name}_#{j.get_port_name}_des"
+
+                else
+                  # å³è¾ºéé
+åã®å ´å */
+                  if ! port.is_skelton_useless? then
+                    f.printf( "    %s,\n",
+                              "#{des_type_cast}&#{j.get_port_global_name}_des" )
+                  else
+                    cell = j.get_rhs_cell
+                    name_array = cell.get_celltype.get_name_array( cell )
+                    f.printf( "    #{name_array[7]},\n" )
+                  end
+                end
+              else
+                # optional ã§å¼ã³å£é
+åè¦ç´ ãåæåããã¦ããªã
+                f.printf( "    0,\n" )
+              end
+            # }
+            end
+            # mikan   cell ã® namespace æªå¯¾å¿ãJoin ã§ Cell ãªãã¸ã§ã¯ããå¼å½ã¦ããå¿
+è¦ãã
+            f.print "};\n"
+          end
+        }
+
+        f.print "\n"
+      end
+    }
+  end
+
+  #=== CB ãåæåãããã­ã°ã©ã ã®çæ
+  def gen_cell_cb_initialize_code f
+    if ! need_CB_initializer?
+      return
+    end
+    f.printf( TECSMsg.get( :CIC_comment ), "#_CIC_#" )
+    f.print <<EOT
+void
+#{@global_name}_CB_initialize()
+{
+EOT
+    if @singleton then
+      f.print <<EOT
+    SET_CB_INIB_POINTER(i,p_cb)
+    INITIALIZE_CB()
+EOT
+    else
+      f.print <<EOT
+    #{@global_name}_CB	*p_cb;
+    int		i;
+    FOREACH_CELL(i,p_cb)
+        SET_CB_INIB_POINTER(i,p_cb)
+        INITIALIZE_CB(p_cb)
+    END_FOREACH_CELL
+EOT
+    end
+
+    f.print <<EOT
+}
+EOT
+  end
+
+  # === CB/INIB ã®å¤ã§åæåãããå¤æ°ã®åºå
+  def gen_cell_cb_out_init fs
+
+    # ã»ã«ããªããã°ãåºåããªã
+    if @n_cell_gen == 0 then
+      return
+    end
+
+    fs.each{ |r, f| f.printf( TECSMsg.get( :AVAI_comment ), "#_AVAI_#" ) }
+
+    # attribute, var ã®ãã¤ã³ã¿åã®åç
+§ããé
+åãçæ
+    @ordered_cell_list.each{ |c|
+      next if  ! c.is_generate?
+
+      f = fs[ c.get_region.get_domain_root ]
+      name_array = get_name_array( c )
+
+      ct = c.get_celltype
+      jl = c.get_join_list
+
+      # attribute, var ã®ãã¤ã³ã¿å¤æ°ãé
+åã«ããåæåãããå ´åã®ãé
+åãåºå
+      av_list = ct.get_attribute_list + ct.get_var_list
+      if av_list.length != 0 then
+        av_list.each{ |a|    # a: Decl
+          j = jl.get_item( a.get_identifier )
+          if j then
+            init = j.get_rhs
+          else
+            init = a.get_initializer
+          end
+
+          if( a.is_type?( PtrType ) && ( (init && init.instance_of?( Array )) || init == nil ) )then
+            ptr_type = a.get_type
+            size = ptr_type.get_size
+
+            if size then
+              # å¼ãè©ä¾¡ãã(attribute, var ã«å«ã¾ããå¤æ°ãåç
+§å¯è½)
+              sz = size.eval_const( c.get_join_list, c.get_celltype.get_name_list )
+              # å¼ãçæããªãã (å¤æ°ãå«ã¾ãªãå½¢ã«ãã)  ä¸å®å
+¨ãªå½¢ã§ Token ãçæ (ã¨ã©ã¼çºçããªããã)
+              size = Expression.new( [:INTEGER_CONSTANT, Token.new(sz, nil, 0, 0)] )
+              array_type = ArrayType.new( size )
+              type = a.get_type.get_referto
+              if ! type.is_const? && a.get_kind == :ATTRIBUTE then
+                type.set_qualifier :CONST
+              end
+              array_type.set_type( type )
+              if a.get_kind == :ATTRIBUTE then
+                f.print "const "
+              end
+              f.printf( "#{a.get_type.get_referto.get_type_str} #{name_array[3]}_#{a.get_identifier}_INIT[%d]#{a.get_type.get_referto.get_type_str_post}", sz )
+								# name_array[3]: cell_CB_INIT
+              if !( $ram_initializer && a.get_kind == :VAR ) then
+                # -R (ram initializer ä½¿ç¨) ã®å ´å var ã¯åæåã³ã¼ããåºåããªã
+                if( init )then
+                  str = " = #{gen_cell_cb_init( f, c, name_array, array_type, init, a.get_identifier, 1, true )}"
+                  str = str.sub( /\}$/, "};\n" )
+                else
+                  str = ";\n"
+                end
+                f.print( str )
+              else
+                f.print( ";\n" )
+              end
+            end
+          end
+        }
+      end
+    }
+  end
+
+  #=== var ã®åæå¤ã® ROM é¨ã¸ã®
+  def gen_cell_var_init f
+    # var ã®{ }ã§å²ã¾ããåæå¤æå®ããããèª¿ã¹ã
+    n_init = 0
+    @var.each { |v|
+      init = v.get_initializer
+      if init && init.instance_of?( Array ) then
+        n_init += 1
+      end
+    }
+
+    if n_init > 0 then
+      f.printf( TECSMsg.get( :AVI_comment ), "#_AVI_#" )
+      @var.each { |v|
+        init = v.get_initializer
+        if init && init.instance_of?( Array ) then
+          type = v.get_type.get_original_type
+
+          if( type.kind_of? PtrType )then
+            # PtrType ã¯ ArrayType ã«ããæ¿ãã
+
+            # åæåå­ã®è¦ç´ æ°ã ãã¨ããï¼å¾ã¯ 0)
+            t2 = ArrayType.new( Expression.create_integer_constant( init.length, nil ) )
+            t2.set_type( type.get_type )
+            type = t2
+          end
+
+          c = @ordered_cell_list[0]   # ä»®ã® cell (å®éã«ã¯ä½¿ãããªã)
+          name_array = get_name_array( c )
+          # f.print "const #{type0.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type0.get_type_str_post} = "
+          f.print "const #{type.get_type_str}\t#{@global_name}_#{v.get_name}_VAR_INIT#{type.get_type_str_post} = "
+          if type.kind_of? StructType then
+            # celltype ã® default ã®åæå¤ãã
+            str = gen_cell_cb_init( f, c, name_array, type, init, v.get_identifier, 1, true )
+          elsif( type.kind_of?( PtrType ) || type.kind_of?( ArrayType ) ) then
+            str = "{ "
+            type = type.get_type
+            # mikan ãã¤ã³ã¿ã§ã¯ãªããé
+ååã¨ããªãã¨ããã¤ã³ã¿å¤æ°ã®é åã®åãæãã
+            init.each { |i|
+              str += gen_cell_cb_init( f, c, name_array, type, i, v.get_identifier, 1, true )
+              str += ", "
+            }
+            str += "}"
+          else
+            p type.class
+            raise "Unknown Type"
+          end
+          f.print str
+          f.print ";\n"
+        end
+      }
+      f.print "\n"
+    end
+
+  end
+
+  def gen_cell_cb fs
+    if has_INIB? then
+      if @n_cell_gen > 0 then
+        fs.each{ |r, f| f.printf( TECSMsg.get( :INIB_comment ), "#_INIB_#" ) }
+      end
+      if @singleton then
+        fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_SINGLE_CELL_INIB = \n" }
+        indent = 0
+      elsif ! @idx_is_id_act then
+        fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_INIB_tab[] = {\n" }
+        indent = 1
+      else
+        indent = 0
+      end
+
+      @ordered_cell_list.each{ |c|
+        next if ! c.is_generate?
+
+        f = fs[ c.get_region.get_domain_root ]
+
+        name_array = get_name_array( c )
+
+        unless @singleton then
+          print_indent( f, indent )
+          f.print "/* cell: #{name_array[2]}:  #{name_array[1]} id=#{c.get_id} */\n"
+			    # name_array[2]: cell_CB_name
+        end
+
+        print_indent( f, indent )
+        if @idx_is_id_act then
+          f.print "const #{@global_name}_INIB #{name_array[5]} = "
+        end
+        f.print "{\n"
+
+        gen_cell_cb_port( c, indent, f, name_array )
+        gen_cell_cb_attribute( c, indent, f, name_array, :INIB )
+
+        unless @singleton then
+          # 1 ã¤ã® cell INIB ã®çµãã
+          if @idx_is_id_act then
+            f.print( "};\n\n" )
+          else
+            f.print( "    },\n" )
+          end
+        end
+      }
+      if ! @idx_is_id_act then
+        fs.each{ |r, f| f.print( "};\n\n" ) }
+      end
+    end  # has_INIB?
+
+    if has_CB? then
+      if @n_cell_gen >0 then
+        fs.each{ |r, f| f.printf( TECSMsg.get( :CB_comment ),  "#_CB_#" ) }
+      end
+
+      # RAM initializer ãä½¿ç¨ããªããã¾ãã¯ ROM åããªã
+      if $ram_initializer == false || $rom == false then
+        if @singleton then
+          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB = \n" }
+          indent = 0
+        elsif ! @idx_is_id_act then
+          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_CB_tab[] = {\n" }
+          indent = 1
+        end
+
+        @ordered_cell_list.each{ |c|
+          next if ! c.is_generate?
+
+          f = fs[ c.get_region.get_domain_root ]
+
+          name_array = get_name_array( c )
+
+          unless @singleton then
+            print_indent( f, indent )
+            f.print "/* cell: #{name_array[2]}:  #{name_array[1]} id=#{c.get_id} */\n"
+            # name_array[2]: cell_CB_name
+          end
+
+          print_indent( f, indent )
+          if @idx_is_id_act then
+            f.print "#{@global_name}_CB #{name_array[2]} = "
+          end
+          f.print "{\n"
+
+          if has_INIB? then
+            print_indent( f, indent + 1 )
+            f.printf( "&%-39s /* _inib */\n", "#{name_array[5]}," )
+          end
+
+          if ! has_INIB? then
+            gen_cell_cb_port( c, indent, f, name_array )
+          end
+
+          gen_cell_cb_attribute( c, indent, f, name_array, :CB )
+          gen_cell_cb_var( c, indent, f, name_array )
+
+          unless @singleton then
+            # 1 ã¤ã® cell CB ã®çµãã
+            if @idx_is_id_act then
+              f.print( "};\n\n" )
+            else
+              f.print( "    },\n" )
+            end
+          end
+        }
+        if ! @idx_is_id_act then
+          fs.each{ |r, f| f.print( "};\n\n" ) }
+        end
+      else
+        if @singleton then
+          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB;\n" }
+          indent = 0
+        elsif @idx_is_id_act then
+          @ordered_cell_list.each{ |c|
+            next if ! c.is_generate?
+
+            f = fs[ c.get_region.get_domain_root ]
+
+            name_array = get_name_array( c )
+            f.print "/* cell: #{name_array[2]}:  #{name_array[1]} id=#{c.get_id} */\n"
+            f.print "#{@global_name}_CB #{name_array[2]} = {};\n"
+          }
+        else
+          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_CB_tab[#{@n_cell_gen}];\n" }
+        end
+      end
+    end  # has_CB?
+  end
+
+  def gen_cell_cb_tab f
+    indent = 0
+    if @idx_is_id_act then
+      if has_INIB? && ( $ram_initializer || ! has_CB? ) then
+        f.print "/* ID to INIB table #_INTAB_# */\n"
+        @ordered_cell_list.each{ |c|
+          if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæå¯¾è±¡ãã¤ãã«ã¼ãä»¥å¤ã
+            name_array = get_name_array( c )
+            print_indent( f, indent + 1 )
+            f.print "extern #{@global_name}_INIB  #{name_array[5]};\n"
+          end
+        }
+
+        f.print "#{@global_name}_INIB *#{@global_name}_INIB_tab[] ={\n"
+        @ordered_cell_list.each{ |c|
+          if c.is_generate? then                           # çæå¯¾è±¡ãï¼
+            name_array = get_name_array( c )
+            print_indent( f, indent + 1 )
+            f.print "&#{name_array[5]},\n"
+          end
+        }
+        f.print "};\n"
+      end
+      if has_CB? then
+        f.print "/* ID to CB table #_CBTAB_# */\n"
+        @ordered_cell_list.each{ |c|
+          if c.is_generate? && ( c.get_region.get_domain_root != Region.get_root ) then # çæå¯¾è±¡ãã¤ãã«ã¼ãä»¥å¤ã
+            name_array = get_name_array( c )
+            print_indent( f, indent + 1 )
+            f.print "extern #{@global_name}_CB  #{name_array[2]};\n"
+          end
+        }
+
+        f.print "#{@global_name}_CB *#{@global_name}_CB_tab[] ={\n"
+        @ordered_cell_list.each{ |c|
+          if c.is_generate? then                           # çæå¯¾è±¡ãï¼
+            name_array = get_name_array( c )
+            print_indent( f, indent + 1 )
+            f.print "&#{name_array[2]},\n"
+          end
+        }
+        f.print "};\n"
+      end
+    end
+  end
+
+
+  #=== name_array ãçæ
+  # IN:   cell  : Cell
+  #       index : CB, INIB é
+åã®æ·»æ°
+  # RETURN: name_array
+  #   name_array[0] = @name           # celltype name
+  #   name_array[1] = cell.get_name   # cell name
+  #   name_array[2] = cell_CB_name    # cell_CB_name
+  #   name_array[3] = cell_CB_INIT    # cell_CB_INIT # CB ã®å¤å´ã§åæåãå¿
+è¦ãªé
+åã®åå
+  #   name_array[4] = cell_CB_proto   # CB name for prototype
+  #   name_array[5] = cell_INIB       # INIB name
+  #   name_array[6] = cell_ID         # ID
+  #   name_array[7] = cell_IDX        # IDX
+  #   name_array[8] = cell_CBP        # CB pointer
+  #   name_array[9] = @global_name    # celltype global name
+  #   name_array[10] = cell.get_global_name # cell global name
+  
+  def get_name_array( cell )
+
+    if @singleton then
+      cell_CB_name = "#{@global_name}_SINGLE_CELL_CB"
+      cell_CB_INIT = cell_CB_name
+      cell_CB_proto = "#{@global_name}_SINGLE_CELL_CB"
+      cell_INIB_name = "#{@global_name}_SINGLE_CELL_INIB"
+      cell_ID = 0
+    else
+      if ! @idx_is_id_act then
+        index = cell.get_id - cell.get_celltype.get_id_base
+        cell_CB_name = "#{@global_name}_CB_tab[#{index}]"
+        cell_CB_INIT = "#{@global_name}_#{cell.get_name}_CB"
+        cell_CB_proto = "#{@global_name}_CB_tab[]"
+        cell_INIB_name = "#{@global_name}_INIB_tab[#{index}]"
+      else
+        cell_CB_name = "#{cell.get_global_name}_CB"
+        cell_CB_INIT = cell_CB_name
+        cell_CB_proto = cell_CB_name
+        cell_INIB_name = "#{cell.get_global_name}_INIB"
+      end
+      cell_ID = cell.get_id
+    end
+    if @idx_is_id_act then
+      cell_IDX = cell_ID
+    else
+      cell_IDX = "&#{cell_CB_name}"
+    end
+
+    if ! has_CB? && ! has_INIB? then
+      cell_CBP = "NULL"    # CB ã INIB ããªããã° NULL ã«ç½®æ
+    else
+      cell_CBP = "&#{cell_CB_name}"
+    end
+
+    name_array = []
+    name_array[0] = @name           # celltype name
+    name_array[1] = cell.get_name   # cell name
+    name_array[2] = cell_CB_name    # cell_CB_name
+    name_array[3] = cell_CB_INIT    # cell_CB_INIT
+    name_array[4] = cell_CB_proto   # CB name for prototype
+    name_array[5] = cell_INIB_name  # cell INIB name
+    name_array[6] = cell_ID         # cell ID
+    name_array[7] = cell_IDX        # cell IDX
+    name_array[8] = cell_CBP        # cell CBP
+    name_array[9] = @global_name    # celltype global name
+    name_array[10] = cell.get_global_name # cell global name
+
+    return name_array
+  end
+
+  #=== attribute ã¨ size_is æå®ããã var (ãã¤ã³ã¿)ã®åæåãã¼ã¿ãåºå
+  #
+  # ROM åãµãã¼ãã®æç¡ãããã³åºåå¯¾è±¡ã CB ã INIB ãã«ããåºåãããå
+å®¹ãç°ãªã
+  def gen_cell_cb_attribute( cell, indent, f, name_array, cb_inib )
+    ct = self
+    jl = cell.get_join_list
+
+    if cb_inib == :INIB then
+      return if @n_attribute_ro == 0 && @n_var_size_is == 0
+      print_indent( f, indent + 1 )
+      f.print "/* attribute(RO) */ \n"
+    elsif $rom then  # && cb_inib == CB
+      # CB ã§ rw ã¨ var
+      return if @n_attribute_rw == 0
+      print_indent( f, indent + 1 )
+      f.print "/* attribute(RW) */ \n"
+    else  # cb_inib == CB && $rom == false
+      # CB ã«å
+¨é¨
+      return if @n_attribute_rw == 0 && @n_attribute_ro == 0 && @n_var_size_is == 0
+      print_indent( f, indent + 1 )
+      f.print "/* attribute */ \n"
+    end
+
+    attribute = ct.get_attribute_list
+    attribute.each{ |a|              # a: Decl
+      next if a.is_omit?
+      if cb_inib == :INIB && a.is_rw? == true then
+        # $rom == true ã§ãããããã¸æ¥ãªã
+        next
+      elsif cb_inib == :CB && $rom && ! a.is_rw? then
+        next
+      end
+
+      j = jl.get_item( a.get_identifier )
+      if j then
+        # cell ã®åæå¤æå®ãã
+        gen_cell_cb_init( f, cell, name_array, a.get_type, j.get_rhs, a.get_identifier, indent + 1 )
+      elsif a.get_initializer then
+        # celltype ã® default ã®åæå¤ãã
+        gen_cell_cb_init( f, cell, name_array, a.get_type, a.get_initializer, a.get_identifier, indent + 1 )
+      else
+        # åæå¤æªæå®
+        gen_cell_cb_init( f, cell, name_array, a.get_type, nil, a.get_identifier, indent + 1 )
+      end
+    }
+    @var.each{ |v|
+      next if v.is_omit?
+      next if v.get_size_is == nil   # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå
+
+      if v.get_initializer && $ram_initializer == false then
+        gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 )
+      else
+        # åæå¤æªæå® ã¾ãã¯ RAM initializer ä½¿ç¨
+        gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 )
+      end
+    }
+  end
+
+  #=== var ã®åæåãã¼ã¿ãåºå
+  def gen_cell_cb_var( cell, indent, f, name_array )
+    jl = cell.get_join_list
+    var = get_var_list
+    if @n_var - @n_var_size_is > 0 then
+      print_indent( f, indent + 1 )
+      f.print "/* var */ \n"
+      var.each{ |v|
+
+        next if v.is_omit?
+        next if v.get_size_is      # size_is æå®ãããå ´å attribute ã®ä¸é¨ã¨ãã¦åºå
+
+        if v.get_initializer && $ram_initializer == false then
+          gen_cell_cb_init( f, cell, name_array, v.get_type, v.get_initializer, v.get_identifier, indent + 1 )
+        else
+          # åæå¤æªæå® ã¾ãã¯ RAM initializer ä½¿ç¨
+          gen_cell_cb_init( f, cell, name_array, v.get_type, nil, v.get_identifier, indent + 1 )
+        end
+      }
+    end
+  end
+
+  def gen_cell_cb_port( cell, indent, f, name_array )
+    gen_cell_cb_call_port( cell, indent, f, name_array )
+    gen_cell_cb_entry_port( cell, indent, f, name_array )
+  end
+
+  #=== å¼ã³å£ã®åæåã³ã¼ãã®çæ
+  def gen_cell_cb_call_port( cell, indent, f, name_array )
+    jl = cell.get_join_list
+
+    port = get_port_list
+    if @n_call_port != 0 then
+      print_indent( f, indent + 1 )
+      f.print "/* call port #_CP_# */ \n"
+      port.each{ |p|
+        next if p.get_port_type != :CALL
+        next if p.is_omit?
+        next if p.is_cell_unique?        # æé©åï¼åä¸ã»ã«ã§å¼ã³å£ãã¯ã­ã«åãè¾¼ã¾ããï¼
+
+        j = jl.get_item( p.get_name )
+        print_indent( f, indent + 1 )
+
+        # debug
+        if j == nil then
+          # optional å¼ã³å£
+          # cdl_error( "H1003 internal error: cell \'$1\' port \'$2\': initializer not found\n" , cell.get_name, p.get_name )
+          # exit( 1 )
+          f.printf( "%-40s /* #_CCP5_# */\n",  "0," )
+          if p.get_array_size == "[]" then
+            # æ·»æ°çç¥ã®å¼ã³å£é
+å
+            print_indent( f, indent + 1 )
+            f.printf( "%-40s /* %s #_CCP6_# */\n", "0,", "length of #{p.get_name} (n_#{p.get_name})" )
+          end
+          next
+        end
+
+        am = j.get_array_member2
+        if am then
+          # å¼ã³å£é
+åã®å ´å
+          f.printf( "%-40s /* #_CCP3_# */\n",  "#{cell.get_global_name}_#{j.get_name}," )
+          if p.get_array_size == "[]" then
+            # æ·»æ°çç¥ã®å¼ã³å£é
+å
+            print_indent( f, indent + 1 )
+            f.printf( "%-40s /* %s #_CCP4_# */\n", "#{am.length},", "length of #{p.get_name} (n_#{p.get_name})" )
+          end
+        else
+          # åä¸ã»ã«ã¿ã¤ãã®çµåã®å ´åãVDES åã¸ã®ã­ã£ã¹ããå¿
+è¦
+          #print "CCP0/CCP1 #{p.get_name}, #{j.get_rhs_cell.get_celltype.get_name}, #{@name}\n"
+          if j.get_rhs_cell.get_celltype == self then
+            definition = j.get_definition
+            des_type_cast = "(struct tag_#{definition.get_signature.get_global_name}_VDES *)"
+          else
+            des_type_cast = ""
+          end
+
+          if j.get_rhs_subscript then
+            # åãå£é
+åã®å ´å
+            subscript = j.get_rhs_subscript
+            f.printf( "%-40s /* %s #_CCP0_# */\n",
+                      # "&#{j.get_cell_global_name}_#{j.get_port_name}_des#{subscript},",
+                      "#{des_type_cast}&#{j.get_port_global_name}_des#{subscript},",
+                      p.get_name )
+          else
+            # å¼ã³å£é
+åã§ããåãå£é
+åã§ããªã
+            if ! p.is_skelton_useless? then
+              f.printf( "%-40s /* %s #_CCP1_# */\n",
+                        "#{des_type_cast}&#{j.get_port_global_name}_des,",
+                        p.get_name )
+            else
+              # ã¹ã±ã«ãã³ä¸è¦æé©åï¼CB (INIB) ã¸ã®ãã¤ã³ã¿ãåãè¾¼ãï¼
+              c = j.get_rhs_cell                    # å¼ã³å
+ã»ã«
+              ct = c.get_celltype                   # å¼ã³å
+ã»ã«ã¿ã¤ã
+              if ct.has_INIB? || ct.has_CB? then
+                name_array = ct.get_name_array( c )   # å¼ã³å
+ã»ã«ã¿ã¤ãã§ name_array ãå¾ã
+                f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name )
+              else
+                # å¼ã³å
+ã¯ CB ã INIB ãæããªãï¼NULL ã«åæåï¼
+                f.printf( "%-40s /* %s #_CCP2_# */\n", "0,", p.get_name )
+              end
+            end
+          end
+        end
+
+      }
+      end
+  end
+
+  #=== åãå£ã®åæåã³ã¼ãã®çæ
+  def gen_cell_cb_entry_port( cell, indent, f, name_array )
+    jl = cell.get_join_list
+
+    port = get_port_list
+    if @n_entry_port != 0 then
+      print_indent( f, indent + 1 )
+      f.print "/* entry port #_EP_# */ \n"
+      @port.each{ |p|
+        # next if p.is_omit?  # åãå£é
+åã®åæ°ã¯çç¥ããªã
+        if p.get_port_type == :ENTRY && p.get_array_size == "[]"
+          print_indent( f, indent + 1 )
+          f.printf( "%-40s /*  #_EEP_# */\n", "#{cell.get_entry_port_max_subscript( p )+1}," )
+        end
+      }
+    end
+  end
+
+  #=== ã»ã«ã® attribute ã®åæå¤ãåºå
+  #
+  #f_get_str:: true ã®å ´åãæå­åãè¿ããfalse ã®å ´åããã¡ã¤ã« f ã«åºåããï¼
+  # æå­åãè¿ãã¨ããæ«å°¾ã« ',' ã¯å«ã¾ããªãï¼
+  # ãã¡ã¤ã«ã¸åºåããã¨ããæ«å°¾ã« ',' ãåºåãããï¼æ§é ä½è¦ç´ ãé
+åè¦ç´ ã®åæå¤ãåºåããã¨ ',' ãäºéã«åºåãããï¼
+  # ãã ãç¾ç¶ã§ã¯ããã¡ã¤ã«ã¸åºåãããã¨ã¯ãªã
+  #
+  def gen_cell_cb_init( f, cell, name_array, type, init, identifier, indent, f_get_str = false )
+
+    cell_CB_name = name_array[2]
+    cell_CB_INIT = name_array[3]
+
+    while type.kind_of?( DefinedType )
+      type = type.get_type
+    end
+
+    if ( init == nil ) then
+
+      if f_get_str then
+        # åæå¤æªæå®
+        if type.kind_of?( BoolType ) then
+          str = "false"   # formerly tecs_false
+        elsif type.kind_of?( IntType ) then
+          str = "0"
+        elsif type.kind_of?( FloatType ) then
+          str = "0.0"
+        elsif type.kind_of?( EnumType ) then
+          str = "0"
+        elsif type.kind_of?( ArrayType ) then
+          str = "{}"
+        elsif type.kind_of?( StructType ) then
+          str = "{}"
+        elsif type.kind_of?( PtrType ) then
+          if type.get_size then
+            str = "#{cell_CB_INIT}_#{identifier}_INIT"
+          else
+            str = "0"
+          end
+        else
+          raise "UnknownType"
+        end
+        return str
+      else
+        # åæå¤æªæå®
+        if type.kind_of?( BoolType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "false,", identifier )   # formerly tecs_false
+        elsif type.kind_of?( IntType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "0,", identifier )
+        elsif type.kind_of?( FloatType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "0.0,", identifier )
+        elsif type.kind_of?( EnumType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "0,", identifier )
+        elsif type.kind_of?( ArrayType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "{},", identifier )
+        elsif type.kind_of?( StructType ) then
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "{},", identifier )
+        elsif type.kind_of?( PtrType ) then
+          if type.get_size then
+            f.print "    " * indent
+            f.printf( "%-40s /* %s */\n", "#{cell_CB_INIT}_#{identifier}_INIT,", identifier )
+          else
+            f.print "    " * indent
+            f.printf( "%-40s /* %s */\n", "0,", identifier )
+          end
+        else
+          raise "UnknownType"
+        end
+      end
+      return
+    end    
+
+    # ãã®ã¡ã½ããã¯ Celltype ã®ãã®ã§ããå¿
+è¦ã¯ç¡ãï¼ä¸ã«ç¶ãã®ã§ããã«ç½®ãï¼
+    # åæå¤æå®ãã
+    if type.kind_of?( BoolType ) then
+      if init.instance_of?( C_EXP ) then
+        init_str = subst_name( init.get_c_exp_string, name_array )
+      else
+        init_str = init.eval_const2(cell.get_join_list,@name_list)
+      end
+
+      if f_get_str then
+        return "#{init_str}"
+      else
+        f.print "    " * indent
+        f.printf( "%-40s /* %s */\n", "#{init_str},", identifier )
+      end
+#      if f_get_str then
+#        return "#{init.eval_const2(nil)}"
+#      else
+#        f.print "    " * indent
+#        f.printf( "%-40s /* %s */\n", "#{init.eval_const2(nil)},", identifier )
+#      end
+    elsif type.kind_of?( IntType ) then
+      if init.instance_of?( C_EXP ) then
+        init_str = subst_name( init.get_c_exp_string, name_array )
+      else
+        init_str = init.eval_const2(cell.get_join_list,@name_list)
+      end
+
+      if f_get_str then
+        return "#{init_str}"
+      else
+        f.print "    " * indent
+        f.printf( "%-40s /* %s */\n", "#{init_str},", identifier )
+      end
+    elsif type.kind_of?( FloatType ) then
+      # mikan C_EXP for FloatType
+      if f_get_str then
+        return "#{init.eval_const2(cell.get_join_list,@name_list)}"
+      else
+        f.print "    " * indent
+        f.printf( "%-40s /* %s */\n", "#{init.eval_const2(cell.get_join_list,@name_list)},", identifier )
+      end
+    elsif type.kind_of?( EnumType ) then
+      # mikan C_EXP for EnumType
+      if f_get_str then
+        return "#{init.eval_const2(cell.get_join_list,@name_list)}"
+      else
+        f.print "    " * indent
+        f.printf( "%-40s /* %s */\n", "#{init.eval_const2(cell.get_join_list,@name_list)},", identifier )
+      end
+    elsif type.kind_of?( ArrayType ) then
+      if type.get_subscript
+        len = type.get_subscript.eval_const(cell.get_join_list,@name_list)
+      else
+        len = init.length
+      end
+
+      at = type.get_type
+      i = 0
+      if f_get_str then
+        str = "{ " 
+      else
+        f.print "    " * indent
+        f.print( "{\n" )
+      end
+
+      len.times {
+        next if ! init[i]        # mikan ãã®å¦ç½®ã¯é©åï¼
+        if f_get_str then
+          str += gen_cell_cb_init( f, cell, name_array, at, init[i], "#{identifier}[#{i}]", indent + 1, f_get_str )
+          str += ', '
+        else
+          gen_cell_cb_init( f, cell, name_array, at, init[i], "#{identifier}[#{i}]", indent + 1, f_get_str )
+        end
+        i += 1
+      }
+
+      if f_get_str then
+         str += "}"
+      else
+        f.print "    " * indent
+        f.print( "},\n" )
+      end
+
+    elsif type.kind_of?( StructType ) then
+      i = 0
+      decls = type.get_members_decl.get_items
+      if f_get_str then
+        str = "{ "
+      else
+        f.print "    " * indent
+        f.print( "{                                        /* #{identifier} */\n" )
+      end
+
+      decls.each{ |d|
+        # p "#{d.get_identifier}: #{init}"
+        next if ! init[i]
+
+        if f_get_str then
+          str += gen_cell_cb_init( f, cell, name_array, d.get_type, init[i], d.get_identifier, indent + 1, f_get_str )
+          str += ', '
+        else
+          gen_cell_cb_init( f, cell, name_array, d.get_type, init[i], d.get_identifier, indent + 1, f_get_str )
+        end
+        i += 1
+      }
+      if f_get_str then
+        str += "}"
+      else
+        f.print "    " * indent
+        f.print( "},\n" )
+      end
+
+    elsif type.kind_of?( PtrType ) then
+
+      if init.instance_of?( Array ) then
+        if f_get_str then
+          return "#{cell_CB_INIT}_#{identifier}_INIT"
+        else
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "#{cell_CB_INIT}_#{identifier}_INIT,", identifier )
+        end
+      elsif init.instance_of?( C_EXP ) then
+        init_str = subst_name( init.get_c_exp_string, name_array )
+
+        if f_get_str then
+          return "#{init_str}"
+        else
+          f.print "    " * indent
+          f.printf( "%-40s /* %s */\n", "#{init_str},", identifier )
+        end
+
+      else
+        if f_get_str then
+          return "#{init.eval_const2(cell.get_join_list,@name_list)}"
+        else
+          f.print "    " * indent
+# p init.eval_const2(cell.get_join_list,@name_list).class
+# p init.eval_const2(cell.get_join_list,@name_list)
+# p identifier
+          f.printf( "%-40s /* %s */\n", "#{init.eval_const2(cell.get_join_list,@name_list)},", identifier )
+
+        end
+      end
+    else
+      raise "UnknownType"
+    end
+  end
+
+  #== é¢æ°ãã¼ãã«ã®å¤é¨åç
+§
+  def gen_cell_extern_mt fs
+    fs.each{ |r, f|
+      if ! r.is_root? then
+        @port.each{ |p|
+          next if p.is_omit?
+          if p.get_port_type == :ENTRY && ! p.is_VMT_useless? then
+            f.print "extern const struct tag_#{p.get_signature.get_global_name}_VMT"
+            f.print " #{@global_name}_#{p.get_name}_MT_;\n"
+          end
+        }
+      end
+    }
+  end
+
+  #=== åãå£ãã£ã¹ã¯ãªãã¿ã®å®ç¾©ãçæ
+  def gen_cell_ep_des fs
+    if @n_cell_gen >0 then
+      fs.each{ |r, f|        f.printf( TECSMsg.get( :EPD_comment ),  "#_EPD_#" ) }
+    end
+
+    index = 0
+    @ordered_cell_list.each{ |c|
+
+      next if ! c.is_generate?
+
+      f = fs[ c.get_region.get_domain_root ]
+
+      ct = c.get_celltype
+      jl = c.get_join_list
+
+      port = ct.get_port_list
+      if port.length != 0 then
+        port.each{ |p|
+          next if p.get_port_type != :ENTRY
+          next if p.is_omit?
+          if p.is_skelton_useless?       # åãå£æé©ån ep_opt
+            f.print( "/* #{p.get_name} : omitted by entry port optimize */\n" )
+            next
+          end
+
+          len = p.get_array_size
+          if len == "[]" then
+            len = c.get_entry_port_max_subscript(p) + 1
+          end
+
+          if len != nil then
+            # åãå£é
+åã®å ´å
+            i = 0
+            while i < len
+              f.print "extern const struct tag_#{@global_name}_#{p.get_name}_DES"
+              f.print " #{c.get_global_name}_#{p.get_name}_des#{i};\n"
+              f.print "const struct tag_#{@global_name}_#{p.get_name}_DES"
+              # f.print " #{c.get_name}_#{p.get_name}_des#{i} = {\n"
+              f.print " #{c.get_global_name}_#{p.get_name}_des#{i} = {\n"
+              if p.is_VMT_useless? then
+                f.print "    0,\n"
+              else
+                f.print "    &#{@global_name}_#{p.get_name}_MT_,\n"
+              end
+              if( @idx_is_id_act )then
+                f.print "    #{c.get_id},           /* ID */\n"
+              else
+                if has_CB? then
+                  if @singleton then
+                    f.print "    &#{@global_name}_SINGLE_CELL_CB,        /* CB */\n"
+                  else
+                    # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
+                    f.print "    &#{@global_name}_CB_tab[#{index}],      /* CB */\n"
+                  end
+                elsif has_INIB? then
+                  if @singleton then
+                    f.print "    &#{@global_name}_SINGLE_CELL_INIB,      /* INIB */\n"
+                  else
+                    f.print "    &#{@global_name}_INIB_tab[#{index}],    /* INIB */\n"
+                  end
+                else
+                  f.print "    0,\n"
+                end
+              end
+              f.print "    #{i}\n"
+              f.print "};\n"
+              i += 1
+            end
+          else
+            f.print "extern const struct tag_#{@global_name}_#{p.get_name}_DES"
+            f.print " #{c.get_global_name}_#{p.get_name}_des;\n"
+            f.print "const struct tag_#{@global_name}_#{p.get_name}_DES"
+            # f.print " #{c.get_name}_#{p.get_name}_des = {\n"
+            f.print " #{c.get_global_name}_#{p.get_name}_des = {\n"
+            if p.is_VMT_useless? then
+              f.print "    0,\n"
+            else
+              f.print "    &#{@global_name}_#{p.get_name}_MT_,\n"
+            end
+            if @idx_is_id_act then
+              f.print "    #{c.get_id},     /* ID */\n"
+            else
+              if has_CB? then
+                if @singleton then
+                  f.print "    &#{@global_name}_SINGLE_CELL_CB,       /* CB */\n"
+                else
+                  f.print "    &#{@global_name}_CB_tab[#{index}],     /* CB */\n"
+                  # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
+                end
+              elsif has_INIB? then
+                if @singleton then
+                  f.print "    &#{@global_name}_SINGLE_CELL_INIB,     /* INIB */\n"
+                else
+                  f.print "    &#{@global_name}_INIB_tab[#{index}],   /* INIB */\n"
+                end
+              else
+                f.print "    0,\n"
+              end
+            end
+            f.print "};\n"
+          end
+        }
+      end
+      index += 1
+    }
+  end
+
+  def generate_template_code
+
+    return if is_all_entry_inline?
+    return if @b_reuse && ! $generate_all_template
+    if ! ( @plugin && @plugin.gen_ep_func? ) then
+      return if $generate_no_template     # $generate_all_template ããåªå
+ããã
+
+      # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ãç¤ºãããã« "_templ" ãä»å ãã
+      fname = "#{$gen}/#{@global_name}_templ.#{$c_suffix}"
+    else
+      # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã
+      # ä¿®æ­£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£
+ã³ã¼ããçæããï¼
+      # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã
+      fname = "#{$gen}/#{@global_name}.#{$c_suffix}"
+    end
+
+    f = AppFile.open(fname)
+
+    unless ( @plugin && @plugin.gen_ep_func? ) then
+      f.printf( TECSMsg.get( :template_note ), @name, @name )
+    else
+      print_note( f, true )
+    end
+
+    f.print TECSMsg.get( :preamble_note )
+    gen_template_attr_access f
+    gen_template_cp_fun f
+    # gen_template_types f     # 0805503 è¿½å ãã¦ã¿ããããã£ã±ãããã
+    f.print( " *\n * #[</PREAMBLE>]# */\n\n" )
+    f.printf TECSMsg.get( :PAC_comment ), "#_PAC_#"
+
+    gen_template_private_header f
+    if ( @plugin ) then
+      # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã
+      @plugin.gen_preamble( f, @singleton, @name, @global_name )
+    end
+
+    gen_template_ep_fun f
+
+    f.print TECSMsg.get( :postamble_note )
+
+    if ( @plugin ) then
+      # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã
+      @plugin.gen_postamble( f, @singleton, @name, @global_name )
+    end
+
+    f.close
+  end
+
+#####  celltype template
+
+  def gen_template_private_header f
+    f.print "#include \"#{@global_name}_tecsgen.#{$h_suffix}\"\n\n"
+    f.print <<EOT
+#ifndef E_OK
+#define	E_OK	0		/* success */
+#define	E_ID	(-18)	/* illegal ID */
+#endif
+
+EOT
+  end
+
+  def gen_template_attr_access f
+
+    if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0 then
+      f.printf( TECSMsg.get( :CAAM_comment ), "#_CAAM_#" )
+    end
+
+    @attribute.each { |a|
+
+      next if a.is_omit?
+
+      f.printf( " * %-16s %-16s %-16s\n", a.get_name, "#{a.get_type.get_type_str} #{a.get_type.get_type_str_post}", "ATTR_#{a.get_name}" )
+
+    }
+
+    @var.each { |v|
+
+      next if v.is_omit?
+
+      f.printf( " * %-16s %-16s %-16s\n", v.get_name, "#{v.get_type.get_type_str} #{v.get_type.get_type_str_post}", "VAR_#{v.get_name}" )
+    }
+
+  end
+
+  def gen_template_types f
+    f.printf( TECSMsg.get( :TYP_comment ), "#_TYP_#", "#{@global_name}_CB", "#{@name}_IDX" )
+  end
+
+  def gen_template_cp_fun f
+    if @n_call_port >0 then
+      f.print " *\n"
+      f.printf( TECSMsg.get( :TCPF_comment ), "#_TCPF_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      # next if p.is_omit?
+
+      sig_name = p.get_signature.get_global_name
+      con_tmp = p.get_signature.get_context
+      if con_tmp then
+        context = " context:#{con_tmp}"
+      else
+        context = ""
+      end
+
+      if p.is_optional? then
+        optional = " optional:true"
+        if p.get_array_size
+          is_join = " *   bool_t     is_#{p.get_name}_joined(int subscript)        check if joined\n"
+        else
+          is_join = " *   bool_t     is_#{p.get_name}_joined()                     check if joined\n"
+        end
+      else
+        optional = ""
+        is_join = ""
+      end
+
+      if p.is_omit? then
+        omit = " omit:true"
+      else
+        omit = ""
+      end
+
+      if p.is_allocator_port? then
+        f.print " * allocator port for #{p.get_port_type.to_s.downcase} port:#{p.get_allocator_port.get_name} func:#{p.get_allocator_func_decl.get_name} param: #{p.get_allocator_param_decl.get_name}\n"
+      elsif ! p.is_require? then
+        f.print " * call port: #{p.get_name} signature: #{sig_name}#{context}#{optional}#{omit}\n#{is_join}"
+      else
+        f.print " * require port: signature:#{sig_name}#{context}\n"
+      end
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        
+        ft = fun.get_declarator.get_type
+
+        f.printf( " *   %-14s ", ft.get_type.get_type_str )
+        if ! p.is_require? || p.has_name? then
+          f.print( "#{p.get_name}_#{fun.get_name}(" )
+        else
+          f.print( "#{fun.get_name}(" )
+        end
+        delim = ""
+
+#        if ! @singleton then
+#          f.print( "#{delim} p_that" )
+#          delim = ","
+#        end
+
+        if p.get_array_size then
+          f.print( "#{delim} subscript" )
+          delim = ","
+        end
+
+        ft.get_paramlist.get_items.each{ |param|
+          f.print( "#{delim} #{param.get_type.get_type_str}" )
+          f.print( " #{param.get_name}#{param.get_type.get_type_str_post}" )
+          delim = ","
+	}
+        f.print( " );\n" )
+
+#        subsc = ""
+#        subsc = "[subscript]" if p.get_array_size
+#
+#        if @singleton then
+#          f.print( " *        #{@global_name}_#{p.get_name}" )
+#        else
+#          f.print( " *        (p_that)->#{p.get_name}" )
+#        end
+#        f.print( "#{subsc}->VMT->#{fun.get_name}(" )
+#        f.print( " (p_that)->#{p.get_name}#{subsc}" )
+#        ft.get_paramlist.get_items.each{ |param|
+#          f.print( ", (#{param.get_name})" )
+#        }
+#        f.print( " )\n" )
+
+      }
+
+      if p.get_array_size then
+        f.print " *       subscript:  0...(NCP_#{p.get_name}-1)\n"
+      end
+
+    }
+
+  end
+
+  def gen_template_ep_fun( f, b_inline = false )
+
+    if @n_entry_port >0 then
+      f.printf( TECSMsg.get( :TEPF_comment ), "#_TEPF_#" )
+    end
+
+    @port.each { |p|
+      next if p.get_port_type != :ENTRY
+      next if p.is_omit?
+      next if b_inline && ! p.is_inline?  # inline ãã¼ã
+      next if ! b_inline && p.is_inline?  # é inline ãã¼ã
+
+      inline_prefix = ""
+      nCELLIDX = "CELLIDX"
+      nCELLCB = "CELLCB"
+      nVALID_IDX = "VALID_IDX"
+      nGET_CELLCB = "GET_CELLCB"
+
+      f.print <<EOT
+/* #[<ENTRY_PORT>]# #{p.get_name}
+ * entry port: #{p.get_name}
+ * signature:  #{p.get_signature.get_global_name}
+ * context:    #{p.get_signature.get_context}
+EOT
+
+      if p.get_array_size != nil then
+        f.print <<EOT
+ * entry port array size:  NEP_#{p.get_name}
+EOT
+      end
+
+      f.print <<EOT
+ * #[</ENTRY_PORT>]# */
+
+EOT
+
+      p.get_signature.get_function_head_array.each{ |fun|
+        f.print <<EOT
+/* #[<ENTRY_FUNC>]# #{p.get_name}_#{fun.get_name}
+ * name:         #{p.get_name}_#{fun.get_name}
+ * global_name:  #{@global_name}_#{p.get_name}_#{fun.get_name}
+ * oneway:       #{fun.is_oneway?}
+ * #[</ENTRY_FUNC>]# */
+EOT
+
+        if b_inline then
+          f.print "Inline "
+        end
+        functype = fun.get_declarator.get_type
+        f.printf "%s\n", functype.get_type_str
+        f.print "#{inline_prefix}#{p.get_name}_#{fun.get_name}("
+        if @singleton then
+          delim = ""
+        else
+          f.print "#{nCELLIDX} idx"
+          delim = ", "
+        end
+
+        if p.get_array_size then
+          f.print "#{delim}int_t subscript"
+          delim = ", "
+        end
+
+        if functype.get_paramlist then
+          items = functype.get_paramlist.get_items
+          len = items.length
+        else
+          # ããã§ nil ã«ãªãã®ã¯ãå¼æ°ãªãã®æã« void ããªãã£ãå ´å
+          items = []
+          len = 0
+        end
+
+        i = 0
+        items.each{ |param|
+          f.print "#{delim}"
+          delim = ", "
+          f.print param.get_type.get_type_str
+          f.print " "
+          f.print param.get_name
+          f.print param.get_type.get_type_str_post
+          i += 1
+        }
+        f.print ")\n"
+
+        f.print "{\n"
+
+        if ( @plugin && @plugin.gen_ep_func? ) then
+          # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã
+          @plugin.gen_ep_func_body( f, @singleton, @name, @global_name, p.get_signature.get_global_name, p.get_name, fun.get_name, "#{@global_name}_#{p.get_name}_#{fun.get_name}", functype, items )
+
+        else
+          if ! @singleton then
+            if functype.get_type.kind_of?( DefinedType ) && ( functype.get_type.get_type_str == "ER" || functype.get_type.get_type_str == "ER_UINT" ) then
+              if ! fun.is_oneway? then
+                f.print "	ER\t\tercd = E_OK;\n"
+                er_cd = "return(E_ID);"
+                ret_cd = "return(ercd);"
+              else
+                er_cd = "#{TECSMsg.get(:oneway_ercd_note)}\n		return(E_OK);"
+                ret_cd = "#{TECSMsg.get(:oneway_ercd_note)}\n	return(E_OK);"
+              end
+            else
+              er_cd = "#{TECSMsg.get(:ercd_note)}"
+              ret_cd = nil
+            end
+            f.print <<EOT
+	#{nCELLCB}	*p_cellcb;
+	if (#{nVALID_IDX}(idx)) {
+		p_cellcb = #{nGET_CELLCB}(idx);
+	}
+	else {
+		#{er_cd}
+	} /* end if #{nVALID_IDX}(idx) */
+
+EOT
+            f.printf( TECSMsg.get( :TEFB_comment ), "#_TEFB_#" )
+            f.printf( "\n" )
+
+            if ret_cd then
+              f.print "	#{ret_cd}\n"
+            end
+          else
+          end # ! @singleton
+        end # @plugin
+
+        f.print "}\n\n"
+      }
+    }
+  end
+
+  def generate_inline_template_code
+    return if @n_entry_port_inline == 0
+    if ! ( @plugin && @plugin.gen_ep_func? ) then
+      return if @b_reuse && ! $generate_all_template
+      return if $generate_no_template     # $generate_all_template ããåªå
+ããã
+
+      # åèã¨ãã¦åºåãããã³ãã¬ã¼ããã¡ã¤ã«ã§ãããã¨ãç¤ºãããã« "_templ" ãä»å ãã
+      fname = "#{$gen}/#{@global_name}_inline_templ.#{$h_suffix}"
+    else
+      # Plugin ã«ããçæãããã»ã«ã¿ã¤ãã«ã¤ãã¦ã¯ãååçã«ãã³ãã¬ã¼ãã§ã¯ãªãã
+      # ä¿®æ­£ä¸è¦ãªã»ã«ã¿ã¤ãã®å®è£
+ã³ã¼ããçæããï¼
+      # ãã®ããããã¡ã¤ã«åã« _temp ãä»å ããªã
+      fname = "#{$gen}/#{@global_name}_inline.#{$h_suffix}"
+    end
+    f = AppFile.open(fname)
+
+    gen_ph_guard f, "_INLINE"
+
+    unless ( @plugin && @plugin.gen_ep_func? ) then
+      f.printf( TECSMsg.get( :inline_template_note ), @name, @name )
+    else
+      print_note( f, true )
+    end
+
+    f.print TECSMsg.get( :preamble_note )
+    gen_template_attr_access f
+    gen_template_cp_fun f
+    f.print( " *\n * #[</PREAMBLE>]# */\n\n" )
+
+    gen_template_ep_fun( f, true )
+
+    f.print TECSMsg.get( :postamble_note )
+
+    if ( @plugin ) then
+      # ãã®ã¡ã½ããã®å¼æ°ã¯ plugin.rb ã®èª¬æãè¦ã
+      @plugin.gen_postamble( f, @singleton, @name, @global_name )
+    end
+
+    f.print "\n"
+    gen_ph_endif f, "INLINE"
+    f.close
+  end
+
+
+##### generate tecsgen.cfg
+
+  def generate_celltype_factory_code
+
+    @ct_factory_list.each { |fa|
+      if fa.get_name == :write then
+
+        # åå¾ã® " ãåãé¤ã
+        # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" )
+        file_name = CDLString.remove_dquote fa.get_file_name
+        format = CDLString.remove_dquote fa.get_format
+        # format    = fa.get_format.sub( /^\"(.*)/, "\\1" )        # åã® " ãåãé¤ã
+        # format    = format.sub( /(.*)\"\z/, "\\1" )              # å¾ã® " ãåãé¤ã
+        format    = format.gsub( /\\\n/, "\n" )                  # \\\n => \n
+
+
+        # mikan ä»¥ä¸ã¯ subst_name ã§ç½®æããããã«å¤æ´ãã¹ã
+        file_name = file_name.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" )   # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ
+        file_name = file_name.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" )   # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ
+        format    = format.gsub( /(^|[^\$])\$ct\$/, "\\1#{@name}" )   # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ
+        format    = format.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{@global_name}" )   # $ct$ ãã»ã«ã¿ã¤ãåã«ç½®æ
+        format    = format.gsub( /\$\$/, "\$" )                # $$ ã $ ã«ç½®æ
+
+        if file_name[0] != ?/ then
+          file_name = "#{$gen}/#{file_name}"
+        end
+
+        begin
+          cfg_file = AppFile.open( file_name )
+          if $debug then
+            print "'#{@name}' : celltype factory format: "
+            puts( format )
+          end
+          # format ä¸­ã® \n, \r, \t, \f ã¨ \" ãªã©ãç½®æ
+          fmt = CDLString.escape format
+          cfg_file.print( fmt )
+          cfg_file.puts( "\n" )
+          cfg_file.close()
+        rescue => evar
+          cdl_error( "H1004 \'$1\' : write error while writing factory (specify -t to get more info)" , file_name )
+          print_exception( evar )
+        end
+      end
+    }
+  end
+
+  def generate_cell_factory_code
+
+    @ordered_cell_list.each{ |c|
+
+      # cell ã®ãã­ãã¿ã¤ãå®£è¨ãªãç¡è¦
+      next if ! c.is_generate?
+
+      name_array = get_name_array( c )
+
+      @factory_list.each { |fa|
+
+        if fa.get_name == :write then
+
+          # åå¾ã® " ãåãé¤ã
+          # file_name = fa.get_file_name.sub( /^\"(.*)\"$/, "\\1" )
+          file_name = CDLString.remove_dquote fa.get_file_name
+          file_name = subst_name( file_name, name_array )
+          # format    = fa.get_format.sub( /^\"(.*)\"$/, "\\1" )        # åå¾ã® "" ãåãé¤ã
+          format    = CDLString.remove_dquote fa.get_format
+          # format    = fa.get_format.sub( /^\"(.*)/, "\\1" )        # åã® " ãåãé¤ã
+          # format    = format.sub( /(.*)\"\z/, "\\1" )              # å¾ã® " ãåãé¤ã
+          format    = format.gsub( /\\\n/, "\n" )                  # \\\n => \n
+
+          format    = subst_name( format, name_array )
+
+          arg_list  = fa.get_arg_list
+
+          if file_name[0] != ?/ then
+            file_name = "#{$gen}/#{file_name}"
+          end
+
+          na = []     # ã·ã³ãã«ã attribute ã®å¤ã«ç½®ãæããå¾ã®å¼æ°
+          if arg_list then
+            arg_list.each { |a|
+              case a[0]
+              when :STRING_LITERAL   # æå­åå®æ°
+                # s = a[1].sub( /^\"(.*)\"$/, "\\1" )            # åå¾ã® "" ãåãé¤ã
+                s = CDLString.remove_dquote a[1]
+                s = subst_name( s, name_array )
+                # s = subst_name( a[1], name_array )
+
+                na << s
+              when :IDENTIFIER
+                param_name = a[1]    # è­å¥å­ï¼å±æ§ã®ååï¼
+                attr = self.find( param_name )
+                init = attr.get_initializer      # celltype ã§æå®ãããåæå¤
+
+                # cell ã® join ã®ãªã¹ãããååãæ¢ã
+                j = c.get_join_list.get_item( param_name )
+                if j then    # param_name ã® cell ã®ã¸ã§ã¤ã³ãããã
+                  init = j.get_rhs                    # cell ã§æå®ãããåæå¤ãåªå
+
+                end
+
+                str = gen_cell_cb_init( nil, c,    name_array, attr.get_type, init, attr.get_identifier, 0,   true )
+                                      # file,cell, name_array, type,          init, identifier,       indent, f_get_str
+
+                # str = str.sub( /^\"(.*)\"$/, "\\1" )            # åå¾ã® "" ãåãé¤ã mikan ããã§ç½®æã§ããï¼
+                str = CDLString.remove_dquote str
+                na << str
+              end
+            }
+          end
+
+          begin
+            cfg_file = AppFile.open( file_name )
+
+            if $debug then
+              print "'#{c.get_name}' : factory format: "
+              print( format )
+              print( " arg: " )
+              na.each { |n| print "'#{n}' " }
+              print( "\n" )
+            end
+
+            # format ä¸­ã® \n, \r, \t, \f ã¨ \" ãªã©ãç½®æ
+            fmt = CDLString.escape format
+            cfg_file.printf( fmt, *na )
+            cfg_file.puts( "\n" )
+            cfg_file.close()
+          rescue => evar
+            cdl_error( "H1005 \'$1\' : write error while writing factory (specify -t to get more info)" , file_name )
+            print_exception( evar )
+          end
+        end
+      }
+    }
+
+  end
+
+  def generate_makefile
+    generate_makefile_template
+    generate_makefile_depend
+  end
+
+  def generate_makefile_template
+
+    return if $generate_no_template
+
+    # Makefile.templ ã®çæï¼è¿½è¨ï¼
+
+    f = AppFile.open( "#{$gen}/Makefile.templ" )
+    f.print <<EOT
+$(_TECS_OBJ_DIR)#{@global_name}.o : #{@global_name}.#{$c_suffix}
+	$(CC) -c $(CFLAGS) -o $@ $<
+ 
+EOT
+# ãã®çæè¦åã¯2ç¹ã§æå³ããªã
+#  ã»$(GEN_DIR) ã« .o ãçæããã«ã¼ã«ããªã
+#  ã»ãã³ãã¬ã¼ãã³ã¼ãããã®ã¾ã¾ãã«ãããã®ã¯ç´ãããã
+# # Celltype: #{@name}
+# $(GEN_DIR)/#{@global_name}_tecsgen.o : $(GEN_DIR)/#{@global_name}_tecsgen.#{$c_suffix}
+# 	$(CC) -c $(CFLAGS) -o $@ $<
+# 
+# $(GEN_DIR)/#{@global_name}_templ.o : $(GEN_DIR)/#{@global_name}_templ.#{$c_suffix}
+# 	$(CC) -c $(CFLAGS) -o $@ $<
+# 
+
+    f.close
+
+  end
+
+  def generate_makefile_depend
+
+    headers = [ "$(GEN_DIR)/#{@global_name}_tecsgen.#{$h_suffix}", "$(GEN_DIR)/#{@global_name}_factory.#{$h_suffix}", "$(GEN_DIR)/global_tecsgen.#{$h_suffix}" ]
+
+    # inline åãå£ãæã¤ãï¼
+    if @n_entry_port_inline > 0 then
+      headers << "#{@global_name}_inline.#{$h_suffix}"
+    end
+
+    # å¼ã³å£ã¾ãã¯åãå£ã®ã·ã°ããã£ã®ããã
+    @port.each { |p|
+      next if p.is_omit?
+      headers << "$(GEN_DIR)/#{p.get_signature.get_global_name}_tecsgen.#{$h_suffix}"
+    }
+
+    headers += get_depend_header_list
+    headers.sort!
+    headers.uniq!
+    headers = headers.join " "
+
+    f = AppFile.open( "#{$gen}/Makefile.depend" )
+
+#    print_Makefile_note f
+
+    f.print <<EOT
+# Celltype: #{@name}  #_MDEP_#
+$(_TECS_OBJ_DIR)#{@global_name}_tecsgen.o : #{@global_name}_tecsgen.#{$c_suffix} #{headers}
+$(_TECS_OBJ_DIR)#{@global_name}_templ.o : #{@global_name}_templ.#{$c_suffix} #{headers}
+$(_TECS_OBJ_DIR)#{@global_name}.o : #{@global_name}.#{$c_suffix} #{headers}
+
+EOT
+    f.close
+  end
+
+  #=== decl ç¨ã® dealloc ã³ã¼ããçæ
+  #b_reset:: Bool:  ãªã»ããç¨ã® dealloc ã³ã¼ãã®çæ (NULL ãã¤ã³ã¿ã®å ´å dealloc ããªã)
+  # mikan string ä¿®é£¾ããããã¤ã³ã¿ã®å
+ã«ãã¤ã³ã¿ãæ¥ãªãã¨ä»®å®ããã¤ã³ã¿åãæã¤æ§é ä½ã®å¯è½æ§ãæé¤ãã¦ããªã
+  # ãã®ã¡ã½ããã§ã¯ãè¡ãåºåããç´åã« " \\\n" ãåºåããè¡æ«ã§æ¹è¡æå­ãåºåããªã
+  def gen_dealloc_code_for_type( f, type, dealloc_func_name, pre, name, post, level, b_reset, count_str = nil )
+    type = type.get_original_type
+    indent = "	" + "  " * (level+1)
+    if ! type.has_pointer?
+      return
+    elsif type.kind_of?( ArrayType ) then
+      if type.get_type.has_pointer?
+        loop_str = "i#{level}__"
+        count_str = "#{type.get_subscript.eval_const(nil)}"
+        f.print " \\\n"
+        f.print "#{indent}{ int_t  #{loop_str};"
+        f.print " \\\n"
+        f.print "#{indent}  for( #{loop_str} = 0; #{loop_str} < #{count_str}; #{loop_str}++ ){ "
+        
+        gen_dealloc_code_for_type( f, type.get_type, dealloc_func_name, pre, name, "#{post}[#{loop_str}]", level+2, b_reset )
+
+        f.print " \\\n"
+        f.print "#{indent}  }"
+        f.print " \\\n"
+        f.print "#{indent}}"
+      end
+    elsif type.kind_of?( StructType ) then
+      members_decl = type.get_members_decl
+      members_decl.get_items.each { |md|
+        pre2 = pre + name.to_s + post + "."
+        name2 = md.get_name
+        post2 = ""
+        type2 = md.get_type.get_original_type
+        if type2.kind_of? PtrType then   # mikan typedef ãããå
+          if type2.get_count then
+            count_str = type2.get_count.to_str( members_decl, pre2, post2 )
+          elsif type2.get_size then
+            count_str = type2.get_size.to_str( members_decl, pre2, post2 )
+          else
+            count_str = nil
+          end
+        else
+            count_str = nil
+        end
+        gen_dealloc_code_for_type( f, md.get_type, dealloc_func_name, pre2, name2, post2, level, b_reset, count_str )
+      }
+
+    elsif type.kind_of?( PtrType ) then
+
+      if b_reset || type.is_nullable? then
+        nullable = ""
+        if( !b_reset && type.is_nullable? )then
+          nullable = "\t/* nullable */"
+        end
+        level2 = level + 1
+        indent2 = indent + "  "
+        f.print " \\\n"
+        f.print "#{indent}if( #{pre}#{name}#{post} ){#{nullable}"
+      else
+        level2 = level
+        indent2 = indent
+      end
+
+      if type.get_type.has_pointer?
+        if count_str then
+          loop_str = "i#{level}__"
+          f.print " \\\n"
+          f.print "#{indent2}{ int_t  #{loop_str};"
+          f.print " \\\n"
+          f.print "#{indent2}  for( #{loop_str} = 0; #{loop_str} < #{count_str}; #{loop_str}++ ){ "
+
+          gen_dealloc_code_for_type( f, type.get_type, dealloc_func_name, pre, name, "#{post}[#{loop_str}]", level2+2, b_reset )
+
+          f.print " \\\n"
+          f.print "#{indent2}  }"
+          f.print " \\\n"
+          f.print "#{indent2}}"
+        else
+          gen_dealloc_code_for_type( f, type.get_type, dealloc_func_name, "(*#{pre}", name, "#{post})", level2, b_reset )
+        end
+      end
+      f.print " \\\n"
+      f.print "#{indent2}#{dealloc_func_name}( #{pre}#{name}#{post} ); "
+
+      if b_reset || type.is_nullable? then
+        f.print " \\\n"
+        f.print "#{indent}}"
+      end
+    else
+      raise "UnknownType"
+    end
+  end
+
+  def get_depend_header_list
+    get_depend_header_list_( [] )
+  end
+
+  def get_depend_header_list_( celltype_list )
+    headers = []
+
+    if celltype_list.include? self then
+      return headers
+    else
+      celltype_list << self
+    end
+
+    # å¼ã³å£ã®çµåå
+ã®ã»ã«ã¿ã¤ãã®ãããï¼æé©åã®å ´åã®ã¿ï¼
+    # çµåå
+ã®åãå£ã inline ã®å ´åãinline ãããã
+    @port.each { |p|
+      next if p.get_port_type != :CALL
+      next if p.is_omit?
+
+      if p.is_skelton_useless? || p.is_cell_unique? || p.is_VMT_useless? then
+        # æé©åã³ã¼ã (optimize) # ã¹ã±ã«ãã³ä¸è¦ãªã©
+        p2 = p.get_real_callee_port
+        if p2 then
+          ct = p2.get_celltype
+          headers << " $(GEN_DIR)/#{ct.get_global_name}_tecsgen.#{$h_suffix}"
+          if p2.is_inline? then
+            headers << " #{ct.get_global_name}_inline.#{$h_suffix}"
+          end
+          headers += ct.get_depend_header_list_( celltype_list )
+        #else
+        #  optional ã§æªçµå  
+        end
+      end
+    }
+    return headers
+  end
+
+
+  #=== $id$, $ct$, $cb$, $idx$ ç½®æ
+  #
+  #  str ã«ä»¥ä¸ã®ç½®æãè¡ã
+  #-   $ct$ â ã»ã«ã¿ã¤ãå(ct)
+  #-   $cell$ â ã»ã«å(cell)   cell ã nil ãªãã°3ã¤ã®ç½®æã¯è¡ãããªã
+  #-   $cb$ â CB ã® C è¨èªå(cb)
+  #-   $cbp$ â CB ã¸ã®ãã¤ã³ã¿(cbp)
+  #-   $cb_proto$ â CB ã® C è¨èªåãã­ãã¿ã¤ãå®£è¨ç¨(cb_proto)
+  #-   $id$ â ct_cell
+  #-   $idx$ â idx
+  #-   $ID$ â id (æ´æ°ã®çªå·)
+  #-   $ct_global$ â ã»ã«ã¿ã¤ãå(ct)
+  #-   $cell_global$ â ã»ã«å(cell)   cell ã nil ãªãã°3ã¤ã®ç½®æã¯è¡ãããªã
+  #-   $$   â $
+  def subst_name( str, name_array )
+    ct   = name_array[0]    # celltype name
+    cell = name_array[1]    # cell name
+    cb   = name_array[2]    # cell CB name
+    cb_init = name_array[3] # cell CB INIT, ããã¯ç½®æã«ä½¿ãããªã
+    cb_proto = name_array[4] # cell CB name for prototype
+    id   = name_array[6]    # cell ID
+    idx  = name_array[7]    # cell CB name for prototype
+    cbp  = name_array[8]    # cell CB pointer
+    ct_global = name_array[9]    # cell CB pointer
+    cell_global  = name_array[10]    # cell CB pointer
+
+    str = str.gsub( /(^|[^\$])\$ct\$/, "\\1#{ct}" )
+    if cell then
+      str = str.gsub( /(^|[^\$])\$cell\$/, "\\1#{cell}" )
+      str = str.gsub( /(^|[^\$])\$cb\$/, "\\1#{cb}" )
+      str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell}" )
+      str = str.gsub( /(^|[^\$])\$cb_proto\$/, "\\1#{cb_proto}" )
+      str = str.gsub( /(^|[^\$])\$ID\$/, "\\1#{id}" )
+      str = str.gsub( /(^|[^\$])\$idx\$/, "\\1#{idx}" )
+      str = str.gsub( /(^|[^\$])\$cbp\$/, "\\1#{cbp}" )
+      str = str.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{ct_global}" )
+      str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" )
+    end
+    str = str.gsub( /\$\$/, "\$" )                       # $$ ã $ ã«ç½®æ
+
+    return str
+  end
+
+end
+
+# Appendable Fileï¼è¿½è¨å¯è½ãã¡ã¤ã«ï¼
+class AppFile
+  # éãããã¡ã¤ã«ã®ãªã¹ã
+  @@file_name_list = {}
+
+  def self.open( name )
+    if $force_overwrite
+      real_name = name
+    else
+      real_name = name+".tmp"
+    end
+
+#2.0
+    if $b_no_kcode then 
+      mode = ":" + $Ruby19_File_Encode
+    else
+      mode = ""
+    end
+
+    # æ¢ã«éãã¦ãããï¼
+    if @@file_name_list[ name ] then
+#2.0
+      mode = "a" + mode
+      # è¿½è¨ã¢ã¼ãã§éã
+      file = File.open( real_name, mode )
+    else
+#2.0
+      mode = "w" + mode
+      # æ°è¦ã¢ã¼ãã§éãï¼æ¢ã«ããã°ããµã¤ãºãï¼ã«ããï¼
+      file = File.open( real_name, mode )
+      @@file_name_list[ name ] = true
+    end
+    # File ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããè¿ã
+    return file
+  end
+
+  def self.update
+    if $force_overwrite
+      return
+    end
+
+    @@file_name_list.each{ |name,boo|
+      b_identical = false
+      if File.readable? name
+        old_lines = File.readlines name
+        new_lines = File.readlines name + ".tmp"
+        if old_lines.length == new_lines.length then
+          i = 0
+          len = old_lines.length
+          while i < len
+            if old_lines[i] != new_lines[i]
+              break
+            end
+            i += 1
+          end
+          if i == len
+            b_identical = true
+          end
+        end
+      end
+      if b_identical == false then
+        if $verbose then
+          print "#{name} updated\n"
+          print "renaming '#{name}.tmp' => '#{name}'\n"
+        end
+        File.rename name+".tmp", name
+      else
+        if $verbose then
+          print "#{name} not updated\n"
+        end
+        File.delete name+".tmp"
+      end
+    }
+  end
+end
+
+class MemFile
+  def initialize
+    @string = ""
+  end
+  def print str
+    @string += str
+  end
+  def get_string
+    @string
+  end
+end
+
+class Region
+
+  def gen_region_str_pre f
+    nest = 1
+    while nest < @family_line.length
+      f.print "  " * ( nest-1 )
+      f.print "region #{@family_line[ nest ].get_name}{\n"
+      nest += 1
+    end
+    return nest - 1
+  end
+
+  def gen_region_str_post f
+    nest = @family_line.length - 1
+    while nest >= 1
+      f.print "  " * ( nest-1 )
+      f.print "};\n"
+      nest -= 1
+    end
+    return nest - 1
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/location.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/location.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/location.rb	(revision 317)
@@ -0,0 +1,135 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: bnf.y.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+class TECSGEN
+
+  #------ manupulate location information --------#
+  def self.new_cell_location cell_location
+    @@current_tecsgen.new_cell_location cell_location
+  end
+  def new_cell_location cell_location
+    @cell_location_list << cell_location
+  end
+  def get_cell_location_list
+    @cell_location_list
+  end
+
+  def self.new_join_location join_location
+    @@current_tecsgen.new_join_location join_location
+  end
+  def new_join_location join_location
+    @join_location_list << join_location
+  end
+  def get_join_location_list
+    @join_location_list
+  end
+
+#==  Cell_location
+  # tecscde ã®ä½ç½®æ
+å ±
+  class  Cell_location
+
+    #=== Join_location#initialize
+    #cell_nspath::NamespacePath
+    #x,y,w,h::Expression
+    #port_location_list::[ [Symbol(ep_or_cp_name), Symbol(edge_name), Expression(offset)], ... ]
+    #ep_name::Symbol
+    def initialize( cell_nspath, x, y, w, h, port_location_list )
+      # p "Cell_location: #{cell_nspath}, #{x}, #{y}, #{w}, #{h}, #{port_location_list}"
+      @cell_nspath = cell_nspath
+      @x = x.eval_const nil
+      @y = y.eval_const nil
+      @w = w.eval_const nil
+      @h = h.eval_const nil
+      @port_location_list = port_location_list
+
+      TECSGEN.new_cell_location self
+    end
+
+    def get_location
+      [ @cell_nspath, @x, @y, @w, @h, @port_location_list ]
+    end
+
+  end # Cell_location
+
+  #==  Join_location
+  # tecscde ã®ä½ç½®æ
+å ±
+  class  Join_location
+    @@join_location_list = []
+
+    #=== Join_location#initialize
+    #cp_cell_nspath::NamespacePath
+    #cp_name::Symbol
+    #ep_cell_nspath::NamespacePath
+    #ep_name::Symbol
+    #bar_list::[[Symbol (VBar or HBar), Expression(position mm)], ....]
+    def initialize( cp_cell_nspath, cp_name, ep_cell_path, ep_name, bar_list )
+      # p "Join_location  #{cp_cell_nspath}, #{cp_name}, #{ep_cell_path}, #{ep_name} #{bar_list}"
+      @cp_cell_nspath = cp_cell_nspath
+      @cp_name = cp_name
+      @ep_cell_path = ep_cell_path
+      @ep_name = ep_name
+      @bar_list = bar_list
+
+      TECSGEN.new_join_location self
+    end
+
+    def get_location
+      [@cp_cell_nspath, @cp_name, @ep_cell_path, @ep_name, @bar_list]
+    end
+
+  end # Join_location
+
+end # TECSGEN
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/messages.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/messages.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/messages.rb	(revision 317)
@@ -0,0 +1,107 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: messages.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== TECS ã®çæããåå½èªåå¿
+è¦ãªæå­å
+# ç¾ç¶ãã¨ã©ã¼ã¡ãã»ã¼ã¸ã¯è±èªã®ã¿
+# çæãã¡ã¤ã«ã®ã³ã¡ã³ãã¨ãã¦åºåãããæå­å
+class TECSMsg
+
+  #=== TECSMsg#çæãããããããã³ãã¬ã¼ããªã©ã«å«ããã³ã¡ã³ãã®åå¾
+  # CDL ã®æå­ã³ã¼ãã«åããã¦ãæå­ã³ã¼ãå¤æãè¡ã
+  def self.get( msg )
+    str = @@comment[ msg ]
+#2.0    if $KCONV_TECSGEN == $KCONV_CDL
+    if $KCONV_TECSGEN == $KCONV_CDL || $KCONV_CDL == Kconv::BINARY then
+      return str
+    else
+      return str.kconv( $KCONV_CDL, $KCONV_TECSGEN )
+    end
+  end
+
+ #=== TECSMsg#ã­ã¼ã«ã©ã¤ãºãããã¨ã©ã¼ã¡ãã»ã¼ã¸ãå¾ã
+ #body::String   : "S0001 error message body"  ã®å½¢å¼
+ # S0001 ã®é¨åãä½¿ç¨ããã
+ # Generator.error2 ããå¼ã³åºããã
+ def self.get_error_message( body )
+   body =~ /^[A-Z0-9]+/    # ã¨ã©ã¼çªå·ãåãåºã
+   num = $&
+   if num then
+     msg = @@error_message[ num.to_sym ]
+   else
+     msg = nil
+   end
+   if msg == nil then
+     m = body
+   else
+     m = num + " " + msg
+   end
+   return m
+ end
+
+ #=== TECSMsg#ã­ã¼ã«ã©ã¤ãºãããã¦ã©ã¼ãã³ã°ã¡ãã»ã¼ã¸ãå¾ã
+ # Generator.warning2 ããå¼ã³åºããã
+ def self.get_warning_message( body )
+   body =~ /^[A-Z0-9]+/    # ã¦ã©ã¼ãã³ã°çªå·ãåãåºã
+   num = $&
+   msg = @@warning_message[ num.to_sym ]
+   if msg == nil then
+     m = body
+   else
+     m = num + " " + msg
+   end
+   return m
+ end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/optimize.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/optimize.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/optimize.rb	(revision 317)
@@ -0,0 +1,463 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: optimize.rb 2300 2015-12-06 11:23:27Z okuma-top $
+#++
+
+=begin
+This file includes the processes between semantics analysis and code generation.
+Optimize is one of them.
+Other processes are setting ID for each cell and setting domain information
+
+ãã®ãã¡ã¤ã«ã«ã¯ãæå³è§£æããã³ã¼ãçæã®éã§è¡ãã¹ãå¦çãå«ã¾ããï¼
+æé©åããã®ä¸ã¤ã§ããï¼
+ãã®ä»ã«ãã»ã«æ¯ã® ID ä»ãããã¡ã¤ã³ãããè¡ãï¼
+ã³ã¼ãçæå¯¾è±¡ã¨ãªãã»ã«ãå¯¾è±¡ã«å¦çãè¡ããã®ãå«ã¾ããï¼
+=end
+
+class Namespace
+
+  #===  åã»ã«ã« ID ï¼æ´æ°å¤ï¼ãå²ä»ãã
+  def set_cell_id_and_domain
+    # celltype ã®åã»ã«ã« ID ãå²ä»ãã
+    @celltype_list.each { |t|
+      t.set_cell_id_and_domain
+    }
+
+    # ãµããã¼ã ã¹ãã¼ã¹ã®åã»ã«ã« ID ãå²ä»ãã
+    @namespace_list.each { |n|
+      n.set_cell_id_and_domain
+    }
+  end
+
+  def optimize
+    # celltype ã®æé©å
+    @celltype_list.each { |t|
+      t.optimize
+    }
+
+    # ãµããã¼ã ã¹ãã¼ã¹ã®æé©å
+    @namespace_list.each { |n|
+      n.optimize
+    }
+  end
+
+  def reset_optimize
+    # celltype ã®æé©å
+    @celltype_list.each { |t|
+      t.reset_optimize
+    }
+
+    # ãµããã¼ã ã¹ãã¼ã¹ã®æé©å
+    @namespace_list.each { |n|
+      n.reset_optimize
+    }
+  end
+end
+
+class Celltype
+
+  ID_BASE = 1               # reset_optimize ã§ãªã»ãããã
+  @@ID_BASE = ID_BASE
+
+  def set_cell_id_and_domain
+    set_cell_id
+    set_domain
+  end
+
+  #=== åã»ã«ã« ID ï¼æ´æ°å¤ï¼ãå²ä»ãã
+  def set_cell_id
+
+    if $verbose then
+      print( "=== id for the cells of celltype #{get_namespace_path.to_s} ===\n" ) 
+    end
+
+    if $unique_id then
+      @id_base = @@ID_BASE   # id ãã·ã¹ãã å
+¨ä½ã§é£çªã«ãã
+    else
+      @id_base = 1           # base ãå¸¸ã« 1 ããå§ãã
+    end
+
+    id_specified_cells = []
+    no_id_specified_cells = []
+
+    # ãã­ãã¿ã¤ããé¤ããæ°ãæ±ãã
+    @cell_list.each{ |c|
+      if c.is_generate? then
+        # c.set_id( @id_base + @n_cell_gen )
+        id = c.get_specified_id
+        if id then
+          id_specified_cells << c
+        else
+          no_id_specified_cells << c
+        end
+        
+        # p "#{c.get_name} #{@id_base+@n_cell_gen}"
+        @@ID_BASE     += 1
+        @n_cell_gen   += 1
+      end
+    }
+
+    @ordered_cell_list = []   # id = 1 ãæ·»æ° 0 ã«æ ¼ç´ããã
+    # ID æå®ããã¦ããã»ã«ã« id çªå·ãä¸ãã
+    id_specified_cells.each{ |c|
+      id = c.get_specified_id
+      if id > 0 then
+        if id >= @n_cell_gen then
+          cdl_error( "S3001 $1: id too large $2 (max=$3)", c.get_name, id, @n_cell_gen )
+          next
+        end
+      else
+        if - id >= @n_cell_gen then
+          cdl_error( "S3002 $1: id too large $2 (max=$3)", c.get_name, id, @n_cell_gen )
+          next
+        end
+        id = @n_cell_gen + id + 1
+      end
+
+      if @ordered_cell_list[ id - 1 ] then
+        cdl_error( "S3003 $1: id number '$2' conflict with $3", c.get_name, id, @ordered_cell_list[ id - 1 ].get_name )
+      end
+      @ordered_cell_list[ id - 1 ] = c
+      # éãçªå·ã¨ããå ´åã®ãã @id_base ãå ãã
+      c.set_id( @id_base - 1 + id )
+      if $verbose then
+        print( "#{c.get_name}: id=#{c.get_id}  specified id=#{c.get_specified_id}\n" )
+      end
+    }
+
+    # ID æå®ããã¦ããªãã»ã«ã« id çªå·ãä¸ãã
+    i = 0
+    no_id_specified_cells.each{ |c|
+      while( @ordered_cell_list[i] != nil )
+        i += 1
+      end
+      @ordered_cell_list[ i ] = c
+      c.set_id( @id_base + i )
+      if $verbose then
+        print( "#{c.get_name}: id=#{c.get_id}\n" )
+      end
+    }
+    if @n_cell_gen >0 && i >= @n_cell_gen then
+      raise "id over id=#{i} N=#{@n_cell_gen}"
+    end
+  end
+
+  def set_domain
+    @cell_list.each{ |c|
+      if c.is_generate? then
+        dr = c.get_region.get_domain_root
+        if dr.get_domain_type then
+          dn = dr.get_domain_type.get_name
+        else
+          dn = nil
+        end
+        if @domain_roots[ dn ] then
+          @domain_roots[ dn ] << dr
+        else
+          @domain_roots[ dn ] = [ dr ]
+        end
+      end
+    }
+
+    @domain_roots.each{ |dn, drs|
+      drs.uniq!
+      if ! $debug then
+        dbgPrint "domains celltype:#{@name} domain=#{dn} "
+        drs.each{ |r|
+          dbgPrint " region=#{r.get_name}"
+        }
+        dbgPrint "\n"
+      end
+    }
+    if @domain_roots.length > 1 then
+      p @domain_roots
+      raise "ambigous DomainType"
+    end
+
+    @domain_roots.each{ |dn, regions|
+      # domain_type ã¯ä¸ã¤ã®ãã¼ãã«ä¸ã¤ãããªãã®ã§ãä¸ã¤ã®è¦ç´ ãç¡æ¡ä»¶ã§åãåºã
+      if regions.length > 1 then
+        cdl_info( "celltype:#{@name} has cells in multi domain.\n" )
+        if @idx_is_id == false then
+          cdl_info( "celltype:#{@name} forcely set idx_is_id\n" )
+        end
+        @idx_is_id_act = true
+      end
+    }
+  end
+
+  def optimize
+
+    # port ã®åç
+§ããã»ã«ã¿ã¤ãã®æ°ãã»ã«ã®æ°ãæ±ãã
+    if $verbose then
+      print "=== optimizing celltype #{get_namespace_path.to_s} ===\n"
+    end
+
+    @port.each{ |port|
+      next if port.get_port_type != :CALL
+      if port.is_omit? then
+        # å¼ã³å£æé©åå®æ½
+        @b_cp_optimized = true
+        @n_call_port_omitted_in_CB += 1               # CB ã§çç¥ããå¼ã³å£
+        port.set_skelton_useless                      # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å
+        port.set_VMT_useless                          # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)
+        if $verbose then
+          print "optimized by omit: port: #{port.get_name} : o\n"
+        end
+        next
+      end
+
+      if $verbose then
+        print "optimizing port : #{port.get_name}\n"
+      end
+
+      port_cells = []    # å¼ã³å
+ã»ã«
+      port_ports = []    # å¼ã³å
+ã®ãã¼ã
+
+      # ã»ã«ã®åç
+§ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼
+      @cell_list.each{ |cell|
+
+        if ! cell.is_generate? then
+          next
+        end
+
+        jl = cell.get_join_list
+        j = jl.get_item( port.get_name )
+
+        if j then
+          if j.get_array_member2 then
+            # å¼ã³å£é
+åã®å ´åãå
+¨é¨ã®çµåå
+ãéãã
+            j.get_array_member2.each { |j2|
+              if j2 then
+                port_cells << j2.get_rhs_cell
+                port_ports << j2.get_rhs_port   # å³è¾ºã®ãã¼ã
+              else
+                # optional ã§ãããæ·»æ°ã®ã¿åæåããã¦ããªãï¼ãã¹ã¦åæåãããªãå ´åã¯ãä¸ï¼
+                port_cells << nil
+                port_ports << nil
+              end
+            }
+          else
+            # å
+¨ã¦ã®çµåå
+ãéãã
+            port_cells << j.get_rhs_cell
+            port_ports << j.get_rhs_port   # å³è¾ºã®ãã¼ã
+          end
+        else
+          # optional ã§åæåããã¦ããªãï¼nil ãè¦ç´ ã«å ãã¦ããï¼
+          port_cells << nil
+          port_ports << nil   # å³è¾ºã®ãã¼ã
+        end
+      }
+
+      # éè¤è¦ç´ ãåãé¤ã
+      port_cells.uniq!
+      port_ports.uniq!
+
+      # å¼ã³å£ã®å¼ã³å
+ãä¸ã¤ã®ãã¼ãã ããï¼
+      if port_ports.length == 1 then
+
+        # å¼ã³å£é
+åãå¯å¤é·ã®å ´åãæé©åããªã
+             # mikan å¼ã³å£é
+åè¦ç´ æ°ãã¯ã­ä¸å
+·åæ«å®å¯¾ç­
+             # ããæã¾ããä¿®æ­£ã¯ãåãå£ã¸ã®ãã¤ã³ã¿ã¯çç¥ããããé
+ååæ°ã¯åºåãã(#_CP_#, #_TCP_#)
+             # ããã«é
+ååæ°ãå®æ°åã§ããã®ã§ããã°ãå®æ°ãã¯ã­ãåºå (#_NCPA_#)
+        next if port.get_array_size == "[]"
+
+        # å¼ã³å£æé©åå®æ½
+        @b_cp_optimized = true
+
+        # å¼ã³å
+ãä¸ã¤ã®ã»ã«ã ããï¼
+        if port_cells.length == 1 then
+
+          # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é
+åã§ã¯ãªããï¼
+          if port_ports[0] == nil || port_ports[0].get_array_size == nil then
+
+            @n_call_port_omitted_in_CB += 1               # CB ã§çç¥ããå¼ã³å£
+            port.set_cell_unique                          # ã»ã«ä¸ã¤ã ãæé©å
+            port.set_skelton_useless                      # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å
+            port.set_VMT_useless                          # VMT ä¸è¦æé©å (ç´æ¥åãå£é¢æ°ãå¼åºã)
+
+            if $verbose then
+              print "cell_unique, VMT_useless & skelton_useless optimize\n"
+            end
+          else
+            port.set_VMT_useless                          # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ°ãå¼åºã)
+
+            if $verbose then
+              print "VMT_useless optimize\n"
+            end
+          end
+
+        else  # å¼ã³å
+ãè¤æ°ã®ã»ã«ï¼åä¸ã®ãã¼ãï¼
+
+          # å¼ã³å£ã¯ optional ã§åæåããã¦ããªããã¾ãã¯åãå£ã¯é
+åã§ã¯ãªããï¼
+          if port_ports[0] == nil || port_ports[0].get_array_size == nil then
+            if ! @singleton then
+              port.set_skelton_useless                    # ã¹ã±ã«ãã³é¢æ°ä¸è¦æé©å
+              port.set_VMT_useless                        # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)
+
+              if $verbose then
+                print "VMT_useless & skelton useless optimize\n"
+              end
+            else
+              port.set_VMT_useless                           # VMT ä¸è¦æé©å (ã¹ã±ã«ãã³é¢æ° or åãå£é¢æ°ãå¼åºã)
+
+              if $verbose then
+                print "VMT_useless optimize\n"
+              end
+            end
+          end
+        end
+
+        port.set_only_callee( port_ports[0], port_cells[0] )
+           # set_cell_unique ã§ãªãå ´å cell ã¯æå³ããªã
+
+      end
+
+      # debug
+      dbgPrint "#{port.get_name} : # of cells : #{port_cells.length}  # of ports : #{port_ports.length}\n"
+    }
+
+    # åãå£æé©åã®è¨­å®
+    @port.each{ |port|
+      next if port.get_port_type != :CALL
+
+      # å¼ã³å£å´ã®æé©åç¶æ
+
+      b_VMT_useless     = port.is_VMT_useless?
+      b_skelton_useless = port.is_skelton_useless?
+
+      # ã»ã«ã®åç
+§ããã»ã«ãéããï¼ãã¼ããä¸ç·ã«éããï¼
+      @cell_list.each{ |cell|
+
+        if ! cell.is_generate? then
+          next
+        end
+
+        jl = cell.get_join_list
+        j = jl.get_item( port.get_name )
+
+        if j then    # optional ã§çµåããã¦ããªãå ´å nil
+          if j.get_array_member2 then
+            # å¼ã³å£é
+å
+            j.get_array_member2.each { |j2|
+              if j2 then
+                port2 = j2.get_rhs_port   # å³è¾ºã®ãã¼ã
+                # åãå£å´ã®æé©åå¯è½æ§ãè¨­å®
+                port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless )
+              #else
+              #  optional ã§å¼ã³å£é
+åè¦ç´ ãåæåããã¦ããªã
+              end
+            }
+          else
+            port2 = j.get_rhs_port      # å³è¾ºã®ãã¼ã
+            # åãå£å´ã®æé©åå¯è½æ§ãè¨­å®
+            port2.set_entry_VMT_skelton_useless( b_VMT_useless, b_skelton_useless )
+          end
+        end
+      }
+    }
+  end
+
+  #Celltype# ãªã»ãããã
+  def reset_optimize
+    @@ID_BASE = ID_BASE      # æ¬å½ã¯ä¸åã ãã§ãã
+    @id_base = 1             # set_cell_id ã§ãªã»ãããããã®ã§ä¸è¦
+
+    @b_cp_optimized = false  # å¼ã³å£æé©å
+    @n_call_port_omitted_in_CB = 0 # å¼ã³å£æé©åã«ããä¸çæã¨ãªã£ããã¼ãã®æ°
+    @n_cell_gen = 0          # çæã»ã«åæ°
+    @port.each{ |p|
+      p.reset_optimize
+    }
+    @included_header = {}
+    @domain_roots = {}
+  end
+
+  #Celltype# ãããã¯ include ããã¦ããã
+  #hname::Symbol : ãããå
+  #RETURN:: bool_t: false ã¤ã³ã¯ã«ã¼ãããã¦ããªããtrue ã¤ã³ã¯ã«ã¼ãããã¦ãã
+  # #_ISH_#, #_ICT_# ã§ããããåãè¾¼ã¾ãã¦ããããã§ãã¯ãã
+  # false ãè¿ã£ãå ´åãhname ã¯ç»é²ããã¦ãæ¬¡åã®å¼ã³åºãã§ã¯ true ãè¿ã
+  def header_included?( hname )
+    if @included_header[ hname ] == nil then
+      @included_header[ hname ] = true
+      return false
+    else
+      return true
+    end
+  end
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/plugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/plugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/plugin.rb	(revision 317)
@@ -0,0 +1,356 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: plugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== class ã¢ã¸ã¥ã¼ã«
+# ThroughPlugin, SignaturePlugin, CelltypePlugin ã« include ãã
+class Plugin < Node
+#@error_backlog:: [msg1, msg2, ... ]   @locale ãè¨­å®ãããåã«çºçããã¨ã©ã¼
+
+  PluginArgProc = {
+    "silent"  => Proc.new { |obj,rhs| obj.set_silent rhs },
+  }
+
+  def initialize
+    super
+    @b_silent = false
+    @locale = nil       # set_locale ãå¼ã³åºãããã¾ã§ nil ã¨ãªã
+    @error_backlog = []
+  end
+
+  #=== Plugin#cdl_error
+  # set_locale ãå¼ã³åºãããã¾ã§ @error_backlog ã«ä¿å­ãä¿çãã
+  def cdl_error *arg
+    if @locale then
+      Generator.error2( @locale, *arg )
+    else
+      @error_backlog << arg
+    end
+  end
+
+  #=== locale ãè¨­å®ãã
+  # Node ã¯ initialize ã§ locale ãè¨­å®ããããplugin ã¯ parse ã¨ã¯
+  # ç°ãªãã¿ã¤ãã³ã° new ããããããlocale ãåè¨­å®ãã
+  # ãã®ã¡ã½ããã2åº¦å¼ã³åºãã¨ @error_backlog ã®ã¨ã©ã¼ã2åº¦åºåããã¦ãã¾ã
+  def set_locale locale
+    @locale = locale
+    @error_backlog.each { |arg|
+      Generator.error2( locale, *arg )
+    }
+  end
+
+### æå³è§£ææ®µéã§å¼ã³åºãããã¡ã½ãã ###
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_cdl_file file
+  end
+
+
+### ã³ã¼ãçæ®µéã§å¼ã³åºãããã¡ã½ãã ###
+  #=== ãã©ã°ã¤ã³ã¯ gen_ep_func ãæä¾ããã
+  # gen_ep_func å®ç¾©   â ãã³ãã¬ã¼ãã§ã¯ãªããã»ã«ã¿ã¤ãã³ã¼ã(tCelltype.c)ãçæ 
+  # gen_ep_func æªå®ç¾© â ãã³ãã¬ã¼ã(tCelltype_templ.c)ãçæ
+  def gen_ep_func?
+    self.class.method_defined?( :gen_ep_func_body )
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã§ããã°ããã©ã°ã¤ã³ã¯ã»ã«ã¿ã¤ãã³ã¼ããçæããªã (éå¸¸éããã³ãã¬ã¼ããçæãã)
+  #      gen_cdl_file ã®ä¸­ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã
+  #file::           FILE        åºåå
+ãã¡ã¤ã« (tCelltype.c)
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  #===  åãå£é¢æ°ã® preamble (Cè¨èª)ãçæãã
+  #     å¿
+è¦ãªã preamble é¨ã«åºåãã
+  #      gen_cdl_file ã®ä¸­ã§ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  def gen_preamble( file, b_singleton, ct_name, global_ct_name )
+    # ããã©ã«ãã§ã¯ä½ãåºåããªã
+  end
+
+  #===  åãå£é¢æ°ã® postamble (Cè¨èª)ãçæãã
+  #     å¿
+è¦ãªã postamble é¨ã«åºåãã
+  #      gen_cdl_file ã®ä¸­ã§çæãããã»ã«ã¿ã¤ãã«å¯¾ãã¦å¼ã³åºããã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  def gen_postamble( file, b_singleton, ct_name, global_ct_name )
+    # ããã©ã«ãã§ã¯ä½ãåºåããªã
+  end
+
+  #=== gen_cdl_file ã®ä¸­ã§çæãããã»ã«ã¿ã¤ãã«æ°ããã»ã«ãçæããã
+  # ã©ã®ã»ã«ã¿ã¤ããã¯ cell.get_celltype ã§åãã
+  #
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  def new_cell cell
+    # ããã©ã«ãã§ã¯ä½ãããªã
+  end
+
+### ãã©ã°ã¤ã³å¼æ°ã®è§£é ###
+  def parse_plugin_arg
+    arg = @plugin_arg_str.dup
+
+    # æ¹è¡ãæ¶ã
+    arg.gsub!( /\\\n/, "" )
+
+    while arg != ""
+
+      # åã®ç©ºç½èª­ã¿é£ã°ã
+      arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1')
+
+      #  è­å¥å­åå¾
+      if arg =~ /\A[a-zA-Z_]\w*/ then
+        ident = $~
+        arg = $'
+      else
+        cdl_error( "P1001 plugin arg: cannot find identifier in $1" , arg )
+        return
+      end
+      
+      # åã®ç©ºç½èª­ã¿é£ã°ã
+      arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1')
+
+      if arg =~ /=/ then
+        arg = $'
+      else
+        cdl_error( "P1002 plugin arg: expecting \'=\' not \'$1\'" , arg )
+        return
+      end
+
+      # åã®ç©ºç½èª­ã¿é£ã°ã
+      arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1')
+
+      # å³è¾ºæå­å
+      if arg =~ /\A\\"(.*?)\\"\s*,/ then      # \"  \" ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A%(.*?)%\s*,/ then      # %   % ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A!(.*?)!\s*,/ then    # $   $ ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A'(.*?)'\s*,/ then    # $   $ ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif  arg =~ /\A\\"(.*?)\\"\s*,/ then  # || ã«ã [,$] ã«ãã§ããªãã£ã
+        rhs = $1
+        remain = $'
+      # elsif arg =~ /\A(.*?)\s*$/ then
+      elsif arg =~ /\A\\"(.*?)\\"\s*\z/ then      # \"  \" ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A%(.*?)%\s*\z/ then      # %   % ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A!(.*?)!\s*\z/ then    # $   $ ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A'(.*?)'\s*\z/ then    # $   $ ã§å²ã¾ãã¦ããå ´å
+        rhs = $1
+        remain = $'
+      elsif  arg =~ /\A\\"(.*?)\\"\s*\z/ then  # || ã«ã [,$] ã«ãã§ããªãã£ã
+        rhs = $1
+        remain = $'
+      elsif arg =~ /\A(.*?),/ then
+        rhs = $1
+        remain = $'
+        # åã®ç©ºç½èª­ã¿é£ã°ã
+        rhs.sub!( /\A\s*(.*)\s*\z/, '\1')
+      elsif arg =~ /\A(.*?)\s*\z/ then
+        rhs = $1
+        remain = $'
+      else
+        cdl_error( "P1003 plugin arg: unexpected $1" , arg )
+        return
+      end
+
+      # 0æå­ã®æå­åã to_sym ããã¨ä¾å¤çºçããã®ã§ç©ºç½æå­ã¨ãã
+      if rhs == "" then
+        rhs = " "
+      end
+
+      arg = remain         # arg ã®æ®ãã®é¨å
+      arg.sub!( /\A\s*(?:\\\n)*\s*(.*)/, '\1')      # åã®ç©ºç½èª­ã¿é£ã°ã
+
+      # \ ãå¤ã
+      rhs = rhs.gsub( /\\(.)/, "\\1" )   # ããã§ $' ãå¤ãããã¨ã«æ³¨æï¼
+      # print "parse_plugin_arg:  #{ident} #{rhs}\n"
+      @plugin_arg_list[ ident ] = rhs
+
+      check_plugin_arg( ident, rhs )
+    end
+    # @plugin_arg_list.each{|i,r|  print "ident: #{i}  rhs: #{r}\n" }
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ãã
+  # @plugin_arg_check_proc_tab ã«å¾ã£ã¦ãã©ã°ã¤ã³å¼æ°ããã§ãã¯ããã
+  # å¤ãç¨æ³ï¼å­ã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããå¼æ°è­å¥å­ãæ­£ããããã§ãã¯ãã
+  #ident:: string: å¼æ°è­å¥å­
+  #rhs:: string: å³è¾ºæå­å
+  def check_plugin_arg( ident, rhs )
+
+    dbgPrint "check_plugin_arg: #{ident} #{rhs.to_str}\n"
+    proc = nil
+    if @plugin_arg_check_proc_tab  then
+      proc = @plugin_arg_check_proc_tab[ident.to_s]
+    end
+    if proc == nil then
+      proc = PluginArgProc[ ident.to_s ]
+    end
+    if proc.instance_of? Proc then
+      dbgPrint "calling: #{self.class.name}.#{proc.to_s}\n"
+      proc.call( self, rhs )
+    else
+      params = ""
+      delim = ""
+      @plugin_arg_check_proc_tab.each{ |j,p|
+        params = "#{params}#{delim}#{j}"
+        delim = ", "
+      }
+      cdl_error( "P1004 $1: unknown plugin argument\'s identifier\n  $2 are acceptible for RPCPlugin." , ident, params )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³ã®ã¡ãã»ã¼ã¸åºå
+  def print_msg( msg )
+    if @b_silent == true then
+      return
+    end
+    print msg
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° silent
+  def set_silent rhs
+    if rhs == "true" || rhs == nil then
+      @b_silent = true
+    end
+  end
+end
+
+#== åºåæå­åã EUC ããåºåãã¡ã¤ã«ã« convert ãã
+# tecsgen ã®ã½ã¼ã¹ã³ã¼ãã¯ EUC ã§è¨è¿°ããã¦ãã
+# ããããåºåãã¡ã¤ã«ã®æå­ã³ã¼ãã«å¤æãã¦åºåãã
+#
+# generate.rb ã§åºåãããã®ã¯ message.rb ã§å¤æãã¦ãã
+# generate.rb ã§åºåãããã®ã¯ APPFile ã¯ã©ã¹ãä½¿ç¨ãã¦ãã
+# mikan: CFile ã§åºåãããã®ã« factory ã§è¿½è¨ã§ããªã (cdl ãã¡ã¤ã«ã®å ´åãè¿½è¨ã§ãã¦ãæå³ããªã)
+class CFile
+  def self.open( path, mode )
+    CFile.new( path, mode )
+  end
+
+  def initialize( path, mode )
+    if $b_no_kcode then 
+      mode += ":" + $Ruby19_File_Encode
+    end
+    @file = File.open( path, mode )
+  end
+
+  def print str
+    if $b_no_kcode && $KCONV_CONSOLE == Kconv::BINARY then 
+      @file.print( str )
+    else
+      @file.print( str.kconv( $KCONV_CDL, $KCONV_TECSGEN ) )
+    end
+  end
+
+  def puts str
+    if $b_no_kcode && $KCONV_CONSOLE == Kconv::BINARY then 
+      @file.print( str )
+    else
+      @file.print( str.kconv( $KCONV_CDL, $KCONV_TECSGEN ) )
+    end
+    @file.print( "\n" )
+  end
+
+  def printf( format, *arg )
+    if $b_no_kcode && $KCONV_CONSOLE == Kconv::BINARY then 
+      @file.print( sprintf( format, *arg ) )
+    else
+      @file.print( sprintf( format, *arg ).kconv( $KCONV_CDL, $KCONV_TECSGEN ) )
+    end
+  end
+
+  def close
+    @file.close
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/pluginModule.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/pluginModule.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/pluginModule.rb	(revision 317)
@@ -0,0 +1,163 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: pluginModule.rb 2081 2014-06-30 05:41:00Z okuma-top $
+#++
+
+#== ãã©ã°ã¤ã³ãã­ã¼ãããå´ã®ã¢ã¸ã¥ã¼ã«
+# @@loaded_plugin_list:: {Symbol=>Integer}
+module PluginModule
+
+  @@loaded_plugin_list = {}
+
+  #=== ãã©ã°ã¤ã³ãã­ã¼ããã
+  #return:: true : æåã false : å¤±æ
+  #
+  # ãã§ã«ã­ã¼ãããã¦ãããã®ã¯ãéè¤ãã¦ã­ã¼ãããªã
+  # load æã®ä¾å¤ã¯ãã®ã¡ã½ããã®ä¸­ã§ã­ã£ããããã¦ false ãè¿ããã
+  def load_plugin( plugin_name, superClass )
+
+    dbgPrint "PluginModule: load_plugin: #{plugin_name}\n"
+    begin
+      unless @@loaded_plugin_list[ plugin_name.to_sym ] then
+        @@loaded_plugin_list[ plugin_name.to_sym ] = 0
+        if ( $verbose ) then
+          print( "load '#{plugin_name}.rb'\n" )
+        end
+        # "#{plugin_name}.rb" ãã­ã¼ãï¼ã·ã¹ãã ç¨ã§ã¯ãªãã®ã§ãfatal ã¨ã©ã¼ã«ããªãï¼
+        if require_tecsgen_lib( "#{plugin_name}.rb", false ) == false
+          cdl_error( "P2001 $1.rb : fail to load plugin" , plugin_name )
+          return false
+        end
+      end
+
+      plSuper = nil
+      # eval( "plSuper = #{plugin_name}.superclass" )
+      eval( "plSuper = #{plugin_name}" )
+      while plSuper != superClass && plSuper != nil
+        plSuper = plSuper.superclass
+      end
+      if plSuper == nil then
+        cdl_error( "P2002 $1: not kind of $2" ,  plugin_name, superClass.name )
+        return false
+      end
+    rescue Exception => evar
+      if $debug then
+        p evar.class
+        pp evar.backtrace
+      end
+      cdl_error( "P2003 $1: load failed" , plugin_name )
+      return false
+    end
+    return true
+  end
+
+  #=== ãã©ã°ã¤ã³ã® gen_cdl_file ãå¼ã³ãã¦ cdl ãã¡ã¤ã«ãçæãããè§£éãè¡ã
+  def generate_and_parse plugin_object
+    if plugin_object == nil     # ãã©ã°ã¤ã³ã®ã­ã¼ãã«å¤±æãã¦ããï¼æ¢ã«ã¨ã©ã¼ï¼
+      return
+    end
+    plugin_name = plugin_object.class.name.to_sym
+    if @@loaded_plugin_list[ plugin_name ] == nil
+      raise "#{plugin_name} might have different name "
+      # ãã©ã°ã¤ã³ã®ãã¡ã¤ã«åã¨ããã©ã°ã¤ã³ã®ã¯ã©ã¹åãç¸éããå ´å
+    end
+    count = @@loaded_plugin_list[ plugin_name ]
+    @@loaded_plugin_list[ plugin_name ] += 1
+    tmp_file_name = "#{$gen}/tmp_#{plugin_name}_#{count}.cdl"
+
+    begin
+      tmp_file = CFile.open( tmp_file_name, "w" )
+    rescue Exception => evar
+      cdl_error( "P2004 $1: open error \'$2\'" , plugin_name, tmp_file_name )
+      print_exception( evar )
+    end
+    dbgPrint "generate_and_parse: #{plugin_object.class}: gen_cdl_file\n"
+    begin
+      plugin_object.gen_cdl_file( tmp_file )
+    rescue Exception => evar
+      cdl_error( "P2005 $1: plugin error in gen_through_cell_code " , plugin_name )
+      print_exception( evar )
+    end
+    begin
+      tmp_file.close
+    rescue Exception => evar
+      cdl_error( "P2006 $1: close error \'$2\'" , plugin_name, tmp_file_name )
+      print_exception( evar )
+    end
+
+    generator = Generator.new
+    generator.set_plugin( plugin_object )
+    generator.parse( [ tmp_file_name ] )
+    generator.finalize
+  end
+
+  #=== ãã©ã°ã¤ã³ã CDL ã® POST ã³ã¼ããçæ
+  # tmp_plugin_post_code.cdl ã¸ã®åºå
+  def self.gen_plugin_post_code file
+    dbgPrint "PluginModule #{@@loaded_plugin_list}\n"
+    @@loaded_plugin_list.each{ |plugin_name,count|
+      dbgPrint "PluginModule: #{plugin_name}\n"
+      eval_str = "#{plugin_name}.gen_post_code( file )"
+      if $verbose then
+        print "gen_plugin_post_code: #{eval_str}\n"
+      end
+      begin
+        eval( eval_str )
+      rescue Exception => evar
+        Generator.error( "P2007 $1: fail to generate post code" , plugin_name )
+
+        print_exception( evar )
+      end
+    }
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/syntaxobj.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/syntaxobj.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/syntaxobj.rb	(revision 317)
@@ -0,0 +1,1285 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2016 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: syntaxobj.rb 2374 2016-01-03 22:14:59Z okuma-top $
+#++
+
+# mikan ruby ã® symbol ã¨æå­åã®ä½¿ãåããã©ããã¦ããã¾ããããªããã¨ãæã
+ããã®ã§ name.to_sym ãå
+¥ãããã¨ã«ãã
+
+#== Node
+#
+# Node ã®ç´æ¥ã®å­ã¯ã©ã¹ï¼ C_EXP, Type, BaseVal, BDNode(ã»ã¨ãã©ã®ãã®ã¯ BDNode ã®å­ã¯ã©ã¹)
+# Node ã« (BDNodeã«ã) å
+¥ããªããã®: Token, Import, Import_C, Generate
+#
+# owner ãæããªããã®ã Node ã¨ãªã
+# ã¨ã©ã¼ã¯ãcdl_error ãéãã¦å ±åãã (æå³è§£æãæ§æè§£æå¾ã«è¡ãããå ´åã«ã¯ãè¡çªå·ãæ­£ããåºåã§ãã
+# 
+
+class Node
+#@locale::    [@file, @lineno, @col]
+
+  def initialize
+    @locale = Generator.current_locale
+  end
+
+  #=== ã¨ã©ã¼ãåºåãã
+  def cdl_error( message, *arg )
+    Generator.error2( @locale, message, *arg )
+  end
+
+  #=== ã¨ã©ã¼ãåºåãã
+  #locale:: Array(locale info) : æ§æè§£æä¸­ã¯ç¡è¦ããã
+  def cdl_error2( locale, message, *arg )
+    Generator.error2( locale, message, *arg )
+  end
+
+  #=== ã¨ã©ã¼ãåºåãã
+  #locale:: Array(locale info)
+  # æ§æè§£æä¸­ cdl_error2 ã§ã¯ locale ãç¡è¦ããããããå¥ã« locale ãåºåãã
+  def cdl_error3( locale, message, *arg )
+    Generator.error(  message, *arg )
+    Console.puts "check: #{locale[0]}: line #{locale[1]} for above error"
+  end
+
+  #=== ã¦ã©ã¼ãã³ã°åºåãã
+  def cdl_warning( message, *arg )
+    Generator.warning2( @locale, message, *arg )
+  end
+
+  #=== ã¦ã©ã¼ãã³ã°åºåãã
+  def cdl_warning2( locale, message, *arg )
+    Generator.warning2( locale, message, *arg )
+  end
+
+  #=== æ
+å ±ãè¡¨ç¤ºãã
+  def cdl_info( message )
+    Console.puts "info: #{message}"
+  end
+
+  def get_locale
+    @locale
+  end
+
+  def set_locale locale
+    @locale = locale
+  end
+
+  def locale_str
+    "locale=( #{@locale[0]}, #{@locale[1]} )"
+  end
+end
+
+#== åæ¹å Node (Bi Direction Node)
+#
+#  Node ã®å­ã¯ã©ã¹
+#  owner Node ããåç
+§ããã¦ãããã® (owner ã¸ã®ãªã³ã¯ãåãåºãã)
+#
+#  get_owner ã§å¾ããããã®
+#    FuncHead => Signature
+#    Decl => Namespace(const), Typedef(typedef),
+#            Celltype, CompositeCelltype(attr,var)
+#            Struct(member), ParamDecl(parameter), FuncHead(funchead)
+#    Signature, Celltype, CompositeCelltype, Typedef => Namespace
+#,   Namespace => Namespace, Generator.class (root Namespace ã®å ´å)
+#    Cell => Region, CompositeCelltype(in_composite)
+#    Port => Celltype, Composite
+#    Factory => Celltype
+#    Join => Cell
+#    CompositeCelltypeJoin => CompositeCelltype
+#    Region => Region, 
+#    ParamDecl => ParamList
+#    ParamList => FuncHead
+#    Expression => Namespace
+#    å¤§åã®ãã®ã¯ new_* ã¡ã½ããã§ owner Node ã«ä¼éããã
+#    ãã®ã¡ã½ãããå¼ã³åºãããã¨ãã« owner Node ãè¨é²ããã
+#    new_* ããªããã®ï¼
+#            Decl(parameter), ParamDecl, ParamList, FuncHead, Expression 
+#
+#    Expression ã¯ãowner Node ã¨ãªããã®ãå¤ãããããæ¹é ãå°é£ã§ãããã
+#    Expression ãå®ç¾©ãããã¨ãã® Namespace ã owner Node ã¨ãã
+#    StructType ã¯ Type ã®ä¸ç¨®ãªã®ã§ owner ãæããªã
+#
+class BDNode < Node
+#@owner::Node
+#@NamespacePath:: NamespacePath
+#@Generator::
+#@import::Import :  
+
+  def initialize
+    super
+    @owner = nil
+    @NamespacePath = nil
+    @import = Import.get_current
+
+  end
+
+  #=== owner ãè¨­å®ãã
+  def set_owner owner
+    dbgPrint "set_owner: #{owner.class.name}\n"
+    @owner = owner
+  end
+
+  #=== owner ãå¾ã
+  # class ã®èª¬æãåç
+§
+  def get_owner
+    if @owner == nil
+      raise "Node have no owner #{self.class.name} #{get_name}"
+    end
+    @owner
+  end
+end
+
+#== Namespace åãæã¤ BDNode
+# Namespace(Region), Signature, Celltype, CompositeCelltype, Cell
+class NSBDNode < BDNode
+
+  def initialize
+    super
+  end
+
+  #=== å±ãã namespace ãå¾ã
+  # owner ã namespace ã«ãã©ãçãã¾ã§ä¸ã«ãã©ã
+  def get_namespace
+    if @owner.kind_of? Namespace
+      return @owner
+    elsif @owner != nil then
+      return @owner.get_namespace
+    else
+      # @owner == nil ãªã "::"
+      if @name != "::" then
+        raise "non-root namespace has no owner #{self.class.name}##{@name} #{self}"
+      end
+      return nil
+    end
+  end
+
+  def set_namespace_path
+    ns = get_namespace
+    if ns then
+      @NamespacePath = ns.get_namespace_path.append( get_name )
+    else
+      raise "get_namespace_path: no namespace found"
+    end
+  end
+
+  #=== NamespacePath ãå¾ã
+  def get_namespace_path
+    return @NamespacePath
+  end
+
+  def is_imported?
+    if @import then
+      return @import.is_imported?
+    else
+      return false    # mikan: ä»® @import ã nil ã«ãªãã±ã¼ã¹ãè¿½æ±ã§ãã¦ããªã
+    end
+  end
+end
+
+class NamedList
+#  @names:: {} of items
+#  @items:: [] of items : item ã® CLASS ã¯ get_name ã¡ã½ãããæã¤ãã¨ get_name ã®æ»ãå¤ã¯ Symbol ã§ãªãã¦ã¯ãªããªã
+#                         NamedList ã clone_for_composite ããå ´åã¯ãitem ã«ãã¡ã½ãããå¿
+è¦
+#  @type:: string	ã¨ã©ã¼ã¡ãã»ã¼ã¸
+
+  def initialize( item, type )
+    @names = {}
+    @items = []
+    @type = type
+    add_item( item )
+  end
+
+  #=== è¦ç´ ãå ãã
+  # parse ããæç¹ã§å ãããã¨(å ´æãè¨æ¶ãã)
+  def add_item( item )
+
+    if item then
+      assert_name item
+      name = item.get_name
+      prev = @names[name]
+      if prev then
+        Generator.error( "S2001 \'$1\' duplicate $2" , name, @type )
+        prev_locale = prev.get_locale
+        puts "previous: #{prev_locale[0]}: line #{prev_locale[1]} \'#{name}\' defined here"
+        return self
+      end
+
+      @names[name]=item
+      @items << item
+    end
+
+    return self
+  end
+
+  def change_item( item )
+    assert_name item
+    name = item.get_name
+
+    prev_one = @names[name]
+    @names[name]=item
+
+    @items = @items - [ prev_one ]
+    @items << item
+  end
+
+  def del_item( item )
+    assert_name item
+    name = item.get_name
+    @names.delete name
+
+    @items = @items - [ item ]
+  end
+
+  def get_item( name )
+    if ! name.kind_of? Symbol
+      print "get_item: '#{name}', items are below\n"
+      @names.each{ |nm,item|
+        p nm
+      }
+      raise "get_item: #{name}: not Symbol"
+    end
+    if name then
+      return @names[name.to_sym]
+    else
+      return nil
+    end
+  end
+
+  def get_items
+    return @items
+  end
+
+  #=== composite cell ã clone ããæã«è¦ç´ (JOIN) ã® clone ãã
+  #
+  # mikan ãã®ã¡ã½ããã¯ Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã
+  def clone_for_composite( ct_name, cell_name, locale )
+    cl = self.clone
+    cl.set_cloned( ct_name, cell_name, locale )
+    return cl
+  end
+
+  #=== clone ããã NamedList ã¤ã³ã¹ã¿ã³ã¹ã®åç
+§ãããã®(item)ã clone
+  #
+  # mikan ãã®ã¡ã½ããã¯ Join ã«ç¹åããã¦ããã®ã§ NamedList ããåé¢ãã¹ã
+  def set_cloned( ct_name, cell_name, locale )
+    items = []
+    names = {}
+    @items.each { |i|
+      dbgPrint "NamedList clone #{ct_name}, #{cell_name}, #{i.get_name}\n"
+
+      cl = i.clone_for_composite( ct_name, cell_name, locale )
+      names[cl.get_name] = cl
+      items << cl
+    }
+    @items = items
+    @names = names
+  end
+
+  def assert_name item
+    if ! item.get_name.kind_of? Symbol
+      raise "Not symbol for NamedList item"
+    end
+  end
+
+  def show_tree( indent )
+    @items.each { |i|
+      i.show_tree( indent )
+    }
+  end
+
+end
+
+class Typedef < BDNode
+# @declarator:: Decl
+
+  def self.new_decl_list( type_spec_qual_list, decl_list )
+    decl_list.each { |decl|
+       Typedef.new( type_spec_qual_list, decl )
+    }
+  end
+
+  def initialize( type_spec_qual_list, decl )
+    super()
+    decl.set_type( type_spec_qual_list )
+    @declarator = decl
+    decl.set_owner self    # Decl(Typedef)
+
+    Namespace.new_typedef( self )
+  end
+
+  def get_name
+    @declarator.get_name
+  end
+
+  def get_declarator
+    @declarator
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Typedef: #{locale_str}"
+    @declarator.show_tree( indent + 1 )
+  end
+end
+
+#== é¢æ°é ­é¨
+# signature ã«ç»é²ãããé¢æ°
+class FuncHead <BDNode
+#  @declarator:: Decl
+
+  def initialize( declarator, type, b_oneway )
+    super()
+    declarator.set_type( type )
+    @declarator = declarator
+    @declarator.set_owner self  # Decl (FuncHead)
+
+    if @declarator.get_type.kind_of?( FuncType ) then
+      if b_oneway then
+        @declarator.get_type.set_oneway( b_oneway )
+      end
+    end
+    @declarator.get_type.check_struct_tag :FUNCHEAD
+
+    # check if return type is pointer
+    if declarator.get_type.kind_of? FuncType then
+      if declarator.get_type.get_type.get_original_type.kind_of?( PtrType ) &&
+          Signature.get_current.is_deviate? == false then
+        cdl_warning( "W3004 $1 pointer type has returned. specify deviate or stop return pointer" , @declarator.get_identifier )
+      end
+    end
+  end
+
+  def get_name
+    @declarator.get_name
+  end
+
+  def get_declarator
+    @declarator
+  end
+
+  def is_oneway?
+    if @declarator.is_function? then
+      return @declarator.get_type.is_oneway?
+    end
+    return false
+  end
+
+  def is_function?
+    @declarator.is_function?
+  end
+
+  #=== FuncHead# é¢æ°ã®ååãè¿ã
+  def get_name
+    return @declarator.get_name
+  end
+
+  #=== FuncHead# é¢æ°ã®æ»ãå¤ã®åãè¿ã
+  # types.rb ã«å®ç¾©ããã¦ããå
+  # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å
+¨ãªå ´å nil ãè¿ã
+  def get_return_type
+    if is_function? then
+      return @declarator.get_type.get_type
+    end
+  end
+
+  #=== FuncHead# é¢æ°ã®å¼æ°ã®ãªã¹ããè¿ã
+  # ParamList ãè¿ã
+  # é¢æ°ãããã®å®ç¾©ã¨ãã¦ä¸å®å
+¨ãªå ´å nil ãè¿ã
+  def get_paramlist
+    if is_function? then
+      return @declarator.get_type.get_paramlist
+    end
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "FuncHead: #{locale_str}"
+    @declarator.show_tree( indent + 1 )
+  end
+end
+
+#=== å®£è¨
+# @kind ã§ç¤ºãããåç¨®ã®å®£è¨
+class Decl < BDNode
+
+# @identifer:: String
+# @global_name:: String | nil : String(@kind=TYPEDEF||:CONSTANT), nil(@kind=ãã®ä»)
+#                set_kind ã«ã¦è¨­å®ããã
+# @type:: ArrayType, FuncType, PtrType, IntType, StructType
+#         VoidType, FloatType, DefinedType, BoolType
+# @initializer:: constant_expression, mikan { initlist }
+# @kind:: :VAR, :ATTRIBUTE, :PARAMETER, :TYPEDEF, :CONSTANT, :MEMBER, :FUNCHEAD(signatureã®é¢æ°å®ç¾©)
+# @b_referenced:: bool
+#
+# ä»¥ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE ã®ã¨ãã«æå¹
+# @rw:: bool     # å¤ãææ³ã§ã¯ attr ã«æå®å¯è½ã ã£ãï¼æ¶ãã«ã¯ generate ã®ä¿®æ­£ãå¿
+è¦ï¼
+# @omit:: bool
+# @choice_list:: [String]  attr åæå¤ã®é¸æè¢
+# ä»¥ä¸ã¯ã@kind ã :VAR, :ATTRIBUTE, :MEMBER ã®ã¨ãã«æå¹
+# @size_is:: Expression or nil unless specified
+# ä»¥ä¸ã¯ã@kind ã :MEMBER ã®ã¨ãã«æå¹
+# @count_is:: Expression or nil unless specified
+#             attr, var ã®å ´åãcount_is ã¯æå®ã§ããªã
+# @string:: Expression, -1 (length not specified) or nil (not specified)
+#
+# mikan  ParamDecl ã ãå¥ã«è¨­ããããMemberDecl, AttrDecl ãªã©ãåããã¹ãã(ï¼)
+
+  def initialize( identifier )
+    super()
+    @identifier = identifier
+    @rw = false
+    @omit = false
+    @size_is = nil
+    @count_is = nil
+    @string  = nil
+    @choice_list  = nil
+    @b_referenced  = false
+  end
+
+  def set_initializer( initializer )
+    @initializer = initializer
+  end
+
+  def get_initializer
+    @initializer
+  end
+
+  def is_function?
+    if @type.class == FuncType then
+      return true
+    else
+      return false
+    end
+  end
+
+  #== Decl ã®æå³çèª¤ãããã§ãã¯ãã
+  def check
+    # return nil if @type == nil
+
+    # æ§é ä½ã¿ã°ãã§ãã¯ï¼ãã¤ã³ã¿åããæ§é ä½ãåç
+§ããã¦ããå ´åã¯ãã¿ã°ã®å­å¨ããã§ãã¯ããªãï¼
+    @type.check_struct_tag @kind
+
+    # åã®ãã§ãã¯ãè¡ã
+    res = @type.check
+    if res then
+      cdl_error( "S2002 $1: $2" , @identifier, res )
+    end
+
+    # ä¸è¦ã®åæåå­ããã§ãã¯ãã
+    if @initializer then
+      case @kind
+      when :PARAMETER, :TYPEDEF, :MEMBER, :FUNCHEAD
+        cdl_error( "S2003 $1: $2 cannot have initializer" , @identifier, @kind.to_s.downcase )
+      when :VAR, :ATTRIBUTE, :CONSTANT
+        # p @initializer  ããã§ã¯ä»£å
+¥å¯è½ãã©ããããã§ãã¯ããªã
+        # :VAR, :ATTRIBUTE, :CONSTANT ã¯ããããã§ãã§ãã¯ãã
+        # return @type.check_init( @identifier, @initializer, @kind )
+      else
+        raise "unknown kind in Delc::check"
+      end
+    end
+
+    if( @type.kind_of? ArrayType ) && ( @type.get_subscript == nil ) && ( @omit == false ) then
+      if @kind == :ATTRIBUTE then
+        cdl_error( "S2004 $1: array subscript must be specified or omit" , @identifier )
+      elsif @kind == :VAR || @kind == :MEMBER then
+        cdl_error( "S2005 $1: array subscript must be specified" , @identifier )
+      end
+    end
+
+    return nil
+  end
+
+  #== ãã¤ã³ã¿ã¬ãã«ãå¾ã
+  # æ»ãå¤ï¼
+  #   éãã¤ã³ã¿å¤æ°   = 0
+  #   ãã¤ã³ã¿å¤æ°     = 1
+  #   äºéãã¤ã³ã¿å¤æ° = 2
+  def get_ptr_level
+    level = 0
+    type = @type
+    while 1
+      if type.kind_of?( PtrType ) then
+        level += 1
+        type = type.get_referto
+#      elsif type.kind_of?( ArrayType ) then  # æ·»æ°ãªãé
+åã¯ãã¤ã³ã¿ã¨ã¿ãªã
+#        if type.get_subscript == nil then
+#          level += 1
+#          type = type.get_type
+#        else
+#          break
+#        end
+        # mikan ãã¤ã³ã¿ã®æ·»æ°ããé
+åã®ãã¤ã³ã¿ã¬ãã«ã¯ï¼ã§ããï¼
+      elsif type.kind_of?( DefinedType ) then
+        type = type.get_type
+        # p "DefinedType: #{type} #{type.class}"
+      else
+        break
+      end
+    end
+    return level
+  end
+
+  def get_name
+    @identifier
+  end
+
+  def get_global_name
+    @global_name
+  end
+
+  def set_type( type )
+    unless @type then
+      @type = type
+    else
+      @type.set_type( type )             # èã«è¨­å®
+    end
+  end
+
+  def get_type
+    @type
+  end
+
+  def get_identifier
+    @identifier
+  end
+
+  # STAGE: B
+  def set_kind( kind )
+    @kind = kind
+    case kind
+    when :TYPEDEF, :CONSTANT
+      if Namespace.get_global_name.to_s == "" then
+        @global_name = @identifier
+      else
+        @global_name = :"#{Namespace.get_global_name}_#{@identifier}"
+      end
+    else
+      @global_name = nil
+    end
+  end
+
+  def get_kind
+    @kind
+  end
+
+  def set_specifier_list( spec_list )
+    spec_list.each{  |spec|
+      case spec[0]
+      when :RW
+        @rw = true
+      when :OMIT
+        @omit = true
+      when :SIZE_IS
+        @size_is = spec[1]
+      when :COUNT_IS
+        @count_is = spec[1]
+      when :STRING
+        @string = spec[1]
+      when :CHOICE
+        @choice_list = spec[1]
+      else
+        raise "Unknown specifier #{spec[0]}"
+      end
+    }
+
+    if @size_is || @count_is || @string
+        @type.set_scs( @size_is, @count_is, @string, nil, false )
+    end
+  end
+
+  def is_rw?
+    @rw
+  end
+
+  def is_omit?
+    @omit
+  end
+
+  def get_size_is
+    @size_is
+  end
+
+  def get_count_is
+    @count_is
+  end
+
+  def get_string
+    @string
+  end
+
+  def get_choice_list
+    @choice_list
+  end
+
+  def referenced
+    @b_referenced = true
+  end
+
+  def is_referenced?
+    @b_referenced
+  end
+
+  def is_type?( type )
+    t = @type
+    while 1
+      if t.kind_of?( type ) then
+        return true
+      elsif t.kind_of?( DefinedType ) then
+        t = t.get_type
+      else
+        return false
+      end
+    end
+  end
+
+  def is_const?
+    type = @type
+    while 1
+      if type.is_const? then
+        return true
+      elsif type.kind_of?( DefinedType ) then
+        type = type.get_type
+      else
+        return false
+      end
+    end
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Declarator: name: #{@identifier} kind: #{@kind} global_name: #{@global_name} #{locale_str}"
+    (indent+1).times { print "  " }
+    puts "type:"
+    @type.show_tree( indent + 2 )
+    if @initializer then
+      (indent+1).times { print "  " }
+      puts "initializer:"
+      @initializer.show_tree( indent + 2 )
+    else
+      (indent+1).times { print "  " }
+      puts "initializer: no"
+    end
+    (indent+1).times { print "  " }
+    puts "size_is: #{@size_is.to_s}, count_is: #{@count_is.to_s}, string: #{@string.to_s} referenced: #{@b_referenced} "
+   
+  end
+
+end
+
+# é¢æ°ãã©ã¡ã¼ã¿ã®å®£è¨
+class ParamDecl < BDNode
+
+# @declarator:: Decl:  Token, ArrayType, FuncType, PtrType
+# @direction:: :IN, :OUT, :INOUT, :SEND, :RECEIVE
+# @size:: Expr   (size_is å¼æ°)
+# @count:: Expr   (count_is å¼æ°)
+# @max:: Expr (size_is ã®ç¬¬äºå¼æ°)
+# @b_nullable:: Bool : nullable 
+# @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼
+# @allocator:: Signature of allocator
+# @b_ref:: bool : size_is, count_is, string_is å¼æ°ã¨ãã¦åç
+§ããã¦ãã
+#
+# 1. é¢æ°åã§ãªããã¨
+# 2. ï¼æ¬¡å
+ä»¥ä¸ã®é
+åã§ãã£ã¦æãå
+å´ä»¥å¤ã®æ·»æ°ããããã¨
+# 3. in, out, ..., size_is, count_is, ... ã®éè¤æå®ããªããã¨
+# 4. ãã¤ã³ã¿ã¬ãã«ãé©åãªãã¨
+
+  def initialize( declarator, specifier, param_specifier )
+    super()
+    @declarator = declarator
+    @declarator.set_owner self  # Decl (ParamDecl)
+    @declarator.set_type( specifier )
+    @param_specifier = param_specifier
+    @b_ref = false
+    @b_nullable = false
+
+    if @declarator.is_function? then		# (1)
+      cdl_error( "S2006 \'$1\' function" , get_name )
+      return
+    end
+
+    res = @declarator.check
+    if res then					# (2)
+      cdl_error( "S2007 \'$1\' $2" , get_name, res )
+      return
+    end
+
+    @param_specifier.each { |i|
+      case i[0]                                     # (3)
+      when :IN, :OUT, :INOUT, :SEND, :RECEIVE
+        if @direction == nil then
+          @direction = i[0]
+        elsif i[0] == @direction then
+          cdl_warning( "W3001 $1: duplicate" , i[0] )
+          next
+        else
+          cdl_error( "S2008 $1: inconsitent with previous one" , i[0] )
+          next
+        end
+
+        case i[0]
+        when :SEND, :RECEIVE
+          @allocator = Namespace.find( i[1] )   #1
+          if ! @allocator.instance_of?( Signature ) then
+            cdl_error( "S2009 $1: not found or not signature" , i[1] )
+            next
+          elsif ! @allocator.is_allocator? then
+            # cdl_error( "S2010 $1: not allocator signature" , i[1] )
+          end
+        end
+
+      when :SIZE_IS
+        if @size then
+          cdl_error( "S2011 size_is duplicate"  )
+        else
+          @size = i[1]
+        end
+      when :COUNT_IS
+        if @count then
+          cdl_error( "S2012 count_is duplicate"  )
+        else
+          @count = i[1]
+        end
+      when :STRING
+        if @string then
+          cdl_error( "S2013 string duplicate"  )
+        elsif i[1] then
+          @string = i[1]
+        else
+          @string = -1
+        end
+      when :MAX_IS
+        # max_is ã¯ãå
+é¨çãªãã® bnf.y.rb åç
+§
+        # size_is ã§éè¤ãã§ãã¯ããã
+        @max = i[1]
+      when :NULLABLE
+        # if ! @declarator.get_type.kind_of?( PtrType ) then
+        #  cdl_error( "S2026 '$1' nullable specified for non-pointer type", @declarator.get_name )
+        # else
+          @b_nullable = true
+        # end
+      end
+
+    }
+
+    if @direction == nil then
+      cdl_error( "S2014 No direction specified. [in/out/inout/send/receive]"  )
+    end
+
+    if ( @direction == :OUT || @direction == :INOUT ) && @string == -1 then
+      cdl_warning( "W3002 $1: this string might cause buffer over run" , get_name )
+    end
+
+    # mikan ãã¤ã³ã¿ã®é
+åï¼æ·»æ°æï¼ã®ã¬ãã«ãï¼
+    ptr_level = @declarator.get_ptr_level
+
+    # p "ptr_level: #{@declarator.get_identifier} #{ptr_level}"
+    # p @declarator
+
+    #----  set req_level, min_level & max_level  ----#
+    if !(@size||@count||@string) then	    # (4)
+      req_level = 1
+    elsif (@size||@count)&&@string then
+      req_level = 2
+    else
+      req_level = 1
+    end
+
+    if @direction == :RECEIVE then
+      req_level += 1
+    end
+    min_level = req_level
+    max_level = req_level
+
+    # IN without pointer specifier can be non-pointer type
+    if @direction == :IN && !(@size||@count||@string) then
+      min_level = 0
+    end
+
+    # if size_is specified and pointer refer to struct, max_level increase
+    if @size then
+      type = @declarator.get_type.get_original_type
+      while type.kind_of? PtrType
+        type = type.get_referto.get_original_type
+      end
+      if type.kind_of? StructType then
+        max_level += 1
+      end
+    end
+    #----  end req_level & max_level    ----#
+
+    # p "req_level: #{req_level} ptr_level: #{ptr_level}"
+    #if ptr_level < req_level && ! ( @direction == :IN && req_level == 1 && ptr_level == 0) then
+    if ptr_level < min_level then
+      cdl_error( "S2014 $1 need pointer or more pointer" , @declarator.get_identifier )
+    elsif ptr_level > max_level then
+      # note: æ§æè§£ææ®µéã§å®è¡ã®ãã get_current å¯
+      if Signature.get_current == nil || Signature.get_current.is_deviate? == false then
+        cdl_warning( "W3003 $1 pointer level mismatch" , @declarator.get_identifier )
+      end
+    end
+
+    type = @declarator.get_type
+    while type.kind_of?( DefinedType )
+      type = type.get_original_type
+    end
+
+    if ptr_level > 0 then
+      # size_is, count_is, string ãã»ãã
+      if @direction == :RECEIVE && ptr_level > 1 then
+        type.get_type.set_scs( @size, @count, @string, @max, @b_nullable )
+      else
+        type.set_scs( @size, @count, @string, @max, @b_nullable )
+      end
+
+#p ptr_level
+#type.show_tree 1
+
+      # ãã¤ã³ã¿ãæãã¦ããå
+ã®ãã¼ã¿åãå¾ã
+      i = 0
+      t2 = type
+      while i < ptr_level
+        t2 = t2.get_referto
+        while t2.kind_of?( DefinedType )
+          t2 = t2.get_original_type
+        end
+        i += 1
+      end
+
+# p @declarator.get_name
+# t2.show_tree 1
+# p t2.is_const?
+
+      # const ä¿®é£¾ãé©åããã§ãã¯
+      if @direction == :IN then
+        if ! t2.is_const? then
+          cdl_error( "S2015 '$1' must be const for \'in\' parameter $2" , get_name, type.class )
+        end
+      else
+        if t2.is_const? then
+          cdl_error( "S2016 '$1' can not be const for $2 parameter" , get_name, @direction )
+        end
+      end
+    else
+      # éãã¤ã³ã¿ã¿ã¤ã
+      if @size != nil || @count != nil || @string != nil || @max != nil || @b_nullable then
+        type.set_scs( @size, @count, @string, @max, @b_nullable )
+      end
+    end
+
+#    if ptr_level > 0 && @direction == :IN then
+#      if type.is_const != :CONST
+#    end
+
+    # p self
+
+  end
+
+  def check_struct_tag kind
+    @declarator.get_type.check_struct_tag :PARAMETER
+  end
+
+  def get_name
+    @declarator.get_name
+  end
+
+  def get_size
+    @size
+  end
+
+  def get_count
+    @count
+  end
+
+  def get_string
+    @string
+  end
+
+  def get_max
+    @max
+  end
+
+  def clear_max
+    # p "clear_max: #{@declarator.get_name} #{@max.to_s}"
+    @max = nil
+    @declarator.get_type.clear_max
+  end
+
+  def is_nullable?
+    @b_nullable
+  end
+
+  def get_type
+    @declarator.get_type
+  end
+
+  def get_direction
+    @direction
+  end
+
+  def get_declarator
+    @declarator
+  end
+
+  def get_allocator
+    @allocator
+  end
+
+  def referenced
+    @b_ref = true
+  end
+
+  def is_referenced?
+    @b_ref
+  end
+
+  #=== PPAllocator ãå¿
+è¦ã
+  # Transparent RPC ã®å ´å in ã§ size_is, count_is, string ã®ãããããæå®ããã¦ããå ´å oneway ã§ã¯ PPAllocator ãå¿
+è¦
+  # Transparent PC ã§ oneway ãã©ããã¯ãããã§ã¯å¤æ­ããªãã®ã§å¥éå¤æ­ãå¿
+è¦
+  # Opaque RPC ã®å ´å size_is, count_is, string ã®ãããããæå®ããã¦ããå ´åãPPAllocator ãå¿
+è¦
+  def need_PPAllocator?( b_opaque = false )
+    if ! b_opaque then
+#      if @direction == :IN && ( @size || @count || @string ) then
+      if @direction == :IN && @declarator.get_type.get_original_type.kind_of?( PtrType ) then
+        return true
+      end
+    else
+      if (@direction == :IN || @direction == :OUT || @direction == :INOUT ) &&
+          @declarator.get_type.get_original_type.kind_of?( PtrType ) then
+        return true
+      end
+    end
+    return false
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "ParamDecl: direction: #{@direction} #{locale_str}"
+    @declarator.show_tree( indent + 1 )
+    if @size then
+      (indent+1).times { print "  " }
+      puts "size:"
+      @size.show_tree( indent + 2 )
+    end
+    if @count then
+      (indent+1).times { print "  " }
+      puts "count:"
+      @count.show_tree( indent + 2 )
+    end
+    if @string then
+      (indent+1).times { print "  " }
+      puts "string:"
+      if @string == -1 then
+       (indent+2).times { print "  " }
+        puts "size is not specified"
+      else
+        @string.show_tree( indent + 2 )
+      end
+    end
+    if @allocator then
+      (indent+1).times { print "  " }
+      puts "allocator: signature: #{@allocator.get_name}"
+    end    
+  end
+end
+
+# é¢æ°ãã©ã¡ã¼ã¿ãªã¹ã
+class ParamList < BDNode
+# @param_list:: NamedList : item: ParamDecl
+
+  def initialize( paramdecl )
+    super()
+    @param_list = NamedList.new( paramdecl, "parameter" )
+    @param_list.get_items.each { |paramdecl|
+      paramdecl.set_owner self   # ParamDecl
+    }
+  end
+
+  def add_param( paramdecl )
+    return if paramdecl == nil    # æ¢ã«ã¨ã©ã¼
+
+    @param_list.add_item( paramdecl )
+    paramdecl.set_owner self   # ParamDecl
+  end
+
+  def get_items
+    @param_list.get_items
+  end
+
+  #=== size_is, count_is, string ã®å¼æ°ã®å¼ããã§ãã¯
+  # å¤æ°ã¯åæ¹åç
+§å¯è½ãªãããé¢æ°é ­é¨ã®æ§æè§£éãçµãã£ãå¾ã«ãã§ãã¯ãã
+  def check_param
+    @param_list.get_items.each { |i|
+      next if i == nil                      # i == nil : ã¨ã©ã¼æ
+
+      if i.get_type.class == VoidType then
+        # åä¸ã® void åã¯ããã«ã¯ããªã
+        cdl_error( "S2027 '$1' parameter cannot be void type", i.get_name )
+      end
+
+      size = i.get_size			# Expression
+      if size then
+        val = size.eval_const( @param_list )
+        if val == nil then			# å®æ°å¼ã§ãªããï¼
+          # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿ OK
+          type = size.get_type( @param_list )
+          unless type.kind_of?( IntType ) then
+            cdl_error( "S2017 size_is argument is not integer type"  )
+          else
+            size.check_dir_for_param( @param_list, i.get_direction, "size_is" )
+          end
+        else
+          if val != Integer( val ) then
+            cdl_error( "S2018 \'$1\' size_is parameter not integer" , i.get_declarator.get_identifier )
+          elsif val <= 0 then
+            cdl_error( "S2019 \'$1\' size_is parameter negative or zero" , i.get_declarator.get_identifier )
+          end
+        end
+      end
+
+      max = i.get_max
+      if max then
+        val2 = max.eval_const( @param_list )
+        if val2 == nil then
+          cdl_error( "S2028 '$1' max (size_is 2nd parameter) not constant", i.get_name )
+        elsif val2 != Integer( val2 ) || val2 <= 0 then
+          cdl_error( "S2029 '$1' max (size_is 2nd parameter) negative or zero, or not integer", i.get_name )
+        end
+      end
+
+      if val != nil && val2 != nil then
+        if val < val2 then
+          cdl_warning( "W3005 '$1' size_is always lower than max. max is ignored", i.get_name )
+          i.clear_max
+        else
+          cdl_error( "S2030 '$1' both size_is and max are const. size_is larger than max", i.get_name )
+        end
+      end
+
+      count = i.get_count			# Expression
+      if count then
+        val = count.eval_const( @param_list )
+        if val == nil then			# å®æ°å¼ã§ãªããï¼
+          # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿ OK
+          type = count.get_type( @param_list )
+          unless type.kind_of?( IntType ) then
+            cdl_error( "S2020 count_is argument is not integer type"  )
+          else
+            count.check_dir_for_param( @param_list, i.get_direction, "count_is" )
+          end
+        else
+          if val != Integer( val ) then
+            cdl_error( "S2021 \'$1\' count_is parameter not integer" , i.get_declarator.get_identifier )
+          elsif val <= 0 then
+            cdl_error( "S2022 \'$1\' count_is parameter negative or zero" , i.get_declarator.get_identifier )
+          end
+        end
+      end
+
+      string = i.get_string			# Expression
+      if string != -1 && string then
+        val = string.eval_const( @param_list )
+        if val == nil then			# å®æ°å¼ã§ãªããï¼
+          # mikan å¤æ°ãå«ãå¼ï¼åä¸ã®å¤æ°ã®ã¿ OK
+          type = string.get_type( @param_list )
+          unless type.kind_of?( IntType ) then
+            cdl_error( "S2023 string argument is not integer type"  )
+          else
+            string.check_dir_for_param( @param_list, i.get_direction, "string" )
+          end
+        else
+          if val != Integer( val ) then
+            cdl_error( "S2024 \'$1\' string parameter not integer" , i.get_declarator.get_identifier )
+          elsif val <= 0 then
+            cdl_error( "S2025 \'$1\' string parameter negative or zero" , i.get_declarator.get_identifier )
+          end
+        end
+      end
+    }
+  end
+
+  def check_struct_tag kind
+    @param_list.get_items.each{ |p|
+      p.check_struct_tag kind
+    }
+  end
+
+  #=== Push Pop Allocator ãå¿
+è¦ãï¼
+  # Transparent RPC ã®å ´å (oneway ãã¤) in ã®é
+å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã
+  def need_PPAllocator?( b_opaque = false )
+    @param_list.get_items.each { |i|
+      if i.need_PPAllocator?( b_opaque ) then
+        return true
+      end
+    }
+    false
+  end
+
+  def find( name )
+    @param_list.get_item( name )
+  end
+
+  #== ParamList# æå­åå
+  #b_name:: Bool: ãã©ã¡ã¼ã¿åãå«ãã
+  def to_str( b_name )
+    str = "("
+    delim = ""
+    @param_list.get_items.each{ |paramdecl|
+      decl = paramdecl.get_declarator
+      str += delim + decl.get_type
+      if b_name then
+        str += " " + decl.get_name
+      end
+      str += decl.get_type_post
+      delim = ", "
+    }
+    str += ")"
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "ParamList: #{locale_str}"
+    @param_list.show_tree( indent + 1 )
+  end
+end
+
+#== CDL ã®æå­åãªãã©ã«ãæ±ãããã®ã¯ã©ã¹
+# CDL ã®æå­åãªãã©ã«ãã®ãã®ã§ã¯ãªã
+class CDLString
+  # ã¨ã¹ã±ã¼ãæå­ãå¤æ
+  def self.escape str
+    str = str.dup
+    str.gsub!( /\\a/, "\x07" )
+    str.gsub!( /\\b/, "\x08" )
+    str.gsub!( /\\f/, "\x0c" )
+    str.gsub!( /\\n/, "\x0a" )
+    str.gsub!( /\\r/, "\x0d" )
+    str.gsub!( /\\t/, "\x08" )
+    str.gsub!( /\\v/, "\x0b" )
+    str.gsub!( /(\\[Xx][0-9A-Fa-f]{1,2})/, '{printf \"\\1\"}' )
+    str.gsub!( /(\\[0-7]{1,3})/, '{printf \"\\1\"}' )
+    str.gsub!( /\\(.)/, "\\1" )   # mikan æªå®ç¾©ã®ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãå¤æãã¦ãã¾ã (gcc V3.4.4 ã§ã¯è­¦åãåºããã)
+    return str
+  end
+
+  #=== CDLString#åå¾ã® " ãåãé¤ã
+  def self.remove_dquote str
+    s = str.sub( /\A"/, "" )
+    s.sub!( /"\z/, "" )
+    return s
+  end
+end
+
+#== CDL ã®åæåå­ãæ±ãããã®ã¯ã©ã¹
+# CDL ã®åæåå­ãã®ãã®ã§ã¯ãªã
+class CDLInitializer
+  #=== åæåå­ã®ã¯ã­ã¼ã³
+  # åæåå­ã¯ Expression, C_EXP, Array ã®ãããã
+  def self.clone_for_composite( rhs, ct_name, cell_name, locale )
+    if rhs.instance_of? C_EXP then
+      # C_EXP ã® clone ãä½ãã¨ã¨ãã«ç½®æ
+      rhs = rhs.clone_for_composite( ct_name, cell_name, locale )
+    elsif rhs.instance_of? Expression then
+      rhs = rhs.clone_for_composite
+    elsif rhs.instance_of? Array then
+      rhs = clone_for_compoiste_array( rhs, ct_name, cell_name, locale )
+    else
+      raise "unknown rhs for join"
+    end
+    return rhs
+  end
+
+  #=== åæåå­ï¼é
+åï¼ã®ã¯ã­ã¼ã³
+  # è¦ç´ ã¯ clone_for_composite ãæã¤ãã®ã ã
+  def self.clone_for_compoiste_array( array, ct_name, cell_name, locale )
+    # "compoiste.identifier" ã®å ´å (CDL ã¨ãã¦ã¯èª¤ã)
+    if array[0] == :COMPOSITE then
+      return array.clone
+    end
+
+    new_array = array.map{ |m|
+      clone_for_composite( m, ct_name, cell_name, locale )
+    }
+    return new_array
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecs_lang.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecs_lang.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecs_lang.rb	(revision 317)
@@ -0,0 +1,369 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecs_lang.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== è¨èªã«é¢ããå¤æ°ãè¨­å®
+# ã¡ãã»ã¼ã¸ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿ãè¡ã (èª­ã¿è¾¼ã¿ã«å¤±æããå ´åãããã©ã«ãã®æå­ã³ã¼ãã«å¤æ´ãã)
+class TECS_LANG
+  # ããã·ã¥ã®ã¿ã°ã¯ case insensitive ã®ãããå¤§æå­ã®æå­åã¨ãã
+  CHARSET_ALIAS = {
+    "UJIS" => :eucJP,
+    "UTF-8" => :utf8,
+    "EUCJP" => :eucJP,   # ä»¥ä¸ case insensitive ã«ãããã
+    "SJIS" => :sjis,
+    "UTF8" => :utf8,
+    "ISO8859-1" => :"iso8859-1"
+  }
+  LANG_ALIAS = {
+    "C" => :en_US,
+    "EN_US" => :en_US,   # ä»¥ä¸ case insensitive ã«ãããã
+    "JA_JP" => :ja_JP
+  }
+  SUITABLE_CHARSET = {
+    :ja_JP => [ :eucJP, :sjis, :utf8 ],
+    :en_US => [ :"iso8859-1", :utf8, nil ]
+  }
+
+  #=== LANG ã®ãã¼ã¹
+  #lang::String  "ja_JP.eucJP@cjknarrow", "C" ãªã©
+  #RETURN:: [ :ja_JP, :eucJP, :cjknarrow ]
+  def self.parse_lang( lang )
+    lang =~ /([^\.@]*)(\.([^@]*))?(@(.*))?/
+
+    lang_terri = $1.to_sym if $1 != nil && $1 != ""
+    # set_kcode_binary ã«ãããC.UTF-8 ã®ã¿ãç¹å¥æ±ãããå¿
+è¦ããªããªã£ã
+    # if lang_terri == :C then    # LANG=C.* ã¯ããã¹ã¦ 1 byte æå­ã³ã¼ãã¨ãã¦æ±ã
+    #  codeset = nil
+    #  modifier = nil
+    # else
+      codeset = $3.to_sym if $3 != nil && $3 != ""
+      modifier = $5.to_sym if $5 != nil && $5 != ""
+    # end
+    [ lang_terri, codeset, modifier ]
+  end
+
+  #=== lang, charset ã®å¥æè§£æ±ºããã³å¦¥å½æ§ã®ãã§ãã¯
+  #lang::Symbol    : :en_US, :ja_JP ãªã©
+  #charset::Symbol : :eucJP, :utf8 ãªã©
+  #RETURN:
+  #  [ lang, charset, result ]::ããresult = false ã®å ´å lang, charset ã¯ä¸é©å
+  def self.resolve_alias_and_check( lang, charset )
+    if LANG_ALIAS[ lang.to_s.upcase ] then
+      ln = LANG_ALIAS[ lang.to_s.upcase ]
+    else
+      ln = lang
+    end
+
+    if CHARSET_ALIAS[ charset.to_s.upcase ] then
+      cs = CHARSET_ALIAS[ charset.to_s.upcase ]
+    else
+      cs = charset
+    end
+
+    if SUITABLE_CHARSET[ ln ] == nil || SUITABLE_CHARSET[ ln ].index( cs ) == nil
+      res = false
+    else
+      res = true
+    end
+
+    # p ln, cs, res
+    [ ln, cs, res ]
+  end
+
+  #=== codepage ãåãåºã
+  #codepage ã¯3ï½5æ¡ã®æ´æ°ã¨ãã¦ä»®å®
+  def self.get_win_codepage
+    cmd_pipe = IO.popen('cmd /c chcp','r')
+    cmd_pipe.read =~ /([0-9]{3,5})/
+    cp = $1
+    cmd_pipe.close
+    return cp
+  end
+
+  #=== codepage ãã LANG ã®è¨­å®æå­åã«å¤æ
+  def self.codepage_to_lang cp
+    if cp == "932" then
+      "ja_JP.sjis"
+    else
+      "en_US"
+    end
+  end
+
+  #=== è¨èªãæå­ã³ã¼ãã«é¢ããå¤æ°ãè¨­å®
+  # ä»¥ä¸ã®é ã«ãã§ãã¯ãããä¸çªæå¾ã«è¨­å®ãããå¤ãæ¡ç¨ããã
+  #   ã»ããã©ã«ã
+  #   ã»codepage  (exerb çã§ TERM æªè¨­å®ã¾ãã¯ TERM=cygwin ã®å ´åã®ã¿)
+  #   ã»LANG ç°å¢å¤æ°
+  #   ã»TECSGEN_LANG ç°å¢å¤æ°
+  #   ã»TECSGEN_FILE_LANG ç°å¢å¤æ° (ãã¡ã¤ã«ã®æå­ã³ã¼ãã®ã¿)
+  #   ã»-k ãªãã·ã§ã³ (ãã¡ã¤ã«ã®æå­ã³ã¼ãã®ã¿)
+  def self.set_lang_var
+
+    if $IN_EXERB && ( ENV[ 'TERM' ] == nil || ENV[ 'TERM' ] == "cygwin" ) then
+      # exerb çã§ç«¯æ« cygwin ã®æã¯ codepage ã®ã¿ãè¦ã
+      cp = get_win_codepage
+      lang = codepage_to_lang cp
+      $LANG_FILE, $CHARSET_FILE, *dum = self.parse_lang( lang )
+      $LANG_CONSOLE = $LANG_FILE
+      $CHARSET_CONSOLE = $CHARSET_FILE
+
+    elsif ENV[ 'LANG' ]then
+      # é exerb çã§ã¯ LANG ç°å¢å¤æ°ãè¦ã
+      # cygwin console ã§ã¯ codepage ã«å¾ã£ã¦åºåããæ¹ãå¹³åãªãã
+
+      $LANG_FILE, $CHARSET_FILE, *dum = self.parse_lang( ENV[ 'LANG' ] )
+      $LANG_CONSOLE = $LANG_FILE
+      $CHARSET_CONSOLE = $CHARSET_FILE
+    end
+
+    if ENV[ 'TECSGEN_LANG' ]then
+      $LANG_FILE, $CHARSET_FILE, *dum = self.parse_lang( ENV[ 'TECSGEN_LANG' ] )
+      $LANG_CONSOLE = $LANG_FILE
+      $CHARSET_CONSOLE = $CHARSET_FILE
+    end
+
+    if ENV[ 'TECSGEN_FILE_LANG' ]then
+      $LANG_FILE, $CHARSET_FILE, *dum = self.parse_lang( ENV[ 'TECSGEN_FILE_LANG' ] )
+    end
+
+    self.set_lang_by_option
+  end
+
+  #=== -k ãªãã·ã§ã³ãããã¡ã¤ã«ç¨ã®è¨èªãæå­ã³ã¼ãå¤æ°ãè¨­å®
+  def self.set_lang_by_option
+    if $kcode == nil
+      return
+    end
+
+    code = $kcode
+    found = false
+    res = $CODE_TYPE_ARRAY.index( code )
+    if res == nil then
+      print "-k: illegal kcode type #{code}. (#{$CODE_TYPE_ARRAY.join(", ")})\n"
+      exit 1
+    end
+
+    case $kcode
+    when "euc"
+      $CHARSET_FILE = :eucJP
+      $LANG_FILE = :ja_JP
+    when "sjis"
+      $CHARSET_FILE = :sjis
+      $LANG_FILE = :ja_JP
+    when "utf8"
+      $CHARSET_FILE = :utf8
+      $LANG_FILE = :ja_JP
+    when "none"
+      $CHARSET_FILE = nil
+      $LANG_FILE = "en_US"
+    end
+  end
+
+  #=== Kconv ã¯ã©ã¹ç¨ã®å¤æ°ãè¨­å®
+  # è¨èªæ
+å ±ãã Kconv ã«é¢ããå¤æ°ãè¨­å®
+  def self.set_kconv_var
+
+    # æå­ã³ã¼ãã®è¨­å®
+    case $CHARSET_FILE           # string: "EUC" | "SJIS" | "NONE" | "UTF8"
+    when :eucJP
+      $KCODE_CDL = "EUC"
+      $KCONV_CDL = Kconv::EUC
+      $Ruby19_File_Encode = "ASCII-8BIT"
+    when :sjis
+      $KCODE_CDL = "SJIS"
+      $KCONV_CDL = Kconv::SJIS
+      $Ruby19_File_Encode = "Shift_JIS"
+    when :utf8
+      $KCODE_CDL = "UTF8"
+      $KCONV_CDL = Kconv::UTF8
+      $Ruby19_File_Encode = "ASCII-8BIT"
+    else
+      $KCODE_CDL = "BINARY"
+      $KCONV_CDL = Kconv::BINARY
+      $Ruby19_File_Encode = "ASCII-8BIT"
+    end
+
+    case $CHARSET_CONSOLE
+    when :eucJP
+      $KCODE_CONSOLE = "EUC"
+      $KCONV_CONSOLE = Kconv::EUC
+    when :sjis
+      $KCODE_CONSOLE = "SJIS"
+      $KCONV_CONSOLE = Kconv::SJIS
+    when :utf8
+      $KCODE_CONSOLE = "UTF8"
+      $KCONV_CONSOLE = Kconv::UTF8
+    else
+      $KCODE_CONSOLE = "BINARY"
+      $KCONV_CONSOLE = Kconv::BINARY
+    end
+
+    $KCODE_TECSGEN = "UTF8"      # string: "EUC"  ãã®ãã¡ã¤ã«ã®æå­ã³ã¼ãï¼ãªãã·ã§ã³ã§ã¯ãªãå®æ°ï¼
+    $KCONV_TECSGEN = Kconv::UTF8 # const: 
+    set_kcode $KCODE_TECSGEN     # ãã®ãã¡ã¤ã«ã®æå­ã³ã¼ããè¨­å®
+  end
+
+  #=== ä¸æçã« KCODE ã BINARY ã«å¤æ´ãã
+  # EUC ã UTF8 ã§èª­ã¿è¾¼ãã å ´åã«æå­åºåããèª¤ãåé¡ã®å¯¾å¿
+  # ã³ã¡ã³ãã®èª­ã¿é£ã°ããèª¤ãç¹ãåé¡
+  # ãã ããSJIS ã®å ´åã¯ãã¨ã¹ã±ã¼ãæå­ã®åé¡ããããããå¤æ´ããªã
+  def self.set_kcode_binary
+
+    #2.0
+    if $b_no_kcode then
+      return
+    end
+
+    $KCODE_BACK = $KCODE
+    if $KCODE != "SJIS" then
+      set_kcode "BINARY"
+    end
+  end
+
+  #=== ä¸æçãªã KCODE ã®å¤æ´ãå
+ã«æ»ã
+  def self.reset_kcode
+    set_kcode $KCODE_BACK
+  end
+
+  #####
+  # $LANG_FILE        è¨èª (C ã¯ en_US ã«å¤æããã)
+  # $LANG_CONSOLE     è¨èª (C ã¯ en_US ã«å¤æããã)
+  # $CHARSET_FILE     ãã¡ã¤ã«ã®æå­ã³ã¼ã
+  # $CHARSET_CONSOLE  ã³ã³ã½ã¼ã«æå­ã³ã¼ã
+
+  # ããã©ã«ãã®è¨­å®ï¼æ­£è¦åæ¸ã¿ã®ãã¨ï¼
+  $LANG_FILE_DEFAULT  = :en_US
+  $CHARSET_FILE_DEFAULT = nil
+  $LANG_CONSOLE_DEFAULT = :en_US
+  $CHARSET_CONSOLE_DEFAULT = nil
+
+  $LANG_FILE = $LANG_FILE_DEFAULT
+  $CHARSET_FILE = $CHARSET_FILE_DEFAULT
+  $LANG_CONSOLE = $LANG_CONSOLE_DEFAULT
+  $CHARSET_CONSOLE = $CHARSET_CONSOLE_DEFAULT
+
+  # -k ã§æå®å¯è½ãªã³ã¼ã
+  $CODE_TYPE_ARRAY = [ "euc", "sjis", "none", "utf8" ]
+
+  # è¨èªãæ±ºå®ãã
+  self.set_lang_var
+
+  # è¨èªãã³ã¼ãã®ãã§ãã¯ã¨æ­£è¦å
+  lang_file, charset_file, res =
+    self.resolve_alias_and_check( $LANG_FILE, $CHARSET_FILE )
+  if res == false then
+    # lang_file, charset_file = lang_file_default, charset_file_default
+    lang_file, charset_file = $LANG_FILE_DEFAULT, $CHARSET_FILE_DEFAULT
+  end
+  lang_console, charset_console, res =
+    self.resolve_alias_and_check( $LANG_CONSOLE, $CHARSET_CONSOLE )
+  if res == false then
+    # lang_console, charset_console = lang_console_default, charset_console_default
+    lang_console, charset_console = $LANG_CONSOLE_DEFAULT, $CHARSET_CONSOLE_DEFAULT
+  end
+
+  # ã¡ãã»ã¼ã¸ã¢ã¸ã¥ã¼ã«ãã­ã¼ã
+  if require_tecsgen_lib( "tecslib/messages/messages_console_#{lang_console}.rb", false ) == false then
+    require_tecsgen_lib( "tecslib/messages/messages_console_#{$LANG_CONSOLE_DEFAULT}.rb" )
+    $LANG_CONSOLE, $CHARSET_CONSOLE = $LANG_CONSOLE_DEFAULT, $CHARSET_CONSOLE_DEFAULT
+  else
+    $LANG_CONSOLE, $CHARSET_CONSOLE = lang_console, charset_console
+  end
+  if require_tecsgen_lib( "tecslib/messages/messages_file_#{lang_file}.rb", false ) == false then
+    require_tecsgen_lib( "tecslib/messages/messages_file_#{$LANG_FILE_DEFAULT}.rb" )
+    $LANG_FILE, $CHARSET_FILE = $LANG_FILE_DEFAULT, $CHARSET_FILE_DEFAULT
+  else
+    $LANG_FILE, $CHARSET_FILE = lang_file, charset_file
+  end
+
+  # Kconv ã¯ã©ã¹ã®ããã®å¤æ°ãè¨­å®
+  self.set_kconv_var 
+
+  dbgPrint "LANG_FILE=#{$LANG_FILE}.#{$CHARSET_FILE}, LANG_CONSOLE=#{$LANG_CONSOLE}.#{$CHARSET_CONSOLE}\n"
+  dbgPrint "KCODE_CDL=#{$KCODE_CDL}(#{$KCONV_CDL}) KCODE_CONSOLE=#{$KCODE_CONSOLE}(#{$KCONV_CONSOLE})\n"
+  dbgPrint "Ruby19_File_Encode=#{$Ruby19_File_Encode}\n"
+
+  #=== åä½ãã¹ãå®è¡
+  if $unit_test then
+    print "unit test: set_lang_var\n"
+    require "kconv"
+    self.set_lang_var
+    print "#{$LANG_FILE} #{$LANG_CONSOLE}\n"
+    print "#{$CHARSET_FILE} #{$CHARSET_CONSOLE}\n"
+
+    $LANG_FILE, $CHARSET_FILE, res = self.resolve_alias_and_check( $LANG_FILE, $CHARSET_FILE )
+    print "#{$LANG_FILE} #{$CHARSET_FILE}, #{res}\n"
+  end
+end
+
+#= Console ã¯ã©ã¹
+# æå­ã³ã¼ããå¤æãã
+class Console
+  def self.print str
+    if $b_no_kcode && $KCONV_CONSOLE == Kconv::BINARY then 
+      STDOUT.print str
+    else
+      STDOUT.print str.kconv( $KCONV_CONSOLE, $KCONV_TECSGEN )
+    end
+  end
+  def self.puts str
+    if $b_no_kcode && $KCONV_CONSOLE == Kconv::BINARY then 
+      STDOUT.puts str
+    else
+      STDOUT.puts str.kconv( $KCONV_CONSOLE, $KCONV_TECSGEN )
+    end
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecsgen.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecsgen.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/tecsgen.rb	(revision 317)
@@ -0,0 +1,461 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecsgen.rb 2389 2016-01-04 07:40:32Z okuma-top $
+#++
+
+
+class TECSGEN
+
+  #=== import ãã¹ (-I) ãæ«å°¾ã«è¿½å 
+  # æ¢ã«ç»é²æ¸ã¿ã§ããã°ãè¿½å ããªã
+  def self.add_import_path path
+    if $import_path.index( path ) == nil then
+      dbgPrint "add_import_path: '#{path}'\n"
+      $import_path << path
+    end
+  end
+
+  #=== EXEB çã®ãã¹ã®èª¿æ´
+  # ç°å¢å¤æ° TECSPATH ã cygwin ã¹ã¿ã¤ã«ã ã¨ãexerb çã§ã¯æ±ããªã
+  # $import_path ã¨ $TECSPATH ãèª¿æ´ãã
+  def self.adjust_exerb_path
+    if $IN_EXERB then
+      new_tecspath = cygpath( $tecspath, $tecspath )
+      pattern = /\A#{$tecspath}/
+      paths = []
+      $import_path.each{ |path|
+        # cygpath ã¯ '..' ãç°¡ç´ãã¦ãã¾ãã®ã§ãnew_tecspath ã§ç½®æãã
+        # paths << cygpath( path, path )
+        paths << path.sub( pattern, new_tecspath )
+      }
+      $import_path = paths
+      $tecspath = new_tecspath
+    else
+      return
+    end
+  end
+
+  #=== $(TECSPATH) ã¸ã®ç½®æ
+  #path::String   : ENV[ 'TECSPATH' ] ã«ä¸è´ããé¨åãããã°ã "$(TECSPATH)" ã«ç½®æ
+  #b_global::Bool : true ãªã gsub ã§ç½®æãfalse ãªã sub ã§ç½®æ
+  def self.subst_tecspath( path, b_global = false )
+    tp = $tecspath.dup
+    tp.gsub!( /\\/, "\\\\\\\\" )
+    pattern = /#{tp}/
+      substr = "$(TECSPATH)"
+    if b_global then
+      str =  path.gsub( pattern, substr )
+    else
+      str = path.sub( pattern, substr )
+    end
+    dbgPrint "subst_tecspath #{path}, #{str}\n"
+    return str
+  end
+
+  #=== path ã¯çµ¶å¯¾ãã¹ã?
+  #path:: String   :
+  # '/' ã¾ãã¯ '$' ã§å§ã¾ãå ´åãçµ¶å¯¾ãã¹ã¨å¤å®ãã
+  def self.is_absolute_path?( path )
+    pa = path[0..0]; pa2 = path[0..1]
+    if pa == '/' || pa == '$' || pa2 =~ /[A-Za-z]:/ then
+      res = true
+    else
+      res = false
+    end
+    dbgPrint "is_absolute( #{path} ) = #{res}  #{path[0]}\n"
+    return res
+  end
+
+  #=== tecsgen ã®ããã©ã«ããè¨­å®
+  def self.set_default_config
+    Makefile::set_default_config
+  end
+
+  ###
+  #== Makefile.templ ã®åºåå
+å®¹ãè¿½å ãå¤æ´ããããã®æä½
+  module Makefile
+    # åºå®ããã¦ããå¤æ°(add_var ã§å¤æ´ã§ããªã)
+    @@fixed_vars = { :INCLUDES => nil, :DEFINES => nil, :TARGET_BASE => nil, :BASE_DIR => nil }
+    @@config_mode = false
+
+    @@vars = { }
+    @@vars_default = { }
+    @@var_comments = { }
+
+    @@objs = []
+    @@ldflags = ""
+    @@search_path = []
+    @@pre_tecsgen_target = []
+    @@post_tecsgen_target = []
+    @@lines = []
+
+    #=== OTHER_OBJS ã«è¿½å ãã
+    def self.add_obj obj
+      @@objs << obj
+    end
+    #=== è¿½å ããå¤æ°
+    # ãã©ã°ã¤ã³ããã¯ãããã©ã«ãå¤ãå¤æ´ã§ãã
+    # config ã«ãã
+    def self.add_var( var, val, comment = nil )
+      if @@fixed_vars[ var ]
+        raise "fixed var '#{var}' cannot be changed"
+      end
+      if @@config_mode then
+        @@vars_default[ var.to_sym ] = val
+        @@var_comments_default[ var.to_sym ] = comment
+      else
+        @@vars[ var.to_sym ] = val
+        @@var_comments[ var.to_sym ] = comment
+      end
+    end
+    #=== LDFLAGS ã«è¿½å ãã
+    def self.add_ldflag ldflag
+      @@ldflags += " " + ldflag
+    end
+    #=== ãµã¼ããã¹ãè¿½å ãã
+    # CFLAGS, vpath ã«è¿½å ãã
+    def self.add_search_path path
+      @@search_path << path
+    end
+    #=== PRE_TECSGEN_TARGET ã«è¿½å ãã
+    # PRE_TECSGEN_TARGET ã« target ãè¿½å ãã
+    def self.add_pre_tecsgen_target target
+      @@pre_tecsgen_target << pre_tecsgen_target
+    end
+    #=== POST_TECSGEN_TARGET ã«è¿½å ãã
+    # POST_TECSGEN_TARGET ã« target ãè¿½å ãã
+    def self.add_post_tecsgen_target target
+      @@post_tecsgen_target << pre_tecsgen_target
+    end
+    #=== è¿½å ããå¤æ°
+    def self.add_line( line )
+      @@lines << line.to_s + "\n"
+    end
+
+    def self.get_objs  # Array ãè¿ã
+      return @@objs.uniq
+    end
+    def self.get_vars  # Array ãè¿ã
+      if RUBY_VERSION >= '1.9' then
+        return (@@vars.keys + @@vars_default.keys).sort.uniq
+      else
+        # V1.8 ã§ã¯ãSymbol ã® sort ãã§ããªãã®ã§ãä¸æ¦ String ã«ç½®æãã
+        return (@@vars.keys + @@vars_default.keys).map{|s| s.to_s }.sort.uniq.map!{|s| s.to_sym }
+      end
+    end
+    def self.get_var_val( var )
+      return @@vars[ var ] ? @@vars[ var ] : @@vars_default[ var ]
+    end
+    def self.get_var_comment( var )
+      return @@var_comments[ var ]
+    end
+    def self.get_ldflags  # String ãè¿ã
+      return @@ldflags
+    end
+    def self.get_search_path  # Array ãè¿ã
+      return @@search_path.uniq
+    end
+    def self.get_pre_tecsgen_target  # Array ãè¿ã
+      return @@pre_tecsgen_target.uniq
+    end
+    def self.get_post_tecsgen_target  # Array ãè¿ã
+      return @@post_tecsgen_target.uniq
+    end
+    def self.get_lines  # ä»å ããè¡ãå¾ã
+      return @@lines.uniq
+    end
+
+    #=== TECSGEN ã®ããã©ã«ãè¨­å®ãè¡ã
+    # Makefile 
+    # @@fixed_vars ã§å®ç¾©ããã¦ããå¤æ°ã¯ãå¤æ´ã§ãããå®æ°å®ç¾©ããã¦ãã
+    def self.set_default_config
+      add_var( "TARGET", "$(TARGET_BASE).exe", "default target name"  )
+      add_var( "TECSGEN", "tecsgen", "default TECS generator"  )
+      add_var( "TIMESTAMP", "$(GEN_DIR)/tecsgen.timestamp", "Time Stamp"  )
+      add_var( "CC", "gcc", "default C Compiler"  )
+      add_var( "CFLAGS", '$(INCLUDES) $(DEFINES) -D  "Inline=static inline"', "default C Compiler options"  )
+      add_var( "LD", "gcc", "default Liknker"  )
+      add_var( "LDFLAGS", @@ldflags, "default Liknker Options"  )
+      add_var( "SRC_DIR", "$(BASE_DIR)/src", "default source directory" )
+      add_var( "_TECS_OBJ_DIR", "$(GEN_DIR)/", "default relocatable object (.o) directory" )
+    end
+  end
+
+  #------ TECSGEN CDL analyze and generate ------#
+
+  def syntax_analisys argv
+    # ã«ã¼ã namespace (region) ãçæ
+    @root_namespace = Region.new("::")
+
+    ####  æ§æè§£æ (post ã³ã¼ããé¤ã) ####
+    # ãã¹ã¦ã® cdl ã import ãã
+    argv.each{ |f|
+      dbgPrint( "## Import: #{f}\n")
+      Import.new( f, false, false )
+    }
+
+    # ãã¹ã¦ã®æ§æè§£éãå®äºãããã¨ã®å ±å
+    #   å®éã«ã¯ãå¾ãããã©ã°ã¤ã³ã®çæãã CDL ã®ãã¼ã¹ãè¡ããã
+    #   ã¨ã©ã¼è¡æ°ã®æ±ºå®æ¹æ³ã®å¤æ´ã®ããã«è¡ã
+    Generator.end_all_parse
+    dbgPrint( "## End all parse (except Post Code)\n")
+  end # syntax_analisys
+
+  def semantics_analisys_1
+    ####  æå³è§£æï¼ (post ã³ã¼ããé¤ã) ####
+    dbgPrint( "## Creating reverse join \n")
+    Cell.create_reverse_join
+
+    #0 set_definition_join ã¯2åå¼ã³åºãããï¼1åç®ï¼
+    dbgPrint( "## Checking all join\n")
+    @root_namespace.set_definition_join
+    # @root_namespace.set_require_join                   ### ãã£ããè¦åãããéè¤ã¨ã©ã¼ãè¦éã
+    # through ãã©ã°ã¤ã³ã§çæãããã»ã«ã«ã require ãçæã§ãã (set_definition_join ã®å¾ãã§å®æ½)
+
+    ####  post ã³ã¼ãã®çæã¨æ§æè§£æ ####
+    # å¼æ°ããªããã°ããã©ã°ã¤ã³ã®ãã¹ãã³ã¼ããåºåããªã
+    if ARGV.length > 0 then
+      dbgPrint( "## Generating Post Code\n")
+      # ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãã®åºåã¨ import
+      tmp_file_name = "#{$gen}/tmp_plugin_post_code.cdl"
+      file = nil
+      begin
+        file = CFile.open( tmp_file_name, "w" )
+      rescue
+        Generator.error( "G9999 fail to create #{tmp_file_name}" )
+      end
+
+      if file then
+        # through ãã©ã°ã¤ã³ã®ãã¹ãã³ã¼ãçæ
+        PluginModule.gen_plugin_post_code file
+
+        begin
+          file.close
+        rescue
+          Generator.error( "G9999 fail to close #{tmp_file_name}" )
+        end
+        dbgPrint( "## Import Post Code\n")
+        Import.new( "#{tmp_file_name}" )
+      end
+    end
+
+    ####  æå³è§£æï¼ (post ã³ã¼ã) ####
+    dbgPrint( "## Creating reverse join (for post code) \n")
+    Cell.create_reverse_join
+
+    # Join ã®å®ç¾©ã®è¨­å®ã¨ãã§ãã¯
+    #0 # åæ¹åç
+§å¯¾å¿
+    #0 set_definition_join ã¯2åå¼ã³åºãããï¼2åç®ï¼  post_code ã§çæããã
+    dbgPrint( "## Checking all join (for cells generated by Post Code\n")
+    @root_namespace.set_definition_join
+
+    dbgPrint( "## Set require join\n")
+    @root_namespace.set_require_join   # mikan post ã®åã«ã
+    # ãã¹ãã³ã¼ãã§çæãããã»ã«ã® require ã®join ãçæ
+    # mikan require ã§ through ãé©ç¨ããã¦ããã¹ãã³ã¼ããå¿
+è¦ã¨ãªã£ã¦ãåºåãããªã
+  end # semantics_analisys_1
+
+  def semantics_analisys_2
+    ####  æå³è§£æï¼ ####
+    Cell.make_cell_list2
+    dbgPrint( "## Set fixed join\n")
+    Cell.create_reverse_require_join
+    # create_reverse_require_join ã¯ set_detinition_join ã«åãè¾¼ããã¨ãã§ããªã
+        # namespace ã«ä¾å­ããªãåºç¾é ã§è¡ã
+        # mikan through ãã©ã°ã¤ã³ãé©ç¨ãããã¹ãã³ã¼ãã«å½±é¿ãä¸ããå ´åãèæ
+®ã§ãã¦ããªã
+        # mikan post code ã«å½±é¿ã®ãããã®ã§ããã°ãæ©ãã« reverse_require_join ã®çµåãå¿
+è¦
+    dbgPrint( "## Setting port reference count\n")
+    @root_namespace.set_port_reference_count
+
+    dbgPrint( "## Checking all join\n")
+    @root_namespace.check_join
+
+    # mikan ãã©ã°ã¤ã³ã§çæãããã³ã³ãã¼ãã³ãã® set_def_and_check_join
+
+    dbgPrint( "## Checking referenced but undefined cell\n")
+    @root_namespace.check_ref_but_undef
+  end  #  semantics_analisys_2
+
+  def optimize_and_generate
+    #### Region link root ãã¨ã«ãªããã£ãã¤ãºããã³çæ ####
+    Region.get_link_roots.each { |region|
+
+      n_cells = region.get_n_cells
+
+      dbgPrint "#{region.get_name} has #{n_cells} cells\n"
+      if $verbose
+        print "=====================================\n"
+        print "=== Region.path_str: #{region.get_namespace_path.get_path_str}\n"
+        print "=====================================\n"
+      else
+        dbgPrint "Region.path_str: #{region.get_namespace_path.get_path_str}\n"
+      end
+
+      if $region_list.length > 0 then
+        if $region_list[ region.get_namespace_path.get_path_str ] then
+          $region_list[ region.get_namespace_path.get_path_str ] = false
+        else
+          next
+        end
+      end
+
+      # ã»ã«ãä¸ã¤ããªããã°çæããªã
+      # ã»ã«ã®çæããªãå ´å
+      if region.get_n_cells == 0 then
+        if $region_list.length > 0 then
+          Generator.warning( "W9999 $1: specified to generate but has no cell", region.get_name )
+        end
+        if region != @root_namespace then
+          next
+        end
+      end
+
+      $generating_region = region
+      if Region.get_link_roots.length > 1 then
+        if region.get_name == "::" then
+          $gen = $gen_base
+        else
+          $gen = $gen_base + "/" + region.get_global_name.to_s
+          begin
+            if ! File.directory?( $gen ) then
+              Dir.mkdir( $gen )
+            end
+          rescue
+            print( "Cannot mkdir #{$gen}\n" )
+            exit 1
+          end
+        end
+      else
+        $gen = $gen_base
+      end
+
+      dbgPrint( "## Unset optimize variables\n")
+      @root_namespace.reset_optimize   # æé©åããªã»ãããã
+
+      if Generator.get_n_error == 0 then
+        # ã¨ã©ã¼ãçºçãã¦ããããè¨­å®ããªã
+        dbgPrint( "## Set cell id\n")
+        @root_namespace.set_cell_id_and_domain      # ã»ã«ã® ID ã¨ãã¡ã¤ã³æ
+å ±ãè¨­å®ï¼linkunit æ¯ã«0ããã¤ããï¼
+
+        # ã¨ã©ã¼ãçºçãã¦ããããæé©åã¯å®æ½ããªã
+        if ! $unopt then
+          dbgPrint( "## Optimizing: Link Region=#{@root_namespace.get_name}\n")
+          @root_namespace.optimize
+        end
+      end
+
+      if $show_tree then
+        # ã¨ã©ã¼ãçºçãã¦ãã¦ãè¡¨ç¤ºï¼ã¨ã©ã¼çºçæã¯æé©åããã¦ããªãã®ã§æ³¨æï¼
+        print "##### show_tree LinkRegion=#{region.get_name} #####\n"
+        @root_namespace.show_tree(0)
+        print "##### END       LinkRegion=#{region.get_name} #####\n\n"
+      end
+
+      # æ§æè§£éãæå³è§£æã§ã¨ã©ã¼çºçãã¦ããããã³ã¼ãçæãããªã
+      if Generator.get_n_error != 0 then
+        print_report
+        exit 1
+      end
+
+      #### ã³ã¼ãçæ ####
+      begin
+        dbgPrint( "## Generating: Link Region=#{@root_namespace.get_name}\n")
+        @root_namespace.generate
+        dbgPrint( "## Generating Post: Link Region=#{@root_namespace.get_name}\n")
+        @root_namespace.generate_post
+      rescue
+        # éå¸¸ããã¸ã¯æ¥ãªã (generate, generate_post ã§å¦ç½®ããã)
+        Generator.error( "G9999 fail to generate" )
+      end
+    }
+  end # optimize_and_generate
+
+  def finalize
+    dbgPrint( "## Generating XML\n")
+    # Region.gen_xml @root_namespace
+    ## 
+    # Namespace.gen_XML  @root_namespace
+
+    $region_list.each{ |region_path_str, val|
+      if val == true then
+        Generator.warning( "W9999 $1: not link root, -G ignored", region_path_str )
+      end
+    }
+
+    # update ãã
+    # APPFile ã§çæããããã¡ã¤ã«ã¯ãããå¤åãããã°ãããã§æ´æ°ãã
+    # ã³ã¼ãçææ®µéã§ã¨ã©ã¼ãçºçããã°ãæ´æ°ããªã
+    # CFile ã§çæããããã®ã¯ãæ´æ°ããã¦ãã
+    if Generator.get_n_error == 0 then
+      begin
+        AppFile.update
+      rescue => evar
+        Generator.error( "G9999 Fail to update. (error occurred while renaming generated files)" )
+        print_exception( evar )
+      end
+    end
+
+    print_report
+    if Generator.get_n_error != 0 then
+      STDERR.print "error occurred while generating. some file can be corrupt in #{$gen_base}\n"
+      exit 1
+    end
+
+    open( "#{$gen_base}/tecsgen.timestamp", "w" ){|io|}
+  end # finalize
+end # class TECSGEN
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/types.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/types.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/types.rb	(revision 317)
@@ -0,0 +1,1654 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#
+#   Copyright (C) 2008-2015 by TOPPERS Project
+#--  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: types.rb 2296 2015-11-29 11:57:33Z okuma-top $
+#++
+
+#= HasType: @type ãå
+é¨ã«æã¤åã®ããã®ã¢ã¸ã¥ã¼ã«
+#  @b_cloned::Bool  : true if @type is cloned
+#
+# ãã®ã¢ã¸ã¥ã¼ã«ã¯ DefinedType, PtrType, ArrayType ã« include ããã
+# æ¬å½ã¯ typedef ãããæã® Decl ã®è¦ç´ ã®ã¿ clone ããã°ããã®ã ããget_type, get_original_type ã§
+# åãåºãããã¨ããset_scs, set_qualifier ãããã¨ãã«ç¡æ¡ä»¶ã§ clone ãã (ç¡é§ã«ã¡ã¢ãªãä½¿ç¨ãã)
+# ãã ããclone ããã®ã¯ä¸åã®ã¿ã§ãã (äºå clone ããã¨å¥ã®åãåç
+§ãã¦ãã¾ã)
+#
+# initialize ã§ clone ãã¦ããå
+±æããã¦ããã¨ãã« clone ãããªã
+#
+module HasType
+  def initHasType
+    @b_cloned = false
+  end
+
+  #=== HasType# @type ãã¯ã­ã¼ã³ãã
+  def clone_type
+#    if @b_cloned == false then
+      @type = @type.clone
+      @b_cloned = true
+#    end
+  end
+end
+
+class Type < Node
+# @b_const    : bool
+# @b_volatile : bool
+
+  def initialize
+    super
+  end
+
+  def set_qualifier( qualifier )
+    case qualifier
+    when :CONST
+#      if @b_const then
+#        cdl_error( "T1001 const duplicate"  )
+#      end
+      @b_const = true
+    when :VOLATILE
+#      if @b_volatile then
+#        cdl_error( "T1002 volatile duplicate"  )
+#      end
+      @b_volatile = true
+    else
+      raise "Unknown qualifier #{qualifier}"
+    end
+  end
+
+  def is_const?
+    if @b_const then
+      return true
+    else
+      return false
+    end
+  end
+
+  def is_volatile?
+    if @b_volatile then
+      return true
+    else
+      return false
+    end
+  end
+
+  def is_void?
+    if self.kind_of? DefinedType then
+      return @type.is_void?
+    elsif self.kind_of? VoidType then
+      return true
+    else
+      return false
+    end
+  end
+
+  #=== size_is, count_is, string ãè¨­å®
+  # æ´¾çã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ãããï¼ããã©ã«ãã§ã¯ã¨ã©ã¼ï¼
+  def set_scs( size, count, string, max = nil, b_nullable = false )
+    str = ""
+    delim = ""
+    if size then
+      str = "size_is"
+      delim = ", "
+    end
+    if count then
+      str = "#{str}#{delim}count_is"
+      delim = ", "
+    end
+    if string then
+      str = "#{str}#{delim}string"
+      delim = ", "
+    end
+    if b_nullable then
+      str = "#{str}#{delim}nullable"
+      delim = ", "
+    end
+    cdl_error( "T1003 $1: unsuitable specifier for $2" , str, self.class )
+  end
+
+  def clear_max
+    raise "clear_max called: #{self.class}"
+  end
+
+  def get_type_str
+    str = ""
+    if @b_const then
+      str = "#{str}const "
+    end
+    if @b_volatile then
+      str = "#{str}volatile "
+    end
+    return str
+  end
+
+  #=== åããã§ãã¯
+  #    æ­£å½ãªåå®ç¾©ãã©ããããã§ãã¯ãã
+  def check
+    # åã«èª¤ããããã°ãã¨ã©ã¼æå­åãè¿ã
+  end
+
+  #=== struct ã® tag ããã§ãã¯
+  #    æ­£å½ãªåå®ç¾©ãã©ããããã§ãã¯ãã
+  #kind:: Decl ã® @kind ãåç
+§
+  def check_struct_tag kind
+    # tag ãå­å¨ããªããã°ã¨ã©ã¼ãåºåãã
+    # é
+ååã§ã¯ãè¦ç´ ã®åãåå¸°çã«ãã§ãã¯
+    # ãã¤ã³ã¿åã§ã¯ãæãå
+ã® tag ãã§ãã¯ã¯ããªã
+    # é¢æ°åã§ã¯ãã©ã¡ã¼ã¿ãªã¹ãã®ãã¹ã¦ã«ã¤ãã¦è¡ã
+  end
+
+  #===  åæåå¯è½ããã§ãã¯
+  #     attribute ãªã©åæåå¯è½ããã§ãã¯ããï¼åã«å¯¾ãæ­£å½ãªåæåå­ãä¸ãããã¦ãããï¼
+  #ident::        string                è¢«ä»£å
+¥å¤æ°å½
+  #initialize::   Expression, Array of initializer or C_EXP
+  #               ä»£å
+¥å¤ãC_EXP ãä¸ããããã®ã¯ IntType ã®å ´åã®ã¿
+  #kind::         symbol (:ATTRIBUTE, :VAR, :CONSTNAT )
+  #attribute::    NameList              kind == :VAR ã®ã¨ãåç
+§ã§ãã attribute
+  #
+  #     locale ãç¬¬ä¸å¼æ°ã¨ãã¦åãã®ã¯ãä»¥ä¸ã®çç±ã«ããã
+  #     ãã®ã¡ã½ããã¯ãå¤æ°ã¸ã®ä»£å
+¥ãè¡ããããè¡ãã«å¯¾ãã¦å¼ã³åºããããã
+  #     Type ã¯ã©ã¹ã®ã¤ã³ã¹ã¿ã³ã¹ã¯ãå¤æ°ãå®ç¾©ããããè¡ããè¨æ¶ãã¦ããã
+  #
+  # STAGE: S
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    #
+  end
+
+  #=== const_val ãæå®ã®åã«ã­ã£ã¹ããã
+  # æ´¾çã¯ã©ã¹ã§ãªã¼ãã¼ã©ã¤ããã¦ããªãã¨ã¨ã©ã¼
+  def cast( const_val )
+    cdl_error( "T1004 cannot cast to $1" , self.class )
+  end
+
+  #=== åãä¸è´ãããã®ãã§ãã¯
+  # ååã®å­é¢ã§ãã§ãã¯ï¼
+  # typedef ãããåãå­é¢ã§ä¸è´ãè¦ããããå
+ã®åãåãã§ãååãç°ãªãã°ä¸ä¸è´ã¨ãªã
+  def equal? type2
+    return ( get_type_str == type2.get_type_str ) && ( get_type_str_post == type2.get_type_str_post )
+  end
+
+  #=== bit size ãå¾ã
+  # IntType, FloatType ä»¥å¤ã¯0
+  def get_bit_size
+    return 0
+  end
+
+  #=== å
+ã®åãå¾ã
+  # typedef ãããåã®å ´åããã®å
+ã®åãè¿ã.
+  # ããä»¥å¤ã¯ãèªåèªèº«ãè¿ãï¼
+  # (DefinedType ã§ã¯æ¬ã¡ã½ããããªã¼ãã¼ã©ã¤ãããã)
+  def get_original_type
+    return self
+  end
+
+  #=== å
+é¨ã«ãã¤ã³ã¿åãæã¤
+  # ãã¤ã³ã¿åãã¾ãã¯ãã¤ã³ã¿åã¡ã³ããæã¤æ§é ä½ãã¾ãã¯è¦ç´ ããã¤ã³ã¿åãæã¤é
+å
+  def has_pointer?
+    false
+  end
+
+  #=== size_is, count_is, string æå®ããããã¤ã³ã¿ãæã¤ã
+  # size_is, count_is, string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ããããè¦ç´ ã«æã¤é
+å
+  def has_sized_pointer?
+    false
+  end
+  
+  #=== é·ãæå®ã®ãªã string ãæã¤
+  # ãªãæå®ã®ãªã string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ãããè¦ç´ ã«æã¤é
+å
+  def has_unsized_string?
+    false
+  end
+
+  def show_tree indent
+    indent.times { print "  " }
+    puts "const=#{@b_const} volatile=#{@b_volatile} #{locale_str}"
+    indent.times { print "  " }
+    puts "has_pointer=#{has_pointer?} has_sized_pointer=#{has_sized_pointer?} has_unsized_string=#{has_unsized_string?}"
+  end
+end
+
+class DefinedType < Type
+#  @type_name::string
+#  @typedef::Typedef
+#  @type:: kind_of Type
+
+  include HasType
+
+  def initialize( type_name )
+    super()
+    @type_name = type_name
+
+    # mikan type_name ã path ã«ãªã£ã¦ããªãããæ«å®
+    @typedef = Namespace.find( [ type_name ] )  #1
+
+#    if @type.class != Typedef then
+#      raise NotTypedef
+    #    end
+    if @typedef == nil then
+      cdl_error( "T1005 \'$1\' not defined" , type_name )
+    elsif @typedef.class != Typedef then
+      cdl_error( "T1006 \'$1\' not type name. expecting type name here" , type_name )
+    end
+    @type = @typedef.get_declarator.get_type
+    initHasType
+  end
+
+  def get_type
+    clone_type
+    return @type
+  end
+
+  def get_type_str
+    "#{super}#{@type_name}"
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def get_size
+    return @type.get_size
+  end
+
+  def is_nullable?
+    return @type.is_nullable?
+  end
+
+  #=== qualifier(const, volatile) ã®è¨­å®
+  def set_qualifier( qualifier )
+    clone_type
+    @type.set_qualifier( qualifier )
+    super
+  end
+
+  def set_scs( size, count, string, max = nil, b_nullable = false )
+    clone_type
+    @type.set_scs( size, count, string, max, b_nullable )
+  end
+
+  def clear_max
+    @type.clear_max
+  end
+
+  def get_original_type
+    clone_type
+    return @type.get_original_type
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil    # typedef ã®æ®µéã§æå³ãã§ãã¯ããã¦ãã
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    get_type.check_init( locale, ident, initializer, kind, attribute )
+  end
+
+  #=== å
+é¨ã«ãã¤ã³ã¿åãæã¤
+  # ãã¤ã³ã¿åãã¾ãã¯ãã¤ã³ã¿åã¡ã³ããæã¤æ§é ä½ãã¾ãã¯è¦ç´ ããã¤ã³ã¿åãæã¤é
+å
+  def has_pointer?
+    @type.has_pointer?
+  end
+
+  #=== size_is, count_is, string æå®ããããã¤ã³ã¿ãæã¤ã
+  # size_is, count_is, string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ããããè¦ç´ ã«æã¤é
+å
+  def has_sized_pointer?
+    @type.has_sized_pointer?
+  end
+  
+  #=== é·ãæå®ã®ãªã string ãæã¤
+  # ãªãæå®ã®ãªã string æå®ããããã¤ã³ã¿åãã¾ãã¯ãããã¡ã³ãã«æã¤æ§é ä½ãã¾ãã¯ãããè¦ç´ ã«æã¤é
+å
+  def has_unsized_string?
+    @type.has_unsized_string?
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    if @typedef == nil then
+      puts "DefinedType: #{@type_name} is missing, const=#{@b_const} volatile=#{@b_volatile} #{locale_str}"
+    else
+      puts "DefinedType: #{@type_name}, const=#{@b_const} volatile=#{@b_volatile}"
+    end
+    super( indent + 1 )
+    @typedef.show_tree( indent + 1 )
+    @type.show_tree( indent + 1 )
+  end
+end
+
+class VoidType < Type
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    cdl_error2( locale, "T1007 $1: void type variable cannot have initializer" , ident )
+  end
+
+  def get_type_str
+    "#{super}void"
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "VoidType #{locale_str}"
+    super( indent + 1 )
+  end
+end
+
+class BoolType < Type
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil
+  end
+
+  def get_type_str
+    "#{super}bool_t"
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "BoolType #{locale_str}"
+    super( indent + 1 )
+  end
+end
+
+class IntType < Type
+#  @bit_size::		-11: char, -1: char_t, -2: short, -3: int, -4: long, -5: long long
+#			8, 16, 32, 64, 128
+#  @sign::		:SIGNED, :UNSIGNED, nil
+
+  def initialize( bit_size )
+    super()
+    @bit_size = bit_size
+    @sign = nil
+  end
+
+  def set_sign( sign, b_uint = false )
+    if @sign then
+      if @sign != sign then
+        cdl_error( "T1008 ambigous signed or unsigned"   )
+      end
+    elsif b_uint == false && @bit_size > 0 then
+      if sign == :SIGNED then
+        cdl_warning( "W2001 signed int$1_t: obsolete. use int$2_t" , @bit_size, @bit_size )
+      else
+        cdl_warning( "W2002 unsinged int$1_t: obsolete. use uint$2_t" , @bit_size, @bit_size )
+      end
+    end
+
+    @sign = sign
+
+    if @sign != :SIGNED && @sign != :UNSIGNED then
+      raise "set_sign: unknown sign: #{@sign}"
+    end
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    val = initializer  # C_EXP, Array
+    if val.instance_of?( Expression ) then
+      val = val.eval_const2( nil, attribute )
+      # è©ä¾¡ã®çµæ C_EXP ã Array ã¨ãªãå¯è½æ§ããã
+    end
+
+    if val.instance_of? Token then    # StringVal å°å
+¥ã«ããããã¯ã Token ã¯æ¥ãªãã¯ã
+      # val ã Token ã®å ´å == ã®å³è¾ºã String ã ã¨ã¨ã©ã¼ãèµ·ãã (#198)
+      cdl_error2( locale, "T1009 $1: $2: not integer" , ident, val )
+      return
+    elsif val.is_a? C_EXP then
+      # #192 var ã attribute ãåç
+§ããattribute ã®å³è¾ºã C_EXP ã®å ´å
+      # const ã®å³è¾ºã C_EXP ã®å ´åã
+      return
+    elsif val.kind_of? FloatVal then
+      cdl_error2( locale, "T1011 $1: need cast to assign float to integer" , ident )
+      return
+    elsif val.instance_of? Array then
+      cdl_error2( locale, "T1017 $1: unsuitable initializer for scalar type" , ident )
+      return
+    elsif val == nil then
+      cdl_error2( locale, "T1010 $1: initializer is not constant" , ident )
+      return
+    end
+
+    if ! val.kind_of? IntegerVal then
+      cdl_error2( locale, "T1012 $1: $2: not integer" , ident, val )
+      return
+    end
+
+    val = val.to_i
+    max = get_max
+    min = get_min
+    dbgPrint "sign=#{@sign} ident=#{ident} val=#{val} max=#{max} min=#{min}\n"
+
+    if max != nil then
+      if val > max then
+        if @sign == :SIGNED || @sign == nil then
+          cdl_error2( locale, "T1013 $1: too large (max=$2)" , ident, max )
+        else
+          cdl_error2( locale, "T1016 $1: too large (max=$2)" , ident, max )
+        end
+      end
+    end
+
+    if min != nil then
+      if val < min
+        if @sign == :SIGNED || @sign == nil then
+          cdl_error2( locale, "T1014 $1: too large negative value (min=$2)" , ident, min )
+        else
+          cdl_error2( locale, "T1015 $1: negative value for unsigned" , ident )
+        end
+      end
+    end
+  end
+
+  #=== IntType# æå¤§å¤ãæå°å¤ããã§ãã¯ãã¦ã¯ãªãããã
+  # ã­ã£ã¹ãæ¼ç®ãè¡ã
+  #in_val:: IntegerVal, FloatVal:  ãã®åã«ã­ã£ã¹ãããå¤
+  #from_type:: Symbol:  :IntType, :FloatType  IntType ã®å ´åã¯ãããæ°ã§ã¯ãªãããFloatType ã®å ´åã¯æå¤§å¤ã§ã¯ãªãã
+  def check_and_clip( in_val, from_type = :IntType )
+    bit_size = get_bit_size
+    if bit_size == -1 then
+      bit_size = 8
+    end
+    val = in_val.to_i
+    if get_max && val > get_max then
+      if from_type == :IntType then
+        rval = ((1 << bit_size)-1) & val   # bit æ°ã§ã¯ãªãã
+      else
+        rval = get_max                         # æå¤§å¤ã§ã¯ãªãã (FloatType)
+      end
+      cdl_warning( "W2003 $1: too large to cast to $2, clipped($3)" , in_val, get_type_str, rval )
+    elsif get_min && val < get_min then
+      if from_type == :IntType then
+        rval = ((1 << bit_size)-1) & val
+      else
+        rval = get_min
+      end
+      if @sign == :SIGNED || @sign == nil then
+        cdl_warning( "W2004 $1: too small to cast to $2, clipped($3)" , in_val, get_type_str, rval )
+      else    # @sign == :UNSIGNED || @sign == nil (char ã®å ´å)
+        cdl_warning( "W2005 $1: negative value for unsigned: convert to $2" , in_val, rval )
+      end
+    else
+      rval = val
+    end
+    return rval
+  end
+
+  def get_min
+    if @sign == :SIGNED || @sign == nil then
+      if @bit_size == -1 then
+        bit_sz = 8   # char_t ã¯ãæç¬¦å·ã«æ±ã
+      else
+        bit_sz = @bit_size
+      end
+      case bit_sz
+      when 8, 16, 32, 64, 128
+        return  - ( 1 << ( bit_sz - 1 ))
+      else # -1, -2, -3, -4, -5, -11
+        return nil
+      end
+    else   # @sign == :UNSIGNED
+      return 0
+    end
+  end
+
+  def get_max
+    if @bit_size == -1 then
+      if @sign == nil then
+        return 255   # char_t ã¯ãç¡ç¬¦å·ã«æ±ã
+      else
+        bit_sz = 8
+      end
+    else
+      bit_sz = @bit_size
+    end
+    if @sign == :SIGNED || @sign == nil then
+      case bit_sz
+      when 8, 16, 32, 64, 128
+        return ( 1 << ( bit_sz - 1 )) -1
+      else # -1, -2, -3, -4, -5, -11
+        return nil
+      end
+    else   # @sign == :UNSIGNED
+      case bit_sz
+      when 8, 16, 32, 64, 128
+        return ( 1 << bit_sz ) - 1
+      else # -2, -3, -4, -5, -11
+        return nil
+      end
+    end
+  end
+
+  #=== IntType# C è¨èªã«ãããååï¼ä¿®é£¾å­ä»ãï¼
+  def get_type_str
+    str = super
+
+    # NEW_MODE
+    case @sign
+    when :SIGNED
+      sign = ""
+      signL = "signed "
+    when :UNSIGNED
+      sign = "u"
+      signL = "unsigned "
+    else
+      sign = ""
+      signL = ""
+    end
+
+    # p "get_type_str: sign:#{@sign} signL=#{signL}"
+
+    case @bit_size
+    when -1      # char_t å
+      if @sign == :SIGNED then
+        sign = "s"
+      end
+      str = "#{str}#{sign}char_t"
+    when -11     # char å(obsolete)
+      str = "#{str}#{signL}char"
+    when -2      # short å
+      str = "#{str}#{signL}short"
+    when -3      # int å
+      str = "#{str}#{signL}int"
+    when -4      # long å
+      str = "#{str}#{signL}long"
+    when -5      # long long å
+      str = "#{str}#{signL}long long"
+    when 8, 16, 32, 64, 128     # int16, int32, int64, int128 å
+      str = "#{str}#{sign}int#{@bit_size}_t"
+    end
+
+    return str
+  end
+
+  #=== IntType# C è¨èªã«ãããååï¼å¾ç½®æå­åï¼
+  def get_type_str_post
+    ""
+  end
+
+  #=== IntType#bit_size ãå¾ã
+  #    è¿ãããå¤ã¯ @bit_size ã®ä»æ§ãåç
+§
+  def get_bit_size
+    return @bit_size
+  end
+
+  #=== IntType# sign ãå¾ã
+  # @sign ã®èª¬æãåç
+§
+  def get_sign
+    @sign
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "IntType bit_size=#{@bit_size} sign=#{@sign} const=#{@b_const} volatile=#{@b_volatile} #{locale_str}"
+    super( indent + 1 )
+  end
+end
+
+class FloatType < Type
+#  @bit_size::         32, 64, (80), -32, -64
+
+  def initialize( bit_size )
+    super()
+    @bit_size = bit_size
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil
+  end
+
+  # mikan Float åã® C_EXP å¯¾å¿ (generate.rb ã«ãå¤æ´å¿
+è¦)
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    # åã«å¯¾ããåæå¤ã«èª¤ããããã°ãã¨ã©ã¼æå­åãè¿ã
+    val = initializer
+    if val.instance_of?( Expression ) then
+      val = val.eval_const2( nil, attribute )
+      # è©ä¾¡ã®çµæ C_EXP ã Array ã¨ãªãå¯è½æ§ããã
+    end
+
+    if val.instance_of? Token then
+      # val ã Token ã®å ´å == ã®å³è¾ºã String ã ã¨ã¨ã©ã¼ãèµ·ãã
+      cdl_error2( locale, "T1018 $1: $2: not number" , ident, val )
+      return
+    elsif val.instance_of? Array then
+      cdl_error2( locale, "T1020 $1: unsuitable initializer for scalar type" , ident )
+      return
+    elsif val.instance_of? C_EXP then
+      return
+    elsif val == nil then
+      cdl_error2( locale, "T1019 $1: initializer is not constant" , ident )
+      return
+    elsif ! val.kind_of?( IntegerVal ) && ! val.kind_of?( FloatVal ) then
+      cdl_error2( locale, "T1037 $1: not number" , ident )
+      return
+    end
+    # else
+    #   cdl_error2( locale, "T1020 $1: unsuitable initializer for scalar type" , ident )
+    #   return
+    # end
+    return
+  end
+
+  def get_type_str
+    str = super
+
+    case @bit_size
+    when 32
+      str = "#{str}float32_t"
+    when 64
+      str = "#{str}double64_t"
+    when -32
+      str = "#{str}float"
+    when -64
+      str = "#{str}double"
+    end
+    return str
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def get_bit_size
+    @bit_size
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "FloatType bit_size=#{@bit_size} qualifier=#{@qualifier} #{locale_str}"
+    super( indent + 1 )
+  end
+end
+
+class EnumType < Type # mikan
+#  @bit_size::		-1: enum
+#			8, 16, 32, 64, 128
+#  @element::		[]
+#  @element_val::	[]
+
+  def initialize( bit_size )
+    super()
+    @bit_size = bit_size
+  end
+
+  def check
+   # mikan enum check
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "EnumType bit_size=#{@bit_size} qualifier=#{@qualifier} #{locale_str}"
+    super( indent + 1 )
+    # mikan element
+  end
+end
+
+class StructType < Type
+#  @tag::
+#  @b_define::  true if define, false if refer
+#  @members_decl:: NamedList
+#  @definition:: StructType
+#  @b_has_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã
+#  @b_has_sized_pointer_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã
+#  @b_has_unsized_string_member:: bool : ã¡ã³ãã«ãã¤ã³ã¿åããã
+#  @member_types_symbol:: Symbol : tag ãç¡ãæã®ã¿è¨­å® (ããä»¥å¤ã§ã¯ nil)
+
+  @@structtype_current_stack = []
+  @@structtype_current_sp = -1
+
+  # tag ãªã struct
+  @@no_struct_tag_num = 0
+  @@no_tag_struct_list = {}
+
+  def initialize( tag = nil )
+    super()
+    @tag = tag
+    @@structtype_current_sp += 1
+    @@structtype_current_stack[@@structtype_current_sp] = self
+    @b_has_pointer_member = false
+    @b_has_sized_pointer_member = false
+    @b_has_unsized_string_member = false
+    @member_types_symbol = nil
+  end
+
+  def self.set_define( b_define )
+    @@structtype_current_stack[@@structtype_current_sp].set_define( b_define )
+  end
+
+  def set_define( b_define )
+    @b_define = b_define
+    if @b_define then
+      @members_decl = NamedList.new( nil, "in struct #{@tag}" )
+      # if @tag then    ç»é²ã¿ã¤ãã³ã°ãçµããã«å¤æ´ V1.0.2.19
+      #  Namespace.new_structtype( self )
+      # end
+    else
+      @definition = Namespace.find_tag( @tag )
+      # check_struct_tag ã«ç§»ã V1.0.2.19
+      # if @definition == nil then
+      #  cdl_error( "T1021 \'$1\': struct not defined" , @tag )
+      # end
+    end
+  end
+
+  def self.new_member( member_decl )
+    @@structtype_current_stack[@@structtype_current_sp].new_member( member_decl )
+  end
+
+  def new_member( member_decl )
+    member_decl.set_owner self   # Decl (StructType)
+    @members_decl.add_item( member_decl )
+    if member_decl.get_type.has_pointer?
+      @b_has_pointer_member = true
+    end
+    if member_decl.get_type.has_sized_pointer?
+      @b_has_sized_pointer_member = true
+    end
+    if member_decl.get_type.has_unsized_string?
+      @b_has_unsized_string_member = true
+    end
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    nil
+  end
+
+  #=== æ§é ä½ã®ã¿ã°ããã§ãã¯
+  #  declarator ã®æç¹ã§ãã§ãã¯ãã
+  #kind:: Decl ã® @kind ãåç
+§
+  def check_struct_tag kind
+    if @tag == nil
+      return
+    end
+
+    st = Namespace.find_tag( @tag )
+    if st == nil then
+      cdl_error( "T1022 struct $1: not defined" , @tag )
+    end
+  end
+
+  # mikan Float åã® C_EXP å¯¾å¿ (generate.rb ã«ãå¤æ´å¿
+è¦)
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+
+    st = Namespace.find_tag( @tag )
+    if st == nil then
+      cdl_error2( locale, "T1023 struct $1: not defined" , @tag )
+      return
+    end
+
+    # åæåå­ãå¼ã®å ´åãåï¼ã¿ã°ï¼ãä¸è´ããããã§ãã¯
+    if initializer.instance_of?( Expression ) then
+      t = initializer.get_type( attribute )
+      # print "Check init #{t.class} #{t.get_name}\n"
+      if ! t.kind_of?( StructType ) then
+        if t then
+          str = t.get_type_str
+        else
+          str = "unknown"
+        end
+        cdl_error2( locale, "T1038 $1: initializer type mismatch. '$2' & '$3'" , ident, get_type_str, str )
+      elsif @tag != t.get_name then
+        cdl_error2( locale, "T1039 $1: struct tag mismatch $2 and $3" , ident, @tag, t.get_name )
+      end
+      initializer = initializer.eval_const( attribute )
+    end
+
+    if initializer.instance_of?( Array ) then
+      i = 0
+      st.get_members_decl.get_items.each { |d|
+        if initializer[i] then
+          d.get_type.check_init( locale, "#{ident}.#{d.get_identifier}", initializer[i], kind )
+        end
+        i += 1
+      }
+    else
+      cdl_error2( locale, "T1024 $1: unsuitable initializer for struct" , ident )
+    end
+  end
+
+  def self.end_of_parse()
+    @@structtype_current_stack[@@structtype_current_sp].end_of_parse
+    @@structtype_current_sp -= 1
+  end
+
+  def end_of_parse()
+    if @members_decl == nil   # @b_define = false ã¾ãã¯ã¡ã³ãã¼ã®ãªãæ§é ä½ï¼ã¨ã©ã¼ï¼
+      return
+    end
+    @members_decl.get_items.each{ |md|
+      size = md.get_size_is
+      if size then
+        val = size.eval_const( @members_decl )
+        if val == nil then
+          type = size.get_type( @members_decl )
+          if ! type.kind_of?( IntType ) then
+            cdl_error( "T1025 size_is argument is not integer type"  )
+          end
+        end
+      end
+      count = md.get_count_is
+      if count then
+        val = count.eval_const( @members_decl )
+        if val == nil then
+          type = count.get_type( @members_decl )
+          if ! type.kind_of?( IntType ) then
+            cdl_error( "T1026 count_is argument is not integer type"  )
+          end
+        end
+      end
+      string = md.get_string
+      if string == -1 then
+        # é·ãæå®ãªã
+      elsif string then
+        val = string.eval_const( @members_decl )
+        if val == nil then
+          type = string.get_type( @members_decl )
+          if ! type.kind_of?( IntType ) then
+            cdl_error( "T1027 string argument is not integer type"  )
+          end
+        end
+      end
+    }
+
+    if @tag == nil then
+      @member_types_symbol = get_member_types_symbol
+      # print "member_types_symbol = #{get_member_types_symbol}\n"
+      if @@no_tag_struct_list[ @member_types_symbol ] then
+        @tag = @@no_tag_struct_list[ @member_types_symbol ]
+      else
+        @tag = :"TAG_#{@@no_struct_tag_num}_TECS_internal__"
+	    @@no_struct_tag_num += 1
+        @@no_tag_struct_list[ @member_types_symbol ] = @tag
+        Namespace.new_structtype( self )
+      end
+    else
+      if @b_define then
+        Namespace.new_structtype( self )
+      end
+    end
+  end
+
+  def get_name
+    @tag
+  end
+
+  def get_type_str      # mikan struct get_type_str
+    str = super
+
+    if @tag then
+      # typedef struct tag StructType; ã®å½¢å¼ã®å ´å
+      # struct ã®æ¬ä½ã¯ãå¥ã«çæããã
+      return "#{str}struct #{@tag} "
+
+    else
+      # typedef struct { int a; } StructType; ã®å½¢å¼ã®å ´å
+      str += "struct {\n"
+      @members_decl.get_items.each{ |i|
+        str += sprintf( "    %-8s %s%s;\n", "#{i.get_type.get_type_str}", "#{i.get_name}", "#{i.get_type.get_type_str_post}" )
+      }
+      str += "} "
+
+      return str
+
+    end
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def get_members_decl
+    return @members_decl if @members_decl
+
+    st = Namespace.find_tag( @tag )
+    if st then
+      return st.get_members_decl
+    end
+
+    return nil
+  end
+
+  def has_pointer?
+    if @definition
+      return @definition.has_pointer?
+    else
+      return @b_has_pointer_member
+    end
+  end
+
+  def has_sized_pointer?
+    if @definition
+      return @definition.has_sized_pointer?
+    else
+      return @b_has_sized_pointer_member
+    end
+  end
+  
+  def has_unsized_string?
+    if @definition
+      return @definition.has_unsized_string?
+    else
+      return @b_has_unsized_string_member
+    end
+  end
+
+  #=== åãæ§é ä½ãã©ãããã§ãã¯ãã
+  # tag ã®ãã§ãã¯ã¯è¡ããªã
+  # ãã¹ã¦ã®ã¡ã³ãã®ååã¨åãä¸è´ãããã¨ãç¢ºèªãã
+  def same? another
+    md = another.get_members_decl
+    if @members_decl == nil || md == nil
+      return false
+    end
+
+    md1 = @members_decl.get_items
+    md2 = md.get_items
+    if( md1.length != md2.length )
+      return false
+    end
+
+    i = 0
+    while i < md1.length
+      if md1[i].get_name != md2[i].get_name ||
+          md1[i].get_type.get_type_str != md2[i].get_type.get_type_str ||
+          md1[i].get_type.get_type_str_post != md2[i].get_type.get_type_str_post
+        return false
+      end
+      i += 1
+    end
+
+    return true
+  end
+  
+  def get_member_types_symbol
+    mts = ''
+    @members_decl.get_items.each { |member|
+      mts += member.get_type.get_type_str + member.get_type.get_type_str_post + ';'
+    }
+    return mts.to_sym
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "StructType tag: #{@tag} qualifier=#{@qualifier} has_pointer=#{@b_has_pointer_member} #{locale_str}"
+    super( indent + 1 )
+    if @b_define then
+      @members_decl.show_tree( indent + 1 )
+    end
+  end
+end
+
+class FuncType < Type
+#  @paramlist::  ParamList
+#  @type:: return type : PtrType, ArrayType, FuncType, IntType, FloatType, ...
+#  @b_oneway:: bool: true, false
+#  @has_in:: bool :  has [in] parameter
+#  @has_inout:: bool : has [inout] parameter
+#  @has_out:: bool : has [out] parameter
+#  @has_send:: bool : has [send] parameter
+#  @has_receive:: bool : has [receive] parameter
+
+  def initialize( paramlist = nil )
+    super()
+
+    @has_in = false
+    @has_inout = false
+    @has_out = false
+    @has_send = false
+    @has_receive = false
+
+    @paramlist = paramlist
+    @b_oneway = false
+    if paramlist then
+      paramlist.check_param
+    else
+      @paramlist = ParamList.new( nil )
+    end
+    @paramlist.set_owner self  # ParamList
+    @paramlist.get_items.each{ |p|
+      case p.get_direction
+      when :IN
+        @has_in = true
+      when :INOUT
+        @has_inout = true
+      when :OUT
+        @has_out = true
+      when :SEND
+        @has_send = true
+      when :RECEIVE
+        @has_receive = true
+      else
+        raise "unkown direction"
+      end
+    }
+
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    if @type.class == ArrayType then	# é
+åãè¿ãé¢æ°
+      return "function returning array"
+    elsif @type.class == FuncType then	# é¢æ°ãè¿ãé¢æ°
+      return "function returning function"
+    end
+    return @type.check   # é¢æ°ã® return ããåã®ãã§ãã¯
+
+    # ãã©ã¡ã¼ã¿ã®åã®ãã§ãã¯ã¯ ParamList#check_param ã§è¡ã
+  end
+
+  def check_struct_tag kind
+    @type.check_struct_tag kind
+    # ParamDecl ã§ããã§ãã¯ãããã®ã§ãããã§ã¯ãã§ãã¯ããªã
+    # @paramlist.check_struct_tag kind
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    cdl_error2( locale, "T1028 $1: cannot initialize function pointer" , ident )
+    return
+  end
+
+  def set_type( type )
+    unless @type then
+      @type = type
+    else
+      @type.set_type( type )
+    end
+  end
+
+  #=== return type ãè¿ã
+  #
+  # return type ãè¿ã
+  # get_return_type ã¨ãã¹ãã ã£ã
+  def get_type
+    @type
+  end
+
+  def get_type_str
+    return @type.get_type_str
+  end
+
+  def get_type_str_post
+    # åã ããè¿ã (ä»®å¼æ°ã®ååãå«ããªã)
+    @paramlist.to_str( false )
+  end
+
+  def get_paramlist
+    @paramlist
+  end
+
+  def set_oneway( b_oneway )
+    @b_oneway = b_oneway
+
+    if ( ( @type.get_type_str != "ER" && @type.get_type_str != "void" ) || @type.get_type_str_post != "" ) then
+      cdl_error( "T1029 oneway function cannot return type \'$1$2\', \'void\' or \'ER\' is permitted" , @type.get_type_str, @type.get_type_str_post )
+    end
+
+    if @paramlist then
+      @paramlist.get_items.each{ |p|
+        if p.get_direction != :IN && p.get_direction != :SEND then
+          cdl_error( "T1030 oneway function cannot have $1 parameter for \'$2\'" , p.get_direction, p.get_name )
+        end
+      }
+    end
+  end
+
+  def is_oneway?
+    @b_oneway
+  end
+
+  #=== Push Pop Allocator ãå¿
+è¦ãï¼
+  # Transparent RPC ã®å ´å oneway ãã¤ in ã®é
+å(size_is, count_is, string ã®ããããã§ä¿®é£¾ï¼ããã
+  def need_PPAllocator?( b_opaque = false )
+    if @b_oneway || b_opaque then
+      return @paramlist.need_PPAllocator?( b_opaque )
+    else
+      return false
+    end
+  end
+
+  #=== ãã©ã¡ã¼ã¿ã in, inout, out, send, receive ãæã¤ã
+  def has_in?
+    @has_in
+  end
+  def has_inout?
+    @has_inout
+  end
+  def has_out?
+    @has_out
+  end
+  def has_send?
+    @has_send
+  end
+  def has_receive?
+    @has_receive
+  end
+
+  #=== å
+¥åæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã
+  def has_inward?
+    @has_in || @has_inout || @has_send
+  end
+  #=== åºåæ¹åã®ãã©ã¡ã¼ã¿ãæã¤ã
+  def has_outward?
+    @has_inout || @has_out || @has_receive
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    if @b_oneway then
+      puts "FunctType:  oneway=true #{locale_str}"
+    else
+      puts "FunctType:  oneway=false #{locale_str}"
+    end
+    super( indent + 1 )
+    if @paramlist then
+      @paramlist.show_tree( indent + 1 )
+    end
+    (indent+1).times { print "  " }
+    puts "return type:"
+    @type.show_tree( indent + 2 )
+  end
+end
+
+class ArrayType < Type
+#  @type:: element type :  ArrayType, FuncType, IntType, FloatType, ...
+#  @subscript:: Expression, nil if '[]'
+
+  include HasType
+
+  def initialize( subscript = nil )
+    super()
+    @subscript = subscript
+    initHasType
+  end
+
+  def set_type( type )
+    unless @type then
+      @type = type
+    else
+      @type.set_type( type )
+    end
+  end
+
+  #=== Array#qualifier(const, volatile) ã®è¨­å®
+  def set_qualifier( qualifier )
+    clone_type
+    @type.set_qualifier( qualifier )
+    super
+  end
+
+  # é
+åè¦ç´ ã const ãªã const
+  def is_const?
+    @type.is_const?
+  end
+
+  # é
+åè¦ç´ ã volatile ãªã volatile
+  def is_volatile?
+    @type.is_volatile?
+  end
+
+  def get_type
+    @type
+  end
+
+  def get_subscript
+    @subscript
+  end
+
+  def get_type_str
+    return "#{@type.get_type_str}"
+  end
+
+  def get_type_str_post
+    if @subscript
+      "[#{@subscript.eval_const(nil)}]#{@type.get_type_str_post}"
+    else
+      "[]#{@type.get_type_str_post}"
+    end
+    # "[#{@subscript.to_s}]#{@type.get_type_str_post}"
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    if @type.class == FuncType then		# é¢æ°ã®é
+å
+      return "array of function"
+    elsif @type.class == ArrayType then	# æ·»æ°ãªãé
+åã®é
+å
+      unless @type.get_subscript then
+        return "subscript not specified"
+      end
+    end
+
+    return @type.check    # é
+åè¦ç´ ã®åããã§ãã¯
+  end
+
+  def check_struct_tag kind
+    @type.check_struct_tag kind
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    if ( initializer.instance_of?( Array ) ) then
+      index = 0
+      initializer.each{ |i|
+        @type.check_init( locale, "#{ident}[#{index}]", i, kind, attribute = nil )
+        index += 1
+      }
+    else
+      cdl_error2( locale, "T1031 $1: unsuitable initializer for array" , ident )
+    end
+  end
+
+  def has_pointer?
+    @type.has_pointer?
+  end
+
+  def has_sized_pointer?
+    @type.has_sized_pointer?
+  end
+
+  def has_unsized_string?
+    @type.has_unsized_string?
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "ArrayType: #{locale_str}"
+    super( indent + 1 )
+    (indent+1).times { print "  " }
+    puts "type:"
+    @type.show_tree( indent + 2 )
+    (indent+1).times { print "  " }
+    puts "subscript:"
+    if @subscript then
+      @subscript.show_tree( indent + 2 )
+    else
+      (indent+2).times { print "  " }
+      puts "no subscript"
+    end
+  end
+end
+
+class PtrType < Type
+#  @type:: refer to : PtrType, FuncType, ArrayType, IntType, FloatType, ...
+#  @size:: Expr, or nil if not specified
+#  @count:: Expr, or nil if not specified
+#  @string:: Expr or -1(if size not specified) ï¼string å¼æ°ï¼, or nil if not specified
+
+  include HasType
+
+  def initialize( referto = nil )
+    super()
+    @type   = referto
+    @size   = nil
+    @count  = nil
+    @string = nil
+    initHasType
+  end
+
+  def set_type( type )
+    unless @type then
+      @type = type
+    else
+      @type.set_type( type )	# æå
+ã® type ãè¨­å®
+    end
+  end
+
+  def get_type_str
+    if @type.kind_of?( ArrayType ) || @type.kind_of?( FuncType ) then
+      parenthes = "("
+    else
+      parenthes = ""
+    end
+    return "#{@type.get_type_str}#{parenthes}*"
+  end
+
+  def get_type_str_post
+    if @type.kind_of?( ArrayType ) || @type.kind_of?( FuncType ) then
+      parenthes = ")"
+    else
+      parenthes = ""
+    end
+    "#{parenthes}#{@type.get_type_str_post}"
+  end
+
+  def check	# æå³çèª¤ããããã°ãæå­åãè¿ã
+    return nil if @type == nil
+    @type.check
+  end
+
+  def check_struct_tag kind
+    if kind != :MEMBER  # æ§é ä½ã¡ã³ãã¼ã®å ´åããã¤ã³ã¿ã®å
+ã®æ§é ä½ã¿ã°ããã§ãã¯ããªã
+      @type.check_struct_tag kind
+    end
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    if ( initializer.instance_of?( Expression ) ) then
+      val = initializer.eval_const2( nil, attribute )
+      if val.kind_of? PointerVal then
+        type = val.get_type  # PtrType
+        t1 = self
+        t2 = type
+        while( t1.kind_of?( PtrType ) && t2.kind_of?( PtrType ) )
+          t1 = t1.get_type
+          t2 = t2.get_type
+          if ( t1.class == t2.class ) && ( t1.get_bit_size == t2.get_bit_size ) then
+          elsif ( t1.kind_of?( CDefinedType) || t2.kind_of?( CDefinedType ) )&& t1.get_type_str == t2.get_type_str && t1.get_type_str_post && t2.get_type_str_post then
+            # int8_t ãªã©ããä¸æ¹ã¯ .h ã«å®ç¾©ããã¦ããã±ã¼ã¹
+          else
+            cdl_error2( locale, "T1032 $1: incompatible pointer type" , ident )
+            break
+          end
+        end
+      elsif val.kind_of? IntegerVal then
+        if val.to_i != 0 then
+          cdl_error2( locale, "T1033 $1: need cast to assign integer to pointer" , ident )
+        end
+      elsif val.kind_of? StringVal then
+        # æå­åå®æ°
+        # mikan L"wide string"
+        if @type.get_bit_size != -1 && @type.get_bit_size != -11 then  # -1: char_t
+          cdl_error2( locale, "T1034 $1: unsuitable string constant" , ident )
+        end
+      elsif ( val.instance_of?( Array ) ) then
+        i = 0
+        val.each { |ini|
+          @type.check_init( locale, "#{ident}[#{i}]", ini, kind, attribute = nil )
+          i += 1
+        }
+      elsif val.instance_of?( C_EXP ) then
+
+      else
+        cdl_error2( locale, "T1035 $1: unsuitable initializer for pointer" , ident )
+      end
+    elsif ( initializer.instance_of?( Array ) ) then
+      if @size == nil && @count == nil then
+        cdl_error2( locale, "T9999 $1: non-size_is pointer cannot have array initializer", ident )
+      end
+
+      i = 0
+      initializer.each { |ini|
+        @type.check_init( locale, "#{ident}[#{i}]", ini, kind, attribute = nil )
+        i += 1
+      }
+    elsif( initializer.instance_of?( C_EXP ) ) then
+
+    else
+      cdl_error2( locale, "T1036 $1: unsuitable initializer for pointer" , ident )
+    end
+  end
+
+  def get_referto
+    clone_type
+    @type
+  end
+
+  def set_scs( size, count, string, max, b_nullable )
+    @size = size
+    @count = count
+    @max = max
+    @b_nullable = b_nullable
+
+    # string ã¯æãå·¦å´ã® ptr ã«ä½ç¨ãã
+    if @type.kind_of?( PtrType ) then
+      # ptr_level ã 2 ä»¥ä¸ã§ãããã¨ã¯ ParamDecl#initializer ã§ãã§ãã¯ããã
+      clone_type
+      @type.set_scs( nil, nil, string, nil, false )
+    elsif @type.kind_of?( VoidType ) && ( size || count || string ) then
+      str = ""
+      if size then
+        str = "size_is"
+      end
+      if count then
+        if str then
+          str += ", "
+        end
+        str += "count_is"
+      end
+      if string then
+        if str then
+          str += ", "
+        end
+        str += "string"
+      end
+
+      cdl_error( "T1040 $1 specified for void pointer type", str )
+    else
+      @string = string
+    end
+
+    if (@size != nil) && (@b_nullable != false) then
+      cdl_error( "T9999 size_is & nullable cannot be specified simultaneously. If size is zero, pointer must be null")
+    end
+  end
+
+  def clear_max
+    @max = nil
+  end
+
+  def get_size
+    @size
+  end
+
+  def get_count
+    @count
+  end
+
+  def get_string
+    @string
+  end
+
+  #=== PtrType# size_is ã®æå¤§å¤
+  def get_max
+    @max
+  end
+
+  def is_nullable?
+    return @b_nullable
+  end
+
+  def get_type
+    clone_type
+    @type
+  end
+
+  def has_pointer?
+    true
+  end
+
+  def has_sized_pointer?
+    @size != nil || @count != nil || @string.instance_of?( Expression ) || @type.has_sized_pointer?
+  end
+
+  def has_unsized_string?
+    @string == -1 || @type.has_unsized_string?
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "PtrType: qualifier=#{@qualifier}, nullable=#{@b_nullable} #{locale_str}"
+    super( indent + 1 )
+    (indent+1).times { print "  " }
+    if @size then
+      print "size=#{@size.to_s}, "
+    else
+      print "size=nil, "
+    end
+    if @max then
+      print "max=#{@size.to_s}, "
+    else
+      print "max=nil, "
+    end
+    if @count then
+      print "count=#{@count.to_s}, "
+    else
+      print "count=nil, "
+    end
+    if @string then
+      if @string.instance_of?( Expression ) then
+        print "string=#{@string.to_s}\n"
+      else
+        print "string=yes\n"
+      end
+    else
+      print "string=nil\n"
+    end
+
+    (indent+1).times { print "  " }
+    puts "type:"
+    @type.show_tree( indent + 2 )
+  end
+
+end
+
+#==  DescriptorType ã¯ã©ã¹
+# åççµåã§æ¸¡ããã¹ã¯ãªãã¿å
+class DescriptorType < Type
+# @sinagure_nsp::NamespacePath
+
+  def initialize( signature_nsp )
+    @signature_nsp = signature_nsp
+    obj = Namespace.find signature_nsp
+    if ! obj.kind_of? Signature then
+      cdl_error( "T9999 '$1': not signature or not found", signature_nsp.to_s )
+    else
+      if obj.has_descriptor? then
+        cdl_error( "T9999 '$1': has Desicrptor in function parameter", signature_nsp.to_s )
+      end
+    end
+  end
+
+  def get_type_str
+    "Descriptor( #{@signature_nsp.to_s} )"
+  end
+
+  def get_type_str_post
+    ""
+  end
+
+  def set_qualifier( qualifier )
+    cdl_error( "T9999 '$1' cannot be specified for Descriptor", qualfier.to_s )
+  end
+
+  def check
+  end
+
+  def check_init( locale, ident, initializer, kind, attribute = nil )
+    case kind
+    when :PARAMETER
+      # å¼æ°ã¯åæåã§ããªã
+    else
+      cdl_error2( locale, "T9999 Descriptor cannot be used for $1", kind)
+    end
+  end
+
+  #== DescriptorType#
+  # æå³è§£ææ®µéã§ã¯ nil ãè¿ãããå¯è½æ§ã«æ³¨æ
+  def get_signature
+    Namespace.find @signature_nsp
+  end
+end
+
+# ä»¥ä¸åä½ãã¹ãã³ã¼ã
+if $unit_test then
+  puts( "===== Unit Test: IntType ===== (types.rb)")
+  sizes = [ 8, 16, 32, 64 ]
+  sizes.each{ |n|
+    int = IntType.new n
+    printf( "%8s  max: %d  min:%d\n", "int#{n}_t", int.get_max, int.get_min )
+  }
+  puts ""
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/core/value.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/core/value.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/core/value.rb	(revision 317)
@@ -0,0 +1,602 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: value.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#= BaseVal æ´æ°ãæµ®åå°æ°ãªã©ã®å¤ãæ±ãã¯ã©ã¹ã®åºåºã¯ã©ã¹
+#
+# TECS ã® CDL ã§æ±ãå¤ã¯ãä»¥ä¸ã«åé¡ããã
+# ã»æ´æ°
+# ã»æµ®åå°æ°
+# ã»æå­å
+# ã»ãã¼ã«å¤
+# éæåï¼æ§é ä½ãé
+åï¼ã¨ C_EXP ã¯ããã§ã¯æ±ããªã
+#
+# ãã®ã¯ã©ã¹ã§å®ç¾©æ¸ã¿ã®æ¼ç®å­ã¯ãã¨ã©ã¼ã¨ãªã
+# åã«ããæ¼ç®å¯è½ãªå ´åãæ¼ç®å­ããªã¼ãã¼ã©ã¤ããã
+#
+class BaseVal < Node
+  def ~@
+    unsupport "~"
+  end
+  def -@
+    unsupport "unary -"
+  end
+  def +@
+    unsupport "unary +"
+  end
+  def not # ! val
+    unsupport "!"
+  end
+
+  def * val
+    unsupport "*"
+  end
+  def / val
+    unsupport "/"
+  end
+  def % val
+    unsupport "%"
+  end
+  def + val
+    unsupport "+"
+  end
+  def - val
+    unsupport "-"
+  end
+  def << val
+    unsupport "<<"
+  end
+  def >> val
+    unsupport ">>"
+  end
+  def > val
+    unsupport ">"
+  end
+  def < val
+    unsupport "<"
+  end
+  def >= val
+    unsupport ">="
+  end
+  def <= val
+    unsupport "<="
+  end
+  def eq val # == val
+    unsupport "=="
+  end
+  def neq val # != val
+    unsupport "!="
+  end
+  def & val
+    unsupport "&"
+  end
+  def ^ val
+    unsupport "^"
+  end
+  def | val
+    unsupport "|"
+  end
+  def lAND val  # && val
+    unsupport "&&"
+  end
+  def lOR val   # || val
+    unsupport "||"
+  end
+  def cast( type )
+    unsupport "CAST"
+  end
+
+  def unsupport op
+    cdl_error( "V1001 $1: unable for $2" , op, self.class )
+  end
+
+  def to_s
+    raise "to_s not overridden"
+  end
+
+  def to_b
+    cdl_error( "V1002 $1: cannot cast to bool (implicitly)" , self.class )
+    false
+  end
+  def to_i
+    cdl_error( "V1003 $1: cannot cast to integer (implicitly)" , self.class )
+    1
+  end
+  def to_f
+    cdl_error( "V1004 $1: cannot cast to float (implicitly)" , self.class )
+    1.0
+  end
+end
+
+#= Pointer å¤ (IntegerVal ã® Pointer ç)
+#
+# ãã¤ã³ã¿å¤ã¯ãCDL ã§ç´æ¥çæããããã¨ã¯ãªã
+# æ´æ°å¤ã®ã­ã£ã¹ãæ¼ç®ã«ããçæããã
+class PointerVal < BaseVal
+#@int_val:: IntegerVal: IntegerVal ã§ãªãã¦ã¯ãªããªã
+#@ptr_type:: PtrType: ãã¤ã³ã¿ã®æãå
+ã®å
+
+  def initialize( int_val, ptr_type )
+    super()
+    @int_val = int_val
+    @ptr_type = ptr_type
+  end
+
+  #=== ãã¤ã³ã¿ã®æãå
+ã®åãå¾ã
+  # PointerVal å°ç¨ã®ã¡ã½ãã
+  def get_type
+    @ptr_type
+  end
+
+  def cast type
+    t = type.get_original_type   # typedef ã®å
+ãå¾ã
+    if t.kind_of? IntType then
+      val = t.check_and_clip( @int_val, :IntType )
+      return IntegerVal.new( val )
+    elsif t.kind_of? FloatType then
+      cdl_error( "V1005 Cannot cast pointer to float"  )
+      return FloatVal.new( @int_val )
+    elsif t.kind_of? PtrType then
+      return PointerVal.new( @int_val, type )
+    else
+      cdl_error( "V1006 pointer value cannot cast to $1" , type.class )
+      return nil
+    end
+  end
+
+  def to_s
+    "(#{@ptr_type.get_type_str}#{@ptr_type.get_type_str_post})#{sprintf("0x%X", @int_val)}"
+  end
+
+  def to_b
+    cdl_error( "V1007 convert pointer value to bool"  )
+    false
+  end
+  def to_i
+    cdl_error( "V1008 convert pointer value to integer without cast"  )
+    @val.to_i
+  end
+end
+
+#= IntegerVal: æ´æ°å¤ãæ±ãã¯ã©ã¹
+class IntegerVal < BaseVal
+#@val:: Integer: value
+#@str:: string: literal
+#@sign:: Symbol: :SIGNED | :UNSIGNED
+#@size:: Symbol: :NORMAL | :SHORT | :LONG | :LONGLONG
+
+  def initialize( val, str = nil, sign = :SIGNED, size = :NORMAL )
+    super()
+    @val = val.to_i
+    @str = str
+    @sign = sign
+    @size = size
+  end
+
+  def ~@
+    IntegerVal.new( ~ @val )
+  end
+  def -@
+    IntegerVal.new( - @val )
+  end
+  def +@
+    self
+  end
+  def not # !
+      BoolVal.new( self.to_b )
+  end
+
+  def * val
+    if val.kind_of? FloatVal then
+      return FloatVal.new( @val.to_f * val.to_f )
+    else
+      return IntegerVal.new( @val * val.to_i )
+    end
+  end
+  def / val
+    if val.kind_of? FloatVal then
+      v2 = val.to_f   # to_f ã2åè©ä¾¡ããªã
+      if v2 == 0.0 then
+        cdl_error( "V1009 / : divieded by zero"  )
+        return FloatVal.new( 1.0 )
+      end
+      return FloatVal.new( @val.to_f / v2 )
+    else
+      v2 = val.to_i   # to_i ã2åè©ä¾¡ããªã
+      if v2 == 0 then
+        cdl_error( "V1010 / : divieded by zero"  )
+        return IntegerVal.new( 1 )
+      end
+      return IntegerVal.new( @val / v2 )
+    end
+  end
+  def % val
+    if val.kind_of? FloatVal then
+      v2 = val.to_f   # to_f ã2åè©ä¾¡ããªã
+      if v2 == 0.0 then
+        cdl_error( "V1011 % : divieded by zero"  )
+        return FloatVal.new( 1.0 )
+      end
+      return FloatVal.new( @val.to_f % v2 )
+    else
+      v2 = val.to_i   # to_i ã2åè©ä¾¡ããªã
+      if v2 == 0 then
+        cdl_error( "V1012 % : divieded by zero"  )
+        return IntegerVal.new( 1 )
+      end
+      return IntegerVal.new( @val % v2 )
+    end
+  end
+  def + val
+    if val.kind_of? FloatVal then
+      return FloatVal.new( @val.to_f + val.to_f )
+    else
+      return IntegerVal.new( @val + val.to_i )
+    end
+  end
+  def - val
+    if val.kind_of? FloatVal then
+      return FloatVal.new( @val.to_f - val.to_f )
+    else
+      return IntegerVal.new( @val - val.to_i )
+    end
+  end
+  def << val
+    return IntegerVal.new( @val << val.to_i )
+  end
+  def >> val
+    return IntegerVal.new( @val >> val.to_i )
+  end
+  def > val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f > val.to_f )
+    else
+      return BoolVal.new( @val > val.to_i )
+    end
+  end
+  def < val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f < val.to_f )
+    else
+      return BoolVal.new( @val < val.to_i )
+    end
+  end
+  def >= val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f >= val.to_f )
+    else
+      return BoolVal.new( @val >= val.to_i )
+    end
+  end
+  def <= val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f <= val.to_f )
+    else
+      return BoolVal.new( @val <= val.to_i )
+    end
+  end
+  def eq val # == val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f == val.to_f )
+    else
+      return BoolVal.new( @val == val.to_i )
+    end
+  end
+  def neq val # != val
+    if val.kind_of? FloatVal then
+      return BoolVal.new( @val.to_f != val.to_f )
+    else
+      return BoolVal.new( @val != val.to_i )
+    end
+  end
+  def & val
+    IntegerVal.new( @val & val.to_i )
+  end
+  def ^ val
+    IntegerVal.new( @val ^ val.to_i )
+  end
+  def | val
+    IntegerVal.new( @val | val.to_i )
+  end
+  def lAND val  # && val
+    BoolVal.new( self.to_b && val.to_b )
+  end
+  def lOR val   # || val
+    BoolVal.new( self.to_b || val.to_b )
+  end
+  def cast( type )
+    t = type.get_original_type   # typedef ã®å
+ãå¾ã
+    if t.kind_of? IntType then
+      val = t.check_and_clip( @val, :IntType )
+      return IntegerVal.new( val )
+    elsif t.kind_of? FloatType then
+      return FloatVal.new( @val )
+    elsif t.kind_of? PtrType then
+      return PointerVal.new( @val, type )
+    elsif t.kind_of? BoolType then
+      return BoolVal.new( @val.to_b )
+    else
+      cdl_error( "V1013 integer value cannot cast to $1" , type.class )
+      return nil
+    end
+  end
+
+  def to_s
+    if @str then
+      @str
+    else
+      @val.to_s
+    end
+  end
+  def to_b
+    @val != 0
+  end
+  def to_i
+    @val
+  end
+  def to_f
+    @val.to_f
+  end
+end
+
+#= BoolVal: bool å¤ãæ±ãã¯ã©ã¹
+class BoolVal < BaseVal
+#@val:: bool: true, false
+
+  def initialize( val )
+    super()
+    if val == true || val == false
+      @val = val
+    elsif val.to_i != 0
+      @val = true
+    else
+      @val = false
+    end
+    # raise "No boolean val" if val != true && val != false
+  end
+
+  def not # ! val
+      BoolVal.new( ! @val )
+  end
+  def eq val # == val
+    if val.kind_of? BoolVal then
+      return BoolVal.new( self.to_i == val.to_i )
+    else
+      cdl_error( "V1014 comparing bool value with \'$1\'" , val.class )
+      return BoolVal.new( false )
+    end
+  end
+  def neq val # != val
+    if val.kind_of? BoolVal then
+      return BoolVal.new( self.to_i != val.to_i )
+    else
+      cdl_error( "V1015 comparing bool value with \'$1\'" , val.class )
+      return BoolVal.new( false )
+    end
+  end
+  def lAND val  # && val
+    BoolVal.new( self.to_b && val.to_b )
+  end
+  def lOR val   # || val
+    BoolVal.new( self.to_b || val.to_b )
+  end
+  def cast( type )
+    t = type.get_original_type   # typedef ã®å
+ãå¾ã
+    if @val then
+      val = 1
+    else
+      val = 0
+    end
+    if t.kind_of? IntType then
+      return IntegerVal.new( val )
+    elsif t.kind_of? FloatType then
+      return FloatVal.new( val )
+    elsif t.kind_of? BoolType then
+      return self
+    else
+      cdl_error( "V1016 bool value cannot cast to $1" , type.class )
+      return nil
+    end
+  end
+
+  def to_s
+    if @val
+      return "true"
+    else
+      return "false"
+    end
+  end
+  def to_b
+    @val
+  end
+  def to_i
+    return 0 if @val == false
+    return 1
+  end
+  def to_f
+    return 0.0 if @val == false
+    return 1.0
+  end
+
+  attr_reader :val
+end
+
+#= FloatVal: å®æ°å¤ãæ±ãã¯ã©ã¹
+class FloatVal < BaseVal
+#@val:: Float
+  def initialize( val )
+    super()
+    @val = val.to_f
+  end
+
+  def -@
+    FloatVal.new( - @val )
+  end
+  def +@
+    self
+  end
+  def * val
+    FloatVal.new( @val * val.to_f )
+  end
+  def / val
+    v2 = val.to_f   # to_f ã2åè©ä¾¡ããªã
+    if v2 == 0.0 then
+      cdl_error( "V1017 / : divieded by zero"  )
+      return FloatVal.new( 1.0 )
+    end
+    return FloatVal.new( @val.to_f / v2 )
+  end
+  def % val
+    v2 = val.to_f   # to_f ã2åè©ä¾¡ããªã
+    if v2 == 0.0 then
+      cdl_error( "V1018 % : divieded by zero"  )
+      return FloatVal.new( 1.0 )
+    end
+    return FloatVal.new( @val.to_f % v2 )
+  end
+  def + val
+    FloatVal.new( @val + val.to_f )
+  end
+  def - val
+    FloatVal.new( @val - val.to_f )
+  end
+  def > val
+    BoolVal.new( @val > val.to_f )
+  end
+  def < val
+    BoolVal.new( @val < val.to_f )
+  end
+  def >= val
+    BoolVal.new( @val >= val.to_f )
+  end
+  def <= val
+    BoolVal.new( @val <= val.to_f )
+  end
+  def eq val # == val
+    BoolVal.new( @val == val.to_f )
+  end
+  def neq val # != val
+    BoolVal.new( @val != val.to_f )
+  end
+  def cast( type )
+    t = type.get_original_type   # typedef ã®å
+ãå¾ã
+    if t.kind_of? IntType then
+      val = t.check_and_clip( @val, :FloatType )
+      return IntegerVal.new( val )
+    elsif t.kind_of? FloatType then
+      return self
+    else
+      cdl_error( "V1019 floating value cannot cast to $1" , type )
+      return self
+    end
+  end
+
+  def to_b
+    cdl_error( "V1020 convert floating value to bool without cast"  )
+    @val.to_i
+  end
+  def to_i
+    cdl_error( "V1021 convert floating value to integer without cast"  )
+    @val.to_i
+  end
+  def to_s
+    @val.to_s
+  end
+  def to_f
+    @val
+  end
+end
+
+#= æå­åãªãã©ã«ãæ±ãã¯ã©ã¹
+class StringVal < BaseVal
+#@str:: Token:
+#@specifier:: Symbol: :WIDE, :NORMAL
+
+  def initialize( str, spec = :NORMAL )
+    super()
+    @str = str
+    @specifier = spec   # mikan L"str" wide æå­åæªå¯¾å¿
+  end
+
+  #===
+  #
+  # string ã® cast ã¯ã§ããªã mikan ãã¤ã³ã¿åã¸ã® cast ã¯ã§ããã¹ã
+  def cast type
+    t = type.get_original_type   # typedef ã®å
+ãå¾ã
+    if t.kind_of? IntType then
+      cdl_error( "V1022 string cannot cast to integer"  )
+    elsif t.kind_of? FloatType then
+      cdl_error( "V1023 string cannot cast to float"  )
+    elsif t.kind_of? PtrType then
+      cdl_error( "V1024 string cannot cast to pointer"  )
+    else
+      cdl_error( "V1025 string cannot cast to $1" , type )
+    end
+  end
+    
+  def to_s
+    @str.to_s
+  end
+
+  def val
+    @str.to_s   # Token ã§æ±ããã¦ããåæ® (val ãåãåºã)
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_en_US.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_en_US.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_en_US.rb	(revision 317)
@@ -0,0 +1,1185 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: messages_console_en_US.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+
+# Console Messages for en_US 
+class TECSMsg
+
+###
+# ã¨ã©ã¼ã¡ãã»ã¼ã¸
+@@error_message = {}
+
+### C_parser.y.rb
+# B1001 need parameter name"
+@@error_message[ :"B1001" ] = "need parameter name"
+
+# B1002 while open or reading \'$1\'"
+@@error_message[ :"B1002" ] = "while open or reading \'$1\'"
+
+# B1003 Unexpected EOF"
+@@error_message[ :"B1003" ] = "Unexpected EOF"
+
+# B1004 syntax error near \'$1\'"
+@@error_message[ :"B1004" ] = "syntax error near \'$1\'"
+
+### ctypes.rb
+# C1001 $1: mismatch, suitable for integer types"
+@@error_message[ :"C1001" ] = "$1: mismatch, suitable for integer types"
+
+# C1002 $1 not compatible with previous one $2"
+@@error_message[ :"C1002" ] = "$1 not compatible with previous one $2"
+
+# C1003 $1 & $2 incompatible  (\'long double\' not support)"
+@@error_message[ :"C1003" ] = "$1 & $2 incompatible  (\'long double\' not support)"
+
+# C1004 $1: qualifier respecified. previous one: $2"
+@@error_message[ :"C1004" ] = "$1: qualifier respecified. previous one: $2"
+
+### expression.rb
+# E1001 $1: not found"
+@@error_message[ :"E1001" ] = "$1: not found"
+
+# E1002 $1: not constant (port)"
+@@error_message[ :"E1002" ] = "$1: not constant (port)"
+
+# E1003 $1: not constant"
+@@error_message[ :"E1003" ] = "$1: not constant"
+
+# E1004 cannot evaluate \'[]\' operator"
+@@error_message[ :"E1004" ] = "cannot evaluate \'[]\' operator"
+
+# E1005 cannot evaluate \'.\' operator"
+@@error_message[ :"E1005" ] = "cannot evaluate \'.\' operator"
+
+# E1006 cannot evaluate \'->\' operator"
+@@error_message[ :"E1006" ] = "cannot evaluate \'->\' operator"
+
+# E1007 cannot evaluate \'sizeof\' operator"
+@@error_message[ :"E1007" ] = "cannot evaluate \'sizeof\' operator"
+
+# E1008 cannot evaluate \'sizeof\' operator"
+@@error_message[ :"E1008" ] = "cannot evaluate \'sizeof\' operator"
+
+# E1009 cannot evaluate \'&\' operator"
+@@error_message[ :"E1009" ] = "cannot evaluate \'&\' operator"
+
+# E1010 cannot evaluate \'*\' operator"
+@@error_message[ :"E1010" ] = "cannot evaluate \'*\' operator"
+
+# E1011 cannot evaluate unary + for $1"
+@@error_message[ :"E1011" ] = "cannot evaluate unary + for $1"
+
+# E1012 $1: not found in parameter list"
+@@error_message[ :"E1012" ] = "$1: not found in parameter list"
+
+# E1013 \'*\': operand is not pointer value"
+@@error_message[ :"E1013" ] = "\'*\': operand is not pointer value"
+
+# E1014 $1: elements_get_type: sorry not supported"
+@@error_message[ :"E1014" ] = "$1: elements_get_type: sorry not supported"
+
+# E1015 \'$1\': direction mismatch for $2, $3 required"
+@@error_message[ :"E1015" ] = "\'$1\': direction mismatch for $2, $3 required"
+
+# E1016 $1: elements_check_dir_for_param: sorry not supported"
+@@error_message[ :"E1016" ] = "$1: elements_check_dir_for_param: sorry not supported"
+
+# E1017 $1: rhs not \'Cell.ePort\' form"
+@@error_message[ :"E1017" ] = "$1: rhs not \'Cell.ePort\' form"
+
+# E1018 $1: namespace cannot be specified"
+@@error_message[ :"E1018" ] = "$1: namespace cannot be specified"
+
+# E1019 $1: rhs not in 'allocator_entry_port' form"
+@@error_message[ :"E1019" ] = "$1: rhs not in 'allocator_entry_port' form"
+
+# E1020 rhs not in 'call_port.func.param' form for $1_$2"
+@@error_message[ :"E1020" ] = "rhs not in 'call_port.func.param' form for $1_$2"
+
+### bnf.y.rb
+# G1001 need specifier for \'$1\'"
+@@error_message[ :"G1001" ] = "need specifier for \'$1\'"
+
+# G1002 need parameter name"
+@@error_message[ :"G1002" ] = "need parameter name"
+
+# G1003 need parameter name"
+@@error_message[ :"G1003" ] = "need parameter name"
+
+# G1004 impossible array type 0"
+@@error_message[ :"G1004" ] = "impossible array type 0"
+
+# G1005 impossible array type 1"
+@@error_message[ :"G1005" ] = "impossible array type 1"
+
+# G1006 impossible array type 2"
+@@error_message[ :"G1006" ] = "impossible array type 2"
+
+# G1007 impossible array type 3"
+@@error_message[ :"G1007" ] = "impossible array type 3"
+
+# G1008 impossible function type"
+@@error_message[ :"G1008" ] = "impossible function type"
+
+# G1009 unexpected specifier"
+@@error_message[ :"G1009" ] = "unexpected specifier"
+
+# G1010 Not function"
+@@error_message[ :"G1010" ] = "Not function"
+
+# G1011 Not function"
+@@error_message[ :"G1011" ] = "Not function"
+
+# G1012 $1 : cannot put specifier here"
+@@error_message[ :"G1012" ] = "$1 : cannot put specifier here"
+
+# G1013 unexpected specifier"
+@@error_message[ :"G1013" ] = "unexpected specifier"
+
+# G1014 while open or reading \'$1\'"
+@@error_message[ :"G1014" ] = "while open or reading \'$1\'"
+
+# G1015 Unexpected EOF"
+@@error_message[ :"G1015" ] = "Unexpected EOF"
+
+# G1016 syntax error near \'$1\'"
+@@error_message[ :"G1016" ] = "syntax error near \'$1\'"
+
+### plugin.rb
+# P1001 plugin arg: cannot find identifier in $1"
+@@error_message[ :"P1001" ] = "plugin arg: cannot find identifier in $1"
+
+# P1002 plugin arg: expecting \'=\' not \'$1\'"
+@@error_message[ :"P1002" ] = "plugin arg: expecting \'=\' not \'$1\'"
+
+# P1003 plugin arg: unexpected $1"
+@@error_message[ :"P1003" ] = "plugin arg: unexpected $1"
+
+# P1004 $1: unknown plugin argument\'s identifier\n  $2 are acceptable for RPCPlugin."
+@@error_message[ :"P1004" ] = "$1: unknown plugin argument\'s identifier\n  $2 are acceptable for RPCPlugin."
+
+### pluginModule.rb
+# P2001 $1.rb : fail to load plugin"
+@@error_message[ :"P2001" ] = "$1.rb : fail to load plugin"
+
+# P2002 $1: not kind of $2"
+@@error_message[ :"P2002" ] = "$1: not kind of $2"
+
+# P2003 $1: load failed"
+@@error_message[ :"P2003" ] = "$1: load failed"
+
+# P2004 $1: open error \'$2\'"
+@@error_message[ :"P2004" ] = "$1: open error \'$2\'"
+
+# P2005 $1: plugin error in gen_through_cell_code "
+@@error_message[ :"P2005" ] = "$1: plugin error in gen_through_cell_code "
+
+# P2006 $1: close error \'$2\'"
+@@error_message[ :"P2006" ] = "$1: close error \'$2\'"
+
+# P2007 $1: fail to generate post code"
+@@error_message[ :"P2007" ] = "$1: fail to generate post code"
+
+### componentobj.rb
+# S1001 context specifier duplicate"
+@@error_message[ :"S1001" ] = "context specifier duplicate"
+
+# S1002 \'$1\': unknown specifier for signature"
+@@error_message[ :"S1002" ] = "\'$1\': unknown specifier for signature"
+
+# S1003 $1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type
+@@error_message[ :"S1003" ] = "$1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type"
+
+# S1004 $1: \'alloc\' 2nd parameter not [in] double pointer"
+@@error_message[ :"S1004" ] = "$1: \'alloc\' 2nd parameter not [in] double pointer"
+
+# S1005 $1: \'alloc\' has no parameter, unsuitable for allocator signature"
+@@error_message[ :"S1005" ] = "$1: \'alloc\' has no parameter, unsuitable for allocator signature"
+
+# S1006 $1: \'dealloc\' 1st parameter not [in] pointer type"
+@@error_message[ :"S1006" ] = "$1: \'dealloc\' 1st parameter not [in] pointer type"
+
+# S1007 "
+     # S1007 $1: \'dealloc\' cannot has 2nd parameter"
+# @@error_message[ :"S1007" ] = "$1: \'dealloc\' cannot has 2nd parameter"
+
+# S1008 $1: \'dealloc\' has no parameter, unsuitable for allocator signature"
+@@error_message[ :"S1008" ] = "$1: \'dealloc\' has no parameter, unsuitable for allocator signature"
+
+# S1009 $1: \'alloc\' function not found, unsuitable for allocator signature"
+@@error_message[ :"S1009" ] = "$1: \'alloc\' function not found, unsuitable for allocator signature"
+
+# S1010 $1: \'dealloc\' function not found, unsuitable for allocator signature"
+@@error_message[ :"S1010" ] = "$1: \'dealloc\' function not found, unsuitable for allocator signature"
+
+# S1011 $1: size_is specified for non-pointer type"
+@@error_message[ :"S1011" ] = "$1: size_is specified for non-pointer type"
+
+# S1012 $1: unsuitable initializer, need array initializer"
+@@error_message[ :"S1012" ] = "$1: unsuitable initializer, need array initializer"
+
+# S1013 $1: too many initializer, $2 for $3"
+@@error_message[ :"S1013" ] = "$1: too many initializer, $2 for $3"
+
+# S1014 generate specifier duplicate"
+@@error_message[ :"S1014" ] = "generate specifier duplicate"
+
+# S1015 $1 cannot be specified for composite"
+@@error_message[ :"S1015" ] = "$1 cannot be specified for composite"
+
+# S1016 $1 not found"
+@@error_message[ :"S1016" ] = "$1 not found"
+
+# S1017 $1 : neither celltype nor cell"
+@@error_message[ :"S1017" ] = "$1 : neither celltype nor cell"
+
+# S1018 $1 : not singleton cell"
+@@error_message[ :"S1018" ] = "$1 : not singleton cell"
+
+# S1019 \'$1\' : not entry port"
+@@error_message[ :"S1019" ] = "\'$1\' : not entry port"
+
+# S1020 \'$1\' : required port cannot be array"
+@@error_message[ :"S1020" ] = "\'$1\' : required port cannot be array"
+
+# S1021 $1 : require cannot have same signature with \'$2\'"
+@@error_message[ :"S1021" ] = "$1 : require cannot have same signature with \'$2\'"
+
+# S1022 $1.$2 : \'$3\' conflict function name in $4.$5"
+@@error_message[ :"S1022" ] = "$1.$2 : \'$3\' conflict function name in $4.$5"
+
+# S1023 $1: fail to new"
+@@error_message[ :"S1023" ] = "$1: fail to new"
+
+# S1024 $1: multiple cell for singleton celltype"
+@@error_message[ :"S1024" ] = "$1: multiple cell for singleton celltype"
+
+# S1025 not found reachable cell for require \'$1\' in celltype \'$2\'"
+@@error_message[ :"S1025" ] = "not found reachable cell for require \'$1\' in celltype \'$2\'"
+
+# S1026 required cell \'$1\' not reachable"
+@@error_message[ :"S1026" ] = "required cell \'$1\' not reachable"
+
+# S1027 \'$1\' celltype not found"
+@@error_message[ :"S1027" ] = "\'$1\' celltype not found"
+
+# S1028 \'$1\' not celltype"
+@@error_message[ :"S1028" ] = "\'$1\' not celltype"
+
+# S1029 $1 mismatch with previous one"
+@@error_message[ :"S1029" ] = "$1 mismatch with previous one"
+
+# S1030 $1: celltype mismatch with previous one"
+@@error_message[ :"S1030" ] = "$1: celltype mismatch with previous one"
+
+# S1031 $1 region \'$2\' mismatch  with previous one \'$3\'"
+@@error_message[ :"S1031" ] = "$1 region \'$2\' mismatch  with previous one \'$3\'"
+
+# S1032 $1: duplicate cell"
+@@error_message[ :"S1032" ] = "$1: duplicate cell"
+
+# S1033 rhs expression is not supported. Only attribute is permitted on current version."
+@@error_message[ :"S1033" ] = "rhs expression is not supported. Only attribute is permitted on current version."
+
+# S1034 $1 : cannot refer to $2\'s attribute here. Use \'composite.$3\' to refer to composite celltype\'s"
+@@error_message[ :"S1034" ] = "$1 : cannot refer to $2\'s attribute here. Use \'composite.$3\' to refer to composite celltype\'s"
+
+# S1035 composite : cannot specify out of composite celltype definition"
+@@error_message[ :"S1035" ] = "composite : cannot specify out of composite celltype definition"
+
+# S1036 $1 : cannot refer to $2\'s here. Use \'composite.$3\' to refer to composite celltype\'s"
+@@error_message[ :"S1036" ] = "$1 : cannot refer to $2\'s here. Use \'composite.$3\' to refer to composite celltype\'s"
+
+# S1037 $1: celltype plugin fail to new_cell"
+@@error_message[ :"S1037" ] = "$1: celltype plugin fail to new_cell"
+
+# S1038 $1.$2: self allocator not supported for array entry port"
+@@error_message[ :"S1038" ] = "$1.$2: self allocator not supported for array entry port"
+
+# S1039 \'$1\': unknown specifier for cell"
+@@error_message[ :"S1039" ] = "\'$1\': unknown specifier for cell"
+
+# S1040 array not supported for relay allocator"
+@@error_message[ :"S1040" ] = "array not supported for relay allocator"
+
+# S1041 \'$1_$2_$3\': not joined. cannot create internal join for relay allocator"
+@@error_message[ :"S1041" ] = "\'$1_$2_$3\': not joined. cannot create internal join for relay allocator"
+
+# S1042 call port \'$1\' not initialized in cell \'$2\'"
+@@error_message[ :"S1042" ] = "call port \'$1\' not initialized in cell \'$2\'"
+
+# S1043 call port \'$1\' not initialized in cell \'$2\'. this call port is created by tecsgen. check allocator specifier"
+@@error_message[ :"S1043" ] = "call port \'$1\' not initialized in cell \'$2\'. this call port is created by tecsgen. check allocator specifier"
+
+# S1044 $1: array initializer too many or few, $2 for $3"
+@@error_message[ :"S1044" ] = "$1: array initializer too many or few, $2 for $3"
+
+# S1045 $1[$2]: not initialized"
+@@error_message[ :"S1045" ] = "$1[$2]: not initialized"
+
+# S1046 $1[$2]: not initialized"
+@@error_message[ :"S1046" ] = "$1[$2]: not initialized"
+
+# S1047 size_is pointer cannot be exposed for composite attribute"
+@@error_message[ :"S1047" ] = "size_is pointer cannot be exposed for composite attribute"
+
+# S1048 $1: size_is specified for non-pointer type"
+@@error_message[ :"S1048" ] = "$1: size_is specified for non-pointer type"
+
+# S1049 $1: size_is arg not constant"
+@@error_message[ :"S1049" ] = "$1: size_is arg not constant"
+
+# S1050 unsuitable initializer, need array initializer"
+@@error_message[ :"S1050" ] = "unsuitable initializer, need array initializer"
+
+# S1051 too many initializer for array, $1 for $2"
+@@error_message[ :"S1051" ] = "too many initializer for array, $1 for $2"
+
+# S1052 attribute \'$1\' not initialized in cell \'$2\'"
+@@error_message[ :"S1052" ] = "attribute \'$1\' not initialized in cell \'$2\'"
+
+# S1053 $1 must be singleton. inner cell \'$2\' is singleton"
+@@error_message[ :"S1053" ] = "$1 must be singleton. inner cell \'$2\' is singleton"
+
+# S1054 $1 : specified active but has no active in this celltype"
+@@error_message[ :"S1054" ] = "$1 : specified active but has no active in this celltype"
+
+# S1055 $1 must be active. inner cell \'$2\' is active"
+@@error_message[ :"S1055" ] = "$1 must be active. inner cell \'$2\' is active"
+
+# S1056 $1 : cannot export, nothing designated"
+@@error_message[ :"S1056" ] = "$1 : cannot export, nothing designated"
+
+# S1057 $1 not found in $2"
+@@error_message[ :"S1057" ] = "$1 not found in $2"
+
+# S1058 \'$1\' : cannot export var"
+@@error_message[ :"S1058" ] = "\'$1\' : cannot export var"
+
+# S1059 \'$1\' : exporting attribute. write in cell or use \'=\' to export attribute"
+@@error_message[ :"S1059" ] = "\'$1\' : exporting attribute. write in cell or use \'=\' to export attribute"
+
+# S1060 \'$1\' : port type mismatch. $2 type is allowed here."
+@@error_message[ :"S1060" ] = "\'$1\' : port type mismatch. $2 type is allowed here."
+
+# S1061 \'$1\' : not defined"
+@@error_message[ :"S1061" ] = "\'$1\' : not defined"
+
+# S1062 $1 has no export definition"
+@@error_message[ :"S1062" ] = "$1 has no export definition"
+
+# S1063 $1 is port but previously defined as an attribute"
+@@error_message[ :"S1063" ] = "$1 is port but previously defined as an attribute"
+
+# S1064 $1 : type \'$2$3\' mismatch with pprevious definition\'$4$5\'"
+@@error_message[ :"S1064" ] = "$1 : type \'$2$3\' mismatch with pprevious definition\'$4$5\'"
+
+# S1065 $1 : port type $2 mismatch with previous definition $3"
+@@error_message[ :"S1065" ] = "$1 : port type $2 mismatch with previous definition $3"
+
+# S1066 $1 : signature \'$2\' mismatch with previous definition \'$3\'"
+@@error_message[ :"S1066" ] = "$1 : signature \'$2\' mismatch with previous definition \'$3\'"
+
+# S1067 $1 : array size mismatch with previous definition"
+@@error_message[ :"S1067" ] = "$1 : array size mismatch with previous definition"
+
+# S1068 $1 : optional specifier mismatch with previous definition"
+@@error_message[ :"S1068" ] = "$1 : optional specifier mismatch with previous definition"
+
+# S1069 $1 is an attribute but previously defined as a port"
+@@error_message[ :"S1069" ] = "$1 is an attribute but previously defined as a port"
+
+# S1070 $1: size_is pointer cannot be exposed for composite attribute"
+@@error_message[ :"S1070" ] = "$1: size_is pointer cannot be exposed for composite attribute"
+
+# S1071 $1 cannot be specified for composite"
+@@error_message[ :"S1071" ] = "$1 cannot be specified for composite"
+
+# S1072 $1: entry port: sizeless array not supported in current version"
+@@error_message[ :"S1072" ] = "$1: entry port: sizeless array not supported in current version"
+
+# S1073 Not constant expression $1"
+@@error_message[ :"S1073" ] = "Not constant expression $1"
+
+# S1074 Not Integer $1"
+@@error_message[ :"S1074" ] = "Not Integer $1"
+
+# S1075 \'$1\' signature not found"
+@@error_message[ :"S1075" ] = "\'$1\' signature not found"
+
+# S1076 \'$1\' not signature"
+@@error_message[ :"S1076" ] = "\'$1\' not signature"
+
+# S1077 inline: cannot be specified for call port"
+@@error_message[ :"S1077" ] = "inline: cannot be specified for call port"
+
+# S1078 optional: cannot be specified for entry port"
+@@error_message[ :"S1078" ] = "optional: cannot be specified for entry port"
+
+# S1079 allocator: cannot be specified for call port"
+@@error_message[ :"S1079" ] = "allocator: cannot be specified for call port"
+
+# S1080 duplicate allocator specifier"
+@@error_message[ :"S1080" ] = "duplicate allocator specifier"
+
+# S1081 self allocator not supported yet"
+@@error_message[ :"S1081" ] = "self allocator not supported yet"
+
+# S1082 function \'$1\' not found in signature"
+@@error_message[ :"S1082" ] = "function \'$1\' not found in signature"
+
+# S1083 \'$1\' not found in function \'$2\'"
+@@error_message[ :"S1083" ] = "\'$1\' not found in function \'$2\'"
+
+# S1084 \'$1\' in function \'$2\' is not send or receive"
+@@error_message[ :"S1084" ] = "\'$1\' in function \'$2\' is not send or receive"
+
+# S1085 duplicate allocator specifier for \'$1_$2\'"
+@@error_message[ :"S1085" ] = "duplicate allocator specifier for \'$1_$2\'"
+
+# S1086 rhs not call_port.func.param for $1_$2"
+@@error_message[ :"S1086" ] = "rhs not call_port.func.param for $1_$2"
+
+# S1087 function \'$1\' not found in signature \'$2\'"
+@@error_message[ :"S1087" ] = "function \'$1\' not found in signature \'$2\'"
+
+# S1088 \'$1\' not found in function \'$2\'"
+@@error_message[ :"S1088" ] = "\'$1\' not found in function \'$2\'"
+
+# S1089 relay allocator send/receive mismatch between $1.$2 and $3_$4.$5"
+@@error_message[ :"S1089" ] = "relay allocator send/receive mismatch between $1.$2 and $3_$4.$5"
+
+# S1090 \'$1\' in function \'$2\' is not send or receive"
+@@error_message[ :"S1090" ] = "\'$1\' in function \'$2\' is not send or receive"
+
+# S1091 call port \'$1\' not found in celltype $2"
+@@error_message[ :"S1091" ] = "call port \'$1\' not found in celltype $2"
+
+# S1092 \'$1\' not namespace"
+@@error_message[ :"S1092" ] = "\'$1\' not namespace"
+
+# S1093 $1 : undefined cell"
+@@error_message[ :"S1093" ] = "$1 : undefined cell"
+
+# S1094 $1: pointer is not constant. check \'const\'"
+@@error_message[ :"S1094" ] = "$1: pointer is not constant. check \'const\'"
+
+# S1095 $1: not constant"
+@@error_message[ :"S1095" ] = "$1: not constant"
+
+# S1096 $1: should be int, float, bool or pointer type"
+@@error_message[ :"S1096" ] = "$1: should be int, float, bool or pointer type"
+
+# S1097 $1: has no initializer"
+@@error_message[ :"S1097" ] = "$1: has no initializer"
+
+# S1098 $1: has unsuitable initializer"
+@@error_message[ :"S1098" ] = "$1: has unsuitable initializer"
+
+# S1099 array subscript not constant"
+@@error_message[ :"S1099" ] = "array subscript not constant"
+
+# S1100 $1: cannot initialize var"
+@@error_message[ :"S1100" ] = "$1: cannot initialize var"
+
+# S1101 \'$1\' cannot initialize entry port"
+@@error_message[ :"S1101" ] = "\'$1\' cannot initialize entry port"
+
+# S1102 $1: must specify array subscript here"
+@@error_message[ :"S1102" ] = "$1: must specify array subscript here"
+
+# S1103 $1: need array subscript"
+@@error_message[ :"S1103" ] = "$1: need array subscript"
+
+# S1104 $1: need array subscript number. ex. \'[0]\'"
+@@error_message[ :"S1104" ] = "$1: need array subscript number. ex. \'[0]\'"
+
+# S1105 $1: cannot specify array subscript here"
+@@error_message[ :"S1105" ] = "$1: cannot specify array subscript here"
+
+# S1106 $1: cannot specify array subscript number. use \'[]\'"
+@@error_message[ :"S1106" ] = "$1: cannot specify array subscript number. use \'[]\'"
+
+# S1107 to export port, use \'cCall => composite.cCall\'"
+@@error_message[ :"S1107" ] = "to export port, use \'cCall => composite.cCall\'"
+
+# S1108 $1: rhs not \'Cell.ePort\' form"
+@@error_message[ :"S1108" ] = "$1: rhs not \'Cell.ePort\' form"
+
+# S1109 \'$1\' not found"
+@@error_message[ :"S1109" ] = "\'$1\' not found"
+
+# S1110 \'$1\' not cell"
+@@error_message[ :"S1110" ] = "\'$1\' not cell"
+
+# S1111 \'$1\' not found"
+@@error_message[ :"S1111" ] = "\'$1\' not found"
+
+# S1112 \'$1\' not entry port"
+@@error_message[ :"S1112" ] = "\'$1\' not entry port"
+
+# S1113 \'$1\' signature mismatch"
+@@error_message[ :"S1113" ] = "\'$1\' signature mismatch"
+
+# S1114 \'$1\' should be array"
+@@error_message[ :"S1114" ] = "\'$1\' should be array"
+
+# S1115 $1[$2]: subscript out of range (< $3)"
+@@error_message[ :"S1115" ] = "$1[$2]: subscript out of range (< $3)"
+
+# S1116 \'$1\' entry port is not array"
+@@error_message[ :"S1116" ] = "\'$1\' entry port is not array"
+
+# S1117 \'$1\' not in celltype"
+@@error_message[ :"S1117" ] = "\'$1\' not in celltype"
+
+# S1118 $1: going out from region \'$2\' not permitted"
+@@error_message[ :"S1118" ] = "$1: going out from region \'$2\' not permitted"
+
+# S1119 $1: going from region \'$2\' to \'$3\' not permitted"
+@@error_message[ :"S1119" ] = "$1: going from region \'$2\' to \'$3\' not permitted"
+
+# S1120 $1: going in to region \'$2\' not permitted"
+@@error_message[ :"S1120" ] = "$1: going in to region \'$2\' not permitted"
+
+# S1121 \'$1\' in region \'$2\' cannot be directly joined $3 in  $4"
+@@error_message[ :"S1121" ] = "\'$1\' in region \'$2\' cannot be directly joined $3 in  $4"
+
+# S1122 $1 : not port: \'through\' can be specified only for port"
+@@error_message[ :"S1122" ] = "$1 : not port: \'through\' can be specified only for port"
+
+# S1123 $1 : not port: \'through\' can be specified only for port"
+@@error_message[ :"S1123" ] = "$1 : not port: \'through\' can be specified only for port"
+
+# S1124 $1: plugin function failed: \'get_through_entry_port_name\'"
+@@error_message[ :"S1124" ] = "$1: plugin function failed: \'get_through_entry_port_name\'"
+
+# S1125 $1: not generated cell \'$2\'"
+@@error_message[ :"S1125" ] = "$1: not generated cell \'$2\'"
+
+# S1126 $1: fail to new"
+@@error_message[ :"S1126" ] = "$1: fail to new"
+
+# S1127 \'$1\' duplicate"
+@@error_message[ :"S1127" ] = "\'$1\' duplicate"
+
+# S1128 \'$1\' inconsistent array definition"
+@@error_message[ :"S1128" ] = "\'$1\' inconsistent array definition"
+
+# S1129 \'$1\' redefinition of subscript $1"
+@@error_message[ :"S1129" ] = "\'$1\' redefinition of subscript $1"
+
+# S1130 \'$1\' inconsistent array definition"
+@@error_message[ :"S1130" ] = "\'$1\' inconsistent array definition"
+
+# S1131 \'$1.$2\' has duplicate initializer"
+@@error_message[ :"S1131" ] = "\'$1.$2\' has duplicate initializer"
+
+# S1132 $1: 1st parameter is not string(file name)"
+@@error_message[ :"S1132" ] = "$1: 1st parameter is not string(file name)"
+
+# S1133 $1: 2nd parameter is not string(fromat)"
+@@error_message[ :"S1133" ] = "$1: 2nd parameter is not string(fromat)"
+
+# S1134 $1: unknown factory function"
+@@error_message[ :"S1134" ] = "$1: unknown factory function"
+
+# S1135 celltype factory can\'t have parameter(s)"
+@@error_message[ :"S1135" ] = "celltype factory can\'t have parameter(s)"
+
+# S1136 \'$1\': not found"
+@@error_message[ :"S1136" ] = "\'$1\': not found"
+
+# S1137 \'$1\': not attribute"
+@@error_message[ :"S1137" ] = "\'$1\': not attribute"
+
+# S1138 internal error Factory.check_arg()"
+@@error_message[ :"S1138" ] = "internal error Factory.check_arg()"
+
+# S1139 $1: region path mismatch. previous path: $2"
+@@error_message[ :"S1139" ] = "$1: region path mismatch. previous path: $2"
+
+# S1140 $1: region specifier must place at first appearence"
+@@error_message[ :"S1140" ] = "$1: region specifier must place at first appearence"
+
+# S1141 $1 duplication, previous one : $2"
+@@error_message[ :"S1141" ] = "$1 duplication, previous one : $2"
+
+# S1142 $1 not found in search path"
+@@error_message[ :"S1142" ] = "$1 not found in search path"
+
+# S1143 import_C: arg2: mismatch with previous one"
+@@error_message[ :"S1143" ] = "import_C: arg2: mismatch with previous one"
+
+# S1144 $1: temporary C source: open error"
+@@error_message[ :"S1144" ] = "$1: temporary C source: open error"
+
+# S1145 $1: temporary C source: writing error"
+@@error_message[ :"S1145" ] = "$1: temporary C source: writing error"
+
+# S1146 $1: error occured while CPP"
+@@error_message[ :"S1146" ] = "$1: error occured while CPP"
+
+# S1147 $1: popen for CPP failed"
+@@error_message[ :"S1147" ] = "$1: popen for CPP failed"
+
+# S1148 $1 not found in search path"
+@@error_message[ :"S1148" ] = "$1 not found in search path"
+
+# S1149 $1 not signature"
+@@error_message[ :"S1149" ] = "$1 not signature"
+
+# S1150 $1: fail to new"
+@@error_message[ :"S1150" ] = "$1: fail to new"
+
+# S1151 $1: not namespace"
+@@error_message[ :"S1151" ] = "$1: not namespace"
+
+# S1152 $1: call port cannot have fixed join"
+@@error_message[ :"S1152" ] = "$1: call port cannot have fixed join"
+
+# "S1153 $1: cannot be entry port array for fixed join port"
+@@error_message[ :"S1153" ] = "$1: cannot be entry port array for fixed join port"
+
+# "S1154 $1: must be singleton celltype for fixed join"
+@@error_message[ :"S1154" ] = "$1: must be singleton celltype for fixed join"
+
+# "S1155 $1: not celltype or not found"
+@@error_message[ :"S1155" ] = "$1: not celltype or not found"
+
+# "S1156 $1: not call port or not found"
+@@error_message[ :"S1156" ] = "$1: not call port or not found"
+
+# "S1157 $1: sized array or not array"
+@@error_message[ :"S1157" ] = "$1: sized array or not array"
+
+# "S1158 $1: singleton cell not found for fixed join"
+@@error_message[ :"S1158" ] = "$1: singleton cell not found for fixed join"
+
+# S1159 $1: non-size_is pointer cannot be initialized with array initializer"
+@@error_message[ :"S1159" ] = "$1: non-size_is pointer cannot be initialized with array initializer"
+
+# S1160 $1 must be constant for id"
+@@error_message[ :"S1160" ] = "$1 must be constant for id"
+
+# S1161 $1 must be constant for id"
+@@error_message[ :"S1161" ] = "$1 must be constant for id"
+
+# S1162 $1: id cannot be 0"
+@@error_message[ :"S1162" ] = "$1: id cannot be 0"
+
+# S1163 generate specifier duplicate"
+@@error_message[ :"S1163" ] = "generate specifier duplicate"
+
+# S1164 '$1' set_specified_id: id not positive integer '$2'"
+@@error_message[ :"S1164" ] = "'$1' set_specified_id: id not positive integer '$2'"
+
+# S1165 '$1' set_specified_id: id duplicate"
+@@error_message[ :"S1165" ] = "'$1' set_specified_id: id duplicate"
+
+# S1166 $1: fail to new"
+@@error_message[ :"S1166" ] = "$1: fail to new"
+
+# S1167 \'$1\': relay mismatch \'$2\'"
+@@error_message[ :"S1167" ] = "\'$1\': relay mismatch \'$2\'"
+
+# S1168 too many initializer for array, $1 for $2"
+@@error_message[ :"S1168" ] = "too many initializer for array, $1 for $2"
+
+# S1169 $1: non-size_is pointer cannot be initialized with array initializer"
+@@error_message[ :"S1169" ] = "$1: non-size_is pointer cannot be initialized with array initializer"
+
+# S1170 \'$1\' has size_is but export attr \'$2\' doesn't have"
+@@error_message[ :"S1170" ] = "\'$1\' has size_is but export attr \'$2\' doesn't have"
+
+# S1171 \'$1\' size_is argument of \'$2\' not exported"
+@@error_message[ :"S1171" ] = "\'$1\' size_is argument of \'$2\' not exported"
+
+# S1172 \'$1\' size_is argument mismatch with exporting one \'$2\'"
+@@error_message[ :"S1172" ] = "\'$1\' size_is argument mismatch with exporting one \'$2\'"
+
+# S1173 $1: allocator mismatch from $2's allocator"
+@@error_message[ :"S1173" ] = "$1: allocator mismatch from $2's allocator"
+
+# S1174 $1 not suitable for lhs, suitable lhs: 'func.param'"
+@@error_message[ :"S1174" ] = "$1 not suitable for lhs, suitable lhs: 'func.param'"
+
+# S1175 $1 not found or not allocator entry port for $2"
+@@error_message[ :"S1175" ] = "$1 not found or not allocator entry port for $2"
+
+# S1176 rhs not in 'call_port.func.param' form for $1_$2"
+@@error_message[ :"S1176" ] = "rhs not in 'call_port.func.param' form for $1_$2"
+
+# S1177 cannot specify 'through' in composite in current version"
+@@error_message[ :"S1177" ] = "cannot specify 'through' in composite in current version"
+
+# S1178 $1 region type specifier duplicate, previous $2"
+@@error_message[ :"S1178" ] = "$1 region type specifier duplicate, previous $2"
+
+### syntaxobj.rb
+# S2001 \'$1\' duplicate $2"
+@@error_message[ :"S2001" ] = "\'$1\' duplicate $2"
+
+# S2002 $1: $2"
+@@error_message[ :"S2002" ] = "$1: $2"
+
+# S2003 $1: $2 cannot have initializer"
+@@error_message[ :"S2003" ] = "$1: $2 cannot have initializer"
+
+# S2004 $1: array subscript must be specified or omit"
+@@error_message[ :"S2004" ] = "$1: array subscript must be specified or omit"
+
+# S2005 $1: array subscript must be specified"
+@@error_message[ :"S2005" ] = "$1: array subscript must be specified"
+
+# S2006 \'$1\' function"
+@@error_message[ :"S2006" ] = "\'$1\' function"
+
+# S2007 \'$1\' $2"
+@@error_message[ :"S2007" ] = "\'$1\' $2"
+
+# S2008 $1: inconsitent with previous one"
+@@error_message[ :"S2008" ] = "$1: inconsitent with previous one"
+
+# S2009 $1: not found or not signature"
+@@error_message[ :"S2009" ] = "$1: not found or not signature"
+
+# S2010 $1: not allocator signature"
+@@error_message[ :"S2010" ] = "$1: not allocator signature"
+
+# S2011 size_is duplicate"
+@@error_message[ :"S2011" ] = "size_is duplicate"
+
+# S2012 count_is duplicate"
+@@error_message[ :"S2012" ] = "count_is duplicate"
+
+# S2013 string duplicate"
+@@error_message[ :"S2013" ] = "string duplicate"
+
+# S2014 $1 need pointer or more pointer"
+@@error_message[ :"S2014" ] = "$1 need pointer or more pointer"
+
+# S2015 $1 must be const for \'in\' parameter $2"
+@@error_message[ :"S2015" ] = "'$1' must be const for \'in\' parameter $2"
+
+# S2016 $1 can not be const for $2 parameter"
+@@error_message[ :"S2016" ] = "'$1' can not be const for $2 parameter"
+
+# S2017 size_is argument is not integer type"
+@@error_message[ :"S2017" ] = "size_is argument is not integer type"
+
+# S2018 \'$1\' size_is parameter not integer"
+@@error_message[ :"S2018" ] = "\'$1\' size_is parameter not integer"
+
+# S2019 \'$1\' size_is parameter negative or zero"
+@@error_message[ :"S2019" ] = "\'$1\' size_is parameter negative or zero"
+
+# S2020 count_is argument is not integer type"
+@@error_message[ :"S2020" ] = "count_is argument is not integer type"
+
+# S2021 \'$1\' count_is parameter not integer"
+@@error_message[ :"S2021" ] = "\'$1\' count_is parameter not integer"
+
+# S2022 \'$1\' count_is parameter negative or zero"
+@@error_message[ :"S2022" ] = "\'$1\' count_is parameter negative or zero"
+
+# S2023 string argument is not integer type"
+@@error_message[ :"S2023" ] = "string argument is not integer type"
+
+# S2024 \'$1\' string parameter not integer"
+@@error_message[ :"S2024" ] = "\'$1\' string parameter not integer"
+
+# S2025 \'$1\' string parameter negative or zero"
+@@error_message[ :"S2025" ] = "\'$1\' string parameter negative or zero"
+
+# S2026 '$1' nullable specified for non-pointer type"
+@@error_message[ :"S2026" ] = "'$1' nullable specified for non-pointer type"
+
+# S2027 '$1' parameter cannot be void type"
+@@error_message[ :"S2027" ] = "'$1' parameter cannot be void type"
+
+# S2028 '$1' max (size_is 2nd parameter) not constant"
+@@error_message[ :"S2028" ] = "'$1' max (size_is 2nd parameter) not constant"
+
+# S2029 '$1' max (size_is 2nd parameter) negative or zero, or not integer"
+@@error_message[ :"S2029" ] = "'$1' max (size_is 2nd parameter) negative or zero, or not integer"
+
+# S2030 '$1' both size_is and max are const. size_is larger than max"
+@@error_message[ :"S2030" ] = "'$1' both size_is and max are const. size_is larger than max"
+
+### optimize.rb
+# S3001 $1: id too large $2 (max=$3)"
+@@error_message[ :"S3001" ] = "$1: id too large $2 (max=$3)"
+
+# S3002 $1: id too large $2 (max=$3)"
+@@error_message[ :"S3002" ] = "$1: id too large $2 (max=$3)"
+
+# S3003 $1: id number '$2' conflict with $3"
+@@error_message[ :"S3003" ] = "$1: id number '$2' conflict with $3"
+
+### types.rb
+# T1001 const duplicate"
+@@error_message[ :"T1001" ] = "const duplicate"
+
+# T1002 volatile duplicate"
+@@error_message[ :"T1002" ] = "volatile duplicate"
+
+# T1003 $1: unsuitable specifier for $2"
+@@error_message[ :"T1003" ] = "$1: unsuitable specifier for $2"
+
+# T1004 cannot cast to $1"
+@@error_message[ :"T1004" ] = "cannot cast to $1"
+
+# T1005 \'$1\' not defined"
+@@error_message[ :"T1005" ] = "\'$1\' not defined"
+
+# T1006 \'$1\' not type name. expecting type name here"
+@@error_message[ :"T1006" ] = "\'$1\' not type name. expecting type name here"
+
+# T1007 $1: void type variable cannot have initializer"
+@@error_message[ :"T1007" ] = "$1: void type variable cannot have initializer"
+
+# T1008 ambigous signed or unsigned"
+@@error_message[ :"T1008" ] = "ambigous signed or unsigned"
+
+# T1009 $1: $2: not integer"
+@@error_message[ :"T1009" ] = "$1: $2: not integer"
+
+# T1010 $1: initializer is not constant"
+@@error_message[ :"T1010" ] = "$1: initializer is not constant"
+
+# T1011 $1: need cast to assign float to integer"
+@@error_message[ :"T1011" ] = "$1: need cast to assign float to integer"
+
+# T1012 $1: $2: not integer"
+@@error_message[ :"T1012" ] = "$1: $2: not integer"
+
+# T1013 $1: too large (max=$2)"
+@@error_message[ :"T1013" ] = "$1: too large (max=$2)"
+
+# T1014 $1: too large negative value (min=-$2)"
+@@error_message[ :"T1014" ] = "$1: too large negative value (min=-$2)"
+
+# T1015 $1: negative value for unsigned"
+@@error_message[ :"T1015" ] = "$1: negative value for unsigned"
+
+# T1016 $1: too large (max=$2)"
+@@error_message[ :"T1016" ] = "$1: too large (max=$2)"
+
+# T1017 $1: unsuitable initializer for scalar type"
+@@error_message[ :"T1017" ] = "$1: unsuitable initializer for scalar type"
+
+# T1018 $1: $2: not number"
+@@error_message[ :"T1018" ] = "$1: $2: not number"
+
+# T1019 $1: initializer is not constant"
+@@error_message[ :"T1019" ] = "$1: initializer is not constant"
+
+# T1020 $1: unsuitable initializer for scalar type"
+@@error_message[ :"T1020" ] = "$1: unsuitable initializer for scalar type"
+
+# T1021 \'$1\': struct not defined"
+@@error_message[ :"T1021" ] = "\'$1\': struct not defined"
+
+# T1022 struct $1: not defined"
+@@error_message[ :"T1022" ] = "struct $1: not defined"
+
+# T1023 struct $1: not defined"
+@@error_message[ :"T1023" ] = "struct $1: not defined"
+
+# T1024 $1: unsuitable initializer for struct"
+@@error_message[ :"T1024" ] = "$1: unsuitable initializer for struct"
+
+# T1025 size_is argument is not integer type"
+@@error_message[ :"T1025" ] = "size_is argument is not integer type"
+
+# T1026 count_is argument is not integer type"
+@@error_message[ :"T1026" ] = "count_is argument is not integer type"
+
+# T1027 string argument is not integer type"
+@@error_message[ :"T1027" ] = "string argument is not integer type"
+
+# T1028 $1: cannot initialize function pointer"
+@@error_message[ :"T1028" ] = "$1: cannot initialize function pointer"
+
+# T1029 oneway function cannot return type \'$1$2\', \'void\' or \'ER\' is permitted"
+@@error_message[ :"T1029" ] = "oneway function cannot return type \'$1$2\', \'void\' or \'ER\' is permitted"
+
+# T1030 oneway function cannot have $1 parameter for \'$2\'"
+@@error_message[ :"T1030" ] = "oneway function cannot have $1 parameter for \'$2\'"
+
+# T1031 $1: unsuitable initializer for array"
+@@error_message[ :"T1031" ] = "$1: unsuitable initializer for array"
+
+# T1032 $1: incompatible pointer type"
+@@error_message[ :"T1032" ] = "$1: incompatible pointer type"
+
+# T1033 $1: need cast to assign integer to pointer"
+@@error_message[ :"T1033" ] = "$1: need cast to assign integer to pointer"
+
+# T1034 $1: unsuitable string constant"
+@@error_message[ :"T1034" ] = "$1: unsuitable string constant"
+
+# T1035 $1: unsuitable initializer for pointer"
+@@error_message[ :"T1035" ] = "$1: unsuitable initializer for pointer"
+
+# T1036 $1: unsuitable initializer for pointer"
+@@error_message[ :"T1036" ] = "$1: unsuitable initializer for pointer"
+
+# T1037 $1: not number"
+@@error_message[ :"T1037" ] = "$1: not number"
+
+# T1038 $1: initializer type mismatch. '$2' & '$3'"
+@@error_message[ :"T1038" ] = "$1: initializer type mismatch. '$2' & '$3'"
+
+# T1039 $1: struct tag mismatch $2 and $3"
+@@error_message[ :"T1039" ] = "$1: struct tag mismatch $2 and $3"
+
+# T1040 $1 specified for void pointer type"
+@@error_message[ :"T1040" ] = "$1 specified for void pointer type"
+
+### gen_xml.rb
+# T2001 fail to create XML file $1"
+@@error_message[ :"T2001" ] = "fail to create XML file $1"
+
+# TEMPORAL set_definition_join: uninitialized array member"
+@@error_message[ :"TEMPORAL" ] = "set_definition_join: uninitialized array member"
+
+# V1001 $1: unable for $2"
+@@error_message[ :"V1001" ] = "$1: unable for $2"
+
+# V1002 $1: cannot cast to bool (implicitly)"
+@@error_message[ :"V1002" ] = "$1: cannot cast to bool (implicitly)"
+
+# V1003 $1: cannot cast to integer (implicitly)"
+@@error_message[ :"V1003" ] = "$1: cannot cast to integer (implicitly)"
+
+# V1004 $1: cannot cast to float (implicitly)"
+@@error_message[ :"V1004" ] = "$1: cannot cast to float (implicitly)"
+
+# V1005 Cannot cast pointer to float"
+@@error_message[ :"V1005" ] = "Cannot cast pointer to float"
+
+# V1006 pointer value cannot cast to $1"
+@@error_message[ :"V1006" ] = "pointer value cannot cast to $1"
+
+# V1007 convert pointer value to bool"
+@@error_message[ :"V1007" ] = "convert pointer value to bool"
+
+# V1008 convert pointer value to integer without cast"
+@@error_message[ :"V1008" ] = "convert pointer value to integer without cast"
+
+# V1009 / : divieded by zero"
+@@error_message[ :"V1009" ] = "/ : divieded by zero"
+
+# V1010 / : divieded by zero"
+@@error_message[ :"V1010" ] = "/ : divieded by zero"
+
+# V1011 % : divieded by zero"
+@@error_message[ :"V1011" ] = "% : divieded by zero"
+
+# V1012 % : divieded by zero"
+@@error_message[ :"V1012" ] = "% : divieded by zero"
+
+# V1013 integer value cannot cast to $1"
+@@error_message[ :"V1013" ] = "integer value cannot cast to $1"
+
+# V1014 comparing bool value with \'$1\'"
+@@error_message[ :"V1014" ] = "comparing bool value with \'$1\'"
+
+# V1015 comparing bool value with \'$1\'"
+@@error_message[ :"V1015" ] = "comparing bool value with \'$1\'"
+
+# V1016 bool value cannot cast to $1"
+@@error_message[ :"V1016" ] = "bool value cannot cast to $1"
+
+# V1017 / : divieded by zero"
+@@error_message[ :"V1017" ] = "/ : divieded by zero"
+
+# V1018 % : divieded by zero"
+@@error_message[ :"V1018" ] = "% : divieded by zero"
+
+# V1019 floating value cannot cast to $1"
+@@error_message[ :"V1019" ] = "floating value cannot cast to $1"
+
+# V1020 convert floating value to bool without cast"
+@@error_message[ :"V1020" ] = "convert floating value to bool without cast"
+
+# V1021 convert floating value to integer without cast"
+@@error_message[ :"V1021" ] = "convert floating value to integer without cast"
+
+# V1022 string cannot cast to integer"
+@@error_message[ :"V1022" ] = "string cannot cast to integer"
+
+# V1023 string cannot cast to float"
+@@error_message[ :"V1023" ] = "string cannot cast to float"
+
+# V1024 string cannot cast to pointer"
+@@error_message[ :"V1024" ] = "string cannot cast to pointer"
+
+# V1025 string cannot cast to $1"
+@@error_message[ :"V1025" ] = "string cannot cast to $1"
+
+###
+# warning ã¡ãã»ã¼ã¸
+@@warning_message = {}
+
+### componentobj.rb
+# W1001 \'$1\': unknown context type. usually specifiy task, non-task or any"
+@@warning_message[ :"W1001" ] = "\'$1\': unknown context type. usually specifiy task, non-task or any"
+
+# W1002 $1: non-active celltype has no entry port & factory"
+@@warning_message[ :"W1002" ] = "$1: non-active celltype has no entry port & factory"
+
+# W1003 $1 : require call port overridden in $2"
+@@warning_message[ :"W1003" ] = "$1 : require call port overridden in $2"
+
+# W1004 $1 : specified singleton but has no singleton in this celltype"
+@@warning_message[ :"W1004" ] = "$1 : specified singleton but has no singleton in this celltype"
+
+# W1005 $1 : idx_is_id is ineffective for composite celltype"
+@@warning_message[ :"W1005" ] = "$1 : idx_is_id is ineffective for composite celltype"
+
+# W1006 $1 : only prototype, unused and undefined cell"
+@@warning_message[ :"W1006" ] = "$1 : only prototype, unused and undefined cell"
+
+# W1007 $1 : non-active cell has no entry join and no factory"
+@@warning_message[ :"W1007" ] = "$1 : non-active cell has no entry join and no factory"
+
+# W1008 $1: reuse designation mismatch with previous import"
+@@warning_message[ :"W1008" ] = "$1: reuse designation mismatch with previous import"
+
+# "W1009 $1: fixed join entry port has multi join"
+@@warning_message[ :"W1009" ] = "$1: fixed join entry port has multi join"
+
+### types.rb
+# W2001 signed int$1_t: obsolete. use int$2_t"
+@@warning_message[ :"W2001" ] = "signed int$1_t: obsolete. use int$2_t"
+
+# W2002 unsinged int$1_t: obsolete. use uint$2_t"
+@@warning_message[ :"W2002" ] = "unsinged int$1_t: obsolete. use uint$2_t"
+
+# W2003 $1: too large to cast to $2, clipped($3)"
+@@warning_message[ :"W2003" ] = "$1: too large to cast to $2, clipped($3)"
+
+# W2004 $1: too small to cast to $2, clipped($3)"
+@@warning_message[ :"W2004" ] = "$1: too small to cast to $2, clipped($3)"
+
+# W2005 $1: negative value for unsigned: convert to $2"
+@@warning_message[ :"W2005" ] = "$1: negative value for unsigned: convert to $2"
+
+### syntaxobj.rb
+# W3001 $1: duplicate"
+@@warning_message[ :"W3001" ] = "$1: duplicate"
+
+# W3002 $1: this string might cause buffer over run"
+@@warning_message[ :"W3002" ] = "$1: this string might cause buffer over run"
+
+# W3003 $1 pointer level mismatch"
+@@warning_message[ :"W3003" ] = "$1 pointer level mismatch"
+
+# W3004 $1 pointer type has returned. specify deviate or stop return pointer"
+@@error_message[ :"W3004" ] = "$1 pointer type has returned. specify deviate or stop return pointer"
+
+# W3005 '$1' size_is always lower than max. max is ignored"
+@@error_message[ :"W3005" ] = "'$1' size_is always lower than max. max is ignored"
+
+### bnf.y.rb
+# W5001 bool: obsolete type. use bool_t"
+@@warning_message[ :"W5001" ] = "bool: obsolete type. use bool_t"
+
+# W5002 float: obsolete type. use float32_t"
+@@warning_message[ :"W5002" ] = "float: obsolete type. use float32_t"
+
+# W5003 double: obsolete type. use double64_t"
+@@warning_message[ :"W5003" ] = "double: obsolete type. use double64_t"
+
+# W5004 char: obsolete type. use char_t"
+@@warning_message[ :"W5004" ] = "char: obsolete type. use char_t"
+
+# W5005 int8: obsolete. use int8_t"
+@@warning_message[ :"W5005" ] = "int8: obsolete. use int8_t"
+
+# W5006 int16: obsolete. use int16_t"
+@@warning_message[ :"W5006" ] = "int16: obsolete. use int16_t"
+
+# W5007 int32: obsolete. use int32_t"
+@@warning_message[ :"W5007" ] = "int32: obsolete. use int32_t"
+
+# W5008 int64: obsolete. use int64_t"
+@@warning_message[ :"W5008" ] = "int64: obsolete. use int64_t"
+
+# W5009 int64: obsolete. use int64_t"
+@@warning_message[ :"W5009" ] = "int64: obsolete. use int64_t"
+
+# W5010 need 'void' for no parameter"
+@@warning_message[ :"W5010" ] = "need 'void' for no parameter"
+
+# W5011 need 'void' for no parameter"
+@@warning_message[ :"W5011" ] = "need 'void' for no parameter"
+
+### C_parser.y.rb
+# W6001 need 'void' for no parameter"
+@@warning_message[ :"W6001" ] = "need 'void' for no parameter"
+
+# W6002 need 'void' for no parameter"
+@@warning_message[ :"W6002" ] = "need 'void' for no parameter"
+
+# W6003 need 'void' for no parameter"
+@@warning_message[ :"W6003" ] = "need 'void' for no parameter"
+
+# W6004 need 'void' for no parameter"
+@@warning_message[ :"W6004" ] = "need 'void' for no parameter"
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_ja_JP.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_ja_JP.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_console_ja_JP.rb	(revision 317)
@@ -0,0 +1,1277 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: messages_console_ja_JP.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+
+# Console Messages for ja_JP
+class TECSMsg
+
+###
+# ã¨ã©ã¼ã¡ãã»ã¼ã¸
+@@error_message = {}
+
+### C_parser.y.rb
+# B1001 need parameter name"
+@@error_message[ :"B1001" ] = "ãã©ã¡ã¼ã¿åãå¿
+è¦ã§ã" 
+
+# B1002 while open or reading \'$1\'"
+@@error_message[ :"B1002" ] = "\'$1\' ã®ãªã¼ãã³ã¾ãã¯èª­ã¿è¾¼ã¿ã«å¤±æãã¾ãã" 
+
+# B1003 Unexpected EOF"
+@@error_message[ :"B1003" ] = "äºæããªã EOF ã§ã"
+
+# B1004 syntax error near \'$1\'"
+@@error_message[ :"B1004" ] = "\'$1\' ä»è¿ã®æ§æã¨ã©ã¼ã§ã"
+
+### ctypes.rb
+# C1001 $1: mismatch, suitable for integer types"
+@@error_message[ :"C1001" ] = "$1: æ´åãã¦ãã¾ãã, ããã¯æ´æ°åã«é©ãã¦ãã¾ã"
+
+# C1002 $1 not compatible with previous one $2"
+@@error_message[ :"C1002" ] = "$1 ã¯ããä»¥åã®ãã®ã§ãã $2 ã¨ä¸¡ç«ãã¾ãã"
+
+# C1003 $1 & $2 incompatible  (\'long double\' not support)"
+@@error_message[ :"C1003" ] = "$1 åã³ $2 ã¯ä¸¡ç«ãã¾ãã (\'long double\' ã¯æªãµãã¼ã)"
+
+# C1004 $1: qualifier respecified. previous one: $2"
+@@error_message[ :"C1004" ] = "$1: ä¿®é£¾å­ãååº¦æå®ããã¾ãã. ãã®åã®ä¿®é£¾å­: $2"
+
+### expression.rb
+# E1001 $1: not found"
+@@error_message[ :"E1001" ] = "$1: è¦ã¤ããã¾ãã"
+
+# E1002 $1: not constant (port)"
+@@error_message[ :"E1002" ] = "$1: å®æ°ã§ã¯ããã¾ãã (port)"
+
+# E1003 $1: not constant"
+@@error_message[ :"E1003" ] = "$1: å®æ°ã§ã¯ããã¾ãã"
+
+# E1004 cannot evaluate \'[]\' operator"
+@@error_message[ :"E1004" ] = "\'[]\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1005 cannot evaluate \'.\' operator"
+@@error_message[ :"E1005" ] = "\'.\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1006 cannot evaluate \'->\' operator"
+@@error_message[ :"E1006" ] = "\'->\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1007 cannot evaluate \'sizeof\' operator"
+@@error_message[ :"E1007" ] = "\'sizeof\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1008 cannot evaluate \'sizeof\' operator"
+@@error_message[ :"E1008" ] = "\'sizeof\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1009 cannot evaluate \'&\' operator"
+@@error_message[ :"E1009" ] = "\'&\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1010 cannot evaluate \'*\' operator"
+@@error_message[ :"E1010" ] = "\'*\' æ¼ç®å­ãè©ä¾¡ã§ãã¾ãã"
+
+# E1011 cannot evaluate unary + for $1"
+@@error_message[ :"E1011" ] = "$1 ã«å¯¾ããåé 
+ã® + ãè©ä¾¡ã§ãã¾ãã"
+
+# E1012 $1: not found in parameter list"
+@@error_message[ :"E1012" ] = "$1: ãã©ã¡ã¼ã¿ãªã¹ãã®ä¸­ã«è¦ã¤ããã¾ãã"
+
+# E1013 \'*\': operand is not pointer value"
+@@error_message[ :"E1013" ] = "\'*\': ãªãã©ã³ãã¯ãã¤ã³ã¿å¤ã§ã¯ããã¾ãã"
+
+# E1014 $1: elements_get_type: sorry not supported"
+@@error_message[ :"E1014" ] = "$1: elements_get_type: ç³ãè¨³ããã¾ããï¼ãµãã¼ãããã¦ãã¾ãã"
+
+# E1015 \'$1\': direction mismatch for $2, $3 required"
+@@error_message[ :"E1015" ] = "\'$1\': $2 ã«å¯¾ããæ¹åãæ´åãã¦ãã¾ããï¼$3 ãå¿
+è¦ã§ã"
+
+# E1016 $1: elements_check_dir_for_param: sorry not supported"
+@@error_message[ :"E1016" ] = "$1: elements_check_dir_for_param: ç³ãè¨³ããã¾ããï¼ãµãã¼ãããã¦ãã¾ãã"
+
+# E1017 $1: rhs not \'Cell.ePort\' form"
+@@error_message[ :"E1017" ] = "$1: å³è¾ºã \'Cell.ePort\' å½¢å¼ã§ã¯ããã¾ãã"
+
+# E1018 $1: namespace cannot be specified"
+@@error_message[ :"E1018" ] = "$1: namespace ãæå®ã§ãã¾ãã"
+
+# E1019 $1: rhs not in 'allocator_entry_port' form"
+@@error_message[ :"E1019" ] = "$1: å³è¾ºã 'allocator_entry_port' å½¢å¼ã§ã¯ããã¾ãã"
+
+# E1020 rhs not in 'call_port.func.param' form for $1_$2"
+@@error_message[ :"E1020" ] = "å³è¾ºã 'call_port.func.param' å½¢å¼ã§ããã¾ãã ($1_$2)"
+
+### bnf.y.rb
+# G1001 need specifier for \'$1\'"
+@@error_message[ :"G1001" ] = "\'$1\' ã«å¯¾ããæå®å­ãå¿
+è¦ã§ã"
+
+# G1002 need parameter name"
+@@error_message[ :"G1002" ] = "ãã©ã¡ã¼ã¿åãå¿
+è¦ã§ã"
+
+# G1003 need parameter name"
+@@error_message[ :"G1003" ] = "ãã©ã¡ã¼ã¿åãå¿
+è¦ã§ã"
+
+# G1004 impossible array type 0"
+@@error_message[ :"G1004" ] = "ããå¾ãªãé
+åå 0 ã§ã"
+
+# G1005 impossible array type 1"
+@@error_message[ :"G1005" ] = "ããå¾ãªãé
+åå 1 ã§ã"
+
+# G1006 impossible array type 2"
+@@error_message[ :"G1006" ] = "ããå¾ãªãé
+åå 2 ã§ã"
+
+# G1007 impossible array type 3"
+@@error_message[ :"G1007" ] = "ããå¾ãªãé
+åå 3 ã§ã"
+
+# G1008 impossible function type"
+@@error_message[ :"G1008" ] = "ããå¾ãªãé¢æ°åã§ã"
+
+# G1009 unexpected specifier"
+@@error_message[ :"G1009" ] = "äºæããªãæå®å­ã§ã"
+
+# G1010 Not function"
+@@error_message[ :"G1010" ] = "é¢æ°ã§ã¯ããã¾ãã"
+
+# G1011 Not function"
+@@error_message[ :"G1011" ] = "é¢æ°ã§ã¯ããã¾ãã"
+
+# G1012 $1 : cannot put specifier here"
+@@error_message[ :"G1012" ] = "$1 : ããã«æå®å­ãç½®ããã¨ã¯ã§ãã¾ãã"
+
+# G1013 unexpected specifier"
+@@error_message[ :"G1013" ] = "äºæããªãæå®å­ã§ã"
+
+# G1014 while open or reading \'$1\'"
+@@error_message[ :"G1014" ] = "\'$1\' ã®ãªã¼ãã³ã¾ãã¯èª­ã¿è¾¼ã¿ã«å¤±æãã¾ãã"
+
+# G1015 Unexpected EOF"
+@@error_message[ :"G1015" ] = "äºæããªã EOF ã§ã"
+
+# G1016 syntax error near \'$1\'"
+@@error_message[ :"G1016" ] = "\'$1\' ä»è¿ã®æ§æã¨ã©ã¼ã§ã"
+
+### plugin.rb
+# P1001 plugin arg: cannot find identifier in $1"
+@@error_message[ :"P1001" ] = "plugin arg: $1 ã®ä¸­ã«è­å¥å­ãè¦ã¤ãããã¨ãã§ãã¾ãã"
+
+# P1002 plugin arg: expecting \'=\' not \'$1\'"
+@@error_message[ :"P1002" ] = "plugin arg: \'$1\' ã§ã¯ãªã \'=\' ãå¿
+è¦ã§ã"
+
+# P1003 plugin arg: unexpected $1"
+@@error_message[ :"P1003" ] = "plugin arg: äºæããªã $1 ã§ã"
+
+# P1004 $1: unknown plugin argument\'s identifier\n  $2 are acceptable for RPCPlugin."
+@@error_message[ :"P1004" ] = "$1: ä¸æãªãã©ã°ã¤ã³å¼æ°ã®è­å¥å­\n  $2 ã RPC ãã©ã°ã¤ã³ã«å¯¾ãã¦åãå
+¥ãå¯è½ã§ã"
+
+### pluginModule.rb
+# P2001 $1.rb : fail to load plugin"
+@@error_message[ :"P2001" ] = "$1.rb : ãã©ã°ã¤ã³ã®èª­ã¿è¾¼ã¿ã«å¤±æãã¾ãã"
+
+# P2002 $1: not kind of $2"
+@@error_message[ :"P2002" ] = "$1: $2 ã®ä¸ç¨®ã§ã¯ããã¾ãã"
+
+# P2003 $1: load failed"
+@@error_message[ :"P2003" ] = "$1: èª­ã¿è¾¼ã¿ã«å¤±æãã¾ãã"
+
+# P2004 $1: open error \'$2\'"
+@@error_message[ :"P2004" ] = "$1: ãªã¼ãã³ã¨ã©ã¼ \'$2\' ãçºçãã¾ãã"
+
+# P2005 $1: plugin error in gen_through_cell_code "
+@@error_message[ :"P2005" ] = "$1: gen_through_cell_code å
+ã®ãã©ã°ã¤ã³ã¨ã©ã¼ãçºçãã¾ãã"
+
+# P2006 $1: close error \'$2\'"
+@@error_message[ :"P2006" ] = "$1: \'$2\' ã®ã¯ã­ã¼ãºã¨ã©ã¼ãçºçãã¾ãã"
+
+# P2007 $1: fail to generate post code"
+@@error_message[ :"P2007" ] = "$1: ãã¹ãã³ã¼ãã®çæã«å¤±æãã¾ãã"
+
+### componentobj.rb
+# S1001 context specifier duplicate"
+@@error_message[ :"S1001" ] = "ã³ã³ãã­ã¹ãæå®å­ãéè¤ãã¦ãã¾ã"
+
+# S1002 \'$1\': unknown specifier for signature"
+@@error_message[ :"S1002" ] = "\'$1\': ã·ã°ããã£ã«å¯¾ããä¸æãªæå®å­ã§ã"
+
+# S1003 $1: \'alloc\' 1st parameter neither [in] integer type nor [out] double pointer type
+@@error_message[ :"S1003" ] = "$1: \'alloc\' é¢æ°ã®ç¬¬1ãã©ã¡ã¼ã¿ã in ã®æ´æ°åã§ã out ã®äºéãã¤ã³ã¿åã§ãããã¾ããï¼"
+
+# S1004 $1: \'alloc\' 2nd parameter not [in] double pointer"
+@@error_message[ :"S1004" ] = "$1: \'alloc\' é¢æ°ã®ç¬¬2ãã©ã¡ã¼ã¿ã in ã®ãã¤ã³ã¿ã¸ã®ãã¤ã³ã¿ã§ã¯ããã¾ããï¼"
+
+# S1005 $1: \'alloc\' has no parameter, unsuitable for allocator signature"
+@@error_message[ :"S1005" ] = "$1: \'alloc\' é¢æ°ããã©ã¡ã¼ã¿ãæã£ã¦ãã¾ããï¼ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã«å¯¾ãã¦ä¸é©å½ã§ãï¼"
+
+# S1006 $1: \'dealloc\' 1st parameter not [in] pointer type"
+@@error_message[ :"S1006" ] = "$1: \'dealloc\' é¢æ°ã®ç¬¬1ãã©ã¡ã¼ã¿ã in ã®ãã¤ã³ã¿åã§ã¯ããã¾ããï¼"
+
+# S1007 "
+     # S1007 $1: \'dealloc\' cannot has 2nd parameter"
+# @@error_message[ :"S1007" ] = "$1: \'dealloc\' é¢æ°ã¯ç¬¬2ãã©ã¡ã¼ã¿ãæã¤ãã¨ãã§ãã¾ããï¼"
+
+# S1008 $1: \'dealloc\' has no parameter, unsuitable for allocator signature"
+@@error_message[ :"S1008" ] = "$1: \'dealloc\' é¢æ°ããã©ã¡ã¼ã¿ãæã£ã¦ãã¾ããï¼ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã«å¯¾ãã¦ä¸é©å½ã§ãï¼"
+
+# S1009 $1: \'alloc\' function not found, unsuitable for allocator signature"
+@@error_message[ :"S1009" ] = "$1: \'alloc\' é¢æ°ãè¦ã¤ããã¾ããï¼ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã«å¯¾ãã¦ä¸é©å½ã§ãï¼"
+
+# S1010 $1: \'dealloc\' function not found, unsuitable for allocator signature"
+@@error_message[ :"S1010" ] = "$1: \'dealloc\' é¢æ°ãè¦ã¤ããã¾ããï¼ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã«å¯¾ãã¦ä¸é©å½ã§ãï¼"
+
+# S1011 $1: size_is specified for non-pointer type"
+@@error_message[ :"S1011" ] = "$1: éãã¤ã³ã¿åã«å¯¾ãã¦ size_is ãæå®ããã¾ãã"
+
+# S1012 $1: unsuitable initializer, need array initializer"
+@@error_message[ :"S1012" ] = "$1: ä¸é©å½ãªåæåå­ã§ãï¼é
+åã®åæåå­ãå¿
+è¦ã§ãï¼"
+
+# S1013 $1: too many initializer, $2 for $3"
+@@error_message[ :"S1013" ] = "$1: åæåå­ãå¤ããã¾ãï¼$3 ã¨ããã¨ããã $2 ã¨ãã¾ããï¼"
+
+# S1014 generate specifier duplicate"
+@@error_message[ :"S1014" ] = "generate æå®å­ãéè¤ãã¾ããï¼"
+
+# S1015 $1 cannot be specified for composite"
+@@error_message[ :"S1015" ] = "$1 ã¯è¤åã»ã«ã«å¯¾ãã¦æå®ã§ãã¾ããï¼"
+
+# S1016 $1 not found"
+@@error_message[ :"S1016" ] = "$1 ãè¦ã¤ããã¾ãã"
+
+# S1017 $1 : neither celltype nor cell"
+@@error_message[ :"S1017" ] = "$1 : ã»ã«ã¿ã¤ãã§ãã»ã«ã§ãããã¾ãã"
+
+# S1018 $1 : not singleton cell"
+@@error_message[ :"S1018" ] = "$1 : ã·ã³ã°ã«ãã³ã»ã«ã§ã¯ããã¾ãã"
+
+# S1019 \'$1\' : not entry port"
+@@error_message[ :"S1019" ] = "\'$1\' : åãå£ã§ã¯ããã¾ãã"
+
+# S1020 \'$1\' : required port cannot be array"
+@@error_message[ :"S1020" ] = "\'$1\' : è¦æ±ãããå£(port)ã¯é
+åã«åºæ¥ã¾ããï¼"
+
+# S1021 $1 : require cannot have same signature with \'$2\'"
+@@error_message[ :"S1021" ] = "$1 : ãªã¯ã¯ã¤ã¢ã¯ \'$2\' ã¨åãã·ã°ããã£ãæã¤ãã¨ãåºæ¥ã¾ããï¼"
+
+# S1022 $1.$2 : \'$3\' conflict function name in $4.$5"
+@@error_message[ :"S1022" ] = "$1.$2 : \'$3\' ã¯ $4.$5 ã«ãããé¢æ°åã¨è¡çªãã¦ãã¾ãï¼"
+
+# S1023 $1: fail to new"
+@@error_message[ :"S1023" ] = "$1: new ã«å¤±æãã¾ããï¼"
+
+# S1024 $1: multiple cell for singleton celltype"
+@@error_message[ :"S1024" ] = "$1: ã·ã³ã°ã«ãã³ã»ã«ã¿ã¤ãã«å¯¾ãè¤æ°ã®ã»ã«ãå­å¨ãã¾ãï¼"
+
+# S1025 not found reachable cell for require \'$1\' in celltype \'$2\'"
+@@error_message[ :"S1025" ] = "ã»ã«ã¿ã¤ã \'$2\' å
+ã®ãªã¯ã¯ã¤ã¢ \'$1\' ã¸å°éå¯è½ãªã»ã«ãè¦ã¤ããã¾ããï¼"
+
+# S1026 required cell \'$1\' not reachable"
+@@error_message[ :"S1026" ] = "å¿
+è¦ã¨ãããã»ã« \'$1\' ã¯å°éå¯è½ã§ã¯ããã¾ããï¼"
+
+# S1027 \'$1\' celltype not found"
+@@error_message[ :"S1027" ] = "ã»ã«ã¿ã¤ã \'$1\' ãè¦ã¤ããã¾ãã"
+
+# S1028 \'$1\' not celltype"
+@@error_message[ :"S1028" ] = "\'$1\' ã¯ã»ã«ã¿ã¤ãã§ã¯ããã¾ãã"
+
+# S1029 $1 mismatch with previous one"
+@@error_message[ :"S1029" ] = "$1 ãããä»¥åã®ãã®ã¨æ´åãã¦ãã¾ãã"
+
+# S1030 $1: celltype mismatch with previous one"
+@@error_message[ :"S1030" ] = "$1: ã»ã«ã¿ã¤ããããä»¥åã®ãã®ã¨æ´åãã¦ãã¾ãã"
+
+# S1031 $1 region \'$2\' mismatch  with previous one \'$3\'"
+@@error_message[ :"S1031" ] = "ã»ã« $1 ã®ãªã¼ã¸ã§ã³ \'$2\' ã¯ããä»¥åã®ãªã¼ã¸ã§ã³ \'$3\' ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1032 $1: duplicate cell"
+@@error_message[ :"S1032" ] = "$1: ã»ã«ãéè¤ãã¦ãã¾ã"
+
+# S1033 rhs expression is not supported. Only attribute is permitted on current version."
+@@error_message[ :"S1033" ] = "å³è¾ºå¼ã¯ãµãã¼ãããã¦ãã¾ããï¼å±æ§ã®ã¿ãç¾å¨ã®ãã¼ã¸ã§ã³ã§ä½¿ç¨ã§ãã¾ãï¼"
+
+# S1034 $1 : cannot refer to $2\'s attribute here. Use \'composite.$3\' to refer to composite celltype\'s"
+@@error_message[ :"S1034" ] = "$1 : ããã§ã¯ $2 ã®å±æ§ãåç
+§ã§ãã¾ãã. è¤åã»ã«ã¿ã¤ãã®å±æ§ãåç
+§ãããã \'composite.$3\' ããä½¿ããã ããï¼"
+
+# S1035 composite : cannot specify out of composite celltype definition"
+@@error_message[ :"S1035" ] = "composite : è¤åã»ã«ã¿ã¤ãå®ç¾©ã®å¤å´ã§ã¯æå®ã§ãã¾ããï¼"
+
+# S1036 $1 : cannot refer to $2\'s here. Use \'composite.$3\' to refer to composite celltype\'s"
+@@error_message[ :"S1036" ] = "$1 : ããã§ã¯$2ã®ãã®ãåç
+§ã§ãã¾ããï¼è¤åã»ã«ã¿ã¤ãã®ãã®ãåç
+§ãããã \'composite.$3\' ããä½¿ããã ããï¼"
+
+# S1037 $1: celltype plugin fail to new_cell"
+@@error_message[ :"S1037" ] = "$1: ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã new_cell ã«å¤±æãã¾ããï¼"
+
+# S1038 $1.$2: self allocator not supported for array entry port"
+@@error_message[ :"S1038" ] = "$1.$2: ã»ã«ãã¢ã­ã±ã¼ã¿ã¯åãå£é
+åã«å¯¾ãã¦ãµãã¼ãããã¦ãã¾ããï¼"
+
+# S1039 \'$1\': unknown specifier for cell"
+@@error_message[ :"S1039" ] = "\'$1\': ã»ã«ã«å¯¾ããä¸æãªæå®å­ã§ãï¼"
+
+# S1040 array not supported for relay allocator"
+@@error_message[ :"S1040" ] = "é
+åã¯ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã«å¯¾ãã¦ãµãã¼ãããã¦ãã¾ããï¼"
+
+# S1041 \'$1_$2_$3\': not joined. cannot create internal join for relay allocator"
+@@error_message[ :"S1041" ] = "\'$1_$2_$3\': çµåããã¾ãã. ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã«å¯¾ãã¦å
+é¨çµåãçæã§ãã¾ããï¼"
+
+# S1042 call port \'$1\' not initialized in cell \'$2\'"
+@@error_message[ :"S1042" ] = "å¼ã³å£ \'$1\' ã¯ã»ã« \'$2\' ã®ä¸­ã§åæåããã¾ããï¼"
+
+# S1043 call port \'$1\' not initialized in cell \'$2\'. this call port is created by tecsgen. check allocator specifier"
+@@error_message[ :"S1043" ] = "å¼ã³å£ \'$1\' ã¯ã»ã« \'$2\' ã®ä¸­ã§åæåããã¾ããï¼ãã®å¼ã³å£ã¯ tecsgen ã«ããçæããã¾ãï¼ã¢ã­ã±ã¼ã¿æå®å­ãç¢ºèªãã¦ãã ããï¼"
+
+# S1044 $1: array initializer too many or few, $2 for $3"
+@@error_message[ :"S1044" ] = "$1: é
+åã®åæåå­ãå¤ããããã¾ãã¯å°ãªããã¾ãï¼$3 ã¨ããã¨ããã $2 ã«ãã¾ããï¼"
+
+# S1045 $1[$2]: not initialized"
+@@error_message[ :"S1045" ] = "$1[$2]: åæåããã¾ããï¼"
+
+# S1046 $1[$2]: not initialized"
+@@error_message[ :"S1046" ] = "$1[$2]: åæåããã¾ãã"
+
+# S1047 size_is pointer cannot be exposed for composite attribute"
+@@error_message[ :"S1047" ] = "size_is ãæå®ããããã¤ã³ã¿å¤æ°ã¯ï¼è¤åã»ã«ã¿ã¤ãã®å±æ§åã«é¢ãã¦ã¯ï¼å¤é¨ã¸å
+¬éãããã¨ãã§ãã¾ããï¼"
+
+# S1048 $1: size_is specified for non-pointer type"
+@@error_message[ :"S1048" ] = "$1: size_is ãéãã¤ã³ã¿åã«å¯¾ãã¦æå®ããã¾ããï¼"
+
+# S1049 $1: size_is arg not constant"
+@@error_message[ :"S1049" ] = "$1: size_is å¼æ°ãå®æ°ã§ã¯ããã¾ããï¼"
+
+# S1050 unsuitable initializer, need array initializer"
+@@error_message[ :"S1050" ] = "ä¸é©å½ãªåæåå­ã§ãï¼é
+åã®åæåå­ãå¿
+è¦ã§ãï¼"
+
+# S1051 too many initializer for array, $1 for $2"
+@@error_message[ :"S1051" ] = "é
+åã«å¯¾ããåæåå­ãå¤ããã¾ãï¼$2 ã¨ããã¨ããã $1 ã«ãã¾ããï¼"
+
+# S1052 attribute \'$1\' not initialized in cell \'$2\'"
+@@error_message[ :"S1052" ] = "å±æ§ \'$1\' ã¯ã»ã« \'$2\' ã®ä¸­ã§åæåããã¾ããï¼"
+
+# S1053 $1 must be singleton. inner cell \'$2\' is singleton"
+@@error_message[ :"S1053" ] = "$1 ã¯ã·ã³ã°ã«ãã³ã§ããå¿
+è¦ãããã¾ãï¼å
+é¨ã»ã« \'$2\' ã¯ã·ã³ã°ã«ãã³ã§ãï¼"
+
+# S1054 $1 : specified active but has no active in this celltype"
+@@error_message[ :"S1054" ] = "$1 : ã¢ã¯ãã£ãã«æå®ããã¾ãããï¼ãã®ã»ã«ã¿ã¤ãã®ä¸­ã«ã¯ã¢ã¯ãã£ããªã»ã«ãããã¾ããï¼"
+
+# S1055 $1 must be active. inner cell \'$2\' is active"
+@@error_message[ :"S1055" ] = "$1 ã¯ active ã§ããå¿
+è¦ãããã¾ã. å
+é¨ã»ã« \'$2\' ãã¢ã¯ãã£ãã§ãï¼"
+
+# S1056 $1 : cannot export, nothing designated"
+@@error_message[ :"S1056" ] = "$1 : å¤é¨ã«å
+¬éãããã¨ãã§ãã¾ããï¼ä½ãæå®ããã¦ãã¾ããï¼"
+
+# S1057 $1 not found in $2"
+@@error_message[ :"S1057" ] = "$1 ã $2 ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1058 \'$1\' : cannot export var"
+@@error_message[ :"S1058" ] = "\'$1\' : å¤æ°ãå¤é¨ã«å
+¬éãããã¨ãã§ãã¾ããï¼"
+
+# S1059 \'$1\' : exporting attribute. write in cell or use \'=\' to export attribute"
+@@error_message[ :"S1059" ] = "\'$1\' : å±æ§ãå
+¬éãã¦ãã¾ã. ã»ã«ã®ä¸­ã«è¨è¿°ãããã¾ãã¯å±æ§ã®å
+¬éã®ããã« \'=\' ãä½¿ã£ã¦ä¸ããï¼"
+
+# S1060 \'$1\' : port type mismatch. $2 type is allowed here."
+@@error_message[ :"S1060" ] = "\'$1\' : å£(port)ã®åãæ´åãã¦ãã¾ãã. ããã§ã¯ $2 åãä½¿ç¨ã§ãã¾ãï¼"
+
+# S1061 \'$1\' : not defined"
+@@error_message[ :"S1061" ] = "\'$1\' : å®ç¾©ããã¦ãã¾ããï¼"
+
+# S1062 $1 has no export definition"
+@@error_message[ :"S1062" ] = "$1 ã«ã¯å¤é¨å®ç¾©ãããã¾ããï¼"
+
+# S1063 $1 is port but previously defined as an attribute"
+@@error_message[ :"S1063" ] = "$1 ã¯å£(port)ã§ããããããåã«å±æ§ã¨ãã¦å®ç¾©ããã¾ããï¼"
+
+# S1064 $1 : type \'$2$3\' mismatch with pprevious definition\'$4$5\'"
+@@error_message[ :"S1064" ] = "$1 : å \'$2$3\' ã¯ããä»¥åã®å®ç¾© \'$4$5\' ã¨æ´åãã¦ã¾ããï¼"
+
+# S1065 $1 : port type $2 mismatch with previous definition $3"
+@@error_message[ :"S1065" ] = "$1 : å£(port)å $2 ã¯ããä»¥åã®å®ç¾© $3 ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1066 $1 : signature \'$2\' mismatch with previous definition \'$3\'"
+@@error_message[ :"S1066" ] = "$1 : ã·ã°ããã£ \'$2\' ã¯ããä»¥åã®å®ç¾© \'$3\' ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1067 $1 : array size mismatch with previous definition"
+@@error_message[ :"S1067" ] = "$1 : é
+åã®ãµã¤ãºãããä»¥åã®å®ç¾©ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1068 $1 : optional specifier mismatch with previous definition"
+@@error_message[ :"S1068" ] = "$1 : ãªãã·ã§ãã«ãªæå®å­ãããä»¥åã®å®ç¾©ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1069 $1 is an attribute but previously defined as a port"
+@@error_message[ :"S1069" ] = "$1 ã¯å±æ§ã§ããããããåã«å£(port)ã¨ãã¦å®ç¾©ããã¾ããï¼"
+
+# S1070 $1: size_is pointer cannot be exposed for composite attribute"
+@@error_message[ :"S1070" ] = "$1: size_is ãæå®ããããã¤ã³ã¿å¤æ°ã¯ï¼è¤åã»ã«ã¿ã¤ãã®å±æ§åã«é¢ãã¦ã¯ï¼å
+¬éãããã¨ãã§ãã¾ããï¼"
+
+# S1071 $1 cannot be specified for composite"
+@@error_message[ :"S1071" ] = "$1 ã¯è¤åã»ã«ã«å¯¾ãã¦æå®ã§ãã¾ããï¼"
+
+# S1072 $1: entry port: sizeless array not supported in current version"
+@@error_message[ :"S1072" ] = "$1: åãå£: ç¾å¨ã®çã§ã¯ãµã¤ãºæªæå®ã®é
+åã¯ãµãã¼ãããã¦ãã¾ããï¼"
+
+# S1073 Not constant expression $1"
+@@error_message[ :"S1073" ] = "$1 ã¯å®æ°å¼ã§ã¯ããã¾ããï¼"
+
+# S1074 Not Integer $1"
+@@error_message[ :"S1074" ] = "$1 ã¯æ´æ°ã§ã¯ããã¾ãã"
+
+# S1075 \'$1\' signature not found"
+@@error_message[ :"S1075" ] = "\'$1\' ã·ã°ããã£ãè¦ã¤ããã¾ããï¼"
+
+# S1076 \'$1\' not signature"
+@@error_message[ :"S1076" ] = "\'$1\' ã¯ã·ã°ããã£ã§ã¯ããã¾ããï¼"
+
+# S1077 inline: cannot be specified for call port"
+@@error_message[ :"S1077" ] = "inline: å¼ã³å£ã«å¯¾ãã¦æå®ã§ãã¾ããï¼"
+
+# S1078 optional: cannot be specified for entry port"
+@@error_message[ :"S1078" ] = "optional: åãå£ã«å¯¾ãã¦æå®ã§ãã¾ããï¼"
+
+# S1079 allocator: cannot be specified for call port"
+@@error_message[ :"S1079" ] = "allocator: å¼ã³å£ã«å¯¾ãã¦æå®ã§ãã¾ããï¼"
+
+# S1080 duplicate allocator specifier"
+@@error_message[ :"S1080" ] = "ã¢ã­ã±ã¼ã¿æå®å­ãéè¤ãã¦ãã¾ãï¼"
+
+# S1081 self allocator not supported yet"
+@@error_message[ :"S1081" ] = "ã»ã«ãã¢ã­ã±ã¼ã¿ã¯ã¾ã ãµãã¼ãããã¦ãã¾ãã"
+
+# S1082 function \'$1\' not found in signature"
+@@error_message[ :"S1082" ] = "é¢æ° \'$1\' ãã·ã°ããã£ã§è¦ã¤ããã¾ãã"
+
+# S1083 \'$1\' not found in function \'$2\'"
+@@error_message[ :"S1083" ] = "\'$1\' ãé¢æ° \'$2\' ã§è¦ã¤ããã¾ãã"
+
+# S1084 \'$1\' in function \'$2\' is not send or receive"
+@@error_message[ :"S1084" ] = "\'$2\' å
+ã® \'$1\' ãåºæ¬æå®å­ send ã¾ãã¯ receive ã§ã¯ããã¾ããï¼"
+
+# S1085 duplicate allocator specifier for \'$1_$2\'"
+@@error_message[ :"S1085" ] = "\'$1_$2\' ã«å¯¾ããéè¤ããã¢ã­ã±ã¼ã¿æå®å­ã§ãï¼"
+
+# S1086 rhs not call_port.func.param for $1_$2"
+@@error_message[ :"S1086" ] = "$1_$2 ã«å¯¾ãã¦ not call_port.func.param ã®å½¢å¼ã§ã¯ããã¾ããï¼"
+
+# S1087 function \'$1\' not found in signature \'$2\'"
+@@error_message[ :"S1087" ] = "é¢æ° \'$1\' ãã·ã°ããã£ \'$2\' ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1088 \'$1\' not found in function \'$2\'"
+@@error_message[ :"S1088" ] = "\'$1\' ãé¢æ° \'$2\' ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1089 relay allocator send/receive mismatch between $1.$2 and $3_$4.$5"
+@@error_message[ :"S1089" ] = "ãªã¬ã¼ã¢ã­ã±ã¼ã¿ send/receive ã¯ $1.$2 åã³ $3_$4.$5 ã®éã§æ´åãã¦ãã¾ããï¼"
+
+# S1090 \'$1\' in function \'$2\' is not send or receive"
+@@error_message[ :"S1090" ] = "é¢æ° \'$2\' å
+ã® \'$1\' ã send ã¾ãã¯ receive ã§ã¯ããã¾ããï¼"
+
+# S1091 call port \'$1\' not found in celltype $2"
+@@error_message[ :"S1091" ] = "å¼ã³å£ \'$1\' ãã»ã«ã¿ã¤ã $2 ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1092 \'$1\' not namespace"
+@@error_message[ :"S1092" ] = "\'$1\' ã¯ãã¼ã ã¹ãã¼ã¹ã§ã¯ããã¾ããï¼"
+
+# S1093 $1 : undefined cell"
+@@error_message[ :"S1093" ] = "$1 : æªå®ç¾©ã®ã»ã«ã§ã"
+
+# S1094 $1: pointer is not constant. check \'const\'"
+@@error_message[ :"S1094" ] = "$1: ãã¤ã³ã¿ãå®æ°ã§ã¯ããã¾ããï¼\'const\' ãç¢ºèªãã¦ãã ãã"
+
+# S1095 $1: not constant"
+@@error_message[ :"S1095" ] = "$1: å®æ°ã§ã¯ããã¾ãã"
+
+# S1096 $1: should be int, float, bool or pointer type"
+@@error_message[ :"S1096" ] = "$1: int, float, bool ã¾ãã¯ãã¤ã³ã¿åã§ããå¿
+è¦ãããã¾ã"
+
+# S1097 $1: has no initializer"
+@@error_message[ :"S1097" ] = "$1: åæåå­ãæã£ã¦ãã¾ãã"
+
+# S1098 $1: has unsuitable initializer"
+@@error_message[ :"S1098" ] = "$1: ä¸é©å½ãªåæåå­ãããã¾ãï¼"
+
+# S1099 array subscript not constant"
+@@error_message[ :"S1099" ] = "é
+åæ·»æ°ãå®æ°ã§ã¯ããã¾ããï¼"
+
+# S1100 $1: cannot initialize var"
+@@error_message[ :"S1100" ] = "$1: å¤æ°ãåæåã§ãã¾ããï¼"
+
+# S1101 \'$1\' cannot initialize entry port"
+@@error_message[ :"S1101" ] = "\'$1\' åãå£ãåæåã§ãã¾ããï¼"
+
+# S1102 $1: must specify array subscript here"
+@@error_message[ :"S1102" ] = "$1: ããã§ã¯é
+åæ·»æ°ãæå®ããå¿
+è¦ãããã¾ãï¼"
+
+# S1103 $1: need array subscript"
+@@error_message[ :"S1103" ] = "$1: é
+åæ·»æ°ãå¿
+è¦ã§ãï¼"
+
+# S1104 $1: need array subscript number. ex. \'[0]\'"
+@@error_message[ :"S1104" ] = "$1: é
+åæ·»æ°ã®æ°å¤ãå¿
+è¦ã§ãï¼(ä¾) \'[0]\'"
+
+# S1105 $1: cannot specify array subscript here"
+@@error_message[ :"S1105" ] = "$1: ããã§ã¯é
+åæ·»æ°ãæå®ãããã¨ãã§ãã¾ããï¼"
+
+# S1106 $1: cannot specify array subscript number. use \'[]\'"
+@@error_message[ :"S1106" ] = "$1: é
+åæ·»æ°ã®æ°å¤ãæå®ãããã¨ãåºæ¥ã¾ããï¼\'[]\' ããä½¿ããã ããï¼"
+
+# S1107 to export port, use \'cCall => composite.cCall\'"
+@@error_message[ :"S1107" ] = "å£(port)ãå¤é¨ã«å
+¬éãããã, \'cCall => composite.cCall\' ããä½¿ããã ããï¼"
+
+# S1108 $1: rhs not \'Cell.ePort\' form"
+@@error_message[ :"S1108" ] = "$1: å³è¾ºã \'Cell.ePort\' ã®å½¢å¼ã§ã¯ããã¾ããï¼"
+
+# S1109 \'$1\' not found"
+@@error_message[ :"S1109" ] = "\'$1\' ãè¦ã¤ããã¾ããï¼"
+
+# S1110 \'$1\' not cell"
+@@error_message[ :"S1110" ] = "\'$1\' ã»ã«ã§ã¯ããã¾ããï¼"
+
+# S1111 \'$1\' not found"
+@@error_message[ :"S1111" ] = "\'$1\' ãè¦ã¤ããã¾ããï¼"
+
+# S1112 \'$1\' not entry port"
+@@error_message[ :"S1112" ] = "\'$1\' åãå£ã§ã¯ããã¾ããï¼"
+
+# S1113 \'$1\' signature mismatch"
+@@error_message[ :"S1113" ] = "\'$1\' ã·ã°ããã£ãæ´åãã¦ãã¾ããï¼"
+
+# S1114 \'$1\' should be array"
+@@error_message[ :"S1114" ] = "\'$1\' é
+åã§ããå¿
+è¦ãããã¾ãï¼"
+
+# S1115 $1[$2]: subscript out of range (< $3)"
+@@error_message[ :"S1115" ] = "$1[$2]: é
+åã®æ·»æ°ãç¯å²å¤ã®å¤ã§ãï¼(< $3)"
+
+# S1116 \'$1\' entry port is not array"
+@@error_message[ :"S1116" ] = "\'$1\' åãå£ãé
+åã§ã¯ããã¾ããï¼"
+
+# S1117 \'$1\' not in celltype"
+@@error_message[ :"S1117" ] = "\'$1\' ã¯ã»ã«ã¿ã¤ãå
+ã«ããã¾ããï¼"
+
+# S1118 $1: going out from region \'$2\' not permitted"
+@@error_message[ :"S1118" ] = "$1: ãªã¼ã¸ã§ã³ $2 ãã out ãããã¨ãã§ãã¾ããï¼"
+
+# S1119 $1: going from region \'$2\' to \'$3\' not permitted"
+@@error_message[ :"S1119" ] = "$1: ãªã¼ã¸ã§ã³ $2 ãããªã¼ã¸ã§ã³ $3ã¸çµåã§ãã¾ããï¼"
+
+# S1120 $1: going in to region \'$2\' not permitted"
+@@error_message[ :"S1120" ] = "$1: ãªã¼ã¸ã§ã³ \'$2\' ã¸ in ãããã¨ãã§ãã¾ããï¼"
+
+# S1121 \'$1\' in region \'$2\' cannot be directly joined $3 in  $4"
+@@error_message[ :"S1121" ] = "ãªã¼ã¸ã§ã³ \'$2\' å
+ã® \'$1\' ã¯ç´æ¥ $4 å
+ã® $3 ã«çµåã§ãã¾ããï¼"
+
+# S1122 $1 : not port: \'through\' can be specified only for port"
+@@error_message[ :"S1122" ] = "$1 :å£(port) ã§ã¯ããã¾ãã: \'through\' ã¯å£(port)ã«å¯¾ãã¦ã®ã¿æå®ã§ãã¾ãï¼"
+
+# S1123 $1 : not port: \'through\' can be specified only for port"
+@@error_message[ :"S1123" ] = "$1 :å£(port) ã§ã¯ããã¾ãã: \'through\' ã¯å£(port)ã«å¯¾ãã¦ã®ã¿æå®ã§ãã¾ãï¼"
+
+# S1124 $1: plugin function failed: \'get_through_entry_port_name\'"
+@@error_message[ :"S1124" ] = "$1: ãã©ã°ã¤ã³é¢æ°ãå¤±æãã¾ããï¼: \'get_through_entry_port_name\'"
+
+# S1125 $1: not generated cell \'$2\'"
+@@error_message[ :"S1125" ] = "$1: çæãããã»ã« \'$2\' ã§ã¯ããã¾ããï¼"
+
+# S1126 $1: fail to new"
+@@error_message[ :"S1126" ] = "$1: new ã«å¤±æãã¾ããï¼"
+
+# S1127 \'$1\' duplicate"
+@@error_message[ :"S1127" ] = "\'$1\' ãéè¤ãã¦ãã¾ãï¼"
+
+# S1128 \'$1\' inconsistent array definition"
+@@error_message[ :"S1128" ] = "\'$1\' ã¯ä¸è²«ããªãé
+åå®ç¾©ã§ãï¼"
+
+# S1129 \'$1\' redefinition of subscript $1"
+@@error_message[ :"S1129" ] = "\'$1\' ã¯é
+åæ·»æ° $1 ã®åå®ç¾©ã§ãï¼"
+
+# S1130 \'$1\' inconsistent array definition"
+@@error_message[ :"S1130" ] = "\'$1\' ã¯ä¸è²«ããªãé
+åå®ç¾©ã§ãï¼"
+
+# S1131 \'$1.$2\' has duplicate initializer"
+@@error_message[ :"S1131" ] = "\'$1.$2\' ã«ã¯éè¤ããåæåå­ãããã¾ãï¼"
+
+# S1132 $1: 1st parameter is not string(file name)"
+@@error_message[ :"S1132" ] = "$1: ç¬¬1ãã©ã¡ã¼ã¿ã string(ãã¡ã¤ã«å) ã§ã¯ããã¾ããï¼"
+
+# S1133 $1: 2nd parameter is not string(fromat)"
+@@error_message[ :"S1133" ] = "$1: ç¬¬2ãã©ã¡ã¼ã¿ã string(ãã¡ã¤ã«å) ã§ã¯ããã¾ããï¼"
+
+# S1134 $1: unknown factory function"
+@@error_message[ :"S1134" ] = "$1: ä¸æãªãã¡ã¯ããªé¢æ°ã§ãï¼"
+
+# S1135 celltype factory can\'t have parameter(s)"
+@@error_message[ :"S1135" ] = "ã»ã«ã¿ã¤ããã¡ã¯ããªã¯ãã©ã¡ã¼ã¿ãæã¤ãã¨ãã§ãã¾ããï¼"
+
+# S1136 \'$1\': not found"
+@@error_message[ :"S1136" ] = "\'$1\': è¦ã¤ããã¾ããï¼"
+
+# S1137 \'$1\': not attribute"
+@@error_message[ :"S1137" ] = "\'$1\': å±æ§ã§ã¯ããã¾ããï¼"
+
+# S1138 internal error Factory.check_arg()"
+@@error_message[ :"S1138" ] = "Factory.check_arg() ã®å
+é¨ã¨ã©ã¼ã§ãï¼"
+
+# S1139 $1: region path mismatch. previous path: $2"
+@@error_message[ :"S1139" ] = "$1: ãªã¼ã¸ã§ã³ãã¹ãæ´åãã¦ãã¾ããï¼ä»¥åã®ãã¹: $2"
+
+# S1140 $1: region specifier must place at first appearence"
+@@error_message[ :"S1140" ] = "$1: ãªã¼ã¸ã§ã³æå®å­ã¯æåã«é
+ç½®ããå¿
+è¦ãããã¾ãï¼"
+
+# S1141 $1 duplication, previous one : $2"
+@@error_message[ :"S1141" ] = "$1 ãéè¤ãã¦ãã¾ã, ä»¥åã®å¤ : $2"
+
+# S1142 $1 not found in search path"
+@@error_message[ :"S1142" ] = "$1 ãæ¤ç´¢ãã¹ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1143 import_C: arg2: mismatch with previous one"
+@@error_message[ :"S1143" ] = "import_C: arg2: ä»¥åã®ãã®ã¨æ´åãã¦ãã¾ããï¼"
+
+# S1144 $1: temporary C source: open error"
+@@error_message[ :"S1144" ] = "$1: ä¸æçãª C ã½ã¼ã¹: ãªã¼ãã³ã¨ã©ã¼ã§ãï¼"
+
+# S1145 $1: temporary C source: writing error"
+@@error_message[ :"S1145" ] = "$1: ä¸æçãª C ã½ã¼ã¹: æ¸è¾¼ã¿ã¨ã©ã¼ã§ãï¼"
+
+# S1146 $1: error occured while CPP"
+@@error_message[ :"S1146" ] = "$1: CPP å®è¡ä¸­ã«ã¨ã©ã¼ãçºçãã¾ããï¼"
+
+# S1147 $1: popen for CPP failed"
+@@error_message[ :"S1147" ] = "$1: CPPã«å¯¾ãã popen ãå¤±æãã¾ããï¼"
+
+# S1148 $1 not found in search path"
+@@error_message[ :"S1148" ] = "$1 ãæ¤ç´¢ãã¹ã®ä¸­ã«è¦ã¤ããã¾ããï¼"
+
+# S1149 $1 not signature"
+@@error_message[ :"S1149" ] = "$1 ã·ã°ããã£ã§ã¯ããã¾ããï¼"
+
+# S1150 $1: fail to new"
+@@error_message[ :"S1150" ] = "$1: new ã«å¤±æãã¾ããï¼"
+
+# S1151 $1: not namespace"
+@@error_message[ :"S1151" ] = "$1: ãã¼ã ã¹ãã¼ã¹ã§ã¯ããã¾ããï¼"
+
+# S1152 $1: call port cannot have fixed join"
+@@error_message[ :"S1152" ] = "$1: å¼ã³å£ã¯åºå®çµåãæã¤ãã¨ãã§ãã¾ããï¼"
+
+# "S1153 $1: cannot be entry port array for fixed join port"
+@@error_message[ :"S1153" ] = "$1: åºå®çµåã®å£ã«å¯¾ããåãå£é
+åã¯ããå¾ã¾ããï¼"
+
+# "S1154 $1: must be singleton celltype for fixed join"
+@@error_message[ :"S1154" ] = "$1: åºå®çµåã«å¯¾ããã·ã³ã°ã«ãã³ã»ã«ã¿ã¤ãã§ããå¿
+è¦ãããã¾ãï¼"
+
+# "S1155 $1: not celltype or not found"
+@@error_message[ :"S1155" ] = "$1: ã»ã«ã¿ã¤ãã§ã¯ãªããã¾ãã¯è¦ã¤ããã¾ããï¼"
+
+# "S1156 $1: not call port or not found"
+@@error_message[ :"S1156" ] = "$1: å¼ã³å£ã§ã¯ãªããã¾ãã¯è¦ã¤ããã¾ããï¼"
+
+# "S1157 $1: sized array or not array"
+@@error_message[ :"S1157" ] = "$1: ãµã¤ãºæå®ãããé
+åãã¾ãã¯é
+åã§ã¯ããã¾ããï¼"
+
+# "S1158 $1: singleton cell not found for fixed join"
+@@error_message[ :"S1158" ] = "$1: ã·ã³ã°ã«ãã³ã»ã«ãåºå®çµåã«å¯¾ãã¦è¦ã¤ããã¾ããï¼"
+
+# S1159 $1: non-size_is pointer cannot be initialized with array initializer"
+@@error_message[ :"S1159" ] = "$1: size_is æå®ããã¦ããªããã¤ã³ã¿ã¯ãé
+ååæåå­ã§åæåã§ãã¾ãã"
+
+# S1160 $1 must be constant for id"
+@@error_message[ :"S1160" ] = "$1 id ã¯å®æ°ã§ãªããã°ãªãã¾ãã"
+
+# S1161 $1 must be constant for id"
+@@error_message[ :"S1161" ] = "$1 id ã¯å®æ°ã§ãªããã°ãªãã¾ãã"
+
+# S1162 $1: id cannot be 0"
+@@error_message[ :"S1162" ] = "$1: id ã« 0 ãæå®ã§ãã¾ãã"
+
+# S1163 generate specifier duplicate"
+@@error_message[ :"S1163" ] = "generate æå®å­ãéè¤ãã¦ãã¾ã"
+
+# S1164 '$1' set_specified_id: id not positive integer '$2'"
+@@error_message[ :"S1164" ] = "'$1' id ãæ­£æ´æ°ã§ããã¾ãã '$2'"
+
+# S1165 '$1' set_specified_id: id duplicate"
+@@error_message[ :"S1165" ] = "'$1' id æå®å­ãéè¤ãã¦ãã¾ã"
+
+# S1166 $1: fail to new"
+@@error_message[ :"S1166" ] = "$1: ãã©ã°ã¤ã³ã®çæã«å¤±æãã¾ãã"
+
+# S1167 \'$1\': relay mismatch \'$2\'"
+@@error_message[ :"S1167" ] = "\'$1\': ãªã¬ã¼ã«ããããã¾ãã \'$2\'"
+
+# S1168 too many initializer for array, $1 for $2"
+@@error_message[ :"S1168" ] = "é
+ååæåå­ãå¤ããã¾ã $1 for $2"
+
+# S1169 $1: non-size_is pointer cannot be initialized with array initializer"
+@@error_message[ :"S1169" ] = "$1: size_is æå®ããã¦ããªããã¤ã³ã¿ã«é
+ååæåå­ãæå®ã§ãã¾ãã"
+
+# S1170 \'$1\' has size_is but export attr \'$2\' doesn't have"
+@@error_message[ :"S1170" ] = "\'$1\' ã« size_is æå®ããã¦ãã¾ããã¨ã¯ã¹ãã¼ããã \'$2\' ã«æå®ããã¦ãã¾ãã"
+
+# S1171 \'$1\' size_is argument of \'$2\' not exported"
+@@error_message[ :"S1171" ] = "\'$1\' \'$2\' size_is å¼æ°ãã¨ã¯ã¹ãã¼ãããã¦ãã¾ãã"
+
+# S1172 \'$1\' size_is argument mismatch with exporting one \'$2\'"
+@@error_message[ :"S1172" ] = "\'$1\' size_is å¼æ°ãã¨ã¯ã¹ãã¼ãããã¦ãã \'$2\' ã¨ä¸è´ãã¾ãã"
+
+# S1173 $1: allocator mismatch from $2's allocator"
+@@error_message[ :"S1173" ] = "$1: ã¢ã­ã±ã¼ã¿ã $2' ã®ã¢ã­ã±ã¼ã¿ã¨ä¸è´ãã¾ãã"
+
+# S1174 $1 not suitable for lhs, suitable lhs: 'func.param'"
+@@error_message[ :"S1174" ] = "$1 å·¦è¾ºãä¸é©åã§ããé©åãªå·¦è¾ºã¯ 'func.param' ã®å½¢å¼ã§ã"
+
+# S1175 $1 not found or not allocator entry port for $2"
+@@error_message[ :"S1175" ] = "$1  $2 ã®ã¢ã­ã±ã¼ã¿åãå£ãè¦å½ãããªãããã¢ã­ã±ã¼ã¿åãå£ã§ã¯ããã¾ãã"
+
+# S1176 rhs not in 'call_port.func.param' form for $1_$2"
+@@error_message[ :"S1176" ] = "å³è¾ºã 'call_port.func.param' å½¢å¼ã§ããã¾ãã ($1_$2)"
+
+# S1177 cannot specify 'through' in composite in current version"
+@@error_message[ :"S1177" ] = "ç¾å¨ã®ãã¼ã¸ã§ã³ã§ã¯ãã³ã³ãã¸ããã»ã«ã« 'through'ãæå®ã§ãã¾ãã"
+
+# S1178 $1 region type specifier duplicate, previous $2"
+@@error_message[ :"S1178" ] = "$1 ãªã¼ã¸ã§ã³ã¿ã¤ãæå®å­ãéè¤ãã¦ãã¾ããä»¥åã¯ $2 ã§ãã"
+
+### syntaxobj.rb
+# S2001 \'$1\' duplicate $2"
+@@error_message[ :"S2001" ] = "\'$1\': éè¤ãã¦ãã¾ã ($2)"
+
+# S2002 $1: $2"
+@@error_message[ :"S2002" ] = "$1: $2"
+
+# S2003 $1: $2 cannot have initializer"
+@@error_message[ :"S2003" ] = "$1: $2 ã¯åæåå­ããã¤ãã¨ãã§ãã¾ããï¼"
+
+# S2004 $1: array subscript must be specified or omit"
+@@error_message[ :"S2004" ] = "$1: é
+åæ·»æ°ã¯æå®ããããã¾ãã¯çç¥ãããå¿
+è¦ãããã¾ãï¼"
+
+# S2005 $1: array subscript must be specified"
+@@error_message[ :"S2005" ] = "$1: é
+åæ·»æ°ã¯æå®ãããå¿
+è¦ãããã¾ãï¼"
+
+# S2006 \'$1\' function"
+@@error_message[ :"S2006" ] = "\'$1\' é¢æ°ã§ãï¼"
+
+# S2007 \'$1\' $2"
+@@error_message[ :"S2007" ] = "\'$1\' $2"
+
+# S2008 $1: inconsitent with previous one"
+@@error_message[ :"S2008" ] = "$1: ä»¥åã®ãã®ã¨ä¸è²«ãã¦ãã¾ããï¼"
+
+# S2009 $1: not found or not signature"
+@@error_message[ :"S2009" ] = "$1: è¦ã¤ãããªããã¾ãã¯ã·ã°ããã£ã§ã¯ããã¾ããï¼"
+
+# S2010 $1: not allocator signature"
+@@error_message[ :"S2010" ] = "$1: ã¢ã­ã±ã¼ã¿ã·ã°ããã£ã§ã¯ããã¾ããï¼"
+
+# S2011 size_is duplicate"
+@@error_message[ :"S2011" ] = "size_is ãéè¤ãã¦ãã¾ãï¼"
+
+# S2012 count_is duplicate"
+@@error_message[ :"S2012" ] = "count_is ãéè¤ãã¦ãã¾ãï¼"
+
+# S2013 string duplicate"
+@@error_message[ :"S2013" ] = "string ãéè¤ãã¦ãã¾ãï¼"
+
+# S2014 $1 need pointer or more pointer"
+@@error_message[ :"S2014" ] = "$1 ã¯ä¸ã¤ä»¥ä¸ã®ãã¤ã³ã¿ãå¿
+è¦ã§ãï¼"
+
+# S2015 $1 must be const for \'in\' parameter $2"
+@@error_message[ :"S2015" ] = "'$1' ã¯ \'in\' ãã©ã¡ã¼ã¿ $2 ã«å¯¾ãã¦å®æ°ã§ããå¿
+è¦ãããã¾ãï¼"
+
+# S2016 $1 can not be const for $2 parameter"
+@@error_message[ :"S2016" ] = "'$1' ã¯ $2 ãã©ã¡ã¼ã¿ã«å¯¾ãã¦å®æ°æå®ã§ãã¾ããï¼ "
+
+# S2017 size_is argument is not integer type"
+@@error_message[ :"S2017" ] = "size_is å¼æ°ãæ´æ°åã§ã¯ããã¾ããï¼"
+
+# S2018 \'$1\' size_is parameter not integer"
+@@error_message[ :"S2018" ] = "\'$1\' size_is ãã©ã¡ã¼ã¿ã¯æ´æ°ã§ã¯ããã¾ããï¼"
+
+# S2019 \'$1\' size_is parameter negative or zero"
+@@error_message[ :"S2019" ] = "\'$1\' size_is ãã©ã¡ã¼ã¿ãè² æ°ã¾ãã¯ã¼ã­ã§ãï¼"
+
+# S2020 count_is argument is not integer type"
+@@error_message[ :"S2020" ] = "count_is å¼æ°ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# S2021 \'$1\' count_is parameter not integer"
+@@error_message[ :"S2021" ] = "\'$1\' count_is ãã©ã¡ã¼ã¿ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# S2022 \'$1\' count_is parameter negative or zero"
+@@error_message[ :"S2022" ] = "\'$1\' count_is ãã©ã¡ã¼ã¿ã¯è² æ°ã¾ãã¯ã¼ã­ã§ãï¼"
+
+# S2023 string argument is not integer type"
+@@error_message[ :"S2023" ] = "string å¼æ°ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# S2024 \'$1\' string parameter not integer"
+@@error_message[ :"S2024" ] = "\'$1\' string ãã©ã¡ã¼ã¿ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# S2025 \'$1\' string parameter negative or zero"
+@@error_message[ :"S2025" ] = "\'$1\' string ãã©ã¡ã¼ã¿ã¯è² æ°ã¾ãã¯ã¼ã­ã§ãï¼"
+
+# S2026 '$1' nullable specified for non-pointer type"
+@@error_message[ :"S2026" ] = "'$1' ãã¤ã³ã¿åä»¥å¤ã« nullable ãæå®ããã¾ãã"
+
+# S2027 '$1' parameter cannot be void type"
+@@error_message[ :"S2027" ] = "'$1' å¼æ°ã void åã«ã§ãã¾ãã"
+
+# S2028 '$1' max (size_is 2nd parameter) not constant"
+@@error_message[ :"S2028" ] = "'$1' max (size_is ã®ç¬¬äºå¼æ°)ãå®æ°ã§ããã¾ãã"
+
+# S2029 '$1' max (size_is 2nd parameter) negative or zero, or not integer"
+@@error_message[ :"S2029" ] = "'$1' max (size_is ã®ç¬¬äºå¼æ°) ãè² ãã¼ã­ã¾ãã¯æ´æ°ã§ã¯ããã¾ãã"
+
+# S2030 '$1' both size_is and max are const. size_is larger than max"
+@@error_message[ :"S2030" ] = "'$1' size_is max ã®ä¸¡æ¹ãå®æ°ã§. size_is ã®æ¹ã max ãè¶
+ãã¦ãã¾ã"
+
+### optimize.rb
+# S3001 $1: id too large $2 (max=$3)"
+@@error_message[ :"S3001" ] = "$1: id ã« $2 ã¯å¤§ãããã¾ã (æå¤§å¤ã¯$3)"
+
+# S3002 $1: id too large $2 (max=$3)"
+@@error_message[ :"S3002" ] = "$1: id too large $2 (max=$3)"
+
+# S3003 $1: id number '$2' conflict with $3"
+@@error_message[ :"S3003" ] = "$1: id çªå· '$2' ã¯ $3 ã¨è¡çªãã¦ãã¾ã"
+
+### types.rb
+# T1001 const duplicate"
+@@error_message[ :"T1001" ] = "const ãéè¤ãã¦ãã¾ãï¼"
+
+# T1002 volatile duplicate"
+@@error_message[ :"T1002" ] = "volatile ãéè¤ãã¦ãã¾ãï¼"
+
+# T1003 $1: unsuitable specifier for $2"
+@@error_message[ :"T1003" ] = "$1: $2 ã«å¯¾ããä¸é©åãªæå®å­ã§ãï¼"
+
+# T1004 cannot cast to $1"
+@@error_message[ :"T1004" ] = "$1 ã¸ã­ã£ã¹ãã§ãã¾ããï¼"
+
+# T1005 \'$1\' not defined"
+@@error_message[ :"T1005" ] = "\'$1\' ã¯å®ç¾©ããã¦ãã¾ããï¼"
+
+# T1006 \'$1\' not type name. expecting type name here"
+@@error_message[ :"T1006" ] = "\'$1\' ã¯ååã§ã¯ããã¾ããï¼ããã¯ååãå¿
+è¦ã§ãï¼"
+
+# T1007 $1: void type variable cannot have initializer"
+@@error_message[ :"T1007" ] = "$1: void åå¤æ°ã¯åæåå­ããã¤ãã¨ãã§ãã¾ããï¼"
+
+# T1008 ambigous signed or unsigned"
+@@error_message[ :"T1008" ] = "ç¬¦å·ä»ãã§ãããã¾ãã¯ç¬¦å·ç¡ãã§ããããææ§ã§ãï¼"
+
+# T1009 $1: $2: not integer"
+@@error_message[ :"T1009" ] = "$1: $2: æ´æ°ã§ã¯ããã¾ããï¼"
+
+# T1010 $1: initializer is not constant"
+@@error_message[ :"T1010" ] = "$1: åæåå­ã¯å®æ°ã§ã¯ããã¾ããï¼"
+
+# T1011 $1: need cast to assign float to integer"
+@@error_message[ :"T1011" ] = "$1: æµ®åå°æ°ç¹åããæ´æ°åã¸å²ãå½ã¦ã®ããã«ã­ã£ã¹ããå¿
+è¦ã§ãï¼"
+
+# T1012 $1: $2: not integer"
+@@error_message[ :"T1012" ] = "$1: $2: æ´æ°ã§ã¯ããã¾ããï¼"
+
+# T1013 $1: too large (max=$2)"
+@@error_message[ :"T1013" ] = "$1: å¤ãå¤§ãããã¾ã (max=$2)"
+
+# T1014 $1: too large negative value (min=-$2)"
+@@error_message[ :"T1014" ] = "$1: è² æ°ã®çµ¶å¯¾å¤ãå¤§ãããã¾ãï¼(min=-$2)"
+
+# T1015 $1: negative value for unsigned"
+@@error_message[ :"T1015" ] = "$1: ç¬¦å·ç¡ãæ´æ°åã«å¯¾ãè² æ°å¤ãä½¿ç¨ããã¦ãã¾ãï¼"
+
+# T1016 $1: too large (max=$2)"
+@@error_message[ :"T1016" ] = "$1: å¤ãå¤§ãããã¾ãï¼(max=$2)"
+
+# T1017 $1: unsuitable initializer for scalar type"
+@@error_message[ :"T1017" ] = "$1: ã¹ã«ã©ã¼åã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1018 $1: $2: not number"
+@@error_message[ :"T1018" ] = "$1: $2: æ°å¤ã§ã¯ããã¾ããï¼"
+
+# T1019 $1: initializer is not constant"
+@@error_message[ :"T1019" ] = "$1: åæåå­ã¯å®æ°ã§ã¯ããã¾ããï¼"
+
+# T1020 $1: unsuitable initializer for scalar type"
+@@error_message[ :"T1020" ] = "$1: ã¹ã«ã©ã¼åã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1021 \'$1\': struct not defined"
+@@error_message[ :"T1021" ] = "\'$1\': æ§é ä½ãå®ç¾©ããã¦ãã¾ããï¼"
+
+# T1022 struct $1: not defined"
+@@error_message[ :"T1022" ] = "æ§é ä½ $1: å®ç¾©ããã¦ãã¾ããï¼"
+
+# T1023 struct $1: not defined"
+@@error_message[ :"T1023" ] = "æ§é ä½ $1: å®ç¾©ããã¦ãã¾ããï¼"
+
+# T1024 $1: unsuitable initializer for struct"
+@@error_message[ :"T1024" ] = "$1: æ§é ä½ã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1025 size_is argument is not integer type"
+@@error_message[ :"T1025" ] = "size_is å¼æ° ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# T1026 count_is argument is not integer type"
+@@error_message[ :"T1026" ] = "count_is å¼æ° ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# T1027 string argument is not integer type"
+@@error_message[ :"T1027" ] = "string å¼æ°ã¯æ´æ°åã§ã¯ããã¾ããï¼"
+
+# T1028 $1: cannot initialize function pointer"
+@@error_message[ :"T1028" ] = "$1: é¢æ°ãã¤ã³ã¿ãåæåãããã¨ã¯ã§ãã¾ããï¼"
+
+# T1029 oneway function cannot return type \'$1$2\', \'void\' or \'ER\' is permitted"
+@@error_message[ :"T1029" ] = "ä¸æ¹åé¢æ°ã¯å \'$1$2\' ãè¿ããã¨ãã§ãã¾ããï¼\'void\' ã¾ãã¯ \'ER\' ãä½¿ç¨ã§ãã¾ãï¼"
+
+# T1030 oneway function cannot have $1 parameter for \'$2\'"
+@@error_message[ :"T1030" ] = "ä¸æ¹åé¢æ°ã¯ \'$2\' ã®ããã« $1 ãã©ã¡ã¼ã¿ãæã¤ãã¨ãã§ãã¾ããï¼"
+
+# T1031 $1: unsuitable initializer for array"
+@@error_message[ :"T1031" ] = "$1: é
+åã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1032 $1: incompatible pointer type"
+@@error_message[ :"T1032" ] = "$1: äºææ§ã®ãªããã¤ã³ã¿åã§ãï¼"
+
+# T1033 $1: need cast to assign integer to pointer"
+@@error_message[ :"T1033" ] = "$1: æ´æ°åããã¤ã³ã¿ã¸å²ãå½ã¦ãããã«ã¯ã­ã£ã¹ããå¿
+è¦ã§ãï¼"
+
+# T1034 $1: unsuitable string constant"
+@@error_message[ :"T1034" ] = "$1: ä¸é©å½ãªæå­åå®æ°ã§ãï¼"
+
+# T1035 $1: unsuitable initializer for pointer"
+@@error_message[ :"T1035" ] = "$1: ãã¤ã³ã¿ã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1036 $1: unsuitable initializer for pointer"
+@@error_message[ :"T1036" ] = "$1: ãã¤ã³ã¿ã«å¯¾ããä¸é©å½ãªåæåå­ã§ãï¼"
+
+# T1037 $1: not number"
+@@error_message[ :"T1037" ] = "$1: æ°å¤ã§ã¯ããã¾ãã"
+
+# T1038 $1: initializer type mismatch. '$2' & '$3'"
+@@error_message[ :"T1038" ] = "$1: åæåå­ã®åãä¸è´ãã¾ãã. '$2' ã¨ '$3'"
+
+# T1039 $1: struct tag mismatch $2 and $3"
+@@error_message[ :"T1039" ] = "$1: æ§é ä½ã¿ã°ã $2 ã¨ $3 ã§ä¸è´ãã¾ãã"
+
+# T1040 $1 specified for void pointer type"
+@@error_message[ :"T1040" ] = "$1 void ãã¤ã³ã¿åã«æå®ããã¾ãã"
+
+### gen_xml.rb
+# T2001 fail to create XML file $1"
+@@error_message[ :"T2001" ] = "XML ãã¡ã¤ã« $1 ã®çæã«å¤±æãã¾ãã"
+
+# TEMPORAL set_definition_join: uninitialized array member"
+@@error_message[ :"TEMPORAL" ] = "set_definition_join: é
+åã¡ã³ããåæåããã¦ãã¾ããï¼"
+
+# V1001 $1: unable for $2"
+@@error_message[ :"V1001" ] = "$1: unable for $2"
+
+# V1002 $1: cannot cast to bool (implicitly)"
+@@error_message[ :"V1002" ] = "$1: ãã¼ã«åã¸ã®(æé»çãª)ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1003 $1: cannot cast to integer (implicitly)"
+@@error_message[ :"V1003" ] = "$1: æ´æ°åã¸ã®(æé»çãª)ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1004 $1: cannot cast to float (implicitly)"
+@@error_message[ :"V1004" ] = "$1: æµ®åå°æ°ç¹åã¸ã®(æé»çãª)ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1005 Cannot cast pointer to float"
+@@error_message[ :"V1005" ] = "ãã¤ã³ã¿åãæµ®åå°æ°ç¹åã¸ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1006 pointer value cannot cast to $1"
+@@error_message[ :"V1006" ] = "ãã¤ã³ã¿å¤ã¯ $1 ã¸ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1007 convert pointer value to bool"
+@@error_message[ :"V1007" ] = "ãã¤ã³ã¿å¤ããã¼ã«åã¸å¤æãã¾ããï¼"
+
+# V1008 convert pointer value to integer without cast"
+@@error_message[ :"V1008" ] = "ãã¤ã³ã¿å¤ãã­ã£ã¹ãç¡ãã§æ´æ°åã¸å¤æãã¾ããï¼"
+
+# V1009 / : divieded by zero"
+@@error_message[ :"V1009" ] = "/ : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1010 / : divieded by zero"
+@@error_message[ :"V1010" ] = "/ : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1011 % : divieded by zero"
+@@error_message[ :"V1011" ] = "% : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1012 % : divieded by zero"
+@@error_message[ :"V1012" ] = "% : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1013 integer value cannot cast to $1"
+@@error_message[ :"V1013" ] = "æ´æ°å¤ã¯ $1 ã¸ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1014 comparing bool value with \'$1\'"
+@@error_message[ :"V1014" ] = "ãã¼ã«å¤ã \'$1\' ã¨æ¯è¼ãã¾ããï¼"
+
+# V1015 comparing bool value with \'$1\'"
+@@error_message[ :"V1015" ] = "ãã¼ã«å¤ã \'$1\' ã¨æ¯è¼ãã¾ããï¼"
+
+# V1016 bool value cannot cast to $1"
+@@error_message[ :"V1016" ] = "ãã¼ã«å¤ã¯ $1 ã¸ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1017 / : divieded by zero"
+@@error_message[ :"V1017" ] = "/ : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1018 % : divieded by zero"
+@@error_message[ :"V1018" ] = "% : ã¼ã­é¤ç®ã¨ã©ã¼ã§ãï¼"
+
+# V1019 floating value cannot cast to $1"
+@@error_message[ :"V1019" ] = "æµ®åå°æ°ç¹å¤ã¯ $1 ã¸ã®ã­ã£ã¹ããè¡ããã¨ãã§ãã¾ããï¼"
+
+# V1020 convert floating value to bool without cast"
+@@error_message[ :"V1020" ] = "æµ®åå°æ°ç¹å¤ãã­ã£ã¹ãç¡ãã§ãã¼ã«åã¸å¤æãã¾ããï¼"
+
+# V1021 convert floating value to integer without cast"
+@@error_message[ :"V1021" ] = "æµ®åå°æ°ç¹åãã­ã£ã¹ãç¡ãã§æ´æ°åã¸å¤æãã¾ããï¼"
+
+# V1022 string cannot cast to integer"
+@@error_message[ :"V1022" ] = "æå­åã¯æ´æ°åã«ã­ã£ã¹ãã§ãã¾ãã"
+
+# V1023 string cannot cast to float"
+@@error_message[ :"V1023" ] = "æå­åã¯æµ®åå°æ°ç¹åã«ã­ã£ã¹ãã§ãã¾ãã"
+
+# V1024 string cannot cast to pointer"
+@@error_message[ :"V1024" ] = "æå­åã¯ãã¤ã³ã¿åã«ã­ã£ã¹ãã§ãã¾ãã"
+
+# V1025 string cannot cast to $1"
+@@error_message[ :"V1025" ] = "æå­åã¯ $1 ã«ã­ã£ã¹ãã§ãã¾ãã"
+
+###
+# warning ã¡ãã»ã¼ã¸
+@@warning_message = {}
+
+### componentobj.rb
+# W1001 \'$1\': unknown context type. usually specifiy task, non-task or any"
+@@warning_message[ :"W1001" ] = "\'$1\': ä¸æãªã³ã³ãã­ã¹ãåã§ãï¼éå¸¸ task, non-task ã¾ãã¯ any ãæå®ãã¦ä¸ããï¼"
+
+# W1002 $1: non-active celltype has no entry port & factory"
+@@warning_message[ :"W1002" ] = "$1: éã¢ã¯ãã£ããªã»ã«ã¿ã¤ããåãå£åã³ãã¡ã¯ããªãæã£ã¦ãã¾ããï¼"
+
+# W1003 $1 : require call port overridden in $2"
+@@warning_message[ :"W1003" ] = "$1 : ãªã¯ã¯ã¤ã¢å¼ã³å£ã $2 ã§ãªã¼ãã¼ã©ã¤ãããã¾ããï¼"
+
+# W1004 $1 : specified singleton but has no singleton in this celltype"
+@@warning_message[ :"W1004" ] = "$1 : specified singleton but has no singleton in this celltype"
+
+# W1005 $1 : idx_is_id is ineffective for composite celltype"
+@@warning_message[ :"W1005" ] = "$1 : idx_is_id ã¯è¤åã»ã«ã¿ã¤ãã«å¯¾ãã¦ã¯ç¡å¹ã§ãï¼"
+
+# W1006 $1 : only prototype, unused and undefined cell"
+@@warning_message[ :"W1006" ] = "$1 : ãã­ãã¿ã¤ãã®ã¿ï¼æªä½¿ç¨ï¼ãã¤æªå®ç¾©ã®ã»ã«ã§ãï¼"
+
+# W1007 $1 : non-active cell has no entry join and no factory"
+@@warning_message[ :"W1007" ] = "$1 : éã¢ã¯ãã£ãã»ã«ã«åãå£ã®çµååã³ãã¡ã¯ããªãããã¾ããï¼"
+
+# W1008 $1: reuse designation mismatch with previous import"
+@@warning_message[ :"W1008" ] = "$1: åä½¿ç¨ã®æç¤ºãä»¥åã®ã¤ã³ãã¼ãã®ã¨æ´åãã¾ããï¼"
+
+# "W1009 $1: fixed join entry port has multi join"
+@@warning_message[ :"W1009" ] = "$1: åºå®çµååãå£ãè¤æ°ã®çµåãæã£ã¦ãã¾ãï¼"
+
+### types.rb
+# W2001 signed int$1_t: obsolete. use int$2_t"
+@@warning_message[ :"W2001" ] = "signed int$1_t: æ¨å¥¨ããã¾ããï¼int$2_t ããä½¿ããã ããï¼"
+
+# W2002 unsinged int$1_t: obsolete. use uint$2_t"
+@@warning_message[ :"W2002" ] = "unsinged int$1_t: æ¨å¥¨ããã¾ããï¼uint$2_t ããä½¿ããã ããï¼"
+
+# W2003 $1: too large to cast to $2, clipped($3)"
+@@warning_message[ :"W2003" ] = "$1: $2 ã¸ã­ã£ã¹ãããã®ã«å¤§ãããã¾ãï¼åãè©°ãã¾ãã($3)"
+
+# W2004 $1: too small to cast to $2, clipped($3)"
+@@warning_message[ :"W2004" ] = "$1: $2 ã¸ã­ã£ã¹ãããã®ã«å°ãããã¾ãï¼åãè©°ãã¾ãã($3)"
+
+# W2005 $1: negative value for unsigned: convert to $2"
+@@warning_message[ :"W2005" ] = "$1: ç¬¦å·ç¡ãæ´æ°åã«å¯¾ãã¦è² æ°å¤ã§ã : $2 ã¸å¤æãã¾ããï¼"
+
+### syntaxobj.rb
+# W3001 $1: duplicate"
+@@warning_message[ :"W3001" ] = "$1: éè¤ãã¦ãã¾ãï¼"
+
+# W3002 $1: this string might cause buffer over run"
+@@warning_message[ :"W3002" ] = "$1: ãã®æå­åã¯ãããã¡ã¼ãªã¼ãã¼ã©ã³ãå¼ãèµ·ããããããã¾ããï¼"
+
+# W3003 $1 pointer level mismatch"
+@@warning_message[ :"W3003" ] = "$1 ãã¤ã³ã¿ã¼ã¬ãã«ã®ä¸æ´åã§ãï¼"
+
+# W3004 $1 pointer type has returned. specify deviate or stop return pointer"
+@@error_message[ :"W3004" ] = "$1 ãã¤ã³ã¿åãè¿ããã¾ãããdeviate ãæå®ããããã¤ã³ã¿ãè¿ãã®ãæ­¢ãã¦ãã ãã"
+
+# W3005 '$1' size_is always lower than max. max is ignored"
+@@error_message[ :"W3005" ] = "'$1' size_is ã¯å¸¸ã« max ããå°ãã. max ã¯ç¡è¦ããã¾ã"
+
+### bnf.y.rb
+# W5001 bool: obsolete type. use bool_t"
+@@warning_message[ :"W5001" ] = "bool: æ¨å¥¨ãããªããã¼ã¿åã§ãï¼bool_t ããä½¿ããã ããï¼"
+
+# W5002 float: obsolete type. use float32_t"
+@@warning_message[ :"W5002" ] = "float: æ¨å¥¨ãããªããã¼ã¿åã§ãï¼float32_t ããä½¿ããã ããï¼"
+
+# W5003 double: obsolete type. use double64_t"
+@@warning_message[ :"W5003" ] = "double: æ¨å¥¨ãããªããã¼ã¿åã§ãï¼double64_t ããä½¿ããã ããï¼"
+
+# W5004 char: obsolete type. use char_t"
+@@warning_message[ :"W5004" ] = "char: æ¨å¥¨ãããªããã¼ã¿åã§ãï¼char_t ããä½¿ããã ããï¼"
+
+# W5005 int8: obsolete. use int8_t"
+@@warning_message[ :"W5005" ] = "int8: æ¨å¥¨ããã¾ããï¼int8_t ããä½¿ããã ããï¼"
+
+# W5006 int16: obsolete. use int16_t"
+@@warning_message[ :"W5006" ] = "int16: æ¨å¥¨ããã¾ããï¼int16_t ããä½¿ããã ããï¼"
+
+# W5007 int32: obsolete. use int32_t"
+@@warning_message[ :"W5007" ] = "int32: æ¨å¥¨ããã¾ããï¼int32_t ããä½¿ããã ããï¼"
+
+# W5008 int64: obsolete. use int64_t"
+@@warning_message[ :"W5008" ] = "int64: æ¨å¥¨ããã¾ããï¼int64_t ããä½¿ããã ããï¼"
+
+# W5009 int64: obsolete. use int64_t"
+@@warning_message[ :"W5009" ] = "int64: æ¨å¥¨ããã¾ããï¼int64_t ããä½¿ããã ããï¼"
+
+# W5010 need 'void' for no parameter"
+@@warning_message[ :"W5010" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+# W5011 need 'void' for no parameter"
+@@warning_message[ :"W5011" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+### C_parser.y.rb
+# W6001 need 'void' for no parameter"
+@@warning_message[ :"W6001" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+# W6002 need 'void' for no parameter"
+@@warning_message[ :"W6002" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+# W6003 need 'void' for no parameter"
+@@warning_message[ :"W6003" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+# W6004 need 'void' for no parameter"
+@@warning_message[ :"W6004" ] = "ãã©ã¡ã¼ã¿ãå­å¨ããªãå ´å 'void' ãå¿
+è¦ã§ã"
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_en_US.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_en_US.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_en_US.rb	(revision 317)
@@ -0,0 +1,349 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: messages_file_en_US.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+
+# File Messages for en_US 
+class TECSMsg
+
+## generate.rb ##
+
+@@comment = {}
+
+# MSg.note
+# @@comment[ :note ] = " * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
+#  * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ã¯ãæå³ããã¦ãã¾ãã
+# "
+@@comment[ :note ] = " * This file was automatically generated by tecsgen.
+ * This file is not intended to be edited.
+"
+
+# @@comment[ :preamble_note ] = "/* #[<PREAMBLE>]#
+#  * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+#  * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+# "
+@@comment[ :preamble_note ] = "/* #[<PREAMBLE>]#
+ * Don't edit the comments between #[<...>]# and #[</...>]#
+ * These comment are used by tecsmerege when merging.
+"
+
+# @@comment[ :postamble_note ] = "/* #[<POSTAMBLE>]#
+#  *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+#  * #[</POSTAMBLE>]#*/
+# "
+@@comment[ :postamble_note ] = "/* #[<POSTAMBLE>]#
+ *   Put non-entry functions below.
+ * #[</POSTAMBLE>]#*/
+"
+
+# @@comment[ :template_note ] = "/*
+#  * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ãããã³ãã¬ã¼ãã¨ãã¦èªåçæããã¾ãã
+#  * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ãæå³ããã¦ãã¾ãã
+#  * tecsgen ã®åå®è¡ã«ããä¸æ¸ãããã¦ãã¾ããããéå¸¸
+#  *   gen/%s_template.c => src/%s.c
+#  * ã®ããã«åå, ãã©ã«ããå¤æ´ãã¦ããä¿®æ­£ãã¾ã
+#  */
+# "
+@@comment[ :template_note ] = "/*
+ * This file was automatically generated by tecsgen.
+ * Move and rename like below before editing,
+ *   gen/%s_template.c => src/%s.c
+ * to avoid to be overwritten by tecsgen.
+ */
+"
+
+# @@comment[ :inline_template_note ] = "/*
+#  * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ãããã³ãã¬ã¼ãã¨ãã¦èªåçæããã¾ãã
+#  * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ãæå³ããã¦ãã¾ãã
+#  * tecsgen ã®åå®è¡ã«ããä¸æ¸ãããã¦ãã¾ããããéå¸¸
+#  *   gen/%s_inline_template.h => src/%s_inline.h
+#  * ã®ããã«åå, ãã©ã«ããå¤æ´ãã¦ããä¿®æ­£ãã¾ã
+#  */
+# "
+@@comment[ :inline_template_note ] = "/*
+ * This file was automatically generated by tecsgen.
+ * Move and rename like below before editing,
+ *   gen/%s_inline_template.h => src/%s_inline.h
+ * to avoid to be overwritten by tecsgen.
+ */
+"
+
+# @@comment[ :Makefile_note ] = "# ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
+# # Makefile.temp ã¯ gen ã®ä¸ã¤ä¸ã®ãã£ã¬ã¯ããªã«ç§»ãã¦ä½¿ç¨ãã¾ã
+# #  % mv Makefile.temp Makefile
+# # 
+# # clean ã®ããã©ã«ãåä½ã¯ $(GEN_DIR)/Makefile.* ãåé¤ãã¾ã
+# 
+# "
+@@comment[ :Makefile_note ] = "# This file was automatically generated by tecsgen.
+# Move Makefile.temp upper directory like below before editing.
+#  % mv Makefile.temp Makefile
+# 
+# \"make clean\" deletes $(GEN_DIR)/Makefile.* by default.
+#
+# This file is generated suitable for GNU make and a target on POSIX environemnt using gcc.
+# You might have to adjust vpath, CFLAGS, OTHER_OBJS, etc.
+# For other target you have to modify this file.
+
+"
+
+# @@comment[ :oneway_ercd_note ] = "/* oneway ã®å ´å E_OK ããè¿ãã¾ãã */"
+@@comment[ :oneway_ercd_note ] = "/* Oneway function always returns E_OK. */"
+
+# @@comment[ :ercd_note ] = "/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */"
+@@comment[ :ercd_note ] = "/* Write error processing code here */"
+
+# @@comment[ :IMP_comment ] = "\n/* import_C ã«ãã import ãããããã %s */\n"
+@@comment[ :IMP_comment ] = "\n/* header imported by import_C %s */\n"
+
+# @@comment[ :MVAR_comment ] = "# å¤æ° %s\n"
+@@comment[ :MVAR_comment ] = "# var %s\n"
+
+# @@comment[ :MRUL_comment ] = "# ã«ã¼ã« %s\n"
+@@comment[ :MRUL_comment ] = "# Rule %s\n"
+
+# @@comment[ :TCM_comment ] = "# ãã³ãã¬ã¼ãã³ã¼ãã§ã¡ã¼ã¯ãã¦ã¿ãå ´å %s\n"
+@@comment[ :TCM_comment ] = "# in case build with template code %s\n"
+
+# @@comment[ :MDEP_comment ] = "\n# depend ã include %s\n"
+@@comment[ :MDEP_comment ] = "\n# include dependcy %s\n"
+
+# @@comment[ :SDI_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿åç
+§ããã %s */\n"
+@@comment[ :SDI_comment ] = "/* descriptor referencing signature header %s */\n"
+
+# @@comment[ :SD_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ %s */\n"
+@@comment[ :SD_comment ] = "/* signature descriptor %s */\n"
+
+# @@comment[ :SFT_comment ] = "/* ã·ã°ããã£é¢æ°ãã¼ãã« %s */\n"
+@@comment[ :SFT_comment ] = "/* signature function table %s */\n"
+
+# @@comment[ :SDES_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿(åççµåç¨) %s */\n"
+@@comment[ :SDES_comment ] = "/* signature descriptor %s for dynamic join */\n"
+
+# @@comment[ :IRTH_comment ] = "/* ã©ã³ã¿ã¤ã ããã %s */\n"
+
+# @@comment[ :UDF_comment ] = "/* inline ã®ããã® undef %s */\n"
+@@comment[ :UDF_comment ] = "/* undef for inline %s */\n"
+
+# @@comment[ :IGH_comment ] = "/* ã°ã­ã¼ãã«ããã %s */\n"
+@@comment[ :IGH_comment ] = "/* global header %s */\n"
+
+# @@comment[ :ISH_comment ] = "/* ã·ã°ããã£ããã %s */\n"
+@@comment[ :ISH_comment ] = "/* signature header %s */\n"
+
+# @@comment[ :ICT_comment ] = "/* æé©åã®ããåç
+§ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã %s */\n"
+@@comment[ :ICT_comment ] = "/* to get the definition of CB type of referenced celltype for optimization %s */\n"
+
+# @@comment[ :NIDB_comment ] = "ID ã®ãã¼ã¹ "
+@@comment[ :NIDB_comment ] = "ID Base "
+
+# @@comment[ :NCEL_comment ] = "ã»ã«ã®åæ°"
+@@comment[ :NCEL_comment ] = " number of cells"
+
+# @@comment[ :CVI_comment ] = "/* IDXã®æ­£å½æ§ãã§ãã¯ãã¯ã­ %s */\n"
+@@comment[ :CVI_comment ] = "/* IDX validation macro %s */\n"
+
+# @@comment[ :CVIA_comment ] = "/* IDXã®æ­£å½æ§ãã§ãã¯ãã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :CVIA_comment ] = "/* IDX validation macro (abbrev.) %s */\n"
+
+# @@comment[ :NCPA_comment ] = "/* å¼ã³å£é
+åã®å¤§ãããå¾ããã¯ã­ %s */\n"
+@@comment[ :NCPA_comment ] = "/* call port array size macro %s */\n"
+
+# @@comment[ :NEPA_comment ] = "/* åãå£é
+åã®å¤§ãããå¾ããã¯ã­ %s */\n"
+@@comment[ :NEPA_comment ] = "/* entry port array size macro %s */\n"
+
+# @@comment[ :TOCP_comment ] = "/* optional å¼ã³å£ããã¹ããããã¯ã­ %s */\n"
+@@comment[ :TOCP_comment ] = "/* optional call port test macro %s */\n"
+
+# @@comment[ :TOCPA_comment ] = "/* optional å¼ã³å£ããã¹ããããã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :TOCPA_comment ] = "/* optional call port test macro (abbrev) %s */\n"
+
+# @@comment[ :GCB_comment ] = "\n/* ã»ã«CBãå¾ããã¯ã­ %s */\n"
+@@comment[ :GCB_comment ] = "\n/* celll CB macro %s */\n"
+
+# @@comment[ :GCBA_comment ] = "\n/* ã»ã«CBãå¾ããã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :GCBA_comment ] = "\n/* cell CB macro (abbrev) %s */\n"
+
+# @@comment[ :CCT_comment ] = "/* CELLCB å(ç­ç¸®å½¢) %s */\n"
+@@comment[ :CCT_comment ] = "/* CELLCB type (abbrev) %s */\n"
+
+# @@comment[ :CTIXA_comment ] = "/* ã»ã«ã¿ã¤ãã®IDXå(ç­ç¸®å½¢) %s */\n"
+@@comment[ :CTIXA_comment ] = "/* celltype IDX type (abbrev) %s */\n"
+
+# @@comment[ :AAM_comment ] = "\n/* å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s */\n"
+@@comment[ :AAM_comment ] = "\n/* attr access  %s */\n"
+
+# @@comment[ :VAM_comment ] = "\n/* var ã¢ã¯ã»ã¹ãã¯ã­ %s */\n"
+@@comment[ :VAM_comment ] = "\n/* var access macro %s */\n"
+
+# @@comment[ :AAMA_comment ] = "\n/* å±æ§ã¢ã¯ã»ã¹ãã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :AAMA_comment ] = "\n/* attr access macro (abbrev) %s */\n"
+
+# @@comment[ :VAMA_comment ] = "\n/* var ã¢ã¯ã»ã¹ãã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :VAMA_comment ] = "\n/* var access macro (abbrev) %s */\n"
+
+# @@comment[ :CPM_comment ] = " /* å¼ã³å£é¢æ°ãã¯ã­ %s */\n"
+@@comment[ :CPM_comment ] = " /* call port function macro %s */\n"
+
+# @@comment[ :CPMA_comment ] = "/* å¼ã³å£é¢æ°ãã¯ã­ï¼ç­ç¸®å½¢ï¼%s */\n"
+@@comment[ :CPMA_comment ] = "/* call port function macro (abbrev) %s */\n"
+
+# @@comment[ :EPM_comment ] = "\n/* åãå£é¢æ°ãã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :EPM_comment ] = "\n/* entry port function macro (abbrev) %s */\n"
+
+# @@comment[ :CTIX_comment ] = "\n/* ã»ã«ã¿ã¤ãã®IDXå %s */\n"
+@@comment[ :CTIX_comment ] = "\n/* celltype IDX type %s */\n"
+
+# @@comment[ :EPP_comment ] = "\n/* åãå£é¢æ°ãã­ãã¿ã¤ãå®£è¨ %s */\n"
+@@comment[ :EPP_comment ] = "\n/* prototype declaration of entry port function %s */\n"
+
+# @@comment[ :EPSP_comment ] = "\n/* åãå£ã¹ã±ã«ãã³é¢æ°ãã­ãã¿ã¤ãå®£è¨ï¼VMTä¸è¦æé©åã«ããåç
+§ãããã®ï¼ %s */\n"
+@@comment[ :EPSP_comment ] = "\n/* prototype declaration of entry port function (referenced when VMT useless optimise enabled) %s */\n"
+
+# @@comment[ :INL_comment ] = "/* inline ãããã® include %s */\n"
+@@comment[ :INL_comment ] = "/*  include inline header %s */\n"
+
+# @@comment[ :CIP_comment ] = "/* ã»ã« INIB åå®£è¨ %s */\n"
+@@comment[ :CIP_comment ] = "/* cell INIB type definition %s */\n"
+
+# @@comment[ :CCTPA_comment ] = "/* ã»ã« CB åå®£è¨ %s */\n"
+@@comment[ :CCTPA_comment ] = "/* cell CB type definition %s */\n"
+
+# @@comment[ :CCDP_comment ] = "/* ã»ã« CB (ããã¼)åå®£è¨ %s */\n"
+@@comment[ :CCDP_comment ] = "/* cell CB (dummy) type definition %s */\n"
+
+# @@comment[ :CCTPO_comment ] = "/* ã»ã« CB åå®£è¨ %s */\n"
+@@comment[ :CCTPO_comment ] = "/* cell CB type definition %s */\n"
+
+# @@comment[ :SCP_comment ] = "/* ã·ã³ã°ã«ãã³ã»ã« CB ãã­ãã¿ã¤ãå®£è¨ %s */\n"
+@@comment[ :SCP_comment ] = "/* singleton cell CB prototype declaration %s */\n"
+
+# @@comment[ :DCI_comment ] = "\n/* CB ã¯å­å¨ããªããINIB ã CB ã®ä»£ããã«ä½¿ç¨ããããã® define %s */\n"
+@@comment[ :DCI_comment ] = "\n/* CB not exist. CB corresponding to INIB %s */\n"
+
+# @@comment[ :FEC_comment ] = "/* ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ %s */\n"
+@@comment[ :FEC_comment ] = "/* iteration code (FOREACH_CELL) %s */\n"
+
+# @@comment[ :DAL_comment ] = "/* deallocate ãã¯ã­ %s */\n"
+@@comment[ :DAL_comment ] = "/* deallocate macro %s */\n"
+
+# @@comment[ :NFEC_comment ] = "/* ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ(CB,INIB ã¯å­å¨ããªã) %s */\n"
+@@comment[ :NFEC_comment ] = "/* iteration code (FOREACH_CELL) (niether CB, nor NIB exit) %s */\n"
+
+# @@comment[ :CIM_comment ] = "/* CB åæåãã¯ã­ %s */\n"
+@@comment[ :CIM_comment ] = "/* CB initialize macro %s */\n"
+
+# @@comment[ :EDT_comment ] = "/* åãå£ãã£ã¹ã¯ãªãã¿å %s */\n"
+@@comment[ :EDT_comment ] = "/* entry port descriptor type %s */\n"
+
+# @@comment[ :EPSF_comment ] = "/* åãå£ã¹ã±ã«ãã³é¢æ° %s */\n"
+@@comment[ :EPSF_comment ] = "/* entry port skelton function %s */\n"
+
+# @@comment[ :EPSFT_comment ] = "/* åãå£ã¹ã±ã«ãã³é¢æ°ãã¼ãã« %s */\n"
+@@comment[ :EPSFT_comment ] = "/* entry port skelton function table %s */\n"
+
+# @@comment[ :CPEPD_comment ] = "/* å¼ã³å£ã®åç
+§ããåãå£ãã£ã¹ã¯ãªãã¿(å®éã®åã¨ç¸éããå®ç¾©) %s */\n"
+@@comment[ :CPEPD_comment ] = "/* entry port descriptor referenced by call port (differ from actual definition) %s */\n"
+
+# @@comment[ :CPA_comment ] = "/* å¼ã³å£é
+å %s */\n"
+@@comment[ :CPA_comment ] = "/* call port array %s */\n"
+
+# @@comment[ :CIC_comment ] = "/* CB åæåã³ã¼ã %s */\n"
+@@comment[ :CIC_comment ] = "/* CB initialize code %s */\n"
+
+# @@comment[ :AVAI_comment ] = "/* å±æ§ã»å¤æ°ã®é
+å %s */\n"
+@@comment[ :AVAI_comment ] = "/* array of attr/var %s */\n"
+
+# @@comment[ :AVI_comment ] = "/* å¤æ°(æ§é ä½ãé
+å)åæå¤ %s */\n"
+@@comment[ :AVI_comment ] = "/* var (struct, array) initial value %s */\n"
+
+# @@comment[ :INIB_comment ] = "/* ã»ã« INIB %s */\n"
+@@comment[ :INIB_comment ] = "/* cell INIB %s */\n"
+
+# @@comment[ :CB_comment ] = "/* ã»ã« CB %s */\n"
+@@comment[ :CB_comment ] = "/* cell CB %s */\n"
+
+# @@comment[ :EPD_comment ] = "/* åãå£ãã£ã¹ã¯ãªãã¿ %s */\n"
+@@comment[ :EPD_comment ] = "/* entry port descriptor %s */\n"
+
+# @@comment[ :PAC_comment ] = "/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã %s */\n"
+@@comment[ :PAC_comment ] = "/* Put prototype declaration and/or variale definition here %s */\n"
+
+# @@comment[ :CAAM_comment ] = " *\n * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s\n"
+@@comment[ :CAAM_comment ] = " *\n * attr access macro %s\n"
+
+# @@comment[ :CAAMI_comment ] = " *\n * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s\n"
+@@comment[ :CAAMI_comment ] = " *\n * attr access macro %s\n"
+
+# @@comment[ :TYP_comment ] = " *\n * å %s\n * CELLCB å  : %s\n * CELLIDX å : %s\n"
+@@comment[ :TYP_comment ] = " *\n * type %s\n * CELLCB type  : %s\n * CELLIDX type : %s\n"
+
+# @@comment[ :TCPF_comment ] = " * å¼ã³å£é¢æ° %s\n"
+@@comment[ :TCPF_comment ] = " * call port function %s\n"
+
+# @@comment[ :TEPF_comment ] = "/* åãå£é¢æ° %s */\n"
+@@comment[ :TEPF_comment ] = "/* entry port function %s */\n"
+
+# @@comment[ :TEFB_comment ] = "\t/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã %s */\n"
+@@comment[ :TEFB_comment ] = "\t/* Put statements here %s */\n"
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_ja_JP.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_ja_JP.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/messages/messages_file_ja_JP.rb	(revision 317)
@@ -0,0 +1,189 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: messages_file_ja_JP.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+
+# File Messages for ja_JP
+class TECSMsg
+
+## generate.rb ##
+
+@@comment = {}
+
+# MSg.note
+@@comment[ :note ] = " * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
+ * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ã¯ãæå³ããã¦ãã¾ãã
+"
+
+@@comment[ :preamble_note ] = "/* #[<PREAMBLE>]#
+ * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+ * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+"
+
+@@comment[ :postamble_note ] = "/* #[<POSTAMBLE>]#
+ *   ããããä¸ã«éåãå£é¢æ°ãæ¸ãã¾ã
+ * #[</POSTAMBLE>]#*/
+"
+
+@@comment[ :template_note ] = "/*
+ * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ãããã³ãã¬ã¼ãã¨ãã¦èªåçæããã¾ãã
+ * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ãæå³ããã¦ãã¾ãã
+ * tecsgen ã®åå®è¡ã«ããä¸æ¸ãããã¦ãã¾ããããéå¸¸
+ *   gen/%s_template.c => src/%s.c
+ * ã®ããã«åå, ãã©ã«ããå¤æ´ãã¦ããä¿®æ­£ãã¾ã
+ */
+"
+
+@@comment[ :inline_template_note ] = "/*
+ * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ãããã³ãã¬ã¼ãã¨ãã¦èªåçæããã¾ãã
+ * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ãæå³ããã¦ãã¾ãã
+ * tecsgen ã®åå®è¡ã«ããä¸æ¸ãããã¦ãã¾ããããéå¸¸
+ *   gen/%s_inline_template.h => src/%s_inline.h
+ * ã®ããã«åå, ãã©ã«ããå¤æ´ãã¦ããä¿®æ­£ãã¾ã
+ */
+"
+
+@@comment[ :Makefile_note ] = "# ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
+# Makefile.temp ã¯ gen ã®ä¸ã¤ä¸ã®ãã£ã¬ã¯ããªã«ç§»ãã¦ä½¿ç¨ãã¾ã
+#  % mv Makefile.temp Makefile
+# 
+# clean ã®ããã©ã«ãåä½ã¯ $(GEN_DIR)/Makefile.* ãåé¤ãã¾ã
+#
+# ãã®ãã¡ã¤ã«ã¯ GNU make ã§ gcc ãç¨ã POSIX ç°å¢ã§åä½ããã¢ã¸ã¥ã¼ã«ããã«ãããã®ã«é©åãªããã«çæããã¦ãã¾ã
+# vpath, CFLAGS, OTHER_OBJS ãªã©ãèª¿æ´ããå¿
+è¦ãããããããã¾ãã
+# ä»ã®ç°å¢ãã¿ã¼ã²ããã®å ´åããã®ãã¡ã¤ã«ãå
+ã«å¤æ´ããå¿
+è¦ãããã¾ã
+
+"
+
+@@comment[ :oneway_ercd_note ] = "/* oneway ã®å ´å E_OK ããè¿ãã¾ãã */"
+@@comment[ :ercd_note ] = "/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿°ãã¾ã */"
+
+@@comment[ :IMP_comment ] = "\n/* import_C ã«ãã import ãããããã %s */\n"
+@@comment[ :MVAR_comment ] = "# å¤æ° %s\n"
+@@comment[ :MRUL_comment ] = "# ã«ã¼ã« %s\n"
+@@comment[ :TCM_comment ] = "# ãã³ãã¬ã¼ãã³ã¼ãã§ã¡ã¼ã¯ãã¦ã¿ãå ´å %s \n"
+@@comment[ :MDEP_comment ] = "\n# depend ã include %s\n"
+@@comment[ :SDI_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿åç
+§ããã %s */\n"
+@@comment[ :SD_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿ %s */\n"
+@@comment[ :SFT_comment ] = "/* ã·ã°ããã£é¢æ°ãã¼ãã« %s */\n"
+@@comment[ :SDES_comment ] = "/* ã·ã°ããã£ãã£ã¹ã¯ãªãã¿(åççµåç¨) %s */\n"
+# @@comment[ :IRTH_comment ] = "/* ã©ã³ã¿ã¤ã ããã %s */\n"
+@@comment[ :UDF_comment ] = "/* inline ã®ããã® undef %s */\n"
+@@comment[ :IGH_comment ] = "/* ã°ã­ã¼ãã«ããã %s */\n"
+@@comment[ :ISH_comment ] = "/* ã·ã°ããã£ããã %s */\n"
+@@comment[ :ICT_comment ] = "/* æé©åã®ããåç
+§ããã»ã«ã¿ã¤ãã® CB åã®å®ç¾©ãåè¾¼ã %s */\n"
+@@comment[ :NIDB_comment ] = "ID ã®ãã¼ã¹ "
+@@comment[ :NCEL_comment ] = "ã»ã«ã®åæ°"
+@@comment[ :CVI_comment ] = "/* IDXã®æ­£å½æ§ãã§ãã¯ãã¯ã­ %s */\n"
+@@comment[ :CVIA_comment ] = "/* IDXã®æ­£å½æ§ãã§ãã¯ãã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :NCPA_comment ] = "/* å¼ã³å£é
+åã®å¤§ãããå¾ããã¯ã­ %s */\n"
+@@comment[ :NEPA_comment ] = "/* åãå£é
+åã®å¤§ãããå¾ããã¯ã­ %s */\n"
+@@comment[ :TOCP_comment ] = "/* optional å¼ã³å£ããã¹ããããã¯ã­ %s */\n"
+@@comment[ :TOCPA_comment ] = "/* optional å¼ã³å£ããã¹ããããã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :GCB_comment ] = "\n/* ã»ã«CBãå¾ããã¯ã­ %s */\n"
+@@comment[ :GCBA_comment ] = "\n/* ã»ã«CBãå¾ããã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :CCT_comment ] = "/* CELLCB å(ç­ç¸®å½¢) %s */\n"
+@@comment[ :CTIXA_comment ] = "/* ã»ã«ã¿ã¤ãã®IDXå(ç­ç¸®å½¢) %s */\n"
+@@comment[ :AAM_comment ] = "\n/* å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s */\n"
+@@comment[ :VAM_comment ] = "\n/* var ã¢ã¯ã»ã¹ãã¯ã­ %s */\n"
+@@comment[ :AAMA_comment ] = "\n/* å±æ§ã¢ã¯ã»ã¹ãã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :VAMA_comment ] = "\n/* var ã¢ã¯ã»ã¹ãã¯ã­(ç­ç¸®å½¢) %s */\n"
+@@comment[ :CPM_comment ] = " /* å¼ã³å£é¢æ°ãã¯ã­ %s */\n"
+@@comment[ :CPMA_comment ] = "/* å¼ã³å£é¢æ°ãã¯ã­ï¼ç­ç¸®å½¢ï¼%s */\n"
+@@comment[ :EPM_comment ] = "\n/* åãå£é¢æ°ãã¯ã­ï¼ç­ç¸®å½¢ï¼ %s */\n"
+@@comment[ :CTIX_comment ] = "\n/* ã»ã«ã¿ã¤ãã®IDXå %s */\n"
+@@comment[ :EPP_comment ] = "\n/* åãå£é¢æ°ãã­ãã¿ã¤ãå®£è¨ %s */\n"
+@@comment[ :EPSP_comment ] = "\n/* åãå£ã¹ã±ã«ãã³é¢æ°ãã­ãã¿ã¤ãå®£è¨ï¼VMTä¸è¦æé©åã«ããåç
+§ãããã®ï¼ %s */\n"
+@@comment[ :INL_comment ] = "/* inline ãããã® include %s */\n"
+@@comment[ :CIP_comment ] = "/* ã»ã« INIB åå®£è¨ %s */\n"
+@@comment[ :CCTPA_comment ] = "/* ã»ã« CB åå®£è¨ %s */\n"
+@@comment[ :CCDP_comment ] = "/* ã»ã« CB (ããã¼)åå®£è¨ %s */\n"
+@@comment[ :CCTPO_comment ] = "/* ã»ã« CB åå®£è¨ %s */\n"
+@@comment[ :SCP_comment ] = "/* ã·ã³ã°ã«ãã³ã»ã« CB ãã­ãã¿ã¤ãå®£è¨ %s */\n"
+@@comment[ :DCI_comment ] = "\n/* CB ã¯å­å¨ããªããINIB ã CB ã®ä»£ããã«ä½¿ç¨ããããã® define %s */\n"
+@@comment[ :FEC_comment ] = "/* ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ %s */\n"
+@@comment[ :DAL_comment ] = "/* deallocate ãã¯ã­ %s */\n"
+@@comment[ :NFEC_comment ] = "/* ã¤ãã¬ã¼ã¿ã³ã¼ã (FOREACH_CELL)ã®çæ(CB,INIB ã¯å­å¨ããªã) %s */\n"
+@@comment[ :CIM_comment ] = "/* CB åæåãã¯ã­ %s */\n"
+@@comment[ :EDT_comment ] = "/* åãå£ãã£ã¹ã¯ãªãã¿å %s */\n"
+@@comment[ :EPSF_comment ] = "/* åãå£ã¹ã±ã«ãã³é¢æ° %s */\n"
+@@comment[ :EPSFT_comment ] = "/* åãå£ã¹ã±ã«ãã³é¢æ°ãã¼ãã« %s */\n"
+@@comment[ :CPEPD_comment ] = "/* å¼ã³å£ã®åç
+§ããåãå£ãã£ã¹ã¯ãªãã¿(å®éã®åã¨ç¸éããå®ç¾©) %s */\n"
+@@comment[ :CPA_comment ] = "/* å¼ã³å£é
+å %s */\n"
+@@comment[ :CIC_comment ] = "/* CB åæåã³ã¼ã %s */\n"
+@@comment[ :AVAI_comment ] = "/* å±æ§ã»å¤æ°ã®é
+å %s */\n"
+@@comment[ :AVI_comment ] = "/* å¤æ°(æ§é ä½ãé
+å)åæå¤ %s */\n"
+@@comment[ :INIB_comment ] = "/* ã»ã« INIB %s */\n"
+@@comment[ :CB_comment ] = "/* ã»ã« CB %s */\n"
+@@comment[ :EPD_comment ] = "/* åãå£ãã£ã¹ã¯ãªãã¿ %s */\n"
+@@comment[ :PAC_comment ] = "/* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã %s */\n"
+@@comment[ :CAAM_comment ] = " *\n * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s\n"
+@@comment[ :CAAMI_comment ] = " *\n * å±æ§ã¢ã¯ã»ã¹ãã¯ã­ %s\n"
+@@comment[ :TYP_comment ] = " *\n * å %s\n * CELLCB å  : %s\n * CELLIDX å : %s\n"
+@@comment[ :TCPF_comment ] = " * å¼ã³å£é¢æ° %s\n"
+@@comment[ :TEPF_comment ] = "/* åãå£é¢æ° %s */\n"
+@@comment[ :TEFB_comment ] = "\t/* ããã«å¦çæ¬ä½ãè¨è¿°ãã¾ã %s */\n"
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb	(revision 317)
@@ -0,0 +1,218 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1AlarmPlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+  file2 = CFile.open( "#{$gen}/ALARM_tecsgen.oil", "w" )
+
+    # ALARM
+    @celltype.get_cell_list.each { |cell|
+
+    if cell.is_generate?
+
+      file2.print "\tALARM #{cell.get_name} {\n"
+
+      # COUNTER
+      join = cell.get_join_list.get_item( :counter )
+      if join then
+        str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+        file2.print "\t\tCOUNTER = #{str};\n"
+      end
+
+      # ACTION
+      join = cell.get_join_list.get_item( :action )
+      if join then
+        str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+      end
+
+      case str
+      when "SETEVENT"
+        file2.print "\t\tACTION = #{str} {\n"
+        join2 = cell.get_join_list.get_item( :task )
+        if join2 then
+          str = join2.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\t\tTASK = #{str};\n"
+        end
+        join2 = cell.get_join_list.get_item( :event )
+        if join2 then
+          str = join2.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\t\tEVENT = #{str};\n"
+        end
+        file2.print "\t\t};\n"
+      when "ACTIVATETASK"
+        file2.print "\t\tACTION = #{str} {\n"
+        join2 = cell.get_join_list.get_item( :task )
+        if join2 then
+          str = join2.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\t\tTASK = #{str};\n"
+        end
+        file2.print "\t\t};\n"
+      when "ALARMCALLBACK"
+        file2.print "\t\tACTION = #{str} {\n"
+        join2 = cell.get_join_list.get_item( :callbackName )
+        if join2 then
+          str = join2.get_rhs.to_s
+          file2.print "\t\t\tALARMCALLBACKNAME = #{str};\n"
+        end
+        file2.print "\t\t};\n"
+      else
+      end
+
+      # AUTOSTART
+      join = cell.get_join_list.get_item( :autoStart )
+      if join then
+        str = join.get_rhs.to_s
+      end
+
+      if str == "TRUE" then
+        file2.print "\t\tAUTOSTART = TRUE {\n"
+        join2 = cell.get_join_list.get_item( :alarmTime )
+        if join2 then
+        str = join2.get_rhs.to_s
+        file2.print "\t\t\tALARMTIME = #{str};\n"
+        end
+        join2 = cell.get_join_list.get_item( :cycleTime )
+        if join2 then
+          str = join2.get_rhs.to_s
+          file2.print "\t\t\tCYCLETIME = #{str};\n"
+        end
+        join2 = cell.get_join_list.get_item( :appMode )
+        delim = ""
+        if join2 then
+          join2.get_rhs.each { |mode|
+            str = mode.to_s.gsub(/^"(.*)"$/, '\1')
+            file2.print "\t\t\tAPPMODE = #{str};\n"
+            delim = ";"
+          }
+        end
+        file2.print "\t\t};\n"
+      else
+        file2.print "\t\tAUTOSTART = FALSE;\n"
+      end
+
+      file2.print "\t};\n"
+      file2.print "\n"
+
+    end
+  }
+
+  file2.close
+
+  # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+  file = AppFile.open( "#{$gen}/tAlarm_tecsgen.#{$c_suffix}" )
+  file.print "\n/* Generated by ATK1AlarmPlugin */\n"
+  @celltype.get_cell_list.each { |cell|
+    if cell.is_generate?
+      name_array = @celltype.get_name_array( cell )
+      join2 = cell.get_join_list.get_item( :callbackName )
+      if join2 then
+        str = join2.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+        file.print <<EOT
+ALARMCALLBACK( #{str} );
+ALARMCALLBACK( #{str} )
+{
+    CELLCB *p_cellcb = #{name_array[8]};
+    cBody_main();
+}
+
+EOT
+      end
+    end
+  }
+
+  file.close
+
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb	(revision 317)
@@ -0,0 +1,129 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1DelayTaskPlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+#    join_list = cell.get_join_list
+#    a = join_list.get_item( :resource )
+#    if a == nil
+#     Generator.error( "resource: must be initialized")
+#    elsif ! a.get_rhs.instance_of? Array
+#      Generator.error( "resource: initializer must be in format of '{val1, val2 ...}'")
+#    end
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+    # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+    file2 = AppFile.open( "#{$gen}/tDelayTaskBody_factory.#{$h_suffix}" )
+    file2.print "\n/* Generated by ATK1DelayTaskPlugin */\n\n"
+    @celltype.get_cell_list.each { |cell|
+      if cell.is_generate?
+        name_array = @celltype.get_name_array( cell )
+
+        join = cell.get_join_list.get_item( :event )
+        if join then
+          str = join.get_rhs.to_s
+          if str =~ /&(.*)/ then
+              str = $1
+          end
+
+          file2.print "DeclareEvent( #{str} );\n"
+        end
+
+      end
+    }
+
+    file2.close
+
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1EventPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1EventPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1EventPlugin.rb	(revision 317)
@@ -0,0 +1,172 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== ATK1 Event celltype ãã©ã°ã¤ã³ã¯ã©ã¹
+class ATK1EventPlugin < CelltypePlugin
+#@@instancies:: []     :ã»ã«å®ä½ç¾¤
+@@instancies = []
+
+  #===  åæå
+  #      å
+¨ã¦ã®ã»ã«ã®å®ä½ãæå³è§£æå¾ã«åç
+§ããå¿
+è¦ãããããã«
+  #      åæåæã« singleton ã® instancies ã«æ ¼ç´ãã
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+    @@instancies << self
+  end
+
+  #===  cellã®çæ
+  def new_cell cell
+  end
+
+  #===  æå³è§£æå®è¡å¾ã®ã³ã¼ãçæ
+  def self.gen_post_code file
+
+    @@instancies.each { |inst|
+      inst.gen_oil_code file
+    }
+
+  end
+
+  #===  OILãã¡ã¤ã«åºå
+  def gen_oil_code file
+
+    file2 = CFile.open( "#{$gen}/EVENT_tecsgen.oil", "w" )
+
+    whole_mask = 0
+
+    # EVENT
+    @celltype.get_cell_list.each { |cell|
+
+#      if cell.is_generate?
+        join = cell.get_join_list.get_item( :mask )
+
+        # AUTO type search and change to zero
+        if join then
+          #mask_bit = join.get_rhs.to_s.eval_cnst( nil )
+          mask_bit = join.get_rhs.to_s.to_i
+          mask_str = join.get_rhs.to_s
+          if mask_str == "AUTO" then
+            new_rhs = Expression.create_integer_constant( 32, @locale )
+            join.change_rhs new_rhs
+          else
+            mask_pattern = 1 << mask_bit
+            whole_mask |= mask_pattern
+          end
+        else
+          new_rhs = Expression.create_integer_constant( 32, @locale )
+          join = Join.new( :mask, nil, new_rhs )
+          cell.new_join(join)
+        end
+
+#        file2.print "\t /* working #{join.get_rhs.to_s} */\n"
+#      end
+
+    }
+
+    mask_count = 0;
+    mask_place = 0;
+
+    @celltype.get_cell_list.each { |cell|
+
+#      if cell.is_generate?
+        # bit place to mask pattern
+        file2.print "\tEVENT #{cell.get_name} {\n"
+        join = cell.get_join_list.get_item( :mask )
+        if join then
+          mask_bit = join.get_rhs.to_s.to_i
+          if mask_bit == 32 then
+            while 1
+    p("mask_count, current_mask")
+    p mask_count
+              current_mask = (1 << mask_count)
+    p current_mask
+              if 0 == whole_mask & current_mask
+                new_rhs = Expression.create_integer_constant( current_mask, @locale )
+                join.change_rhs new_rhs
+                whole_mask = whole_mask | current_mask
+                mask_place = mask_count
+                break
+              end
+              if current_mask >= 0x8000
+                mask_place = 0
+                break
+              end
+              mask_count = mask_count + 1
+            end
+          else
+            mask_place = join.get_rhs.to_s.to_i
+            current_mask = 1 << mask_place
+            new_rhs = Expression.create_integer_constant( current_mask, @locale )
+            join.change_rhs new_rhs
+          end
+          file2.print "\t\tMASK = #{mask_place.to_s};\n"
+        end
+
+        file2.print "\t};\n"
+        file2.print "\n"
+
+#      end
+
+    }
+
+    file2.close
+
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb	(revision 317)
@@ -0,0 +1,197 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1ISRPlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+  file2 = CFile.open( "#{$gen}/ISR_tecsgen.oil", "w" )
+
+    # ISR
+    @celltype.get_cell_list.each { |cell|
+
+    if cell.is_generate?
+
+      file2.print "\tISR #{cell.get_name} {\n"
+
+      # CATEGORY
+      join = cell.get_join_list.get_item( :category )
+      if join then
+        file2.print "\t\tCATEGORY = #{join.get_rhs.to_s};\n"
+      end
+
+      # PRIORITY
+      join = cell.get_join_list.get_item( :priority )
+      if join then
+        file2.print "\t\tPRIORITY = #{join.get_rhs.to_s};\n"
+      end
+
+      # ENTRY (entryã¯tecsgenã®äºç´èªã®ããNumberãä»å )
+      join = cell.get_join_list.get_item( :entryNumber )
+      if join then
+        file2.print "\t\tENTRY = #{join.get_rhs.to_s};\n"
+      end
+
+      # RESOURCE
+      join2 = cell.get_join_list.get_item( :resource )
+      delim = ""
+      if join2 then
+        join2.get_rhs.each { |res|
+          str = res.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\tRESOURCE = #{str};\n"
+          delim = ";"
+        }
+      end
+
+      # MESSAGE
+      join2 = cell.get_join_list.get_item( :message )
+      delim = ""
+      if join2 then
+        join2.get_rhs.each { |msg|
+          str = msg.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\tMESSAGE = #{str};\n"
+          delim = ";"
+        }
+      end
+
+      file2.print "\t};\n"
+      file2.print "\n"
+
+    end
+  }
+
+  file2.close
+
+  # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+  file = AppFile.open( "#{$gen}/tISR_tecsgen.#{$c_suffix}" )
+  file.print "\n/* Generated by ATK1ISRPlugin */\n"
+  @celltype.get_cell_list.each { |cell|
+    if cell.is_generate?
+      name_array = @celltype.get_name_array( cell )
+      join2 = cell.get_join_list.get_item( :category )
+      if join2 then
+        str = join2.get_rhs.to_s
+        if str == "1" then
+          file.print <<EOT
+#if defined( OMIT_ISR1_ENTRY )
+EOT
+          file.print "/* ISR1å
+¥ãå£æªçææã¯æ¬é¢æ°ãå²è¾¼ã¿é¢æ°æå®ãã  */\n"
+          file.print <<EOT
+#pragma INTERRUPT  #{cell.get_name}
+#endif  /* OMIT_ISR1_ENTRY  */
+void  RxHwSerialInt( void );
+void
+RxHwSerialInt( void )
+EOT
+        else
+          file.print <<EOT
+ISR(#{cell.get_name})
+EOT
+        end
+      end
+
+      file.print <<EOT
+{
+    CELLCB *p_cellcb = #{name_array[8]};
+    cBody_main();
+}
+
+EOT
+    end
+  }
+
+  file.close
+
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb	(revision 317)
@@ -0,0 +1,312 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1KernelPlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+  @@cell_list = []
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+#    join_list = cell.get_join_list
+#    a = join_list.get_item( :resource )
+#    if a == nil
+#     Generator.error( "resource: must be initialized")
+#    elsif ! a.get_rhs.instance_of? Array
+#      Generator.error( "resource: initializer must be in format of '{val1, val2 ...}'")
+#    end
+  @@cell_list << cell
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+    file2 = CFile.open( "#{$gen}/Kernel_tecsgen.oil", "w" )
+
+    # Kernel
+    @celltype.get_cell_list.each { |cell|
+
+      if cell.is_generate?
+
+        file2.print "\tOS #{cell.get_name} {\n"
+
+        # STATUS
+        join = cell.get_join_list.get_item( :status )
+        if join then
+          str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+          file2.print "\t\tSTATUS = #{str};\n"
+        end
+
+        # STARTUPHOOK
+        join = cell.get_join_list.get_item( :useStartupHook )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tSTARTUPHOOK = #{str};\n"
+        end
+
+        # ERRORHOOK
+        join = cell.get_join_list.get_item( :useErrorHook )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tERRORHOOK = #{str};\n"
+        end
+
+        # SHUTDOWNHOOK
+        join = cell.get_join_list.get_item( :useShutdownHook )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tSHUTDOWNHOOK = #{str};\n"
+        end
+
+        # PRETASKHOOK
+        join = cell.get_join_list.get_item( :usePreTaskHook )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tPRETASKHOOK = #{str};\n"
+        end
+
+        # POSTASKHOOK
+        join = cell.get_join_list.get_item( :usePostTaskHook )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tPOSTTASKHOOK = #{str};\n"
+        end
+
+        # USEGETSERVICEID
+        join = cell.get_join_list.get_item( :useGetServiceId )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tUSEGETSERVICEID = #{str};\n"
+        end
+
+        # USEPARAMETERACCESS
+        join = cell.get_join_list.get_item( :useParameterAccess )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tUSEPARAMETERACCESS = #{str};\n"
+        end
+
+        # USERESSCHEDULER
+        join = cell.get_join_list.get_item( :useResourceScheduler )
+        if join then
+          str = join.get_rhs.to_s
+          file2.print "\t\tUSERESSCHEDULER = #{str};\n"
+        end
+
+        file2.print "\t};\n\n"
+
+      end
+
+    }
+
+    file2.close
+
+    # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+    file2 = AppFile.open( "#{$gen}/tKernel_tecsgen.#{$c_suffix}" )
+    file2.print "\n/* Generated by ATK1KernelPlugin */\n\n"
+    @celltype.get_cell_list.each { |cell|
+      if cell.is_generate?
+        name_array = @celltype.get_name_array( cell )
+
+        join = cell.get_join_list.get_item( :useStartupHook )
+        if join then
+          str = join.get_rhs.to_s
+          if str == "TRUE" then
+            file2.print <<EOT
+#ifdef USE_STARTUPHOOK
+void StartupHook(void)
+{
+/*    CELLCB *p_cellcb = #{name_array[8]}; */
+    INT32 i;
+    for(i = 0; i < N_CP_cStartupHookBody; i++){
+        cStartupHookBody_main(i);
+    }
+}
+#endif /* USE_STARTUPHOOK */
+EOT
+          end
+        end
+
+        join = cell.get_join_list.get_item( :useErrorHook )
+        if join then
+          str = join.get_rhs.to_s
+          if str == "TRUE" then
+            file2.print <<EOT
+#ifdef USE_ERRORHOOK
+void ErrorHook(StatusType ercd)
+{
+/*    CELLCB *p_cellcb = #{name_array[8]}; */
+    cErrorHookBody_main( ercd );
+}
+#endif /* USE_ERRORHOOK */
+
+EOT
+          end
+        end
+
+        join = cell.get_join_list.get_item( :useShutdownHook )
+        if join then
+          str = join.get_rhs.to_s
+          if str == "TRUE" then
+            file2.print <<EOT
+#ifdef USE_SHUTDOWNHOOK
+void ShutdownHook(StatusType ercd)
+{
+/*    CELLCB *p_cellcb = #{name_array[8]}; */
+    INT32 i;
+    for(i = 0; i < N_CP_cShutdownHookBody; i++){
+        cShutdownHookBody_main( i, ercd );
+    }
+}
+#endif /* USE_SHUTDOWNHOOK */
+
+EOT
+          end
+        end
+
+        join = cell.get_join_list.get_item( :usePreTaskHook )
+        if join then
+          str = join.get_rhs.to_s
+          if str == "TRUE" then
+            file2.print <<EOT
+#ifdef USE_PRETASKHOOK
+void PreTaskHook(void)
+{
+/*    CELLCB *p_cellcb = #{name_array[8]}; */
+    cPreTaskHookBody_main();
+}
+#endif /* USE_PRETASKHOOK */
+
+EOT
+          end
+        end
+
+        join = cell.get_join_list.get_item( :usePostTaskHook )
+        if join then
+          str = join.get_rhs.to_s
+          if str == "TRUE" then
+            file2.print <<EOT
+#ifdef USE_POSTTASKHOOK
+void PostTaskHook(void)
+{
+/*    CELLCB *p_cellcb = #{name_array[8]}; */
+    cPostTaskHookBody_main();
+}
+#endif /* USE_POSTTASKHOOK */
+
+EOT
+          end
+        end
+
+      end
+    }
+
+    file2.close
+
+  end
+
+  def self.gen_post_code file
+
+  @@cell_list.each { |cell|
+    join =  cell.get_join_list.get_item( :useResourceScheduler )
+    if join then
+      flag = join.get_rhs.to_s
+      if flag == "TRUE" then
+        file.print <<EOT
+cell tResource RES_SCHEDULER {
+	property = "STANDARD";
+};
+EOT
+      else
+        file.print <<EOT
+EOT
+      end
+    end
+  }
+  
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb	(revision 317)
@@ -0,0 +1,146 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1ResourcePlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+  file2 = CFile.open( "#{$gen}/RESOURCE_tecsgen.oil", "w" )
+  file3 = CFile.open( "#{$gen}/#{@celltype.get_name}_factory.#{$h_suffix}", "w" )
+
+  # RESOURCE
+  @celltype.get_cell_list.each { |cell|
+
+    if cell.is_generate?
+
+      str = cell.get_name
+
+      if str.to_s == "RES_SCHEDULER" then
+
+        cell.set_specified_id( 1 )
+
+      else
+
+        file3.print "DeclareResource( #{cell.get_name} );\n"
+
+        file2.print "\tRESOURCE #{cell.get_name} {\n"
+
+        # PROPERTY
+        join = cell.get_join_list.get_item( :property )
+        if join then
+          str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+
+          if str == "LINKED" then
+            file2.print "\t\tRESOURCEPROPERTY = #{str} {\n"
+            join2 = cell.get_join_list.get_item( :linkedResource )
+            str2 = join2.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+            file2.print "\t\t\tLINKEDRESOURCE = #{str2};\n"
+            file2.print "\t\t};\n"
+          else
+            file2.print "\t\tRESOURCEPROPERTY = #{str};\n"
+          end
+        end
+
+        file2.print "\t};\n"
+        file2.print "\n"
+
+      end
+
+    end
+  }
+
+  file2.close
+  file3.close
+
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb	(revision 317)
@@ -0,0 +1,243 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator Cell-type plugin
+#      for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project TECS-WG
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class ATK1TaskPlugin < CelltypePlugin
+#@celltype:: Celltype
+#@option:: String     :ãªãã·ã§ã³æå­å
+
+  #signature::     Celltype        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã®ã³ã¼ããçæ
+  #      éè¤ãã¦çæãã¦ã¯ãªããªã
+  #      ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ã
+  #      ãããã¯ååã® import ã«ãããéè¤ãé¿ãããã¨ã
+  #file::        FILE       çæãããã¡ã¤ã«
+#  def gen_cdl_file file
+#  end
+
+  def new_cell cell
+#    join_list = cell.get_join_list
+#    a = join_list.get_item( :resource )
+#    if a == nil
+#     Generator.error( "resource: must be initialized")
+#    elsif ! a.get_rhs.instance_of? Array
+#      Generator.error( "resource: initializer must be in format of '{val1, val2 ...}'")
+#    end
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     ãã®ã¡ã½ãããæªå®ç¾©ã®å ´åãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã®ã¡ã½ãããå®ç¾©æ¸ã¿ã®å ´åãï¼ãã³ãã¬ã¼ãã§ã¯ãªããå¤æ´ããå¿
+è¦ã®ãªãï¼ã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+#  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+#  end
+
+  def gen_factory file
+
+  file2 = CFile.open( "#{$gen}/TASK_tecsgen.oil", "w" )
+
+  extended_task_count = 1
+
+  # TASK
+  @celltype.get_cell_list.each { |cell|
+
+    if cell.is_generate?
+
+      file2.print "\tTASK #{cell.get_name} {\n"
+
+      # AUTOSTART
+      join = cell.get_join_list.get_item( :autoStart )
+      if join then
+        str = join.get_rhs.to_s
+
+        if str == "TRUE" then
+          join2 = cell.get_join_list.get_item( :appMode )
+          if join2 then
+            file2.print "\t\tAUTOSTART = TRUE {\n"
+            delim = ""
+            join2.get_rhs.each { |mode|
+              str = mode.to_s.gsub(/^"(.*)"$/, '\1')
+              file2.print "\t\t\tAPPMODE = #{str};\n"
+              delim = ";"
+            }
+            file2.print "\t\t};\n"
+          else
+            file2.print "\t\tAUTOSTART = TRUE;\n"
+          end
+        elsif str == "FALSE" then
+          file2.print "\t\tAUTOSTART = FALSE;\n"
+        else
+        end
+      end
+
+      # PRIORITY
+      join = cell.get_join_list.get_item( :priority )
+      if join then
+        file2.print "\t\tPRIORITY = #{join.get_rhs.to_s};\n"
+      end
+
+      # ACTIVATION
+      join = cell.get_join_list.get_item( :activation )
+      if join then
+        file2.print "\t\tACTIVATION = #{join.get_rhs.to_s};\n"
+      end
+
+      # SCHEDULE
+      join = cell.get_join_list.get_item( :schedule )
+      if join then
+        str = join.get_rhs.to_s.gsub(/^"(.*)"$/, '\1')
+        file2.print "\t\tSCHEDULE = #{str};\n"
+      end
+
+      # EVENT
+      join = cell.get_join_list.get_item( :event )
+      delim = ""
+      if join then
+        join.get_rhs.each { |evt|
+          str = evt.to_s.gsub(/^"(.*)"$/, '\1')
+          if !(str == "OMISSIBLE")
+              file2.print "\t\tEVENT = #{str};\n"
+          end
+          delim = ";"
+        }
+        join.get_rhs.each { |evt|
+          str = evt.to_s.gsub(/^"(.*)"$/, '\1')
+          if !(str == "OMISSIBLE")
+              cell.set_specified_id( extended_task_count );
+              ++extended_task_count;
+              break
+          end
+        }
+      end
+
+      # RESOURCE
+      join = cell.get_join_list.get_item( :resource )
+      delim = ""
+      if join then
+        join.get_rhs.each { |res|
+          str = res.to_s.gsub(/^"(.*)"$/, '\1')
+          if !(str == "OMISSIBLE")
+              file2.print "\t\tRESOURCE = #{str};\n"
+          end
+          delim = ";"
+        }
+      end
+
+      # MESSAGE
+      join = cell.get_join_list.get_item( :message )
+      delim = ""
+      if join then
+        join.get_rhs.each { |msg|
+          str = msg.to_s.gsub(/^"(.*)"$/, '\1')
+          if !(str == "OMISSIBLE")
+              file2.print "\t\tMESSAGE = #{str};\n"
+          end
+          delim = ";"
+        }
+      end
+
+      # STACKSIZE
+      join = cell.get_join_list.get_item( :stackSize )
+      if join then
+        file2.print "\t\tSTACKSIZE = #{join.get_rhs.to_s};\n"
+      end
+
+      file2.print "\t};\n"
+      file2.print "\n"
+
+    end
+  }
+
+  file2.close
+
+  # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+  file = AppFile.open( "#{$gen}/tTask_tecsgen.#{$c_suffix}" )
+  file.print "\n/* Generated by ATK1TaskPlugin */\n"
+  @celltype.get_cell_list.each { |cell|
+    if cell.is_generate?
+      name_array = @celltype.get_name_array( cell )
+      file.print <<EOT
+TASK(#{cell.get_name})
+{
+    CELLCB *p_cellcb = #{name_array[8]};
+    cBody_main();
+    terminate();
+}
+
+EOT
+    end
+  }
+
+  file.close
+
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/C2TECSBridgePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/C2TECSBridgePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/C2TECSBridgePlugin.rb	(revision 317)
@@ -0,0 +1,231 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2015 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: C2TECSBridgePlugin.rb 2278 2015-11-01 20:10:07Z okuma-top $
+#++
+
+#== C => TECS åãå£å¼ã³åºãã®ãã©ã°ã¤ã³
+class C2TECSBridgePlugin < SignaturePlugin
+#@signature:: Signature   ãã©ã°ã¤ã³ã®å¯¾è±¡ã¨ãªãã·ã°ããã£
+#@option:: String   '"', '"' ã§å²ã¾ããæå­å
+
+  # ãã©ã°ã¤ã³å¼æ°åã¨ Proc
+  C2TECSBridgePluginArgProc = {
+    "prefix" => Proc.new { |obj,rhs| obj.set_prefix rhs },
+    "suffix" => Proc.new { |obj,rhs| obj.set_suffix rhs },
+    "header_name" => Proc.new { |obj,rhs| obj.set_header_name rhs },
+  }
+
+
+  @@signature_list = { }
+
+  #signature::     Signature        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( signature, option )
+    super
+
+    @signature = signature
+    @header_name = "#{$gen}/C2TECS_#{@signature.get_global_name}.h"
+    @prefix = ""
+    @suffix = ""
+    @celltype_name = :"t#{@signature.get_global_name}"
+    @plugin_arg_check_proc_tab = C2TECSBridgePluginArgProc
+    parse_plugin_arg
+  end
+
+  def gen_cdl_file file
+    if @@signature_list[ @signature.get_global_name ] then
+      @@signature_list[ @signature.get_global_name ] << self
+      cdl_warning( "C2TW001 signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
+      return
+    end
+
+    @@signature_list[ @signature.get_global_name ] = [ self ]
+    print_msg "  C2TECSBridgePlugin: [celltype] C2TECS::#{@celltype_name}. Create cell then join the call port 'cCall' to the target cell\n"
+    file.print <<EOT
+namespace nC2TECS{
+  [singleton, active]    // this celltype is not active actually. 'active' is specified to prevent W1002.
+  celltype #{@celltype_name} {
+    call #{@signature.get_namespace_path} cCall;
+  };
+};
+EOT
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã®ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    # nothing to do
+
+  end
+
+
+  def gen_postamble( file, b_singleton, ct_name, global_name )
+
+    header_file = open( @header_name, "w" )
+
+    header_comment =<<EOT
+/*
+ * This file was generated by C2TECSBridgePlugin and has prototype
+ * decalarations of functions in signature '#{@signature.get_namespace_path}'
+ */
+
+EOT
+
+    file.print header_comment
+    header_file.print header_comment
+    header_file.print <<EOT
+#ifndef #{@signature.get_global_name}__h
+#define #{@signature.get_global_name}__h
+
+/*
+ * function prototype declarations
+ *    signature: '#{@signature.get_namespace_path}'
+ *
+ * These functions can be called from C sources directly.
+ * If function name collides, please consider to specify 'prefix' option for C2TECSBridgePlugin.
+ */
+EOT
+
+    # generate C functions calling function of call port
+    @signature.get_function_head_array.each { |func_head|
+      func_name = func_head.get_name
+      ret_type  = func_head.get_return_type
+      params    = func_head.get_paramlist.get_items
+
+      # p "celltype_name, sig_name, func_name, func_global_name"
+      # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+      # function header
+      file.print( "#{ret_type.get_type_str}\n" )
+      header_file.printf( "%-16s", ret_type.get_type_str )
+      file.print( "#{@prefix}#{func_name}#{@suffix}(" )
+      header_file.print( "#{@prefix}#{func_name}#{@suffix}(" )
+
+      delim = ""
+      params.each{ |param|
+        file.printf( "#{delim} #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post}" )
+        header_file.printf( "#{delim} #{param.get_type.get_type_str} #{param.get_name}#{param.get_type.get_type_str_post}" )
+        delim = ","
+      }
+      file.print( " )\n{\n" )
+      header_file.print( " );\n" )
+
+      # call function in call port
+      if ! ret_type.is_void? then
+        file.print( "  #{ret_type.get_type_str}  retval;\n" )
+        file.print( "  retval = " )
+      else
+        file.print( "  " )
+      end
+
+      file.print( "cCall_#{func_name}(" )
+
+      delim = ""
+      params.each{ |param|
+        file.printf( "#{delim} #{param.get_name}" )
+        delim = ","
+      }
+      file.print( " );\n" )
+
+      if ! ret_type.is_void? then
+        file.print( "  return retval;\n" )
+      end
+      file.print( "}\n\n" )
+    }
+
+    header_file.print <<EOT
+
+#endif /* #{@signature.get_global_name}__h */
+
+EOT
+    
+    header_file.close
+  end
+
+  #===  set_prefix - prefix ãã©ã°ã¤ã³ãªãã·ã§ã³
+  def set_prefix rhs
+    @prefix = rhs.to_s
+  end
+  #===  set_suffix - suffix ãã©ã°ã¤ã³ãªãã·ã§ã³
+  def set_suffix rhs
+    @suffix = rhs.to_s
+  end
+  #===  set_header_name - header_name ãã©ã°ã¤ã³ãªãã·ã§ã³
+  def set_header_name rhs
+    @header_name = "#{$gen}/" + rhs.to_s
+    if ! ( @header_name =~ /\.h\Z/ ) then
+      @header_name += ".h"
+    end
+  end
+  
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CellPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CellPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CellPlugin.rb	(revision 317)
@@ -0,0 +1,80 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2011 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: celltypePlugin.rb 1540 2011-08-12 14:04:37Z okuma-top $
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class CellPlugin < Plugin
+
+  #=== CellPlugin# initialize
+  #cell::     Cell        ã»ã«ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  # ãã®ã¡ã½ããã¯ãã»ã«ã®æ§æè§£æãçµãã£ãã¨ããã§å¼ã³åºããã
+  # ãã®æ®µéã§ã¯æå³è§£æãçµãã£ã¦ããªã
+  def initialize( cell, option )
+    super()
+    @cell = cell
+    @plugin_arg_str = CDLString.remove_dquote option
+    # @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' )    # åå¾ã® "" ãåãé¤ã
+    # @plugin_arg_str.sub!( /(.*)"\z/, '\1' )
+    @plugin_arg_list = {}
+  end
+
+  #=== å¾ãã® CDL ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CelltypePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CelltypePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/CelltypePlugin.rb	(revision 317)
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: CelltypePlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class CelltypePlugin < Plugin
+
+  #celltype::     Celltype        ã»ã«ã¿ã¤ãï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( celltype, option )
+    super()
+    @celltype = celltype
+    # @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' )    # åå¾ã® "" ãåãé¤ã
+    # @plugin_arg_str.sub!( /(.*)"\z/, '\1' )
+    @plugin_arg_str = CDLString.remove_dquote option
+    @plugin_arg_list = {}
+  end
+
+  #=== æ°ããã»ã«
+  #cell::        Cell            ã»ã«
+  #
+  # celltype ãã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã»ã«ãçæããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ã«å¯¾ããæ°ããã»ã«ã®å ±å
+  def new_cell( cell )
+  end
+
+
+  #=== tCelltype_factory.h ã«æ¿å
+¥ããã³ã¼ããçæãã
+  # file ä»¥å¤ã®ä»ã®ãã¡ã¤ã«ã«ãã¡ã¯ããªã³ã¼ããçæãã¦ããã
+  # ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãæå®ãããã»ã«ã¿ã¤ãã®ã¿å¼ã³åºããã
+  def gen_factory file
+  end
+
+  #=== å¾ãã® CDL ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/DomainPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/DomainPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/DomainPlugin.rb	(revision 317)
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: TracePlugin.rb 2032 2014-03-16 12:10:58Z okuma-top $
+#++
+
+#== ãã¡ã¤ã³ãã©ã°ã¤ã³ã®è¦ªã¯ã©ã¹
+class DomainPlugin < Plugin
+
+  #== domain æå®ããããªã¼ã¸ã§ã³ãå®ç¾©ããã
+  # region ã§ domain æå®ããã£ã
+  #domain_type_name::Symbol : domain æå®å­ã®ç¬¬ä¸å¼æ°
+  #option::String : domain æå®å­ã®ç¬¬äºå¼æ°
+  def initialize( region, domain_type_name, option )
+  end
+
+  #== çµå join ã«ãã©ã°ã¤ã³ãæ¿å
+¥ãã
+  #join::Join : çµåã«é¢ããæ
+å ±
+  #return::[ plugin_name::String, option::String ]: æ¿å
+¥ãããã©ã°ã¤ã³ã æ¿å
+¥ãããã®ããªããã° nil ãè¿ã
+  #return::(1) [ plugin_name, option ] or (2) [[ plugin_name, option ], ...], or [] or nil:  (2): not supported now
+  #   nil: region éã®çµåç¦æ­¢, []: region éã®çµåå¯(ãã©ã°ã¤ã³æ¿å
+¥ç¡ã)
+  #   [ plugin_name, option ]: *_through( plugin_name, option ) æå®ããã®ã¨åç­
+  #
+  # region éã® through ãæå®ããã¦ããå ´åãout_through, to_through
+  # ã§ã¯ããããã«ãã£ã¦æå®ããããã©ã°ã¤ã³ã®å¾ãã«ãin_through ã®å ´å
+  # in_through ãã©ã°ã¤ã³ã®åã«æ¿å
+¥ããã
+  #
+  # ãã®ã¡ã½ãããå¼åºãããæç¹ã§ã¯ Join#get_rhs_cell ãªã©æå³è§£æå¾
+  # ã«ããå¼ã³åºããªãã¡ã½ãããå¼åºãã¦ããæå¹ãªå¤ã¯å¾ãããªã
+  #
+  def add_through_plugin( join, current_region, next_region, through_type )
+    # join.get_owner:Cell  å·¦è¾ºã®ã»ã«
+    # join.get_definition:Port å¼ã³å£
+    # join.get_subscript:Integer or nil å¼ã³å£é
+åã®æ·»æ° (Join::@subscript ã®èª¬æåç
+§)
+    # join.get_cell:Cell å³è¾ºã®ã»ã«
+    # join.get_port_name:Symbol åãå£
+    # get_rhs_subscript:Integer or nil åãå£é
+åã®æ·»æ° (Join::@rhs_subscript ã®èª¬æåç
+§)
+    # return []
+    return nil
+  end
+
+  #== require ãçµåå¯è½ãï¼
+  def joinable?(current_region, next_region, through_type )
+    return false
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2AlarmHandlerPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2AlarmHandlerPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2AlarmHandlerPlugin.rb	(revision 317)
@@ -0,0 +1,92 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRP2AlarmHandlerPlugin < HRP2KernelObjectPlugin
+    @@ep = [:eStartAlarm, :eStopAlarm, :eManageAlarm, :eReferAlarm ]
+    ##
+    #
+    # file : output file (ex.tecsgen.cfg)
+    # cell : 
+    # val  : 
+    # tab  : 
+    def print_cfg_cre(file, cell, val, tab)
+        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        # $cbp$ã®ä»£ãã
+        index = cell.get_id - @celltype.get_id_base
+        cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
+        # CRE_XXXã®çæ
+        if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN)
+            # ç¡æå± or ã¦ã¼ã¶ãã¡ã¤ã³ã«å±ããå ´å
+                raise "alarm handler #{val[:id]} must belong to kernel domain."
+        else
+            file.print <<EOT
+#{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tAlarmHandler_start });
+EOT
+        end
+    end
+
+    def print_cfg_sac(file, val, acv)
+       file.puts "SAC_ALM(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+    end
+
+    #tAlarmã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+    
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Cache.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Cache.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Cache.rb	(revision 317)
@@ -0,0 +1,3 @@
+# -*- coding: utf-8 -*-
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb	(revision 317)
@@ -0,0 +1,93 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRP2CyclicHandlerPlugin < HRP2KernelObjectPlugin
+    @@ep = [:eStartCyclic, :eStopCyclic, :eManageCyclic, :eReferCyclic ]
+    ##
+    #
+    # file : output file (ex.tecsgen.cfg)
+    # cell : 
+    # val  : 
+    # tab  : 
+    def print_cfg_cre(file, cell, val, tab)
+        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        # $cbp$ã®ä»£ãã
+        index = cell.get_id - @celltype.get_id_base
+        cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
+        # CRE_XXXã®çæ
+        if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN)
+            # ç¡æå± or ã¦ã¼ã¶ãã¡ã¤ã³ã«å±ããå ´å
+                raise "cyclic handler #{val[:id]} must belong to kernel domain."
+        else
+            file.print <<EOT
+#{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} });
+EOT
+        end
+    end
+
+    def print_cfg_sac(file, val, acv)
+       file.puts "SAC_CYC(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+    end
+
+    #tCyclicHandlerã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb	(revision 317)
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+
+class HRP2DataqueuePlugin < HRP2KernelObjectPlugin
+    @@ep = [:eSendDataqueue, :eReceiveDataqueue, :eManageDataqueue, :eReferDataqueue ]
+    #=== HRP2DataqueuePlugin#print_cfg_cre
+    # CRE_DTQã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        file.print tab
+        file.puts "CRE_DTQ(#{val[:id]}, {#{val[:attribute]}, #{val[:count]}, #{val[:dtqmb]}});"
+    end
+    #=== HRP2DataqueuePlugin#print_cfg_sac
+    # SAC_DTQã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        file.puts "SAC_DTQ(#{val[:id]}, {#{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]}});"
+    end
+    #tDataqueueã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb	(revision 317)
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+
+class HRP2EventflagPlugin < HRP2KernelObjectPlugin
+    @@ep = [:eSetEventflag, :eWaitEventflag, :eManageEventflag, :eReferEventflag ]
+    #=== HRP2EventflagPlugin#print_cfg_cre
+    # CRE_FLGã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        file.print tab
+        file.puts "CRE_FLG(#{val[:id]}, {#{val[:attribute]}, #{val[:flagPattern]}});"
+    end
+    #=== HRP2EventflagPlugin#print_cfg_sac
+    # SAC_FLGã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        file.puts "SAC_FLG(#{val[:id]}, {#{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]}});"
+    end
+    #tEventflagã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb	(revision 317)
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+
+class HRP2FixedSizeMemoryPoolPlugin < HRP2KernelObjectPlugin
+    @@ep = [:eSendFixedSizeMemoryPool, :eReceiveFixedSizeMemoryPool, :eManageFixedSizeMemoryPool, :eReferFixedSizeMemoryPool ]
+    #=== HRP2FixedSizeMemoryPoolPlugin#print_cfg_cre
+    # CRE_MPFã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        file.print tab
+        file.puts "CRE_MPF(#{val[:id]}, {#{val[:attribute]}, #{val[:blockCount]}, #{val[:blockSize]}, #{val[:mpf]}, #{val[:mpfmb]}});"
+    end
+    #=== HRP2FixedSizeMemoryPoolPlugin#print_cfg_sac
+    # SAC_MPFã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        file.puts "SAC_MPF(#{val[:id]}, {#{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]}});"
+    end
+    #tFixedSizeMemoryPoolã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb	(revision 317)
@@ -0,0 +1,110 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRP2HandlerPlugin < HRP2KernelObjectPlugin
+    @@ep = [:eStartAlarm, :eStopAlarm, :eManageAlarm, :eReferAlarm ]
+    ##
+    #
+    # file : output file (ex.tecsgen.cfg)
+    # cell : 
+    # val  : 
+    # tab  : 
+    def print_cfg_cre(file, cell, val, tab)
+        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        # $cbp$ã®ä»£ãã
+        index = cell.get_id - @celltype.get_id_base
+        cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
+        # CRE_XXXã®çæ
+        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+        # if (cell.get_region.get_region_type != :DOMAIN) || (cell.get_region.get_param != :KERNEL_DOMAIN)
+        if (domainOption == "OutOfDomain") || (domainOption != "trusted")
+            # ç¡æå± or ã¦ã¼ã¶ãã¡ã¤ã³ã«å±ããå ´å
+                raise "#{@plugin_arg_str.to_s.downcase} handler #{val[:id]} must belong to kernel domain."
+        elsif @plugin_arg_str == "ALARM"
+            file.print <<EOT
+#{tab}CRE_ALM(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tAlarmHandler_start });
+EOT
+        elsif @plugin_arg_str == "CYCLIC"
+            file.print <<EOT
+#{tab}CRE_CYC(#{val[:id]}, { #{val[:attribute]}, &#{cell_CB_name}, tCyclicHandler_start, #{val[:cyclicTime]}, #{val[:cyclicPhase]} });
+EOT
+        else
+            raise "#{@plugin_arg_str} is unknown option"
+        end
+    end
+
+    def print_cfg_sac(file, val, acv)
+        if @plugin_arg_str == "ALARM"
+            file.puts "SAC_ALM(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+        elsif @plugin_arg_str == "CYCLIC"
+            file.puts "SAC_CYC(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+        else
+            raise "#{@plugin_arg_str} is unknown option"
+        end
+    end
+
+=begin
+    #tAlarmã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+=end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb	(revision 317)
@@ -0,0 +1,390 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+# Regionã¯ã©ã¹ã«ã¡ã½ãããè¿½å 
+=begin
+class Region
+    def get_params
+        return @region_type_param
+    end
+
+    def get_param
+        return @region_type_param[0]
+    end
+
+    def is_root
+        return self == @@root_namespace
+    end
+end
+=end
+
+# Cellã¯ã©ã¹ã«ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã¨ã¡ã½ãããè¿½å 
+=begin
+class Cell
+    def set_referenced_region( region )
+        if @referenced_regions.nil?
+            @referenced_regions = Array.new
+        end
+        if !@referenced_regions.include?(region)
+            @referenced_regions << region
+        end
+    end
+
+    def get_referenced_regions
+        return @referenced_regions
+    end
+
+    # set_referenced_cellã«ããã»ãããã
+    # def set_referenced_region( region, port_name )
+    def set_referenced_cell( cell, port_name )
+        if @referenced_cells.nil?
+            @referenced_cells = Hash.new
+        end
+        if !@referenced_cells.include?(port_name)
+            @referenced_cells[port_name] = Array.new
+        end
+        if !@referenced_cells[port_name].include?(cell)
+            @referenced_cells[port_name] << cell
+        end
+
+        region = cell.get_region
+        puts "***** set_referenced_regions *****"
+        puts "region=#{region.get_name}, port=#{port_name}(#{port_name.class})"
+        if @referenced_regions.nil?
+            @referenced_regions = Hash.new
+        end
+        if !@referenced_regions.include?(port_name)
+            @referenced_regions[port_name] = Array.new
+        end
+        if !@referenced_regions[port_name].include?(region)
+            @referenced_regions[port_name] << region
+        end
+        puts "#{@referenced_regions[port_name]}"
+    end
+
+    def get_referenced_cells( port_name )
+        if !@referenced_cells.nil? && @referenced_cells.include?(port_name)
+            return @referenced_cells[port_name]
+        else
+            return nil
+        end
+    end
+
+    def get_referenced_regions( port_name )
+        if !@referenced_regions.nil? && @referenced_regions.include?(port_name)
+            return @referenced_regions[port_name]
+        else
+            return nil
+        end
+    end
+
+    def self.get_cell_list
+        return @@cell_list
+    end
+
+    def self.get_cell_list2
+        return @@cell_list2
+    end
+end
+=end
+
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRP2KernelObjectPlugin < CelltypePlugin
+    # @@obj_hash = {}
+
+    #@celltype:: Celltype
+    #@option:: String     :ãªãã·ã§ã³æå­å
+    def initialize( celltype, option )
+        super
+        # ããããã®ã«ã¼ãã«ãªãã¸ã§ã¯ããè§£æå¯¾è±¡ã»ã«ã¿ã¤ãã«è¿½å 
+        HRP2KernelObjectPlugin.set_celltype(celltype)
+    end
+  
+    #=== HRP2KernelObjectPlugin#print_cfg_cre
+    # åç¨®ã«ã¼ãã«ãªãã¸ã§ã¯ãã®CRE_*ã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        raise "called virtual method print_cfg_cre in #{@celltype.get_name} plugin"
+    end
+  
+    #=== HRP2KernelObjectPlugin#print_cfg_sac
+    # åç¨®ã«ã¼ãã«ãªãã¸ã§ã¯ãã®SAC_*ã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿
+    def print_cfg_sac(file, val, acv)
+        raise "called virtual method print_cfg_sac in #{@celltype.get_name} plugin"
+    end
+  
+    #=== HRP2KernelObjectPlugin#get_entry_ports_name_list
+    # ã«ã¼ãã«ãªãã¸ã§ã¯ãã®åç¨®ã¢ã¯ã»ã¹ã®ç¨®å¥ã®åãå£åãåå¾
+    def get_entry_ports_name_list()
+        raise "called virtual method get_entry_ports_name_list in #{@celltype.get_name} plugin"
+    end
+
+    def string_cfg_cre(cell, val)
+        raise "called virtual method string_cfg_cre in #{@celltype.get_name} plugin"
+    end
+
+    def gen_factory file
+        puts "===== begin #{@celltype.get_name.to_s} plugin ====="
+
+        # å¯¾è±¡ã¨ãªããã¹ã¦ã®ã»ã«ã«ã¤ãã¦ãåãå£ã«çµåããã¦ãã
+        # ã»ã«ã®æå±ãã¡ã¤ã³ãè§£æ
+        if !HRP2KernelObjectPlugin.isChecked()
+            HRP2KernelObjectPlugin.check_referenced_cells()
+        else
+            puts "***** already checked"
+        end
+
+        # è¿½è¨ããããã« AppFile ãä½¿ãï¼æå­ã³ã¼ãå¤æãããªãï¼
+        file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+        file2.print "\n/* Generated by #{self.class.name} */\n\n"
+
+        @celltype.get_cell_list.each { |cell|
+            if cell.is_generate?
+                puts "===== begin check my domain #{cell.get_name} ====="
+                # attrã®å¤ãããã·ã¥ã«å
+¥ãã
+                val = {}
+                @celltype.get_attribute_list.each{ |a|
+                    p a.get_name
+                    if a.get_type.kind_of?( ArrayType )
+                        val[a.get_name] = []
+                        if j = cell.get_join_list.get_item(a.get_name)
+                            # ã»ã«çææã«åæåããå ´å
+                            j.get_rhs.each { |elem|
+                                val[a.get_name] << elem.to_s
+                            }
+                        elsif i = a.get_initializer
+                            # ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+                            i.each { |elem|
+                                val[a.get_name] << elem.to_s
+                            }
+                        else
+                            raise "attribute is not initialized"
+                        end
+                    else
+                        if j = cell.get_join_list.get_item(a.get_name)
+                            # ã»ã«çææã«åæåããå ´å
+                            val[a.get_name] = j.get_rhs.to_s
+                        elsif i = a.get_initializer
+                            # ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+                            val[a.get_name] = i.to_s
+                        else
+                            raise "attribute is not initialized"
+                        end
+                    end
+                }
+                # generate.rbãåèã«
+                # $id$ãç½®æ
+                if val[:id].nil? != true
+                    puts val[:id]
+                    val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+                end
+                # $cbp$ã®ä»£ãã
+                index = cell.get_id - @celltype.get_id_base
+                cell_CB_name = "#{@celltype.get_global_name}_CB_tab[#{index}]"
+                cell_domain_root = cell.get_region.get_domain_root
+                cell_domain_type = cell.get_region.get_domain_root.get_domain_type
+
+                # CRE_XXX/DEF_XXXã®çæ
+                if cell_domain_type.get_option.to_s != "OutOfDomain"
+                    # ä¿è­·ãã¡ã¤ã³ã«å±ããå ´å
+                    if !HRP2KernelObjectPlugin.include_region(cell_domain_root.get_name.to_s)
+                        # ãã®ä¿è­·ãã¡ã¤ã³ã®.cfgãçæããã¦ããªãå ´å
+                        HRP2KernelObjectPlugin.set_region_list(cell_domain_root.get_name.to_s)
+                        puts "~~~~~ #{cell_domain_root.get_name.to_s} is registered!"
+
+                        # if cell.get_region.get_param == :KERNEL_DOMAIN
+                        if cell_domain_type.get_option.to_s == "trusted"
+                            # file2.print "#{cell.get_region.get_name.to_s}{\n"
+                            file2.print "KERNEL_DOMAIN{\n"
+                        else
+                            file2.print "DOMAIN(#{cell_domain_root.get_name.to_s}){\n"
+                        end
+                        file2.puts "\tINCLUDE(\"#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg\");" 
+                        file2.puts "}\n"
+                    else
+                        print "~~~~~ #{cell.get_region.get_name.to_s} is included in"
+                        p @@region_list
+                    end
+                    file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" )
+                    print_cfg_cre(file3, cell, val,"")
+                    file3.close
+                else
+                    # ç¡æå±ã®å ´å
+                    puts "~~~~~ #{cell_domain_root.get_name.to_s} is OutOfDomain"
+                    print_cfg_cre(file2, cell, val, "")
+                end
+
+                puts "===== end check my domain #{cell.get_name} ====="
+                # SAC_XXXã®çæ
+                puts "===== begin check regions #{cell.get_name} ====="
+                p val[:accessPattern]
+                p val[:accessPattern].class
+
+                #ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ]
+                #åã«ã¼ãã«ãªãã¸ã§ã¯ãã®åãå£åãåå¾
+                # ep = get_entry_ports_name_list()
+                i = 0
+                acv = []
+                # ã¢ã¯ã»ã¹è¨±å¯ãã¯ã¿ã®çæ
+                val[:accessPattern].each { |acptnx|
+                    # ã¢ã¯ã»ã¹è¨±å¯ãã¿ã¼ã³ã®çæ
+                    if acptnx != "OMIT"
+                        acv << acptnx
+                        p acv[i]
+                    elsif cell_domain_type.get_option.to_s == "trusted"
+                        acv << "TACP_KERNEL"
+                        p acv[i]
+                    elsif cell_domain_type.get_option.to_s != "OutOfDomain"
+                        acv << "TACP(#{cell_domain_root.get_name.to_s})"
+                    else
+                        acv << "TACP_SHARED"
+                    end
+
+                    i += 1
+                }
+
+                print "acv = "
+                p acv
+
+                #åç¨®SACã®çæ
+                domainOption = cell_domain_type.get_option
+                # if cell.get_region.get_region_type == :DOMAIN
+                if domainOption != "OutOfDomain"
+                    # ä¿è­·ãã¡ã¤ã³ã«å±ããå ´å
+                    file3 = AppFile.open( "#{$gen}/tecsgen_#{cell.get_region.get_name.to_s}.cfg" )
+                    print_cfg_sac(file3, val, acv)
+                    file3.close
+                else
+                    # ç¡æå±ã®å ´å
+                    print_cfg_sac(file2, val, acv)
+                end
+
+                puts "===== end check regions #{cell.get_name} ====="
+            end
+        }
+
+        puts "===== end #{@celltype.get_name.to_s} plugin ====="
+        file2.close
+    end
+
+    # ã«ã¼ãã«ãªãã¸ã§ã¯ãã»ã«ã¿ã¤ãã®ç®¡ç
+    # HRP2KernelObjectPluginã¯ã©ã¹ã«å¯¾ãã¦ã¡ã½ããå¼åºããè¡ããã¨ãæ³å®
+    @@checked = false
+    @@celltype_list = []
+    @@region_list = []
+
+    def self.isChecked()
+        return @@checked
+    end
+
+    def self.check_referenced_cells()
+        puts "===== begin check registered celltype ====="
+        self.get_celltype_list.each { |ct|
+            p ct.get_name.to_s
+        }
+        puts "===== end check registered celltype ====="
+
+=begin
+        Cell.get_cell_list2.each { |cell|
+            cell.get_celltype.get_port_list.each{ |p|
+                next if p.get_port_type != :CALL
+                j = cell.get_join_list.get_item(p.get_name)
+                printf "===== check call port : "
+                p p.get_name.to_s
+                next if j.nil? # æªçµåã®å ´å
+                if @@celltype_list.include?(j.get_celltype)
+                    # j.get_cell.set_referenced_region(cell.get_region)
+                    # j.get_cell.set_referenced_region(cell.get_region, j.get_port_name)
+                    j.get_cell.set_referenced_cell(cell, j.get_port_name)
+                    printf "===== check joined rhs cell : "
+                    p j.get_cell.get_name.to_s
+                    printf "===== check joined rhs port_name : "
+                    p j.get_port_name
+                end
+            }
+        }
+=end
+        @@checked = true
+    end
+
+    def self.set_celltype( celltype )
+        @@celltype_list << celltype
+    end
+
+    def self.get_celltype_list
+        return @@celltype_list
+    end
+
+    def self.set_region_list( region )
+        @@region_list << region
+    end
+
+    def self.include_region( region )
+        return @@region_list.include?(region)
+    end
+
+    def self.include_celltype?( celltype )
+        return @@celltype_list.include?(celltype)
+    end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb	(revision 317)
@@ -0,0 +1,113 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+
+class HRP2ObjectPlugin < HRP2KernelObjectPlugin
+    # @@ep = [:eSignalSemaphore, :eWaitSemaphore, :eManageSemaphore, :eReferSemaphore ]
+    @@api = {
+        "SEMAPHORE"=>["SEM", :id, :attribute, :count, :max],
+        "EVENTFLAG"=>["FLG", :id, :attribute, :flagPattern],
+        "DATAQUEUE"=>["DTQ", :id, :attribute, :count, :dtqmb],
+        "PRIORITY_DATAQUEUE"=>["PDQ", :id, :attribute, :count, :maxDataPriority, :pdqmb],
+        "FIXED_SIZE_MEMORYPOOL"=>["MPF", :id, :attribute, :blockCount, :blockSize, :mpf, :mpfmb],
+        "KERNEL"=>["SYS"],
+        "MESSAGE_BUFFER"=>["MBF", :id, :attribute, :maxSize, :bufferSize, :mbfmb],
+    }
+
+    #=== HRP2SemaphorePlugin#print_cfg_cre
+    # CRE_SEMã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        if @@api.has_key?(@plugin_arg_str) == false
+            raise "#{@plugin_arg_str} is unknown"
+        elsif @plugin_arg_str != "KERNEL"
+            arg_list = []
+            @@api[@plugin_arg_str].slice(2..-1).each { |attr|
+                arg_list << "#{val[attr]}"
+            }
+            file.print tab
+            file.puts "CRE_#{@@api[@plugin_arg_str].at(0)}(#{val[:id]}, { #{arg_list.join(", ")} });"
+        end
+    end
+    #=== HRP2SemaphorePlugin#print_cfg_sac
+    # SAC_SEMã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        if @@api.has_key?(@plugin_arg_str) == false
+            raise "#{@plugin_arg_str} is unknown"
+        elsif @plugin_arg_str != "KERNEL"
+            file.puts "SAC_#{@@api[@plugin_arg_str].at(0)}(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3] }});"
+        else
+            file.puts "SAC_#{@@api[@plugin_arg_str].at(0)}({ #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+        end
+    end
+
+=begin
+    #tSemaphoreã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+=end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Plugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Plugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2Plugin.rb	(revision 317)
@@ -0,0 +1,138 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#
+# åã¡ã½ããã®å½¹å²ãã¯ãDomainPlugin.rb ãåç
+§ã®ãã¨
+# HRP2ã«ã¼ãã«ç¨ãã¡ã¤ã³ãã©ã°ã¤ã³
+class HRP2Plugin < DomainPlugin
+
+  def initialize( region, name, option )
+    print "MyDomainPlugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n"
+  end
+
+  def add_through_plugin( join, current_region, next_region, through_type )
+    # join.get_owner:Cell  å·¦è¾ºã®ã»ã«
+    # join.get_definition:Port å¼ã³å£
+    # join.get_subscript:Integer or nil å¼ã³å£é
+åã®æ·»æ° (Join::@subscript ã®èª¬æåç
+§)
+    # join.get_cell:Cell å³è¾ºã®ã»ã«
+    # join.get_port_name:Symbol åãå£
+    # get_rhs_subscript:Integer or nil åãå£é
+åã®æ·»æ° (Join::@rhs_subscript ã®èª¬æåç
+§)
+    # return []
+    print "MyDomainPlugin: add_through_plugin: #{current_region.get_name}=>#{next_region.get_name}, #{join.get_owner.get_name}.#{join.get_definition.get_name}=>#{join.get_cell.get_name}.#{join.get_port_name}, #{through_type}\n"
+
+    puts "=====Join Check Start====="
+    puts "caller: #{join.get_owner.get_name.to_s}, callee: #{join.get_cell.get_name.to_s}"
+    puts "=====Join Check param====="
+    current_domain = current_region.get_domain_root.get_domain_type
+    next_domain = next_region.get_domain_root.get_domain_type
+    puts current_domain.get_option.to_s
+    if !next_domain.nil?
+        puts next_domain.get_option.to_s
+    else
+        puts "next domain is nil!"
+    end
+
+    if HRP2KernelObjectPlugin.include_celltype?(join.get_cell.get_celltype)
+        # çµåå
+ãã«ã¼ãã«ãªãã¸ã§ã¯ãã»ã«
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        # ä½ãããªãthrough
+        puts "***** #{join.get_cell.get_celltype.get_name} is kernel object"
+        return []
+        # return [ :HRP2SVCPlugin, "channelCelltype=tMessagebufferChannel,noClientSemaphore=true" ]
+    # elsif @end_region.is_root?
+    # elsif next_region.get_option == OutOfDomain
+    # elsif next_domain.nil?
+    elsif next_domain.get_option.to_s == "OutOfDomain"
+    #     # çµåå
+ãç¡æå±
+    #     # ä½ãããªãthrough
+    #     # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        puts "***** nil"
+        return []
+        # return [ :HRP2SVCPlugin, "channelCelltype=tMessagebufferChannel,noClientSemaphore=true" ]
+    #elsif @start_region.get_param != :KERNEL_DOMAIN && @end_region.get_param == :KERNEL_DOMAIN
+    elsif current_domain.get_option.to_s != "trusted" && next_domain.get_option.to_s == "trusted"
+        # ã¦ã¼ã¶ãã¡ã¤ã³ããã«ã¼ãã«ãã¡ã¤ã³ã¸ã®çµå
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        puts "***** svc"
+        return [ :HRP2SVCPlugin, "" ]
+    elsif current_domain != next_domain
+        # ã¦ã¼ã¶ãã¡ã¤ã³ããå¥ã®ã¦ã¼ã¶ãã¡ã¤ã³ã¸ã®çµå
+        # @plugin_body = HRP2RPCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        puts "***** rpc"
+        return [ :HRP2RPCPlugin, "channelCelltype=tMessagebufferChannel,noClientSemaphore=true" ]
+    else
+        # ãã®ä»
+        # ä½ãããªãthrough
+        # @plugin_body = HRP2SVCPlugin.new(cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell)
+        print "warning: at HRP2 Join Check"
+        return nil
+    end
+
+    puts "=====Join Check End====="
+  end
+
+  def joinable?(current_region, next_region, through_type )
+    print "MyDomainPlugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n"
+    return true
+  end
+
+  def self.gen_post_code file
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PostHook.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PostHook.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PostHook.rb	(revision 317)
@@ -0,0 +1,127 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+class HRP2PostHook
+    #@celltype:: Celltype
+    def initialize( celltype )
+        puts "new post hook #{celltype.get_name}"
+        @celltype = celltype
+    end
+
+    def generate
+        # ã«ã¼ãã«ãªãã¸ã§ã¯ãã®ã»ã«ã¿ã¤ãã¯ã¡ã¢ãªä¿è­·ããªã
+#=begin
+        # TODO: ãã¹ãã®ããã«ç¡å¹å
+        if HRP2KernelObjectPlugin.include_celltype?( @celltype )
+            puts "nothing is generated for kernel object component"
+            return
+        end
+#=end
+
+        rlist = @celltype.get_region_list
+        if @celltype.is_singleton?
+            # singletonã®å ´å
+            puts "<singleton>"
+
+            if rlist.length == 0
+                file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+            else
+                file = AppFile.open( "#{$gen}/tecsgen_#{rlist[0].get_param.to_s}.cfg" )
+            end
+            # ã»ã«ç®¡çãã­ãã¯ã¨ã¹ã±ã«ãã³ã®ã¡ã¢ãªä¿è­·
+            file.print "ATT_MOD(\"#{@celltype.get_global_name}_tecsgen.o\");\n"
+            if !@celltype.is_all_entry_inline?
+                # ã»ã«ã¿ã¤ãã³ã¼ãã®ã¡ã¢ãªä¿è­·
+                file.print "ATT_MOD(\"#{@celltype.get_global_name}.o\");\n"
+            end
+
+            file.close
+
+        else
+            # singletonã§ãªãå ´å
+            puts "<non-singleton>"
+
+            # ã¹ã±ã«ãã³ã¨ã»ã«ã¿ã¤ãã³ã¼ãã®ä¿è­·
+            if (rlist.length == 1) && 
+                (@celltype.get_n_cell_gen == @celltype.get_n_cell_gen_r( rlist[0] ))
+                # æå±ããä¿è­·ãã¡ã¤ã³ã1ã¤ã®å ´å
+                puts "<private celltype>"
+                file = AppFile.open( "#{$gen}/tecsgen_#{rlist[0].get_param.to_s}.cfg" )
+            else
+                # ç¡æå± or æå±ããä¿è­·ãã¡ã¤ã³ãè¤æ°ã®å ´å
+                puts "<shared celltype>"
+                file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+            end
+
+            # ã¹ã±ã«ãã³ã®ã¡ã¢ãªä¿è­·
+            file.print "ATT_MOD(\"#{@celltype.get_global_name}_tecsgen.o\");\n"
+            if !@celltype.is_all_entry_inline?
+                # ã»ã«ã¿ã¤ãã³ã¼ãã®ã¡ã¢ãªä¿è­·
+                file.print "ATT_MOD(\"#{@celltype.get_global_name}.o\");\n"
+            end
+            file.close
+
+            # ã»ã«ç®¡çãã­ãã¯ã®ä¿è­·
+            rlist.each { |reg|
+                file = AppFile.open( "#{$gen}/tecsgen_#{reg.get_param.to_s}.cfg" )
+                file.print "ATT_MOD(\"#{@celltype.get_global_name}_#{reg.get_name.to_s}_tecsgen.o\");\n"
+                file.close
+            }
+
+        end
+    end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb	(revision 317)
@@ -0,0 +1,84 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2012 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+class HRP2PriorityDataqueuePlugin < HRP2KernelObjectPlugin
+    @@ep = [:eSendPriorityDataqueue, :eReceivePriorityDataqueue, :eManagePriorityDataqueue, :eReferPriorityDataqueue ]
+    #=== HRP2PriorityDataqueuePlugin#print_cfg_cre
+    # CRE_PDQã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        file.print tab
+        file.puts "CRE_PDQ(#{val[:id]}, {#{val[:attribute]}, #{val[:count]}, #{val[:maxDataPriority]}, #{val[:pdqmb]}});"
+    end
+    #=== HRP2PriorityDataqueuePlugin#print_cfg_sac
+    # SAC_PDQã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        file.puts "SAC_PDQ(#{val[:id]}, {#{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]}});"
+    end
+    #tPriorityDataqueueã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb	(revision 317)
@@ -0,0 +1,348 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+require_tecsgen_lib "lib/GenHRP2Marshaler.rb"
+
+# require_tecsgen_lib "GenParamCopy.rb"
+
+#= Transparent RPC ãã©ã°ã¤ã³
+# Transparent RPC ãã£ã³ãã«ãçæãã
+# ãã©ã°ã¤ã³å¼æ°ã¯ä»¥ä¸ã® RPCPluginArgProc ãåç
+§
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+#
+# RPCãç¨ãããã¡ã¤ã³ééä¿¡ã®
+# throughãã©ã°ã¤ã³
+# HRP2ãã¡ã¤ã³ãã©ã°ã¤ã³ã«ãã£ã¦æ¿å
+¥ããã
+#
+class HRP2RPCPlugin < ThroughPlugin
+
+  include GenTransparentMarshaler
+  # include GenParamCopy
+
+  # RPCPlugin å°ç¨ã®ãªãã·ã§ã³
+  TransparentRPCPluginArgProc = RPCPluginArgProc.dup  # è¤è£½ãä½ã£ã¦å
+ãå¤æ´ããªãããã«ãã
+  TransparentRPCPluginArgProc[ "noClientSemaphore"  ] = Proc.new { |obj,rhs| obj.set_noClientSemaphore rhs }
+  TransparentRPCPluginArgProc[ "semaphoreCelltype"  ] = Proc.new { |obj,rhs| obj.set_semaphoreCelltype rhs }
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super
+    @b_noClientSemaphore = false
+    @semaphoreCelltype = "tSemaphore"
+    initialize_transparent_marshaler cell_name
+
+    # ãªãã·ã§ã³ï¼GenTransparentMarshaler åç
+§
+    @plugin_arg_check_proc_tab = TransparentRPCPluginArgProc
+    parse_plugin_arg
+
+    @rpc_channel_celltype_name = "tRPCPlugin_#{@TDRCelltype}_#{@channelCelltype}_#{@signature.get_name}"
+    @rpc_channel_celltype_file_name = "#{$gen}/#{@rpc_channel_celltype_name}.cdl"
+
+    if @signature.need_PPAllocator? then
+      if @PPAllocatorSize == nil then
+        cdl_error( "PPAllocatorSize must be speicified for oneway [in] array" )
+        # @PPAllocatorSize = 0   # ä»®ã« 0 ã¨ãã¦ãã (cdl ã®æ§æã¨ã©ã¼ãé¿ãããã)
+      end
+    end
+
+#    @signature.each_param{ |func_decl, param_decl|
+#      if func_decl.get_type.is_oneway? then
+#        if ( param_decl.get_size || param_decl.get_count ) && param_decl.get_string then
+#          cdl_error( "array of string not supported for oneway function in Transparent RPC" )  # mikan æå­åã®é
+å
+#        elsif param_decl.get_string == -1 then
+#          cdl_error( "length unspecified string is not permited for oneway function in Transparent RPC" )  # mikan é·ãæªæå®æå­å
+#        end
+#      end
+#    }
+  end
+
+  #=== plugin ã®å®£è¨ã³ã¼ã (celltype ã®å®ç¾©) çæ
+  def gen_plugin_decl_code( file )
+
+    ct_name = "#{@ct_name}_#{@channelCelltype}"
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ ct_name ] == nil then
+      @@generated_celltype[ ct_name ] = [ self ]
+    else
+      @@generated_celltype[ ct_name ] << self
+      return
+    end
+
+    gen_marshaler_celltype
+
+    if @PPAllocatorSize then
+      alloc_cell = "  cell tPPAllocator PPAllocator {\n    heapSize = #{@PPAllocatorSize};\n  };\n"
+      alloc_call_port_join = "    cPPAllocator = PPAllocator.ePPAllocator;\n"
+    else
+      alloc_cell = ""
+      alloc_call_port_join = ""
+    end
+
+    if @b_noClientSemaphore == false then
+      semaphore1 = <<EOT
+  // Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this)
+  cell #{@semaphoreCelltype} Semaphore {
+    count = 1;
+    attribute = C_EXP( "TA_NULL" );
+  };
+EOT
+      semaphore2 = "    cLockChannel = Semaphore.eSemaphore;\n"
+    else
+      semaphore1 = ""
+      semaphore2 = ""
+    end
+
+    f = CFile.open( @rpc_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+
+composite #{@rpc_channel_celltype_name}Client {
+  /* Interface */
+  entry #{@signature.get_name} eThroughEntry;
+  //call sTDR       cTDR;
+  call sEventflag cEventflag;
+  call sSemaphore cSemaphore;
+  call sMessageBuffer cMessageBuffer;
+
+  /* Implementation */
+#{semaphore1}
+  cell #{@marshaler_celltype_name} #{@signature.get_name}_marshaler{
+    //cTDR         => composite.cTDR;
+    cEventflag   => composite.cEventflag;
+    cSemaphore   => composite.cSemaphore;
+    cMessageBuffer => composite.cMessageBuffer;
+#{semaphore2}  };
+  composite.eThroughEntry => #{@signature.get_name}_marshaler.eClientEntry;
+};
+
+[active]
+composite #{@rpc_channel_celltype_name}Server {
+  /* Interface */
+  attr {
+    PRI taskPriority;
+  };
+  call #{@signature.get_name} #{@call_port_name};
+  //call sTDR       cTDR;
+  call sEventflag cEventflag;
+  call sSemaphore cSemaphore;
+  call sMessageBuffer cMessageBuffer;
+
+  /* Implementation */
+#{alloc_cell}  cell #{@unmarshaler_celltype_name} #{@signature.get_name}_unmarshaler{
+    //cTDR        => composite.cTDR;
+    cEventflag  => composite.cEventflag;
+    cSemaphore  => composite.cSemaphore;
+    cMessageBuffer => composite.cMessageBuffer;
+    cServerCall => composite.#{@call_port_name};
+#{alloc_call_port_join}  };
+  cell tRPCDedicatedTaskMain RPCTaskMain{
+    cMain = #{@signature.get_name}_unmarshaler.eUnmarshalAndCallFunction;
+  };
+  cell tTask Task {
+    cBody     = RPCTaskMain.eMain;
+    priority  = taskPriority;
+    taskAttribute = C_EXP( "TA_ACT" );  /* mikan : marshaler starts at the beginning */
+    //stackSize     = 4096;
+    userStackSize     = 4096;
+  };
+};
+EOT
+    # mikan stackSize option & ææ° tecs_package å¯¾å¿
+
+    f.close
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]
+    # cell = Namespace.find( path )
+    cell = Namespace.find( @next_cell.get_namespace_path )
+
+    file.print <<EOT
+import( "#{@rpc_channel_celltype_file_name}" );
+EOT
+
+    #nest = @end_region.gen_region_str_pre file
+    indent_str = ""
+
+    file.print <<EOT
+#{indent_str}// one way channel cell
+#{indent_str}cell #{@channelCelltype} #{@channelCellName} {
+#{indent_str}};
+
+#{indent_str}// RPC channel cell
+EOT
+
+    nest = @start_region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    # #473 ãè§£æ±ºãããå ´åãcomposite ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã«å¤æ´ãã¹ã
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      dbgPrint "make allocator"
+      file.print "#{indent_str}[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        file.print delim
+        delim = ",\n#{indent_str}           "        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = "eThroughEntry" #RPCã®åãå£åã«å¤æ´
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc}"
+      end
+
+      file.puts ")]"
+    end
+
+    file.print <<EOT
+#{indent_str}cell #{@rpc_channel_celltype_name}Client #{@cell_name} {
+#{indent_str}  //cTDR         = #{@channelCellName}.eTDR;
+#{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
+#{indent_str}  cSemaphore   = #{@channelCellName}.eSemaphore;
+#{indent_str}  cMessageBuffer   = #{@channelCellName}.eMessageBuffer;
+#{indent_str}};
+EOT
+
+    @start_region.gen_region_str_post file
+
+    nest = @end_region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    file.print <<EOT
+#{indent_str}cell #{@rpc_channel_celltype_name}Server #{@cell_name}Body {
+#{indent_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+//#{indent_str}    #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
+#{indent_str}  //cTDR         = #{@channelCellName}.eTDR;
+#{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
+#{indent_str}  cSemaphore   = #{@channelCellName}.eSemaphore;
+#{indent_str}  cMessageBuffer  = #{@channelCellName}.eMessageBuffer;
+#{indent_str}  taskPriority = #{@task_priority};
+#{indent_str}};
+EOT
+
+    @end_region.gen_region_str_post file
+  end
+
+
+  #=== ãã©ã°ã¤ã³å¼æ° noClientSemaphore ã®ãã§ãã¯
+  def set_noClientSemaphore rhs
+    rhs = rhs.to_sym
+    if rhs == :true then
+      @b_noClientSemaphore = true
+    elsif rhs == :false then
+      @b_noClientSemaphore = false
+    else
+      cdl_error( "RPCPlugin: specify true or false for noClientSemaphore" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° semaphoreCelltype ã®ãã§ãã¯
+  def set_semaphoreCelltype rhs
+    @semaphoreCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @semaphoreCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: semaphoreCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== NamespacePath ãå¾ã
+  # çæããã»ã«ã® namespace path ãçæãã
+  def get_cell_namespace_path
+#    nsp = @region.get_namespace.get_namespace_path
+    nsp = @start_region.get_namespace_path
+    return nsp.append( @cell_name )
+  end
+
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb	(revision 317)
@@ -0,0 +1,487 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+class SVCManage
+    # TODO: ããã©ã«ãã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«åãäºç´ãã¦ãã
+    # ããã©ã«ãã®æ¡å¼µãµã¼ãã¹ã³ã¼ã«ï¼syslogãªã©ï¼ãã³ã³ãã¼ãã³ãåããã¾ã§
+    @@id = 20
+    @@func_ids = {}
+    def self.get_func_id func_name
+        return @@func_ids[ func_name ]
+    end
+    def self.set_func_id func_name
+        @@func_ids[ func_name ] = self.assign_id
+        puts @@func_ids[ func_name ]
+    end
+    def self.include_func_id? func_name
+        return @@func_ids.has_key?( func_name )
+    end
+    def self.get_id
+        return @@id
+    end
+    def self.set_id id
+        @@id = id
+    end
+    def self.assign_id
+        @@id += 1
+        return @@id
+    end
+end
+
+#
+# æ¡å¼µãµã¼ãã¹ã³ã¼ã«ãç¨ãããã¡ã¤ã³ééä¿¡ã®
+# throughãã©ã°ã¤ã³
+# HRP2ãã¡ã¤ã³ãã©ã°ã¤ã³ã«ãã£ã¦æ¿å
+¥ããã
+#
+class HRP2SVCPlugin < ThroughPlugin
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  @@generated_celltype_header = {}
+
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super
+    @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
+    @ct_name = "#{@ct_name}SVCCaller_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
+    @cell_name_body = "#{@cell_name}SVCBody".to_sym
+    @cell_name = "#{@cell_name}SVCCaller".to_sym
+    puts "%%%% "
+    p @next_cell.get_name
+    p @caller_cell.get_name
+  end
+
+  #=== NamespacePath ãå¾ã
+  # çæããã»ã«ã® namespace path ãçæãã
+  def get_cell_namespace_path
+#    nsp = @region.get_namespace.get_namespace_path
+    nsp = @start_region.get_namespace_path
+    return nsp.append( @cell_name )
+  end
+
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
+    if @@generated_celltype[ @ct_name_body ] == nil then
+        @@generated_celltype[ @ct_name_body ] = [ self ]
+        file2 = CFile.open( "#{$gen}/#{@ct_name_body}.cdl", "w" )
+        file2.print <<EOT
+[active]
+celltype #{@ct_name_body} {
+    call #{@signature.get_name} #{@call_port_name};
+};
+EOT
+        file2.close
+    else
+      @@generated_celltype[ @ct_name_body ] << self
+    end
+    file.print "import( \"#{$gen}/#{@ct_name_body}.cdl\" );\n"
+    end
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @ct_name ] == nil then
+        @@generated_celltype[ @ct_name ] = [ self ]
+        file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
+        if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
+        file2.print <<EOT
+celltype #{@ct_name} {
+    entry #{@signature.get_name} #{@entry_port_name};
+};
+EOT
+        else
+            # TODO inlineã«ããæ¹ãå¹çããããï¼tecsgenã®çæããããããã¡ã¤ã«ã®
+            # èª­è¾¼é ã®ããã«ã¨ã©ã¼ã¨ãªã
+        file2.print <<EOT
+celltype #{@ct_name} {
+    //[inline] entry #{@signature.get_name} #{@entry_port_name};
+    entry #{@signature.get_name} #{@entry_port_name};
+    call #{@signature.get_name} #{@call_port_name};
+};
+EOT
+        end
+        
+        file2.close
+    else
+      @@generated_celltype[ @ct_name ] << self
+    end
+    file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
+
+=begin
+    # TODO: send. receive å¯¾å¿
+    send_receive = []
+    if @signature != nil then
+      @signature.each_param{ |fd,param|
+        dir =param.get_direction
+        case dir
+        when :SEND, :RECEIVE
+          send_receive << [ dir, fd, param ]
+        end
+      }
+    end
+=end
+
+=begin
+composite #{@ct_name} {
+    entry #{@signature.get_name} #{@entry_port_name};
+    call #{@signature.get_name} #{@call_port_name};
+
+    cell #{@ct_name}Client #{@cell_name}Client{
+    };
+
+    [active]
+    cell #{@ct_name}Server #{@cell_name}Server{
+        #{@call_port_name} => composite.#{@call_port_name};
+    };
+
+    composite.#{@entry_port_name} => #{@cell_name}.#{@entry_port_name};
+};
+=end
+
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+    #require "HRP2Cache"
+
+    gen_plugin_decl_code( file )
+
+    if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]  # mikan namespace
+    # cell = Namespace.find( path )
+    # cell = Namespace.find( @next_cell.get_namespace_path )
+
+    ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
+    # file.print "[domain(HRP2, \"trusted\")]"
+    nest = @start_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã«ã®çæ
+    # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
+    file.print <<EOT
+#{nest_str}  //  Client Side Channel
+#{nest_str}  cell #{@ct_name} #{@cell_name}{
+#{nest_str}  };
+
+EOT
+
+    @start_region.gen_region_str_post file
+    file.print "\n\n"
+
+    ##### ãµã¼ãã¼å´ã®ã»ã«ã®çæ #####
+    nest = @end_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ãµã¼ãã¼å´ãã£ã³ãã«ã®çæ 
+    # æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½
+    file.print <<EOT
+
+#{nest_str}  //  Server Side Channel
+#{nest_str}  cell #{@ct_name_body} #{@cell_name_body}{
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}  };
+EOT
+
+    @end_region.gen_region_str_post file
+
+    file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+    file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
+    file2.print <<EOT
+#include "#{@ct_name_body}_factory.h"
+EOT
+    file2.close
+    else
+
+    ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
+    nest = @start_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã«ã®çæ
+    # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
+    file.print <<EOT
+#{nest_str}  //  Client Side Channel
+#{nest_str}  cell #{@ct_name} #{@cell_name}{
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}  };
+
+EOT
+
+    @start_region.gen_region_str_post file
+    file.print "\n\n"
+
+    end
+   end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+      puts "generate ep_func for #{ct_name}"
+
+    if !HRP2KernelObjectPlugin.include_celltype?(@next_cell.get_celltype)
+        # æ¡å¼µãµã¼ãã¹ã³ã¼ã«å¼åºã
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  #{func_type.get_type_str}  retval;\n" )
+        end
+
+        if ! b_singleton then
+
+            file.print <<EOT
+  #{ct_name}_CB    *p_cellcb;
+  if( VALID_IDX( idx ) ){
+    p_cellcb = #{global_ct_name}_GET_CELLCB(idx);
+  }else{
+     /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+  }
+
+EOT
+        end
+
+        # p "celltype_name, sig_name, func_name, func_global_name"
+        # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+        delim = ""
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  retval = (#{func_type.get_type_str})" )
+        else
+            file.print( "  " )
+        end
+
+        #file.print( "#{@call_port_name}_#{func_name}(" )
+        # svcid = SVCManage.assign_id
+        new_func = false
+        if SVCManage.include_func_id?( "#{@ct_name_body}_#{func_name}" ) == false
+            new_func = true
+            SVCManage.set_func_id( "#{@ct_name_body}_#{func_name}" )
+        end
+        svcid = SVCManage.get_func_id( "#{@ct_name_body}_#{func_name}" )
+        #file.print( "cal_svc( #{@ct_name_body}_#{func_name}" )
+        file.print( "cal_svc( #{svcid.to_s}" )
+
+        #    if ( ! b_singleton ) then
+        #      file.print( " tecs_this" )
+        #      delim = ","
+        #    end
+
+        i = 0
+        params.each{ |param|
+            delim = ","
+            file.printf( "#{delim} #{param.get_name}" )
+            i += 1
+        }
+
+        while(i < 5) do
+            delim = ","
+            file.printf( "#{delim} 0" )
+            i += 1
+        end
+
+        file.print( " );\n" )
+
+        if ! func_type.get_type.kind_of?( VoidType ) then
+            file.print( "  return retval;\n" )
+        end
+
+        # æ¡å¼µãµã¼ãã¹ã³ã¼ã«æ¬ä½
+        if new_func
+            file2 = AppFile.open( "#{$gen}/#{@ct_name_body}.c" )
+
+#             if @@generated_celltype_header[ @ct_name_body ].nil?
+#                 @@generated_celltype_header[ @ct_name_body ] = true
+#                 p @@generated_celltype_header[ @ct_name_body ]
+#                 file2.print <<EOT
+# /*
+#  * ãã®ãã¡ã¤ã«ã¯ tecsgen ã«ããèªåçæããã¾ãã
+#  * ãã®ãã¡ã¤ã«ãç·¨éãã¦ä½¿ç¨ãããã¨ã¯ãæå³ããã¦ãã¾ãã
+#  */
+# /* #[<PREAMBLE>]#
+#  * #[<...>]# ãã #[</...>]# ã§å²ã¾ããã³ã¡ã³ãã¯ç·¨éããªãã§ãã ãã
+#  * tecsmerge ã«ãããã¼ã¸ã«ä½¿ç¨ããã¾ã
+#  *
+#  * #[</PREAMBLE>]# */
+# 
+# /* ãã­ãã¿ã¤ãå®£è¨ãå¤æ°ã®å®ç¾©ãããã«æ¸ãã¾ã #_PAC_# */
+# #include "#{@ct_name_body}_tecsgen.h"
+# 
+# #ifndef E_OK
+# #define	E_OK	0		/* success */
+# #define	E_ID	(-18)	/* illegal ID */
+# #endif
+# 
+# EOT
+#             end
+
+            if func_type.get_type.kind_of?( VoidType ) then
+                retval_assign = ""
+                retval_return = ""
+            else
+                retval_assign = "retval = (ER_UINT)"
+                retval_return = "retval"
+            end
+
+            file2.print <<EOT
+ER_UINT
+#{@ct_name_body}_#{func_name}(intptr_t par1, intptr_t par2, intptr_t par3, intptr_t par4, intptr_t par5, ID cdmid)
+{
+    #{@ct_name_body}_CB    *p_cellcb;
+#if 0
+    if( VALID_IDX( idx ) ){
+      p_cellcb = #{@ct_name_body}_GET_CELLCB(idx);
+    }else{
+       /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+    }
+#else
+    p_cellcb = NULL;
+#endif
+
+    ER_UINT retval = 0;
+
+EOT
+
+            num = 1
+            params.each{ |param|
+                if param.get_declarator.get_ptr_level > 0 then
+                    if param.get_direction == :IN then
+                        file2.print <<EOT
+    if(prb_mem((void *)par#{num.to_s}, sizeof(#{param.get_type.get_type_str}), TSK_SELF, TPM_READ) != E_OK){
+        return E_MACV;
+    }
+EOT
+
+                    elsif param.get_direction == :OUT then
+                        file2.print <<EOT
+    if(prb_mem((void *)par#{num.to_s}, sizeof(#{param.get_type.get_type_str}), TSK_SELF, TPM_WRITE) != E_OK){
+        return E_MACV;
+    }
+EOT
+
+                    end
+                end
+                num += 1
+            }
+
+            file2.print"    #{retval_assign}#{@call_port_name}_#{func_name}("
+
+            delim = ""
+            num = 1
+            params.each{ |param|
+                file2.print "#{delim}"
+                delim = ", "
+                file2.print "(#{param.get_type.get_type_str})"
+                file2.print "par" + num.to_s
+                file2.print param.get_type.get_type_str_post
+                num += 1
+            }
+
+            file2.print ");\n"
+
+            if !func_type.get_type.kind_of?( VoidType ) then
+                file2.print "\n    return #{retval_return};\n"
+            end
+            file2.print "}\n\n"
+
+            file2.close
+
+            file2 = AppFile.open( "#{$gen}/tecsgen.cfg" )
+            file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
+            # TODO: ã¹ã¿ãã¯ãµã¤ãºã¯é©å½
+            file2.print <<EOT
+KERNEL_DOMAIN{
+    DEF_SVC( #{svcid.to_s}, { TA_NULL, #{@ct_name_body}_#{func_name}, 256 } );
+}
+EOT
+            file2.close
+
+            file2 = AppFile.open( "#{$gen}/#{@ct_name_body}_factory.h" )
+            file2.print "\n/* Generated by HRP2SVCPlugin */\n\n"
+            file2.print <<EOT
+extern ER_UINT #{@ct_name_body}_#{func_name}(intptr_t par1, intptr_t par2, intptr_t par3, intptr_t par4, intptr_t par5, ID cdmid);
+EOT
+            file2.close
+        end
+    else
+        # ã«ã¼ãã«ãã¡ã¤ã³ã®ã»ã«ã¯ç¹å¥ãªãã¨ã¯ä½ãããï¼æ®éã«å¼ã³åºã
+        super
+    end
+  end
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb	(revision 317)
@@ -0,0 +1,85 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2011 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+
+class HRP2SemaphorePlugin < HRP2KernelObjectPlugin
+    @@ep = [:eSignalSemaphore, :eWaitSemaphore, :eManageSemaphore, :eReferSemaphore ]
+    #=== HRP2SemaphorePlugin#print_cfg_cre
+    # CRE_SEMã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # tab :: string:   ã¤ã³ãã³ãç¨ã®tab
+    def print_cfg_cre(file, cell, val, tab)
+        file.print tab
+        file.puts "CRE_SEM(#{val[:id]}, {#{val[:attribute]}, #{val[:count]}, #{val[:max]}});"
+    end
+    #=== HRP2SemaphorePlugin#print_cfg_sac
+    # SAC_SEMã®åºå
+    # file:: FILE:     åºåå
+ãã¡ã¤ã«
+    # val :: string:   ã«ã¼ãã«ãªãã¸ã§ã¯ãã®å±æ§ã®è§£æçµæ
+    # acv :: string:   ã¢ã¯ã»ã¹ãã¯ã¿    
+    def print_cfg_sac(file, val, acv)
+        file.puts "SAC_SEM(#{val[:id]}, {#{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]}});"
+    end
+    #tSemaphoreã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+end
+
+
+  
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb	(revision 317)
@@ -0,0 +1,214 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#require "HRP2KernelObjectPlugin"
+require_tecsgen_lib "HRP2KernelObjectPlugin.rb"
+#== celltype ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class HRP2TaskPlugin < HRP2KernelObjectPlugin
+    # @@ep = [:eActivateTask, :eControlTask, :eManageTask, :eReferTask ]
+    # ATT_MODãçææ¸ã¿ãã©ãã
+    @@generate_memory_module = false
+
+    ##
+    #
+    # file : output file (ex.tecsgen.cfg)
+    # cell : 
+    # val  : 
+    # tab  : 
+    def print_cfg_cre(file, cell, val, tab)
+        val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
+        # $cbp$ã®ä»£ãã
+        index = cell.get_id - @celltype.get_id_base
+        #cell_CB_name = "#{@celltype.get_global_name}_pCB_tab[#{index}]"
+        cell_CB_name = "#{index}"
+        # CRE_XXX/DEF_XXXã®çæ
+        print "assign task plugin\n"
+        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
+        # if cell.get_region.get_region_type == :DOMAIN
+        if domainOption != "OutOfDomain"
+            # ä¿è­·ãã¡ã¤ã³ã«å±ããå ´å
+            if domainOption == "trusted"
+                # ã«ã¼ãã«ãã¡ã¤ã³
+                if val[:userStackSize] != "OMIT"
+                    raise "system task cannot have user stack."
+                end
+                file.print <<EOT
+#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:systemStackSize]}, NULL });
+EOT
+            else
+                # ã¦ã¼ã¶ãã¡ã¤ã³
+                if val[:userStackSize] == "OMIT"
+                    raise "user task must have user stack."
+                end
+                if val[:systemStackSize] == "OMIT"
+                    file.print <<EOT
+#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL });
+EOT
+                else
+                    file.print <<EOT
+#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL, #{val[:systemStackSize]}, NULL });
+EOT
+                end
+            end
+        else
+            # ç¡æå±ã®å ´å
+            raise "task #{val[:id]} must belong to a domain."
+        end
+   
+        # ä¾å¤ç¨ã®ãçæ
+        file.print <<EOT
+#{tab}DEF_TEX(#{val[:id]}, { #{val[:exceptionAttribute]}, tTask_start_exception });
+EOT
+    end
+
+    def print_cfg_sac(file, val, acv)
+       file.puts "SAC_TSK(#{val[:id]}, { #{acv[0]}, #{acv[1]}, #{acv[2]}, #{acv[3]} });"
+    end
+
+=begin
+    #tTaskã®åãå£ãªã¹ã 
+    def get_entry_ports_name_list()
+        @@ep
+    end
+=end
+    # 
+    #  ATT_MODã®çæ
+    #  gen_factoryå®è¡æã«ã¯ï¼ãã¹ã¦ã®ã»ã«ã¿ã¤ããã©ã°ã¤ã³ãçææ¸ã¿ã®ã¯ããªã®ã§ï¼
+    #  ã«ã¼ãã«APIã³ã¼ãã®ã¡ã¢ãªä¿è­·ãçç¥ã§ããï¼
+    #
+    def gen_factory file
+        super
+        if @@generate_memory_module == false
+            check_celltype_list = []
+
+            Cell.get_cell_list2.each { |cell|
+                # ãã¹ã¦ã®ã»ã«ãèµ°æ»ãã¦ã»ã«ã¿ã¤ãããã§ãã¯
+                ct = cell.get_celltype
+                if ct.class == Celltype && check_celltype_list.include?( ct ) == false
+                    # æªãã§ãã¯ã®ã»ã«ã¿ã¤ãã ã£ãå ´å
+                    # puts "check for ATT_MOD : #{ct.classget_global_name}"
+                    puts "check for ATT_MOD : #{ct.get_global_name}"
+                        
+                    # ã«ã¼ãã«APIã®ã³ã¼ãï¼ãã¼ã¿ã¯ã¡ã¢ãªä¿è­·ããªã
+                    next if HRP2KernelObjectPlugin.include_celltype?( ct )
+
+                    # å¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã®ã³ã¼ãï¼ãã¼ã¿ã¯ã¡ã¢ãªä¿è­·ããªã
+                    next if ! ct.need_generate?
+
+                    # HRP2ã®ãã¡ã¤ã³ãªã¼ã¸ã§ã³ãåå¾
+                    regions = ct.get_domain_roots
+                    regions_hrp2 = regions[ :HRP2 ]
+                    print "HRP2 domain in #{ct.get_name}: "
+                    regions_hrp2.each { |reg|
+                        print reg.get_name
+                    }
+                    puts ""
+
+                    # ã»ã«ç®¡çãã­ãã¯ã¨ã¹ã±ã«ãã³ã®ã¡ã¢ãªä¿è­·
+                    # gen_celltype_names_domain ç¸å½ã®å¦ç
+                    if regions_hrp2.include?( Region.get_root ) == false && regions_hrp2.length > 1
+                        # ãã¡ã¤ã³ãè¤æ°ã§ï¼OutOfDomainã«ã»ã«ãå­å¨ããªãã»ã«ã¿ã¤ãã®å ´å
+                        # å
+±æã®ã»ã«ç®¡çãã­ãã¯ã¨ã¹ã±ã«ãã³ã³ã¼ããç»é²ãã
+                        file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+                        file.print "ATT_MOD(\"#{ct.get_global_name}_tecsgen.o\");\n"
+                        file.close
+                    end
+
+                    regions_hrp2.each { |reg|
+                        if reg.is_root? 
+                            nsp = ""
+                        else
+                            nsp = "_#{reg.get_namespace_path.get_global_name}"
+                        end
+                        file = AppFile.open( "#{$gen}/tecsgen#{nsp}.cfg" )
+                        file.print "ATT_MOD(\"#{ct.get_global_name}#{nsp}_tecsgen.o\");\n"
+                        file.close
+                    }
+
+                    # ã»ã«ã¿ã¤ãã³ã¼ãããªãå ´åã¯ã¹ã­ãã
+                    next if ct.is_all_entry_inline? && ! ct.is_active?
+
+                    # ã»ã«ã¿ã¤ãã³ã¼ãã®ã¡ã¢ãªä¿è­·
+                    # gen_celltype_names_domain2 ç¸å½ã®å¦ç
+                    if regions_hrp2.include?( Region.get_root ) == true || regions_hrp2.length > 1
+                        # OutOfDomainã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+                        # ã¾ãã¯ï¼è¤æ°ã®ãã¡ã¤ã³ã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+                        # ã»ã«ã¿ã¤ãã³ã¼ããå
+±æããããã«ç»é²ãã
+                        file = AppFile.open( "#{$gen}/tecsgen.cfg" )
+                    else
+                        # OutOfDomainã§ãªãåä¸ã®ãã¡ã¤ã³ã«ã»ã«ãå­å¨ããã»ã«ã¿ã¤ãã®å ´å
+                        # ã»ã«ã¿ã¤ãã³ã¼ããå°æããããã«ç»é²ãã
+                        file = AppFile.open( "#{$gen}/tecsgen_#{regions_hrp2[0].get_namespace_path.get_global_name}.cfg" )
+                    end
+
+                    file.print "ATT_MOD(\"#{ct.get_global_name}.o\");\n"
+                    file.close
+
+                    check_celltype_list << ct
+                else
+                    # ä½ãããªã
+                end
+            }
+
+            @@generate_memory_module = true
+        else
+            # ä½ãããªã
+        end
+    end
+    
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/Mruby2CBridgePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/Mruby2CBridgePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/Mruby2CBridgePlugin.rb	(revision 317)
@@ -0,0 +1,103 @@
+# -*- coding: utf-8 -*-
+#
+#  mruby => TECS bridge
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: Mruby2CBridgePlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#
+
+class Mruby2CBridgePlugin < SignaturePlugin
+  @@signature_list = { }
+
+  def initialize( signature, option )
+    super
+
+    @celltype_name = :"t#{@signature.get_global_name}"
+    @class_name = :"T#{@signature.get_global_name}"
+
+    parse_plugin_arg
+  end
+
+  def gen_cdl_file( file )
+    if( @@signature_list.length == 0 )then
+      print_msg "  Mruby2CBridgePlugin: [initialize function] 'void initializeBridge( mrb_state *mrb )' must be called from VM.\n"
+      c2tecs = "generate( C2TECSBridgePlugin, nMruby::sInitializeBridge, \"silent=true\" );\n"
+    end
+
+    if @@signature_list[ @signature.get_global_name ] then
+      @@signature_list[ @signature.get_global_name ] << self
+      cdl_warning( "MRCW001 signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
+      return
+    end
+
+    @@signature_list[ @signature.get_global_name ] = [self]
+    print_msg "  Mruby2CBridgePlugin: [object creattion]    object = TECS::#{@class_name}.new( 'C#{@signature.get_global_name}' )\n"
+    print_msg "  Mruby2CBridgePlugin: [function call]       result = object.function( params )  # substitute 'function' and params \n"
+
+    cf = CFile.open( "#{$gen}/Mruby2C_tsInitializerBridge.cdl", "w")
+    cf.print <<EOT
+cell nC2TECS::tnMruby_sInitializeBridge C2TECS_tsInitializeBridge{
+    cCall = VM_TECSInitializer.eInitialize;
+};
+EOT
+    cf.close
+
+    file.print <<EOT
+generate( MrubyBridgePlugin, #{@signature.get_namespace_path}, "silent=true" );
+generate( TECS2CBridgePlugin, #{@signature.get_namespace_path}, "silent=true" );
+#{c2tecs}
+cell nMruby::t#{@signature.get_name} C#{@signature.get_name}{
+    cTECS = TECS2C_#{@signature.get_name}.eEnt;
+};
+cell nTECS2C::t#{@signature.get_name} TECS2C_#{@signature.get_name}{};
+
+import( "Mruby2C_tsInitializerBridge.cdl" );
+EOT
+
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb	(revision 317)
@@ -0,0 +1,1216 @@
+# -*- coding: utf-8 -*-
+#
+#  mruby => TECS bridge
+#  
+#   Copyright (C) 2008-2015 by TOPPERS Project
+#
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: MrubyBridgePlugin.rb 2554 2016-02-27 06:11:34Z okuma-top $
+#
+
+# Todo:
+# çæãããã®
+#  gen_cdl_file
+#    ããªãã¸åæåã»ã«ã¿ã¤ã (ã·ã°ããã£ãã¨)
+#       @@init_celltypes ã«è¨é²
+#    ããªãã¸ã»ã«ã¿ã¤ã (ã·ã°ããã£ãã¨)
+#       @@celltypes ã«è¨é²
+#    æ§é ä½ã»ã«ã¿ã¤ã
+#       @@struct_list ã«è¨é²
+#  new_cell
+#    TECS åæåã»ã«(ãã­ãã¿ã¤ãå®£è¨)
+#       @@VM_init_cells ã«è¨é²
+#       @@VM_struct_list ã«è¨é²
+#       @@VM_ptr_list ã«è¨é²
+#  gen_post_code
+#    æ§é ä½åæåã»ã«
+#    ãã¤ã³ã¿åæåã»ã«
+#    TECS åæåã»ã«
+#
+#   ep_func ã®ä½æ
+#     signature, ãã¤ã³ã¿ãæ§é ä½ â¦ åæååãå£ï¼mruby VM ã¸ã®ç»é²
+#     ãã¤ã³ã¿
+#   preamble ã®ä½æ
+#     ãã¤ã³ã¿ãæ§é ä½ â¦ ã¢ã¯ã»ã¹ç¨ã³ã¼ãã®çæ
+#     signature â¦ ããªãã¸é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨
+#   postamble ã®ä½æ
+#     signature â¦ ããªãã¸é¢æ°ã®å®ç¾©
+
+class MrubyBridgePlugin < SignaturePlugin
+
+  # ãã©ã°ã¤ã³å¼æ°å => Proc
+  MrubyBridgePluginArgProc = { 
+      "ignoreUnsigned" => Proc.new { |obj,rhs| obj.set_ignoreUnsigned rhs },
+      "include" => Proc.new { |obj,rhs| obj.set_include rhs },
+      "exclude" => Proc.new { |obj,rhs| obj.set_exclude rhs },
+  }
+
+  @@celltypes = { }             # {celltype_name => [ BridgePlugin ã®ã¤ã³ã¹ã¿ã³ã¹ã®é
+å }
+  @@init_celltypes = { }        # {celltype_name => [ BridgePlugin ã®ã¤ã³ã¹ã¿ã³ã¹ã®é
+å }
+  @@struct_list = { }           # {struct_name=>StructType}
+  @@ptr_list = { }              # {ptr_celltype_name=> @@TYPE_MAP ã®å¯¾å¿ãããã®}
+  @@VM_list = { }               # VM_name => true
+  @@VM_celltypes = {  }             # VM_name => { @celltype_name => ã»ã«ã®é
+å }
+  @@VM_struct_list = { }           # {name=>StructType}
+  @@VM_ptr_list = { }              # { VM_name => {name=> @@TYPE_MAP ã®å¯¾å¿ãããã®} }
+  @@TYPE_MAP = {           # type_str   class             GET_SET
+    :char_t            => [:char_t,    "Char",     :Char,  :INT   ],
+    :uchar_t           => [:uchar_t,   "UChar",    :Char,  :INT   ],
+    :schar_t           => [:schar_t,   "SChar",    :Char,  :INT   ],
+
+    :bool_t            => [:bool_t,    "Bool",     :Bool,  :BOOL  ],
+    :int8_t            => [:int8_t,    "Int8",     :Int,   :INT   ],
+    :int16_t           => [:int16_t,   "Int16",    :Int,   :INT   ],
+    :int32_t           => [:int32_t,   "Int32",    :Int,   :INT   ],
+    :int64_t           => [:int64_t,   "Int64",    :Int,   :INT   ],
+    :uint8_t           => [:uint8_t,   "UInt8",    :Int,   :INT   ],
+    :uint16_t          => [:uint16_t,  "UInt16",   :Int,   :INT   ],
+    :uint32_t          => [:uint32_t,  "UInt32",   :Int,   :INT   ],
+    :uint64_t          => [:uint64_t,  "UInt64",   :Int,   :INT   ],
+
+    :int               => [:int,       "Int",      :Int,  :INT   ], 
+    :char              => [:char,      "Char",     :Char, :INT   ],    # char ã¯ char_t ã¨ãã¦æ±ã
+    :short             => [:short,     "Short",    :Int,  :INT   ],
+    :long              => [:long,      "Long",     :Int,  :INT   ],
+
+    :"unsigned char"   => [:uchar_t,   "UChar",         :Char, :INT   ],
+    :"unsigned int"    => [:"unsigned int",   "UInt",   :Int,  :INT   ],
+    :"unsigned short"  => [:"unsigned short", "UShort", :Int,  :INT   ],
+    :"unsigned long"   => [:"unsigned long",  "ULong",  :Int,  :INT   ],
+    :"signed char"     => [:schar_t,   "SChar",    :Char,  :INT   ],
+    :"signed int"      => [:int,       "Int",      :Int,   :INT   ],
+    :"signed short"    => [:short,     "Short",    :Int,   :INT   ],
+    :"signed long"     => [:long,      "Long",     :Int,   :INT   ],
+
+    :float32_t         => [:float32_t, "Float32",  :Float, :FLOAT ],
+    :double64_t        => [:double64_t,"Double64", :Float, :FLOAT ],
+
+    :float             => [:float,     "Float32",  :Float, :FLOAT ],
+    :double            => [:double,    "Double64", :Float, :FLOAT ]
+  }
+
+  # included  or excluded functions
+
+  ### ã­ã¼ããããæç¹ã§å®è¡ããã ###
+
+  # -I ã« $(TECSPATH)/mruby ãè¿½å 
+  # TECSGEN::Makefile.add_obj "$(MRUBY_MAIN_OBJ)"
+  TECSGEN::Makefile.add_ldflag "-lmruby -L$(MRUBYPATH)/lib -lm"
+  TECSGEN::Makefile.add_search_path "$(MRUBYPATH)/include"
+  TECSGEN::Makefile.add_var "MRUBYPATH",      "..",  "CHANGE this to suitable path"
+  # TECSGEN::Makefile.add_var "MRUBY_MAIN_OBJ", "$(_TECS_OBJ_DIR)tecs_mruby.o", "CHANGE this if your have your main"
+
+
+  #=== ãã©ã°ã¤ã³ã¤ã³ã¹ã¿ã³ã¹ã®åæå
+  # æ»ãå¤ãå¼æ°ã®åãä½¿ç¨å¯è½ãªãã®ããã§ãã¯ãã
+  #
+  def initialize( signature, option )
+    super
+
+    if ! $no_banner
+      STDERR << "MrubyBridgePlugin: version 1.2.0 (Suitable for mruby ver 1.2.0. Has backward compatibility with ver 1.1.0)\n"
+    end
+
+    @b_ignoreUnsigned = false
+    @includes = []
+    @excludes = []
+    @struct_list = { }
+    @ptr_list = { }
+
+    @plugin_arg_check_proc_tab = MrubyBridgePluginArgProc
+    parse_plugin_arg
+
+    @celltype_name = :"t#{@signature.get_global_name}"
+    @init_celltype_name = :"#{@celltype_name}_Initializer"
+        # this variable is sometimes not used. rhs coded directry.
+    @class_name = :"T#{@signature.get_global_name}"
+
+    @func_head_array = []
+    if @includes.length > 0 && @excludes.length > 0 then
+      cdl_error( "MRB1011 both include && exclude are specified" )
+    end
+
+    if signature.get_function_head_array == nil then
+      return   # ä»¥åã«ææ³ã¨ã©ã¼çºç
+    end
+
+    signature.get_function_head_array.each{ |func_head|
+      if @includes.length > 0 then
+        if @includes.index func_head.get_name then
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} INCLUDED\n"
+          @func_head_array << func_head
+        else
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT included\n"
+        end
+      elsif @excludes.length > 0 then
+        if @excludes.index( func_head.get_name ) == nil then
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} NOT excluded\n"
+          @func_head_array << func_head
+        else
+          dbgPrint "MrubyBridgePlugin: #{func_head.get_name} EXCLUDED\n"
+        end
+      else
+        @func_head_array << func_head
+      end
+    }
+
+    if @func_head_array.length == 0 then
+      cdl_error( "MRB1012 '$1' no function remained by exclude", @signature.get_name )
+    end
+
+    check_name_and_return_type @func_head_array
+    check_parameter_type @func_head_array
+
+  end
+
+  #=== check function name & return type
+  def check_name_and_return_type func_head_array
+    b_init = false; b_init_cell = false
+    func_head_array.each{ |func_head|
+      if( func_head.get_name == :initialize )then
+        cdl_warning( "MRW2001 initialize: internally defined. change to initialize_cell in ruby" )
+        b_init = true
+      elsif( func_head.get_name == :initialize_cell )then
+        b_init_cell = true
+      end
+      rtype = func_head.get_return_type.get_original_type
+      case rtype
+      when BoolType, IntType, FloatType, VoidType
+      else
+        cdl_error( "MRB1001 cannot return type $1", rtype.get_type_str )
+      end
+    }
+    if( b_init && b_init_cell )then
+      cdl_warning( "MRB1002 initialize: internally defined. change to initialize_cell in ruby" )
+    end
+  end
+
+  #=== check paramter type
+  def check_parameter_type func_head_array
+    # check type of parameters
+    func_head_array.each{ |fh|
+      fh.get_paramlist.get_items.each{ |param_decl|
+        case param_decl.get_direction
+        when :SEND, :RECEIVE
+          cdl_error( "MRB1003 $1: $2 parameter cannot be used in mruby Bridge",  param_decl.get_name, param_decl.get_direction.to_s.downcase )
+        end
+        type = param_decl.get_type
+        type_org = type.get_original_type
+        type_str = type.get_type_str + type.get_type_str_post
+
+        b_ng = false
+        case type_org
+        when IntType
+          case  type_org.get_bit_size
+          when 8, 16, 32, 64
+          when -1, -2, -3, -4, -11
+          else
+            b_ng = true
+          end
+        when BoolType
+        when FloatType
+        when PtrType
+          ttype_org = type_org.get_type       # ãã¤ã³ã¿ã®æãã¦ããå
+ã®å
+          ttype = ttype_org.get_original_type # ä¸è¨ã® typedef ããã¦ããå ´åãå
+ã®å
+          register_ptr_type ttype_org
+
+          if( type_org.get_string.to_s == "-1" ) then
+            case param_decl.get_direction
+            when :OUT, :INOUT
+              cdl_error( "MRB9999 string specifier without length cannot be used for out & inout parameter")
+            end
+          end
+
+          case ttype
+          when IntType
+            bit_size = ttype.get_bit_size
+            # if  bit_size < 0 && bit_size != -1 then
+            #   b_ng = true
+            # end
+          when FloatType
+          when BoolType
+          when StructType
+            if( type_org.get_size || type_org.get_string || type_org.get_count ) then
+              cdl_error( "MRB1004 $1: size_is, count_is, string cannot be specified for struct pointer", param_decl.get_name )
+            end
+            check_struct_member ttype_org
+          else
+            b_ng = true
+          end
+        when StructType
+          check_struct_member type_org
+        else  # ArrayType, FuncType, EnumType, VoidType
+          b_ng = true
+        end
+        if b_ng then
+          cdl_error( "MRB1005 $1: type $2 cannot be used in mruby Bridge", param_decl.get_name, type_str )
+        end
+      }
+    }
+  end
+
+  #=== æ§é ä½ã®ã¡ã³ãã¼ã®åã®ãã§ãã¯
+  def check_struct_member struct_type
+    #p "tag name:#{struct_type.get_name}"
+    # sttype = Namespace.find_tag( struct_type.get_name )
+    sttype = struct_type.get_original_type
+    if sttype.get_name == nil then
+      cdl_error( "MRB10007 tagless-struct cannot be handled")
+    end
+    sttype.get_members_decl.get_items.each { |d|
+      t = d.get_type.get_original_type
+      case t
+      when IntType, FloatType, BoolType
+      else
+        cdl_error( "MRB1006 $1: type $2 not allowed for struct member", d.get_name, d.get_type.get_type_str + d.get_type.get_type_str_post )
+      end
+    }
+    st_name = :"t{}"
+    if @struct_list[ sttype.get_name ] == nil then
+      # print_msg "  MrubyBridgePlugin: [struct]   #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
+      print "  MrubyBridgePlugin: [struct]   #{struct_type.get_type_str} => class TECS::Struct#{sttype.get_name}\n"
+      @struct_list[ sttype.get_name ] = sttype
+    end
+  end
+
+  def register_ptr_type ttype
+    t_org = ttype.get_original_type
+    tment = get_type_map_ent t_org
+    if tment == nil then
+      return
+      cdl_error( "MRB1008 unknown pointer type '$1'", ttype.get_type_str )
+    end
+    ptr_celltype_name = :"t#{tment[1]}Pointer"
+    if @@ptr_list[ ptr_celltype_name ] == nil then
+      # print_msg "  MrubyBridgePlugin: [pointer]  #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
+      print "  MrubyBridgePlugin: [pointer]  #{ttype.get_type_str}* => class TECS::#{tment[1]}Pointer\n"
+      @@ptr_list[ ptr_celltype_name ] = tment
+    end
+    if @ptr_list[ ptr_celltype_name ] == nil then
+      @ptr_list[ ptr_celltype_name ] = tment
+    end
+  end
+
+  def get_type_map_ent ttype
+    # structure type is registerd in check_struct_member
+    if ttype.kind_of? StructType
+      return
+    end
+    tstr = ttype.get_type_str.sub( /const /, "" )    # const ã¯ç¡è¦
+    tstr = tstr.sub( /volatile /, "" )               # volatile ãç¡è¦
+    if @b_ignoreUnsigned then
+      tstr = tstr.sub( /unsigned /, "" )             # volatile ãç¡è¦
+      tstr = tstr.sub( /uint/, "int" )               # volatile ãç¡è¦
+      tstr = tstr.sub( /[cs]char/, "char" )          # volatile ãç¡è¦
+    end
+    return @@TYPE_MAP[ tstr.to_sym ]
+  end
+
+  #===  CDL ãã¡ã¤ã«ã®çæ
+  #      typedef, signature, celltype, cell ã³ã¼ããçæ
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_cdl_file(file)
+
+    # ããªãã¸ã»ã«ã¿ã¤ãã®çæ
+    if @@celltypes[ @celltype_name ] == nil then
+      @@celltypes[ @celltype_name ] = [ self ]
+      @@init_celltypes[ @init_celltype_name ] = true
+      print_msg <<EOT
+  MrubyBridgePlugin: [signature] #{@signature.get_namespace_path} => [celltype] nMruby::#{@celltype_name} => [class] TECS::#{@class_name}
+EOT
+
+      file.print <<EOT
+import( <mruby.cdl> );
+
+/****  Ruby => TECS Bridge Celltype (MBP500) ****/
+namespace nMruby{
+    // bridge celltype
+    [idx_is_id,active]   // not actually active, to avoid warning W1002, W1007
+    celltype #{@celltype_name} {
+        call #{@signature.get_namespace_path.to_s} cTECS;
+        attr {
+            [omit]
+            char_t *VMname = "VM";
+        };
+    };
+    // bridge initializer celltype
+    celltype #{@init_celltype_name} {
+        entry sInitializeTECSBridge eInitialize;
+    };
+};
+EOT
+
+      # æ§é ä½ã»ã«ã¿ã¤ãã®çæ
+      @struct_list.each{ |name, sttype|
+        if @@struct_list[ name ] == nil then
+          file.print <<EOT
+namespace nMruby{
+    [singleton]
+    celltype #{name} {
+        entry sInitializeTECSBridge eInitialize;
+    };
+};
+EOT
+          @@struct_list[ name ] = sttype
+        end
+      }
+
+    else
+      cdl_warning( "MRBW001 MrubyBridgePlugin: signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
+      @@celltypes[ @celltype_name ] << self
+    end
+  end
+
+  #=== gen_cdl_file ã§å®ç¾©ããã»ã«ã¿ã¤ãã« æ°ããã»ã«ãå®ç¾©ããã
+  # cell ã®ã»ã«ã¿ã¤ãã®ååã¯ @celltype_name
+  def new_cell cell
+    if cell.get_celltype.get_name != @celltype_name then
+      return
+    end
+
+    join = cell.get_join_list.get_item :VMname
+    if join then
+      vm_name = CDLString.remove_dquote(join.get_rhs.to_s).to_sym
+    else
+      vm_name = :"VM"
+    end
+
+    if @@VM_list[ vm_name ] == nil then
+      @@VM_list[ vm_name ] = true
+
+      initializer_celltype_cdl = "#{$gen}/#{cell.get_name}Initializer.cdl"
+      file = CFile.open( initializer_celltype_cdl, "w" )
+
+      # TECS åæåã»ã«(ãã­ãã¿ã¤ãå®£è¨)
+      print_msg "  MrubyBridgePlugin: join your VM's cInitialize to #{vm_name}_TECSInitializer.eInitialize\n"
+
+      file.print <<EOT
+
+  // prototype of TECSInitializer (MBP510)
+  cell nMruby::tTECSInitializer #{vm_name}_TECSInitializer;
+EOT
+      file.close
+
+      Generator.parse( initializer_celltype_cdl, self )
+    end
+
+    if @@VM_celltypes[ vm_name ] then
+      vma = @@VM_celltypes[ vm_name ]
+
+      if vma[ @celltype_name ] then
+        vma[ @celltype_name ] << cell
+      else
+        vma[ @celltype_name ] = [cell]
+        @@VM_celltypes[ vm_name ] = vma
+      end
+    else
+      vma = { }
+      vma[ @celltype_name ] = [cell]
+      @@VM_celltypes[ vm_name ] = vma
+    end
+
+    @struct_list.each{ |stname, sttype|
+      if @@VM_struct_list[ vm_name ] then
+        @@VM_struct_list[ vm_name ][ sttype.get_name ] = sttype
+      else
+        @@VM_struct_list[ vm_name ] = { sttype.get_name => sttype }
+      end
+    }
+    @ptr_list.each{ |ptr_celltype_name, tment|
+      if @@VM_ptr_list[ vm_name ] then
+        @@VM_ptr_list[ vm_name ][ ptr_celltype_name ] = tment
+      else
+        @@VM_ptr_list[ vm_name ] = { ptr_celltype_name => tment }
+      end
+    }
+
+  end
+
+  #=== ãã©ã°ã¤ã³ã CDL ã® POST ã³ã¼ããçæ
+  # tmp_plugin_post_code.cdl ã¸ã®åºå
+  def self.gen_post_code file
+
+#     file.print <<EOT
+# namespace nMruby {
+# EOT
+# 
+#     @@ptr_list.each{ |name,tment|
+#       file.print <<EOT
+# 
+#     // MBP600
+#     [singleton]
+#     celltype #{name} {
+#         entry  sInitializeTECSBridge eInitialize;
+#     };
+# EOT
+#     }
+# 
+#     file.print <<EOT
+# };
+# EOT
+
+# gen_post_code ã§çæãã celltype ã¯ gen_ep_func ãå¼ã³åºãããªã #847
+#    @@struct_list.each{ |name,sttype|
+#      file.print <<EOT
+#
+#    [singleton]
+#    celltype #{name} {
+#        entry  sInitializeTECSBridge eInitialize;
+#    };
+#EOT
+#    }
+
+    file.print "  // MBP601\n"
+    @@VM_celltypes.each{ |vm_name, instance_list|
+      instance_list.each { |celltype_name, array|
+        cell = array[0]
+	if cell.get_celltype then
+	  ct_name = cell.get_celltype.get_name
+        file.print <<EOT
+  cell nMruby::#{ct_name}_Initializer #{vm_name}_#{ct_name}_Initializer{ };
+EOT
+        end
+      }
+    }
+
+    file.print "  // MBP602\n"
+    @@ptr_list.each{ |name,tment|
+      file.print <<EOT
+  cell nMruby::#{name} C#{name} { };
+EOT
+    }
+
+    file.print "  // MBP603\n"
+    @@struct_list.each{ |name,sttype|
+      file.print <<EOT
+  cell nMruby::#{name} C#{name} { };
+EOT
+    }
+
+    if @@VM_celltypes == nil
+      raise "are0"
+    end
+    @@VM_celltypes.each{ |vm_name, instance_list|
+      file.print "  /* === VM #{vm_name} === (MBP610) */\n"
+      init_cell_name = "#{vm_name}_TECSInitializer"
+
+      file.print "  cell nMruby::tTECSInitializer #{init_cell_name} {\n"
+
+      instance_list.each { |celltype_name, array|
+        array.each{ |cell|
+          ct_name = cell.get_celltype.get_name
+          file.print "    cInitialize[] = #{vm_name}_#{ct_name}_Initializer.eInitialize;\n"
+        }
+      }
+      if @@VM_ptr_list[vm_name] then
+        @@VM_ptr_list[vm_name].each{ |name, tment|
+          file.print "    cInitialize[] = C#{name}.eInitialize;\n"
+        }
+      end
+      if @@VM_struct_list[vm_name] then
+        @@VM_struct_list[vm_name].each{ |name, sttype|
+          file.print "    cInitialize[] = C#{name}.eInitialize;\n"
+        }
+      end
+      file.print "  };"
+    }
+    
+  end
+
+  ####### ä»¥ä¸ã³ã¼ãçææ®µé ######
+
+  #===  åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é ­é¨ã¨æ«å°¾ã¯å¥éåºåï¼
+  #ct_name:: Symbol    (ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ãã
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    if @@celltypes[ ct_name ] then
+      gen_ep_func_body_bridge( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    elsif @@init_celltypes[ ct_name ] then
+      gen_ep_func_body_bridge_init( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    elsif @@ptr_list[ ct_name ] then
+      gen_ep_func_body_ptr( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    elsif @@struct_list[ ct_name ] then
+      gen_ep_func_body_struct( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    else
+      raise "Unknown #{ct_name}"
+    end
+  end
+
+  def gen_ep_func_body_bridge( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    raise "unexpected "
+  end
+
+  def gen_ep_func_body_bridge_init( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    file.print <<EOT
+    CELLCB *p_cellcb = GET_CELLCB( idx );  /* no error check */     /* MBP700 */
+    struct RClass	*rc;
+
+    rc = mrb_define_class_under( mrb, TECS, \"#{@class_name}\", mrb->object_class );
+    mrb_define_method( mrb, rc, "initialize", MrubyBridge_#{@celltype_name}_initialize, MRB_ARGS_REQ(1) );
+    MRB_SET_INSTANCE_TT(rc, MRB_TT_DATA);
+EOT
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type = f.get_return_type
+      n_param = 0
+      f.get_paramlist.get_items.each{ |param|
+        case param.get_direction
+        when :IN, :INOUT, :OUT
+          n_param += 1
+        when :SEND, :RECEIVE
+          raise "send, receive"
+        end
+      }
+      if n_param > 0 then
+        p_str = "MRB_ARGS_REQ( #{n_param} )"
+      else
+        p_str = "MRB_ARGS_NONE()"
+      end
+      file.print <<EOT
+	mrb_define_method( mrb, rc, "#{func_name}", MrubyBridge_#{@celltype_name}_#{func_name}, #{p_str} );
+EOT
+    }
+  end
+
+  def gen_ep_func_body_ptr( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    
+    t = @@ptr_list[ct_name]
+    type = t[1]
+    file.print <<EOT
+	struct RClass *a;                                /* MBP710 */
+
+    a = mrb_define_class_under(mrb, TECS, "#{type}Pointer", mrb->object_class);
+    MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
+
+    mrb_define_method(mrb, a, "initialize",      #{type}Pointer_initialize,   MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "[]",              #{type}Pointer_aget,         MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "value",           #{type}Pointer_get_val,      MRB_ARGS_NONE());
+    mrb_define_method(mrb, a, "[]=",             #{type}Pointer_aset,         MRB_ARGS_REQ(2));
+    mrb_define_method(mrb, a, "value=",          #{type}Pointer_set_val,      MRB_ARGS_REQ(1));
+    mrb_define_method(mrb, a, "size",            #{type}Pointer_size,         MRB_ARGS_NONE());
+    mrb_define_method(mrb, a, "length",          #{type}Pointer_size,         MRB_ARGS_NONE());
+EOT
+
+    if t[2] == :Char then
+      file.print <<EOT
+	mrb_define_method(mrb, a, "to_s",            CharPointer_to_s, MRB_ARGS_NONE());
+	mrb_define_method(mrb, a, "from_s",          CharPointer_from_s, MRB_ARGS_REQ(1));
+EOT
+    end
+  end
+
+  def gen_ep_func_body_struct( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    tag = ct_name
+    structType = @@struct_list[ tag ]
+    file.print  <<EOT
+	struct RClass *a;                                /* MBP720 */
+
+	a = mrb_define_class_under(mrb, TECS, "Struct#{tag}", mrb->object_class);
+	MRB_SET_INSTANCE_TT(a, MRB_TT_DATA);
+
+	mrb_define_method(mrb, a, "initialize", Struct_#{tag}_initialize, MRB_ARGS_NONE());
+EOT
+
+      structType.get_members_decl.get_items.each{ |d|
+        file.print "  STRUCT_INIT_MEMBER( #{tag}, #{d.get_name} )\n"
+      }
+  end
+
+  #===  åãå£é¢æ°ã® preamble (Cè¨èª)ãçæãã
+  #     å¿
+è¦ãªã preamble é¨ã«åºåãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  def gen_preamble( file, b_singleton, ct_name, global_ct_name )
+    if @@celltypes[ ct_name ] then
+      gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
+    elsif @@init_celltypes[ ct_name ] then
+      gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+      gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
+    elsif @@ptr_list[ ct_name ] then
+      gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
+    elsif @@struct_list[ ct_name ] then
+      gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
+    else
+      raise "Unknown #{ct_name}"
+    end
+  end
+
+  def gen_preamble_mruby( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+/* MBP: MrubyBridgePlugin: MBP000 */
+#include "mruby.h"
+#include "mruby/class.h"
+#include "mruby/data.h"
+#include "mruby/string.h"
+#include "TECSPointer.h"
+#include "TECSStruct.h"
+
+#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#define DLLEXPORT __declspec(dllexport)
+#else
+#define DLLEXPORT
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+EOT
+  end
+
+  def gen_preamble_instance( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+
+/* RData MBP001 */
+static void 
+#{@celltype_name}_free( mrb_state *mrb, void *p )
+{
+	if( p )
+		(void)mrb_free( mrb, p );
+}
+
+/* RData MBP002 */
+struct mrb_data_type data_type_#{@celltype_name} =
+{
+	"#{@celltype_name}",
+	#{@celltype_name}_free
+};
+
+/* RData MBP003 */
+struct tecs_#{@celltype_name} {
+    CELLCB  *cbp;
+};
+
+/* name_to_cbp MBP010 */
+const struct name_to_cbp_#{@celltype_name} {
+    char   *name;    /* Cell Name */
+    CELLCB *cbp;
+} Name_to_cbp_#{@celltype_name}[] = {
+EOT
+
+    # mikan namespace
+    nsp = NamespacePath.new( :nMruby, true )
+    nsp.append! ct_name
+    ct = Namespace.find nsp
+
+    ct.get_cell_list.each{ |cell|
+      if cell.is_generate? then
+        name_array = ct.get_name_array( cell )
+        file.print "\t{ \"#{cell.get_name}\", #{name_array[8]} },\n"
+      end
+    }
+
+    file.print <<EOT
+\t{ 0, 0 },
+};
+
+EOT
+
+  end
+
+  def gen_preamble_ptr( file, b_singleton, ct_name, global_ct_name )
+    tment = @@ptr_list[ ct_name ]
+    file.print <<EOT
+
+GET_SET_#{tment[3]}( #{tment[1]}, #{tment[0]} )
+POINTER_CLASS( #{tment[1]}, #{tment[0]} )
+EOT
+  end
+
+  def gen_preamble_struct( file, b_singleton, ct_name, global_ct_name )
+    tag = ct_name
+    structType = @@struct_list[ tag ]
+    file.print <<EOT
+/* struct #{tag} */
+STRUCT_CLASS( #{tag} )
+EOT
+
+    structType.get_members_decl.get_items.each{ |d|
+      type = d.get_type.get_original_type
+      case type
+      when IntType, CIntType
+        bit_size = type.get_bit_size
+        case bit_size
+        when -11, -1
+          tType = "Char"
+          ttype = "char"
+        when -2
+          tType = "Short"
+          ttype = "short"
+        when -3
+          tType = "Int"
+          ttype = "int"
+        when -4
+          tType = "Long"
+          ttype = "long"
+        when -5
+          tType = "IntPtr"
+          ttype = "intptr"
+        when 8, 16, 32, 64
+          tType = "Int#{bit_size}"
+          ttype = "int#{bit_size}"
+        else
+            raise "cannot handle bit_size #{bit_size}"
+        end
+        file.print "MEMBER_GET_SET_INT( #{tag}, #{d.get_name}, #{tType}, #{ttype} )\n"
+      when FloatType, CFloatType
+        file.print "MEMBER_GET_SET_FLOAT( #{tag}, #{d.get_name} )\n"
+      else
+        raise "cannot handle type"
+      end
+    }
+
+  end
+
+  def gen_preamble_instance_proto( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+//  Prototype MBP400
+mrb_value  MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self);
+EOT
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type  = f.get_return_type
+      ret_type0 = f.get_return_type.get_original_type
+      b_void    = ret_type0.is_void?
+      plist     = f.get_paramlist.get_items
+
+      file.print <<EOT
+mrb_value  MrubyBridge_#{@celltype_name}_#{func_name}( mrb_state *mrb, mrb_value self );
+EOT
+    }
+  end
+
+  def gen_preamble_instance_initialize( file, b_singleton, ct_name, global_ct_name )
+    file.print <<EOT
+
+/* MBP100 */
+mrb_value
+MrubyBridge_#{@celltype_name}_initialize( mrb_state *mrb, mrb_value self)
+{
+	mrb_value	name;
+	struct tecs_#{@celltype_name} *tecs_cb;
+	const struct name_to_cbp_#{@celltype_name} *ntc;
+
+	/* set DATA_TYPE earlier to avoid SEGV */
+	DATA_TYPE( self ) = &data_type_#{@celltype_name};
+
+	mrb_get_args(mrb, "o", &name );
+	if( mrb_type( name ) != MRB_TT_STRING ){
+		mrb_raise(mrb, E_NAME_ERROR, "cell name not string");
+	}
+	for( ntc = &Name_to_cbp_#{@celltype_name}[0]; ntc->name != NULL; ntc++ ){
+		if( strcmp( ntc->name, RSTRING_PTR( name ) ) == 0 )
+			break;
+	}
+	if( ntc->name == 0 ){
+		mrb_raise(mrb, E_ARGUMENT_ERROR, "cell not found");
+	}
+	tecs_cb = (struct tecs_#{@celltype_name} *)mrb_malloc(mrb, sizeof(struct tecs_#{@celltype_name}) );
+	tecs_cb->cbp = ntc->cbp;
+	DATA_PTR( self ) = (void *)tecs_cb;
+
+	return self;
+}
+EOT
+  end
+
+  def gen_preamble_bridge_func( file, b_singleton, ct_name, global_ct_name )
+
+    @func_head_array.each{ |f|
+      if ! f.is_function? then
+        next
+      end
+      if f.get_name != :initialize then
+        func_name = f.get_name
+      else
+        func_name = :initialize_cell
+      end
+
+      ret_type  = f.get_return_type
+      ret_type0 = f.get_return_type.get_original_type
+      b_void    = ret_type0.is_void?
+      plist     = f.get_paramlist.get_items
+
+      file.print <<EOT
+
+/* bridge function (MBP101) */
+mrb_value
+MrubyBridge_#{ct_name}_#{func_name}( mrb_state *mrb, mrb_value self )
+{
+	/* cellcbp (MBP105) */
+	CELLCB	*p_cellcb = ((struct tecs_#{@celltype_name} *)DATA_PTR(self))->cbp;
+EOT
+      
+      file.print "	/* variables for return & parameter (MBP110) */\n"
+      if ! b_void then
+        file.print "	", ret_type.get_type_str, "\tret_val", ret_type.get_type_str_post, ";\n"
+      end
+      arg_str = ""
+      n_param  = 0
+      n_scalar = 0
+      n_ptr    = 0
+      n_struct = 0
+      plist.each{ |param|
+        case param.get_direction
+        when :IN, :INOUT, :OUT
+          type = param.get_type.get_original_type
+          case type
+          when IntType
+            file.print "	mrb_int	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "i"
+            n_param += 1
+            n_scalar += 1
+          when FloatType
+            file.print "	mrb_float	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "f"
+            n_param += 1
+            n_scalar += 1
+          when BoolType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_scalar += 1
+          when PtrType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_ptr += 1
+          when StructType
+            file.print "	mrb_value	mrb_", param.get_name, ";\n"
+            file.print "	#{param.get_type.get_type_str}	*#{param.get_name}#{param.get_type.get_type_str_post};\n"
+            arg_str += "o"
+            n_param += 1
+            n_struct += 1
+          else
+            raise "Unkown type"
+          end
+        end
+      }
+
+      if n_param > 0 then
+        file.print "	/* retrieve arguments (MBP111) */\n"
+        file.print "	mrb_get_args(mrb, \"#{arg_str}\""
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+              file.print ", &mrb_", param.get_name
+            when FloatType
+              file.print ", &mrb_", param.get_name
+            when BoolType
+              file.print ", &mrb_", param.get_name
+            when PtrType
+              file.print ", &mrb_", param.get_name
+            when StructType
+              file.print ", &mrb_", param.get_name
+            else
+              raise "Unkown type"
+            end
+          end
+        }
+        file.print " );\n"
+
+        if n_scalar > 0 || n_struct > 0 then
+          file.print "	/* convert mrb to C (MBP112) */\n"
+        end
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+              ttype = type.get_original_type
+              tment = get_type_map_ent ttype
+              file.print "	VALCHECK_#{tment[1]}( mrb, mrb_#{param.get_name} );\n"
+              file.print "	#{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
+            when FloatType
+              file.print "	#{param.get_name} = (#{param.get_type.get_type_str})mrb_#{param.get_name};\n"
+            when BoolType
+              file.print "	#{param.get_name} = mrb_test( mrb_#{param.get_name} );\n"
+            when PtrType
+              ttype = type.get_type.get_original_type
+              case ttype
+              when StructType
+                file.print "	CHECK_STRUCT( #{ttype.get_name}, mrb_#{param.get_name} );\n"
+                file.print "	#{param.get_name} = (struct #{ttype.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
+              when IntType
+              when FloatType
+              when BoolType
+              else
+                raise "cannot handle type"
+              end
+            when StructType
+              file.print "	CHECK_STRUCT( #{type.get_name}, mrb_#{param.get_name} );\n"
+              file.print "	#{param.get_name} = (struct #{type.get_name}*)DATA_PTR(mrb_#{param.get_name});\n"
+            else
+              raise( "canot treat class" )
+            end
+          end
+        }
+
+        if n_ptr > 0 then
+          file.print "	/* convert mrb to C for pointer types (MBP113) */\n"
+        end
+        plist.each{ |param|
+          case param.get_direction
+          when :IN, :INOUT, :OUT
+            type = param.get_type.get_original_type
+            case type
+            when IntType
+            when FloatType
+            when BoolType
+            when PtrType
+              case type.get_type.get_original_type
+              when StructType
+              when IntType
+                ptrMrb2C file, type, param
+              when FloatType
+                ptrMrb2C file, type, param
+              when BoolType
+                ptrMrb2C file, type, param
+              else
+                raise "cannot handle type"
+              end
+            when StructType
+            else
+              raise( "canot treat class" )
+            end
+          end
+        }
+
+      end
+
+      file.print "	/* calling target (MBP120) */\n"
+      if ! b_void then
+        file.print "	ret_val = "
+      else
+        file.print "	"
+      end
+      delim = ""
+      file.print "cTECS_", f.get_name, "( "
+      plist.each{ |param|
+        if param.get_type.get_original_type.kind_of? StructType then
+          aster = "*"
+        else
+          aster = ""
+        end
+        file.print delim, aster, param.get_name
+        delim = ", "
+      }
+      file.print " );\n"
+      
+      file.print "	/* return (MBP130) */\n"
+      case ret_type0
+      when BoolType
+        file.print "	return ret_val ? mrb_true_value() : mrb_false_value();\n"
+      when IntType
+        file.print "	return mrb_fixnum_value( ret_val );\n"
+      when FloatType
+        file.print "	return mrb_float_value( mrb, ret_val );\n"
+      when VoidType
+        file.print "	return  mrb_nil_value();\n"
+      else
+        raise "unknown type"
+      end
+
+      file.print "}\n"
+    }
+  end
+
+  def ptrMrb2C file, type, param
+    ttype = type.get_type.get_original_type
+    tment = get_type_map_ent ttype
+    tstr = tment[1]
+=begin
+    case ttype
+    when IntType
+      bit_size = ttype.get_bit_size
+      case bit_size
+      when -1, -11
+        tstr = "Char"
+      when 8, 16, 32, 64
+        tstr = "Int#{bit_size}"
+      when -2
+        tstr = "Short"
+      when -3
+        tstr = "Int"
+      when -4
+        tstr = "Long"
+      when -5
+        tstr = "IntPtr"
+      else
+        raise "not handle type"
+      end
+    when FloatType
+      if ttype.get_bit_size == 32 then
+        tstr = "Float32"
+      else
+        tstr = "Double64"
+      end
+    when BoolType
+      tstr = "Bool"
+    when StructType
+      raise "not handle type 2 #{ttype}"
+    else
+      raise "not handle type 2 #{ttype}"
+    end
+=end
+    if( param.get_size ) then
+      sz_str = param.get_size.to_s
+    elsif param.get_string then      # mikan ã¨ãããã size_is ã¨ string ã®åææå® (äºéãã¤ã³ã¿) ã¯ãªã
+      sz_str = param.get_string.to_s
+    else
+      sz_str = "1"
+    end
+    # unsigned åã®å ´åã«ã¯ cast ãå¿
+è¦
+    if ttype.get_original_type.get_type_str != param.get_type.get_type.get_type_str then
+      cast_str = "(#{param.get_type.get_type_str})"
+    else
+      cast_str = ""
+    end
+
+    modify = ""
+    case param.get_direction
+    when :OUT, :INOUT
+      case tstr
+      when "Char", "SChar", "UChar"
+        modify = "Mod"
+      end
+    end
+    if param.is_nullable? then
+      nullable = "Nullable"
+    else
+      nullable = ""
+    end
+
+    # file.print "	CHECK_POINTER( #{tstr}, mrb_#{param.get_name}, #{sz_str} );\n"
+    # file.print "	#{param.get_name} = #{cast_str}((struct #{tstr}PointerBody*)(DATA_PTR(mrb_#{param.get_name})))->buf;\n"
+    file.print "	#{param.get_name} = CheckAndGet#{tstr}Pointer#{modify}#{nullable}( mrb, mrb_#{param.get_name}, #{sz_str} );\n"
+  end
+
+  def get_celltype_name
+    @celltype_name
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° ignoreUnsigned
+  def set_ignoreUnsigned rhs
+    if rhs == "true" || rhs == nil then
+      @b_ignoreUnsigned = true
+    end
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° include
+  def set_include rhs
+    funcs = rhs.split ','
+    funcs.each{ |rhs_func|
+      found = false
+      rhs_func.gsub!( /\s/, "" )
+      @signature.get_function_head_array.each{ |a|
+        if rhs_func.to_sym == a.get_name then
+          found = true
+        end
+      }
+      if found == false then
+        cdl_error( "MRB1009 include function '$1' not found in signagture '$2'", rhs, @signature.get_name )
+      else
+        @includes << rhs_func.to_sym
+      end
+    }
+  end
+  #=== ãã©ã°ã¤ã³å¼æ° exclude
+  def set_exclude rhs
+    funcs = rhs.split ','
+    funcs.each{ |rhs_func|
+      found = false
+      rhs_func.gsub!( /\s/, "" )
+      @signature.get_function_head_array.each{ |a|
+        if rhs_func.to_sym == a.get_name then
+          found = true
+        end
+      }
+      if found == false then
+        cdl_error( "MRB1010 exclude function '$1' not found in signagture '$2", rhs, @signature.get_name )
+      else
+        @excludes << rhs_func.to_sym
+      end
+    }
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/NotifierPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/NotifierPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/NotifierPlugin.rb	(revision 317)
@@ -0,0 +1,1104 @@
+# -*- coding: utf-8 -*-
+#
+#  Copyright (C) 2015 by Ushio Laboratory
+#              Graduate School of Engineering Science, Osaka Univ., JAPAN
+#  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+#
+
+NotifierPluginArgProc = {
+	"factory" => Proc.new { |obj, rhs| obj.set_factory(rhs) },
+	"output_file" => Proc.new { |obj, rhs| obj.set_factory_output_file(rhs) }
+}
+
+class NotifierPlugin < CelltypePlugin
+
+	# ---------- ã¢ããã¿é¢æ°ã®çæ -------------
+	#
+	# siHandlerBodyã®åãå£é¢æ°ã¯ï¼ã¿ã¤ã ã¤ãã³ãéç¥ã®éç¥å
+ã¨ãã¦ç´æ¥æå®ãã
+	# ãã¨ã¯ã§ããªãï¼ã·ã°ããã£ãä¸è´ãã¦ããªããã¨ãçç±ã§ããï¼ãã®ããï¼ã¢ã
+	# ãã¿ã¨ãã¦åä½ããé¢æ°ãçæãï¼ã«ã¼ãã«ããã®å¼åºããTECSã®å¼åºãã«å¤æã§
+	# ããããã«ããå¿
+è¦ãããï¼
+	#
+	# åºæ¬çã«ã¯ï¼åãå£æ¯ã«ã¢ããã¿é¢æ°ãçæããã°ååã§ããï¼ãããï¼ããã§ã¯
+	# ã¡ã¢ãªæ¶è²»éãä¸å¿
+è¦ã«å¢å ãã¦ãã¾ãï¼ããã§ï¼éç¥å
+é¢æ°ã«intptr_tåã®å¼æ°
+	# ãæ¸¡ãããã¨ã«çç®ãï¼é¢æ°ã®"ä¸è¬å"ãå³ãï¼ããªãã¡åãå£ã®ããå±æ§(ãã
+	# ã§ã¯ï¼çµåå
+ã®ã»ã«ï¼æ·»å­ãªã©ãæã)ãï¼ã¢ããã¿é¢æ°ã®å¼æ°ã¨ãã¦åãåãã
+	# ããã«ãï¼1åã®ã¢ããã¿é¢æ°ã2åä»¥ä¸ã®çµåã«å¯¾ãç¨ãããã¨ãã§ããããã«
+	# ããï¼
+	#
+	# ã¢ããã¿é¢æ°ã®å±æ§ã«ã¤ãã¦æ´çããã¨ï¼
+	#  - åãå£é¢æ° - ä¸è¬åãè¡ãã¨ï¼å®è¡æã³ã¹ããå¤§ããå¢å¤§ãã¦ãã¾ããã¨ã
+	#    ç¢ºèªããã¦ããï¼ãã®ããï¼ä¸è¬åã¯è¡ããªãï¼EntryPropertyã«ãå«ããªãï¼
+	#  - ã»ã«ã¤ã³ããã¯ã¹ - CELLIDXåã§ï¼åã®è¦å®ã¯ãªããï¼"ãã¤ã³ã¿å¤ã§ãã£ãã
+	#    æ´æ°å¤ã§ãã£ããããã" (TECS 5.3.6) ããï¼ã¤ã³ããã¯ã¹ããã¤ã³ã¿ãã
+	#    ãã¨ãåããï¼ã¤ã³ããã¯ã¹ã ã¨ããã¨ï¼ãã®å¤ã¯ã»ã«CBã®ã¢ãã¬ãã·ã³ã°ã«
+	#    ä½¿ç¨ãããã®ã§ï¼intptr_tã«åã¾ãç­ã§ããï¼ãã¤ã³ã¿ã®å ´åï¼å½ç¶intptr_t
+	#    ã«åã¾ãï¼
+	#  - åãå£é
+åã®æ·»å­ - int_tï¼åæ§ã«intptr_tã«åã¾ãç­ã§ããï¼
+	# ãããã®ãã¡ï¼ã»ã«ã¤ã³ããã¯ã¹ã¨åãå£é
+åã®æ·»å­ã¯ãã©ã¡ã¼ã¿ã«å«ãããã¨ã
+	# ã§ãããã§ãããï¼ä¸¡æ¹ã¯ç¡çã§ããï¼
+	# ä¸¡æ¹ãæ ¼ç´ããé
+åãçæãï¼ãã®é
+åã®è¦ç´ ã¸ã®ãã¤ã³ã¿ãæ¸¡ãããã«ããã¨ã
+	# ãé¸æè¢ãå¯è½ã§ãããï¼å®è¡éåº¦ãåªå
+ããããã«ï¼ãã®æ¹æ³ã¯ã¨ããªãã£ãï¼
+	#
+	# ãã®ããï¼ä¸è¬åã¯ä»¥ä¸ã®ãã¿ã¼ã³ã«åé¡ãã¦è¡ãï¼
+	#
+	# 1. ã»ã«ã¤ã³ããã¯ã¹ã®ã¿ä¸è¬åï¼ã»ã«ã¤ã³ããã¯ã¹ã®ãã¿ã¼ã³æ°ãåãå£é
+åã®
+	#    æ·»å­ã®ãã¿ã¼ã³æ°ããå¤ããï¼ãããã¯åãå£ãé
+åã§ãªãå ´åã«è¡ãããï¼
+	# 2. åãå£é
+åã®æ·»å­ã®ã¿ä¸è¬åï¼ãã®å ´åï¼ã»ã«ãã¨ã«ç°ãªãé¢æ°ãç¨ããï¼
+	#
+	# ããããï¼ååãå£é¢æ°ã«ã¤ãã¦ï¼ã¢ããã¿é¢æ°ã®çæåæ°ã¯ï¼
+	#         O(min{ã»ã«ã¤ã³ããã¯ã¹ã®ãã¿ã¼ã³æ°, æ·»å­ã®ãã¿ã¼ã³æ°})
+	# ã¨ãªãï¼
+	#
+	# ãã©ã°ã¤ã³ã§ã®å¦çãã¯ã³ãã¹ã§è¡ãããã«ï¼tecsgen.cfgã§ã¯ã¢ããã¿é¢æ°ãç´
+	# æ¥æå®ããã®ã§ã¯ãªãï¼ä»£ããã«ã¢ããã¿é¢æ°ãè¡¨ããã¯ã­ãä½¿ç¨ããï¼ãã®
+	# ãã¯ã­ã¯ã¢ããã¿é¢æ°ãã³ãã«ã¨å¼ã¶ãã¨ã«ããï¼
+	# ã¢ããã¿é¢æ°ãã³ãã«ã¯ï¼æ¬¡ã®2åã®è¦ç´ ããæãï¼
+	#  - ã¢ããã¿é¢æ°ã¸ã®ã®ãã¤ã³ã¿
+	#  - ã¢ããã¿é¢æ°ã®å¼æ°
+
+	# @private
+	class AdapterGenerator
+
+		# çµåå
+ã«é¢ããå±æ§ãå«ãï¼ã»ã«ï¼åãå£é
+åã®æ·»å­ããæãï¼
+		# åä¸ã®EntryPropertyã¨ãªãçµåã¯ï¼å
+¨ãåãæ¹æ³ã§ãã®åãå£é¢æ°ãå¼ã³
+		# åºããï¼
+		# @private
+		class EntryProperty
+			# @return [Cell] åãå£å´ã®ã»ã«ï¼
+			attr_reader :cell
+
+			# @return [Integer, nil] åãå£é
+åã®æ·»å­ï¼é
+åã§ãªãå ´åã¯nilï¼
+			attr_reader :subscript
+
+			def initialize(cell, subscript)
+				@cell = cell
+				@subscript = subscript
+			end
+
+			def self.from_join(join)
+				EntryProperty.new(join.get_rhs_cell, join.get_rhs_subscript)
+			end
+
+			# åå¤æ§ã®å®ç¾©ï¼Hashã®ã­ã¼ã¨ãã¦ä½¿ç¨ããã®ã«å¿
+è¦ï¼
+			def eql?(o) @cell == o.cell && @subscript == o.subscript end
+			def hash() @cell.hash ^ @subscript.hash end
+		end
+
+		# @private
+		class EntryPort
+			# @param [Port] port çµåå
+ã®ã»ã«ã®ã»ã«ã¿ã¤ãã®åãå£ï¼
+			def initialize(port, prefix)
+				@port = port
+				@global_name = "#{prefix}_#{@port.get_celltype.get_global_name}_#{@port.get_name}"
+
+				# åãå£é¢æ°åï¼siHandlerBodyãæ³å®ãã¦ããã®ã§ï¼é¢æ°åã¯mainã§åºå®ã§ããï¼
+				@entry_fn_name = "#{@port.get_celltype.get_global_name}_#{@port.get_name}_main"
+
+				@props = [] 	# Array<EntryProperty>
+				@prop_map = {}	# Hash<EntryProperty, Integer>
+			end
+
+			# @return [String] ã°ã­ã¼ãã«ã«ä¸æ(ãªãã®ã¨ãã¦æ±ãããã)ãªè­å¥å­ï¼
+			attr_reader :global_name
+
+			# @return [Port]
+			attr_reader :port
+
+			# æå®ããEntryPropertyã«å¯¾å¿ããã¢ããã¿é¢æ°ãã³ãã«ãåå¾ããï¼
+			# @param [EntryProperty] ep
+			# @return [String] ã¢ããã¿é¢æ°ãã³ãã«ï¼
+			# @private
+			def adapter_handle_for_entry_property(ep)
+				index = @prop_map.fetch(ep)
+				return [
+					"#{@global_name}_#{index}_fp",
+					"#{@global_name}_#{index}_arg"
+				]
+			end
+
+			# çµåå
+ã®æ
+å ±ã«å¿ããã¢ããã¿é¢æ°ãã½ã¼ã¹ã»ãããã¼ã«åºåããï¼
+			# ä¸è¬åæå®ã¯ï¼`cell`ã¾ãã¯`subscript`ã®ä¸æ¹ã®ã¿è¡ããã¨ãã§ããï¼
+			#
+			# @param [AdapterGenerator] context
+			# @param [String] fn_name é¢æ°åï¼
+			# @param [Cell, Symbol] cell ã»ã«ï¼ã»ã«ã«ã¤ãã¦ä¸è¬åããå ´åã¯ `:generic`
+			# @param [Integer, Symbol, nil] subscript æ·»å­ï¼æ·»å­ã«ã¤ãã¦ä¸è¬åããå ´åã¯ `:generic`
+			# @private
+			def generate_inner(context, fn_name, cell, subscript)
+				source_file = context.source_file
+				header_file = context.header_file
+
+				source_file.print "void #{fn_name}(intptr_t extinf) {\n"
+
+				params = []
+				ct = @port.get_celltype
+
+				# ã·ã³ã°ã«ãã³ã»ã«ã¿ã¤ãä»¥å¤ã§ã¯ï¼CELLIDXã®æå®ãå¿
+è¦ï¼
+				unless ct.is_singleton?
+					if cell == :generic
+						params << "(CELLIDX)extinf"
+					else
+						# ã»ã«ã®CELLIDXãå¾ã
+						if ct.has_INIB? || ct.has_CB?
+							params << ct.get_name_array(cell)[7]
+						else
+							params << "0"
+						end
+					end
+				end
+
+				# åãå£é
+åã®æ·»å­ï¼
+				if @port.get_array_size
+					if subscript == :generic
+						params << "(int_t)extinf"
+					else
+						params << "#{subscript}"
+					end
+				end
+
+				params_str = params.join(", ")
+
+				source_file.print "\t#{@entry_fn_name}(#{params_str});\n"
+				source_file.print "}\n\n"
+
+				header_file.print "extern void #{fn_name}(intptr_t extinf);\n\n"
+
+			end
+
+			# æå®ããJoinã«å¯¾å¿ããã¢ããã¿é¢æ°ãã³ãã«ãåå¾ããï¼
+			# @return [Array] ã¢ããã¿é¢æ°ãã³ãã«ï¼
+			def make_adapter_handle(join)
+				prop = EntryProperty.from_join(join)
+				unless @prop_map.has_key?(prop)
+					@prop_map[prop] = @props.length
+					@props << prop
+				end
+				return adapter_handle_for_entry_property(prop)
+			end
+
+			# ã½ã¼ã¹ã»ãããã¼ã®è¨è¿°ãçæããï¼
+			# @param [AdapterGenerator] context
+			def generate(context)
+				header_file = context.header_file
+				return if @props.empty?
+
+				ct = @port.get_celltype
+
+				header_file.print "/*\n * #{@global_name}\n"
+
+				cells = @props.group_by { |prop| prop.cell }
+				subscripts = @props.group_by { |prop| prop.subscript }
+				no_cellidx = false
+				if !(ct.has_INIB? || ct.has_CB?)
+					# CB, INIBæé©åã«ããï¼CB, INIBãä¸¡æ¹ä¸è¦ã«ãªã£ãã±ã¼ã¹ï¼
+					# CELLIDXãä¸è¦ã§ããã®ã§ï¼ã»ã«ã«ã¤ãã¦ä¸è¬åãã¦ãæå³
+					# ã¯ãªãã®ã§ï¼æ·»å­ã«ããä¸è¬åãé¸æããï¼
+					generalize_by_cell_idx = false
+					no_cellidx = true
+
+					# å
+¨ã¦ã®ã»ã«ãåä¸è¦ããï¼
+					cells = { @props[0].cell => @props }
+
+					header_file.print " * No INIB & CB: generalized by subscript\n"
+				elsif @port.get_array_size
+					# ä¸è¬åãã¿ã¼ã³ã®åé¡ãè¡ãããã«ï¼åãå£å´ã»ã«ãæ·»å­ã®
+					# ãã¿ã¼ã³æ°ãåæãã¦ï¼æé©ãªæ¹ãé¸æããï¼
+					generalize_by_cell_idx = cells.length >= subscripts.length
+					if generalize_by_cell_idx
+						header_file.print " * more cells than subscripts: generalized by cell\n"
+					else
+						header_file.print " * more subscripts than cells: generalized by subscript\n"
+					end
+				else
+					# å¸¸ã«CELLIDXã§ä¸è¬å
+					generalize_by_cell_idx = true
+					header_file.print " * non-array entry port: generalized by cell\n"
+				end
+
+				header_file.print " */\n\n"
+
+				if generalize_by_cell_idx
+					# CELLIDXã«ã¤ãã¦ä¸è¬å
+					subscripts.each { |subscript, props|
+						if subscript
+							fn_name = "#{@global_name}_adap_#{subscript}"
+						else
+							# åãå£é
+åã§ãªãå ´å
+							fn_name = "#{@global_name}_adap"
+						end
+
+						generate_inner context, fn_name,
+							:generic, subscript
+
+						props.each { |prop|
+							handle = adapter_handle_for_entry_property(prop)
+
+							# ã»ã«ã®CELLIDXãå¾ã
+							if ct.has_INIB? || ct.has_CB?
+								idx = ct.get_name_array(prop.cell)[7]
+							else
+								idx = "0"
+							end
+							header_file.print "\#define #{handle[0]} &#{fn_name}\n"
+							header_file.print "\#define #{handle[1]} #{idx}\n\n"
+						}
+					}
+				else
+					# æ·»å­ã«ã¤ãã¦ä¸è¬å
+					cells.each { |cell, props|
+						if no_cellidx
+							# CB/INIB ãªã
+							fn_name = "#{@global_name}_adap"
+						else
+							fn_name = "#{@global_name}_adap_#{cell.get_global_name}"
+						end
+
+						generate_inner context, fn_name,
+							cell, :generic
+
+						props.each { |prop|
+							handle = adapter_handle_for_entry_property(prop)
+
+							header_file.print "\#define #{handle[0]} &#{fn_name}\n"
+							header_file.print "\#define #{handle[1]} #{prop.subscript || 0}\n\n"
+						}
+					}
+				end
+			end
+		end
+
+		# @private
+		attr :source_file
+
+		# @private
+		attr :header_file
+
+		# @param [String] celltype_name ãã³ãã©é¢æ°ã®ã»ã«ã¿ã¤ãï¼
+		# @param [String] prefix ååè¡çªãé²ãããã®ãã¬ãã£ãã¯ã¹ï¼
+		def initialize(celltype_name, prefix)
+			@celltype_name = celltype_name
+			@prefix = prefix
+
+			# Hash<Port, EntryPort>
+			@entry_ports = {}
+		end
+
+		# ===AdapterGenerator#make_adapter_handle===
+		# æå®ããçµåã®å¼åºããè¡ãããã®ã¢ããã¿é¢æ°ãã³ãã«ãçæããï¼
+		# @return [Array] ã¢ããã¿é¢æ°ãã³ãã«ï¼
+		def make_adapter_handle(join)
+			entry_port = @entry_ports[join.get_rhs_port]
+			unless entry_port
+				entry_port = EntryPort.new(join.get_rhs_port,
+					"#{@celltype_name}_#{@prefix}")
+				@entry_ports[join.get_rhs_port] = entry_port
+			end
+			return entry_port.make_adapter_handle(join)
+		end
+
+		# ===AdapterGenerator#finish===
+		# ååãå£ã«å¯¾ãï¼ã¢ããã¿é¢æ°ãçæããï¼
+		def finish
+			@source_file = AppFile.open( "#{$gen}/#{@celltype_name}.c" )
+	        @source_file.print "\n/* Generated by #{self.class.name} */\n\n"
+	        @source_file.print "\#include \"#{@celltype_name}_aux.h\"\n\n"
+	        @source_file.print "\#include \"#{@celltype_name}_tecsgen.h\"\n\n"
+
+			@header_file = AppFile.open( "#{$gen}/#{@celltype_name}.h" )
+	        @header_file.print "\n/* Generated by #{self.class.name} */\n\n"
+
+			# NotifierPluginãä½¿ç¨ããã»ã«ã¿ã¤ããè¤æ°ããå ´åï¼ããããã«
+			# å¯¾ãAdapterGenerator#finishãå¼ã³åºãããï¼tTimeEventHandler.hã«
+			# ç¶ãã¦æ¸ãè¾¼ãã§ãã¾ãã¨ï¼ãããã¼ã¬ã¼ãã®é¢ä¿ã§2åç®ä»¥éã®è¨è¿°
+			# ãèª­ã¿è¾¼ã¾ããªããªã£ã¦ãã¾ãï¼ãã®ããï¼ãã¡ã¤ã«å + ã»ã«ã¿ã¤ãå
+			# ã¨ããå°ãç¹æ®ãªãããã¼ã¬ã¼ããç¨ããï¼
+			header_guard = "#{@celltype_name}_H_#{@prefix}"
+
+	        @header_file.print "\#ifndef #{header_guard}\n"
+	        @header_file.print "\#define #{header_guard}\n\n"
+
+	        # ã«ã¼ãã«ã³ã³ãã£ã®ã¥ã¬ã¼ã¿ãå®è¡ããéï¼ãã³ãã©åãå£ã®ã»ã«ã¿ã¤ã
+	        # ã®ã»ã«CBã®å®ç¾©ãå¿
+è¦ãªå ´åãããï¼
+	        @header_file.print "\#include \"#{@celltype_name}_aux.h\"\n\n"
+
+			# çµåå
+ã®ã»ã«ã¿ã¤ãã®å®ç¾©ã¯ï¼èªåã®ã»ã«ã®tecsgen.hãããå
+ã«
+			# èª­ã¿è¾¼ã¾ãªããã°ãªããªããï¼ãã®ãã©ã°ã¤ã³ãè¤æ°å®è¡ãããã¨ï¼
+			# é åºãå´©ãã¦ãã¾ãï¼ããã§ï¼çµåå
+ã®ã»ã«ã¿ã¤ãã®å®ç¾©ã¯ããä¸ã¤ã®
+			# ãããã¼ãã¡ã¤ã«(tCelltypeName_aux.h)ããèª­ã¿è¾¼ãããã«ããï¼
+			aux_header_file = AppFile.open( "#{$gen}/#{@celltype_name}_aux.h" )
+	        aux_header_file.print "\n/* Generated by #{self.class.name} */\n\n"
+
+			aux_header_guard = "#{@celltype_name}_AUX_H_#{@prefix}"
+
+	        aux_header_file.print "\#ifndef #{aux_header_guard}\n"
+	        aux_header_file.print "\#define #{aux_header_guard}\n\n"
+
+			cb_type_only_guard = "#{@celltype_name}_AUX_H_#{@prefix}_CB_TYPE_ONLY"
+
+			# çµåå
+ã®ã»ã«ã¿ã¤ãã®å®ç¾©ãèª­ã¿è¾¼ã
+			aux_header_file.print "#ifndef TOPPERS_CB_TYPE_ONLY\n"
+		    aux_header_file.print "#define TOPPERS_CB_TYPE_ONLY\n"
+		    aux_header_file.print "#define #{cb_type_only_guard}\n"
+			aux_header_file.print "#endif\n"
+			@entry_ports.values.map { |ep|
+				ep.port.get_celltype
+			}.uniq.each { |ct|
+				hname = "#{ct.get_global_name}_tecsgen.#{$h_suffix}"
+				aux_header_file.print "\#include \"#{hname}\"\n"
+			}
+			aux_header_file.print "#ifdef #{cb_type_only_guard}\n"
+		    aux_header_file.print "#undef #{cb_type_only_guard}\n"
+		    aux_header_file.print "#undef TOPPERS_CB_TYPE_ONLY\n"
+			aux_header_file.print "#endif\n\n"
+
+			aux_header_file.print "\#endif\n"
+			aux_header_file.close
+
+			@entry_ports.each { |port, entry_port|
+				entry_port.generate self
+			}
+
+	        @header_file.print "\#endif\n"
+
+			@source_file.close
+			@header_file.close
+		end
+
+	end
+
+	# ------ éç¥ã®ãã³ãã©ã®ç¨®é¡ã®å®ç¾© -------
+
+	class Handler
+		def initialize(call_port_name)
+			@call_port_name = call_port_name
+		end
+
+		attr :call_port_name
+	end
+
+	# éå¸¸ã®ãã³ãã©
+	EVENT_HANDLER = Handler::new("ciNotificationHandler")
+
+	# ã¨ã©ã¼ãã³ãã© (éå¸¸ã®ãã³ãã©ãå¤±æããå ´åã«å¼ã³åºããã)
+	ERROR_HANDLER = Handler::new("ciErrorNotificationHandler")
+
+	HANDLERS = [
+		EVENT_HANDLER,
+		ERROR_HANDLER
+	]
+
+	class HandlerAttribute
+		def initialize(name, error_name = nil)
+			@name = name
+			@error_name = error_name || (name + 'ForError')
+		end
+
+		def name_for_handler(handler)
+			case handler
+			when EVENT_HANDLER then return @name
+			when ERROR_HANDLER then return @error_name
+			else raise "unknown handler #{handler}"
+			end
+		end
+	end
+
+	# ------ éç¥ã®å±æ§ã®å®ç¾© -------
+	#
+	# ãã³ãã©ã¿ã¤ãã«åè´ããªãå±æ§ãæå®ãããå ´åã«
+	# ã¨ã©ã¼ãåºåã§ãããããå
+¨ã¦ã®å±æ§ãããã§åæããã
+
+	SETVAR_ADDR_ATTR =   HandlerAttribute::new("setVariableAddress")
+	SETVAR_VALUE_ATTR =  HandlerAttribute::new("setVariableValue")
+	INCVAR_ADDR_ATTR =   HandlerAttribute::new("incrementedVariableAddress")
+	SNDDTQ_VALUE_ATTR =  HandlerAttribute::new("dataqueueSentValue")
+	SETFLG_FLAG_ATTR =   HandlerAttribute::new("flagPattern")
+
+	ATTRS = [
+		SETVAR_ADDR_ATTR,
+		SETVAR_VALUE_ATTR,
+		INCVAR_ADDR_ATTR,
+		SNDDTQ_VALUE_ATTR,
+		SETFLG_FLAG_ATTR
+	]
+
+	# ------ ãã³ãã©ã¿ã¤ãã®å®ç¾© -------
+
+	class BaseHandlerType
+
+		def initialize()
+			super
+
+			# HandlerAttribute[]
+			@required_attributes = []
+		end
+
+		attr :required_attributes
+
+	    #=== NotifierPlugin#BaseHandlerType#validate_join
+	    # æå®ããã»ã«ã®çµåå
+ãããã®ãã³ãã©ã¿ã¤ãã«è©²å½ããããæ¤è¨¼
+	    # handler:: Handler : ãã³ãã©
+	    # cell:: Cell : ã»ã«
+	    # join:: Join : çµå (declarationãPortã§ãããã®)
+		def validate_join(handler, cell, join)
+        	return !generate_attr_map(handler, cell).nil?
+		end
+
+	    #=== NotifierPlugin#BaseHandlerType#generate_attr_map
+	    # æå®ããã»ã«ã®å±æ§ã¨ãæ¢ç¥ã®HandlerAttributeã®ãããã³ã°ã
+	    # çæããHash<HandlerAttribute, Join> (åå±æ§ã¨ããã«å¯¾å¿ãã
+	    # Join(declarationãDeclã®ãã®)ãè¡¨ãHash)ããããã¯ã
+		# ãããã³ã°ãè¡ããªãå ´å(å±æ§ã®ä¸è¶³ãéå°)ã¯nilãè¿ãã
+	    #
+	    # handler:: Handler : ãã³ãã©
+	    # cell:: Cell : ã»ã«
+		def generate_attr_map(handler, cell)
+			map = {}
+
+			join_list = cell.get_join_list
+
+			ATTRS.each { |known_attr|
+				attr_name = known_attr.name_for_handler(handler)
+				join = join_list.get_item(attr_name.to_sym)
+
+				# ãã®ã»ã«ã¿ã¤ãã«ããã¦å¿
+é ã®å±æ§ã?
+				is_required = @required_attributes.include?(known_attr)
+
+				# å±æ§ã®æå®ãä¸è¶³ãã¦ãã? or éå°?
+				# æ³¨: ãã³ãã©ã¿ã¤ãã®å¤å¥ã«ã¯ãã»ã«ã§å¤ãæå®ããã¦ããã
+				#     ãèæ
+®ããããã»ã«ã¿ã¤ãã§åæå¤ãæå®ããã¦ãã¦ãã
+				#     ããã¯ãã³ãã©ã¿ã¤ãã®æ±ºå®ã«å½±é¿ããªãã
+				return nil if join.nil? != !is_required
+
+				# å¿
+è¦ã®ãªãå±æ§ã§ãããæå®ãããã¦ããªãã®ã§é£ã°ã
+				next if join.nil?
+
+				# TODO: attrã®çµåã§ãããã¨ãæ¤è¨¼
+
+				map[known_attr] = join
+			}
+
+			return map
+		end
+
+	    #=== NotifierPlugin#BaseHandlerType#gen_cfg_handler_type
+	    # ã¿ã¤ã ã¤ãã³ãã®éç¥ã®ç¨®é¡ãè¡¨ãã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®è¨è¿°ãçæããStringã¾ãã¯nilãè¿ã
+	    # handler:: Handler : ãã³ãã©
+		def gen_cfg_handler_type(handler)
+        	raise "called abstract method gen_cfg_handler_type"
+		end
+
+	    #=== NotifierPlugin#BaseHandlerType#gen_cfg_handler_parameters
+	    # ã¿ã¤ã ã¤ãã³ãã®éç¥ã®å¼æ°ãè¡¨ãã³ã³ãã£ã®ã¥ã¬ã¼ã¿ã®è¨è¿°ãçæããString[]ãè¿ã
+	    # handler:: Handler : ãã³ãã©
+	    # join:: Join : çµå (declarationãPortã§ãããã®)
+	    # attrMap:: Hash<HandlerAttribute, Join> :
+	    #     åå±æ§ã¨ããã«å¯¾å¿ããJoin (declarationãDeclã®ãã®)
+	    # cell:: Cell : ã»ã«
+		# adpt_gen:: AdapterGenerator : ã¢ããã¿é¢æ°ãçæãããªãã¸ã§ã¯ã
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+        	return nil
+		end
+
+	    #=== NotifierPlugin#BaseHandlerType#might_fail
+	    # éç¥ã®éãã¨ã©ã¼ãçºçãããã®çµæã¨ã©ã¼éç¥ãå¼ã¶å¿
+è¦ãçãã
+	    # ãã©ãããè¿ãã
+		def might_fail
+			return false
+		end
+
+	end
+	class BaseTaskHandlerType < BaseHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join && join.get_rhs_cell.get_celltype.get_name == :tTask
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			taskCell = join.get_cell
+			id_attr_join = taskCell.get_join_list.get_item(:id)
+			id_attr = join.get_rhs_cell.get_celltype.find(:id)
+			if id_attr_join
+				# ã»ã«çææã«åæåããå ´å
+				id = id_attr_join.get_rhs.to_s
+			else
+				# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+				id = id_attr.get_initializer.to_s
+			end
+
+			# $id$ç­ã®ç½®æ
+			name_array = taskCell.get_celltype.get_name_array(taskCell)
+			id = taskCell.get_celltype.subst_name(id, name_array)
+
+        	return [id]
+		end
+		def might_fail
+			return true
+		end
+	end
+	class ActivateTaskHandlerType < BaseTaskHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.get_port_name == :eiActivateNotificationHandler
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_ACTTSK"
+				when ERROR_HANDLER then return "TENFY_ACTTSK"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class WakeUpTaskHandlerType < BaseTaskHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.get_port_name == :eiWakeUpNotificationHandler
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_WUPTSK"
+				when ERROR_HANDLER then return "TENFY_WUPTSK"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class SetVariableHandlerType < BaseHandlerType
+		def initialize()
+			super
+			@required_attributes = [
+				SETVAR_ADDR_ATTR,
+				SETVAR_VALUE_ATTR
+			] # .to_set
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.nil? &&
+				handler == EVENT_HANDLER
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			var_addr = attrMap[SETVAR_ADDR_ATTR].get_rhs.to_s
+			var_value = attrMap[SETVAR_VALUE_ATTR].get_rhs.to_s
+
+			# $id$ç­ã®ç½®æ
+			name_array = cell.get_celltype.get_name_array(cell)
+			var_addr = cell.get_celltype.subst_name(var_addr, name_array)
+			var_value = cell.get_celltype.subst_name(var_value, name_array)
+
+        	return [var_addr, var_value]
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_SETVAR"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class SetVariableToErrorCodeHandlerType < BaseHandlerType
+		def initialize()
+			super
+			@required_attributes = [
+				SETVAR_ADDR_ATTR
+			] # .to_set
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.nil? &&
+				handler == ERROR_HANDLER
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			var_addr = attrMap[SETVAR_ADDR_ATTR].get_rhs.to_s
+
+			# $id$ç­ã®ç½®æ
+			name_array = cell.get_celltype.get_name_array(cell)
+			var_addr = cell.get_celltype.subst_name(var_addr, name_array)
+
+        	return [var_addr]
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when ERROR_HANDLER then return "TENFY_SETVAR"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class IncrementVariableHandlerType < BaseHandlerType
+		def initialize()
+			super
+			@required_attributes = [
+				INCVAR_ADDR_ATTR
+			] # .to_set
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.nil?
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			var_addr = attrMap[INCVAR_ADDR_ATTR].get_rhs.to_s
+
+			# $id$ç­ã®ç½®æ
+			name_array = cell.get_celltype.get_name_array(cell)
+			var_addr = cell.get_celltype.subst_name(var_addr, name_array)
+
+        	return [var_addr]
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_INCVAR"
+				when ERROR_HANDLER then return "TENFY_INCVAR"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class SignalSemaphoreHandlerType < BaseHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join && join.get_rhs_cell.get_celltype.get_name == :tSemaphore
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			semaphoreCell = join.get_cell
+			id_attr_join = semaphoreCell.get_join_list.get_item(:id)
+			id_attr = join.get_rhs_cell.get_celltype.find(:id)
+			if id_attr_join
+				# ã»ã«çææã«åæåããå ´å
+				id = id_attr_join.get_rhs.to_s
+			else
+				# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+				id = id_attr.get_initializer.to_s
+			end
+
+			# $id$ç­ã®ç½®æ
+			name_array = semaphoreCell.get_celltype.get_name_array(semaphoreCell)
+			id = semaphoreCell.get_celltype.subst_name(id, name_array)
+
+        	return [id]
+		end
+		def might_fail
+			return true
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_SIGSEM"
+				when ERROR_HANDLER then return "TENFY_SIGSEM"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class SetEventflagHandlerType < BaseHandlerType
+		def initialize()
+			super
+			@required_attributes = [
+				SETFLG_FLAG_ATTR
+			] # .to_set
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join && join.get_rhs_cell.get_celltype.get_name == :tEventflag
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			eventflagCell = join.get_cell
+			id_attr_join = eventflagCell.get_join_list.get_item(:id)
+			id_attr = join.get_rhs_cell.get_celltype.find(:id)
+			if id_attr_join
+				# ã»ã«çææã«åæåããå ´å
+				id = id_attr_join.get_rhs.to_s
+			else
+				# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+				id = id_attr.get_initializer.to_s
+			end
+			flg_pattern = attrMap[SETFLG_FLAG_ATTR].get_rhs.to_s
+
+			# $id$ç­ã®ç½®æ
+			name_array = eventflagCell.get_celltype.get_name_array(eventflagCell)
+			id = eventflagCell.get_celltype.subst_name(id, name_array)
+
+			name_array = cell.get_celltype.get_name_array(cell)
+			flg_pattern = cell.get_celltype.subst_name(flg_pattern, name_array)
+
+        	return [id, flg_pattern]
+		end
+		def might_fail
+			return true
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_SETFLG"
+				when ERROR_HANDLER then return "TENFY_SETFLG"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class DataqueueHandlerType < BaseHandlerType
+		def initialize()
+			super
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join && join.get_rhs_cell.get_celltype.get_name == :tDataqueue
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			dataqueueCell = join.get_cell
+			id_attr_join = dataqueueCell.get_join_list.get_item(:id)
+			id_attr = join.get_rhs_cell.get_celltype.find(:id)
+			if id_attr_join
+				# ã»ã«çææã«åæåããå ´å
+				id = id_attr_join.get_rhs.to_s
+			else
+				# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+				id = id_attr.get_initializer.to_s
+			end
+
+			# $id$ç­ã®ç½®æ
+			name_array = dataqueueCell.get_celltype.get_name_array(dataqueueCell)
+			id = dataqueueCell.get_celltype.subst_name(id, name_array)
+
+			name_array = cell.get_celltype.get_name_array(cell)
+
+        	return [id]
+		end
+		def might_fail
+			return true
+		end
+	end
+	class SendToDataqueueHandlerType < DataqueueHandlerType
+		def initialize()
+			super
+			@required_attributes = [
+				SNDDTQ_VALUE_ATTR
+			] # .to_set
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) && handler == EVENT_HANDLER
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			params = super(handler, join, attrMap, cell, adpt_gen)
+
+			sent_value = attrMap[SNDDTQ_VALUE_ATTR].get_rhs.to_s
+
+			# $id$ç­ã®ç½®æ
+			name_array = cell.get_celltype.get_name_array(cell)
+			sent_value = cell.get_celltype.subst_name(sent_value, name_array)
+
+			params << sent_value
+
+        	return params
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_SNDDTQ"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class SendErrorCodeToDataqueueHandlerType < DataqueueHandlerType
+		def initialize()
+			super
+		end
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) && handler == ERROR_HANDLER
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when ERROR_HANDLER then return "TENFY_SNDDTQ"
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+	class UserHandlerType < BaseHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				handler != ERROR_HANDLER && # invalid for error handler
+				join && join.get_rhs_cell.get_celltype.get_name == :tTimeEventHandler
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when EVENT_HANDLER then return "TNFY_HANDLER"
+				else raise "unknown handler #{handler}"
+			end
+		end
+		def gen_cfg_handler_parameters(handler, join, attrMap, cell, adpt_gen)
+			# tTimeEventHandlerã®çµåå
+ãåå¾
+			handler_cell = join.get_rhs_cell
+	    	call_join = handler_cell.get_join_list.get_item(:ciHandlerBody)
+
+			# çµåããã¦ããªãå ´åã¯tecsgenãã¨ã©ã¼ãåºãã¯ããªã®ã§ããã§ã¯
+			# ã¨ã©ã¼ã«ããç¡è¦ããï¼
+			return [] unless call_join
+
+			# ã¢ããã¿é¢æ°ãã³ãã«ãåå¾
+			adapter_handle = adpt_gen.make_adapter_handle(call_join)
+        	return [adapter_handle[1], adapter_handle[0]]
+		end
+	end
+	class NullHandlerType < BaseHandlerType
+		def validate_join(handler, cell, join, *args)
+			return super(handler, cell, join, *args) &&
+				join.nil? &&
+				handler != EVENT_HANDLER # handler is mandatory for normal handler!
+		end
+		def gen_cfg_handler_type(handler)
+			case handler
+				when ERROR_HANDLER then return nil
+				else raise "unknown handler #{handler}"
+			end
+		end
+	end
+
+	HANDLER_TYPES = [
+		ActivateTaskHandlerType.new,
+		WakeUpTaskHandlerType.new,
+		SetVariableHandlerType.new,
+		SetVariableToErrorCodeHandlerType.new,
+		IncrementVariableHandlerType.new,
+		SignalSemaphoreHandlerType.new,
+		SetEventflagHandlerType.new,
+		SendToDataqueueHandlerType.new,
+		SendErrorCodeToDataqueueHandlerType.new,
+		UserHandlerType.new,
+		NullHandlerType.new
+	]
+
+    #@celltype:: Celltype
+    #@option:: String     :ãªãã·ã§ã³æå­å
+    def initialize( celltype, option )
+    	super
+    	@plugin_arg_check_proc_tab = NotifierPluginArgProc
+    	@plugin_arg_str = option
+    	@plugin_arg_str = option.gsub( /\A"(.*)/, '\1' )    # åå¾ã® "" ãåãé¤ã
+    	@plugin_arg_str.sub!( /(.*)"\z/, '\1' )
+    	@factory = nil
+    	@output_file = nil
+    	parse_plugin_arg
+    	unless @factory
+    		cdl_error("ASP1003 celltype $1: option factory is not specified",
+    			celltype.get_name)
+    	end
+    	unless @output_file
+    		cdl_error("ASP1003 celltype $1: option output_file is not specified",
+    			celltype.get_name)
+    	end
+    end
+
+    def set_factory(template_string)
+    	unless @factory.nil?
+    		cdl_error("ASP1003 celltype $1: option factory was specified more than once",
+    			celltype.get_name)
+    	end
+    	@factory = template_string
+    end
+
+    def set_factory_output_file(output_file)
+    	unless @output_file.nil?
+    		cdl_error("ASP1003 celltype $1: option output_file was specified more than once",
+    			celltype.get_name)
+    	end
+    	@output_file = output_file
+    end
+
+    def gen_factory file
+        puts "===== begin #{@celltype.get_name.to_s} plugin ====="
+
+        kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
+        kernelCfg.print "\n/* Generated by #{self.class.name} */\n"
+        kernelCfg.print "\#include \"tTimeEventHandler.h\"\n"
+
+		# ã¢ããã¿é¢æ°ãçæããæºå
+		@adpt_gen = AdapterGenerator.new("tTimeEventHandler", @celltype.get_global_name)
+
+    	# å±æ§ç½®æãè¡ãããã¨ãæ¤è¨¼ããã
+    	# ããã§è¡ãã®ã¯ãfactoryã§æå®ãããå±æ§åã
+    	# å­å¨ãããã¨ãç¢ºèªããããªããã°ã¨ã©ã¼ãåºåãããã¨ã®ã¿ã§ããã
+    	# ã»ã«ãã¨ã®å¦çã®æä¸­ã«ã¨ã©ã¼ãåºåãããã¨ãå¯è½ã§ã¯ãããã
+    	# ããããã¨ã»ã«ã¿ã¤ãå´ã®åé¡ã§ããã®ã«ãããããããã»ã«ãã¨ã«
+    	# ã¨ã©ã¼ãè¡¨ç¤ºããã¦ãã¾ãã
+    	# {{attribute_name}} -> attribute_value
+    	@factory.scan(/\{\{([a-zA-Z0-9_]*?)\}\}/) { |match|
+    		name = $1.to_sym
+
+    		# {{_handler_params_}} ã¯ãã³ãã©ã«é¢ããæå®ããã©ã°ã¤ã³å
+ã§å¤ãçæããã
+    		next if name == :_handler_params_
+
+			subst_attr = @celltype.find(name)
+			unless subst_attr
+	    		cdl_error( "ASP1007 celltype $1: additional_param: attribute $2 does not exist.",
+	    			@celltype.get_name, name)
+			end
+		}
+
+        @celltype.get_cell_list.each { |cell|
+        	gen_factory_for_cell kernelCfg, cell
+        }
+
+		# ã¢ããã¿é¢æ°ã®çæãå®äºããã
+		@adpt_gen.finish
+
+        kernelCfg.close
+        puts "===== end #{@celltype.get_name.to_s} plugin ====="
+    end
+
+    def gen_factory_for_cell(kernelCfg, cell)
+    	handler_flags = []
+    	handler_args = []
+
+    	event_handler_might_fail = true
+    	handler_flag = nil
+
+		# ignoreErrorsãåå¾
+		ignoreErrors_attr_join = cell.get_join_list.get_item(:ignoreErrors)
+		ignoreErrors_attr = cell.get_celltype.find(:ignoreErrors)
+		if ignoreErrors_attr_join
+			# ã»ã«çææã«åæåããå ´å
+			ignoreErrors = ignoreErrors_attr_join.get_rhs.to_s
+		else
+			# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+			ignoreErrors = ignoreErrors_attr.get_initializer.to_s
+		end
+		case ignoreErrors
+			when 'true' then ignoreErrors = true
+			when 'false' then ignoreErrors = false
+			else
+				cdl_warning( "ASP1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
+					cell.get_name, ignoreErrors )
+				ignoreErrors = false
+		end
+
+    	[EVENT_HANDLER, ERROR_HANDLER].each { |handler|
+    		# å¼ã³å£ã®çµåãåå¾
+    		call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym)
+
+	    	# ãã³ãã©ã¿ã¤ããå¤å¥ãã
+	    	matches = HANDLER_TYPES.select { |handler_type|
+	    		handler_type.validate_join(handler, cell, call_join)
+	    	}
+
+	    	if matches.length == 0
+	    		cdl_error( "ASP1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
+	    		next
+	    	end
+
+			# æåã«è¦ã¤ãã£ãæå¹ãªãã³ãã©ã¿ã¤ããä½¿ç¨
+	    	ht = matches[0]
+
+			# éç¥ãã³ãã©ã§ãã¨ã©ã¼ãçºçããã¯ãããªããã®ã«ãã¨ã©ã¼ãã³ãã©ãæå®ããã¦ããã
+			# ãããã¯ãã®éã®ãã¿ã¼ã³ãæ¤åºããã
+			# (handler_flagãnilã§ããå ´åããã³ãã©ã¿ã¤ããä¸æã§ãããã¨ã©ã¼ãçºçãããä¸æ
+			#  ãªãããæ¤åºã¯è¡ããªãã)
+    		if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail
+	    		cdl_error( "ASP1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.",
+	    			cell.get_name, handler_flag)
+    		end
+    		if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors
+	    		cdl_warning( "ASP1006 cell $1: handler type $2 which might raise an error was inferred for the normal notificaton handler, but an error notification handler was not specified.",
+	    			cell.get_name, handler_flag)
+    		end
+
+			# assertion
+	    	unless ht.validate_join(handler, cell, call_join)
+	    		raise "!validate_join"
+	    	end
+
+			# éç¥æ¹æ³ã®éçAPIè¨è¿°ãçæãã
+	    	handler_flag = ht.gen_cfg_handler_type(handler)
+	    	handler_flags << handler_flag if handler_flag
+
+	    	attr_map = ht.generate_attr_map(handler, cell)
+
+	    	handler_arg = ht.gen_cfg_handler_parameters(handler, call_join, attr_map, cell, @adpt_gen)
+	    	handler_args += handler_arg if handler_arg
+
+	    	if handler == EVENT_HANDLER
+	    		event_handler_might_fail = ht.might_fail
+	    	end
+    	}
+
+		# $id$ç­ã®ç½®æ
+		name_array = cell.get_celltype.get_name_array(cell)
+		handler_args.collect! { |e|
+			if e == "$cbp$"
+				cell.get_celltype.subst_name(e, name_array)
+			else
+				e
+			end
+		}
+
+    	# tecsgen.cfgã®è¨è¿°ãçæããã
+    	# factoryã«å¯¾ãããã©ã¡ã¼ã¿ç½®æãè¡ãã
+    	# {{attribute_name}} -> attribute_value
+    	text = @factory.gsub(/\{\{([a-zA-Z0-9_]*?)\}\}/) { |match|
+    		name = $1.to_sym
+			subst_attr = cell.get_celltype.find(name)
+
+			# {{_handler_params_}} ã¯ãã³ãã©ã®æå®ã«ç½®æããã
+			if name == :_handler_params_
+		    	args_joined = handler_flags.join(' | ')
+		    	if handler_args.length > 0
+			    	args_joined << ", "
+			    	args_joined << handler_args.join(', ')
+			    end
+			    next args_joined
+			end
+
+			unless subst_attr
+				# å±æ§ãè¦ã¤ãããªãã¨ããã¨ã©ã¼ã¯ãã§ã«å ±åããã¦ããã®ã§
+				# ããã§ã¯ããã¼å¤ãè¿ãã¦ããã ãã§ããã
+				next ""
+			end
+
+			subst_attr_join = cell.get_join_list.get_item(name)
+			if subst_attr_join
+				# ã»ã«çææã«åæåããå ´å
+				subst = subst_attr_join.get_rhs.to_s
+			else
+				# ã»ã«ã¿ã¤ãã®åæåå¤ãä½¿ãå ´å
+				subst = subst_attr.get_initializer.to_s
+			end
+
+			# $id$ç­ã®ç½®æ
+			cell.get_celltype.subst_name(subst, name_array)
+    	}
+
+    	# åºå
+    	kernelCfg.puts text
+
+    end
+    private :gen_factory_for_cell
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueMarshalerPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueMarshalerPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueMarshalerPlugin.rb	(revision 317)
@@ -0,0 +1,100 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: OpaqueMarshalerPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== OpaqueMarshaler
+# OpaqueRPC ç¨ã®ãã¼ã·ã£ã©ãã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ããçæããã·ã°ããã£ãã©ã°ã¤ã³
+
+require_tecsgen_lib "lib/GenOpaqueMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+class OpaqueMarshalerPlugin < SignaturePlugin
+
+  OpaqueMarshalerPluginArgProc = { }
+
+  include GenOpaqueMarshaler
+  include GenParamCopy
+
+  def initialize( signature, option )
+    super
+    @b_noClientSemaphore = false
+    @noServerChannelOpenerCode = true
+    initialize_opaque_marshaler
+
+    @plugin_arg_check_proc_tab = OpaqueMarshalerPluginArgProc
+    parse_plugin_arg
+    # check_PPAllocator
+    if @signature.need_PPAllocator?(true) then
+      @PPAllocatorSize = 1    # PPAllocatorã®å¿
+è¦æ§æã®ããã«è¨­å® (ãµã¤ãºã¯ä½¿ãããªã)
+      necessity = "Necessary"
+    else
+      necessity = "Unnecessary"
+    end
+
+    print "OpaqueMarshalerPlugin: signature=#{signature.get_namespace_path}, PPAllocator=#{necessity}\n"
+  end
+
+  def gen_cdl_file file
+    gen_marshaler_celltype
+    file.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+EOT
+  end
+
+  def subst_name( val )
+    return :"_"
+    # return nil
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb	(revision 317)
@@ -0,0 +1,347 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: OpaqueRPCPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+require_tecsgen_lib "lib/GenOpaqueMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+class OpaqueRPCPlugin < ThroughPlugin
+
+  include GenOpaqueMarshaler
+  include GenParamCopy
+
+  # OpaqueRPCPlugin å°ç¨ã®ãªãã·ã§ã³
+  OpaqueRPCPluginArgProc = RPCPluginArgProc.dup  # è¤è£½ãä½ã£ã¦å
+ãå¤æ´ããªãããã«ãã
+  OpaqueRPCPluginArgProc[ "noClientSemaphore"  ] = Proc.new { |obj,rhs| obj.set_noClientSemaphore rhs }
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super
+    @b_noClientSemaphore = false
+    initialize_opaque_marshaler
+
+    @plugin_arg_check_proc_tab = OpaqueRPCPluginArgProc
+    parse_plugin_arg
+    check_opener_code
+    check_PPAllocator
+
+    print "OpaqueRPCPlugin: #{@clientChannelCell}\n"
+
+    @rpc_server_channel_celltype_name = "tOpaqueRPCPlugin_#{@TDRCelltype}_#{@serverChannelCelltype}_#{@signature.get_global_name}"
+    @rpc_server_channel_celltype_file_name = "#{$gen}/#{@rpc_server_channel_celltype_name}.cdl"
+    @rpc_client_channel_celltype_name = "tOpaqueRPCPlugin_#{@TDRCelltype}_#{@clientChannelCelltype}_#{@signature.get_global_name}"
+    @rpc_client_channel_celltype_file_name = "#{$gen}/#{@rpc_client_channel_celltype_name}.cdl"
+  end
+
+  def gen_plugin_decl_code( file )
+
+    gen_marshaler_celltype
+
+    # ãã£ã³ãã« composite ã»ã«ã¿ã¤ãã®çæ
+    #  ããã§çæããã CDL ãã¡ã¤ã«ã¯ãtecsgen ãç´æ¥ import ããã®ã§ã¯ãªã
+    #  ã»ã«ã³ã¼ãã® CDL ãã import ããã
+
+    f = CFile.open( @rpc_client_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+
+/* RPC Client side composite celltype */
+composite #{@rpc_client_channel_celltype_name} {
+  /* marshaler entry port */
+  entry #{@signature.get_namespace_path} eThroughEntry;
+  call  sChannel cChannel;
+  [optional]
+    call sRPCErrorHandler cErrorHandler;
+  [optional]
+    call sSemaphore cLockChannel;
+
+  cell #{@TDRCelltype} TDR {
+    cChannel => composite.cChannel;
+  };
+  cell #{@marshaler_celltype_name} Marshaler{
+    cTDR = TDR.eTDR;
+    cErrorHandler => composite.cErrorHandler;
+    cLockChannel  => composite.cLockChannel;
+  };
+
+  composite.eThroughEntry => Marshaler.eClientEntry;
+};
+EOT
+    f.close
+
+    if @PPAllocatorSize then
+      alloc_cell = "  cell tPPAllocator PPAllocator {\n    heapSize = #{@PPAllocatorSize};\n  };\n"
+      alloc_call_port_join = "    cPPAllocator = PPAllocator.ePPAllocator;\n"
+    else
+      alloc_cell = ""
+      alloc_call_port_join = ""
+    end
+
+    f = CFile.open( @rpc_server_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+
+/* RPC Server side composite celltype */
+composite #{@rpc_server_channel_celltype_name} {
+  /* Interface */
+  call  #{@signature.get_namespace_path} #{@call_port_name};
+  call  sChannel   cChannel;
+  [optional]
+    call sRPCErrorHandler cErrorHandler;
+  entry sUnmarshalerMain  eService;
+
+  /* Implementation */
+  cell #{@TDRCelltype} TDR {
+    cChannel => composite.cChannel;
+  };
+#{alloc_cell}  cell #{@unmarshaler_celltype_name} Unmarshaler{
+    cTDR        = TDR.eTDR;
+    cErrorHandler => composite.cErrorHandler;
+    cServerCall => composite.#{@call_port_name};
+#{alloc_call_port_join}  };
+  composite.eService => Unmarshaler.eService;
+};
+EOT
+
+    f.close
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]  # mikan namespace
+    # cell = Namespace.find( path )
+    cell = Namespace.find( @next_cell.get_namespace_path )
+
+    file.print <<EOT
+import( "#{@rpc_client_channel_celltype_file_name}" );
+import( "#{@rpc_server_channel_celltype_file_name}" );
+
+EOT
+
+    ##### ã¯ã©ã¤ã¢ã³ãå´ã®ã»ã«ã®çæ #####
+    nest = @start_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    # ã»ããã©ã®çæ
+    if @b_noClientSemaphore == false then
+      file.print <<EOT
+
+#{nest_str}  //  Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this)
+#{nest_str}  cell #{@semaphoreCelltype} #{@serverChannelCell}_Semaphore{
+#{nest_str}    #{@semaphoreInitializer}
+#{nest_str}  };
+EOT
+    end
+
+    # ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (TINET, Socket ãªã©)ã®çæ
+    file.print <<EOT
+#{nest_str}  //  Client Side Channel
+#{nest_str}  cell #{@clientChannelCelltype} #{@clientChannelCell}{
+#{nest_str}    #{@clientChannelInitializer}
+#{nest_str}  };
+
+#{nest_str}  //  Marshaler
+EOT
+
+    # ã»ããã©ã®çµåæ
+    if @b_noClientSemaphore == false then
+      semaphore = "#{nest_str}    cLockChannel = #{@serverChannelCell}_Semaphore.eSemaphore;\n"
+    else
+      semaphore = ""
+    end
+
+    ### ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (ãã¼ã·ã£ã©+TDR)ã®çæ ###
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      file.print nest_str
+      file.print "[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        alloc_str = alloc.to_s
+        subst = @substituteAllocator[alloc_str.to_sym]
+        if subst then
+          alloc_str = subst[2]+"."+subst[3]
+        end
+
+        file.print delim
+        delim = ",\n"        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = "eThroughEntry" #RPCã®åãå£åã«å¤æ´
+        file.print nest_str
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc_str}"
+      end
+
+      file.puts ")]"
+    end
+
+    if @clientErrorHandler then
+      clientErrorHandler_str = "#{nest_str}    cErrorHandler = #{@clientErrorHandler};\n"
+    else
+      clientErrorHandler_str = ""
+    end
+
+    file.print <<EOT
+#{nest_str}  cell #{@rpc_client_channel_celltype_name} #{@cell_name} {
+#{nest_str}    cChannel = #{@clientChannelCell}.eC0;
+#{clientErrorHandler_str}#{semaphore}#{nest_str}  };
+
+EOT
+    ### END: ã¯ã©ã¤ã¢ã³ãå´ãã£ã³ãã« (ãã¼ã·ã£ã©+TDR)ã®çæ ###
+
+    @start_region.gen_region_str_post file
+    file.print "\n\n"
+
+    ##### ãµã¼ãã¼å´ã®ã»ã«ã®çæ #####
+    nest = @end_region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    if @serverErrorHandler then
+      serverErrorHandler_str = "#{nest_str}    cErrorHandler = #{@serverErrorHandler};\n"
+    else
+      serverErrorHandler_str = ""
+    end
+
+    if @b_genOpener then
+      opener = "#{nest_str}    cOpener       = #{@serverChannelCell}.eOpener;\n"
+    else
+      opener = ""
+    end
+
+    # ãµã¼ãã¼å´ãã£ã³ãã« (TINET, Socket ãªã©)
+    file.print <<EOT
+
+#{nest_str}  //  Server Side Channel
+#{nest_str}  cell #{@serverChannelCelltype} #{@serverChannelCell}{
+#{nest_str}    #{@serverChannelInitializer}
+#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´ãã£ã³ãã« (ã¢ã³ãã¼ã·ã£ã©+TDR)
+    file.print <<EOT
+
+#{nest_str}  //  Unmarshaler
+#{nest_str}  cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler {
+#{nest_str}    cChannel = #{@serverChannelCell}.eC1;
+#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{serverErrorHandler_str}#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´ã¿ã¹ã¯ã¡ã¤ã³
+    file.print <<EOT
+
+#{nest_str}  //  Unmarshaler Task Main
+#{nest_str}  cell #{@taskMainCelltype} #{@serverChannelCell}_TaskMain {
+#{nest_str}    cMain         = #{@serverChannelCell}_Unmarshaler.eService;
+#{opener}#{nest_str}  };
+EOT
+
+    # ãµã¼ãã¼å´ã¿ã¹ã¯
+    file.print <<EOT
+
+#{nest_str}  //  Unmarshaler Task
+#{nest_str}  cell #{@taskCelltype} #{@serverChannelCell}_Task {
+#{nest_str}    cBody         = #{@serverChannelCell}_TaskMain.eMain;
+#{nest_str}    priority      = #{@taskPriority};
+#{nest_str}    stackSize     = #{@stackSize};
+#{nest_str}    taskAttribute = C_EXP( "TA_ACT" );  /* mikan : marshaler task starts at beginning */
+#{nest_str}  };
+EOT
+    @end_region.gen_region_str_post file
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° noClientSemaphore ã®ãã§ãã¯
+  def set_noClientSemaphore rhs
+    rhs = rhs.to_sym
+    if rhs == :true then
+      @b_noClientSemaphore = true
+    elsif rhs == :false then
+      @b_noClientSemaphore = false
+    else
+      cdl_error( "RPCPlugin: specify true or false for noClientSemaphore" )
+    end
+  end
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/RPCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/RPCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/RPCPlugin.rb	(revision 317)
@@ -0,0 +1,295 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: RPCPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+require_tecsgen_lib "lib/GenTransparentMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+#= Transparent RPC ãã©ã°ã¤ã³
+# Transparent RPC ãã£ã³ãã«ãçæãã
+# ãã©ã°ã¤ã³å¼æ°ã¯ä»¥ä¸ã® RPCPluginArgProc ãåç
+§
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+class RPCPlugin < ThroughPlugin
+
+  include GenTransparentMarshaler
+  include GenParamCopy
+
+  # RPCPlugin å°ç¨ã®ãªãã·ã§ã³
+  TransparentRPCPluginArgProc = RPCPluginArgProc.dup  # è¤è£½ãä½ã£ã¦å
+ãå¤æ´ããªãããã«ãã
+  TransparentRPCPluginArgProc[ "noClientSemaphore"  ] = Proc.new { |obj,rhs| obj.set_noClientSemaphore rhs }
+  TransparentRPCPluginArgProc[ "semaphoreCelltype"  ] = Proc.new { |obj,rhs| obj.set_semaphoreCelltype rhs }
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super
+    @b_noClientSemaphore = false
+    @semaphoreCelltype = "tSemaphore"
+    initialize_transparent_marshaler cell_name
+
+    # ãªãã·ã§ã³ï¼GenTransparentMarshaler åç
+§
+    @plugin_arg_check_proc_tab = TransparentRPCPluginArgProc
+    parse_plugin_arg
+
+    @rpc_channel_celltype_name = "tRPCPlugin_#{@TDRCelltype}_#{@channelCelltype}_#{@signature.get_global_name}"
+    @rpc_channel_celltype_file_name = "#{$gen}/#{@rpc_channel_celltype_name}.cdl"
+
+    if @signature.need_PPAllocator? then
+      if @PPAllocatorSize == nil then
+        cdl_error( "PPAllocatorSize must be speicified for oneway [in] array" )
+        # @PPAllocatorSize = 0   # ä»®ã« 0 ã¨ãã¦ãã (cdl ã®æ§æã¨ã©ã¼ãé¿ãããã)
+      end
+    end
+
+#    @signature.each_param{ |func_decl, param_decl|
+#      if func_decl.get_type.is_oneway? then
+#        if ( param_decl.get_size || param_decl.get_count ) && param_decl.get_string then
+#          cdl_error( "array of string not supported for oneway function in Transparent RPC" )  # mikan æå­åã®é
+å
+#        elsif param_decl.get_string == -1 then
+#          cdl_error( "length unspecified string is not permited for oneway function in Transparent RPC" )  # mikan é·ãæªæå®æå­å
+#        end
+#      end
+#    }
+  end
+
+  #=== plugin ã®å®£è¨ã³ã¼ã (celltype ã®å®ç¾©) çæ
+  def gen_plugin_decl_code( file )
+
+    ct_name = "#{@ct_name}_#{@channelCelltype}"
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ ct_name ] == nil then
+      @@generated_celltype[ ct_name ] = [ self ]
+    else
+      @@generated_celltype[ ct_name ] << self
+      return
+    end
+
+    gen_marshaler_celltype
+
+    if @PPAllocatorSize then
+      alloc_cell = "  cell tPPAllocator PPAllocator {\n    heapSize = #{@PPAllocatorSize};\n  };\n"
+      alloc_call_port_join = "    cPPAllocator = PPAllocator.ePPAllocator;\n"
+    else
+      alloc_cell = ""
+      alloc_call_port_join = ""
+    end
+
+    if @b_noClientSemaphore == false then
+      semaphore1 = <<EOT
+  // Semaphore for Multi-task use ("specify noClientSemaphore" option to delete this)
+  cell #{@semaphoreCelltype} Semaphore {
+    count = 1;
+    attribute = C_EXP( "TA_NULL" );
+  };
+EOT
+      semaphore2 = "    cLockChannel = Semaphore.eSemaphore;\n"
+    else
+      semaphore1 = ""
+      semaphore2 = ""
+    end
+
+    f = CFile.open( @rpc_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+
+[active]
+composite #{@rpc_channel_celltype_name} {
+  /* Interface */
+  attr {
+    PRI taskPriority;
+  };
+  call #{@signature.get_namespace_path} #{@call_port_name};
+  entry #{@signature.get_namespace_path} eThroughEntry;
+  call sTDR       cTDR;
+  call sEventflag cEventflag;
+
+  /* Implementation */
+#{semaphore1}
+  cell #{@marshaler_celltype_name} #{@signature.get_global_name}_marshaler{
+    cTDR         => composite.cTDR;
+    cEventflag   => composite.cEventflag;
+#{semaphore2}  };
+#{alloc_cell}  cell #{@unmarshaler_celltype_name} #{@signature.get_global_name}_unmarshaler{
+    cTDR        => composite.cTDR;
+    cEventflag  => composite.cEventflag;
+    cServerCall => composite.#{@call_port_name};
+#{alloc_call_port_join}  };
+  cell tRPCDedicatedTaskMain RPCTaskMain{
+    cMain = #{@signature.get_global_name}_unmarshaler.eUnmarshalAndCallFunction;
+  };
+  cell tTask Task {
+    cBody     = RPCTaskMain.eMain;
+    priority  = taskPriority;
+    taskAttribute = C_EXP( "TA_ACT" );  /* mikan : marshaler starts at the beginning */
+    stackSize     = 4096;
+  };
+  composite.eThroughEntry => #{@signature.get_global_name}_marshaler.eClientEntry;
+};
+EOT
+    # mikan stackSize option & ææ° tecs_package å¯¾å¿
+
+    f.close
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_global_name]
+    # cell = Namespace.find( path )
+    cell = Namespace.find( @next_cell.get_namespace_path )
+
+    file.print <<EOT
+import( "#{@rpc_channel_celltype_file_name}" );
+
+EOT
+
+    nest = @region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    file.print <<EOT
+#{indent_str}// ä¸æ¹åãã£ã³ãã«ã»ã«
+#{indent_str}cell #{@channelCelltype} #{@channelCellName} {
+#{indent_str}};
+
+#{indent_str}// RPC ãã£ã³ãã«ã»ã«
+EOT
+
+    # #473 ãè§£æ±ºãããå ´åãcomposite ãªã¬ã¼ã¢ã­ã±ã¼ã¿ã«å¤æ´ãã¹ã
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      file.print "#{indent_str}[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        file.print delim
+        delim = ",\n#{indent_str}           "        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = "eThroughEntry" #RPCã®åãå£åã«å¤æ´
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc}"
+      end
+
+      file.puts ")]"
+    end
+
+    file.print <<EOT
+#{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
+#{indent_str}  cTDR         = #{@channelCellName}.eTDR;
+#{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
+#{indent_str}  taskPriority = #{@task_priority};
+#{indent_str}};
+EOT
+    @region.gen_region_str_post file
+  end
+
+
+  #=== ãã©ã°ã¤ã³å¼æ° noClientSemaphore ã®ãã§ãã¯
+  def set_noClientSemaphore rhs
+    rhs = rhs.to_sym
+    if rhs == :true then
+      @b_noClientSemaphore = true
+    elsif rhs == :false then
+      @b_noClientSemaphore = false
+    else
+      cdl_error( "RPCPlugin: specify true or false for noClientSemaphore" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° semaphoreCelltype ã®ãã§ãã¯
+  def set_semaphoreCelltype rhs
+    @semaphoreCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @semaphoreCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: semaphoreCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb	(revision 317)
@@ -0,0 +1,398 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: SharedOpaqueRPCPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+require_tecsgen_lib "lib/GenOpaqueMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+#= SharedOpaqueRPC ãã©ã°ã¤ã³
+# SharedOpaqueRPC ãã£ã³ãã«ãçæãã
+# ãã©ã°ã¤ã³å¼æ°ã¯ GenTransparentMarshaler åç
+§
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+class SharedOpaqueRPCPlugin < ThroughPlugin
+
+  # ãã£ã³ãã«ãå
+±æãããã©ã°ã¤ã³ãªãã¸ã§ã¯ãã¸ã®ããã·ã¥ãªã¹ã
+  @@shared_channel_list = {}    # { chan_name => [ Plugin_obj0, Plugin_Obj1, ... ] }
+
+  attr_reader :cell_name, :start_region, :end_region
+  include GenOpaqueMarshaler
+  include GenParamCopy
+
+  # SharedOpaqueRPCPlugin å°ç¨ã®ãªãã·ã§ã³
+  SharedOpaqueRPCPluginArgProc = RPCPluginArgProc.dup  # è¤è£½ãä½ã£ã¦å
+ãå¤æ´ããªãããã«ãã
+  SharedOpaqueRPCPluginArgProc[ "sharedChannelName"  ] = Proc.new { |obj,rhs| obj.set_sharedChannelName rhs }
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super
+    initialize_opaque_marshaler
+    @entry_port_name = :"eClientEntry"   # Marshaler ã®åãå£å (through ã»ã«ã®å
+¥ãå£)
+
+    # ãªãã·ã§ã³ï¼GenOpaqueMarshaler åç
+§
+    @plugin_arg_check_proc_tab = SharedOpaqueRPCPluginArgProc
+    @sharedChannelName = nil
+    parse_plugin_arg
+    check_opener_code
+    check_PPAllocator
+
+    @shared_channel_ct_name = :"tSharedOpaqueRPCPluginChannel_tTDR"
+    @shared_channel_server_ct_name = :"#{@shared_channel_ct_name}_Server"
+    @shared_channel_client_ct_name = :"#{@shared_channel_ct_name}_Client"
+    @shared_channel_ct_file_name = "#{$gen}/#{@shared_channel_ct_name}.cdl"
+    if @sharedChannelName == nil then
+      cdl_error( "'sharedChannelName' option: mandatory")
+    else
+      @shared_channel_cell = @sharedChannelName
+    end
+
+    if @@shared_channel_list[ @shared_channel_cell ] == nil then
+      @@shared_channel_list[ @shared_channel_cell ] = [ self ]
+    else
+      @@shared_channel_list[ @shared_channel_cell ] << self
+    end
+    @sub_channel_no = ( @@shared_channel_list[ @shared_channel_cell ].length ) -1
+
+    prev_start = @@shared_channel_list[ @shared_channel_cell ][0].start_region
+    if @start_region != prev_start then
+      # ååºã¨ start ãªã¼ã¸ã§ã³ä¸ä¸è´ (ååºã¯ãèªåèªèº«ã¨ãã§ãã¯ããããç¡é§ã ãå°ããã®ã§æ¾ç½®)
+      cdl_error( "SharedRPCPlugin: start region mismatch current: #{@region.get_name} previous: #{prev_start.get_name}")
+    end
+
+    prev_end = @@shared_channel_list[ @shared_channel_cell ][0].end_region
+    if @end_region != prev_end then
+      # ååºã¨ end ãªã¼ã¸ã§ã³ä¸ä¸è´  (ååºã¯ãèªåèªèº«ã¨ãã§ãã¯ããããç¡é§ã ãå°ããã®ã§æ¾ç½®)
+      cdl_error( "SharedRPCPlugin: end region mismatch current: #{@region.get_name} previous: #{prev_end.get_name}")
+    end
+
+  end
+
+  # def set_through_info( start_region, end_region, through_type )
+  #   super
+  # end
+
+  #=== ãã©ã°ã¤ã³å¼æ° sharedChannelCell ã®ãã§ãã¯
+  def set_sharedChannelName( rhs )
+    @sharedChannelName = rhs
+    # path = [ "::", rhs ]
+    # obj = Namespace.find( path )
+    # if ! obj.instance_of?( Cell ) then
+    #   cdl_error( "SharedOpaqueRPCPlugin: sharedChannelName '#{rhs}' not cell" )
+    # end
+  end
+
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @shared_channel_server_ct_name ] == nil then
+      @@generated_celltype[ @shared_channel_server_ct_name ] = [ self ]
+    else
+      @@generated_celltype[ @shared_channel_server_ct_name ] << self
+    end
+
+    gen_marshaler_celltype
+
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    if @PPAllocatorSize then
+      alloc_call_port = "  call sPPAllocator cPPAllocator;\n"
+      alloc_call_port_join = "  cPPAllocator => composite.cPPAllocator;\n"
+    else
+      alloc_call_port = ""
+      alloc_call_port_join = ""
+    end
+
+    f = CFile.open( @shared_channel_ct_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+
+/* Shared Channel Celltype for Client */
+composite #{@shared_channel_client_ct_name} {
+  entry  sTDR       eTDR;
+  entry  sSemaphore eSemaphore[];
+  call   sChannel   cClientChannel;
+
+  cell tTDR TDR {
+    cChannel => composite.cClientChannel;
+  };
+  cell tSemaphore Semaphore {
+    count = 1;
+    attribute = C_EXP("TA_NULL");
+  };
+  cell tRPCSharedChannelMan SharedChannelMan{
+    cSemaphore             = Semaphore.eSemaphore;
+    cClientSideTDR         = TDR.eTDR;
+  };
+  composite.eSemaphore     => SharedChannelMan.eSemaphore;
+  composite.eTDR           => TDR.eTDR;
+};
+
+/* Shared Channel Celltype for Server */
+[active]
+composite #{@shared_channel_server_ct_name} {
+  entry  sTDR       eTDR;
+  call   sChannel   cServerChannel;
+  call   sUnmarshalerMain  cUnmarshalAndCallFunction[];
+  call   sServerChannelOpener cOpener;
+  attr {
+    PRI    priority;
+  };
+
+  cell tTDR TDR {
+    cChannel => composite.cServerChannel;
+  };
+  cell tRPCSharedTaskMainWithOpener RPCSharedTaskMain {
+    cUnmarshalAndCallFunction => composite.cUnmarshalAndCallFunction;
+    cServerSideTDR = TDR.eTDR;
+    cOpener => composite.cOpener;
+  };
+  cell tTask Task {
+    cBody = RPCSharedTaskMain.eMain;
+    taskAttribute = C_EXP("TA_ACT");
+    stackSize = 4096;
+    priority = composite.priority;
+  };
+  composite.eTDR           => TDR.eTDR;
+};
+
+EOT
+    f.close
+
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    file.print <<EOT
+
+import( "#{@marshaler_celltype_file_name}" );
+import( "#{@shared_channel_ct_file_name}" );
+EOT
+
+#    nest = @caller_cell.get_region.gen_region_str_pre file
+    nest = @start_region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]
+    # cell = Namespace.find( path )
+    cell = Namespace.find( @next_cell.get_namespace_path )
+
+    # å
+±æãããéä¿¡ãã£ã³ãã«ã®çæã®ãã­ãã¿ã¤ãå®£è¨
+    file.print <<EOT
+#{indent_str}cell #{@shared_channel_client_ct_name} #{@shared_channel_cell};
+EOT
+
+    # ãã¼ã·ã£ã©ã»ã«ã®çæï¼ã¢ã­ã±ã¼ã¿ã³ã¼ãã®çæããï¼
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      file.print "#{indent_str}[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        alloc_str = alloc.to_s
+        subst = @substituteAllocator[alloc_str.to_sym]
+
+        if subst then
+          alloc_str = subst[2]+"."+subst[3]
+        end
+
+        file.print delim
+        delim = ",\n#{indent_str}           "        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = @entry_port_name #RPCã®åãå£åã«å¤æ´
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc_str}"
+      end
+
+      file.puts ")]"
+    end
+
+    # ãã¼ã·ã£ã©ã»ã«æ¬ä½çæ
+    file.print <<EOT
+/* OpaqueRPC Marshaler Cell */
+#{indent_str}cell #{@marshaler_celltype_name} #{@cell_name} {
+#{indent_str}  cTDR         = #{@shared_channel_cell}.eTDR;
+#{indent_str}  cLockChannel = #{@shared_channel_cell}.eSemaphore[#{@sub_channel_no}];
+#{indent_str}};
+EOT
+    # @caller_cell.get_region.gen_region_str_post file
+    @start_region.gen_region_str_post file
+
+    # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã®åºå
+    # ã»ã«æ¬ä½ã®çæ
+    nest = @end_region.gen_region_str_pre file
+
+    file.print <<EOT
+/* Server Channel Cell prototype */
+#{indent_str}cell #{@shared_channel_server_ct_name} #{@sharedChannelName}_Server;
+
+EOT
+
+    # PPAllocator ãå¿
+è¦ã?
+    if @PPAllocatorSize then
+      if @sub_channel_no == 0 then
+        file.print <<EOT
+#{indent_str}cell tPPAllocator PPAllocator_#{@shared_channel_cell}{
+#{indent_str}  heapSize = #{@PPAllocatorSize};
+#{indent_str}};
+EOT
+      end
+
+      ppallocator_join = "#{indent_str}  cPPAllocator = PPAllocator_#{@shared_channel_cell}.ePPAllocator;\n"
+    else
+      ppallocator_join = ""
+    end
+
+    file.print <<EOT
+#{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server {
+#{indent_str}  cTDR         = #{@shared_channel_cell}_Server.eTDR;
+#{indent_str}  cServerCall  = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{ppallocator_join}#{indent_str}};
+EOT
+    @end_region.gen_region_str_post file
+
+  end
+
+  #=== post ã³ã¼ã(CDL) ãçæ
+  # ãã©ã°ã¤ã³ã®å¾ã®ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+
+    file.print "/* '#{self.name}' post code */\n"
+
+    @@shared_channel_list.each{ |chan_name,plugin_obj_array|
+      file.print "/* '#{chan_name}' shared channel */\n"
+      plugin_obj_array[0].gen_post_code( file, plugin_obj_array )
+    }
+
+  end
+
+  #=== post ã³ã¼ã(CDL) ãçæ
+  # å
+±æãã£ã³ãã«ãçæãã
+  # ãã®ã¡ã½ããã¯ããã£ã³ãã«ãå
+±æããæåã®ãã©ã°ã¤ã³ãªãã¸ã§ã¯ãã®ã¿å¼ã³åºããã
+  def gen_post_code( file, plugin_obj_array )
+
+    # å
+±æããã¦ããéä¿¡ãã£ã³ãã«ã®çæ
+    # åãã©ã°ã¤ã³ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ @shared_channel_ct_name ã¨ãã¦è¨æ¶ãã¦ãã
+    # region = @caller_cell.get_region
+    nest = @start_region.gen_region_str_pre file
+    indent_str = "  " * nest
+    file.print <<EOT
+#{indent_str}cell #{@shared_channel_client_ct_name} #{@sharedChannelName} {
+#{indent_str}    cClientChannel = #{@clientChannelCell}.eC0;
+#{indent_str}};
+EOT
+    @start_region.gen_region_str_post file
+
+    nest = @end_region.gen_region_str_pre file
+    indent_str = "  " * nest
+    file.print "#{indent_str}cell #{@shared_channel_server_ct_name} #{@sharedChannelName}_Server {\n"
+      file.print <<EOT
+#{indent_str}    cServerChannel = #{@serverChannelCell}.eC1;
+#{indent_str}    cOpener        = #{@serverChannelCell}.eOpener;
+EOT
+    plugin_obj_array.each{ |po|
+      file.print <<EOT
+#{indent_str}    cUnmarshalAndCallFunction[] = #{po.cell_name}_Server.eService;
+EOT
+    }
+    file.printf <<EOT
+#{indent_str}    priority = #{@taskPriority};
+#{indent_str}};
+EOT
+    @end_region.gen_region_str_post file
+
+  end
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedRPCPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedRPCPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SharedRPCPlugin.rb	(revision 317)
@@ -0,0 +1,365 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: SharedRPCPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+require_tecsgen_lib "lib/GenTransparentMarshaler.rb"
+require_tecsgen_lib "lib/GenParamCopy.rb"
+
+#= SharedRPC ãã©ã°ã¤ã³
+# SharedRPC ãã£ã³ãã«ãçæãã
+# ãã©ã°ã¤ã³å¼æ°ã¯ GenTransparentMarshaler åç
+§
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+# ãããå©ç¨ããå ´åãä»¥ä¸ã®ããã« toppers_jsp.cdl sChannel.cdl ãæå®ããå¿
+è¦ããã
+# tecsgen toppers_jsp.cdl sChannel.cdl your_description.cdl
+
+# ä»¥ä¸ãä»®å®ï¼å¶éäºé 
+ï¼
+#  å¼ã³å
+ãå¼ã³å
+ã®ã¨ã³ãã£ã¢ã³ãchar, short, int_t, long_t, intptr_t ã®ãµã¤ãºãåã
+#  æç¬¦å·ãç¡ç¬¦å·ã§ãµã¤ãºãåã
+
+class SharedRPCPlugin < ThroughPlugin
+
+  attr_reader :region
+  @@shared_channel_list = {}
+  include GenTransparentMarshaler
+  include GenParamCopy
+
+  #=== RPCPlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+
+    # mikan ãã©ã°ã¤ã³ãªãã·ã§ã³æå®ã®ä¸ä¸è´ã®ãã§ãã¯ task_priority, 
+
+    super
+    initialize_transparent_marshaler cell_name
+
+    # ãªãã·ã§ã³ï¼GenTransparentMarshaler åç
+§
+    @plugin_arg_check_proc_tab = RPCPluginArgProc
+    @channelCellName = ""     # nil ã«ãã¦ãã
+    parse_plugin_arg
+
+    @shared_channel_ct_name = :"tSharedRPCPlugin_#{@channelCelltype}"
+    @shared_channel_ct_file_name = "#{$gen}/#{@shared_channel_ct_name}.cdl"
+    @rpc_channel_celltype_name = :"tSharedRPCPlugin_#{@TDRCelltype}_#{@channelCelltype}_#{@signature.get_global_name}"
+    @rpc_channel_celltype_file_name = "#{$gen}/#{@rpc_channel_celltype_name}.cdl"
+
+    @shared_channel_cell = @channelCellName
+    if @shared_channel_cell == "" then
+      cdl_error( "SharedRPCPlugin: need channelCellName option" )
+    end
+
+    if @@shared_channel_list[ @shared_channel_cell ] == nil then
+      # ååº
+      @@shared_channel_list[ @shared_channel_cell ] = [ self ]
+    else
+      # äºçªç®ä»¥é
+      @@shared_channel_list[ @shared_channel_cell ] << self
+    end
+    @sub_channel_no = ( @@shared_channel_list[ @shared_channel_cell ].length ) -1
+
+    if @region != @@shared_channel_list[ @shared_channel_cell ][0].region then
+      # ååºã¨ãªã¼ã¸ã§ã³ä¸ä¸è´ (ååºã¯ãèªåèªèº«ã¨ãã§ãã¯ããããç¡é§ã ãå°ããã®ã§æ¾ç½®)
+      cdl_error( "SharedRPCPlugin: preferred region mismatch current: #{@region.get_name} previous: #{@@shared_channel_list[ @shared_channel_cell ][0].region.get_name}")
+    else
+      dbgPrint "SahredRPCPlugin: Region: #{@region.get_name}, #{@@shared_channel_list[ @shared_channel_cell ][0].region.get_name}\n"
+    end
+
+    if @signature.need_PPAllocator? then
+      if @PPAllocatorSize == nil then
+        cdl_error( "PPAllocatorSize must be speicified for oneway [in] array" )
+      end
+    end
+
+  end
+
+  # def set_through_info( start_region, end_region, through_type )
+  #   super
+  #  
+  # end
+
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @shared_channel_ct_name ] == nil then
+      @@generated_celltype[ @shared_channel_ct_name ] = [ self ]
+    else
+      @@generated_celltype[ @shared_channel_ct_name ] << self
+    end
+
+    if @@generated_celltype[ @ct_name ] == nil then
+      @@generated_celltype[ @ct_name ] = [ self ]
+    else
+      @@generated_celltype[ @ct_name ] << self
+    end
+
+    gen_marshaler_celltype
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    if @signature.need_PPAllocator? then
+      alloc_call_port = "  call sPPAllocator cPPAllocator;\n"
+      alloc_call_port_join = "  cPPAllocator => composite.cPPAllocator;\n"
+    else
+      alloc_call_port = ""
+      alloc_call_port_join = ""
+    end
+
+    f = CFile.open( @rpc_channel_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+import( "#{@marshaler_celltype_file_name}" );
+
+composite #{@rpc_channel_celltype_name} {
+  /* Interface */
+  call  #{@signature.get_namespace_path} #{@call_port_name};
+  entry #{@signature.get_namespace_path} eThroughEntry;
+  call  sTDR       cTDR;
+  call  sEventflag cEventflag;
+  entry sUnmarshalerMain  eUnmarshalAndCallFunction;
+#{alloc_call_port}
+  [optional]
+    call sSemaphore cLockChannel;
+
+  /* Implementation */
+  cell #{@marshaler_celltype_name} #{@signature.get_global_name}_marshaler{
+    cTDR         => composite.cTDR;
+    cEventflag   => composite.cEventflag;
+    cLockChannel => composite.cLockChannel;
+  };
+  cell #{@unmarshaler_celltype_name} #{@signature.get_global_name}_unmarshaler{
+    cTDR         => composite.cTDR;
+    cEventflag   => composite.cEventflag;
+    cServerCall  => composite.#{@call_port_name};
+#{alloc_call_port_join}  };
+  composite.eThroughEntry => #{@signature.get_global_name}_marshaler.eClientEntry;
+  composite.eUnmarshalAndCallFunction => #{@signature.get_global_name}_unmarshaler.eUnmarshalAndCallFunction;
+};
+EOT
+    # mikan stackSize option & ææ° tecs_package å¯¾å¿
+
+    f.close
+
+    f = CFile.open( "#{$gen}/#{@shared_channel_ct_name}.cdl", "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+[active]
+composite #{@shared_channel_ct_name} {
+  /* Interface */
+  entry  sSemaphore eSemaphore[];
+  call   sUnmarshalerMain  cUnmarshalAndCallFunction[];
+
+  entry  sDataqueue eDataqueue;
+  entry  sTDR       eTDR;
+  entry  sEventflag eEventflag;
+
+  attr {
+    PRI    priority;
+  };
+
+  /* Implementation */
+  cell #{@channelCelltype} Channel{
+  };
+  cell tSemaphore Semaphore {count = 1; attribute = C_EXP("TA_NULL");};
+  cell tRPCSharedTaskMain RPCSharedTaskMain {
+    cUnmarshalAndCallFunction => composite.cUnmarshalAndCallFunction;
+    cServerSideTDR            = Channel.eTDR;
+  };
+  cell tRPCSharedChannelMan RPCChannelMan {
+    cSemaphore                = Semaphore.eSemaphore;
+    cClientSideTDR            = Channel.eTDR;
+  };
+  cell tTask RPCSharedTask {
+    cBody = RPCSharedTaskMain.eMain;
+    taskAttribute = C_EXP("TA_ACT");
+    stackSize = 4096;
+    priority = composite.priority;
+  };
+  composite.eTDR           => Channel.eTDR;
+  composite.eEventflag     => Channel.eEventflag;
+  composite.eSemaphore     => RPCChannelMan.eSemaphore;
+  composite.eDataqueue     => Channel.eDataqueue;
+};
+EOT
+    f.close
+
+  end
+
+  #===  through cell ã³ã¼ããçæ
+  #
+  #
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    file.print <<EOT
+import( "#{@rpc_channel_celltype_file_name}" );
+import( "#{$gen}/#{@shared_channel_ct_name}.cdl" );
+EOT
+
+    # nest = @next_cell.get_region.gen_region_str_pre file
+    nest = @region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    # ã»ã«ãæ¢ã
+    # path =["::",@next_cell.get_name]
+    # cell = Namespace.find( path )
+    cell = Namespace.find( @next_cell.get_namespace_path )
+
+    # PPAllocator ãå¿
+è¦ã?
+    if @signature.need_PPAllocator? then
+      if @sub_channel_no == 0 then
+        file.print <<EOT
+#{indent_str}cell tPPAllocator PPAllocator_#{@shared_channel_cell}{
+#{indent_str}  heapSize = #{@PPAllocatorSize};
+#{indent_str}};
+EOT
+      end
+
+      ppallocator_join = "#{indent_str}  cPPAllocator = PPAllocator_#{@shared_channel_cell}.ePPAllocator;\n"
+    else
+      ppallocator_join = ""
+    end
+
+    # å
+±æãããéä¿¡ãã£ã³ãã«ã®çæã®ãã­ãã¿ã¤ãå®£è¨
+    file.print <<EOT
+#{indent_str}cell #{@shared_channel_ct_name} #{@shared_channel_cell};
+EOT
+
+    # ããããåçµåãã¨ã®ã»ã«ãçæ
+
+    # ã¢ã­ã±ã¼ã¿ã®æå®ããããï¼
+    if cell.get_allocator_list.length > 0 then
+
+      file.print "#{indent_str}[allocator("
+
+      delim = ""
+      cell.get_allocator_list.each do |type, eport, subsc, func, buf, alloc|
+
+        file.print delim
+        delim = ",\n#{indent_str}           "        # æçµè¡ã«ã¯åºããªã
+
+        if subsc then        # é
+åæ·»æ°
+          subsc_str = '[#{subsc}]'
+        else
+          subsc_str = ""
+        end
+
+        eport = "eThroughEntry" #RPCã®åãå£åã«å¤æ´
+        file.print  "#{eport}#{subsc_str}.#{func}.#{buf} = #{alloc}"
+      end
+
+      file.puts ")]"
+    end
+
+    # ã»ã«æ¬ä½ã®çæ
+    file.print <<EOT
+#{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
+#{indent_str}  cTDR         = #{@shared_channel_cell}.eTDR;
+#{indent_str}  cEventflag   = #{@shared_channel_cell}.eEventflag;
+#{indent_str}  cLockChannel =  #{@shared_channel_cell}.eSemaphore[#{@sub_channel_no}];
+#{ppallocator_join}#{indent_str}};
+EOT
+    @region.gen_region_str_post file
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã®ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    file.print "/* '#{self.name}' post code */\n"
+    @@shared_channel_list.each{ |chan_name,plugin_obj|
+      plugin_obj[0].gen_post_code( file, plugin_obj )
+    }
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  # plugin_obj[0] ãä»£è¡¨ãã¦åºåããï¼ã¤ã³ã¹ã¿ã³ã¹å¤æ°ã«ã¢ã¯ã»ã¹ãããããï¼
+  def gen_post_code( file, plugin_obj )
+
+    chan_name = @shared_channel_cell
+
+    nest = @region.gen_region_str_pre file
+    indent_str = "  " * nest
+
+    # å
+±æããã¦ããéä¿¡ãã£ã³ãã«ã®çæ
+    # åãã©ã°ã¤ã³ã¤ã³ã¹ã¿ã³ã¹ã§ã¯ @shared_channel_ct_name ã¨ãã¦è¨æ¶ãã¦ãã
+    file.print "#{indent_str}cell tSharedRPCPlugin_#{@channelCelltype} #{chan_name} {\n"
+    plugin_obj.each{ |po|
+      file.print <<EOT
+#{indent_str}    cUnmarshalAndCallFunction[] = #{@cell_name}.eUnmarshalAndCallFunction;
+EOT
+    }
+    file.printf "#{indent_str}    priority = #{@task_priority};\n#{indent_str}};\n"
+    @region.gen_region_str_post file
+
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SignaturePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SignaturePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/SignaturePlugin.rb	(revision 317)
@@ -0,0 +1,97 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: SignaturePlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== signature ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹
+class SignaturePlugin < Plugin
+#@signature:: Signature   ãã©ã°ã¤ã³ã®å¯¾è±¡ã¨ãªãã·ã°ããã£
+#@option:: String   '"', '"' ã§å²ã¾ããæå­å
+
+  #signature::     Signature        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( signature, option )
+    super()
+    @signature = signature
+    # @plugin_arg_str = option.gsub( /\A"(.*)/, '\1' )    # åå¾ã® "" ãåãé¤ã
+    # @plugin_arg_str.sub!( /(.*)"\z/, '\1' )
+    @plugin_arg_str = CDLString.remove_dquote option
+    @plugin_arg_list = {}
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã® CDL ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    raise "gen_ep_func_body must be overridden by sub class"
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TECS2CBridgePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TECS2CBridgePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TECS2CBridgePlugin.rb	(revision 317)
@@ -0,0 +1,202 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: TECS2CBridgePlugin.rb 2068 2014-06-21 07:04:08Z okuma-top $
+#++
+
+#== TECS => C å¼ã³åºããã©ã°ã¤ã³
+class TECS2CBridgePlugin < SignaturePlugin
+#@signature:: Signature   ãã©ã°ã¤ã³ã®å¯¾è±¡ã¨ãªãã·ã°ããã£
+#@option:: String   '"', '"' ã§å²ã¾ããæå­å
+
+  @@signature_list = { }
+
+  #signature::     Signature        ã·ã°ããã£ï¼ã¤ã³ã¹ã¿ã³ã¹ï¼
+  def initialize( signature, option )
+    super
+
+    @signature = signature
+    @header_name = "#{$gen}/#{@signature.get_global_name}.#{$h_suffix}"
+    @celltype_name = :"t#{@signature.get_global_name}"
+
+    parse_plugin_arg
+  end
+
+  def gen_cdl_file file
+    if @@signature_list[ @signature.get_global_name ] then
+      @@signature_list[ @signature.get_global_name ] << self
+      cdl_warning( "T2CW001 signature '$1' duplicate. ignored current one", @signature.get_namespace_path )
+      return
+    end
+    @@signature_list[ @signature.get_global_name ] = [ self ]
+
+    print_msg "  TECS2CBridgePlugin: [celltype] TECS2C::#{@celltype_name}. Create cell then join to entry port 'eEntry' from the caller cell\n"
+    file.print <<EOT
+namespace nTECS2C{
+  [singleton]
+  celltype #{@celltype_name} {
+    [inline]
+    entry #{@signature.get_namespace_path} eEnt;
+  };
+};
+EOT
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã®ã³ã¼ããçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    ret_type = func_type.get_type
+    b_ret_void = ret_type.is_void?
+
+    if ! b_ret_void then
+      file.print( "  #{ret_type.get_type_str}  retval;\n" )
+    end
+
+    if ! b_singleton then
+
+      file.print <<EOT
+  #{ct_name}_CB    *p_cellcb;
+  if( VALID_IDX( idx ) ){
+    p_cellcb = #{global_ct_name}_GET_CELLCB(idx);
+  }else{
+     /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+  }
+
+EOT
+    end
+
+    # p "celltype_name, sig_name, func_name, func_global_name"
+    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+    if ! b_ret_void then
+      file.print( "  retval = " )
+    else
+      file.print( "  " )
+    end
+
+    file.print( "#{func_name}(" )
+
+    delim = ""
+    params.each{ |param|
+      file.printf( "#{delim} #{param.get_name}" )
+      delim = ","
+    }
+
+    file.print( " );\n" )
+
+    if ! b_ret_void then
+      file.print( "  return retval;\n" )
+    end
+
+  end
+
+
+  def gen_postamble( file, b_singleton, ct_name, global_name )
+
+    # generate header file here, NOT postamble
+    file2 = CFile.open( @header_name, "w" )
+    file2.print <<EOT
+/*
+ * This file was generated by TECS2CBridgePlugin and has prototype
+ * decalarations of functions in signature '#{@signature.get_namespace_path}'
+ */
+
+#include "global_tecsgen.#{$h_suffix}"
+
+EOT
+    @signature.get_function_head_array.each { |f|
+      decl = f.get_declarator
+      func_type = decl.get_type
+      params = func_type.get_paramlist.get_items
+      func_name = decl.get_name
+
+      ret_type = func_type.get_type
+
+      # p "celltype_name, sig_name, func_name, func_global_name"
+      # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+      file2.print( "#{ret_type.get_type_str}  #{func_name}(" )
+
+      delim = ""
+      params.each{ |param|
+        file2.printf( "#{delim} #{param.get_name}" )
+        delim = ","
+      }
+      
+      file2.print( " )#{ret_type.get_type_str_post};\n" )
+    }
+
+      file2.close
+  end
+
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ThroughPlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ThroughPlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/ThroughPlugin.rb	(revision 317)
@@ -0,0 +1,372 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: ThroughPlugin.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+# mikan through plugin: namespace ãèæ
+®ããã¦ããªã
+
+#==  ã¹ã«ã¼ãã©ã°ã¤ã³ã®å
+±éã®è¦ªã¯ã©ã¹ããã¤ ï¼ä½ãããï¼ã¹ã«ã¼ããã»ã«ãæ¿å
+¥ããã¹ã«ã¼ãã©ã°ã¤ã³
+#    ã¹ã«ã¼ãã©ã°ã¤ã³ã¯ ThroughPlugin ã®å­ã¯ã©ã¹ã¨ãã¦å®ç¾©ãã
+class ThroughPlugin < Plugin
+#@cell_name::      Symbol             çæããã»ã«åï¼è¤æ°ã»ã«ãçæããå ´åãåãå£å´ã®ã»ã«ï¼
+#@plugin_arg_str:: string             through ã§æå®ãããå¼æ°
+#@next_cell:: Cell                    å¼ã³å£ãçµåããã»ã«
+#@next_cell_port_name:: Symbol       å¼ã³å£ãçµåããåå£ã®åå
+#@signature::      Signature          ã·ã°ããã£
+#@celltype::       Celltype           å¼ã³å
+ã®ã»ã«ã®ã»ã«ã¿ã¤ã. through ãé£æ¥ããå ´åãæçµçãªå¼ã³å
+ã®ã»ã«ã®ã»ã«ã¿ã¤ã
+#@entry_port_name::Symbol             çæããã»ã«ã®åãå£å  "eThroughEntry"
+#@call_port_name:: Symbol             çæããã»ã«ã®å¼ã³å£å  "cCall"
+#@ct_name::        Symbol             çæããã»ã«ã®ã»ã«ã¿ã¤ãå   "t#{self.class.name}_#{@signature.get_global_name}"
+#@plugin_arg_list:: Hash              ãã©ã°ã¤ã³å¼æ°ããã¼ã¹ããçµæã®ããã·ã¥å¤æ°
+#@caller_cell::    Cell               å¼ã³å
+ã®ã»ã«ï¼through ãã©ã°ã¤ã³ãé£æ¥ããå ´åã§ã¯ãæãå¼ã³å
+ã®ã»ã«ï¼($source$)
+#                                     through ãã©ã°ã¤ã³ãåæµããã±ã¼ã¹ã§ã¯ã1ã¤ç®ã®å¼ã³å
+ã»ã«ã®ã¿å¼æ°ã¨ãã¦ä¸ãããã
+#                                     å¾ã£ã¦ TracePlugin ã®å¼ã³å
+ã®å¤å¥ã«å©ç¨ããå ´åã¯ãç°ãªãå¼ã³å
+ããå¼ã°ããå¯è½æ§ããããã¨ã«æ³¨æããªãã¦ã¯ãªããªã
+#@callee_cell:: Cell                  å¼ã³å
+ã®ã»ã«($destination$)
+#@plugin_arg_check_proc_tab:: [string => Proc]  ãã©ã°ã¤ã³å¼æ°åâãã§ãã¯é¢æ°
+# ä»¥ä¸ã®å¤æ°ã¯ãinitialize ã§ã¯ãªããå¾ããè¨­å®ããã
+#@start_@region::  Region             å§ã¾ãã®ãªã¼ã¸ã§ã³ï¼ caller_cell ã®ãªã¼ã¸ã§ã³ã¨ã¯ç°ãªãå¯è½æ§ããã ($start_region$)
+#@end_region::  Region                çµããã®ãªã¼ã¸ã§ã³ï¼ next_cell ã®ãªã¼ã¸ã§ã³ã¨ã¯ç°ãªãå¯è½æ§ããã ($end_region$)
+#@region:: Region                     @start_region ã¨ @end_region ã®ããããã§ãcell ãç½®ãã®ãå¥½ã¾ãããªã¼ã¸ã§ã³ ($preferred_region$)
+#@through_type:: Symbol              :THROUGH, :TO_THROUGH, :IN_THROUGH, :OUT_THROUGH ã®ãããã
+
+  # ãã® Plugin ãçæããã»ã«ã¿ã¤ãã®ãªã¹ã
+  @@generated_celltype = {}
+
+  #=== ThroughPlugin ã®åæå
+  #     through ãæå®ãããæç¹ã§çæãè¡ããã
+  #         åæåã§ã¯ãæå®ãããå¼æ°ãè¨é²ããã«çãã
+  #cell_name::      Symbol             çæãã¹ãã»ã«åï¼åå£å´ï¼
+  #plugin_arg::     string             through ã§æå®ãããå¼æ°
+  #next_cell::      Cell               å¼ã³å£ãæ¥ç¶ããã»ã«
+  #next_cell_port_name:: Symbol        å¼ã³å£ãæ¥ç¶ããåå£ã®åå
+  #signature::      Signature          ã·ã°ããã£
+  #celltype::       Celltype           ã»ã«ã¿ã¤ã (å¼ã³å
+ã®ã»ã«ã®ã»ã«ã¿ã¤ã)
+  #caller_cell::    Cell               å¼ã³å
+ã®ã»ã«ï¼@caller_cell ã®é 
+ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+    super()
+    @cell_name = cell_name                      # çæãã¹ãã»ã«åï¼åãå£å´ã®ã»ã«åï¼
+                                                # ãã®å¼ã³å
+ã«å¥ã»ã«ãçæããå ´åããã®ååãæ¥é ­è¾ã¨ãã¹ã
+    @next_cell = next_cell                      # å¼ã³å
+ã®ã»ã«
+    @next_cell_port_name = next_cell_port_name
+    @signature = signature
+    @entry_port_name = :"eThroughEntry"
+    @call_port_name = :"cCall"
+    @ct_name = :"t#{self.class.name}_#{@signature.get_global_name}"
+    @celltype = celltype
+    @plugin_arg_str = plugin_arg
+    @plugin_arg_list = {}                       # ãã©ã°ã¤ã³å¼æ°ããã¼ã¹ããçµæã®ããã·ã¥å¤æ°
+    @caller_cell     = caller_cell
+    Join.set_through_info self                  # å¼æ°ã§æ¸¡ããªã(å¾ããè¿½å ããã)ãã®ã¯ set_through_info ã§è¨­å®ããã
+    print( "#{self.class.name}.new( '#{cell_name}', '#{plugin_arg}', '#{next_cell.get_name}', '#{next_cell_port_name}', #{celltype.get_name} )\n" )
+  end
+
+  #=== æ
+å ±ãè¨­å®ãã
+  # å
+±æãã£ã³ãã«ã®å ´å caller_cell, next_cell ã®ãããã® region ã§ããªãã±ã¼ã¹ããã
+  # å¾ããè¿½å ããã®ã§ initialize ã®å¼æ°ã§ã¯ãªããå¥ã¡ã½ããã§è¨­å®
+  # ãã®ã¡ã½ããã¯ããªã¼ãã¼ã©ã¤ãããªãã§ãã ãã
+  # Join ã¨ ThrougPlugin ã®éã®é£çµ¡ç¨ã§ãä»å¾ã¨ãå¼æ°ãè¿½å ãããå¯è½æ§ããããã
+  # ãã®ã¡ã½ããã¯ V1.C.0.34 ã§ä½ç½®ãç§»åãããThroughPlugin#initialize ã§å¼ã³åºããã
+  def set_through_info( start_region, end_region, through_type, join, callee_cell, count )
+    @start_region = start_region
+    @end_region = end_region
+    @through_type = through_type
+    @join = join
+    @callee_cell = callee_cell
+    @count = count
+
+    # preferred_region ã®è¨­å®
+    case through_type
+    when :IN_THROUGH, :THROUGH
+      @region = end_region
+    when :OUT_THROUGH, :TO_THROUGH
+      @region = start_region
+    else
+      raise "Unknown through_type #{through_type}"
+    end
+  end
+
+  #===  ã»ã«ã®ååãå¾ã
+  def get_cell_name
+    @cell_name
+  end
+
+  #=== NamespacePath ãå¾ã
+  # çæããã»ã«ã® namespace path ãçæãã
+  def get_cell_namespace_path
+#    nsp = @region.get_namespace.get_namespace_path
+    nsp = @region.get_namespace_path
+    return nsp.append( @cell_name )
+  end
+
+  #===  çæãããã»ã«ã®åãå£ã®ååãå¾ã
+  def get_through_entry_port_name
+    @entry_port_name
+  end
+
+  #===  å®£è¨ã³ã¼ãã®çæ
+  #      typedef, signature, celltype ãªã©ï¼cell ä»¥å¤ï¼ã®ã³ã¼ããçæ
+  #          éè¤ãã¦çæãã¦ã¯ãªããªãï¼ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ï¼
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @ct_name ] == nil then
+      @@generated_celltype[ @ct_name ] = [ self ]
+    else
+      @@generated_celltype[ @ct_name ] << self
+      return
+    end
+
+    file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
+
+    send_receive = []
+    if @signature != nil then
+      @signature.each_param{ |fd,param|
+        dir =param.get_direction
+        case dir
+        when :SEND, :RECEIVE
+          send_receive << [ dir, fd, param ]
+        end
+      }
+    end
+
+    file2.print <<EOT
+celltype #{@ct_name} {
+EOT
+
+    if send_receive.length > 0 then
+      file2.print "  [ allocator(\n"
+      delim = ""
+      send_receive.each { |a|
+        file2.print "#{delim}\t#{a[1].get_name}.#{a[2].get_name}<=#{@call_port_name}.#{a[1].get_name}.#{a[2].get_name}"
+        delim = ",\n"
+      }
+      file2.print "\n  )]\n"
+    end
+
+    file2.print <<EOT
+  entry #{@signature.get_namespace_path} #{@entry_port_name};
+  call  #{@signature.get_namespace_path} #{@call_port_name};
+};
+EOT
+    file2.close
+
+    file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
+  end
+
+  #=== CDL ãã¡ã¤ã«ã®çæ
+  #file::     FILE    çæãããã¡ã¤ã«
+  def gen_cdl_file( file )
+    gen_plugin_decl_code( file )
+    gen_through_cell_code( file )
+  end
+
+  #===  ã»ã«ã³ã¼ãã®çæ
+  #     through æå®ã«ããçããã»ã«ã³ã¼ã(CDL)ãçæãã
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_through_cell_code( file )
+
+    nest = @region.gen_region_str_pre file
+    nest_str = "  " * nest
+
+    file.print <<EOT
+#{nest_str}cell #{@ct_name} #{@cell_name} {
+#{nest_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{nest_str}};
+EOT
+    @region.gen_region_str_post file
+
+  end
+
+  #=== å¾ãã®ã³ã¼ããçæ
+  #ãã©ã°ã¤ã³ã®å¾ãã®ã³ã¼ã (CDL) ãçæ
+  #file:: File: 
+  def self.gen_post_code( file )
+    # è¤æ°ã®ãã©ã°ã¤ã³ã® post_code ãä¸ã¤ã®ãã¡ã¤ã«ã«å«ã¾ãããããä»¥ä¸ã®ãããªè¦åºããã¤ãããã¨
+    # file.print "/* '#{self.class.name}' post code */\n"
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½(Cè¨èª)ãçæãã
+  #     éå¸¸ã§ããã°ãã¸ã§ãã¬ã¼ã¿ã¯åãå£é¢æ°ã®ãã³ãã¬ã¼ããçæãã
+  #     ãã©ã°ã¤ã³ã®å ´åãå¤æ´ããå¿
+è¦ã®ãªãã»ã«ã¿ã¤ãã³ã¼ããçæãã
+  #file::           FILE        åºåå
+ãã¡ã¤ã«
+  #b_singleton::    bool        true if singleton
+  #ct_name::        Symbol
+  #global_ct_name:: string
+  #sig_name::       string
+  #ep_name::        string
+  #func_name::      string
+  #func_global_name:: string
+  #func_type::      class derived from Type
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    ret_type = func_type.get_type
+    b_ret_void = ret_type.is_void?
+
+    if ! b_ret_void then
+      file.print( "  #{ret_type.get_type_str}  retval;\n" )
+    end
+
+    if ! b_singleton then
+
+      file.print <<EOT
+  #{ct_name}_CB    *p_cellcb;
+  if( VALID_IDX( idx ) ){
+    p_cellcb = #{global_ct_name}_GET_CELLCB(idx);
+  }else{
+     /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+  }
+
+EOT
+    end
+
+    # p "celltype_name, sig_name, func_name, func_global_name"
+    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+    delim = ""
+    if ! b_ret_void then
+      file.print( "  retval = " )
+    end
+
+    file.print( "#{@call_port_name}_#{func_name}(" )
+
+#    if ( ! b_singleton ) then
+#      file.print( " tecs_this" )
+#      delim = ","
+#    end
+
+    params.each{ |param|
+      file.printf( "#{delim} #{param.get_name}" )
+      delim = ","
+    }
+
+    file.print( " );\n" )
+
+    if ! b_ret_void then
+      file.print( "  return retval;\n" )
+    end
+  end
+
+  #=== Through ãã©ã°ã¤ã³ã®å¼æ°ã®ååãç½®æãã
+  def check_plugin_arg( ident, rhs )
+    rhs = subst_name rhs
+    super( ident, rhs )
+  end
+
+  #=== ThroughPlugin#ååã®ç½®æ
+  # ãã©ã°ã¤ã³ãªãã·ã§ã³å¼æ°å
+ã®æå­åãç½®æãã
+  #   $source$       â¦ å¼ã³å
+ã®ã»ã«å
+  #   $destination$  â¦ å¼ã³å
+ã®ã»ã«å
+  #   $SOURCE$       â¦ å¼ã³å
+ã®ã»ã«å (ãªã¼ã¸ã§ã³åã '_' ã§é£çµãã global_name)
+  #   $DESTINATION$  â¦ å¼ã³å
+ã®ã»ã«å (ãªã¼ã¸ã§ã³åã '_' ã§é£çµãã global_name)
+  #   $next$         â¦ æ¬¡ã®ã»ã«å
+  #                     è¤æ°ã® through ãã¤ãªãã£ã¦ããå ´åãããå¾ãã«æ¥ããã®
+  #   $NEXT$         â¦ æ¬¡ã®ã»ã«å (ãªã¼ã¸ã§ã³åã '_' ã§é£çµãã global_name)
+  #                     è¤æ°ã® through ãã¤ãªãã£ã¦ããå ´åãããå¾ãã«æ¥ããã®
+  #   $start_region$ â¦ $source$ ã®ã»ã«ã®å­å¨ãã region (global_name)
+  #   $end_region$   â¦ $destination$ ã®ã»ã«ã®å­å¨ãã region (global_name)
+  #   $preferred_region$  â¦ é©åãª region (global_name), start_region ã¾ãã¯ end_region
+  #   $count$        â¦ region éã® through ã®é©ç¨æ°
+  #   $$             â¦ $ ã«ç½®æ
+  def subst_name( str )
+    # ã»ã«åã®ç½®æ
+    str = str.gsub( /(^|[^\$])\$source\$/, "\\1#{@caller_cell.get_name}" )
+    str = str.gsub( /(^|[^\$])\$destination\$/, "\\1#{@callee_cell.get_name}" )
+    str = str.gsub( /(^|[^\$])\$SOURCE\$/, "\\1#{@caller_cell.get_global_name}" )
+    str = str.gsub( /(^|[^\$])\$DESTINATION\$/, "\\1#{@callee_cell.get_global_name}" )
+    str = str.gsub( /(^|[^\$])\$next\$/, "\\1#{@next_cell.get_name}" )
+    str = str.gsub( /(^|[^\$])\$NEXT\$/, "\\1#{@next_cell.get_global_name}" )
+    # region åã®ç½®æ
+    str = str.gsub( /(^|[^\$])\$start_region\$/, "\\1#{@start_region.get_global_name}" )
+    str = str.gsub( /(^|[^\$])\$end_region\$/, "\\1#{@end_region.get_global_name}" )
+    str = str.gsub( /(^|[^\$])\$preferred_region\$/, "\\1#{@region.get_global_name}" )
+    str = str.gsub( /(^|[^\$])\$count\$/, "\\1#{@count}" )
+
+    str = str.gsub( /\$\$/, "\$" )                       # $$ ã $ ã«ç½®æ
+
+    return str
+  end
+
+  def show_tree( indent )
+    indent.times { print "  " }
+    puts "Plugin: celltype: #{@ct_name} cell: #{@cell_name}"
+    (indent+1).times { print "  " }
+    puts "next: signature: #{@signature.get_namespace_path} call = #{@next_cell.get_name}.#{@next_cell_port_name}"
+  end
+end
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TracePlugin.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TracePlugin.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/TracePlugin.rb	(revision 317)
@@ -0,0 +1,503 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: TracePlugin.rb 2270 2015-10-25 12:08:44Z okuma-top $
+#++
+
+class TracePlugin < ThroughPlugin
+#@cellEntry_list::[ "Cell.eEntry", "Cell2.eEntry2", ... ]
+#@b_generate::bool  : true : TracePlugin ãçæããå¿
+è¦ããã
+
+  #=== TracePlugin ã® initialize
+  #  èª¬æã¯ ThroughPlugin (plugin.rb) ãåç
+§
+  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
+
+    @maxArrayDisplay = 16
+    @cellEntry_list  = []
+    @probeName       = ""
+    @b_generate      = false
+    @b_displayTime   = false
+    @kernelCelltype  = :"tKernel"
+    @syslogCelltype  = :"tSysLog"
+
+    super
+    @plugin_arg_check_proc_tab = TracePluginArgProc
+    parse_plugin_arg
+
+    if @cellEntry_list.length > 0 then
+      @cellEntry_list.each{ |ce|
+        if "#{next_cell.get_name}.#{next_cell_port_name}".to_sym == ce.to_sym
+          @b_generate = true
+        end
+      }
+    else
+      @b_generate = true
+    end
+
+    if @b_generate == false then
+      # å
+ã
+å¼ã³åºãã»ã«ã«çµåãããã®ã¨ãã
+      @entry_port_name = next_cell_port_name
+      @cell_name = next_cell.get_name
+    end
+  end
+
+  #===  å®£è¨ã³ã¼ãã®çæ
+  #      typedef, signature, celltype ãªã©ï¼cell ä»¥å¤ï¼ã®ã³ã¼ããçæ
+  #          éè¤ãã¦çæãã¦ã¯ãªããªãï¼ãã§ã«çæããã¦ããå ´åã¯åºåããªããã¨ï¼
+  #file::        FILE       çæãããã¡ã¤ã«
+  def gen_plugin_decl_code( file )
+
+    # ãã®ã»ã«ã¿ã¤ãï¼åãã·ã°ããã£ï¼ã¯æ¢ã«çæããã¦ãããï¼
+    if @@generated_celltype[ @ct_name ] == nil then
+      @@generated_celltype[ @ct_name ] = [ self ]
+    else
+      @@generated_celltype[ @ct_name ] << self
+      return
+    end
+
+    file2 = CFile.open( "#{$gen}/#{@ct_name}.cdl", "w" )
+
+    send_receive = []
+    if @signature != nil then
+      @signature.each_param{ |fd,param|
+        dir =param.get_direction
+        case dir
+        when :SEND, :RECEIVE
+          send_receive << [ dir, fd, param ]
+        end
+      }
+    end
+
+    file2.print <<EOT
+celltype #{@ct_name} {
+EOT
+
+    if send_receive.length > 0 then
+      file2.print "  [ allocator(\n"
+      delim = ""
+      send_receive.each { |a|
+        file2.print "#{delim}\t#{a[1].get_name}.#{a[2].get_name}<=#{@call_port_name}.#{a[1].get_name}.#{a[2].get_name}"
+        delim = ",\n"
+      }
+      file2.print "\n  )]\n"
+    end
+
+    file2.print <<EOT
+  entry #{@signature.get_namespace_path} #{@entry_port_name};
+  call  #{@signature.get_namespace_path} #{@call_port_name};
+  attr{
+    char_t   *probeName_str      = "";
+    char_t   *from_str           = "";
+  };
+  require  #{@syslogCelltype}.eSysLog;
+  require  #{@kernelCelltype}.eKernel;
+};
+EOT
+#    char_t   *cell_port_name_str = "";
+
+    file2.close
+
+    file.print "import( \"#{$gen}/#{@ct_name}.cdl\" );\n"
+  end
+
+  def gen_through_cell_code( file )
+
+    gen_plugin_decl_code( file )
+
+    if @b_generate != false then
+      nest = @region.gen_region_str_pre file
+      indent_str =  "  " * nest
+
+      if @probeName then
+        probeName_str = "#{indent_str}  probeName_str = \"" + @probeName + ": \";\n"
+      else
+        probeName_str = ""
+      end
+      if @caller_cell then
+        caller_cell_str = "#{indent_str}  from_str = \"#{@caller_cell.get_name}\";\n"
+      else
+        caller_cell_str = ""
+      end
+
+      file.print <<EOT
+#{indent_str}cell #{@ct_name} #{@cell_name} {
+#{indent_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
+#{probeName_str}#{caller_cell_str}#{indent_str}};
+EOT
+#  cell_port_name_str = \"#{@next_cell.get_name}.#{@next_cell_port_name}\";
+      @region.gen_region_str_post file
+    end
+
+  end
+
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    if ! func_type.get_type.is_void? then
+      file.print( "\t#{func_type.get_type_str}\tretval;\n" )
+    end
+
+    file.print( "\tSYSUTM\tutime;\n" )
+
+    if ! b_singleton then
+
+      file.print <<EOT
+\t#{ct_name}_CB *p_cellcb;
+\tif( VALID_IDX( idx ) ){
+\t\tp_cellcb = #{global_ct_name}_GET_CELLCB(idx);
+\t}else{
+\t\t/* put code here for error */
+\t}
+
+EOT
+    end
+
+#    p "celltype_name, sig_name, func_name, func_global_name"
+#    p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+
+    file.print <<EOT
+\tgetMicroTime( &utime );
+\tsyslog( LOG_INFO, \"Enter: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}.#{func_name} calledFrom: %s\", ATTR_probeName_str, utime, ATTR_from_str );
+EOT
+
+    print_params( params, file, 0, :IN )
+
+    delim = ""
+    if ! func_type.get_type.is_void? then
+      file.print( "\tretval = " )
+    else
+      file.print( "\t" )
+    end
+
+    file.print( "#{@call_port_name}_#{func_name}(" )
+
+    params.each{ |param|
+      file.printf( "#{delim} #{param.get_name}" )
+      delim = ","
+    }
+    file.print( " );\n" )
+
+    file.print <<EOT
+\tgetMicroTime( &utime );
+\tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}.#{func_name}\", ATTR_probeName_str, utime );
+EOT
+
+    print_params( params, file, 0, :OUT )
+
+    if( ! func_type.get_type.is_void? ) then
+      print_param( "retval", func_type.get_type, file, 0, :RETURN, func_type.get_type.get_type_str, nil, nil)
+      file.print( "\treturn retval;\n" )
+    end
+
+  end
+
+  def print_params( params, file, nest, direction )
+    params.each{ |param|
+      dir = param.get_direction
+      if( direction == :IN )then
+        case dir
+        when :IN, :INOUT, :SEND
+          print_param( param.get_name, param.get_type, file, nest, dir, param.get_type.get_type_str, nil, nil )
+        end
+      else
+        case dir
+        when :OUT, :INOUT
+          print_param( param.get_name, param.get_type, file, nest, dir, param.get_type.get_type_str, nil, nil )
+        when  :RECEIVE
+          outer = "*"
+          outer2 = nil
+          print_param( param.get_name, param.get_type.get_referto, file, nest, dir,
+                       param.get_type.get_referto.get_type_str, outer, outer2 )
+        end
+      end
+    }
+  end
+
+  def print_param( name, type, file, nest, direction, type_str, outer, outer2, name_list = nil )
+    indent = "    " * ( nest + 1 )
+
+    case type
+    when DefinedType
+      print_param( name, type.get_type, file, nest, direction, type_str, outer, outer2, name_list )
+    when VoidType
+    when BoolType
+      file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %d;\", #{outer}#{name}#{outer2} );\n" )
+    when IntType
+      file.print <<EOT
+#{indent}if( sizeof(#{outer}#{name}#{outer2}) > sizeof(int_t) )
+#{indent}\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %ld;\", (long)#{outer}#{name}#{outer2} );
+#{indent}else
+#{indent}\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %d;\", #{outer}#{name}#{outer2} );
+EOT
+#      file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %ld;\", (long)#{outer}#{name}#{outer2} );\n" )
+    when FloatType
+      file.print( "#{indent}syslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{outer}#{name}#{outer2} = %g;\", (double)#{outer}#{name}#{outer2} );\n" )
+    when EnumType  # mikan EnumType
+
+    when StructType
+      members_decl =type.get_members_decl
+      if outer || outer2
+        outer = "(#{outer}#{name}#{outer2})."
+      else
+        outer = "#{name}."
+      end
+      members_decl.get_items.each { |m|
+        print_param( m.get_name, m.get_type, file, nest, direction, m.get_type.get_type_str, outer, nil, members_decl )
+      }
+    when FuncType  # mikan FuncType
+    when ArrayType # mikan ArrayType
+    when PtrType
+
+      se = type.get_size
+      ce = type.get_count
+      max_loop = @maxArrayDisplay
+      loop_count = nil
+
+      if se then
+        loop_count = "(((#{se.to_str( name_list, outer, outer2 )})>#{max_loop}) ? #{max_loop} : (#{se.to_str( name_list, outer, outer2 )}))"
+        file.print( "#{indent}syslog( LOG_INFO, \"#{indent}size_is(#{se.to_str( name_list, outer, outer2 )})=%d\", #{se.to_str( name_list, outer, outer2 )} );\n" )
+        size = "#{se.to_str( name_list, outer, outer2 )}"
+      elsif ce then
+        loop_count = "(((#{ce.to_str( name_list, outer, outer2 )})>#{max_loop}) ? #{max_loop} : (#{ce.to_str( name_list, outer, outer2 )})) "
+        file.print( "#{indent}syslog( LOG_INFO, \"#{indent}count_is(#{ce.to_str( name_list, outer, outer2 )})=%d\", #{ce.to_str( name_list, outer, outer2 )} );\n" )
+        size = "#{ce.to_str( name_list, outer, outer2 )}"
+      end
+
+      # mikan PtrType: string
+
+      referto = type.get_referto
+      type0 = type
+      type = referto
+      type_str = type.get_type_str
+      if type.kind_of?( DefinedType ) then
+        type = type.get_original_type
+      end
+
+      if type0.is_nullable? then
+        nest += 1
+        indent0 = indent
+        outer0 = outer
+        outer20 = outer2
+        indent += "    "
+        file.print"#{indent0}if( #{outer}#{name}#{outer2} ){\n"
+      end
+
+      if loop_count == nil then
+        case type
+        when StructType
+          members = type.get_members_decl
+          if outer || outer2
+            outer = "(#{outer}#{name}#{outer2})->"
+          else
+            outer = "#{name}->"
+          end
+          outer2 = nil
+          members.get_items.each { |m|
+            print_param( m.get_name, m.get_type, file, nest, direction, m.get_type.get_type_str, outer, outer2, members )
+          }
+        when FuncType  # mikan FuncType
+        when ArrayType # mikan ArrayType
+        when BoolType, IntType, FloatType, EnumType, PtrType
+          outer = "*#{outer}"
+          outer2 = "#{outer2}"
+          print_param( name, type, file, nest, direction, type_str, outer, outer2 )
+        end
+      else # loop_count != nil
+        if type.kind_of?( PtrType ) || type.kind_of?( StructType ) then
+          num_per_loop = 1
+        else
+          num_per_loop = 4
+        end
+
+          file.print <<EOT
+#{indent}{
+#{indent}\tint i__#{nest}, loop_count__ = #{loop_count};
+#{indent}\tfor( i__#{nest} = 0; i__#{nest} < loop_count__; i__#{nest}+=#{num_per_loop} ){
+EOT
+
+        case type
+        when StructType
+          members = type.get_members_decl
+          if outer || outer2
+            outer = "(#{outer}#{name}#{outer2})[i__#{nest}]."
+          else
+            outer = "#{name}[i__#{nest}]."
+          end
+          members.get_items.each { |m|
+            print_param( m.get_name, m.get_type, file, nest + 1, direction, m.get_type.get_type_str, outer, nil, members )
+          }
+        when FuncType  # mikan FuncType
+        when ArrayType # mikan ArrayType
+
+        when BoolType, FloatType
+          if outer || outer2
+            outer = "(#{outer}"
+            outer2 = "#{outer2})"
+          end
+
+          file.print <<EOT
+#{indent}\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %d %d %d %d\",
+#{indent}\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
+EOT
+        when IntType
+          if outer || outer2
+            outer = "(#{outer}"
+            outer2 = "#{outer2})"
+          end
+
+          file.print <<EOT
+#{indent}\t\tif( sizeof(#{outer}#{name}#{outer2}) > sizeof(int_t) )
+#{indent}\t\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %02x %02x %02x %02x\",
+#{indent}\t\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
+#{indent}\t\telse
+#{indent}\t\t\tsyslog( LOG_INFO, \"#{indent}[#{direction}]#{type_str} #{name}[%d]: %02lx %02lx %02lx %02lx\",
+#{indent}\t\t\t\t\ti__#{nest}, #{outer}#{name}#{outer2}[i__#{nest}], #{outer}#{name}#{outer2}[i__#{nest}+1], #{outer}#{name}#{outer2}[i__#{nest}+2], #{outer}#{name}#{outer2}[i__#{nest}+3] );
+EOT
+
+        when PtrType
+          # type = type.get_referto
+          if outer || outer2
+            outer = "(#{outer}"
+            outer2 = "#{outer2})[i__#{nest}]"
+          else
+            outer = ""
+            outer2 = "[i__#{nest}]"
+          end
+          print_param( name, type, file, nest + 1, direction, type_str, outer, outer2 )
+        end
+
+        file.print <<EOT
+#{indent}\t} /* for ( i__#{nest} ) */
+#{indent}\tif( i__#{nest} < #{size} )
+#{indent}\t\tsyslog( LOG_INFO, \"#{indent}(%d elements are omitted)\", #{size} - i__#{nest} );
+#{indent}\telse if( i__#{nest} > #{size} )
+#{indent}\t\tsyslog( LOG_INFO, \"#{indent}(last %d elements are void)\", i__#{nest} - #{size} );
+#{indent}}
+EOT
+      end # loop_count == nil
+
+      if type0.is_nullable? then
+        file.print <<EOT
+#{indent0}} else {
+#{indent0}    syslog( LOG_INFO, \"#{indent0}[#{direction}]#{outer0}#{name}#{outer20} = NULL\" );
+#{indent0}}
+EOT
+      end
+    end
+  end
+
+  # ãã©ã°ã¤ã³å¼æ°åã¨ Proc
+  TracePluginArgProc = {
+    "maxArrayDisplay"    => Proc.new { |obj,rhs| obj.set_maxArrayDisplay rhs },
+    "cellEntry"          => Proc.new { |obj,rhs| obj.set_cellEntry rhs },
+    "probeName"          => Proc.new { |obj,rhs| obj.set_probeName rhs },
+    "displayTime"        => Proc.new { |obj,rhs| obj.set_displayTime rhs },
+    "kernelCelltype"     => Proc.new { |obj,rhs| obj.set_kernelCelltype rhs },
+    "syslogCelltype"     => Proc.new { |obj,rhs| obj.set_syslogCelltype rhs },
+  }
+
+  def set_maxArrayDisplay rhs
+    @maxArrayDisplay = rhs
+  end
+
+  def set_cellEntry rhs
+    ces = rhs.to_s.split /\s*,\s*/
+    ces.each{ |ce|
+      if ce =~ /^[A-Za-z_]\w*\.[A-Za-z_]\w*$/ then
+        # OK
+      else
+        cdl_error( "#{ce}: TracePlugin arg not in \"symbol.symbol\" form" )
+      end
+    }
+    @cellEntry_list.concat ces
+  end
+
+  def set_probeName rhs
+    @probeName = rhs.to_s
+  end
+
+  def set_displayTime rhs
+    if rhs.to_s == "true"
+      @b_diplayTime = true
+    elsif rhs.to_s == "false"
+      @b_diplayTime = false
+    else
+      cdl_error( "displayTime : #{rhs} unsuitable: specify true or false" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° tKernel ã®ãã§ãã¯
+  def set_kernelCelltype( rhs )
+    @kernelCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @kernelCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "TracePlugin: kernelCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° tSyslog ã®ãã§ãã¯
+  def set_syslogCelltype( rhs )
+    @syslogCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @syslogCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "TracePlugin: syslogCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+end
+
+
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb	(revision 317)
@@ -0,0 +1,799 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#++
+
+#ãã©ã°ã¤ã³ãªãã·ã§ã³ç¨å¤æ°
+#@task_priority:: Integer
+#@channelCelltype:: String
+#@channelCellName:: String
+#@PPAllocatorSize:: Integer
+module GenTransparentMarshaler
+
+  # ãã©ã°ã¤ã³å¼æ°åã¨ Proc
+  RPCPluginArgProc = {
+    "taskPriority"    => Proc.new { |obj,rhs| obj.set_taskPriority rhs },
+    "channelCelltype" => Proc.new { |obj,rhs| obj.set_channelCelltype rhs },
+    "TDRCelltype"     => Proc.new { |obj,rhs| obj.set_TDRCelltype rhs },
+    "channelCell"     => Proc.new { |obj,rhs| obj.set_channelCellName rhs },
+    "PPAllocatorSize" => Proc.new { |obj,rhs| obj.set_PPAllocatorSize rhs },
+  }
+
+  #=== ãã©ã°ã¤ã³å¼æ° taskPriority ã®ãã§ãã¯
+  def set_taskPriority( rhs )
+    @task_priority = rhs
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° channelCelltype ã®ãã§ãã¯
+  def set_channelCelltype( rhs )
+    @channelCelltype = rhs.to_sym
+    # path = [ "::", @channelCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @channelCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: channeclCelltype '#{rhs}' not celltype or not found" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° TDRCelltype ã®ãã§ãã¯
+  def set_TDRCelltype( rhs )
+    @TDRCelltype = rhs.to_sym
+    # path = [ "::", @TDRCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @TDRCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: TDRCelltype '#{rhs}' not celltype or not found" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° channelCellName ã®ãã§ãã¯
+  def set_channelCellName( rhs )
+    @channelCellName = rhs
+    if @channelCellName =~ /\A[a-zA-Z_]\w*/ then
+      # OK
+    else
+      cdl_error( "RPCPlugin: channeclCellName '#{rhs}' unsuitable for identifier" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° PPAllocatorSize ã®ãã§ãã¯
+  def set_PPAllocatorSize( rhs )
+    @PPAllocatorSize = rhs
+  end
+
+  #=== marshaler ã®ã»ã«ã¿ã¤ãåãè¨­å®ãã
+  def initialize_transparent_marshaler cell_name
+    @task_priority = 8
+    @channelCelltype = "tDataqueueOWChannel"
+    @TDRCelltype     = "tTDR"
+    @channelCellName = "#{cell_name}_Channel"
+    @PPAllocatorSize = nil
+
+    @marshaler_celltype_name = "tMarshaler_#{@signature.get_name}"
+    @unmarshaler_celltype_name = "tUnmarshaler_#{@signature.get_name}"
+    @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl"
+  end
+
+  def gen_marshaler_celltype 
+
+    if @PPAllocatorSize then
+      alloc_call_port = "  call sPPAllocator cPPAllocator;\n"
+    else
+      alloc_call_port = ""
+    end
+
+    f = CFile.open( @marshaler_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    # modified by ishikawa
+    f.print <<EOT
+
+celltype #{@marshaler_celltype_name} {
+  entry #{@signature.get_name} eClientEntry;
+  call sEventflag  cEventflag;
+  call sSemaphore  cSemaphore;
+  call sMessageBuffer cMessageBuffer;
+  //[optional]
+  //  call sSemaphore cLockChannel;  // this port is eliminated by optimize
+};
+celltype #{@unmarshaler_celltype_name} {
+  call #{@signature.get_name} cServerCall;
+  call sEventflag  cEventflag;
+  call sSemaphore  cSemaphore;
+  call sMessageBuffer cMessageBuffer;
+  entry sTaskBody  eUnmarshalAndCallFunction;
+#{alloc_call_port}
+  FACTORY{
+    write("$ct$_factory.h", "#include <t_syslog.h>");
+  };
+};
+EOT
+    f.close
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é ­é¨ã¨æ«å°¾ã¯å¥éåºåï¼
+  #ct_name:: Symbol    (through ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ããï¼ãããï¼
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    # unmarshaler ã¯ã©ã¹ã?
+    if ct_name == @unmarshaler_celltype_name.to_sym then
+      gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    else
+      gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    end
+  end
+
+  #===  marshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    b_void = false
+    b_ret_er = false
+
+    # é¢æ°ã®æ»ãå¤ã®å
+ã®åãå¾ã(typedef ããã¦ããå ´å)
+    type = func_type.get_type.get_original_type
+
+    # æ»ãå¤è¨æ¶ç¨ã®å¤æ°ãåºåï¼void åã®é¢æ°ã§ã¯åºåããªãï¼
+    if ! type.kind_of?( VoidType ) then
+      if func_type.get_type.kind_of?( DefinedType ) && ( func_type.get_type.get_type_str == "ER" || func_type.get_type.get_type_str == "ER_INT" ) then
+        file.print( "    #{func_type.get_type.get_type_str}  retval_ = E_OK;\n" )
+        b_ret_er = true
+      else
+        file.print( "    #{func_type.get_type.get_type_str}  retval_;\n" )
+      end
+    else
+      b_void = true
+    end
+
+    file.print( "    ER      ercd_;\n" )
+    file.print( "    FLGPTN  flgptn;\n" )
+
+    # å¼ã³å
+ã® signature ãåãåºã
+    signature = @signature
+
+    # é¢æ° ID ï¼æ´æ°å¤ï¼
+    func_id = signature.get_id_from_func_name( func_name )
+    file.print( "    int16_t  func_id_ = #{func_id};    /* id of #{func_name}: #{func_id} */\n" )
+
+    file.print( "    uint8_t  msg[256];\n" )
+
+    # ã·ã³ã°ã«ãã³ã§ãªããï¼
+    if ! b_singleton then
+
+      # singleton ã§ãªããã° p_cellcb åå¾ã³ã¼ããåºå
+      file.print <<EOT
+    #{ct_name}_CB *p_cellcb;
+
+    if( VALID_IDX( idx ) ){
+        p_cellcb = GET_CELLCB(idx);
+EOT
+
+      # ã¨ã©ã¼ãè¿ããï¼
+      if b_ret_er then
+        file.print <<EOT
+    }else{
+         return ERCD( E_RPC, E_ID );
+    }
+EOT
+      else
+        file.print <<EOT
+    }else{
+        /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+    }
+EOT
+      end
+    end
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+    ///* Channel Lock */
+    //if( is_cLockChannel_joined() )
+    //  cLockChannel_wait();
+
+EOT
+
+=begin
+    # SOP ãéä¿¡
+    file.print "    /* SOPã®éåº */\n"
+    file.print "    if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n"
+    file.print "      goto error_reset;\n"
+=end
+
+    # func_id ãéä¿¡
+    file.print "    /* é¢æ° id ã®éåº */\n"
+=begin
+    file.print "    if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n"
+    file.print "        goto error_reset;\n"
+=end
+    file.print "    *((int16_t *)(&msg[0])) = func_id_;\n"   
+
+    # p "celltype_name, sig_name, func_name, func_global_name"
+    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+    b_get = false    # marshal ãªã put
+    b_marshal = true  # marshal
+
+    # in æ¹åã®å
+¥åºåãåºå
+    @index = 2
+    file.print "    /* å
+¥åå¼æ°éåº */\n"
+    print_params( params, file, 1, b_marshal, b_get, true, func_type.is_oneway? )
+    print_params( params, file, 1, b_marshal, b_get, false, func_type.is_oneway? )
+=begin
+    if ! b_void && ! func_type.is_oneway? then
+      ret_ptr_type = PtrType.new( func_type.get_type )
+      print_param_nc( "retval_", ret_ptr_type, file, 1, :RETURN, "&", nil, b_get )
+    end
+=end
+
+    file.print "    /* EOPã®éåºï¼ãã±ããã®æãã ãï¼ */\n"
+    if ! func_type.is_oneway? then
+      b_continue = "true"
+    else
+      b_continue = "false"
+    end
+=begin
+    file.print "    if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n"
+    file.print "        goto error_reset;\n\n"
+=end
+    file.print "    if( (ercd_=cMessageBuffer_send(msg, #{@index})) != E_OK )\n"
+    file.print "        goto error_reset;\n\n"
+
+    file.print "        cSemaphore_signal();\n\n"
+
+    if ! func_type.is_oneway? then
+      file.print <<EOT
+    if( (ercd_=cEventflag_wait( 0x01, TWF_ANDW, &flgptn )) != E_OK ){
+      ercd_ = ERCD(E_RPC,ercd_);
+      goto error_reset;
+    }
+    if( (ercd_=cEventflag_clear( 0x00 ) ) != E_OK ){
+      ercd_ = ERCD(E_RPC,ercd_);
+      goto error_reset;
+    }
+EOT
+    end # ! func_type.is_oneway?
+
+    file.print <<EOT
+    ///* Channel Lock */
+    //if( is_cLockChannel_joined() )
+    //  cLockChannel_signal();
+EOT
+
+    if( b_void == false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "    cMessageBuffer_receive(&retval_);\n" )
+      file.print( "    return retval_;\n" )
+    else
+      file.print( "    return;\n" )
+    end
+
+    file.print <<EOT
+
+error_reset:
+#if 0
+    if( ercd_ != ERCD( E_RPC, E_RESET ) )
+        (void)cTDR_reset();
+#endif
+EOT
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+    ///* Channel Lock */
+    //if( is_cLockChannel_joined() )
+    //  cLockChannel_signal();
+
+EOT
+
+    if( b_ret_er != false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "    return ercd_;\n" )
+    else
+      file.print( "    return;\n" )
+    end
+
+  end
+
+  #===  unmarshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+#    b_ret_er = true
+    b_ret_er = false
+
+    # func_id ãå¾ãã³ã¼ããçæ
+    file.print <<EOT
+
+    int16_t   func_id_;
+    ER        ercd_;
+
+    #{ct_name}_CB *p_cellcb;
+
+    if( VALID_IDX( idx ) ){
+        p_cellcb = GET_CELLCB(idx);
+EOT
+
+    if b_ret_er then
+        file.print <<EOT
+    }else{
+        return ERCD( E_RPC, E_ID );
+    }
+EOT
+    else
+        file.print <<EOT
+    }else{
+        /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+    }
+EOT
+    end
+
+    file.print <<EOT
+
+    cSemaphore_wait();
+
+#if 0
+    /* SOPã®ãã§ãã¯ */
+    if( (ercd_=cTDR_receiveSOP( false )) != E_OK )
+        goto error_reset;
+    /* func_id ã®åå¾ */
+    if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK )
+        goto error_reset;
+#endif
+
+    if( (ercd_ = cMessageBuffer_receive(msg) < 0 ) )
+        goto error_reset;
+    func_id_ = ((int16_t *)msg)[0];
+
+#ifdef RPC_DEBUG
+    syslog(LOG_INFO, "unmarshaler task: func_id: %d", func_id_ );
+#endif
+    switch( func_id_ ){
+EOT
+
+    # å¼ã³å
+ã® signature ãåãåºã
+    # port = @celltype.find( @next_cell_port_name )
+    # signature = port.get_signature
+    signature = @signature
+
+    # through ã® signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = signature.get_id_from_func_name( f_name )
+
+      # é¢æ°ã¯è¿ãå¤ãæã¤ã?
+      if f_type.get_type.kind_of?( VoidType ) then
+        b_void = true
+      else
+        b_void = false
+      end
+
+      # ãã±ããã®çµããããã§ãã¯ï¼æªåãåãã®ãã¼ã¿ãæ®ã£ã¦ããªãããã§ãã¯ï¼
+      file.print "    case #{id}:       /*** #{f_name} ***/ \n"
+      file.print "        if( tTransparentUnmarshaler_#{@signature.get_name}_#{f_name}() != E_OK )\n"
+      file.print "            goto error_reset;\n"
+      file.print "        break;\n"
+
+    } # 
+
+    if @PPAllocatorSize then
+      ppallocator_dealloc_str = "    /* PPAllocator ã®ãã¹ã¦ãè§£æ¾ */\n    cPPAllocator_dealloc_all();"
+    else
+      ppallocator_dealloc_str = ""
+    end
+
+
+    file.print <<EOT
+    default:
+#if 0 // deleted by ishikawa: tSysLogãæªå®è£
+
+        syslog(LOG_INFO, "unmarshaler task: ERROR: unknown func_id: %d", func_id_ );
+#endif /* 0 */
+        break;
+    };
+#{ppallocator_dealloc_str}
+    return;
+
+error_reset:
+#if 0
+    if( ercd_ != ERCD( E_RPC, E_RESET ) )
+        (void)cTDR_reset();
+#else
+    return ercd_;
+#endif
+#{ppallocator_dealloc_str}
+EOT
+
+  end
+
+  # IN b_marshal, b_get
+  #  b_marshal = true  && b_get == false   :  ãã¼ã·ã£ã©ã§å
+¥åå¼æ°éåº
+  #  b_marshal = true  && b_get == true    :  ãã¼ã·ã£ã©ã§åºåå¼æ°åå
+  #  b_marshal = false && b_get == true    :  ã¢ã³ãã¼ã·ã£ã©ã§å
+¥åå¼æ°åå
+  #  b_marshal = false && b_get == get     :  ã¢ã³ãã¼ã·ã£ã©ã§åºåå¼æ°éåº
+  def print_params( params, file, nest, b_marshal, b_get, b_referenced, b_oneway = false )
+    params.each{ |param|
+# p "#{param.get_name}:  b_marshal: #{b_marshal} b_get: #{b_get}"
+      if ! ( b_referenced == param.is_referenced? ) then
+        next
+      end
+
+      dir = param.get_direction
+      type = param.get_type
+      if b_oneway && dir == :IN && type.get_original_type.kind_of?( PtrType ) || type.get_original_type.kind_of?( ArrayType ) then
+        # oneway, in, PtrType ã®å ´åã³ãã¼
+        alloc_cp = "cPPAllocator_alloc"
+        alloc_cp_extra = nil
+        print_param( param.get_name, type, file, nest, dir, nil, nil, b_get, alloc_cp, alloc_cp_extra )
+      else
+        if( b_get == false && b_marshal == true || b_get == true && b_marshal == false  )then
+          case dir
+#          when :IN, :INOUT, :SEND
+          when :IN, :INOUT, :OUT, :SEND, :RECEIVE
+            print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
+          end
+        else
+#         case dir
+#         when :OUT, :INOUT, :RECEIVE
+#         when :RECEIVE
+#           print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
+#         end
+        end
+      end
+    }
+  end
+
+  #=== ã³ãã¼ããªãå¼æ°æ¸¡ãã³ã¼ãã®åºå
+  def print_param_nc( name, type, file, nest, b_marshal, outer, outer2, b_get )
+    indent = "    " * ( nest + 1 )
+
+    case type
+    when DefinedType
+      print_param_nc( name, type.get_type, file, nest, b_marshal, outer, outer2, b_get )
+    when BoolType, IntType, FloatType, PtrType, ArrayType
+      case type
+      when BoolType
+        type_str = "Int8"
+        cast_str = "int8_t"
+      when IntType
+        bit_size = type.get_bit_size
+        case type.get_sign
+        when :UNSIGNED
+          signC = "U"
+          sign  = "u"
+        when :SIGNED
+          if bit_size == -1 || bit_size == -11 then
+            # signed char ã®å ´åãsigned ãæå®ãã
+            signC = "S"
+            sign  = "s"
+          else
+            signC = ""
+            sign  = ""
+          end
+        else
+          signC = ""
+          sign  = ""
+        end
+
+        # p "pn:: #{name} #{bit_size} #{type.get_type_str}"
+        case bit_size
+        when  -1, -11  # -1: char_t, -11: char
+          type_str = "#{signC}Char"
+          cast_str = "#{sign}char_t"
+        when -2
+          type_str = "#{signC}Short"
+          cast_str = "#{sign}short_t"
+        when -3
+          type_str = "#{signC}Int"
+          cast_str = "#{sign}int_t"
+        when -4
+          type_str = "#{signC}Long"
+          cast_str = "#{sign}long_t"
+        when -5
+          type_str = "Intptr"
+          cast_str = "intptr_t"
+        when 8, 16, 32, 64, 128
+          type_str = "#{signC}Int#{bit_size}"
+          cast_str = "#{sign}int#{bit_size}_t"
+        else
+          raise "unknown bit_size '#{bit_size}' for int type "
+        end
+
+      when FloatType
+        bit_size = type.get_bit_size
+        if bit_size == 32 then
+          type_str = "Float32"
+          cast_str = "float32_t"
+        else
+          type_str = "Double64"
+          cast_str = "double64_t"
+        end
+
+      when PtrType
+        type_str = "Intptr"
+        cast_str = "intptr_t"
+      when ArrayType
+        type_str = "Intptr"
+        cast_str = "intptr_t"
+      end
+
+      if type.get_type_str == cast_str then
+        cast_str = ""
+      else
+        cast_str = "(" + cast_str + ")"
+      end
+
+      if( b_get )then
+        cast_str.gsub!( /\)$/, "*)" )
+        file.print "    " * nest
+=begin
+        file.print "if( ( ercd_ = cTDR_get#{type_str}( #{cast_str}&(#{outer}#{name}#{outer2}) ) ) != E_OK )\n"
+        file.print "    " * nest
+        file.print "    goto error_reset;\n"
+=end
+        file.print "#{name} = *((#{type.get_type_str} *)(&msg[#{@index}]));\n"
+        if bit_size.nil?
+            raise "HRP2 RPC supports only specified bit_size"
+        else
+            case bit_size
+            when 8, 16, 32, 64, 128
+            else
+                raise "HRP2 RPC supports only specified bit_size"
+            end
+        end
+        @index += bit_size / 8
+      else
+        file.print "    " * nest
+=begin
+        file.print "if( ( ercd_ = cTDR_put#{type_str}( #{cast_str}#{outer}#{name}#{outer2} ) ) != E_OK )\n"
+        file.print "    " * nest
+        file.print "    goto error_reset;\n"
+=end
+        file.print "*((#{type.get_type_str} *)(&msg[#{@index}])) = #{name};\n"
+        if bit_size.nil?
+            raise "HRP2 RPC supports only specified bit_size"
+        else
+            case bit_size
+            when 8, 16, 32, 64, 128
+            else
+                raise "HRP2 RPC supports only specified bit_size"
+            end
+        end
+        @index += bit_size / 8
+      end
+
+    when StructType
+      members_decl =type.get_members_decl
+      members_decl.get_items.each { |m|
+        if m.is_referenced? then
+          print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
+        end
+      }
+      members_decl.get_items.each { |m|
+        if ! m.is_referenced? then
+          print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
+        end
+      }
+
+    when VoidType
+    when EnumType  # mikan EnumType
+    when FuncType  # mikan FuncType
+    end
+  end
+
+
+  #=== PREAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ãçæ
+  def gen_preamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    file.print "/* ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ */\n"
+    # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+      file.print "static ER  tTransparentUnmarshaler_#{@signature.get_name}_#{f_name}();\t/* func_id: #{id} */\n"
+    }
+    file.print "\n"
+    file.print "static uint8_t msg[256];\n"
+    file.print "\n"
+  end
+
+  #=== POSTAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®çæ
+  def gen_postamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    file.print "\n/*** ã¢ã³ãã¼ã·ã£ã©é¢æ° ***/\n\n"
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+
+      # é¢æ°ã¯è¿ãå¤ãæã¤ã?
+      if f_type.get_type.kind_of?( VoidType ) then
+        b_void = true
+      else
+        b_void = false
+      end
+
+      file.print <<EOT
+/*
+ * name:    #{f_name}
+ * func_id: #{id} 
+ */
+EOT
+      file.print "static ER\n"
+      file.print "tTransparentUnmarshaler_#{@signature.get_name}_#{f_name}()\n"
+      file.print "{\n"
+      file.print "	ER  ercd_;\n"
+
+      # å¼æ°ãååãå¤æ°ã®å®ç¾©
+      param_list = f.get_declarator.get_type.get_paramlist.get_items
+           # FuncHead->  Decl->    FuncType->ParamList
+      param_list.each{ |par|
+        name = par.get_name
+        type = par.get_type
+        if type.kind_of? ArrayType then
+          type = type.get_type
+          aster = "(*"
+          aster2 = ")"
+        else
+          aster = ""
+          aster2 = ""
+        end
+
+        type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" ãå¤ã
+
+        file.printf( "    %-12s %s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post )
+      }
+
+      # æ»ãå¤ãåãåãå¤æ°ã®å®ç¾©
+      if ! b_void then
+        if f.is_oneway? then
+          retval_ptr = ""   # oneway ã®å ´åãåãåããæ¨ã¦ããã
+        else
+          # =begin ishikawa modified
+          # retval_ptr = "*"
+          retval_ptr = ""
+          # =end ishikawa modified
+        end
+        file.printf( "    %-12s #{retval_ptr}retval_%s;\n", f_type.get_type.get_type_str, f_type.get_type.get_type_str_post )
+      end
+
+      # in æ¹åã®å
+¥åºåãå
+¥å
+      file.print "\n        /* å
+¥åå¼æ°åå */\n"
+      b_get = true    # unmarshal ã§ã¯ get
+      b_marshal  = false
+      @index = 2
+      print_params( param_list, file, 1, b_marshal, b_get, true, f.is_oneway? )
+      print_params( param_list, file, 1, b_marshal, b_get, false, f.is_oneway? )
+=begin
+      if ! b_void && ! f.is_oneway? then
+        ret_ptr_type = PtrType.new( f_type.get_type )
+        print_param_nc( "retval_", ret_ptr_type, file, 2, :RETURN, nil, nil, b_get )
+      end
+=end
+      # ãã±ããã®åä¿¡å®äº
+      # mikan æ¬å½ã¯ãå¯¾è±¡é¢æ°ãå¼åºãå¾ã«å®æ½ãããï¼å¼åºããã±ããã®ä½¿ç¨çµãããå®£è¨ããç®çã¨ãã¦
+      file.print "        /* ãã±ããçµããããã§ãã¯ */\n"
+      if ! f.is_oneway? then
+        b_continue = "true"
+      else
+        b_continue = "false"
+      end
+=begin
+      file.print "    if( (ercd_=cTDR_receiveEOP(#{b_continue})) != E_OK )\n"
+      file.print "        goto error_reset;\n\n"
+=end
+      # å¯¾è±¡é¢æ°ãå¼åºã
+      file.print "    /* å¯¾è±¡é¢æ°ã®å¼åºã */\n"
+      if b_void then
+        file.print( "    cServerCall_#{f_name}(" )
+      else
+        file.print( "    #{retval_ptr}retval_ = cServerCall_#{f_name}(" )
+      end
+
+      delim = " "
+      param_list.each{ |par|
+        file.print delim
+        delim = ", "
+        file.print "#{par.get_name}"
+      }
+      file.print( " );\n" )
+
+      # æ»ãå¤ãåºåå¼æ°ã®ååã³ã¼ãã®çæ
+
+      if ! b_void && ! f.is_oneway? then
+        file.print "    if( (ercd_ = cMessageBuffer_send(&retval_, sizeof(#{f_type.get_type.get_type_str})) != E_OK ) )\n"
+        file.print "        goto error_reset;\n"
+
+      end
+      # oneway ã®å ´ååºåãæ»ãå¤ãç¡ããååãå¾
+ããªãï¼éåæãªå¼åºãï¼
+      if ! f.is_oneway? then
+        file.print <<EOT
+    /* é¢æ°å¦çã®çµäºãéç¥ */
+    if( ( ercd_ = cEventflag_set( 0x01 ) ) != E_OK ){
+      goto error_reset;
+    }
+EOT
+      end  # ! f.is_oneway?
+      file.print <<EOT
+    return E_OK;
+error_reset:
+    return ercd_;
+}
+
+EOT
+
+    }
+
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb	(revision 317)
@@ -0,0 +1,1139 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: GenOpaqueMarshaler.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#== GenOpaqueMarshaler
+# OpaqueRPCPlugin, sharedOpaqueRPCPlugin å
+±éã®è¦ç´ ãéããã¢ã¸ã¥ã¼ã«
+module GenOpaqueMarshaler
+
+  # ãã©ã°ã¤ã³å¼æ°åã¨ Proc
+  RPCPluginArgProc = {
+    "clientChannelCelltype" => Proc.new { |obj,rhs| obj.set_clientChannelCelltype rhs },
+    "serverChannelCelltype" => Proc.new { |obj,rhs| obj.set_serverChannelCelltype rhs },
+    "clientChannelCell" => Proc.new { |obj,rhs| obj.set_clientChannelCell rhs },
+    "serverChannelCell" => Proc.new { |obj,rhs| obj.set_serverChannelCell rhs },
+    "clientChannelInitializer" => Proc.new { |obj,rhs| obj.set_clientChannelInitializer rhs },
+    "serverChannelInitializer" => Proc.new { |obj,rhs| obj.set_serverChannelInitializer rhs },
+    "clientSemaphoreCelltype" => Proc.new { |obj,rhs| obj.set_clientSemaphoreCelltype rhs },
+    "clientSemaphoreInitializer" => Proc.new { |obj,rhs| obj.set_clientSemaphoreInitializer rhs },
+    "clientErrorHandler" => Proc.new { |obj,rhs| obj.set_clientErrorHandler rhs },
+    "serverErrorHandler" => Proc.new { |obj,rhs| obj.set_serverErrorHandler rhs },
+    "TDRCelltype"     => Proc.new { |obj,rhs| obj.set_TDRCelltype rhs },
+    "PPAllocatorSize" => Proc.new { |obj,rhs| obj.set_PPAllocatorSize rhs },
+    "substituteAllocator"  => Proc.new { |obj,rhs| obj.set_substituteAllocator rhs },
+    "noServerChannelOpenerCode"  => Proc.new { |obj,rhs| obj.set_noServerChannelOpenerCode rhs },
+    "taskCelltype"    => Proc.new { |obj,rhs| obj.set_taskCelltype rhs },
+    "taskPriority"    => Proc.new { |obj,rhs| obj.set_taskPriority rhs },
+    "stackSize"      => Proc.new { |obj,rhs| obj.set_stackSize rhs },
+  }
+
+  ##### ãã©ã°ã¤ã³å¼æ°ãã§ãã¯é¢æ°
+
+  #=== ãã©ã°ã¤ã³å¼æ° taskPriority ã®ãã§ãã¯
+  def set_taskPriority( rhs )
+    @taskPriority = rhs
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° serverChannelCelltype ã®ãã§ãã¯
+  def set_serverChannelCelltype( rhs )
+    @serverChannelCelltype = rhs.to_sym
+    # path = [ "::", @serverChannelCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @serverChannelCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: serverChannelCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientChannelCelltype ã®ãã§ãã¯
+  def set_clientChannelCelltype( rhs )
+    @clientChannelCelltype = rhs.to_sym
+    # path = [ "::", @clientChannelCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @clientChannelCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: clientChanneclCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° serverChannelCell ã®ãã§ãã¯
+  def set_serverChannelCell( rhs )
+    @serverChannelCell = rhs.to_sym
+    # ChannelCell ã¯ãã©ã°ã¤ã³ã§çæããããããããã§ã¯ãã§ãã¯ã§ããªã
+    # path = [ "::", @serverChannelCell ]
+    # obj = Namespace.find( path )
+    # if ! obj.instance_of?( Cell ) then
+    #   cdl_error( "RPCPlugin: serverChanneclCell '#{rhs}' not cell or not defined" )
+    # end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientChannelCell ã®ãã§ãã¯
+  def set_clientChannelCell( rhs )
+    @clientChannelCell = rhs.to_sym
+    # ChannelCell ã¯ãã©ã°ã¤ã³ã§çæããããããããã§ã¯ãã§ãã¯ã§ããªã
+    # path = [ "::", @clientChannelCell ]
+    # obj = Namespace.find( path )
+    # if ! obj.instance_of?( Cell ) then
+    #   cdl_error( "RPCPlugin: clientChanneclCell '#{rhs}' not cell or not defined" )
+    # end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° serverChannelInitializer ã®ãã§ãã¯
+  def set_serverChannelInitializer( rhs )
+    @serverChannelInitializer = rhs.to_sym
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientChannelInitializer ã®ãã§ãã¯
+  def set_clientChannelInitializer( rhs )
+    @clientChannelInitializer = rhs.to_sym
+  end
+
+  #=== ã¿ã¹ã¯ã¿ã¤ã taskCellype ã®ãã§ãã¯
+  def set_taskCelltype( rhs )
+    @taskCelltype = rhs.to_sym
+    # path = [ "::", @taskCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @taskCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: taskCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== ã¿ã¹ã¯ã¿ã¤ã stack\size ã®ãã§ãã¯
+  def set_stackSize( rhs )
+    @stackSize = rhs
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° PPAllocatorSize ã®ãã§ãã¯
+  def set_PPAllocatorSize( rhs )
+    @PPAllocatorSize = rhs
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° TDRCelltype ã®ãã§ãã¯
+  def set_TDRCelltype( rhs )
+    @TDRCelltype = rhs.to_sym
+    # path = [ "::", @TDRCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @TDRCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: TDRCelltype '#{rhs}' not celltype or not found" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° substituteAllocator ã®ãã§ãã¯
+  # ãªãã·ã§ã³å¼æ°ããä»¥ä¸ã®å½¢å¼ã§ãããã¨ããã§ãã¯
+  #     substituteAllocator(Alloc.eAlloc=>Subst.eAlloc,Alloc2.eAlloc=>Subst2.eAlloc)
+  def set_substituteAllocator( rhs )
+    #str::String : ç ´å£ãããï¼ãããããæ®ãã«ãªãï¼ãstr.empty? ã§ç©ºã«ãªã£ããã¨ããã§ãã¯ã§ãã
+    #regexp::Regexp : æå¾
+ãããã¼ã¯ã³ã«ãããããæ­£è¦è¡¨ç¾ã "\A" åºå§ãã
+    #expected::String: æå¾
+ãããã¼ã¯ã³ãregexp ãåºç¾ããªãã£ãå ´åã«ã¨ã©ã¼ã¡ãã»ã¼ã¸ã¨ãã¦è¡¨ç¤º
+    def optparse (str,regexp,expected)
+      str.strip!
+      token = nil
+      res = str.sub!( regexp ){ |matched|  token = matched;  "" }
+      if ! token then
+        cdl_error( "syntax error in substituteAllocator option near '#{str}', expected '#{expected}'" )
+      end
+      return token
+    end
+
+    opt = rhs.dup
+    ident_rexpr = /\A(\w[\w\d]*)/
+
+    # "Alloc.eAlloc=>CAlloc.eAlloc" ã®å½¢å¼ã«ãªã£ã¦ãããã¨ããã§ãã¯
+    while true
+      lhs_alloc_cell = optparse( opt, ident_rexpr, "allocator cell name" )
+      break if ! lhs_alloc_cell
+
+      res = optparse( opt, /\A\./, "." )
+      break if ! res
+
+      lhs_alloc_ent = optparse( opt, ident_rexpr, "allocator cell entry name" )
+      break if ! lhs_alloc_ent
+
+      res = optparse( opt, /\A\=\>/, "=>" )
+      break if ! res
+
+      rhs_alloc_cell = optparse( opt, ident_rexpr, "allocator cell name" )
+      break if ! rhs_alloc_cell
+
+      res = optparse( opt, /\A\./, "." )
+      break if ! res
+
+      rhs_alloc_ent = optparse( opt, ident_rexpr, "allocator cell entry name" )
+      break if ! rhs_alloc_ent
+
+#  ããã§ã¯ãå³è¾ºã®ãã§ãã¯ã¯ã§ããªããå³è¾ºã®ã»ã«ã¯åæ¹åç
+§ã¨ãªã
+#      path = [ "::", rhs_alloc_cell.to_sym ]   # mikan namespace
+#      obj = Namespace.find( path )
+#      if ! obj.instance_of?( Cell ) || obj.get_region.get_path_string != @clientRegion then
+#        cdl_error( "RPCPlugin: substituteAllocator: '#{rhs_alloc_cell}' not cell or not found in client region" )
+#      else
+#        ct = obj.get_celltype
+#        if ct #  nil ãªãæ¢ã«ã¨ã©ã¼
+#          ent = ct.find rhs_alloc_ent
+#          if ! ent.instance_of? Port || ent.get_port_type != :ENTRY || ent.get_signature == nil || ! ent.get_signature.is_allocator?
+#            cdl_error( "RPCPlugin: substituteAllocator: '#{rhs_alloc_cell}.#{rhs_alloc_ent}' not entry port or not have alllocator signature" )
+#          end
+#        end
+#      end
+
+      @substituteAllocator[ "#{lhs_alloc_cell}.#{lhs_alloc_ent}".to_sym ] =
+        [ lhs_alloc_cell, lhs_alloc_ent, rhs_alloc_cell, rhs_alloc_ent ]
+
+# p "substituteAllocator: #{lhs_alloc_cell}.#{lhs_alloc_ent}=>#{rhs_alloc_cell}.#{rhs_alloc_ent}"
+
+      break if opt.empty?
+
+      res = optparse( opt, /\A\,/, "," )
+      break if ! res
+    end
+
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° noServerChannelOpenerCode ã®ãã§ãã¯
+  def set_noServerChannelOpenerCode( rhs )
+    rhs = rhs.to_sym
+    if rhs == :true
+      @noServerChannelOpenerCode = true
+    elsif rhs == :false then
+      @noServerChannelOpenerCode = false
+    else
+      cdl_error( "RPCPlugin: specify true or false for noServerChannelOpenerCode" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientSemaphoreCelltype ã®ãã§ãã¯
+  def set_clientSemaphoreCelltype rhs
+    @semaphoreCelltype = rhs.to_sym
+    nsp = NamespacePath.analyze( @semaphoreCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: clientSemaphoreCelltype '#{rhs}' not celltype or not defined" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientSemaphoreInitializer ã®ãã§ãã¯
+  def set_clientSemaphoreInitializer rhs
+    @semaphoreInitializer = rhs.to_sym
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° clientErrorHandler ã®ãã§ãã¯
+  def set_clientErrorHandler rhs
+    @clientErrorHandler = rhs.to_sym
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° serverErrorHandler ã®ãã§ãã¯
+  def set_serverErrorHandler rhs
+    @serverErrorHandler = rhs.to_sym
+  end
+
+
+  #===  ã»ã«ã®ååãå¾ã
+  # ThroughPlugin::get_cell_name plugin.rb ããªã¼ãã¼ã©ã¤ã
+  def get_cell_name
+    @cell_name
+    # @clientChannelCell
+  end
+
+  #=== marshaler ã®ã»ã«ã¿ã¤ãåãè¨­å®ãã
+  def initialize_opaque_marshaler
+
+    # ãªãã·ã§ã³è¨­å®ãããå¤æ°ã®ããã©ã«ããè¨­å®
+    @taskPriority = 11
+    @stackSize  = 4096
+    @serverChannelCelltype = :"tSocketServer"
+    @clientChannelCelltype = :"tSocketClient"
+    @serverChannelCell = :"#{@cell_name}Server"
+    @clientChannelCell = :"#{@cell_name}Client"
+    @serverChannelInitializer = subst_name( "portNo=8931+$count$;" ).to_sym
+    @clientChannelInitializer = subst_name( "portNo=8931+$count$; serverAddr=\"127.0.0.1\"; " ).to_sym
+    @taskCelltype = :"tTask"
+    @PPAllocatorSize = nil
+    # @TDRCelltype  = :"tTDR"   # "tNBOTDR" ã«å¤æ´ã®äºå®
+    @TDRCelltype  = :"tNBOTDR"
+    @substituteAllocator = {}
+    @noServerChannelOpenerCode = false
+    @semaphoreCelltype = :"tSemaphore"
+    @semaphoreInitializer = :"count = 1; attribute = C_EXP( \"TA_NULL\" ); ";
+    @clientErrorHandler = nil
+    @serverErrorHandler = nil
+    @b_genOpener = false
+    @taskMainCelltype = :"tRPCDedicatedTaskMain"
+
+    @marshaler_celltype_name = :"tOpaqueMarshaler_#{@signature.get_global_name}"
+    @unmarshaler_celltype_name = :"tOpaqueUnmarshaler_#{@signature.get_global_name}"
+    @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl"
+
+    # signature ã§å¯¾å¿ã§ããªããã®ããã§ãã¯
+    @signature.each_param{ |func_decl, param_decl|
+      if param_decl.get_direction == :OUT then
+        if param_decl.get_count && ! param_decl.get_size then
+          cdl_error( "#{@signature.get_namespace_path}.#{func_decl.get_name}.#{param_decl.get_name}: size_is must be specified for out parameter of Opaque RPC" )
+        end
+        if param_decl.get_string == -1 then
+          cdl_error( "#{@signature.get_namespace_path}.#{func_decl.get_name}.#{param_decl.get_name}: string length must be specified for out parameter of Opaque RPC" )
+        end
+      end
+    }
+  end
+
+  #=== GenOpaqueMarshaler# Opener Code ã®çææã®ãã§ãã¯
+  def check_opener_code
+    # ãµã¼ãã¼ãã£ã³ãã«ã»ã«ã¿ã¤ãã entry sServerChannelOpener eOpener ãæã¤ãã©ããããã§ãã¯
+    # mikan entry ã (call ã§ãªãã) ããã§ãã¯ãã¦ããªã
+    # scct = Namespace.find ["::", @serverChannelCelltype] # mikan namespace
+    nsp = NamespacePath.analyze( @serverChannelCelltype.to_s )
+    scct = Namespace.find nsp
+    if scct then
+      obj = scct.find( :"eOpener" )
+      if obj.instance_of? Port then
+        if obj.get_signature.get_name.to_sym == :sServerChannelOpener then
+          if @noServerChannelOpenerCode == false then
+            @b_genOpener = true
+            @taskMainCelltype = :"tRPCDedicatedTaskMainWithOpener"
+          end
+        end
+      end
+    end
+    if @noServerChannelOpenerCode == false && @taskMainCelltype != :"tRPCDedicatedTaskMainWithOpener" then
+      cdl_warning( "O9999 ServerChannelOpener code not generated, not found 'entry sServerChannelOpener eOpener'")
+    end
+  end
+
+  #=== GenOpaqueMarshaler# PPAllocator ã®å¿
+è¦æ§ããã§ãã¯ãã
+  def check_PPAllocator
+    if @signature.need_PPAllocator?(true) then
+      if @PPAllocatorSize == nil then
+        cdl_error( "PPAllocatorSize must be speicified for size_is array" )
+      end
+    end
+  end
+
+  ##### 
+
+  def gen_marshaler_celltype
+    f = CFile.open( @marshaler_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    if @PPAllocatorSize then
+      alloc_call_port = "  call sPPAllocator cPPAllocator;\n"
+    else
+      alloc_call_port = ""
+    end
+
+    f.print <<EOT
+
+celltype #{@marshaler_celltype_name} {
+  entry #{@signature.get_namespace_path} eClientEntry;
+  call sTDR       cTDR;
+  [optional]
+    call sSemaphore cLockChannel;
+  [optional]
+    call sRPCErrorHandler cErrorHandler;
+};
+celltype #{@unmarshaler_celltype_name} {
+  call #{@signature.get_namespace_path} cServerCall;
+  call  sTDR       cTDR;
+  [optional]
+    call sRPCErrorHandler cErrorHandler;
+  entry sUnmarshalerMain  eService;
+#{alloc_call_port}};
+EOT
+    f.close
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é ­é¨ã¨æ«å°¾ã¯å¥éåºåï¼
+  #ct_name:: Symbol    (through ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ããï¼ãããï¼
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    # unmarshaler ã¯ã©ã¹ã?
+    if ct_name == @unmarshaler_celltype_name.to_sym then
+      gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    else
+      gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    end
+  end
+
+  #===  marshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    b_void = false
+    b_ret_er = false
+
+    # é¢æ°ã®æ»ãå¤ã®å
+ã®åãå¾ã(typedef ããã¦ããå ´å)
+    type = func_type.get_type.get_original_type
+
+    # æ»ãå¤è¨æ¶ç¨ã®å¤æ°ãåºåï¼void åã®é¢æ°ã§ã¯åºåããªãï¼
+    if ! type.is_void? then
+      file.print( "\t#{func_type.get_type.get_type_str}\t\tretval_;\n" )
+      if func_type.get_type.kind_of?( DefinedType ) && ( func_type.get_type.get_type_str == "ER" || func_type.get_type.get_type_str == "ER_INT" ) then
+        b_ret_er = true
+      end
+    else
+      b_void = true
+    end
+
+    file.print( "\tER\t\tercd_;\n" )
+    file.print( "\tint16_t\tstate_;\n" )
+
+    # é¢æ° ID ï¼æ´æ°å¤ï¼
+    func_id = "FUNCID_#{@signature.get_global_name}_#{func_name}".upcase
+    fid = @signature.get_id_from_func_name( func_name )
+    file.print( "\tint16_t\tfunc_id_ = #{func_id};	/* (id of '#{func_name}') = #{fid}*/\n" )
+
+    # ã·ã³ã°ã«ãã³ã§ãªããï¼
+    if ! b_singleton then
+
+      # singleton ã§ãªããã° p_cellcb åå¾ã³ã¼ããåºå
+      file.print <<EOT
+	#{ct_name}_CB *p_cellcb;
+
+	if( VALID_IDX( idx ) ){
+		p_cellcb = GET_CELLCB(idx);
+EOT
+
+      # ã¨ã©ã¼ãè¿ããï¼
+      if b_ret_er then
+        file.print <<EOT
+	}else{
+		return ERCD( E_RPC, E_ID );
+	}
+EOT
+      else
+        file.print <<EOT
+	}else{
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+	}
+
+EOT
+      end
+    end
+
+    if func_type.has_receive? then
+      file.print "	/* initialize receive parameters */\n"
+      params.each{ |param|
+        if param.get_direction == :RECEIVE then
+          file.print "	*#{param.get_name} = 0;\n"
+        end
+      }
+    end
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+
+	/* Channel Lock */
+	SET_RPC_STATE( state_, RPCSTATE_CLIENT_GET_SEM );
+	if( is_cLockChannel_joined() )
+		cLockChannel_wait();
+EOT
+
+    # SOP ãéä¿¡
+    file.print "	/* SOPã®éåº */\n"
+    file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_SOP );\n"
+    file.print "	if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n"
+    file.print "		goto error_reset;\n"
+
+    # func_id ãéä¿¡
+    file.print "	/* é¢æ° id ã®éåº */\n"
+    file.print "	if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n"
+    file.print "		goto error_reset;\n"
+
+    # p "celltype_name, sig_name, func_name, func_global_name"
+    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+    b_get = false    # marshal ãªã put
+    b_marshal = true  # marshal
+
+    # in æ¹åã®å
+¥åºåãåºå
+    if func_type.has_inward? then
+      file.print "	/* å
+¥åå¼æ°éåº */\n"
+      file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_BODY );\n"
+      print_params( params, file, 1, b_marshal, b_get, true, "eClientEntry", func_name )
+      print_params( params, file, 1, b_marshal, b_get, false, "eClientEntry", func_name )
+    end
+    print_out_nullable( params, file, 1, b_marshal );
+
+    if ! func_type.is_oneway? then
+      b_continue = "true"
+    else
+      b_continue = "false"
+    end
+    file.print "	/* EOPã®éåºï¼ãã±ããã®æãã ãï¼ */\n"
+    file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_SEND_EOP );\n"
+    file.print "	if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n"
+    file.print "		goto error_reset;\n\n"
+
+    # send ã®ã¡ã¢ãªããã¢ã­ã±ã¼ã
+    if func_type.has_send? then
+      file.print "	/* dealloc send parameter while executing */\n"
+      file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_EXEC );\n"
+      dir = :SEND; nest = 1; dealloc_cp = "eClientEntry_#{func_name}"
+      dealloc_for_params( params, file, nest, dir, dealloc_cp )
+      file.print "\n"
+    end
+
+    if ! func_type.is_oneway? then
+
+      file.print "	/* ãã±ããã®å§ã¾ãããã§ãã¯ */\n"
+      file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_SOP );\n"
+      file.print "	if( (ercd_=cTDR_receiveSOP( true )) != E_OK )\n"
+      file.print "		goto error_reset;\n"
+
+      b_get = true     # marshaler ã¯ get
+      file.print "	/* æ»ãå¤ã®åãåã */\n"
+      print_param( "retval_", func_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get )
+
+      if func_type.has_outward? then
+        if b_ret_er then
+          indent_level = 2
+          file.print "	if( MERCD( retval_ ) != E_RPC ){\n"
+        else
+          indent_level = 1
+        end
+        indent = "	" * indent_level
+
+        file.print "#{indent}/* åºåå¤ã®åãåã */\n"
+        file.print "#{indent}SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_BODY );\n"
+        print_params( params, file, indent_level, b_marshal, b_get, true, "eClientEntry", func_name )
+        print_params( params, file, indent_level, b_marshal, b_get, false, "eClientEntry", func_name )
+
+        if b_ret_er then
+          file.print "	}\n"
+        end
+      end
+
+      file.print "\n	/* ãã±ããã®çµããããã§ãã¯ */\n"
+      file.print "	SET_RPC_STATE( state_, RPCSTATE_CLIENT_RECV_EOP );\n"
+      file.print "	if( (ercd_=cTDR_receiveEOP(false)) != E_OK )\n"  # b_continue = false
+      file.print "		goto error_reset;\n"
+
+    end # ! func_type.is_oneway?
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+	/* Channel Unlock */
+	SET_RPC_STATE( state_, RPCSTATE_CLIENT_RELEASE_SEM );
+	if( is_cLockChannel_joined() )
+		cLockChannel_signal();
+EOT
+
+    if( b_void == false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "	return retval_;\n" )
+    else
+      file.print( "	return;\n" )
+    end
+
+    file.print <<EOT
+
+error_reset:
+EOT
+    # send ã®ã¡ã¢ãªããã¢ã­ã±ã¼ã
+    if func_type.has_send? then
+      file.print "	/* dealloc send parameter */\n"
+      file.print "	if( state_ < RPCSTATE_CLIENT_EXEC ){\n"
+      dir = :SEND; nest = 2; dealloc_cp = "eClientEntry_#{func_name}"
+      dealloc_for_params( params, file, nest, dir, dealloc_cp )
+      file.print "	}\n"
+    end
+
+    # receive ã®ã¡ã¢ãªããã¢ã­ã±ã¼ã
+    if func_type.has_receive? then
+      file.print( "	/* receive parameter */\n" )
+      dir = :RECEIVE; nest = 1; dealloc_cp = "eClientEntry_#{func_name}"
+      dealloc_for_params( params, file, nest, dir, dealloc_cp, true )
+    end
+
+    file.print <<EOT
+	if( MERCD( ercd_ ) != E_RESET )
+		(void)cTDR_reset();
+EOT
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+	/* Channel Unlock */
+	if( is_cLockChannel_joined() )
+		cLockChannel_signal();
+
+	if( ercd_ != E_OK && is_cErrorHandler_joined() )
+		cErrorHandler_errorOccured( func_id_, ercd_, state_ );
+EOT
+
+    if( b_ret_er != false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "	return ERCD( E_RPC, MERCD( ercd_ ) );\n" )
+    else
+      file.print( "	return;\n" )
+    end
+
+  end
+
+  #===  unmarshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    b_ret_er = true
+
+    # func_id ãå¾ãã³ã¼ããçæ
+    file.print <<EOT
+
+	int16_t	func_id_;
+	ER		ercd_ = E_OK;
+	int16_t	state_;
+
+	#{ct_name}_CB *p_cellcb;
+
+	if( VALID_IDX( idx ) ){
+		p_cellcb = GET_CELLCB(idx);
+EOT
+
+    if b_ret_er then
+        file.print <<EOT
+	}else{
+		return;
+	}
+EOT
+    else
+        file.print <<EOT
+	}else{
+		/* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+	}
+EOT
+    end
+
+    file.print <<EOT
+
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "Entering RPC service loop" );
+#endif
+
+	/* SOPã®ãã§ãã¯ */
+	SET_RPC_STATE( state_, RPCSTATE_SERVER_RECV_SOP );
+	if( (ercd_=cTDR_receiveSOP( false )) != E_OK )
+		goto error_reset;
+	/* func_id ã®åå¾ */
+	if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK )
+		goto error_reset;
+
+#ifdef RPC_DEBUG
+	syslog(LOG_INFO, "unmarshaler task: func_id: %d", func_id_ );
+#endif
+	switch( func_id_ ){
+EOT
+
+    # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      func_id = "FUNCID_#{@signature.get_global_name}_#{f_name}".upcase
+      fid = @signature.get_id_from_func_name( f_name )
+
+      file.print "	case #{func_id}:		/* (id of '#{f_name}') = #{fid} */ \n"
+      file.print "		ercd_ = tOpaqueUnmarshaler_#{@signature.get_global_name}_#{f_name}( p_cellcb, &state_ );\n"
+      file.print "		break;\n"
+
+    } #
+
+    if @PPAllocatorSize then
+      ppallocator_dealloc_str = "	/* PPAllocator ã®ãã¹ã¦ãè§£æ¾ */\n	cPPAllocator_dealloc_all();"
+    else
+      ppallocator_dealloc_str = ""
+    end
+
+    file.print <<EOT
+	default:
+		syslog(LOG_INFO, "unmarshaler task: ERROR: unknown func_id: %d", func_id_ );
+		ercd_ = E_ID;
+	};
+error_reset:  /* OK cases also come here */
+#{ppallocator_dealloc_str}
+	if( ercd_ == E_OK )
+		return ercd_;
+	if( is_cErrorHandler_joined() )
+		ercd_ = cErrorHandler_errorOccured( func_id_, ercd_, state_ );
+	if( MERCD( ercd_ ) != E_RESET )
+		(void)cTDR_reset();
+	return ercd_;
+EOT
+
+  end
+
+  #=== PREAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ãçæ
+  def gen_preamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    # string.h ã® include (memset, strlen ã®ãã)
+    file.print "/* header file (strlen, memset) */\n"
+    file.print "#include\t<string.h>\n\n"
+
+    file.print "/* ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ */\n"
+    # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+      file.print "static ER  tOpaqueUnmarshaler_#{@signature.get_global_name}_#{f_name}(CELLCB *p_cellcb, int16_t *state);\t/* func_id: #{id} */\n"
+    }
+    file.print "\n"
+  end
+
+  #=== POSTAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãåã
+ã®ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®çæ
+  def gen_postamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    file.print "\n/*** ã¢ã³ãã¼ã·ã£ã©é¢æ° ***/\n\n"
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+
+      # é¢æ°ã¯è¿ãå¤ãæã¤ã?
+      b_ret_er = false
+      init_retval = ""
+      if f_type.get_type.is_void? then
+        b_void = true
+      else
+        b_void = false
+        if f_type.get_type.get_type_str == "ER" || f_type.get_type.get_type_str == "ER_INT" then
+          b_ret_er = true
+          init_retval = " = E_OK"
+        end
+      end
+
+      file.print <<EOT
+/*
+ * name:    #{f_name}
+ * func_id: #{id} 
+ */
+EOT
+      file.print "static ER\n"
+      file.print "tOpaqueUnmarshaler_#{@signature.get_global_name}_#{f_name}(CELLCB *p_cellcb, int16_t *state_)\t\t\n"
+      file.print "{\n"
+      file.print "	ER      ercd_;\n"
+
+      # å¼æ°ãååãå¤æ°ã®å®ç¾©
+      params = f.get_declarator.get_type.get_paramlist.get_items
+           # FuncHead->  Decl->    FuncType->ParamList
+      params.each{ |par|
+        name = par.get_name
+        type = par.get_type.get_original_type
+
+        dir = par.get_direction
+        if( dir == :RECEIVE )then
+          # type ã¯ PtrType ã§ããããåãé¤ããå
+          type = type.get_type
+        end
+        if( dir == :SEND || dir == :RECEIVE )then
+          init = " = 0"
+        else
+          init = ""
+        end
+
+        if type.kind_of? ArrayType then
+          type = type.get_type
+          aster = "(*"
+          aster2 = ")"
+        else
+          aster = ""
+          aster2 = ""
+        end
+
+        type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" ãå¤ã
+        file.printf( "	%-12s %s%s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post, init )
+
+        if dir == :OUT && type.is_nullable? then
+          file.print( "	int8_t\tb_#{name}_null_;\n" )
+        end
+      }
+
+      if ! b_void then
+        file.printf( "	%-12s retval_%s%s;\n", f_type.get_type.get_type_str, f_type.get_type.get_type_str_post, init_retval )
+      end
+
+      # in æ¹åã®å
+¥åºåãå
+¥å
+      file.print "\n	/* å
+¥åå¼æ°åå */\n"
+      file.print "	SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_BODY );\n"
+      b_get = true    # unmarshal ã§ã¯ get
+      b_marshal  = false
+      print_params( params, file, 1, b_marshal, b_get, true, "cServerCall", f_name )
+      print_params( params, file, 1, b_marshal, b_get, false, "cServerCall", f_name )
+      print_out_nullable( params, file, 1, b_marshal );
+
+
+      # ãã±ããã®åä¿¡å®äº
+      file.print "	/* ãã±ããçµããããã§ãã¯ */\n"
+      file.print "	SET_RPC_STATE( *state_, RPCSTATE_SERVER_RECV_EOP );\n"
+      if ! f_type.is_oneway? then
+        b_continue = "true"
+      else
+        b_continue = "false"
+      end
+      file.print "	if( (ercd_=cTDR_receiveEOP(#{b_continue})) != E_OK )\n"
+      file.print "		goto error_reset;\n\n"
+
+      # out ã®ã¡ã¢ãªãã¢ã­ã±ã¼ã
+      dir = :OUT; alloc_cp = "cPPAllocator_alloc"; alloc_cp_extra = nil; nest = 1
+      alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra )
+
+      # å¯¾è±¡é¢æ°ãå¼åºã
+      file.print "	/* å¯¾è±¡é¢æ°ã®å¼åºã */\n"
+      file.print "	SET_RPC_STATE( *state_, RPCSTATE_SERVER_EXEC );\n"
+      if b_void then
+        file.print( "	cServerCall_#{f_name}(" )
+      else
+        file.print( "	retval_ = cServerCall_#{f_name}(" )
+      end
+
+      delim = " "
+      params.each{ |par|
+        file.print delim
+        delim = ", "
+        if par.get_direction == :RECEIVE then
+          file.print "&"
+        end
+        file.print par.get_name
+      }
+      file.print( " );\n" )
+
+      # æ»ãå¤ãåºåå¼æ°ã®ååã³ã¼ãã®çæ
+
+      # oneway ã®å ´ååºåãæ»ãå¤ãç¡ããååãå¾
+ããªãï¼éåæãªå¼åºãï¼
+      if ! f.is_oneway? then
+
+        file.print "\n	/* SOPã®éåº */\n"
+        file.print "	SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_SOP );\n"
+
+        file.print "	if( ( ercd_ = cTDR_sendSOP( false ) ) != E_OK )\n"
+        file.print "		goto error_reset;\n"
+
+        b_get = false     # unmarshaler ã¯ put
+        if( ! b_void )then
+          file.print "	/* æ»ãå¤ã®éåº */\n"
+          print_param( "retval_", f_type.get_type, file, 1, :RETURN, nil, nil, b_marshal, b_get )
+        end
+
+        if f_type.has_outward? then
+          if b_ret_er then
+            indent_level = 2
+            file.print "	if( MERCD( retval_ ) != E_RPC ){\n"
+          else
+            indent_level = 1
+          end
+          indent = "	" * indent_level
+
+          file.print "#{indent}/* åºåå¤ã®éåº */\n"
+          file.print "#{indent}SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_BODY );\n"
+          print_params( params, file, indent_level, b_marshal, b_get, true, "cServerCall", f_name )
+          print_params( params, file, indent_level, b_marshal, b_get, false, "cServerCall", f_name )
+
+          # receive ã®ã¡ã¢ãªããã¢ã­ã±ã¼ã
+          if f_type.has_receive? then
+            file.print "#{indent}/* dealloc receive parameter */\n"
+            dir = :RECEIVE; dealloc_cp = "cServerCall_#{f_name}"
+            dealloc_for_params( params, file, indent_level, dir, dealloc_cp )
+          end
+
+          if b_ret_er then
+            file.print "	}\n"
+          end
+        end
+
+        file.print "	/* ãã±ããã®çµããï¼æãã ãï¼ */\n"
+        file.print "	SET_RPC_STATE( *state_, RPCSTATE_SERVER_SEND_EOP );\n"
+        file.print "	if( (ercd_=cTDR_sendEOP(false)) != E_OK )\n"  # b_continue = false
+        file.print "		goto error_reset;\n"
+      end  # ! f.is_oneway?
+
+      file.print "	return E_OK;\n"
+      file.print <<EOT
+
+error_reset:
+EOT
+      # send ã®ãªã»ããç¨ãã¢ã­ã±ã¼ã
+      if f_type.has_send? then
+        file.print "	/* dealloc send parameter */\n"
+        file.print "	if( *state_ < RPCSTATE_SERVER_EXEC ){\n"
+        dir = :SEND; indent_level = 2; dealloc_cp = "cServerCall_#{f_name}"
+        dealloc_for_params( params, file, indent_level, dir, dealloc_cp, true )
+        file.print "	}\n"
+      end
+
+      # receive ã®ã¡ã¢ãªããã¢ã­ã±ã¼ã
+      if f_type.has_receive? && b_ret_er then
+        file.print "	/* dealloc receive parameter */\n"
+        file.print "	if( MERCD( retval_ ) != E_RPC ){\n"
+        dir = :RECEIVE; indent_level = 2; dealloc_cp = "cServerCall_#{f_name}"
+        dealloc_for_params( params, file, indent_level, dir, dealloc_cp )
+        file.print "	}\n"
+      end
+
+      file.print "	return ERCD( E_RPC, MERCD( ercd_ ) );\n"
+      file.print "}\n\n"
+
+      # ããï¼åã
+ã®é¢æ°ï¼ã§ã¯ã¨ã©ã¼ãã³ãã©ã¼ã¯å¼ã³åºããªããå¼ã³å
+ï¼ãµã¼ãã¼ã®ã¡ã¤ã³é¢æ°ï¼ã§å¼ã³åºãã
+    }
+  end
+ 
+
+  #b_marshal:: bool
+  #b_get:: bool
+  #  b_marshal = true  && b_get == false   :  ãã¼ã·ã£ã©ã§å
+¥åå¼æ°éåº
+  #  b_marshal = true  && b_get == true    :  ãã¼ã·ã£ã©ã§åºåå¼æ°åå
+  #  b_marshal = false && b_get == false   :  ã¢ã³ãã¼ã·ã£ã©ã§å
+¥åå¼æ°åå
+  #  b_marshal = false && b_get == true    :  ã¢ã³ãã¼ã·ã£ã©ã§åºåå¼æ°éåº
+  #b_referenced:: size_is, count_is, string ã§åç
+§ããã¦ãããã®ãåºå
+  def print_params( params, file, nest, b_marshal, b_get, b_referenced, port_name, func_name )
+    params.each{ |param|
+# p "#{param.get_name}:  b_marshal: #{b_marshal} b_get: #{b_get}"
+      if ! ( b_referenced == param.is_referenced? ) then
+        next
+      end
+
+      dir = param.get_direction
+      if( b_get == false && b_marshal == true || b_get == true && b_marshal == false  )then
+        case dir
+        when :IN, :INOUT
+          alloc_cp = "cPPAllocator_alloc"
+          alloc_cp_extra = nil
+          print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        when :SEND
+          alloc_cp = "#{port_name}_#{func_name}_#{param.get_name}_alloc"
+          alloc_cp_extra = nil
+          print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        end
+      else
+        case dir
+        when :OUT, :INOUT
+          alloc_cp = nil        # inout ã® b_get==true&&b_marsha==true ã®ã¨ãã¢ã­ã±ã¼ã¿ã³ã¼ãã¯ä¸ç¨
+          alloc_cp_extra = nil
+          print_param( param.get_name, param.get_type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        when :RECEIVE
+          alloc_cp = "#{port_name}_#{func_name}_#{param.get_name}_alloc"
+          alloc_cp_extra = nil
+          if b_get then
+            outer = "(*"         # ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ã (send ã¨æ¯ã¹) ä¸ã¤å¤ã
+            outer2 = ")"
+          else
+            outer = nil          # ã¢ã³ãã¼ã·ã£ã©å´ã§ã¯ããã¤ã³ã¿ãä¸ã¤å¤ããã¦ãã
+            outer2 = nil
+          end
+          type = param.get_type.get_referto
+          print_param( param.get_name, type, file, nest, dir, outer, outer2, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        end
+      end
+    }
+  end
+
+  #=== ã¢ã­ã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨)
+  def alloc_for_out_params( params, file, nest, dir, alloc_cp, alloc_cp_extra )
+    params.each{ |param|
+      dir = param.get_direction
+      if dir == :OUT then
+        alloc_for_out_param( param.get_name, param.get_type, file, nest, nil, nil, alloc_cp, alloc_cp_extra )
+      end
+    }
+  end
+
+  #=== ã¢ã­ã±ã¼ã¿ã³ã¼ããçæ (out ã®ã¢ã³ãã¼ã·ã£ã©ç¨åå¥ãã©ã¡ã¼ã¿ã®çæ)
+  def alloc_for_out_param( name, type, file, nest, outer, outer2, alloc_cp, alloc_cp_extra )
+    org_type = type.get_original_type
+    if org_type.is_nullable? then
+      indent = "\t" * nest
+      file.print "#{indent}if( ! b_#{name}_null_  ){\n"
+      nest += 1
+    end
+    case org_type
+    when PtrType
+      indent = "\t" * nest
+      count = type.get_count; size = type.get_size; string = type.get_string
+      if count || size || string then
+        loop_counter_type = IntType.new(16)   # mikan æ¹ã size_is, count_is ã®å¼æ°ã®åã¨ãã
+        if count then
+          len = type.get_count.to_s
+        elsif size then
+          len = type.get_size.to_s
+        elsif string then
+          if  type.get_string.instance_of? Expression then
+            len = type.get_string.to_s
+          else
+            raise "unsuscripted string used for out parameter #{name}"
+          end
+        end
+
+        # size_is ã« max æå®ãããå ´åãlength ã max ãè¶
+ãã¦ããããã§ãã¯ããã³ã¼ããçæ
+        if org_type.get_max != nil && string == nil then
+          file.print "#{indent}if( #{len} > #{type.get_max} ){\t/* GenOpaqueMarshaler max check 2 */\n"
+          file.print "#{indent}	ercd_ = E_PAR;\n"
+          file.print "#{indent}	goto error_reset;\n"
+          file.print "#{indent}}\n"
+        end
+
+        file.print <<EOT
+#{indent}if((ercd_=#{alloc_cp}(sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post})*#{len},(void **)&#{outer}#{name}#{outer2}#{alloc_cp_extra}))!=E_OK)\t/* GenOpaqueMarshaler 1 */
+#{indent}	goto error_reset;
+EOT
+
+        if type.get_type.kind_of? PtrType then
+          file.print "#{indent}{\n"
+          file.print "#{indent}	#{loop_counter_type.get_type_str}  i__#{nest}, length__#{nest} = #{len};\n"
+          file.print "#{indent}	for( i__#{nest} = 0; i__#{nest} < length__#{nest}; i__#{nest}++ ){\n"
+          alloc_for_out_param( name, type.get_type, file, nest + 2, outer, "#{outer2}[i__#{nest}]", alloc_cp, alloc_cp_extra )
+          file.print "#{indent}	}\n"
+          file.print "#{indent}}\n"
+        end
+
+      else
+        file.print <<EOT
+#{indent}if((ercd_=#{alloc_cp}(sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post}),(void **)&#{outer}#{name}#{outer2}#{alloc_cp_extra}))!=E_OK)\t/* GenOpaqueMarshaler 2 */
+#{indent}	goto error_reset;
+EOT
+      end
+    end
+    if org_type.is_nullable? then
+      nest -= 1
+      indent = "\t" * nest
+      file.print "#{indent}} else {\n"
+      file.print "#{indent}	#{name} = NULL;\n"
+      file.print "#{indent}}\n"
+      nest += 1
+    end
+  end
+
+  #=== å¼æ°ã®ä¸æ¬ãã¢ã­ã±ã¼ãã³ã¼ãã®çæ
+  # sendï¼ãã¼ã·ã£ã©ã®æå¾ãreceiveï¼ã¢ã³ãã¼ã·ã£ã©ã®æå¾ã§ä¸æ¬ãã¦å¼æ°ããã¢ã­ã±ã¼ããã
+  def dealloc_for_params( params, file, nest, dir, dealloc_cp, b_reset = false )
+    if b_reset then
+      reset_str = "_reset"
+    else
+      reset_str = ""
+    end
+
+    params.each{ |param|
+      if dir == param.get_direction then
+        indent = "\t" * nest
+        type = param.get_type.get_original_type
+        aster = ""
+        if dir == :RECEIVE then
+          type = type.get_type.get_original_type   # ãã¤ã³ã¿ãä¸ã¤å¤ã
+          if b_reset then
+            aster = "*"
+          end
+        end
+        count = type.get_count; size = type.get_size
+        if (size || count) && type.get_type.has_pointer? then
+          if count then
+            len = ", #{type.get_count.to_s}"
+          elsif size then
+            len = ", #{type.get_size.to_s}"
+          end
+        else
+          len = ""
+        end
+        cp = "#{dealloc_cp}_#{param.get_name}_dealloc#{reset_str}".upcase
+        file.print "#{indent}#{cp}(#{aster}#{param.get_name}#{len});\n"
+      end
+    }
+  end
+
+  #== out ã§ nullable ãªå¼æ°ã®æ
+å ±ãæ¸¡ã
+  # out nullable ã®å ´åãin, send, receive ã®ããã«ãå¤ãæ¸¡ãç´åã§ã¯ãªããå¼åºãæã«æ¸¡ã
+  def  print_out_nullable( params, file, nest, b_marshal );
+    indent = "\t" * nest
+    params.each{ |param|
+      next if param.get_direction != :OUT
+      next if ! param.is_nullable?
+      if b_marshal then
+        file.print "#{indent}if( (ercd_=cTDR_putInt8( (int8_t)(#{param.get_name} == NULL) )) != E_OK )\n"
+        file.print "#{indent}\tgoto error_reset;\n"
+      else
+        # å¼ã³å
+ã¯ alloc_for_out_param ã§ nullable ã®å¯¾å¿ãã
+        file.print "#{indent}if( (ercd_=cTDR_getInt8( &b_#{param.get_name}_null_)) != E_OK )\n"
+        file.print "#{indent}\tgoto error_reset;\n"
+      end
+    }
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenParamCopy.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenParamCopy.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenParamCopy.rb	(revision 317)
@@ -0,0 +1,384 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: GenParamCopy.rb 2061 2014-05-31 22:15:33Z okuma-top $
+#++
+
+#= ParamCopy
+#
+# ãã©ã¡ã¼ã¿ã³ãã¼ãããã¼ã·ã£ã©ï¼ã¢ã³ãã¼ã·ã£ã©ã³ã¼ããçæããã¡ã½ãã print_param ãæä¾ããï¼
+# RPCPlugin, OpaqueRPCPlugin ã« include ãããï¼
+# RPCPlugin (ãã©ã³ã¹ãã¢ã¬ã³ã) ã§ã¯ãoneway é¢æ°ã§ in ã®ãã¤ã³ã¿å¼æ°ã®å ´åã«éã£ã¦ print_param ãç¨ããããï¼
+#
+module  GenParamCopy
+
+  #=== å¼æ°ã®è»¢éã³ã¼ããçæ
+
+  def print_param( name, type, file, nest, dir, outer, outer2, b_marshal, b_get, alloc_cp = nil, alloc_cp_extra = nil, name_list = nil )
+    if type.get_original_type.kind_of?( ArrayType ) && b_get && dir != :OUT then
+      indent = "	" * nest
+      subsc = type.get_subscript
+      if subsc == nil
+        raise "Unsubscripted Array Not Supported"
+      else        
+        size_str = subsc.to_str( name_list, outer, outer2 )
+        file.print <<EOT
+#{indent}if((ercd_=#{alloc_cp}(sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post})*(#{size_str}),(void **)&#{outer}#{name}#{outer2}#{alloc_cp_extra}))!=E_OK)\t/* GenParamCopy 1 */
+#{indent}	goto error_reset;
+EOT
+        if ( dir == :SEND || dir == :RECEIVE ) && type.get_type.has_pointer? then
+          # send, receive ã®å ´åã¯ãã¨ã©ã¼ãªã»ããã«åã NULL ã«ãã
+          file.print <<EOT
+#{indent}memset( (void *)#{outer}#{name}#{outer2}#{alloc_cp_extra}, 0, sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post})*(#{size_str});   /* GenParamCopy Alloc1 */
+EOT
+        end
+      end
+    end
+    print_param0( name, type, file, nest, dir, outer, outer2, b_marshal, b_get, alloc_cp, alloc_cp_extra, name_list )
+  end
+
+  def print_param0( name, type, file, nest, dir, outer, outer2, b_marshal, b_get, alloc_cp = nil, alloc_cp_extra = nil, name_list = nil )
+    indent = "	" * nest
+
+    case type
+    when DefinedType
+      print_param0( name, type.get_type, file, nest, dir, outer, outer2, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+    when BoolType, IntType, FloatType
+      case type
+      when BoolType
+        type_str = "Bool"
+      when IntType
+        bit_size = type.get_bit_size
+        case type.get_sign
+        when :UNSIGNED
+          sign = "U"
+        when :SIGNED
+          if bit_size == -1 || bit_size == -11 then
+            sign = "S"   # signed char ã®å ´åã®ã¿ S ãã¤ã
+          else
+            sign = ""
+          end
+        else
+          sign = ""
+        end
+
+        case bit_size
+        when -1, -11  # -1: char_t, -11: char
+          type_str = "#{sign}Char"
+        when -2
+          type_str = "#{sign}Short"
+        when -3
+          type_str = "#{sign}Int"
+        when -4
+          type_str = "#{sign}Long"
+        when -5
+          type_str = "Intptr"
+        when 8, 16, 32, 64, 128
+          type_str = "#{sign}Int#{bit_size}"
+        else
+          raise "unknown bit_size '#{bit_size}' for int type "
+        end
+
+      when FloatType
+        bit_size = type.get_bit_size
+        if bit_size == 32 then
+          type_str = "Float32"
+        else
+          type_str = "Double64"
+        end
+
+      end
+
+      if( b_get )then
+        file.print indent
+        file.print "if( ( ercd_ = cTDR_get#{type_str}( &(#{outer}#{name}#{outer2}) ) ) != E_OK )\t/* GenParamCopy 2 */\n"
+        file.print indent
+        file.print "	goto error_reset;\n"
+      else
+        file.print indent
+        file.print "if( ( ercd_ = cTDR_put#{type_str}( #{outer}#{name}#{outer2} ) ) != E_OK )\t/* GenParamCopy 3 */\n"
+        file.print indent
+        file.print "	goto error_reset;\n"
+      end
+
+    when PtrType
+
+      count = type.get_count; size = type.get_size; string = type.get_string
+      if count || size || string then
+        nest = print_nullable_pre( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+        indent = "\t" * nest
+        loop_counter_type = IntType.new(32)   # mikan åã size_is, count_is ã®å¼æ°ã®åã¨ãã
+        file.print "#{indent}{\t/* GenParamCopy 4 */\n"
+        file.print "#{indent}	#{loop_counter_type.get_type_str}  i__#{nest}, length__#{nest};\n"
+
+        if size || count then
+          if size then
+            size_str = size.to_str( name_list, outer, outer2 )
+          end
+
+          if count then
+            count_str = count.to_str( name_list, outer, outer2 )
+          else
+            # size_is ã¯å¿
+é . count_is ã¯ãªãã·ã§ã³
+            count_str = size_str
+          end
+          file.print "#{indent}	length__#{nest} = #{count_str};\t/* GenParamCopy 5 */\n"
+
+          # size_is ã« max æå®ãããå ´åãlength ã max ãè¶
+ãã¦ããããã§ãã¯ããã³ã¼ããçæ
+              # alloc_cp == nil ã®ã¨ã dir ã¯ INOUT, OUT ã®ã¯ã (æ¡ä»¶ãåé·)ãè©¦é¨ãçµãã£ã¦ããã®ã§ãæ¬¡åè¦ç´ãæã«å¤ã
+          if b_get && type.get_max != nil && ! ( ( dir == :INOUT || dir == :OUT ) && alloc_cp == nil ) then
+            file.print "#{indent}	if( length__#{nest} > #{type.get_max.to_s} ){\t/* GenParamCopy max check 1 */\n"
+            file.print "#{indent}		ercd_ = E_PAR;\n"
+            file.print "#{indent}		goto error_reset;\n"
+            file.print "#{indent}	}\n"
+          end
+
+        else # if string then
+          case type.get_type.get_bit_size
+          when -1              # char_t
+            b_size = 8
+          when 8, 16, 32, 64   # intN_t, uintN_t
+            b_size = type.get_type.get_bit_size
+          else
+            cdl_error( "R9999 $1: string specifier cannot be specified to '$2' in current implementation",
+                       name, type.get_type.get_type_str + type.get_type.get_type_str_post )
+          end
+          if ! b_get then
+            if  string.instance_of? Expression then
+              len = string.to_str( name_list, outer, outer2 )
+              file.print "#{indent}	length__#{nest} = STRNLEN#{b_size}(#{outer}#{name}#{outer2},(#{len}-1))+1;\t/* GenParamCopy 6 */\n"
+              file.print "#{indent}	if( length__#{nest} < #{len})\tlength__#{nest} += 1;\n"
+            else
+              file.print "#{indent}	length__#{nest} = STRLEN#{b_size}(#{outer}#{name}#{outer2})+1;\t/* GenParamCopy 7 */\n"
+            end
+            size_str = "length__#{nest}"     # string ã®å ´åãstrnlen ä»¥ä¸ã®é åãç¢ºä¿ããªã
+          else
+            if ( dir == :INOUT ) then
+              if ( string.instance_of? Expression ) then
+                len = string.to_str( name_list, outer, outer2 )
+                size_str = "#{len}"              # string(len) ã®å ´å len ãç¢ºä¿ãã
+              else
+                raise "unsuscripted string used for inout parameter #{name}"
+              end
+            else
+              size_str = "length__#{nest}"     # string ã®å ´åãstrnlen ä»¥ä¸ã®é åãç¢ºä¿ããªã
+            end
+          end
+          print_param0( "length__#{nest}", loop_counter_type, file, nest + 1, dir, nil, nil, b_marshal, b_get )
+        end
+
+        if b_get && ( dir == :IN || dir == :INOUT || dir == :SEND || dir == :RECEIVE ) && alloc_cp then
+          file.print <<EOT
+#{indent}	if((ercd_=#{alloc_cp}(sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post})*(#{size_str}),(void **)&#{outer}#{name}#{outer2}#{alloc_cp_extra}))!=E_OK)\t/* GenParamCopy 8 */
+#{indent}		goto error_reset;
+EOT
+          if ( dir == :SEND || dir == :RECEIVE ) && type.get_type.has_pointer? then
+            # send, receive ã®å ´åã¯ãã¨ã©ã¼ãªã»ããã«åã NULL ã«ãã
+            file.print <<EOT
+#{indent}	memset( (void *)#{outer}#{name}#{outer2}#{alloc_cp_extra}, 0, sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post})*(#{size_str}) );   /* GenParamCopy Alloc2 */
+EOT
+          end
+        end
+        file.print "#{indent}	for( i__#{nest} = 0; i__#{nest} < length__#{nest}; i__#{nest}++ ){\t/* GenParamCopy 9 */\n"
+
+        print_param0( name, type.get_type, file, nest + 2, dir, outer, "#{outer2}[i__#{nest}]", b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        file.print "#{indent}	}\n"
+        file.print "#{indent}}\n"
+
+        nest = print_nullable_post( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+        indent = "\t" * nest
+      else
+
+        # nullable (pre)
+        nest = print_nullable_pre( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+        indent = "	" * nest
+
+        # allocate memory for getting value
+        if b_get && ( dir == :IN || dir == :INOUT || dir == :SEND || dir == :RECEIVE ) && alloc_cp then
+          file.print <<EOT
+#{indent}if((ercd_=#{alloc_cp}(sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post}),(void **)&#{outer}#{name}#{outer2}#{alloc_cp_extra}))!=E_OK)\t/* GenParamCopy 10 */
+#{indent}	 goto error_reset;
+EOT
+          if ( dir == :SEND || dir == :RECEIVE ) && type.get_type.has_pointer? then
+            # send, receive ã®å ´åã¯ãã¨ã©ã¼ãªã»ããã«åã NULL ã«ãã
+            file.print <<EOT
+#{indent}memset( (void *)#{outer}#{name}#{outer2}#{alloc_cp_extra}, 0, sizeof(#{type.get_type.get_type_str}#{type.get_type.get_type_str_post}) );   /* GenParamCopy Alloc3 */
+EOT
+          end
+        end
+
+        print_param0( name, type.get_type, file, nest, dir, "(*#{outer}", "#{outer2})", b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        # nullable (post)
+        nest = print_nullable_post( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+        indent = "	" * nest
+      end
+    when StructType
+      members_decl =type.get_members_decl
+      members_decl.get_items.each { |m|
+        if m.is_referenced?
+          print_param0( m.get_name, m.get_type, file, nest, dir, "#{outer}#{name}#{outer2}.", nil, b_marshal, b_get, alloc_cp, alloc_cp_extra, members_decl )
+        end
+      }
+      members_decl.get_items.each { |m|
+        if ! m.is_referenced?
+          print_param0( m.get_name, m.get_type, file, nest, dir, "#{outer}#{name}#{outer2}.", nil, b_marshal, b_get, alloc_cp, alloc_cp_extra, members_decl )
+        end
+      }
+
+    when VoidType
+    when EnumType  # mikan EnumType
+    when FuncType  # mikan FuncType
+    when ArrayType # mikan ArrayType
+      subsc = type.get_subscript
+      if subsc == nil
+        raise "Unsubscripted Array Not Supported"
+      else        
+        size_str = subsc.to_str( name_list, outer, outer2 )
+
+        loop_counter_type = IntType.new(32)   # mikan åã size_is, count_is ã®å¼æ°ã®åã¨ãã
+        file.print "#{indent}{\t/* GenParamCopy 11 */\n"
+        file.print "#{indent}	#{loop_counter_type.get_type_str}  i__#{nest}, length__#{nest} = #{size_str};\n"
+
+        file.print "#{indent}	for( i__#{nest} = 0; i__#{nest} < length__#{nest}; i__#{nest}++ ){\n"
+        print_param0( name, type.get_type, file, nest + 2, dir, outer, "#{outer2}[i__#{nest}]", b_marshal, b_get, alloc_cp, alloc_cp_extra )
+        file.print "#{indent}	}\n"
+        file.print "#{indent}}\n"
+      end
+    end
+  end
+
+  #=== nullable (pre)
+  def print_nullable_pre( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+    if type.is_nullable? then
+      indent = "	" * nest
+      if dir == :OUT then  # OUT ã®å ´å print_out_nullable ã§ NULL ãã©ããã®æ
+å ±ãæ¸¡ã
+        # 'null or not' is sent in the function 'print_out_nullable'
+        if b_get then
+          file.print "#{indent}if( #{outer}#{name}#{outer2} ){\t/* GenParamCopy Null 10 */\n"
+        else
+          file.print "#{indent}if( ! b_#{name}_null_ ){\t/* GenParamCopy Null 11 */\n"
+        end
+        nest += 1
+      else # dir = :IN, :INOUT, :SEND, :RECEIVE
+        if b_get then
+          file.print "#{indent}{\n"
+          if ! ( dir == :INOUT && b_marshal == true ) then
+            file.print <<EOT
+#{indent}	int8_t  b_null_;
+#{indent}	if((ercd_=cTDR_getInt8( &b_null_ )) != E_OK )\t/* GenParamCopy Null 20 */
+#{indent}		 goto error_reset;
+#{indent}	if( ! b_null_ ){
+EOT
+          else # dir = :INOUT, b_marshal = true, b_get = true ã®å ´åãNULL ãã©ããã®æ
+å ±ãæ¸¡ããªã
+            file.print <<EOT
+#{indent}	int8_t  b_null_ = (#{outer}#{name}#{outer2} == NULL);\t/* GenParamCopy Null 21 */
+#{indent}	if( ! b_null_ ){
+EOT
+          end
+        else
+          file.print <<EOT
+#{indent}{
+#{indent}	int8_t  b_null_ = (int8_t)(#{outer}#{name}#{outer2} == NULL);\t/* GenParamCopy Null 31 */
+EOT
+
+          if ! ( dir == :INOUT && b_marshal == false ) then
+            # dir = :INOUT, b_marshal = false, b_get = false ã®å ´å
+            file.print <<EOT
+#{indent}	if((ercd_=cTDR_putInt8( b_null_ )) != E_OK )\t/* GenParamCopy Null 32 */
+#{indent}		 goto error_reset;
+EOT
+          end
+
+          file.print <<EOT
+#{indent}	if( ! b_null_ ){\t/* GenParamCopy Null 33 */
+EOT
+        end
+        nest += 2
+      end
+    end
+    return nest
+  end
+
+  #== nullable (post)
+  def print_nullable_post( name, type, file, nest, dir, outer, outer2, b_marshal, b_get )
+    if type.is_nullable? then
+      if dir == :OUT then  # OUT ã®å ´å print_out_nullable ã§ NULL ãã©ããã®æ
+å ±ãæ¸¡ã
+        nest -= 1
+        indent = "	" * nest
+        file.print "#{indent}}  /* ! b_#{name}_null_   GenParamCopy Null 50 */\n"
+      else # ( dir == :IN || dir == :INOUT || dir == :SEND || dir == :RECEIVE )
+        nest -= 2
+        indent = "	" * nest
+        if b_get then
+          if ! ( dir == :INOUT && b_marshal == true ) then
+            file.print <<EOT
+
+#{indent}	} else { /* null  GenParamCopy Null 51 */
+#{indent}		#{outer}#{name}#{outer2} = NULL;
+#{indent}	}  /* ! b_null_ */
+EOT
+          else # dir = :INOUT, b_marshal = true   # inout ã® out æ¹å
+            file.print "#{indent}	}  /* ! b_null_  GenParamCopy Null 52 */\n"
+          end
+        else
+          file.print "#{indent}	}\t/* GenParamCopy Null 53 */\n"
+        end
+        file.print "#{indent}}\t/* GenParamCopy Null 54 */\n"
+      end
+    end
+    return nest
+  end
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb	(revision 317)
@@ -0,0 +1,720 @@
+# -*- coding: utf-8 -*-
+#
+#  TECS Generator
+#      Generator for TOPPERS Embedded Component System
+#  
+#   Copyright (C) 2008-2014 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: GenTransparentMarshaler.rb 2418 2016-01-04 12:17:36Z okuma-top $
+#++
+
+#ãã©ã°ã¤ã³ãªãã·ã§ã³ç¨å¤æ°
+#@task_priority:: Integer
+#@channelCelltype:: String
+#@channelCellName:: String
+#@PPAllocatorSize:: Integer
+module GenTransparentMarshaler
+
+  # ãã©ã°ã¤ã³å¼æ°åã¨ Proc
+  RPCPluginArgProc = {
+    "taskPriority"    => Proc.new { |obj,rhs| obj.set_taskPriority rhs },
+    "channelCelltype" => Proc.new { |obj,rhs| obj.set_channelCelltype rhs },
+    "TDRCelltype"     => Proc.new { |obj,rhs| obj.set_TDRCelltype rhs },
+    "channelCell"     => Proc.new { |obj,rhs| obj.set_channelCellName rhs },
+    "PPAllocatorSize" => Proc.new { |obj,rhs| obj.set_PPAllocatorSize rhs },
+  }
+
+  #=== ãã©ã°ã¤ã³å¼æ° taskPriority ã®ãã§ãã¯
+  def set_taskPriority( rhs )
+    @task_priority = rhs
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° channelCelltype ã®ãã§ãã¯
+  def set_channelCelltype( rhs )
+    @channelCelltype = rhs.to_sym
+    # path = [ "::", @channelCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @channelCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: channeclCelltype '#{rhs}' not celltype or not found" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° TDRCelltype ã®ãã§ãã¯
+  def set_TDRCelltype( rhs )
+    @TDRCelltype = rhs.to_sym
+    # path = [ "::", @TDRCelltype ]
+    # obj = Namespace.find( path )
+    nsp = NamespacePath.analyze( @TDRCelltype.to_s )
+    obj = Namespace.find( nsp )
+    if ! obj.instance_of?( Celltype ) && ! obj.instance_of?( CompositeCelltype ) then
+      cdl_error( "RPCPlugin: TDRCelltype '#{rhs}' not celltype or not found" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° channelCellName ã®ãã§ãã¯
+  def set_channelCellName( rhs )
+    @channelCellName = rhs
+    if @channelCellName =~ /\A[a-zA-Z_]\w*/ then
+      # OK
+    else
+      cdl_error( "RPCPlugin: channeclCellName '#{rhs}' unsuitable for identifier" )
+    end
+  end
+
+  #=== ãã©ã°ã¤ã³å¼æ° PPAllocatorSize ã®ãã§ãã¯
+  def set_PPAllocatorSize( rhs )
+    @PPAllocatorSize = rhs
+  end
+
+  #=== marshaler ã®ã»ã«ã¿ã¤ãåãè¨­å®ãã
+  def initialize_transparent_marshaler cell_name
+    @task_priority = 8
+    @channelCelltype = "tDataqueueOWChannel"
+    @TDRCelltype     = "tTDR"
+    @channelCellName = "#{cell_name}_Channel"
+    @PPAllocatorSize = nil
+
+    @marshaler_celltype_name = "tMarshaler_#{@signature.get_global_name}"
+    @unmarshaler_celltype_name = "tUnmarshaler_#{@signature.get_global_name}"
+    @marshaler_celltype_file_name = "#{$gen}/#{@marshaler_celltype_name}.cdl"
+  end
+
+  def gen_marshaler_celltype 
+
+    if @PPAllocatorSize then
+      alloc_call_port = "  call sPPAllocator cPPAllocator;\n"
+    else
+      alloc_call_port = ""
+    end
+
+    f = CFile.open( @marshaler_celltype_file_name, "w" )
+    # åãå
+å®¹ãäºåº¦æ¸ãå¯è½æ§ãã (AppFile ã¯ä¸å¯)
+
+    f.print <<EOT
+
+celltype #{@marshaler_celltype_name} {
+  entry #{@signature.get_namespace_path} eClientEntry;
+  call sTDR        cTDR;
+  call sEventflag  cEventflag;
+  [optional]
+    call sSemaphore cLockChannel;  // this port is eliminated by optimize
+};
+celltype #{@unmarshaler_celltype_name} {
+  call #{@signature.get_namespace_path} cServerCall;
+  call sTDR        cTDR;
+  call sEventflag  cEventflag;
+  entry sUnmarshalerMain  eUnmarshalAndCallFunction;
+#{alloc_call_port}};
+EOT
+    f.close
+  end
+
+  #===  åãå£é¢æ°ã®æ¬ä½ã³ã¼ããçæï¼é ­é¨ã¨æ«å°¾ã¯å¥éåºåï¼
+  #ct_name:: Symbol    (through ãã©ã°ã¤ã³ã§çæããã) ã»ã«ã¿ã¤ãå ï¼Symbol ã¨ãã¦éããã¦ããï¼ãããï¼
+  def gen_ep_func_body( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    # unmarshaler ã¯ã©ã¹ã?
+    if ct_name == @unmarshaler_celltype_name.to_sym then
+      gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    else
+      gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+    end
+  end
+
+  #===  marshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_marshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+    b_void = false
+    b_ret_er = false
+
+    # é¢æ°ã®æ»ãå¤ã®å
+ã®åãå¾ã(typedef ããã¦ããå ´å)
+    type = func_type.get_type.get_original_type
+
+    # æ»ãå¤è¨æ¶ç¨ã®å¤æ°ãåºåï¼void åã®é¢æ°ã§ã¯åºåããªãï¼
+    if ! type.is_void? then
+      if func_type.get_type.kind_of?( DefinedType ) && ( func_type.get_type.get_type_str == "ER" || func_type.get_type.get_type_str == "ER_INT" ) then
+        file.print( "    #{func_type.get_type.get_type_str}  retval_ = E_OK;\n" )
+        b_ret_er = true
+      else
+        file.print( "    #{func_type.get_type.get_type_str}  retval_;\n" )
+      end
+    else
+      b_void = true
+    end
+
+    file.print( "    ER      ercd_;\n" )
+    file.print( "    FLGPTN  flgptn;\n" )
+
+    # å¼ã³å
+ã® signature ãåãåºã
+    signature = @signature
+
+    # é¢æ° ID ï¼æ´æ°å¤ï¼
+    func_id = signature.get_id_from_func_name( func_name )
+    file.print( "    int16_t  func_id_ = #{func_id};    /* id of #{func_name}: #{func_id} */\n" )
+
+    # ã·ã³ã°ã«ãã³ã§ãªããï¼
+    if ! b_singleton then
+
+      # singleton ã§ãªããã° p_cellcb åå¾ã³ã¼ããåºå
+      file.print <<EOT
+    #{ct_name}_CB *p_cellcb;
+
+    if( VALID_IDX( idx ) ){
+        p_cellcb = GET_CELLCB(idx);
+EOT
+
+      # ã¨ã©ã¼ãè¿ããï¼
+      if b_ret_er then
+        file.print <<EOT
+    }else{
+         return ERCD( E_RPC, E_ID );
+    }
+EOT
+      else
+        file.print <<EOT
+    }else{
+        /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+    }
+EOT
+      end
+    end
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+    /* Channel Lock */
+    if( is_cLockChannel_joined() )
+      cLockChannel_wait();
+
+EOT
+
+    # SOP ãéä¿¡
+    file.print "    /* SOPã®éåº */\n"
+    file.print "    if( ( ercd_ = cTDR_sendSOP( true ) ) != E_OK )\n"
+    file.print "      goto error_reset;\n"
+
+    # func_id ãéä¿¡
+    file.print "    /* é¢æ° id ã®éåº */\n"
+    file.print "    if( ( ercd_ = cTDR_putInt16( func_id_ ) ) != E_OK )\n"
+    file.print "        goto error_reset;\n"
+
+    # p "celltype_name, sig_name, func_name, func_global_name"
+    # p "#{ct_name}, #{sig_name}, #{func_name}, #{func_global_name}"
+
+    b_get = false    # marshal ãªã put
+    b_marshal = true  # marshal
+
+    # in æ¹åã®å
+¥åºåãåºå
+    file.print "    /* å
+¥åå¼æ°éåº */\n"
+    print_params( params, file, 1, b_marshal, b_get, true, func_type.is_oneway? )
+    print_params( params, file, 1, b_marshal, b_get, false, func_type.is_oneway? )
+    if ! b_void && ! func_type.is_oneway? then
+      ret_ptr_type = PtrType.new( func_type.get_type )
+      print_param_nc( "retval_", ret_ptr_type, file, 1, :RETURN, "&", nil, b_get )
+    end
+
+    file.print "    /* EOPã®éåºï¼ãã±ããã®æãã ãï¼ */\n"
+    if ! func_type.is_oneway? then
+      b_continue = "true"
+    else
+      b_continue = "false"
+    end
+    file.print "    if( (ercd_=cTDR_sendEOP(#{b_continue})) != E_OK )\n"
+    file.print "        goto error_reset;\n\n"
+
+    if ! func_type.is_oneway? then
+      file.print <<EOT
+    if( (ercd_=cEventflag_wait( 0x01, TWF_ANDW, &flgptn )) != E_OK ){
+      ercd_ = ERCD(E_RPC,ercd_);
+      goto error_reset;
+    }
+    if( (ercd_=cEventflag_clear( 0x00 ) ) != E_OK ){
+      ercd_ = ERCD(E_RPC,ercd_);
+      goto error_reset;
+    }
+EOT
+    end # ! func_type.is_oneway?
+
+    file.print <<EOT
+    /* Channel Lock */
+    if( is_cLockChannel_joined() )
+      cLockChannel_signal();
+EOT
+
+    if( b_void == false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "    return retval_;\n" )
+    else
+      file.print( "    return;\n" )
+    end
+
+    file.print <<EOT
+
+error_reset:
+    if( ercd_ != ERCD( E_RPC, E_RESET ) )
+        (void)cTDR_reset();
+EOT
+
+    # channel lock ã³ã¼ã
+    file.print <<EOT
+    /* Channel Lock */
+    if( is_cLockChannel_joined() )
+      cLockChannel_signal();
+
+EOT
+
+    if( b_ret_er != false )then
+      # å¼ã³å
+ã«æ»ãå¤ããªã¿ã¼ã³
+      file.print( "    return ercd_;\n" )
+    else
+      file.print( "    return;\n" )
+    end
+
+  end
+
+  #===  unmarshal ã³ã¼ãã®çæ
+  def gen_ep_func_body_unmarshal( file, b_singleton, ct_name, global_ct_name, sig_name, ep_name, func_name, func_global_name, func_type, params )
+
+#    b_ret_er = true
+    b_ret_er = false
+
+    # func_id ãå¾ãã³ã¼ããçæ
+    file.print <<EOT
+
+    int16_t   func_id_;
+    ER        ercd_;
+
+    #{ct_name}_CB *p_cellcb;
+
+    if( VALID_IDX( idx ) ){
+        p_cellcb = GET_CELLCB(idx);
+EOT
+
+    if b_ret_er then
+        file.print <<EOT
+    }else{
+        return ERCD( E_RPC, E_ID );
+    }
+EOT
+    else
+        file.print <<EOT
+    }else{
+        /* ã¨ã©ã¼å¦çã³ã¼ããããã«è¨è¿° */
+    }
+EOT
+    end
+
+    file.print <<EOT
+
+    /* SOPã®ãã§ãã¯ */
+    if( (ercd_=cTDR_receiveSOP( false )) != E_OK )
+        goto error_reset;
+    /* func_id ã®åå¾ */
+    if( (ercd_=cTDR_getInt16( &func_id_ )) != E_OK )
+        goto error_reset;
+
+#ifdef RPC_DEBUG
+    syslog(LOG_INFO, "unmarshaler task: func_id: %d", func_id_ );
+#endif
+    switch( func_id_ ){
+EOT
+
+    # å¼ã³å
+ã® signature ãåãåºã
+    # port = @celltype.find( @next_cell_port_name )
+    # signature = port.get_signature
+    signature = @signature
+
+    # through ã® signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = signature.get_id_from_func_name( f_name )
+
+      # é¢æ°ã¯è¿ãå¤ãæã¤ã?
+      if f_type.get_type.is_void? then
+        b_void = true
+      else
+        b_void = false
+      end
+
+      # ãã±ããã®çµããããã§ãã¯ï¼æªåãåãã®ãã¼ã¿ãæ®ã£ã¦ããªãããã§ãã¯ï¼
+      file.print "    case #{id}:       /*** #{f_name} ***/ \n"
+      file.print "        if( tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}() != E_OK )\n"
+      file.print "            goto error_reset;\n"
+      file.print "        break;\n"
+
+    } # 
+
+    if @PPAllocatorSize then
+      ppallocator_dealloc_str = "    /* PPAllocator ã®ãã¹ã¦ãè§£æ¾ */\n    cPPAllocator_dealloc_all();"
+    else
+      ppallocator_dealloc_str = ""
+    end
+
+
+    file.print <<EOT
+    default:
+        syslog(LOG_INFO, "unmarshaler task: ERROR: unknown func_id: %d", func_id_ );
+    };
+#{ppallocator_dealloc_str}
+    return;
+
+error_reset:
+    if( ercd_ != ERCD( E_RPC, E_RESET ) )
+        (void)cTDR_reset();
+#{ppallocator_dealloc_str}
+EOT
+
+  end
+
+  # IN b_marshal, b_get
+  #  b_marshal = true  && b_get == false   :  ãã¼ã·ã£ã©ã§å
+¥åå¼æ°éåº
+  #  b_marshal = true  && b_get == true    :  ãã¼ã·ã£ã©ã§åºåå¼æ°åå
+  #  b_marshal = false && b_get == true    :  ã¢ã³ãã¼ã·ã£ã©ã§å
+¥åå¼æ°åå
+  #  b_marshal = false && b_get == get     :  ã¢ã³ãã¼ã·ã£ã©ã§åºåå¼æ°éåº
+  def print_params( params, file, nest, b_marshal, b_get, b_referenced, b_oneway = false )
+    params.each{ |param|
+# p "#{param.get_name}:  b_marshal: #{b_marshal} b_get: #{b_get}"
+      if ! ( b_referenced == param.is_referenced? ) then
+        next
+      end
+
+      dir = param.get_direction
+      type = param.get_type
+      if b_oneway && dir == :IN && type.get_original_type.kind_of?( PtrType ) || type.get_original_type.kind_of?( ArrayType ) then
+        # oneway, in, PtrType ã®å ´åã³ãã¼
+        alloc_cp = "cPPAllocator_alloc"
+        alloc_cp_extra = nil
+        print_param( param.get_name, type, file, nest, dir, nil, nil, b_marshal, b_get, alloc_cp, alloc_cp_extra )
+      else
+        if( b_get == false && b_marshal == true || b_get == true && b_marshal == false  )then
+          case dir
+#          when :IN, :INOUT, :SEND
+          when :IN, :INOUT, :OUT, :SEND, :RECEIVE
+            print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
+          end
+        else
+#         case dir
+#         when :OUT, :INOUT, :RECEIVE
+#         when :RECEIVE
+#           print_param_nc( param.get_name, type, file, nest, b_marshal, nil, nil, b_get )
+#         end
+        end
+      end
+    }
+  end
+
+  #=== ã³ãã¼ããªãå¼æ°æ¸¡ãã³ã¼ãã®åºå
+  def print_param_nc( name, type, file, nest, b_marshal, outer, outer2, b_get )
+    indent = "    " * ( nest + 1 )
+
+    case type
+    when DefinedType
+      print_param_nc( name, type.get_type, file, nest, b_marshal, outer, outer2, b_get )
+    when BoolType, IntType, FloatType, PtrType, ArrayType
+      case type
+      when BoolType
+        type_str = "Int8"
+        cast_str = "int8_t"
+      when IntType
+        bit_size = type.get_bit_size
+        case type.get_sign
+        when :UNSIGNED
+          signC = "U"
+          sign  = "u"
+        when :SIGNED
+          if bit_size == -1 || bit_size == -11 then
+            # signed char ã®å ´åãsigned ãæå®ãã
+            signC = "S"
+            sign  = "s"
+          else
+            signC = ""
+            sign  = ""
+          end
+        else
+          signC = ""
+          sign  = ""
+        end
+
+        # p "pn:: #{name} #{bit_size} #{type.get_type_str}"
+        case bit_size
+        when  -1, -11  # -1: char_t, -11: char
+          type_str = "#{signC}Char"
+          cast_str = "#{sign}char_t"
+        when -2
+          type_str = "#{signC}Short"
+          cast_str = "#{sign}short_t"
+        when -3
+          type_str = "#{signC}Int"
+          cast_str = "#{sign}int_t"
+        when -4
+          type_str = "#{signC}Long"
+          cast_str = "#{sign}long_t"
+        when -5
+          type_str = "Intptr"
+          cast_str = "intptr_t"
+        when 8, 16, 32, 64, 128
+          type_str = "#{signC}Int#{bit_size}"
+          cast_str = "#{sign}int#{bit_size}_t"
+        else
+          raise "unknown bit_size '#{bit_size}' for int type "
+        end
+
+      when FloatType
+        bit_size = type.get_bit_size
+        if bit_size == 32 then
+          type_str = "Float32"
+          cast_str = "float32_t"
+        else
+          type_str = "Double64"
+          cast_str = "double64_t"
+        end
+
+      when PtrType
+        type_str = "Intptr"
+        cast_str = "intptr_t"
+      when ArrayType
+        type_str = "Intptr"
+        cast_str = "intptr_t"
+      end
+
+      if type.get_type_str == cast_str then
+        cast_str = ""
+      else
+        cast_str = "(" + cast_str + ")"
+      end
+
+      if( b_get )then
+        cast_str.gsub!( /\)$/, "*)" )
+        file.print "    " * nest
+        file.print "if( ( ercd_ = cTDR_get#{type_str}( #{cast_str}&(#{outer}#{name}#{outer2}) ) ) != E_OK )\n"
+        file.print "    " * nest
+        file.print "    goto error_reset;\n"
+      else
+        file.print "    " * nest
+        file.print "if( ( ercd_ = cTDR_put#{type_str}( #{cast_str}#{outer}#{name}#{outer2} ) ) != E_OK )\n"
+        file.print "    " * nest
+        file.print "    goto error_reset;\n"
+      end
+
+    when StructType
+      members_decl =type.get_members_decl
+      members_decl.get_items.each { |m|
+        if m.is_referenced? then
+          print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
+        end
+      }
+      members_decl.get_items.each { |m|
+        if ! m.is_referenced? then
+          print_param_nc( m.get_name, m.get_type, file, nest, b_marshal, "#{outer}#{name}#{outer2}.", nil, b_get )
+        end
+      }
+
+    when VoidType
+    when EnumType  # mikan EnumType
+    when FuncType  # mikan FuncType
+    end
+  end
+
+
+  #=== PREAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ãçæ
+  def gen_preamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    file.print "/* ã¢ã³ãã¼ã·ã£ã©é¢æ°ã®ãã­ãã¿ã¤ãå®£è¨ */\n"
+    # signature ã«å«ã¾ãã ãã¹ã¦ã®é¢æ°ã«ã¤ãã¦
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+      file.print "static ER  tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}();\t/* func_id: #{id} */\n"
+    }
+    file.print "\n"
+  end
+
+  #=== POSTAMBLE é¨ã®ã³ã¼ãçæ
+  # ã¢ã³ãã¼ã·ã£ã©ã»ã«ã¿ã¤ãã®å ´åãã¢ã³ãã¼ã·ã£ã©é¢æ°ã®çæ
+  def gen_postamble file, b_singleton, ct_name, global_name
+    if ct_name != @unmarshaler_celltype_name.to_sym then
+      return
+    end
+
+    file.print "\n/*** ã¢ã³ãã¼ã·ã£ã©é¢æ° ***/\n\n"
+    @signature.get_function_head_array.each { |f|
+      f_name = f.get_name
+      f_type = f.get_declarator.get_type
+      id = @signature.get_id_from_func_name( f_name )
+
+      # é¢æ°ã¯è¿ãå¤ãæã¤ã?
+      if f_type.get_type.is_void? then
+        b_void = true
+      else
+        b_void = false
+      end
+
+      file.print <<EOT
+/*
+ * name:    #{f_name}
+ * func_id: #{id} 
+ */
+EOT
+      file.print "static ER\n"
+      file.print "tTransparentUnmarshaler_#{@signature.get_global_name}_#{f_name}()\n"
+      file.print "{\n"
+      file.print "	ER  ercd_;\n"
+      file.print "	CELLCB  *p_cellcb;\n"
+
+      # å¼æ°ãååãå¤æ°ã®å®ç¾©
+      param_list = f.get_declarator.get_type.get_paramlist.get_items
+           # FuncHead->  Decl->    FuncType->ParamList
+      param_list.each{ |par|
+        name = par.get_name
+        type = par.get_type
+        if type.kind_of? ArrayType then
+          type = type.get_type
+          aster = "(*"
+          aster2 = ")"
+        else
+          aster = ""
+          aster2 = ""
+        end
+
+        type_str = type.get_type_str.gsub( /\bconst\b */, "" ) # "const" ãå¤ã
+
+        file.printf( "    %-12s %s%s%s%s;\n", type_str, aster, name, aster2, type.get_type_str_post )
+      }
+
+      # æ»ãå¤ãåãåãå¤æ°ã®å®ç¾©
+      if ! b_void then
+        if f.is_oneway? then
+          retval_ptr = ""   # oneway ã®å ´åãåãåããæ¨ã¦ããã
+        else
+          retval_ptr = "*"
+        end
+        file.printf( "    %-12s #{retval_ptr}retval_%s;\n", f_type.get_type.get_type_str, f_type.get_type.get_type_str_post )
+      end
+
+      # in æ¹åã®å
+¥åºåãå
+¥å
+      file.print "\n        /* å
+¥åå¼æ°åå */\n"
+      b_get = true    # unmarshal ã§ã¯ get
+      b_marshal  = false
+      print_params( param_list, file, 1, b_marshal, b_get, true, f.is_oneway? )
+      print_params( param_list, file, 1, b_marshal, b_get, false, f.is_oneway? )
+      if ! b_void && ! f.is_oneway? then
+        ret_ptr_type = PtrType.new( f_type.get_type )
+        print_param_nc( "retval_", ret_ptr_type, file, 2, :RETURN, nil, nil, b_get )
+      end
+
+      # ãã±ããã®åä¿¡å®äº
+      # mikan æ¬å½ã¯ãå¯¾è±¡é¢æ°ãå¼åºãå¾ã«å®æ½ãããï¼å¼åºããã±ããã®ä½¿ç¨çµãããå®£è¨ããç®çã¨ãã¦
+      file.print "        /* ãã±ããçµããããã§ãã¯ */\n"
+      if ! f.is_oneway? then
+        b_continue = "true"
+      else
+        b_continue = "false"
+      end
+      file.print "    if( (ercd_=cTDR_receiveEOP(#{b_continue})) != E_OK )\n"
+      file.print "        goto error_reset;\n\n"
+
+      # å¯¾è±¡é¢æ°ãå¼åºã
+      file.print "    /* å¯¾è±¡é¢æ°ã®å¼åºã */\n"
+      if b_void then
+        file.print( "    cServerCall_#{f_name}(" )
+      else
+        file.print( "    #{retval_ptr}retval_ = cServerCall_#{f_name}(" )
+      end
+
+      delim = " "
+      param_list.each{ |par|
+        file.print delim
+        delim = ", "
+        file.print "#{par.get_name}"
+      }
+      file.print( " );\n" )
+
+      # æ»ãå¤ãåºåå¼æ°ã®ååã³ã¼ãã®çæ
+
+      # oneway ã®å ´ååºåãæ»ãå¤ãç¡ããååãå¾
+ããªãï¼éåæãªå¼åºãï¼
+      if ! f.is_oneway? then
+        file.print <<EOT
+    /* é¢æ°å¦çã®çµäºãéç¥ */
+    if( ( ercd_ = cEventflag_set( 0x01 ) ) != E_OK ){
+      goto error_reset;
+    }
+EOT
+      end  # ! f.is_oneway?
+      file.print <<EOT
+    return E_OK;
+error_reset:
+    return ercd_;
+}
+
+EOT
+
+    }
+
+  end
+
+end
Index: asp3_gr_sakura/trunk/tecsgen/tecslib/version.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecslib/version.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecslib/version.rb	(revision 317)
@@ -0,0 +1,2 @@
+$package = "tecsgen"
+$version = "1.3.1.5"
Index: asp3_gr_sakura/trunk/tecsgen/tecsmerge
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsmerge	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsmerge	(revision 317)
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+# $Id: tecsmerge 1138 2010-10-08 03:10:44Z okuma-top $
+
+tecsmerge.rb $*
+
Index: asp3_gr_sakura/trunk/tecsgen/tecsmerge.rb
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/tecsmerge.rb	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/tecsmerge.rb	(revision 317)
@@ -0,0 +1,778 @@
+#! /usr/bin/env ruby
+# -*- coding: utf-8 -*-
+
+#
+#  TECS merger
+#      Merger for TECS generated templates
+#  
+#   Copyright (C) 2008-2015 by TOPPERS Project
+#--
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   $Id: tecsmerge.rb 2224 2015-08-22 03:15:56Z okuma-top $
+#++
+
+#= tecsgen  : TECS ã®ãã¼ã¸ã£
+#
+#Authors::   å¤§å±± åå¸
+#Version::   
+#Copyright:: Copyright (C) TOPPERS Project, 2008-2015. All rights reserved.
+#License::   TOPPERS ã©ã¤ã»ã³ã¹ã«æºæ 
+
+=begin
+tecsmerge ã¯ãã³ãã¬ã¼ããã¡ã¤ã«ãå
+ã«ä½æãããã»ã«ã¿ã¤ãã³ã¼ãï¼å«ã¤ã³ã©ã¤ã³é¢æ°ãè¨è¿°ããã»ã«ã¿ã¤ãã¤ã³ã©ã¤ã³ãããï¼ãä¿å®ãããã®ã§ããã
+ã»ã«ã¿ã¤ãã«ä»¥ä¸ã®æ¹å¤ãå ããããå ´åã«å¯¾å¿ããã
+ã»åãå£é¢æ°ãå¢ãã
+ã»åãå£ã®ååãå¤æ´ããã
+ã»åãå£é¢æ°ã®ååãå¤æ´ããã
+
+% tecsmerge source_dir   dest_dir
+% tecsmerge source_files dest_dir
+
+% tecsmerge -p port_name -f old_name:new_name source_file dest_dir
+% tecsmerge -p old_name:new_name source_file dest_dir
+
+source_file ã®ååã¯ _teml.c, _templ.h ã§çµãã£ã¦ããªãã¦ã¯ãªããªã
+dest_file ã¯ source_file ã® _templ ãåãé¤ããååã§ãªãã¦ã¯ãªããªã
+dest_file ãå­å¨ããªãå ´åã_templ ãåãé¤ããååã§ã³ãã¼ããã ãã§ãã
+
+ä»¥ä¸ã®ã­ã¼ã¯ã¼ãã å«ãè¡ãæ¢ã
+
+0) å
+é ­
+1) /* #[<PREAMBLE>]#,
+2)  * #[</PREAMBLE>]#
+3) /* #[<ENTRY_PORT>]#
+4)  * #[</ENTRY_PORT>]#
+5) /* #[<ENTRY_FUNC>]#
+6) {                       # new mode (function header is changed)
+    * #[/<ENTRY_FUNC>]#    # when --old-mode
+    * #[/ENTRY_FUNC>]#     # for Bug compatibility
+7) /* #[<POSTAMBLE>]#
+8)  * #[</POSTAMBLE>]#
+9) çµãã
+
+ä¸è¨ã®ãã¡ 1), 3), 5), 7) ãéå§ã­ã¼ã¯ã¼ãã¨å¼ã¶ã
+ãªããç¹ã«æ­ãã®ãªãå ´åã9) ãéå§ã­ã¼ã¯ã¼ãã«å«ãã
+
+ååã®å¤æ´
+
+a) åãå£åã®å¤æ´
+
+  -p old_port_name:new_port_name
+
+b) åãå£é¢æ°åã®å¤æ´
+
+  -f old_port_name:new_port_name
+
+ old_port_name, new_port_name ã¯ãæ¬¡ã®å½¢å¼ã§ãªãã¦ã¯ãªããªãã
+
+  åãå£å + '_' + é¢æ°å
+
+
+i) ãããï¼
+
+  0) ã¨éå§ã­ã¼ã¯ã¼ãã®é
+
+ii) ãããï¼
+
+  1) ã¨éå§ã­ã¼ã¯ã¼ãã®é
+
+éå¸¸ããããè¤æ°å­å¨ãããã¨ã¯ãªãããè¤æ°å­å¨ããå ´åããã¹ã¦ãã¡ã¤ã«
+ã®å
+é ­ã«åºåãããã
+
+iii) åãå£ããã
+
+  3) ã¨éå§ã­ã¼ã¯ã¼ãã®é
+
+åãå£ãããã¯ãå¾ç¶ã®åãå£é¢æ°ã®åãå£ãè¡¨ããã®ã¨ä»®å®ãããã
+åãå£ãããã¯ãéè¦ã§ã¯ãªãã
+
+iv) åãå£é¢æ°
+
+  5) ã¨éå§ã­ã¼ã¯ã¼ãã®é
+
+=end
+
+require 'optparse'
+$n_err   = 0
+$b_show  = false
+$b_exist = false            # ã³ãã¼å
+ã«ãã¡ã¤ã«ãããå ´åã®ã¿ãã¼ã¸
+$old_mode = false           # old_mode (é¢æ°æ¬ä½ã¨ãã¦ /<ENTRY_FUNC> ã®ä»£ããã« '{' ãä½¿ã
+
+#2.0
+def write_array( file, array )
+  array.each{ |line|
+    file.write line
+  }
+end
+
+class PortRenamer
+  @@port_renamer_list = {}
+  @@port_renamer_current = nil
+
+  def initialize( old_port_name, new_port_name )
+    old_port_name = old_port_name.to_sym
+    if new_port_name then
+      new_port_name = new_port_name.to_sym
+    end
+    # p "port_renamer: #{old_port_name}"
+    @@port_renamer_list[old_port_name] = self
+    @@port_renamer_current = self
+    @old_port_name = old_port_name
+    @new_port_name = new_port_name
+    @func_renamer_list = {}
+  end
+
+  def self.add_func( old_name, new_name )
+    # p "add_func: #{old_name}"
+    if @@port_renamer_current == nil then
+      STDERR.puts( "error: #{old_name}: specify -p before -f" )
+      n_err += 1
+    else
+      @@port_renamer_current.add_func( old_name, new_name )
+    end
+  end
+
+  def add_func( old_name, new_name )
+    old_name = old_name.to_sym
+    new_name = new_name.to_sym
+    if @func_renamer_list[old_name] then
+      STDERR.puts( "error: #{old_name}: duplicate in port #{@old_port_name}" )
+      $n_err += 1
+    elsif old_name == new_name then
+      STDERR.puts( "error: #{old_name}: old and new are the same name" )
+      $n_err += 1
+    end
+    @func_renamer_list[old_name] = new_name
+  end
+
+  def self.show
+    if @@port_renamer_list then
+      @@port_renamer_list.each { |pr,pc|
+        pc.show
+      }
+    end
+  end
+
+  def self.get_list
+    @@port_renamer_list
+  end
+
+  attr_accessor  :old_port_name, :new_port_name, :func_renamer_list
+
+  def show
+    print "port: #{@old_port_name}"
+    if @new_port_name then
+      print " => #{@new_port_name}"
+    end
+    puts ""
+
+    @func_renamer_list.each { |old,new|
+      print "  func: #{old} => #{new}\n"
+    }
+  end
+end
+
+
+class CDLContents
+  #@head::             [string]
+  #@preamble_comment:: [string]
+  #@preamble_body::    [string]
+  #@entry_port::       {ep_name=>CDLEntryPort}
+  #@entry_port_array:: [CDLEntryPort]
+  #@postamble_comment::[string]
+  #@postamble_body::   [string]
+
+  @@DELIMITERS = {
+    # state             => [ regexp_original,                 [previous states]                   , Regexp ]
+    :HEAD               => [ "#[<BeginingOfFile>]#",          []                       ],
+    :PREAMBLE_COMMENT   => [ "/* #[<PREAMBLE>]#",             [:HEAD]                  ],
+    :PREAMBLE_BODY      => [ " * #[</PREAMBLE>]#",            [:PREAMBLE_COMMENT]      ],
+    :ENTRY_COMMENT      => [ "/* #[<ENTRY_PORT>]# PORT_NAME", [:PREAMBLE_BODY, :ENTRY_FUNC_BODY, :ENTRY_FUNC_BODY2] ],
+    :ENTRY_BODY         => [ " * #[</ENTRY_PORT>]#",          [:ENTRY_COMMENT]         ],
+    :ENTRY_FUNC_COMMENT => [ "/* #[<ENTRY_FUNC>]# FUNC_NAME", [:ENTRY_BODY, :ENTRY_FUNC_BODY, :ENTRY_FUNC_BODY2]    ],
+    :POSTAMBLE_COMMENT  => [ "/* #[<POSTAMBLE>]#",            [:ENTRY_FUNC_BODY, :ENTRY_FUNC_BODY2, :PREAMBLE_BODY] ],
+    :POSTAMBLE_BODY     => [ " * #[</POSTAMBLE>]#",           [:POSTAMBLE_COMMENT]     ],
+    :EOF                => [ "#[</EndOfFile>]#",              [:POSTAMBLE_BODY,:ENTRY_FUNC_BODY, :ENTRY_FUNC_BODY2, :PREAMBLE_BODY]  ],
+  }
+
+  @@DELIMITERS_FUNC_BY_COMMENT = {
+    :ENTRY_FUNC_BODY    => [ " * #[</ENTRY_FUNC>]#",          [:ENTRY_FUNC_COMMENT]    ],
+    :ENTRY_FUNC_BODY2   => [ " * #[/ENTRY_FUNC>]#",           [:ENTRY_FUNC_COMMENT]    ],  # for Bug compatibility
+  }
+
+  @@DELIMITERS_FUNC_BY_BRACKET = {
+    :ENTRY_FUNC_BODY    => [ "\\\{",                          [:ENTRY_FUNC_COMMENT]    ],
+  }
+
+  def self.rewrite_DELIMITERS  delimiters
+    delimiters.each{ |stat, stat_info|
+      s = stat_info[0].gsub( /([\*\[\]])/, "\\\\\\1" )   # *, [, ] ã®åã« \\ ãæ¿å
+¥
+      s.gsub!( /\s*\w*_NAME/, "\\s*(\\w*)" )             # ..._NAME ã (w*) ã«å¤æ´
+      s = "^" + s                                        # ^ ãå
+é ­ã«æ¿å
+¥
+      stat_info[2] = Regexp.new( s )
+      # p stat_info[2]
+    }
+  end
+
+  rewrite_DELIMITERS @@DELIMITERS
+  rewrite_DELIMITERS @@DELIMITERS_FUNC_BY_COMMENT
+  rewrite_DELIMITERS @@DELIMITERS_FUNC_BY_BRACKET
+
+  #=== ã¢ã¼ãã«å¾ã DELIMITERS ã« DELIMITERS_FUNC_BY_* ããã¼ã¸ãã
+  # mode :OLD_FUNC_BODY, :NEW_FUNC_BODY
+  def self.merge_DELIMITERS mode
+    case mode
+    when :OLD_FUNC_BODY
+      @@DELIMITERS.merge! @@DELIMITERS_FUNC_BY_COMMENT
+    when :NEW_FUNC_BODY
+      @@DELIMITERS.merge! @@DELIMITERS_FUNC_BY_BRACKET
+    else
+      raise "unknown mode"
+    end
+  end
+
+  #all_contents:: [string,...]
+  def initialize all_contents
+    part = []
+    line_no = 0
+    stat = :HEAD
+    arg = nil
+    port_name = nil
+    func_name = nil
+
+    @entry_port = {}
+    @entry_port_array = []
+
+    @head = []
+    @preamble_comment = []
+    @preamble_body = []
+    @postamble_comment = []
+    @postamble_body = []
+
+    (all_contents+[nil]).each{ |line|  # nil: EOF
+      line_no += 1
+      # p "L: #{line}"
+      b_delim = false        # ããªãã¿ã­ã¼ã¯ã¼ãã®è¡
+      @@DELIMITERS.each { |next_stat,stat_info|
+
+        next if next_stat == :HEAD || ( next_stat == :EOF && line != nil )
+
+        # p "R: #{stat_info[0]}"
+        if stat_info[2] =~ line || ( line == nil && next_stat == :EOF ) then
+          # p "D: #{line}: #{stat}"
+          b_delim = true
+
+          found = false
+          stat_info[1].each{ |prev_stat|
+            if stat == prev_stat then
+              found = true
+            end
+          }
+          if ! found then
+            STDERR.puts "error #{line_no}: unsuitable previous keyword"
+            STDERR.puts "error #{line_no}:   previous:  \"#{@@DELIMITERS[stat][0]}\""
+            STDERR.puts "error #{line_no}:   current:   \"#{@@DELIMITERS[next_stat][0]}\""
+            expect = ""; delim = ""
+            stat_info[1].each{ |prev_stat| expect = "#{expect+delim}\"#{@@DELIMITERS[prev_stat][0]}\""; delim = ", " }
+            STDERR.puts "error #{line_no}:   suitable previous: #{expect}"
+            $n_err += 1
+          end
+
+          case stat
+          when :PREAMBLE_COMMENT, :ENTRY_COMMENT, :ENTRY_FUNC_COMMENT, :POSTAMBLE_COMMENT
+            part << line
+          end
+
+          case stat   # åã®ç¶æ
+
+          when :HEAD
+            @head = part
+          when :PREAMBLE_COMMENT
+            @preamble_comment = part
+          when :PREAMBLE_BODY
+            @preamble_body = part
+          when :ENTRY_COMMENT
+            port_name = arg.to_sym
+            @entry_port[ port_name ] = CDLEntryPort.new
+            @entry_port_array << port_name
+            @entry_port[ port_name ].entry_comment = part
+          when :ENTRY_BODY
+            @entry_port[ port_name ].entry_body = part
+          when :ENTRY_FUNC_COMMENT
+            func_name = arg.to_sym
+            if @entry_port[ port_name ] then   # nil ãªãæ¢ã«ã¨ã©ã¼
+              @entry_port[ port_name ].entry_func_comment[ func_name ] = part
+              @entry_port[ port_name ].entry_func_array << func_name
+            end
+          when :ENTRY_FUNC_BODY, :ENTRY_FUNC_BODY2
+            if @entry_port[ port_name ] then   # nil ãªãæ¢ã«ã¨ã©ã¼
+              @entry_port[ port_name ].entry_func_body[ func_name ] = part
+            end
+          when :POSTAMBLE_COMMENT
+            @postamble_comment = part
+          when :POSTAMBLE_BODY
+            @postamble_body = part
+          else
+            raise "Unknown state #{stat}"
+          end
+
+          case next_stat
+          when :PREAMBLE_COMMENT, :ENTRY_COMMENT, :ENTRY_FUNC_COMMENT, :POSTAMBLE_COMMENT
+            part = [ line ]
+          else
+            part = []
+          end
+
+          stat = next_stat
+          arg = $1     # arg ã«åã£ã¦ãã
+          # p stat, arg
+          break
+        end
+      }
+
+      if ! b_delim then
+        part << line
+      end
+    }
+      
+  end
+
+  def check template
+    # template ã«ãªããã®ããã§ãã¯
+    @entry_port.each{ |port_name, entry_port|
+      temp_entry_port = template.entry_port[port_name]
+      if temp_entry_port == nil then
+        STDERR.puts "info: #{port_name} is deleted port"
+        next
+      end
+      # temp_entry_port.entry_func_body.each{ |f,b|  p f }
+      entry_port.entry_func_body.each{ |func_name, func_body|
+        if temp_entry_port.entry_func_body[func_name] == nil then
+          STDERR.puts "info: #{func_name} is deleted function"
+        end
+      }
+    }
+  end
+
+  def rename
+
+    renamed_entry_port = {}
+    PortRenamer.get_list.each{ |pon,pr|
+
+      # å¯¾è±¡åãå£ãæã
+      ep = @entry_port[pon]
+      if ep == nil then
+        STDERR.puts "warning: #{pon}: renaming port not found"
+        next
+      end
+
+      # ãã¼ãã® rename
+      pnn = pr.new_port_name    # ç½®æå¾ã®åå
+      if pnn then
+        # ç½®æããååãããã°ãç»é²ããªãã
+        renamed_entry_port[pnn] = @entry_port[pon]
+        @entry_port.delete pon
+      end
+
+      # æå®ãããé¢æ°ã®ç½®æ
+      renamed_func_comment = {}
+      renamed_func_body = {}
+      pr.func_renamer_list.each{ |old,new|
+        ofn = "#{pon}_#{old}".to_sym
+        nfn = "#{pon}_#{new}".to_sym
+        # p "fnn: #{ofn} #{nfn} #{pon}"
+        if ep.entry_func_comment[ofn] == nil then
+          STDERR.puts "warning: #{old}: renaming function not found"
+          next
+        end
+        ep.entry_func_array.map! { |fn|
+          # p fn, nfn, ofn, fn==ofn ? nfn : fn
+          fn==ofn ? nfn : fn
+        }
+        renamed_func_comment[nfn] = ep.entry_func_comment[ofn]
+        renamed_func_body[nfn]    = ep.entry_func_body[ofn]
+        ep.entry_func_comment.delete ofn
+        ep.entry_func_body.delete    ofn
+      }
+      ep.entry_func_comment.merge! renamed_func_comment
+      ep.entry_func_body.merge!    renamed_func_body
+
+      # ãã¼ãåã®å¤æ´ã«ããé¢æ°åã®ç½®æ
+      renamed_func_comment = {}
+      renamed_func_body = {}
+      if pnn then
+        ep.entry_func_array.map! { |ofn|
+          nfn = ofn.to_s.sub( /#{pon.to_s}/, pnn.to_s ).to_sym
+          # p "pnn: #{ofn} #{nfn} #{pon}  #{pnn}"
+          if nfn != ofn then
+            renamed_func_comment[nfn] = ep.entry_func_comment[ofn]
+            renamed_func_body[nfn]    = ep.entry_func_body[ofn]
+            ep.entry_func_comment.delete ofn
+            ep.entry_func_body.delete    ofn
+            nfn
+          else
+            ofn
+          end
+        }
+        ep.entry_func_comment.merge! renamed_func_comment
+        ep.entry_func_body.merge!    renamed_func_body
+
+        # ep.entry_func_comment.each { |f,e| p "FF: #{f}" }
+        # ep.entry_func_array.each { |f,e| p "FA: #{f}" }
+      end
+    }
+    # p renamed_entry_port
+    @entry_port.merge! renamed_entry_port
+  end
+
+  def merge src
+    @head = src.head
+    @preamble_body = src.preamble_body
+    @postamble_body = src.postamble_body
+
+    @entry_port_array.each{ |port_name|
+      # p "merging #{port_name}"
+      entry_port = @entry_port[ port_name ]
+      src_entry_port = src.entry_port[port_name]
+      if src_entry_port == nil then
+        print "port merged:   #{port_name}\n"
+        next
+      end
+      entry_port.entry_body = src_entry_port.entry_body
+      entry_port.entry_func_array.each{ |func_name|
+        # p "merging #{func_name}"
+        func_body = entry_port.entry_func_body[ func_name ]
+        if src_entry_port.entry_func_body[func_name] == nil then
+          print "func merged:   #{func_name}\n"
+          next
+        end
+        print "func remained: #{func_name}\n"
+        # entry_port.entry_func_comment[func_name] = src_entry_port.entry_func_comment[func_name]
+        entry_port.entry_func_body[func_name]    = src_entry_port.entry_func_body[func_name]
+      }
+    }
+  end
+
+  def write file
+#2.0    file.write @head
+    write_array( file, @head )
+#2.0    file.write @preamble_comment
+    write_array( file, @preamble_comment )
+#2.0    file.write @preamble_body
+    write_array( file, @preamble_body )
+    @entry_port_array.each{ |port_name| @entry_port[port_name].write file }
+#2.0    file.write @postamble_comment
+    write_array( file, @postamble_comment )
+#2.0    file.write @postamble_body
+    write_array( file, @postamble_body )
+  end
+
+  attr_accessor :head, :preamble_comment, :preamble_body, :entry_port, :postamble_body
+end
+
+class CDLEntryPort
+  #@entry_comment::      [string]
+  #@entry_body::         [string]
+  #@entry_func_comment:: {ep_func_name=>string}
+  #@entry_func_body::    {ep_func_name=>string}
+  #@entry_func_array::   [string]
+
+  def initialize
+    @entry_comment = []
+    @entry_body = []
+    @entry_func_comment = {}
+    @entry_func_body = {}
+    @entry_func_array = []
+  end
+
+  def write file
+#2.0    file.write @entry_comment
+    write_array( file, @entry_comment )
+#2.0    file.write @entry_body
+    write_array( file, @entry_body )
+    @entry_func_array.each{ |fnm|
+      # p @entry_func_comment[fnm][0]
+
+#2.0      file.write @entry_func_comment[fnm]
+      write_array( file, @entry_func_comment[fnm] )
+#2.0      file.write @entry_func_body[fnm]
+      write_array( file, @entry_func_body[fnm] )
+    }
+  end
+
+  attr_accessor :entry_comment, :entry_body, :entry_func_comment, :entry_func_body, :entry_func_array
+end
+
+def merge( src_file, dst_dir )
+  unless src_file =~ /(.*)_templ(.[ch])$/ then
+    STDERR.puts( "error: #{src_file}: not end with _templ.c/h" )
+    exit 1
+  end
+
+  fname = "#{$1}#{$2}"
+  dst_file = "#{dst_dir}/#{File.basename fname}"
+  if FileTest.file?( dst_file ) then
+    print( "merging #{src_file} to #{dst_file}\n" )
+    # dst_file ã®èª­è¾¼ã¿
+    begin
+      dst = open( dst_file )
+#2.0
+      set_encoding dst
+      old_contents = dst.readlines
+    rescue
+      STDERR.puts "error: cannot open #{dst_file}"
+      $n_err += 1
+      exit 1
+    ensure
+      dst.close
+    end
+    old = CDLContents.new( old_contents )
+
+    # template ã®èª­è¾¼ã¿
+    begin
+      src = open( src_file )
+#2.0
+      set_encoding src
+      new_contents = src.readlines
+    rescue
+      STDERR.puts "error: cannot open #{src_file}"
+      $n_err += 1
+      exit 1
+    ensure
+      src.close
+    end
+    templ = CDLContents.new( new_contents )
+
+    old.rename
+    error_check dst_file, 1
+
+    old.check templ
+    error_check dst_file, 2
+
+    templ.merge old
+    error_check dst_file, 3
+
+    bkup_file = rename_dst( dst_file )
+
+    begin
+      dst = open( dst_file, "w" )
+#2.0
+      set_encoding dst
+      templ.write dst
+    ensure
+      dst.close
+    end
+
+  elsif $b_exist == false then
+    # src_file ã dst_file ã¸ã³ãã¼
+    begin
+      src = File.open( src_file )
+#2.0
+      set_encoding src
+      contents = src.readlines
+    rescue
+      print "#{src_file}: fail to read\n"
+    ensure
+      src.close
+    end
+
+    begin
+      dst = File.open( dst_file, "w" )
+      set_encoding dst
+#2.0      dst.write( contents )
+      contents.each{ |line|
+        dst.print line
+      }
+    rescue
+      print "#{dst_file}: fail to write\n"
+    ensure
+      dst.close
+    end
+  else
+    print "info: #{dst_file} skipped\n"
+  end
+end
+
+def error_check dst_file, level
+  if $n_err > 0 then
+    STDERR.puts "=== #{dst_file} not generated because of error ==="
+    exit level
+  end
+end
+
+
+#=== ãã¡ã¤ã«ã®ã¨ã³ã³ã¼ãã£ã³ã°ã ASCII-8BIT ã«å¤æ´
+# Ruby 1.9 ä»¥ä¸ã®å ´åã«å¤æ´
+def set_encoding file
+  if RUBY_VERSION >= "1.9.0" then
+    file.set_encoding "ASCII-8BIT"
+  end
+end
+
+#=== rename_dst
+# dst_file ã®ããã¯ã¢ãããã¡ã¤ã«åãæ±ºå®ãããªãã¼ã ãã
+# æåããã°ããªãã¼ã å¾ã®ãã¡ã¤ã«åãè¿ã
+# dst_file ãå­å¨ããªããã°ï¼ãªãã¼ã ã¯è¡ãããï¼nil ãè¿ãã
+def rename_dst( dst_file )
+  begin
+    File.stat dst_file
+  rescue
+    STDERR.puts( "info: backup not generated for #{dst_file}" )
+    # ãªããã°çµãã
+    return nil
+  end
+
+  i = 0
+  found = true
+  while found == true
+    begin
+      i = i + 1
+      bkup_file = "#{dst_file}_#{i}"
+      File.stat bkup_file
+    rescue
+      found = false
+    end
+  end
+
+  begin
+    File.rename( dst_file, bkup_file )
+    STDERR.puts( "info: backup generated for #{dst_file} to #{bkup_file}" )
+    return bkup_file
+  rescue
+    STDERR.puts( "error: fail to rename backup file: #{bkup_file}" )
+    exit 1
+  end
+
+  return nil
+end
+
+ARGV.options {|parser|
+  parser.banner =<<EOT
+Usage: tecsmerge [options] files_templ.c   src_dir
+       tecsmerge [options] gen_dir         src_dir
+EOT
+  parser.on('-e', '--exist-only',  "merge if exist in destination directory") { |fs|
+    $b_exist = true
+  }
+  parser.on('-p', '--port=old_name:new_name',  "specify entry port name change") { |ps|
+    p = ps.split( ':' )
+    PortRenamer.new( p[0], p[1] )
+  }
+  parser.on('-f', '--func=old_name:new_name',  "specify entry function name change") { |fs|
+    f = fs.split( ':' )
+    PortRenamer.add_func( f[0], f[1] )
+  }
+  parser.on('-s', '--show_change_set',  "show change set. all substitute") {
+    $b_show = true
+  }
+  parser.on('-o', '--old-mode',  "old mode (function head not substituted)") { |fs|
+    $old_mode = true
+  }
+  parser.version = #{$version}
+  parser.release = nil
+  parser.parse!
+#  if ARGV.empty?
+  if ARGV.length < 2 then
+    puts parser.help
+    exit 1
+  end
+}
+
+if $b_show then
+  PortRenamer.show
+end
+
+if $old_mode then
+  CDLContents.merge_DELIMITERS :OLD_FUNC_BODY
+else
+  CDLContents.merge_DELIMITERS :NEW_FUNC_BODY
+end
+
+if $n_err > 0 then
+  STDERR.puts( "#{$n_err} errors" )
+  exit 1
+end
+
+src = ARGV[0,ARGV.length-1]
+dst = ARGV[-1]
+
+begin
+  stat = File.stat dst
+rescue
+  STDERR.puts( "error: #{dst}: not found" )
+  exit 1
+ensure
+  if stat && ! stat.directory? then
+    STDERR.puts( "error: #{dst}: not directory" )
+    exit 1
+  end
+end
+
+src.each { |s|
+  begin
+    stat = File.stat s
+  rescue
+    STDERR.puts( "error: #{s}: not found or cannot access" )
+    exit 1
+  end
+
+  if stat.directory? then
+    Dir.foreach(s) {|file|
+      if file =~ /_templ.[ch]$/ then
+        merge( "#{s}/#{file}", dst )
+      end
+    }
+  elsif stat.file? then
+    merge( s, dst )
+  end
+}
Index: asp3_gr_sakura/trunk/tecsgen/test
===================================================================
--- asp3_gr_sakura/trunk/tecsgen/test	(revision 317)
+++ asp3_gr_sakura/trunk/tecsgen/test	(revision 317)
@@ -0,0 +1,1 @@
+link ../test/
Index: asp3_gr_sakura/trunk/tinet/Makefile.tinet
===================================================================
--- asp3_gr_sakura/trunk/tinet/Makefile.tinet	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/Makefile.tinet	(revision 317)
@@ -0,0 +1,396 @@
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#   Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+#   Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+#   ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+#   è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+#   ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+#   å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+#   å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+#   æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+#  
+#   @(#) $Id: Makefile.tinet 1.7 2017/6/1 8:50:42 abe $
+#
+
+#
+#  ãããã«ã¦ã§ã¢ã® Makefile ã®ã¤ã³ã¯ã«ã¼ããã«è¿½å ããã
+#
+
+#
+#  ã«ã¼ãã«ã®è­å¥
+#
+ifdef SRCLANG
+	TARGET_KERNEL = ASP
+	TINET_CDEFS := $(TINET_CDEFS) -DTARGET_KERNEL_ASP
+else
+	TARGET_KERNEL = JSP
+	TINET_CDEFS := $(TINET_CDEFS) -DTARGET_KERNEL_JSP
+endif
+
+#
+#  TINET ã½ã¼ã¹ãã¡ã¤ã«ã®ãã£ã¬ã¯ããªã®å®ç¾©
+#
+TINET_ROOT = $(SRCDIR)/tinet
+
+#
+#  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+#
+ifndef SUPPORT_INET4
+	ifndef SUPPORT_INET6
+		SUPPORT_INET4 = true
+	endif
+endif
+
+#
+#  TINET 1.7 ä»¥éã¯ããããã¯ã¼ã¯å±¤ã®æå®ãå¤æ´ããã
+#
+
+ifeq ($(SUPPORT_INET6),true)
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET6
+endif
+
+ifeq ($(SUPPORT_INET4),true)
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_INET4
+endif
+
+ifeq ($API_CFG_IP4MAPPED_ADDR,true)
+	TINET_CDEFS := $(TINET_CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
+endif
+
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã«é¢ããå®ç¾©
+#
+
+#  æ±ç¨éä¿¡æ©è½
+
+TINET_DIRS = $(TINET_ROOT)/net:$(TINET_ROOT)/netinet:$(TINET_ROOT)/netinet6
+TINET_COBJS := $(TINET_COBJS) \
+               net_buf.o net_count.o net_subr.o net_timer.o if.o \
+               in_subr.o route_cfg.o
+TINET_CFG_COBJS := $(TINET_CFG_COBJS) tinet_cfg.o
+
+#  IPv6
+
+TINET_COBJS := $(TINET_COBJS) \
+               in6.o in6_ifattach.o nd6_rtr.o \
+               in6_subr.o ip6_input.o icmp6.o \
+               dest6.o route6.o frag6.o \
+               ah_input.o esp_input.o \
+               nd6.o nd6_nbr.o ip6_output.o scope6.o
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet6/ip6.cfg
+
+#  IPv4
+
+TINET_COBJS := $(TINET_COBJS) \
+               ip_input.o ip_output.o ip_icmp.o in4_subr.o
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/ip.cfg
+
+#  loop back
+
+ifeq ($(NET_IF),loop)
+
+	TINET_COBJS := $(TINET_COBJS) if_loop.o
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/if_loop.cfg
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_LOOP
+
+endif
+
+#  ppp
+
+ifeq ($(NET_IF),ppp)
+
+	TINET_COBJS := $(TINET_COBJS) \
+	               ppp.o ppp_hdlc.o ppp_lcp.o ppp_fsm.o \
+	               ppp_auth.o ppp_upap.o
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/net/ppp.cfg
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_PPP
+
+#  IPv6ç¨ cp
+	TINET_COBJS := $(TINET_COBJS) ppp_ipv6cp.o
+
+#  IPv4ç¨ cp
+	TINET_COBJS := $(TINET_COBJS) ppp_ipcp.o
+
+ifeq ($(PPP_CFG_MODEM),true)
+
+	TINET_COBJS := $(TINET_COBJS) ppp_modem.o 
+	TINET_CDEFS := $(TINET_CDEFS) -DPPP_CFG_MODEM
+
+endif
+
+endif
+
+#  ã¿ã¼ã²ããä¾å­ã®å®ç¾©ã®ã¤ã³ã¯ã«ã¼ã
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+	-include $(TARGETDIR)/Makefile.tinet
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+	ifdef TOOL
+		ifdef SYS
+			-include $(SRCDIR)/config/$(CPU)-$(TOOL)/$(SYS)/Makefile.tinet
+		endif
+		-include $(SRCDIR)/config/$(CPU)-$(TOOL)/Makefile.tinet
+	else
+		ifdef SYS
+			-include $(SRCDIR)/config/$(CPU)/$(SYS)/Makefile.tinet
+		endif
+		-include $(SRCDIR)/config/$(CPU)/Makefile.tinet
+	endif
+
+endif
+
+#  ethernet
+
+ifeq ($(NET_IF),ether)
+
+	TINET_COBJS := $(TINET_COBJS) ethernet.o if6_ether.o if_ether.o
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) \
+	                    $(TINET_ROOT)/net/ethernet.cfg \
+	                    $(TINET_ROOT)/netinet/if_ether.cfg
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_ETHER
+	include $(TINET_ROOT)/netdev/$(NET_DEV)/Makefile.tinet
+
+endif
+
+#  TCP
+
+ifeq ($(SUPPORT_TCP),true)
+
+	TINET_COBJS := $(TINET_COBJS) \
+	               tcp_input.o tcp_output.o tcp_timer.o \
+	               tcp_subr.o tcp_subr_cs.o tcp_subr_ncs.o 
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/tcp.cfg
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_TCP
+
+endif
+
+#  UDP
+
+ifeq ($(SUPPORT_UDP),true)
+
+	TINET_COBJS := $(TINET_COBJS) \
+	               udp_input.o udp_output.o udp_subr.o
+	TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netinet/udp.cfg
+	TINET_CDEFS := $(TINET_CDEFS) -DSUPPORT_UDP
+
+endif
+
+#
+#  TINET ã©ã¤ãã©ãªã®å®ç¾©
+#
+
+ifeq ($(NO_USE_TINET_LIBRARY),true)
+
+	ifeq ($(SUPPORT_TCP),true)
+		TINET_COBJS := $(TINET_COBJS) tcp_usrreq.o 
+	endif
+
+	ifeq ($(SUPPORT_UDP),true)
+		TINET_COBJS := $(TINET_COBJS) udp_usrreq.o udp_usrreq_nblk.o
+	endif
+
+else
+
+	ifeq ($(SUPPORT_TCP),true)
+		TINET_LCSRCS := $(TINET_LCSRCS) tcp_usrreq.c 
+	endif
+
+	ifeq ($(SUPPORT_UDP),true)
+		TINET_LCSRCS := $(TINET_LCSRCS) udp_usrreq.c udp_usrreq_nblk.c
+	endif
+
+	TINET_CDEFS := $(TINET_CDEFS) -DTCP_CFG_LIBRARY -DUDP_CFG_LIBRARY
+
+	ifdef TINET_LIB
+		MAKE_TINET_LIB :=
+		LIBTINET := $(TINET_LIB)/libtinet.a
+	else
+		MAKE_TINET_LIB := libtinet.a
+		LIBTINET := $(MAKE_TINET_LIB)
+	endif
+
+	MAKE_MTASK := $(MAKE_MTASK) $(LIBTINET)
+
+endif
+
+#
+#  ã©ã¤ãã©ãªåããã½ã¼ã¹ãã¡ã¤ã«ããçæããã
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«ã®å®ç¾©
+#
+TINET_LCOBJS = $(foreach file,$(TINET_LCSRCS),$($(file:.c=)))
+
+tcp_usrreq = 	tcp_cre_rep.o tcp_del_rep.o \
+		tcp_cre_cep.o tcp_del_cep.o \
+		tcp_acp_cep.o tcp_con_cep.o tcp_sht_cep.o \
+		tcp_cls_cep.o tcp_can_cep.o \
+		tcp_snd_dat.o tcp_rcv_dat.o \
+		tcp_snd_oob.o tcp_rcv_oob.o \
+		tcp_get_buf.o tcp_snd_buf.o \
+		tcp_rcv_buf.o tcp_rel_buf.o \
+		tcp_set_opt.o tcp_get_opt.o
+
+udp_usrreq = 	udp_can_cep.o udp_send_data.o \
+		udp_can_snd.o udp_can_rcv.o \
+		udp_snd_dat.o udp_rcv_dat.o \
+		udp_set_opt.o udp_get_opt.o \
+		udp_cre_cep.o udp_del_cep.o
+
+udp_usrreq_nblk = \
+		udp_can_snd_nblk.o udp_can_rcv_nblk.o \
+		udp_snd_dat_nblk.o udp_rcv_dat_nblk.o
+
+#
+#  ã©ã¤ãã©ãªåããã½ã¼ã¹ãã¡ã¤ã«ããçæããã
+#  ãªãã¸ã§ã¯ããã¡ã¤ã«ã®ä¾å­é¢ä¿ã®å®ç¾©
+#
+$(tcp_usrreq) $(tcp_usrreq:.o=.s) $(tcp_usrreq:.o=.d): tcp_usrreq.c tcpn_usrreq.c
+$(udp_usrreq) $(udp_usrreq:.o=.s) $(udp_usrreq:.o=.d): udp_usrreq.c udpn_usrreq.c
+$(udp_usrreq_nblk) $(udp_usrreq_nblk:.o=.s) $(udp_usrreq_nblk:.o=.d): udp_usrreq_nblk.c
+
+#
+#  TINET ã©ã¤ãã©ãªã®å®ç¾©
+#
+TINET_LIB_OBJS = $(TINET_LCOBJS)
+
+#
+#  TINET ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®å®ç¾©
+#
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+TINET_CFG_OUT = tinet_cfg.c tinet_cfg.h tinet_kern.cfg
+TINET_KERNEL_CFG :=	$(TINET_KERNEL_CFG) \
+			$(TINET_ROOT)/tinet_asp.cfg $(TINET_ROOT)/net/net_asp.cfg 
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+TINET_CFG = tinet_$(UNAME).cfg
+TINET_CFG_OUT = tinet_cfg.c tinet_id.h tinet_kern.cfg
+TINET_KERNEL_CFG :=	$(TINET_KERNEL_CFG) tinet_kern.cfg \
+			$(TINET_ROOT)/tinet.cfg $(TINET_ROOT)/net/net_jsp.cfg 
+TINET_CFG_OUT := $(TINET_CFG_OUT) $(IPSEC_CFG_OUT)
+
+endif
+
+#
+#  å
+±éã³ã³ãã¤ã«ãªãã·ã§ã³ã®å®ç¾©ã¸ã®è¿½å 
+#
+CDEFS := $(CDEFS) $(TINET_CDEFS)
+INCLUDES := $(INCLUDES) -I$(TINET_ROOT)
+
+#
+#  TINET ã³ã³ãã¤ã«ãªãã·ã§ã³ã®å®ç¾©ã¸ã®è¿½å 
+#
+TINET_CFLAGS := $(TINET_CFLAGS) -fno-strict-aliasing
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ãããã«ã¦ã§ã¢ã«é¢ããå®ç¾©
+#
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+	SYSSVC_DIRS := $(SYSSVC_DIRS):$(TINET_DIRS)
+	SYSSVC_ASMOBJS := $(SYSSVC_ASMOBJS)
+	SYSSVC_COBJS := $(SYSSVC_COBJS) $(TINET_COBJS)
+	SYSSVC_CFLAGS := $(SYSSVC_CFLAGS) $(TINET_CFLAGS)
+	SYSSVC_LIBS := $(SYSSVC_LIBS) $(LIBTINET) -lc
+
+	CFG_COBJS := $(CFG_COBJS) $(TINET_CFG_COBJS)
+
+	CLEAN_FILES := $(CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+	MTASK_CFG := $(MTASK_CFG) $(TINET_CFG)
+	MTASK_KERNEL_CFG := $(MTASK_KERNEL_CFG) $(TINET_KERNEL_CFG)
+	MTASK_DIR := $(MTASK_DIRS):$(TINET_DIRS)
+	MTASK_LCSRCS := $(MTASK_LCSRCS) $(TINET_LCSRCS)
+	MTASK_ASMOBJS := $(MTASK_ASMOBJS)
+	ifdef USE_CXX
+		MTASK_CXXOBJS := $(MTASK_CXXOBJS)
+		MTASK_COBJS := $(MTASK_COBJS) $(TINET_COBJS)
+	else
+		MTASK_COBJS := $(MTASK_COBJS) $(TINET_COBJS)
+	endif
+	MTASK_CFLAGS := $(MTASK_CFLAGS) $(TINET_CFLAGS)
+	MTASK_LIBS := $(MTASK_LIBS) $(LIBTINET) -lc
+	MTASK_CLEAN_FILES := $(MTASK_CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
+
+endif
+
+#
+#  TINET ã©ã¤ãã©ãªãã¡ã¤ã«ã®çæ
+#
+libtinet.a: $(TINET_LIB_OBJS)
+	rm -f libtinet.a
+	$(AR) -rcs libtinet.a $(TINET_LIB_OBJS)
+	$(RANLIB) libtinet.a
+
+#
+#  ã³ã³ãã¤ã«ã«ã¼ã«ã®å®ç¾©
+#
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+$(TINET_LCOBJS): %.o:
+	$(CC) -D__$(*F) -o $@ -c $(CFLAGS) $(SYSSVC_CFLAGS) $<
+
+tinet_cfg1_out.o: %.o: %.c
+	$(CC) -c $(CFLAGS) $(KERNEL_CFG_CFLAGS) $<
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+$(TINET_LCOBJS): %.o:
+	$(CC) -D__$(*F) -o $@ -c $(CFLAGS) $(MTASK_CFLAGS) $<
+
+endif
+
+#
+#  ã³ã³ãã¤ã«çµæã®æ¶å»
+#
+cleantinet:
+	rm -f $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
Index: asp3_gr_sakura/trunk/tinet/asp_sample/Makefile
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/Makefile	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/Makefile	(revision 317)
@@ -0,0 +1,32 @@
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+#
+
+#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+NET_IF = @(NET_IF)
+
+#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+NET_DEV = @(NET_DEV)
+
+#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+@(SUPPORT_INET6)
+@(SUPPORT_INET4)
+
+#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+@(API_CFG_IP4MAPPED_ADDR)
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+@(SUPPORT_TCP)
+@(SUPPORT_UDP)
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/Makefile.tinet
+
+#
Index: asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.copyright
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.copyright	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.copyright	(revision 317)
@@ -0,0 +1,44 @@
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#   Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+#   ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+#   è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+#   ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+#   å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ãå
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã¯ï¼
+#   æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ã
+#   ãªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çããã
+#   ããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+# 
+#  @(#) $Id: Makefile.copyright 1.7 2017/6/1 8:50:38 abe $
+# 
Index: asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.minsv
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.minsv	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.minsv	(revision 317)
@@ -0,0 +1,69 @@
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+#
+
+#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+NET_IF = @(NET_IF)
+
+#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+NET_DEV = @(NET_DEV)
+
+#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+@(SUPPORT_INET6)
+@(SUPPORT_INET4)
+
+#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+@(API_CFG_IP4MAPPED_ADDR)
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+@(SUPPORT_TCP)
+@(SUPPORT_UDP)
+
+#
+#  ãµã³ãã«ã®ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ã«é¢ããå®ç¾©
+#
+
+#  TCP ã«çµè¾¼ãæ©è½ã®é¸æ
+TCP_CFG_RWBUF_CSAVE_ONLY = true
+TCP_CFG_SWBUF_CSAVE_ONLY = true
+
+#  TCP ã®æ©è½ã¨ API ã®é¸æ
+
+USE_COPYSAVE_API = true
+
+#  å
+±éãµã¼ããã­ã°ã©ã ã®é¸æ
+
+USE_WWW_SRV = true
+
+#  TCP ã¨ã³ã¼ãµã¼ããã­ã°ã©ã ã®é¸æ
+#    tcp_echo_srv1: éåä¿¡ã¿ã¹ã¯åä¸å
+
+TCP_ECHO_SRV = tcp_echo_srv1
+
+#  å
+±éãµã¼ãã¿ã¹ã¯æ°ã®é¸æ
+
+CDEFS := $(CDEFS) -DNUM_WWW_SRV_TASKS=1		# WWW ãµã¼ãã¿ã¹ã¯æ°ãæå¤§ 2
+CDEFS := $(CDEFS) -DNUM_TCP_ECHO_SRV_TASKS=1	# TCP ECHO ãµã¼ãã¿ã¹ã¯æ°ãæå¤§ 8
+
+#  TCP ã®ã»ã°ã¡ã³ããµã¤ãºã®é¸æ
+
+CDEFS := $(CDEFS) -DUSE_TCP_MSS_SEG		# ã»ã°ã¡ã³ããµã¤ãºã MSS ã«ããã
+
+#
+#  ãµã³ãã«ã®ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/netapp/Makefile.netapp
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/Makefile.tinet
+
+#
Index: asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.nserv
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.nserv	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/Makefile.nserv	(revision 317)
@@ -0,0 +1,137 @@
+#
+#  ãããã¯ã¼ã¯ãµã¼ãã¹ã®å®ç¾©
+#
+
+#  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãä½ããä¸ã¤é¸æããã
+
+NET_IF = @(NET_IF)
+
+#  ã¤ã¼ãµãããã»ãã£ãã¤ã¹ãã©ã¤ãã®é¸æ
+
+NET_DEV = @(NET_DEV)
+
+#  ãããã¯ã¼ã¯å±¤ã®é¸æ
+
+@(SUPPORT_INET6)
+@(SUPPORT_INET4)
+
+#  API ã«çµè¾¼ãæ©è½ã®é¸æ
+
+@(API_CFG_IP4MAPPED_ADDR)
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+@(SUPPORT_TCP)
+@(SUPPORT_UDP)
+
+#
+#  ãµã³ãã«ã®ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ã®é¸æ
+#
+
+#  TCP ã«çµè¾¼ãæ©è½ã®é¸æ
+
+#TCP_CFG_RWBUF_CSAVE_ONLY = true
+TCP_CFG_RWBUF_CSAVE = true
+#TCP_CFG_SWBUF_CSAVE_ONLY = true
+TCP_CFG_SWBUF_CSAVE = true
+TCP_CFG_NON_BLOCKING = true
+TCP_CFG_EXTENTIONS = true
+
+#  TCP ã®æ©è½ã¨ API ã®é¸æ
+
+#USE_TCP_NON_BLOCKING = true
+#USE_TCP_EXTENTIONS = true
+USE_COPYSAVE_API = true
+
+#  UDP ã«çµè¾¼ãæ©è½ã®é¸æ
+
+UDP_CFG_NON_BLOCKING = true
+UDP_CFG_EXTENTIONS = true
+
+#  UDP ã®æ©è½ã®é¸æ
+
+#USE_UDP_EXTENTIONS = true
+
+#  UDP ã®æ©è½ã®é¸æãä¸¡æ¹åæã«ã¯é¸æã§ããªãã
+
+#USE_UDP_NON_BLOCKING = true
+#USE_UDP_CALL_BACK = true
+
+#  å
+±éãµã¼ããã­ã°ã©ã ã®é¸æ
+
+USE_WWW_SRV = true
+USE_WWW4_SRV = true
+USE_UDP_ECHO_SRV = true
+USE_UDP4_ECHO_SRV = true
+USE_TCP_DISCARD_SRV = true
+
+#  TCP ã¨ã³ã¼ãµã¼ããã­ã°ã©ã ã®é¸æããã ããä¸¡æ¹ã¯é¸æã§ããªãã
+#    tcp_echo_srv1: éåä¿¡ã¿ã¹ã¯åä¸å
+#    tcp_echo_srv2: éåä¿¡ã¿ã¹ã¯åé¢å
+
+TCP_ECHO_SRV = tcp_echo_srv1
+#TCP_ECHO_SRV = tcp_echo_srv2
+
+USE_TCP4_ECHO_SRV = true
+
+#  ã³ã³ã½ã¼ã«å
+¥åºåã®é¸æ
+
+# ã·ãªã¢ã«çµç±ã®ã¿
+USE_DBG_CONS = true
+
+# falseãæå®ããã¨ãé¢æ° dbg_parse() ãå¿
+è¦ã§ããã
+USE_DBG_CONS_PARSER = true
+
+# ã·ãªã¢ã«ã¨ãããã¯ã¼ã¯çµç±
+# ãã ãããã³ãã­ãã­ã³ã°ã³ã¼ã«ãçµè¾¼ãã ææå¹
+USE_NET_CONS = true
+
+#  å
+±éã¯ã©ã¤ã¢ã³ããã­ã°ã©ã ã®é¸æ
+
+USE_TCP_ECHO_CLI = true
+USE_TCP4_ECHO_CLI = true
+USE_UDP_ECHO_CLI = true
+USE_UDP4_ECHO_CLI = true
+USE_TCP_DISCARD_CLI = true
+USE_UDP_DISCARD_CLI = true
+USE_DHCP6_CLI = true
+USE_DHCP4_CLI = true
+USE_RESOLVER = true
+USE_PING = true
+
+#  å
+±éãµã¼ãã¿ã¹ã¯æ°ã®é¸æ
+
+CDEFS := $(CDEFS) -DNUM_WWW_SRV_TASKS=1		# WWW ãµã¼ãã¿ã¹ã¯æ°ãæå¤§ 2
+CDEFS := $(CDEFS) -DNUM_TCP_ECHO_SRV_TASKS=4	# TCP ECHO ãµã¼ãã¿ã¹ã¯æ°ãæå¤§ 8
+
+#  äºç´ ID æ°ã®é¸æ
+
+CDEFS := $(CDEFS) -DNUM_VRID_TCP6_REPS=2	# TCP/IPv6 åä»å£äºç´ ID æ°ãæå¤§ 2
+CDEFS := $(CDEFS) -DNUM_VRID_TCP6_CEPS=4	# TCP/IPv6 éä¿¡ç«¯ç¹äºç´ ID æ°ãæå¤§ 4
+CDEFS := $(CDEFS) -DNUM_VRID_UDP6_CEPS=2	# UDP/IPv6 éä¿¡ç«¯ç¹äºç´ ID æ°ãæå¤§ 2
+CDEFS := $(CDEFS) -DNUM_VRID_TCP4_REPS=2	# TCP/IPv4 åä»å£äºç´ ID æ°ãæå¤§ 2
+CDEFS := $(CDEFS) -DNUM_VRID_TCP4_CEPS=2	# TCP/IPv4 éä¿¡ç«¯ç¹äºç´ ID æ°ãæå¤§ 4
+CDEFS := $(CDEFS) -DNUM_VRID_UDP4_CEPS=2	# UDP/IPv4 éä¿¡ç«¯ç¹äºç´ ID æ°ãæå¤§ 2
+
+#  TCP ã®ã»ã°ã¡ã³ããµã¤ãºã®é¸æ
+#CDEFS := $(CDEFS) -DUSE_TCP_MSS_SEG		# ã»ã°ã¡ã³ããµã¤ãºã MSS ã«ããã
+
+#  IPv6 MMTU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã®é¸æ
+#CDEFS := $(CDEFS) -DUSE_IPV6_MMTU
+
+#
+#  ãµã³ãã«ã®ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/netapp/Makefile.netapp
+
+#
+#  ã·ã¹ãã ãµã¼ãã¹ã® Makefile ã®ã¤ã³ã¯ã«ã¼ã
+#
+include $(SRCDIR)/tinet/Makefile.tinet
+
+#
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos4.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos4.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos4.c	(revision 317)
@@ -0,0 +1,521 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  IPv4ãTCP ECHO ãµã¼ããéåä¿¡ã¿ã¹ã¯åä¸å
+ */
+
+#include <string.h>
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/tcp.h>
+
+#include "echos4.h"
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  æ³¨æ:
+ *
+ *    BUF_SIZE ã¯ TCP ã®
+ *    éä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãº + åä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãºã® 
+ *    3/2 åä»¥ä¸ã®å¤§ããããªããã°ããããã­ãã¯ããå¯è½æ§ãããã
+ */
+
+#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
+                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
+
+static T_IPV4EP		dst;
+
+#ifdef USE_TCP_NON_BLOCKING
+
+static ER		nblk_error = E_OK;
+static ER_UINT		nblk_slen  = 0;
+static ER_UINT		nblk_rlen  = 0;
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_COPYSAVE_API
+
+static uint8_t 		buffer[BUF_SIZE];
+
+#endif	/* of #ifndef USE_COPYSAVE_API */
+
+/*
+ *  TCP éåä¿¡ãããã¡
+ */
+
+uint8_t tcp_echo_srv_swbuf[TCP_ECHO_SRV_SWBUF_SIZE];
+uint8_t tcp_echo_srv_rwbuf[TCP_ECHO_SRV_RWBUF_SIZE];
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		nblk_error = *(ER*)p_parblk;
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		if ((nblk_rlen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] recv err: %s", itron_strerror(nblk_rlen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_SND_DAT:
+		if ((nblk_slen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] send err: %s", itron_strerror(nblk_slen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if ((nblk_error = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] clse err: %s", itron_strerror(nblk_error));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_BUF:
+		if ((nblk_rlen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] rbuf err: %s", itron_strerror(nblk_rlen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_GET_BUF:
+		if ((nblk_slen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] sbuf err: %s", itron_strerror(nblk_slen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	T_IN4_ADDR	addr;
+	ID		tskid;
+	ER		error = E_OK;
+	uint32_t	total;
+	uint16_t	rblen, sblen, rlen, slen, soff, count;
+	char		*rbuf, *sbuf;
+
+	get_tid(&tskid);
+	addr = IPV4_ADDR_LOCAL;
+	syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK):%d,%d] (copy save API) started, IP Address: %s.", 
+	                   tskid, (ID)exinf, ip2str(NULL, &addr));
+	while (true) {
+		if ((error = tcp_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		if (nblk_error == E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] connected from %s:%d", ip2str(NULL, &dst.ipaddr), dst.portno);
+		else {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(nblk_error));
+			continue;
+			}
+
+		total = rlen = count = 0;
+		while (true) {
+			if ((error = tcp_rcv_buf((int_t)exinf, (void **)&rbuf, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s", itron_strerror(error));
+				break;
+				}
+
+			/* åä¿¡ããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+			if (nblk_rlen < 0) {		/* ã¨ã©ã¼ */
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s", itron_strerror(nblk_rlen));
+				break;
+				}
+			else if (nblk_rlen == 0)	/* åä¿¡çµäº */
+				break;
+
+			rblen = (uint16_t)nblk_rlen;
+
+			/* ãããã¡ã®æ®ãã«ãããåä¿¡é·ãèª¿æ´ããã*/
+			if (rblen > BUF_SIZE - rlen)
+				rblen = BUF_SIZE - rlen;
+
+			total += rblen;
+			rlen   = rblen;
+			count ++;
+			memcpy(buffer, rbuf, rblen);
+
+			if ((error = tcp_rel_buf((int_t)exinf, rlen)) < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) REL] error: %s",
+				                   itron_strerror(error));
+				break;
+				}
+
+			soff = 0;
+			while (rlen > 0) {
+
+				if ((error = tcp_get_buf((int_t)exinf, (void **)&sbuf, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+
+				/* éä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+				if (nblk_slen < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] error: %s",
+					                   itron_strerror(nblk_slen));
+					goto err_fin;
+					}
+				else
+					/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] len: %d", nblk_slen)*/;
+
+				sblen = (uint16_t)nblk_slen;
+				slen = sblen < rlen ? sblen : rlen;
+				memcpy(sbuf, buffer + soff, slen);
+
+				if ((error = tcp_snd_buf((int_t)exinf, slen)) != E_OK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] len: %d", slen);*/
+
+				rlen -= slen;
+				soff += slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_NBLK)) != E_WBLK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CLS] error: %s", itron_strerror(error));
+
+		/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) FIN] finished, total count: %d, len: %d", count, total);
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	T_IN4_ADDR	addr;
+	ID		tskid;
+	ER		error;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, count;
+
+	get_tid(&tskid);
+	addr = IPV4_ADDR_LOCAL;
+	syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK):%d,%d] started, IP Address: %s.", 
+	                   tskid, (ID)exinf, ip2str(NULL, &addr));
+	while (true) {
+		if ((error = tcp_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		if (nblk_error == E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] connected from %s:%d",
+			                   ip2str(NULL, &dst.ipaddr), dst.portno);
+			}
+		else {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(nblk_error));
+			continue;
+			}
+
+		count = total = 0;
+		while (true) {
+			if ((error = tcp_rcv_dat((int_t)exinf, buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s",
+				                   itron_strerror(error));
+				break;
+				}
+
+			/* åä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+			if (nblk_rlen < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s",
+				                   itron_strerror(nblk_rlen));
+				break;
+				}
+			else if (nblk_rlen == 0)
+				break;
+
+			rlen   = (uint16_t)nblk_rlen;
+			total += (uint32_t)nblk_rlen;
+			count ++;
+			soff = 0;
+			while (rlen > 0) {
+				if ((error = tcp_snd_dat((int_t)exinf, &buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+
+				/* éä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+				if (nblk_slen < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(nblk_slen));
+					goto err_fin;
+					}
+				else
+					/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] len: %4d", nblk_slen)*/;
+
+				slen = (uint16_t)nblk_slen;
+				rlen -= slen;
+				soff += slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_NBLK)) != E_WBLK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CLS] error: %s", itron_strerror(error));
+
+		/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	T_IN4_ADDR	addr;
+	ID		tskid;
+	ER_UINT		rblen, sblen;
+	ER		error = E_OK;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, count;
+	char		*rbuf, *sbuf;
+
+	get_tid(&tskid);
+	addr = IPV4_ADDR_LOCAL;
+	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] (copy save API) started, IP Address: %s.", 
+	                   tskid, (ID)exinf, ip2str(NULL, &addr));
+	while (true) {
+		if (tcp_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_FEVR) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		total = count = 0;
+		syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] connected from %s:%d", ip2str(NULL, &dst.ipaddr), dst.portno);
+		while (true) {
+			if ((rblen = tcp_rcv_buf((int_t)exinf, (void **)&rbuf, TMO_FEVR)) <= 0) {
+				if (rblen != E_OK)
+					syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] error: %s", itron_strerror(rblen));
+				break;
+				}
+
+			rlen   = (uint16_t)rblen;
+			total += (uint32_t)rblen;
+			count ++;
+			soff = 0;
+			while (rlen > 0) {
+
+				if ((sblen = tcp_get_buf((int_t)exinf, (void **)&sbuf, TMO_FEVR)) < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV GET] error: %s",
+					                   itron_strerror(sblen));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV GET] len: %d", sblen);*/
+			
+				slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
+				memcpy(sbuf, rbuf + soff, slen);
+				if ((error = tcp_snd_buf((int_t)exinf, slen)) != E_OK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV SND] len: %d", slen);*/
+
+				rlen -= slen;
+				soff += slen;
+				}
+
+			if ((error = tcp_rel_buf((int_t)exinf, rblen)) < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV REL] error: %s", itron_strerror(error));
+				break;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV CLS] error: %s", itron_strerror(error));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	T_IN4_ADDR	addr;
+	ID		tskid;
+	ER_UINT		rlen, slen;
+	ER		error = E_OK;
+	uint16_t	soff, count, total;
+
+	get_tid(&tskid);
+	addr = IPV4_ADDR_LOCAL;
+	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] started, IP Address: %s.", 
+	                   tskid, (ID)exinf, ip2str(NULL, &addr));
+	while (true) {
+		if (tcp_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_FEVR) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		total = count = 0;
+		syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] connected from %s:%d",
+		                   ip2str(NULL, &dst.ipaddr), dst.portno);
+		while (true) {
+			if ((rlen = tcp_rcv_dat((int_t)exinf, buffer, BUF_SIZE - 1, TMO_FEVR)) <= 0) {
+				if (rlen != E_OK)
+					syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] error: %s",
+					                   itron_strerror(rlen));
+				break;
+				}
+
+			/*syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] count: %4d, len: %4d, data %02x -> %02x",
+			       ++ count, (uint16_t)rlen, *buffer, *(buffer + rlen - 1));*/
+			count ++;
+			total += (uint16_t)rlen;
+			soff = 0;
+			while (rlen > 0) {
+				if ((slen = tcp_snd_dat((int_t)exinf, &buffer[soff], rlen, TMO_FEVR)) < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV SND] error: %s",
+					                   itron_strerror(slen));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV SND] len: %d", slen);*/
+				rlen -=     slen;
+				soff += (uint16_t)slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV CLS] error: %s", itron_strerror(error));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos4.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos4.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos4.cfg	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "echos4.h"
+
+/*
+ *  TCP ECHO ãµã¼ã #1ãéåä¿¡ã¿ã¹ã¯åä¸å
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(TCP_ECHO_SRV_TASK,  {
+	TA_HLNG|TA_ACT,
+	TCP_ECHO_SRV_CEPID,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos4.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos4.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos4.h	(revision 317)
@@ -0,0 +1,96 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _ECHOS_H_
+#define _ECHOS_H_
+
+#include <tinet_defs.h>
+
+/* 
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã 
+ */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024	/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5	/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  ä½¿ç¨ãã API ã®é¸æ
+ */
+
+//#define USE_TCP_NON_BLOCKING
+//#define USE_COPYSAVE_API
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE	(TCP_MSS)
+#define TCP_ECHO_SRV_RWBUF_SIZE	(TCP_MSS)
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  TCP éåä¿¡ãããã¡
+ */
+
+extern uint8_t tcp_echo_srv_swbuf[];
+extern uint8_t tcp_echo_srv_rwbuf[];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void tcp_echo_srv_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _ECHOS_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos6.c	(revision 317)
@@ -0,0 +1,507 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  IPv6ãTCP ECHO ãµã¼ããéåä¿¡ã¿ã¹ã¯åä¸å
+ */
+
+#include <string.h>
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/tcp.h>
+
+#include "echos6.h"
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  æ³¨æ:
+ *
+ *    BUF_SIZE ã¯ TCP ã®
+ *    éä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãº + åä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãºã® 
+ *    3/2 åä»¥ä¸ã®å¤§ããããªããã°ããããã­ãã¯ããå¯è½æ§ãããã
+ */
+
+#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
+                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
+
+static T_IPV6EP		dst;
+
+#ifdef USE_TCP_NON_BLOCKING
+
+static ER		nblk_error = E_OK;
+static ER_UINT		nblk_slen  = 0;
+static ER_UINT		nblk_rlen  = 0;
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_COPYSAVE_API
+
+static uint8_t 		buffer[BUF_SIZE];
+
+#endif	/* of #ifndef USE_COPYSAVE_API */
+
+/*
+ *  TCP éåä¿¡ãããã¡
+ */
+
+uint8_t tcp_echo_srv_swbuf[TCP_ECHO_SRV_SWBUF_SIZE];
+uint8_t tcp_echo_srv_rwbuf[TCP_ECHO_SRV_RWBUF_SIZE];
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		nblk_error = *(ER*)p_parblk;
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		if ((nblk_rlen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] recv err: %s", itron_strerror(nblk_rlen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_SND_DAT:
+		if ((nblk_slen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] send err: %s", itron_strerror(nblk_slen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if ((nblk_error = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] clse err: %s", itron_strerror(nblk_error));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_BUF:
+		if ((nblk_rlen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] rbuf err: %s", itron_strerror(nblk_rlen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_GET_BUF:
+		if ((nblk_slen = *(ER_UINT*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CBN] sbuf err: %s", itron_strerror(nblk_slen));
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+		break;
+
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	ID		tskid;
+	ER		error = E_OK;
+	uint32_t	total;
+	uint16_t	rblen, sblen, rlen, slen, soff, count;
+	char		*rbuf, *sbuf;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK):%d,%d] (copy save API) started.", tskid, (int_t)exinf);
+	while (true) {
+		if ((error = tcp6_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		if (nblk_error == E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] connected from %s:%d", ipv62str(NULL, &dst.ipaddr), dst.portno);
+		else {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(nblk_error));
+			continue;
+			}
+
+		total = rlen = count = 0;
+		while (true) {
+			if ((error = tcp_rcv_buf((int_t)exinf, (void **)&rbuf, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s", itron_strerror(error));
+				break;
+				}
+
+			/* åä¿¡ããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+			if (nblk_rlen < 0) {		/* ã¨ã©ã¼ */
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s", itron_strerror(nblk_rlen));
+				break;
+				}
+			else if (nblk_rlen == 0)	/* åä¿¡çµäº */
+				break;
+
+			rblen = (uint16_t)nblk_rlen;
+
+			/* ãããã¡ã®æ®ãã«ãããåä¿¡é·ãèª¿æ´ããã*/
+			if (rblen > BUF_SIZE - rlen)
+				rblen = BUF_SIZE - rlen;
+
+			total += rblen;
+			rlen   = rblen;
+			count ++;
+			memcpy(buffer, rbuf, rblen);
+
+			if ((error = tcp_rel_buf((int_t)exinf, rlen)) < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) REL] error: %s",
+				                   itron_strerror(error));
+				break;
+				}
+
+			soff = 0;
+			while (rlen > 0) {
+
+				if ((error = tcp_get_buf((int_t)exinf, (void **)&sbuf, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+
+				/* éä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+				if (nblk_slen < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] error: %s",
+					                   itron_strerror(nblk_slen));
+					goto err_fin;
+					}
+				else
+					/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) GET] len: %d", nblk_slen)*/;
+
+				sblen = (uint16_t)nblk_slen;
+				slen = sblen < rlen ? sblen : rlen;
+				memcpy(sbuf, buffer + soff, slen);
+
+				if ((error = tcp_snd_buf((int_t)exinf, slen)) != E_OK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] len: %d", slen);*/
+
+				rlen -= slen;
+				soff += slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_NBLK)) != E_WBLK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CLS] error: %s", itron_strerror(error));
+
+		/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) FIN] finished, total count: %d, len: %d", count, total);
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	ID		tskid;
+	ER		error;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, count;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK):%d,%d] started.", tskid, (int_t)exinf);
+	while (true) {
+		if ((error = tcp6_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		if (nblk_error == E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] connected from %s:%d",
+			                   ipv62str(NULL, &dst.ipaddr), dst.portno);
+			}
+		else {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) ACP] error: %s", itron_strerror(nblk_error));
+			continue;
+			}
+
+		count = total = 0;
+		while (true) {
+			if ((error = tcp_rcv_dat((int_t)exinf, buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s",
+				                   itron_strerror(error));
+				break;
+				}
+
+			/* åä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+			if (nblk_rlen < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) RCV] error: %s",
+				                   itron_strerror(nblk_rlen));
+				break;
+				}
+			else if (nblk_rlen == 0)
+				break;
+
+			rlen   = (uint16_t)nblk_rlen;
+			total += (uint32_t)nblk_rlen;
+			count ++;
+			soff = 0;
+			while (rlen > 0) {
+				if ((error = tcp_snd_dat((int_t)exinf, &buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+
+				/* éä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+				if (nblk_slen < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] error: %s",
+					                   itron_strerror(nblk_slen));
+					goto err_fin;
+					}
+				else
+					/*syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND] len: %4d", nblk_slen)*/;
+
+				slen = (uint16_t)nblk_slen;
+				rlen -= slen;
+				soff += slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_NBLK)) != E_WBLK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) CLS] error: %s", itron_strerror(error));
+
+		/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_NBLK_READY));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	ID		tskid;
+	ER_UINT		rblen, sblen;
+	ER		error = E_OK;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, count;
+	char		*rbuf, *sbuf;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] (copy save API) started.", tskid, (int_t)exinf);
+	while (true) {
+		if (tcp6_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_FEVR) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		total = count = 0;
+		syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] connected from %s:%d", ipv62str(NULL, &dst.ipaddr), dst.portno);
+		while (true) {
+			if ((rblen = tcp_rcv_buf((int_t)exinf, (void **)&rbuf, TMO_FEVR)) <= 0) {
+				if (rblen != E_OK)
+					syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] error: %s", itron_strerror(rblen));
+				break;
+				}
+
+			rlen   = (uint16_t)rblen;
+			total += (uint32_t)rblen;
+			count ++;
+			soff = 0;
+			while (rlen > 0) {
+
+				if ((sblen = tcp_get_buf((int_t)exinf, (void **)&sbuf, TMO_FEVR)) < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV GET] error: %s",
+					                   itron_strerror(sblen));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV GET] len: %d", sblen);*/
+			
+				slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
+				memcpy(sbuf, rbuf + soff, slen);
+				if ((error = tcp_snd_buf((int_t)exinf, slen)) != E_OK) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV SND] error: %s",
+					                   itron_strerror(error));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV SND] len: %d", slen);*/
+
+				rlen -= slen;
+				soff += slen;
+				}
+
+			if ((error = tcp_rel_buf((int_t)exinf, rblen)) < 0) {
+				syslog(LOG_NOTICE, "[TCP ECHO SRV REL] error: %s", itron_strerror(error));
+				break;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV CLS] error: %s", itron_strerror(error));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	ID		tskid;
+	ER_UINT		rlen, slen;
+	ER		error = E_OK;
+	uint16_t	soff, count, total;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d,%d] started.", tskid, (int_t)exinf);
+	while (true) {
+		if (tcp6_acp_cep((int_t)exinf, TCP_ECHO_SRV_REPID, &dst, TMO_FEVR) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] error: %s", itron_strerror(error));
+			continue;
+			}
+
+		total = count = 0;
+		syslog(LOG_NOTICE, "[TCP ECHO SRV ACP] connected from %s:%d",
+		                   ipv62str(NULL, &dst.ipaddr), dst.portno);
+		while (true) {
+			if ((rlen = tcp_rcv_dat((int_t)exinf, buffer, BUF_SIZE - 1, TMO_FEVR)) <= 0) {
+				if (rlen != E_OK)
+					syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] error: %s",
+					                   itron_strerror(rlen));
+				break;
+				}
+
+			/*syslog(LOG_NOTICE, "[TCP ECHO SRV RCV] count: %4d, len: %4d, data %02x -> %02x",
+			       ++ count, (uint16_t)rlen, *buffer, *(buffer + rlen - 1));*/
+			count ++;
+			total += (uint16_t)rlen;
+			soff = 0;
+			while (rlen > 0) {
+				if ((slen = tcp_snd_dat((int_t)exinf, &buffer[soff], rlen, TMO_FEVR)) < 0) {
+					syslog(LOG_NOTICE, "[TCP ECHO SRV SND] error: %s",
+					                   itron_strerror(slen));
+					goto err_fin;
+					}
+				/*syslog(LOG_NOTICE, "[TCP ECHO SRV SND] len: %d", slen);*/
+				rlen -=     slen;
+				soff += (uint16_t)slen;
+				}
+			}
+	err_fin:
+
+		if ((error = tcp_sht_cep((int_t)exinf)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV SHT] error: %s", itron_strerror(error));
+
+		if ((error = tcp_cls_cep((int_t)exinf, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[TCP ECHO SRV CLS] error: %s", itron_strerror(error));
+
+		syslog(LOG_NOTICE, "[TCP ECHO SRV FIN] finished, total cnt: %d, len: %d", count, total);
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos6.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos6.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos6.cfg	(revision 317)
@@ -0,0 +1,82 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "echos6.h"
+
+/*
+ *  TCP ECHO ãµã¼ã #1ãéåä¿¡ã¿ã¹ã¯åä¸å
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+CRE_TSK(TCP_ECHO_SRV_TASK,  {
+	TA_HLNG|TA_ACT,
+	TCP_ECHO_SRV_CEPID,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/echos6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/echos6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/echos6.h	(revision 317)
@@ -0,0 +1,96 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _ECHOS_H_
+#define _ECHOS_H_
+
+#include <tinet_defs.h>
+
+/* 
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã 
+ */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024	/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5	/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  ä½¿ç¨ãã API ã®é¸æ
+ */
+
+#define USE_TCP_NON_BLOCKING
+//#define USE_COPYSAVE_API
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE	(TCP6_MSS)
+#define TCP_ECHO_SRV_RWBUF_SIZE	(TCP6_MSS)
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  TCP éåä¿¡ãããã¡
+ */
+
+extern uint8_t tcp_echo_srv_swbuf[];
+extern uint8_t tcp_echo_srv_rwbuf[];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void tcp_echo_srv_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _ECHOS_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/minsv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/minsv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/minsv.c	(revision 317)
@@ -0,0 +1,71 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  æå°æ§æãµã¼ãè©¦é¨ãã­ã°ã©ã ã®æ¬ä½
+ */
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+
+#include "minsv.h"
+
+/*
+ *  arp_callback_duplicated -- IP ã¢ãã¬ã¹éè¤æ¤åºç¨ã³ã¼ã«ããã¯é¢æ°
+ */
+
+bool_t arp_callback_duplicated (uint8_t *shost)
+{
+	static uint8_t shost_addr[sizeof("00:00:00:00:00:00")];
+
+	mac2str(shost_addr, shost);
+	syslog(LOG_ERROR, "[MINSV] IP address duplicated: %s", shost_addr);
+
+	return false;
+	}
Index: asp3_gr_sakura/trunk/tinet/asp_sample/minsv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/minsv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/minsv.cfg	(revision 317)
@@ -0,0 +1,63 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  æå°æ§æãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "@(TINETDIR)/netapp/wwws.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv1.h"
+
+#include "minsv.h"
+
+INCLUDE("@(TINETDIR)/netapp/wwws_asp.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_echo_srv1.cfg");
+INCLUDE("@(TINETDIR)/netapp/netapp_subr.cfg");
Index: asp3_gr_sakura/trunk/tinet/asp_sample/minsv.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/minsv.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/minsv.h	(revision 317)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _MINSV_H_
+#define _MINSV_H_
+
+/* 
+ *  æå°æ§æãµã¼ãè©¦é¨ãã­ã°ã©ã 
+ */
+
+#include <tinet_defs.h>
+
+/* 
+ *  ãµã¼ãã®ã¹ã¿ãã¯ãµã¤ãº
+ */
+
+#undef  TCP_ECHO_SRV_STACK_SIZE
+#define TCP_ECHO_SRV_STACK_SIZE		768		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+#undef  WWW_SRV_STACK_SIZE
+#define	WWW_SRV_STACK_SIZE		768		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#undef  DBG_CON_STACK_SIZE
+#define	DBG_CON_STACK_SIZE		1024		/* ã³ã³ã½ã¼ã«ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+#endif	/* of #ifndef _MINSV_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/nserv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/nserv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/nserv.c	(revision 317)
@@ -0,0 +1,75 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®æ¬ä½
+ */
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+
+#include "nserv.h"
+
+#if defined(SUPPORT_ETHER) && defined(SUPPORT_INET4)
+
+/*
+ *  arp_callback_duplicated -- IP ã¢ãã¬ã¹éè¤æ¤åºç¨ã³ã¼ã«ããã¯é¢æ°
+ */
+
+bool_t arp_callback_duplicated (uint8_t *shost)
+{
+	static char shost_addr[sizeof("00:00:00:00:00:00")];
+
+	mac2str(shost_addr, (char *)shost);
+	syslog(LOG_ERROR, "[NSERV] IP address duplicated: %s", shost_addr);
+
+	return false;
+	}
+
+#endif	/* of #if defined(SUPPORT_ETHER) && defined(SUPPORT_INET4) */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/nserv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/nserv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/nserv.cfg	(revision 317)
@@ -0,0 +1,90 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "@(TINETDIR)/netapp/wwws.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv1.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv2.h"
+#include "@(TINETDIR)/netapp/tcp_echo_cli.h"
+#include "@(TINETDIR)/netapp/tcp_discard_srv.h"
+#include "@(TINETDIR)/netapp/tcp_discard_cli.h"
+#include "@(TINETDIR)/netapp/udp6_echo_srv.h"
+#include "@(TINETDIR)/netapp/udp4_echo_srv.h"
+#include "@(TINETDIR)/netapp/udp6_echo_cli.h"
+#include "@(TINETDIR)/netapp/udp4_echo_cli.h"
+#include "@(TINETDIR)/netapp/udp_discard_cli.h"
+#include "@(TINETDIR)/netapp/dbg_cons.h"
+#include "@(TINETDIR)/netapp/resolver.h"
+#include "@(TINETDIR)/netapp/dhcp6_cli.h"
+#include "@(TINETDIR)/netapp/dhcp4_cli.h"
+
+#include "nserv.h"
+
+INCLUDE("@(TINETDIR)/netapp/wwws_asp.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_echo_srv1.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_echo_srv2.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_discard_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/tcp_discard_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/udp6_echo_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/udp4_echo_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/udp6_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/udp4_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/udp_discard_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/dbg_cons.cfg");
+INCLUDE("@(TINETDIR)/netapp/net_cons.cfg");
+INCLUDE("@(TINETDIR)/netapp/netapp_subr.cfg");
+INCLUDE("@(TINETDIR)/netapp/resolver_asp.cfg");
+INCLUDE("@(TINETDIR)/netapp/dhcp6_cli_asp.cfg");
+INCLUDE("@(TINETDIR)/netapp/dhcp4_cli_asp.cfg");
Index: asp3_gr_sakura/trunk/tinet/asp_sample/nserv.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/nserv.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/nserv.h	(revision 317)
@@ -0,0 +1,53 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NSERV_H_
+#define _NSERV_H_
+
+/* 
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã 
+ */
+
+#endif	/* of #ifndef _NSERV_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/route_cfg.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/route_cfg.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/route_cfg.c	(revision 317)
@@ -0,0 +1,113 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+#include <kernel.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef _IP6_CFG
+
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+T_IN6_RTENTRY routing6_tbl[NUM_IN6_ROUTE_ENTRY];
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
+
+#endif	/* of #ifdef _IP6_CFG */
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef _IP4_CFG
+
+#ifdef SUPPORT_LOOP
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_PPP
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+	{ 0, 0, 0 },
+	};
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+T_IN4_RTENTRY routing4_tbl[NUM_IN4_ROUTE_ENTRY] = {
+
+	/* ç°ãªã LANãdefault gateway ã«ããéæ¥é
+é	*/
+	{ 0,			0,			IPV4_ADDR_DEFAULT_GW	},
+
+	/* åä¸ LAN å
+ãç´æ¥é
+é				*/
+	{ IPV4_ADDR_LOCAL &
+	  IPV4_ADDR_LOCAL_MASK,	IPV4_ADDR_LOCAL_MASK,	0			},
+
+	/* åä¸ LAN å
+ã¸ã®ãã­ã¼ãã­ã£ã¹ããç´æ¥é
+é	*/
+	{ 0xffffffff,		0xffffffff,		0			},
+
+	};
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifdef _IP4_CFG */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.c	(revision 317)
@@ -0,0 +1,775 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯åãµã³ãã«ãã­ã°ã©ã (1)ã®æ¬ä½
+ */
+
+#include <stdarg.h>
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include "syssvc/serial.h"
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <netinet/in4.h>
+#include <netinet6/in6.h>
+#include <netinet/in_itron.h>
+
+#include "sample1n.h"
+
+/*
+ *  ãã¯ã­å®ç¾©
+ */
+
+/*  ãªãã¼ã ã®è§£é¤  */
+
+#undef syslog
+#undef serial_rea_dat
+#undef serial_ctl_por
+
+#define EOF		(-1)
+
+/*  TELNET ãªãã·ã§ã³ */
+
+#define TELNET_OPT_SE		(240)
+#define TELNET_OPT_NOP		(241)
+#define TELNET_OPT_DM		(242)
+#define TELNET_OPT_BRK		(243)
+#define TELNET_OPT_IP		(244)
+#define TELNET_OPT_AO		(245)
+#define TELNET_OPT_AYT		(246)
+#define TELNET_OPT_EC		(247)
+#define TELNET_OPT_EL		(248)
+#define TELNET_OPT_GA		(249)
+#define TELNET_OPT_SB		(250)
+#define TELNET_OPT_WILL		(251)
+#define TELNET_OPT_WONT		(252)
+#define TELNET_OPT_DO		(253)
+#define TELNET_OPT_DONT		(254)
+#define TELNET_OPT_IAC		(255)
+
+/*
+ *  å¤æ°
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+uint8_t tcp_swbuf[TCP_SWBUF_SIZE];
+uint8_t tcp_rwbuf[TCP_RWBUF_SIZE];
+
+bool_t		connected	= false;	/* ã³ãã¯ã·ã§ã³ã®ç¶æ
+	*/
+bool_t		wait_accept	= false;	/* æ¥ç¶è¦æ±å¾
+ã¡ä¸­	*/
+
+#ifdef SUPPORT_INET6
+
+T_IPV6EP	dst;
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+T_IPV4EP	dst;
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+uint8_t		*snd_buff	= NULL;
+uint8_t		*rcv_buff	= NULL;
+uint_t		snd_off		= 0;
+uint_t		rcv_off		= 0;
+ER_UINT		snd_len		= 0;
+ER_UINT		rcv_len		= 0;
+uint_t		net_ioctl	= IOCTL_NULL;
+uint8_t		addr[sizeof("0123:4567:89ab:cdef:0123:4567:89ab:cdef")];
+
+/*
+ *  ãããã¯ã¼ã¯å±¤ã®é¸æ
+ */
+
+#ifdef SUPPORT_INET6
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ipv62str(s,a)
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#define TCP_ACP_CEP(c,r,d,t)	tcp_acp_cep(c,r,d,t)
+#define IP2STR(s,a)		ip2str(s,a)
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		IP2STR(addr, &dst.ipaddr);
+		syslog(LOG_NOTICE, "connected:    %s.%d", addr, dst.portno);
+		if (*(ER*)p_parblk == E_OK)
+			connected = true;
+		snd_len = snd_off = rcv_len = rcv_off = 0;
+		wait_accept = false;
+		break;
+
+	case TFN_TCP_CLS_CEP:
+	case TFN_TCP_RCV_BUF:
+	case TFN_TCP_GET_BUF:
+	case TFN_TCP_RCV_DAT:
+	case TFN_TCP_SND_DAT:
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  ã³ãã¯ã·ã§ã³ãåæ­
+ */
+
+ER
+disconnecting (void)
+{
+	ER	error = E_OK;
+
+	if (connected) {
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off > 0)
+			tcp_snd_buf(TCP_CEPID, snd_off);
+		tcp_sht_cep(TCP_CEPID);
+		tcp_cls_cep(TCP_CEPID, TMO_FEVR);
+		connected = false;
+		syscall(sig_sem(SEM_NET_SEND));
+		IP2STR(addr, &dst.ipaddr);
+		syslog(LOG_NOTICE, "disconnected: %s.%d", addr, dst.portno);
+		}
+	return error;
+	}
+
+/*
+ *  éä¿¡ãããã¡ã®ãã©ãã·ã¥
+ */
+
+void
+flush_snd_buff (ID cepid)
+{
+	if (connected) {
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off > 0) {
+			tcp_snd_buf(cepid, snd_off);
+			snd_len = snd_off = 0;
+			}
+		syscall(sig_sem(SEM_NET_SEND));
+		}
+	return;
+	}
+
+/*
+ *  æå­éä¿¡
+ */
+
+void
+put_char (ID cepid, char ch)
+{
+	if (connected) {
+		if (ch == '\n' && (net_ioctl & IOCTL_CRLF) != 0)
+			put_char(cepid, '\r');
+		syscall(wai_sem(SEM_NET_SEND));
+		if (snd_off >= snd_len) {
+			if (tcp_snd_buf(cepid, snd_off) != E_OK) {
+				syscall(sig_sem(SEM_NET_SEND));
+				return;
+				}
+			snd_off = 0;
+			if ((snd_len = tcp_get_buf(cepid, (void**)&snd_buff, TMO_FEVR)) <= 0) {
+				syscall(sig_sem(SEM_NET_SEND));
+				return;
+				}
+			}
+		snd_buff[snd_off ++] = ch;
+		syscall(sig_sem(SEM_NET_SEND));
+		}
+	}
+
+/*
+ *  æå­åä¿¡ï¼å¤æãªãï¼
+ */
+
+int_t
+get_char_raw (ID cepid)
+{
+	if (connected) {
+		if (rcv_off >= rcv_len) {
+			rcv_off = 0;
+			if (tcp_rel_buf(TCP_CEPID, rcv_len) != E_OK) {
+				disconnecting();
+				return EOF;
+				}
+			if ((rcv_len = tcp_rcv_buf(TCP_CEPID, (void**)&rcv_buff, TMO_FEVR)) == 0) {
+				disconnecting();
+				return EOF;
+				}
+			else if (rcv_len < 0) {
+				disconnecting();
+				return EOF;
+				}
+			}
+		return rcv_buff[rcv_off ++];
+		}
+	else
+		return EOF;
+	}
+
+/*
+ *  æå­åä¿¡ï¼TELNET ãªãã·ã§ã³ãã¹ã­ããï¼
+ */
+
+int_t
+get_char (ID cepid)
+{
+	int_t	ch, req;
+
+	while ((ch = get_char_raw(cepid)) == TELNET_OPT_IAC || ch == '\0') {
+		if (ch != '\0') {
+			switch (ch = get_char_raw(cepid)) {
+			case TELNET_OPT_WILL:
+			case TELNET_OPT_WONT:
+			case TELNET_OPT_DO:
+			case TELNET_OPT_DONT:
+				req = get_char_raw(cepid);
+				break;
+			case TELNET_OPT_SB:
+				while ((ch = get_char_raw(cepid)) != EOF && ch != TELNET_OPT_IAC) {
+					if ((ch = get_char_raw(cepid)) == EOF || ch == TELNET_OPT_SE)
+						break;
+					}
+				break;
+			default:
+				break;
+				}
+			}
+		}
+	return ch;
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãããã®èª­åºã
+ */
+
+ER_UINT
+net_serial_rea_dat (ID portid, char *buf, uint_t len)
+{
+	T_SERIAL_RPOR	rpor;
+	uint_t		off;
+	int_t		ch;
+
+	if (!wait_accept && !connected) {
+		wait_accept = true;
+		if (TCP_ACP_CEP(TCP_CEPID, TCP_REPID, &dst, TMO_NBLK) != E_WBLK)
+			return 0;
+		}
+
+	while (true) {
+		if (connected) {
+			off = 0;
+			while (off < len && (ch = get_char(TCP_CEPID)) != EOF) {
+				*(buf + off ++) = ch;
+				if ((net_ioctl & IOCTL_ECHO) != 0) {
+					put_char(TCP_CEPID, ch);
+					flush_snd_buff(TCP_CEPID);
+					}
+				}
+			return off;
+			}
+		else if (serial_ref_por(portid, &rpor) == E_OK && rpor.reacnt > 0) {
+			return serial_rea_dat(portid, buf, len);
+			}
+		dly_tsk(500);
+		}
+	return off;
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡
+ */
+
+ER
+net_serial_ctl_por (ID portid, uint_t ioctl)
+{
+	net_ioctl = ioctl;
+	return serial_ctl_por(portid, ioctl);
+	}
+
+/*
+ *  ãã£ã¨ãé·ãæ´æ°å (LONGEST) ã¨ç¬¦å·ãªãæ´æ°å (ULONGEST)
+ */
+
+#ifdef LONGLONG_TYPE
+
+typedef LONGLONG_TYPE		LONGEST;
+typedef unsigned LONGLONG_TYPE	ULONGEST;
+
+#else	/* of #ifdef LONGLONG_TYPE */
+
+#ifdef LONG_TYPE
+
+typedef LONG_TYPE		LONGEST;
+typedef unsigned LONG_TYPE	ULONGEST;
+
+#else	/* of #ifdef LONG_TYPE */
+
+typedef int_t			LONGEST;
+typedef uint_t			ULONGEST;
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#endif	/* of #ifdef LONGLONG_TYPE */
+
+/*
+ *  ã­ã°ã®ã·ãã¥ã¬ã¼ã·ã§ã³
+ */
+
+/*  æ°å¤å¤æã®ããã®å¤æè¡¨  */
+
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  put_num -- printf ã®æ°å¤å¤æ
+ */
+
+int_t
+put_num(ID cepid, ULONGEST val, int_t radix, const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+	bool_t	left;
+
+	if (width < 0) {
+		width = -width;
+		left = true;
+		}
+	else
+		left = false;
+
+	ix = 0;
+	do {
+		digits[ix ++] = radchar[val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	pad = ix;
+	if (!left)	/* å³è©°ã */
+		for ( ; pad < width; pad ++)
+			put_char(cepid, padchar);
+
+	while (ix -- > 0)
+		put_char(cepid, digits[ix]);
+
+	if (left)	/* å·¦è©°ã */
+		for ( ; pad < width; pad ++)
+			put_char(cepid, padchar);
+
+	return pchars;
+	}
+
+/*
+ *  ipv6addr -- IPv6 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv6addr (ID cepid, const T_IN6_ADDR *addr, int_t width)
+{
+	int_t	len = 0, ix;
+	bool_t	omit = false, zero = false;
+
+	if (addr == NULL) {
+		put_char(cepid, '0');
+		put_char(cepid, ':');
+		put_char(cepid, ':');
+		put_char(cepid, '0');
+		len = 4;
+		}
+	else {
+		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+			if (omit) {
+				len += put_num(cepid, addr->s6_addr16[ix], 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					put_char(cepid, ':');
+					len ++;
+					}
+				}
+			else if (ix > 0 && ix < 7 && addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					put_char(cepid, ':');
+					len ++;
+					}
+				len += put_num(cepid, addr->s6_addr16[ix], 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					put_char(cepid, ':');
+					len ++;
+					}
+				}
+			}
+
+		for ( ; len < width; len ++)
+			put_char(cepid, ' ');
+		}
+	return len;
+	}
+
+/*
+ *  put_ipv4addr -- IPv4 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv4addr (ID cepid, ULONGEST *addr, int_t width)
+{
+	int_t len = 3;	/* 3 ã¯ '.' ã®æå­æ° */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+	len += put_num(cepid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+
+#else	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	len += put_num(cepid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	put_char(cepid, '.');
+	len += put_num(cepid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+
+#endif	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	for ( ; len < width; len ++)
+		put_char(cepid, ' ');
+
+	return len;
+	}
+
+/*
+ *  put_macaddr -- MAC ã¢ãã¬ã¹åºå
+ */
+
+static int_t
+put_macaddr (ID cepid, char *mac, int_t width)
+{
+	int_t oct, len;
+
+	for (oct = 5; oct -- > 0; ) {
+		put_num(cepid, *mac ++, 16, radhex, 2, false, '0'); 
+		put_char(cepid, ':');
+		}
+	put_num(cepid, *mac, 16, radhex, 2, false, '0'); 
+
+	for (len = 17; len < width; len ++)
+		put_char(cepid, ' ');
+
+	return len;
+	}
+
+/*
+ *  å¼æ°ãåãåºãããã®ãã¯ã­
+ */
+
+#ifdef LONGLONG_TYPE
+
+#ifdef LONG_TYPE
+
+#define GET_ARG(ap,lf)	((lf > 1) ? va_arg(ap, LONGLONG_TYPE)	\
+			 (lf      ? va_arg(ap, LONG_TYPE)	\
+			          : va_arg(ap, int_t)))
+
+#else	/* of #ifdef LONG_TYPE */
+
+#define GET_ARG(ap,lf)	((lf > 1) ? va_arg(ap, LONGLONG_TYPE)	\
+			          : va_arg(ap, int_t))
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#else	/* of #ifdef LONGLONG_TYPE */
+
+#ifdef LONG_TYPE
+
+#define GET_ARG(ap,lf)	 (lf      ? va_arg(ap, LONG_TYPE)	\
+			          : va_arg(ap, int_t))
+
+#else	/* of #ifdef LONG_TYPE */
+
+#define GET_ARG(ap,lf)	(va_arg(ap, int_t))
+
+#endif	/* of #ifdef LONG_TYPE */
+
+#endif	/* of #ifdef LONGLONG_TYPE */
+
+/*
+ *  ã­ã°åºå
+ */
+
+void
+net_syslog (uint_t prio, const char *format, ...)
+{
+	LONGEST	val;
+	SYSLOG	log;
+	va_list	ap;
+	char	padchar, *str;
+	int_t	ch, width, longflag, shortflag, left, i, c;
+
+	if (connected) {
+		syscall(wai_sem(SEM_TCP_SYSLOG));
+		va_start(ap, format);
+		while ((ch = *format ++) != '\0') {
+			if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+				put_char(TCP_CEPID, (char)ch);
+				continue;
+				}
+
+			width = longflag = shortflag = 0;
+			padchar = ' ';
+
+			if (ch == '-') {		/* å·¦è©°ã */
+				format ++;
+				left = -1;
+				}
+			else
+				left = 1;
+
+			if ((ch = *format ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+				padchar = '0';
+				ch = *format ++;
+				}
+
+			while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+				width = width * 10 + ch - '0';
+				ch = *format ++;
+				}
+
+			while (ch == 'l') {		/* long (long) ã®æå® */
+				longflag ++;
+				ch = *format ++;
+				}
+
+			while (ch == 'h') {		/* short ã®æå® */
+				shortflag ++;
+				ch = *format ++;
+				}
+
+			switch (ch) {
+			case 'd':
+				val = GET_ARG(ap, longflag);
+				if (val >= 0)
+					put_num(TCP_CEPID,  val, 10, radhex, width * left, false, padchar);
+				else
+					put_num(TCP_CEPID, -val, 10, radhex, width * left, true, padchar);
+				break;
+
+			case 'u':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 10, radhex, width * left, false, padchar);
+				break;
+
+			case 'x':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 16, radhex, width * left, false, padchar);
+				break;
+
+			case 'X':
+				val = GET_ARG(ap, longflag);
+				put_num(TCP_CEPID, val, 16, radHEX, width * left, false, padchar);
+				break;
+
+			case 'c':
+				ch = va_arg(ap, int_t);
+				put_char(TCP_CEPID, (char)ch);
+				break;
+
+			case 's':
+				str = va_arg(ap, char*);
+				while ((ch = *str ++) != '\0') {
+					put_char(TCP_CEPID, (char)ch);
+					width --;
+					}
+				while (width -- > 0)
+					put_char(TCP_CEPID, ' ');
+				break;
+
+			case 'I':
+
+				if (longflag) {
+					str = va_arg(ap, char*);
+					put_ipv6addr(TCP_CEPID, (T_IN6_ADDR *)str, width);
+					}
+				else if (shortflag) {
+					val = GET_ARG(ap, longflag);
+					put_ipv4addr(TCP_CEPID, (ULONGEST *)val, width);
+					}
+				else {
+
+#ifdef SUPPORT_INET6
+
+					str = va_arg(ap, char*);
+					put_ipv6addr(TCP_CEPID, (T_IN6_ADDR *)str, width);
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+					val = GET_ARG(ap, longflag);
+					put_ipv4addr(TCP_CEPID, (ULONGEST *)val, width);
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+					}
+
+				break;
+
+			case 'M':
+				str = va_arg(ap, char*);
+				put_macaddr(TCP_CEPID, str, width);
+				break;
+
+			case '%':
+				put_char(TCP_CEPID, '%');
+				break;
+
+			case '0':
+				format --;
+				break;
+
+			default:
+				break;
+				}
+
+			}
+		va_end(ap);
+		put_char(TCP_CEPID, '\n');
+		flush_snd_buff(TCP_CEPID);
+		syscall(sig_sem(SEM_TCP_SYSLOG));
+		return /*E_OK*/;
+		}
+	else {
+		log.logtype = LOG_TYPE_COMMENT;
+		log.loginfo[0] = (intptr_t)format;
+		i = 1;
+		va_start(ap, format);
+
+		while ((c = *format++) != '\0' && i < TMAX_LOGINFO) {
+			if (c != '%') {
+				continue;
+				}
+
+			c = *format++;
+			while ('0' <= c && c <= '9') {
+				c = *format++;
+				}
+			switch (c) {
+			case 'd':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, int_t);
+				break;
+			case 'u':
+			case 'x':
+			case 'X':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, uint_t);
+				break;
+			case 'p':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, void *);
+				break;
+			case 'c':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, int_t);
+				break;
+			case 's':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, const char *);
+				break;
+			case '\0':
+				format--;
+				break;
+			default:
+				break;
+				}
+			}
+		va_end(ap);
+		return /*(syslog_wri_log(prio, &log))*/;
+		}
+	}
Index: asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.cfg	(revision 317)
@@ -0,0 +1,22 @@
+/*
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ãµã³ãã«ãã­ã°ã©ã (1)ã®
+ *  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+
+#include "sample1n.h"
+
+INCLUDE("sample1.cfg");
+
+INCLUDE("tinet_asp.cfg");
+
+INCLUDE("tinet_sample1n.cfg");
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_TCP_SYSLOG, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_NET_SEND,   { TA_TPRI, 1, 1 });
Index: asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/sample1n.h	(revision 317)
@@ -0,0 +1,85 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _SAMPLE1N_H_
+#define _SAMPLE1N_H_
+
+#include <tinet_defs.h>
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ãµã³ãã«ãã­ã°ã©ã (1)ã®ããããã¡ã¤ã«
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº  */
+
+#define TCP_SWBUF_SIZE	512
+#define TCP_RWBUF_SIZE	512
+
+/*  ãªãã¼ã   */
+
+#define syslog		net_syslog
+#define serial_rea_dat	net_serial_rea_dat
+#define serial_ctl_por	net_serial_ctl_por
+
+#ifndef _MACRO_ONLY
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+extern uint8_t tcp_swbuf[];
+extern uint8_t tcp_rwbuf[];
+
+/*  ãããã¯ã¼ã¯å¯¾å¿åé¢æ°  */
+
+extern void net_syslog(uint_t prio, const char *format, ...) throw();
+extern ER_UINT	net_serial_rea_dat(ID portid, char *buf, uint_t len) throw();
+extern ER	net_serial_ctl_por(ID portid, uint_t ioctl) throw();
+
+/*  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°  */
+
+extern ER	callback_nblk_tcp(ID cepid, FN fncd, void *p_parblk);
+
+#endif /* _MACRO_ONLY */
+
+#endif	/* of #ifndef _SAMPLE1N_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h	(revision 317)
@@ -0,0 +1,668 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_APP_CONFIG_H_
+#define _TINET_APP_CONFIG_H_
+
+/*
+ *  ã¤ã³ã¿ã¼ããããã­ãã³ã«ãã¡ããªã¼ã®ãµãã¼ã
+ *
+ *    Makefile ã§æå®ãã¦ãè¯ã
+ */
+
+/*#define SUPPORT_INET4		TCP/IP,IPv4		*/
+/*#define SUPPORT_INET6		TCP/IP,IPv6		*/
+/*#define SUPPORT_TCP		TCP			*/
+/*#define SUPPORT_UDP		UDP			*/
+
+/*ãã¼ã¿ãªã³ã¯å±¤ã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãé¸æãã	*/
+/*ããããä¸ã¤ã ãé¸æã§ããã				*/
+
+/*#define SUPPORT_PPP		PointtoPointProtocol	*/
+/*#define SUPPORT_LOOP		LocalLoopBack		*/
+/*#define SUPPORT_ETHER		Ethernet		*/
+
+/*#define SUPPORT_MIB		MIB(SNMP)		*/
+
+/*
+ *  TCP/IP ã«é¢ããå®ç¾©
+ */
+
+/* TCP ã«é¢ããå®ç¾© */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+ *    æ³¨æ: Makefile ã§æå®ãã¦ããã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_RWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
+ *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ã
+ *  ãã ããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
+ *  ã¾ããæå®ããªãã¨å¶éããªãã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_MAX_QUEUES	2*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã§ã
+ *  éä¿¡ã¦ã£ã³ããããã¡ã«ä½¿ç¨ãããããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef SUPPORT_INET6
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IPV6_MMTU)	/* æå¤§ãµã¤ãº */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IP4_MSS)		/* æå¤§ãµã¤ãº */
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	IF_PDU_SIZE			/* æå¤§ãµã¤ãº */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MIN_SIZE	0				/* æå°ãµã¤ãº */
+
+/*
+ *  TCP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_TCP_CFG_NON_BLOCKING
+#undef TCP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
+ *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef MAX_TCP_SND_SEG
+#undef MAX_TCP_SND_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define MAX_TCP_SND_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define MAX_TCP_SND_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef DEF_TCP_RCV_SEG
+#undef DEF_TCP_RCV_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define DEF_TCP_RCV_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define DEF_TCP_RCV_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹åé¢æ©è½
+ *
+ *  Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ã®ã¨ã³ããªæ°ãæå®ããã
+ *  æå®ããªããã0 ãæå®ããã¨ã
+ *  ã¿ã¹ã¯ãã Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ãåé¢ããæ©è½ã¯çµè¾¼ã¾ãªãã
+ */
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_TCP_TW_CEP_ENTRY		3
+#else
+#define NUM_TCP_TW_CEP_ENTRY		6
+#endif
+
+/*
+ *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½
+ */
+//#define TCP_CFG_TRACE
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã® IPv4 ã¢ãã¬ã¹
+ *  IPV4_ADDRANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¹ããå¯¾è±¡ã¨ããã
+ */
+#define TCP_CFG_TRACE_IPV4_RADDR	IPV4_ADDRANY
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_RPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_RPORTNO		UINT_C(7)
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ã­ã¼ã«ã«ãã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_LPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_LPORTNO		UINT_C(7)
+
+/*
+ *  ITRON TCP/IP APIãTCP ã®æ¡å¼µæ©è½
+ */
+//#define TCP_CFG_EXTENTIONS
+
+/*
+ *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
+ *
+ *    -1: BSD ã®å®è£
+ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
+ *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
+ */
+
+//#define TCP_CFG_URG_OFFSET	-1
+//#define TCP_CFG_URG_OFFSET	0
+
+/* UDP ã«é¢ããå®ç¾© */
+
+/*
+ *  UDP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_UDP_CFG_NON_BLOCKING
+#undef UDP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  ITRON TCP/IP APIãUDP ã®æ¡å¼µæ©è½
+ */
+//#define UDP_CFG_EXTENTIONS
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#if 1
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,1,21)
+#else
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#if 1
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(192,168,1,31)
+#else
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+#ifdef DHCP4_CLI_CFG
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(0,0,0,0)
+
+#else	/* of #ifdef DHCP4_CLI_CFG */
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(172,25,129,200)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(255,255,255,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(172,25,129,140)
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	3
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+/*
+ *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ã¤ã¼ãµãããã«é¢ããå®ç¾©
+ */
+
+/*
+ *  PPP ã«é¢ããå®ç¾©
+ */
+
+#define HDLC_PORTID			1	/* HDLC(PPP)ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·	*/
+
+/*#define PPP_IDLE_TIMEOUT		(180*NET_TIMER_HZ)*/
+					/* åæ­ã¾ã§ã®ã¢ã¤ãã«æéã		*/
+					/* åæ­ããªãå ´åã¯ã³ã¡ã³ãã¢ã¦ãããã	*/
+
+/*#define PPP_CFG_MODEM			 ã¢ãã æ¥ç¶ã®å ´åã¯ã³ã¡ã³ããå¤ãã	*/
+
+#define MODEM_CFG_INIT			"ATE1&D0&S0\\V0\\Q1S0=1"
+					/* ã¢ãã åæåæå­å			*/
+					/* NTT DoComo ã¢ãã¤ã«ã¢ããã¿ 96F ç¨	*/
+					/*   E1: ã¨ã³ã¼ããã¯ãã			*/
+					/*  &D0: ERä¿¡å·ç¡è¦			*/
+					/*  &S0: DRä¿¡å·å¸¸æ ON			*/
+					/*  \V0: ãªã¶ã«ãã³ã¼ã TYPE 1		*/
+					/*  \Q1: XON/XOFF ãã­ã¼å¶å¾¡		*/
+					/* S0=1: èªåçä¿¡ãªã³ã°åæ° = 1 å	*/
+
+#define MODEM_CFG_PHONE_NUMBER		"090-xxxx-9242"
+
+					/* èªæ§ææ
+å ±ã®è¦å®å¤			*/
+#define DEF_LCP_LOCAL_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+					/* ç¸æã«è¨±ãæ§ææ
+å ±ã®è¦å®å¤		*/
+#define DEF_LCP_REMOTE_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+/*
+ *  èªè¨¼ã«é¢ããå®ç¾©
+ */
+
+#define AUTH_CFG_CLIENT		   	/* èªè¨¼ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã	*/
+#define AUTH_CFG_SERVER			/* èªè¨¼ãµã¼ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã		*/
+
+#define AUTH_LOCAL_USER			"h8"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å	*/
+#define AUTH_LOCAL_PASSWD		"3048f"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã	*/
+#define AUTH_REMOTE_USER		"pen3"		/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å		*/
+#define AUTH_REMOTE_PASSWD		"600MHz"	/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã		*/
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+/*#define ARP_CFG_CALLBACK_DUPLICATED*/	/* IP ã¢ãã¬ã¹éè¤æ¤åºã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã		*/
+
+/*
+ *  ICMPv4/v6 ã«é¢ããå®ç¾©
+ */
+
+#ifdef USE_PING
+
+#define ICMP_CFG_CALLBACK_ECHO_REPLY	/* ICMP ECHO å¿ç­ãåä¿¡ããã¨ãå¼åºãã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã			*/
+
+#endif	/* of #ifdef USE_PING */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
+ */
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
+ */
+
+/*
+ *  64 ãªã¯ããã
+ *
+ *    IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    IPv6 ã§ã¯ãTCP å¶å¾¡ã»ã°ã¡ã³ãï¼CSEGãSDU ãªãï¼ãµã¤ãºã®
+ *    ãããã¯ã¼ã¯ãããã¡ï¼IF + IPv6 + TCP = 74ï¼ä»¥ä¸ã®
+ *    ãããã¯ã¼ã¯ãããã¡ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_64
+#undef NUM_MPF_NET_BUF_64
+#endif
+
+#ifdef SUPPORT_INET4
+#define NUM_MPF_NET_BUF_64		2
+#else
+#define NUM_MPF_NET_BUF_64		0
+#endif
+
+/*
+ *  CSEGï¼IF + IP + TCPï¼
+ *
+ *    IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *
+ *    NE2000 äºæ NIC ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_edï¼ã®æä½å²å½ã¦é·ã¯ã
+ *    ã¤ã¼ãµããããã¬ã¼ã ã®æç­é·ã§ãã 60ï¼CRC ã® 4 ãªã¯ããããé¤ãã
+ *    æ´ã«ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã§ããã
+ *    å¾ã£ã¦ãIPv4 ã§ã¯ãCSEG ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ *   ï¼IF + IPv4 + TCP = 54ï¼ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_CSEG
+#undef NUM_MPF_NET_BUF_CSEG
+#endif
+
+#ifdef SUPPORT_INET6
+#define NUM_MPF_NET_BUF_CSEG		2
+#else
+#define NUM_MPF_NET_BUF_CSEG		0
+#endif
+
+/*
+ *  128 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    128 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_128
+#undef NUM_MPF_NET_BUF_128
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_128		0
+#else
+#define NUM_MPF_NET_BUF_128		1
+#endif
+
+/*
+ *  256 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    256 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_256
+#undef NUM_MPF_NET_BUF_256
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_256		0
+#else
+#define NUM_MPF_NET_BUF_256		1
+#endif
+
+/*
+ *  512 ãªã¯ããã	
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    512 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_512
+#undef NUM_MPF_NET_BUF_512
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_512		0
+#else
+#define NUM_MPF_NET_BUF_512		1
+#endif
+
+/*
+ *  TCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼
+ *
+ *   ã»IPv4 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IP_MSS
+#undef NUM_MPF_NET_BUF_IP_MSS
+#endif
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG)
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IP_MSS		3
+#else
+#define NUM_MPF_NET_BUF_IP_MSS		2	/* IF + 576 ãªã¯ããã	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+#define NUM_MPF_NET_BUF_IP_MSS		0	/* IF + 576 ãªã¯ããã	*/
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+/*
+ *  1024 ãªã¯ããã	
+ *
+ *    TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    1024 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_1024
+#undef NUM_MPF_NET_BUF_1024
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_1024		0	/* 1024 ãªã¯ããã	*/
+#else
+#define NUM_MPF_NET_BUF_1024		1	/* 1024 ãªã¯ããã	*/
+#endif
+
+/*
+ *  TCP MSSï¼IPV6 MMTUãIF + 1280 ãªã¯ãããï¼
+ *
+ *   ã»IPv6 ã§ã®ã¿å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IPV6_MMTU
+#undef NUM_MPF_NET_BUF_IPV6_MMTU
+#endif
+
+#if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU))
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IPV6_MMTU	3	/* IF + 1280	*/
+#else
+#define NUM_MPF_NET_BUF_IPV6_MMTU	2	/* IF + 1280	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+/*
+ *  IF æå¤§ PDU ãµã¤ãº
+ *
+ *   ã»TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *     IF æå¤§ PDU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IF_PDU
+#undef NUM_MPF_NET_BUF_IF_PDU
+#endif
+
+#ifdef USE_TCP_MSS_SEG
+
+#define NUM_MPF_NET_BUF_IF_PDU		0
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#if (defined(TCP_CFG_RWBUF_CSAVE) || defined(TCP_CFG_SWBUF_CSAVE)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IF_PDU		9
+#else
+#define NUM_MPF_NET_BUF_IF_PDU		8
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  65536 ãªã¯ããã
+ *
+ *  ã»NET_BUF_CFG_LONG_LEN ãå®ç¾©ããã¨ãã®ã¿å²ãå½ã¦ãã
+ */
+
+#ifdef NET_BUF_CFG_LONG_LEN
+
+/* IPv6 ç¨ */
+
+#ifdef NUM_MPF_NET_BUF6_65536
+#undef NUM_MPF_NET_BUF6_65536
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF6_65536	0
+#else
+#define NUM_MPF_NET_BUF6_65536	2
+#endif
+
+#else	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#define NUM_MPF_NET_BUF6_65536	0
+
+#endif	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  DNS ãµã¼ãã«é¢ããå®ç¾©
+ */
+
+/* DNS ãµã¼ãã® IP ã¢ãã¬ã¹ */
+
+#if !defined(DHCP6_CLI_CFG)
+
+#define IPV6_ADDR_DNS_INIT	\
+	{{{ UINT_C(0xfd), UINT_C(0x90), UINT_C(0xcc), UINT_C(0xe5), \
+	    UINT_C(0x25), UINT_C(0xf6), UINT_C(0xff), UINT_C(0x81), \
+	    UINT_C(0x02), UINT_C(0xa0), UINT_C(0x24), UINT_C(0xff), \
+	    UINT_C(0xfe), UINT_C(0x56), UINT_C(0xc5), UINT_C(0xd6) }}}
+
+#endif	/* of #if !defined(DHCP6_CLI_CFG) */
+
+#if !defined(DHCP4_CLI_CFG)
+#define IPV4_ADDR_DNS		MAKE_IPV4_ADDR(172,25,129,140)
+#endif
+
+/* DOMAIN å */
+
+#if !(defined(DHCP4_CLI_CFG) || defined(DHCP6_CLI_CFG))
+#define RSLV_CFG_DNS_DOMAIN_NAME_STR	"jo.tomakomai-ct.ac.jp"
+#endif
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã«é¢ããå®ç¾©
+ */
+
+/* DHCPv6 ã®åä½ã¢ã¼ãã®è¨­å® */
+
+#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATELESS
+//#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_STATEFULL
+
+#endif /* _TINET_APP_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h.minsv
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h.minsv	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_app_config.h.minsv	(revision 317)
@@ -0,0 +1,651 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id: tinet_app_config.h.minsv,v 1.6 2012/07/18 04:08:37 abe Exp abe $
+ */
+
+#ifndef _TINET_APP_CONFIG_H_
+#define _TINET_APP_CONFIG_H_
+
+/*
+ *  ã¤ã³ã¿ã¼ããããã­ãã³ã«ãã¡ããªã¼ã®ãµãã¼ã
+ *
+ *    Makefile ã§æå®ãã¦ãè¯ã
+ */
+
+/*#define SUPPORT_INET4		TCP/IP,IPv4		*/
+/*#define SUPPORT_INET6		TCP/IP,IPv6		*/
+/*#define SUPPORT_TCP		TCP			*/
+/*#define SUPPORT_UDP		UDP			*/
+
+/*ãã¼ã¿ãªã³ã¯å±¤ã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãé¸æãã	*/
+/*ããããä¸ã¤ã ãé¸æã§ããã				*/
+
+/*#define SUPPORT_PPP		PointtoPointProtocol	*/
+/*#define SUPPORT_LOOP		LocalLoopBack		*/
+/*#define SUPPORT_ETHER		Ethernet		*/
+
+/*#define SUPPORT_MIB		MIB(SNMP)		*/
+
+/*
+ *  TCP/IP ã«é¢ããå®ç¾©
+ */
+
+/* TCP ã«é¢ããå®ç¾© */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+ *    æ³¨æ: Makefile ã§æå®ãã¦ããã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_RWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE_ONLY*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿æå¹ã«ããã	*/
+/*#define TCP_CFG_SWBUF_CSAVE*/
+			/* TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããã	*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
+ *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ã
+ *  ãã ããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
+ *  ã¾ããæå®ããªãã¨å¶éããªãã
+ */
+/*#define TCP_CFG_RWBUF_CSAVE_MAX_QUEUES	2*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã§ã
+ *  éä¿¡ã¦ã£ã³ããããã¡ã«ä½¿ç¨ãããããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef SUPPORT_INET6
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IPV6_MMTU)	/* æå¤§ãµã¤ãº */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	(IF_HDR_SIZE + IP4_MSS)		/* æå¤§ãµã¤ãº */
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MAX_SIZE	IF_PDU_SIZE			/* æå¤§ãµã¤ãº */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+#define TCP_CFG_SWBUF_CSAVE_MIN_SIZE	0				/* æå°ãµã¤ãº */
+
+/*
+ *  TCP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_TCP_CFG_NON_BLOCKING
+#undef TCP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  MAX_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    ç¸æãã MSS ãªãã·ã§ã³ã§ã»ã°ã¡ã³ããµã¤ãºãæå®ããã¦ãã
+ *    ãã®å¤ã§ãã»ã°ã¡ã³ããµã¤ãºãå¶éã§ããã
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef MAX_TCP_SND_SEG
+#undef MAX_TCP_SND_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define MAX_TCP_SND_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define MAX_TCP_SND_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  DEF_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifdef USE_TCP_MSS_SEG
+
+#ifdef DEF_TCP_RCV_SEG
+#undef DEF_TCP_RCV_SEG
+#endif
+
+#ifdef SUPPORT_INET6
+
+#define DEF_TCP_RCV_SEG			TCP6_MSS
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+#define DEF_TCP_RCV_SEG			TCP_MSS
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹åé¢æ©è½
+ *
+ *  Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ã®ã¨ã³ããªæ°ãæå®ããã
+ *  æå®ããªããã0 ãæå®ããã¨ã
+ *  ã¿ã¹ã¯ãã Time Wait ç¶æ
+ã® TCP éä¿¡ç«¯ç¹ãåé¢ããæ©è½ã¯çµè¾¼ã¾ãªãã
+ */
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_TCP_TW_CEP_ENTRY		3
+#else
+#define NUM_TCP_TW_CEP_ENTRY		6
+#endif
+
+/*
+ *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½
+ */
+//#define TCP_CFG_TRACE
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã® IPv4 ã¢ãã¬ã¹
+ *  IPV4_ADDRANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¹ããå¯¾è±¡ã¨ããã
+ */
+#define TCP_CFG_TRACE_IPV4_RADDR	IPV4_ADDRANY
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ãªã¢ã¼ããã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_RPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_RPORTNO		UINT_C(7)
+
+/*
+ *  ãã¬ã¼ã¹åºåå¯¾è±¡ã®ã­ã¼ã«ã«ãã¹ãã®ãã¼ãçªå·
+ *  TCP_PORTANY ãæå®ããã¨ãå
+¨ã¦ã®ãã¼ãçªå·ãå¯¾è±¡ã«ããã
+ */
+#define TCP_CFG_TRACE_LPORTNO		TCP_PORTANY
+//#define TCP_CFG_TRACE_LPORTNO		UINT_C(7)
+
+/*
+ *  ITRON TCP/IP APIãTCP ã®æ¡å¼µæ©è½
+ */
+//#define TCP_CFG_EXTENTIONS
+
+/*
+ *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
+ *
+ *    -1: BSD ã®å®è£
+ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
+ *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
+ */
+
+//#define TCP_CFG_URG_OFFSET	-1
+//#define TCP_CFG_URG_OFFSET	0
+
+/* UDP ã«é¢ããå®ç¾© */
+
+/*
+ *  UDP ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½
+ */
+
+#ifdef UNDEF_UDP_CFG_NON_BLOCKING
+#undef UDP_CFG_NON_BLOCKING
+#endif
+
+/*
+ *  ITRON TCP/IP APIãUDP ã®æ¡å¼µæ©è½
+ */
+//#define UDP_CFG_EXTENTIONS
+
+/* IPv6 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+#define NUM_IN6_STATIC_ROUTE_ENTRY	0
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/* IPv4 ã«é¢ããå®ç¾© */
+
+#ifdef SUPPORT_PPP
+
+#if 1
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(192,168,1,21)
+#else
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#if 1
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(192,168,1,31)
+#else
+#define IPV4_ADDR_REMOTE		MAKE_IPV4_ADDR(0,0,0,0)		/* ç¸æã«å²ãå½ã¦ã¦ãããå ´å	*/
+#endif
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+#ifdef DHCP4_CLI_CFG
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(0,0,0,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(0,0,0,0)
+
+#else	/* of #ifdef DHCP4_CLI_CFG */
+
+#define IPV4_ADDR_LOCAL			MAKE_IPV4_ADDR(172,25,129,200)
+#define IPV4_ADDR_LOCAL_MASK		MAKE_IPV4_ADDR(255,255,255,0)
+#define IPV4_ADDR_DEFAULT_GW		MAKE_IPV4_ADDR(172,25,129,140)
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	3
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_LOOP
+
+#define NUM_IN4_STATIC_ROUTE_ENTRY	1
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+/*
+ *  ãã¼ã¿ãªã³ã¯å±¤ (ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹) ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  ã¤ã¼ãµãããã«é¢ããå®ç¾©
+ */
+
+/*
+ *  PPP ã«é¢ããå®ç¾©
+ */
+
+#define HDLC_PORTID			1	/* HDLC(PPP)ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·	*/
+
+/*#define PPP_IDLE_TIMEOUT		(180*NET_TIMER_HZ)*/
+					/* åæ­ã¾ã§ã®ã¢ã¤ãã«æéã		*/
+					/* åæ­ããªãå ´åã¯ã³ã¡ã³ãã¢ã¦ãããã	*/
+
+/*#define PPP_CFG_MODEM			 ã¢ãã æ¥ç¶ã®å ´åã¯ã³ã¡ã³ããå¤ãã	*/
+
+#define MODEM_CFG_INIT			"ATE1&D0&S0\\V0\\Q1S0=1"
+					/* ã¢ãã åæåæå­å			*/
+					/* NTT DoComo ã¢ãã¤ã«ã¢ããã¿ 96F ç¨	*/
+					/*   E1: ã¨ã³ã¼ããã¯ãã			*/
+					/*  &D0: ERä¿¡å·ç¡è¦			*/
+					/*  &S0: DRä¿¡å·å¸¸æ ON			*/
+					/*  \V0: ãªã¶ã«ãã³ã¼ã TYPE 1		*/
+					/*  \Q1: XON/XOFF ãã­ã¼å¶å¾¡		*/
+					/* S0=1: èªåçä¿¡ãªã³ã°åæ° = 1 å	*/
+
+#define MODEM_CFG_PHONE_NUMBER		"090-xxxx-9242"
+
+					/* èªæ§ææ
+å ±ã®è¦å®å¤			*/
+#define DEF_LCP_LOCAL_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+					/* ç¸æã«è¨±ãæ§ææ
+å ±ã®è¦å®å¤		*/
+#define DEF_LCP_REMOTE_CFGS		(LCP_CFG_MRU|LCP_CFG_ACCM|LCP_CFG_MAGIC|\
+					 LCP_CFG_ACCOMP|LCP_CFG_PCOMP|LCP_CFG_PAP)
+
+/*
+ *  èªè¨¼ã«é¢ããå®ç¾©
+ */
+
+#define AUTH_CFG_CLIENT		   	/* èªè¨¼ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã	*/
+#define AUTH_CFG_SERVER			/* èªè¨¼ãµã¼ãã¢ã¼ãã®æã¯ã³ã¡ã³ããå¤ãã		*/
+
+#define AUTH_LOCAL_USER			"h8"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å	*/
+#define AUTH_LOCAL_PASSWD		"3048f"		/* èªãã¹ãã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã	*/
+#define AUTH_REMOTE_USER		"pen3"		/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ã¦ã¼ã¶å		*/
+#define AUTH_REMOTE_PASSWD		"600MHz"	/* ç¸æã¸ã®ã­ã°ã¤ã³èªè¨¼ãã¹ã¯ã¼ã		*/
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+/*#define ARP_CFG_CALLBACK_DUPLICATED*/	/* IP ã¢ãã¬ã¹éè¤æ¤åºã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã		*/
+
+/*
+ *  ICMPv4/v6 ã«é¢ããå®ç¾©
+ */
+
+#ifdef USE_PING
+
+#define ICMP_CFG_CALLBACK_ECHO_REPLY	/* ICMP ECHO å¿ç­ãåä¿¡ããã¨ãå¼åºãã³ã¼ã«ããã¯é¢æ°ã	*/
+					/* å®ç¾©ããå ´åã¯ã³ã¡ã³ããå¤ãã			*/
+
+#endif	/* of #ifdef USE_PING */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã«é¢ããå®ç¾©
+ */
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ã¤ã¼ãµãããã®å ´åã®ãããã¯ã¼ã¯ãããã¡æ°ã®å²ãå½ã¦
+ */
+
+/*
+ *  64 ãªã¯ããã
+ *
+ *    IPv4 ã®ã¿ãçµè¾¼ãæã«å²ãå½ã¦ãã
+ *
+ *    IPv6 ã§ã¯ãTCP å¶å¾¡ã»ã°ã¡ã³ãï¼CSEGãSDU ãªãï¼ãµã¤ãºã®
+ *    ãããã¯ã¼ã¯ãããã¡ï¼IF + IPv6 + TCP = 74ï¼ä»¥ä¸ã®
+ *    ãããã¯ã¼ã¯ãããã¡ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_64
+#undef NUM_MPF_NET_BUF_64
+#endif
+
+#if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+#define NUM_MPF_NET_BUF_64		2
+#else
+#define NUM_MPF_NET_BUF_64		0
+#endif
+
+/*
+ *  CSEGï¼IF + IP + TCPï¼
+ *
+ *    IPv6 ã®ã¿ãçµè¾¼ãæã«å²ãå½ã¦ãã
+ *
+ *    NE2000 äºæ NIC ã®ãã£ãã¤ã¹ãã©ã¤ãï¼if_edï¼ã®æä½å²å½ã¦é·ã¯ã
+ *    ã¤ã¼ãµããããã¬ã¼ã ã®æç­é·ã§ãã 60ï¼CRC ã® 4 ãªã¯ããããé¤ãã
+ *    æ´ã«ã¢ã©ã¤ã³ãã¦ 62ï¼ãªã¯ãããã§ããã
+ *    å¾ã£ã¦ãIPv4 ã§ã¯ãCSEG ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ *   ï¼IF + IPv4 + TCP = 54ï¼ã¯ä¸è¦ã§ããã
+ */
+
+#ifdef NUM_MPF_NET_BUF_CSEG
+#undef NUM_MPF_NET_BUF_CSEG
+#endif
+
+#if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4)
+#define NUM_MPF_NET_BUF_CSEG		2
+#else
+#define NUM_MPF_NET_BUF_CSEG		0
+#endif
+
+/*
+ *  128 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    128 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_128
+#undef NUM_MPF_NET_BUF_128
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_128		0
+#else
+#define NUM_MPF_NET_BUF_128		1
+#endif
+
+/*
+ *  256 ãªã¯ããã
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    256 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_256
+#undef NUM_MPF_NET_BUF_256
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_256		0
+#else
+#define NUM_MPF_NET_BUF_256		1
+#endif
+
+/*
+ *  512 ãªã¯ããã	
+ *
+ *    IPv4 ã§ãTCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼ã®
+ *    ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    512 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_512
+#undef NUM_MPF_NET_BUF_512
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_512		0
+#else
+#define NUM_MPF_NET_BUF_512		1
+#endif
+
+/*
+ *  TCP MSSï¼IP MSSãIF + 576 ãªã¯ãããï¼
+ *
+ *   ã»IPv4 ã®ã¿ãçµè¾¼ãæã«å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IP_MSS
+#undef NUM_MPF_NET_BUF_IP_MSS
+#endif
+
+#if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG)
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IP_MSS		4
+#else
+#define NUM_MPF_NET_BUF_IP_MSS		3	/* IF + 576 ãªã¯ããã	*/
+#endif
+
+#else	/* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+#define NUM_MPF_NET_BUF_IP_MSS		0	/* IF + 576 ãªã¯ããã	*/
+
+#endif	/* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP_MSS_SEG) */
+
+/*
+ *  1024 ãªã¯ããã	
+ *
+ *    TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *    1024 ãªã¯ãããã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_1024
+#undef NUM_MPF_NET_BUF_1024
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF_1024		0	/* 1024 ãªã¯ããã	*/
+#else
+#define NUM_MPF_NET_BUF_1024		1	/* 1024 ãªã¯ããã	*/
+#endif
+
+/*
+ *  TCP MSSï¼IPV6 MMTUãIF + 1280 ãªã¯ãããï¼
+ *
+ *   ã»IPv6 ãçµè¾¼ãæã«å²ãå½ã¦ãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IPV6_MMTU
+#undef NUM_MPF_NET_BUF_IPV6_MMTU
+#endif
+
+#if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU))
+
+#if (defined(TCP_CFG_RWBUF_CSAVE)      || defined(TCP_CFG_SWBUF_CSAVE) ||	\
+     defined(TCP_CFG_RWBUF_CSAVE_ONLY) || defined(TCP_CFG_SWBUF_CSAVE_ONLY)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IPV6_MMTU	3	/* IF + 1280	*/
+#else
+#define NUM_MPF_NET_BUF_IPV6_MMTU	2	/* IF + 1280	*/
+#endif
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+#define NUM_MPF_NET_BUF_IPV6_MMTU	0	/* IF + 1280	*/
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)) */
+
+/*
+ *  IF æå¤§ PDU ãµã¤ãº
+ *
+ *   ã»TCP MSS ã®ãããã¯ã¼ã¯ãããã¡ãå²ãå½ã¦ãå ´åã
+ *     IF æå¤§ PDU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã¯å²ãå½ã¦ãªãã
+ *   ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã§ã
+ *     çã³ãã¼ API ãä½¿ç¨ããã¨ãã¯ã+1 å²ãå½ã¦ãã
+ */
+
+#ifdef NUM_MPF_NET_BUF_IF_PDU
+#undef NUM_MPF_NET_BUF_IF_PDU
+#endif
+
+#ifdef USE_TCP_MSS_SEG
+
+#define NUM_MPF_NET_BUF_IF_PDU		0
+
+#else	/* of #ifdef USE_TCP_MSS_SEG */
+
+#if (defined(TCP_CFG_RWBUF_CSAVE) || defined(TCP_CFG_SWBUF_CSAVE)) && defined(USE_COPYSAVE_API)
+#define NUM_MPF_NET_BUF_IF_PDU		6
+#else
+#define NUM_MPF_NET_BUF_IF_PDU		5
+#endif
+
+#endif	/* of #ifdef USE_TCP_MSS_SEG */
+
+/*
+ *  65536 ãªã¯ããã
+ *
+ *  ã»NET_BUF_CFG_LONG_LEN ãå®ç¾©ããã¨ãã®ã¿å²ãå½ã¦ãã
+ */
+
+#ifdef NET_BUF_CFG_LONG_LEN
+
+/* IPv6 ç¨ */
+
+#ifdef NUM_MPF_NET_BUF6_65536
+#undef NUM_MPF_NET_BUF6_65536
+#endif
+
+#if defined(USE_TCP_MSS_SEG)
+#define NUM_MPF_NET_BUF6_65536	0
+#else
+#define NUM_MPF_NET_BUF6_65536	2
+#endif
+
+#else	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#define NUM_MPF_NET_BUF6_65536	0
+
+#endif	/* of ifdef NET_BUF_CFG_LONG_LEN */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  TINET å
+é¨ã®ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãºã®è¨­å®
+ */
+
+#undef  TCP_OUT_TASK_STACK_SIZE
+#define	TCP_OUT_TASK_STACK_SIZE	768	/* TCP åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+#undef  ETHER_INPUT_STACK_SIZE
+#define	ETHER_INPUT_STACK_SIZE	768	/* Ethernet å
+¥åã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#undef  ETHER_OUTPUT_STACK_SIZE
+#define	ETHER_OUTPUT_STACK_SIZE	768	/* Ethernet åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#undef  NET_TIMER_STACK_SIZE
+#define	NET_TIMER_STACK_SIZE	768	/* ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+#endif /* _TINET_APP_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos4.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos4.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos4.cfg	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "echos4.h"
+
+/* TCP åä»å£ */
+
+TCP_CRE_REP (TCP_ECHO_SRV_REPID,	{ 0, { IPV4_ADDRANY, 7 } } );
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID, {
+	0,
+	tcp_echo_srv_swbuf,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID, {
+	0,
+	tcp_echo_srv_swbuf,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos6.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos6.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_echos6.cfg	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "echos6.h"
+
+/* TCP åä»å£ */
+
+TCP6_CRE_REP (TCP_ECHO_SRV_REPID,	{ 0, { IPV6_ADDRANY, 7 } } );
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID, {
+	0,
+	tcp_echo_srv_swbuf,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID, {
+	0,
+	tcp_echo_srv_swbuf,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_minsv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_minsv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_minsv.cfg	(revision 317)
@@ -0,0 +1,56 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+  *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  æå°æ§æãµã¼ãè©¦é¨ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "@(TINETDIR)/netapp/wwws.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv1.h"
+
+#include "minsv.h"
+
+INCLUDE("@(TINETDIR)/netapp/tinet_wwws.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp64_echo_srv1.cfg");
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_nserv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_nserv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_nserv.cfg	(revision 317)
@@ -0,0 +1,85 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã¼ãè©¦é¨ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+#include "@(TINETDIR)/netapp/wwws.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv1.h"
+#include "@(TINETDIR)/netapp/tcp_echo_srv2.h"
+#include "@(TINETDIR)/netapp/tcp_echo_cli.h"
+#include "@(TINETDIR)/netapp/tcp_discard_srv.h"
+#include "@(TINETDIR)/netapp/tcp_discard_cli.h"
+#include "@(TINETDIR)/netapp/udp6_echo_srv.h"
+#include "@(TINETDIR)/netapp/udp4_echo_srv.h"
+#include "@(TINETDIR)/netapp/udp6_echo_cli.h"
+#include "@(TINETDIR)/netapp/udp4_echo_cli.h"
+#include "@(TINETDIR)/netapp/net_cons.h"
+#include "@(TINETDIR)/netapp/dhcp6_cli.h"
+#include "@(TINETDIR)/netapp/dhcp4_cli.h"
+
+#include "nserv.h"
+
+INCLUDE("@(TINETDIR)/netapp/tinet_wwws.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp64_echo_srv1.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp64_echo_srv1_nblk.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp6_echo_srv1.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp6_echo_srv1_nblk.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp4_echo_srv1.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp4_echo_srv1_nblk.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp_echo_srv2.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp_discard_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_tcp_discard_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_udp6_echo_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_udp4_echo_srv.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_udp6_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_udp4_echo_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_udp_discard_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_dbg_cons.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_net_cons.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_resolver.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_dhcp6_cli.cfg");
+INCLUDE("@(TINETDIR)/netapp/tinet_dhcp4_cli.cfg");
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_sample1n.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_sample1n.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_sample1n.cfg	(revision 317)
@@ -0,0 +1,96 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯å¯¾å¿ sample1.c ãã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "sample1n.h"
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (TCP_REPID, { 0, { IPV6_ADDRANY, 23 } } );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_REP (TCP_REPID,	 { 0, { IPV4_ADDRANY, 23 } } );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_CEP (TCP_CEPID, {
+	0,
+	tcp_swbuf,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_CEP (TCP_CEPID, {
+	0,
+	tcp_swbuf,
+	TCP_SWBUF_SIZE,
+	tcp_rwbuf,
+	TCP_RWBUF_SIZE,
+	(FP)callback_nblk_tcp
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv4.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv4.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv4.cfg	(revision 317)
@@ -0,0 +1,59 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ããã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "usrv4.h"
+
+/*
+ *  UDP éä¿¡ç«¯ç¹
+ */
+
+UDP_CRE_CEP(USRV_CEPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 7 },
+	NULL });
Index: asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv6.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv6.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/tinet_usrv6.cfg	(revision 317)
@@ -0,0 +1,59 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ããã­ã°ã©ã ã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "usrv6.h"
+
+/*
+ *  UDP éä¿¡ç«¯ç¹
+ */
+
+UDP6_CRE_CEP(USRV_CEPID, {
+	TA_NULL,
+	{ IPV6_ADDRANY, 7 },
+	NULL });
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.c	(revision 317)
@@ -0,0 +1,107 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ */
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include "usrv4.h"
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+usrv_task(intptr_t exinf)
+{
+	static uint8_t buffer[BUF_SIZE];
+
+	T_IPV4EP	dst;
+	T_IN4_ADDR	addr;
+	ER_UINT		len;
+	ID		tskid;
+
+	get_tid(&tskid);
+	addr = IPV4_ADDR_LOCAL;
+	syslog(LOG_NOTICE, "[UDP ECHO SRV:%d,%d] started, IP Address: %s.", 
+	                   tskid, (ID)exinf, ip2str(NULL, &addr));
+	while (true) {
+		if ((len = udp_rcv_dat((ID)exinf, &dst, buffer, sizeof(buffer), 20 * 1000)) >= 0) {
+			buffer[len] = '\0';
+			syslog(LOG_NOTICE, "[UDP ECHO SRV] recv, addr: %s:%d, len: %d, msg: '%s'",
+			                   ip2str(NULL, &dst.ipaddr), dst.portno, len, buffer);
+			if ((int)len > 0) {
+				if ((len = udp_snd_dat((ID)exinf, &dst, buffer, len, TMO_FEVR)) < 0)
+					syslog(LOG_NOTICE, "[UDP ECHO SRV] send, error: %s", itron_strerror(len));
+				}
+			}
+		else
+			syslog(LOG_NOTICE, "[UDP ECHO SRV] recv, error: %s", itron_strerror(len));
+		}
+	}
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.cfg	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "usrv4.h"
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+CRE_TSK(USRV_TASK, {
+	TA_HLNG | TA_ACT,
+	USRV_CEPID,
+	usrv_task,
+	USRV_MAIN_PRIORITY,
+	USRV_STACK_SIZE,
+	NULL
+	});
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv4.h	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _USRV_H_
+#define _USRV_H_
+
+#include <tinet_defs.h>
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ */
+
+#define USRV_STACK_SIZE		1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#define USRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	usrv_task(intptr_t exinf);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _USRV_H_ */
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.c	(revision 317)
@@ -0,0 +1,104 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ */
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include "usrv6.h"
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+usrv_task(intptr_t exinf)
+{
+	static uint8_t buffer[BUF_SIZE];
+
+	T_IPV6EP	dst;
+	T_IN6_ADDR	addr;
+	ER_UINT		len;
+	ID		tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		if ((len = udp6_rcv_dat((ID)exinf, &dst, buffer, sizeof(buffer), 20 * 1000)) >= 0) {
+			buffer[len] = '\0';
+			syslog(LOG_NOTICE, "[UDP ECHO SRV] recv, addr: %s:%d,\n"
+			                   "                     len: %d, msg: '%s'",
+			                   ipv62str(NULL, &dst.ipaddr), dst.portno, len, buffer);
+			if ((int)len > 0) {
+				if ((len = udp6_snd_dat((ID)exinf, &dst, buffer, len, TMO_FEVR)) < 0)
+					syslog(LOG_NOTICE, "[UDP ECHO SRV] send, error: %s", itron_strerror(len));
+				}
+			}
+		else
+			syslog(LOG_NOTICE, "[UDP ECHO SRV] recv, error: %s", itron_strerror(len));
+		}
+	}
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.cfg	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+INCLUDE("@(SRCDIR)/syssvc/serial.cfg");
+INCLUDE("@(SRCDIR)/syssvc/logtask.cfg");
+INCLUDE("target_timer.cfg");
+
+INCLUDE("@(TINETDIR)/tinet_asp.cfg");
+
+#include "usrv6.h"
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+CRE_TSK(USRV_TASK, {
+	TA_HLNG | TA_ACT,
+	USRV_CEPID,
+	usrv_task,
+	USRV_MAIN_PRIORITY,
+	USRV_STACK_SIZE,
+	NULL
+	});
Index: asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/asp_sample/usrv6.h	(revision 317)
@@ -0,0 +1,69 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _USRV_H_
+#define _USRV_H_
+
+#include <tinet_defs.h>
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ */
+
+#define USRV_STACK_SIZE		1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#define USRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	usrv_task(intptr_t exinf);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _USRV_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ether_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ether_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ether_var.h	(revision 317)
@@ -0,0 +1,60 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _ETHER_VAR_H_
+#define _ETHER_VAR_H_
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  Ethernet å¦çã¿ã¹ã¯
+ */
+
+extern void ether_input_task(intptr_t exinf);
+extern void ether_output_task(intptr_t exinf);
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _ETHER_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ethernet.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ethernet.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ethernet.c	(revision 317)
@@ -0,0 +1,515 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  Ethernet å¦çã¿ã¹ã¯ã®æ¬ä½
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_llc.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/if_ether.h>
+
+#include <netinet6/if6_ether.h>
+#include <netinet6/nd6.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  å¤æ°
+ */
+
+#if defined(_IP4_CFG)
+
+const uint8_t ether_broad_cast_addr[ETHER_ADDR_LEN] = {
+	UINT_C(0xff), UINT_C(0xff), UINT_C(0xff),
+	UINT_C(0xff), UINT_C(0xff), UINT_C(0xff)
+	};
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+/*
+ *  å¤æ°
+ */
+
+/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ */
+
+static T_IFNET ether_ifnet;
+
+#ifdef SUPPORT_MIB
+
+/*  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB) */
+
+T_IF_STATS if_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#ifdef ETHER_CFG_802_WARNING
+
+/*
+ *  é¢æ°
+ */
+
+static void ieee_802_input (T_NET_BUF *input);
+
+/*
+ *  ieee_802_input -- IEEE 802.3 å
+¥åå¦ç
+ */
+
+static void
+ieee_802_input (T_NET_BUF *input)
+{
+	T_8023MAC_HDR	*mhdr;
+	T_8022SNAP_HDR	*shdr;
+
+	mhdr = GET_8023MAC_HDR(input);
+	shdr = GET_8022SNAP_HDR(input);
+	syslog(LOG_WARNING, "[ETHER] unexp 802.3 from: %s, proto: 0x%04x.",
+	                    mac2str(NULL, mhdr->shost), ntohs(*(uint16_t*)&shdr->type));
+	}
+
+#endif	/* of #ifdef ETHER_CFG_802_WARNING */
+
+/*
+ *  ether_srand -- ä¹±æ°ãåæå¤ãè¿ãã
+ */
+
+uint32_t
+ether_srand (void)
+{
+	T_IF_SOFTC	*ic;
+	uint32_t	rval;
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	rval  = (ic->ifaddr.lladdr[2] << 24)
+	      + (ic->ifaddr.lladdr[3] << 16)
+	      + (ic->ifaddr.lladdr[4] <<  8)
+	      + (ic->ifaddr.lladdr[5]      );
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+
+	rval += (ether_collect_addr.lladdr[2] << 24)
+	      + (ether_collect_addr.lladdr[3] << 16)
+	      + (ether_collect_addr.lladdr[4] <<  8)
+	      + (ether_collect_addr.lladdr[5]      );
+
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+	return rval;
+	}
+
+/*
+ *  ether_get_ifnet -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã
+ */
+
+T_IFNET *
+ether_get_ifnet (void)
+{
+	return &ether_ifnet;
+	}
+
+#if defined(_IP6_CFG)
+
+/*
+ *  ether_in6_resolve_multicast -- ã¤ã¼ãµãããã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã¸ã®å¤æ
+ */
+
+ER
+ether_in6_resolve_multicast (T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr)
+{
+	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ããã§ãã¯ããã*/
+	if (!IN6_IS_ADDR_MULTICAST(maddr))
+		return E_PAR;
+
+	/* ã¤ã¼ãµãããã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã¸ã®å¤æ */
+	ether_map_ipv6_multicast(ifaddr, maddr);
+
+	return E_OK;
+	}
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+/*
+ *  ether_raw_output -- Ethernet ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°ãMAC ã¢ãã¬ã¹è§£æ±ºç¡ã
+ */
+
+ER
+ether_raw_output (T_NET_BUF *output, TMO tmout)
+{
+	ER error = E_OK;
+
+	/* Ethernet åºåã­ã¥ã¼ã«æå
+¥ããã*/
+	if ((error = tsnd_dtq(DTQ_ETHER_OUTPUT, (intptr_t)output, tmout)) != E_OK) {
+		NET_COUNT_ETHER(net_count_ether.out_err_packets, 1);
+		NET_COUNT_MIB(if_stats.ifOutDiscards, 1);
+
+		/* IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ããã§ãã¯ããã*/
+		if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+			syscall(rel_net_buf(output));
+			}
+		else {
+			output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+			}
+		IF_ETHER_NIC_RESET(IF_ETHER_NIC_GET_SOFTC());
+		}
+	return error;
+	}
+
+/*
+ *  ether_output -- Ethernet ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°ãMAC ã¢ãã¬ã¹è§£æ±ºæã
+ */
+
+ER
+ether_output (T_NET_BUF *output, const void *dst, T_IF_ADDR *gw, TMO tmout)
+{
+	T_IF_SOFTC	*ic;
+	ER		error = E_OK;
+
+	/* éä¿¡å
+ MAC ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	memcpy(GET_ETHER_HDR(output)->shost, ic->ifaddr.lladdr, ETHER_ADDR_LEN);
+
+	switch(ntohs(GET_ETHER_HDR(output)->type)) {
+
+#if defined(_IP4_CFG)
+
+	case ETHER_TYPE_IP:		/* IPv4	*/
+		if (arp_resolve(&ic->ifaddr, output, *(uint32_t*)dst)) {	/* true ãªãã¢ãã¬ã¹è§£æ±ºæ¸ */
+			error = ether_raw_output(output, tmout);
+			}
+		break;
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
+
+	case ETHER_TYPE_IPV6:		/* IPv6	*/
+		error = nd6_storelladdr((T_ETHER_ADDR*)GET_ETHER_HDR(output)->dhost,
+		                        (const T_IN6_ADDR*)dst, gw);
+		if (error == E_OK)
+			error = ether_raw_output(output, tmout);
+
+		/* IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ããã§ãã¯ããã*/
+		else if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+			syscall(rel_net_buf(output));
+			}
+		else {
+			output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+			}
+		break;
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+	default:
+		NET_COUNT_MIB(if_stats.ifOutErrors, 1);
+
+		/* IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ããã§ãã¯ããã*/
+		if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+			syscall(rel_net_buf(output));
+			}
+		else {
+			output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+			}
+		error = E_PAR;
+		break;
+		}
+
+	if (error != E_OK)
+		NET_COUNT_ETHER(net_count_ether.out_err_packets, 1);
+	return error;
+	}
+
+/*
+ *  Ethernet åºåã¿ã¹ã¯
+ */
+
+void
+ether_output_task(intptr_t exinf)
+{
+	T_IF_SOFTC	*ic;
+	T_NET_BUF	*output;
+	ID		tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[ETHER OUTPUT:%d] started.", tskid);
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+
+	while (true) {
+		while (rcv_dtq(DTQ_ETHER_OUTPUT, (intptr_t*)&output) == E_OK) {
+			NET_COUNT_ETHER(net_count_ether.out_octets,  output->len);
+			NET_COUNT_MIB(if_stats.ifOutOctets, output->len + 8);
+			NET_COUNT_ETHER(net_count_ether.out_packets, 1);
+
+#ifdef SUPPORT_MIB
+			if ((*(GET_ETHER_HDR(output)->dhost) & ETHER_MCAST_ADDR) == 0) {
+				NET_COUNT_MIB(if_stats.ifOutUcastPkts, 1);
+				}
+			else {
+				NET_COUNT_MIB(if_stats.ifOutNUcastPkts, 1);
+				}
+#endif	/* of #ifdef SUPPORT_MIB */
+
+			syscall(wai_sem(ic->semid_txb_ready));
+
+			IF_ETHER_NIC_START(ic, output);
+
+#ifndef ETHER_NIC_CFG_RELEASE_NET_BUF
+
+			if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+				syscall(rel_net_buf(output));
+				}
+			else {
+				output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+
+#ifdef SUPPORT_TCP
+				sig_sem(SEM_TCP_POST_OUTPUT);
+#endif	/* of #ifdef SUPPORT_TCP */
+				}
+
+#endif	/* of #ifndef ETHER_NIC_CFG_RELEASE_NET_BUF */
+
+			}
+		}
+	}
+
+/*
+ *  Ethernet å
+¥åã¿ã¹ã¯
+ */
+
+void
+ether_input_task(intptr_t exinf)
+{
+	T_IF_SOFTC	*ic;
+	T_NET_BUF	*input;
+	T_ETHER_HDR	*eth;
+	ID		tskid;
+	uint16_t	proto;
+	uint8_t		rcount = 0;
+
+	/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ç®¡çãåæåããã*/
+	ifinit();
+
+	/* ã¤ã¼ãµããããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ç®¡çãåæåããã*/
+
+#if defined(_IP4_CFG)
+
+	ether_ifnet.in4_ifaddr.addr = IPV4_ADDR_LOCAL;		/* IPv4 ã¢ãã¬ã¹		*/
+	ether_ifnet.in4_ifaddr.mask = IPV4_ADDR_LOCAL_MASK;	/* ãµãããããã¹ã¯		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	/* NIC ãåæåããã*/
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	IF_ETHER_NIC_PROBE(ic);
+	IF_ETHER_NIC_INIT(ic);
+
+	/* Ethernet åºåã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(ETHER_OUTPUT_TASK));
+
+	/* ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(NET_TIMER_TASK));
+
+	get_tid(&tskid);
+
+	syslog(LOG_NOTICE, "[ETHER INPUT:%2d] started on MAC Addr: %s.",
+	                   tskid, mac2str(NULL, ic->ifaddr.lladdr));
+
+#if defined(_IP4_CFG)
+
+	/* ARP ãåæåããã*/
+	arp_init();
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	ether_ifnet.ic = ic;
+
+	/* ä¹±æ°çæãåæåããã*/
+	net_srand(0);
+
+	while (true) {
+		syscall(wai_sem(ic->semid_rxb_ready));
+		if ((input = IF_ETHER_NIC_READ(ic)) != NULL) {
+			NET_COUNT_ETHER(net_count_ether.in_octets,  input->len);
+			NET_COUNT_MIB(if_stats.ifInOctets, input->len + 8);
+			NET_COUNT_ETHER(net_count_ether.in_packets, 1);
+			eth = GET_ETHER_HDR(input);
+			proto = ntohs(eth->type);
+
+			/* ä¹±æ°çæãåæåããã*/
+			if (rcount == 0) {
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+				memcpy(ether_collect_addr.lladdr, eth->shost, 
+				sizeof(ether_collect_addr.lladdr));
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+				net_srand(0);
+				}
+			rcount ++;
+
+
+#ifdef SUPPORT_MIB
+			if ((*eth->dhost & ETHER_MCAST_ADDR) == 0) {
+				NET_COUNT_MIB(if_stats.ifInUcastPkts, 1);
+				}
+			else {
+				NET_COUNT_MIB(if_stats.ifInNUcastPkts, 1);
+				}
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL)
+
+			if ((*eth->dhost & ETHER_MCAST_ADDR) && *eth->dhost != 0xff) {
+
+#ifdef ETHER_CFG_MCAST_WARNING
+
+				if (proto <= 1500)
+					proto = ntohs(*(uint16_t*)&(GET_8022SNAP_HDR(input)->type));
+				syslog(LOG_WARNING, "[ETHER] mcast addr  from: %s, to: %s, proto: 0x%04x.",
+				                    mac2str(NULL, eth->shost), mac2str(NULL, eth->dhost), proto);
+
+#endif	/* of #ifdef ETHER_CFG_MCAST_WARNING */
+
+				NET_COUNT_ETHER(net_count_ether.in_err_packets, 1);
+				NET_COUNT_MIB(if_stats.ifInErrors, 1);
+				syscall(rel_net_buf(input));
+				continue;
+				}
+
+#endif	/* of #if defined(_IP4_CFG) && defined(ETHER_CFG_ACCEPT_ALL) */
+
+			switch(proto) {
+
+#if defined(_IP4_CFG)
+
+			case ETHER_TYPE_IP:		/* IP	*/
+				ip_input(input);
+				break;
+
+			case ETHER_TYPE_ARP:		/* ARP	*/
+				arp_input(&ic->ifaddr, input);
+				break;
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
+
+			case ETHER_TYPE_IPV6:		/* IPv6	*/
+				ip6_input(input);
+				break;
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+			default:
+
+#ifdef ETHER_CFG_UNEXP_WARNING
+
+#ifdef ETHER_CFG_802_WARNING
+
+				if (proto <= 1500)
+					ieee_802_input(input);
+				else
+					syslog(LOG_NOTICE, "[ETHER] unexp proto from: %s, proto: 0x%04x.",
+					                   mac2str(NULL, GET_ETHER_HDR(input)->shost), proto);
+
+#else	/* of #ifdef ETHER_CFG_802_WARNING */
+
+				syslog(LOG_INFO, "[ETHER] unexp proto from: %s, proto: 0x%04x.",
+				                   mac2str(NULL, GET_ETHER_HDR(input)->shost), proto);
+
+#endif	/* of #ifdef ETHER_CFG_802_WARNING */
+
+#endif	/* of #ifdef ETHER_CFG_UNEXP_WARNING */
+
+				NET_COUNT_ETHER(net_count_ether.in_err_packets, 1);
+				NET_COUNT_MIB(if_stats.ifUnknownProtos, 1);
+				syscall(rel_net_buf(input));
+				break;
+				}
+			}
+		}
+	}
+
+#endif /* of #ifdef SUPPORT_ETHER */
Index: asp3_gr_sakura/trunk/tinet/net/ethernet.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ethernet.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ethernet.cfg	(revision 317)
@@ -0,0 +1,61 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  Ethernet ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef SUPPORT_ETHER
+
+CRE_TSK(ETHER_OUTPUT_TASK, { TA_HLNG       , 0, ether_output_task, ETHER_OUTPUT_PRIORITY, ETHER_OUTPUT_STACK_SIZE, NULL });
+CRE_TSK(ETHER_INPUT_TASK,  { TA_HLNG|TA_ACT, 0, ether_input_task,  ETHER_INPUT_PRIORITY,  ETHER_INPUT_STACK_SIZE,  NULL });
+
+CRE_DTQ(DTQ_ETHER_OUTPUT,  { TA_TFIFO, NUM_DTQ_ETHER_OUTPUT,  NULL });
+
+/* ãµãã¼ãé¢æ° max2str ç¨ã»ããã© */
+
+CRE_SEM(SEM_MAC2STR_BUFF_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef SUPPORT_ETHER */
Index: asp3_gr_sakura/trunk/tinet/net/ethernet.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ethernet.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ethernet.h	(revision 317)
@@ -0,0 +1,324 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ * Fundamental constants relating to ethernet.
+ *
+ * $FreeBSD: src/sys/net/ethernet.h,v 1.9.2.1 1999/08/29 16:28:13 peter Exp $
+ *
+ */
+
+#ifndef _ETHERNET_H_
+#define _ETHERNET_H_
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  ãã£ã¼ã«ãé·
+ */
+
+#define ETHER_ADDR_LEN		6	/* Ethernet (MAC) Address	*/
+#define ETHER_TYPE_LEN		2	/* Type		*/
+#define ETHER_CRC_LEN		4	/* CRC		*/
+
+/*
+ *  ãã¬ã¼ã é· (Ethernet ãããã¨ CRC ãå«ã)
+ */
+
+#define ETHER_MIN_LEN		64
+#define ETHER_MAX_LEN		(IF_MTU + sizeof(T_ETHER_HDR) + ETHER_CRC_LEN)
+
+/*
+ *  Ethernet ããã
+ */
+
+#ifndef IF_ETHER_NIC_HDR_ALIGN
+#error IF_ETHER_NIC_HDR_ALIGN expected.
+#endif	/* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
+
+#if defined(__RX)
+
+#pragma pack
+typedef struct t_ether_header {
+
+#if IF_ETHER_NIC_HDR_ALIGN != 0
+
+	uint8_t		align[IF_ETHER_NIC_HDR_ALIGN];	/* ã¢ã©ã¤ã³èª¿æ´ */
+
+#endif	/* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
+
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	type;
+	} T_ETHER_HDR;
+#pragma packoption
+
+#elif defined(TOPPERS_S810_CLG3_85)	/* of #if defined(__RX) */
+
+typedef struct t_ether_header {
+
+#if IF_ETHER_NIC_HDR_ALIGN != 0
+
+	uint8_t		align[IF_ETHER_NIC_HDR_ALIGN];	/* ã¢ã©ã¤ã³èª¿æ´ */
+
+#endif	/* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
+
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	type;
+	} T_ETHER_HDR;
+
+#else	/* of #if defined(__RX) */
+
+typedef struct t_ether_header {
+
+#if IF_ETHER_NIC_HDR_ALIGN != 0
+
+	uint8_t		align[IF_ETHER_NIC_HDR_ALIGN];	/* ã¢ã©ã¤ã³èª¿æ´ */
+
+#endif	/* of #if IF_ETHER_NIC_HDR_ALIGN != 0 */
+
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	type;
+	} __attribute__((packed))T_ETHER_HDR;
+
+#endif	/* of #if defined(__RX) */
+
+#define GET_ETHER_HDR(nbuf)		((T_ETHER_HDR*)((nbuf)->buf))
+
+/*
+ *  MAC ã¢ãã¬ã¹ã®å®ç¾©
+ */
+
+#define ETHER_MCAST_ADDR	UINT_C(0x01)	/* ãã«ãã­ã£ã¹ãã»ã¢ãã¬ã¹	*/
+#define ETHER_LOCAL_ADDR	UINT_C(0x02)	/* ã­ã¼ã«ã«ã»ã¢ãã¬ã¹		*/
+
+typedef struct t_ether_addr {
+	uint8_t		lladdr[ETHER_ADDR_LEN];
+	} T_ETHER_ADDR;
+
+/*
+ *  Type ãã£ã¼ã«ã
+ */
+
+#define ETHER_TYPE_IP		UINT_C(0x0800)	/* IPv4	*/
+#define ETHER_TYPE_ARP		UINT_C(0x0806)	/* ARP	*/
+#define ETHER_TYPE_IPV6		UINT_C(0x86dd)	/* IPv6	*/
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãã¯ã­
+ */
+
+#define T_IF_HDR		T_ETHER_HDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ããã				*/
+#define T_IF_ADDR		T_ETHER_ADDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹			*/
+#define IF_HDR_ALIGN		2			/* ãããã®ã¢ã©ã¤ã³åä½				*/
+#define IF_MTU			1500			/* ã¤ã³ã¿ãã§ã¼ã¹ã® MTU				*/
+#define IF_MIN_LEN		ETHER_MIN_LEN		/* ã¤ã³ã¿ã¼ãã§ã¼ã¹ãã¬ã¼ã ã®æç­é·		*/
+
+#define IF_OUTPUT(o,d,g,t)	ether_output(o,d,g,t)	/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°			*/
+#define IF_RAW_OUTPUT(o,t)	ether_raw_output(o,t)	/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°ãã¢ãã¬ã¹è§£æ±ºç¡ã	*/
+#define IF_SET_PROTO(b,p)	(GET_ETHER_HDR(b)->type = htons(p))
+							/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã­ãã³ã«è¨­å®é¢æ°		*/
+#define IF_SOFTC_TO_IFADDR(s)	((T_IF_ADDR*)(s)->ifaddr.lladdr)
+							/* ã½ããã¦ã§ã¢æ
+å ±ãã MAC ã¢ãã¬ã¹ãåãåºã	*/
+#define IF_GET_IFNET()		ether_get_ifnet()	/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã		*/
+#define IF_TYPE			IFT_ETHER		/* ã¤ã³ã¿ãã§ã¼ã¹ã®å				*/
+#define IF_SRAND()		ether_srand()	/* ã¤ã³ã¿ãã§ã¼ã¹ã®ä¹±æ°åæå¤			*/
+
+/* IPv4 é¢ä¿ */
+
+#define IF_PROTO_IP		ETHER_TYPE_IP		/* ã¤ã³ã¿ãã§ã¼ã¹ã® IPv4 ãã­ãã³ã«æå®		*/
+#define IF_PROTO_ARP		ETHER_TYPE_ARP		/* ã¤ã³ã¿ãã§ã¼ã¹ã® ARP ãã­ãã³ã«æå®		*/
+
+/* IPv6 é¢ä¿ */
+
+#define MAX_IF_MADDR_CNT	2			/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®æå¤§ãµã¤ãº	*/
+#define IF_MADDR_INIT		{ { { 0, 0, 0, 0, 0, 0 } }, { { 0, 0, 0, 0, 0, 0 } } }
+							/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®åæå	*/
+#define IF_PROTO_IPV6		ETHER_TYPE_IPV6		/* ã¤ã³ã¿ãã§ã¼ã¹ã® IPv6 ãã­ãã³ã«æå®			*/
+#define IF_ADDMULTI(s)		IF_ETHER_NIC_ADDMULTI(s)
+							/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®ç»é²				*/
+#define IF_IN6_NEED_CACHE(i)	(true)			/* è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãä½¿ç¨ããã				*/
+#define IF_IN6_IFID(i,a)	IF_ETHER_NIC_IN6_IFID(i,a)
+							/* ã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ã®è¨­å®				*/
+#define IF_IN6_RESOLVE_MULTICAST(i,m)	\
+				ether_in6_resolve_multicast(i,m)
+							/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã¸ã®å¤æ		*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+#ifndef T_IF_SOFTC_DEFINED
+
+typedef struct t_if_softc T_IF_SOFTC;
+
+#define T_IF_SOFTC_DEFINED
+
+#endif	/* of #ifndef T_IF_SOFTC_DEFINED */
+
+#ifndef T_IN4_ADDR_DEFINED
+
+typedef uint32_t T_IN4_ADDR;
+
+#define T_IN4_ADDR_DEFINED
+
+#endif	/* of #ifndef T_IN4_ADDR_DEFINED */
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããªãã½ããã¦ã§ã¢æ
+å ±
+ */
+
+#ifdef T_IF_ETHER_NIC_SOFTC
+
+struct t_if_softc {
+	T_IF_ADDR		ifaddr;			/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+	uint16_t		timer;			/* éä¿¡ã¿ã¤ã ã¢ã¦ã			*/
+	T_IF_ETHER_NIC_SOFTC	*sc;			/* ãã£ãã¤ã¹ä¾å­ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	ID			semid_txb_ready;	/* éä¿¡ã»ããã©				*/
+	ID			semid_rxb_ready;	/* åä¿¡ã»ããã©				*/
+
+#ifdef _IP6_CFG
+
+	T_IF_ADDR 	maddrs[MAX_IF_MADDR_CNT];	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãªã¹ã	*/
+
+#endif	/* of #ifdef _IP6_CFG */
+	};
+
+#endif	/* of #ifdef T_IF_ETHER_NIC_SOFTC */
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef ETHER_CFG_COLLECT_ADDR
+
+T_ETHER_ADDR ether_collect_addr;
+
+#endif	/* of #ifdef ETHER_CFG_COLLECT_ADDR */
+
+/*
+ *  é¢æ°
+ */
+
+#ifdef _IP6_CFG
+
+/* åæ¹åç
+§ */
+
+#ifndef T_IN6_ADDR_DEFINED
+
+typedef struct t_in6_addr T_IN6_ADDR;
+
+#define T_IN6_ADDR_DEFINED
+
+#endif	/* of #ifndef T_IN6_ADDR_DEFINED */
+
+extern ER ether_in6_resolve_multicast(T_ETHER_ADDR *ifaddr, const T_IN6_ADDR *maddr);
+
+#endif	/* of #ifdef _IP6_CFG */
+
+extern T_IFNET *ether_get_ifnet (void);
+extern ER ether_output (T_NET_BUF *data, const void *dst, T_IF_ADDR *gw, TMO tmout);
+extern ER ether_raw_output (T_NET_BUF *data, TMO tmout);
+extern uint32_t ether_srand (void);
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _ETHERNET_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/fcstab.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/fcstab.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/fcstab.c	(revision 317)
@@ -0,0 +1,34 @@
+static UH fcstab[256] = {
+	0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
+	0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
+	0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
+	0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
+	0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
+	0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
+	0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
+	0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
+	0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
+	0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
+	0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
+	0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
+	0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
+	0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
+	0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
+	0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
+	0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
+	0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
+	0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
+	0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
+	0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
+	0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
+	0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
+	0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
+	0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
+	0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
+	0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
+	0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
+	0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
+	0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
+	0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
+	0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78,
+	};
Index: asp3_gr_sakura/trunk/tinet/net/genfcstab.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/genfcstab.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/genfcstab.c	(revision 317)
@@ -0,0 +1,32 @@
+/*
+ * Generate a FCS table for the HDLC FCS (RFC1171).
+ *
+ * Drew D. Perkins at Carnegie Mellon University.
+ *
+ * Code liberally borrowed from Mohsen Banan and D. Hugh Redelmeier.
+ */
+
+#include <stdio.h>
+
+/* The HDLC polynomail: X**0 + X**5 + X**12 + X**16 (0x8408) */
+
+#define Polynomial	0x8408
+
+int
+main (int argc, char *argv[])
+{
+	unsigned int	count, octet;
+	int		bit;
+
+	printf("%s = {\n", argv[1]);
+	for (count = 0; count < 256; count ++) {
+		octet = count;
+		for (bit = 8; bit-- > 0; )
+			octet = (octet & 0x01) ? ((octet >> 1) ^ Polynomial) : (octet >> 1);
+		printf("%c0x%04x,", count % 8 ? ' ' : '\t', octet & 0xffff);
+		if (count % 8 == 7)
+			putchar('\n');
+		}
+	fputs("\t};\n", stdout);
+	return 0;
+	}
Index: asp3_gr_sakura/trunk/tinet/net/if.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if.c	(revision 317)
@@ -0,0 +1,194 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1980, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if.c	8.3 (Berkeley) 1/4/94
+ * $FreeBSD: src/sys/net/if.c,v 1.64.2.1 1999/08/29 16:28:14 peter Exp $
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#include <netinet6/in6.h>
+#include <netinet6/in6_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  é¢æ°
+ */
+
+static void if_slowtimo (void *ignore);
+
+/*
+ *  if_slowtimo -- ã¤ã³ã¿ãã§ã¼ã¹ã®ã¯ããããã°ã¿ã¤ãå¶å¾¡
+ */
+
+static void
+if_slowtimo (void *ignore)
+{
+	T_IF_SOFTC	*ic;
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+
+	if (ic->timer > 0) {
+		ic->timer --;
+		if (ic->timer == 0)
+			IF_ETHER_NIC_WATCHDOG(ic);
+		}
+	timeout(if_slowtimo, NULL, IF_TIMER_TMO);
+	}
+
+/*
+ *  ifinit -- ã¤ã³ã¿ãã§ã¼ã¹ç®¡çã®åæå
+ */
+
+void
+ifinit (void)
+{
+	timeout(if_slowtimo, NULL, IF_TIMER_TMO);
+	}
+
+#endif /* of #ifdef SUPPORT_ETHER */
+
+#ifdef _IP6_CFG
+
+/*
+ *  if_addmulti -- ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®ç»é²
+ */
+
+ER
+if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type)
+{
+#if MAX_IF_MADDR_CNT > 0
+
+	T_IF_ADDR	llmaddr;
+	ER		error = E_OK;
+	int_t		ix;
+
+	if (type == AT_INET6) {
+
+		if ((ix = in6_addr2maix((T_IN6_ADDR*)maddr)) == IPV6_MADDR_IX_EXTRA)
+			return E_PAR;
+
+		/* IPv6 ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãç»é²ããã*/
+		ifp->in6_maddrs[ix] = *(T_IN6_ADDR*)maddr;
+
+		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ã«å¤æããç»é²ããã*/
+		error = IF_IN6_RESOLVE_MULTICAST(&llmaddr, (T_IN6_ADDR*)maddr);
+		if (error != E_OK)
+			return error;
+		ifp->ic->maddrs[ix] = llmaddr;
+		}
+
+	return IF_ADDMULTI(ifp->ic);
+
+#else	/* of #if MAX_IF_MADDR_CNT > 0 */
+
+	return E_OK;
+
+#endif	/* of #if MAX_IF_MADDR_CNT > 0 */
+	}
+
+#endif	/* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/net/if.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if.h	(revision 317)
@@ -0,0 +1,120 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/net/if.h,v 1.49.2.1 1999/08/29 16:28:15 peter Exp $
+ */
+
+#ifndef _IF_H_
+#define _IF_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ç¨ã¿ã¤ãã®å®ç¾©
+ */
+
+#define IF_TIMER_TMO		NET_TIMER_HZ	/* ã¿ã¤ã ã¢ã¦ãã1 [s]	*/
+#define IF_TIMER_HZ		1		/* ã¿ã¤ãã®å¨æ³¢æ°ã1 [s]	*/
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ãã©ã°
+ */
+
+#define IFF_UP			UINT_C(0x0001)	/* èµ·åæ¸ã¿		*/
+#define IFF_RUNNING		UINT_C(0x0002)	/* åä½ä¸­		*/
+
+/*
+ *  æ±ç¨å®ç¾©
+ */
+
+#define IF_HDR_SIZE		(sizeof(T_IF_HDR))
+#define IF_PDU_SIZE		(IF_HDR_SIZE + IF_MTU)	/* Protocol Data Unit */
+
+/*
+ *  é¢æ°
+ */
+
+#ifdef SUPPORT_ETHER
+
+extern void ifinit (void);
+
+#else	/* of #ifdef SUPPORT_ETHER */
+
+#define ifinit
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _IF_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if6_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if6_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if6_var.h	(revision 317)
@@ -0,0 +1,157 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _IF6_VAR_H_
+#define _IF6_VAR_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½
+ */
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+struct t_ifnet {
+	T_IF_SOFTC	*ic;		/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	T_IN6_IFADDR 	in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
+					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	T_IN6_ADDR	in6_maddrs [MAX_IN6_MADDR_CNT];
+					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	T_IN4_IFADDR 	in4_ifaddr;	/* IPv4 ã¢ãã¬ã¹æ
+å ±				*/
+	uint8_t		flags;		/* ãã©ã°					*/
+	};
+
+#else	/* of #if defined(_IP4_CFG) */
+
+struct t_ifnet {
+	T_IF_SOFTC	*ic;		/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	T_IN6_IFADDR 	in6_ifaddrs[NUM_IN6_IFADDR_ENTRY];
+					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	T_IN6_ADDR	in6_maddrs [MAX_IN6_MADDR_CNT];
+					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	uint8_t		flags;		/* ãã©ã°					*/
+	};
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+struct t_ifnet {
+	T_IF_SOFTC	*ic;		/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	T_IN4_IFADDR 	in4_ifaddr;	/* IPv4 ã¢ãã¬ã¹æ
+å ±				*/
+	};
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+#if defined(_IP6_CFG)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define ND6_IFPTOMAC(i)		(IF_SOFTC_TO_IFADDR((i)->ic))
+
+/*
+ *  é¢æ°
+ */
+
+extern ER if_addmulti (T_IFNET *ifp, void *maddr, uint8_t type);
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #ifndef _IF6_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_arp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_arp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_arp.h	(revision 317)
@@ -0,0 +1,151 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if_arp.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/net/if_arp.h,v 1.10.2.3 1999/11/19 09:30:31 julian Exp $
+ */
+
+#ifndef _IF_ARP_H_
+#define _IF_ARP_H_
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  Address Resolution Protocol.
+ *
+ *  RFC 826 åç
+§
+ */
+
+/*
+ *  æ§é ä½
+ */
+
+/* ARP ããã */
+
+typedef struct t_arp_hdr {
+	uint16_t	hrd_addr;	/* ç©çã¢ãã¬ã¹ãã©ã¼ããã	*/
+	uint16_t	proto;		/* ãã­ãã³ã«			*/
+	uint8_t		hdr_len;	/* ç©çã¢ãã¬ã¹é·		*/
+	uint8_t		proto_len;	/* ãã­ãã³ã«é·			*/
+	uint16_t	opcode;		/* å½ä»¤ã³ã¼ã			*/
+	} T_ARP_HDR;
+
+#define ARP_HDR_SIZE			(sizeof(T_ARP_HDR))
+#define IF_ARP_HDR_SIZE			(IF_HDR_SIZE + ARP_HDR_SIZE)
+
+#define GET_ARP_HDR(nbuf)		((T_ARP_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+
+#define GET_IF_ARP_HDR_SIZE(nbuf)	(IF_HDR_SIZE + ARP_HDR_SIZE)
+
+/* hrd_addrãç©çã¢ãã¬ã¹ãã©ã¼ãããã®å¤ */
+
+#define ARPHRD_ETHER	1	/* Ethernet	*/
+
+/* opcode, å½ä»¤ã³ã¼ãã®å¤ */
+
+#define ARPOP_REQUEST		UINT_C(1)	/* ã¢ãã¬ã¹è§£æ±ºè¦æ±		*/
+#define ARPOP_REPLY		UINT_C(2)	/* ã¢ãã¬ã¹è§£æ±ºå¿ç­		*/
+#define ARPOP_REV_REQUEST	UINT_C(3)	/* ãã­ãã³ã«ã»ã¢ãã¬ã¹è§£æ±ºè¦æ±	*/
+#define ARPOP_REV_REPLY		UINT_C(4)	/* ãã­ãã³ã«ã»ã¢ãã¬ã¹è§£æ±ºè¦æ±	*/
+#define ARPOP_INV_REQUEST	UINT_C(8)	/* çµç«¯è­å¥è¦æ±			*/
+#define ARPOP_INV_REPLY		UINT_C(9)	/* çµç«¯è­å¥è¦æ±			*/
+
+/*
+ *  ã¤ã¼ãµããããã©ã¤ãã¢ã¸ã¥ã¼ã«ã§ä½¿ç¨ããã ARP æ
+å ±
+ */
+
+typedef struct arpcom {
+	uint8_t		mac_addr[ETHER_ADDR_LEN];
+	} T_ARPCOM;
+
+/*
+ *  ARP ã­ã£ãã·ã¥æ´æ°ã¿ã¤ãã®å®ç¾©
+ */
+
+#define ARP_TIMER_TMO		(60*NET_TIMER_HZ)	/* ã¿ã¤ã ã¢ã¦ãã60 [s]	*/
+
+/*
+ *  å¤æ°
+ */
+
+extern const uint8_t	ether_broad_cast_addr[ETHER_ADDR_LEN];
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _IF_ARP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_llc.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_llc.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_llc.h	(revision 317)
@@ -0,0 +1,121 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *      @(#)if_llc.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/net/if_llc.h,v 1.6.4.1 1999/08/29 16:28:18 peter Exp $
+ */
+
+#ifndef _IF_LLC_H_
+#define _IF_LLC_H_
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  é·ãã®å®ç¾©
+ */
+
+#define SNAP_ORG_LEN		3
+#define SNAP_TYPE_LEN		2
+
+/*
+ *  802.3 ããã
+ */
+
+typedef struct t_8023mac_header {
+	uint8_t		dhost[ETHER_ADDR_LEN];
+	uint8_t		shost[ETHER_ADDR_LEN];
+	uint16_t	len;
+	} T_8023MAC_HDR;
+
+typedef struct t_8022llc_header {
+	uint8_t		dsap;
+	uint8_t		ssap;
+	uint8_t		control;
+	} T_8022LLC_HDR;
+
+typedef struct t_8022snap_header {
+	uint8_t		original[SNAP_ORG_LEN];
+	uint8_t		type[SNAP_TYPE_LEN];
+	} T_8022SNAP_HDR;
+
+#define GET_8023MAC_HDR(nbuf)		((T_8023MAC_HDR*)((nbuf)->buf))
+#define GET_8022LLC_HDR(nbuf)		((T_8022LLC_HDR*)((nbuf)->buf + sizeof(T_8023MAC_HDR)))
+#define GET_8022SNAP_HDR(nbuf)		((T_8022SNAP_HDR*)((nbuf)->buf + sizeof(T_8023MAC_HDR) + sizeof(T_8022LLC_HDR)))
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _IF_LLC_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_loop.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_loop.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_loop.c	(revision 317)
@@ -0,0 +1,249 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if_loop.c	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/net/if_loop.c,v 1.37.2.1 1999/08/29 16:28:19 peter Exp $
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_LOOP
+
+/*
+ *  ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹
+ */
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  å¤æ°
+ */
+
+/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ */
+
+#if defined(_IP6_CFG)
+
+static T_IFNET loop_ifnet = {
+	NULL,			/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{},			/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	{},			/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	};
+
+#elif defined(_IP4_CFG)	/* of #if defined(_IP6_CFG) */
+
+static T_IFNET loop_ifnet = {
+	NULL,			/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{
+		IPV4_ADDR_LOOPBACK,		/* IPv4 ã¢ãã¬ã¹			*/
+		IPV4_ADDR_LOOPBACK_MASK,	/* ãµãããããã¹ã¯			*/
+		},
+	};
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+/*
+ *  loop_get_ifnet -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã
+ */
+
+T_IFNET *
+loop_get_ifnet (void)
+{
+	return &loop_ifnet;
+	}
+
+/*
+ *  looutput -- ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°
+ */
+
+ER
+looutput (T_NET_BUF *output, TMO tmout)
+{
+	ER error;
+
+	NET_COUNT_LOOP(net_count_loop.out_octets,  output->len);
+	NET_COUNT_LOOP(net_count_loop.out_packets, 1);
+
+	if ((error = tsnd_dtq(DTQ_LOOP_OUTPUT, output, tmout)) != E_OK)
+		syslog(LOG_NOTICE, "[LOOP] drop error: %s", itron_strerror(error));
+	return error;
+	}
+
+/*
+ *  ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã»åºåã¿ã¹ã¯
+ */
+
+void
+if_loop_output_task (intptr_t exinf)
+{
+	T_NET_BUF	*output;
+	ER		error;
+	ID		tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[LOOP OUTPUT:%d] started.", tskid);
+	while (true) {
+		if (rcv_dtq(DTQ_LOOP_OUTPUT, (intptr_t*)&output) == E_OK) {
+			NET_COUNT_LOOP(net_count_loop.in_octets,  output->len);
+			NET_COUNT_LOOP(net_count_loop.in_packets, 1);
+			if ((error = snd_dtq(DTQ_LOOP_INPUT, output)) != E_OK)
+				syslog(LOG_NOTICE, "[LOOP OUTPUT] drop error: %s", itron_strerror(error));
+			}
+		}
+	}
+
+/*
+ *  ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã»å
+¥åã¿ã¹ã¯
+ */
+
+void
+if_loop_input_task (intptr_t exinf)
+{
+	T_NET_BUF	*input;
+	ID		tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[LOOP INPUT:%d] started.", tskid);
+	while (true) {
+		if (rcv_dtq(DTQ_LOOP_INPUT, (intptr_t)&input) == E_OK) {
+			NET_COUNT_LOOP(net_count_loop.in_octets,  input->len);
+			NET_COUNT_LOOP(net_count_loop.in_packets, 1);
+
+#if defined(_IP4_CFG)
+
+			/* IPv4 å
+¥åé¢æ°ãå¼ã³åºã */
+			if (IP4_VHL_V(GET_IP4_HDR(input)->vhl) == IPV4_VERSION)
+				ip_input(input);
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
+
+			/* IPv6 å
+¥åé¢æ°ãå¼ã³åºã */
+			if (IP6_VCF_V(ntohl(GET_IP6_HDR(input)->vcf)) == IPV6_VERSION)
+				ip6_input(input);
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+			}
+		}
+	}
+
+#endif	/* of #ifdef SUPPORT_LOOP */
Index: asp3_gr_sakura/trunk/tinet/net/if_loop.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_loop.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_loop.cfg	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã»ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef SUPPORT_LOOP
+
+CRE_TSK(LOOP_OUTPUT_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	if_loop_output_task,
+	LOOP_OUTPUT_PRIORITY,
+	LOOP_OUTPUT_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(LOOP_INPUT_TASK,  {
+	TA_HLNG|TA_ACT,
+	0,
+	if_loop_input_task,
+	LOOP_INPUT_PRIORITY,
+	LOOP_INPUT_STACK_SIZE,
+	NULL
+	});
+
+CRE_DTQ(DTQ_LOOP_OUTPUT,  { TA_TFIFO, NUM_DTQ_LOOP_OUTPUT, NULL });
+CRE_DTQ(DTQ_LOOP_INPUT,   { TA_TFIFO, NUM_DTQ_LOOP_INPUT,  NULL });
+
+#endif	/* of #ifdef SUPPORT_LOOP */
Index: asp3_gr_sakura/trunk/tinet/net/if_loop.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_loop.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_loop.h	(revision 317)
@@ -0,0 +1,169 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ */
+
+#ifndef _IF_LOOP_H_
+#define _IF_LOOP_H_
+
+#ifdef SUPPORT_LOOP
+
+/*
+ *  ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã»ãããã¨ã¢ãã¬ã¹
+ */
+
+typedef struct t_loop_hdr  { } T_LOOP_HDR;
+typedef struct t_loop_addr { } T_LOOP_ADDR;
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãã¯ã­
+ */
+
+#define T_IF_HDR		T_LOOP_HDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ããã	*/
+#define T_IF_ADDR		T_LOOP_ADDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+#define IF_HDR_ALIGN		4			/* ãããã®ã¢ã©ã¤ã³åä½		*/
+#define IF_MTU			LOMTU			/* ã¤ã³ã¿ãã§ã¼ã¹ã® MTU		*/
+
+#define IF_OUTPUT(o,d,g,t)	looutput(o,t)		/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°	*/
+#define IF_RAW_OUTPUT(o,t)	looutput(o,t)		/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°ãã¢ãã¬ã¹è§£æ±ºç¡ã*/
+#define IF_SET_PROTO(b,p)				/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã­ãã³ã«è¨­å®é¢æ°	*/
+#define IF_GET_IFNET()		loop_get_ifnet()	/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã		*/
+#define IF_SRAND()		(0)			/* ã¤ã³ã¿ã¼ãã§ã¼ã¹ã®ä¹±æ°åæå¤			*/
+
+/* IPv4 é¢ä¿ */
+
+#define IF_PROTO_IP		0			/* ã¤ã³ã¿ãã§ã¼ã¹ã® IP ãã­ãã³ã«æå®		*/
+
+/* IPv6 é¢ä¿ */
+
+#define MAX_IF_MADDR_CNT	0			/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®æå¤§ãµã¤ãº	*/
+#define IF_IN6_NEED_CACHE(i)	(false)			/* è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãä½¿ç¨ããã				*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+#ifndef T_IF_SOFTC_DEFINED
+
+typedef struct t_if_softc T_IF_SOFTC;
+
+#define T_IF_SOFTC_DEFINED
+
+#endif	/* of #ifndef T_IF_SOFTC_DEFINED */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããªãã½ããã¦ã§ã¢æ
+å ±
+ */
+
+struct t_if_softc { };
+
+/*
+ *  é¢æ°
+ */
+
+extern T_IFNET *loop_get_ifnet (void);
+ER looutput (T_NET_BUF *output, TMO tmout);
+
+/*
+ *  ã­ã¼ã«ã«ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã»å¦çã¿ã¹ã¯
+ */
+
+extern void	if_loop_output_task(intptr_t exinf);
+extern void	if_loop_input_task(intptr_t exinf);
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#endif	/* of #ifndef _IF_LOOP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_ppp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_ppp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_ppp.h	(revision 317)
@@ -0,0 +1,173 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * if_ppp.h - Point-to-Point Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/sys/net/if_ppp.h,v 1.13.2.1 1999/08/29 16:28:21 peter Exp $
+ */
+
+#ifndef _IF_PPP_H_
+#define _IF_PPP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  PPP ã¢ãã¬ã¹ã®å®ç¾©ï¼ããã¼ï¼
+ */
+
+typedef struct t_ppp_addr {
+	uint8_t		lladdr[0];
+	} T_PPP_ADDR;
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã®é¸æãã¯ã­
+ */
+
+#define T_IF_HDR		T_PPP_HDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ããã		*/
+#define T_IF_ADDR		T_PPP_ADDR		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹			*/
+#define IF_HDR_ALIGN		2			/* ãããã®ã¢ã©ã¤ã³åä½			*/
+#define IF_MTU			DEF_PPP_MTU		/* ã¤ã³ã¿ãã§ã¼ã¹ã® MTU			*/
+
+#define IF_OUTPUT(o,d,g,t)	ppp_output(o,t)		/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°		*/
+#define IF_RAW_OUTPUT(o,t)	ppp_output(o,t)		/* ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°ãã¢ãã¬ã¹è§£æ±ºç¡ã*/
+#define IF_SET_PROTO(b,p)	(*GET_PPP_HDR(b) = htons(p))
+							/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã­ãã³ã«è¨­å®é¢æ°	*/
+#define IF_SOFTC_TO_IFADDR(s)	((T_IF_ADDR*)(s)->ifaddr.lladdr)
+							/* ã½ããã¦ã§ã¢æ
+å ±ãã PPP ã¢ãã¬ã¹ãåãåºã	*/
+#define IF_GET_IFNET()		ppp_get_ifnet()		/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã*/
+#define IF_SRAND()		(0)			/* ã¤ã³ã¿ã¼ãã§ã¼ã¹ã®ä¹±æ°åæå¤			*/
+
+/* IPv4 é¢ä¿ */
+
+#define IF_PROTO_IP		PPP_IP			/* ã¤ã³ã¿ãã§ã¼ã¹ã® IPv4 ãã­ãã³ã«æå®	*/
+
+/* IPv6 é¢ä¿ */
+
+#define MAX_IF_MADDR_CNT	0			/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®æå¤§ãµã¤ãº*/
+#define IF_PROTO_IPV6		PPP_IPV6		/* ã¤ã³ã¿ãã§ã¼ã¹ã® IPv6 ãã­ãã³ã«æå®	*/
+#define IF_IN6_NEED_CACHE(i)	(false)			/* è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãä½¿ç¨ããã	*/
+#define IF_IN6_IFID(i,a)	get_rand_ifid(i,a)	/* ã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ã®è¨­å®		*/
+#define IF_IN6_RESOLVE_MULTICAST(i,m)	{}		/* ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã¸ã®å¤æ		*/
+
+/*
+ *  MTU (MRU) ã«é¢ããå®ç¾©
+ */
+
+#define DEF_PPP_MTU		1500	/* PPP ã® æ¨æº MTU	*/
+#define MAX_PPP_MTU		16384	/* PPP ã® æå¤§ MTU	*/
+#define MIN_PPP_MTU		128	/* PPP ã® æå° MTU	*/
+
+/*
+ *  PPP ããã
+ */
+
+typedef uint16_t T_PPP_HDR;				/* ä¸ä½ãã­ãã³ã«		*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+#ifndef T_IF_SOFTC_DEFINED
+
+typedef struct t_if_softc T_IF_SOFTC;
+
+#define T_IF_SOFTC_DEFINED
+
+#endif	/* of #ifndef T_IF_SOFTC_DEFINED */
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããªãã½ããã¦ã§ã¢æ
+å ±
+ */
+
+struct t_if_softc {
+	T_IF_ADDR	ifaddr;		/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+	};
+
+/*
+ *  é¢æ°
+ */
+
+extern T_IFNET *ppp_get_ifnet (void);
+ER ppp_output (T_NET_BUF *data, TMO tmout);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _IF_PPP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_types.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_types.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_types.h	(revision 317)
@@ -0,0 +1,87 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+/*-
+ * Copyright (c) 1989, 1993, 1994
+ *	The Regents of the University of California.  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.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if_types.h	8.3 (Berkeley) 4/28/95
+ * $FreeBSD: src/sys/net/if_types.h,v 1.23.6.1 2008/11/25 02:59:29 kensmith Exp $
+ * $NetBSD: if_types.h,v 1.16 2000/04/19 06:30:53 itojun Exp $
+ */
+
+#ifndef _IF_TYPES_
+#define _IF_TYPES_
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã®åã®å®ç¾©
+ */
+
+#define IFT_ETHER	0x6	/* Ethernet CSMA/CD	*/
+
+#endif	/* of #ifndef _IF_TYPES_ */
Index: asp3_gr_sakura/trunk/tinet/net/if_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/if_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/if_var.h	(revision 317)
@@ -0,0 +1,110 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _IF_VAR_H_
+#define _IF_VAR_H_
+
+#include <net/if6_var.h>
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_if_stats {
+	uint32_t	ifInOctets;
+	uint32_t	ifInUcastPkts;
+	uint32_t	ifInNUcastPkts;
+/*	uint32_t	ifInDiscards;*/
+	uint32_t	ifInErrors;
+	uint32_t	ifUnknownProtos;
+	uint32_t	ifOutOctets;
+	uint32_t	ifOutUcastPkts;
+	uint32_t	ifOutNUcastPkts;
+	uint32_t	ifOutDiscards;
+	uint32_t	ifOutErrors;
+/*	uint32_t	ifOutQlen;*/
+} T_IF_STATS;
+
+extern T_IF_STATS if_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#endif	/* of #ifndef _IF_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net.cfg	(revision 317)
@@ -0,0 +1,78 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  å
+±é æ±ç¨ãããã¯ã¼ã¯ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ * ãããã¯ã¼ã¯ã¿ã¤ã
+ */
+
+CRE_TSK(NET_TIMER_TASK, {
+		TA_HLNG,
+		0,
+		net_timer_task,
+		NET_TIMER_PRIORITY,
+		NET_TIMER_STACK_SIZE,
+		NULL
+		});
+
+CRE_CYC(NET_TIMER_HANDLER, {
+		TA_STA,
+		{ TNFY_HANDLER, 0, net_timer_handler },
+		NET_TIMER_CYCLE,
+		1
+		});
+
+/* ãããã¯ã¼ã¯ã¿ã¤ãã®å¼åºãã¨ã³ããªç¨ã»ããã© */
+
+CRE_SEM(SEM_CALL_OUT_LOCK,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_CALL_OUT_TIMEOUT,	{ TA_TPRI, 0, NUM_NET_CALLOUT });
+
+/* ãµãã¼ãé¢æ° ip2strãipv62str ç¨ã»ããã© */
+
+CRE_SEM(SEM_IP2STR_BUFF_LOCK,	{ TA_TPRI, 1, 1 });
Index: asp3_gr_sakura/trunk/tinet/net/net.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net.h	(revision 317)
@@ -0,0 +1,142 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _NET_H_
+#define _NET_H_
+
+/*
+ *  ãã­ãã³ã«ãè­å¥ãããã©ã°ã«é¢ããå®ç¾©
+ *
+ *    ã»çµ±è¨æ
+å ±
+ */
+
+#define PROTO_FLG_PPP_HDLC	ULONG_C(0x00000001)	/* ppp_hdlc.c	*/
+#define PROTO_FLG_PPP_FSM	ULONG_C(0x00000002)	/* ppp_fsm.c	*/
+#define PROTO_FLG_PPP_AUTH	ULONG_C(0x00000004)	/* ppp_auth.c	*/
+#define PROTO_FLG_PPP_LCP	ULONG_C(0x00000008)	/* ppp_lcp.c	*/
+#define PROTO_FLG_PPP_IPCP	ULONG_C(0x00000010)	/* ppp_ipcp.c	*/
+#define PROTO_FLG_PPP_IPV6CP	ULONG_C(0x00000020)	/* ppp_ipv6cp.c	*/
+#define PROTO_FLG_PPP_CCP	ULONG_C(0x00000040)	/* ppp_ccp.c	*/
+#define PROTO_FLG_PPP_PAP	ULONG_C(0x00000080)	/* ppp_upap.c	*/
+#define PROTO_FLG_PPP_MODEM	ULONG_C(0x00000100)	/* ppp_modem.c	*/
+#define PROTO_FLG_PPP		ULONG_C(0x00000200)	/* ppp.c	*/
+
+#define PROTO_FLG_ETHER_NIC	ULONG_C(0x00000001)	/* if_??.c	*/
+
+#define PROTO_FLG_LOOP		ULONG_C(0x00000100)	/* if_loop.c	*/
+
+#define PROTO_FLG_ETHER		ULONG_C(0x00000100)	/* ethernet.c	*/
+
+#define PROTO_FLG_IF		ULONG_C(0x00000800)	/* if.c		*/
+
+#define PROTO_FLG_ARP		ULONG_C(0x00008000)	/* if_ether.c	*/
+
+#define PROTO_FLG_IP4		ULONG_C(0x00010000)	/* ip_*.c	*/
+#define PROTO_FLG_ICMP4		ULONG_C(0x00040000)	/* ip_icmp.c	*/
+
+#define PROTO_FLG_IP6		ULONG_C(0x00100000)	/* ip6_*.c	*/
+#define PROTO_FLG_ICMP6		ULONG_C(0x00400000)	/* icmp6.c	*/
+#define PROTO_FLG_ND6		ULONG_C(0x00800000)	/* nd6_*.c	*/
+
+#define PROTO_FLG_UDP		ULONG_C(0x08000000)	/* udp_*.c	*/
+
+#define PROTO_FLG_TCP		ULONG_C(0x01000000)	/* tcp_*.c	*/
+
+#define PROTO_FLG_NET_BUF	ULONG_C(0x10000000)	/* net_buf.c	*/
+#define PROTO_FLG_NET		ULONG_C(0x80000000)	/* route.c, net*.c	*/
+
+/*
+ *  ã¢ãã¬ã¹å½¢å¼ã®å®ç¾©
+ */
+
+#define AT_ETHER		UINT_C(0x01)		/* ã¤ã¼ãµããã		*/
+#define AT_INET4		UINT_C(0x10)		/* IPv4 ã¢ãã¬ã¹	*/
+#define AT_INET6		UINT_C(0x20)		/* IPv6 ã¢ãã¬ã¹	*/
+
+#if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
+
+/*
+ *  TINET ç¬èªé¢æ°
+ */
+
+extern char *mac2str (char *buf, uint8_t *macaddr);
+
+#endif /* #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY) */
+
+#endif	/* of #ifndef _NET_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_asp.cfg	(revision 317)
@@ -0,0 +1,183 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASPç¨ æ±ç¨ãããã¯ã¼ã¯ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é æ±ç¨ãããã¯ã¼ã¯ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+INCLUDE("net/net.cfg");
+
+/*
+ * ãããã¯ã¼ã¯ãããã¡
+ */
+
+#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
+CRE_MPF(MPF_NET_BUF_CSEG, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_CSEG,
+		sizeof(T_NET_BUF_CSEG),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
+
+#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
+CRE_MPF(MPF_NET_BUF_64, {
+		TA_TFIFO, NUM_MPF_NET_BUF_64,
+		sizeof(T_NET_BUF_64),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0
+CRE_MPF(MPF_NET_BUF_128, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_128,
+		sizeof(T_NET_BUF_128),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0
+CRE_MPF(MPF_NET_BUF_256, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_256,
+		sizeof(T_NET_BUF_256),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0
+CRE_MPF(MPF_NET_BUF_512, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_512,
+		sizeof(T_NET_BUF_512),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0
+CRE_MPF(MPF_NET_BUF_IP_MSS, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IP_MSS,
+		sizeof(T_NET_BUF_IP_MSS),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */
+
+#if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0
+CRE_MPF(MPF_NET_BUF_1024, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_1024,
+		sizeof(T_NET_BUF_1024),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0
+CRE_MPF(MPF_NET_BUF_IPV6_MMTU, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IPV6_MMTU,
+		sizeof(T_NET_BUF_IPV6_MMTU),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
+CRE_MPF(MPF_NET_BUF_IF_PDU, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IF_PDU,
+		sizeof(T_NET_BUF_IF_PDU),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
+
+#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_REASSM,
+		sizeof(T_NET_BUF6_REASSM),
+		NULL,
+		NULL
+		});
+
+#else /* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF4_REASSM,
+		sizeof(T_NET_BUF4_REASSM),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0
+CRE_MPF(MPF_NET_BUF6_65536, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_65536,
+		sizeof(T_NET_BUF6_65536),
+		NULL,
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
Index: asp3_gr_sakura/trunk/tinet/net/net_buf.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_buf.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_buf.c	(revision 317)
@@ -0,0 +1,522 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+
+/*
+ *  é¢æ°
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+/*
+ *  å¤æ°
+ */
+
+static T_NET_BUF_ENTRY net_buf_table[] = {
+
+#if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0
+	{
+		MPF_NET_BUF6_65536,
+		IF_IP6_HDR_SIZE + 65536,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF6_65536,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
+
+#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
+	{
+		MPF_NET_BUF_REASSM,
+		IP6_CFG_FRAG_REASSM_SIZE,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF6_REASSM,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+
+#else	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
+	{
+		MPF_NET_BUF_REASSM,
+		IP4_CFG_FRAG_REASSM_SIZE,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF4_REASSM,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
+	{
+		MPF_NET_BUF_IF_PDU,
+		IF_PDU_SIZE,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_IF_PDU,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0
+	{
+		MPF_NET_BUF_IPV6_MMTU,
+		IF_HDR_SIZE + IPV6_MMTU,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_IPV6_MMTU,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */
+
+#if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0
+	{
+		MPF_NET_BUF_1024,
+		UINT_C(1024),
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_1024,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0
+	{
+		MPF_NET_BUF_IP_MSS,
+		IF_HDR_SIZE + IP4_MSS,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_IP_MSS,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */
+
+#if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0
+	{
+		MPF_NET_BUF_512,
+		UINT_C(512),
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_512,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0
+	{
+		MPF_NET_BUF_256,
+		UINT_C(256),
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_256,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0
+	{
+		MPF_NET_BUF_128,
+		UINT_C(128),
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_128,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
+
+#if defined(_IP4_CFG)
+
+#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
+	{
+		MPF_NET_BUF_64,
+		UINT_C(64),
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_64,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
+	{
+		MPF_NET_BUF_CSEG,
+		IF_HDR_SIZE + IP_HDR_SIZE + TCP_HDR_SIZE,
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+		NUM_MPF_NET_BUF_CSEG,
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+		},
+#endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
+
+	};
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+/*
+ *  nbuf_get_tbl -- ãããã¯ã¼ã¯ãããã¡ç®¡çè¡¨ãç²å¾ããã
+ *
+ *    æ³¨æ: ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬ç¨
+ */
+
+const T_NET_BUF_ENTRY *
+nbuf_get_tbl (void)
+{
+	return net_buf_table;
+	}
+
+/*
+ *  nbuf_get_tbl_size -- ãããã¯ã¼ã¯ãããã¡ç®¡çã¨ã³ããªæ°ãç²å¾ããã
+ *
+ *    æ³¨æ: ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬ç¨
+ */
+
+uint_t
+nbuf_get_tbl_size (void)
+{
+	return sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY);
+	}
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+/*
+ *  tget_net_buf_up -- å¤§ããªãµã¤ãºã®æ¹åã«æ¢ç´¢ãã¦ããããã¯ã¼ã¯ãããã¡ãç²å¾ããã
+ */
+
+static ER
+tget_net_buf_up (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, TMO tmout)
+{
+	int_t	ix, req_ix;
+	ER	error = E_OK;
+
+	/* æé©ãªãµã¤ãºã®åºå®é·ã¡ã¢ãªãã¼ã«ãæ¢ãã*/
+	ix = sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY);
+	while (ix -- > 0 && minlen > net_buf_table[ix].size)
+		;
+	req_ix = ix;
+
+	NET_COUNT_NET_BUF(net_buf_table[req_ix].requests, 1);
+
+	while (1) {
+		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
+			(*buf)->idix  = (uint8_t)ix;
+			(*buf)->len   = (uint16_t)minlen;
+			(*buf)->flags = 0;
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+			NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
+			net_buf_table[ix].busies ++;
+#endif
+			return error;
+			}
+		else if (ix == 0 || net_buf_table[ix].size > maxlen)
+			break;
+		ix --;
+		}
+
+	syslog(LOG_WARNING, "[BUF] busy, up   index:%d,%d[%4d], len:%4d.",
+	                    (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
+	*buf = NULL;
+	NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
+	return error;
+	}
+
+/*
+ *  tget_net_buf_down -- å°ããªãµã¤ãºã®æ¹åã«æ¢ç´¢ãã¦ããããã¯ã¼ã¯ãããã¡ãç²å¾ããã
+ */
+
+static ER
+tget_net_buf_down (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, TMO tmout)
+{
+	int_t	ix, req_ix;
+	ER	error = E_OK;
+
+	/* æé©ãªãµã¤ãºã®åºå®é·ã¡ã¢ãªãã¼ã«ãæ¢ãã*/
+	ix = sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY);
+	while (ix -- > 0 && maxlen > net_buf_table[ix].size)
+		;
+	req_ix = ix;
+
+	NET_COUNT_NET_BUF(net_buf_table[req_ix].requests, 1);
+
+	while (1) {
+		if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf,
+		                      ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) {
+			(*buf)->idix  = (uint8_t)ix;
+			(*buf)->len   = net_buf_table[ix].size;
+			(*buf)->flags = 0;
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+			NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
+			net_buf_table[ix].busies ++;
+#endif
+			return error;
+			}
+		ix ++;
+		if (ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) || net_buf_table[ix].size < minlen)
+			break;
+		}
+
+	syslog(LOG_WARNING, "[BUF] busy, down index:%d,%d[%4d], len:%4d.",
+	                    (uint16_t)req_ix, ix, net_buf_table[req_ix].size, minlen);
+	*buf = NULL;
+	NET_COUNT_NET_BUF(net_buf_table[req_ix].errors, 1);
+	return error;
+	}
+
+/*
+ *  tget_net_buf_ex -- ãããã¯ã¼ã¯ãããã¡ãç²å¾ããï¼æ¡å¼µæ©è½ï¼ã
+ */
+
+ER
+tget_net_buf_ex (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout)
+{
+	/* æå°ãµã¤ãºãæå¤§ãµã¤ãºãè¶
+ãã¦ãããã¨ã©ã¼ */
+	if ((nbatr & NBA_SEARCH_DESCENT) != 0 && minlen > maxlen) {
+		syslog(LOG_WARNING, "[NET BUF] E_PAR, minlen=%4d > maxlen=%4d.", minlen, maxlen);
+		return E_PAR;
+		}
+
+	/* å²å½ã¦å¯è½ãªæå¤§ã®ãµã¤ãºãè¶
+ãã¦ãããã¨ã©ã¼ */
+	if (minlen > net_buf_table[0].size || maxlen > net_buf_table[0].size) {
+		syslog(LOG_WARNING, "[NET BUF] E_PAR, minlen=%4d or maxlen=%4d > %4d",
+		                    minlen, maxlen, net_buf_table[0].size);
+		return E_PAR;
+		}
+
+#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
+
+	/* TCP ã§äºç´ãããããã¯ã¼ã¯ãããã¡ãåãåºãã*/
+	if ((nbatr & NBA_RESERVE_TCP) != 0) {
+		if ((*buf = TCP_PULL_RES_NBUF(nbatr)) != NULL) {
+			return E_OK;
+			}
+		}
+
+#endif	/* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
+
+	if ((nbatr & NBA_SEARCH_DESCENT) != 0)
+		return tget_net_buf_down(buf, minlen, maxlen, tmout);
+	else if ((nbatr & NBA_SEARCH_ASCENT) != 0)
+		return tget_net_buf_up(buf, minlen, (uint_t)net_buf_table[0].size, tmout);
+	else {
+		syslog(LOG_WARNING, "[NET BUF] E_PAR, nbatr=%08x.", nbatr);
+		return E_PAR;
+		}
+	}
+
+/*
+ *  tget_net_buf -- ãããã¯ã¼ã¯ãããã¡ãç²å¾ããï¼äºæï¼ã
+ */
+
+ER
+tget_net_buf (T_NET_BUF **buf, uint_t len, TMO tmout)
+{
+	return tget_net_buf_ex(buf, len, (uint_t)net_buf_table[0].size, NBA_SEARCH_ASCENT, tmout);
+	}
+
+/*
+ * rel_net_buf -- ãããã¯ã¼ã¯ãããã¡ãè¿å´ããã
+ */
+
+ER
+rel_net_buf (T_NET_BUF *buf)
+{
+	ER	error = E_OK;
+
+	/* ãããã¯ã¼ã¯ãããã¡ã® ID ã®æ­£å½æ§ãæ¤è¨¼ããã*/
+	if ((int_t)buf->idix >= (int_t)(sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY))) {
+		syslog(LOG_WARNING, "[NET BUF] E_ID, ID=%d.", buf->idix);
+		error = E_ID;
+		}
+	else {
+
+#if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE)
+
+		/* TCP ã§ããããã¯ã¼ã¯ãããã¡ãäºç´ããã*/
+		if (TCP_PUSH_RES_NBUF(buf) == NULL)
+			return E_OK;
+
+#endif	/* of #if defined(SUPPORT_TCP) && defined(TCP_CFG_SWBUF_CSAVE) */
+
+		/* åºå®ã¡ã¢ãªãã¼ã«ã«è¿ãã*/
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+		net_buf_table[buf->idix].busies --;
+#endif
+		if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
+			syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
+			}
+		}
+	return error;
+	}
+
+/*
+ * rus_net_buf -- ãããã¯ã¼ã¯ãããã¡ãåå©ç¨ããã
+ */
+
+ER
+rus_net_buf (T_NET_BUF *buf)
+{
+	ER	error = E_OK;
+
+	if (buf->idix >= sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY)) {
+		syslog(LOG_WARNING, "[NET BUF] E_ID, ID=%d.", buf->idix);
+		error = E_ID;
+		}
+	else {
+		buf->len   = net_buf_table[buf->idix].size;
+		buf->flags = 0;
+		error = E_OK;
+		}
+	return error;
+	}
+
+/*
+ * net_buf_siz -- ãããã¯ã¼ã¯ãããã¡ã®ãµã¤ãºãè¿ãã
+ */
+
+ER_UINT
+net_buf_siz (T_NET_BUF *buf)
+{
+	if (buf->idix >= sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY)) {
+		syslog(LOG_WARNING, "[BUF SIZ] E_ID, ID=%d.", buf->idix);
+		return E_ID;
+		}
+	else
+		return (ER_UINT)net_buf_table[buf->idix].size;
+	}
+
+/*
+ * net_buf_max_siz -- ãããã¯ã¼ã¯ãããã¡ã®æå¤§ãµã¤ãºãè¿ãã
+ */
+
+uint_t
+net_buf_max_siz (void)
+{
+	return (uint_t)net_buf_table[0].size;
+	}
Index: asp3_gr_sakura/trunk/tinet/net/net_buf.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_buf.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_buf.h	(revision 317)
@@ -0,0 +1,264 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NET_BUF_H_
+#define _NET_BUF_H_
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡
+ *
+ *    4 ãªã¯ãããã§ã¢ã©ã¤ã³ããå¿
+è¦ã®ãããã­ã»ããµãèæ
+®ãã¦ã
+ *    IF ããããµã¤ãºã 4 ãªã¯ãããå¢çã§ãªãã®å ´åã
+ *    IP ãããä»¥éã 4 ãªã¯ãããå¢çã«èª¿æ´ããã
+ */
+
+#ifndef CPU_NET_ALIGN
+#error "CPU_NET_ALIGN expected."
+#endif
+
+/*
+ *  ãã³ãã¬ã¼ã
+ */
+
+struct t_net_buf {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_MIN_LEN];	/* ãããã¡æ¬ä½ */
+	};
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+/*
+ *  64 ãªã¯ããã
+ */
+
+typedef struct t_net_buf_64 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[64]; /* ãããã¡æ¬ä½	*/
+	} T_NET_BUF_64;
+
+/*
+ *  128 ãªã¯ããã
+ */
+
+typedef struct t_net_buf_128 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[128]; /* ãããã¡æ¬ä½	*/
+	} T_NET_BUF_128;
+
+/*
+ *  256 ãªã¯ããã
+ */
+
+typedef struct t_net_buf_256 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[256]; /* ãããã¡æ¬ä½	*/
+	} T_NET_BUF_256;
+
+/*
+ *  512 ãªã¯ããã
+ */
+
+typedef struct t_net_buf_512 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[512];/* ãããã¡æ¬ä½	*/
+	} T_NET_BUF_512;
+
+/*
+ *  1024 ãªã¯ããã
+ */
+
+typedef struct t_net_buf_1024 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[1024]; /* ãããã¡æ¬ä½	*/
+	} T_NET_BUF_1024;
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®æå¤§ PDU ãµã¤ãº
+ */
+
+#if defined(IF_PDU_SIZE)
+
+typedef struct t_net_buf_if_pdu {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_PDU_SIZE];
+				/* ãããã¡æ¬ä½		*/
+#if defined(IF_PDU_HDR_PADDING)
+	uint8_t		padding[IF_PDU_HDR_PADDING];
+#endif				/* ãããã®ä½å		*/
+	} T_NET_BUF_IF_PDU;
+
+#endif	/* of #if defined(IF_PDU_SIZE) */
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡è¡¨
+ */
+
+typedef struct t_net_buf_entry {
+
+	uint16_t	index;
+	uint_t		size;
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+	ulong_t		prepares;
+	ulong_t		busies;
+	ulong_t		requests;
+	ulong_t		allocs;
+	ulong_t		errors;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+	} T_NET_BUF_ENTRY;
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ã»ãã©ã°	
+ */
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹åºåå¾ã«ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªãã
+ *  æ³¨æ: åºåå¾ã«ãã®ãã©ã°ã¯ã¯ãªã¢ãããã
+ */
+#define NB_FLG_NOREL_IFOUT	UINT_C(0x80)
+
+/*
+ *  ESP ç¨ãã©ã°
+ */
+#define NB_FLG_DECRYPED		UINT_C(0x40)
+
+/*
+ *  ãããã¯ã¼ã¯ãããã¡ç²å¾å±æ§
+ */
+
+/* æ¢ç´¢å±æ§ */
+
+#define NBA_SEARCH_ASCENT	UINT_C(0x1000)	/* å¤§ããªãµã¤ãºã®æ¹åã«æ¢ç´¢ããã	*/
+#define NBA_SEARCH_DESCENT	UINT_C(0x2000)	/* å°ããªãµã¤ãºã®æ¹åã«æ¢ç´¢ããã	*/
+#define NBA_RESERVE_TCP		UINT_C(0x4000)	/* TCP ç¨ã«ãããã¯ã¼ã¯ãããã¡ãäºç´ããã*/
+#define NBA_ID_MASK		UINT_C(0x0fff)	/* éä¿¡ç«¯ç¹ ID ãæ¸¡ãå ´åã®ãã¹ã¯å¤	*/
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define get_net_buf(b,l)	tget_net_buf((b),(l),TMO_FEVR)
+
+/*
+ *  é¢æ°
+ */
+
+extern ER tget_net_buf_ex (T_NET_BUF **blk, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout);
+extern ER tget_net_buf (T_NET_BUF **blk, uint_t len, TMO tmout);
+extern ER rel_net_buf (T_NET_BUF *blk);
+extern ER rus_net_buf (T_NET_BUF *blk);
+extern ER_UINT net_buf_siz (T_NET_BUF *blk);
+extern uint_t net_buf_max_siz (void);
+extern const T_NET_BUF_ENTRY *nbuf_get_tbl (void);
+extern uint_t nbuf_get_tbl_size (void);
+
+#endif	/* of #ifndef _NET_BUF_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_count.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_count.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_count.c	(revision 317)
@@ -0,0 +1,275 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_count.h>
+
+/*
+ *  è¨æ¸¬ç¨å¤æ°
+ */
+
+#ifdef SUPPORT_PPP
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP
+
+T_NET_COUNT	net_count_ppp;
+T_NET_COUNT_VAL	net_count_ppp_no_bufs;		/* net_buf å²ãå½ã¦å¤±ææ°	*/
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP
+
+T_NET_COUNT_VAL	net_count_ppp_lcp_in_octets;
+T_NET_COUNT_VAL	net_count_ppp_lcp_in_packets;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
+
+T_NET_COUNT_VAL	net_count_ppp_ipv6cp_in_octets;
+T_NET_COUNT_VAL	net_count_ppp_ipv6cp_in_packets;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP
+
+T_NET_COUNT_VAL	net_count_ppp_ipcp_in_octets;
+T_NET_COUNT_VAL	net_count_ppp_ipcp_in_packets;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_PAP
+
+T_NET_COUNT_VAL	net_count_ppp_upap_in_octets;
+T_NET_COUNT_VAL	net_count_ppp_upap_in_packets;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_PAP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_HDLC
+
+T_NET_COUNT	net_count_hdlc;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_HDLC */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#if NET_COUNT_ENABLE & PROTO_FLG_LOOP
+
+T_NET_COUNT	net_count_loop;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_LOOP */
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ETHER
+
+T_NET_COUNT	net_count_ether;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ETHER_NIC
+
+T_NET_COUNT_VAL net_count_ether_nic[NC_ETHER_NIC_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER_NIC */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(_IP4_CFG)
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ARP
+
+T_NET_COUNT	net_count_arp;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ARP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_IP4
+
+T_NET_COUNT_VAL net_count_ip4[NC_IP4_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP4 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ICMP4
+
+T_NET_COUNT	net_count_icmp4;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
+
+#if NET_COUNT_ENABLE & PROTO_FLG_IP6
+
+T_NET_COUNT_VAL net_count_ip6[NC_IP6_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP6 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ICMP6
+
+T_NET_COUNT_VAL	net_count_icmp6[NC_ICMP6_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP6 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ND6
+
+T_NET_COUNT_VAL	net_count_nd6[NC_ND6_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#ifdef SUPPORT_TCP
+
+#if NET_COUNT_ENABLE & PROTO_FLG_TCP
+
+T_NET_COUNT_VAL net_count_tcp[NC_TCP_SIZE];
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_TCP */
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+#if NET_COUNT_ENABLE & PROTO_FLG_UDP
+
+T_NET_COUNT	net_count_udp;
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_UDP */
+
+#endif	/* of #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/net_count.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_count.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_count.h	(revision 317)
@@ -0,0 +1,594 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _NET_COUNT_H_
+#define _NET_COUNT_H_
+
+/*
+ *  ãããã¯ã¼ã¯çµ±è¨æ
+å ±ã®è¨æ¸¬
+ */
+
+#if NET_COUNT_ENABLE != 0
+
+#ifndef _MACRO_ONLY
+
+#ifdef _int64_
+typedef uint64_t T_NET_COUNT_VAL;
+#else
+typedef uint32_t T_NET_COUNT_VAL;
+#endif
+
+typedef struct t_net_count {
+	T_NET_COUNT_VAL	in_octets;		/* åä¿¡ãªã¯ãããæ°	*/
+	T_NET_COUNT_VAL	out_octets;		/* éä¿¡ãªã¯ãããæ°	*/
+	T_NET_COUNT_VAL	in_packets;		/* åä¿¡ãã±ããæ°	*/
+	T_NET_COUNT_VAL	out_packets;		/* éä¿¡ãã±ããæ°	*/
+	T_NET_COUNT_VAL	in_err_packets;		/* åä¿¡ã¨ã©ã¼ãã±ããæ°	*/
+	T_NET_COUNT_VAL	out_err_packets;	/* éä¿¡ã¨ã©ã¼ãã±ããæ°	*/
+	} T_NET_COUNT;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #if NET_COUNT_ENABLE != 0 */
+
+#ifdef SUPPORT_PPP
+
+/* PPP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP
+
+#define NET_COUNT_PPP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_ppp;
+extern T_NET_COUNT_VAL	net_count_ppp_no_bufs;	/* net_buf å²ãå½ã¦å¤±ææ°	*/
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#define NC_PPP_SIZE	7			/* ã«ã¦ã³ã¿æ° */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP */
+
+#define NET_COUNT_PPP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP */
+
+/* PPP HDLC */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_HDLC
+
+#define NET_COUNT_PPP_HDLC(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_hdlc;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_HDLC */
+
+#define NET_COUNT_PPP_HDLC(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_HDLC */
+
+/* PPP LCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP
+
+#define NET_COUNT_PPP_LCP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_lcp_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_lcp_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
+
+#define NET_COUNT_PPP_LCP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_LCP */
+
+/* PPP IPV6CP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP
+
+#define NET_COUNT_PPP_IPV6CP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_ipv6cp_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
+#define NET_COUNT_PPP_IPV6CP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPV6CP */
+
+/* PPP IPCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP
+
+#define NET_COUNT_PPP_IPCP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_ipcp_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_ipcp_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP */
+
+#define NET_COUNT_PPP_IPCP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_IPCP */
+
+/* PPP CCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_CCP
+
+#define NET_COUNT_PPP_CCP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_ccp_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_ccp_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_CCP */
+
+#define NET_COUNT_PPP_CCP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_CCP */
+
+/* PPP PAP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_PPP_PAP
+
+#define NET_COUNT_PPP_PAP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ppp_upap_in_octets;
+extern T_NET_COUNT_VAL net_count_ppp_upap_in_packets;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_PAP */
+
+#define NET_COUNT_PPP_PAP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_PPP_PAP */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+/* ã«ã¼ãããã¯ */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_LOOP
+
+#define NET_COUNT_LOOP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_loop;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_LOOP */
+
+#define NET_COUNT_LOOP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_LOOP */
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#ifdef SUPPORT_ETHER
+
+/* Ethernet */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ETHER
+
+#define NET_COUNT_ETHER(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_ether;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER */
+
+#define NET_COUNT_ETHER(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER */
+
+/* NIC (if_ed) */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ETHER_NIC
+
+#define NC_ETHER_NIC_RESETS		0	/* ãªã»ããæ°			*/
+#define NC_ETHER_NIC_TXB_QOVRS		1	/* éä¿¡ã»ããã©è³æºè¿å´ä¸éãªã¼ãã¼æ°*/
+#define NC_ETHER_NIC_TIMEOUTS		2	/* éä¿¡ã¿ã¤ã ã¢ã¦ãæ°		*/
+#define NC_ETHER_NIC_COLS		3	/* ã³ãªã¸ã§ã³æ°			*/
+#define NC_ETHER_NIC_OUT_ERR_PACKETS	4	/* éä¿¡ã¨ã©ã¼ãã±ããæ°		*/
+#define NC_ETHER_NIC_OUT_PACKETS	5	/* éä¿¡ãã±ããæ°		*/
+#define NC_ETHER_NIC_OUT_OCTETS		6	/* éä¿¡ãªã¯ãããæ°		*/
+#define NC_ETHER_NIC_RXB_QOVRS		7	/* åä¿¡ã»ããã©è³æºè¿å´ä¸éãªã¼ãã¼æ°*/
+#define NC_ETHER_NIC_NO_BUFS		8	/* net_buf å²ãå½ã¦å¤±ææ°	*/
+#define NC_ETHER_NIC_IN_ERR_PACKETS	9	/* åä¿¡ã¨ã©ã¼ãã±ããæ°		*/
+#define NC_ETHER_NIC_IN_PACKETS		10	/* åä¿¡ãã±ããæ°		*/
+#define NC_ETHER_NIC_IN_OCTETS		11	/* åä¿¡ãªã¯ãããæ°		*/
+#define NC_ETHER_NIC_SIZE		12	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_ETHER_NIC(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ether_nic[NC_ETHER_NIC_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER_NIC */
+
+#define NET_COUNT_ETHER_NIC(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ETHER_NIC */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/* ãããã¯ã¼ã¯ãããã¡ */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
+
+#define NET_COUNT_NET_BUF(v,c)		((v)+=(c))
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+#define NET_COUNT_NET_BUF(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
+
+#if defined(_IP4_CFG)
+
+/* ARP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ARP
+
+#define NET_COUNT_ARP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_arp;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ARP */
+
+#define NET_COUNT_ARP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ARP */
+
+/* IPv4 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_IP4
+
+#define NC_IP4_FRAG_OUT_FRAGS		0	/* åå²éä¿¡ããã©ã°ã¡ã³ãæ°	*/
+#define NC_IP4_FRAG_OUT			1	/* åå²éä¿¡æ°			*/
+#define NC_IP4_OUT_ERR_PACKETS		2	/* éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°	*/
+#define NC_IP4_OUT_PACKETS		3	/* éä¿¡ãã¼ã¿ã°ã©ã æ°		*/
+#define NC_IP4_OUT_OCTETS		4	/* éä¿¡ãªã¯ãããæ°		*/
+#define NC_IP4_FRAG_IN_TMOUT		5	/* åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°		*/
+#define NC_IP4_FRAG_IN_NO_BUF		6	/* åå²åä¿¡ãããã¡ãå½ã¦å¤±ææ°	*/
+#define NC_IP4_FRAG_IN_DROP		7	/* åå²åä¿¡ç ´æ£æ°		*/
+#define NC_IP4_FRAG_IN_OK		8	/* åå²åä¿¡åæ§ææåæ°		*/
+#define NC_IP4_FRAG_IN_FRAGS		9	/* åå²åä¿¡ãã©ã°ã¡ã³ãæ°		*/
+#define NC_IP4_FRAG_IN			10	/* åå²åä¿¡æ°			*/
+#define NC_IP4_OPTS			11	/* ãªãã·ã§ã³å
+¥åæ°		*/
+#define NC_IP4_IN_ERR_PROTO		12	/* ãã­ãã³ã«ã¨ã©ã¼æ°		*/
+#define NC_IP4_IN_ERR_ADDR		13	/* ã¢ãã¬ã¹ã¨ã©ã¼æ°		*/
+#define NC_IP4_IN_ERR_VER		14	/* ãã¼ã¸ã§ã³ã¨ã©ã¼æ°		*/
+#define NC_IP4_IN_ERR_SHORT		15	/* é·ãã¨ã©ã¼æ°			*/
+#define NC_IP4_IN_ERR_CKSUM		16	/* ãã§ãã¯ãµã ã¨ã©ã¼æ°		*/
+#define NC_IP4_IN_ERR_PACKETS		17	/* åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°	*/
+#define NC_IP4_IN_PACKETS		18	/* åä¿¡ãã¼ã¿ã°ã©ã æ°		*/
+#define NC_IP4_IN_OCTETS		19	/* åä¿¡ãªã¯ãããæ°		*/
+#define NC_IP4_SIZE			20	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_IP4(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ip4[NC_IP4_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP4 */
+
+#define NET_COUNT_IP4(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP4 */
+
+/* ICMP4 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ICMP4
+
+#define NET_COUNT_ICMP4(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_icmp4;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
+
+#define NET_COUNT_ICMP4(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP4 */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG)
+
+/* IPv6 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_IP6
+
+#define NC_IP6_FRAG_OUT_FRAGS		0	/* åå²éä¿¡ããã©ã°ã¡ã³ãæ°	*/
+#define NC_IP6_FRAG_OUT			1	/* åå²éä¿¡æ°			*/
+#define NC_IP6_OUT_ERR_PACKETS		2	/* éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°	*/
+#define NC_IP6_OUT_PACKETS		3	/* éä¿¡ãã¼ã¿ã°ã©ã æ°		*/
+#define NC_IP6_OUT_OCTETS		4	/* éä¿¡ãªã¯ãããæ°		*/
+#define NC_IP6_FRAG_IN_TMOUT		5	/* åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°		*/
+#define NC_IP6_FRAG_IN_NO_BUF		6	/* åå²åä¿¡ãããã¡ãå½ã¦å¤±ææ°	*/
+#define NC_IP6_FRAG_IN_DROP		7	/* åå²åä¿¡ç ´æ£æ°		*/
+#define NC_IP6_FRAG_IN_OK		8	/* åå²åä¿¡åæ§ææåæ°		*/
+#define NC_IP6_FRAG_IN_FRAGS		9	/* åå²åä¿¡ãã©ã°ã¡ã³ãæ°		*/
+#define NC_IP6_FRAG_IN			10	/* åå²åä¿¡æ°			*/
+#define NC_IP6_IN_ERR_PROTO		11	/* ãã­ãã³ã«ã¨ã©ã¼æ°		*/
+#define NC_IP6_IN_ERR_ADDR		12	/* ã¢ãã¬ã¹ã¨ã©ã¼æ°		*/
+#define NC_IP6_IN_ERR_VER		13	/* ãã¼ã¸ã§ã³ã¨ã©ã¼æ°		*/
+#define NC_IP6_IN_ERR_SHORT		14	/* é·ãã¨ã©ã¼æ°			*/
+#define NC_IP6_IN_ERR_PACKETS		15	/* åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°	*/
+#define NC_IP6_IN_PACKETS		16	/* åä¿¡ãã¼ã¿ã°ã©ã æ°		*/
+#define NC_IP6_IN_OCTETS		17	/* åä¿¡ãªã¯ãããæ°		*/
+#define NC_IP6_SIZE			18	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_IP6(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_ip6[NC_IP6_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP6 */
+
+#define NET_COUNT_IP6(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_IP6 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ICMP6
+
+#define NC_ICMP6_OUT_ERR_PACKETS	0	/* éä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ°	*/
+#define NC_ICMP6_OUT_PACKETS		1	/* éä¿¡ ICMP ãã¼ã¿æ°		*/
+#define NC_ICMP6_OUT_OCTETS		2	/* éä¿¡ ICMP ãªã¯ãããæ°		*/
+#define NC_ICMP6_IN_ERR_CKSUM		3	/* é·ãã¨ã©ã¼æ°			*/
+#define NC_ICMP6_IN_ERR_PACKETS		4	/* åä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ°	*/
+#define NC_ICMP6_IN_PACKETS		5	/* åä¿¡ ICMP ãã¼ã¿æ°		*/
+#define NC_ICMP6_IN_OCTETS		6	/* åä¿¡ ICMP ãªã¯ãããæ°		*/
+#define NC_ICMP6_SIZE			7	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_ICMP6(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL	net_count_icmp6[NC_ICMP6_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP6 */
+
+#define NET_COUNT_ICMP6(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ICMP6 */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_ND6
+
+#define NC_ND6_DAD_OUT_PACKETS		0	/* éè¤ã¢ãã¬ã¹æ¤åºéä¿¡æ°		*/
+#define NC_ND6_NS_OUT_PACKETS		1	/* è¿é£è¦è«éä¿¡æ°		*/
+#define NC_ND6_NS_IN_PACKETS		2	/* è¿é£è¦è«åä¿¡æ°		*/
+#define NC_ND6_NA_OUT_PACKETS		3	/* è¿é£éç¥éä¿¡æ°		*/
+#define NC_ND6_NA_IN_PACKETS		4	/* è¿é£éç¥åä¿¡æ°		*/
+#define NC_ND6_RS_OUT_PACKETS		5	/* ã«ã¼ã¿è¦è«åºåæ°		*/
+#define NC_ND6_RA_IN_PACKETS		6	/* ã«ã¼ã¿éç¥åä¿¡æ°		*/
+#define NC_ND6_SIZE			7	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_ND6(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL	net_count_nd6[NC_ND6_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
+
+#define NET_COUNT_ND6(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_ND6 */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#ifdef SUPPORT_TCP
+
+/* TCP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_TCP
+
+#define NC_TCP_CONNECTS			0	/* è½åãªã¼ãã³æ°		*/
+#define NC_TCP_ACCEPTS			1	/* ååãªã¼ãã³æ°		*/
+#define NC_TCP_RTT_UPDATES		2	/* RTT æ´æ°æ°			*/
+#define NC_TCP_SEND_RSTS		3	/* éä¿¡ãRST æ°			*/
+#define NC_TCP_SEND_ACKS		4	/* éä¿¡ãACK æ°			*/
+#define NC_TCP_SEND_URG_SEGS		5	/* éä¿¡ãç·æ¥ã»ã°ã¡ã³ãæ°	*/
+#define NC_TCP_SEND_DATA_SEGS		6	/* éä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°	*/
+#define NC_TCP_SEND_REXMIT_SEGS		7	/* åéä¿¡ã»ã°ã¡ã³ãæ°		*/
+#define NC_TCP_SEND_SEGS		8	/* éä¿¡ã»ã°ã¡ã³ãæ°		*/
+#define NC_TCP_SEND_CNTL_SEGS		9	/* éä¿¡å¶å¾¡ã»ã°ã¡ã³ãæ°		*/
+#define NC_TCP_SEND_DATA_OCTETS		10	/* éä¿¡ãã¼ã¿ãªã¯ãããæ°	*/
+#define NC_TCP_FREE_RCV_QUEUE		11	/* åä¿¡ã­ã¥ã¼è§£æ¾æ°		*/
+#define NC_TCP_RECV_DUP_SEGS		12	/* åä¿¡ãå¤éæ°			*/
+#define NC_TCP_RECV_DROP_SEGS		13	/* åä¿¡ãç ´æ£æ°			*/
+#define NC_TCP_RECV_RSTS		14	/* åä¿¡ãRST æ°			*/
+#define NC_TCP_RECV_DUP_ACKS		15	/* åä¿¡ãå¤é ACK æ°		*/
+#define NC_TCP_RECV_ACKS		16	/* åä¿¡ãACK æ°			*/
+#define NC_TCP_RECV_BAD_CKSUMS		17	/* åä¿¡ããã§ãã¯ãµã ä¸æ­£æ°	*/
+#define NC_TCP_RECV_BAD_HEADERS		18	/* åä¿¡ããããä¸æ­£æ°		*/
+#define NC_TCP_RECV_URG_SEGS		19	/* åä¿¡ãç·æ¥ã»ã°ã¡ã³ãæ°	*/
+#define NC_TCP_RECV_DATA_SEGS		20	/* åä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°	*/
+#define NC_TCP_RECV_SEGS		21	/* åä¿¡ã»ã°ã¡ã³ãæ°		*/
+#define NC_TCP_RECV_DATA_OCTETS		22	/* åä¿¡ãã¼ã¿ãªã¯ãããæ°	*/
+#define NC_TCP_RECV_OCTETS		23	/* åä¿¡ãªã¯ãããæ°		*/
+#define NC_TCP_SIZE			24	/* ã«ã¦ã³ã¿æ°			*/
+
+#define NET_COUNT_TCP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT_VAL net_count_tcp[NC_TCP_SIZE];
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_TCP */
+
+#define NET_COUNT_TCP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_TCP */
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+/* UDP */
+
+#if NET_COUNT_ENABLE & PROTO_FLG_UDP
+
+#define NET_COUNT_UDP(v,c)	((v)+=(c))
+
+#ifndef _MACRO_ONLY
+
+extern T_NET_COUNT	net_count_udp;
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#else	/* of #if NET_COUNT_ENABLE & PROTO_FLG_UDP */
+
+#define NET_COUNT_UDP(v,c)
+
+#endif	/* of #if NET_COUNT_ENABLE & PROTO_FLG_UDP */
+
+#endif	/* of #ifdef SUPPORT_UDP */
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+#define NET_COUNT_MIB(v, c)		((v)+=(c))
+
+#else	/* of #ifdef SUPPORT_MIB */
+
+#define NET_COUNT_MIB(v, c)
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#endif	/* of #ifndef _NET_COUNT_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_endian.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_endian.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_endian.h	(revision 317)
@@ -0,0 +1,209 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _NET_ENDIAN_H_
+#define _NET_ENDIAN_H_
+
+/*
+ *  ãã¤ããªã¼ãã®å®ç¾©
+ */
+
+#define _NET_CFG_LITTLE_ENDIAN	1234
+#define _NET_CFG_BIG_ENDIAN	4321
+
+#ifdef TARGET_KERNEL_ASP
+
+#if defined(SIL_ENDIAN_LITTLE)
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
+
+#elif defined(SIL_ENDIAN_BIG)
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
+
+#else	/* of #if defined(SIL_ENDIAN_BIG) */
+
+#error "SIL_ENDIAN expected."
+
+#endif	/* of #if defined(SIL_ENDIAN_BIG) */
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#if SIL_ENDIAN == SIL_ENDIAN_LITTLE
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_LITTLE_ENDIAN
+
+#elif SIL_ENDIAN == SIL_ENDIAN_BIG	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#define _NET_CFG_BYTE_ORDER	_NET_CFG_BIG_ENDIAN
+
+#else	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#error "SIL_ENDIAN expected."
+
+#endif	/* of #if SIL_ENDIAN == SIL_ENDIAN_LITTLE */
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+/*
+ *  ãã¤ããªã¼ãå¤æã®å®ç¾©
+ */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define ntohs(n)		((uint16_t)n)
+#define htons(h)		((uint16_t)h)
+#define ntohl(n)		((uint32_t)n)
+#define htonl(h)		((uint32_t)h)
+
+#define NTOHS(n)
+#define HTONS(h)
+#define NTOHL(n)
+#define HTONL(h)
+
+/*
+ *  æ³¨æ: IPãããä»¥éã¯ã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã¦ããäºã
+ *        åæã¨ãã¦ãããã4 ãã¤ãå¢çã§ã¢ã¯ã»ã¹ãã
+ *        ãã­ã»ããµã§ããããã¯ã¼ã¯å´ã®ãã¼ã¿ãã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³
+ *        ããã¦ããªãå ´åã¯ãntoahlãahtonlãnahcmpl ãä½¿ç¨ãããã¨ã
+ */
+
+#define ntoahs(h,n)		memcpy((void*)&(h),(n),sizeof(uint16_t))
+#define ahtons(n,h)		memcpy((n),(void*)&(h),sizeof(uint16_t))
+#define ntoahl(h,n)		memcpy((void*)&(h),(n),sizeof(uint32_t))
+#define ahtonl(n,h)		memcpy((n),(void*)&(h),sizeof(uint32_t))
+
+#define nahcmpl(n,h)		memcmp((n),(void*)&(h),sizeof(uint32_t))
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#ifndef NET_REV_ENDIAN_HWORD
+
+#define NET_REV_ENDIAN_HWORD(d)	((uint16_t)((((uint16_t)(d)&0xff)<<8)|(((uint16_t)(d)>>8)&0xff)))
+
+#endif	/* of #ifndef NET_REV_ENDIAN_HWORD */
+
+#ifndef NET_REV_ENDIAN_WORD
+
+#define NET_REV_ENDIAN_WORD(d)	((uint32_t)((((uint32_t)(d)&0xff)<<24)|(((uint32_t)(d)&0xff00)<<8)| \
+				            (((uint32_t)(d)>>8)&0xff00)|(((uint32_t)(d)>>24)&0xff)))
+
+#endif	/* of #ifndef NET_REV_ENDIAN_WORD */
+
+#define ntohs(n)		NET_REV_ENDIAN_HWORD(n)
+#define htons(h)		NET_REV_ENDIAN_HWORD(h)
+#define ntohl(n)		NET_REV_ENDIAN_WORD(n)
+#define htonl(h)		NET_REV_ENDIAN_WORD(h)
+
+#define NTOHS(n)		((n)=NET_REV_ENDIAN_HWORD(n))
+#define HTONS(h)		((h)=NET_REV_ENDIAN_HWORD(h))
+#define NTOHL(n)		((n)=NET_REV_ENDIAN_WORD(n))
+#define HTONL(h)		((h)=NET_REV_ENDIAN_WORD(h))
+
+/*
+ *  æ³¨æ: IPãããä»¥éã¯ã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã¦ããäºã
+ *        åæã¨ãã¦ãããã4 ãã¤ãå¢çã§ã¢ã¯ã»ã¹ãã
+ *        ãã­ã»ããµã§ããããã¯ã¼ã¯å´ã®ãã¼ã¿ãã4 ãã¤ãå¢çã«ã¢ã©ã¤ã³
+ *        ããã¦ããªãå ´åã¯ãntoahlãahtonlãnahcmpl ãä½¿ç¨ãããã¨ã
+ */
+
+#ifndef _MACRO_ONLY
+
+extern void rev_memcpy_word  (void *dst, void *src);
+extern void rev_memcpy_hword (void *dst, void *src);
+
+extern int  rev_memcmp_word (void *data1, void *data2);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#define ntoahs(h,n)		rev_memcpy_hword((void*)&(h),(n))
+#define ahtons(n,h)		rev_memcpy_hword((n),(void*)&(h))
+#define ntoahl(h,n)		rev_memcpy_word((void*)&(h),(n))
+#define ahtonl(n,h)		rev_memcpy_word((n),(void*)&(h))
+
+#define nahcmpl(n,h)		rev_memcmp_word((n),(void*)&(h))
+
+#else	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#error "_NET_CFG_BYTE_ORDER expected."
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifndef _NET_ENDIAN_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_jsp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_jsp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_jsp.cfg	(revision 317)
@@ -0,0 +1,173 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSPç¨ æ±ç¨ãããã¯ã¼ã¯ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+
+/*
+ *  å
+±é æ±ç¨ãããã¯ã¼ã¯ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#include "net/net.cfg"
+
+/*
+ * ãããã¯ã¼ã¯ãããã¡
+ */
+
+#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
+CRE_MPF(MPF_NET_BUF_CSEG, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_CSEG,
+		sizeof(T_NET_BUF_CSEG),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
+
+#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
+CRE_MPF(MPF_NET_BUF_64, {
+		TA_TFIFO, NUM_MPF_NET_BUF_64,
+		sizeof(T_NET_BUF_64),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0
+CRE_MPF(MPF_NET_BUF_128, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_128,
+		sizeof(T_NET_BUF_128),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0
+CRE_MPF(MPF_NET_BUF_256, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_256,
+		sizeof(T_NET_BUF_256),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_256) && NUM_MPF_NET_BUF_256 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0
+CRE_MPF(MPF_NET_BUF_512, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_512,
+		sizeof(T_NET_BUF_512),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_512) && NUM_MPF_NET_BUF_512 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0
+CRE_MPF(MPF_NET_BUF_IP_MSS, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IP_MSS,
+		sizeof(T_NET_BUF_IP_MSS),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IP_MSS) && NUM_MPF_NET_BUF_IP_MSS > 0 */
+
+#if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0
+CRE_MPF(MPF_NET_BUF_1024, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_1024,
+		sizeof(T_NET_BUF_1024),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_1024) && NUM_MPF_NET_BUF_1024 > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0
+CRE_MPF(MPF_NET_BUF_IPV6_MMTU, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IPV6_MMTU,
+		sizeof(T_NET_BUF_IPV6_MMTU),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IPV6_MMTU) && NUM_MPF_NET_BUF_IPV6_MMTU > 0 */
+
+#if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0
+CRE_MPF(MPF_NET_BUF_IF_PDU, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF_IF_PDU,
+		sizeof(T_NET_BUF_IF_PDU),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF_IF_PDU) && NUM_MPF_NET_BUF_IF_PDU > 0 */
+
+#if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_REASSM,
+		sizeof(T_NET_BUF6_REASSM),
+		NULL
+		});
+
+#else	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0
+
+CRE_MPF(MPF_NET_BUF_REASSM, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF4_REASSM,
+		sizeof(T_NET_BUF4_REASSM),
+		NULL
+		});
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF4_REASSM) && NUM_MPF_NET_BUF4_REASSM > 0 */
+
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_REASSM) && NUM_MPF_NET_BUF6_REASSM > 0 */
+
+#if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0
+CRE_MPF(MPF_NET_BUF6_65536, {
+		TA_TFIFO,
+		NUM_MPF_NET_BUF6_65536,
+		sizeof(T_NET_BUF6_65536),
+		NULL
+		});
+#endif	/* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
Index: asp3_gr_sakura/trunk/tinet/net/net_rename.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_rename.h	(revision 317)
@@ -0,0 +1,186 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NET_RENAME_H_
+#define _NET_RENAME_H_
+
+/*
+ *  æ±ç¨ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹å
+é¨åã®ãªãã¼ã 
+ */
+
+/* net/ethernet.c */
+
+#define ether_input_task	_tinet_ether_input_task
+#define ether_get_ifnet		_tinet_ether_get_ifnet
+#define ether_in6_resolve_multicast	\
+				_tinet_ether_in6_resolve_multicast
+#define ether_srand		_tinet_ether_srand
+#define ether_output		_tinet_ether_output
+#define	ether_raw_output	_tinet_ether_raw_output
+#define ether_output_task	_tinet_ether_output_task
+
+#define ether_broad_cast_addr	_tinet_ether_broad_cast_addr
+#define ether_ipv4_addr_local	_tinet_ether_ipv4_addr_local
+#define ether_ipv4_addr_local_mask	\
+				_tinet_ether_ipv4_addr_local_mask
+
+#define ether_in6_ifaddr	_tinet_ether_in6_ifaddr
+#define ether_in6_ifaddr_list	_tinet_ether_in6_ifaddr_list
+
+/* net/if.c */
+
+#ifdef SUPPORT_ETHER
+
+#define ifinit			_tinet_ifinit
+#define if_addmulti		_tinet_if_addmulti
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/* net/net_buf.c */
+
+#define tget_net_buf_ex		_tinet_tget_net_buf_ex
+#define tget_net_buf		_tinet_tget_net_buf
+#define rel_net_buf		_tinet_rel_net_buf
+#define rus_net_buf		_tinet_rus_net_buf
+#define net_buf_siz		_tinet_net_buf_siz
+#define net_buf_max_siz		_tinet_net_buf_max_siz
+#define nbuf_get_tbl		_tinet_nbuf_get_tbl
+#define nbuf_get_tbl_size	_tinet_nbuf_get_tbl_size
+
+/* net/net_subr.c */
+
+#define convert_hexdigit	_tinet_convert_hexdigit
+#define net_rand		_tinet_net_rand
+#define net_srand		_tinet_net_srand
+#define rev_memcpy_word		_tinet_rev_memcpy_word
+#define rev_memcmp_word		_tinet_rev_memcmp_word
+
+/* net/net_timer.c */
+
+#define timeout			_tinet_timeout
+#define untimeout		_tinet_untimeout
+#define busy_callout		_tinet_busy_callout
+#define max_busy		_tinet_max_busy
+
+/* route_cfg.c */
+
+#define routing6_tbl		_tinet_routing6_tbl
+#define routing4_tbl		_tinet_routing4_tbl
+
+#ifdef SUPPORT_PPP
+
+/* net/ppp.c */
+
+#define ppp_output		_tinet_ppp_output
+#define ppp_cp_output		_tinet_ppp_cp_output
+#define ppp_phase		_tinet_ppp_phase
+#define protocols		_tinet_protocols
+
+/* net/ppp_hdlc.c */
+
+#define HDLC_dummy_read		_tinet_HDLC_dummy_read
+#define HDLC_read		_tinet_HDLC_read
+#define HDLC_write		_tinet_HDLC_write
+#define remote_ACCM		_tinet_remote_ACCM
+
+/* net/ppp_lcp.c */
+
+#define lcp_close		_tinet_lcp_close
+#define lcp_open		_tinet_lcp_open
+#define lcp_lowerdown		_tinet_lcp_lowerdown
+#define lcp_sprotrej		_tinet_lcp_sprotrej
+#define lcp_lowerup		_tinet_lcp_lowerup
+#define lcp_finished		_tinet_lcp_finished
+#define lcp_down		_tinet_lcp_down
+#define lcp_callbacks		_tinet_lcp_callbacks
+#define lcp_fsm			_tinet_lcp_fsm
+#define lcp_protent		_tinet_lcp_protent
+#define lcp_local_ack_cfg	_tinet_lcp_local_ack_cfg
+#define lcp_remote_ack_cfg	_tinet_lcp_remote_ack_cfg
+
+/* net/ppp_fsm.c */
+
+#define fsm_init		_tinet_fsm_init
+#define fsm_open		_tinet_fsm_open
+#define fsm_input		_tinet_fsm_input
+#define fsm_protreject		_tinet_fsm_protreject
+#define fsm_lowerdown		_tinet_fsm_lowerdown
+#define fsm_close		_tinet_fsm_close
+#define fsm_lowerup		_tinet_fsm_lowerup
+#define ppp_open_mode		_tinet_ppp_open_mode
+
+/* net/ppp_auth.c */
+
+#define auth_reset		_tinet_auth_reset
+#define link_terminated		_tinet_link_terminated
+#define link_established	_tinet_link_established
+#define link_required		_tinet_link_required
+#define network_phase		_tinet_network_phase
+#define link_down		_tinet_link_down
+
+/* net/ppp_ipcp.c */
+
+#define wait_ipcp		_tinet_wait_ipcp
+#define ppp_get_ifnet		_tinet_ppp_get_ifnet
+#define ipcp_protent		_tinet_ipcp_protent
+#define ipcp_callbacks		_tinet_ipcp_callbacks
+#define ipcp_fsm		_tinet_ipcp_fsm
+#define ipcp_remote_ack_cfg	_tinet_ipcp_remote_ack_cfg
+#define ipcp_local_ack_cfg	_tinet_ipcp_local_ack_cfg
+
+/* net/ppp_upap.c */
+
+#define upap_auth_client	_tinet_upap_auth_client
+#define upap_auth_server	_tinet_upap_auth_server
+#define pap_protent		_tinet_pap_protent
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_LOOP
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+#endif	/* of #ifndef _NET_RENAME_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_subr.c	(revision 317)
@@ -0,0 +1,257 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯æ±ç¨ãµãã¼ãã«ã¼ãã³
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+
+/*
+ *  å¤æ°
+ */
+
+static uint32_t next = ULONG_C(1);
+
+/*
+ *  net_rand -- ä¹±æ°ãè¿ãã
+ */
+
+uint32_t
+net_rand (void)
+{
+	next = (next * 99991 + 12345) & ULONG_C(0x7fffffff);
+	return next;
+	}
+
+/*
+ *  srand -- ä¹±æ°ãåæåããã
+ */
+
+void
+net_srand (uint32_t seed)
+{
+	SYSTIM now;
+
+	syscall(get_tim(&now));
+	next += now + seed + IF_SRAND();
+	}
+
+/*
+ *  convert_hexdigit -- 16é²æ°âæå­åå¤æ
+ */
+
+int_t
+convert_hexdigit (char *buf, uint_t val, int_t radix, int_t width, char padchar)
+{
+	static const char radhex[] = "0123456789abcdef";
+
+	char	digits[11], *start;
+	int_t	ix, pad;
+
+	ix = 0;
+	start = buf;
+	do {
+		digits[ix ++] = radhex[(val % radix) & 0x0f];
+		val /= radix;
+		} while (val != 0);
+	for (pad = ix; pad < width; pad ++)
+		*buf ++ = padchar;
+	while (ix -- > 0)
+		*buf ++ = digits[ix];
+	*buf = '\0';
+	return (int_t)(buf - start);
+	}
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  mac2str -- MAC ã¢ãã¬ã¹ãæå­åã«å¤æããã
+ */
+
+char *
+mac2str (char *buf, uint8_t *macaddr)
+{
+	static char	addr_sbuf[NUM_MACADDR_STR_BUFF][sizeof("00:00:00:00:00:00")];
+	static int_t	bix = NUM_MACADDR_STR_BUFF;
+
+	char *start;
+
+	if (buf == NULL) {
+		syscall(wai_sem(SEM_MAC2STR_BUFF_LOCK));
+		buf = addr_sbuf[-- bix];
+		if (bix <= 0)
+			bix = NUM_MACADDR_STR_BUFF;
+		syscall(sig_sem(SEM_MAC2STR_BUFF_LOCK));
+		}
+
+	start = buf;
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*(buf ++) = ':';
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*(buf ++) = ':';
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*(buf ++) = ':';
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*(buf ++) = ':';
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*(buf ++) = ':';
+	buf += convert_hexdigit(buf, (uint_t)(*macaddr ++), 16, 2, '0');
+	*buf = '\0';
+	return start;
+	}
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+/*
+ *  rev_memcpy_hword -- åè»¢ã¡ã¢ãªã³ãã¼ï¼2 ãã¤ãï¼
+ *
+ *    ãã¤ãåä½ã«ã¢ã¯ã»ã¹ããäºã«ããã
+ *    å¢çã¸ã®ã¢ã©ã¤ã³ã®åé¡ãè§£æ±ºããã
+ */
+
+void
+rev_memcpy_hword (void *dst, void *src)
+{
+	*((uint8_t*)dst    ) = *((uint8_t*)src + 1);
+	*((uint8_t*)dst + 1) = *((uint8_t*)src    );
+	}
+
+/*
+ *  rev_memcpy_word -- åè»¢ã¡ã¢ãªã³ãã¼ï¼4 ãã¤ãï¼
+ *
+ *    ãã¤ãåä½ã«ã¢ã¯ã»ã¹ããäºã«ããã
+ *    å¢çã¸ã®ã¢ã©ã¤ã³ã®åé¡ãè§£æ±ºããã
+ */
+
+void
+rev_memcpy_word (void *dst, void *src)
+{
+	*((uint8_t*)dst    ) = *((uint8_t*)src + 3);
+	*((uint8_t*)dst + 1) = *((uint8_t*)src + 2);
+	*((uint8_t*)dst + 2) = *((uint8_t*)src + 1);
+	*((uint8_t*)dst + 3) = *((uint8_t*)src    );
+	}
+
+/*
+ *  rev_memcmp_word -- åè»¢ã¡ã¢ãªæ¯è¼ï¼4 ãã¤ãï¼
+ *
+ *    ãã¤ãåä½ã«ã¢ã¯ã»ã¹ããäºã«ããã
+ *    å¢çã¸ã®ã¢ã©ã¤ã³ã®åé¡ãè§£æ±ºããã
+ */
+
+int_t
+rev_memcmp_word (void *data1, void *data2)
+{
+	int_t	ix, diff;
+
+	for (ix = sizeof(uint32_t); ix -- > 0; ) {
+		diff = *((uint8_t*)data1 + ix) -  *((uint8_t*)data2 + (3 - ix));
+		if (diff != 0)
+			return diff;
+		}
+	return 0;
+	}
+
+#endif	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN */
Index: asp3_gr_sakura/trunk/tinet/net/net_timer.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_timer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_timer.c	(revision 317)
@@ -0,0 +1,257 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+/*
+ *  å¤æ°
+ */
+
+static T_NET_CALLOUT callout[NUM_NET_CALLOUT];
+
+/*
+ *  å¼åºãã¨ã³ããªç»é²
+ */
+
+void
+timeout (callout_func func, void *arg, RELTIM timeout)
+{
+	int_t ix;
+
+	/* å¼åºãã¨ã³ããªãç²å¾ãã */
+	syscall(wai_sem(SEM_CALL_OUT_LOCK));
+	for (ix = NUM_NET_CALLOUT; callout[-- ix].func != NULL; )
+		if (ix == 0) {
+			syslog(LOG_WARNING, "[NET] callout busy, size=%d.", NUM_NET_CALLOUT);
+			syscall(sig_sem(SEM_CALL_OUT_LOCK));
+			return;
+			}
+
+	/* å¼åºãã¨ã³ããªãè¨­å®ãã */
+	callout[ix].func	= func;
+	callout[ix].arg		= arg;
+	callout[ix].timeout	= timeout;
+	syscall(sig_sem(SEM_CALL_OUT_LOCK));
+	}
+
+/*
+ *  å¼åºãã¨ã³ããªåé¤
+ */
+
+void
+untimeout (callout_func func, void *arg)
+{
+	int_t ix;
+
+	/* ã¨ã³ããªãæ¢ã */
+	for (ix = NUM_NET_CALLOUT; ix -- > 0; ) {
+		syscall(wai_sem(SEM_CALL_OUT_LOCK));
+		if (callout[ix].func == func && callout[ix].arg == arg && callout[ix].timeout > 0) {
+			callout[ix].func = NULL;
+			syscall(sig_sem(SEM_CALL_OUT_LOCK));
+			break;
+			}
+		syscall(sig_sem(SEM_CALL_OUT_LOCK));
+		}
+	}
+
+/*
+ *  ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯
+ *
+ *    æ³¨æ: ã¿ã¹ã¯ã³ã³ãã­ã¹ãã§å®è¡ããå¿
+è¦ãããããï¼
+ *          å¨æãã³ãã©ã¯ä½¿ç¨ã§ããªãã
+ */
+
+static char const tinet_banner[] =
+"\n"
+"TINET %d.%d.%d (" __DATE__ ", " __TIME__ ")\n"
+"Copyright (C) 2001-2012 by Dep. of Computer Science and Engineering\n"
+"                    Tomakomai National College of Technology, JAPAN\n";
+
+void
+net_timer_task(intptr_t exinf)
+{
+	ID		tskid;
+	int_t		ix;
+	callout_func	func;
+	void 		*arg;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, tinet_banner,
+	       (TINET_PRVER   >> 12) & UINT_C(0x0f),
+	       (TINET_PRVER   >>  4) & UINT_C(0x0f),
+	        TINET_PRVER          & UINT_C(0x0f));
+	syslog(LOG_NOTICE, "[NET/TIMER:%d] started.", tskid);
+
+	/* IP ãåæåããã*/
+
+#if defined(_IP6_CFG)
+	ip6_init();
+#endif
+
+#if defined(_IP4_CFG)
+	ip_init();
+#endif
+
+#ifdef SUPPORT_TCP
+
+	/* TCP åºåã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(TCP_OUTPUT_TASK));
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#if defined(SUPPORT_UDP) && defined(UDP_CFG_NON_BLOCKING)
+
+	/* UDP åºåã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(UDP_OUTPUT_TASK));
+
+#endif	/* of #if defined(SUPPORT_UDP) && defined(UDP_CFG_NON_BLOCKING) */
+
+	while (true) {
+		/* ã¿ã¤ã ã¢ã¦ãããã¨ã³ããªãå¼åºãã*/
+		syscall(wai_sem(SEM_CALL_OUT_TIMEOUT));
+		for (ix = NUM_NET_CALLOUT; ix -- > 0; ) {
+			syscall(wai_sem(SEM_CALL_OUT_LOCK));
+			if (callout[ix].func != NULL && callout[ix].timeout == 0) {
+				func = callout[ix].func;
+				arg  = callout[ix].arg;
+				callout[ix].func = NULL;
+				syscall(sig_sem(SEM_CALL_OUT_LOCK));
+				(func)(arg);
+				}
+			else
+				syscall(sig_sem(SEM_CALL_OUT_LOCK));
+			}
+		}
+	}
+
+/*
+ *  ãããã¯ã¼ã¯ã¿ã¤ããã³ãã©
+ *
+ *    NET_TIMER_CYCLE (100ms) æ¯ã«å¼åºãããã
+ */
+
+void
+net_timer_handler(intptr_t exinf)
+{
+	int_t	ix, count = 0;
+
+	for (ix = NUM_NET_CALLOUT; ix -- > 0; ) {
+		if (callout[ix].func != NULL && callout[ix].timeout > 0) {
+			callout[ix].timeout --;
+			if (callout[ix].timeout == 0)
+				count ++;
+			}
+		}
+
+	if (count)
+		syscall(isig_sem(SEM_CALL_OUT_TIMEOUT));
+	}
Index: asp3_gr_sakura/trunk/tinet/net/net_timer.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_timer.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_timer.h	(revision 317)
@@ -0,0 +1,130 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _NET_TIMER_H_
+#define _NET_TIMER_H_
+
+#include <tinet_kernel_defs.h>	/* ã«ã¼ãã«ã«é¢ããäºææ§å®ç¾©ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããã*/
+
+/*
+ *  TOPPERS/JSP ã«ã¼ãã«ãã·ã¹ãã æå» (SYSTIM) ã®å¨æ³¢æ°
+ */
+
+#define SYSTIM_HZ		ULONG_C(1000000)	/* [us]					*/
+
+/*
+ *  ãããã¯ã¼ã¯ã¿ã¤ãã®å®ç¾©
+ */
+
+#define NET_TIMER_CYCLE		ULONG_C(100000)	/* [us]ãfast timeout ä½¿ç¨æã®åä½å¨æ	*/
+						/* ã¿ã¤ãã®å¨æ³¢æ°			*/
+#define NET_TIMER_HZ		(SYSTIM_HZ/NET_TIMER_CYCLE)
+
+#ifdef _IP6_CFG
+#define NUM_NET_CALLOUT		12		/* ã¿ã¤ã ã¢ã¦ãå¼åºãæ°ã10 ä»¥ä¸	*/
+#else
+#define NUM_NET_CALLOUT		10		/* ã¿ã¤ã ã¢ã¦ãå¼åºãæ°ã10 ä»¥ä¸	*/
+#endif
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå¼åºãã¨ã³ããª
+ */
+
+typedef void	(*callout_func)(void*);
+
+typedef struct t_net_callout {
+	callout_func	func;		/* å¼åºãé¢æ°		*/
+	void		*arg;		/* é¢æ°ã¸ã®å¼æ°		*/
+	RELTIM		timeout;	/* ã¿ã¤ã ã¢ã¦ã		*/
+	} T_NET_CALLOUT;
+
+/*
+ *  é¢æ°
+ */
+
+extern void timeout (callout_func func, void *arg, RELTIM timeout);
+extern void untimeout (callout_func func, void *arg);
+
+/*
+ *  ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ã¨å¨æãã³ãã©
+ */
+
+extern void net_timer_task(intptr_t exinf);
+extern void net_timer_handler(intptr_t exinf);
+
+#endif	/* of #ifndef _NET_TIMER_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/net_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/net_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/net_var.h	(revision 317)
@@ -0,0 +1,95 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _NET_VAR_H_
+#define _NET_VAR_H_
+
+/*
+ *  é¢æ°
+ */
+
+extern int_t convert_hexdigit (char *buf, uint_t val, int_t radix, int_t width, char padchar);
+
+/*
+ *  é¢æ°
+ */
+
+extern uint32_t net_rand (void);
+extern void net_srand (uint32_t seed);
+
+#endif	/* of #ifndef _NET_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp.c	(revision 317)
@@ -0,0 +1,461 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* 
+ *  PPP å¦çã¿ã¹ã¯ã®æ¬ä½
+ */
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_ipv6cp.h>
+#include <net/ppp_ipcp.h>
+#include <net/ppp_ccp.h>
+#include <net/ppp_upap.h>
+#include <net/ppp_modem.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+uint8_t	ppp_phase = PPP_PHASE_INITIALIZE;	/* ãªã³ã¯ã®ç¶æ
+		*/
+
+/*
+ *  ãã­ãã³ã«è¡¨
+ */
+
+T_PPP_PROTENT *protocols[] = {
+	&lcp_protent,
+
+#ifdef _IP6_CFG
+	&ipv6cp_protent,
+#endif	/* of #ifdef _IP6_CFG */
+
+#ifdef _IP4_CFG
+	&ipcp_protent,
+#endif	/* of #ifdef _IP4_CFG */
+
+#ifdef SUPPORT_CCP
+	&ccp_protent,
+#endif	/* of #ifdef SUPPORT_CCP */
+
+#ifdef LCP_CFG_PAP
+	&pap_protent,
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_CHAP
+	&chap_protent,
+#endif	/* of #ifdef LCP_CFG_CHAP */
+
+	NULL
+	};
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef PPP_IDLE_TIMEOUT
+
+static bool_t idle = false;
+
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+/*
+ *  é¢æ°
+ */
+
+static void parse_input (T_NET_BUF *input);
+
+#ifdef PPP_IDLE_TIMEOUT
+
+static void idle_timeout (void *arg);
+
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+/*
+ *  PPP å
+¥åã®è§£æ
+ */
+
+static void
+parse_input(T_NET_BUF *input)
+{
+	T_PPP_PROTENT	*entry;
+	int_t		ix;
+	uint16_t	proto;
+
+	NET_COUNT_PPP(net_count_ppp.in_octets,  input->len);
+	NET_COUNT_PPP(net_count_ppp.in_packets, 1);
+
+	/* ãã¬ã¼ã é·ããã§ãã¯ãã */
+	if (input->len < sizeof(T_PPP_HDR)) {	/* FreeBSD ã§ã¯ PPP_HDRLEN ã¯ 4 */
+		syslog(LOG_NOTICE, "[PPP] recv short frame.");
+		goto buf_rel;
+		}
+
+	proto = ntohs(*GET_PPP_HDR(input));
+
+	/* ãã­ãã³ã«ã LCP ä»¥å¤ã§ãLCP ããªã¼ãã³ããã¦ããªããã°ã¨ã©ã¼ */
+	if (proto != PPP_LCP && lcp_fsm.state != PPP_FSM_OPENED) {
+		syslog(LOG_NOTICE, "[PPP] LCP not open.");
+		goto buf_rel;
+		}
+
+	/* ãªã³ã¯ãèªè¨¼ç¶æ
+ä»¥åã¯ãLCPãLQRãPAPãCHAP ã®ã¿åãä»ãã */
+	if (ppp_phase <= PPP_PHASE_AUTHENTICATE &&
+	    !(proto == PPP_LCP || proto == PPP_LQR ||
+	      proto == PPP_PAP || proto == PPP_CHAP)) {
+		syslog(LOG_NOTICE, "[PPP] disc proto: 0x%04x, phase: %d.", proto, ppp_phase);
+		goto buf_rel;
+		}
+
+	/* ä¸ä½ãã­ãã³ã«ã®å
+¥åé¢æ°ãå¼åºã */
+	for (ix = 0; (entry = protocols[ix]) != NULL; ix ++) {
+		if (entry->proto == proto && entry->input != NULL) {
+			(*entry->input)(input);
+			syscall(rel_net_buf(input));
+			return;
+			}
+		if ((entry->proto & ~0x8000) == proto && entry->datainput != NULL) {
+			(*entry->datainput)(input);
+			return;
+			}
+		}
+
+	syslog(LOG_INFO, "[PPP] unexp proto: 0x%04x.", proto);
+	lcp_sprotrej(input);
+
+buf_rel:
+	NET_COUNT_PPP(net_count_ppp.in_err_packets, 1);
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  ppp_output -- PPP ã¤ã³ã¿ãã§ã¼ã¹ã®åºåé¢æ°
+ */
+
+ER
+ppp_output (T_NET_BUF *output, TMO tmout)
+{
+	ER error = E_OK;
+
+#ifdef PPP_CFG_MODEM
+
+#if 0	/* ä¿ç */
+	/* ã¢ãã ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+	if ((error = wait_modem()) != E_OK)
+		goto buf_ret;
+#endif
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+#ifdef _IP6_CFG
+	/* IPV6CP ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+	if ((error = wait_ipv6cp()) != E_OK)
+		goto buf_ret;
+#endif	/* of #ifdef _IP6_CFG */
+
+#ifdef _IP4_CFG
+	/* IPCP ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+	if ((error = wait_ipcp()) != E_OK)
+		goto buf_ret;
+#endif	/* of #ifdef _IP4_CFG */
+
+#ifdef _IP4_CFG
+	/* IPCP ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+	if ((error = wait_ipcp()) != E_OK)
+		goto buf_ret;
+#endif	/* of #ifdef _IP4_CFG */
+
+#ifdef PPP_IDLE_TIMEOUT
+	wai_sem(SEM_IDLE_TIMEOUT);
+	if (idle) {
+		untimeout((FP)idle_timeout, NULL);
+		idle = false;
+		}
+	sig_sem(SEM_IDLE_TIMEOUT);
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+	/* PPP åºåã­ã¥ã¼ã«æå
+¥ããã*/
+	if ((error = tsnd_dtq(DTQ_PPP_OUTPUT, output, tmout)) != E_OK)
+		goto buf_ret;
+
+#ifdef PPP_IDLE_TIMEOUT
+	wai_sem(SEM_IDLE_TIMEOUT);
+	if (!idle && ppp_phase == PPP_PHASE_NETWORK) {
+		timeout((FP)idle_timeout, NULL, PPP_IDLE_TIMEOUT);
+		idle = true;
+		}
+	sig_sem(SEM_IDLE_TIMEOUT);
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+	return error;
+
+buf_ret:
+	syscall(rel_net_buf(output));
+	NET_COUNT_PPP(net_count_ppp.out_err_packets, 1);
+	return error;
+	}
+
+/*
+ *  ppp_cp_output -- CP ãã¬ã¼ã ã®éä¿¡
+ */
+
+void
+ppp_cp_output (uint8_t code, uint8_t id, T_NET_BUF *output)
+{
+	T_PPP_CP_HDR	*cph;
+
+	/* CP ããããè¨­å®ãã */
+	cph = GET_PPP_CP_HDR(output);
+	cph->code = code;
+	cph->id   = id;
+	cph->len  = htons(output->len - sizeof(T_PPP_HDR));
+
+	/* PPP åºåã­ã¥ã¼ã«æå
+¥ããã*/
+	if (snd_dtq(DTQ_PPP_OUTPUT, output) != E_OK) {
+		syscall(rel_net_buf(output));
+		NET_COUNT_PPP(net_count_ppp.out_err_packets, 1);
+		}
+	}
+
+/*
+ *  PPP å
+¥åã¿ã¹ã¯
+ */
+
+void
+ppp_input_task(intptr_t exinf)
+{
+	T_NET_BUF	*input;
+	T_PPP_PROTENT	*proto;
+	ID		tskid;
+	int_t		ix;
+	uint8_t		rcount = 0;
+
+	/* ãã¼ããåæè¨­å®ãã */
+	syscall(serial_opn_por(HDLC_PORTID));
+	syscall(serial_ctl_por(HDLC_PORTID, IOCTL_FCSND | IOCTL_FCRCV));
+
+	get_tid(&tskid);
+
+#ifdef PPP_CFG_MODEM
+
+	init_modem();
+	syslog(LOG_NOTICE, "[PPP INPUT:%d] started with modem on port %d.", tskid, HDLC_PORTID);
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+	syslog(LOG_NOTICE, "[PPP INPUT:%d] started on port %d.", tskid, HDLC_PORTID);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+	/* ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(NET_TIMER_TASK));
+
+	/* ä¸ä½ãã­ãã³ã«ãåæåãã */
+	for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
+		if (proto->init != NULL)
+			(*proto->init)();
+
+	lcp_lowerup();
+	lcp_open(PPP_OPEN_PASSIVE);
+
+	/* PPP åºåã¿ã¹ã¯ãèµ·åãã */
+	syscall(act_tsk(PPP_OUTPUT_TASK));
+
+	/* ä¹±æ°çæãåæåããã*/
+	net_srand(0);
+
+	while (true) {
+		if (tget_net_buf(&input, IF_PDU_SIZE, TMO_PPP_GET_NET_BUF) == E_OK) {
+			while (HDLC_read(input, IF_PDU_SIZE) != E_OK)
+				;
+			if (input->len > 0) {
+
+				/* ä¹±æ°çæãåæåããã*/
+				if (rcount == 0)
+					net_srand(input->len);
+				rcount ++;
+
+#ifdef PPP_IDLE_TIMEOUT
+				wai_sem(SEM_IDLE_TIMEOUT);
+				if (idle && ntohs(*GET_PPP_HDR(input)) != PPP_LCP) {
+					untimeout((FP)idle_timeout, NULL);
+					idle = false;
+					}
+				sig_sem(SEM_IDLE_TIMEOUT);
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+				parse_input(input);
+				}
+			else
+				syscall(rel_net_buf(input));
+
+#ifdef PPP_IDLE_TIMEOUT
+			wai_sem(SEM_IDLE_TIMEOUT);
+			if (!idle && ppp_phase == PPP_PHASE_NETWORK) {
+				timeout((FP)idle_timeout, NULL, PPP_IDLE_TIMEOUT);
+				idle = true;
+				}
+			else if (idle && ppp_phase != PPP_PHASE_NETWORK) {
+				untimeout((FP)idle_timeout, NULL);
+				idle = false;
+				}
+			sig_sem(SEM_IDLE_TIMEOUT);
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+			}
+		else {
+			HDLC_dummy_read();
+			NET_COUNT_PPP(net_count_ppp.in_err_packets, 1);
+			NET_COUNT_PPP(net_count_ppp_no_bufs, 1);
+			}
+		}
+	}
+
+/*
+ *  PPP åºåã¿ã¹ã¯
+ */
+
+void
+ppp_output_task(intptr_t exinf)
+{
+	T_NET_BUF	*output;
+	ID		tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[PPP OUTPUT:%d] started.", tskid);
+
+	while (true) {
+		while (rcv_dtq(DTQ_PPP_OUTPUT, (intptr_t*)&output) == E_OK) {
+			NET_COUNT_PPP(net_count_ppp.out_octets,  output->len);
+			NET_COUNT_PPP(net_count_ppp.out_packets, 1);
+			syscall(HDLC_write(output));
+			syscall(rel_net_buf(output));
+			}
+		}
+	}
+
+#ifdef PPP_IDLE_TIMEOUT
+
+/*
+ *  ã¢ã¤ãã«ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+idle_timeout (void *arg)
+{
+	syslog(LOG_NOTICE, "[PPP] idel %d [s], disconnecting.", (uint16_t)(PPP_IDLE_TIMEOUT / NET_TIMER_HZ));
+	lcp_close();
+	}
+
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp.cfg	(revision 317)
@@ -0,0 +1,86 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  PPP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef SUPPORT_PPP
+
+CRE_TSK(PPP_OUTPUT_TASK, {
+	TA_HLNG,
+	0,
+	ppp_output_task,
+	PPP_OUTPUT_PRIORITY,
+	PPP_OUTPUT_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(PPP_INPUT_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	ppp_input_task,
+	PPP_INPUT_PRIORITY,
+	PPP_INPUT_STACK_SIZE,
+	NULL
+	});
+
+CRE_DTQ(DTQ_PPP_OUTPUT,   { TA_TFIFO, NUM_DTQ_PPP_OUTPUT,  NULL });
+
+CRE_SEM(SEM_MODEM_READY,  { TA_TPRI, 0, 1 });
+
+#if defined(_IP6_CFG)
+CRE_SEM(SEM_IPV6CP_READY, { TA_TPRI, 0, 1 });
+#endif
+
+#if defined(_IP4_CFG)
+CRE_SEM(SEM_IPCP_READY,   { TA_TPRI, 0, 1 });
+#endif
+
+#ifdef PPP_IDLE_TIMEOUT
+CRE_SEM(SEM_IDLE_TIMEOUT, { TA_TPRI, 1, 1 });
+#endif	/* of #ifdef PPP_IDLE_TIMEOUT */
+
+#endif	/* of #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp.h	(revision 317)
@@ -0,0 +1,152 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef _PPP_H_
+#define _PPP_H_
+
+/*
+ *  PPP ãããã®ãã­ãã³ã«ãã£ã¼ã«ãã®å¤
+ */
+
+#define PPP_IP		UINT_C(0x0021)		/* IPv4		*/
+#define PPP_IPV6	UINT_C(0x0057)		/* IPv6		*/
+
+#define PPP_IPCP	UINT_C(0x8021)		/* IPCP		*/
+#define PPP_IPV6CP	UINT_C(0x8057)		/* IPV6CP	*/
+#define PPP_CCP		UINT_C(0x80fd)		/* CCP		*/
+
+#define PPP_LCP		UINT_C(0xc021)		/* LCP		*/
+#define PPP_PAP		UINT_C(0xc023)		/* PAP		*/
+#define PPP_LQR		UINT_C(0xc025)		/* LQR		*/
+#define PPP_CHAP	UINT_C(0xc223)		/* CHAP		*/
+
+#define GET_PPP_HDR(nbuf)	((T_PPP_HDR*)((nbuf)->buf))
+
+/*
+ *  ãªã³ã¯ã®ç¶æ
+
+ */
+
+#define PPP_PHASE_DEAD		0
+#define PPP_PHASE_INITIALIZE	1
+#define PPP_PHASE_DORMANT	2
+#define PPP_PHASE_ESTABLISH	3
+#define PPP_PHASE_AUTHENTICATE	4
+#define PPP_PHASE_CALLBACK	5
+#define PPP_PHASE_NETWORK	6
+#define PPP_PHASE_TERMINATE	7
+#define PPP_PHASE_HOLDOFF	8
+
+/*
+ *  PPP ãªã³ã¯å¶å¾¡ (CP) ãããæ§é ä½
+ */
+
+typedef struct t_ppp_cp_hdr {
+	uint8_t		code;		/* å¶å¾¡ã³ã¼ã	*/
+	uint8_t		id;		/* è­å¥å­	*/
+	uint16_t	len;		/* é·ã		*/
+	} T_PPP_CP_HDR;
+
+#define GET_PPP_CP_HDR(nbuf)	((T_PPP_CP_HDR*)((nbuf)->buf + sizeof(T_PPP_HDR)))
+
+/*
+ *  PPP ãªã³ã¯å¶å¾¡ (CP) ã®å¶å¾¡ã³ã¼ã
+ */
+
+#define PPP_VENDER		UINT_C(0)	/* Vender Specific		*/
+#define PPP_CONFREQ		UINT_C(1)	/* Configuration Request	*/
+#define PPP_CONFACK		UINT_C(2)	/* Configuration ACK		*/
+#define PPP_CONFNAK		UINT_C(3)	/* Configuration NAK		*/
+#define PPP_CONFREJ		UINT_C(4)	/* Configuration Reject		*/
+#define PPP_TERMREQ		UINT_C(5)	/* Termination Request		*/
+#define PPP_TERMACK		UINT_C(6)	/* Termination ACK		*/
+#define PPP_CODEREJ		UINT_C(7)	/* Code Reject			*/
+
+/*
+ * æ§ææ
+å ± (CI) ããã
+ */
+
+typedef struct t_ppp_ci_hdr {
+	uint8_t		type;		/* CI ã®å	*/
+	uint8_t		len;		/* é·ã		*/
+	} T_PPP_CI_HDR;
+
+#endif	/* of #ifndef _PPP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_auth.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_auth.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_auth.c	(revision 317)
@@ -0,0 +1,294 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * auth.c - PPP authentication and phase control.
+ *
+ * Copyright (c) 1993 The Australian National University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Australian National University.  The name of the University
+ * may not be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *			PPP Secret Key Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/auth.c,v 1.50 1999/12/27 11:43:30 brian Exp $
+ *
+ *	TODO:
+ *		o Implement check against with registered IP addresses.
+ */
+
+#include <s_services.h>
+#include <t_services.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_auth.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_upap.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  å®æ°
+ */
+
+#define PAP_PEND_SERVER		UINT_C(0x01)
+#define PAP_PEND_CLIENT		UINT_C(0x02)
+#define CHAP_PEND_SERVER	UINT_C(0x04)
+#define CHAP_PEND_CLIENT	UINT_C(0x08)
+
+/*
+ *  network_phase -- ã³ãã¯ã·ã§ã³ç¢ºç«
+ */
+
+void
+network_phase (void)
+{
+	int_t		num, ix;
+	T_PPP_PROTENT	*proto;
+
+	ppp_phase = PPP_PHASE_NETWORK;
+
+	/* ä¸ä½ãã­ãã³ã«ããªã¼ãã³ãã */
+	num = 0;
+	for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
+#if 0	/* ä¿çãåé¤ç¦æ­¢ */
+		if (proto->proto < 0xc000 && proto->open != NULL) {
+#else	/* of #if 0 */
+		if (proto->open != NULL) {
+#endif	/* of #if 0 */
+			(*proto->open)();
+			if (proto->proto != PPP_CCP)
+				num ++;
+			}
+
+	if (num == 0)
+		/* ä¸ä½ãã­ãã³ã«ããªã */
+		lcp_close();
+	else
+		syslog(LOG_NOTICE, "[PPP] up.");
+	}
+
+/*
+ *  link_required -- ãªã³ã¯ãéè¨­ããã
+ */
+
+void
+link_required (void)
+{
+	}
+
+/*
+ *  link_terminated -- ã­ã°ã¢ã¦ããã¦ããªã³ã¯ãåæ­ããã
+ */
+
+void
+link_terminated (void)
+{
+	ppp_phase     = PPP_PHASE_DEAD;
+	ppp_open_mode = PPP_OPEN_PASSIVE;
+	syslog(LOG_NOTICE, "[PPP] down.");
+	}
+
+/*
+ *  link_down -- ãªã³ã¯ãè§£æ¾ããã
+ */
+
+void
+link_down (void)
+{
+	int_t		ix;
+	T_PPP_PROTENT	*proto;
+
+	/* ä¸ä½ãã­ãã³ã«ãè§£æ¾ãã */
+	for (ix = 0; (proto = protocols[ix]) != NULL; ix ++) {
+		if (proto->proto != PPP_LCP && proto->lowerdown != NULL)
+			(*proto->lowerdown)();
+		if (proto->proto < 0xc000 && proto->close != NULL)
+			(*proto->close)();
+		}
+
+	if (ppp_phase != PPP_PHASE_DEAD)
+		ppp_phase = PPP_PHASE_TERMINATE;
+	}
+
+/*
+ *  link_established -- ãªã³ã¯ã®æ¥ç¶ãç¢ºç«ããã
+ */
+
+void
+link_established (void)
+{
+	int_t		ix;
+	T_PPP_PROTENT	*proto;
+
+#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
+
+	int		auth;
+
+#endif	/* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
+
+	/* ä¸ä½ãã­ãã³ã«ãèµ·åãã */
+	for (ix = 0; (proto = protocols[ix]) != NULL; ix ++)
+		if (proto->lowerup != NULL)
+			(*proto->lowerup)();
+
+	/* èªè¨¼ãªãã·ã§ã³ãç¢ºèªããããæªå®è£
+ã*/
+
+	ppp_phase = PPP_PHASE_AUTHENTICATE;
+
+#if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP)
+
+	auth = 0;
+
+#ifdef AUTH_CFG_SERVER
+
+#if defined(LCP_CFG_CHAP)
+
+	if (lcp_local_ack_cfg.options & LCP_CFG_CHAP) {
+		chap_auth_server();
+		auth |= CHAP_PEND_SERVER;
+		}
+
+#endif	/* of #if defined(LCP_CFG_CHAP) */
+
+#if defined(LCP_CFG_PAP)
+	
+	if (lcp_local_ack_cfg.options & LCP_CFG_PAP) {
+		upap_auth_server();
+		auth |= PAP_PEND_SERVER;
+		}
+
+#endif	/* of #if defined(LCP_CFG_PAP) */
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+#ifdef AUTH_CFG_CLIENT
+
+#if defined(LCP_CFG_PAP)
+	
+	if (lcp_remote_ack_cfg.options & LCP_CFG_PAP) {
+		upap_auth_client();
+		auth |= PAP_PEND_CLIENT;
+		}
+
+#endif	/* of #if defined(LCP_CFG_PAP) */
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+	if (auth == 0)
+		network_phase();
+
+#else	/* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
+
+	network_phase();
+
+#endif	/* of #if defined(LCP_CFG_CHAP) || defined(LCP_CFG_PAP) */
+
+	}
+
+/*
+ *  auth_reset -- èªè¨¼ãªãã·ã§ã³ãåç¢ºèªããã
+ */
+
+void
+auth_reset (void)
+{
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_auth.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_auth.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_auth.h	(revision 317)
@@ -0,0 +1,86 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/auth.h,v 1.18 1999/08/28 01:18:16 peter Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_AUTH_H_
+#define _PPP_AUTH_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+extern void link_required (void);
+extern void link_established (void);
+extern void link_terminated (void);
+extern void link_down (void);
+extern void auth_reset (void);
+extern void network_phase (void);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_AUTH_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ccp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ccp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ccp.c	(revision 317)
@@ -0,0 +1,264 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ccp.c - PPP Compression Control Protocol.
+ *
+ * Copyright (c) 1994 The Australian National University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation is hereby granted, provided that the above copyright
+ * notice appears in all copies.  This software is provided without any
+ * warranty, express or implied. The Australian National University
+ * makes no representations about the suitability of this software for
+ * any purpose.
+ *
+ * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+ * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
+ * OR MODIFICATIONS.
+ */
+
+/*
+ *	   PPP Compression Control Protocol (CCP) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1994, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ccp.c,v 1.54.2.2 2000/08/19 09:29:59 brian Exp $
+ *
+ *	TODO:
+ *		o Support other compression protocols
+ */
+
+/*
+ *  å®è£
+äºå®ãç¾å¨ã¯ãã¹ã¦æå¦
+ */
+
+#include <t_services.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_ccp.h>
+
+/*
+ *  é¢æ°
+ */
+
+static void ccp_init (void);
+static void ccp_input (T_NET_BUF *nbuf);
+static void ccp_protrej (void);
+static void ccp_lowerup (void);
+static void ccp_lowerdown (void);
+static void ccp_open (void);
+static void ccp_close (void);
+
+/*
+ * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢
+ */
+
+static int_t  ccp_reqci	(T_PPP_FSM *fsm, T_NET_BUF *nbuf);
+					/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_FSM_CALLBACKS ccp_callbacks = {
+	NULL,				/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	NULL,				/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	NULL,				/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	NULL,				/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	NULL,				/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	NULL,				/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	ccp_reqci,			/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	NULL,				/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+	NULL,				/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+	NULL,				/* ä¸ä½å±¤ãéå§ããã		*/
+	NULL,				/* ä¸ä½å±¤ãçµäºããã		*/
+	NULL,				/* åéããã			*/
+	NULL,				/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	};
+
+T_PPP_FSM ccp_fsm = {
+	&ccp_callbacks,			/* ã³ã¼ã«ããã¯é¢æ°		*/
+	PPP_CCP,			/* ãã­ãã³ã«			*/
+	};
+
+T_PPP_PROTENT ccp_protent = {
+	PPP_CCP,
+	ccp_init,			/* åæå			*/
+	ccp_input,			/* å
+¥å				*/
+	ccp_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	ccp_lowerup,			/* ä¸ä½å±¤ãèµ·åãã		*/
+	ccp_lowerdown,			/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	ccp_open,			/* ãªã¼ãã³ãã			*/
+	ccp_close,			/* ã¯ã­ã¼ãºãã			*/
+	NULL,				/* ãã¼ã¿å
+¥å			*/
+	};
+
+/*
+ *  ccp_init -- CCP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+ccp_init (void)
+{
+	fsm_init(&ccp_fsm);
+	}
+
+/*
+ *  ccp_input -- CCP å
+¥å
+ */
+
+static void
+ccp_input (T_NET_BUF *nbuf)
+{
+	NET_COUNT_PPP_CCP(net_count_ppp_ccp_in_octets,  nbuf->len);
+	NET_COUNT_PPP_CCP(net_count_ppp_ccp_in_packets, 1);
+	fsm_input(&ccp_fsm, nbuf);
+	}
+
+/*
+ *  ccp_reqci -- ç¸æã®æ§ææ
+å ±ãè§£æããã
+ */
+
+static int_t
+ccp_reqci (T_PPP_FSM *fsm, T_NET_BUF *nbuf)
+{
+/*
+ *  å®è£
+äºå®ãç¾å¨ã¯ãã¹ã¦ã®ãªãã·ã§ã³ãæå¦ããã
+ */
+	return nbuf->len > (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)) ? PPP_CONFREJ : PPP_CONFACK;
+	}
+
+/*
+ *  ccp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+ccp_protrej (void)
+{
+	fsm_lowerdown(&ccp_fsm);
+	}
+
+/*
+ *  ccp_lowerup -- CCP ä¸ä½å±¤ãèµ·åããã
+ */
+
+static void
+ccp_lowerup (void)
+{
+	fsm_lowerup(&ccp_fsm);
+	}
+
+/*
+ *  ccp_lowerdown -- CCP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+static void
+ccp_lowerdown (void)
+{
+	fsm_lowerdown(&ccp_fsm);
+	}
+
+/*
+ *  ccp_open -- CCP ã®ãªã¼ã
+ */
+
+static void
+ccp_open (void)
+{
+	fsm_open(&ccp_fsm);
+	}
+
+/*
+ *  ccp_close -- CCP ã®ã¯ã­ã¼ãº
+ */
+
+static void
+ccp_close (void)
+{
+	fsm_close(&ccp_fsm);
+	}
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ccp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ccp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ccp.h	(revision 317)
@@ -0,0 +1,110 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ccp.h - Definitions for PPP Compression Control Protocol.
+ *
+ * Copyright (c) 1994 The Australian National University.
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation is hereby granted, provided that the above copyright
+ * notice appears in all copies.  This software is provided without any
+ * warranty, express or implied. The Australian National University
+ * makes no representations about the suitability of this software for
+ * any purpose.
+ *
+ * IN NO EVENT SHALL THE AUSTRALIAN NATIONAL UNIVERSITY BE LIABLE TO ANY
+ * PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+ * THE AUSTRALIAN NATIONAL UNIVERSITY HAVE BEEN ADVISED OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * THE AUSTRALIAN NATIONAL UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE AUSTRALIAN NATIONAL UNIVERSITY HAS NO
+ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
+ * OR MODIFICATIONS.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/ccp.h,v 1.7.2.1 1999/08/29 15:46:56 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ccp.h,v 1.22 1999/08/28 01:18:19 peter Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_CCP_H_
+#define _PPP_CCP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  å¤æ°
+ */
+
+extern T_PPP_PROTENT	ccp_protent;
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_CCP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_fsm.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_fsm.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_fsm.c	(revision 317)
@@ -0,0 +1,828 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * fsm->c - {Link, IP} Control Protocol Finite State Machine.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *		PPP Finite State Machine for LCP/IPCP
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/fsm->c,v 1.52.2.3 2000/08/19 09:30:03 brian Exp $
+ *
+ *  TODO:
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_timer.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_fsm.h>
+
+#include <netinet/in.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+uint8_t	ppp_open_mode = PPP_OPEN_PASSIVE;	/* ãªã¼ãã³æã®åä½ã¢ã¼ã	*/
+
+/*
+ *  é¢æ°
+ */
+
+static void fsm_sconfreq	(T_PPP_FSM *fsm, int_t retansmit);
+static void fsm_rconfreq	(T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input);
+static void fsm_rconfack	(T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input);
+static void fsm_rconfnakrej	(T_PPP_FSM *fsm, uint8_t code, uint8_t id, T_NET_BUF *input);
+static void fsm_rtermreq	(T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input);
+static void fsm_rtermack	(T_PPP_FSM *fsm, T_NET_BUF *input);
+static void fsm_rcoderej	(T_PPP_FSM *fsm, T_NET_BUF *input);
+static void fsm_stermreq	(T_PPP_FSM *fsm, uint8_t id);
+static void fsm_timeout		(void *arg);
+
+/*
+ *  fsm_sconfreq -- Configure-Request ãéä¿¡ããã
+ */
+
+static void
+fsm_sconfreq (T_PPP_FSM *fsm, int_t retransmit)
+{
+	T_NET_BUF	*output;
+	uint16_t	len;
+
+	if (!(fsm->state == PPP_FSM_REQSENT ||
+	      fsm->state == PPP_FSM_ACKRCVD ||
+	      fsm->state == PPP_FSM_ACKSENT)) {
+		/* ã¾ã ãã´ããã¦ããªãããªãã·ã§ã³ããªã»ããããã */
+		if (fsm->callbacks->resetci)
+			(*fsm->callbacks->resetci)(fsm);
+		fsm->failures = 0;
+		}
+	if (retransmit == 0) {
+		/* æ°ãããªã¯ã¨ã¹ããåéã«ã¦ã³ã¿ããªã»ããããæ°ãã ID ãè¨­å®ããã */
+		fsm->retrans = MAX_PPP_CONFIGURES;
+		fsm->reqid   = ++ fsm->id;
+		}
+
+	fsm->seen_ack = 0;
+
+	if (fsm->callbacks->cilen && fsm->callbacks->addci) {
+		/* æ§ææ
+å ±ãã±ãããä½ãã */
+		len = (*fsm->callbacks->cilen)(fsm);
+
+		syscall(get_net_buf(&output, len + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+		(*fsm->callbacks->addci)(fsm, output);
+
+		/* æ§ææ
+å ±ãã±ãããéä¿¡ããã */
+		IF_SET_PROTO(output, fsm->proto);
+		ppp_cp_output(PPP_CONFREQ, fsm->reqid, output);
+
+		-- fsm->retrans;
+		timeout((FP)fsm_timeout, fsm, DEF_PPP_TIMEOUT);
+		}
+	}
+
+/*
+ *  fsm_rconfreq -- Configure-Request ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rconfreq (T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input)
+{
+	T_NET_BUF	*output;
+	uint16_t	code;
+
+	switch (fsm->state) {
+	case PPP_FSM_CLOSED:
+		syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		ppp_cp_output(PPP_TERMACK, id, output);
+		return;
+		break;
+
+	case PPP_FSM_CLOSING:
+	case PPP_FSM_STOPPING:
+		return;
+		break;
+
+	case PPP_FSM_OPENED:
+		/* ä¸ä½å±¤ãåæ­¢ãã¦ããã´ã«ç§»ãã */
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm_sconfreq(fsm, 0);		/* æåã® Configure-Request ãéãã */
+		break;
+
+	case PPP_FSM_STOPPED:
+		/* ç¸æãããã´ãéå§ããã */
+		fsm_sconfreq(fsm, 0);		/* æåã® Configure-Request ãéãã */
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+		}
+
+	syscall(get_net_buf(&output, input->len));
+
+	/* ä¸ä½ãã­ãã³ã«ã«è¦æ±ããã Configure-Request ãéãã */
+	if (fsm->callbacks->reqci != NULL)	/* æ§ææ
+å ±ããã§ãã¯ããã */
+		code = (*fsm->callbacks->reqci)(fsm, input, output);
+	else if (output->len > sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR))
+		code = PPP_CONFREJ;
+	else
+		code = PPP_CONFACK;
+
+	/* ç¸æã« ACK, NAK ã¾ãã¯ REJ ãéä¿¡ããã */
+	ppp_cp_output(code, id, output);
+
+	if (code == PPP_CONFACK) {
+		if (fsm->state == PPP_FSM_ACKRCVD) {
+			untimeout((FP)fsm_timeout, fsm);
+			fsm->state = PPP_FSM_OPENED;
+			if (fsm->callbacks->up != NULL)
+				(*fsm->callbacks->up)(fsm);
+			}
+		else
+			fsm->state = PPP_FSM_ACKSENT;
+		fsm->failures = 0;
+		}
+	else {
+		/* ACK ã REJ ãéã */
+		if (fsm->state != PPP_FSM_ACKRCVD)
+			fsm->state = PPP_FSM_REQSENT;
+		if (code == PPP_CONFNAK)
+			fsm->failures ++;
+		}
+	}
+
+/*
+ *  fsm_rconfnakrej -- Configure-NAK/REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rconfnakrej (T_PPP_FSM *fsm, uint8_t code, uint8_t id, T_NET_BUF *input)
+{
+	int_t		ret = 0;
+	T_NET_BUF	*output;
+
+	/* äºæãã ID ã§ãªãããNAK/REJ ãäºæãã¦ããªãã¨ãã¯çµäºããã*/
+	if (id != fsm->reqid || fsm->seen_ack) {
+		syslog(LOG_WARNING, "[PPP/FSM] bad ID or unexp NAK/REJ.");
+		return;
+		}
+
+	if (code == PPP_CONFNAK) {
+		if (fsm->callbacks->nakci != NULL && (ret = (*fsm->callbacks->nakci)(fsm, input)) == 0) {
+			syslog(LOG_WARNING, "[PPP/FSM] bad NAK.");
+			return;
+			}
+		}
+	else {
+		if (fsm->callbacks->rejci != NULL && (ret = (*fsm->callbacks->rejci)(fsm, input)) == 0) {
+			syslog(LOG_WARNING, "[PPP/FSM] bad REJ.");
+			return;
+			}
+		}
+
+	fsm->seen_ack = 1;
+
+	switch (fsm->state) {
+	case PPP_FSM_CLOSED:
+	case PPP_FSM_STOPPED:
+		syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		ppp_cp_output(PPP_TERMACK, id, output);
+		return;
+		break;
+
+	case PPP_FSM_REQSENT:
+	case PPP_FSM_ACKSENT:
+		untimeout((FP)fsm_timeout, fsm);
+		if (ret < 0)		/* éä¿¡ãã Conf-Req ãç ´æãç©ºã® NAK/REJ ãå±ããã*/
+			fsm->state = PPP_FSM_STOPPED;
+		else
+			fsm_sconfreq(fsm, 0);
+		break;
+
+	case PPP_FSM_ACKRCVD:
+		untimeout((FP)fsm_timeout, fsm);
+		fsm_sconfreq(fsm, 0);
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+	case PPP_FSM_OPENED:
+		/* åèµ·åãããã´ãããç´ãã*/
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm_sconfreq(fsm, 0);
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+		}
+	}
+
+/*
+ *  fsm_rconfack -- Configure-ACK ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rconfack (T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input)
+{
+	T_NET_BUF	*output;
+
+	/* äºæãã ID ã§ãªãããACK ãäºæãã¦ããªãã¨ãã¯çµäºããã*/
+	if (id != fsm->reqid || fsm->seen_ack) {
+		syslog(LOG_WARNING, "[PPP/FSM] bad ID or unexp ACK.");
+		return;
+		}
+
+	if (fsm->callbacks->ackci != NULL) {
+		if ((*fsm->callbacks->ackci)(fsm, input) != true) {
+			syslog(LOG_WARNING, "[PPP/FSM] bad ACK.");
+			return;
+			}
+		}
+	else if (input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)) != 0) {
+		syslog(LOG_WARNING, "[PPP/FSM] bad ACK.");
+		return;
+		}
+
+	fsm->seen_ack = 1;
+
+	switch (fsm->state) {
+	case PPP_FSM_CLOSED:
+	case PPP_FSM_STOPPED:
+		syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		ppp_cp_output(PPP_TERMACK, id, output);
+		break;
+
+	case PPP_FSM_REQSENT:
+		fsm->state = PPP_FSM_ACKRCVD;
+		fsm->retrans = MAX_PPP_CONFIGURES;
+		break;
+
+	case PPP_FSM_ACKRCVD:
+		untimeout((FP)fsm_timeout, fsm);
+		fsm_sconfreq(fsm, 0);
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+	case PPP_FSM_ACKSENT:
+		untimeout((FP)fsm_timeout, fsm);
+		fsm->state = PPP_FSM_OPENED;
+		fsm->retrans = MAX_PPP_CONFIGURES;
+		if (fsm->callbacks->up != NULL)
+			(*fsm->callbacks->up)(fsm);
+		break;
+
+	case PPP_FSM_OPENED:
+		/* åèµ·åãããã´ãããç´ãã*/
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm_sconfreq(fsm, 0);
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+	default	:
+		syslog(LOG_WARNING, "[PPP/FSM] unexp state: %d in recv Conf-ACK.", fsm->state);
+		break;
+		}
+
+	}
+
+/*
+ *  fsm_rtermreq -- Terminate-Request ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rtermreq (T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input)
+{
+	T_NET_BUF	*output;
+
+	switch (fsm->state) {
+	case PPP_FSM_ACKRCVD:
+	case PPP_FSM_ACKSENT:
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+	case PPP_FSM_OPENED:
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm->retrans = 0;
+		fsm->state = PPP_FSM_STOPPING;
+		timeout((FP)fsm_timeout, fsm, DEF_PPP_TIMEOUT);
+		break;
+		}
+	syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+	memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	ppp_cp_output(PPP_TERMACK, id, output);
+	}
+
+/*
+ *  fsm_rtermack -- Terminate-ACK ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rtermack (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	switch (fsm->state) {
+	case PPP_FSM_CLOSING:
+		untimeout((FP)fsm_timeout, fsm);
+#if 0	/* æ¬æ¥ã®åä½ã¯ CLOSED ã«é·ç§»ããã*/
+		fsm->state = PPP_FSM_CLOSED;
+#else	/* of #if 0 */
+		fsm->state = PPP_FSM_STOPPED;
+#endif	/* of #if 0 */
+		if (fsm->callbacks->finished != NULL)
+			(*fsm->callbacks->finished)(fsm);
+		break;
+
+	case PPP_FSM_STOPPING:
+		untimeout((FP)fsm_timeout, fsm);
+		fsm->state = PPP_FSM_STOPPED;
+		if (fsm->callbacks->finished != NULL)
+			(*fsm->callbacks->finished)(fsm);
+		break;
+
+	case PPP_FSM_ACKRCVD:
+		fsm->state = PPP_FSM_REQSENT;
+		break;
+
+	case PPP_FSM_OPENED:
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm_sconfreq(fsm, 0);
+		break;
+		}
+	}
+
+/*
+ *  fsm_rcoderej -- Code-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+fsm_rcoderej (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_PPP_CP_HDR	*hdr;
+
+ 	/* PPP ãªã³ã¯å¶å¾¡ (CP) ãããããç­ããã°ã¨ã©ã¼ */
+ 	if (input->len < sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)) {
+ 		syslog(LOG_WARNING, "[PPP/FSM] bad len: %d in recv Code-REJ.", input->len);
+ 		return;
+ 		}
+
+ 	hdr = GET_PPP_CP_HDR(input);
+
+	syslog(LOG_WARNING, "[PPP/FSM] recv Code-REJ, code=%d, id=%d.", hdr->code, hdr->id);
+
+	if (fsm->state == PPP_FSM_ACKRCVD)
+		fsm->state = PPP_FSM_REQSENT;
+	}
+
+/*
+ *  fsm_timeout -- ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+fsm_timeout (void *arg)
+{
+	T_PPP_FSM *fsm = (T_PPP_FSM*)arg;
+
+	switch (fsm->state) {
+	case PPP_FSM_CLOSING:
+	case PPP_FSM_STOPPING:
+		if (fsm->retrans <= 0) {
+			/* æå¤§åéåæ°ãè¶
+ããã¨ãã®å¦ç */
+#if 0	/* æ¬æ¥ã®åä½ã¯ CLOSED ã«é·ç§»ããã*/
+			fsm->state = (fsm->state == PPP_FSM_CLOSING) ? PPP_FSM_CLOSED : PPP_FSM_STOPPED;
+#else	/* of #if 0 */
+			fsm->state = PPP_FSM_STOPPED;
+#endif	/* of #if 0 */
+			if (fsm->callbacks->finished != NULL)
+				(*fsm->callbacks->finished)(fsm);
+			}
+		else {
+			/* Terminate-Request ãéä¿¡ããã*/
+			fsm_stermreq(fsm, ++ fsm->id);
+			}
+		break;
+	case PPP_FSM_REQSENT:
+	case PPP_FSM_ACKRCVD:
+	case PPP_FSM_ACKSENT:
+		if (fsm->retrans <= 0) {
+			/* æå¤§åéåæ°ãè¶
+ããã¨ãã®å¦ç */
+			syslog(LOG_WARNING, "[PPP/FSM] retrans Conf-Req.");
+			fsm->state = PPP_FSM_STOPPED;
+			if (ppp_open_mode != PPP_OPEN_PASSIVE && fsm->callbacks->finished)
+				(*fsm->callbacks->finished)(fsm);
+			}
+		else {
+			/* Configure-Request ãåéããã*/
+			if (fsm->callbacks->retrans != NULL)
+				(*fsm->callbacks->retrans)(fsm);
+			fsm_sconfreq(fsm, 1);
+			if (fsm->state == PPP_FSM_ACKRCVD)
+				fsm->state = PPP_FSM_REQSENT;
+			}
+
+		break;
+
+	default	:
+		syslog(LOG_WARNING, "[PPP/FSM] unexp state: %d in timeout.", fsm->state);
+		break;
+		}
+	}
+
+/*
+ *  fsm_stermreq -- Terminate-Request ãéä¿¡ããã
+ */
+
+static void
+fsm_stermreq (T_PPP_FSM *fsm, uint8_t id)
+{
+	T_NET_BUF	*input;
+
+	syscall(get_net_buf(&input, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+	IF_SET_PROTO(input, fsm->proto);
+	ppp_cp_output(PPP_TERMREQ, id, input);
+
+	timeout((FP)fsm_timeout, fsm, DEF_PPP_TIMEOUT);
+	fsm->retrans --;
+	}
+
+/*
+ *  fsm_init -- FSM ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+void
+fsm_init (T_PPP_FSM *fsm)
+{
+	fsm->state = PPP_FSM_INITIAL;
+	fsm->id	   = 0;
+	}
+
+/*
+ *  fsm_lowerup -- FSM ä¸ä½å±¤ãèµ·åããã
+ */
+
+void
+fsm_lowerup (T_PPP_FSM *fsm)
+{
+	switch (fsm->state) {
+	case PPP_FSM_INITIAL:
+		fsm->state = PPP_FSM_CLOSED;
+		break;
+
+	case PPP_FSM_STARTING:
+		if (ppp_open_mode == PPP_OPEN_PASSIVE)
+			fsm->state = PPP_FSM_STOPPED;
+        	else {
+			fsm_sconfreq(fsm, 0);
+			fsm->state = PPP_FSM_REQSENT;
+			}
+		break;
+
+	default	:
+		syslog(LOG_WARNING, "[PPP/FSM] unexp state: %d in lowerup", fsm->state);
+		break;
+		}
+	}
+
+/*
+ *  fsm_lowerdown -- FSM ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+void
+fsm_lowerdown (T_PPP_FSM *fsm)
+{
+	switch (fsm->state) {
+	case PPP_FSM_CLOSED:
+		fsm->state = PPP_FSM_INITIAL;
+		break;
+
+	case PPP_FSM_STOPPED:
+		fsm->state = PPP_FSM_STARTING;
+		if (fsm->callbacks->starting != NULL)
+			(*fsm->callbacks->starting)(fsm);
+		break;
+
+	case PPP_FSM_CLOSING:
+		fsm->state = PPP_FSM_INITIAL;
+		untimeout((FP)fsm_timeout, fsm);
+		break;
+
+	case PPP_FSM_STOPPING:
+	case PPP_FSM_REQSENT:
+	case PPP_FSM_ACKRCVD:
+	case PPP_FSM_ACKSENT:
+		fsm->state = PPP_FSM_STARTING;
+		untimeout((FP)fsm_timeout, fsm);
+		break;
+
+	case PPP_FSM_OPENED:
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+		fsm->state = PPP_FSM_STARTING;
+		break;
+
+	default	:
+		syslog(LOG_WARNING, "[PPP/FSM] unexp state: %d in lowerdown", fsm->state);
+		break;
+		}
+	}
+
+/*
+ *  fsm_open -- FSM ã®ãªã¼ãã³
+ */
+
+void
+fsm_open (T_PPP_FSM *fsm)
+{
+	switch (fsm->state) {
+	case PPP_FSM_INITIAL:
+		fsm->state = PPP_FSM_STARTING;
+		if (fsm->callbacks->starting != NULL)
+			(*fsm->callbacks->starting)(fsm);
+		break;
+
+	case PPP_FSM_CLOSED:
+		if (ppp_open_mode == PPP_OPEN_PASSIVE)
+			fsm->state = PPP_FSM_STOPPED;
+		else {
+			fsm_sconfreq(fsm, 0);
+			fsm->state = PPP_FSM_REQSENT;
+			}
+		break;
+
+	case PPP_FSM_CLOSING:
+		fsm->state = PPP_FSM_STOPPING;
+		/* nobreak;	ä¸ã«è½ã¡ã */
+
+	case PPP_FSM_STOPPED:
+	case PPP_FSM_OPENED:
+		fsm_lowerdown(fsm);
+		fsm_lowerup(fsm);
+		break;
+		}
+	}
+
+/*
+ *  fsm_close -- ãªã³ã¯ã®åæ­ãéå§ããã
+ */
+
+void
+fsm_close (T_PPP_FSM *fsm)
+{
+	switch (fsm->state) {
+	case PPP_FSM_STARTING:
+		fsm->state = PPP_FSM_INITIAL;
+		break;
+
+#if 0	/* æ¬æ¥ã®åä½ã¯ CLOSED ã«é·ç§»ããã*/
+	case PPP_FSM_STOPPED:
+		fsm->state = PPP_FSM_CLOSED;
+		break;
+#endif	/* of #if 0 */
+
+	case PPP_FSM_STOPPING:
+		fsm->state = PPP_FSM_CLOSING;
+		break;
+
+	case PPP_FSM_REQSENT:
+	case PPP_FSM_ACKRCVD:
+	case PPP_FSM_ACKSENT:
+	case PPP_FSM_OPENED:
+		if (fsm->state != PPP_FSM_OPENED)
+			untimeout((FP)fsm_timeout, fsm);
+		else if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+
+		/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããTerminate-Request ãéä¿¡ããã*/
+		fsm->retrans = MAX_PPP_TERMINATES;
+		fsm_stermreq(fsm, fsm->reqid = ++ fsm->id);
+		fsm->state = PPP_FSM_CLOSING;
+		break;
+		}
+	}
+
+/*
+ *  fsm_input -- å
+¥åãPPP ãªã³ã¯å¶å¾¡ (CP) ã®å¶å¾¡ã³ã¼ãã«ããé©å½ãªé¢æ°ãå¼åºã
+ */
+
+void
+fsm_input (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_PPP_CP_HDR	*hdr;
+	T_NET_BUF	*output;
+
+ 	/* PPP ãªã³ã¯å¶å¾¡ (CP) ãããããç­ããã°ã¨ã©ã¼ */
+ 	if (input->len < (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR))) {
+ 		syslog(LOG_WARNING, "[PPP/FSM] short hdr: %d.", input->len);
+ 		return;
+ 		}
+
+ 	hdr = GET_PPP_CP_HDR(input);
+
+ 	/* ãããã®é·ãã¨å
+¥åãã¼ã¿ãµã¤ãºãä¸è´ããªããã°ã¨ã©ã¼ */
+ 	if (hdr->len != input->len - sizeof(T_PPP_HDR)) {
+ 		syslog(LOG_WARNING, "[PPP/FSM] bad len: %d.", hdr->len);
+ 		return;
+ 		}
+ 
+ 	/* ç¶æ
+ã INITIAL ã STARTING ãªãã¨ã©ã¼ */
+ 	if (fsm->state == PPP_FSM_INITIAL || fsm->state == PPP_FSM_STARTING) {
+ 		syslog(LOG_WARNING, "[PPP/FSM] unexp state: %d in input.", fsm->state);
+ 		return;
+ 		}
+ 
+ 	/*
+ 	 *  å¶å¾¡ã³ã¼ãã«ããé©å½ãªé¢æ°ãå¼åºã
+ 	 */
+
+	switch (hdr->code) {
+	case PPP_CONFREQ:
+		fsm_rconfreq(fsm, hdr->id, input);
+		break;
+
+	case PPP_CONFACK:
+		fsm_rconfack(fsm, hdr->id, input);
+		break;
+
+	case PPP_CONFNAK:
+	case PPP_CONFREJ:
+		fsm_rconfnakrej(fsm, hdr->code, hdr->id, input);
+		break;
+
+	case PPP_TERMREQ:
+		fsm_rtermreq(fsm, hdr->id, input);
+		break;
+
+	case PPP_TERMACK:
+		fsm_rtermack(fsm, input);
+		break;
+
+	case PPP_CODEREJ:
+		fsm_rcoderej(fsm, input);
+		break;
+
+	default:
+		if (fsm->callbacks->extcode == NULL ||
+		    (*fsm->callbacks->extcode)(fsm, hdr->code, hdr->id, input) != true) {
+			syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+			memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+			ppp_cp_output(PPP_CODEREJ, ++ fsm->id, output);
+			}
+		break;
+		}
+	}
+
+/*
+ *  fsm_protoreject -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+void
+fsm_protreject (T_PPP_FSM *fsm)
+{
+	switch (fsm->state) {
+	case PPP_FSM_CLOSING:
+		untimeout((FP)fsm_timeout, fsm);
+
+#if 0	/* æ¬æ¥ã®åä½ã¯ CLOSED ã«é·ç§»ããã*/
+		/* ä¸ã«è½ã¡ã */
+#else	/* of #if 0 */
+		fsm->state = PPP_FSM_STOPPED;
+		if (fsm->callbacks->finished != NULL)
+			(*fsm->callbacks->finished)(fsm);
+		break;
+#endif	/* of #if 0 */
+
+	case PPP_FSM_CLOSED:
+		fsm->state = PPP_FSM_CLOSED;
+		if (fsm->callbacks->finished != NULL)
+			(*fsm->callbacks->finished)(fsm);
+		break;
+
+	case PPP_FSM_STOPPING:
+	case PPP_FSM_REQSENT:
+	case PPP_FSM_ACKRCVD:
+	case PPP_FSM_ACKSENT:
+		untimeout((FP)fsm_timeout, fsm);
+		/* ä¸ã«è½ã¡ã */
+
+	case PPP_FSM_STOPPED:
+		fsm->state = PPP_FSM_STOPPED;
+		if (fsm->callbacks->finished != NULL)
+			(*fsm->callbacks->finished)(fsm);
+		break;
+
+	case PPP_FSM_OPENED:
+		if (fsm->callbacks->down != NULL)
+			(*fsm->callbacks->down)(fsm);
+
+		/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããTerminate-Request ãéä¿¡ããã*/
+		fsm->retrans = MAX_PPP_TERMINATES;
+		fsm_stermreq(fsm, fsm->reqid = ++ fsm->id);
+		fsm->state = PPP_FSM_STOPPING;
+		break;
+
+		}
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_fsm.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_fsm.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_fsm.h	(revision 317)
@@ -0,0 +1,203 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * fsm.h - {Link, IP} Control Protocol Finite State Machine definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/fsm.h,v 1.6.2.1 1999/08/29 15:47:00 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/fsm.h,v 1.23 1999/12/27 11:54:53 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_FSM_H_
+#define _PPP_FSM_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  ç¶æ
+ç®¡çæ§é ä½
+ */
+
+struct t_ppp_fsm_callbacks;
+
+typedef struct t_fsm {
+	struct t_ppp_fsm_callbacks	*callbacks;	/* ã³ã¼ã«ããã¯é¢æ°*/
+	uint16_t	proto;		/* ãã­ãã³ã«				*/
+	uint8_t		state;		/* FSM ã®ç¶æ
+				*/
+	uint8_t		id;		/* ç¾å¨ã® ID				*/
+	uint8_t		reqid;		/* è¦æ± ID				*/
+	uint8_t		seen_ack;	/* è¦æ±ã«å¯¾ãæ­£å¸¸ãª ACK/NAK/REJ ãåä¿¡	*/
+	int8_t		failures;	/* é»èªãã NAK æ°			*/
+	int8_t		retrans;	/* Configure-Request ã¾ãã¯ã		*/
+					/* Terminate-Request ã®åéåæ°		*/
+	} T_PPP_FSM;
+
+#define T_PPP_FSM_DEFINED
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°æ§é ä½
+ */
+
+typedef struct t_ppp_fsm_callbacks {
+	void (*resetci)	(T_PPP_FSM *);	/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	int_t  (*cilen)	(T_PPP_FSM *);	/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	void (*addci)	(T_PPP_FSM *, T_NET_BUF *);
+					/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	bool_t (*ackci)	(T_PPP_FSM *, T_NET_BUF *);
+					/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	int_t  (*nakci)	(T_PPP_FSM *, T_NET_BUF *);
+					/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	int_t  (*rejci)	(T_PPP_FSM *, T_NET_BUF *);
+					/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	int_t  (*reqci)	(T_PPP_FSM *, T_NET_BUF *, T_NET_BUF *);
+					/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	void (*up)	(T_PPP_FSM *);	/* ãªã³ã¯ã®æ¥ç¶ãç¢ºç«ããã	*/
+	void (*down)	(T_PPP_FSM *);	/* ãªã³ã¯ã®æ¥ç¶ãè§£æ¾ããã	*/
+	void (*starting)(T_PPP_FSM *);	/* ä¸ä½å±¤ãéå§ããã		*/
+	void (*finished)(T_PPP_FSM *);	/* ä¸ä½å±¤ãçµäºããã		*/
+	void (*retrans)	(T_PPP_FSM *);	/* åéããã			*/
+					/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	bool_t  (*extcode)(T_PPP_FSM *, uint8_t, uint8_t, T_NET_BUF *);
+	} T_PPP_FSM_CALLBACKS;
+
+/*
+ *  FSM ã®ç¶æ
+
+ */
+
+#define PPP_FSM_INITIAL		0	/* æªæ¥ç¶ãæªãªã¼ãã³	*/
+#define PPP_FSM_STARTING	1	/* æªæ¥ç¶ããªã¼ãã³	*/
+#define PPP_FSM_CLOSED		2	/* æ¥ç¶ã  æªãªã¼ãã³	*/
+#define PPP_FSM_STOPPED		3	/* ãªã¼ãã³ãåæ­å¾
+ã¡	*/
+#define PPP_FSM_CLOSING		4	/* åæ­ä¸­ãæªãªã¼ãã³	*/
+#define PPP_FSM_STOPPING	5	/* åæ­ä¸­ããªã¼ãã³	*/
+#define PPP_FSM_REQSENT		6	/* Config REQ éä¿¡æ¸ã¿	*/
+#define PPP_FSM_ACKRCVD		7	/* Config ACK åä¿¡æ¸ã¿	*/
+#define PPP_FSM_ACKSENT		8	/* Config ACK éä¿¡æ¸ã¿	*/
+#define PPP_FSM_OPENED		9	/* æ¥ç¶ãéä¿¡å¯è½	*/
+
+/*
+ *  ãªã¼ãã³æã®åä½ã¢ã¼ã
+ */
+
+#define PPP_OPEN_PASSIVE	false	/* ååãªã¼ãã³		*/
+#define PPP_OPEN_ACTIVE		true	/* è½åãªã¼ãã³		*/
+
+/*
+ *  åéãã¿ã¤ã ã¢ã¦ãã®æ¢å®å¤
+ */
+
+#define DEF_PPP_TIMEOUT		(3*NET_TIMER_HZ)
+					/* RFC1661 ã§ã¯  3 ç§			*/
+#define MAX_PPP_TERMINATES	2	/* Terminate-Requests ã®æå¤§åéåæ°	*/
+					/* RFC1661 ã§ã¯  2 å			*/
+#define MAX_PPP_CONFIGURES	10	/* Configure-Requests ã®æå¤§åéåæ°	*/
+					/* RFC1661 ã§ã¯ 10 å			*/
+#define MAX_PPP_FAILURES	5	/* Configure-NAK ã®æå¤§é»èªåæ°		*/
+					/* RFC1661 ã§ã¯  5 å			*/
+
+/*
+ *  é¢æ°
+ */
+
+extern void fsm_init    (T_PPP_FSM *fsm);
+extern void fsm_lowerup (T_PPP_FSM *fsm);
+extern void fsm_lowerdown(T_PPP_FSM *fsm);
+extern void fsm_open    (T_PPP_FSM *fsm);
+extern void fsm_close	(T_PPP_FSM *fsm);
+extern void fsm_input	(T_PPP_FSM *fsm, T_NET_BUF *data);
+extern void fsm_protreject(T_PPP_FSM *fsm);
+
+/*
+ *  å¤æ°
+ */
+
+extern uint8_t ppp_open_mode;
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_FSM_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.c	(revision 317)
@@ -0,0 +1,564 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *	     PPP High Level Link Control (HDLC) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/hdlc.c,v 1.46 1999/12/20 20:29:42 brian Exp $
+ *
+ *	TODO:
+ */
+
+#include <s_services.h>
+#include <t_services.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_modem.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  RFC1171 (PPP) ã® HDLC é¨ã®å®ç¾©
+ */
+
+/*
+ *  å¤æ°
+ */
+
+uint32_t remote_ACCM	= DEF_REMOTE_ACCM;
+
+/*
+ *  é¢æ°
+ */
+
+static ER HDLC_putoctet (uint8_t octet);
+static ER HDLC_getoctet (uint8_t *octet);
+
+/*
+ *  genfcstab.c ã«ããä½æãã FCS ã®ã«ãã¯ã¢ããè¡¨
+ *  RFC1171 åç
+§
+ */
+
+static uint16_t fcstab[256] = {
+	UINT_C(0x0000), UINT_C(0x1189), UINT_C(0x2312), UINT_C(0x329b),
+	UINT_C(0x4624), UINT_C(0x57ad), UINT_C(0x6536), UINT_C(0x74bf),
+	UINT_C(0x8c48), UINT_C(0x9dc1), UINT_C(0xaf5a), UINT_C(0xbed3),
+	UINT_C(0xca6c), UINT_C(0xdbe5), UINT_C(0xe97e), UINT_C(0xf8f7),
+	UINT_C(0x1081), UINT_C(0x0108), UINT_C(0x3393), UINT_C(0x221a),
+	UINT_C(0x56a5), UINT_C(0x472c), UINT_C(0x75b7), UINT_C(0x643e),
+	UINT_C(0x9cc9), UINT_C(0x8d40), UINT_C(0xbfdb), UINT_C(0xae52),
+	UINT_C(0xdaed), UINT_C(0xcb64), UINT_C(0xf9ff), UINT_C(0xe876),
+	UINT_C(0x2102), UINT_C(0x308b), UINT_C(0x0210), UINT_C(0x1399),
+	UINT_C(0x6726), UINT_C(0x76af), UINT_C(0x4434), UINT_C(0x55bd),
+	UINT_C(0xad4a), UINT_C(0xbcc3), UINT_C(0x8e58), UINT_C(0x9fd1),
+	UINT_C(0xeb6e), UINT_C(0xfae7), UINT_C(0xc87c), UINT_C(0xd9f5),
+	UINT_C(0x3183), UINT_C(0x200a), UINT_C(0x1291), UINT_C(0x0318),
+	UINT_C(0x77a7), UINT_C(0x662e), UINT_C(0x54b5), UINT_C(0x453c),
+	UINT_C(0xbdcb), UINT_C(0xac42), UINT_C(0x9ed9), UINT_C(0x8f50),
+	UINT_C(0xfbef), UINT_C(0xea66), UINT_C(0xd8fd), UINT_C(0xc974),
+	UINT_C(0x4204), UINT_C(0x538d), UINT_C(0x6116), UINT_C(0x709f),
+	UINT_C(0x0420), UINT_C(0x15a9), UINT_C(0x2732), UINT_C(0x36bb),
+	UINT_C(0xce4c), UINT_C(0xdfc5), UINT_C(0xed5e), UINT_C(0xfcd7),
+	UINT_C(0x8868), UINT_C(0x99e1), UINT_C(0xab7a), UINT_C(0xbaf3),
+	UINT_C(0x5285), UINT_C(0x430c), UINT_C(0x7197), UINT_C(0x601e),
+	UINT_C(0x14a1), UINT_C(0x0528), UINT_C(0x37b3), UINT_C(0x263a),
+	UINT_C(0xdecd), UINT_C(0xcf44), UINT_C(0xfddf), UINT_C(0xec56),
+	UINT_C(0x98e9), UINT_C(0x8960), UINT_C(0xbbfb), UINT_C(0xaa72),
+	UINT_C(0x6306), UINT_C(0x728f), UINT_C(0x4014), UINT_C(0x519d),
+	UINT_C(0x2522), UINT_C(0x34ab), UINT_C(0x0630), UINT_C(0x17b9),
+	UINT_C(0xef4e), UINT_C(0xfec7), UINT_C(0xcc5c), UINT_C(0xddd5),
+	UINT_C(0xa96a), UINT_C(0xb8e3), UINT_C(0x8a78), UINT_C(0x9bf1),
+	UINT_C(0x7387), UINT_C(0x620e), UINT_C(0x5095), UINT_C(0x411c),
+	UINT_C(0x35a3), UINT_C(0x242a), UINT_C(0x16b1), UINT_C(0x0738),
+	UINT_C(0xffcf), UINT_C(0xee46), UINT_C(0xdcdd), UINT_C(0xcd54),
+	UINT_C(0xb9eb), UINT_C(0xa862), UINT_C(0x9af9), UINT_C(0x8b70),
+	UINT_C(0x8408), UINT_C(0x9581), UINT_C(0xa71a), UINT_C(0xb693),
+	UINT_C(0xc22c), UINT_C(0xd3a5), UINT_C(0xe13e), UINT_C(0xf0b7),
+	UINT_C(0x0840), UINT_C(0x19c9), UINT_C(0x2b52), UINT_C(0x3adb),
+	UINT_C(0x4e64), UINT_C(0x5fed), UINT_C(0x6d76), UINT_C(0x7cff),
+	UINT_C(0x9489), UINT_C(0x8500), UINT_C(0xb79b), UINT_C(0xa612),
+	UINT_C(0xd2ad), UINT_C(0xc324), UINT_C(0xf1bf), UINT_C(0xe036),
+	UINT_C(0x18c1), UINT_C(0x0948), UINT_C(0x3bd3), UINT_C(0x2a5a),
+	UINT_C(0x5ee5), UINT_C(0x4f6c), UINT_C(0x7df7), UINT_C(0x6c7e),
+	UINT_C(0xa50a), UINT_C(0xb483), UINT_C(0x8618), UINT_C(0x9791),
+	UINT_C(0xe32e), UINT_C(0xf2a7), UINT_C(0xc03c), UINT_C(0xd1b5),
+	UINT_C(0x2942), UINT_C(0x38cb), UINT_C(0x0a50), UINT_C(0x1bd9),
+	UINT_C(0x6f66), UINT_C(0x7eef), UINT_C(0x4c74), UINT_C(0x5dfd),
+	UINT_C(0xb58b), UINT_C(0xa402), UINT_C(0x9699), UINT_C(0x8710),
+	UINT_C(0xf3af), UINT_C(0xe226), UINT_C(0xd0bd), UINT_C(0xc134),
+	UINT_C(0x39c3), UINT_C(0x284a), UINT_C(0x1ad1), UINT_C(0x0b58),
+	UINT_C(0x7fe7), UINT_C(0x6e6e), UINT_C(0x5cf5), UINT_C(0x4d7c),
+	UINT_C(0xc60c), UINT_C(0xd785), UINT_C(0xe51e), UINT_C(0xf497),
+	UINT_C(0x8028), UINT_C(0x91a1), UINT_C(0xa33a), UINT_C(0xb2b3),
+	UINT_C(0x4a44), UINT_C(0x5bcd), UINT_C(0x6956), UINT_C(0x78df),
+	UINT_C(0x0c60), UINT_C(0x1de9), UINT_C(0x2f72), UINT_C(0x3efb),
+	UINT_C(0xd68d), UINT_C(0xc704), UINT_C(0xf59f), UINT_C(0xe416),
+	UINT_C(0x90a9), UINT_C(0x8120), UINT_C(0xb3bb), UINT_C(0xa232),
+	UINT_C(0x5ac5), UINT_C(0x4b4c), UINT_C(0x79d7), UINT_C(0x685e),
+	UINT_C(0x1ce1), UINT_C(0x0d68), UINT_C(0x3ff3), UINT_C(0x2e7a),
+	UINT_C(0xe70e), UINT_C(0xf687), UINT_C(0xc41c), UINT_C(0xd595),
+	UINT_C(0xa12a), UINT_C(0xb0a3), UINT_C(0x8238), UINT_C(0x93b1),
+	UINT_C(0x6b46), UINT_C(0x7acf), UINT_C(0x4854), UINT_C(0x59dd),
+	UINT_C(0x2d62), UINT_C(0x3ceb), UINT_C(0x0e70), UINT_C(0x1ff9),
+	UINT_C(0xf78f), UINT_C(0xe606), UINT_C(0xd49d), UINT_C(0xc514),
+	UINT_C(0xb1ab), UINT_C(0xa022), UINT_C(0x92b9), UINT_C(0x8330),
+	UINT_C(0x7bc7), UINT_C(0x6a4e), UINT_C(0x58d5), UINT_C(0x495c),
+	UINT_C(0x3de3), UINT_C(0x2c6a), UINT_C(0x1ef1), UINT_C(0x0f78),
+	};
+
+/*
+ *  ã¤ã³ã©ã¤ã³é¢æ°
+ */
+
+Inline uint16_t Next_FCS (uint16_t FCS, uint8_t Octet) {
+	return (FCS >> 8) ^ fcstab[(FCS ^ Octet) & 0xff];
+	};
+
+/*
+ *  HDLC_putoctet -- HDLC ãªã¯ãããåºå
+ */
+
+static
+ER HDLC_putoctet (uint8_t octet)
+{
+	static uint8_t escape[2] = { HDLC_CNTL_ESC };
+
+	ER error;
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, 1);
+
+	if ((octet < 0x20 && ((1 << octet) & lcp_remote_ack_cfg.ACCM)) ||
+	    octet == HDLC_CNTL_ESC || octet == HDLC_FLAG_SEQ) {
+		escape[1] = octet ^ HDLC_ESC_MASK;
+		error = serial_wri_dat(HDLC_PORTID, escape, sizeof(escape));
+		}
+	else
+		error = serial_wri_dat(HDLC_PORTID, &octet, sizeof(octet));
+
+	return error > 0 ? E_OK : error;
+	}
+
+/*
+ *  HDLC_wirte -- HDLC åºå
+ */
+
+ER HDLC_write (T_NET_BUF *nbuf)
+{
+	static char flag_seq_ac[4] = {
+		HDLC_FLAG_SEQ,
+		HDLC_ADDR_ALL,
+		HDLC_CNTL_ESC,
+		HDLC_CNTL_UI ^ HDLC_ESC_MASK,
+		};
+
+#ifdef LCP_CFG_ACCOMP
+
+	static char flag_seq = HDLC_FLAG_SEQ;
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+	ER		error;
+	uint32_t	fcs;
+	uint16_t	len;
+	uint8_t 	*buf;
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.out_packets, 1);
+
+#ifdef LCP_CFG_ACCOMP
+
+	if (lcp_local_ack_cfg.options & LCP_CFG_ACCOMP) {
+		NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq));
+		/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ ãéä¿¡ãã    */
+		if ((error = serial_wri_dat(HDLC_PORTID, &flag_seq, sizeof(flag_seq))) < 0) {
+			goto err_ret;
+			}
+		fcs = HDLC_INIT_FCS;
+		}
+	else {
+
+		NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq_ac));
+		/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ãAddress ã¨ Control ãéä¿¡ãã    */
+		if ((error = serial_wri_dat(HDLC_PORTID, flag_seq_ac, sizeof(flag_seq_ac))) < 0) {
+			goto err_ret;
+			}
+		/* Address ã¨ Control ã® FCS ã®è¨ç®ã¯ HDLC_INIT_FCS_AC ã«å«ãã¦ãã */
+		fcs = HDLC_INIT_FCS_AC;
+		}
+
+#else	/* of #ifdef LCP_CFG_ACCOMP */
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, sizeof(flag_seq_ac));
+	/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ãAddress ã¨ Control ãéä¿¡ãã    */
+	if ((error = serial_wri_dat(HDLC_PORTID, flag_seq_ac, sizeof(flag_seq_ac))) < 0) {
+		goto err_ret;
+		}
+	/* Address ã¨ Control ã® FCS ã®è¨ç®ã¯ HDLC_INIT_FCS_AC ã«å«ãã¦ãã */
+	fcs = HDLC_INIT_FCS_AC;
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+	buf = nbuf->buf;
+	len = nbuf->len;
+
+#ifdef LCP_CFG_PCOMP
+
+	if ((lcp_local_ack_cfg.options & LCP_CFG_ACCOMP) && *buf == 0 && *(buf + 1) < 0xff) {
+		buf ++;
+		len --;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+	/* ãã¼ã¿ãéä¿¡ãã */
+	while (len -- > 0) {
+
+		if ((error = HDLC_putoctet(*buf)) != E_OK)
+			goto err_ret;
+		fcs = Next_FCS(fcs, *buf);
+		buf ++;
+		}
+
+	/* FCS ãéä¿¡ãã */
+	fcs = ~fcs;
+	if ((error = HDLC_putoctet(fcs & 0xff)) != E_OK)
+		goto err_ret;
+	if ((error = HDLC_putoctet(fcs >> 8)) != E_OK)
+		goto err_ret;
+
+	/* ãã¬ã¼ã çµäºãã©ã°ã·ã¼ã±ã³ã¹ãéä¿¡ãã */
+	if ((error = serial_wri_dat(HDLC_PORTID, &flag_seq_ac[0], sizeof(char))) < 0)
+		goto err_ret;
+
+	return E_OK;
+
+err_ret:
+	NET_COUNT_PPP_HDLC(net_count_hdlc.out_err_packets, 1);
+	return error;
+	}
+
+/*
+ *  HDLC_getoctet -- HDLC ãªã¯ãããå
+¥å
+ *
+ *	æ»ãå¤ã true ãªããã©ã°ã·ã¼ã±ã³ã¹
+ */
+
+static
+ER_BOOL HDLC_getoctet (uint8_t *octet)
+{
+	ER error;
+
+	/* 1ãªã¯ãããå
+¥åãã */
+	if ((error = serial_rea_dat(HDLC_PORTID, octet, sizeof(uint8_t))) <= 0) {
+		return error;
+		}
+
+	/* å
+¥åãããªã¯ãããããã©ã°ã·ã¼ã±ã³ã¹ãªã true ãè¿ã */
+	if (*octet == HDLC_FLAG_SEQ)
+		return true;
+
+	/* å
+¥åãããªã¯ããããã¨ã¹ã±ã¼ããªããããï¼ãªã¯ãããå
+¥åããã¹ã¯ãè§£é¤ãã */
+	if (*octet == HDLC_CNTL_ESC) {
+		if ((error = serial_rea_dat(HDLC_PORTID, octet, sizeof(uint8_t))) <= 0)
+			return error;
+		*octet ^= HDLC_ESC_MASK;
+		}
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.in_octets, 1);
+	return E_OK;
+	}
+
+/*
+ *  HDLC_read -- HDLC å
+¥å
+ *
+ *	HDLC ãã¬ã¼ã ãå
+¥åããã
+ */
+
+ER HDLC_read (T_NET_BUF *nbuf, uint16_t size)
+{
+	ER		error;
+	uint32_t	fcs = 0;
+	uint16_t	olen = 0;
+	uint8_t		*buf, octet;
+
+	buf = nbuf->buf;
+
+	/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ã¾ã§å
+¥åãèª­ã¿é£ã°ã */
+	while ((error = HDLC_getoctet(&octet)) != true) {
+
+		if (error != E_OK)
+			goto err_ret;
+
+#ifdef PPP_CFG_MODEM
+
+		else if (octet == '\n') {
+			/* ã¢ãã å¶å¾¡ãå¼ã³åºãã*/
+			modem_cntl(modem_getline(nbuf, size));
+			/* ä¸åº¦ããã®é¢æ°ãçµäºããã*/
+			nbuf->len = 0;
+			return E_OK;
+			}
+
+#endif/* of #ifdef PPP_CFG_MODEM */
+
+		}
+
+	/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ã®éã¯å
+¥åãèª­ã¿é£ã°ã */
+	while (1) {
+		if ((error = HDLC_getoctet(&octet)) == E_OK)
+			break;
+		else if (error != true)
+			goto err_ret;
+		}
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.in_packets, 1);
+
+	/* å
+¥åãããªã¯ãããã¯ Address: All-Stations ã */
+	if (octet == HDLC_ADDR_ALL) {
+
+		/* æ¬¡ã¯ Control: UI */
+		if ((error = HDLC_getoctet(&octet)) != E_OK || octet != HDLC_CNTL_UI) {
+			error = E_SYS;
+			goto err_ret;
+			}
+		if ((error = HDLC_getoctet(&octet)) != E_OK)
+			goto err_ret;
+		/* Address ã¨ Control ã® FCS ã®è¨ç®ã¯ HDLC_INIT_FCS_AC ã«å«ãã¦ãã */
+		fcs = HDLC_INIT_FCS_AC;
+		}
+
+#ifdef LCP_CFG_ACCOMP
+
+	else if (lcp_remote_ack_cfg.options & LCP_CFG_ACCOMP) {
+		fcs = HDLC_INIT_FCS;
+		}
+
+#endif/* of #ifdef LCP_CFG_ACCOMP */
+
+	else {
+		error = E_SYS;
+		goto err_ret;
+		}
+
+	nbuf->len = 0;
+
+#ifdef LCP_CFG_PCOMP
+
+	if ((lcp_remote_ack_cfg.options & LCP_CFG_PCOMP) && (octet & 0x01) != 0) {
+		*buf ++ = 0x00;
+		size  --;
+		nbuf->len ++;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+	fcs = Next_FCS(fcs, octet);
+	*buf ++ = octet;
+	size  --;
+	nbuf->len ++;
+
+	/* SUD + FCS ãå
+¥åãã */
+	while ((error = HDLC_getoctet(&octet)) == E_OK) {
+		fcs = Next_FCS(fcs, octet);
+		if (size > 0) {
+			*buf ++ = octet;
+			size  --;
+			}
+		else
+			olen ++;
+		nbuf->len ++;
+		}
+
+	if (error == true) {
+		if (size > 0)
+			nbuf->len -= 2;
+		else if (olen <= 2)
+			nbuf->len -= olen;
+		else {
+			error = E_BOVR;
+			goto err_ret;
+			}
+		}
+	else
+		goto err_ret;
+
+	/* FCS ããã§ãã¯ãã */
+	if (fcs != HDLC_GOOD_FCS) {
+		error = E_SYS;
+		goto err_ret;
+		}
+
+	return E_OK;
+
+err_ret:
+	NET_COUNT_PPP_HDLC(net_count_hdlc.in_err_packets, 1);
+	return error;
+	}
+
+/*
+ *  HDLC_dummy_read -- HDLC å
+¥å (ç©ºèª­ã¿)
+ *
+ *	HDLC ãã¬ã¼ã ãç©ºèª­ã¿ããã
+ */
+
+void
+HDLC_dummy_read (void)
+{
+	uint8_t	octet;
+	ER	error;
+
+	/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ã¾ã§å
+¥åãèª­ã¿é£ã°ã */
+	while ((error = HDLC_getoctet(&octet)) != true) {
+		if (error != E_OK)
+			return;
+		}
+
+	/* ãã¬ã¼ã éå§ãã©ã°ã·ã¼ã±ã³ã¹ã®éã¯å
+¥åãèª­ã¿é£ã°ã */
+	while (octet == HDLC_FLAG_SEQ)
+		if (HDLC_getoctet(&octet) != E_OK)
+			return;
+
+	/* å
+¥åãããªã¯ãããã¯ Address: All-Stations ã */
+	if (octet == HDLC_ADDR_ALL) {
+
+		/* æ¬¡ã¯ Control: UI */
+		if (HDLC_getoctet(&octet) != E_OK || octet != HDLC_CNTL_UI)
+			return;
+		if (HDLC_getoctet(&octet) != E_OK)
+			return;
+		}
+
+#ifdef LCP_CFG_ACCOMP
+
+	else if (lcp_remote_ack_cfg.options & LCP_CFG_ACCOMP)
+		;
+
+#endif/* of #ifdef LCP_CFG_ACCOMP */
+
+	else
+		return;
+
+	while (HDLC_getoctet(&octet) == E_OK)
+		;
+	}
+
+#ifdef PPP_CFG_MODEM
+
+/*
+ *  HDLC_raw_getoctet -- HDLC ãªã¯ããã (Raw) å
+¥å
+ */
+
+int HDLC_raw_getoctet (void)
+{
+	uint8_t ch;
+
+	/* 1ãªã¯ãããå
+¥åãã */
+	if (serial_rea_dat(HDLC_PORTID, &ch, sizeof(ch)) <= 0)
+		return '\0';
+
+	NET_COUNT_PPP_HDLC(net_count_hdlc.in_octets, 1);
+	return ch;
+	}
+
+/*
+ *  HDLC_raw_putoctet -- HDLC ãªã¯ããã (Raw) åºå
+ */
+
+void HDLC_raw_putoctet (uint8_t ch)
+{
+	NET_COUNT_PPP_HDLC(net_count_hdlc.out_octets, 1);
+	/* 1ãªã¯ãããåºåãã */
+	serial_wri_dat(HDLC_PORTID, &ch, sizeof(ch));
+	}
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_hdlc.h	(revision 317)
@@ -0,0 +1,108 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/hdlc.h,v 1.21 1999/12/30 13:27:15 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP__HDLC_H_
+#define _PPP__HDLC_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  RFC1171 (PPP) ã® HDLC é¨ã®å®ç¾©
+ */
+
+/*
+ *  æ¢å®å¤
+ */
+
+#define HDLC_FLAG_SEQ		UINT_C(0x7e)		/* Flag Sequence			*/
+#define HDLC_CNTL_ESC		UINT_C(0x7d)		/* Control Escape octet			*/
+#define HDLC_ADDR_ALL		UINT_C(0xff)		/* Address: All-Stations		*/
+#define HDLC_CNTL_UI		UINT_C(0x03)		/* Control: UI				*/
+#define HDLC_ESC_MASK		UINT_C(0x20)		/* Escape Mask				*/
+#define HDLC_INIT_FCS		UINT_C(0xffff)		/* Initial FCS value			*/
+#define HDLC_INIT_FCS_AC	UINT_C(0x3de3)		/* Initial FCS value with		*/
+							/* Address and Control: UI		*/
+#define HDLC_GOOD_FCS		UINT_C(0xf0b8)		/* Good final FCS value			*/
+
+/*
+ *  é¢æ°
+ */
+
+extern ER HDLC_write (T_NET_BUF *data);
+extern ER HDLC_read (T_NET_BUF *data, uint16_t size);
+extern void HDLC_dummy_read (void);
+
+#ifdef PPP_CFG_MODEM
+
+extern int_t HDLC_raw_getoctet (void);
+extern void HDLC_raw_putoctet (uint8_t ch);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP__HDLC_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.c	(revision 317)
@@ -0,0 +1,722 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipcp.c - PPP IP Control Protocol.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	PPP IP Control Protocol (IPCP) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipcp.c,v 1.90.2.4 2000/08/19 09:30:03 brian Exp $
+ *
+ *	TODO:
+ *		o Support IPADDRS properly
+ *		o Validate the length in IpcpDecodeConfig
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_ipcp.h>
+#include <net/ppp_modem.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+static void ipcp_init (void);
+static void ipcp_input (T_NET_BUF *input);
+static void ipcp_protrej (void);
+static void ipcp_lowerup (void);
+static void ipcp_lowerdown (void);
+static void ipcp_open (void);
+static void ipcp_close (void);
+
+/*
+ * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢
+ */
+
+static void  ipcp_resetci(T_PPP_FSM *fsm);	/* èªæ§ææ
+å ±ããªã»ããããã	*/
+static int_t ipcp_cilen	(T_PPP_FSM *fsm);	/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+static void  ipcp_addci	(T_PPP_FSM *fsm, T_NET_BUF *output);
+						/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+static bool_t  ipcp_ackci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipcp_nakci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipcp_rejci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+static int_t ipcp_reqci	(T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output);
+						/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+static void ipcp_up	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+static void ipcp_down	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+static void ipcp_finished(T_PPP_FSM *fsm);	/* ä¸ä½å±¤ãçµäºããã		*/
+
+/*
+ *  å¤æ°
+ */
+
+static T_IFNET ipcp_local_def_cfg = {		/* èªæ§ææ
+å ±ã®è¦å®å¤		*/
+	NULL,
+	{
+		IPV4_ADDR_LOCAL,		/* IPv4 ã¢ãã¬ã¹			*/
+		UINT_C(0),			/* ãµãããããã¹ã¯		*/
+		},
+	};
+
+static T_IFNET ipcp_remote_def_cfg = {		/* ç¸æã®æ§ææ
+å ±ã®è¦å®å¤	*/
+	NULL,
+	{
+		IPV4_ADDR_REMOTE,		/* IPv4 ã¢ãã¬ã¹			*/
+		UINT_C(0),			/* ãµãããããã¹ã¯		*/
+		}
+	};
+
+static T_IFNET ipcp_local_neg_cfg;		/* ãã´ä¸­ã®èªæ§ææ
+å ±		*/
+
+static T_IFNET ipcp_remote_neg_cfg;		/* ãã´ä¸­ã®ç¸æã®æ§ææ
+å ±		*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_FSM_CALLBACKS ipcp_callbacks = {
+	ipcp_resetci,			/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	ipcp_cilen,			/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	ipcp_addci,			/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	ipcp_ackci,			/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipcp_nakci,			/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipcp_rejci,			/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipcp_reqci,			/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	ipcp_up,			/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+	ipcp_down,			/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+	NULL,				/* ä¸ä½å±¤ãéå§ããã		*/
+	ipcp_finished,			/* ä¸ä½å±¤ãçµäºããã		*/
+	NULL,				/* åéããã			*/
+	NULL,				/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	};
+
+T_PPP_FSM ipcp_fsm = {
+	&ipcp_callbacks,		/* ã³ã¼ã«ããã¯é¢æ°		*/
+	PPP_IPCP,			/* ãã­ãã³ã«			*/
+	};
+
+T_PPP_PROTENT ipcp_protent = {
+	PPP_IPCP,
+	ipcp_init,			/* åæå			*/
+	ipcp_input,			/* å
+¥å				*/
+	ipcp_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	ipcp_lowerup,			/* ä¸ä½å±¤ãèµ·åãã		*/
+	ipcp_lowerdown,			/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	ipcp_open,			/* ãªã¼ãã³ãã			*/
+	ipcp_close,			/* ã¯ã­ã¼ãºãã			*/
+	ip_input,			/* ãã¼ã¿å
+¥åãIPv4 å
+¥å	*/
+	};
+
+T_IFNET ipcp_local_ack_cfg;		/* ç¸æã«è¨±å¯ãããã®èªæ§ææ
+å ±	*/
+T_IFNET ipcp_remote_ack_cfg;		/* ç¸æã«è¨±å¯ããæ§ææ
+å ±	*/
+
+/*
+ *  ppp_get_ifnet -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã
+ */
+
+T_IFNET *
+ppp_get_ifnet (void)
+{
+	return &ipcp_local_ack_cfg;
+	}
+
+/*
+ *  wait_ipcp -- IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã
+ *
+ *	æ»ãå¤: æ¥ç¶ã«å¤±æããã E_OBJ ãè¿ãã
+ */
+
+ER
+wait_ipcp (void)
+{
+#ifdef PPP_CFG_MODEM
+	ER error;
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+	if (ipcp_fsm.state <= PPP_FSM_STOPPED) {
+
+#ifdef PPP_CFG_MODEM
+
+		/* ã¢ãã ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		if ((error = wait_modem()) != E_OK)
+			return error;
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+		/*
+		 * ååãªã¼ãã³ããç¸æããã®æ¥ç¶å¾
+ã¡ãªã LCP ãä¸åº¦ã¯ã­ã¼ãºãã
+		 * è½åãªã¼ãã³ç¶æ
+ã§ãåãªã¼ãã³ããã
+		 */
+		lcp_close();
+		lcp_open(PPP_OPEN_ACTIVE);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+		}
+
+	if (ipcp_fsm.state != PPP_FSM_OPENED) {
+		/* IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		wai_sem(SEM_IPCP_READY);
+		if (ipcp_fsm.state != PPP_FSM_OPENED)
+			return E_OBJ;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  ipcp_init -- IPCP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+ipcp_init (void)
+{
+	fsm_init(&ipcp_fsm);
+	}
+
+/*
+ *  ipcp_input -- IPCP å
+¥å
+ */
+
+static void
+ipcp_input (T_NET_BUF *input)
+{
+	NET_COUNT_PPP_IPCP(net_count_ppp_ipcp_in_octets,  input->len);
+	NET_COUNT_PPP_IPCP(net_count_ppp_ipcp_in_packets, 1);
+	fsm_input(&ipcp_fsm, input);
+	}
+
+/*
+ *  ipcp_resetci -- IPCPã®æ§ææ
+å ±ããªã»ããããã
+ */
+
+static void
+ipcp_resetci (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipcp_local_neg_cfg = ipcp_local_def_cfg;
+	memset((void*)&ipcp_local_ack_cfg, 0, sizeof(T_IFNET));
+
+	/* ç¸æã®æ§ææ
+å ±ã®åæè¨­å® */
+	ipcp_remote_neg_cfg = ipcp_remote_def_cfg;
+	memset((void*)&ipcp_remote_ack_cfg, 0, sizeof(T_IFNET));
+	}
+
+/*
+ *  ipcp_cilen -- æ§ææ
+å ±ã®é·ããè¿ãã
+ */
+
+static int_t
+ipcp_cilen (T_PPP_FSM *fsm)
+{
+	int_t cilen = 0;
+
+	cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* IPv4 ã¢ãã¬ã¹ */
+
+	return cilen;
+	}
+
+/*
+ *  ipcp_addci -- IPCPã®æ§ææ
+å ±ãè¿½å ããã
+ */
+
+static void
+ipcp_addci (T_PPP_FSM *fsm, T_NET_BUF *output)
+{
+	uint8_t *buf;
+
+	buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/* IPv4 ã¢ãã¬ã¹ãªãã·ã§ã³ãè¿½å ããã */
+	*buf ++ = IPCP_CIT_ADDR;
+	*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+	ahtonl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr);
+	buf += sizeof(uint32_t);
+	}
+
+/*
+ *  ipcp_ackci -- ACK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	true  ACK ã¯æ­£å¸¸
+ *		false ACK ã¯ç°å¸¸
+ */
+
+static bool_t
+ipcp_ackci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	/*
+	 *  æ§ææ
+å ±ã¯éä¿¡ããé ã«å®å
+¨ã«ä¸è´ããªããã°ãªããªãã
+	 *  å¾ã£ã¦ãipcp_addci ã§ä½æããé ã«è§£æããã
+	 */
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	||
+	    *buf ++ != IPCP_CIT_ADDR			||
+	    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
+	    nahcmpl(buf, ipcp_local_neg_cfg.in4_ifaddr.addr))
+		return false;
+	buf += sizeof(uint32_t);
+	len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+
+	return true;
+	}
+
+/*
+ *  ipcp_nakci -- NAK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  NAK ã¯æ­£å¸¸
+ *		0  NAK ã¯ç°å¸¸
+ */
+
+static int_t
+ipcp_nakci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint32_t	cilong;
+	uint16_t	len;
+	uint8_t		*buf, cilen;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipcp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == IPCP_CIT_ADDR				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)) {
+	    	ntoahl(cilong, buf + 2);
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		new_cfg.in4_ifaddr.addr = cilong;
+		}
+
+	/* å¾ã¯ç¡è¦ããã*/
+	while (len > sizeof(T_PPP_CI_HDR)) {
+		cilen = *(buf + 1);
+		if (len < cilen)
+			return 0;
+		buf += cilen;
+		len -= cilen;
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipcp_local_neg_cfg = new_cfg;
+               		
+	return 1;
+	}
+
+/*
+ *  ipcp_rejci -- REJ ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  REJ ã¯æ­£å¸¸
+ *		0  REJ ã¯ç°å¸¸
+ */
+
+static int_t
+ipcp_rejci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipcp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == IPCP_CIT_ADDR				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)) {
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		new_cfg.in4_ifaddr.addr = 0;
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipcp_local_neg_cfg = new_cfg;
+
+	return 1;
+	}
+
+/*
+ *  ipcp_reqci -- ç¸æã®æ§ææ
+å ±ãè§£æããã
+ */
+
+static int_t
+ipcp_reqci (T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output)
+{
+	uint32_t	addr;
+	uint16_t	code, final, len, cilen;
+	uint8_t		*np, *rp, *ap, *cp, type = 0;
+
+	rp = ap = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+				/* rp: REJãap: ACK ãã CI ã®ãã¤ã³ã¿	*/
+				/* æå¦ããå ´åã¯ãå¼æ° buf ã«ä¸æ¸ãããã	*/
+	len   = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	np    = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	final = PPP_CONFACK;	/* æçµçã«éä¿¡ããã³ã¼ã */
+	while (len > 0) {
+		code = PPP_CONFACK;
+		cp   = ap;	/* cp: ç¾å¨å¦çä¸­ã® CI	*/
+
+		if (len < sizeof(T_PPP_CI_HDR)) {
+
+			/* æ®ãã CI ãããããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPCP] bad CI len: %d.", len);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+
+		type  = *ap ++;	/* CI ã®å		*/
+		cilen = *ap ++;	/* CI ã®é·ã		*/
+		if (len < cilen) {
+
+			/* æ®ãã CI é·ããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPCP] bad CI len: %d.", cilen);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+		len -= sizeof(T_PPP_CI_HDR);
+
+		/* CI ã®åã«ããåå²ããã*/
+		switch (type) {
+
+		case IPCP_CIT_ADDR:	/* IPv4 ã¢ãã¬ã¹ */
+
+		 	/* CI é·ããããã + 4 ãªã¯ãããã§ãªããã°ã¨ã©ã¼ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t))
+				code = PPP_CONFREJ;
+			else {
+				ntoahl(addr, ap);
+				if (addr != ipcp_remote_neg_cfg.in4_ifaddr.addr &&
+				    (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr != 0)) {
+					*np ++ = IPCP_CIT_ADDR;
+					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+					ahtonl(np, ipcp_remote_neg_cfg.in4_ifaddr.addr);
+					np  += sizeof(uint32_t);
+					code = PPP_CONFNAK;
+					}
+#if 1	/* è¦ç¢ºèª */
+				else if (addr == 0 && ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
+#else
+				else if (addr == 0 || ipcp_remote_neg_cfg.in4_ifaddr.addr == 0)
+#endif
+					code = PPP_CONFREJ;
+				else
+					ipcp_remote_neg_cfg.in4_ifaddr.addr = addr;
+				}
+			break;
+
+		default:
+			syslog(LOG_INFO, "[PPP/IPCP] unexp opt: %d.", type);
+			code = PPP_CONFREJ;
+			break;
+			}
+endswitch:
+
+		if (code == PPP_CONFNAK) {
+			/* CI ã®åã Magic Number ã®å ´åãé¤ãã¦ãNAK ã®åæ°ã	*/
+			/* æå¤§å¤ MAX_PPP_FAILURES  ãè¶
+ãããæå¦ããã	*/
+			if (fsm->failures >= MAX_PPP_FAILURES)
+				code = PPP_CONFREJ;
+			else if (final != PPP_CONFREJ)
+				final = PPP_CONFNAK;
+			}
+
+		/* ãã® CI ãæå¦ãã */
+		if (code == PPP_CONFREJ) {
+			if (rp < cp)		/* åã«è©°ããã*/
+				memcpy(rp, cp, cilen);
+			rp += cilen;
+			final = PPP_CONFREJ;
+			}
+
+		ap   += cilen - sizeof(T_PPP_CI_HDR);
+		len  -= cilen - sizeof(T_PPP_CI_HDR);
+		}
+
+	/* æçµçãªé·ããèª¿æ´ããã*/
+	switch (final) {
+	case PPP_CONFNAK:
+		output->len = np - output->buf;
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		break;
+	case PPP_CONFREJ:
+		memcpy(output->buf, input->buf, output->len = rp - input->buf);
+		break;
+	case PPP_CONFACK:
+		memcpy(output->buf, input->buf, input->len);
+		break;
+		}
+
+	return final;
+	}
+
+/*
+ *  ipcp_up -- ãªã³ã¯æ¥ç¶ãç¢ºç«ããã
+ */
+
+static void
+ipcp_up (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipcp_local_ack_cfg = ipcp_local_neg_cfg;
+
+	/*
+	 *  ãµãããããã¹ã¯ã¨
+	 *  ã­ã¼ã«ã«ã»ãã­ã¼ãã­ã£ã¹ã IPv4 ã¢ãã¬ã¹ãè¨­å®ããã
+	 */
+	ipcp_local_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_local_neg_cfg.in4_ifaddr.addr);
+
+	/* ç¸æã®æ§ææ
+å ±ã®åæè¨­å® */
+	ipcp_remote_ack_cfg = ipcp_remote_neg_cfg;
+
+	/*
+	 *  ãµãããããã¹ã¯ã¨
+	 *  ã­ã¼ã«ã«ã»ãã­ã¼ãã­ã£ã¹ã IPv4 ã¢ãã¬ã¹ãè¨­å®ããã
+	 */
+	ipcp_remote_ack_cfg.in4_ifaddr.mask = MAKE_IPV4_LOCAL_MASK(ipcp_remote_neg_cfg.in4_ifaddr.addr);
+
+	sig_sem(SEM_IPCP_READY);
+
+	syslog(LOG_NOTICE, "[PPP/IPCP] up, Local IPv4 Addr: %s, Remote IPv4 Addr: %s.",
+	                   ip2str(NULL, &ipcp_local_neg_cfg.in4_ifaddr.addr),
+	                   ip2str(NULL, &ipcp_remote_neg_cfg.in4_ifaddr.addr));
+	}
+
+/*
+ *  ipcp_down -- ãªã³ã¯æ¥ç¶ãè§£æ¾ããã
+ */
+
+static void
+ipcp_down (T_PPP_FSM *fsm)
+{
+	sig_sem(SEM_IPCP_READY);
+	syslog(LOG_NOTICE, "[PPP/IPCP] down.");
+	}
+
+/*
+ *  ipcp_finished -- ä¸ä½å±¤ãçµäºããã
+ */
+
+static void
+ipcp_finished (T_PPP_FSM *fsm)
+{
+	}
+
+/*
+ *  ipcp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+ipcp_protrej (void)
+{
+	fsm_lowerdown(&ipcp_fsm);
+	}
+
+/*
+ *  ipcp_lowerup -- IPCP ä¸ä½å±¤ãèµ·åããã
+ */
+
+static void
+ipcp_lowerup (void)
+{
+	fsm_lowerup(&ipcp_fsm);
+	}
+
+/*
+ *  ipcp_lowerdown -- IPCP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+static void
+ipcp_lowerdown (void)
+{
+	fsm_lowerdown(&ipcp_fsm);
+	}
+
+/*
+ *  ipcp_open -- IPCP ã®ãªã¼ãã³
+ */
+
+static void
+ipcp_open (void)
+{
+	fsm_open(&ipcp_fsm);
+	}
+
+/*
+ *  ipcp_close -- IPCP ã®ã¯ã­ã¼ãº
+ */
+
+static void
+ipcp_close (void)
+{
+	fsm_close(&ipcp_fsm);
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ipcp.h	(revision 317)
@@ -0,0 +1,143 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipcp.h - IP Control Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/ipcp.h,v 1.9.2.1 1999/08/29 15:47:01 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipcp.h,v 1.30.2.2 2000/06/15 17:08:28 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_IPCP_H_
+#define _PPP_IPCP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  IPCP ã®æ§ææ
+å ± (CI)
+ */
+
+/*
+ *  CI ã®å
+ */
+
+#define IPCP_CIT_ADDRS		UINT_C(1)	/* IP ã¢ãã¬ã¹ (å»æ£)	*/
+#define IPCP_CIT_COMP_TYPE	UINT_C(2)	/* å§ç¸®æ¹å¼		*/
+#define IPCP_CIT_ADDR		UINT_C(3)	/* IP ã¢ãã¬ã¹		*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef T_PPP_FSM_DEFINED
+extern T_PPP_FSM	ipcp_fsm;
+#endif	/* of #ifdef T_PPP_FSM_DEFINED */
+
+#ifdef T_PPP_PROTENT_DEFINED
+extern T_PPP_PROTENT	ipcp_protent;
+#endif	/* of #ifdef T_PPP_PROTENT_DEFINED */
+
+extern T_IFNET	ipcp_local_ack_cfg;
+extern T_IFNET	ipcp_remote_ack_cfg;
+
+/*
+ *  é¢æ°
+ */
+
+extern ER wait_ipcp (void);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_IPCP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.c	(revision 317)
@@ -0,0 +1,713 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipv6cp.c - PPP IP Control Protocol.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	PPP IP Control Protocol (IPV6CP) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipv6cp.c,v 1.90.2.4 2000/08/19 09:30:03 brian Exp $
+ *
+ *	TODO:
+ *		o Support IPADDRS properly
+ *		o Validate the length in IpcpDecodeConfig
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_ipv6cp.h>
+#include <net/ppp_modem.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+static void ipv6cp_init (void);
+static void ipv6cp_input (T_NET_BUF *input);
+static void ipv6cp_protrej (void);
+static void ipv6cp_lowerup (void);
+static void ipv6cp_lowerdown (void);
+static void ipv6cp_open (void);
+static void ipv6cp_close (void);
+
+/*
+ * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢
+ */
+
+static void  ipv6cp_resetci(T_PPP_FSM *fsm);	/* èªæ§ææ
+å ±ããªã»ããããã	*/
+static int_t ipv6cp_cilen	(T_PPP_FSM *fsm);	/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+static void  ipv6cp_addci	(T_PPP_FSM *fsm, T_NET_BUF *output);
+						/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+static bool_t  ipv6cp_ackci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipv6cp_nakci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t  ipv6cp_rejci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+static int_t ipv6cp_reqci	(T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output);
+						/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+static void ipv6cp_up	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+static void ipv6cp_down	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+static void ipv6cp_finished(T_PPP_FSM *fsm);	/* ä¸ä½å±¤ãçµäºããã		*/
+
+/*
+ *  å¤æ°
+ */
+
+static T_IFNET ipv6cp_local_def_cfg = {		/* èªæ§ææ
+å ±ã®è¦å®å¤		*/
+	NULL,					/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{},					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	{},					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	0,					/* ãã©ã°					*/
+	};
+
+static T_IFNET ipv6cp_remote_def_cfg = {	/* ç¸æã®æ§ææ
+å ±ã®è¦å®å¤	*/
+	NULL,					/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	{},					/* IPv6 ã¢ãã¬ã¹æ
+å ±				*/
+	{},					/* ãã«ãã­ã£ã¹ã IPv6 ã¢ãã¬ã¹			*/
+	0,					/* ãã©ã°					*/
+	};
+
+static T_IFNET ipv6cp_local_neg_cfg;		/* ãã´ä¸­ã®èªæ§ææ
+å ±		*/
+
+static T_IFNET ipv6cp_remote_neg_cfg;		/* ãã´ä¸­ã®ç¸æã®æ§ææ
+å ±		*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_FSM_CALLBACKS ipv6cp_callbacks = {
+	ipv6cp_resetci,			/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	ipv6cp_cilen,			/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	ipv6cp_addci,			/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	ipv6cp_ackci,			/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_nakci,			/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_rejci,			/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	ipv6cp_reqci,			/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	ipv6cp_up,			/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+	ipv6cp_down,			/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+	NULL,				/* ä¸ä½å±¤ãéå§ããã		*/
+	ipv6cp_finished,			/* ä¸ä½å±¤ãçµäºããã		*/
+	NULL,				/* åéããã			*/
+	NULL,				/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	};
+
+T_PPP_FSM ipv6cp_fsm = {
+	&ipv6cp_callbacks,		/* ã³ã¼ã«ããã¯é¢æ°		*/
+	PPP_IPV6CP,			/* ãã­ãã³ã«			*/
+	};
+
+T_PPP_PROTENT ipv6cp_protent = {
+	PPP_IPV6CP,
+	ipv6cp_init,			/* åæå			*/
+	ipv6cp_input,			/* å
+¥å				*/
+	ipv6cp_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	ipv6cp_lowerup,			/* ä¸ä½å±¤ãèµ·åãã		*/
+	ipv6cp_lowerdown,		/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	ipv6cp_open,			/* ãªã¼ãã³ãã			*/
+	ipv6cp_close,			/* ã¯ã­ã¼ãºãã			*/
+	ip6_input,			/* ãã¼ã¿å
+¥åãIPv6 å
+¥å	*/
+	};
+
+T_IFNET ipv6cp_local_ack_cfg;		/* ç¸æã«è¨±å¯ãããã®èªæ§ææ
+å ±	*/
+T_IFNET ipv6cp_remote_ack_cfg;		/* ç¸æã«è¨±å¯ããæ§ææ
+å ±	*/
+
+/*
+ *  ppp_get_ifnet -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ãè¿ãã
+ */
+
+T_IFNET *
+ppp_get_ifnet (void)
+{
+	return &ipv6cp_local_ack_cfg;
+	}
+
+/*
+ *  wait_ipv6cp -- IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã
+ *
+ *	æ»ãå¤: æ¥ç¶ã«å¤±æããã E_OBJ ãè¿ãã
+ */
+
+ER
+wait_ipv6cp (void)
+{
+#ifdef PPP_CFG_MODEM
+	ER error;
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+	if (ipv6cp_fsm.state <= PPP_FSM_STOPPED) {
+
+#ifdef PPP_CFG_MODEM
+
+		/* ã¢ãã ã®æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		if ((error = wait_modem()) != E_OK)
+			return error;
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+		/*
+		 * ååãªã¼ãã³ããç¸æããã®æ¥ç¶å¾
+ã¡ãªã LCP ãä¸åº¦ã¯ã­ã¼ãºãã
+		 * è½åãªã¼ãã³ç¶æ
+ã§ãåãªã¼ãã³ããã
+		 */
+		lcp_close();
+		lcp_open(PPP_OPEN_ACTIVE);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+		}
+
+	if (ipv6cp_fsm.state != PPP_FSM_OPENED) {
+		/* IP æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		wai_sem(SEM_IPV6CP_READY);
+		if (ipv6cp_fsm.state != PPP_FSM_OPENED)
+			return E_OBJ;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  ipv6cp_init -- IPV6CP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+ipv6cp_init (void)
+{
+	fsm_init(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_input -- IPV6CP å
+¥å
+ */
+
+static void
+ipv6cp_input (T_NET_BUF *input)
+{
+	NET_COUNT_PPP_IPV6CP(net_count_ppp_ipv6cp_in_octets,  input->len);
+	NET_COUNT_PPP_IPV6CP(net_count_ppp_ipv6cp_in_packets, 1);
+	fsm_input(&ipv6cp_fsm, input);
+	}
+
+/*
+ *  ipv6cp_resetci -- IPV6CPã®æ§ææ
+å ±ããªã»ããããã
+ */
+
+static void
+ipv6cp_resetci (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_local_neg_cfg = ipv6cp_local_def_cfg;
+	memset((void*)&ipv6cp_local_ack_cfg, 0, sizeof(T_IFNET));
+
+	/* ç¸æã®æ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_remote_neg_cfg = ipv6cp_remote_def_cfg;
+	memset((void*)&ipv6cp_remote_ack_cfg, 0, sizeof(T_IFNET));
+	}
+
+/*
+ *  ipv6cp_cilen -- æ§ææ
+å ±ã®é·ããè¿ãã
+ */
+
+static int_t
+ipv6cp_cilen (T_PPP_FSM *fsm)
+{
+	int_t cilen = 0;
+
+	cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* IPv6 ã¢ãã¬ã¹ */
+
+	return cilen;
+	}
+
+/*
+ *  ipv6cp_addci -- IPV6CPã®æ§ææ
+å ±ãè¿½å ããã
+ */
+
+static void
+ipv6cp_addci (T_PPP_FSM *fsm, T_NET_BUF *output)
+{
+	uint8_t *buf;
+
+	buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/* IPv6 ã¢ãã¬ã¹ãªãã·ã§ã³ãè¿½å ããã */
+	*buf ++ = IPV6CP_CIT_ADDR;
+	*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+	ahtonl(buf, ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr);
+	buf += sizeof(uint32_t);
+	}
+
+/*
+ *  ipv6cp_ackci -- ACK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	true  ACK ã¯æ­£å¸¸
+ *		false ACK ã¯ç°å¸¸
+ */
+
+static bool_t
+ipv6cp_ackci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	/*
+	 *  æ§ææ
+å ±ã¯éä¿¡ããé ã«å®å
+¨ã«ä¸è´ããªããã°ãªããªãã
+	 *  å¾ã£ã¦ãipv6cp_addci ã§ä½æããé ã«è§£æããã
+	 */
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	||
+	    *buf ++ != IPV6CP_CIT_ADDR			||
+	    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
+	    nahcmpl(buf, ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr))
+		return false;
+	buf += sizeof(uint32_t);
+	len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+
+	return true;
+	}
+
+/*
+ *  ipv6cp_nakci -- NAK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  NAK ã¯æ­£å¸¸
+ *		0  NAK ã¯ç°å¸¸
+ */
+
+static int_t
+ipv6cp_nakci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint32_t	addr;
+	uint16_t	len;
+	uint8_t		*buf, cilen;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipv6cp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(addr)		&&
+	    * buf      == IPV6CP_CIT_ADDR			&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(addr)) {
+		memcpy(&new_cfg.in6_ifaddrs[0].addr, buf + 2, sizeof(addr));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(addr);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(addr);
+		}
+
+	/* å¾ã¯ç¡è¦ããã*/
+	while (len > sizeof(T_PPP_CI_HDR)) {
+		cilen = *(buf + 1);
+		if (len < cilen)
+			return 0;
+		buf += cilen;
+		len -= cilen;
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipv6cp_local_neg_cfg = new_cfg;
+               		
+	return 1;
+	}
+
+/*
+ *  ipv6cp_rejci -- REJ ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  REJ ã¯æ­£å¸¸
+ *		0  REJ ã¯ç°å¸¸
+ */
+
+static int_t
+ipv6cp_rejci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_IFNET		new_cfg;
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = ipv6cp_local_neg_cfg;
+
+	/* ADDR ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr)	&&
+	    * buf      == IPV6CP_CIT_ADDR					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr)) {
+		memcpy(&new_cfg.in6_ifaddrs[0].addr, &in6_addr_unspecified,
+		 sizeof(new_cfg.in6_ifaddrs[0].addr));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(new_cfg.in6_ifaddrs[0].addr);
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		ipv6cp_local_neg_cfg = new_cfg;
+
+	return 1;
+	}
+
+/*
+ *  ipv6cp_reqci -- ç¸æã®æ§ææ
+å ±ãè§£æããã
+ */
+
+static int_t
+ipv6cp_reqci (T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output)
+{
+	T_IN6_ADDR	addr;
+	uint16_t	code, final, len, cilen;
+	uint8_t		*np, *rp, *ap, *cp, type = 0;
+
+	rp = ap = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+				/* rp: REJãap: ACK ãã CI ã®ãã¤ã³ã¿	*/
+				/* æå¦ããå ´åã¯ãå¼æ° buf ã«ä¸æ¸ãããã	*/
+	len   = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	np    = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	final = PPP_CONFACK;	/* æçµçã«éä¿¡ããã³ã¼ã */
+	while (len > 0) {
+		code = PPP_CONFACK;
+		cp   = ap;	/* cp: ç¾å¨å¦çä¸­ã® CI	*/
+
+		if (len < sizeof(T_PPP_CI_HDR)) {
+
+			/* æ®ãã CI ãããããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPV6CP] bad CI len: %d.", len);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+
+		type  = *ap ++;	/* CI ã®å		*/
+		cilen = *ap ++;	/* CI ã®é·ã		*/
+		if (len < cilen) {
+
+			/* æ®ãã CI é·ããç­ã */
+			syslog(LOG_NOTICE, "[PPP/IPV6CP] bad CI len: %d.", cilen);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len  = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+		len -= sizeof(T_PPP_CI_HDR);
+
+		/* CI ã®åã«ããåå²ããã*/
+		switch (type) {
+
+		case IPV6CP_CIT_ADDR:	/* IPv6 ã¢ãã¬ã¹ */
+
+		 	/* CI é·ããããã + 4 ãªã¯ãããã§ãªããã°ã¨ã©ã¼ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(addr))
+				code = PPP_CONFREJ;
+			else {
+				memcpy((uint8_t*)&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr, ap,
+				           sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+				if (!IN6_ARE_ADDR_EQUAL(&addr, &ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr) &&
+				    (IN6_IS_ADDR_UNSPECIFIED(&addr) ||
+				     IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr))) {
+					memcpy(np, (uint8_t*)&ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr,
+					               sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+					*np ++ = IPV6CP_CIT_ADDR;
+					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+					np    += sizeof(ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr);
+					code = PPP_CONFNAK;
+					}
+#if 1	/* è¦ç¢ºèª */
+				else if (IN6_IS_ADDR_UNSPECIFIED(&addr) &&
+				         IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0]))
+#else
+				else if (IN6_IS_ADDR_UNSPECIFIED(&addr) ||
+				         IN6_IS_ADDR_UNSPECIFIED(&ipv6cp_remote_neg_cfg.in6_ifaddrs[0]))
+#endif
+					code = PPP_CONFREJ;
+				else
+					ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr = addr;
+				}
+			break;
+
+		default:
+			syslog(LOG_INFO, "[PPP/IPV6CP] unexp opt: %d.", type);
+			code = PPP_CONFREJ;
+			break;
+			}
+endswitch:
+
+		if (code == PPP_CONFNAK) {
+			/* CI ã®åã Magic Number ã®å ´åãé¤ãã¦ãNAK ã®åæ°ã	*/
+			/* æå¤§å¤ MAX_PPP_FAILURES  ãè¶
+ãããæå¦ããã	*/
+			if (fsm->failures >= MAX_PPP_FAILURES)
+				code = PPP_CONFREJ;
+			else if (final != PPP_CONFREJ)
+				final = PPP_CONFNAK;
+			}
+
+		/* ãã® CI ãæå¦ãã */
+		if (code == PPP_CONFREJ) {
+			if (rp < cp)		/* åã«è©°ããã*/
+				memcpy(rp, cp, cilen);
+			rp += cilen;
+			final = PPP_CONFREJ;
+			}
+
+		ap   += cilen - sizeof(T_PPP_CI_HDR);
+		len  -= cilen - sizeof(T_PPP_CI_HDR);
+		}
+
+	/* æçµçãªé·ããèª¿æ´ããã*/
+	switch (final) {
+	case PPP_CONFNAK:
+		output->len = np - output->buf;
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		break;
+	case PPP_CONFREJ:
+		memcpy(output->buf, input->buf, output->len = rp - input->buf);
+		break;
+	case PPP_CONFACK:
+		memcpy(output->buf, input->buf, input->len);
+		break;
+		}
+
+	return final;
+	}
+
+/*
+ *  ipv6cp_up -- ãªã³ã¯æ¥ç¶ãç¢ºç«ããã
+ */
+
+static void
+ipv6cp_up (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	ipv6cp_local_ack_cfg = ipv6cp_local_neg_cfg;
+
+	sig_sem(SEM_IPV6CP_READY);
+
+	syslog(LOG_NOTICE, "[PPP/IPV6CP] up, Local IPv6 Addr: %s, Remote IPv6 Addr: %s.",
+	                   ipv62str(NULL, &ipv6cp_local_neg_cfg.in6_ifaddrs[0].addr),
+	                   ipv62str(NULL, &ipv6cp_remote_neg_cfg.in6_ifaddrs[0].addr));
+	}
+
+/*
+ *  ipv6cp_down -- ãªã³ã¯æ¥ç¶ãè§£æ¾ããã
+ */
+
+static void
+ipv6cp_down (T_PPP_FSM *fsm)
+{
+	sig_sem(SEM_IPV6CP_READY);
+	syslog(LOG_NOTICE, "[PPP/IPV6CP] down.");
+	}
+
+/*
+ *  ipv6cp_finished -- ä¸ä½å±¤ãçµäºããã
+ */
+
+static void
+ipv6cp_finished (T_PPP_FSM *fsm)
+{
+	}
+
+/*
+ *  ipv6cp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+ipv6cp_protrej (void)
+{
+	fsm_lowerdown(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_lowerup -- IPV6CP ä¸ä½å±¤ãèµ·åããã
+ */
+
+static void
+ipv6cp_lowerup (void)
+{
+	fsm_lowerup(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_lowerdown -- IPV6CP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+static void
+ipv6cp_lowerdown (void)
+{
+	fsm_lowerdown(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_open -- IPV6CP ã®ãªã¼ãã³
+ */
+
+static void
+ipv6cp_open (void)
+{
+	fsm_open(&ipv6cp_fsm);
+	}
+
+/*
+ *  ipv6cp_close -- IPV6CP ã®ã¯ã­ã¼ãº
+ */
+
+static void
+ipv6cp_close (void)
+{
+	fsm_close(&ipv6cp_fsm);
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_ipv6cp.h	(revision 317)
@@ -0,0 +1,143 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * ipv6cp.h - IP Control Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/ipv6cp.h,v 1.9.2.1 1999/08/29 15:47:01 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/ipv6cp.h,v 1.30.2.2 2000/06/15 17:08:28 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_IPV6CP_H_
+#define _PPP_IPV6CP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  IPV6CP ã®æ§ææ
+å ± (CI)
+ */
+
+/*
+ *  CI ã®å
+ */
+
+#define IPV6CP_CIT_ADDRS		UINT_C(1)	/* IP ã¢ãã¬ã¹ (å»æ£)	*/
+#define IPV6CP_CIT_COMP_TYPE	UINT_C(2)	/* å§ç¸®æ¹å¼		*/
+#define IPV6CP_CIT_ADDR		UINT_C(3)	/* IP ã¢ãã¬ã¹		*/
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef T_PPP_FSM_DEFINED
+extern T_PPP_FSM	ipv6cp_fsm;
+#endif	/* of #ifdef T_PPP_FSM_DEFINED */
+
+#ifdef T_PPP_PROTENT_DEFINED
+extern T_PPP_PROTENT	ipv6cp_protent;
+#endif	/* of #ifdef T_PPP_PROTENT_DEFINED */
+
+extern T_IFNET	ipv6cp_local_ack_cfg;
+extern T_IFNET	ipv6cp_remote_ack_cfg;
+
+/*
+ *  é¢æ°
+ */
+
+extern ER wait_ipv6cp (void);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_IPV6CP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_lcp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_lcp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_lcp.c	(revision 317)
@@ -0,0 +1,1375 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * lcp.c - PPP Link Control Protocol.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	      PPP Link Control Protocol (LCP) Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/lcp.c,v 1.81.2.3 2000/08/19 09:30:04 brian Exp $
+ *
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_auth.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+static void lcp_init    (void);
+static void lcp_protrej (void);
+static void lcp_input   (T_NET_BUF *input);
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+static void send_echo_req  (T_PPP_FSM *fsm);
+static void recv_echo_rep  (T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input);
+static void echo_timeout   (void *arg);
+static void echo_lowerup   (void);
+static void echo_lowerdown (void);
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+/*
+ * FSM ããå¼åºãããã³ã¼ã«ããã¯é¢æ°
+ */
+
+static void  lcp_resetci(T_PPP_FSM *fsm);	/* èªæ§ææ
+å ±ããªã»ããããã	*/
+static int_t lcp_cilen	(T_PPP_FSM *fsm);	/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+static void  lcp_addci	(T_PPP_FSM *fsm, T_NET_BUF *output);
+						/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+static bool_t lcp_ackci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t lcp_nakci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+static bool_t lcp_rejci	(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+static int_t lcp_reqci	(T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output);
+						/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+static void lcp_up	(T_PPP_FSM *fsm);	/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+static void lcp_starting(T_PPP_FSM *fsm);	/* ä¸ä½å±¤ãéå§ããã		*/
+static bool_t lcp_extcode	(T_PPP_FSM *fsm, uint8_t code, uint8_t id, T_NET_BUF *input);
+						/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+static void lcp_rprotrej(T_PPP_FSM *fsm, T_NET_BUF *input);
+						/* Proto-REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+/*
+ *  å¤æ°
+ */
+
+static T_LCP_CONFIGS lcp_def_cfg = {		/* æ§ææ
+å ±ã®åæè¨­å®å¤		*/
+	DEF_REMOTE_ACCM,			/* ACCM				*/
+
+#ifdef LCP_CFG_MAGIC
+
+	ULONG_C(0),				/* ãã¸ãã¯çªå·			*/
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+	DEF_PPP_MTU,				/* MRU				*/
+	UINT_C(0),				/* ãªãã·ã§ã³ãã©ã°		*/
+	};
+
+static T_LCP_CONFIGS lcp_local_def_cfg = {	/* èªæ§ææ
+å ±ã®è¦å®å¤		*/
+	DEF_LOCAL_ACCM,				/* ACCM				*/
+
+#ifdef LCP_CFG_MAGIC
+
+	ULONG_C(0),				/* ãã¸ãã¯çªå·			*/
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+	DEF_PPP_MTU,				/* MRU				*/
+	DEF_LCP_LOCAL_CFGS,			/* ãªãã·ã§ã³ãã©ã°		*/
+	};
+
+static T_LCP_CONFIGS lcp_local_neg_cfg;		/* ãã´ä¸­ã®èªæ§ææ
+å ±		*/
+
+static T_LCP_CONFIGS lcp_remote_neg_cfg;	/* ãã´ä¸­ã®ç¸æã®æ§ææ
+å ±		*/
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+static uint8_t echo_pending  = UINT_C(0);
+static uint8_t echo_number   = UINT_C(0);
+static uint8_t timer_running = false;
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_FSM_CALLBACKS lcp_callbacks = {
+	lcp_resetci,			/* èªæ§ææ
+å ±ããªã»ããããã	*/
+	lcp_cilen,			/* æ§ææ
+å ±ã®é·ããè¿ãã		*/
+	lcp_addci,			/* èªæ§ææ
+å ±ãè¿½å ããã		*/
+	lcp_ackci,			/* ACK ãåä¿¡ããã¨ãã®å¦ç	*/
+	lcp_nakci,			/* NAK ãåä¿¡ããã¨ãã®å¦ç	*/
+	lcp_rejci,			/* REJ ãåä¿¡ããã¨ãã®å¦ç	*/
+	lcp_reqci,			/* ç¸æã®æ§ææ
+å ±ãç¢ºèªããã	*/
+	lcp_up,				/* ãªã³ã¯æ¥ç¶ãç¢ºç«ããã		*/
+	lcp_down,			/* ãªã³ã¯æ¥ç¶ãè§£æ¾ããã		*/
+	lcp_starting,			/* ä¸ä½å±¤ãéå§ããã		*/
+	lcp_finished,			/* ä¸ä½å±¤ãçµäºããã		*/
+	NULL,				/* åéããã			*/
+	lcp_extcode,			/* ä¸æãª CP ãåä¿¡ããã¨ãã®å¦ç	*/
+	};
+
+T_PPP_FSM lcp_fsm = {
+	&lcp_callbacks,			/* ã³ã¼ã«ããã¯é¢æ°		*/
+	PPP_LCP,			/* ãã­ãã³ã«			*/
+	};
+
+T_PPP_PROTENT lcp_protent = {
+	PPP_LCP,
+	lcp_init,			/* åæå			*/
+	lcp_input,			/* å
+¥å				*/
+	lcp_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	NULL,				/* ä¸ä½å±¤ãèµ·åãã		*/
+	lcp_lowerdown,			/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	NULL,				/* ãªã¼ãã³ãã			*/
+	lcp_close,			/* ã¯ã­ã¼ãºãã			*/
+	NULL,				/* ãã¼ã¿å
+¥å			*/
+	};
+
+T_LCP_CONFIGS lcp_local_ack_cfg;	/* ç¸æã«è¨±å¯ãããã®èªæ§ææ
+å ±	*/
+T_LCP_CONFIGS lcp_remote_ack_cfg;	/* ç¸æã«è¨±å¯ããæ§ææ
+å ±		*/
+
+/*
+ *  lcp_init -- LCP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+lcp_init (void)
+{
+	fsm_init(&lcp_fsm);
+	}
+
+/*
+ *  lcp_input -- LCP å
+¥å
+ */
+
+static void
+lcp_input (T_NET_BUF *input)
+{
+	NET_COUNT_PPP_LCP(net_count_ppp_lcp_in_octets,  input->len);
+	NET_COUNT_PPP_LCP(net_count_ppp_lcp_in_packets, 1);
+	fsm_input(&lcp_fsm, input);
+	}
+
+/*
+ *  lcp_resetci -- LCPã®æ§ææ
+å ±ããªã»ããããã
+ */
+
+static void
+lcp_resetci (T_PPP_FSM *fsm)
+{
+#ifdef LCP_CFG_MAGIC
+
+	SYSTIM	time;
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+	/* èªæ§ææ
+å ±ã®åæè¨­å® */
+	lcp_local_neg_cfg	= lcp_local_def_cfg;
+	lcp_local_ack_cfg	= lcp_def_cfg;
+
+	/* ç¸æã®æ§ææ
+å ±ã®åæè¨­å® */
+	lcp_remote_neg_cfg	= lcp_def_cfg;
+	lcp_remote_ack_cfg	= lcp_def_cfg;
+
+#ifdef LCP_CFG_MAGIC
+
+	syscall(get_tim(&time));
+	net_srand((unsigned int)time);
+	lcp_local_neg_cfg.magic = net_rand();
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+	auth_reset();
+	}
+
+/*
+ *  lcp_cilen -- æ§ææ
+å ±ã®é·ããè¿ãã
+ */
+
+static int_t
+lcp_cilen (T_PPP_FSM *fsm)
+{
+	int_t cilen = 0;
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_MRU)
+		cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);	/* MRU   */
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCM)
+		cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* ACCM  */
+
+#ifdef LCP_CFG_MAGIC
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_MAGIC)
+		cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);	/* Magic */
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+#ifdef LCP_CFG_PAP
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_PAP)
+		cilen += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);	/* PAP   */
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_PCOMP)
+		cilen += sizeof(T_PPP_CI_HDR);			/* ãã­ãã³ã«å§ç¸® */
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCOMP)
+		cilen += sizeof(T_PPP_CI_HDR);			/* ã¢ãã¬ã¹ã»å¶å¾¡å§ç¸® */
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+	return cilen;
+	}
+
+/*
+ *  lcp_addci -- LCPã®æ§ææ
+å ±ãè¿½å ããã
+ */
+
+static void
+lcp_addci (T_PPP_FSM *fsm, T_NET_BUF *output)
+{
+	uint8_t *buf;
+
+	buf = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/* MRU ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_MRU) {
+		*buf ++ = LCP_CIT_MRU;
+		*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		*((uint16_t*)buf) = htons(lcp_local_neg_cfg.MRU);
+		buf += sizeof(uint16_t);
+		}
+
+	/* ACCM ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCM) {
+		*buf ++ = LCP_CIT_ACCM;
+		*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		ahtonl(buf, lcp_local_neg_cfg.ACCM);
+		buf += sizeof(uint32_t);
+		}
+
+#ifdef LCP_CFG_MAGIC
+
+	/* Magic Number ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_MAGIC) {
+		*buf ++ = LCP_CIT_MAGIC;
+		*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		ahtonl(buf, lcp_local_neg_cfg.magic);
+		buf += sizeof(uint32_t);
+		}
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+#ifdef LCP_CFG_PAP
+
+	/* èªè¨¼ãã­ãã³ã«ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_PAP) {
+		*buf ++ = LCP_CIT_AUTH;
+		*buf ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		*((uint16_t*)buf) = htons(PPP_PAP);
+		buf += sizeof(uint16_t);
+		}
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+	/* ãã­ãã³ã«å§ç¸®ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_PCOMP) {
+		*buf ++ = LCP_CIT_PCOMP;
+		*buf ++ = sizeof(T_PPP_CI_HDR);
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+	/* ã¢ãã¬ã¹ã»å¶å¾¡å§ç¸®ãªãã·ã§ã³ãè¿½å ããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCOMP) {
+		*buf ++ = LCP_CIT_ACCOMP;
+		*buf ++ = sizeof(T_PPP_CI_HDR);
+		}
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+	}
+
+/*
+ *  lcp_ackci -- ACK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	TURE  ACK ã¯æ­£å¸¸
+ *		false ACK ã¯ç°å¸¸
+ */
+
+static bool_t
+lcp_ackci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	uint8_t		*buf;
+	uint16_t	len;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	/*
+	 *  æ§ææ
+å ±ã¯éä¿¡ããé ã«å®å
+¨ã«ä¸è´ããªããã°ãªããªãã
+	 *  å¾ã£ã¦ãlcp_addci ã§ä½æããé ã«è§£æããã
+	 */
+
+	/* MRU ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_MRU) {
+		if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	||
+		    *buf ++ != LCP_CIT_MRU			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)||
+		    *((uint16_t*)buf) != htons(lcp_local_neg_cfg.MRU)	)
+			return false;
+		buf += sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		}
+
+	/* ACCM ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCM) {
+		if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	||
+		    *buf ++ != LCP_CIT_ACCM			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
+		    nahcmpl(buf, lcp_local_neg_cfg.ACCM)        )
+			return false;
+		buf += sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		}
+
+#ifdef LCP_CFG_MAGIC
+
+	/* Magic Number ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_MAGIC) {
+		if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	||
+		    *buf ++ != LCP_CIT_MAGIC			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)||
+		    nahcmpl(buf, lcp_local_neg_cfg.magic)       )
+			return false;
+		buf += sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		}
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+#ifdef LCP_CFG_PAP
+
+	/* èªè¨¼ãã­ãã³ã«ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_PAP) {
+		if (len < sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	||
+		    *buf ++ != LCP_CIT_AUTH			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)||
+		    *((uint16_t*)buf) != htons(PPP_PAP)		)
+			return false;
+		buf += sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		}
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+	/* ãã­ãã³ã«å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_PCOMP) {
+		if (len < sizeof(T_PPP_CI_HDR)			||
+		    *buf ++ != LCP_CIT_PCOMP			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR))
+			return false;
+		len -= sizeof(T_PPP_CI_HDR);
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+	/* ã¢ãã¬ã¹ã»å¶å¾¡å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (lcp_local_neg_cfg.options & LCP_CFG_ACCOMP) {
+		if (len < sizeof(T_PPP_CI_HDR)			||
+		    *buf ++ != LCP_CIT_ACCOMP			||
+		    *buf ++ != sizeof(T_PPP_CI_HDR))
+			return false;
+		len -= sizeof(T_PPP_CI_HDR);
+		}
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+	return true;
+	}
+
+/*
+ *  lcp_nakci -- NAK ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  NAK ã¯æ­£å¸¸
+ *		0  NAK ã¯ç°å¸¸
+ */
+
+static int_t
+lcp_nakci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_LCP_CONFIGS	new_cfg;
+	bool_t		loop = false;	/* ã«ã¼ãããã¯ããã§ãã¯ */
+	uint32_t	cilong;
+	uint16_t	cishort, len;
+	uint8_t		*buf, cilen;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = lcp_local_neg_cfg;
+
+	/* MRU ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)		&&
+	    * buf      == LCP_CIT_MRU				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_MRU)) {
+	    	cishort = ntohs(*((uint16_t*)(buf + 2)));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		if (cishort <= lcp_local_neg_cfg.MRU || cishort <= DEF_PPP_MTU)
+			new_cfg.MRU = cishort;
+		}
+
+	/* ACCM ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == LCP_CIT_ACCM				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_ACCM)) {
+	    	ntoahl(cilong, buf + 2);
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		new_cfg.ACCM |= cilong;
+		}
+
+#ifdef LCP_CFG_MAGIC
+
+	/* Magic Number ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == LCP_CIT_MAGIC				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_MAGIC)) {
+	    	ntoahl(cilong, buf + 2);
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		new_cfg.magic = cilong;
+		loop = true;
+		}
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+#ifdef LCP_CFG_PAP
+
+	/* èªè¨¼ãã­ãã³ã«ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)		&&
+	    * buf      == LCP_CIT_AUTH				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_PAP)) {
+	    	cishort = ntohs(*((uint16_t*)(buf + 2)));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		if (cishort == PPP_PAP)
+			new_cfg.options &= ~LCP_CFG_PAP;
+		else
+			return 0;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+	/* ãã­ãã³ã«å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR)				&&
+	    * buf      == LCP_CIT_PCOMP				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR)			&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_PCOMP)) {
+		buf += sizeof(T_PPP_CI_HDR);
+		len -= sizeof(T_PPP_CI_HDR);
+		new_cfg.options &= ~LCP_CFG_PCOMP;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+	/* ã¢ãã¬ã¹ã»å¶å¾¡å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR)				&&
+	    * buf      == LCP_CIT_ACCOMP			&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR)			&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_ACCOMP)) {
+		buf += sizeof(T_PPP_CI_HDR);
+		len -= sizeof(T_PPP_CI_HDR);
+		new_cfg.options &= ~LCP_CFG_ACCOMP;
+		}
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+	/* å¾ã¯ç¡è¦ããã*/
+	while (len > sizeof(T_PPP_CI_HDR)) {
+		cilen = *(buf + 1);
+		if (len < cilen)
+			return 0;
+		buf += cilen;
+		len -= cilen;
+		}
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED) {
+		if (loop) {
+			syslog(LOG_WARNING, "[PPP/LCP] line looped.");
+			lcp_close();
+			}
+		lcp_local_neg_cfg = new_cfg;
+		}
+	return 1;
+	}
+
+/*
+ *  lcp_rejci -- REJ ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *	æ»ãå¤:	1  REJ ã¯æ­£å¸¸
+ *		0  REJ ã¯ç°å¸¸
+ */
+
+static int_t
+lcp_rejci (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_LCP_CONFIGS	new_cfg;
+	uint32_t	cilong;
+	uint16_t	cishort, len;
+	uint8_t		*buf;
+
+	buf = input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	len = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+	new_cfg = lcp_local_neg_cfg;
+
+	/* MRU ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)		&&
+	    * buf      == LCP_CIT_MRU					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_MRU)) {
+	    	cishort = ntohs(*((uint16_t*)(buf + 2)));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		if (cishort != lcp_local_neg_cfg.MRU)
+			return 0;
+		else
+			new_cfg.options &= ~LCP_CFG_MRU;
+		}
+		
+	/* ACCM ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == LCP_CIT_ACCM					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_ACCM)) {
+	    	ntoahl(cilong, buf + 2);
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		if (cilong != lcp_local_neg_cfg.ACCM)
+			return 0;
+		else
+			new_cfg.options &= ~LCP_CFG_ACCM;
+		}
+
+#ifdef LCP_CFG_MAGIC
+
+	/* Magic Number ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)		&&
+	    * buf      == LCP_CIT_MAGIC					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint32_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_MAGIC)) {
+	    	ntoahl(cilong, buf + 2);
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+		if (cilong != lcp_local_neg_cfg.magic)
+			return 0;
+		else
+			new_cfg.options &= ~LCP_CFG_MAGIC;
+		}
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+#ifdef LCP_CFG_PAP
+
+	/* èªè¨¼ãã­ãã³ã«ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)		&&
+	    * buf      == LCP_CIT_AUTH					&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR) + sizeof(uint16_t)	&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_PAP)) {
+	    	cishort = ntohs(*((uint16_t*)(buf + 2)));
+		buf += sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		len -= sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+		if (cishort != PPP_PAP)
+			return 0;
+		else
+			new_cfg.options &= ~LCP_CFG_PAP;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+	/* ãã­ãã³ã«å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR)				&&
+	    * buf      == LCP_CIT_PCOMP				&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR)			&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_PCOMP)) {
+		buf += sizeof(T_PPP_CI_HDR);
+		len -= sizeof(T_PPP_CI_HDR);
+		new_cfg.options &= ~LCP_CFG_PCOMP;
+		}
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+	/* ã¢ãã¬ã¹ã»å¶å¾¡å§ç¸®ãªãã·ã§ã³ãè§£æããã */
+	if (len >= sizeof(T_PPP_CI_HDR)				&&
+	    * buf      == LCP_CIT_ACCOMP			&&
+	    *(buf + 1) == sizeof(T_PPP_CI_HDR)			&&
+	    (lcp_local_neg_cfg.options & LCP_CFG_ACCOMP)) {
+		buf += sizeof(T_PPP_CI_HDR);
+		len -= sizeof(T_PPP_CI_HDR);
+		new_cfg.options &= ~LCP_CFG_ACCOMP;
+		}
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+	/* é·ãã 0 ã§ãªããã°ã¨ã©ã¼ */
+	if (len != 0)
+		return 0;
+
+	/* æ°ãããªãã·ã§ã³ãè¨­å®ããã*/
+	if (fsm->state != PPP_FSM_OPENED)
+		lcp_local_neg_cfg = new_cfg;
+
+	return 1;
+	}
+
+/*
+ *  lcp_reqci -- ç¸æã®æ§ææ
+å ±ãè§£æããã
+ */
+
+static int_t
+lcp_reqci (T_PPP_FSM *fsm, T_NET_BUF *input, T_NET_BUF *output)
+{
+#if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC
+
+	uint32_t	cilong;
+
+#endif	/* of #if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC */
+
+	uint16_t	code, final, len, cilen, cishort;
+	uint8_t		*np, *rp, *ap, *cp, type = 0;
+
+	rp = ap = input->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+				/* rp: REJãap: ACK ãã CI ã®ãã¤ã³ã¿		*/
+				/* æå¦ããå ´åã¯ãå¼æ° input ã«ä¸æ¸ãããã	*/
+	len   = input->len - (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	np    = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+	final = PPP_CONFACK;	/* æçµçã«éä¿¡ããã³ã¼ã */
+	while (len > 0) {
+		code = PPP_CONFACK;
+		cp   = ap;	/* cp: ç¾å¨å¦çä¸­ã® CI	*/
+
+		if (len < sizeof(T_PPP_CI_HDR)) {
+
+			/* æ®ãã CI ãããããç­ã */
+			syslog(LOG_WARNING, "[PPP/LCP] bad CI len: %d.", len);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len   = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+
+		type  = *ap ++;	/* CI ã®å		*/
+		cilen = *ap ++;	/* CI ã®é·ã		*/
+		if (len < cilen) {
+
+			/* æ®ãã CI é·ããç­ã */
+			syslog(LOG_WARNING, "[PPP/LCP] bad CI len: %d.", cilen);
+			cilen = len;	/* ãã¼ã¿é·ãç°å¸¸ã®å ´åã®å¦ç½®	*/
+			len   = 0;	/* ã«ã¼ãããæããã		*/
+			code  = PPP_CONFREJ;
+			goto endswitch;
+			}
+		len -= sizeof(T_PPP_CI_HDR);
+
+		/* CI ã®åã«ããåå²ããã*/
+		switch (type) {
+
+		case LCP_CIT_MRU:	/* æå¤§åä¿¡é (Maximum Receive Unit) */
+
+#if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MRU) == 0
+
+			code = PPP_CONFREJ;
+
+#else	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MRU) == 0 */
+
+		 	/* CI é·ããããã + 2 ãªã¯ãããã§ãªããã° REJ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(uint16_t))
+				code = PPP_CONFREJ;
+			{
+				cishort = ntohs(*(uint16_t*)ap);
+
+				/* æå°åä¿¡éããå°ãããã° NAK */
+				if (cishort < MIN_PPP_MTU) {
+					*np ++ = LCP_CIT_MRU;
+					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint16_t);
+					*((uint16_t*)np) = htons(MIN_PPP_MTU);
+					np  += sizeof(uint16_t);
+					code = PPP_CONFNAK;
+					}
+				else {
+					lcp_remote_neg_cfg.MRU = cishort;
+					lcp_remote_neg_cfg.options |= LCP_CFG_MRU;
+					}
+				}
+
+#endif	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MRU) == 0 */
+
+			break;
+
+		case LCP_CIT_ACCM:	/* Async Control Character Map */
+
+#if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCM) == 0
+
+			code = PPP_CONFREJ;
+
+#else	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCM) == 0 */
+
+		 	/* CI é·ããããã + 4 ãªã¯ãããã§ãªããã° REJ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t))
+				code = PPP_CONFREJ;
+			else {
+				ntoahl(lcp_remote_neg_cfg.ACCM, ap);
+				lcp_remote_neg_cfg.options |= LCP_CFG_ACCM;
+				}
+
+#endif	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCM) == 0 */
+
+			break;
+
+		case LCP_CIT_MAGIC:	/* ãã¸ãã¯çªå· */
+
+#if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC) == 0
+
+			code = PPP_CONFREJ;
+
+#else	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC) == 0 */
+
+		 	/* CI é·ããããã + 4 ãªã¯ãããã§ãªããã° REJ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR) + sizeof(uint32_t))
+				code = PPP_CONFREJ;
+			else {
+				ntoahl(cilong, ap);
+
+				/* çªå·ãèªåã¨åããªã NAK */
+				if (cilong == lcp_local_neg_cfg.magic) {
+					cilong = net_rand();
+					*np ++ = LCP_CIT_MAGIC;
+					*np ++ = sizeof(T_PPP_CI_HDR) + sizeof(uint32_t);
+					ahtonl(np, cilong);
+					np  += sizeof(uint32_t);
+					code = PPP_CONFNAK;
+					}
+				else {
+					lcp_remote_neg_cfg.magic = cilong;
+					lcp_remote_neg_cfg.options |= LCP_CFG_MAGIC;
+					}
+				}
+
+#endif	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC) == 0 */
+
+			break;
+
+#ifdef LCP_CFG_PAP
+		/* CHAP ã¯å®è£
+äºå®	*/
+
+		case LCP_CIT_AUTH:	/* èªè¨¼ãã­ãã³ã« */
+
+		 	/* CI é·ããããã + 2 ãªã¯ãããããç­ãã¨ãã¯ã¨ã©ã¼ */
+		 	if (cilen < sizeof(T_PPP_CI_HDR) + sizeof(uint16_t))
+				code = PPP_CONFREJ;
+			else {
+				cishort = ntohs(*(uint16_t*)ap);
+
+				/* èªè¨¼ãã­ãã³ã«ã«ããåå²ãã	*/
+				if (cishort == PPP_PAP &&
+				    cilen   == sizeof(T_PPP_CI_HDR) + sizeof(uint16_t) &&
+			 	    (DEF_LCP_REMOTE_CFGS & LCP_CFG_PAP) != 0)
+					lcp_remote_neg_cfg.options |= LCP_CFG_PAP;
+				else
+					code = PPP_CONFREJ;
+				}
+			break;
+
+#endif	/* of #ifdef LCP_CFG_PAP */
+
+#ifdef LCP_CFG_PCOMP
+
+		case LCP_CIT_PCOMP:	/* ãã­ãã³ã«é¨å§ç¸®ã¯å®è£
+äºå® */
+
+#if (DEF_LCP_REMOTE_CFGS & LCP_CFG_PCOMP) == 0
+
+			code = PPP_CONFREJ;
+
+#else	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_PCOMP) == 0 */
+
+		 	/* CI é·ãããããé·ã ãã§ãªããã° REJ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR))
+				code = PPP_CONFREJ;
+			else
+				lcp_remote_neg_cfg.options |= LCP_CFG_PCOMP;
+
+#endif	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_PCOMP) == 0 */
+
+			break;
+
+#endif	/* of #ifdef LCP_CFG_PCOMP */
+
+#ifdef LCP_CFG_ACCOMP
+
+		case LCP_CIT_ACCOMP:	/* ã¢ãã¬ã¹ã»å¶å¾¡é¨å§ç¸® */
+
+#if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCOMP) == 0
+
+			code = PPP_CONFREJ;
+
+#else	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCOMP) == 0 */
+
+		 	/* CI é·ãããããé·ã ãã§ãªããã° REJ */
+		 	if (cilen != sizeof(T_PPP_CI_HDR))
+				code = PPP_CONFREJ;
+			else
+				lcp_remote_neg_cfg.options |= LCP_CFG_ACCOMP;
+
+#endif	/* of #if (DEF_LCP_REMOTE_CFGS & LCP_CFG_ACCOMP) == 0 */
+
+			break;
+
+#endif	/* of #ifdef LCP_CFG_ACCOMP */
+
+		default:
+			syslog(LOG_WARNING, "[PPP/LCP] unexp opt: %d.", type);
+			code  = PPP_CONFREJ;
+			break;
+			}
+endswitch:
+		if (code == PPP_CONFNAK) {
+			/* CI ã®åã Magic Number ã®å ´åãé¤ãã¦ãNAK ã®åæ°ã	*/
+			/* æå¤§å¤ MAX_PPP_FAILURES  ãè¶
+ãããæå¦ããã	*/
+			if (fsm->failures >= MAX_PPP_FAILURES && type != LCP_CIT_MAGIC)
+				code = PPP_CONFREJ;
+			else if (final != PPP_CONFREJ)
+				final = PPP_CONFNAK;
+			}
+
+		/* ãã® CI ãæå¦ãã */
+		if (code == PPP_CONFREJ) {
+			if (rp < cp)		/* åã«è©°ããã*/
+				memcpy(rp, cp, cilen);
+			rp += cilen;
+			final = PPP_CONFREJ;
+			}
+
+		ap   += cilen - sizeof(T_PPP_CI_HDR);
+		len  -= cilen - sizeof(T_PPP_CI_HDR);
+		}
+
+	/* æçµçãªé·ããèª¿æ´ããã*/
+	switch (final) {
+	case PPP_CONFNAK:
+		output->len = np - output->buf;
+		memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+		break;
+	case PPP_CONFREJ:
+		memcpy(output->buf, input->buf, output->len = rp - input->buf);
+		break;
+	case PPP_CONFACK:
+		memcpy(output->buf, input->buf, input->len);
+		break;
+		}
+	return final;
+	}
+
+/*
+ *  lcp_up -- ãªã³ã¯æ¥ç¶ãç¢ºç«ãã (Phase: Establish ã«ç§»è¡ãã)ã
+ */
+
+static void
+lcp_up (T_PPP_FSM *fsm)
+{
+	/* èªæ§ææ
+å ±ã®è¨­å® */
+	lcp_local_ack_cfg = lcp_local_neg_cfg;
+
+	/* ç¸æã®æ§ææ
+å ±ã®è¨­å® */
+	lcp_remote_ack_cfg = lcp_remote_neg_cfg;
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+	echo_lowerup();
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+	link_established();
+	}
+
+/*
+ *  lcp_starting -- ä¸ä½å±¤ãéå§ããã
+ */
+
+static void
+lcp_starting (T_PPP_FSM *fsm)
+{
+	link_required();
+	}
+
+/*
+ *  lcp_extcode -- LCP ç¹æã® CP ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static bool_t
+lcp_extcode (T_PPP_FSM *fsm, uint8_t code, uint8_t id, T_NET_BUF *input)
+{
+#if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC
+
+	T_NET_BUF *output;
+
+#endif	/* of #if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC */
+
+	switch (code) {
+	case PPP_PROTREJ:
+		lcp_rprotrej(fsm, input);
+		break;
+
+	case PPP_ECHOREQ:
+
+#if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC
+
+		if (fsm->state == PPP_FSM_OPENED) {
+			syscall(get_net_buf(&output, sizeof(T_PPP_HDR)
+			                           + sizeof(T_PPP_CP_HDR)
+			                           + sizeof(uint32_t)));
+			*(uint32_t*)(output->buf + sizeof(T_PPP_HDR)
+			                   + sizeof(T_PPP_CP_HDR)) = lcp_local_ack_cfg.magic;
+			IF_SET_PROTO(output, PPP_LCP);
+			ppp_cp_output(PPP_ECHOREP, id, output);
+			}
+
+#endif	/* of #if DEF_LCP_REMOTE_CFGS & LCP_CFG_MAGIC */
+
+		break;
+
+	case PPP_ECHOREP:
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+		recv_echo_rep(fsm, id, input);
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+		break;
+
+	case PPP_DISCREQ:
+		break;
+
+	default:
+		return false;
+		break;
+
+		}
+	return true;
+	}
+
+/*
+ *  lcp_rprotrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+lcp_rprotrej (T_PPP_FSM *fsm, T_NET_BUF *input)
+{
+	T_PPP_PROTENT	*entry;
+	int_t		ix;
+	uint16_t	proto;
+
+	if (input->len < sizeof(uint16_t)) {
+		syslog(LOG_WARNING, "[PPP/LCP] bad len: %d in recv Proto-REJ.");
+		return;
+		}
+
+	proto = ntohs(*GET_PPP_HDR(input));
+
+	if (fsm->state != PPP_FSM_OPENED) {
+		return;
+		}
+
+	/* ä¸ä½ãã­ãã³ã«ãåæåãã */
+	for (ix = 0; (entry = protocols[ix]) != NULL; ix ++)
+		if (entry->proto == proto) {
+			(*entry->protrej)();
+			return;
+			}
+
+	syslog(LOG_WARNING, "[PPP/LCP] unexp proto: %d in recv Proto-REJ.", proto);
+	}
+
+/*
+ *  lcp_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+lcp_protrej (void)
+{
+	fsm_protreject(&lcp_fsm);
+	}
+
+/*
+ *  lcp_lowerup -- LCP ä¸ä½å±¤ãèµ·åããã
+ */
+
+void
+lcp_lowerup (void)
+{
+	fsm_lowerup(&lcp_fsm);
+	}
+
+/*
+ *  lcp_lowerdown -- LCP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+void
+lcp_lowerdown (void)
+{
+	fsm_lowerdown(&lcp_fsm);
+	}
+
+/*
+ *  lcp_open -- LCP ã®ãªã¼ã
+ */
+
+void
+lcp_open (uint8_t open_mode)
+{
+	ppp_open_mode = open_mode;	/* ãªã¼ãã³æã®åä½ã¢ã¼ã	*/
+	fsm_open(&lcp_fsm);
+	}
+
+/*
+ *  lcp_close -- LCP ã®ã¯ã­ã¼ãº
+ */
+
+void
+lcp_close (void)
+{
+	if (ppp_phase != PPP_PHASE_DEAD)
+		ppp_phase = PPP_PHASE_TERMINATE;
+
+	if (ppp_open_mode == PPP_OPEN_PASSIVE && lcp_fsm.state == PPP_FSM_STOPPED) {
+		lcp_fsm.state = PPP_FSM_CLOSED;
+		lcp_finished(&lcp_fsm);
+		}
+	else
+		fsm_close(&lcp_fsm);
+	}
+
+/*
+ *  lcp_sprotrej -- èªè­ã§ããªããã­ãã³ã«ãéããã¦ããã¨ãã®å¦ç
+ */
+
+void
+lcp_sprotrej (T_NET_BUF *input)
+{
+	T_NET_BUF	*output;
+	/*
+	 *  Protocol-Reject ãéãè¿ãã
+	 */
+
+	syscall(get_net_buf(&output, input->len + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+
+	memcpy(output->buf, input->buf, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+	memcpy(output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR), input->buf, input->len);
+
+	IF_SET_PROTO(output, PPP_LCP);
+	ppp_cp_output(PPP_PROTREJ, ++ lcp_fsm.id, output);
+	}
+
+/*
+ *  lcp_down -- ãªã³ã¯æ¥ç¶ãè§£æ¾ãã (Phase: Dead ã«ç§»è¡ãã)ã
+ */
+
+void
+lcp_down (T_PPP_FSM *fsm)
+{
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+	echo_lowerdown();
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+	link_down();
+	}
+
+/*
+ *  lcp_finished -- ä¸ä½å±¤ãçµäºããã
+ */
+
+void
+lcp_finished (T_PPP_FSM *fsm)
+{
+	link_terminated();
+	}
+
+#if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC
+
+/*
+ *  recv_echo_rep -- ECHOREP ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+recv_echo_rep(T_PPP_FSM *fsm, uint8_t id, T_NET_BUF *input)
+{
+	T_PPP_CP_HDR	*hdr;
+	uint32_t	magic;
+
+ 	hdr = GET_PPP_CP_HDR(input);
+
+ 	/* Magic Number ã®é·ãä»¥ä¸ãªãã¨ã©ã¼ */
+ 	if (hdr->len < sizeof(T_PPP_CP_HDR) + sizeof(uint32_t)) {
+		syslog(LOG_WARNING, "[PPP/LCP] bad ECHOREP len: %d.", hdr->len);
+		return;
+		}
+
+	ntoahl(magic, input->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR));
+
+ 	/* åä¿¡ãã Magic Number ãèªåã¨åããªãã«ã¼ããã¦ããã*/
+	if ((lcp_local_ack_cfg.options & LCP_CFG_MAGIC) && magic == lcp_local_ack_cfg.magic) {
+		syslog(LOG_WARNING, "[PPP/LCP] ECHOREP looped.");
+		return;
+		}
+
+	echo_pending = 0;
+	}
+
+/*
+ *  echo_timeout -- ECHO REQ/REP ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+echo_timeout (void *arg)
+{
+	if (timer_running) {
+		timer_running = false;
+		send_echo_req((T_PPP_FSM *)arg);
+		}
+	}
+
+/*
+ *  send_echo_req -- ECHO REQ ãéä¿¡ããã
+ */
+
+static void
+send_echo_req (T_PPP_FSM *fsm)
+{
+	T_NET_BUF	*input;
+
+#if LCP_ECHO_FAILS > 0
+
+	if (echo_pending >= LCP_ECHO_FAILS) {
+		syslog(LOG_WARNING, "[PPP/LCP] no reply to ECHOREQ.");
+		lcp_close();
+		echo_pending = 0;
+		}
+
+#endif	/* of #if LCP_ECHO_FAILS > 0 */
+
+	if (fsm->state == PPP_FSM_OPENED) {
+
+		/* ECHOREQ ãéä¿¡ããã*/
+		syscall(get_net_buf(&input, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR) + sizeof(uint32_t)));
+		*(uint32_t*)(input->buf +  sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)) = lcp_local_ack_cfg.magic;
+		IF_SET_PROTO(input, PPP_LCP);
+		ppp_cp_output(PPP_ECHOREQ, echo_number ++, input);
+		echo_pending ++;
+
+		/* ã¿ã¤ãã¼ãã¹ã¿ã¼ãããã*/
+		timeout((FP)echo_timeout, fsm, LCP_ECHO_INTERVAL);
+		timer_running = true;
+		}
+	}
+
+/*
+ *  echo_lowerup -- ECHO REQ/REP ã®èµ·å
+ */
+
+static void
+echo_lowerup (void)
+{
+	echo_pending  = 0;
+	echo_number   = 0;
+	timer_running = false;
+
+	send_echo_req(&lcp_fsm);
+	}
+
+/*
+ *  echo_lowerdown -- ECHO REQ/REP ã®åæ­¢
+ */
+
+static void
+echo_lowerdown (void)
+{
+	if (timer_running) {
+		untimeout((FP)echo_timeout, &lcp_fsm);
+		timer_running = false;
+		}
+	}
+
+#endif	/* of #if DEF_LCP_LOCAL_CFGS & LCP_CFG_MAGIC */
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_lcp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_lcp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_lcp.h	(revision 317)
@@ -0,0 +1,174 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * lcp.h - Link Control Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/lcp.h,v 1.6.2.1 1999/08/29 15:47:03 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/lcp.h,v 1.23.2.1 2000/08/19 09:30:04 brian Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_LCP_H_
+#define _PPP_LCP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  LCP ç¹æã® PPP ãªã³ã¯å¶å¾¡ (CP) ã®å¶å¾¡ã³ã¼ã
+ */
+
+#define PPP_PROTREJ		UINT_C(8)	/* Protocol Reject	*/
+#define PPP_ECHOREQ		UINT_C(9)	/* Echo Request		*/
+#define PPP_ECHOREP		UINT_C(10)	/* Echo Reply		*/
+#define PPP_DISCREQ		UINT_C(11)	/* Discard Request	*/
+
+/*
+ *  LCP ã®æ§ææ
+å ± (CI)
+ */
+
+/*
+ *  CI ã®å
+ */
+
+#define LCP_CIT_MRU		UINT_C(1)	/* æå¤§åä¿¡é (Maximum Receive Unit)	*/
+#define LCP_CIT_ACCM		UINT_C(2)	/* Async Control Character Map		*/
+#define LCP_CIT_AUTH		UINT_C(3)	/* èªè¨¼ãã­ãã³ã«			*/
+#define LCP_CIT_QUALITY		UINT_C(4)	/* åè³ªãã­ãã³ã«ã¯æªå®è£
+			*/
+#define LCP_CIT_MAGIC		UINT_C(5)	/* ãã¸ãã¯çªå·				*/
+#define LCP_CIT_PCOMP		UINT_C(7)	/* ãã­ãã³ã«é¨å§ç¸®ã¯å®è£
+äºå®		*/
+#define LCP_CIT_ACCOMP		UINT_C(8)	/* ã¢ãã¬ã¹ã»å¶å¾¡é¨å§ç¸®ã¯å®è£
+äºå®		*/
+#define LCP_CIT_FCS_ALTER	UINT_C(9)	/* FCS-Alternatives ã¯æªå®è£
+		*/
+#define LCP_CIT_SELF_PAD	UINT_C(10)	/* Self-Describing-Padding ã¯æªå®è£
+	*/
+#define LCP_CIT_CALLBACK	UINT_C(13)	/* Callback ã¯æªå®è£
+			*/
+#define LCP_CIT_CFRAMES		UINT_C(15)	/* Compound-Frames ã¯æªå®è£
+		*/
+
+/*
+ *  LCP ã®æ§ææ
+å ±ãªãã·ã§ã³
+ */
+
+typedef struct t_lcp_configs {
+	uint32_t	ACCM;		/* ACCM			*/
+
+#ifdef LCP_CFG_MAGIC
+
+	uint32_t	magic;		/* ãã¸ãã¯çªå·		*/
+
+#endif	/* of #ifdef LCP_CFG_MAGIC */
+
+	uint16_t	MRU;		/* MRU			*/
+	uint16_t	options;	/* ãªãã·ã§ã³ãã©ã°	*/
+	} T_LCP_CONFIGS;
+
+/*
+ *  å¤æ°
+ */
+
+extern T_PPP_FSM	lcp_fsm;
+extern T_PPP_PROTENT	lcp_protent;
+extern T_LCP_CONFIGS	lcp_local_ack_cfg;	/* ç¸æã«è¨±å¯ãããã®èªæ§ææ
+å ±	*/
+extern T_LCP_CONFIGS	lcp_remote_ack_cfg;	/* ç¸æã«è¨±å¯ããæ§ææ
+å ±		*/
+
+/*
+ *  é¢æ°
+ */
+
+extern void lcp_lowerup (void);
+extern void lcp_lowerdown (void);
+extern void lcp_down (T_PPP_FSM *fsm);
+extern void lcp_finished (T_PPP_FSM *fsm);
+extern void lcp_open (uint8_t open_mode);
+extern void lcp_close (void);
+extern void lcp_sprotrej (T_NET_BUF *data);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_LCP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_modem.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_modem.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_modem.c	(revision 317)
@@ -0,0 +1,325 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  PPP ã¢ãã å¶å¾¡
+ */
+
+#include <string.h>
+
+#include <t_services.h>
+#include "kernel_id.h"
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_modem.h>
+#include <net/ppp_lcp.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+uint8_t	modem_state = PPP_MODEM_DOWN;	/* ã¢ãã ã®ç¶æ
+		*/
+
+/*
+ *  ã¢ãã å
+¥åæå­å
+ */
+
+#define MODEM_RCODE_OK		0
+#define MODEM_RCODE_CONNECT	1
+#define MODEM_RCODE_RING	2
+#define MODEM_RCODE_NO_CARRIER	3
+#define MODEM_RCODE_ERROR	4
+#define MODEM_RCODE_NO_DIALTONE	5
+#define MODEM_RCODE_BUSY	6
+#define MODEM_RCODE_DELAYED	7
+
+/*
+ *  å¤æ°
+ */
+
+static uint8_t *modem_rcode[] = {
+	"OK",
+	"CONNECT",
+	"RING",
+	"NO CARRIER",
+	"ERROR",
+	"NO DIALTONE",
+	"BUSY",
+	"DELAYED"
+	};
+
+static int_t dial_retry;
+
+/*
+ *  é¢æ°
+ */
+
+static void do_dial (void);
+static void modem_putstr (uint8_t *str);
+static void modem_wait (uint8_t *line);
+static void modem_putline (uint8_t *line);
+
+/*
+ *  modem_getline -- ã¢ãã è¡å
+¥å
+ */
+
+T_NET_BUF *
+modem_getline (T_NET_BUF *nbuf, uint16_t size)
+{
+	uint8_t *buf;
+
+	buf = nbuf->buf;
+	size --;			/* '\0' ã®å */
+	while (size > 0 && (*buf = HDLC_raw_getoctet()) != '\r') {
+		buf  ++;
+		size --;
+		}
+	*buf = '\0';
+	HDLC_raw_getoctet();		/* \n ãèª­ã¿é£ã°ãã*/
+	nbuf->len = buf - nbuf->buf;
+	return nbuf;
+	}
+
+/*
+ *  ã¢ãã å¶å¾¡
+ *
+ *	æ»ãå¤: ã¢ãã ããã®ãªã¶ã«ãã³ã¼ã
+ */
+
+int_t
+modem_cntl (T_NET_BUF *input)
+{
+	int_t	code;
+
+	code = sizeof(modem_rcode) / sizeof(uint8_t*) - 1;
+	while (strcmp(modem_rcode[code], input->buf) != 0) {
+		if (code == 0)
+			return modem_state;
+		code --;
+		}
+
+	switch (modem_state) {
+
+	case PPP_MODEM_UP:
+		if (code == MODEM_RCODE_RING)
+			modem_state = PPP_MODEM_RING;
+		break;
+
+	case PPP_MODEM_DIAL:
+		if (code == MODEM_RCODE_CONNECT) {
+			syslog(LOG_NOTICE, "[MODEM] up.");
+			modem_state = PPP_MODEM_CONNECT;
+			lcp_open(PPP_OPEN_ACTIVE);
+			sig_sem(SEM_MODEM_READY);
+			}
+		else {
+			syslog(LOG_NOTICE, "[MODEM] dial failed '%s'.", modem_rcode[code]);
+			if (-- dial_retry == 0) {
+				syslog(LOG_WARNING, "[MODEM] dial failed %d times.", MODEM_CFG_RETRY_CNT);
+				modem_state = PPP_MODEM_UP;
+				}
+			else {
+				syscall(dly_tsk(MODEM_CFG_RETRY_WAIT));
+				do_dial();
+				}
+			}
+		break;
+
+	case PPP_MODEM_RING:
+		if (code == MODEM_RCODE_CONNECT) {
+			syslog(LOG_NOTICE, "[MODEM] up.");
+			modem_state = PPP_MODEM_CONNECT;
+			lcp_open(PPP_OPEN_PASSIVE);
+			}
+		else
+			modem_state = PPP_MODEM_UP;
+		break;
+
+	default:
+		if (code == MODEM_RCODE_NO_CARRIER) {
+			if (lcp_fsm.state == PPP_FSM_OPENED)
+				lcp_close();
+			syslog(LOG_NOTICE, "[MODEM] down.");
+			modem_state = PPP_MODEM_UP;
+			}
+		break;
+
+		}
+
+	return code;
+	}
+
+/*
+ *  init_modem -- ã¢ãã ãåæåããã
+ */
+
+void
+init_modem (void)
+{
+	modem_putline("AT");
+
+#ifdef MODEM_CFG_INIT
+
+	modem_putline(MODEM_CFG_INIT);
+
+#endif	/* of #ifdef MODEM_CFG_INIT */
+
+	modem_state = PPP_MODEM_UP;
+	}
+
+/*
+ *  wait_modem -- æ¥ç¶å®äºã¾ã§å¾
+ã¤ã
+ *
+ *	æ»ãå¤: æ¥ç¶ã«å¤±æããã E_OBJ ãè¿ãã
+ */
+
+ER
+wait_modem (void)
+{
+	ER error = E_OK;
+
+	if (modem_state == PPP_MODEM_UP) {
+		dial();
+		}
+
+	if (modem_state != PPP_MODEM_CONNECT) {
+		/* æ¥ç¶å®äºã¾ã§å¾
+ã¤ã*/
+		wai_sem(SEM_MODEM_READY);
+		if (modem_state != PPP_MODEM_CONNECT)
+			error = E_OBJ;
+		}
+
+	return error;
+	}
+
+/*
+ *  dial -- ãã¤ã¤ã«ããããªãã©ã¤åæ°ãã»ããããã
+ */
+
+void
+dial (void)
+{
+	do_dial();
+	dial_retry = MODEM_CFG_RETRY_CNT;
+	modem_state = PPP_MODEM_DIAL;
+	}
+
+/*
+ *  do_dial -- ãã¤ã¤ã«ãããdial() ã®ä¸è«ãé¢æ°
+ */
+
+static void
+do_dial (void)
+{
+	syslog(LOG_NOTICE, "[MODEM] dial: %s.", MODEM_CFG_PHONE_NUMBER);
+	modem_putstr(MODEM_CFG_DIAL);
+	modem_putstr(MODEM_CFG_PHONE_NUMBER);
+	modem_putstr("\r");
+	}
+
+/*
+ *  modem_putstr -- ã¢ãã æå­ååºå
+ */
+
+static void
+modem_putstr (uint8_t *str)
+{
+	while (*str)
+		HDLC_raw_putoctet(*str ++);
+	}
+
+/*
+ *  modem_wait -- ã¢ãã ããæå­åãå¾
+ã¤
+ */
+
+static void
+modem_wait (uint8_t *line)
+{
+	int_t ch, state, len = strlen(line);
+
+	state = len;
+	while (state != 0) {
+		ch = HDLC_raw_getoctet();
+		if (ch != line[len - state])
+			state = len;
+		if (ch == line[len - state])
+			state --;
+		}
+	}
+
+/*
+ *  modem_putline -- ã¢ãã è¡åºå
+ */
+
+static void
+modem_putline (uint8_t *line)
+{
+	modem_putstr(line);
+	modem_putstr("\r");
+	modem_wait("OK\r\n");
+	}
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_modem.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_modem.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_modem.h	(revision 317)
@@ -0,0 +1,95 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _PPP_MODEM_H_
+#define _PPP_MODEM_H_
+
+#ifdef SUPPORT_PPP
+
+#ifdef PPP_CFG_MODEM
+
+/*
+ *  ã¢ãã ã®ç¶æ
+
+ */
+
+#define PPP_MODEM_CONNECT	UINT_C(0)
+#define PPP_MODEM_DISCONN	UINT_C(1)
+#define PPP_MODEM_RING		UINT_C(2)
+#define PPP_MODEM_DIAL		UINT_C(3)
+#define PPP_MODEM_UP		UINT_C(4)
+#define PPP_MODEM_DOWN		UINT_C(5)
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+extern uint8_t modem_state;	/* ã¢ãã ã®ç¶æ
+		*/
+
+/*
+ *  é¢æ°
+ */
+
+extern T_NET_BUF *modem_getline (T_NET_BUF *nbuf, uint16_t size);
+extern int modem_cntl (T_NET_BUF *input);
+extern void init_modem (void);
+extern void dial (void);
+extern ER wait_modem (void);
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+/*
+ *  é¢æ°
+ */
+
+#define init_modem
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_MODEM_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_upap.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_upap.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_upap.c	(revision 317)
@@ -0,0 +1,625 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * upap.c - User/Password Authentication Protocol.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *			PPP PAP Module
+ *
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993-94, Internet Initiative Japan, Inc.
+ *		     All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan, Inc.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/pap.c,v 1.42.2.1 2000/08/19 09:30:05 brian Exp $
+ *
+ *	TODO:
+ */
+
+#include <string.h>
+
+#include <s_services.h>
+#include <t_services.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+#include <net/ppp.h>
+#include <net/ppp_var.h>
+#include <net/ppp_hdlc.h>
+#include <net/ppp_auth.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_upap.h>
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  é¢æ°
+ */
+
+static void upap_init (void);
+static void upap_input (T_NET_BUF *input);
+static void upap_protrej (void);
+static void upap_lowerup (void);
+static void upap_lowerdown (void);
+static bool_t compare (uint8_t *rstr, uint8_t *lstr, uint8_t rlen);
+
+#ifdef AUTH_CFG_CLIENT
+
+static void upap_sauthreq (void);
+static void upap_rauthack (void);
+static void upap_rauthnak (void);
+
+#if defined(DEF_PAP_TIMEOUT)
+
+static void upap_timeout(void *arg);
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+static void upap_rauthreq (T_NET_BUF *input);
+static void upap_sresp    (uint8_t code, uint8_t id);
+
+#if defined(DEF_PAP_REQTIME)
+
+static void upap_reqtimeout(void *arg);
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+T_PPP_PROTENT pap_protent = {
+	PPP_PAP,
+	upap_init,			/* åæå			*/
+	upap_input,			/* å
+¥å				*/
+	upap_protrej,			/* Proto-REJ åä¿¡å¦ç		*/
+	upap_lowerup,			/* ä¸ä½å±¤ãèµ·åãã		*/
+	upap_lowerdown,			/* ä¸ä½å±¤ãåæ­¢ãã		*/
+	NULL,				/* ãªã¼ãã³ãã			*/
+	NULL,				/* ã¯ã­ã¼ãºãã			*/
+	NULL,				/* ãã¼ã¿å
+¥å			*/
+	};
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef AUTH_CFG_CLIENT
+
+static uint8_t client_state;
+static uint8_t client_cp_id;
+
+#if defined(DEF_PAP_TIMEOUT)
+
+static uint8_t client_rexmt = 0;
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+static uint8_t server_state;
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+/*
+ *  upap_init -- UPAP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+static void
+upap_init (void)
+{
+#ifdef AUTH_CFG_CLIENT
+
+	client_cp_id = 0;
+	client_state = PAP_CS_INIT;
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+	server_state = PAP_SS_INIT;
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+	}
+
+/*
+ *  upap_input -- UPAP å
+¥å
+ */
+
+static void
+upap_input (T_NET_BUF *input)
+{
+	T_PPP_CP_HDR	*hdr;
+
+	NET_COUNT_PPP_PAP(net_count_ppp_upap_in_octets,  input->len);
+	NET_COUNT_PPP_PAP(net_count_ppp_upap_in_packets, 1);
+
+ 	/* PPP ãªã³ã¯å¶å¾¡ (CP) ãããããç­ããã°ã¨ã©ã¼ */
+ 	if (input->len < (sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR))) {
+ 		syslog(LOG_WARNING, "[PPP/PAP] short hdr: %d.", input->len);
+ 		return;
+ 		}
+
+ 	hdr = GET_PPP_CP_HDR(input);
+
+ 	/* ãããã®é·ãã¨å
+¥åãã¼ã¿ãµã¤ãºãä¸è´ããªããã°ã¨ã©ã¼ */
+ 	if (hdr->len != input->len - sizeof(T_PPP_HDR)) {
+ 		syslog(LOG_WARNING, "[PPP/PAP] bad len: %d.", hdr->len);
+ 		return;
+ 		}
+ 
+ 	/*
+ 	 *  å¶å¾¡ã³ã¼ãã«ããé©å½ãªé¢æ°ãå¼åºã
+ 	 */
+
+	switch (hdr->code) {
+
+#ifdef AUTH_CFG_CLIENT
+
+	case PAP_AUTHACK:
+		upap_rauthack();
+		break;
+
+	case PAP_AUTHNAK:
+		upap_rauthnak();
+		break;
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+	case PAP_AUTHREQ:
+		upap_rauthreq(input);
+		break;
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+		}
+	}
+
+/*
+ *  upap_protrej -- Proto-REJ ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+upap_protrej (void)
+{
+#ifdef AUTH_CFG_CLIENT
+
+	if (client_state == PAP_CS_AUTHREQ)
+	 	syslog(LOG_WARNING, "[PPP/PAP] proto-rej recved.");
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+	if (server_state == PAP_SS_LISTEN) {
+	 	syslog(LOG_WARNING, "[PPP/PAP] proto-rej recved.");
+		lcp_close();
+		}
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+	upap_lowerdown();
+	}
+
+/*
+ *  upap_lowerup -- UPAP ä¸ä½å±¤ãèµ·åããã
+ */
+
+static void
+upap_lowerup (void)
+{
+#ifdef AUTH_CFG_CLIENT
+
+	if (client_state == PAP_CS_INIT)
+		client_state = PAP_CS_CLOSED;
+	else if (client_state == PAP_CS_PENDING)
+		upap_sauthreq();
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+	if (server_state == PAP_SS_INIT)
+		server_state = PAP_SS_CLOSED;
+	else if (server_state == PAP_SS_PENDING) {
+		server_state = PAP_SS_LISTEN;
+
+#if defined(DEF_PAP_REQTIME)
+
+		timeout((FP)upap_reqtimeout, NULL, DEF_PAP_REQTIME);
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+
+		}
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+	}
+
+/*
+ *  upap_lowerdown -- UPAP ä¸ä½å±¤ãåæ­¢ããã
+ */
+
+static void
+upap_lowerdown (void)
+{
+#ifdef AUTH_CFG_CLIENT
+
+#if defined(DEF_PAP_TIMEOUT)
+
+	if (client_state == PAP_CS_AUTHREQ)
+		untimeout((FP)upap_timeout, NULL);
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+	client_state = PAP_CS_INIT;
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+#if defined(DEF_PAP_REQTIME)
+
+	if (server_state == PAP_SS_LISTEN)
+		untimeout((FP)upap_reqtimeout, NULL);
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+
+	server_state = PAP_SS_INIT;
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+	}
+#ifdef AUTH_CFG_CLIENT
+
+/*
+ *  ã¯ã©ã¤ã¢ã³ãã¢ã¼ãã§ PAP èªè¨¼ãéå§ããã
+ */
+
+void
+upap_auth_client (void)
+{
+#if defined(DEF_PAP_TIMEOUT)
+
+	client_rexmt = 0;
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+	if (client_state == PAP_CS_INIT || client_state == PAP_CS_PENDING) {
+		client_state = PAP_CS_PENDING;
+		return;
+		}
+
+	upap_sauthreq();
+	}
+
+/*
+ *  upap_rauthack -- èªè¨¼ ACK å¦ç
+ */
+
+static void
+upap_rauthack (void)
+{
+	if (client_state == PAP_CS_AUTHREQ) {
+		client_state = PAP_CS_OPEN;
+		network_phase();
+		}
+	}
+
+/*
+ *  upap_rauthnak -- èªè¨¼ NAK å¦ç
+ */
+
+static void
+upap_rauthnak (void)
+{
+ 	syslog(LOG_WARNING, "[PPP/PAP] auth-req NAKed.");
+	client_state = PAP_CS_BADAUTH;
+	}
+
+/*
+ *  upap_sauthreq -- èªè¨¼è¦æ±å¦ç
+ */
+
+static void
+upap_sauthreq (void)
+{
+	T_NET_BUF	*output;
+	uint8_t		*data;
+
+	syscall(get_net_buf(&output, sizeof(T_PPP_HDR)        + sizeof(T_PPP_CP_HDR)
+	                           + sizeof(AUTH_REMOTE_USER) + sizeof(AUTH_REMOTE_PASSWD)));
+
+	data = output->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/* ã¦ã¼ã¶åãè¨­å®ããã*/
+	*data = sizeof(AUTH_REMOTE_USER) - 1;
+	strcpy(data + 1, AUTH_REMOTE_USER);
+
+	/* ãã¹ã¯ã¼ããè¨­å®ããã*/
+	*(data + sizeof(AUTH_REMOTE_USER)) = sizeof(AUTH_REMOTE_PASSWD) - 1;
+	strcpy(data + sizeof(AUTH_REMOTE_USER) + 1, AUTH_REMOTE_PASSWD);
+
+	/* éä¿¡ãã */
+	IF_SET_PROTO(output, PPP_PAP);
+	ppp_cp_output(PAP_AUTHREQ, ++ client_cp_id, output);
+
+#if defined(DEF_PAP_TIMEOUT)
+
+	timeout((FP)upap_timeout, NULL, DEF_PAP_TIMEOUT);
+	client_rexmt ++;
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+	client_state = PAP_CS_AUTHREQ;
+	}
+
+#if defined(DEF_PAP_TIMEOUT)
+
+/*
+ *  upap_timeout -- ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+upap_timeout (void *arg)
+{
+	if (client_state != PAP_CS_AUTHREQ)
+		return;
+
+	if (client_rexmt >= MAX_PAP_REXMT) {
+ 		syslog(LOG_WARNING, "[PPP/PAP] no reply auth-req.");
+		client_state = PAP_CS_BADAUTH;
+		return;
+		}
+
+	upap_sauthreq();
+	}
+
+#endif	/* of #if defined(DEF_PAP_TIMEOUT) */
+
+#endif	/* of #ifdef AUTH_CFG_CLIENT */
+
+#ifdef AUTH_CFG_SERVER
+
+/*
+ *  ãµã¼ãã¢ã¼ãã§ PAP èªè¨¼ãéå§ããã
+ */
+
+void
+upap_auth_server (void)
+{
+	if (server_state == PAP_SS_INIT || server_state == PAP_SS_PENDING) {
+		server_state = PAP_SS_PENDING;
+		return;
+		}
+
+	server_state = PAP_SS_LISTEN;
+
+#if defined(DEF_PAP_REQTIME)
+
+	timeout((FP)upap_reqtimeout, NULL, DEF_PAP_REQTIME);
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+	}
+
+/*
+ *  upap_rauthreq -- èªè¨¼è¦æ±å¿ç­å¦ç
+ */
+
+static void
+upap_rauthreq (T_NET_BUF *input)
+{
+	int16_t	cplen;
+	uint8_t	*data, *user, ulen, plen, code, id;
+
+	if (server_state < PAP_SS_LISTEN)
+		return;
+
+	/*
+	 *  åè¦æ±ããã£ãã¨ãã®å¦ç
+	 */
+	id = GET_PPP_CP_HDR(input)->id;
+	if (server_state == PAP_SS_OPEN) {
+		upap_sresp(PAP_AUTHACK, id);
+		return;
+		}
+
+	if (server_state == PAP_SS_BADAUTH) {
+		upap_sresp(PAP_AUTHNAK, id);
+		return;
+		}
+
+	cplen = GET_PPP_CP_HDR(input)->len;
+	data  = input->buf + sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR);
+
+	/*
+	 *  ã¦ã¼ã¶åãç¹å®ããã
+	 */
+	ulen  = *data;
+	if (cplen < sizeof(T_PPP_CP_HDR) + ulen + sizeof(uint8_t)) {
+ 		syslog(LOG_WARNING, "[PPP/PAP] bad req len: %d.", cplen);
+ 		return;
+		}
+	user = ++ data;
+	data += ulen;
+
+	/*
+	 *  ãã¹ã¯ã¼ããç¹å®ããã
+	 */
+	plen  = *data;
+	if (cplen < sizeof(T_PPP_CP_HDR) + ulen + plen + sizeof(uint8_t) * 2) {
+ 		syslog(LOG_WARNING, "[PPP/PAP] bad req len: %d.", cplen);
+ 		return;
+		}
+
+	/*
+	 *  ã¦ã¼ã¶åã¨ãã¹ã¯ã¼ãããã§ãã¯ããã
+	 */
+	if (compare(user,     AUTH_LOCAL_USER,   ulen) &&
+	    compare(data + 1, AUTH_LOCAL_PASSWD, plen))
+		code = PAP_AUTHACK;
+	else
+		code = PAP_AUTHNAK;
+
+	upap_sresp(code, id);
+
+	if (code == PAP_AUTHACK) {
+		network_phase();
+		server_state = PAP_SS_OPEN;
+		}
+	else {
+		lcp_close();
+		server_state = PAP_SS_BADAUTH;
+		}
+
+#if defined(DEF_PAP_REQTIME)
+
+	untimeout((FP)upap_reqtimeout, NULL);
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+	}
+
+/*
+ *  upap_sresp -- å¿ç­ãè¿ãã
+ */
+
+static void
+upap_sresp (uint8_t code, uint8_t id)
+{
+	T_NET_BUF *output;
+
+	/* éä¿¡ãã */
+	syscall(get_net_buf(&output, sizeof(T_PPP_HDR) + sizeof(T_PPP_CP_HDR)));
+	IF_SET_PROTO(output, PPP_PAP);
+	ppp_cp_output(code, id, output);
+	}
+
+/*
+ *  compare -- ã¦ã¼ã¶åã¨ãã¹ã¯ã¼ãã®æ¯è¼
+ */
+
+static bool_t
+compare (uint8_t *rstr, uint8_t *lstr, uint8_t rlen)
+{
+	while (rlen -- > 0) {
+		if (*rstr != *lstr)
+			return false;
+		rstr ++;
+		lstr ++;
+		}
+	return *lstr ? false : true;
+	}
+
+#if defined(DEF_PAP_REQTIME)
+
+/*
+ *  upap_reqtimeout -- è¦æ±ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+upap_reqtimeout (void *arg)
+{
+	if (server_state == PAP_SS_LISTEN) {
+		lcp_close();
+		server_state = PAP_SS_BADAUTH;
+		}
+	}
+
+#endif	/* of #if defined(DEF_PAP_REQTIME) */
+
+#endif	/* of #ifdef AUTH_CFG_SERVER */
+
+#endif	/* fo #ifdef SUPPORT_PPP */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_upap.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_upap.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_upap.h	(revision 317)
@@ -0,0 +1,142 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * upap.h - User/Password Authentication Protocol definitions.
+ *
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/pppd/upap.h,v 1.6.2.1 1999/08/29 15:47:10 peter Exp $
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * $FreeBSD: src/usr.sbin/ppp/pap.h,v 1.11 1999/08/28 01:18:37 peter Exp $
+ *
+ *	TODO:
+ */
+
+#ifndef _PPP_UPAP_H_
+#define _PPP_UPAP_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  PAP ã®å¶å¾¡ã³ã¼ã
+ */
+
+#define PAP_AUTHREQ		UINT_C(1)	/* èªè¨¼è¦æ±	*/
+#define PAP_AUTHACK		UINT_C(2)	/* èªè¨¼ ACK	*/
+#define PAP_AUTHNAK		UINT_C(3)	/* èªè¨¼ NAK	*/
+
+/*
+ *  ã¯ã©ã¤ã¢ã³ãã®ç¶æ
+
+ */
+
+#define PAP_CS_INIT		UINT_C(0)	/* æªæ¥ç¶		*/
+#define PAP_CS_CLOSED		UINT_C(1)	/* æ¥ç¶ãæªèªè¨¼		*/
+#define PAP_CS_PENDING		UINT_C(2)	/* æªæ¥ç¶ãèªè¨¼		*/
+#define PAP_CS_AUTHREQ		UINT_C(3)	/* èªè¨¼è¦æ±éä¿¡æ¸ã¿	*/
+#define PAP_CS_OPEN		UINT_C(4)	/* ACK åä¿¡		*/
+#define PAP_CS_BADAUTH		UINT_C(5)	/* NAK åä¿¡		*/
+
+/*
+ *  ãµã¼ãã®ç¶æ
+
+ */
+
+#define PAP_SS_INIT		UINT_C(0)	/* æªæ¥ç¶		*/
+#define PAP_SS_CLOSED		UINT_C(1)	/* æ¥ç¶ãæªèªè¨¼		*/
+#define PAP_SS_PENDING		UINT_C(2)	/* æªæ¥ç¶ãèªè¨¼		*/
+#define PAP_SS_LISTEN		UINT_C(3)	/* èªè¨¼è¦æ±åä¿¡å¾
+ã¡	*/
+#define PAP_SS_OPEN		UINT_C(4)	/* ACK éä¿¡		*/
+#define PAP_SS_BADAUTH		UINT_C(5)	/* NAK éä¿¡		*/
+
+/*
+ *  å¤æ°
+ */
+
+extern T_PPP_PROTENT	pap_protent;
+
+/*
+ *  é¢æ°
+ */
+
+extern void upap_auth_client (void);
+extern void upap_auth_server (void);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef _PPP_UPAP_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/ppp_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/ppp_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/ppp_var.h	(revision 317)
@@ -0,0 +1,131 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1989 Carnegie Mellon University.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by Carnegie Mellon University.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/*
+ *	    Written by Toshiharu OHNO (tony-o@iij.ad.jp)
+ *
+ *   Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the Internet Initiative Japan.  The name of the
+ * IIJ may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef PPP_VAR_H_
+#define PPP_VAR_H_
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  PPP ãã­ãã³ã«ã¨ã³ããªæ§é ä½
+ */
+
+typedef struct t_ppp_protent {
+	uint16_t	proto;			/* ãã­ãã³ã«çªå·	*/
+	void		(*init)		(void);	/* åæåé¢æ°		*/
+	void		(*input)	(T_NET_BUF *data);
+						/* å
+¥åé¢æ°		*/
+	void		(*protrej)	(void);	/* Ptoto-REJ åä¿¡å¦ç	*/
+	void		(*lowerup)	(void);	/* ä¸ä½å±¤ãèµ·åããã	*/
+	void		(*lowerdown)	(void);	/* ä¸ä½å±¤ãåæ­¢ããã	*/
+	void		(*open)		(void);	/* ãªã¼ãã³ããã	*/
+	void		(*close)	(void);	/* ã¯ã­ã¼ãºããã	*/
+	void		(*datainput)	(T_NET_BUF *data);
+					/* ãã¼ã¿å
+¥åé¢æ°	*/
+	} T_PPP_PROTENT;
+
+#define T_PPP_PROTENT_DEFINED
+
+/*
+ *  å¤æ°
+ */
+
+extern T_PPP_PROTENT	*protocols[];	/* ãã­ãã³ã«è¡¨			*/
+extern uint8_t		ppp_phase;	/* ãªã³ã¯ã®ç¶æ
+			*/
+
+/*
+ *  é¢æ°
+ */
+
+extern void ppp_cp_output(uint8_t code, uint8_t id, T_NET_BUF *data);
+
+/*
+ *  PPP å¦çã¿ã¹ã¯
+ */
+
+extern void	ppp_input_task(intptr_t exinf);
+extern void	ppp_output_task(intptr_t exinf);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#endif	/* of #ifndef PPP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/route.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/route.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/route.h	(revision 317)
@@ -0,0 +1,92 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1980, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)route.h	8.3 (Berkeley) 4/19/94
+ * $FreeBSD: src/sys/net/route.h,v 1.28.2.2 1999/09/15 08:38:05 ru Exp $
+ */
+
+#ifndef _ROUTE_H_
+#define _ROUTE_H_
+
+/*
+ * TINET 1.1 ã¨ã®äºææ§ç¢ºä¿
+ */
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#endif	/* of #ifndef _ROUTE_H_ */
Index: asp3_gr_sakura/trunk/tinet/net/tinet.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/net/tinet.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/net/tinet.h	(revision 317)
@@ -0,0 +1,59 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_H_
+#define _TINET_H_
+
+#if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
+
+/*
+ *  TINET ç¬èªé¢æ°
+ */
+
+extern char *mac2str (char *buf, uint8_t *macaddr);
+
+#endif /* #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY) */
+
+#endif	/* of #ifndef _TINET_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/Makefile.netapp
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/Makefile.netapp	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/Makefile.netapp	(revision 317)
@@ -0,0 +1,412 @@
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#   Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+# 
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+#   ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+#   è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+#   ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+#   å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+# 
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+#   å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+#   æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+#  
+#   @(#) $Id: Makefile.netapp 1.7 2017/6/1 8:50:28 abe $
+# 
+
+#
+#  ãµã³ãã«ã®ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ã«é¢ããå®ç¾©
+#
+
+#
+#  ã«ã¼ãã«ã®è­å¥
+#
+ifdef SRCLANG
+	TARGET_KERNEL = ASP
+	TINET_CDEFS := $(TINET_CDEFS) -DTARGET_KERNEL_ASP
+else
+	TARGET_KERNEL = JSP
+	TINET_CDEFS := $(TINET_CDEFS) -DTARGET_KERNEL_JSP
+endif
+
+#  å¿ç¨ãã­ã°ã©ã 
+
+TINET_ROOT = $(SRCDIR)/tinet
+NETAPP_DIRS = $(TINET_ROOT)/netapp
+NETAPP_COBJS := $(NETAPP_COBJS) netapp_subr.o
+
+ifeq ($(USE_LCD),true)
+
+	NETAPP_COBJS := $(NETAPP_COBJS) lcd.o
+
+ifeq ($(TARGET_KERNEL),ASP)
+	NETAPP_COBJS := $(NETAPP_COBJS) target_lcd.o sc1602.o
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+	NETAPP_COBJS := $(NETAPP_COBJS) hw_lcd.o sc1602.o
+endif
+
+endif
+
+#  ãã©ã³ã¹ãã¼ãå±¤ã®é¸æ
+
+#SUPPORT_TCP = false
+#SUPPORT_UDP = false
+
+# 
+#  å
+±éã¯ã©ã¤ã¢ã³ãã»ãµã¼ããã­ã°ã©ã ã®è¨­å®
+# 
+
+ifeq ($(USE_WWW4_SRV),true)
+	USE_WWW_SRV = true
+	CDEFS := $(CDEFS) -DUSE_WWW4_SRV
+endif
+
+ifeq ($(USE_WWW_SRV),true)
+
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_WWW_SRV
+	NETAPP_COBJS := $(NETAPP_COBJS) wwws.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/wwws.cfg
+
+endif
+
+ifeq ($(USE_TCP4_ECHO_SRV),true)
+	TCP_ECHO_SRV = tcp_echo_srv1
+	CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_SRV
+endif
+
+ifeq ($(TCP_ECHO_SRV),tcp_echo_srv1)		# éåä¿¡ã¿ã¹ã¯åä¸å
+
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV1
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv1.cfg
+
+	ifeq ($(USE_TCP_NON_BLOCKING),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_nblk.o
+	endif
+
+	ifeq ($(USE_TCP_EXTENTIONS),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv1_ext.o
+	endif
+
+endif
+
+ifeq ($(TCP_ECHO_SRV),tcp_echo_srv2)		# éåä¿¡ã¿ã¹ã¯åé¢å
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_SRV2
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_srv2.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_srv2.cfg
+endif
+
+ifeq ($(USE_UDP4_ECHO_SRV),true)
+	USE_UDP_ECHO_SRV = true
+endif
+
+ifeq ($(USE_UDP_ECHO_SRV),true)
+
+	CDEFS := $(CDEFS) -DUSE_UDP_ECHO_SRV
+
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		USE_NETAPP_SUBR = true
+		CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_SRV_TSK
+		NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_srv.o
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_srv.cfg
+
+		ifeq ($(SUPPORT_INET4),true)
+			ifeq ($(USE_UDP4_ECHO_SRV),true)
+				CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
+				NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
+				NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
+			endif
+		endif
+	else
+		ifeq ($(SUPPORT_INET4),true)
+			SUPPORT_UDP = true
+			USE_NETAPP_SUBR = true
+			CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_SRV_TSK
+			NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_srv.o
+			NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_srv.cfg
+		endif
+	endif
+endif
+
+
+ifeq ($(USE_TCP4_ECHO_CLI),true)
+	USE_TCP_ECHO_CLI = true
+	CDEFS := $(CDEFS) -DUSE_TCP4_ECHO_CLI
+endif
+
+ifeq ($(USE_TCP_ECHO_CLI),true)
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_TCP_ECHO_CLI
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_echo_cli.o tcp_echo_cli_snd.o tcp_echo_cli_rcv.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_echo_cli.cfg
+endif
+
+ifeq ($(USE_UDP4_ECHO_CLI),true)
+	USE_UDP_ECHO_CLI = true
+endif
+
+ifeq ($(USE_UDP_ECHO_CLI),true)
+
+	CDEFS := $(CDEFS) -DUSE_UDP_ECHO_CLI
+
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		USE_NETAPP_SUBR = true
+		CDEFS := $(CDEFS) -DUSE_UDP6_ECHO_CLI_TSK
+		NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg
+	
+		ifeq ($(SUPPORT_INET4),true)
+			ifeq ($(USE_UDP4_ECHO_CLI),true)
+				CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
+				NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
+				NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
+			endif
+		endif
+        else
+		ifeq ($(SUPPORT_INET4),true)
+			SUPPORT_UDP = true
+			USE_NETAPP_SUBR = true
+			CDEFS := $(CDEFS) -DUSE_UDP4_ECHO_CLI_TSK
+			NETAPP_COBJS := $(NETAPP_COBJS) udp4_echo_cli.o
+			NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp4_echo_cli.cfg
+		endif
+
+	endif
+endif
+
+ifeq ($(USE_TCP_DISCARD_SRV),true)
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_SRV
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_srv.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_srv.cfg
+endif
+
+ifeq ($(USE_TCP_DISCARD_CLI),true)
+	SUPPORT_TCP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_TCP_DISCARD_CLI
+	NETAPP_COBJS := $(NETAPP_COBJS) tcp_discard_cli.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/tcp_discard_cli.cfg
+endif
+
+ifeq ($(USE_UDP_DISCARD_CLI),true)
+	SUPPORT_UDP = true
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_UDP_DISCARD_CLI
+	NETAPP_COBJS := $(NETAPP_COBJS) udp_discard_cli.o
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp_discard_cli.cfg
+endif
+
+ifeq ($(USE_NET_CONS),true)
+	ifeq ($(TCP_CFG_NON_BLOCKING),true)
+		SUPPORT_TCP = true
+		USE_DBG_CONS = true
+		USE_NETAPP_SUBR = true
+		CDEFS := $(CDEFS) -DUSE_NET_CONS
+		NETAPP_COBJS := $(NETAPP_COBJS) net_cons.o
+		NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/net_cons.cfg
+	endif
+endif
+
+ifeq ($(USE_DBG_CONS),true)
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_DBG_CONS
+	NETAPP_COBJS := $(NETAPP_COBJS) dbg_cons.o 
+	NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/dbg_cons.cfg
+	ifeq ($(USE_DBG_CONS_PARSER),true)
+		CDEFS := $(CDEFS) -DUSE_DBG_CONS_PARSER
+	endif
+	ifeq ($(USE_DBG_CONS_EXTRA_PARSE),true)
+		CDEFS := $(CDEFS) -DUSE_DBG_CONS_EXTRA_PARSE
+	endif
+endif
+
+ifeq ($(USE_PING),true)
+	USE_NETAPP_SUBR = true
+	CDEFS := $(CDEFS) -DUSE_PING
+	ifeq ($(SUPPORT_INET4),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) ping.o
+	endif
+	ifeq ($(SUPPORT_INET6),true)
+		NETAPP_COBJS := $(NETAPP_COBJS) ping6.o
+	endif
+endif
+
+ifeq ($(USE_RESOLVER),true)
+	SUPPORT_UDP = true
+	CDEFS := $(CDEFS) -DUSE_RESOLVER
+	NETAPP_COBJS := $(NETAPP_COBJS) resolver.o 
+
+endif
+
+ifeq ($(USE_DHCP6_CLI),true)
+	ifeq ($(SUPPORT_INET6),true)
+		SUPPORT_UDP = true
+		UDP_CFG_NON_BLOCKING = true
+		USE_UDP_NON_BLOCKING = true
+		CDEFS := $(CDEFS) -DDHCP6_CLI_CFG
+		NETAPP_COBJS := $(NETAPP_COBJS) dhcp6_cli.o 
+	endif
+endif
+
+ifeq ($(USE_DHCP4_CLI),true)
+	ifeq ($(SUPPORT_INET4),true)
+		SUPPORT_UDP = true
+		UDP_CFG_NON_BLOCKING = true
+		USE_UDP_NON_BLOCKING = true
+		CDEFS := $(CDEFS) -DDHCP4_CLI_CFG
+		NETAPP_COBJS := $(NETAPP_COBJS) dhcp4_cli.o 
+	endif
+endif
+
+ifeq ($(USE_NETAPP_SUBR),true)
+	CDEFS := $(CDEFS) -DUSE_NETAPP_SUBR
+endif
+
+ifeq ($(API_CFG_IP4MAPPED_ADDR),true)
+	CDEFS := $(CDEFS) -DAPI_CFG_IP4MAPPED_ADDR
+endif
+
+ifeq ($(USE_COPYSAVE_API),true)
+	CDEFS := $(CDEFS) -DUSE_COPYSAVE_API
+endif
+
+ifeq ($(TCP_CFG_RWBUF_CSAVE_ONLY),true)
+	CDEFS := $(CDEFS) -DTCP_CFG_RWBUF_CSAVE_ONLY -DTCP_CFG_RWBUF_CSAVE
+endif
+
+ifeq ($(TCP_CFG_RWBUF_CSAVE),true)
+	CDEFS := $(CDEFS) -DTCP_CFG_RWBUF_CSAVE
+endif
+
+ifeq ($(TCP_CFG_SWBUF_CSAVE_ONLY),true)
+	CDEFS := $(CDEFS) -DTCP_CFG_SWBUF_CSAVE_ONLY -DTCP_CFG_SWBUF_CSAVE
+endif
+
+ifeq ($(TCP_CFG_SWBUF_CSAVE),true)
+	CDEFS := $(CDEFS) -DTCP_CFG_SWBUF_CSAVE
+endif
+
+ifeq ($(TCP_CFG_NON_BLOCKING),true)
+	ifeq ($(USE_TCP_NON_BLOCKING),true)
+		CDEFS := $(CDEFS) -DUSE_TCP_NON_BLOCKING
+	endif
+else
+	CDEFS := $(CDEFS) -DUNDEF_TCP_CFG_NON_BLOCKING
+endif
+
+ifeq ($(TCP_CFG_EXTENTIONS),true)
+	CDEFS := $(CDEFS) -DTCP_CFG_EXTENTIONS
+	ifeq ($(USE_TCP_EXTENTIONS),true)
+		CDEFS := $(CDEFS) -DUSE_TCP_EXTENTIONS
+	endif
+endif
+
+ifeq ($(UDP_CFG_NON_BLOCKING),true)
+	ifeq ($(USE_UDP_NON_BLOCKING),true)
+		CDEFS := $(CDEFS) -DUSE_UDP_NON_BLOCKING
+	else
+		ifeq ($(USE_UDP_CALL_BACK),true)
+			CDEFS := $(CDEFS) -DUSE_UDP_CALL_BACK
+		endif
+	endif
+else
+	CDEFS := $(CDEFS) -DUNDEF_UDP_CFG_NON_BLOCKING
+	ifeq ($(USE_UDP_CALL_BACK),true)
+		CDEFS := $(CDEFS) -DUSE_UDP_CALL_BACK
+	endif
+endif
+
+ifeq ($(UDP_CFG_EXTENTIONS),true)
+	CDEFS := $(CDEFS) -DUDP_CFG_EXTENTIONS
+	ifeq ($(USE_UDP_EXTENTIONS),true)
+		CDEFS := $(CDEFS) -DUSE_UDP_EXTENTIONS
+	endif
+endif
+
+ifeq ($(USE_LCD),true)
+	CDEFS := $(CDEFS) -DUSE_LCD
+endif
+
+#
+#  ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ã«é¢ããå®ç¾©ã¸ã®è¿½å 
+#
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+	APPLDIR := $(APPLDIR) $(NETAPP_DIRS)
+	APPL_COBJS := $(APPL_COBJS) $(NETAPP_COBJS)
+	APPL_CFLAGS := $(APPL_CFLAGS) -fno-strict-aliasing
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+	UTASK_DIRS := $(UTASK_DIRS):$(NETAPP_DIRS)
+	UTASK_COBJS := $(UTASK_COBJS) $(NETAPP_COBJS)
+	UTASK_CFLAGS := $(UTASK_CFLAGS) -fno-strict-aliasing
+
+endif
+
+ifeq ($(USE_LCD),true)
+
+ifeq ($(TARGET_KERNEL),ASP)
+
+	APPLDIR := $(APPLDIR) $(SRCDIR)/pdic/sc1602
+
+endif
+
+ifeq ($(TARGET_KERNEL),JSP)
+
+	UTASK_DIRS := $(UTASK_DIRS):$(SRCDIR)/pdic/sc1602
+
+endif
+
+endif
+
+#
+#  TINET ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®å®ç¾©ã¸ã®è¿½å 
+#
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(NETAPP_KERNEL_CFG)
Index: asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.c	(revision 317)
@@ -0,0 +1,3347 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã°ã³ã³ã½ã¼ã«
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <syssvc/serial.h>
+#include <syssvc/logtask.h>
+#include "kernel/kernel_impl.h"
+#include "kernel/task.h"
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#include "../kernel/jsp_kernel.h"
+#include "../kernel/task.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/ppp_var.h>
+#include <net/ppp_fsm.h>
+#include <net/ppp_lcp.h>
+#include <net/ppp_ipcp.h>
+#include <net/ppp_modem.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/if_ether.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_timer.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include <netinet6/nd6.h>
+
+#include <net/if_var.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/wwws.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv2.h>
+#include <netapp/tcp_echo_cli.h>
+#include <netapp/tcp_discard_cli.h>
+#include <netapp/udp6_echo_srv.h>
+#include <netapp/udp4_echo_srv.h>
+#include <netapp/udp6_echo_cli.h>
+#include <netapp/udp4_echo_cli.h>
+#include <netapp/udp_discard_cli.h>
+#include <netapp/resolver.h>
+#include <netapp/dbg_cons.h>
+#include <netapp/dhcp6_cli.h>
+#include <netapp/dhcp4_cli.h>
+#include "lcd.h"
+
+#ifdef USE_DBG_CONS
+
+/*
+ *  dbg_cons_task_status -- ã¿ã¹ã¯ã®ç¶æ
+ã®åºå
+ */
+
+static const char task_stat_str[][sizeof("SUSPENDED")] = {
+	"DORMANT",		/* ä¼æ­¢ç¶æ
+		*/
+	"RUNNABLE",		/* å®è¡ã§ããç¶æ
+	*/
+	"WAINTING",		/* å¾
+ã¡ç¶æ
+		*/
+	"SUSPENDED",		/* å¼·å¶å¾
+ã¡ç¶æ
+		*/
+	"SLEEP",		/* èµ·åºå¾
+ã¡ç¶æ
+		*/
+	"WOBJ",			/* åæã»éä¿¡ãªãã¸ã§ã¯ãã«å¯¾ããå¾
+ã¡ç¶æ
+	*/
+	"WOBJCB",		/* å
+±éé¨åã®å¾
+ã¡ã­ã¥ã¼ã«ã¤ãªãã£ã¦ããã	*/
+	};
+
+void
+dbg_cons_task_status (ID portid, char *line)
+{
+	TCB	*tcb;
+	int_t	ix, st, sx;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "TASK Status\n"
+	            "ID PI State\n");
+	for (ix = TMIN_TSKID; ix <= tmax_tskid; ix ++) {
+		tcb = get_tcb(ix);
+		cons_printf(portid, "%2d %2d ", ix, tcb->priority);
+		st = tcb->tstat;
+		for (sx = 0; st; sx ++) {
+			if (st & 0x01) {
+				cons_printf(portid, "%s", task_stat_str[sx]);
+				if (st & 0xfe)
+					cons_printf(portid, "|");
+				}
+			st >>= 1;
+			}
+		cons_putchar(portid, '\n');
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  tcp_status -- TCP ã®ç¶æ
+ã®åºå
+ */
+
+static const char tcp_fsm_str[][sizeof("ESTABLISHED")] = {
+	"CLOSED",		/* ã¯ã­ã¼ãº			*/
+	"LISTEN",		/* ååãªã¼ãã³			*/
+	"SYN_SENT",		/* è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿	*/
+	"SYN_RECVD",		/* ååãªã¼ãã³ãSYN åä¿¡æ¸ã¿	*/
+	"ESTABLISHED",		/* ã³ãã¯ã·ã§ã³éè¨­å®äº		*/
+	"CLOSE_WAIT",		/* ç¸æãã FIN åä¿¡ãAPP ã®çµäºå¾
+ã¡	*/
+	"FIN_WAIT_1",		/* APP ãçµäºãFIN éä¿¡æ¸ã¿ãACK å¾
+ã¡	*/
+	"CLOSING",		/* åæã¯ã­ã¼ãºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡	*/
+	"LAST_ACK",		/* APP ãçµäºãACK å¾
+ã¡			*/
+	"FIN_WAIT_2",		/* ç¸æããã® FIN å¾
+ã¡			*/
+	"TIME_WAIT",		/* ç¸æããã® FIN åä¿¡æ¸ã¿ãæéå¾
+ã¡	*/
+	};
+
+#if defined(SUPPORT_INET6)
+
+static void
+tcp_cep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	int		len;
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	T_TCP_TWCEP*	twcep;
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	cons_printf(portid,
+	            "TCP CEP Status\n"
+	            "ID  Snd-Q Rcv-Q Foreign Address                               State\n");
+
+	for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
+		if (!VALID_TCP_CEP(cep)) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " INVALID\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " CLOSED\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_LISTEN) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                                            "
+			            " LISTEN\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else {
+			cons_printf(portid,
+			            "%2d%c%c %5d %5d ",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4',
+			            cep->swbuf_count, cep->rwbuf_count);
+
+#if defined(SUPPORT_INET4)
+
+			if (TCP_IS_CEP_IPV4(cep)) {
+				T_IN4_ADDR	addr;
+
+				addr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+				len  = put_ipv4addr(portid, &addr, 0);
+				}
+			else
+				len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			len  = put_ipv6addr(portid, &cep->dstaddr.ipaddr, 0);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 44 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (cep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
+				                    cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
+			}
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
+		if (twcep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2dTW     0     0"
+			            " -                                            "
+			            " CLOSED\n",
+			            GET_TCP_TWCEPID(twcep));
+			}
+		else {
+			cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
+
+#if defined(SUPPORT_INET4)
+
+			if (TCP_IS_CEP_IPV4(twcep)) {
+				T_IN4_ADDR	addr;
+
+				addr = ntohl(twcep->dstaddr.ipaddr.s6_addr32[3]);
+				len  = put_ipv4addr(portid, &addr, 0);
+				}
+			else
+				len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			len  = put_ipv6addr(portid, &twcep->dstaddr.ipaddr, 0);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 44 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
+				                    twcep->timer_2msl / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
+			}
+		}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+static void
+tcp_cep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	uint_t		len;
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	T_TCP_TWCEP*	twcep;
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	cons_printf(portid,
+	            "TCP CEP Status\n"
+	            "ID  Snd-Q Rcv-Q Local Address         Foreign Address       State\n");
+
+	for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++)
+		if (!VALID_TCP_CEP(cep)) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                    "
+			            " -                    "
+			            " INVALID\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0"
+			            " -                    "
+			            " -                    "
+			            " CLOSED\n",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			}
+		else if (cep->fsm_state == TCP_FSM_LISTEN) {
+			cons_printf(portid,
+			            "%2d%c%c     0     0 ",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : '.',
+			            TCP_IS_CEP_IPV6(cep) ? '6' : '4');
+			len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 20 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			cons_printf(portid,
+			            " -                    "
+			            " LISTEN\n");
+			}
+		else {
+			cons_printf(portid,
+			            "%2d%c %5d %5d ",
+			            GET_TCP_CEPID(cep),
+			            DYNAMIC_TCP_CEP(cep) ? 'D' : ' ',
+			            cep->swbuf_count, cep->rwbuf_count);
+			len  = PUT_IPADDR(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 21 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			len  = PUT_IPADDR(portid, &cep->dstaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, cep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 20 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (cep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[cep->fsm_state],
+				                    cep->timer[TCP_TIM_2MSL] / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[cep->fsm_state]);
+			}
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	for (twcep = tcp_twcep; twcep < &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep ++) {
+		if (twcep->fsm_state == TCP_FSM_CLOSED) {
+			cons_printf(portid,
+			            "%2dTW     0     0"
+			            " -                    "
+			            " -                    "
+			            " CLOSED\n",
+			            GET_TCP_TWCEPID(twcep));
+			}
+		else {
+			cons_printf(portid, "%2dTW     0     0 ", GET_TCP_TWCEPID(twcep));
+			len  = PUT_IPADDR(portid, &twcep->myaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, twcep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 21 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			len  = PUT_IPADDR(portid, &twcep->dstaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, twcep->dstaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 20 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			if (twcep->fsm_state == TCP_FSM_TIME_WAIT)
+				cons_printf(portid, " %s(%d)\n", tcp_fsm_str[twcep->fsm_state],
+				                    twcep->timer_2msl / TCP_SLOW_HZ);
+			else
+				cons_printf(portid, " %s\n", tcp_fsm_str[twcep->fsm_state]);
+			}
+		}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if TNUM_TCP6_REPID > 0
+
+static void
+tcp6_rep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	T_TCP6_REP*	rep;
+	ID		repid;
+	int_t		cnt;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "TCP6 REP Status\n"
+	            "ID  Local Address         CEP\n");
+	for (repid = TMIN_TCP6_REPID; repid <= tmax_tcp6_repid; repid ++) {
+		rep = GET_TCP6_REP(repid);
+		cons_printf(portid, "%2d%c ", GET_TCP6_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
+		if (VALID_TCP_REP(rep)) {
+			len  = PUT_IPADDR(portid, &rep->myaddr.ipaddr, 0);
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 21 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			cnt = 0;
+			for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
+				if (TCP_IS_CEP_IPV6(cep) && cep->rep == rep) {
+					if (cnt > 0)
+						cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
+					else
+						cons_printf(portid, "%d", GET_TCP_CEPID(cep));
+					cnt ++;
+					}
+				}
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+	}
+
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+
+#if TNUM_TCP4_REPID > 0
+
+static void
+tcp4_rep_status (ID portid, char *line)
+{
+	T_TCP_CEP*	cep;
+	T_TCP4_REP*	rep;
+	ID		repid;
+	int_t		cnt;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "TCP4 REP Status\n"
+	            "ID  Local Address         CEP\n");
+	for (repid = TMIN_TCP4_REPID; repid <= tmax_tcp4_repid; repid ++) {
+		rep = GET_TCP4_REP(repid);
+		cons_printf(portid, "%2d%c ", GET_TCP4_REPID(rep), DYNAMIC_TCP_REP(rep) ? 'D' : ' ');
+		if (VALID_TCP_REP(rep)) {
+			len  = put_ipv4addr(portid, &rep->myaddr.ipaddr, 0);
+			cons_putchar(portid, ':');
+			len += cons_putnumber(portid, rep->myaddr.portno, 10, radhex, 0, false, ' ');
+			for (len = 21 - len; len -- > 0; )
+				cons_putchar(portid, ' ');
+			cnt = 0;
+			for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (TCP_IS_CEP_IPV4(cep) && cep->rep4 == rep) {
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (TCP_IS_CEP_IPV4(cep) && cep->rep == rep) {
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+					if (cnt > 0)
+						cons_printf(portid, ",%d", GET_TCP_CEPID(cep));
+					else
+						cons_printf(portid, "%d", GET_TCP_CEPID(cep));
+					cnt ++;
+					}
+				}
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+	}
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+
+static void
+tcp_status (ID portid, char *line)
+{
+	WAI_NET_CONS_PRINTF();
+
+	tcp_cep_status(portid, line);
+
+#if TNUM_TCP6_REPID > 0
+	tcp6_rep_status(portid, line);
+#endif
+
+#if TNUM_TCP4_REPID > 0
+	tcp4_rep_status(portid, line);
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+/*
+ *  udp6_status -- UDP ã®ç¶æ
+ã®åºå
+ */
+
+#if TNUM_UDP6_CEPID > 0
+
+extern const ID tmax_tcp_cepid;
+
+static void
+udp6_status (ID portid, char *line)
+{
+	T_UDP6_CEP*	cep;
+	ID		cepid;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "UDP6 CEP Status\n"
+	            "ID  Local Address\n");
+
+	for (cepid = TMIN_UDP6_CEPID; cepid <= tmax_udp6_cepid; cepid ++) {
+		cep = GET_UDP6_CEP(cepid);
+		cons_printf(portid, "%2d%c ", GET_UDP6_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
+		if (VALID_UDP_CEP(cep)) {
+			len  = put_ipv6addr(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+
+	SIG_NET_CONS_PRINTF();
+	}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+/*
+ *  udp4_status -- UDP ã®ç¶æ
+ã®åºå
+ */
+
+#if TNUM_UDP4_CEPID > 0
+
+static void
+udp4_status (ID portid, char *line)
+{
+	T_UDP4_CEP*	cep;
+	ID		cepid;
+	uint_t		len;
+
+	cons_printf(portid,
+	            "UDP4 CEP Status\n"
+	            "ID  Local Address\n");
+
+	for (cepid = TMIN_UDP4_CEPID; cepid <= tmax_udp4_cepid; cepid ++) {
+		cep = GET_UDP4_CEP(cepid);
+		cons_printf(portid, "%2d%c ", GET_UDP4_CEPID(cep), DYNAMIC_UDP_CEP(cep) ? 'D' : ' ');
+		if (VALID_UDP_CEP(cep)) {
+			len  = put_ipv4addr(portid, &cep->myaddr.ipaddr, 0);
+			cons_putchar(portid, '.');
+			len += cons_putnumber(portid, cep->myaddr.portno, 10, radhex, 0, false, ' ');
+			}
+		else
+			cons_printf(portid, "INVALID");
+		cons_putchar(portid, '\n');
+		}
+
+	SIG_NET_CONS_PRINTF();
+	}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+static void
+udp_status (ID portid, char *line)
+{
+	WAI_NET_CONS_PRINTF();
+
+#if TNUM_UDP6_CEPID > 0
+	udp6_status(portid, line);
+#endif
+
+#if TNUM_UDP4_CEPID > 0
+	udp4_status(portid, line);
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #ifdef SUPPORT_UDP */
+
+#ifdef SUPPORT_ETHER
+
+#if defined(SUPPORT_INET6)
+
+/*
+ * ifa6_status -- è¿é£ã­ã£ãã·ã¥ç¶æ
+ã®åºå
+ */
+
+static const char nd_state_str[][sizeof("INCOMPLETE")] = {
+	"FREE",			/* æªä½¿ç¨		*/
+	"NO STATE",		/* ç¶æ
+æªå®ç¾©		*/
+	"INCOMPLETE",		/* æªè§£æ±º		*/
+	"REACHABLE",		/* å°éå¯è½		*/
+	"STALE",		/* å°éå¯è½æ§ã¯æªç¢ºèª	*/
+	"DELAY",		/* å°éå¯è½æ§ã®ç¢ºèªå¾
+æ©	*/
+	"PROBE",		/* å°éå¯è½æ§ãç¢ºèªä¸­	*/
+	};
+
+static void
+ifa6_status (ID portid, char *line)
+{
+	const T_LLINFO_ND6	*cache;
+	SYSTIM			now;
+	int_t			ix;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "ND Cache Status\n"
+	            "IX Expire State      MAC Address       IP Address\n");
+
+	/* expire ã®åä½ã¯ [ms]ã*/
+	get_tim(&now);
+	cache = nd6_get_cache();
+	for (ix = 0; ix < NUM_ND6_CACHE_ENTRY; ix ++) {
+		if (cache[ix].state != ND6_LLINFO_FREE) {
+			cons_printf(portid, "%2d %6ld %10s %M %lI\n",
+			            ix, 
+			            cache[ix].state == ND6_LLINFO_STALE ||
+			            (uint32_t)((int32_t)(cache[ix].expire - now) <= 0
+			                 ? 0 : (int32_t)(cache[ix].expire - now) / SYSTIM_HZ),
+			            nd_state_str[cache[ix].state],
+			            &cache[ix].ifaddr,
+			            &cache[ix].addr);
+			}
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  ifa4_status -- ARP ã­ã£ãã·ã¥åºå
+ */
+
+static void
+ifa4_status (ID portid, char *line)
+{
+	const T_ARP_ENTRY	*cache;
+	int_t			ix;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "ARP Cache\n"
+	            "IX Expire MAC Address       IP Address\n");
+
+	/* expire ã®åä½ã¯ [ms]ã*/
+	cache = arp_get_cache();
+	for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
+		if (cache[ix].expire != 0)
+			cons_printf(portid, "%2d %6d %M %hI\n",
+			                    ix, cache[ix].expire / NET_TIMER_HZ,
+			                    cache[ix].mac_addr, &cache[ix].ip_addr);
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if NET_COUNT_ENABLE
+
+/*
+ *  net_count_struct -- ãããã¯ã¼ã¯çµ±è¨æ
+å ±
+ */
+
+static void
+net_count_struct (ID portid, char *name, T_NET_COUNT *item)
+{
+	cons_printf(portid, "\n%s\n", name);
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",	item->in_octets);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",	item->out_octets);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",		item->in_packets);
+	cons_printf(portid, "\téä¿¡ãã±ããæ°\t%lu\n",		item->out_packets);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",	item->in_err_packets);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",	item->out_err_packets);
+	}
+
+/*
+ *  net_count -- ãããã¯ã¼ã¯çµ±è¨æ
+å ±
+ */
+
+static void
+net_count (ID portid, char *line)
+{
+	const T_NET_BUF_ENTRY	*tbl;
+	SYSTIM			now;
+	int_t			ix;
+
+	WAI_NET_CONS_PRINTF();
+	get_tim(&now);
+	cons_printf(portid, "ãããã¯ã¼ã¯çµ±è¨æ
+å ±\tçµéæé[ms]\t%lu\t", now);
+	if (now > (1000 * 3600 * 24))
+		cons_printf(portid, "%3luæ¥ %2luæé %2luå %2luç§\n",
+		             now / (1000 * 3600 * 24),
+		            (now / (1000 * 3600)) % 24,
+		            (now / (1000 * 60  )) % 60,
+		            (now /  1000        ) % 60);
+	else
+		cons_printf(portid, "%2luæé %2luå %2luç§\n",
+		            (now / (1000 * 3600)) % 24,
+		            (now / (1000 * 60  )) % 60,
+		            (now /  1000        ) % 60);
+
+#ifdef SUPPORT_PPP
+
+	net_count_struct(portid, "HDLC", &net_count_hdlc);
+	cons_printf(portid, "\nPPP\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",	net_count_ppp.in_octets);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",	net_count_ppp.out_octets);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",		net_count_ppp.in_packets);
+	cons_printf(portid, "\téä¿¡ãã±ããæ°\t%lu\n",		net_count_ppp.out_packets);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",	net_count_ppp.in_err_packets);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",	net_count_ppp.out_err_packets);
+	cons_printf(portid, "\tnet_buf å²ãå½ã¦å¤±ææ°\t%lu\n",	net_count_ppp_no_bufs);
+
+	cons_printf(portid, "\nLCP\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",	net_count_ppp_lcp_in_octets);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",		net_count_ppp_lcp_in_packets);
+
+	cons_printf(portid, "\nIPCP\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",	net_count_ppp_ipcp_in_octets);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",		net_count_ppp_ipcp_in_packets);
+
+	cons_printf(portid, "\nPAP\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",	net_count_ppp_upap_in_octets);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",		net_count_ppp_upap_in_packets);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+	net_count_struct(portid, "ã¤ã¼ãµããã", &net_count_ether);
+
+	cons_printf(portid, "\nã¤ã¼ãµãããã»ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",			net_count_ether_nic[NC_ETHER_NIC_IN_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",				net_count_ether_nic[NC_ETHER_NIC_IN_PACKETS]);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",			net_count_ether_nic[NC_ETHER_NIC_IN_ERR_PACKETS]);
+	cons_printf(portid, "\tnet_buf å²ãå½ã¦å¤±ææ°\t%lu\n",			net_count_ether_nic[NC_ETHER_NIC_NO_BUFS]);
+	cons_printf(portid, "\tåä¿¡ã»ããã©è³æºè¿å´ä¸éãªã¼ãã¼æ°\t%lu\n",	net_count_ether_nic[NC_ETHER_NIC_RXB_QOVRS]);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",			net_count_ether_nic[NC_ETHER_NIC_OUT_OCTETS]);
+	cons_printf(portid, "\téä¿¡ãã±ããæ°\t%lu\n",				net_count_ether_nic[NC_ETHER_NIC_OUT_PACKETS]);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",			net_count_ether_nic[NC_ETHER_NIC_OUT_ERR_PACKETS]);
+	cons_printf(portid, "\tã³ãªã¸ã§ã³æ°\t%lu\n",				net_count_ether_nic[NC_ETHER_NIC_COLS]);
+	cons_printf(portid, "\téä¿¡ã»ããã©è³æºè¿å´ä¸éãªã¼ãã¼æ°\t%lu\n",	net_count_ether_nic[NC_ETHER_NIC_TXB_QOVRS]);
+	cons_printf(portid, "\téä¿¡ã¿ã¤ã ã¢ã¦ãæ°	\t%lu\n",		net_count_ether_nic[NC_ETHER_NIC_TIMEOUTS]);
+	cons_printf(portid, "\tãªã»ããæ°\t%lu\n",				net_count_ether_nic[NC_ETHER_NIC_RESETS]);
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "\nIPv6\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_ip6[NC_IP6_IN_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ãã¼ã¿ã°ã©ã æ°\t%lu\n",		net_count_ip6[NC_IP6_IN_PACKETS]);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°\t%lu\n",	net_count_ip6[NC_IP6_IN_ERR_PACKETS]);
+	cons_printf(portid, "\té·ãã¨ã©ã¼æ°\t%lu\n",			net_count_ip6[NC_IP6_IN_ERR_SHORT]);
+	cons_printf(portid, "\tãã¼ã¸ã§ã³ã¨ã©ã¼æ°\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_VER]);
+	cons_printf(portid, "\tã¢ãã¬ã¹ã¨ã©ã¼æ°\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_ADDR]);
+	cons_printf(portid, "\tãã­ãã³ã«ã¨ã©ã¼æ°\t%lu\n",		net_count_ip6[NC_IP6_IN_ERR_PROTO]);
+	cons_printf(portid, "\tåå²åä¿¡æ°\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN]);
+	cons_printf(portid, "\tåå²åä¿¡ãã©ã°ã¡ã³ãæ°\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_FRAGS]);
+	cons_printf(portid, "\tåå²åä¿¡åæ§ææåæ°\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_OK]);
+	cons_printf(portid, "\tåå²åä¿¡ç ´æ£æ°\t%lu\n",			net_count_ip6[NC_IP6_FRAG_IN_DROP]);
+	cons_printf(portid, "\tåå²åä¿¡ãããã¡ãå½ã¦å¤±ææ°\t%lu\n",	net_count_ip6[NC_IP6_FRAG_IN_NO_BUF]);
+	cons_printf(portid, "\tåå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°\t%lu\n",		net_count_ip6[NC_IP6_FRAG_IN_TMOUT]);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_ip6[NC_IP6_OUT_OCTETS]);
+	cons_printf(portid, "\téä¿¡ãã¼ã¿ã°ã©ã æ°\t%lu\n",		net_count_ip6[NC_IP6_OUT_PACKETS]);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°\t%lu\n",	net_count_ip6[NC_IP6_OUT_ERR_PACKETS]);
+	cons_printf(portid, "\tåå²éä¿¡æ°\t%lu\n",			net_count_ip6[NC_IP6_FRAG_OUT]);
+	cons_printf(portid, "\tåå²éä¿¡ãã©ã°ã¡ã³ãæ°\t%lu\n",		net_count_ip6[NC_IP6_FRAG_OUT_FRAGS]);
+
+	cons_printf(portid, "\nICMPv6\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ãã±ããæ°\t%lu\n",			net_count_icmp6[NC_ICMP6_IN_PACKETS]);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS]);
+	cons_printf(portid, "\tåä¿¡ããã¯ãµã ã¨ã©ã¼æ°\t%lu\n",		net_count_icmp6[NC_ICMP6_IN_ERR_CKSUM]);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_OCTETS]);
+	cons_printf(portid, "\téä¿¡ãã±ããæ°\t%lu\n",			net_count_icmp6[NC_ICMP6_OUT_PACKETS]);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã±ããæ°\t%lu\n",		net_count_icmp6[NC_ICMP6_OUT_ERR_PACKETS]);
+
+	cons_printf(portid, "\nè¿é£æ¢ç´¢\n");
+	cons_printf(portid, "\tã«ã¼ã¿éç¥åä¿¡æ°\t%lu\n",		net_count_nd6[NC_ND6_RA_IN_PACKETS]);
+	cons_printf(portid, "\tã«ã¼ã¿è¦è«éä¿¡æ°\t%lu\n",		net_count_nd6[NC_ND6_RS_OUT_PACKETS]);
+	cons_printf(portid, "\tè¿é£éç¥åä¿¡æ°\t%lu\n",			net_count_nd6[NC_ND6_NA_IN_PACKETS]);
+	cons_printf(portid, "\tè¿é£éç¥éä¿¡æ°\t%lu\n",			net_count_nd6[NC_ND6_NA_OUT_PACKETS]);
+	cons_printf(portid, "\tè¿é£è¦è«åä¿¡æ°\t%lu\n",			net_count_nd6[NC_ND6_NS_IN_PACKETS]);
+	cons_printf(portid, "\tè¿é£è¦è«éä¿¡æ°\t%lu\n",			net_count_nd6[NC_ND6_NS_OUT_PACKETS]);
+	cons_printf(portid, "\téè¤ã¢ãã¬ã¹æ¤åºéä¿¡æ°\t%lu\n",		net_count_nd6[NC_ND6_DAD_OUT_PACKETS]);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#ifdef SUPPORT_ETHER
+
+	net_count_struct(portid, "ARP", &net_count_arp);
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	cons_printf(portid, "\nIPv4\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_ip4[NC_IP4_IN_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ãã¼ã¿ã°ã©ã æ°\t%lu\n",		net_count_ip4[NC_IP4_IN_PACKETS]);
+	cons_printf(portid, "\tåä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°\t%lu\n",	net_count_ip4[NC_IP4_IN_ERR_PACKETS]);
+	cons_printf(portid, "\tãã§ãã¯ãµã ã¨ã©ã¼æ°\t%lu\n",		net_count_ip4[NC_IP4_IN_ERR_CKSUM]);
+	cons_printf(portid, "\té·ãã¨ã©ã¼æ°\t%lu\n",			net_count_ip4[NC_IP4_IN_ERR_SHORT]);
+	cons_printf(portid, "\tãã¼ã¸ã§ã³ã¨ã©ã¼æ°\t%lu\n",		net_count_ip4[NC_IP4_IN_ERR_VER]);
+	cons_printf(portid, "\tã¢ãã¬ã¹ã¨ã©ã¼æ°\t%lu\n",		net_count_ip4[NC_IP4_IN_ERR_ADDR]);
+	cons_printf(portid, "\tãã­ãã³ã«ã¨ã©ã¼æ°\t%lu\n",		net_count_ip4[NC_IP4_IN_ERR_PROTO]);
+	cons_printf(portid, "\tãªãã·ã§ã³å
+¥åæ°\t%lu\n",		net_count_ip4[NC_IP4_OPTS]);
+	cons_printf(portid, "\tåå²åä¿¡æ°\t%lu\n",			net_count_ip4[NC_IP4_FRAG_IN]);
+	cons_printf(portid, "\tåå²åä¿¡ãã©ã°ã¡ã³ãæ°\t%lu\n",		net_count_ip4[NC_IP4_FRAG_IN_FRAGS]);
+	cons_printf(portid, "\tåå²åä¿¡åæ§ææåæ°\t%lu\n",		net_count_ip4[NC_IP4_FRAG_IN_OK]);
+	cons_printf(portid, "\tåå²åä¿¡ç ´æ£æ°\t%lu\n",			net_count_ip4[NC_IP4_FRAG_IN_DROP]);
+	cons_printf(portid, "\tåå²åä¿¡ãããã¡ãå½ã¦å¤±ææ°\t%lu\n",	net_count_ip4[NC_IP4_FRAG_IN_NO_BUF]);
+	cons_printf(portid, "\tåå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°\t%lu\n",		net_count_ip4[NC_IP4_FRAG_IN_TMOUT]);
+	cons_printf(portid, "\téä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_ip4[NC_IP4_OUT_OCTETS]);
+	cons_printf(portid, "\téä¿¡ãã¼ã¿ã°ã©ã æ°\t%lu\n",		net_count_ip4[NC_IP4_OUT_PACKETS]);
+	cons_printf(portid, "\téä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°\t%lu\n",	net_count_ip4[NC_IP4_OUT_ERR_PACKETS]);
+	cons_printf(portid, "\tåå²éä¿¡æ°\t%lu\n",			net_count_ip4[NC_IP4_FRAG_OUT]);
+	cons_printf(portid, "\tåå²éä¿¡ãã©ã°ã¡ã³ãæ°\t%lu\n",		net_count_ip4[NC_IP4_FRAG_OUT_FRAGS]);
+
+	net_count_struct(portid, "ICMP", &net_count_icmp4);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#ifdef SUPPORT_TCP
+
+	cons_printf(portid, "\nTCP\n");
+	cons_printf(portid, "\tåä¿¡ãªã¯ãããæ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ãã¼ã¿ãªã¯ãããæ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_DATA_OCTETS]);
+	cons_printf(portid, "\tåä¿¡ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_SEGS]);
+	cons_printf(portid, "\tåä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_DATA_SEGS]);
+	cons_printf(portid, "\tåä¿¡ãç·æ¥ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_URG_SEGS]);
+	cons_printf(portid, "\tåä¿¡ããããä¸æ­£æ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_BAD_HEADERS]);
+	cons_printf(portid, "\tåä¿¡ããã§ãã¯ãµã ä¸æ­£æ°\t%lu\n",	net_count_tcp[NC_TCP_RECV_BAD_CKSUMS]);
+	cons_printf(portid, "\tåä¿¡ãACK æ°\t%lu\n",			net_count_tcp[NC_TCP_RECV_ACKS]);
+	cons_printf(portid, "\tåä¿¡ãå¤é ACK æ°\t%lu\n",		net_count_tcp[NC_TCP_RECV_DUP_ACKS]);
+	cons_printf(portid, "\tåä¿¡ãRST æ°\t%lu\n",			net_count_tcp[NC_TCP_RECV_RSTS]);
+	cons_printf(portid, "\tåä¿¡ãå¤éæ°\t%lu\n",			net_count_tcp[NC_TCP_RECV_DUP_SEGS]);
+	cons_printf(portid, "\tåä¿¡ãç ´æ£æ°\t%lu\n",			net_count_tcp[NC_TCP_RECV_DROP_SEGS]);
+	cons_printf(portid, "\tåä¿¡ã­ã¥ã¼è§£æ¾æ°\t%lu\n",		net_count_tcp[NC_TCP_FREE_RCV_QUEUE]);
+	cons_printf(portid, "\téä¿¡ãã¼ã¿ãªã¯ãããæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_DATA_OCTETS]);
+	cons_printf(portid, "\téä¿¡å¶å¾¡ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_CNTL_SEGS]);
+	cons_printf(portid, "\téä¿¡ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_SEGS]);
+	cons_printf(portid, "\tåéä¿¡ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_REXMIT_SEGS]);
+	cons_printf(portid, "\téä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_DATA_SEGS]);
+	cons_printf(portid, "\téä¿¡ãç·æ¥ã»ã°ã¡ã³ãæ°\t%lu\n",		net_count_tcp[NC_TCP_SEND_URG_SEGS]);
+	cons_printf(portid, "\téä¿¡ãACK æ°\t%lu\n",			net_count_tcp[NC_TCP_SEND_ACKS]);
+	cons_printf(portid, "\téä¿¡ãRST æ°\t%lu\n",			net_count_tcp[NC_TCP_SEND_RSTS]);
+	cons_printf(portid, "\tRTT æ´æ°æ°\t%lu\n",			net_count_tcp[NC_TCP_RTT_UPDATES]);
+	cons_printf(portid, "\tååãªã¼ãã³æ°\t%lu\n",			net_count_tcp[NC_TCP_ACCEPTS]);
+	cons_printf(portid, "\tè½åãªã¼ãã³æ°\t%lu\n",			net_count_tcp[NC_TCP_CONNECTS]);
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+	net_count_struct(portid, "UDP",  &net_count_udp);
+
+#endif	/* of #ifdef SUPPORT_UDP */
+
+	tbl = nbuf_get_tbl();
+	cons_printf(portid, "\nãããã¯ã¼ã¯ãããã¡\n\tãµã¤ãº\tç¨ææ°\tä½¿ç¨ä¸­æ°\tå²å½è¦æ±æ°\tå²å½æ°\tå²å½ã¦ã¨ã©ã¼æ°\n");
+	for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
+		cons_printf(portid, "\t%lu\t%lu\t%lu\t%lu\t%lu\t%lu\n",
+		                    tbl[ix].size,
+		                    tbl[ix].prepares,
+		                    tbl[ix].busies,
+		                    tbl[ix].requests,
+		                    tbl[ix].allocs,
+		                    tbl[ix].errors);
+		}
+
+	cons_printf(portid, "\nãããã¯ã¼ã¯çµ±è¨æ
+å ±\tçµéæé[ms]\t%lu\t", now);
+	if (now > (1000 * 3600 * 24))
+		cons_printf(portid, "%3luæ¥ %2luæé %2luå %2luç§\n",
+		             now / (1000 * 3600 * 24),
+		            (now / (1000 * 3600)) % 24,
+		            (now / (1000 * 60  )) % 60,
+		            (now /  1000        ) % 60);
+	else
+		cons_printf(portid, "%2luæé %2luå %2luç§\n",
+		            (now / (1000 * 3600)) % 24,
+		            (now / (1000 * 60  )) % 60,
+		            (now /  1000        ) % 60);
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#if defined(SUPPORT_INET4)
+
+#ifdef IP4_CFG_FRAGMENT
+
+/*
+ *  nbuf_stat_ip4_frag_queue -- IPv4 åæ§æã­ã¥ã¼å
+ãããã¯ã¼ã¯ãããã¡æ
+å ±
+ */
+
+static void
+nbuf_stat_ip4_frag_queue (ID portid)
+{
+	const T_NET_BUF_ENTRY	*tbl;
+	const T_NET_BUF		*nbuf, **queue;
+	int_t			ix, fix, count;
+
+	cons_printf(portid, "\nIPv4åæ§æã­ã¥ã¼å
+\nIndex\tTime");
+	tbl = nbuf_get_tbl();
+	for (ix = nbuf_get_tbl_size(); ix -- > 0; )
+		cons_printf(portid, "\t%d", tbl[ix].size);
+	cons_putchar(portid, '\n');
+
+	queue = ip_get_frag_queue();
+	for (fix = 0; fix < NUM_IP4_FRAG_QUEUE; fix ++) {
+		if (queue[fix] != NULL) {
+			cons_printf(portid, "%d\t%d", fix, GET_QIP4_HDR(queue[fix])->ttl);
+			for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
+				count = 0;
+				for (nbuf = queue[fix]; nbuf != NULL; nbuf = GET_QIP4_HDR(nbuf)->next)
+					if (nbuf->idix == ix)
+						count ++;
+				cons_printf(portid, "\t%d", count);
+				}
+			cons_putchar(portid, '\n');
+			}
+		}
+	}
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+#ifdef IP6_CFG_FRAGMENT
+
+/*
+ *  nbuf_stat_ip6_frag_queue -- IPv6 åæ§æã­ã¥ã¼å
+ãããã¯ã¼ã¯ãããã¡æ
+å ±
+ */
+
+static void
+nbuf_stat_ip6_frag_queue (ID portid)
+{
+	const T_NET_BUF_ENTRY	*tbl;
+	const T_NET_BUF		*nbuf, **queue;
+	int_t			ix, fix, count;
+
+	cons_printf(portid, "\nIPv6åæ§æã­ã¥ã¼å
+\nIndex\tTime");
+	tbl = nbuf_get_tbl();
+	for (ix = nbuf_get_tbl_size(); ix -- > 0; )
+		cons_printf(portid, "\t%d", tbl[ix].size);
+	cons_putchar(portid, '\n');
+
+	queue = ip6_get_frag_queue();
+	for (fix = 0; fix < NUM_IP6_FRAG_QUEUE; fix ++) {
+		if (queue[fix] != NULL) {
+			cons_printf(portid, "%d\t%d", fix, GET_QIP6_HDR(queue[fix])->ftim);
+			for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
+				count = 0;
+				for (nbuf = queue[fix]; nbuf != NULL; nbuf = GET_QIP6_HDR(nbuf)->next_frag)
+					if (nbuf->idix == ix)
+						count ++;
+				cons_printf(portid, "\t%d", count);
+				}
+			cons_putchar(portid, '\n');
+			}
+		}
+	}
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+/*
+ *  nbuf_status -- ãããã¯ã¼ã¯ãããã¡æ
+å ±
+ */
+
+static void
+nbuf_status (ID portid, char *line)
+{
+	SYSTIM		now;
+
+#if NET_COUNT_ENABLE
+	const T_NET_BUF_ENTRY	*tbl;
+	int_t			ix;
+#endif	/* of #if NET_COUNT_ENABLE */
+
+#ifdef SUPPORT_TCP
+	T_NET_BUF		*nbuf;
+	T_TCP_CEP*		cep;
+	T_TCP_Q_HDR*		tqhdr;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	T_TCP_HDR*		tcph;
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+#endif	/* of #ifdef SUPPORT_TCP */
+
+	WAI_NET_CONS_PRINTF();
+	get_tim(&now);
+	cons_printf(portid, "ãããã¯ã¼ã¯ãããã¡æ
+å ±\tçµéæé[ms]\t%u\n", now);
+
+#if NET_COUNT_ENABLE
+
+	cons_printf(portid, "\nãããã¯ã¼ã¯ãããã¡\n\tãµã¤ãº\tç¨ææ°\tä½¿ç¨ä¸­æ°\tå²å½è¦æ±æ°\tå²å½æ°\tå²å½ã¦ã¨ã©ã¼æ°\n");
+	tbl = nbuf_get_tbl();
+	for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
+		cons_printf(portid, "\t%u\t%u\t%u\t%u\t%u\t%u\n",
+		                    tbl[ix].size,
+		                    tbl[ix].prepares,
+		                    tbl[ix].busies,
+		                    tbl[ix].requests,
+		                    tbl[ix].allocs,
+		                    tbl[ix].errors);
+		}
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+#ifdef SUPPORT_TCP
+
+	cons_printf(portid, "\nCEPå
+\nCEPID\n");
+
+	for (cep = tcp_cep; cep < &tcp_cep[tmax_tcp_cepid]; cep ++) {
+		cons_printf(portid, "%2d", GET_TCP_CEPID(cep));
+		for (nbuf = cep->reassq; nbuf != NULL; nbuf = tqhdr->next) {
+			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
+			cons_printf(portid, "[a:%6lu-%6lu] ",
+			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
+			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
+			}
+
+#ifdef TCP_CFG_RWBUF_CSAVE
+		for (nbuf = cep->rwbufq; nbuf != NULL; nbuf = tqhdr->next) {
+			tqhdr = GET_TCP_Q_HDR(nbuf, GET_TCP_HDR_OFFSET(nbuf));
+			cons_printf(portid, "[r:%6lu-%6lu] ",
+			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff,
+			            ntohl(tqhdr->seq) - cep->irs + tqhdr->soff + tqhdr->slen);
+			}
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+		if (cep->swbufq != NULL) {
+			tcph = GET_TCP_HDR(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq));
+#if 0
+			cons_printf(portid, "[s:%6lu-%6lu] ",
+			            ntohl(tcph->seq) - cep->iss,
+			            ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 
+			                                           GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))));
+#else
+			cons_printf(portid, "[s:%6lu-%6lu,%08x,%08x] ",
+			            ntohl(tcph->seq) - cep->iss,
+			            ntohl(tcph->seq) - cep->iss + (GET_IP_SDU_SIZE(cep->swbufq) - 
+			                                           GET_TCP_HDR_SIZE(cep->swbufq, GET_TCP_HDR_OFFSET(cep->swbufq))),
+			            ntohl(tcph->seq), cep->iss);
+#endif
+			}
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		cons_putchar(portid, '\n');
+		}
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#if NET_COUNT_ENABLE
+
+#if defined(SUPPORT_INET4)
+
+#ifdef IP4_CFG_FRAGMENT
+
+	nbuf_stat_ip4_frag_queue(portid);
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+#ifdef IP6_CFG_FRAGMENT
+
+	nbuf_stat_ip6_frag_queue(portid);
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#ifdef USE_RESOLVER
+
+/*
+ *  show_dns_soa -- DNS ã® SOA RDATA ãè¡¨ç¤ºããã
+ */
+
+static ER_UINT
+show_dns_soa (ID portid, uint8_t *msg, ER_UINT length, uint_t offset)
+{
+	T_RSLV_SOA	soa;
+	ER_UINT		error;
+	uint_t		rn_offset;
+
+	if ((error = dns_analyze_soa(&soa, offset, msg, length)) < 0)
+		return error;
+
+	cons_printf(portid, "    mname:   ");
+	rn_offset = show_dns_domain_name(portid, msg, offset);
+	cons_putchar(portid, '\n');
+	cons_printf(portid, "    rname:   ");
+	show_dns_domain_name(portid, msg, rn_offset);
+	cons_putchar(portid, '\n');
+
+	cons_printf(portid, "    serial:  %d\n", soa.serial);
+	cons_printf(portid, "    refresh: %d\n", soa.refresh);
+	cons_printf(portid, "    retry:   %d\n", soa.retry);
+	cons_printf(portid, "    expirel: %d\n", soa.expire);
+	cons_printf(portid, "    minimum: %d\n", soa.minimum);
+
+	return E_OK;
+	}
+
+/*
+ *  show_dns_qdsection -- DNS ã® Question ã»ã¯ã·ã§ã³ãè¡¨ç¤ºããã
+ */
+
+static ER_UINT
+show_dns_qdsection (ID portid, uint8_t *msg, ER_UINT length, T_RSLV_DNS_MSG *rslv)
+{
+	T_RSLV_QD	qd;
+	ER_UINT		offset, error;
+	int		scount;
+
+	cons_printf(portid, "question   section: %d\n", rslv->dns_hdr.qdcount);
+	offset = rslv->qd_offset;
+	for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount ++) {
+		if ((error = dns_analyze_qd(&qd, offset, msg, length)) < 0)
+			return error;
+
+		cons_printf(portid, "%2d: ", scount);
+		show_dns_domain_name(portid, msg, offset);
+		cons_printf(portid, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
+		offset = error;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  show_dns_section -- DNS ã®åã»ã¯ã·ã§ã³ãè¡¨ç¤ºããã
+ */
+
+static ER_UINT
+show_dns_section (ID portid, uint8_t *msg, ER_UINT length, uint_t scount, uint_t offset, char *title)
+{
+	T_RSLV_RR	rr;
+	T_IN4_ADDR	in4_addr;
+	ER_UINT		error;
+	int		count, dcount, col;
+	T_IN6_ADDR	in6_addr;
+
+	cons_printf(portid, "%10s section: %d\n", title, scount);
+	for (count = 1; count <= scount; count ++) {
+		if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
+			return error;
+
+		cons_printf(portid, "%2d: ", count);
+		show_dns_domain_name(portid, msg, offset);
+		cons_printf(portid, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
+		            dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
+
+		switch (rr.type) {
+		case DNS_TYPE_A:
+			memcpy((void*)&in4_addr, (void*)(msg + rr.rdata_offset), sizeof(in4_addr));
+			in4_addr = ntohl(in4_addr);
+			cons_printf(portid, "    IPv4 addr: %hI\n", &in4_addr);
+			break;
+		case DNS_TYPE_NS:
+			cons_printf(portid, "    host: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_CNAME:
+			cons_printf(portid, "    host: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_SOA:
+			show_dns_soa(portid, msg, length, rr.rdata_offset);
+			break;
+		case DNS_TYPE_PTR:
+			cons_printf(portid, "     PTR: ");
+			show_dns_domain_name(portid, msg, rr.rdata_offset);
+			cons_putchar(portid, '\n');
+			break;
+		case DNS_TYPE_AAAA:
+			memcpy((void*)&in6_addr, (void*)(msg + rr.rdata_offset), sizeof(in6_addr));
+			cons_printf(portid, "    IPv6 addr: %lI\n", &in6_addr);
+			break;
+		default:
+			cons_printf(portid, "    data: ");
+			col = 32;
+			for (dcount = 0; dcount < rr.rdlength; dcount ++) {
+				cons_printf(portid, "%02x", *(msg + rr.rdata_offset + dcount));
+				if (-- col == 0) {
+					cons_printf(portid, "\n          ");
+					col = 32;
+					}
+				}
+			cons_putchar(portid, '\n');
+			break;
+			}
+		}
+
+	return E_OK;
+	}
+/*
+ *  dns_info -- DNS æ
+å ±ã®è¡¨ç¤º
+ */
+
+static void
+dns_info (ID portid)
+{
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	in6_addr;
+#endif
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	in4_addr;
+#endif
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "domain name:     %s\n", dns_in6_get_dname());
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+	cons_printf(portid, "domain name:     %s\n", dns_in4_get_dname());
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET6)
+	dns_in6_get_addr(&in6_addr);
+	cons_printf(portid, "IPv6 DNS server: ");
+	if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
+		cons_printf(portid, "not available.\n");
+	else
+		cons_printf(portid, "%lI.\n", &in6_addr);
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+	dns_in4_get_addr(&in4_addr);
+	cons_printf(portid, "IPv4 DNS server: ");
+	if (in4_addr == IPV4_ADDRANY)
+		cons_printf(portid, "not available.\n");
+	else
+		cons_printf(portid, "%hI.\n", &in4_addr);
+#endif	/* of #if defined(SUPPORT_INET4) */
+	}
+
+/*
+ *  name_lookup -- ãã¹ãåï¼IP ã¢ãã¬ã¹å¤æ
+ */
+
+const char *rcode_str[] = {
+	"no error",
+	"format error",
+	"server error",
+	"name error",
+	"not implement",
+	"refused",
+	};
+
+static void
+name_lookup (ID portid, char *line)
+{
+	static char hostname[DBG_LINE_SIZE + 1];
+
+	T_RSLV_DNS_MSG	rslv;
+	ER_UINT		length, offset;
+	ER		error;
+	uint_t		flags = 0;
+	uint8_t 	*msg;
+
+	/* ã³ãã³ãã®ãªãã·ã§ã³ãè¨­å®ããã*/
+	line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
+	if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
+		cons_printf(portid, "DNS server not available.\n");
+		return;
+		}
+
+	/* ç
+§ä¼ãããã¹ãåã»IP ã¢ãã¬ã¹ãè§£æããã*/
+	resolv_hoststr(&flags, hostname, sizeof(hostname), line);
+
+	/* æ­£å¼ãã§ãéå¼ãã§ããã­ãã³ã«ä¸ã¯æ­£å¼ããæå®ããã*/
+	flags |= DNS_LUP_OPCODE_FORWARD;
+
+	/* IPv6 ã¢ãã¬ã¹ãã¾ãã¯ IPv4 ã¢ãã¬ã¹ãæå®ãããæã¯ãç
+§ä¼ã¿ã¤ãã¯ PTR ã«è¨­å®ããã*/
+	if (((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV6) ||
+	    ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_IPV4))
+		flags = (flags & ~DNS_LUP_FLAGS_QTYPE_MASK) | DNS_LUP_FLAGS_QTYPE_PTR;
+
+	if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
+		cons_printf(portid, "get buffer error: %s.\n", itron_strerror(error));
+		return;
+		}
+
+	if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
+		//cons_printf(portid, "error: %s.\n", itron_strerror(length));
+		goto err_ret;
+		}
+
+	dly_tsk(1 * 1000);
+	cons_printf(portid, "DNS header: flags: ");
+	if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE     |
+	                         DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_QR_RESPONSE)         ? "QR," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_AUTHORITATIVE)       ? "AA," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_TRUN_CATION)         ? "TC," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED)   ? "RD," : "");
+		cons_printf(portid, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
+		cons_printf(portid, " ");
+		}
+	cons_printf(portid, "opcode: ");
+	cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE)      ? "RV"  : "FW");
+	cons_printf(portid, (rslv.dns_hdr.code & DNS_OPCODE_STATUS)       ? ",ST" : "");
+	cons_printf(portid, ", rcode: %s.\n",
+	            (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
+	            	? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
+
+	if ((offset = show_dns_qdsection(portid, msg, length, &rslv)) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+	if ((offset = show_dns_section(portid, msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
+		cons_printf(portid, "msg error: %s.\n", itron_strerror(offset));
+		}
+
+err_ret:
+	if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
+		cons_printf(portid, "release buffer error: %s.\n", itron_strerror(error));
+	return;
+	}
+
+#endif	 /* of #ifdef USE_RESOLVER */
+
+#if defined(DHCP6_CLI_CFG)
+
+/*
+ *  dhcp6c_info -- DHCPv6 ã¯ã©ã¤ã¢ã³ãæ
+å ±ã®è¡¨ç¤º
+ */
+
+static void
+dhcp6c_info (ID portid)
+{
+	T_IN6_ADDR	svaddr;
+	SYSTIM		bind_start;
+	ER		error;
+	uint32_t	expire, renew, rebind, deprefer;
+
+	if ((error = dhcp6c_get_info(&svaddr, &expire, &renew, &rebind, &deprefer, &bind_start)) == E_OK) {
+		cons_printf(portid, "      DHCPv6 server: %lI.\n", &svaddr);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	
+		cons_printf(portid, "      DHCPv6 mode:   stateless.\n");
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		cons_printf(portid, "      DHCPv6 mode:   statefull,\n");
+		cons_printf(portid, "        Renew:       %u:%02u:%02u, Deprefer: %u:%02u:%02u,\n",
+		                       renew / 3600, (   renew / 60) % 60,    renew % 60,
+		                    deprefer / 3600, (deprefer / 60) % 60, deprefer % 60);
+		cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
+		                      rebind / 3600, (  rebind / 60) % 60,   rebind % 60,
+		                      expire / 3600, (  expire / 60) % 60,   expire % 60);
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+		}
+	else if (error == E_OBJ)
+		cons_printf(portid, "      DHCPv6 server: not available.\n");
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#if defined(DHCP4_CLI_CFG)
+
+/*
+ *  dhcp4c_info -- DHCPv4 ã¯ã©ã¤ã¢ã³ãæ
+å ±ã®è¡¨ç¤º
+ */
+
+static void
+dhcp4c_info (ID portid)
+{
+	T_IN4_ADDR	svaddr;
+	SYSTIM		bind_start;
+	ER		error;
+	uint32_t	expire, renew, rebind;
+
+	if ((error = dhcp4c_get_info(&svaddr, &expire, &renew, &rebind, &bind_start)) == E_OK) {
+		cons_printf(portid, "      DHCPv4 server: %hI,\n", &svaddr);
+		cons_printf(portid, "        Renew:       %u:%02u:%02u,\n", 
+		                      renew  / 3600, (renew  / 60) % 60, renew % 60);
+		cons_printf(portid, "        Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
+		                      rebind / 3600, (rebind / 60) % 60, rebind % 60,
+		                      expire / 3600, (expire / 60) % 60, expire % 60);
+		}
+	else if (error == E_OBJ)
+		cons_printf(portid, "      DHCPv4 server: not available.\n");
+	}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG) */
+
+#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
+
+/*
+ *  dhcpc -- DHCP ã¯ã©ã¤ã¢ã³ãæ
+å ±ã®è¡¨ç¤ºã¨å¶å¾¡
+ */
+
+static void
+dhcpc (ID portid, char *line)
+{
+	WAI_NET_CONS_PRINTF();
+
+	switch (*line) {
+
+#if defined(DHCP6_CLI_CFG)
+	case '6':			/* DHCPv6 ã®å¶å¾¡ */
+		switch (*(line + 1)) {
+		case 'r':		/* ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã*/
+			dhcp6c_rel_info();
+			break;
+
+		case 'n':		/* ã¢ãã¬ã¹æ
+å ±ãååå¾ããã*/
+			dhcp6c_renew_info();
+			break;
+
+		default:
+			dhcp6c_info(portid);
+			break;
+			}
+		break;
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#if defined(DHCP4_CLI_CFG)
+	case '4':		/* DHCPv4 ã®å¶å¾¡ */
+		switch (*(line + 1)) {
+		case 'r':		/* ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã*/
+			dhcp4c_rel_info();
+			break;
+
+		case 'n':		/* ã¢ãã¬ã¹æ
+å ±ãååå¾ããã*/
+			dhcp4c_renew_info();
+			break;
+
+		default:
+			dhcp4c_info(portid);
+			break;
+			}
+		break;
+#endif	/* of #if defined(DHCP4_CLI_CFG) */
+
+	default:
+
+#if defined(DHCP6_CLI_CFG)
+		dhcp6c_info(portid);
+#endif
+
+#if defined(DHCP4_CLI_CFG)
+		dhcp4c_info(portid);
+#endif
+		break;
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
+
+#if defined(SUPPORT_INET6)
+
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+/*
+ *  defrtrlist_status -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãç¶æ
+ã®åºå
+ */
+
+static void
+defrtrlist_status (ID portid, char *line)
+{
+	const T_DEF_ROUTER	*dr;
+	SYSTIM			now;
+	int_t			rix, pix, pcnt, ptitle;
+	uint_t			count, mask;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "Default Router List Status\n"
+	            "IX Expire Lifetime flags prefix");
+	for (ptitle = NUM_ND6_PREFIX_ENTRY * 2 - sizeof("prefix"); ptitle -- > 0; )
+		cons_printf(portid, " ");
+	cons_printf(portid, " IP Address\n");
+
+	/* expire ã®åä½ã¯ [ms]ã*/
+	get_tim(&now);
+	dr = nd6_get_drl(&count);
+	for (rix = 0; rix < count; rix ++) {
+		if (dr[rix].state == ND6_DEF_RTR_BUSY) {
+			cons_printf(portid, "%2d", rix);
+			if (dr[rix].lifetime == ND6_INFINITE_LIFETIME)
+				cons_printf(portid, "  INFIN    INFIN");
+			else
+				cons_printf(portid, " %6d %8d",
+				            (uint32_t)(dr[rix].expire - now) <= 0
+				                ? 0 : (dr[rix].expire - now) / SYSTIM_HZ,
+				            dr[rix].lifetime / SYSTIM_HZ);
+			cons_printf(portid, "    %02x", dr[rix].flags);
+			pcnt = NUM_ND6_PREFIX_ENTRY;
+			ptitle = NUM_ND6_PREFIX_ENTRY * 2 - sizeof(" prefix");
+			mask = 1;
+			for (pix = 0; pix < NUM_ND6_PREFIX_ENTRY; pix ++) {
+				if ((dr[rix].plistmap & mask) != 0) {
+					if (pcnt == NUM_ND6_PREFIX_ENTRY)
+						cons_printf(portid, " ");
+					else
+						cons_printf(portid, ",");
+					cons_printf(portid, "%d", pix);
+					pcnt --;
+					ptitle -= 2;
+					}
+				mask <<= 1;
+				}
+			while (pcnt --) {
+				cons_printf(portid, "  ");
+				ptitle -= 2;
+				}
+			while (ptitle -- > 0)
+				cons_printf(portid, " ");
+			cons_printf(portid, " %lI\n",  &dr[rix].addr);
+			}
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+/*
+ *  prefixlist_status -- ãã¬ãã£ãã¯ã¹ã»ãªã¹ãç¶æ
+ã®åºå
+ */
+
+static void
+prefixlist_status (ID portid, char *line)
+{
+	const T_ND6_PREFIX	*pr;
+	SYSTIM			now;
+	int_t			rix, pix, rcnt, rtitle;
+	uint_t			mask;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "Prefix List Status\n"
+	            "IX  Expire Lifetime flags router");
+	for (rtitle = NUM_ND6_DEF_RTR_ENTRY * 2 - sizeof("router"); rtitle -- > 0; )
+		cons_printf(portid, " ");
+	cons_printf(portid, " Len Prefix\n");
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	get_tim(&now);
+	now /= SYSTIM_HZ;
+	pr = nd6_get_prl();
+	for (pix = 0; pix < NUM_ND6_PREFIX_ENTRY; pix ++) {
+		if ((pr[pix].flags & ND6_PREFIX_STATE_BUSY) != 0) {
+			cons_printf(portid, "%2d", pix);
+			if (pr[pix].vltime == ND6_INFINITE_LIFETIME)
+				cons_printf(portid, "  INFIN    INFIN");
+			else
+				cons_printf(portid, " %7d %8d",
+				            (uint32_t)(pr[pix].expire - now) <= 0
+				                ? 0 : (pr[pix].expire - now),
+				             pr[pix].vltime);
+			cons_printf(portid, "    %02x", pr[pix].flags);
+			rcnt = NUM_ND6_DEF_RTR_ENTRY;
+			rtitle = NUM_ND6_DEF_RTR_ENTRY * 2 - sizeof(" router");
+			mask = 1;
+			for (rix = 0; rix < NUM_ND6_DEF_RTR_ENTRY; rix ++) {
+				if ((pr[pix].routermap & mask) != 0) {
+					if (rcnt == NUM_ND6_DEF_RTR_ENTRY)
+						cons_printf(portid, " ");
+					else
+						cons_printf(portid, ",");
+					cons_printf(portid, "%d", rix);
+					rcnt --;
+					rtitle -= 2;
+					}
+				mask <<= 1;
+				}
+			while (rcnt --) {
+				cons_printf(portid, "  ");
+				rtitle -= 2;
+				}
+			while (rtitle -- > 0)
+				cons_printf(portid, " ");
+			cons_printf(portid, "%4d %lI\n",  pr[pix].prefix_len, &pr[pix].prefix);
+			}
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+/*
+ *  routing6_table_status -- çµè·¯è¡¨ï¼IPv6ï¼ã®åºå
+ */
+
+static void
+routing6_table_status (ID portid, char *line)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "\nRouting Table Status (IPv6)\n"
+	            "IX Expire flags Prefix Target                         Gateway\n");
+
+	for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++) {
+		cons_printf(portid, "%2d STATIC     - %6d %30lI %lI\n",
+		            ix,
+		             routing6_tbl[ix].prefix_len,
+		            &routing6_tbl[ix].target,
+		            &routing6_tbl[ix].gateway);
+		            
+		}
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	get_tim(&now);
+	now /= SYSTIM_HZ;
+
+	for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		if (routing6_tbl[ix].flags & IN_RTF_DEFINED)
+			cons_printf(portid, "%2d %6d    %02x %6d %30lI %lI\n",
+			            ix,
+			            (uint32_t)(routing6_tbl[ix].expire - now) <= 0
+			                ? 0 : routing6_tbl[ix].expire - now,
+			             routing6_tbl[ix].flags,
+			             routing6_tbl[ix].prefix_len,
+			            &routing6_tbl[ix].target,
+			            &routing6_tbl[ix].gateway);
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if NUM_IN4_ROUTE_ENTRY > 0
+
+/*
+ *  routing4_table_status -- çµè·¯è¡¨ï¼IPv4ï¼ã®åºå
+ */
+
+static void
+routing4_table_status (ID portid, char *line)
+{
+	int_t	ix;
+
+	if ('0' <= *(line = skip_blanks(line)) && *line <= '9') {
+		T_IN4_ADDR	target, mask, gateway;
+
+		ix = atoi(line);
+		while ('0' <= *line && *line <= '9')
+			line ++;
+		line = get_ipv4addr(&target,  skip_blanks(line));
+		line = get_ipv4addr(&mask,    skip_blanks(line));
+		       get_ipv4addr(&gateway, skip_blanks(line));
+		in4_add_route(ix, target, mask, gateway);
+		}
+
+	WAI_NET_CONS_PRINTF();
+	cons_printf(portid,
+	            "\nRouting Table Status (IPv4)\n"
+	            "IX Target          Mask            Gateway         Expire\n");
+
+	for (ix = 0; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0)
+			;
+		else if ((routing4_tbl[ix].flags & IN_RTF_REDIRECT) != 0)
+			cons_printf(portid, "%2d %15hI %15hI %15hI %4d\n",
+			            ix,
+			            &routing4_tbl[ix].target,
+			            &routing4_tbl[ix].mask,
+			            &routing4_tbl[ix].gateway,
+			            &routing4_tbl[ix].expire);
+		else
+			cons_printf(portid, "%2d %15hI %15hI %hI\n",
+			            ix,
+			            &routing4_tbl[ix].target,
+			            &routing4_tbl[ix].mask,
+			            &routing4_tbl[ix].gateway);
+		            
+		}
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if NUM_IN4_ROUTE_ENTRY > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  routing_status -- çµè·¯æ
+å ±
+ */
+
+static void
+routing_status (ID portid, char *line)
+{
+	switch (*line) {
+
+#if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0
+
+	case 'l':		/* ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãæ
+å ± */
+		defrtrlist_status(portid, line + 1);
+		break;
+
+	case 'p':		/* ãã¬ãã£ãã¯ã¹ã»ãªã¹ãæ
+å ± */
+		prefixlist_status(portid, line + 1);
+		break;
+
+#endif	/* #if defined(SUPPORT_INET6) && NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+	default:
+
+		/* çµè·¯è¡¨æ
+å ± */
+
+#if defined(SUPPORT_INET6) && NUM_IN6_ROUTE_ENTRY > 0
+		routing6_table_status(portid, line);
+#endif
+
+#if defined(SUPPORT_INET4) && NUM_IN4_ROUTE_ENTRY > 0
+		routing4_table_status(portid, line);
+#endif
+
+		break;
+		}
+	}
+
+/*
+ *  dbg_cons_network_status -- ãããã¯ã¼ã¯ã®ç¶æ
+ã®åºå
+ */
+
+void
+dbg_cons_network_status (ID portid, char *line)
+{
+	switch (*line) {
+
+#ifdef SUPPORT_ETHER
+
+	case 'a':		/* IF ã¢ãã¬ã¹æ
+å ± */
+
+#if defined(SUPPORT_INET6)
+		ifa6_status(portid, line + 1);
+#endif
+#if defined(SUPPORT_INET4)
+		ifa4_status(portid, line + 1);
+#endif
+
+		break;
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	case 'b':		/* ãããã¯ã¼ã¯ãããã¡æ
+å ± */
+		nbuf_status(portid, line + 1);
+		break;
+
+#if NET_COUNT_ENABLE
+
+	case 'c':		/* ãããã¯ã¼ã¯çµ±è¨æ
+å ± */
+		net_count(portid, line + 1);
+		break;
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+	case 'r':		/* çµè·¯æ
+å ± */
+		routing_status(portid, line + 1);
+		break;
+
+#ifdef USE_RESOLVER
+
+	case 's':		/* name lookup */
+		if (*(line = skip_blanks(line + 1)) == '\0')
+			dns_info(portid);
+		else
+			name_lookup(portid, line);
+		break;
+
+#endif	 /* of #ifdef USE_RESOLVER */
+
+#ifdef SUPPORT_TCP
+
+	case 't':		/* TCP status */
+		tcp_status(portid, line + 1);
+		break;
+
+#endif	 /* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+	case 'u':		/* UDP status */
+		udp_status(portid, line + 1);
+		break;
+
+#endif	 /* of #ifdef SUPPORT_UDP */
+
+	default:
+		cons_printf(portid, "no such command: '%c%c'.\n", *(line - 1), *line);
+		SIG_NET_CONS_PRINTF();
+		FLUSH_SND_BUFF();
+		break;
+		}
+	}
+
+/*
+ *  dbg_cons_ifconfig -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®æ§ææ
+å ±
+ */
+
+void
+dbg_cons_ifconfig (ID portid, char *line)
+{
+#ifdef SUPPORT_ETHER
+
+	T_IF_SOFTC	*ic;
+
+	WAI_NET_CONS_PRINTF();
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	cons_printf(portid, "ether: %M\n", ic->ifaddr.lladdr);
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+	}
+
+#if defined(NETAPP_IP6_CFG)
+
+/*
+ *  dbg_cons_ifconfig6 -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ï¼IPv6ï¼ã®æ§ææ
+å ±
+ */
+
+void
+dbg_cons_ifconfig6 (ID portid, char *line)
+{
+#ifdef SUPPORT_ETHER
+
+	T_IFNET		*ifp = IF_GET_IFNET();
+	int_t		ix;
+	SYSTIM		now;
+
+	WAI_NET_CONS_PRINTF();
+
+	/* expire ã¨ vltime ã®åä½ã¯ [s]ã*/
+	get_tim(&now);
+	now /= SYSTIM_HZ;
+
+	cons_printf(portid, "IPv6:\nIX   Expire Preffered RTR PFX Flags IP Address\n");
+	for (ix = 0; ix < NUM_IN6_IFADDR_ENTRY; ix ++) {
+		if (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) {
+			cons_printf(portid, " %d", ix);
+			if (ifp->in6_ifaddrs[ix].lifetime.vltime == ND6_INFINITE_LIFETIME)
+				cons_printf(portid, "    INFIN     INFIN");
+			else
+				cons_printf(portid, " %8d %9d",
+				                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.expire - now) <= 0 
+				                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.expire - now,
+				                    (uint32_t)(ifp->in6_ifaddrs[ix].lifetime.preferred - now) <= 0
+				                         ? 0 : ifp->in6_ifaddrs[ix].lifetime.preferred - now);
+			if (ifp->in6_ifaddrs[ix].router_index == IN6_RTR_IX_UNREACH)
+				cons_printf(portid, "   -");
+			else
+				cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].router_index);
+			if (ifp->in6_ifaddrs[ix].prefix_index == ND6_PREFIX_IX_INVALID)
+				cons_printf(portid, "   -");
+			else
+				cons_printf(portid, " %3d", ifp->in6_ifaddrs[ix].prefix_index);
+			cons_printf(portid, "    %02x %lI\n",
+			                     ifp->in6_ifaddrs[ix].flags,
+			                    &ifp->in6_ifaddrs[ix].addr);
+			}
+		}
+
+#ifdef DHCP6_CLI_CFG
+	dhcp6c_info(portid);
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+	}
+
+#endif	/* of #if defined(NETAPP_IP6_CFG) */
+
+#if defined(NETAPP_IP4_CFG)
+
+/*
+ *  dbg_cons_ifconfig4 -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ï¼IPv4ï¼ã®æ§ææ
+å ±
+ */
+
+void
+dbg_cons_ifconfig4 (ID portid, char *line)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN4_ADDR	bc;
+
+#ifdef SUPPORT_ETHER
+
+	if (*(line = skip_blanks(line))) {
+		T_IN4_ADDR	addr, mask;
+
+		get_ipv4addr(&mask, skip_blanks(get_ipv4addr(&addr, line)));
+		in4_add_ifaddr(addr, mask);
+		}
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	WAI_NET_CONS_PRINTF();
+
+	bc = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
+	cons_printf(portid,
+	            "IPv4: %hI, mask: %hI, broadcast: %hI\n",
+	            &ifp->in4_ifaddr.addr,
+	            &ifp->in4_ifaddr.mask,
+	            &bc);
+
+#ifdef DHCP4_CLI_CFG
+	dhcp4c_info(portid);
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#endif	/* of #if defined(NETAPP_IP4_CFG) */
+
+/*
+ *  dbg_cons_show_config -- ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³è¨­å®ã®è¡¨ç¤º
+ */
+
+void
+dbg_cons_show_config (ID portid, char *line)
+{
+#if defined(SUPPORT_ETHER)
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	addr;
+#endif
+#endif	/* of #if defined(SUPPORT_ETHER) */
+
+	cons_printf(portid, "DHCP:\n");
+	cons_printf(portid, "  DHCP6_CLI_CFG: ");
+
+#if defined(DHCP6_CLI_CFG)
+
+	cons_printf(portid, "On\n           Mode: ");
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	cons_printf(portid, "STATELESS\n");
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+	cons_printf(portid, "STATEFULL\n");
+#endif
+
+#else	/* of #if define(DHCP6_CLI_CFG) */
+
+	cons_printf(portid, "Off\n");
+
+#endif	/* of #if define(DHCP6_CLI_CFG) */
+
+	cons_printf(portid, "  DHCP4_CLI_CFG: ");
+
+#if defined(DHCP4_CLI_CFG)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "Resolver:\n");
+	cons_printf(portid, "  USE_RESOLVER: ");
+
+#if defined(USE_RESOLVER)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#if defined(SUPPORT_TCP)
+
+	cons_printf(portid, "TCP:\n");
+
+	cons_printf(portid, "  TCP_CFG_OPT_MSS:      ");
+#if defined(TCP_CFG_OPT_MSS)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_DELAY_ACK:    ");
+#if defined(TCP_CFG_DELAY_ACK)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_ALWAYS_KEEP:  ");
+#if defined(TCP_CFG_ALWAYS_KEEP)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_RWBUF_CSAVE:  ");
+#if defined(TCP_CFG_RWBUF_CSAVE_ONLY)
+	cons_printf(portid, "Only, ");
+#if defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
+	cons_printf(portid, "TCP_CFG_RWBUF_CSAVE_MAX_QUEUES: %2d\n",
+	                     TCP_CFG_RWBUF_CSAVE_MAX_QUEUES);
+#else
+	cons_printf(portid, "TCP_CFG_RWBUF_CSAVE_MAX_QUEUES: Undefined\n");
+#endif
+#elif defined(TCP_CFG_RWBUF_CSAVE)
+	cons_printf(portid, "On,   ");
+#if defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
+	cons_printf(portid, "TCP_CFG_RWBUF_CSAVE_MAX_QUEUES: %2d\n",
+	                     TCP_CFG_RWBUF_CSAVE_MAX_QUEUES);
+#else
+	cons_printf(portid, "TCP_CFG_RWBUF_CSAVE_MAX_QUEUES: Undefined\n");
+#endif
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_SWBUF_CSAVE:  ");
+#if defined(TCP_CFG_SWBUF_CSAVE_ONLY)
+	cons_printf(portid, "Only, TCP_CFG_SWBUF_CSAVE_MAX_SIZE: %4d\n"
+	                    "                        "
+	                    "      TCP_CFG_SWBUF_CSAVE_MIN_SIZE: %4d\n",
+	                    TCP_CFG_SWBUF_CSAVE_MAX_SIZE, 
+                            TCP_CFG_SWBUF_CSAVE_MIN_SIZE);
+#elif defined(TCP_CFG_SWBUF_CSAVE)
+	cons_printf(portid, "On,   TCP_CFG_SWBUF_CSAVE_MAX_SIZE: %4d\n"
+	                    "                        "
+	                    "      TCP_CFG_SWBUF_CSAVE_MIN_SIZE: %4d\n",
+	                    TCP_CFG_SWBUF_CSAVE_MAX_SIZE, 
+                            TCP_CFG_SWBUF_CSAVE_MIN_SIZE);
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_NON_BLOCKING: ");
+#if defined(TCP_CFG_NON_BLOCKING)
+#if defined(USE_TCP_NON_BLOCKING)
+	cons_printf(portid, "Use\n");
+#else
+	cons_printf(portid, "On\n");
+#endif
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_NON_BLOCKING_COMPAT14: ");
+#if defined(TCP_CFG_NON_BLOCKING_COMPAT14)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  TCP_CFG_EXTENTIONS:   ");
+#if defined(TCP_CFG_EXTENTIONS)
+#if defined(USE_TCP_EXTENTIONS)
+	cons_printf(portid, "Use\n");
+#if defined(SUPPORT_INET6)
+	cons_printf(portid, "  NUM_VRID_TCP6_REPS:   %3d\n", NUM_VRID_TCP6_REPS);
+	cons_printf(portid, "  NUM_VRID_TCP6_CEPS:   %3d\n", NUM_VRID_TCP6_CEPS);
+#endif
+#if defined(SUPPORT_INET4)
+	cons_printf(portid, "  NUM_VRID_TCP4_REPS:   %3d\n", NUM_VRID_TCP4_REPS);
+	cons_printf(portid, "  NUM_VRID_TCP4_CEPS:   %3d\n", NUM_VRID_TCP4_CEPS);
+#endif
+#else
+	cons_printf(portid, "On\n");
+#endif
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  USE_COPYSAVE_API:     ");
+#if defined(USE_COPYSAVE_API)
+	cons_printf(portid, "Use\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#if NUM_TCP_TW_CEP_ENTRY > 0
+	cons_printf(portid, "  TCP_TW_CEP:           On, NUM_TCP_TW_CEP_ENTRY:     %d\n", NUM_TCP_TW_CEP_ENTRY);
+#else
+	cons_printf(portid, "  TCP_TW_CEP:           Off\n");
+#endif
+
+#if defined(TCP_CFG_TRACE)
+	cons_printf(portid, "  TCP_CFG_TRACE:        On, TCP_CFG_TRACE_LPORTNO:    %d\n", TCP_CFG_TRACE_LPORTNO);
+#if defined(SUPPORT_INET4)
+	addr = TCP_CFG_TRACE_IPV4_RADDR;
+	cons_printf(portid, "                            TCP_CFG_TRACE_IPV4_RADDR: %hI\n", &addr);
+#endif
+	cons_printf(portid, "                            TCP_CFG_TRACE_RPORTNO:    %d\n", TCP_CFG_TRACE_RPORTNO);
+#else
+	cons_printf(portid, "  TCP_CFG_TRACE:        Off\n");
+#endif
+
+	cons_printf(portid, "  MAX_TCP_SND_SEG:      %4d\n", MAX_TCP_SND_SEG);
+	cons_printf(portid, "  DEF_TCP_SND_SEG:      %4d\n", DEF_TCP_SND_SEG);
+	cons_printf(portid, "  MAX_TCP_RCV_SEG:      %4d\n", MAX_TCP_RCV_SEG);
+	cons_printf(portid, "  DEF_TCP_RCV_SEG:      %4d\n", DEF_TCP_RCV_SEG);
+	cons_printf(portid, "  MAX_TCP_REALLOC_SIZE: %4d\n", MAX_TCP_REALLOC_SIZE);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP)
+
+	cons_printf(portid, "UDP:\n");
+
+	cons_printf(portid, "  UDP_CFG_IN_CHECKSUM:  ");
+#if defined(UDP_CFG_IN_CHECKSUM)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  UDP_CFG_OUT_CHECKSUM: ");
+#if defined(UDP_CFG_OUT_CHECKSUM)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  UDP_CFG_NON_BLOCKING: ");
+#if defined(UDP_CFG_NON_BLOCKING)
+#if defined(USE_UDP_NON_BLOCKING)
+	cons_printf(portid, "Use\n");
+#else
+	cons_printf(portid, "On\n");
+#endif
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  UDP_CFG_NON_BLOCKING_COMPAT14: ");
+#if defined(UDP_CFG_NON_BLOCKING_COMPAT14)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  UDP_CFG_EXTENTIONS:   ");
+#if defined(UDP_CFG_EXTENTIONS)
+#if defined(USE_UDP_EXTENTIONS)
+	cons_printf(portid, "Use\n");
+#else
+	cons_printf(portid, "On\n");
+#endif
+	cons_printf(portid, "  NUM_VRID_UDP4_CEPS:   %3d\n", NUM_VRID_UDP4_CEPS);
+	cons_printf(portid, "  NUM_VRID_UDP6_CEPS:   %3d\n", NUM_VRID_UDP6_CEPS);
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  NUM_DTQ_UDP_RCVQ:     %3d\n", NUM_DTQ_UDP_RCVQ);
+	cons_printf(portid, "  NUM_DTQ_UDP_OUTPUT:   %3d\n", NUM_DTQ_UDP_OUTPUT);
+
+#endif	/* of #if defined(SUPPORT_UDP) */
+
+	cons_printf(portid, "ICMP:\n");
+
+	cons_printf(portid, "  ICMP_CFG_CALLBACK_ECHO_REPLY: ");
+#if defined(ICMP_CFG_CALLBACK_ECHO_REPLY)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  ICMP_REPLY_ERROR:             ");
+#if defined(ICMP_REPLY_ERROR)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
+#if NUM_REDIRECT_ROUTE_ENTRY > 0
+	cons_printf(portid, "  TMO_IN_REDIRECT: %4d[s]\n", TMO_IN_REDIRECT / NET_TIMER_HZ);
+#endif
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+#if defined(SUPPORT_INET6)
+
+	cons_printf(portid, "IPv6:\n");
+
+	cons_printf(portid, "  IP6_IPV4_MAPPED_ADDR:   ");
+#if defined(IP6_CFG_IPV4_MAPPED_ADDR)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  Routing Table:\n");
+	cons_printf(portid, "    NUM_IN6_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN6_STATIC_ROUTE_ENTRY);
+	cons_printf(portid, "    NUM_IN6_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN6_REDIRECT_ROUTE_ENTRY);
+
+	cons_printf(portid, "ND:\n");
+	cons_printf(portid, "  TMO_ND6_RTR_SOL_DELAY:    %5d[ms]\n", TMO_ND6_RTR_SOL_DELAY);
+	cons_printf(portid, "  TMO_ND6_RTR_SOL_INTERVAL: %5d[ms]\n", TMO_ND6_RTR_SOL_INTERVAL);
+	cons_printf(portid, "  NUM_IP6_DAD_COUNT:        %5d\n",     NUM_IP6_DAD_COUNT);
+	cons_printf(portid, "  NUM_ND6_CACHE_ENTRY:      %5d\n",     NUM_ND6_CACHE_ENTRY);
+
+#if defined(SUPPORT_ETHER)
+
+	cons_printf(portid, "  NUM_ND6_DEF_RTR_ENTRY     %5d\n",     NUM_ND6_DEF_RTR_ENTRY);
+	cons_printf(portid, "  NUM_ND6_RTR_SOL_RETRY     %5d\n",     NUM_ND6_RTR_SOL_RETRY);
+
+	cons_printf(portid, "  IP6_CFG_AUTO_LINKLOCAL: ");
+#if defined(IP6_CFG_AUTO_LINKLOCAL)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#endif	/* of #if defined(SUPPORT_ETHER) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	cons_printf(portid, "IPv4:\n");
+
+	cons_printf(portid, "  IP4_CFG_FRAGMENT: ");
+
+#if defined(IP4_CFG_FRAGMENT)
+	cons_printf(portid, "On\n");
+	cons_printf(portid, "    NUM_IP4_FRAG_QUEUE:       %4d\n", NUM_IP4_FRAG_QUEUE);
+	cons_printf(portid, "    IP4_CFG_FRAG_REASSM_SIZE: %4d\n", IP4_CFG_FRAG_REASSM_SIZE);
+#else
+	cons_printf(portid, "Off\n");
+#endif	/* of #if defined(IP4_CFG_FRAGMENT) */
+
+#if defined(SUPPORT_ETHER)
+	addr = IPV4_ADDR_LOCAL;
+	cons_printf(portid, "  IPV4_ADDR_LOCAL:      %hI\n", &addr);
+	addr = IPV4_ADDR_LOCAL_MASK;
+	cons_printf(portid, "  IPV4_ADDR_LOCAL_MASK: %hI\n", &addr);
+	addr = IPV4_ADDR_DEFAULT_GW;
+	cons_printf(portid, "  IPV4_ADDR_DEFAULT_GW: %hI\n", &addr);
+#endif	/* of #if defined(SUPPORT_ETHER) */
+
+	cons_printf(portid, "  Routing Table:\n");
+	cons_printf(portid, "    NUM_IN4_STATIC_ROUTE_ENTRY:   %d\n", NUM_IN4_STATIC_ROUTE_ENTRY);
+	cons_printf(portid, "    NUM_IN4_REDIRECT_ROUTE_ENTRY: %d\n", NUM_IN4_REDIRECT_ROUTE_ENTRY);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER)
+
+	cons_printf(portid, "ARP:\n");
+	cons_printf(portid, "  ARP_CACHE_KEEP: %4d[s]\n", ARP_CACHE_KEEP / NET_TIMER_HZ);
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(SUPPORT_ETHER) */
+
+#if defined(SUPPORT_ETHER)
+
+	cons_printf(portid, "Ethernet:\n");
+
+	cons_printf(portid, "  NUM_DTQ_ETHER_OUTPUT:    %3d\n", NUM_DTQ_ETHER_OUTPUT);
+
+	cons_printf(portid, "  ETHER_CFG_ACCEPT_ALL:    ");
+#if defined(ETHER_CFG_ACCEPT_ALL)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  ETHER_CFG_UNEXP_WARNING: ");
+#if defined(ETHER_CFG_UNEXP_WARNING)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  ETHER_CFG_802_WARNING:   ");
+#if defined(ETHER_CFG_802_WARNING)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  ETHER_CFG_MCAST_WARNING: ");
+#if defined(ETHER_CFG_MCAST_WARNING)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	cons_printf(portid, "  ETHER_COLLECT_ADDR:      ");
+#if defined(ETHER_COLLECT_ADDR)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#endif	/* of #if defined(SUPPORT_ETHER) */
+
+#if defined(SUPPORT_PPP)
+
+	cons_printf(portid, "PPP:\n");
+
+	cons_printf(portid, "  HDLC_PORTNO: %d", HDLC_PORTID);
+
+	cons_printf(portid, "  PPP_IDLE_TIMEOUT: ");
+#if defined(PPP_IDLE_TIMEOUT)
+	cons_printf(portid, "  %4d[s]\n", PPP_IDLE_TIMEOUT / NET_TIMER_HZ);
+#else
+	cons_printf(portid, "  Off\n");
+#endif
+
+	cons_printf(portid, "  PPP_CFG_MODEM: ");
+#if defined(PPP_CFG_MODEM)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+#endif	/* of #if defined(SUPPORT_PPP) */
+
+	cons_printf(portid, "Network Buffer:\n");
+
+#if defined(NUM_MPF_NET_BUF_64)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_64:        %2d\n", NUM_MPF_NET_BUF_64);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_CSEG)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_CSEG:      %2d\n", NUM_MPF_NET_BUF_CSEG);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_128)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_128:       %2d\n", NUM_MPF_NET_BUF_128);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_256)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_256:       %2d\n", NUM_MPF_NET_BUF_256);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_512)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_512:       %2d\n", NUM_MPF_NET_BUF_512);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_IP_MSS)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_IP_MSS:    %2d\n", NUM_MPF_NET_BUF_IP_MSS);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_1024)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_1024:      %2d\n", NUM_MPF_NET_BUF_1024);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_IPV6_MMTU)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_IPV6_MMTU: %2d\n", NUM_MPF_NET_BUF_IPV6_MMTU);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_IF_PDU)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_IF_PDU:    %2d\n", NUM_MPF_NET_BUF_IF_PDU);
+#endif
+
+#if defined(NUM_MPF_NET_BUF_REASSM)
+	cons_printf(portid, "  NUM_MPF_NET_BUF_REASSM:    %2d\n", NUM_MPF_NET_BUF_REASSM);
+#endif
+
+#if defined(NUM_MPF_NET_BUF6_65536)
+	cons_printf(portid, "  NUM_MPF_NET_BUF6_65536:    %2d\n", NUM_MPF_NET_BUF6_65536);
+#endif
+
+	cons_printf(portid, "Network Counter Mask: %08x\n", NET_COUNT_ENABLE);
+
+	cons_printf(portid, "SUPPORT_MIB: ");
+#if defined(SUPPORT_MIB)
+	cons_printf(portid, "On\n");
+#else
+	cons_printf(portid, "Off\n");
+#endif
+
+	SIG_NET_CONS_PRINTF();
+	FLUSH_SND_BUFF();
+	}
+
+#ifdef USE_PING
+
+/*
+ *  ping ã³ãã³ã
+ */
+
+void
+dbg_cons_ping_comd (ID portid, char *line)
+{
+	int_t	tmo, size;
+	char	apip = DEFAULT_API_PROTO;
+
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	addr;
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	addr4;
+#endif
+#else
+	T_IN4_ADDR	addr;
+#endif
+
+#if defined(PING_CFG_I6RLP)
+
+	static const char i6rlp_pmtu_str1[] = " FF1E::1:2 1 1452";
+	static const char i6rlp_pmtu_str2[] = " FF1E::1:2 1 1352";
+	static const char i6rlp_pmtu_str3[] = " fe80::0200:00ff:fe00:0100 1 2";
+
+	if      (apip == '1')
+		strcpy(line, i6rlp_pmtu_str1);
+	else if (apip == '2')
+		strcpy(line, i6rlp_pmtu_str2);
+	else if (apip == '3')
+		strcpy(line, i6rlp_pmtu_str3);
+
+#endif	/* of #ifdef PING_CFG_I6RLP */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if ('0' <= *line && *line <= '9') {
+		if (*line == '6')
+			apip = API_PROTO_IPV6;
+		if (*line == '4')
+			apip = API_PROTO_IPV4;
+		line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+		syslog(LOG_NOTICE, "[PING] unknown host.");
+		return;
+		}
+
+	line = skip_blanks(line);
+	if ('0' <= *line && *line <= '9')
+		line = get_int(&tmo, line);
+	else
+		tmo = 3;
+
+	line = skip_blanks(line);
+	if ('0' <= *line && *line <= '9')
+		line = get_int(&size, line);
+	else
+		size = 64;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6) {
+		syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
+		ping6(&addr, (uint_t)tmo, (uint_t)size);
+		}
+	else {
+		addr4 = ntohl(addr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr4));
+		ping4(&addr4, (uint_t)tmo, (uint_t)size);
+		}
+
+#else /* of #if defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[PING6] size: %d, tmo: %d, host: %s", size, tmo, ipv62str(NULL, &addr));
+	ping6(&addr, (uint_t)tmo, (uint_t)size);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+
+	syslog(LOG_NOTICE, "[PING4] size: %d, tmo: %d, host: %s", size, tmo, ip2str(NULL, &addr));
+	ping4(&addr, (uint_t)tmo, (uint_t)size);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	}
+
+#endif	/* of #ifdef USE_PING */
+
+#ifdef USE_DBG_CONS_PARSER
+
+/*
+ *  ãããã°ã³ãã³ãè§£æ
+ */
+
+void
+dbg_parse (ID portid, char *line)
+{
+	int_t	cepid;
+	ER	error = E_OK;
+
+#if defined(SUPPORT_UDP) && defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	int_t	udp_cep_ipproto;
+#endif
+
+	switch (*line) {
+
+	case 'c':		/* cancel CEP */
+		switch (*(line + 1)) {
+
+		case 'f':	/* show configurations */
+			dbg_cons_show_config(portid, line + 1);
+			break;
+
+#ifdef SUPPORT_TCP
+
+		case 't':	/* cancel TCP */
+			cepid = atoi(line = skip_blanks(line + 2));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+			if ((error = tcp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+				cons_printf(portid, "[TCP CAN CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+			break;
+
+#endif	/* of #ifdef SUPPORT_TCP */
+
+#ifdef SUPPORT_UDP
+
+		case 'u':	/* cancel UDP */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+			udp_cep_ipproto = (*(line + 2) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6);
+			cepid = atoi(line = skip_blanks(line + 3));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+
+#if TNUM_UDP6_CEPID > 0
+
+			if (udp_cep_ipproto == API_PROTO_IPV6) {
+				if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+					cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+#if TNUM_UDP4_CEPID > 0
+
+			if (udp_cep_ipproto == API_PROTO_IPV4) {
+				if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+					cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if TNUM_UDP6_CEPID > 0
+
+			cepid = atoi(line = skip_blanks(line + 2));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+
+			if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+				cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if TNUM_UDP6_CEPID > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if TNUM_UDP4_CEPID > 0
+
+			cepid = atoi(line = skip_blanks(line + 2));
+			while ('0' <= *line && *line <= '9')
+				line ++;
+
+			if ((error = udp_can_cep((ID)cepid, atoi(skip_blanks(line)))) != E_OK && error != E_RLWAI) {
+				cons_printf(portid, "[UDP CAN CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+			break;
+
+#endif	/* of #ifdef SUPPORT_UDP */
+
+			}
+
+		break;
+
+	case 'd':	/* discard client */
+		switch (*(line + 1)) {
+
+#if defined(SUPPORT_PPP)
+
+		case 'c':		/* disconnect */
+			if (lcp_fsm.state != PPP_FSM_STOPPED)
+				lcp_close();
+			break;
+
+#endif	/* of #if defined(SUPPORT_PPP) */
+
+#if defined(SUPPORT_ETHER) && defined(USE_NET_CONS)
+
+		case 'c':		/* disconnect */
+			discon_net_cons();
+			break;
+
+#endif	/* of #if defined(SUPPORT_ETHER) && defined(USE_NET_CONS) */
+
+#if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG)
+
+		case 'h':		/* DHCP client */
+			dhcpc(portid, line + 2);
+			break;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) || defined(DHCP4_CLI_CFG) */
+
+#ifdef USE_TCP_DISCARD_CLI
+
+		case 't':	/* TCP discard client */
+			line += 2;
+			switch (*line) {
+
+			case 's':	/* cancel TCP discard client */
+				tcp_discard_cli_valid = false;
+				break;
+
+			default:
+				if ((error = psnd_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
+					cons_printf(portid, "[TCP DISCARD CLI] error: %s.\n",
+					       itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+
+				}
+			break;
+
+#endif	/* of #ifdef USE_TCP_DISCARD_CLI */
+
+#ifdef USE_UDP_DISCARD_CLI
+
+		case 'u':	/* UDP discard client */
+			line += 2;
+			switch (*line) {
+
+			case 's':	/* cancel UDP discard client */
+				udp_discard_cli_valid = false;
+				break;
+
+			default:
+				if ((error = psnd_dtq(DTQ_UDP_DISCARD_CLI, (intptr_t)line)) != E_OK) {
+					cons_printf(portid, "[UDP DISCARD CLI] error: %s.\n",
+					       itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+
+				}
+			break;
+
+#endif	/* of #ifdef USE_UDP_DISCARD_CLI */
+
+			}
+
+		break;
+
+#if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI)
+
+	case 'e':	/* echo client */
+		switch (*(line + 1)) {
+
+#ifdef USE_TCP_ECHO_CLI
+
+		case 't':	/* TCP echo client */
+			line += 2;
+			switch (*line) {
+
+			case 's':	/* cancel TCP echo */
+				tcp_echo_cli_valid = false;
+				break;
+
+			default:
+				if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t)line)) != E_OK) {
+					cons_printf(portid, "[TCP ECHO CLI] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+
+				}
+			break;
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
+
+#if defined(USE_UDP_ECHO_CLI)
+
+		case 'u':	/* UDP echo client */
+			switch (*(line + 2)) {
+
+			case 's':	/* cancel UDP echo */
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+				if (*(line + 3) == '4')
+					udp4_echo_cli_valid = false;
+				else
+					udp6_echo_cli_valid = false;
+
+#else	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+				udp6_echo_cli_valid = false;
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+#if defined(USE_UDP4_CLI_TSK)
+
+				udp4_echo_cli_valid = false;
+
+#endif	/* of #if defined(USE_UDP4_CLI_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+
+				break;
+
+			default:
+
+				line += 2;
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+				if (*line == '4') {
+					line ++;
+					error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
+					}
+				else {
+					if (*line && *line != ' ')
+						line ++;
+					error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
+					}
+
+#else	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+				if (*line && *line != ' ')
+					line ++;
+				error = psnd_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t)line);
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+				if (*line && *line != ' ')
+					line ++;
+				error = psnd_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t)line);
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
+
+				if (error != E_OK) {
+					cons_printf(portid, "[UDP ECHO CLI] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+
+				break;
+
+				}
+			break;
+
+#endif	/* of #if defined(USE_UDP_ECHO_CLI) */
+
+			}
+
+		break;
+
+#endif	/* of #if defined(USE_TCP_ECHO_CLI) || defined(USE_UDP_ECHO_CLI) */
+
+	case 'i':
+
+		if (*(line + 1) == 'f') {
+
+			dbg_cons_ifconfig (portid, line + 2);
+
+#if defined(NETAPP_IP6_CFG)
+			dbg_cons_ifconfig6(portid, line + 2);
+#endif
+
+#if defined(NETAPP_IP4_CFG)
+			dbg_cons_ifconfig4(portid, line + 2);
+#endif
+
+			}
+
+#ifdef SUPPORT_PPP
+
+#ifdef PPP_CFG_MODEM
+
+		else if (lcp_fsm.state == PPP_FSM_STOPPED)
+			dial();		/* initiate */
+
+#else	/* of #ifdef PPP_CFG_MODEM */
+
+		else if (lcp_fsm.state == PPP_FSM_STOPPED)
+			lcp_open(PPP_OPEN_ACTIVE);
+
+#endif	/* of #ifdef PPP_CFG_MODEM */
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+		break;
+
+	case 'n':		/* network status */
+		dbg_cons_network_status(portid, line + 1);
+		break;
+
+	case 'p':		/* ping or task status */
+
+		if (*(line + 1) == 's')
+			dbg_cons_task_status(portid, skip_blanks(line + 2));
+
+#ifdef USE_PING
+
+		else
+			dbg_cons_ping_comd(portid, line + 1);
+
+#endif	/* of #ifdef USE_PING */
+
+		break;
+
+	case 'r':		/* release wait task */
+		if ((error = rel_wai(atoi(skip_blanks(line + 1)))) != E_OK) {
+			cons_printf(portid, "[REL WAI TSK] error: %s.\n", itron_strerror(error));
+			SIG_NET_CONS_PRINTF();
+			FLUSH_SND_BUFF();
+			}
+		break;
+
+	case 't':		/* terminate (delete) REP/CEP */
+		switch (*(line + 1)) {
+
+#ifdef USE_TCP_EXTENTIONS
+
+		case 't':		/* TCP REP */
+	
+			error = tcp_del_rep(atoi(skip_blanks(line + 2)));
+			if (error != E_OK) {
+				cons_printf(portid, "[TCP DEL REP] ID: %d, error: %s.\n", 
+				                    atoi(skip_blanks(line + 2)),
+				                    itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+			break;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+		case 'u':		/* UDP CEP */
+
+#if defined(USE_UDP6_ECHO_SRV_TSK)
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+			if (*(line + 2) == '4') {
+				if ((error = udp_del_cep(atoi(skip_blanks(line + 3)))) != E_OK) {
+					cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+			else {
+				if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+					cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				}
+
+#else	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+			if ((error = udp6_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+				cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+			if ((error = udp_del_cep(atoi(skip_blanks(line + 2)))) != E_OK) {
+				cons_printf(portid, "[UDP DEL CEP] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+			break;
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+			}
+		break;
+
+#if defined(USE_TCP_EXTENTIONS) || defined(USE_UDP_EXTENTIONS)
+
+	case 'w':		/* wakeup server */
+				/* wake up task */
+		switch (*(line + 1)) {
+
+#ifdef USE_TCP_EXTENTIONS
+
+		case 't':		/* tcp server */
+			switch (*(line + 2)) {
+
+#ifdef USE_TCP_DISCARD_SRV
+			case 'd':		/* tcp discard server */
+				if ((error = wup_tsk(TCP_DISCARD_SRV_TASK)) != E_OK) {
+					//cons_printf(portid, "[WUP TCP DISCARD SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+#endif	/* of #ifdef USE_TCP_DISCARD_SRV */
+
+#if defined(USE_TCP_ECHO_SRV1)
+			case 'e':		/* tcp echo server */
+				if ((error = wakeup_tcp_echo_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
+					//cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
+
+#if defined(USE_TCP_ECHO_SRV2)
+			case 'e':		/* tcp echo server */
+				if ((error = wup_tsk(TCP_ECHO_SRV_TASK2)) != E_OK) {
+					//cons_printf(portid, "[WUP TCP ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+#endif	/* of #if defined(USE_TCP_ECHO_SRV2) */
+
+#ifdef USE_WWW_SRV
+			case 'w':		/* WWW server */
+				if ((error = wakeup_www_srv((*(line + 3) == '4' ? API_PROTO_IPV4 : API_PROTO_IPV6))) != E_OK) {
+					//cons_printf(portid, "[WUP WWW SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+				break;
+#endif	/* of #ifdef USE_TCP_DISCARD_SRV */
+
+				}
+			break;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+		case 'u':		/* udp server */
+			switch (*(line + 2)) {
+
+#if !defined(USE_UDP_CALL_BACK)
+
+			case 'e':		/* udp echo server */
+
+#if defined(USE_UDP6_ECHO_SRV_TSK)
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+				if (*(line + 3) == '4') {
+					if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
+						cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
+						SIG_NET_CONS_PRINTF();
+						FLUSH_SND_BUFF();
+						}
+					}
+				else {
+					if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
+						cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
+						SIG_NET_CONS_PRINTF();
+						FLUSH_SND_BUFF();
+						}
+					}
+
+#else	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+				if ((error = wup_tsk(UDP6_ECHO_SRV_TASK)) != E_OK) {
+					cons_printf(portid, "[WUP UDP6 ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#else	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+#if defined(USE_UDP4_ECHO_SRV_TSK)
+
+				if ((error = wup_tsk(UDP4_ECHO_SRV_TASK)) != E_OK) {
+					cons_printf(portid, "[WUP UDP4 ECHO SRV] error: %s.\n", itron_strerror(error));
+					SIG_NET_CONS_PRINTF();
+					FLUSH_SND_BUFF();
+					}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_SRV_TSK) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_SRV_TSK) */
+
+				break;
+
+#endif	/* of #if !defined(USE_UDP_CALL_BACK) */
+
+				}
+			break;
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+		default:
+			if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
+				cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
+				SIG_NET_CONS_PRINTF();
+				FLUSH_SND_BUFF();
+				}
+			break;
+
+			}
+		break;
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) || defined(USE_UDP_EXTENTIONS) */
+
+	case 'w':		/* wake up task */
+		if ((error = wup_tsk(atoi(skip_blanks(line + 1)))) != E_OK) {
+			cons_printf(portid, "[WUP TSK] error: %s.\n", itron_strerror(error));
+			SIG_NET_CONS_PRINTF();
+			FLUSH_SND_BUFF();
+			}
+		break;
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) || defined(USE_UDP_EXTENTIONS) */
+
+	default:
+
+		if (*line) {
+
+#ifdef USE_DBG_CONS_EXTRA_PARSE
+
+			//cons_printf(portid, "extra command: '%c'.\n", *line);
+			dbg_cons_extra_parse(portid, line);
+
+#else	/* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
+
+			//cons_printf(portid, "command: '%c'.\n", *line);
+			cons_printf(portid, "no such command: '%c'.\n", *line);
+			SIG_NET_CONS_PRINTF();
+			FLUSH_SND_BUFF();
+
+#endif	/* of #ifdef USE_DBG_CONS_EXTRA_PARSE */
+
+			}
+		break;
+		}
+	}
+
+#endif	/* of #ifdef USE_DBG_CONS_PARSER */
+
+/*
+ *  ãããã°ã³ã³ã½ã¼ã«ã¿ã¹ã¯
+ */
+
+void
+dbg_con_task (intptr_t exinf)
+{
+	static char line[DBG_LINE_SIZE + 1];
+
+	ID	tskid;
+
+#ifdef USE_LCD
+#ifdef SUPPORT_ETHER
+
+#if 0
+#if defined(SUPPORT_INET6)
+
+	uint32_t	lllen;
+	const uint8_t	*lladdr;
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+#endif
+
+	lcd_initialize(0);
+
+#if 0
+#if defined(SUPPORT_INET6)
+
+	dly_tsk(1 * 1000);
+	lladdr = IF_ETHER_NIC_GET_SOFTC()->ifaddr.lladdr;
+	for (lllen = ETHER_ADDR_LEN; lllen --; )
+		lcd_printf(LCD_PORTID, "%02x", *lladdr ++);
+	lcd_putc(LCD_PORTID, '\n');
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+	if ((TINET_PRVER & UINT_C(0x0f)) > 0)
+		lcd_printf(LCD_PORTID, "TINET-%d.%d.%d\n",
+		       (TINET_PRVER   >> 12) & UINT_C(0x0f),
+		       (TINET_PRVER   >>  4) & UINT_C(0x0f),
+		        TINET_PRVER          & UINT_C(0x0f));
+	else
+		lcd_printf(LCD_PORTID, "TINET-%d.%d\n",
+		       (TINET_PRVER   >> 12) & UINT_C(0x0f),
+		       (TINET_PRVER   >>  4) & UINT_C(0x0f));
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+#endif
+
+#if 0
+#if defined(SUPPORT_INET4)
+
+	dly_tsk(1 * 1000);
+	lcd_puts(LCD_PORTID, ip2str(NULL, in4_get_ifaddr(0)));
+	lcd_putc(LCD_PORTID, '\n');
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+#endif
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+#endif	/* of #ifdef USE_LCD */
+
+	get_tid(&tskid);
+	cons_printf(CONSOLE_PORTID, "[CONSOLE:%d] started.\n", tskid);
+	serial_ctl_por(CONSOLE_PORTID,
+	               IOCTL_ECHO  | IOCTL_CRLF  |
+	               IOCTL_FCSND | IOCTL_FCANY | IOCTL_FCRCV);
+	netapp_srand (tskid);
+	while (true) {
+		cons_getline(CONSOLE_PORTID, line, DBG_LINE_SIZE);
+		dbg_parse(CONSOLE_PORTID, line);
+		}
+	}
+
+#endif	/* of #ifdef USE_DBG_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.cfg	(revision 317)
@@ -0,0 +1,63 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã°ã³ã³ã½ã¼ã«ã®ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_DBG_CONS
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(DBG_CON_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	dbg_con_task,
+	DBG_CON_PRIORITY,
+	DBG_CON_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_DBG_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dbg_cons.h	(revision 317)
@@ -0,0 +1,78 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _DBG_CONS_
+#define _DBG_CONS_
+
+/* 
+ *  ã³ã³ã½ã¼ã«
+ */
+
+#define	DBG_CON_STACK_SIZE	1024		/* ã³ã³ã½ã¼ã«ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+#define DBG_CON_PRIORITY	5		/* ã³ã³ã½ã¼ã«ã¿ã¹ã¯ã®åªå
+åº¦ */
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	dbg_con_task (intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern void act_tasks (void);
+extern void dbg_parse (ID portid, char *line);
+extern void dbg_cons_extra_parse (ID portid, char *line);
+extern void dbg_cons_task_status (ID portid, char *line);
+extern void dbg_cons_network_status (ID portid, char *line);
+extern void dbg_cons_ifconfig (ID portid, char *line);
+extern void dbg_cons_ifconfig6 (ID portid, char *line);
+extern void dbg_cons_ifconfig4 (ID portid, char *line);
+extern void dbg_cons_show_config (ID portid, char *line);
+extern void dbg_cons_ping_comd (ID portid, char *line);
+
+#endif	/* of #ifndef _DBG_CONS_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4.h	(revision 317)
@@ -0,0 +1,387 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_H
+#define DHCP4_H
+
+/*
+ *  DHCP ã«é¢ããå®ç¾©
+ *
+ *    RFC2131
+ */
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸ã®å®æ°ã®å®ç¾©
+ */
+
+#define DHCP4_CHADDR_LEN	16
+#define DHCP4_SNAME_LEN		64
+#define DHCP4_FILE_LEN		128
+#define DHCP4_DFLT_OPT_LEN	312
+#define DHCP4_UDP_MSG_LENGTH	(sizeof(uint32_t)*7+DHCP4_CHADDR_LEN	\
+				 +DHCP4_SNAME_LEN+DHCP4_FILE_LEN+DHCP4_DFLT_OPT_LEN)
+#define DHCP4_SNAME_OFFSET	(sizeof(uint32_t)*7+DHCP4_CHADDR_LEN)
+#define DHCP4_FILE_OFFSET	(DHCP4_SNAME_OFFSET+DHCP4_SNAME_LEN)
+#define DHCP4_OPTION_OFFSET	(DHCP4_FILE_OFFSET+DHCP4_FILE_LEN)
+#define DHCP4_TIME_INFINITY	UINT_C(0xffffffff)
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸
+ */
+
+typedef struct dhcp4_msg {
+	uint8_t		op;			/* packet type			*/
+	uint8_t		htype;			/* hardware address type	*/
+	uint8_t		hlen;			/* hardware address length	*/
+	uint8_t		hops;			/* gateway hops			*/
+	uint32_t	xid;			/* transaction ID		*/
+	uint16_t	secs;			/* seconds since boot began	*/
+	uint16_t	flags;
+	uint32_t	ciaddr;			/* client IP address		*/
+	uint32_t	yiaddr;			/* your   IP address		*/
+	uint32_t	siaddr;			/* server IP address		*/
+	uint32_t	giaddr;			/* relay agent IP address	*/
+	uint8_t		chaddr [DHCP4_CHADDR_LEN];	/* client hardware address	*/
+	uint8_t		sname  [DHCP4_SNAME_LEN];	/* server host name		*/
+	uint8_t		file   [DHCP4_FILE_LEN];		/* boot file name		*/
+	uint8_t		options[DHCP4_DFLT_OPT_LEN];	/* optional parameters field	*/
+	} T_DHCP4_MSG;
+
+/* packet type ã®å®ç¾© */
+
+#define DHCP4_REQUEST		UINT_C(1)
+#define DHCP4_REPLY		UINT_C(2)
+
+/* hardware address type ã®å®ç¾© */
+
+#define DHCP4_HWA_TYPE_ETHER	UINT_C(1)
+#define DHCP4_HWA_TYPE_IEEE802	UINT_C(6)
+
+/*
+ *  DHCP ãªãã·ã§ã³
+ *
+ *    RFC1533
+ */
+
+/*
+ *  ãªãã·ã§ã³ã®ç©´åã
+ */
+#define DHCP4_OPT_PAD		UINT_C(0)
+
+/*
+ *  ãµãããããã¹ã¯
+ *
+ *     code   len   subnet mask
+ *   +------+-----+-----+-----+-----+-----+
+ *   |   1  |  4  |  m1 |  m2 |  m3 |  m4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_SUBNET_MASK	UINT_C(1)
+
+/*
+ *  ã«ã¼ã¿
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |   3  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_ROUTER		UINT_C(3)
+
+/*
+ *  DNS ãµã¼ã
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |   6  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_DNS_SERVER	UINT_C(6)
+
+/*
+ *  ãã¹ãå
+ *
+ *     code   len   host name
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  12  |  n  |  h1 |  h2 |  h3 |  h4 | ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_HOST_NAME	UINT_C(12)
+
+/*
+ *  ãã¡ã¤ã³å
+ *
+ *     code   len   domain name
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  15  |  n  |  d1 |  d2 |  d3 |  d4 | ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_DOMAIN_NAME	UINT_C(15)
+
+/*
+ *  ã«ã¼ã¿æ¢ç´¢
+ *
+ *     code   len  value
+ *   +------+-----+-----+
+ *   |  31  |  1  | 0/1 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_RTR_DISOVERY	UINT_C(31)
+
+/*
+ *  éççµè·¯
+ *
+ *     code   len   destination #1          router #1
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |  33  |  n  |  d1 |  d2 |  d3 |  d4 |  r1 |  r2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_STATIC_ROUTE	UINT_C(33)
+
+/*
+ *  ãã³ãã¼åºææ
+å ±
+ *
+ *     code   len   vendor-specific informations
+ *   +------+-----+-----+-----+-----+---
+ *   |  43  |  n  |  i1 |  i2 |  i3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_VENDOR_INFO	UINT_C(43)
+
+/*
+ *  NetBIOS over TCP/IP ãã¼ã ãµã¼ã
+ *
+ *     code   len   addres #1               address #2
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ *   |  44  |  n  |  a1 |  a2 |  a3 |  a4 |  a1 |  a2 | ...
+ *   +------+-----+-----+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_NETBIOS_NS	UINT_C(44)
+
+/*
+ *  NetBIOS over TCP/IP ãã¼ãã¿ã¤ã
+ *
+ *     code   len   type
+ *   +------+-----+-----+
+ *   |  46  |  1  | type|
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_NETBIOS_NODE	UINT_C(46)
+
+/*
+ *  NetBIOS over TCP/IP ã¹ã³ã¼ã
+ *
+ *     code   len   NetBIOS scope
+ *   +------+-----+-----+-----+-----+-----+---
+ *   |  44  |  n  |  s1 |  s2 |  s3 |  s4 |  ...
+ *   +------+-----+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_NETBIOS_SCOPE	UINT_C(47)
+
+/*
+ *  ç¹å®ã® IPv4 ã¢ãã¬ã¹è¦æ±
+ *
+ *     code   len   IPv4 address
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  50  |  4  |  a1 |  a2 |  a3 |  a4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_REQ_IPV4	UINT_C(50)
+
+/*
+ *  ãªã¼ã¹æé
+ *
+ *     code   len   lease time
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  51  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_LEASE_TIME	UINT_C(51)
+
+/*
+ *  ãªãã·ã§ã³ãªã¼ãã¼ã­ã¼ã
+ *
+ *     code   len  value
+ *   +------+-----+-----+
+ *   |  52  |  1  | 1-3 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_OPT_OVERLOAD	UINT_C(52)
+
+/* value ã®å®ç¾© */
+
+#define DHCP4_OPTOL_FILE	UINT_C(0x01)
+#define DHCP4_OPTOL_SNAME	UINT_C(0x02)
+#define DHCP4_OPTOL_BOTH	UINT_C(0x03)
+
+/*
+ *  DHCP ã¡ãã»ã¼ã¸ã¿ã¤ã
+ *
+ *     code   len   type
+ *   +------+-----+-----+
+ *   |  53  |  1  | 1-7 |
+ *   +------+-----+-----+
+ */
+#define DHCP4_OPT_MSG_TYPE	UINT_C(53)
+
+/* type ã®å®ç¾© */
+
+#define DHCP4_MTYPE_BOOTP	UINT_C(0)
+#define DHCP4_MTYPE_DISCOVER	UINT_C(1)
+#define DHCP4_MTYPE_OFFER	UINT_C(2)
+#define DHCP4_MTYPE_REQUEST	UINT_C(3)
+#define DHCP4_MTYPE_DECLINE	UINT_C(4)
+#define DHCP4_MTYPE_ACK		UINT_C(5)
+#define DHCP4_MTYPE_NAK		UINT_C(6)
+#define DHCP4_MTYPE_RELEASE	UINT_C(7)
+#define DHCP4_MTYPE_INFOMATION	UINT_C(8)
+
+/*
+ *  ãµã¼ã ID
+ *
+ *     code   len   IPv4 address
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  54  |  4  |  a1 |  a2 |  a3 |  a4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_SERVER_ID	UINT_C(54)
+
+/*
+ *  è¦æ±ãã©ã¡ã¼ã¿ãªã¹ã
+ *
+ *     code   len   option code
+ *   +------+-----+-----+-----+-----+---
+ *   |  55  |  n  |  c1 |  c2 |  c3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_REQ_PARAM	UINT_C(55)
+
+/*
+ *  Renewal (T1) æé
+ *
+ *     code   len   T1 interval
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  58  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_RENEWAL_T1	UINT_C(58)
+
+/*
+ *  Rebinding (T2) æé
+ *
+ *     code   len   T2 interval
+ *   +------+-----+-----+-----+-----+-----+
+ *   |  59  |  4  |  t1 |  t2 |  t3 |  t4 |
+ *   +------+-----+-----+-----+-----+-----+
+ */
+#define DHCP4_OPT_REBINDING_T2	UINT_C(59)
+
+/*
+ *  ãã³ãã¼ã¯ã©ã¹ IDï¼RFC2132ï¼
+ *
+ *     code   len   vendor class ID
+ *   +------+-----+-----+-----+-----+---
+ *   |  60  |  n  |  i1 |  i2 |  i3 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ */
+#define DHCP4_OPT_VCLASS_ID	UINT_C(60)
+
+/*
+ *  ã¯ã©ã¤ã¢ã³ã ID
+ *
+ *     code   len   type  client ID
+ *   +------+-----+-----+-----+-----+---
+ *   |  61  |  n  | type|  i1 |  i2 | ...  
+ *   +------+-----+-----+-----+-----+---
+ *
+ *   type       : ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹ã¿ã¤ã
+ *   i1, i2, ...: éå¸¸ MAC ã¢ãã¬ã¹
+ */
+#define DHCP4_OPT_CLIENT_ID	UINT_C(61)
+
+/*
+ *  ã¯ã©ã¹ãªãéççµè·¯ï¼RFC3442ï¼
+ *
+ *     code   len   destination #1     router #1
+ *   +------+-----+-----+------+-----+-----+-----+-----+---
+ *   |  121 |  n  |  d1 |  ... |  dN |  r1 |  r2 |  r3 | ...
+ *   +------+-----+-----+------+-----+-----+-----+-----+---
+ */
+#define DHCP4_OPT_CLASSLESS_RTE	UINT_C(121)
+
+/*
+ *  ãªãã·ã§ã³ã®çµäº
+ */
+#define DHCP4_OPT_END		UINT_C(255)
+
+/*
+ *  magic çªå·ï¼RFC1048ï¼
+ */
+
+#define DHCP4_RFC1048_MAGIC	{ UINT_C(99), UINT_C(130), UINT_C(83), UINT_C(99), }
+#define DHCP4_MAGIC_LEN		4
+
+/*
+ *  UDP ãã¼ãçªå·
+ */
+
+#ifndef DHCP4_SRV_CFG_PORTNO
+#define DHCP4_SRV_CFG_PORTNO	67	/* server	*/
+#endif
+
+#ifndef DHCP4_CLI_CFG_PORTNO
+#define DHCP4_CLI_CFG_PORTNO	68	/* client	*/
+#endif
+
+#endif	/* of #ifndef DHCP4_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.c	(revision 317)
@@ -0,0 +1,2128 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    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 Internet Software Consortium 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 INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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 software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/if_ether.h>
+
+#include <net/if_var.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/dhcp4_cli.h>
+#include <netapp/dhcp4_cli_var.h>
+#include <netapp/resolver.h>
+#include "lcd.h"
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/*
+ *  å¤æ°
+ */
+
+static T_DHCP4_CLI_CONTEXT	context;			/* ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ã	*/
+static uint8_t	magicno[DHCP4_MAGIC_LEN] = DHCP4_RFC1048_MAGIC;	/* magic çªå·ï¼RFC1048ï¼*/
+
+/* å¿
+é ãªãã·ã§ã³ãªã¹ã */
+#ifdef DHCP4_CLI_CFG_REQUIRED_OLIST
+static uint8_t	required_plist[] = DHCP4_CLI_CFG_REQUIRED_OLIST;
+#endif
+
+/* è¦æ±ãªãã·ã§ã³ãªã¹ã */
+#ifdef DHCP4_CLI_CFG_REQUEST_OLIST
+static uint8_t	request_plist[] = DHCP4_CLI_CFG_REQUEST_OLIST;
+#endif
+
+/*
+ *  dhcp4_cksum -- ãã§ãã¯ãµã ã®è¨ç®é¢æ°
+ */
+
+static uint32_t
+dhcp4_cksum (void *data, uint_t len /*ãªã¯ãããåä½*/)
+{
+	uint32_t carry, sum = 0;
+
+	for ( ; len > 0; len -= 2) {
+		sum += (*(uint8_t*)data << 8) + *((uint8_t*)data + 1);
+		data = (uint8_t*)data + 2;
+		}
+
+	while (sum >= 0x00010000) {
+		carry = sum >> 16;
+		sum   = (sum & 0xffff) + carry;
+		}
+
+	return sum;
+	}
+
+/*
+ *  create_xid -- ãã©ã³ã¶ã¯ã·ã§ã³ ID ãçæããã
+ */
+
+static uint32_t
+create_xid (void)
+{
+	T_IF_SOFTC	*ic;
+	SYSTIM		time;
+
+	ic = IF_ETHER_NIC_GET_SOFTC();
+	get_tim(&time);
+	return (dhcp4_cksum((void*)&ic->ifaddr.lladdr, ETHER_ADDR_LEN) << 16)
+	      + dhcp4_cksum((void*)&time, sizeof(time));
+	}
+
+/*
+ *  find_option_sub -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° size ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ */
+
+static uint8_t *
+find_option_sub (T_DHCP4_CLI_MSG *msg, uint_t off, uint_t len, 
+                                      uint_t tag, uint_t size, bool_t overload)
+{
+	uint8_t	*opt, *tmp;
+
+	opt = (uint8_t*)&msg->msg + off;
+	while (opt < (uint8_t*)&msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE) {
+				tmp = find_option_sub(msg, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, tag, len, false);
+				if (tmp != NULL)
+					return tmp;
+				}
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME) {
+				tmp = find_option_sub(msg, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, tag, len, false);
+				if (tmp != NULL)
+					return tmp;
+				}
+			opt += *(opt + 1) + 2;
+			}
+		else if (*opt == tag && (size == 0 || *(opt + 1) == size))
+			return opt;
+		else
+			opt += *(opt + 1) + 2;
+		}
+	return NULL;
+	}
+
+/*
+ *  find_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° size ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ */
+
+static uint8_t *
+find_option (T_DHCP4_CLI_MSG *msg, uint_t tag, uint_t size)
+{
+	return find_option_sub(msg, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	                       msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN),
+	                       tag, size, true);
+	}
+
+/*
+ *  is_equal_sid -- ã¡ãã»ã¼ã¸å
+ã® SERVER ID ãæ¯è¼ããã
+ */
+
+static bool_t
+is_equal_sid (T_DHCP4_CLI_MSG *msg1, T_DHCP4_CLI_MSG *msg2)
+{
+	uint8_t	*opt1, *opt2;
+
+	if ((opt1 = find_option(msg1, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return false;
+	if ((opt2 = find_option(msg2, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return false;
+
+	return msg2host32(opt1) == msg2host32(opt2);
+	}
+
+/*
+ *  timer_value -- ã¡ãã»ã¼ã¸ããæéæ
+å ±ãåãåºãã
+ */
+
+static uint32_t
+timer_value (T_DHCP4_CLI_MSG *msg, uint_t tag, uint32_t def_value)
+{
+	uint8_t 	*opt;
+	uint32_t	seconds;
+
+	if ((opt = find_option(msg, tag, sizeof(uint32_t))) == NULL)
+		return def_value;
+	else {
+
+		/* ãµã¼ãããã®ãªã¼ã¹æéã¯[s]ã*/
+		seconds = msg2host32(opt + 2);
+
+		/* ã³ã³ãã­ã¹ãå
+ã®ãªã¼ã¹æéã¯ SYSTIM_HZã*/
+		if (seconds == DHCP4_TIME_INFINITY)
+			return DHCP4_TIME_INFINITY;
+		else if (seconds > SYSTIM2SEC(DHCP4_TIME_INFINITY))
+			return DHCP4_TIME_INFINITY;
+		else
+			return SEC2SYSTIM(seconds);
+		}
+	}
+
+/*
+ *  rel_addr -- IPv4 ã¢ãã¬ã¹ããµãããããã¹ã¯ãéççµè·¯è¡¨ãè§£æ¾ããã
+ */
+
+static void
+rel_addr (void)
+{
+	ER	error;
+	uint_t	count = 0;
+
+	if ((error = in4_add_ifaddr(IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, IPv4 addr: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(0, IPV4_ADDRANY, IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(1, IPV4_ADDRANY, IPV4_ADDRANY, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if ((error = in4_add_route(2, 0xffffffff, 0xffffffff, IPV4_ADDRANY)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, release routing table: %s", itron_strerror(error));
+		count ++;
+		}
+
+	if (count == 0) {
+		syslog(LOG_NOTICE, "[DHCP4C] release IPv4 addr.");
+
+#if 0
+#ifdef USE_LCD
+		dly_tsk(1 * 1000);
+		lcd_puts(LCD_PORTID, "0.0.0.0\n");
+#endif	/* of #ifdef USE_LCD */
+#endif
+
+		}
+	}
+
+/*
+ *  rel_options -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã
+ */
+
+static void
+rel_options (T_DHCP4_CLI_CONTEXT *ct, uint_t off, uint_t len, bool_t overload)
+{
+#if defined(USE_RESOLVER)
+	T_IN4_ADDR	addr;
+#endif
+
+	uint8_t	*opt;
+
+	opt = (uint8_t*)&ct->act_msg->msg + off;
+	while (opt < (uint8_t*)&ct->act_msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE)
+				rel_options(ct, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, false);
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME)
+				rel_options(ct, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, false);
+			opt += *(opt + 1) + 2;
+			}
+		else {
+
+			switch (*opt) {
+
+#if defined(USE_RESOLVER)
+
+			case DHCP4_OPT_DNS_SERVER:
+				addr = IPV4_ADDRANY;
+				dns_in4_set_addr(&addr);
+				break;
+
+			case DHCP4_OPT_HOST_NAME:
+				break;
+
+			case DHCP4_OPT_DOMAIN_NAME:
+				dns_in4_set_dname("", 0);
+				break;
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_DNS_SERVER:
+			case DHCP4_OPT_HOST_NAME:
+			case DHCP4_OPT_DOMAIN_NAME:
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_SUBNET_MASK:
+			case DHCP4_OPT_ROUTER:
+			case DHCP4_OPT_LEASE_TIME:
+			case DHCP4_OPT_RENEWAL_T1:
+			case DHCP4_OPT_REBINDING_T2:
+				break;
+
+			default:
+				break;
+				}
+
+			opt += *(opt + 1) + 2;
+			}
+		}
+	}
+
+/*
+ *  rel_lease -- ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã
+ */
+
+static void
+rel_lease (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãç¡ããã°ä½ãããªãã*/
+	if (ct->act_msg == NULL)
+		return;
+
+	/* ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã*/
+	rel_options(ct, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	              ct->act_msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN), true);
+	rel_addr();
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+	syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)ct->act_msg));
+	ct->act_msg = NULL;
+	}
+
+/*
+ *  set_addr -- IPv4 ã¢ãã¬ã¹ããµãããããã¹ã¯ãéççµè·¯è¡¨ãè¨­å®ããã
+ */
+
+static void
+set_addr (T_DHCP4_CLI_CONTEXT *ct, uint8_t *mopt, uint8_t *ropt)
+{
+	ER		error;
+	T_IN4_ADDR	addr, mask, router, net_addr;
+
+	addr     = ntohl(ct->act_msg->msg.yiaddr);
+	mask     = msg2host32(mopt + 2);
+	net_addr = addr & mask;
+	router   = msg2host32(ropt + 2);
+	
+	if ((error = in4_add_ifaddr(addr, mask)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set IPv4 addr: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(0, IPV4_ADDRANY, IPV4_ADDRANY, router)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(1, net_addr, mask, IPV4_ADDRANY)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if ((error = in4_add_route(2, 0xffffffff, 0xffffffff, IPV4_ADDRANY)) != E_OK)
+		syslog(LOG_NOTICE, "[DHCP4C] error, set routing table: %s", itron_strerror(error));
+
+	if (error == E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] set IPv4 addr: %s.", ip2str(NULL, &addr));
+
+#ifdef USE_LCD
+		dly_tsk(1 * 1000);
+		lcd_puts(LCD_PORTID, ip2str(NULL, &addr));
+		lcd_putc(LCD_PORTID, '\n');
+#endif	/* of #ifdef USE_LCD */
+
+		}
+	}
+
+/*
+ *  set_options -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã
+ */
+
+static void
+set_options (T_DHCP4_CLI_CONTEXT *ct, uint_t off, uint_t len, bool_t overload)
+{
+#if defined(USE_RESOLVER)
+	T_IN4_ADDR	addr;
+#endif
+
+	uint8_t	*opt, *mopt = NULL, *ropt = NULL;
+
+	opt = (uint8_t*)&ct->act_msg->msg + off;
+	while (opt < (uint8_t*)&ct->act_msg->msg + off + len && *opt != DHCP4_OPT_END) {
+		if (*opt == DHCP4_OPT_PAD)
+			opt ++;
+		else if ((*opt == DHCP4_OPT_OPT_OVERLOAD) && overload) {
+			if (*(opt + 2) & DHCP4_OPTOL_FILE)
+				set_options(ct, DHCP4_FILE_OFFSET, DHCP4_FILE_LEN, false);
+			if (*(opt + 2) & DHCP4_OPTOL_SNAME)
+				set_options(ct, DHCP4_SNAME_OFFSET, DHCP4_SNAME_LEN, false);
+			opt += *(opt + 1) + 2;
+			}
+		else {
+
+			switch (*opt) {
+			case DHCP4_OPT_SUBNET_MASK:
+				mopt = opt;
+				break;
+
+			case DHCP4_OPT_ROUTER:
+				ropt = opt;
+				break;
+
+#if defined(USE_RESOLVER)
+
+			case DHCP4_OPT_DNS_SERVER:
+				addr = msg2host32(opt + 2);
+				dns_in4_set_addr(&addr);
+				break;
+
+			case DHCP4_OPT_HOST_NAME:
+				break;
+
+			case DHCP4_OPT_DOMAIN_NAME:
+				dns_in4_set_dname(opt + 2, *(opt + 1));
+				break;
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_DNS_SERVER:
+			case DHCP4_OPT_HOST_NAME:
+			case DHCP4_OPT_DOMAIN_NAME:
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+			case DHCP4_OPT_LEASE_TIME:
+			case DHCP4_OPT_RENEWAL_T1:
+			case DHCP4_OPT_REBINDING_T2:
+				break;
+
+			default:
+				break;
+				}
+
+			opt += *(opt + 1) + 2;
+			}
+		}
+	if (!(mopt == NULL || ropt == NULL))
+		set_addr(ct, mopt, ropt);
+	}
+
+/*
+ *  set_lease -- ãªã¼ã¹ãããæ
+å ±ãè¨­å®ããã
+ */
+
+static void
+set_lease (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã*/
+	set_options(ct, DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN,
+	              ct->act_msg->len - (DHCP4_OPTION_OFFSET + DHCP4_MAGIC_LEN), true);
+	}
+
+/*
+ *  validate_duplicate -- æå®ããã IPv4 ã¢ãã¬ã¹ãä½¿ããã¦ããªããæ¤è¨¼ããã
+ *
+ *    ä½¿ããã¦ããªãæã¯ true ãè¿ãã
+ */
+
+static bool_t
+validate_duplicate (T_DHCP4_CLI_MSG *msg)
+{
+	T_IN4_ADDR	yiaddr;
+
+	/* æå®ããã IPv4 ã¢ãã¬ã¹ã ADDR ANY ãªãä½¿ããã¦ããªãã¨å¤æ­ããã*/
+	yiaddr = ntohl(msg->msg.yiaddr);
+	if (yiaddr == IPV4_ADDRANY)
+		return true;
+
+	/* ARP ã­ã£ãã·ã¥ã«ããã°ä½¿ããã¦ããã¨å¤æ­ããã*/
+	if (arp_lookup(yiaddr, false) != NULL)
+		return false;
+
+	/*
+	 *  ARP è¦æ±ãåºåãã¦ TMO_DHCP4C_ARP_WAIT å¾
+ã¡ã
+	 *  ARP ã­ã£ãã·ã¥ã«ãªããã°ä½¿ããã¦ããªãã¨å¤æ­ããã
+	 */
+	arp_request(&IF_ETHER_NIC_GET_SOFTC()->ifaddr, yiaddr);
+	dly_tsk(TMO_DHCP4C_ARP_WAIT);
+	return arp_lookup(yiaddr, false) == NULL;
+	}
+
+/*
+ *  validate_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_rcv_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *msg)
+{
+	uint8_t 	*opt;
+
+	/* packet type ã DHCP4_REPLY ã§ãããã¨ãç¢ºèªããã*/
+	if (!(msg->msg.op == DHCP4_REPLY))
+		return false;
+
+	/* ã¡ãã»ã¼ã¸ã¿ã¤ããªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_option(msg, DHCP4_OPT_MSG_TYPE, 1)) == NULL)
+		return E_PAR;
+
+	/* ã¡ãã»ã¼ã¸ã®ã¿ã¤ããä¸è´ãã¦ãããã¨ãæ¤è¨¼ããã*/
+	msg->type = *(opt + 2);
+	switch (ct->fsm) {
+
+	case DHCP4_FSM_SELECT:
+		if (!(msg->type == DHCP4_MTYPE_OFFER))
+			return E_PAR;
+		break;
+
+	case DHCP4_FSM_REQUEST:
+	case DHCP4_FSM_REBOOT:
+	case DHCP4_FSM_RENEW:
+	case DHCP4_FSM_REBIND:
+	case DHCP4_FSM_REL_INFO:
+		if (!((msg->type == DHCP4_MTYPE_ACK) || (msg->type == DHCP4_MTYPE_NAK)))
+			return E_PAR;
+		break;
+
+	case DHCP4_FSM_INIT:
+	case DHCP4_FSM_BOUND:
+	case DHCP4_FSM_INIT_REBOOT:
+		return E_PAR;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP4C] error, unknown state: %d.", ct->fsm);
+		return E_PAR;
+		break;
+		}
+
+	/* ãã¸ãã¯çªå·ãæ¤è¨¼ããã*/
+	if (memcmp((uint8_t*)&msg->msg.options, magicno, DHCP4_MAGIC_LEN))
+		return E_PAR;
+
+	/* ãã©ã³ã¶ã¯ã·ã§ã³ ID ãç°ãªã£ã¦ããã°ã¨ã©ã¼ */
+	if (ntohl(msg->msg.xid) != ct->xid)
+		return E_PAR;
+
+	/* ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹é·ã 6ï¼MAC ã¢ãã¬ã¹é·ï¼ã§ãªããã°ã¨ã©ã¼ */
+	if (msg->msg.hlen != ETHER_ADDR_LEN)
+		return E_PAR;
+
+	/* ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹ãç°ãªã£ã¦ããã°ã¨ã©ã¼ */
+	if (memcmp(&msg->msg.chaddr, &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr)))
+		return E_PAR;
+
+	/*
+	 *  ã¡ãã»ã¼ã¸ã¿ã¤ãã OFFER ã®å ´åã¯ã
+	 *  ARP ãä½¿ç¨ãã¦ãæå®ããã IPv4 ã¢ãã¬ã¹ãä½¿ããã¦ããªããæ¤è¨¼ããã
+	 *  ä½¿ããã¦ããæã¯ãä»ã® IPv4 ã¢ãã¬ã¹ã®æä¾ãå¾
+ã¤ã
+	 */
+	if (msg->type == DHCP4_MTYPE_OFFER) {
+		if (!validate_duplicate(msg))
+			return E_PAR;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  eval_prefer -- åä¿¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_prefer (T_DHCP4_CLI_MSG *msg)
+{
+	int	ix;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (msg == NULL)
+		return;
+
+	/* æå®ããã IPv4 ã¢ãã¬ã¹ã ADDR ANY ãªãæ¨å¥¨åº¦ã 0ã«è¨­å®ããã*/
+	if (ntohl(msg->msg.yiaddr) == IPV4_ADDRANY)
+		msg->prefer = 0;
+	else
+		msg->prefer = DHCP4_CLI_CFG_PREFER_ADDR;
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		if (find_option(msg, request_plist[ix], 0) != NULL)
+			msg->prefer ++;
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		if (find_option(msg, required_plist[ix], 0) == NULL)
+			msg->prefer = 0;
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+	}
+
+/*
+ *  eval_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãè©ä¾¡ããã
+ */
+
+static ER
+eval_rcv_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*evl, *msg;
+
+	/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	if (ct->val_lst == NULL) {
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* æ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãããè©ä¾¡ã¡ãã»ã¼ã¸ãåãåºãã*/
+	evl         = ct->val_lst;
+	ct->val_lst = ct->val_lst->next;
+	evl->next   = NULL;
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if (validate_rcv_msg(ct, evl) != E_OK) {
+
+		/* ã¨ã©ã¼ãçºçããè©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		goto rcv_ret;
+		}
+
+	/* åä¿¡ããã¡ãã»ã¼ã¸ã NAK ã®æã®å¦ç */
+	if (evl->type == DHCP4_MTYPE_NAK) {
+
+		/* ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* å
+é¨ã¨ã©ã¼ãè¨­å®ãã¦çµäºããã*/
+		return E_PAR;
+		}
+
+	/* REL_INFO ç¶æ
+ã®æã®å¦ç */
+	//cons_printf(CONSOLE_PORTID, "evl_rcv_msg3[s=%d]\n", ct->fsm);
+	if (ct->fsm == DHCP4_FSM_REL_INFO) {
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã*/
+	eval_prefer(evl);
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããç©ºãªãè©ä¾¡ã¡ãã»ã¼ã¸ãç§»ãã¦çµäºããã*/
+	if (ct->prf_lst == NULL) {
+		ct->max_prefer = evl->prefer;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã¨æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ãæ¯è¼ããã*/
+	if (evl->prefer > ct->max_prefer) {
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããé«ããã°ã
+		 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		ct->max_prefer = evl->prefer;
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		if (ct->rcv_lst == NULL)
+			ct->rcv_lst = ct->prf_lst;
+		else {
+			for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+				;
+			msg->next = ct->prf_lst;
+			}
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	else if (evl->prefer == ct->max_prefer) {
+		for (msg = ct->prf_lst; msg != NULL; msg = msg->next) {
+			if (is_equal_sid(evl, msg)) {
+
+				/*
+				 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«åã DHCP4_OPT_SERVER_ID ã®ã¡ãã»ã¼ã¸ãããã°ã
+				 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+				 */
+				goto rcv_ret;
+				}
+			}
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+	
+	/*else */
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããä½ããã°ã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+
+rcv_ret:
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	evl->next   = ct->rcv_lst;
+	ct->rcv_lst = evl;
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+	return E_OK;
+	}
+
+/*
+ *  select_msg -- æ¨å¥¨ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static T_DHCP4_CLI_MSG*
+select_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG		*msg, *select;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+	if (ct->prf_lst == NULL) {
+		/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		return NULL;
+		}
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã*/
+	select = ct->prf_lst;
+	ct->prf_lst  = ct->prf_lst->next;
+	select->next = NULL;
+
+	/* é¸æãããªãã£ãæ¤è¨¼ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->rcv_lst == NULL)
+		ct->rcv_lst = ct->prf_lst;
+	else {
+		for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+			;
+		msg->next = ct->prf_lst;
+		}
+	syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+	return select;
+	}
+
+/*
+ *  select_ack -- ACK ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ *
+ *    åãå
+¥ãããã¨ãå¯è½ã®æã¯ true ãè¿ãã
+ */
+
+static bool_t
+select_ack (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*msg;
+
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ããã°ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->act_msg != NULL) {
+		syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+		ct->act_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->act_msg;
+		syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+		}
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ã«è¨­å®ããã*/
+	ct->act_msg = msg;
+	return true;
+	}
+
+/*
+ *  select_offer -- OFFER ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ *
+ *    åãå
+¥ãããã¨ãå¯è½ã®æã¯ true ãè¿ãã
+ */
+
+static bool_t
+select_offer (T_DHCP4_CLI_CONTEXT *ct)
+{
+	return (ct->off_msg = select_msg(ct)) != NULL;
+	}
+
+/*
+ *  cancel_all_timers -- å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã
+ */
+
+static void
+cancel_all_timers (T_DHCP4_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; )
+		ct->timers[ix] = 0;
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+
+/*
+ *  start_select -- DISCOVER ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_select (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* éä¿¡ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->snd_start);
+
+	/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_RCV_OFFER] = SYSTIM2TIMER(TMO_DHCP4C_OFFER);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã«ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* éä¿¡ééããªã»ããããã*/
+	ct->interval = 0;
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_SELECT;
+
+	/* DISCOVER ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_DISC;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  start_bound -- BOUND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_bound (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹ãããæ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* ãªã¼ã¹ã®æå¹æéãè¨­å®ããã*/
+	ct->expire = timer_value(ct->act_msg, DHCP4_OPT_LEASE_TIME, TMO_DHCP4C_DEF_LEASE);
+
+	/* ãªã¼ã¹æéã TMO_DHCP4C_MIN_LEASE ä»¥ä¸ã®æã¯ãTMO_DHCP4C_MIN_LEASE ã«è¨­å®ããã*/
+	if (ct->expire < TMO_DHCP4C_MIN_LEASE)
+		ct->expire = TMO_DHCP4C_MIN_LEASE;
+
+	/* RENEW ç¶æ
+ã¾ã§ã®æéãè¨­å®ããã*/
+	ct->renew = timer_value(ct->act_msg, DHCP4_OPT_RENEWAL_T1, ct->expire / 2);
+
+	/* REBIND ç¶æ
+ã¾ã§ã®æéãè¨­å®ããã*/
+	ct->rebind = timer_value(ct->act_msg, DHCP4_OPT_REBINDING_T2, ct->renew + ct->renew / 2 + ct->renew / 4);
+
+	/* EXPIREãRENEWãREBIND ã¿ã¤ãã¼ãè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_EXPIRE] = SYSTIM2TIMER(ct->expire);		/* EXPIRE      ã¾ã§ã®æé */
+	ct->timers[DHCP4C_TIMER_REBIND] = SYSTIM2TIMER(ct->rebind);		/* REBINDï¼T2ï¼ã¾ã§ã®æé */
+	ct->timers[DHCP4C_TIMER_RENEW]  = SYSTIM2TIMER(ct->renew);		/* RENEW ï¼T1ï¼ã¾ã§ã®æé */
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_BOUND;
+
+	/* BIND ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->bind_start);
+	}
+
+/*
+ *  start_send_request -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ãæå®ãããç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_send_request (T_DHCP4_CLI_CONTEXT *ct, uint_t fsm)
+{
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	/* éä¿¡ãéå§ããæéãè¨é²ããã*/
+	get_tim(&ct->snd_start);
+
+	/* é·ç§»ããç¶æ
+ã RENEW ä»¥å¤ã§ã¯ ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	if (fsm != DHCP4_FSM_RENEW) { 
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_ACK] = SYSTIM2TIMER(TMO_DHCP4C_ACK);
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+		}
+
+	/*
+	 *  é·ç§»ããç¶æ
+ã RENEW ã§ã
+	 *  SERVER ID ãªãã·ã§ã³ãããã°ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããéä¿¡ããã
+	 */
+	if ((fsm == DHCP4_FSM_RENEW) &&
+	    (find_option(ct->act_msg, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR)) !=  NULL))
+		ct->dst.ipaddr = (ifp->in4_ifaddr.addr &  ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
+	else
+		ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* éä¿¡ééããªã»ããããã*/
+	ct->interval = 0;
+
+	/* æå®ãããç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = fsm;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REQ;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv4 ã® RFC2131 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP4_FSM_SLEEP;
+		return;
+		}
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã«ã­ã¼ã«ã«ãããã¯ã¼ã¯ã¸ã®ãã­ã¼ãã­ã£ã¹ããè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP4C_FLAG_TMOUT_SND_REL;
+	syscall(sig_sem(SEM_DHCP4_CLI_READY));
+	}
+
+/*
+ *  setup_dhcp_com_msg -- DHCP ã¡ãã»ã¼ã¸ã®å
+±éé¨åãä½æããã
+ */
+
+static uint8_t *
+setup_dhcp_com_msg (T_DHCP4_CLI_CONTEXT *ct, uint_t op, uint_t type)
+{
+	uint8_t	*option;
+
+	memset((void*)&ct->snd_msg->msg, sizeof(ct->snd_msg->msg), 0);
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg);
+
+	/* ãããé¨ãè¨­å®ããã*/
+	ct->snd_msg->msg.op = op;
+	ct->snd_msg->msg.htype = DHCP4_HWA_TYPE_ETHER;
+	ct->snd_msg->msg.hlen = ETHER_ADDR_LEN;
+	HOST2MSG32(ct->snd_msg->msg.xid, ct->xid);
+
+	/* MAC ã¢ãã¬ã¹ãè¨­å®ããã*/
+	memcpy(&ct->snd_msg->msg.chaddr, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+
+	/*
+	 *  ãªãã·ã§ã³é¨ãè¨­å®ããã
+	 */
+
+	/* RFC1048 ã«å®ç¾©ããã¦ãããã¸ãã¯çªå·ãè¨­å®ããã*/
+	memcpy(&ct->snd_msg->msg.options, magicno, DHCP4_MAGIC_LEN);
+	option = ct->snd_msg->msg.options + DHCP4_MAGIC_LEN;
+
+	/* DHCP ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	*(option ++) = DHCP4_OPT_MSG_TYPE;
+	*(option ++) = 1;
+	*(option ++) = type;
+
+	return option;
+	}
+
+/*
+ *  setup_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_release_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *ref)
+{
+	uint8_t *opt, *ref_opt;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ããªããã°ã¨ã©ã¼ */
+	if (ref == NULL)
+		return E_PAR;
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_RELEASE)) == NULL)
+		return E_PAR;
+
+	/*
+	 *  ãµã¼ã IDï¼server-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if ((ref_opt = find_option(ref, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+		return E_PAR;
+	*(opt ++) = *(ref_opt ++);
+	*(opt ++) = *(ref_opt ++);
+	memcpy(opt, ref_opt, *(ref_opt - 1));
+	opt += *(ref_opt - 1);
+
+	/* 
+	 *  ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/*
+	 *  ã¯ã©ã¤ã¢ã³ã IP ã¢ãã¬ã¹ï¼ciaddrï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	HOST2MSG32(ct->snd_msg->msg.ciaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+
+/*
+ *  setup_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_request_msg (T_DHCP4_CLI_CONTEXT *ct, T_DHCP4_CLI_MSG *ref)
+{
+	uint8_t *opt, *ref_opt;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+	uint_t	len = 0;
+#endif
+
+	/* åç
+§ããã¡ãã»ã¼ã¸ããªããã°ã¨ã©ã¼ */
+	if (ref == NULL)
+		return E_PAR;
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_REQUEST)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¿½å ã®ãªãã·ã§ã³ãè¨­å®ããã*/
+
+	*opt  = DHCP4_OPT_REQ_PARAM;
+	 opt += 2;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(required_plist) > 0) {
+		memcpy(opt, required_plist, sizeof(required_plist));
+		opt += sizeof(required_plist);
+		len += sizeof(required_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(request_plist) > 0) {
+		memcpy(opt, request_plist, sizeof(request_plist));
+		opt += sizeof(request_plist);
+		len += sizeof(request_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	*(opt - len - 1) = len;
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	/*
+	 *  ãµã¼ã IDï¼server-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if (ct->fsm == DHCP4_FSM_REQUEST) {
+		if ((ref_opt = find_option(ref, DHCP4_OPT_SERVER_ID, sizeof(T_IN4_ADDR))) == NULL)
+			return E_PAR;
+		*(opt ++) = *(ref_opt ++);
+		*(opt ++) = *(ref_opt ++);
+		memcpy(opt, ref_opt, *(ref_opt - 1));
+		opt += *(ref_opt - 1);
+		}
+
+	/*
+	 *  è¦æ± IP ã¢ãã¬ã¹ï¼requested-ipï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 *  RFC2131 ã§ã¯ãDHCP4_FSM_RENEW ã®æ MUST NOT ã«ãªã£ã¦ãããã
+	 *  MUST ã®ããã§ããã
+	 */
+	*(opt ++) = DHCP4_OPT_REQ_IPV4;
+	*(opt ++) = sizeof(ref->msg.yiaddr);
+	if (ct->fsm == DHCP4_FSM_REQUEST || ct->fsm == DHCP4_FSM_INIT_REBOOT ||
+	    ct->fsm == DHCP4_FSM_RENEW   || ct->fsm == DHCP4_FSM_REBIND)
+	 	/* åç
+§ã¡ãã»ã¼ã¸ã¨åã IP ã¢ãã¬ã¹ï¼requested-ipï¼ãè¦æ±ããã*/
+		memcpy(opt, (uint8_t*)&ref->msg.yiaddr, sizeof(ref->msg.yiaddr));
+	else
+		host2msg32(opt, IPV4_ADDRANY);
+	opt += sizeof(ref->msg.yiaddr);
+
+	/* 
+	 *  ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/*
+	 *  ã¯ã©ã¤ã¢ã³ã IP ã¢ãã¬ã¹ï¼ciaddrï¼ãè¨­å®ããã
+	 *  RFC2131 4.4.1 Initialization and allocation of network address åç
+§
+	 */
+	if (ct->fsm == DHCP4_FSM_RENEW || ct->fsm == DHCP4_FSM_REBIND)
+		HOST2MSG32(ct->snd_msg->msg.ciaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+	else
+		HOST2MSG32(ct->snd_msg->msg.ciaddr, IPV4_ADDRANY);
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+/*
+ *  setup_discover_msg -- DISCOVER ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_discover_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	uint8_t *opt;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+	uint_t	len = 0;
+#endif
+
+	ct->xid = create_xid();
+	if ((opt = setup_dhcp_com_msg(ct, DHCP4_REQUEST, DHCP4_MTYPE_DISCOVER)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¿½å ã®ãªãã·ã§ã³ãè¨­å®ããã*/
+
+	*opt  = DHCP4_OPT_REQ_PARAM;
+	 opt += 2;
+
+#if defined(DHCP4_CLI_CFG_REQUIRED_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(required_plist) > 0) {
+		memcpy(opt, required_plist, sizeof(required_plist));
+		opt += sizeof(required_plist);
+		len += sizeof(required_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP4_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãªã¹ããè¨­å®ããã*/
+	if (sizeof(request_plist) > 0) {
+		memcpy(opt, request_plist, sizeof(request_plist));
+		opt += sizeof(request_plist);
+		len += sizeof(request_plist);
+		}
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	*(opt - len - 1) = len;
+
+#endif	/* of #if defined(DHCP4_CLI_CFG_REQUIRED_OLIST) || defined(DHCP4_CLI_CFG_REQUEST_OLIST) */
+
+	/* æ¢ã«ã¢ãã¬ã¹æ
+å ±ããªã¼ã¹ããã¦ããã°ãåã IP ã¢ãã¬ã¹ãè¦æ±ããã*/
+	if (ct->act_msg != NULL) {
+		*(opt ++) = DHCP4_OPT_REQ_IPV4;
+		*(opt ++) = sizeof(ct->act_msg->msg.yiaddr);
+		memcpy(opt, (uint8_t*)&ct->act_msg->msg.yiaddr, sizeof(ct->act_msg->msg.yiaddr));
+		opt += sizeof(ct->act_msg->msg.yiaddr);
+		}
+
+	/* ã¯ã©ã¤ã¢ã³ã IDï¼MAC ã¢ãã¬ã¹ï¼ãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_CLIENT_ID;
+	*(opt ++) = ETHER_ADDR_LEN + 1;
+	*(opt ++) = DHCP4_HWA_TYPE_ETHER;
+	memcpy(opt, &ct->sc->ifaddr.lladdr, ETHER_ADDR_LEN);
+	opt += ETHER_ADDR_LEN;
+
+	/* ãªãã·ã§ã³ã®çµäºãè¨­å®ããã*/
+	*(opt ++) = DHCP4_OPT_END;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr = IPV4_ADDRBROADCAST;
+
+	/* ã¡ãã»ã¼ã¸é·ãè¨­å®ããã*/
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg) - DHCP4_DFLT_OPT_LEN
+	             + (opt - (uint8_t*)&ct->snd_msg->msg.options);
+	return E_OK;
+	}
+
+/*
+ *  ack_msg_timeout -- ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+ack_msg_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ACK ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_ack(ct)) {
+
+		/* REQUEST ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_SND_REQ] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/*
+		 *  ç¶æ
+ã REQUEST ã®æã¯ã
+		 *  OFFER ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+		if (ct->fsm == DHCP4_FSM_REQUEST && ct->off_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->off_msg;
+			syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg = NULL;
+			}
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+	else {
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		ct->error = E_TMOUT;
+		}
+	}
+
+/*
+ *  send_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_request_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*ref;
+	ER		error;
+	SYSTIM		time;
+	RELTIM		interval;
+	uint16_t	secs;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* ACK ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_ack(ct)) {
+
+		/* ACK/NAK ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_ACK] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/*
+		 *  ç¶æ
+ã REQUEST ã®æã¯ã
+		 *  OFFER ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+		if (ct->fsm == DHCP4_FSM_REQUEST && ct->off_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->off_msg;
+			syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+			ct->off_msg = NULL;
+			}
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		ref = ct->off_msg;
+	else
+		ref = ct->act_msg;
+	if ((error = setup_request_msg(ct, ref)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup request message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ãéå§ãã¦ããã®æéãå¾ãã*/
+	get_tim(&time);
+	interval = time - ct->snd_start;
+
+	/*
+	 * éä¿¡ãéå§ãã¦ããã®æéï¼ç§ï¼ãã¡ãã»ã¼ã¸ã«è¨­å®ããã
+	 * æå¤§å¤ã¯ 65535ã
+	 */
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		secs = ct->secs;
+	else {
+		if (SYSTIM2SEC(interval) < 65536)
+			secs = SYSTIM2SEC(interval);
+		else
+			secs = 65535;
+		}
+	HOST2MSG16(ct->snd_msg->msg.secs, secs);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send request message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ééãè¨­å®ããã*/
+	if (ct->interval == 0)
+		/* æªè¨­å® */
+		ct->interval = TMO_DHCP4C_INIT_INTVL;
+	else
+		/* ããã¯ãªãã¢ã«ã´ãªãºã ã§ 2åã«ããï¼ä¹±æ°ä½¿ç¨ï¼éä¿¡ééãå ç®ããã*/
+		ct->interval += (netapp_rand() >> 2) % (ct->interval << 1);
+	
+	/* éä¿¡å¨æã®å¶éå¤ãè¶
+ããªãããã«ããã*/
+	if (ct->interval > TMO_DHCP4C_MAX_BACKOFF)
+		ct->interval = (TMO_DHCP4C_MAX_BACKOFF >> 1) + ((netapp_rand() >> 2) % TMO_DHCP4C_MAX_BACKOFF);
+
+	/* ãªã¼ã¹æéã®ã¿ã¤ã ã¢ã¦ããå
+éãã */
+	if (ct->fsm != DHCP4_FSM_REQUEST &&
+	    TIMEC_GT(ct->interval + time, ct->expire + ct->bind_start))
+		ct->interval = ct->expire + ct->bind_start - time + SYSTIM_HZ;
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_SND_REQ] = SYSTIM2TIMER(ct->interval);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+/*
+ *  send_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_release_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER		error;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_release_msg(ct, ct->act_msg)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup release message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send release message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* ã¡ãã»ã¼ã¸éä¿¡å¾
+ã¡ãè¡ãã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_READY));
+
+	/* SLEEP ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP4_FSM_SLEEP;
+	}
+
+/*
+ *  offer_msg_timeout -- OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+offer_msg_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* OFFER ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãREQUEST ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_offer(ct)) {
+
+		/* DISCOVER ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_SND_DISC] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
+ã«é·ç§»ããã*/
+		start_send_request(ct, DHCP4_FSM_REQUEST);
+		}
+	else
+		ct->error = E_TMOUT;
+	}
+
+/*
+ *  send_discover_msg -- DISCOVERã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_discover_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER	error;
+	SYSTIM	time;
+	RELTIM	interval;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* OFFER ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãREQUEST ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+	if (select_offer(ct)) {
+
+		/* OFFER ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+		ct->timers[DHCP4C_TIMER_RCV_OFFER] = 0;
+		syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REQUEST ç¶æ
+ã«é·ç§»ããã*/
+		start_send_request(ct, DHCP4_FSM_REQUEST);
+		return;
+		}
+
+	/* DISCOVER ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_discover_msg(ct)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, setup discover message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ãéå§ãã¦ããã®æéãå¾ãã*/
+	get_tim(&time);
+	interval = time - ct->snd_start;
+
+	/*
+	 * éä¿¡ãéå§ãã¦ããã®æéï¼ç§ï¼ãã¡ãã»ã¼ã¸ã«è¨­å®ããã
+	 * æå¤§å¤ã¯ 65535ã
+	 */
+	if (SYSTIM2SEC(interval) < 65536)
+		ct->secs = SYSTIM2SEC(interval);
+	else
+		ct->secs = 65535;
+	HOST2MSG16(ct->snd_msg->msg.secs, ct->secs);
+
+	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = udp_snd_dat(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, send discover message: %s", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* éä¿¡ééãè¨­å®ããã*/
+	if (ct->interval == 0)
+		/* æªè¨­å® */
+		ct->interval = TMO_DHCP4C_INIT_INTVL;
+	else
+		/* ããã¯ãªãã¢ã«ã´ãªãºã ã§ 2åã«ããï¼ä¹±æ°ä½¿ç¨ï¼éä¿¡ééãå ç®ããã*/
+		ct->interval += (netapp_rand() >> 2) % (ct->interval << 1);
+	
+	/* éä¿¡å¨æã®å¶éå¤ãè¶
+ããªãããã«ããã*/
+	if (ct->interval > TMO_DHCP4C_MAX_BACKOFF)
+		ct->interval = (TMO_DHCP4C_MAX_BACKOFF >> 1) + ((netapp_rand() >> 2) % TMO_DHCP4C_MAX_BACKOFF);
+
+	/* OFFER ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¶
+ããªãããã«èª¿æ´ããã*/
+	if (TIMEC_GT(time + ct->interval, ct->snd_start + TMO_DHCP4C_OFFER))
+		ct->interval = (TMO_DHCP4C_INIT_INTVL + TMO_DHCP4C_OFFER) - time + 1;
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	ct->timers[DHCP4C_TIMER_SND_DISC] = SYSTIM2TIMER(ct->interval);
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+	}
+
+/*
+ *  dhcpc_timer -- TIMER ç®¡ç
+ */
+
+static void
+dhcpc_timer (T_DHCP4_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP4_CLI_TIMER));
+	for (ix = NUM_DHCP4C_TIMERS; ix -- > 0; ) {
+		if (ct->timers[ix] != 0) {
+			ct->timers[ix] --;
+			if (ct->timers[ix] == 0) {
+				ct->flags = (ct->flags & ~DHCP4C_FLAG_TMOUT_MASK) | DHCP4C_FLAG_TMOUT_TIMER | ix;
+				syscall(sig_sem(SEM_DHCP4_CLI_READY));
+				}
+			}
+		}
+	syscall(sig_sem(SEM_DHCP4_CLI_TIMER));
+
+	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããã*/
+	timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ);
+	}
+
+/*
+ *  expire_timeout -- EXPIRE ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+expire_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	//ER	error;
+
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* ç¶æ
+ã REQUEST ã®æã¯ä½ãããªãã*/
+	if (ct->fsm == DHCP4_FSM_REQUEST)
+		return;
+
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* ãªã¼ã¹ãããæ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	ct->error = E_TMOUT;
+	}
+
+/*
+ *  rebind_timeout -- REBIND ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+rebind_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ REBIND ç¶æ
+ã«é·ç§»ããã*/
+	start_send_request(ct, DHCP4_FSM_REBIND);
+	}
+
+/*
+ *  renew_timeout -- RENEW ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+renew_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããã©ã°ãã¯ãªã¢ã¼ããã*/
+	ct->flags &= ~DHCP4C_FLAG_TMOUT_MASK;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ RENEW ç¶æ
+ã«é·ç§»ããã*/
+	start_send_request(ct, DHCP4_FSM_RENEW);
+	}
+
+/*
+ *  dispatch_timeout -- ã¿ã¤ã ã¢ã¦ãããæã®å¦ç
+ */
+
+static ER
+dispatch_timeout (T_DHCP4_CLI_CONTEXT *ct)
+{
+	switch (ct->flags & DHCP4C_FLAG_TMOUT_TIMER_MASK) {
+
+	case DHCP4C_TIMER_SND_DISC:
+		send_discover_msg(ct);
+		break;
+
+	case DHCP4C_TIMER_SND_REQ:
+		send_request_msg(ct);
+		break;
+
+	case DHCP4C_TIMER_RCV_OFFER:
+		offer_msg_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_RCV_ACK:
+		ack_msg_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_RENEW:
+		renew_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_REBIND:
+		rebind_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_EXPIRE:
+		expire_timeout(ct);
+		break;
+
+	case DHCP4C_TIMER_SND_REL:
+		send_release_msg(ct);
+		break;
+
+	default:
+		break;
+		}
+
+	return ct->error;
+	}
+
+/*
+ *  dispatch_event -- ã¤ãã³ãæ¯ã®å¦ç
+ */
+
+static ER
+dispatch_event (T_DHCP4_CLI_CONTEXT *ct)
+{
+	ER	error = E_OK;
+
+	while (ct->fsm != DHCP4_FSM_SLEEP && error == E_OK) {
+
+		/* ã¡ãã»ã¼ã¸ã®åä¿¡ã¨ã¿ã¤ã ã¢ã¦ããå¾
+ã¤ã*/
+		syscall(wai_sem(SEM_DHCP4_CLI_READY));
+
+		if (ct->flags & DHCP4C_FLAG_RCV_MSG) {
+			while (ct->val_lst != NULL) {
+				error = eval_rcv_msg(ct);
+				}
+			ct->flags &= ~DHCP4C_FLAG_RCV_MSG;
+			}
+		if (ct->flags & DHCP4C_FLAG_TMOUT_MASK)
+			error = dispatch_timeout(ct);
+
+		if (ct->error != E_OK)
+			error = ct->error;
+		}
+
+	return error;
+	}
+
+/*
+ *  init_context -- DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã
+ */
+
+static void
+init_context (T_DHCP4_CLI_CONTEXT *ct, ID cepid)
+{
+  	memset(ct, 0, sizeof(*ct));
+	ct->cepid	= cepid;
+	ct->sc		= IF_ETHER_NIC_GET_SOFTC();
+	ct->dst.portno	= DHCP4_SRV_CFG_PORTNO;
+	ct->dst.ipaddr	= IPV4_ADDRANY;
+	}
+
+/*
+ *  rel_cli_msg -- ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã
+ */
+
+static void
+rel_cli_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*ptr, *cell;
+
+	for (ptr = ct->rcv_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->val_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->prf_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)cell));
+		}
+
+	if (ct->snd_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP4_CLI_MSG, (void*)ct->snd_msg));
+	ct->rcv_lst = ct->prf_lst = ct->val_lst = ct->snd_msg = NULL;
+	}
+
+/*
+ *  init_cli_msg -- åã¡ãã»ã¼ã¸æ§é ä½ãåæåããã
+ */
+
+static ER
+init_cli_msg (T_DHCP4_CLI_CONTEXT *ct)
+{
+	T_DHCP4_CLI_MSG	*cell;
+	ER		error;
+	int		count;
+
+	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	if ((error = tget_mpf(MPF_DHCP4_CLI_MSG, (void*)&ct->snd_msg, TMO_DHCP4C_MPF_GET)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP4C] error, tget_mpf() for send: %s.", itron_strerror(error));
+		return error;
+		}
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãããå ´åã¯ã
+	 *  ç²å¾ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã®æ§é ä½ã 1æ¸ããã
+	 */
+	if (ct->act_msg == NULL)
+		count = NUM_DHCP4_MSG_LIST;
+	else
+		count = NUM_DHCP4_MSG_LIST - 1;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	while (count --> 0) {
+		if ((error = tget_mpf(MPF_DHCP4_CLI_MSG, (void*)&cell, TMO_DHCP4C_MPF_GET)) != E_OK) {
+			syslog(LOG_NOTICE, "[DHCP4C] error, tget_mpf() for receive: %s.", itron_strerror(error));
+			break;
+			}
+		cell->next  = ct->rcv_lst;
+		ct->rcv_lst = cell;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  dhcp4c_renew_info -- ãããã¯ã¼ã¯æ
+å ±ãååå¾ããã
+ */
+
+ER
+dhcp4c_renew_info (void)
+{
+	if (context.fsm == DHCP4_FSM_BOUND) {
+
+		/* REL_INFO ç¶æ
+ã«é·ç§»ããå¾ã« SLEEP ãè§£é¤ããããã«è¨­å®ããã*/
+		context.flags |= DHCP4C_FLAG_RENEW;
+		start_rel_info(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP4_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP4_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+	}
+
+/*
+ *  dhcp4c_rel_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè§£æ¾ããã
+ */
+
+ER
+dhcp4c_rel_info (void)
+{
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	start_rel_info(&context);
+	return E_OK;
+	}
+
+/*
+ *  dhcp4c_get_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè¿ãã
+ */
+
+ER
+dhcp4c_get_info (T_IN4_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                   uint32_t *rebind, SYSTIM *bind_start)
+{
+	if (addr  == NULL || expire == NULL || 
+	    renew == NULL || rebind == NULL || bind_start == NULL)
+		return E_PAR;
+	else if (context.act_msg == NULL)
+		return E_OBJ;
+	else {
+		*addr		= context.act_msg->srv.ipaddr;
+		*expire		= context.timers[DHCP4C_TIMER_EXPIRE];
+		*renew		= context.timers[DHCP4C_TIMER_RENEW];
+		*rebind		= context.timers[DHCP4C_TIMER_REBIND];
+		*bind_start	= context.bind_start;
+		return E_OK;
+		}
+	}
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_dhcp4_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	T_DHCP4_CLI_MSG	*msg;
+	ER_UINT		len;
+
+	len = *(ER_UINT*)p_parblk;
+	if (len < 0 && len != E_RLWAI) {
+		/* E_RLWAI ä»¥å¤ã§ã0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ãæå³ãã¦ããã*/
+		syslog(LOG_NOTICE, "[DHCPC(CBR)] error: %s, fncd: %s", itron_strerror(len), in_strtfn(fncd));
+		}
+	else {
+		if (fncd == TEV_UDP_RCV_DAT) {
+
+			/* åä¿¡ã¡ãã»ã¼ã¸ãªã¹ããç©ºã®æã¯ãåä¿¡ããªãã§ãã¼ã¿ã°ã©ã ãæ¨ã¦ãã*/
+			if (context.rcv_lst == NULL) 
+				syslog(LOG_NOTICE, "[DHCP4C(CBR)] receive buffer all busy.");
+			else {
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã¡ãã»ã¼ã¸æ§é ä½ãæºåããã*/
+				syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+				msg = context.rcv_lst;
+				context.rcv_lst = context.rcv_lst->next;
+				syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã*/
+				len = udp_rcv_dat(context.cepid, &msg->srv, &msg->msg, sizeof(msg->msg), TMO_POL);
+
+				syscall(wai_sem(SEM_DHCP4_CLI_LOCK));
+				msg->len = len;
+				if (len >= 0) {
+					/* åä¿¡ããã¡ãã»ã¼ã¸ãæ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã*/
+					msg->next = context.val_lst;
+					context.val_lst = msg;
+					context.flags |= DHCP4C_FLAG_RCV_MSG;
+					}
+				else {
+					/* ã¡ãã»ã¼ã¸æ§é ä½ãåä¿¡ã¡ãã»ã¼ã¸ãªã¹ãã«æ»ãã*/
+					context.error = len;
+					msg->next = context.rcv_lst;
+					context.rcv_lst = msg;
+					}
+				syscall(sig_sem(SEM_DHCP4_CLI_LOCK));
+				}
+			}
+		syscall(sig_sem(SEM_DHCP4_CLI_READY));
+		}
+	return E_OK;
+	}
+
+/*
+ *  dhcp4_cli_task -- DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+void
+dhcp4_cli_task (intptr_t exinf)
+{
+	T_DHCP4_CLI_CONTEXT	*ct;
+	ID			tskid;
+	ER			error;
+
+	dly_tsk(1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[DHCP4C:%d,%d] started.", tskid, (ID)exinf);
+	dly_tsk(500);
+	ct = &context;
+
+	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
+	init_context(ct, (ID)exinf);
+
+	while (true) {
+
+		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP4C_TIMER_HZ);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+		if ((error = init_cli_msg(ct)) == E_OK) {
+
+			/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+			start_select(ct);
+
+			/* ã¡ã¤ã³ã«ã¼ã */
+			error = dispatch_event(ct);
+			}
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)dhcpc_timer, ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg (ct);
+
+		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
+		if (!(ct->flags & DHCP4C_FLAG_RENEW)) {
+
+			/* ä¼æ­¢ããã*/
+			if (error == E_OK)
+				syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
+			else {
+				syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(error));
+				ct->fsm = DHCP4_FSM_SLEEP;
+				}
+			slp_tsk();
+			}
+		ct->flags = 0;
+		ct->error = E_OK;
+		}
+	}
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.cfg	(revision 317)
@@ -0,0 +1,74 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(DHCP4_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP4_DHCP_CLI_CEPID,
+	dhcp4_cli_task,
+	DHCP4_CLI_MAIN_PRIORITY,
+	DHCP4_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
+
+/* ã»ããã© */
+
+#ifdef DHCP4_CLI_CFG
+
+CRE_SEM(SEM_DHCP4_CLI_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_DHCP4_CLI_TIMER,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_DHCP4_CLI_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli.h	(revision 317)
@@ -0,0 +1,280 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    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 Internet Software Consortium 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 INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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 software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_CLI_H
+#define DHCP4_CLI_H
+
+#include <netapp/dhcp4.h>
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®ã¹ã¿ãã¯ãµã¤ãº
+ */
+
+#define DHCP4_CLI_STACK_SIZE		1024		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®åªå
+åº¦
+ */
+
+#define DHCP4_CLI_MAIN_PRIORITY		5		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* æ¨å¥¨åº¦ã®å®ç¾© */
+#define DHCP4_CLI_CFG_PREFER_ADDR	100		/* ã¢ãã¬ã¹ã®æ¨å¥¨åº¦	*/
+
+/* DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸ã®åä¿¡ãªã¹ããµã¤ãºï¼2ä»¥ä¸æå®ãããã¨ï¼ */
+#define NUM_DHCP4_MSG_LIST		3
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½æ°ãå¤æ´ç¦æ­¢ã
+ *  +1 ã¯éä¿¡ç¨
+ */
+#define NUM_MPF_DHCP4_CLI_MSG		(NUM_DHCP4_MSG_LIST+1)
+
+/* 
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³
+ */
+
+/* DHCP å¿
+é ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP4_CLI_CFG_REQUIRED_OLIST
+
+#define DHCP4_CLI_CFG_REQUIRED_OLIST {	\
+	DHCP4_OPT_SUBNET_MASK,		\
+	DHCP4_OPT_ROUTER,		\
+}
+
+#endif	/* of #ifndef DHCP4_CLI_CFG_REQUIRED_OLIST */
+
+/* DHCP è¦æ±ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP4_CLI_CFG_REQUEST_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP4_CLI_CFG_REQUEST_OLIST {	\
+	DHCP4_OPT_DNS_SERVER,		\
+	DHCP4_OPT_DOMAIN_NAME,		\
+}
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP4_CLI_CFG_REQUEST_OLIST */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå¤
+ */
+
+/* åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_OFFER	ULONG_C(120*1000)	/* OFFER ã¡ãã»ã¼ã¸	*/
+#define TMO_DHCP4C_ACK		ULONG_C(60*1000)	/* ACK/NAK ã¡ãã»ã¼ã¸	*/
+
+/* ãªã¼ã¹æéã®æ¢å®å¤	*/
+#define TMO_DHCP4C_DEF_LEASE	ULONG_C(12*60*60*1000)	/* æ¨æºæé	*/
+#define TMO_DHCP4C_MIN_LEASE	ULONG_C(60*1000)	/* æå°æé	*/
+
+/* ã¡ãã»ã¼ã¸ã®éä¿¡å¨æ	*/
+#define TMO_DHCP4C_INIT_INTVL	ULONG_C(3*1000)		/* åæå¤	*/
+#define TMO_DHCP4C_MAX_BACKOFF	ULONG_C(15*1000)	/* å¶éå¤	*/
+
+/* DHCP ãµã¼ãã¸ã® UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_UDP_SND	ULONG_C(1000000)		/* [us] */
+
+/* ã¡ãã»ã¼ã¸æ§é ä½ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP4C_MPF_GET	ULONG_C(1000000)		/* [us] */
+
+/* ARP è¦æ±ãéä¿¡ãã¦ããã®å¾
+ã¡æé	*/
+#define TMO_DHCP4C_ARP_WAIT	ULONG_C(1000000)		/* [us] */
+
+/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ããã®å¾
+ã¡æé	*/
+#define TMO_DHCP4C_SND_REL_WAIT	ULONG_C(1000000)	/* [us] */
+
+#ifndef _MACRO_ONLY
+
+#ifdef T_IPV4EP_DEFINED
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½
+ */
+
+typedef struct dhcp4_cli_msg {
+	/* 4ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã*/
+	T_DHCP4_MSG		msg;		/* DHCP ã¡ãã»ã¼ã¸æ§é ä½	*/
+	struct dhcp4_cli_msg	*next;		/* ãªã¹ãã®æ¬¡ã®ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IPV4EP		srv;		/* ãµã¼ãã®IPv4ã¢ãã¬ã¹/ãã¼ãçªå· */
+	uint16_t		len;		/* msg ã®æå¹é·			*/
+	uint16_t		prefer;		/* msg ã®æ¨å¥¨åº¦			*/
+	uint8_t			type;		/* ã¡ãã»ã¼ã¸ã¿ã¤ã		*/
+	} T_DHCP4_CLI_MSG;
+
+#endif	/*of #ifdef T_IPV4EP_DEFINED */
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+extern ER callback_nblk_dhcp4_cli (ID cepid, FN fncd, void *p_parblk);
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	dhcp4_cli_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+#ifdef T_IN4_ADDR_DEFINED
+
+extern ER dhcp4c_rel_info (void);
+extern ER dhcp4c_renew_info (void);
+extern ER dhcp4c_get_info (T_IN4_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                             uint32_t *rebind, SYSTIM *bind_start);
+
+#endif	/* of #ifdef T_IN4_ADDR_DEFINED */
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef DHCP4_CLI_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_asp.cfg	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+INCLUDE("netapp/dhcp4_cli.cfg");
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP4_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP4_CLI_MSG,
+	sizeof(T_DHCP4_CLI_MSG),
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_jsp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_jsp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_jsp.cfg	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+#include "netapp/dhcp4_cli.cfg"
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP4_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP4_CLI_MSG,
+	sizeof(T_DHCP4_CLI_MSG),
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp4_cli_var.h	(revision 317)
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2004 Henning Brauer <henning@openbsd.org>
+ * Copyright (c) 1995, 1996, 1997, 1998, 1999
+ * The Internet Software Consortium.    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 Internet Software Consortium 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 INTERNET SOFTWARE CONSORTIUM 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 INTERNET SOFTWARE CONSORTIUM 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 software has been written for the Internet Software Consortium
+ * by Ted Lemon <mellon@fugue.com> in cooperation with Vixie
+ * Enterprises.  To learn more about the Internet Software Consortium,
+ * see ``http://www.vix.com/isc''.  To learn more about Vixie
+ * Enterprises, see ``http://www.vix.com''.
+ *
+ * This client was substantially modified and enhanced by Elliot Poger
+ * for use on Linux while he was working on the MosquitoNet project at
+ * Stanford.
+ *
+ * The current version owes much to Elliot's Linux enhancements, but
+ * was substantially reorganized and partially rewritten by Ted Lemon
+ * so as to use the same networking framework that the Internet Software
+ * Consortium DHCP server uses.   Much system-specific configuration code
+ * was moved into a shell script so that as support for more operating
+ * systems is added, it will not be necessary to port and maintain
+ * system-specific configuration code to these operating systems - instead,
+ * the shell script can invoke the native tools to accomplish the same
+ * purpose.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP4_CLI_VAR_H
+#define DHCP4_CLI_VAR_H
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½
+ */
+
+/* TIMER ã®å®ç¾© */
+
+#define DHCP4C_TIMER_SND_DISC	0
+#define DHCP4C_TIMER_SND_REQ	1
+#define DHCP4C_TIMER_SND_REL	2
+#define DHCP4C_TIMER_RCV_OFFER	3
+#define DHCP4C_TIMER_RCV_ACK	4
+#define DHCP4C_TIMER_RENEW	5
+#define DHCP4C_TIMER_REBIND	6
+#define DHCP4C_TIMER_EXPIRE	7
+#define NUM_DHCP4C_TIMERS	8
+
+#define DHCP4C_TIMER_HZ		1
+
+typedef struct dhcp4_cli_context {
+	T_DHCP4_CLI_MSG	*rcv_lst;	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*val_lst;	/* æ¤è¨¼ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*prf_lst;	/* æ¨å¥¨ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP4_CLI_MSG	*snd_msg;	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½			*/
+	T_DHCP4_CLI_MSG	*off_msg;	/* éç¥ããããªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_DHCP4_CLI_MSG	*act_msg;	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IF_SOFTC	*sc;		/* IF ã®ã½ããã¦ã§ã¢æ
+å ±		*/
+	T_IPV4EP	dst;		/* éä¿¡å
+ã®IPã¢ãã¬ã¹/ãã¼ãçªå·	*/
+	SYSTIM		snd_start;	/* éä¿¡ãéå§ããæé			*/
+	SYSTIM		bind_start;	/* BINDãéå§ããæé			*/
+	SYSTIM		expire;		/* ãªã¼ã¹ã®æå¹æéï¼msï¼		*/
+	SYSTIM		renew;		/* RENEWï¼T1ï¼ã¾ã§ã®æéï¼msï¼	*/
+	SYSTIM		rebind;		/* REBINDï¼T2ï¼ã¾ã§ã®æéï¼msï¼	*/
+	SYSTIM		timers[NUM_DHCP4C_TIMERS];	
+					/* ã¿ã¤ãã¼é
+å			*/
+	RELTIM		interval;	/* éä¿¡éé			*/
+	ER_UINT		error;		/* ã¨ã©ã¼ã»ãã¼ã¿é·		*/
+	ID		cepid;		/* CEP ID			*/
+	uint32_t	xid;		/* ãã©ã³ã¶ã¯ã·ã§ã³ ID		*/
+	uint16_t	flags;		/* åç¨®ãã©ã°			*/
+	uint16_t	max_prefer;	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦	*/
+	uint16_t	secs;		/* seconds since boot began	*/
+	uint8_t		fsm;		/* ç¾å¨ã®ç¶æ
+			*/
+	} T_DHCP4_CLI_CONTEXT;
+
+/* fsmï¼ç¶æ
+é·ç§»ï¼ã®å®ç¾© */
+
+#define DHCP4_FSM_INIT		1
+#define DHCP4_FSM_SELECT	2
+#define DHCP4_FSM_REQUEST	3
+#define DHCP4_FSM_BOUND		4
+#define DHCP4_FSM_RENEW		5
+#define DHCP4_FSM_REBIND	6
+#define DHCP4_FSM_INIT_REBOOT	7
+#define DHCP4_FSM_REBOOT	8
+#define DHCP4_FSM_REL_INFO	11	/* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
+#define DHCP4_FSM_SLEEP		12	/* DHCPv4 ã® RFC2131 ã«ã¯ç¡ãã*/
+
+/* flag ã®å®ç¾© */
+
+#define DHCP4C_FLAG_TMOUT_SND_DISC	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_DISC)
+#define DHCP4C_FLAG_TMOUT_SND_REQ	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REQ)
+#define DHCP4C_FLAG_TMOUT_SND_REL	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_SND_REL)
+#define DHCP4C_FLAG_TMOUT_RCV_OFFER	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_OFFER)
+#define DHCP4C_FLAG_TMOUT_RCV_ACK	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RCV_ACK)
+#define DHCP4C_FLAG_TMOUT_EXPIRE	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_EXPIRE)
+#define DHCP4C_FLAG_TMOUT_RENEW		(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_RENEW)
+#define DHCP4C_FLAG_TMOUT_REBIND	(DHCP4C_FLAG_TMOUT_TIMER|DHCP4C_TIMER_REBIND)
+#define DHCP4C_FLAG_TMOUT_TIMER		UINT_C(0x0010)
+#define DHCP4C_FLAG_TMOUT_TIMER_MASK	UINT_C(0x000f)
+#define DHCP4C_FLAG_TMOUT_MASK		UINT_C(0x001f)
+
+#define DHCP4C_FLAG_RCV_MSG		UINT_C(0x0200)
+#define DHCP4C_FLAG_RENEW		UINT_C(0x0400)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* ã¿ã¤ã ã¢ã¦ãã®è¨ç® */
+
+#define DHCP4C_TMOC(t)		(((t)-1000)+dhcp_rand()%2000)
+
+/* æéæ¯è¼ */
+
+#define TIMEC_GT(a,b)		((int32_t)((a)-(b))>0)
+#define TIMEC_GE(a,b)		((int32_t)((a)-(b))>=0)
+
+/* æéå®æ°ã®å¤æ */
+
+#define SYSTIM2TIMER(t)		(((t)<SYSTIM_HZ/DHCP4C_TIMER_HZ)?(DHCP4C_TIMER_HZ):((t)*DHCP4C_TIMER_HZ)/SYSTIM_HZ)
+#define SYSTIM2SEC(t)		(((t)<SYSTIM_HZ)?1:((t)/SYSTIM_HZ))
+#define SEC2TIMER(t)		((t)*DHCP4C_TIMER_HZ)
+#define SEC2SYSTIM(t)		((t)*SYSTIM_HZ)
+
+#endif	/* of #ifndef DHCP4_CLI_VAR_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6.h	(revision 317)
@@ -0,0 +1,345 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_H
+#define DHCP6_H
+
+/*
+ *  DHCPv6 ã«é¢ããå®ç¾©
+ *
+ *    RFC3315
+ */
+
+/*
+ *  DHCPv6 ã¡ãã»ã¼ã¸ã®å®æ°ã®å®ç¾©
+ */
+
+#define DHCP6_XID_LEN		3
+#define DHCP6_OPTION_LEN	(512-(1+DHCP6_XID_LEN))
+
+/*
+ *  DHCPv6 ã¡ãã»ã¼ã¸
+ */
+
+typedef struct dhcp6_msg_hdr {
+	uint8_t	type;				/* message type		*/
+	uint8_t	xid[DHCP6_XID_LEN];		/* transaction ID	*/
+	} T_DHCP6_MSG_HDR;
+
+typedef struct dhcp6_msg {
+	T_DHCP6_MSG_HDR	hdr;
+	uint8_t		options[DHCP6_OPTION_LEN];	/* options	*/
+	} T_DHCP6_MSG;
+
+/* message type ã®å®ç¾© */
+
+#define DHCP6_SOLICIT		UINT_C(1)
+#define DHCP6_ADVERTISE		UINT_C(2)
+#define DHCP6_REQUEST		UINT_C(3)
+#define DHCP6_CONFIRM		UINT_C(4)
+#define DHCP6_RENEW		UINT_C(5)
+#define DHCP6_REBIND		UINT_C(6)
+#define DHCP6_REPLY		UINT_C(7)
+#define DHCP6_RELEASE		UINT_C(8)
+#define DHCP6_DECLINE		UINT_C(9)
+#define DHCP6_RECONFIGURE	UINT_C(10)
+#define DHCP6_INFO_REQ		UINT_C(11)
+#define DHCP6_RELAY_FORW	UINT_C(12)
+#define DHCP6_RELAY_REPL	UINT_C(13)
+
+/*
+ *  DHCPv6 ãªãã·ã§ã³
+ */
+
+#define DHCP6_OPT_CLIENTID	UINT_C(1)
+#define DHCP6_OPT_SERVERID	UINT_C(2)
+#define DHCP6_OPT_IA_NA		UINT_C(3)
+#define DHCP6_OPT_IA_TA		UINT_C(4)
+#define DHCP6_OPT_IAADDR	UINT_C(5)
+#define DHCP6_OPT_ORO		UINT_C(6)
+#define DHCP6_OPT_PREFERENCE	UINT_C(7)
+#define DHCP6_OPT_UNICAST	UINT_C(12)
+#define DHCP6_OPT_STATUS_CODE	UINT_C(13)
+#define DHCP6_OPT_RAPID_COMMIT	UINT_C(14)
+#define DHCP6_OPT_NAME_SERVERS	UINT_C(23)
+#define DHCP6_OPT_DOMAIN_SEARCH	UINT_C(24)
+#define DHCP6_OPT_IA_PD		UINT_C(25)
+
+/* hardware address type ã®å®ç¾© */
+
+#define DHCP6_HWA_TYPE_ETHER	UINT_C(1)
+#define DHCP6_HWA_TYPE_IEEE802	UINT_C(6)
+
+/* STATUS CODE ã®å®ç¾© */
+
+#define DHCP6_STAT_SUCCESS	UINT_C(0)
+#define DHCP6_STAT_UNSPECIFID	UINT_C(1)
+#define DHCP6_STAT_NO_AVAIL	UINT_C(2)
+#define DHCP6_STAT_NO_BINDING	UINT_C(3)
+#define DHCP6_STAT_NO_ONLINK	UINT_C(4)
+#define DHCP6_STAT_USE_MCAST	UINT_C(5)
+
+/* æéå®æ°[s]ã®å®ç¾© */
+
+#define DHCP6_MAX_TIME		UINT_C(0xffffffff)
+
+/*
+ *  ãªãã·ã§ã³ã®ãããé¨ã®å®ç¾©
+ */
+
+/* ãªãã·ã§ã³ã®å
+±éé¨ */
+
+typedef struct dhcp6_option {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPTION;
+
+/* ãªãã·ã§ã³ã®å
+±éé¨ */
+
+/* CLIENTID ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_clientid {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_CLIENTID;
+
+/* SERVERID ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_serverid {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_SERVERID;
+
+/* IA_NA/IA_PD ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_ia_na_pd {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint32_t	iaid;		/* IA ID		*/
+	uint32_t	renew;		/* renew  timeout (T1)	*/
+	uint32_t	rebind;		/* rebind timeout (T2)	*/
+	} T_DHCP6_OPT_IA_NA_PD;
+
+/* IA_TA ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_ia_ta {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint32_t	iaid;		/* IA ID		*/
+	} T_DHCP6_OPT_IA_TA;
+
+/* IAADDR ãªãã·ã§ã³ */
+
+#ifdef T_IN6_ADDR_DEFINED
+
+typedef struct dhcp6_opt_iaaddr {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addr;		/* IPv6 address		*/
+	uint32_t	prefer;		/* preferred lifetime	*/
+	uint32_t	valid;		/* valid     lifetime	*/
+	} T_DHCP6_OPT_IAADDR;
+
+#endif	/* of #ifdef T_IN6_ADDR_DEFINED */
+
+/* ORO ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_oro {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	} T_DHCP6_OPT_ORO;
+
+/* PREFERENCE ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_preference {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint8_t		prefer;		/* preference value	*/
+	} T_DHCP6_OPT_PREFERENCE;
+
+/* UNICAST ãªãã·ã§ã³ */
+
+#ifdef T_IN6_ADDR_DEFINED
+
+typedef struct dhcp6_opt_unicast {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addr;		/* IPv6 address for server*/
+	} T_DHCP6_OPT_UNICAST;
+
+#endif	/* of #ifdef T_IN6_ADDR_DEFINED */
+
+/* STATUS CODE ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_status_code {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint16_t	status;		/* status code		*/
+	} T_DHCP6_OPT_STATUS_CODE;
+
+/* NAME SERVERS ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_name_servers {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	T_IN6_ADDR	addrs[1];	/* IPv6 address		*/
+	} T_DHCP6_OPT_NAME_SERVERS;
+
+/* DOMAIN SEARCH ãªãã·ã§ã³ */
+
+typedef struct dhcp6_opt_domain_search {
+	uint16_t	code;		/* option code		*/
+	uint16_t	len;		/* option length	*/
+	uint8_t		name[1];	/* domain search	*/
+	} T_DHCP6_OPT_DOMAIN_SEARCH;
+
+/*
+ *  DHCPv6 ã¿ã¤ãã³ã°å®æ°ãRFC3315 5.5 åç
+§ã
+ *  ãã®ä»ã®ã¿ã¤ãã³ã°å®æ°ã¯ dhcp6_cli.h åç
+§
+ */
+
+#ifdef SYSTIM_HZ
+
+#define TMO_SOL_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_SOL_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_SOL_MAX_RT		(120*SYSTIM_HZ)	/* 120[s] 	*/
+#define TMO_REQ_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_REQ_MAX_RT		(30*SYSTIM_HZ)	/*  30[s] 	*/
+#define TMO_REQ_MAX_RC		10		/* åéä¿¡åæ°	*/
+#define TMO_CNF_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_CNF_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_CNF_MAX_RT		(4*SYSTIM_HZ)	/*   4[s] 	*/
+#define TMO_CNF_MAX_RD		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REN_TIMEOUT		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REN_MAX_RT		(600*SYSTIM_HZ)	/* 600[s] 	*/
+#define TMO_REB_TIMEOUT		(10*SYSTIM_HZ)	/*  10[s] 	*/
+#define TMO_REB_MAX_RT		(600*SYSTIM_HZ)	/* 600[s] 	*/
+#define TMO_INF_MAX_DELAY	(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_INF_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_INF_MAX_RT		(120*SYSTIM_HZ)	/* 120[s] 	*/
+#define TMO_REL_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_REL_MAX_RC		5		/* åéä¿¡åæ°	*/
+#define TMO_DEC_TIMEOUT		(1*SYSTIM_HZ)	/*   1[s] 	*/
+#define TMO_DEC_MAX_RC		5		/* åéä¿¡åæ°	*/
+#define TMO_REC_TIMEOUT		(2*SYSTIM_HZ)	/*   2[s] 	*/
+#define TMO_REC_MAX_RC		8		/* åéä¿¡åæ°	*/
+
+#endif	/* of #ifdef SYSTIM_HZ */
+
+/*
+ *  DUID -- DHCP Unique ID
+ */
+
+/* DUID_LLT æ§é ä½ */
+
+typedef struct dhcp6_duid_llt_hdr {
+	uint16_t	code;		/* DUID code		*/
+	uint16_t	type;		/* hardware type	*/
+	uint32_t	time;		/* time			*/
+	} T_DHCP6_DUID_LLT_HDR;
+
+/* DUID_LL æ§é ä½ */
+
+typedef struct dhcp6_duid_ll_hdr {
+	uint16_t	code;		/* DUID code		*/
+	uint16_t	type;		/* hardware type	*/
+	} T_DHCP6_DUID_LL_HDR;
+
+/* DUID ã¿ã¤ããRFC3315 9åç
+§ã*/
+
+#define DUID_LLT		1
+#define DUID_EN			2
+#define DUID_LL			3
+
+/*
+ *  DUID æéã®èª¿æ´
+ *  DUID æéã®éå§ã¯ 2001/1/1
+ */
+
+#define DUID_TIME_EPOCH		0
+
+/* ãªã¬ã¼è»¢éã®æå¤§ãããæ° */
+
+#define HOP_COUNT_LIMIT		32
+
+/*
+ *  IPv6 ã¢ãã¬ã¹
+ */
+
+#define IPV6_ADDR_ALL_DHCP_RELAY_SERVERS_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x02) }}}
+
+#define IPV6_ADDR_ALL_DHCP_SERVERS_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x05), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x01), UINT_C(0x00), UINT_C(0x03) }}}
+
+/*
+ *  UDP ãã¼ãçªå·
+ */
+
+#ifndef DHCP6_SRV_CFG_PORTNO
+#define DHCP6_SRV_CFG_PORTNO	547	/* server	*/
+#endif
+
+#ifndef DHCP6_CLI_CFG_PORTNO
+#define DHCP6_CLI_CFG_PORTNO	546	/* client	*/
+#endif
+
+#endif	/* of #ifndef DHCP6_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.c	(revision 317)
@@ -0,0 +1,3338 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+
+#include <net/if_var.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/dhcp6_cli.h>
+#include <netapp/dhcp6_cli_var.h>
+#include <netapp/resolver.h>
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/*
+ *  DHCP åä½ã¢ã¼ã
+ *
+ *    #define DHCP6_CLI_CFG_MODE ã§æå®ããã
+ *
+ */
+
+#if !defined(DHCP6_CLI_CFG_MODE)
+#define DHCP6_CLI_CFG_MODE	DHCP6_CLI_CFG_MODE_DEFAULT
+#endif
+
+/*
+ *  å¤æ°
+ */
+
+static const T_IN6_ADDR in6_addr_all_DHCP_relay_servers =
+	IPV6_ADDR_ALL_DHCP_RELAY_SERVERS_INIT;			/* ãªã¬ã¼ã»ãµã¼ãã® IPv6 ã¢ãã¬ã¹	*/
+static T_DHCP6_CLI_CONTEXT	context;			/* ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ã	*/
+
+#ifdef DHCP6_CLI_CFG_REQUIRED_OLIST
+static uint8_t	required_plist[] = DHCP6_CLI_CFG_REQUIRED_OLIST;	/* å¿
+é ãªãã·ã§ã³ãªã¹ã		*/
+#endif
+
+#ifdef DHCP6_CLI_CFG_REQUEST_OLIST
+static uint8_t	request_plist[] = DHCP6_CLI_CFG_REQUEST_OLIST;		/* è¦æ±ãªãã·ã§ã³ãªã¹ã		*/
+#endif
+
+/*
+ *  dhcp6_rand -- RFC3315 ã«è¦å®ãããä¹±æ°ãçºçããã
+ */
+
+static int32_t
+dhcp6_rand (SYSTIM base)
+{
+	SYSTIM 		range, split;
+	uint32_t	rval;
+
+	split = (base - 1) / 10;
+	if (split == 0)
+		return 0;
+	range = (split * 2) + 10;
+	rval = netapp_rand() % range - split;
+
+	return rval;
+	}
+
+/*
+ *  init_duid -- ã¯ã©ã¤ã¢ã³ãã® DUID ãè¨­å®ããã
+ */
+
+static void
+init_duid (T_DHCP6_CLI_CONTEXT *ct)
+{
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	/* åä½ã¢ã¼ãã« STATELESS ãæå®ãããæã¯ LL å½¢å¼ã«ããã*/
+
+	T_DHCP6_DUID_LL_HDR	*ll;
+
+	ll = (T_DHCP6_DUID_LL_HDR*)&ct->duid[0];
+	HOST2MSG16(ll->code, DUID_LL);
+	HOST2MSG16(ll->type, DHCP6_HWA_TYPE_ETHER);
+	memcpy(&ct->duid[sizeof(*ll)], &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr));
+	ct->duid_len = sizeof(*ll) + sizeof(ct->sc->ifaddr.lladdr);	/* DIUD é·ãè¨é²ããã*/
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	/*
+	 *    åä½ã¢ã¼ãã« DHCP6_CLI_CFG_STATEFULL ãæå®ãããæã¯ LLT å½¢å¼ã«ããã
+	 *    time ã¡ã³ãã¼ã«ã¯ç¾å¨ã®æé[s]ãè¨­å®ããã
+	 *    æ³¨æ: æ«å®çã« get_tim() ã®å¤ãä½¿ãããè¦æ¤è¨
+	 */
+
+	T_DHCP6_DUID_LLT_HDR	*llt;
+	SYSTIM			time;
+
+	get_tim(&time);
+	time = SYSTIM2SEC(time) - DUID_TIME_EPOCH;
+	llt = (T_DHCP6_DUID_LLT_HDR*)&ct->duid[0];
+	HOST2MSG16(llt->code, DUID_LLT);
+	HOST2MSG16(llt->type, DHCP6_HWA_TYPE_ETHER);
+	HOST2MSG32(llt->time, time);
+	memcpy(&ct->duid[sizeof(*llt)], &ct->sc->ifaddr.lladdr, sizeof(ct->sc->ifaddr.lladdr));
+	ct->duid_len = sizeof(*llt) + sizeof(ct->sc->ifaddr.lladdr);	/* DIUD é·ãè¨é²ããã*/
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	}
+
+/*
+ *  cancel_all_timers -- å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã
+ */
+
+static void
+cancel_all_timers (T_DHCP6_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	for (ix = NUM_DHCP6C_TIMERS; ix -- > 0; )
+		ct->timers[ix] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+	}
+
+/*
+ *  dhcpc_timer -- TIMER ç®¡ç
+ */
+
+static void
+dhcpc_timer (T_DHCP6_CLI_CONTEXT *ct)
+{
+	int ix;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	for (ix = NUM_DHCP6C_TIMERS; ix -- > 0; ) {
+		if (ct->timers[ix] != 0) {
+			ct->timers[ix] --;
+			if (ct->timers[ix] == 0) {
+				ct->flags = (ct->flags & ~DHCP6C_FLAG_TMOUT_MASK) | DHCP6C_FLAG_TMOUT_TIMER | ix;
+				syscall(sig_sem(SEM_DHCP6_CLI_READY));
+				}
+			}
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããã*/
+	timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP6C_TIMER_HZ);
+	}
+
+/*
+ *  find_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° len ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ *          å¼æ° len ã«ã¯ãªãã·ã§ã³å
+¨ä½ã®ãµã¤ãºãæå®ãããã¨ã
+ */
+
+static uint8_t *
+find_option (uint8_t *msg, uint_t msg_len, uint_t code, uint_t len)
+{
+	T_DHCP6_OPTION	*hdr;
+	uint8_t		*last;
+
+	last = msg + msg_len;
+	while (msg < last) {
+		hdr = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(hdr->code) == code && (len == 0 || (MSG2HOST16(hdr->len) + sizeof(*hdr)) == len))
+			return msg;
+		else
+			msg += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	return NULL;
+	}
+
+/*
+ *  find_msg_option -- æå®ãããªãã·ã§ã³ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: å¼æ° len ã 0 ã®æã¯ãªãã·ã§ã³ãµã¤ãºãæ¤è¨¼ããªãã
+ *          å¼æ° len ã«ã¯ãªãã·ã§ã³å
+¨ä½ã®ãµã¤ãºãæå®ãããã¨ã
+ */
+
+static uint8_t *
+find_msg_option (T_DHCP6_CLI_MSG *cli_msg, uint_t code, uint_t len)
+{
+	return find_option(cli_msg->msg.options, cli_msg->len, code, len);
+	}
+
+/*
+ *  is_equal_sid -- ã¡ãã»ã¼ã¸å
+ã® SERVER ID ãæ¯è¼ããã
+ */
+
+static bool_t
+is_equal_sid (T_DHCP6_CLI_MSG *msg1, T_DHCP6_CLI_MSG *msg2)
+{
+	T_DHCP6_OPT_SERVERID	*sid1;
+	T_DHCP6_OPT_SERVERID	*sid2;
+
+	if ((sid1 = (T_DHCP6_OPT_SERVERID*)find_msg_option(msg1, DHCP6_OPT_SERVERID, 0)) == NULL)
+		return false;
+	if ((sid2 = (T_DHCP6_OPT_SERVERID*)find_msg_option(msg2, DHCP6_OPT_SERVERID, 0)) == NULL)
+		return false;
+	if (MSG2HOST16(sid1->len) != MSG2HOST16(sid2->len))
+		return false;
+
+	return memcmp((uint8_t*)sid1 + sizeof(*sid1),
+	              (uint8_t*)sid2 + sizeof(*sid2), MSG2HOST16(sid1->len)) == 0;
+	}
+
+/*
+ *  validate_iaaddrs -- ã¢ãã¬ã¹æ
+å ±ï¼IAADDRï¼ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_iaaddrs (uint8_t *opt, uint_t len)
+{
+	T_DHCP6_OPT_IAADDR	*iaa;
+
+	/* ãªãã·ã§ã³ã IAADDR ã§ãããã¨ãæ¤è¨¼ããã*/
+	iaa = (T_DHCP6_OPT_IAADDR*)opt;
+	if (MSG2HOST16(iaa->code) != DHCP6_OPT_IAADDR)
+		return E_PAR;
+
+	while (len > 0) {
+		/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+		if (len < sizeof(*iaa))
+			return E_PAR;
+
+		/* ãªãã·ã§ã³é·ã T_DHCP6_OPT_IAADDR ã®ãµã¤ãºã¨ä¸è´ãã¦ããªããã°ã¨ã©ã¼ */
+		iaa = (T_DHCP6_OPT_IAADDR*)opt;
+		if ((MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) < (sizeof(*iaa) - sizeof(T_DHCP6_OPTION)))
+			return E_PAR;
+
+		/*
+		 *  perferred-lifetime ã¨ valid-lifetime ã®å¤ãçç¾ãã¦ããã¨ãã¯ã¨ã©ã¼
+		 *  ãRFC3315 (22.6) åç
+§ã
+		 */
+		if (MSG2HOST32(iaa->prefer) > MSG2HOST32(iaa->valid))
+			return E_PAR;
+
+		len -= (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(T_DHCP6_OPTION);
+		opt += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(T_DHCP6_OPTION);
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  validate_ia_na_pd -- IA_NA/IA_PD ãªãã·ã§ã³ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_ia_na_pd (T_DHCP6_CLI_MSG *msg, uint16_t code)
+{
+	T_DHCP6_OPT_IA_NA_PD	*na;
+	uint8_t			*opt;
+
+	/* IA_NA/IA_PD ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_msg_option(msg, code, 0)) == NULL)
+		return E_OK;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	na = (T_DHCP6_OPT_IA_NA_PD*)opt;
+	if (!(msg->len >= (opt - (uint8_t*)&msg->msg) + sizeof(*na) &&
+	                         (MSG2HOST16(na->len) & ~DHCP6C_IAA_FLAG_MASK) >= sizeof(*na)))
+		return E_PAR;
+
+	/*
+	 *  T1 ã¨ T2 ã®å¤ãçç¾ãã¦ããæãã¾ãã¯ã¢ãã¬ã¹æ
+å ±ãèª¤ã£ã¦ããæã¯ã¨ã©ã¼
+	 *  ãRFC3315 (22.4) åç
+§ã
+	 */
+	if (MSG2HOST32(na->renew) > 0 && MSG2HOST32(na->rebind) > 0 &&
+	    MSG2HOST32(na->renew) >      MSG2HOST32(na->rebind))
+		return E_PAR;
+
+	if (validate_iaaddrs(opt + sizeof(*na), (MSG2HOST16(na->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*na) - sizeof(T_DHCP6_OPTION))) != E_OK)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  validate_ia_ta -- IA_TA ãªãã·ã§ã³ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_ia_ta (T_DHCP6_CLI_MSG *msg)
+{
+	T_DHCP6_OPT_IA_TA	*ta;
+	uint8_t			*opt;
+
+	/* IA_TA ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_IA_TA, 0)) == NULL)
+		return E_OK;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	ta = (T_DHCP6_OPT_IA_TA	*)opt;
+	if (!(msg->len >= (opt - (uint8_t*)&msg->msg) + sizeof(*ta) &&
+	                         (MSG2HOST16(ta->len) & ~DHCP6C_IAA_FLAG_MASK) >= sizeof(*ta)))
+		return E_PAR;
+
+	/*
+	 *  ã¢ãã¬ã¹æ
+å ±ãèª¤ã£ã¦ããæã¯ã¨ã©ã¼ãRFC3315 (22.4) åç
+§ã
+	 */
+	if (validate_iaaddrs(opt + sizeof(*ta), (MSG2HOST16(ta->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*ta) - sizeof(T_DHCP6_OPTION))) != E_OK)
+		return E_PAR;
+
+	return E_OK;
+	}
+/*
+ *  classify_reply -- å¿ç­ã¡ãã»ã¼ã¸ãåé¡ããã
+ */
+
+static ER
+classify_reply (T_DHCP6_CLI_MSG *msg)
+{
+	ER	error;
+
+	/* IA_NA ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_na_pd(msg, DHCP6_OPT_IA_NA)) != E_OK)
+		return error;
+
+	/* IA_TA ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_ta(msg)) != E_OK)
+		return error;
+
+	/* IA_PD ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	if ((error = validate_ia_na_pd(msg, DHCP6_OPT_IA_PD)) != E_OK)
+		return error;
+
+	/* ãµã¼ã DUID ããããã¨ãæ¤è¨¼ããã*/
+	if (find_msg_option(msg, DHCP6_OPT_SERVERID, 0) == NULL)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  validate_reply -- å¿ç­ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_reply (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *msg)
+{
+	T_DHCP6_OPT_CLIENTID	*cid;
+	uint8_t			*opt;
+
+	/* ãµã¼ã DUID ããããã¨ãæ¤è¨¼ããã*/
+	if (find_msg_option(msg, DHCP6_OPT_SERVERID, 0) == NULL)
+		return E_PAR;
+
+	/* ã¯ã©ã¤ã¢ã³ã DUID ããããèªåã®ã¯ã©ã¤ã¢ã³ã DUID ã¨åããã¨ãæ¤è¨¼ããã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_CLIENTID, 0)) == NULL)
+		return E_PAR;
+
+	cid = (T_DHCP6_OPT_CLIENTID*)opt;
+	if (MSG2HOST16(cid->len) != ct->duid_len)
+		return E_PAR;
+	if (memcmp(opt + sizeof(*cid), ct->duid, ct->duid_len) != 0)
+		return E_PAR;
+
+	return E_OK;
+	}
+
+/*
+ *  get_status_code -- STATUS ãªãã·ã§ã³ã®çµæã³ã¼ããç²å¾ããã
+ */
+
+static ER_UINT
+get_status_code (uint8_t *msg, uint_t msg_len)
+{
+	T_DHCP6_OPT_STATUS_CODE	*status;
+	uint8_t			*opt;
+
+	/* STATUS ãªãã·ã§ã³ãç¡ããã°æ¤è¨¼ããªãã*/
+	if ((opt = find_option(msg, msg_len, DHCP6_OPT_STATUS_CODE, 0)) == NULL)
+		return DHCP6_STAT_SUCCESS;
+
+	/* ãªãã·ã§ã³é·ãæ¤è¨¼ããã*/
+	status = (T_DHCP6_OPT_STATUS_CODE*)opt;
+	if (msg_len < sizeof(*status))
+		return E_PAR;
+	if (MSG2HOST16(status->len) < sizeof(*status) - sizeof(T_DHCP6_OPTION))
+		return E_PAR;
+
+	return MSG2HOST16(status->status);
+	}
+
+/*
+ *  get_msg_status_code -- STATUS ãªãã·ã§ã³ã®çµæã³ã¼ããç²å¾ããã
+ */
+
+static ER_UINT
+get_msg_status_code (T_DHCP6_CLI_MSG *cli_msg, uint_t *code)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IA_TA	*ta;
+	ER_UINT			status;
+	uint8_t			*msg, *last;
+
+	*code = 0;
+	cli_msg->status = DHCP6_CLI_STAT_UNDEFINED;
+	if ((status = get_status_code(cli_msg->msg.options, cli_msg->len)) == DHCP6_STAT_SUCCESS) {
+
+		msg = cli_msg->msg.options;
+		last = msg + (cli_msg->len - sizeof(T_DHCP6_MSG_HDR));
+		while (msg < last) {
+
+			opt = (T_DHCP6_OPTION*)msg;
+			status = get_status_code(msg + sizeof(*opt), MSG2HOST16(opt->len));
+			if (status != DHCP6_STAT_SUCCESS) {
+				*code = MSG2HOST16(opt->code);
+				break;
+				}
+
+			if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+				ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+				status = get_status_code(msg + sizeof(*opt), MSG2HOST16(ia->len));
+				if (status != DHCP6_STAT_SUCCESS) {
+					*code = MSG2HOST16(((T_DHCP6_OPTION*)((uint8_t*)opt + sizeof(*opt)))->code);
+					break;
+					}
+				}
+
+			else if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_TA) {
+
+				ta = (T_DHCP6_OPT_IA_TA*)opt;
+				status = get_status_code(msg + sizeof(*opt), MSG2HOST16(ta->len));
+				if (status != DHCP6_STAT_SUCCESS) {
+					*code = MSG2HOST16(((T_DHCP6_OPTION*)((uint8_t*)opt + sizeof(*opt)))->code);
+					break;
+					}
+				}
+
+			msg += MSG2HOST16(opt->len) + sizeof(*opt);
+			}
+		cli_msg->status = status;
+		}
+	
+	return status;
+	}
+
+/*
+ *  validate_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã
+ */
+
+static ER
+validate_rcv_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *msg)
+{
+	ER	error;
+	uint_t	code;
+
+	/* ã¡ãã»ã¼ã¸ã®ã¿ã¤ããä¸è´ãã¦ãããã¨ãæ¤è¨¼ããã*/
+	switch (ct->fsm) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6_FSM_SELECT:
+		if (msg->msg.hdr.type != DHCP6_REPLY)
+			return E_PAR;
+		break;
+	case DHCP6_FSM_INFORMED:
+		return E_PAR;
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6_FSM_INIT:
+		if (msg->msg.hdr.type != DHCP6_ADVERTISE)
+			return E_PAR;
+		break;
+
+	case DHCP6_FSM_SELECT:
+	case DHCP6_FSM_RENEW:
+	case DHCP6_FSM_REBIND:
+	case DHCP6_FSM_REL_INFO:
+		if (msg->msg.hdr.type != DHCP6_REPLY)
+			return E_PAR;
+		break;
+
+	case DHCP6_FSM_BOUND:
+		return E_PAR;
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] error, unknown state: %d.", ct->fsm);
+		return E_PAR;
+		break;
+		}
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if ((error = validate_reply(ct, msg)) != E_OK)
+		return error;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ãåé¡ããã*/
+	if ((error = classify_reply(msg)) != E_OK)
+		return error;
+
+	/* åä¿¡ããã¡ãã»ã¼ã¸å
+ã® STATUS CODE ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	error = get_msg_status_code(msg, &code);
+	if (error != E_OK)
+		return error > 0 ? E_PAR : error;
+
+	return E_OK;
+	}
+
+/*
+ *  eval_ia_prefer -- IA_NA/IA_TA/IA_PD ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_ia_prefer (T_DHCP6_CLI_MSG *cli_msg)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IA_TA	*ta;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (cli_msg == NULL)
+		return;
+
+	msg = cli_msg->msg.options;
+	last = msg + (cli_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+		opt = (T_DHCP6_OPTION*)msg;
+
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			aoff  = sizeof(*ia);
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			while (aoff < asize) {
+				cli_msg->prefer += DHCP6_CLI_CFG_PREFER_IAADDR;
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+			cli_msg->prefer = (cli_msg->prefer + DHCP6_CLI_CFG_PREFER_IA) | DHCP6_ClI_MSG_PREFER_ADDR;
+			}
+
+		else if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_TA) {
+
+			ta = (T_DHCP6_OPT_IA_TA*)opt;
+			aoff  = sizeof(*ta);
+			asize = MSG2HOST16(ta->len) + sizeof(*opt);
+			while (aoff < asize) {
+				cli_msg->prefer += DHCP6_CLI_CFG_PREFER_IAADDR;
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+			cli_msg->prefer = (cli_msg->prefer + DHCP6_CLI_CFG_PREFER_IA) | DHCP6_ClI_MSG_PREFER_ADDR;
+			}
+
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	}
+
+/*
+ *  eval_prefer -- åä¿¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã
+ */
+
+static void
+eval_prefer (T_DHCP6_CLI_MSG *msg)
+{
+	uint8_t			*opt;
+	int			ix;
+
+	/* ç¡å¹ã®å ´åã¯çµäºããã*/
+	if (msg == NULL)
+		return;
+
+	/* PREFERENCE ãªãã·ã§ã³ãè©ä¾¡ããã*/
+	if ((opt = find_msg_option(msg, DHCP6_OPT_PREFERENCE, sizeof(T_DHCP6_OPT_PREFERENCE))) != NULL)
+		msg->prefer = MSG2HOST16(((T_DHCP6_OPT_PREFERENCE*)opt)->prefer) | DHCP6_ClI_MSG_PREFER_OPTION;
+	else
+		msg->prefer = 1;
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		if (find_msg_option(msg, required_plist[ix], 0) == NULL)
+			msg->prefer = 0;
+		}
+	msg->prefer |= DHCP6_ClI_MSG_PREFER_REQUIRED;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãæ¤è¨¼ããã*/
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		if (find_msg_option(msg, request_plist[ix], 0) != NULL)
+			msg->prefer = (msg->prefer + 1) | DHCP6_ClI_MSG_PREFER_REQUEST;
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+	}
+
+/*
+ *  eval_rcv_msg -- åä¿¡ã¡ãã»ã¼ã¸ãè©ä¾¡ããã
+ */
+
+static ER
+eval_rcv_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*evl, *msg;
+	SYSTIM		time;
+
+	/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->val_lst == NULL) {
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* æ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãããè©ä¾¡ã¡ãã»ã¼ã¸ãåãåºãã*/
+	evl         = ct->val_lst;
+	ct->val_lst = ct->val_lst->next;
+	evl->next   = NULL;
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	/* åä¿¡æéãè¨­å®ããã*/
+	get_tim(&time);
+	evl->rcv_time = time;
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ãæ¤è¨¼ããã*/
+	if (validate_rcv_msg(ct, evl) != E_OK) {
+
+		/* ã¨ã©ã¼ãçºçããè©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		goto rcv_ret;
+		}
+
+	/* REL_INFO ç¶æ
+ã®æã®å¦ç */
+	if (ct->fsm == DHCP6_FSM_REL_INFO) {
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		if (evl->status == DHCP6_STAT_SUCCESS) {
+			/*
+			 *  STATUS CODE ã DHCP6_STAT_SUCCESS ãªãã
+			 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«è¨­å®ãã¦çµäºããã
+			 */
+			evl->next   = ct->prf_lst;
+			ct->prf_lst = evl;
+			}
+		else {
+			/* è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã¦çµäºããã*/
+			evl->next   = ct->rcv_lst;
+			ct->rcv_lst = evl;
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãè©ä¾¡ããã*/
+	eval_prefer(evl);
+	eval_ia_prefer(evl);
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããç©ºãªãè©ä¾¡ã¡ãã»ã¼ã¸ãç§»ãã¦çµäºããã*/
+	if (ct->prf_lst == NULL) {
+		ct->max_prefer = evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	/* è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã¨æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ãæ¯è¼ããã*/
+	if ((evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) > ct->max_prefer) {
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããé«ããã°ã
+		 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		ct->max_prefer = evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK;
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		if (ct->rcv_lst == NULL)
+			ct->rcv_lst = ct->prf_lst;
+		else {
+			for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+				;
+			msg->next = ct->prf_lst;
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+
+	else if ((evl->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) == ct->max_prefer) {
+		for (msg = ct->prf_lst; msg != NULL; msg = msg->next) {
+			if (is_equal_sid(evl, msg)) {
+
+				/*
+				 *  æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«åã DHCP6_OPT_SERVERID ã®ã¡ãã»ã¼ã¸ãããã°ã
+				 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+				 */
+				goto rcv_ret;
+				}
+			}
+
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã
+		 */
+		evl->next   = ct->prf_lst;
+		ct->prf_lst = evl;
+		return E_OK;
+		}
+	
+	/*else */
+		/* 
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ãæ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®æå¤§æ¨å¥¨åº¦ããä½ããã°ã
+		 *  è©ä¾¡ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+		 */
+
+rcv_ret:
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	evl->next   = ct->rcv_lst;
+	ct->rcv_lst = evl;
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	return E_OK;
+	}
+
+/*
+ *  select_msg -- æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static T_DHCP6_CLI_MSG*
+select_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg, *select;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->prf_lst == NULL) {
+		/* ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ä¸­æ­¢ããã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+	select = ct->prf_lst;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	if ((select->prefer & DHCP6_ClI_MSG_PREFER_REQUIRED) == 0) {
+		/* å¿
+é ãªãã·ã§ã³ãç¡ããã°é¸æããªãã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	if (((select->prefer & DHCP6_ClI_MSG_PREFER_REQUIRED) == 0) ||
+	    ((select->prefer & DHCP6_ClI_MSG_PREFER_ADDR)     == 0)) {
+		/* å¿
+é ãªãã·ã§ã³ã¨ã¢ãã¬ã¹ãç¡ããã°é¸æããªãã*/
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return NULL;
+		}
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	/* æ¨å¥¨ã¡ãã»ã¼ã¸ãªã¹ãã®å
+é ­ã®ã¡ãã»ã¼ã¸ãé¸æããã*/
+	ct->prf_lst  = ct->prf_lst->next;
+	select->next = NULL;
+
+	/* é¸æãããªãã£ãæ¤è¨¼ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+	if (ct->rcv_lst == NULL)
+		ct->rcv_lst = ct->prf_lst;
+	else {
+		for (msg = ct->rcv_lst; msg->next != NULL; msg = msg->next)
+			;
+		msg->next = ct->prf_lst;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	return select;
+	}
+
+/*
+ *  advance_retrans -- åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã
+ */
+
+static void
+advance_retrans (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/*
+	 *  åéä¿¡ééï¼RTï¼ãæ´æ°ããã
+	 *  åéä¿¡æ¯ã«ç´ 2åãããã
+	 *  æå¤§éä¿¡ééï¼MRTï¼ãè¶
+ããªãããã«ããã
+	 */
+	ct->RT += ct->RT + dhcp6_rand(ct->RT);
+	if ((ct->MRT != 0) && (ct->RT > ct->MRT))
+		ct->RT = ct->MRT + dhcp6_rand(ct->MRT);
+
+	/* åéä¿¡åæ°ãæ´æ°ããã*/
+	ct->txcount ++;
+	}
+
+/*
+ *  init_retrans -- åéä¿¡åæ°ããã©ã³ã¶ã¯ã·ã§ã³ IDããã®ä»ãè¨­å®ããã
+ */
+
+static void
+init_retrans (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* éä¿¡åæ°ããªã»ããããã*/
+	ct->txcount = 0;
+
+	/* åéä¿¡ééãè¨­å®ããã*/
+	ct->RT = ct->IRT + dhcp6_rand(ct->IRT);
+
+	/* ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	ct->xid = netapp_rand() % 0x00ffffff;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦ããªã»ããããã*/
+	ct->max_prefer = 0;
+	}
+
+/*
+ *  setup_msg_header -- ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã
+ */
+
+static uint8_t *
+setup_msg_header (T_DHCP6_CLI_CONTEXT *ct, uint_t type)
+{
+	memset((void*)&ct->snd_msg->msg, sizeof(ct->snd_msg->msg), 0);
+	ct->snd_msg->len = sizeof(ct->snd_msg->msg);
+
+	/* ãããé¨ãè¨­å®ããã*/
+	ct->snd_msg->msg.hdr.type   = type;
+	ct->snd_msg->msg.hdr.xid[0] = (ct->xid >> 16) & 0xff;
+	ct->snd_msg->msg.hdr.xid[1] = (ct->xid >>  8) & 0xff;
+	ct->snd_msg->msg.hdr.xid[2] =  ct->xid        & 0xff;
+
+	return (uint8_t*)&ct->snd_msg->msg + sizeof(ct->snd_msg->msg.hdr);
+	}
+
+/*
+ *  common_options -- æ¨æºãªãã·ã§ã³ãè¿½å ããã
+ */
+
+static uint8_t *
+common_options (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t type, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_CLIENTID	*cid;
+	T_DHCP6_OPT_SERVERID	*sid;
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+	T_DHCP6_OPT_ORO		*oro;
+#endif
+
+	uint8_t			*opt;
+	uint_t			opt_len;
+	int_t			ix;
+
+#if defined(DHCP6_CLI_CFG_RAPID_COMMIT)
+
+	/* Rapid-commit ã®æå® */
+	if (type == DHCP6_SOLICIT)
+		;
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_RAPID_COMMIT) */
+
+	/* ã¯ã©ã¤ã¢ã³ã DUID ãè¿½å ããã*/
+	cid = (T_DHCP6_OPT_CLIENTID*)msg;
+	HOST2MSG16(cid->code, DHCP6_OPT_CLIENTID);
+	HOST2MSG16(cid->len,  ct->duid_len);
+	memcpy(msg + sizeof(T_DHCP6_OPT_CLIENTID), ct->duid, ct->duid_len);
+	msg += ct->duid_len + sizeof(T_DHCP6_OPT_CLIENTID);
+
+	/* ãµã¼ã DUID ãè¿½å ããã*/
+	if (lease == NULL) {
+		if (!(type == DHCP6_SOLICIT || type == DHCP6_INFO_REQ))
+			return NULL;
+		}
+	else if (!(type == DHCP6_CONFIRM || type == DHCP6_REBIND)) {
+		if ((opt = find_msg_option(lease, DHCP6_OPT_SERVERID, 0)) != NULL) {
+			sid = (T_DHCP6_OPT_SERVERID*)opt;
+			opt_len = MSG2HOST16(sid->len);
+			memcpy(msg, opt, opt_len + sizeof(*sid));
+			msg += opt_len + sizeof(*sid);
+			}
+		}
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* å¿
+é ã»è¦æ±ãªãã·ã§ã³ãè¿½å ããã*/
+	oro = (T_DHCP6_OPT_ORO*)msg;
+	HOST2MSG16(oro->code, DHCP6_OPT_ORO);
+	HOST2MSG16(oro->len, 0);
+	msg += sizeof(oro->code) + sizeof(oro->len);
+
+#if defined(DHCP6_CLI_CFG_REQUIRED_OLIST)
+
+	/* å¿
+é ãªãã·ã§ã³ãè¿½å ããã*/
+	HOST2MSG16(oro->len, MSG2HOST16(oro->len) + sizeof(required_plist) * 2);
+	for (ix = sizeof(required_plist); ix -- > 0; ) {
+		host2msg16(msg, required_plist[ix]);
+		msg += sizeof(uint16_t);
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) */
+
+#if defined(DHCP6_CLI_CFG_REQUEST_OLIST)
+
+	/* è¦æ±ãªãã·ã§ã³ãè¿½å ããã*/
+	HOST2MSG16(oro->len, MSG2HOST16(oro->len) + sizeof(request_plist) * 2);
+	for (ix = sizeof(request_plist); ix -- > 0; ) {
+		host2msg16(msg, request_plist[ix]);
+		msg += sizeof(uint16_t);
+		}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_REQUIRED_OLIST) || defined(DHCP6_CLI_CFG_REQUEST_OLIST) */
+
+	return msg;
+	}
+
+/*
+ *  rel_lease -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè§£æ¾ããã
+ */
+
+static void
+rel_lease (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION			*hdr;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	T_DHCP6_OPT_IA_NA_PD		*ia;
+	T_DHCP6_OPT_IAADDR		*iaa;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+	uint8_t		*opt, *last;
+
+	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãç¡ããã°ä½ãããªãã*/
+	if (ct->act_msg == NULL)
+		return;
+
+	opt  = ct->act_msg->msg.options;
+	last = opt + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (opt < last) {
+		hdr = (T_DHCP6_OPTION*)opt;
+		switch (MSG2HOST16(hdr->code)) {
+
+		case DHCP6_OPT_NAME_SERVERS:
+			dns_in6_set_addr(NULL);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			syslog(LOG_NOTICE, "[DHCP6C] release DNS server addr.");
+#endif
+			break;
+
+		case DHCP6_OPT_DOMAIN_SEARCH:
+			dns_in6_set_dname(NULL, 0);
+			break;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		case DHCP6_OPT_IA_NA:
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			if (MSG2HOST16(ia->len) > sizeof(*iaa)) {
+				iaa = (T_DHCP6_OPT_IAADDR*)(opt + sizeof(*ia));
+				in6_del_ifaddr(&iaa->addr);
+				}
+			break;
+
+		case DHCP6_OPT_IA_TA:
+			break;
+
+		case DHCP6_OPT_IA_PD:
+			break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+		default:
+			break;
+			}
+		opt += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	}
+
+/*
+ *  set_lease -- ãªã¼ã¹ããããªãã·ã§ã³ãè§£æãã¦å¤ãè¨­å®ããã
+ */
+
+static void
+set_lease (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION			*hdr;
+	T_DHCP6_OPT_NAME_SERVERS	*ns;
+	T_DHCP6_OPT_DOMAIN_SEARCH	*ds;
+	const uint8_t			*dname;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	T_DHCP6_OPT_IA_NA_PD		*ia;
+	T_DHCP6_OPT_IAADDR		*iaa;
+	SYSTIM				time, delay;
+	ER				error;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+	uint8_t		*opt, *last;
+
+	opt  = ct->act_msg->msg.options;
+	last = opt + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (opt < last) {
+		hdr = (T_DHCP6_OPTION*)opt;
+		switch (MSG2HOST16(hdr->code)) {
+
+		case DHCP6_OPT_NAME_SERVERS:
+			ns = (T_DHCP6_OPT_NAME_SERVERS*)opt;
+			dns_in6_set_addr(&ns->addrs[0]);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			syslog(LOG_NOTICE, "[DHCP6C] set DNS server addr: %s.", ipv62str(NULL, &ns->addrs[0]));
+#endif
+			break;
+
+		case DHCP6_OPT_DOMAIN_SEARCH:
+			ds = (T_DHCP6_OPT_DOMAIN_SEARCH*)opt;
+			dname = dns_in6_set_dname(ds->name, MSG2HOST16(ds->len));
+			break;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+		case DHCP6_OPT_IA_NA:
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			if (MSG2HOST16(ia->len) > sizeof(*iaa)) {
+				get_tim(&time);
+				delay = time - ct->act_msg->rcv_time;
+				iaa = (T_DHCP6_OPT_IAADDR*)(opt + sizeof(*ia));
+				error = in6_upd_ifaddr(&iaa->addr, 64, MSG2HOST32(iaa->valid)  - SYSTIM2SEC(delay),
+				                                       MSG2HOST32(iaa->prefer) - SYSTIM2SEC(delay));
+				if (error == E_OK)
+					syslog(LOG_NOTICE, "[DHCP6C] set IPv6 addr: %s.", ipv62str(NULL, &iaa->addr));
+				else
+					syslog(LOG_NOTICE, "[DHCP6C] set IPv6 addr, error: %s.", itron_strerror(error));
+				}
+			break;
+
+		case DHCP6_OPT_IA_TA:
+			break;
+
+		case DHCP6_OPT_IA_PD:
+			break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL */
+
+		default:
+			break;
+			}
+		opt += MSG2HOST16(hdr->len) + sizeof(*hdr);
+		}
+	}
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+/*
+ *  start_req_info -- INFO-REQUEST ãéå§ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_req_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.5) åç
+§ã*/
+	ct->IRT = TMO_INF_TIMEOUT;
+	ct->MRT = TMO_INF_MAX_RT;
+	ct->MRC = 0;
+
+	/* DHCP6_CLI_CFG_ONE_TRYãæå®ããã¦ããªããã°æ¨æºã¿ã¤ã ã¢ã¦ãã¾ã§åéããã*/
+#if defined(DHCP6_CLI_CFG_ONE_TRY)
+	ct->MRD = 0;
+#else
+	ct->MRD = TMO_DHCP6C_NORMAL;
+#endif
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/*
+	 *  INFO-REQUEST ã¡ãã»ã¼ã¸éä¿¡é
+å»¶æéãè¨­å®ããã
+	 *  ãã ããTMO_INF_MAX_DELAY ã 1[s]ãªã®ã§ãdly_tsk()ãä½¿ç¨ããã
+	 */
+	dly_tsk(netapp_rand() % TMO_INF_MAX_DELAY);
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SELECT;
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_IREQ;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_informed -- INFORMED ç¶æ
+ã«é·ç§»ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_informed (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ãªã¼ã¹æ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* INFORMED ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_INFORMED;
+
+	//ct->flags |= DHCP6C_FLAG_STAY_STATE;
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* SLEEP ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SLEEP;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  select_info_reply -- æé©ãª REPLY (INFO-REQUEST ã¸ã®å¿ç­) ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_info_reply (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg;
+
+	/* æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã*/
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+	
+	ct->act_msg = msg;
+	return true;
+	}
+
+/*
+ *  setup_info_req_msg -- INFO-REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_info_req_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, DHCP6_INFO_REQ)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, DHCP6_INFO_REQ, NULL)) == NULL)
+		return E_PAR;
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+	return E_OK;
+	}
+
+/*
+ *  send_info_req_msg -- INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_info_req_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (select_info_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* INFORMED ç¶æ
+ã«é·ç§»ããã*/
+		start_informed(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_info_req_msg(ct)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup request message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* INFO-REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send info-request message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_IREQ] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+/*
+ *  select_reply -- æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_reply (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG		*msg;
+
+	/* æé©ãª REPLY ã¡ãã»ã¼ã¸ãé¸æããã*/
+	if ((msg = select_msg(ct)) == NULL)
+		return false;
+
+	if (ct->adv_msg != NULL) {
+		eval_prefer(ct->adv_msg);
+		eval_ia_prefer(ct->adv_msg);
+		}
+
+	/*
+	 *  æé©ãª REPLY ã¡ãã»ã¼ã¸ã®æ¨å¥¨åº¦ã ADVERTISE ã¡ãã»ã¼ã¸æ¨å¥¨åº¦ã®
+	 *  1/2 ä»¥ä¸ã®æã¯åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã
+	 */
+	if ((ct->adv_msg != NULL) && (ct->max_prefer < (ct->adv_msg->prefer & DHCP6_ClI_MSG_PREFER_VALUE_MASK) / 2)) {
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		msg->next = ct->rcv_lst;
+		ct->rcv_lst = msg;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		}
+	else {
+
+		/*
+		 *  ct->act_msg ã«ããæå¹ãªå
+ REPLY ã¡ãã»ã¼ã¸ã
+		 *  åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã¦ã
+		 *  æé©ãª REPLY ã¡ãã»ã¼ã¸ã act ã«ç§»ãã
+		 */
+		if (ct->act_msg != NULL) {
+			syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+			ct->act_msg->next = ct->rcv_lst;
+			ct->rcv_lst = ct->act_msg;
+			syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+			}
+		ct->act_msg = msg;
+		}
+
+	return ct->act_msg != NULL;
+	}
+
+/*
+ *  select_adv -- æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ãé¸æããã
+ */
+
+static bool_t
+select_adv (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ã adv ã«ç§»ãã*/
+	if ((ct->adv_msg = select_msg(ct)) != NULL) {
+
+		/*
+		 *  æé©ãª ADVERTISE ã¡ãã»ã¼ã¸ã®ãµã¼ãã® IPv6 ã¢ãã¬ã¹ã
+		 *  æ¬¡ããéä¿¡ããã¢ãã¬ã¹ã«è¨­å®ããã
+		 */
+		ct->dst = ct->adv_msg->srv;
+		return true;
+		}
+	else
+		return false;
+	}
+
+/*
+ *  eval_expire -- æ¨å¥¨æå¹æéã¨æå¹æéãæ±ºå®ããã
+ */
+
+static void
+eval_expire (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint32_t	depref, expire,
+			high, low, renew, rebind,
+			tval, iaa_high, iaa_low;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize, addrs;
+
+	/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RENEW]  = 0;
+	ct->timers[DHCP6C_TIMER_REBIND] = 0;
+	ct->timers[DHCP6C_TIMER_DEPREF] = 0;
+	ct->timers[DHCP6C_TIMER_EXPIRE] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+	
+	addrs = high = expire = 0;
+	low = renew = rebind = depref = DHCP6_MAX_TIME;
+
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	get_tim(&time);
+	while (msg < last) {
+		opt = (T_DHCP6_OPTION*)msg;
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæå¹æéãæ´æ°ããã*/
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			//dump_msg_option("evl_expire1", msg);
+			iaa_high = 0;
+			iaa_low  = DHCP6_MAX_TIME;
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			aoff  = sizeof(*ia);
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			while (aoff < asize) {
+
+				/* æç­ã®æ¨å¥¨æå¹æéãæ´æ°ããã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				//dump_msg_option("evl_depref1", (uint8_t*)iaa);
+				if (!(MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_DEPREFERD)) {
+					if (MSG2HOST32(iaa->prefer) == DHCP6_MAX_TIME)
+						tval = DHCP6_MAX_TIME;
+					else
+						tval = MSG2HOST32(iaa->prefer) + SYSTIM2SEC(ct->act_msg->rcv_time);
+					if (tval < depref)
+						depref = tval;
+					}
+
+				/* IAADDR ã®æå¹æéãæ´æ°ããã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if (!(MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_EXPIRED)) {
+					if (MSG2HOST32(iaa->valid) == DHCP6_MAX_TIME)
+						tval = DHCP6_MAX_TIME;
+					else
+						tval = MSG2HOST32(iaa->valid) + SYSTIM2SEC(ct->act_msg->rcv_time);
+					tval -= SYSTIM2SEC(ct->act_msg->rcv_time);
+					if (tval > iaa_high)
+						iaa_high = tval;
+					if (tval < iaa_low)
+						iaa_low  = tval;
+					addrs ++;
+					}
+
+				aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa);
+				}
+
+			/* iaa_low ã¨ iaa_high/2 ã®æé·ã®æ¹ãæå¹æéã¨ãã¦é¸æããã*/
+			if (iaa_low <= (iaa_high / 2))
+				expire = iaa_high;
+			else
+				expire = iaa_low;
+
+			/* expire ã æå¤§å¤ï¼ç¡å¶éï¼ã 1 ä»¥ä¸ãªãæ¢å®å¤ã«è¨­å®ããã*/
+			if ((expire == DHCP6_MAX_TIME) || (expire <= 1))
+				expire  = SYSTIM2SEC(TMO_DHCP6C_REQ_LEASE) / 2;
+			else
+				expire /= 2;
+
+			/* renew ãæ±ºå®ããã*/
+			if (MSG2HOST32(ia->renew) == 0)
+				tval = expire + SYSTIM2SEC(ct->act_msg->rcv_time);
+			else if (MSG2HOST32(ia->renew) == DHCP6_MAX_TIME)
+				tval = DHCP6_MAX_TIME;
+			else
+				tval = MSG2HOST32(ia->renew) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (tval < renew)
+				renew = tval;
+
+			/* rebind ãæ±ºå®ããã*/
+			if (MSG2HOST32(ia->rebind) == 0)
+				tval = (expire + expire / 2) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			else if (MSG2HOST32(ia->rebind) == DHCP6_MAX_TIME)
+				tval = DHCP6_MAX_TIME;
+			else
+				tval = MSG2HOST32(ia->rebind) + SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (tval < rebind)
+				rebind = tval;
+
+			/* æç­æå¹æéã¨æé·æå¹æéãæ´æ°ããã*/
+			iaa_low  += SYSTIM2SEC(ct->act_msg->rcv_time);
+			iaa_high += SYSTIM2SEC(ct->act_msg->rcv_time);
+			if (iaa_low < low)
+				low = iaa_low;
+			if (iaa_high > high)
+				high = iaa_high;
+			}
+
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	/* ã¢ãã¬ã¹ãéããã¦ããªããã°ãSLEEP ç¶æ
+ã«é·ç§»ããã*/
+	if (addrs == 0) {
+		ct->fsm    = DHCP6_FSM_SLEEP;
+		}
+
+	/* ç¶æ
+ã«ä¾å­ããå¦ç */
+	switch (ct->fsm) {
+
+	case DHCP6_FSM_BOUND:
+
+		/* RENEW ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+		if ((rebind > SYSTIM2SEC(time)) && (renew < rebind)) {
+			ct->next_MRD = SEC2SYSTIM(rebind) - time;
+			syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+			ct->timers[DHCP6C_TIMER_RENEW] = SEC2TIMER(renew) - SYSTIM2TIMER(time);
+			syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+			break;
+			}
+		/* break; */	/* ä¸ã«æããã*/
+
+	case DHCP6_FSM_RENEW:
+
+		/* REBIND ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+		ct->MRD = SEC2SYSTIM(rebind);
+		if (rebind != DHCP6_MAX_TIME) {
+			ct->next_MRD = SEC2SYSTIM(high) - time;
+			syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+			ct->timers[DHCP6C_TIMER_REBIND] = SEC2TIMER(rebind) - SYSTIM2TIMER(time);
+			syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+			}
+		break;
+
+	case DHCP6_FSM_REBIND:
+
+		ct->next_MRD = (SEC2TIMER(high) - time) - time;
+		break;
+
+	default:
+		break;
+		}
+
+	/* DEPREF ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+	if (depref != DHCP6_MAX_TIME) {
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_DEPREF] = SEC2TIMER(depref) - SYSTIM2TIMER(time);
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+		}
+
+	/* EXPIRE ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+	if (low != DHCP6_MAX_TIME) {
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_EXPIRE] = SEC2TIMER(low) - SYSTIM2TIMER(time);
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+		}
+	}
+
+/*
+ *  start_init -- INIT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_init (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (17.1.2) åç
+§ã*/
+	ct->IRT = TMO_SOL_TIMEOUT;
+	ct->MRT = TMO_SOL_MAX_RT;
+	ct->MRC = 0;
+
+	/* DHCP6_CLI_CFG_ONE_TRYãæå®ããã¦ããªããã°æ¨æºã¿ã¤ã ã¢ã¦ãã¾ã§åéããã*/
+#if defined(DHCP6_CLI_CFG_ONE_TRY)
+	ct->MRD = 0;
+#else
+	ct->MRD = TMO_DHCP6C_NORMAL;
+#endif
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* RFC3315 (17.1.2) ã®è¦å®ã«å¾ã£ã¦ã¿ã¤ã ã¢ã¦ããèª¿æ´ããã*/
+	if (ct->RT <= ct->IRT)
+		ct->RT = ct->IRT + (ct->IRT - ct->RT);
+	if (ct->RT <= ct->IRT)
+		ct->RT = ct->IRT + SEC2SYSTIM(1);
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_ADV] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/*
+	 *  SOLICIT ã¡ãã»ã¼ã¸éä¿¡é
+å»¶æéãè¨­å®ããã
+	 *  ãã ããTMO_SOL_MAX_DELAY ã 1[s]ãªã®ã§ãdly_tsk()ãä½¿ç¨ããã
+	 */
+	dly_tsk(netapp_rand() % TMO_SOL_MAX_DELAY);
+
+	/* INIT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_INIT;
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_SOL;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_select -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_select (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãª ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã° SLEEP ç¶æ
+ã«é·ç§»ããã*/
+	if (ct->adv_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.1) åç
+§ã*/
+	ct->IRT = TMO_REQ_TIMEOUT;
+	ct->MRT = TMO_REQ_MAX_RT;
+	ct->MRC = TMO_REQ_MAX_RC;
+	ct->MRD = 0;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* SELECT ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_SELECT;
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REQ;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_bound -- BOUND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_bound (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL)
+		ct->fsm = DHCP6_FSM_SLEEP;
+
+	/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm    = DHCP6_FSM_BOUND;
+
+	/* ãªã¼ã¹æ
+å ±ãè¨­å®ããã*/
+	set_lease(ct);
+
+	/* æå¹æéãæ±ºå®ããã*/
+	eval_expire(ct);
+
+	}
+/*
+ *  start_renew -- RENEW ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_renew (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.3) åç
+§ã*/
+	ct->IRT = TMO_REN_TIMEOUT;
+	ct->MRT = TMO_REN_MAX_RT;
+	ct->MRC = 0;
+	ct->MRD = ct->next_MRD;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REFRESH ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	ct->refresh_type = DHCP6_RENEW;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_RENEW;
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REF;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_rebind -- REBIND ç¶æ
+ã«é·ç§»ããã
+ */
+
+static void
+start_rebind (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.4) åç
+§ã*/
+	ct->IRT = TMO_REB_TIMEOUT;
+	ct->MRT = TMO_REB_MAX_RT;
+	ct->MRC = 0;
+	ct->MRD = ct->next_MRD;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REFRESH ã¡ãã»ã¼ã¸ã¿ã¤ããè¨­å®ããã*/
+	ct->refresh_type = DHCP6_REBIND;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®åä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_RCV_REPLY] = SYSTIM2TIMER(ct->MRD);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+
+	/* REBIND ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_REBIND;
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REF;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+/*
+ *  start_rel_info -- ã¢ãã¬ã¹æ
+å ±ãè§£æ¾ããã
+ *
+ *    æ³¨æ: DHCPv6 ã® RFC3315 ã«ã¯ç¡ã
+ */
+
+static void
+start_rel_info (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+	cancel_all_timers(ct);
+
+	/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+	rel_lease(ct);
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ãç¡ããã° SLEEP ã«é·ç§»ããã*/
+	if (ct->act_msg == NULL) {
+		ct->fsm = DHCP6_FSM_SLEEP;
+		return;
+		}
+
+	/* ã¿ã¤ã ã¢ã¦ããè¨­å®ããããRFC3315 (18.1.1) åç
+§ã*/
+	ct->IRT = TMO_REL_TIMEOUT;
+	ct->MRT = 0;
+	ct->MRC = TMO_REL_MAX_RC;
+	ct->MRD = 0;
+
+	/* åéåæ°ã¨ãã©ã³ã¶ã¯ã·ã§ã³ ID ãè¨­å®ããã*/
+	init_retrans(ct);
+
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	ct->fsm = DHCP6_FSM_REL_INFO;
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	ct->flags |= DHCP6C_FLAG_TMOUT_SND_REL;
+	syscall(sig_sem(SEM_DHCP6_CLI_READY));
+	}
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+/*
+ *  solicit_ia_option -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã
+ */
+
+static void
+solicit_ia_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IA_TA	*ia;
+	uint_t			off, len;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	ia = (T_DHCP6_OPT_IA_TA*)msg;
+	HOST2MSG16(ia->code, code);
+
+	/* IAID ãè¨­å®ããã*/
+	if (sizeof(ct->sc->ifaddr.lladdr) > sizeof(uint32_t)) {
+		off = sizeof(ct->sc->ifaddr.lladdr) - 4;
+		len = 4;
+		}
+	else {
+		off = 0;
+		len = sizeof(ct->sc->ifaddr.lladdr);
+		}
+	memcpy((uint8_t*)&ia->iaid, ((uint8_t*)ct->sc->ifaddr.lladdr) + off, len);
+	}
+
+/*
+ *  solicit_iaaddr_option -- SOLICIT ã¡ãã»ã¼ã¸ã® IAADDR ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+static uint_t
+solicit_iaaddr_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IAADDR	*iaa;
+	uint32_t		t1, t2;
+	uint8_t			*opt;
+	uint_t			len;
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_NA/IA_TA/IA_PDï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	if ((ct->act_msg == NULL) || (opt = find_msg_option(ct->act_msg, code, 0)) == NULL)
+		return 0;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	iaa = (T_DHCP6_OPT_IAADDR*)msg;
+	HOST2MSG16(iaa->code, DHCP6_OPT_IAADDR);
+
+	/* IAADDR ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(iaa->len, sizeof(*iaa) - sizeof(T_DHCP6_OPTION));
+
+	/* ã¢ãã¬ã¹ãè¨­å®ããã*/
+	len = code == DHCP6_OPT_IA_TA ? sizeof(T_DHCP6_OPT_IA_TA)
+	                              : sizeof(T_DHCP6_OPT_IA_NA_PD);
+	memcpy(&iaa->addr, opt + sizeof(T_DHCP6_OPTION) + len, sizeof(iaa->addr));
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	t1 = TMO_DHCP6C_REQ_LEASE / 2;
+	t2 = t1 + (t1 / 2);
+	HOST2MSG32(iaa->prefer, t1);
+	HOST2MSG32(iaa->valid,  t2);
+
+	return sizeof(*iaa);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  solicit_ia_na_pd -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_NA/IA_PD ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+solicit_ia_na_pd (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code)
+{
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	uint32_t		t1, t2;
+	uint_t			len;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	solicit_ia_option(ct, msg, code);
+	ia = (T_DHCP6_OPT_IA_NA_PD*)msg;
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	t1 = TMO_DHCP6C_REQ_LEASE / 2;
+	t2 = t1 + (t1 / 2);
+	HOST2MSG32(ia->renew,  SYSTIM2SEC(t1));
+	HOST2MSG32(ia->rebind, SYSTIM2SEC(t2));
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_NA/IA_PDï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	msg += sizeof(*ia);
+	len  = solicit_iaaddr_option(ct, msg, code);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(ia->len, (sizeof(*ia) + len) - sizeof(T_DHCP6_OPTION));
+
+	return msg + len;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  solicit_ia_ta -- SOLICIT ã¡ãã»ã¼ã¸ã® IA_TA ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+static uint8_t *
+solicit_ia_ta (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg)
+{
+	T_DHCP6_OPT_IA_TA	*ia;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	solicit_ia_option(ct, msg, DHCP6_OPT_IA_TA);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	ia = (T_DHCP6_OPT_IA_TA*)msg;
+	HOST2MSG16(ia->len, sizeof(*ia) - sizeof(T_DHCP6_OPTION));
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸ãæ®ã£ã¦ãã¦ã
+	 *  æå®ããããªãã·ã§ã³ï¼IA_TAï¼ãããå ´åã¯
+	 *  åãã¢ãã¬ã¹ãè¦æ±ããã
+	 */
+	msg += sizeof(*ia);
+	return msg + solicit_iaaddr_option(ct, msg, code);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_TA) */
+
+/*
+ *  setup_solicit_msg -- SOLICIT ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_solicit_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease)
+{
+	uint8_t	*head, *msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((head = setup_msg_header(ct, DHCP6_SOLICIT)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, head, DHCP6_SOLICIT, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = solicit_ia_na_pd(ct, msg, DHCP6_OPT_IA_NA);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+	/* IA_TA ãè¿½å ããã*/
+	msg = solicit_ia_ta(ct, msg);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = solicit_ia_na_pd(ct, msg, DHCP6_OPT_IA_PD);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ct->dst.ipaddr	= in6_addr_all_DHCP_relay_servers;
+	return E_OK;
+	}
+
+/*
+ *  send_solicit_msg -- SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_solicit_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	ct->error = E_OK;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãSELECT ç¶æ
+ã«é·ç§»ããã*/
+	if (select_adv(ct)) {
+
+		/* ADVERTISE ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_ADV] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+ 		/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã*/
+ 		start_select(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_solicit_msg(ct, NULL)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup solicit message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* SOLICIT ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send solicit message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_SOL] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  request_ia_option -- REQUEST ã¡ãã»ã¼ã¸ã® IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+request_ia_option (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t code, uint8_t *lease)
+{
+	T_DHCP6_OPT_IA_NA_PD	*dst, *src;
+
+	dst = (T_DHCP6_OPT_IA_NA_PD*)msg;
+	src = (T_DHCP6_OPT_IA_NA_PD*)lease;
+
+	/* ãªãã·ã§ã³ã³ã¼ããè¨­å®ããã*/
+	HOST2MSG16(dst->code, code);
+
+	/* IA_NAIA_TA/IA_PD ãªãã·ã§ã³ãé¤ãããªãã·ã§ã³é·ãè¨­å®ããã*/
+	HOST2MSG16(dst->len, sizeof(*dst) - (sizeof(dst->code) + sizeof(dst->len)));
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ãã IA ID ãã³ãã¼ããã*/
+	memcpy(&dst->iaid, &src->iaid, sizeof(src->iaid));
+
+	return msg + sizeof(uint16_t) * 2 + sizeof(uint32_t);
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_TA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  request_ia_na_pd -- REQUEST ã¡ãã»ã¼ã¸ã® IA_NA/IA_PD ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD)
+
+static uint8_t *
+request_ia_na_pd (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t msg_type, uint_t opt_code, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_IA_NA_PD	*dia,  *sia;
+	T_DHCP6_OPT_IAADDR	*diaa, *siaa;
+	uint8_t			*opt;
+	uint32_t		t1, t2;
+	uint_t			ix, nsiaa;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã«æå®ããããªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_msg_option(lease, opt_code, 0)) == NULL)
+		return msg;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	dia = (T_DHCP6_OPT_IA_NA_PD*)msg;
+	sia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+	msg = request_ia_option(ct, msg, opt_code, opt);
+
+	/* T1ãT2 ãæ±ºå®ããã*/
+	switch (msg_type) {
+	case DHCP6_REQUEST:
+	case DHCP6_RENEW:
+	case DHCP6_REBIND:
+		t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+		t2 = t1 + (t1 / 2);
+		break;
+
+	case DHCP6_CONFIRM:
+	case DHCP6_RELEASE:
+	case DHCP6_DECLINE:
+		t1 = t2 = 0;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] unkown msg_type in setup IA_NA/IA_PD for request message: %d.", msg_type);
+		return NULL;
+		break;
+		}
+
+	/* T1ãT2 ãè¨­å®ããã*/
+	HOST2MSG32(dia->renew,  t1);
+	HOST2MSG32(dia->rebind, t2);
+	msg += sizeof(dia->renew) + sizeof(dia->rebind);
+
+	/* IAADDR ãªãã·ã§ã³ãè¨­å®ããã*/
+	nsiaa = ((MSG2HOST16(sia->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*sia) - (sizeof(sia->code) + sizeof(sia->len)))) / sizeof(*siaa);
+
+	for (ix = 0; ix <nsiaa; ix++) {
+		diaa = (T_DHCP6_OPT_IAADDR*)(msg + sizeof(*diaa) * ix);
+		siaa = (T_DHCP6_OPT_IAADDR*)((opt + sizeof(*sia)) + sizeof(*siaa) * ix);
+
+		/* ã¢ãã¬ã¹ã®æå¹æéãåãã¦ããã°ã¹ã­ããããã*/
+		if (MSG2HOST16(siaa->len) & DHCP6C_IAA_FLAG_EXPIRED)
+			continue;
+
+		/* ã³ã¼ãã¨é·ããè¨­å®ããã*/
+		memcpy(&diaa->code, &siaa->code, sizeof(siaa->code));
+		HOST2MSG16(diaa->len, MSG2HOST16(siaa->len) & ~DHCP6C_IAA_FLAG_MASK);
+		msg += sizeof(dia->code) + sizeof(dia->len);
+
+		/* IPv6 ã¢ãã¬ã¹ãã³ãã¼ããã*/
+		memcpy(&diaa->addr, &siaa->addr, sizeof(siaa->addr));
+		msg += sizeof(diaa->addr);
+
+		/* T1ãT2 ãæ±ºå®ããã*/
+		switch (msg_type) {
+		case DHCP6_REQUEST:
+		case DHCP6_RENEW:
+		case DHCP6_REBIND:
+			t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+			t2 = t1 + 300;
+			break;
+
+		case DHCP6_CONFIRM:
+		case DHCP6_RELEASE:
+		case DHCP6_DECLINE:
+			t1 = t2 = 0;
+			break;
+
+		default:
+			syslog(LOG_NOTICE, "[DHCP6C] unknown msg_type in setup IA_NA/IA_PD for request: %d.", msg_type);
+			return NULL;
+			break;
+			}
+
+		/* T1ãT2 ãè¨­å®ããã*/
+		HOST2MSG32(diaa->prefer, t1);
+		HOST2MSG32(diaa->valid,  t2);
+		msg += sizeof(diaa->prefer) + sizeof(diaa->valid);
+
+		/* IAADDR ã«ä»å ãªãã·ã§ã³ãè¿½å ãããå
+éããã*/
+		}
+
+	HOST2MSG16(((T_DHCP6_OPTION*)dia)->len, 
+	MSG2HOST16(((T_DHCP6_OPTION*)dia)->len) + (msg - (uint8_t*)dia) - sizeof(*dia));
+	return msg;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_NA) || defined(DHCP6_CLI_CFG_IA_PD) */
+
+/*
+ *  request_ia_ta -- REQUEST ã¡ãã»ã¼ã¸ã® IA_TA ãªãã·ã§ã³ãè¿½å ããã
+ */
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+static uint8_t *
+request_ia_ta (T_DHCP6_CLI_CONTEXT *ct, uint8_t *msg, uint_t msg_type, T_DHCP6_CLI_MSG *lease)
+{
+	T_DHCP6_OPT_IA_TA	*dia,  *sia;
+	T_DHCP6_OPT_IAADDR	*diaa, *siaa;
+	uint8_t			*opt;
+	uint32_t		t1, t2;
+	uint_t			ix, nsiaa;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ã« IA_TA ãªãã·ã§ã³ããããã¨ãç¢ºèªããã*/
+	if ((opt = find_msg_option(lease, DHCP6_OPT_IA_TA, 0)) == NULL)
+		return msg;
+
+	/* IA_NA/IA_TA/IA_PD ãªãã·ã§ã³ã®å
+±éé¨åãè¿½å ããã*/
+	dia = (T_DHCP6_OPT_IA_TA*)msg;
+	sia = (T_DHCP6_OPT_IA_TA*)opt;
+	msg = request_ia_option(ct, msg, DHCP6_OPT_IA_TA, opt);
+
+	/* IAADDR ãªãã·ã§ã³ãè¨­å®ããã*/
+	nsiaa = ((MSG2HOST16(sia->len) & ~DHCP6C_IAA_FLAG_MASK) - (sizeof(*sia) - (sizeof(sia->code) + sizeof(sia->len)))) / sizeof(*siaa);
+
+	for (ix = 0; ix <nsiaa; ix++) {
+		diaa = (T_DHCP6_OPT_IAADDR*)(msg + sizeof(*diaa) * ix);
+		siaa = (T_DHCP6_OPT_IAADDR*)((opt + sizeof(*sia)) + sizeof(*siaa) * ix);
+
+		/* ã¢ãã¬ã¹ã®æå¹æéãåãã¦ããã°ã¹ã­ããããã*/
+		if (MSG2HOST16(siaa->len) & DHCP6C_IAA_FLAG_EXPIRED)
+			continue;
+
+		/* ã³ã¼ãã¨é·ããè¨­å®ããã*/
+		memcpy(diaa->code, siaa->code, sizeof(siaa->code));
+		diaa->len  = HOST2MSG16(MSG2HOST16(siaa->len) & ~DHCP6C_IAA_FLAG_MASK);
+		msg += sizeof(dia->code) + sizeof(dia->len);
+
+		/* IPv6 ã¢ãã¬ã¹ãã³ãã¼ããã*/
+		memcpy(diaa->addr, siaa->addr, sizeof(siaa->addr));
+		msg += sizeof(diaa->addr);
+
+		/* T1ãT2 ãæ±ºå®ããã*/
+		switch (msg_type) {
+		case DHCP6_REQUEST:
+		case DHCP6_RENEW:
+		case DHCP6_REBIND:
+			t1 = SYSTIM2TIMER(TMO_DHCP6C_REQ_LEASE);
+			t2 = t1 + 300;
+			break;
+
+		case DHCP6_CONFIRM:
+		case DHCP6_RELEASE:
+		case DHCP6_DECLINE:
+			t1 = t2 = 0;
+			break;
+
+		default:
+			syslog(LOG_NOTICE, "[DHCP6C] unknown msg_type in setup IA_TA for request message: %d.", msg_type);
+			return NULL;
+			break;
+			}
+
+		/* T1ãT2 ãè¨­å®ããã*/
+		HOST2MSG32(diaa->prefer, t1);
+		HOST2MSG32(diaa->valid,  t2);
+		msg += sizeof(diaa->prefer) + sizeof(diaa->valid);
+
+		/* IAADDR ã«ä»å ãªãã·ã§ã³ãè¿½å ãããå
+éããã*/
+		}
+
+	return msg;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG_IA_TA) */
+
+/*
+ *  setup_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_request_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease, uint_t type)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, type)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, type, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_NA, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_TA)
+
+	/* IA_TA ãè¿½å ããã*/
+	msg = request_ia_ta(ct, msg, type, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_PD, lease);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+	return E_OK;
+	}
+
+/*
+ *  send_request_msg -- REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_request_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	ct->error = E_OK;
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+
+	/* ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ã¨ã©ã¼ */
+	if (ct->adv_msg == NULL) {
+		ct->error  = E_OBJ;
+		return;
+		}
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	 	/* ADVERTISE ã¡ãã»ã¼ã¸ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		ct->adv_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->adv_msg;
+		ct->adv_msg = NULL;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_request_msg(ct, ct->adv_msg, DHCP6_REQUEST)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup request message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send request message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REQ] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  send_refresh_msg -- REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_refresh_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPT_UNICAST	*uc;
+	ER			error;
+	uint8_t			*opt;
+
+	/* æå¹ãªãªã¼ã¹æ
+å ±ããªããã°ã¨ã©ã¼ */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL)
+		ct->error = E_OBJ;
+
+	/* REFRESH ã¿ã¤ãã RENEW ã¾ãã¯ REBIND ã§ãªããã°ã¨ã©ã¼ */
+	if (!((ct->refresh_type == DHCP6_RENEW) || (ct->refresh_type == DHCP6_REBIND)))
+		ct->error = E_PAR;
+
+	/* REPLY ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* REPLY ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		return;
+		}
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		eval_expire(ct);
+		return;
+		}
+
+	/*
+	 *  ãµã¼ããã UNICAST ãªãã·ã§ã³ãåä¿¡ããã¨ãã¯
+	 *  æå®ããã¢ãã¬ã¹ãéä¿¡å
+ã¢ãã¬ã¹ã«è¨­å®ããã
+	 */
+	if ((opt = find_msg_option(ct->act_msg, DHCP6_OPT_UNICAST, sizeof(T_DHCP6_OPT_UNICAST))) != NULL) {
+		uc = (T_DHCP6_OPT_UNICAST*)opt;
+		ct->dst.ipaddr = uc->addr;
+		}
+
+	/* REFRESH (REQUEST) ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_request_msg(ct, ct->act_msg, ct->refresh_type)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup refresh message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* REFRESH ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send refresh message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REF] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  setup_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_release_msg (T_DHCP6_CLI_CONTEXT *ct, T_DHCP6_CLI_MSG *lease, uint_t type)
+{
+	uint8_t	*msg;
+
+	/* ã¡ãã»ã¼ã¸ã®ãããé¨åãä½æããã*/
+	if ((msg = setup_msg_header(ct, type)) == NULL)
+		return E_PAR;
+
+	if ((msg = common_options(ct, msg, type, lease)) == NULL)
+		return E_PAR;
+
+#if defined(DHCP6_CLI_CFG_IA_NA)
+
+	/* IA_NA ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_NA, lease);
+#endif
+
+#if defined(DHCP6_CLI_CFG_IA_PD)
+
+	/* IA_PD ãè¿½å ããã*/
+	msg = request_ia_na_pd(ct, msg, type, DHCP6_OPT_IA_PD, lease);
+#endif
+
+	/* ã¡ãã»ã¼ã¸æ§é ä½é·ãè¨­å®ããã*/
+	ct->snd_msg->len = msg - (uint8_t*)&ct->snd_msg->msg;
+	return E_OK;
+	}
+
+/*
+ *  send_release_msg -- RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static void
+send_release_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error;
+
+	/* æå¹ãª REPLY ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããªããã°ã¨ã©ã¼ */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL)
+		ct->error = E_OBJ;
+
+	/* æå¹ãª REPLY ã¡ãã»ã¼ã¸ãåä¿¡ãã¦ããã°ãSLEEP ç¶æ
+ã«é·ç§»ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	if (ct->prf_lst != NULL) {
+
+		/* åéä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+		ct->timers[DHCP6C_TIMER_RCV_REPLY] = 0;
+		syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+		/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		if (ct->act_msg != NULL) {
+			syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->act_msg));
+			ct->act_msg = NULL;
+			}
+
+		/* SLEEP ç¶æ
+ã«é·ç§»ããã*/
+		ct->fsm    = DHCP6_FSM_SLEEP;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+		return;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	/* åéä¿¡åæ°ãç¢ºèªããã*/
+	if ((ct->MRC != 0) && (ct->txcount > ct->MRC)) {
+		ct->error  = E_TMOUT;
+		return;
+		}
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((error = setup_release_msg(ct, ct->act_msg, DHCP6_RELEASE)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, setup release message: %s.", itron_strerror(error));
+		ct->error = error;
+		return;
+		}
+
+	/* RELEASE ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+	error = UDP_SND_DAT(ct->cepid, &ct->dst, &ct->snd_msg->msg, ct->snd_msg->len, TMO_NBLK);
+	if (error != E_WBLK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, send release message: %s.", itron_strerror(error));
+		ct->error  = error;
+		return;
+		}
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REL] = SYSTIM2TIMER(ct->RT);
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	/* åéä¿¡ã¿ã¤ã ã¢ã¦ããæ´æ°ããã*/
+	advance_retrans(ct);
+	}
+
+/*
+ *  advertise_msg_timeout -- ADVERTISE ã¡ãã»ã¼ã¸ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+advertise_msg_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* SOLICIT ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_SOL] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+	if (select_adv(ct)) {
+		/*
+		 *  ADVERTISE ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ã
+ 		 *  REQUEST ã¡ãã»ã¼ã¸ãéä¿¡ãã¦ SELECT ç¶æ
+ã«é·ç§»ããã
+ 		 */
+ 		start_select(ct);
+		}
+	else
+		ct->error  = E_TMOUT;
+	}
+
+/*
+ *  renew_timeout -- RENEW ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+renew_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	start_renew(ct);
+	}
+
+/*
+ *  rebind_timeout -- REBIND ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+rebind_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* REBIND ç¶æ
+ã«é·ç§»ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	start_rebind(ct);
+	}
+
+/*
+ *  depref_timeout -- DEPREF ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+depref_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize;
+
+	/* æå¹ãªãªã¼ã¹ãç¡ããã°å¦ççµäº */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL) {
+		return;
+		}
+
+	get_tim(&time);
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæ¨å¥¨æå¹æéãç¢ºèªããã*/
+		opt = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			for (aoff  = sizeof(*ia); aoff < asize;
+				                  aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa)) {
+
+				/* ãã§ã«æ¨å¥¨æå¹æéãçµéãã¦ããã°å¦çããªãã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if ((MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_DEPREFERD))
+					continue;
+
+				/* æ¨å¥¨æå¹æéçµéãã¦ããã° FLAG ãè¨­å®ããã*/
+				if (TIMEC_GE(time, ct->act_msg->rcv_time + MSG2HOST32(iaa->prefer))) {
+					HOST2MSG16(iaa->len, MSG2HOST16(iaa->len) | DHCP6C_IAA_FLAG_DEPREFERD);
+					if (MSG2HOST16(ia->code) == DHCP6_OPT_IA_NA)
+						syslog(LOG_NOTICE, "[DHCP6C] address depreferd: %s.", ipv62str(NULL, &iaa->addr));
+					else
+						syslog(LOG_NOTICE, "[DHCP6C] prefix  depreferd: %s.", ipv62str(NULL, &iaa->addr));
+
+					/*ãDNS ã®å¦çãå¿
+è¦ã*/
+					}
+				}
+			}
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	eval_expire(ct);
+	}
+
+/*
+ *  expire_timeout -- EXPIRE ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+expire_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_OPTION		*opt;
+	T_DHCP6_OPT_IA_NA_PD	*ia;
+	T_DHCP6_OPT_IAADDR	*iaa;
+	SYSTIM		time;
+	uint8_t		*msg, *last;
+	uint_t		aoff, asize, addrs = 0;
+
+	/* æå¹ãªãªã¼ã¹ãç¡ããã°å¦ççµäº */
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	if (ct->act_msg == NULL) {
+		return;
+		}
+
+	get_tim(&time);
+	msg = ct->act_msg->msg.options;
+	last = msg + (ct->act_msg->len - sizeof(T_DHCP6_MSG_HDR));
+	while (msg < last) {
+
+		/* IA_NA/IA_PD ãªãã·ã§ã³ã§ããã°ãæå¹æéãç¢ºèªããã*/
+		opt = (T_DHCP6_OPTION*)msg;
+		if (MSG2HOST16(opt->code) == DHCP6_OPT_IA_NA || MSG2HOST16(opt->code) == DHCP6_OPT_IA_PD) {
+
+			ia = (T_DHCP6_OPT_IA_NA_PD*)opt;
+			asize = MSG2HOST16(ia->len) + sizeof(*opt);
+			for (aoff  = sizeof(*ia); aoff < asize;
+				                  aoff += (MSG2HOST16(iaa->len) & ~DHCP6C_IAA_FLAG_MASK) + sizeof(*iaa)) {
+
+				/* ãã§ã«æå¹æéãçµéãã¦ããã°å¦çããªãã*/
+				iaa = (T_DHCP6_OPT_IAADDR*)((uint8_t*)opt + aoff);
+				if ((MSG2HOST16(iaa->len) & DHCP6C_IAA_FLAG_EXPIRED))
+					continue;
+
+				/* æå¹æéçµéãã¦ããã° FLAG ãè¨­å®ããã*/
+				if (TIMEC_GE(time, ct->act_msg->rcv_time + MSG2HOST32(iaa->valid))) {
+					HOST2MSG16(iaa->len, MSG2HOST16(iaa->len) | DHCP6C_IAA_FLAG_EXPIRED);
+					if (MSG2HOST16(ia->code) == DHCP6_OPT_IA_NA)
+						syslog(LOG_NOTICE, "[DHCP6C] address expired: %s.", ipv62str(NULL, &iaa->addr));
+					else
+						syslog(LOG_NOTICE, "[DHCP6C] prefix  expired: %s.", ipv62str(NULL, &iaa->addr));
+
+					/*ãDNS ã®å¦çãå¿
+è¦ã*/
+					continue;
+					}
+				addrs ++;
+				}
+			}
+		msg += MSG2HOST16(opt->len) + sizeof(*opt);
+		}
+
+	/* æå¹ãªã¢ãã¬ã¹ãå
+¨ã¦ç¡ããªã£ãæã¯ INIT ç¶æ
+ã«é·ç§»ããã*/
+	if (addrs == 0) {
+
+	 	/* ACTIVE ãªã¼ã¹ãåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã«æ»ãã*/
+		syslog(LOG_NOTICE, "[DHCP6C] all address expired.");
+		syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+		ct->act_msg->next = ct->rcv_lst;
+		ct->rcv_lst = ct->act_msg;
+		ct->act_msg = NULL;
+		syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* INIT ç¶æ
+ã«é·ç§»ããã*/
+		start_init(ct);
+		return;
+		}
+
+	eval_expire(ct);
+	}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+/*
+ *  reply_msg_timeout -- REPLY ã¡ãã»ã¼ã¸ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+reply_msg_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+	/* SOLICIT ã¡ãã»ã¼ã¸éä¿¡ã¿ã¤ãã¼ãåæ­¢ããã*/
+	ct->flags &= ~DHCP6C_FLAG_TMOUT_MASK;
+	syscall(wai_sem(SEM_DHCP6_CLI_TIMER));
+	ct->timers[DHCP6C_TIMER_SND_REQ] = 0;
+	ct->timers[DHCP6C_TIMER_SND_REF] = 0;
+	syscall(sig_sem(SEM_DHCP6_CLI_TIMER));
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	/* STATELES ã¢ã¼ãã§ã¯SLEEP ã«é·ç§»ããã*/
+	ct->error = E_TMOUT;
+	ct->fsm   = DHCP6_FSM_SLEEP;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	/* RENEW ã¡ãã»ã¼ã¸ã®é¸æãçµäºãã¦ããã°ãBOUND ç¶æ
+ã«é·ç§»ããã*/
+	if (select_reply(ct)) {
+
+		/* ãªã¼ã¹æ
+å ±ãè§£æ¾ããã*/
+		rel_lease(ct);
+
+		/* BOUND ç¶æ
+ã«é·ç§»ããã*/
+		start_bound(ct);
+		}
+	else if (ct->fsm == DHCP6_FSM_RENEW || ct->fsm == DHCP6_FSM_REBIND)
+		eval_expire(ct);
+	else {
+		/* SLEEP ã«é·ç§»ããã*/
+		ct->error = E_TMOUT;
+		ct->fsm   = DHCP6_FSM_SLEEP;
+		}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+	}
+
+/*
+ *  dispatch_timeout -- ã¿ã¤ã ã¢ã¦ãããæã®å¦ç
+ */
+
+static ER
+dispatch_timeout (T_DHCP6_CLI_CONTEXT *ct)
+{
+
+	switch (ct->flags & DHCP6C_FLAG_TMOUT_TIMER_MASK) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6C_TIMER_SND_IREQ:
+		send_info_req_msg(ct);
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA
+
+	case DHCP6C_TIMER_SND_SOL:
+		send_solicit_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REQ:
+		send_request_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REF:
+		send_refresh_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_SND_REL:
+		send_release_msg(ct);
+		break;
+
+	case DHCP6C_TIMER_RCV_ADV:
+		advertise_msg_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_RENEW:
+		renew_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_REBIND:
+		rebind_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_DEPREF:
+		depref_timeout(ct);
+		break;
+
+	case DHCP6C_TIMER_EXPIRE:
+		expire_timeout(ct);
+		break;
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL || DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_RA */
+
+	case DHCP6C_TIMER_RCV_REPLY:
+		reply_msg_timeout(ct);
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[DHCP6C] error, unknown timeout: %d.", ct->flags & DHCP6C_FLAG_TMOUT_TIMER_MASK);
+		break;
+		}
+
+	return ct->error;
+	}
+
+/*
+ *  dispatch_event -- ã¤ãã³ãæ¯ã®å¦ç
+ */
+
+static ER
+dispatch_event (T_DHCP6_CLI_CONTEXT *ct)
+{
+	ER	error = E_OK;
+
+	while (ct->fsm != DHCP6_FSM_SLEEP && error == E_OK) {
+
+		/* ã¡ãã»ã¼ã¸ã®éåä¿¡ã¨ã¿ã¤ã ã¢ã¦ããå¾
+ã¤ã*/
+		syscall(wai_sem(SEM_DHCP6_CLI_READY));
+
+		if (ct->flags & DHCP6C_FLAG_RCV_MSG) {
+			while (ct->val_lst != NULL) {
+				error = eval_rcv_msg(ct);
+				}
+			ct->flags &= ~DHCP6C_FLAG_RCV_MSG;
+			}
+
+		if (ct->flags & DHCP6C_FLAG_TMOUT_MASK)
+			error = dispatch_timeout(ct);
+
+		if (ct->error != E_OK)
+			error = ct->error;
+		}
+
+	return error;
+	}
+
+/*
+ *  init_context -- DHCPv6 ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã
+ */
+
+static void
+init_context (T_DHCP6_CLI_CONTEXT *ct, ID cepid)
+{
+  	memset(ct, 0, sizeof(*ct));
+	ct->cepid	= cepid;
+	ct->sc		= IF_ETHER_NIC_GET_SOFTC();
+	ct->dst.portno	= DHCP6_SRV_CFG_PORTNO;
+	}
+
+/*
+ *  rel_cli_msg -- ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã
+ */
+
+static void
+rel_cli_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*ptr, *cell;
+
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	for (ptr = ct->rcv_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->val_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	for (ptr = ct->prf_lst; ptr != NULL; ) {
+		cell = ptr;
+		ptr = ptr->next;
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)cell));
+		}
+
+	if (ct->snd_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->snd_msg));
+	if (ct->adv_msg != NULL)
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->adv_msg));
+	ct->rcv_lst = ct->prf_lst = ct->val_lst = ct->snd_msg = ct->adv_msg = NULL;
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	/* ã¹ãã¼ãã¬ã¹ã®æã¯æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+	if (ct->act_msg != NULL) {
+		syscall(rel_mpf(MPF_DHCP6_CLI_MSG, (void*)ct->act_msg));
+		ct->act_msg = NULL;
+		}
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+	}
+
+/*
+ *  init_cli_msg -- åã¡ãã»ã¼ã¸æ§é ä½ãåæåããã
+ */
+
+static ER
+init_cli_msg (T_DHCP6_CLI_CONTEXT *ct)
+{
+	T_DHCP6_CLI_MSG	*cell;
+	ER		error;
+	int		count;
+
+	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	if ((error = tget_mpf(MPF_DHCP6_CLI_MSG, (void*)&ct->snd_msg, TMO_DHCP6C_MPF_GET)) != E_OK) {
+		syslog(LOG_NOTICE, "[DHCP6C] error, tget_mpf() for send: %s.", itron_strerror(error));
+		return error;
+		}
+
+	/*
+	 *  æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½ãããå ´åã¯ã
+	 *  ç²å¾ããåä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ãã®æ§é ä½ã 1æ¸ããã
+	 */
+	if (ct->act_msg == NULL)
+		count = NUM_DHCP6_CLI_MSG_LIST;
+	else
+		count = NUM_DHCP6_CLI_MSG_LIST - 1;
+
+	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãç²å¾ããã*/
+	syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+	while (count --> 0) {
+		if ((error = tget_mpf(MPF_DHCP6_CLI_MSG, (void*)&cell, TMO_DHCP6C_MPF_GET)) != E_OK) {
+			syslog(LOG_NOTICE, "[DHCP6C] error, tget_mpf() for receive: %s.", itron_strerror(error));
+			break;
+			}
+		cell->next  = ct->rcv_lst;
+		ct->rcv_lst = cell;
+		}
+	syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+	return E_OK;
+	}
+
+/*
+ *  dhcp6c_renew_info -- ãããã¯ã¼ã¯æ
+å ±ãååå¾ããã
+ */
+
+ER
+dhcp6c_renew_info (void)
+{
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+
+	if (context.fsm == DHCP6_FSM_INFORMED) {
+
+		/* REL_INFO ç¶æ
+ã«é·ç§»ããå¾ã« SLEEP ãè§£é¤ããããã«è¨­å®ããã*/
+		context.flags |= DHCP6C_FLAG_RENEW;
+		start_rel_info(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP6_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP6_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+
+	if (context.fsm == DHCP6_FSM_BOUND) {
+
+		/* RENEW ç¶æ
+ã«é·ç§»ããã*/
+		start_renew(&context);
+		return E_OK;
+		}
+	else if (context.fsm == DHCP6_FSM_SLEEP) {
+
+		/* SLEEP ãè§£é¤ããã*/
+		wup_tsk(DHCP6_CLI_TASK);
+		return E_OK;
+		}
+	else
+		return E_OBJ;
+
+#else	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+#endif	/* of #if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS */
+
+	}
+
+/*
+ *  dhcp6c_rel_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè§£æ¾ããã
+ */
+
+ER
+dhcp6c_rel_info (void)
+{
+	/* REL_INFO ç¶æ
+ã«é·ç§»ããã*/
+	start_rel_info(&context);
+	return E_OK;
+	}
+
+/*
+ *  dhcp6c_get_info -- DHCP ã§è¨­å®ããããããã¯ã¼ã¯æ
+å ±ãè¿ãã
+ */
+
+ER
+dhcp6c_get_info (T_IN6_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                   uint32_t *rebind, uint32_t *deprefer, SYSTIM *bind_start)
+{
+	if (addr   == NULL || expire ==   NULL || renew == NULL || 
+	    rebind == NULL || deprefer == NULL || bind_start == NULL)
+		return E_PAR;
+	else if (context.act_msg == NULL)
+		return E_OBJ;
+	else {
+		//            context.timers[DHCP6C_TIMER_EXPIRE],
+		//            context.timers[DHCP6C_TIMER_RENEW],
+		//            context.timers[DHCP6C_TIMER_REBIND],
+		//            context.timers[DHCP6C_TIMER_DEPREF]);
+
+		*addr = context.act_msg->srv.ipaddr;
+		*expire		= context.timers[DHCP6C_TIMER_EXPIRE];
+		*renew		= context.timers[DHCP6C_TIMER_RENEW];
+		*rebind		= context.timers[DHCP6C_TIMER_REBIND];
+		*deprefer	= context.timers[DHCP6C_TIMER_DEPREF];
+		*bind_start	= context.act_msg->rcv_time;
+		return E_OK;
+		}
+	}
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_dhcp6_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	T_DHCP6_CLI_MSG	*msg;
+	ER_UINT		len;
+
+	len = *(ER_UINT*)p_parblk;
+	if (len < 0 && len != E_RLWAI) {
+		/* E_RLWAI ä»¥å¤ã§ã0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[DHCP6C(CBR)] error: %s, fncd: %s.", itron_strerror(len), in_strtfn(fncd));
+		}
+	else {
+		if (fncd == TEV_UDP_RCV_DAT) {
+
+			/* åä¿¡ã¡ãã»ã¼ã¸ãªã¹ããç©ºã®æã¯ãåä¿¡ããªãã§ãã¼ã¿ã°ã©ã ãæ¨ã¦ãã*/
+			if (context.rcv_lst == NULL) 
+				syslog(LOG_NOTICE, "[DHCP6C(CBR)] receive buffer all busy.");
+			else {
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã¡ãã»ã¼ã¸æ§é ä½ãæºåããã*/
+				syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+				msg = context.rcv_lst;
+				context.rcv_lst = context.rcv_lst->next;
+				syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+
+				/* ã¡ãã»ã¼ã¸ãåä¿¡ããã*/
+				len = UDP_RCV_DAT(context.cepid, &msg->srv, &msg->msg, sizeof(msg->msg), TMO_POL);
+
+				syscall(wai_sem(SEM_DHCP6_CLI_LOCK));
+				msg->len = len;
+				if (len >= 0) {
+					/* åä¿¡ããã¡ãã»ã¼ã¸ãæ¤è¨¼ã¡ãã»ã¼ã¸ãªã¹ãã«ç§»ãã*/
+					msg->next = context.val_lst;
+					context.val_lst = msg;
+					context.flags |= DHCP6C_FLAG_RCV_MSG;
+					}
+				else {
+					/* ã¡ãã»ã¼ã¸æ§é ä½ãåä¿¡ã¡ãã»ã¼ã¸ãªã¹ãã«æ»ãã*/
+					context.error = len;
+					msg->next = context.rcv_lst;
+					context.rcv_lst = msg;
+					}
+				syscall(sig_sem(SEM_DHCP6_CLI_LOCK));
+				}
+			}
+		syscall(sig_sem(SEM_DHCP6_CLI_READY));
+		}
+	return E_OK;
+	}
+/*
+ *  dhcp6_cli_task -- DHCPv6 ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯
+ */
+
+void
+dhcp6_cli_task (intptr_t exinf)
+{
+	T_DHCP6_CLI_CONTEXT	*ct;
+	ID			tskid;
+	ER			error;
+
+	dly_tsk(1000);
+	get_tid(&tskid);
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+	syslog(LOG_NOTICE, "[DHCP6C:%d] started in stateless.", tskid);
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+	syslog(LOG_NOTICE, "[DHCP6C:%d] started in statefull.", tskid);
+#else
+#endif
+
+	dly_tsk(500);
+	ct = &context;
+
+	/* DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½ãåæåããã*/
+	init_context(ct, (ID)exinf);
+
+	while (true) {
+
+		/* 1ç§æ¯ã«ã¿ã¤ã ã¢ã¦ãããããã«ã¿ã¤ãã¼ãè¨­å®ããã*/
+		timeout((callout_func)dhcpc_timer, ct, NET_TIMER_HZ / DHCP6C_TIMER_HZ);
+
+		/* ã¯ã©ã¤ã¢ã³ã DUID ãè¨­å®ããã*/
+		init_duid(ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãåæåããã*/
+		if ((error = init_cli_msg(ct))  == E_OK) {
+
+#if DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATELESS
+			start_req_info(ct);
+#elif DHCP6_CLI_CFG_MODE == DHCP6_CLI_CFG_STATEFULL
+			start_init(ct);
+#else
+#endif
+
+			/* ã¡ã¤ã³ã«ã¼ã */
+			error = dispatch_event(ct);
+			}
+
+		/* å
+¨ã¦ã® TIMER ãã­ã£ã³ã»ã«ããã*/
+		cancel_all_timers(ct);
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)dhcpc_timer, ct);
+
+		/* ã¡ãã»ã¼ã¸æ§é ä½ãè§£æ¾ããã*/
+		rel_cli_msg(ct);
+
+		/* ãªã¼ã¹ãè§£æ¾å¾ãååå¾ãæå®ããã¦ããªããã°ä¼æ­¢ããã*/
+		if (!(ct->flags & DHCP6C_FLAG_RENEW)) {
+
+			/* ä¼æ­¢ããã*/
+			if (error == E_OK)
+				syslog(LOG_NOTICE, "[DHCP6C] lease released, go to sleep.");
+			else {
+				syslog(LOG_NOTICE, "[DHCP6C] server not available, go to sleep, error: %s.", itron_strerror(error));
+				ct->fsm = DHCP6_FSM_SLEEP;
+				}
+			slp_tsk();
+			}
+		ct->flags = 0;
+		ct->error = E_OK;
+		}
+	}
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.cfg	(revision 317)
@@ -0,0 +1,70 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(DHCP6_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP6_DHCP_CLI_CEPID,
+	dhcp6_cli_task,
+	DHCP6_CLI_MAIN_PRIORITY,
+	DHCP6_CLI_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_DHCP6_CLI_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_DHCP6_CLI_TIMER,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_DHCP6_CLI_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli.h	(revision 317)
@@ -0,0 +1,282 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_CLI_H
+#define DHCP6_CLI_H
+
+#ifdef DHCP6_CLI_CFG
+
+#include <netinet/in.h>
+#include <netapp/dhcp6.h>
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®ã¹ã¿ãã¯ãµã¤ãº
+ */
+
+#define DHCP6_CLI_STACK_SIZE		1024		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* 
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã®åªå
+åº¦
+ */
+
+#define DHCP6_CLI_MAIN_PRIORITY		5		/* DHCP ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* 
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³
+ */
+
+/*
+ *  DHCPv6 åä½ã¢ã¼ã
+ *
+ *    #define DHCP6_CLI_CFG_MODE ã§æå®ããã
+ *    æå®ããã¦ããªããã°ãã¹ãã¼ãã¬ã¹ã«è¨­å®ããã
+ *
+ */
+
+#define DHCP6_CLI_CFG_STATELESS		0	/* ã¹ãã¼ãã¬ã¹ã«è¨­å®ããã		*/
+#define DHCP6_CLI_CFG_STATEFULL		1	/* ã¹ãã¼ããã«ã«è¨­å®ããã		*/
+#define DHCP6_CLI_CFG_RA		2	/* RA ã® M/O ãããã«ããè¨­å®ããã	*/
+#define DHCP6_CLI_CFG_MODE_DEFAULT	DHCP6_CLI_CFG_STATELESS
+
+/* IA ã®è¨­å® */
+#define DHCP6_CLI_CFG_IA_NA		1
+//#define DHCP6_CLI_CFG_IA_TA		1
+//#define DHCP6_CLI_CFG_IA_PD		1
+
+/* Rapid-commit ã®æå® */
+//#define DHCP6_CLI_CFG_RAPID_COMMIT	1
+
+/* æ¨å¥¨åº¦ã®å®ç¾© */
+#define DHCP6_CLI_CFG_PREFER_IA		50	/* IA_NA/TA/PD å½ããã®æ¨å¥¨åº¦	*/
+#define DHCP6_CLI_CFG_PREFER_IAADDR	100	/* ã¢ãã¬ã¹å½ããã®æ¨å¥¨åº¦	*/
+
+/* DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸ã®åä¿¡ãªã¹ããµã¤ãºï¼2ä»¥ä¸æå®ãããã¨ï¼ */
+#define NUM_DHCP6_CLI_MSG_LIST		3
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½æ°ãå¤æ´ç¦æ­¢ã
+ *  +1 ã¯éä¿¡ç¨
+ */
+#define NUM_MPF_DHCP6_CLI_MSG		(NUM_DHCP6_CLI_MSG_LIST+1)
+
+/* DHCP å¿
+é ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP6_CLI_CFG_REQUIRED_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP6_CLI_CFG_REQUIRED_OLIST {	\
+	DHCP6_OPT_NAME_SERVERS,		\
+	}
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP6_CLI_CFG_REQUIRED_OLIST */
+
+/* DHCP è¦æ±ãªãã·ã§ã³ãªã¹ã */
+
+#ifndef DHCP6_CLI_CFG_REQUEST_OLIST
+
+#if defined(USE_RESOLVER)
+
+#define DHCP6_CLI_CFG_REQUEST_OLIST {	\
+	DHCP6_OPT_DOMAIN_SEARCH,	\
+	}
+
+#else	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #if defined(USE_RESOLVER) */
+
+#endif	/* of #ifndef DHCP6_CLI_CFG_REQUEST_OLIST */
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå®æ°
+ *  RFC3315 ã«è¦å®ãããã¿ã¤ãã³ã°å®æ°ã¯ dhcp6.h åç
+§
+ */
+
+/* æ¨æºã¡ãã»ã¼ã¸ã®åéä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_NORMAL	ULONG_C(60*1000)
+
+/* æ¨æºè¦æ±ãªã¼ã¹æé			*/
+#define TMO_DHCP6C_REQ_LEASE	ULONG_C(7200*1000)
+
+/* ã¡ãã»ã¼ã¸æ§é ä½ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_MPF_GET	ULONG_C(1000)
+
+/* ã¡ãã»ã¼ã¸åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DHCP6C_RCV_DAT	ULONG_C(1000)
+
+/*
+ *  DHCPv6 ã¯ã©ã¤ã¢ã³ãã¡ãã»ã¼ã¸æ§é ä½
+ */
+
+typedef struct dhcp6_cli_msg {
+	/* 4ãã¤ãå¢çã«ã¢ã©ã¤ã³ããã*/
+	T_DHCP6_MSG		msg;		/* DHCPv6 ã¡ãã»ã¼ã¸æ§é ä½	*/
+	struct dhcp6_cli_msg	*next;		/* ãªã¹ãã®æ¬¡ã®ã¡ãã»ã¼ã¸æ§é ä½	*/
+	SYSTIM			rcv_time;	/* åä¿¡ããæé			*/
+	T_IPV6EP		srv;		/* ãµã¼ãã®IPv6ã¢ãã¬ã¹/ãã¼ãçªå· */
+	uint16_t		len;		/* msg ã®æå¹é·			*/
+	uint16_t		prefer;		/* msg ã®æ¨å¥¨åº¦			*/
+	uint16_t		status;		/* STATUS CODE ãªãã·ã§ã³ã® status */
+	} T_DHCP6_CLI_MSG;
+
+/* prefer ã®ãã©ã° */
+
+#define DHCP6_ClI_MSG_PREFER_ADDR	UINT_C(0x8000)	/* ã¢ãã¬ã¹æ
+å ±ãã		*/
+#define DHCP6_ClI_MSG_PREFER_REQUIRED	UINT_C(0x4000)	/* å¿
+é ãªãã·ã§ã³ãã		*/
+#define DHCP6_ClI_MSG_PREFER_REQUEST	UINT_C(0x2000)	/* è¦æ±ãªãã·ã§ã³ãã		*/
+#define DHCP6_ClI_MSG_PREFER_OPTION	UINT_C(0x1000)	/* PREFER ãªãã·ã§ã³ãã	*/
+#define DHCP6_ClI_MSG_PREFER_FLAG_MASK	UINT_C(0xf000)
+#define DHCP6_ClI_MSG_PREFER_VALUE_MASK	(~(DHCP6_ClI_MSG_PREFER_FLAG_MASK))
+
+/*
+ *  STATUS CODE ãªãã·ã§ã³ãç¡ãæã®å¤
+ */
+
+#define DHCP6_CLI_STAT_UNDEFINED	(-1)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+extern ER callback_nblk_dhcp6_cli (ID cepid, FN fncd, void *p_parblk);
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	dhcp6_cli_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER dhcp6c_rel_info (void);
+extern ER dhcp6c_renew_info (void);
+extern ER dhcp6c_get_info (T_IN6_ADDR *addr, uint32_t *expire, uint32_t *renew,
+                                             uint32_t *rebind, uint32_t *deprefer, SYSTIM *bind_start);
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
+
+#endif	/* of #ifndef DHCP6_CLI_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_asp.cfg	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+INCLUDE("netapp/dhcp6_cli.cfg");
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP6_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP6_CLI_MSG,
+	sizeof(T_DHCP6_CLI_MSG),
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_jsp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_jsp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_jsp.cfg	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é DHCP ã¯ã©ã¤ã¢ã³ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+#include "netapp/dhcp6_cli.cfg"
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_DHCP6_CLI_MSG, {
+	TA_TFIFO,
+	NUM_MPF_DHCP6_CLI_MSG,
+	sizeof(T_DHCP6_CLI_MSG),
+	NULL
+	});
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dhcp6_cli_var.h	(revision 317)
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 1995-2003 by Internet Software Consortium
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *   Internet Systems Consortium, Inc.
+ *   950 Charter Street
+ *   Redwood City, CA 94063
+ *   <info@isc.org>
+ *   https://www.isc.org/
+ *
+ * This code is based on the original client state machine that was
+ * written by Elliot Poger.  The code has been extensively hacked on
+ * by Ted Lemon since then, so any mistakes you find are probably his
+ * fault and not Elliot's.
+ */
+/*
+ * WIDE Project DHCP Implementation
+ * Copyright (c) 1995-1997 Akihiro Tominaga
+ * Copyright (c) 1995-1997 WIDE Project
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided the following conditions
+ * are satisfied,
+ *
+ * 1. Both the copyright notice and this permission notice appear in
+ *    all copies of the software, derivative works or modified versions,
+ *    and any portions thereof, and that both notices appear in
+ *    supporting documentation.
+ * 2. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by WIDE Project and
+ *      its contributors.
+ * 3. Neither the name of WIDE Project 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 DEVELOPER ``AS IS'' AND WIDE
+ * PROJECT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. ALSO, THERE
+ * IS NO WARRANTY IMPLIED OR OTHERWISE, NOR IS SUPPORT PROVIDED.
+ *
+ * Feedback of the results generated from any improvements or
+ * extensions made to this software would be much appreciated.
+ * Any such feedback should be sent to:
+ * 
+ *  Akihiro Tominaga
+ *  WIDE Project
+ *  Keio University, Endo 5322, Kanagawa, Japan
+ *  (E-mail: dhcp-dist@wide.ad.jp)
+ *
+ * WIDE project has the rights to redistribute these changes.
+ */
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DHCP6_CLI_VAR_H
+#define DHCP6_CLI_VAR_H
+
+#ifdef DHCP6_CLI_CFG
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ãã³ã³ãã­ã¹ãæ§é ä½
+ */
+
+/* TIMER ã®å®ç¾© */
+
+#define DHCP6C_TIMER_SND_SOL	0
+#define DHCP6C_TIMER_SND_REQ	1
+#define DHCP6C_TIMER_SND_REL	2
+#define DHCP6C_TIMER_RCV_ADV	3
+#define DHCP6C_TIMER_RCV_REPLY	4
+#define DHCP6C_TIMER_RENEW	5
+#define DHCP6C_TIMER_REBIND	6
+#define DHCP6C_TIMER_EXPIRE	7
+#define DHCP6C_TIMER_DEPREF	8
+#define DHCP6C_TIMER_SND_REF	9
+#define DHCP6C_TIMER_SND_IREQ	10
+#define NUM_DHCP6C_TIMERS	11
+
+#define DHCP6C_TIMER_HZ		1
+
+/* å®æ°ã®å®ç¾© */
+
+#define MAX_DUID_LEN		(ETHER_ADDR_LEN+8)
+
+typedef struct dhcp6_cli_context {
+	T_DHCP6_CLI_MSG		*rcv_lst;	/* åä¿¡ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*val_lst;	/* æ¤è¨¼ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*prf_lst;	/* æ¨å¥¨ã¡ãã»ã¼ã¸æ§é ä½ãªã¹ã		*/
+	T_DHCP6_CLI_MSG		*snd_msg;	/* éä¿¡ã¡ãã»ã¼ã¸æ§é ä½			*/
+	T_DHCP6_CLI_MSG		*adv_msg;	/* éç¥ããããªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_DHCP6_CLI_MSG		*act_msg;	/* æå¹ãªãªã¼ã¹ã»ã¡ãã»ã¼ã¸æ§é ä½	*/
+	T_IF_SOFTC		*sc;		/* IF ã®ã½ããã¦ã§ã¢æ
+å ±		*/
+	T_IPV6EP		dst;		/* éä¿¡å
+ã®IPã¢ãã¬ã¹/ãã¼ãçªå·	*/
+	SYSTIM			RT;		/* åéä¿¡éé				*/
+	SYSTIM			IRT;		/* åæåéä¿¡éé			*/
+	SYSTIM			MRT;		/* æå¤§åéä¿¡éé			*/
+	SYSTIM			MRD;		/* æå¤§åéä¿¡ç¶ç¶æé			*/
+	SYSTIM			next_MRD;	/* æ¬¡ã®æå¤§åéä¿¡ç¶ç¶æé		*/
+	SYSTIM			timers[NUM_DHCP6C_TIMERS];	
+						/* ã¿ã¤ãã¼é
+å			*/
+	ER_UINT			error;		/* ã¨ã©ã¼ã»ãã¼ã¿é·		*/
+	ID			cepid;		/* CEP ID			*/
+	uint32_t		xid;		/* ãã©ã³ã¶ã¯ã·ã§ã³ ID		*/
+	uint16_t		flags;		/* åç¨®ãã©ã°			*/
+	uint16_t		max_prefer;	/* åä¿¡ã¡ãã»ã¼ã¸ã®æå¤§æ¨å¥¨åº¦	*/
+	uint8_t			duid[MAX_DUID_LEN];	
+						/* client DHCP Unique ID	*/
+	uint8_t			duid_len;	/* client DUID é·		*/
+	uint8_t			fsm;		/* ç¾å¨ã®ç¶æ
+			*/
+	uint8_t			MRC;		/* æå¤§åéä¿¡åæ°		*/
+	uint8_t			txcount;	/* åéä¿¡åæ°			*/
+	uint8_t			refresh_type;	/* REFRESH ã®ã¡ãã»ã¼ã¸ã¿ã¤ã	*/
+	} T_DHCP6_CLI_CONTEXT;
+
+/* fsmï¼ç¶æ
+é·ç§»ï¼ã®å®ç¾© */
+
+#define DHCP6_FSM_INIT		1
+#define DHCP6_FSM_SELECT	2
+#define DHCP6_FSM_BOUND		4
+#define DHCP6_FSM_RENEW		5
+#define DHCP6_FSM_REBIND	6
+#define DHCP6_FSM_REQ_INFO	9	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_INFORMED	10	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_REL_INFO	11	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+#define DHCP6_FSM_SLEEP		12	/* DHCPv6 ã® RFC3315 ã«ã¯ç¡ãã*/
+
+/* flag ã®å®ç¾© */
+
+#define DHCP6C_FLAG_TMOUT_SND_SOL	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_SOL)
+#define DHCP6C_FLAG_TMOUT_SND_REQ	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REQ)
+#define DHCP6C_FLAG_TMOUT_SND_REL	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REL)
+#define DHCP6C_FLAG_TMOUT_RCV_ADV	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RCV_ADV)
+#define DHCP6C_FLAG_TMOUT_RCV_REPLY	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RCV_REPLY)
+#define DHCP6C_FLAG_TMOUT_RENEW		(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_RENEW)
+#define DHCP6C_FLAG_TMOUT_REBIND	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_REBIND)
+#define DHCP6C_FLAG_TMOUT_EXPIRE	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_EXPIRE)
+#define DHCP6C_FLAG_TMOUT_DEPREF	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_DEPREF)
+#define DHCP6C_FLAG_TMOUT_SND_REF	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_REF)
+#define DHCP6C_FLAG_TMOUT_SND_IREQ	(DHCP6C_FLAG_TMOUT_TIMER|DHCP6C_TIMER_SND_IREQ)
+#define DHCP6C_FLAG_TMOUT_TIMER		UINT_C(0x0010)
+#define DHCP6C_FLAG_TMOUT_TIMER_MASK	UINT_C(0x000f)
+#define DHCP6C_FLAG_TMOUT_MASK		UINT_C(0x001f)
+
+#define DHCP6C_FLAG_RCV_MSG		UINT_C(0x0200)
+#define DHCP6C_FLAG_RENEW		UINT_C(0x0400)
+
+/* IAADDR æ§é ä½ã® FLAG ã®å®ç¾©ï¼len ã«å¤éåããï¼*/
+
+#define DHCP6C_IAA_FLAG_EXPIRED		UINT_C(0x8000)
+#define DHCP6C_IAA_FLAG_DEPREFERD	UINT_C(0x4000)
+#define DHCP6C_IAA_FLAG_MASK		UINT_C(0xc000)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* æéæ¯è¼ */
+
+#define TIMEC_GT(a,b)		((int32_t)((a)-(b))>0)
+#define TIMEC_GE(a,b)		((int32_t)((a)-(b))>=0)
+
+/* æéå®æ°ã®å¤æ */
+
+#define SYSTIM2TIMER(t)		(((t)<SYSTIM_HZ/DHCP6C_TIMER_HZ)?(DHCP6C_TIMER_HZ):((t)*DHCP6C_TIMER_HZ)/SYSTIM_HZ)
+#define SYSTIM2SEC(t)		(((t)<SYSTIM_HZ)?1:((t)/SYSTIM_HZ))
+#define SEC2TIMER(t)		((t)*DHCP6C_TIMER_HZ)
+#define SEC2SYSTIM(t)		((t)*SYSTIM_HZ)
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
+
+#endif	/* of #ifndef DHCP6_CLI_VAR_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/dns.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/dns.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/dns.h	(revision 317)
@@ -0,0 +1,294 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef DNS_H
+#define DNS_H
+
+/*
+ *  DNS ã¡ãã»ã¼ã¸ã«é¢ããå®ç¾©
+ *
+ *    RFC1034ãRFC1035ãRFC1886ãRFC2136ã
+ *    RFC2671ãRFC2845ãRFC2930ãRFC3596
+ *
+ *  DNS ã¡ãã»ã¼ã¸
+ *
+ *  +---------------------+
+ *  |       Header        |
+ *  +---------------------+
+ *  |      Question       | Question section å½¢å¼
+ *  +---------------------+
+ *  |       Answer        | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *  |     Authority       | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *  |     Additional      | RR (Resouce Record) å½¢å¼
+ *  +---------------------+
+ *
+ *  DNS ããã
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                      ID                       |
+ *  +--+-----------+--+--+--+--+--------+-----------+
+ *  |QR|   Opcode  |AA|TC|RD|RA|    Z   |   RCODE   |
+ *  +--+--------+--+--+--+--+--+--------+-----------+
+ *  |                    QDCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ANCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    NSCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ARCOUNT                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct dns_hdr {
+	uint16_t	id;		/* ID */
+	uint16_t	code;	/* QR:		1
+				   Opcode:	4
+				   AA:		1
+				   TC:		1
+				   RD:		1
+				   RA:		1
+				   Z:		3
+				   RCODE:	4
+				   */
+	uint16_t	qdcount;	/* question   section */
+	uint16_t	ancount;	/* answer     section */
+	uint16_t	nscount;	/* authority  section */
+	uint16_t	arcount;	/* additional section */
+	} T_DNS_HDR;
+
+/*
+ *  code ã®å®ç¾©
+ */
+
+/* QR ã®å®ç¾© */
+
+#define DNS_QR_QUERY		0x0000U
+#define DNS_QR_RESPONSE		0x8000U
+
+/* Opcode ã®å®ç¾© */
+
+#define DNS_OPCODE_MASK		0x7800U
+#define DNS_OPCODE_FORWARD	0x0000U
+#define DNS_OPCODE_REVERSE	0x0800U
+#define DNS_OPCODE_STATUS	0x1000U
+
+/* AA ã®å®ç¾© */
+
+#define DNS_AUTHORITATIVE	0x0400U
+
+/* TC ã®å®ç¾© */
+
+#define DNS_TRUN_CATION		0x0200U
+
+/* RD ã®å®ç¾© */
+
+#define DNS_RECURSION_DESIRED	0x0100U
+
+/* RA ã®å®ç¾© */
+
+#define DNS_RECURSION_AVAILABLE	0x0080U
+
+/* RCODE ã®å®ç¾© */
+
+#define DNS_RCODE_MASK		0x000fU
+#define DNS_RCODE_NO_ERROR	0x0000U
+#define DNS_RCODE_FORMAT_ERROR	0x0001U
+#define DNS_RCODE_SERVER_ERROR	0x0002U
+#define DNS_RCODE_NAME_ERROR	0x0003U
+#define DNS_RCODE_NOT_IMPLEMENT	0x0004U
+#define DNS_RCODE_REFUSED	0x0005U
+
+/*
+ * DNS TYPE ã®å®ç¾©
+ */
+
+#define DNS_TYPE_A		(uint16_t)1U
+#define DNS_TYPE_NS		(uint16_t)2U
+#define DNS_TYPE_CNAME		(uint16_t)5U
+#define DNS_TYPE_SOA		(uint16_t)6U
+#define DNS_TYPE_PTR		(uint16_t)12U
+#define DNS_TYPE_AAAA		(uint16_t)28U
+
+/*
+ * DNS CLASS ã®å®ç¾©
+ */
+
+#define DNS_CLASS_IN		(uint16_t)1U
+
+/*
+ *  RR (Resouce Record) å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                      NAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                      TYPE                     |
+ *  +-----------------------------------------------+
+ *  |                      CLASS                    |
+ *  +-----------------------------------------------+
+ *  |                       TTL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    RDLENGTH                   |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RDATA                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ */
+
+typedef struct dns_rr {
+					/* NAME			*/
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	uint32_t	ttl;		/* TTL			*/
+	uint16_t	rdlength;	/* RDATA length		*/
+					/* RDATA		*/
+	} T_DNS_RR;
+
+#define T_DNS_RR_SIZE	(sizeof(uint16_t)*3+sizeof(uint32_t))
+
+/*
+ *  Question section å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     QNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                     QTYPE                     |
+ *  +-----------------------------------------------+
+ *  |                     QCLASS                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct dns_qd {
+					/* QNAME		*/
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	} T_DNS_QD;
+
+#define T_DNS_QD_SIZE	(sizeof(uint16_t)*2)
+
+/*
+ *  SOA RDATA å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     MNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                    SERIAL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    REFRESH                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                     RETRY                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    EXPIRE                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    MINIMUM                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ */
+
+typedef struct dns_soa {
+					/* MNAME		*/
+					/* RNAME		*/
+	uint32_t	serial;		/* SERIAL		*/
+	uint32_t	refresh;	/* REFRESH		*/
+	uint32_t	retry;		/* RETRY		*/
+	uint32_t	expire;		/* EXPIRE		*/
+	uint32_t	minimum;	/* MINIMUM		*/
+	} T_DNS_SOA;
+
+#define T_DNS_SOA_SIZE	(sizeof(uint32_t)*5)
+
+/*
+ *  DNS ã®å®æ°ã®å®ç¾©
+ */
+
+#define DNS_LABEL_LENGTH	63
+#define DNS_NAME_LENGTH		255
+#define DNS_UDP_MSG_LENGTH	512
+
+#define DNS_MSG_COMP_MARK	0xc0
+
+#endif	/* of #ifndef DNS_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/lcd.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/lcd.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/lcd.c	(revision 317)
@@ -0,0 +1,495 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <sil.h>
+#include "target_syssvc.h"
+#include "target_lcd.h"
+#include <kernel.h>
+#include <t_syslog.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "hw_lcd.h"
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/lcd.h>
+
+/*
+ *  å±æå¤æ°ã®å®ç¾©
+ */
+
+static bool_t newline = false;
+static int_t col = 0;
+static int8_t line[LCD_COLUMN_SIZE + 1] = { "                " };
+
+/*
+ *  lcd_cls -- LCD è¡¨ç¤ºã¯ãªã¢
+ */
+
+void
+lcd_cls (void)
+{
+	target_lcd_cls();
+	col = 0;
+	newline = false;
+	}
+
+/*
+ *  lcd_newline -- LCD ã®è¡¨ç¤ºãæ¹è¡ããã
+ */
+
+static void
+lcd_newline (void)
+{
+	target_lcd_newline(line, col);
+	col = 0;
+	newline = false;
+	}
+
+/*
+ *  lcd_initialize -- LCD åæå
+ */
+
+void
+lcd_initialize (intptr_t exinf)
+{
+	target_lcd_initialize();
+	lcd_cls();
+	}
+
+/*
+ *  lcd_putc -- LCD åºå
+ */
+
+void
+lcd_putc (ID portid, int8_t data)
+{
+	if (data == '\n')
+		newline = true;
+	else {
+		if (newline)
+			lcd_newline();
+		target_lcd_data_putc(data);
+		line[col ++] = data;
+		if (col >= LCD_COLUMN_SIZE)
+			newline = true;
+		}
+	}
+
+/*
+ *  lcd_puts -- LCD ã¸ã®æå­åã®åºå
+ */
+
+void
+lcd_puts (ID portid, const char *str)
+{
+	while (*str != '\0')
+		lcd_putc(portid, *str ++);
+	}
+
+/*
+ *  LCD ã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+
+/*
+ *  æ°å¤å¤æã®ããã®å¤æè¡¨
+ */
+
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  ãã£ã¨ãé·ãæ´æ°å (LONGEST) ã¨ç¬¦å·ãªãæ´æ°å (ULONGEST)
+ */
+
+#ifdef _int64_
+
+typedef _int64_			LONGEST;
+typedef unsigned _int64_	ULONGEST;
+
+#else	/* of #ifdef _int64_ */
+
+#ifdef _int32_
+
+typedef _int32_			LONGEST;
+typedef unsigned _int32_	ULONGEST;
+
+#else	/* of #ifdef _int32_ */
+
+typedef int_t			LONGEST;
+typedef uint_t			ULONGEST;
+
+#endif	/* of #ifdef _int32_ */
+
+#endif	/* of #ifdef _int64_ */
+
+/*
+ *  convert -- lcd_printf ã®æ°å¤å¤æ
+ */
+
+static int_t
+convert (ID portid, ULONGEST val, int_t radix,
+         const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+	bool_t	left;
+
+	if (width < 0) {
+		width = -width;
+		left = true;
+		}
+	else
+		left = false;
+
+	ix = 0;
+	do {
+		digits[ix ++] = radchar[val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	pad = ix;
+	if (!left)	/* å³è©°ã */
+		for ( ; pad < width; pad ++)
+			lcd_putc(portid, padchar);
+
+	while (ix -- > 0)
+		lcd_putc(portid, digits[ix]);
+
+	if (left)	/* å·¦è©°ã */
+		for ( ; pad < width; pad ++)
+			lcd_putc(portid, padchar);
+
+	return pchars;
+	}
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  ipv4addr -- IPv4 ã¢ãã¬ã¹åºå
+ */
+
+static void
+put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width)
+{
+	int_t len = 3;	/* 3 ã¯ '.' ã®æå­æ° */
+
+	len += convert(portid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	lcd_putc(portid, '.');
+	len += convert(portid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+
+	for ( ; len < width; len ++)
+		lcd_putc(portid, ' ');
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  ipv6addr -- IPv6 ã¢ãã¬ã¹åºå
+ */
+
+static void
+put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width)
+{
+	int_t	len = 0, ix;
+	bool_t	omit = false, zero = false;
+
+	if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) {
+		lcd_putc(portid, ':');
+		lcd_putc(portid, ':');
+		}
+	else {
+		for (ix = 0; ix < sizeof(T_IN6_ADDR) / 2; ix ++) {
+			if (omit) {
+				if (ix < 7) {
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				}
+			else if (ix > 0 && ix < 7 && addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				if (ix < 7) {
+					lcd_putc(portid, ':');
+					len ++;
+					}
+				}
+			}
+
+		for ( ; len < width; len ++)
+			lcd_putc(portid, ' ');
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  macaddr -- MAC ã¢ãã¬ã¹åºå
+ */
+
+static void
+macaddr (ID portid, uint8_t *mac, int_t width)
+{
+	int_t oct, len;
+
+	for (oct = 5; oct -- > 0; ) {
+		convert(portid, *mac ++, 16, radhex, 2, false, '0'); 
+		lcd_putc(portid, ':');
+		}
+	convert(portid, *mac, 16, radhex, 2, false, '0'); 
+
+	for (len = 17; len < width; len ++)
+		lcd_putc(portid, ' ');
+	}
+
+/*
+ *  å¼æ°ãåãåºãããã®ãã¯ã­
+ */
+
+#ifdef _int32_
+
+#define GET_ARG(ap,lf)	 (lf ? va_arg(ap, _int32_) : va_arg(ap, int_t))
+
+#else	/* of #ifdef _int32_ */
+
+#define GET_ARG(ap,lf)	(va_arg(ap, int_t))
+
+#endif	/* of #ifdef _int32_ */
+
+/*
+ *  lcd_printf -- ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºå
+ */
+
+void
+lcd_printf (ID portid, const char *fmt, ...)
+{
+	va_list	ap;
+	LONGEST	val;
+	char	padchar, *str;
+	int_t	ch, width, longflag, shortflag, left;
+
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	*addr;
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+	va_start(ap, fmt);
+	while ((ch = *fmt ++) != '\0') {
+		if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+			lcd_putc(portid, (char)ch);
+			continue;
+			}
+
+		width = longflag = shortflag = 0;
+		padchar = ' ';
+
+		if (ch == '-') {		/* å·¦è©°ã */
+			fmt ++;
+			left = -1;
+			}
+		else
+			left = 1;
+
+		if ((ch = *fmt ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+			padchar = '0';
+			ch = *fmt ++;
+			}
+
+		while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+			width = width * 10 + ch - '0';
+			ch = *fmt ++;
+			}
+
+		while (ch == 'l') {		/* long (long) ã®æå® */
+			longflag ++;
+			ch = *fmt ++;
+			}
+
+		while (ch == 'h') {		/* short ã®æå® */
+			shortflag ++;
+			ch = *fmt ++;
+			}
+
+		switch (ch) {
+		case 'd':
+			val = GET_ARG(ap, longflag);
+			if (val >= 0)
+				convert(portid, val, 10, radhex, width * left, false, padchar);
+			else
+				convert(portid, -val, 10, radhex, width * left, true, padchar);
+			break;
+
+		case 'u':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 10, radhex, width * left, false, padchar);
+			break;
+
+		case 'x':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 16, radhex, width * left, false, padchar);
+			break;
+
+		case 'X':
+			val = GET_ARG(ap, longflag);
+			convert(portid, val, 16, radHEX, width * left, false, padchar);
+			break;
+
+		case 'c':
+			ch = va_arg(ap, int_t);
+			lcd_putc(portid, (char)ch);
+			break;
+
+		case 's':
+			str = va_arg(ap, char*);
+			while ((ch = *str ++) != '\0')
+				lcd_putc(portid, (char)ch);
+			break;
+
+		case 'I':
+
+			if (longflag) {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				}
+			else if (shortflag) {
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+				}
+			else {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				}
+			break;
+
+		case 'M':
+			str = va_arg(ap, char*);
+			macaddr(portid, str, width);
+			break;
+
+		case '%':
+			lcd_putc(portid, '%');
+			break;
+
+		case '0':
+			fmt --;
+			break;
+
+		default:
+			break;
+			}
+
+		}
+	va_end(ap);
+	}
Index: asp3_gr_sakura/trunk/tinet/netapp/lcd.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/lcd.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/lcd.h	(revision 317)
@@ -0,0 +1,78 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  æ±ç¨ LCD ãã©ã¤ã
+ */
+
+#ifndef LCD_H
+#define LCD_H
+
+/*
+ *  lcd_cls -- LCD è¡¨ç¤ºã¯ãªã¢
+ */
+extern void lcd_cls (void);
+
+/*
+ *  lcd_initialize -- LCD åæå
+ */
+extern void lcd_initialize (intptr_t exinf);
+
+/*
+ *  lcd_putc -- LCD åºå
+ */
+extern void lcd_putc (ID portid, int8_t data);
+
+/*
+ *  lcd_puts -- LCD ã¸ã®æå­åã®åºå
+ */
+extern void lcd_puts (ID portid, const char *str);
+
+/*
+ *  LCD ã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+extern void lcd_printf (ID portid, const char *fmt, ...);
+
+#endif	/* of #ifndef LCD_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/net_cons.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/net_cons.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/net_cons.c	(revision 317)
@@ -0,0 +1,609 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
+¥åºå
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <syssvc/serial.h>
+#include <syssvc/logtask.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/net_cons.h>
+
+#ifdef USE_NET_CONS
+
+/*
+ *  ãã¯ã­å®ç¾©
+ */
+
+/*  ãªãã¼ã ã®è§£é¤  */
+
+#undef syslog
+#undef serial_rea_dat
+#undef serial_ctl_por
+
+#define EOF		(-1)
+
+/*  TELNET ãªãã·ã§ã³ */
+
+#define TELNET_OPT_SE		(240)
+#define TELNET_OPT_NOP		(241)
+#define TELNET_OPT_DM		(242)
+#define TELNET_OPT_BRK		(243)
+#define TELNET_OPT_IP		(244)
+#define TELNET_OPT_AO		(245)
+#define TELNET_OPT_AYT		(246)
+#define TELNET_OPT_EC		(247)
+#define TELNET_OPT_EL		(248)
+#define TELNET_OPT_GA		(249)
+#define TELNET_OPT_SB		(250)
+#define TELNET_OPT_WILL		(251)
+#define TELNET_OPT_WONT		(252)
+#define TELNET_OPT_DO		(253)
+#define TELNET_OPT_DONT		(254)
+#define TELNET_OPT_IAC		(255)
+
+#if defined(SUPPORT_INET6)
+#define API_PROTO		'6'
+#else
+#define API_PROTO		'4'
+#endif
+
+/*
+ *  å¤æ°
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+uint8_t net_cons_swbuf[NET_CONS_SWBUF_SIZE];
+uint8_t net_cons_rwbuf[NET_CONS_RWBUF_SIZE];
+
+bool_t	connected	= false;	/* ã³ãã¯ã·ã§ã³ã®ç¶æ
+	*/
+bool_t	wait_accept	= false;	/* æ¥ç¶è¦æ±å¾
+ã¡ä¸­	*/
+
+#if defined(SUPPORT_INET6)
+
+T_IPV6EP	dst;
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+T_IPV4EP	dst;
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+uint8_t		*snd_buff	= NULL;
+uint8_t		*rcv_buff	= NULL;
+uint_t		snd_off		= 0;
+uint_t		rcv_off		= 0;
+uint_t		net_ioctl	= IOCTL_NULL;
+ER_UINT		snd_len		= 0;
+ER_UINT		rcv_len		= 0;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_net_cons (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+	SYSTIM	now;
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		get_tim(&now);
+		if (*(ER*)p_parblk == E_OK) {
+			syslog(LOG_NOTICE, "[NCS%c:%02u CBN] conct: %7lu, from: %s.%u",
+			                   API_PROTO, cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+			connected = true;
+			}
+		else
+			syslog(LOG_NOTICE, "[NCS%c:%02d CBN] error: %s",
+			                   API_PROTO, itron_strerror(*(ER*)p_parblk));
+		snd_len = snd_off = rcv_len = rcv_off = 0;
+		wait_accept = false;
+		break;
+
+	case TFN_TCP_CLS_CEP:
+	case TFN_TCP_RCV_BUF:
+	case TFN_TCP_GET_BUF:
+	case TFN_TCP_RCV_DAT:
+	case TFN_TCP_SND_DAT:
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  éä¿¡ãããã¡ã®ãã©ãã·ã¥
+ */
+
+void
+flush_snd_buff (void)
+{
+	ER_UINT	error;
+
+	if (connected) {
+		syscall(wai_sem(SEM_NET_CONS_SEND));
+		if (snd_off > 0) {
+			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
+				syslog(LOG_NOTICE, "[NCS%c:%02d SND] flush send error: %s",
+				                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+			snd_len = snd_off = 0;
+			}
+		syscall(sig_sem(SEM_NET_CONS_SEND));
+		}
+	return;
+	}
+
+/*
+ *  æå­éä¿¡
+ */
+
+void
+cons_putchar (ID portid, char ch)
+{
+	ER_UINT	error;
+
+	if (connected) {
+		if (ch == '\n' && (net_ioctl & IOCTL_CRLF) != 0)
+			cons_putchar(portid, '\r');
+		syscall(wai_sem(SEM_NET_CONS_SEND));
+		if (snd_off >= snd_len) {
+			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK) {
+				if (error != E_CLS)
+					syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+				syscall(sig_sem(SEM_NET_CONS_SEND));
+				return;
+				}
+			snd_off = 0;
+			if ((snd_len = tcp_get_buf(NET_CONS_CEPID, (void*)&snd_buff, TMO_FEVR)) <= 0) {
+				if (snd_len != E_CLS)
+					syslog(LOG_NOTICE, "[NCS%c:%02d SND] get buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(snd_len));
+				syscall(sig_sem(SEM_NET_CONS_SEND));
+				return;
+				}
+			}
+		snd_buff[snd_off ++] = ch;
+		syscall(sig_sem(SEM_NET_CONS_SEND));
+		}
+	else
+		serial_wri_dat(portid, &ch, sizeof(ch));
+	}
+
+/*
+ *  æå­åä¿¡ï¼å¤æãªãï¼
+ */
+
+static int_t
+cons_getchar_raw (void)
+{
+	ER	error = E_OK;
+
+	if (connected) {
+		if (rcv_off >= rcv_len) {
+			rcv_off = 0;
+			if ((error = tcp_rel_buf(NET_CONS_CEPID, rcv_len)) != E_OK) {
+				if (error != E_CLS)
+					syslog(LOG_NOTICE, "[NCS%c:%02d RCV] release buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+				discon_net_cons();
+				return EOF;
+				}
+			if ((rcv_len = tcp_rcv_buf(NET_CONS_CEPID, (void*)&rcv_buff, TMO_FEVR)) == 0) {
+				discon_net_cons();
+				return EOF;
+				}
+			else if (rcv_len < 0) {
+				if (rcv_len != E_CLS)
+					syslog(LOG_NOTICE, "[NCS%c:%02d RCV] recieve buff error: %s",
+					                   API_PROTO, NET_CONS_CEPID, itron_strerror(rcv_len));
+				discon_net_cons();
+				return EOF;
+				}
+			}
+		return rcv_buff[rcv_off ++];
+		}
+	else
+		return EOF;
+	}
+
+/*
+ *  æå­åä¿¡ï¼TELNET ãªãã·ã§ã³ãã¹ã­ããï¼
+ */
+
+int_t
+cons_getchar (ID portid)
+{
+	T_SERIAL_RPOR	rpor;
+	int_t		ch;
+	char		uch;
+	ER		error;
+
+	if (!wait_accept && !connected) {
+		wait_accept = true;
+		error = TCP_ACP_CEP(NET_CONS_CEPID, NET_CONS_REPID, &dst, TMO_NBLK);
+#if 0
+		syslog(LOG_NOTICE, "[NCS%c:%02d ACP] status: %s",
+		                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+#endif
+		if (error != E_WBLK)
+			return EOF;
+		}
+
+	while (true) {
+		if (connected) {
+			while ((ch = cons_getchar_raw()) == TELNET_OPT_IAC || ch == '\0') {
+				if (ch != '\0') {
+					switch (ch = cons_getchar_raw()) {
+					case TELNET_OPT_WILL:
+					case TELNET_OPT_WONT:
+					case TELNET_OPT_DO:
+					case TELNET_OPT_DONT:
+						cons_getchar_raw();
+						break;
+					case TELNET_OPT_SB:
+						while ((ch = cons_getchar_raw()) != EOF && ch != TELNET_OPT_IAC) {
+							if ((ch = cons_getchar_raw()) == EOF || ch == TELNET_OPT_SE)
+								break;
+							}
+						break;
+					default:
+						break;
+						}
+					}
+				}
+			if (ch != '\n') {
+				if ((net_ioctl & IOCTL_ECHO) != 0 && ch != EOF) {
+					cons_putchar(portid, ch);
+					flush_snd_buff();
+					}
+				return ch;
+				}
+			}
+
+		else if (serial_ref_por(portid, &rpor) == E_OK && rpor.reacnt > 0) {
+			if (serial_rea_dat(portid, &uch, sizeof(uch)) > 0)
+				return uch;
+			else
+				return EOF;
+			}
+		dly_tsk(100);
+		}
+	return EOF;
+	}
+
+/*
+ *  ã³ãã¯ã·ã§ã³ãåæ­
+ */
+
+ER
+discon_net_cons (void)
+{
+	ER	error = E_OK;
+	SYSTIM	now;
+
+	if (connected) {
+		syscall(wai_sem(SEM_NET_CONS_SEND));
+		if (snd_off > 0) {
+			if ((error = tcp_snd_buf(NET_CONS_CEPID, snd_off)) != E_OK && error != E_CLS)
+				syslog(LOG_NOTICE, "[NCS%c:%02d SND] send buff error: %s",
+				                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+			}
+		if ((error = tcp_sht_cep(NET_CONS_CEPID)) != E_OK)
+			syslog(LOG_NOTICE, "[NCS%c:%02d SHT] shutdown error: %s",
+			                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+		if ((error = tcp_cls_cep(NET_CONS_CEPID, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[NCS%c:%02d CLS] close error: %s",
+			                   API_PROTO, NET_CONS_CEPID, itron_strerror(error));
+		connected = false;
+		syscall(sig_sem(SEM_NET_CONS_SEND));
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[NCS%c:%02u SND] discn: %7lu, from: %s.%u",
+		                   API_PROTO, NET_CONS_CEPID, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+		}
+	return error;
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã®å¶å¾¡
+ */
+
+ER
+net_serial_ctl_por (ID portid, uint_t ioctl)
+{
+	net_ioctl = ioctl;
+	return serial_ctl_por(portid, ioctl);
+	}
+
+/*
+ *  ã­ã°åºå
+ */
+
+ER
+net_syslog (uint_t prio, const char *format, ...)
+{
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	*addr;
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+	ulong_t		val;
+	SYSLOG		log;
+	va_list		ap;
+	char		padchar, *str;
+	int_t		ch, width, left, i;
+	bool_t		longflag;
+
+	if (connected) {
+		syscall(wai_sem(SEM_NET_CONS_PRINTF));
+		va_start(ap, format);
+		while ((ch = *format ++) != '\0') {
+			if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+				cons_putchar(CONSOLE_PORTID, (char)ch);
+				continue;
+				}
+
+			width = 0;
+			longflag = false;
+			padchar = ' ';
+
+			if (ch == '-') {		/* å·¦è©°ã */
+				format ++;
+				left = -1;
+				}
+			else
+				left = 1;
+
+			if ((ch = *format ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+				padchar = '0';
+				ch = *format ++;
+				}
+
+			while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+				width = width * 10 + ch - '0';
+				ch = *format ++;
+				}
+
+			while (ch == 'l') {		/* long (long) ã®æå® */
+				longflag = true;
+				ch = *format ++;
+				}
+
+			switch (ch) {
+			case 'd':
+				val = longflag ? (ulong_t)va_arg(ap, long_t)
+				               : (ulong_t)va_arg(ap, int_t);
+				if ((long_t)val >= 0)
+					cons_putnumber(CONSOLE_PORTID,  val, 10, radhex, width * left, false, padchar);
+				else
+					cons_putnumber(CONSOLE_PORTID, -val, 10, radhex, width * left, true, padchar);
+				break;
+
+			case 'u':
+				val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+				               : (ulong_t)va_arg(ap, uint_t);
+				cons_putnumber(CONSOLE_PORTID, val, 10, radhex, width * left, false, padchar);
+				break;
+
+			case 'x':
+				val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+				               : (ulong_t)va_arg(ap, uint_t);
+				cons_putnumber(CONSOLE_PORTID, val, 16, radhex, width * left, false, padchar);
+				break;
+
+			case 'X':
+				val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+				               : (ulong_t)va_arg(ap, uint_t);
+				cons_putnumber(CONSOLE_PORTID, val, 16, radHEX, width * left, false, padchar);
+				break;
+
+			case 'c':
+				ch = va_arg(ap, int_t);
+				cons_putchar(CONSOLE_PORTID, (char)ch);
+				break;
+
+			case 's':
+				str = va_arg(ap, char*);
+				while ((ch = *str ++) != '\0') {
+					cons_putchar(CONSOLE_PORTID, (char)ch);
+					width --;
+					}
+				while (width -- > 0)
+					cons_putchar(CONSOLE_PORTID, ' ');
+				break;
+
+			case 'I':
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR*);
+				put_ipv4addr(CONSOLE_PORTID, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(CONSOLE_PORTID, (T_IN6_ADDR *)str, width);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				break;
+
+			case 'M':
+				str = va_arg(ap, char*);
+				put_macaddr(CONSOLE_PORTID, (uint8_t *)str, width);
+				break;
+
+			case '%':
+				cons_putchar(CONSOLE_PORTID, '%');
+				break;
+
+			case '0':
+				format --;
+				break;
+
+			default:
+				break;
+				}
+
+			}
+		va_end(ap);
+		cons_putchar(CONSOLE_PORTID, '\n');
+		flush_snd_buff();
+		syscall(sig_sem(SEM_NET_CONS_PRINTF));
+		return E_OK;
+		}
+	else {
+		log.logtype = LOG_TYPE_COMMENT;
+		log.loginfo[0] = (intptr_t)format;
+		i = 1;
+		va_start(ap, format);
+
+		while ((ch = *format++) != '\0' && i < TMAX_LOGINFO) {
+			if (ch != '%') {
+				continue;
+				}
+
+			longflag = false;
+
+			ch = *format++;
+			while ('0' <= ch && ch <= '9') {
+				ch = *format++;
+				}
+
+			while (ch == 'l') {		/* long (long) ã®æå® */
+				longflag = true;
+				ch = *format ++;
+				}
+
+			switch (ch) {
+			case 'd':
+				log.loginfo[i++] = longflag
+					? (intptr_t)va_arg(ap, long_t) 
+					: (intptr_t)va_arg(ap, int_t);
+				break;
+			case 'u':
+			case 'x':
+			case 'X':
+				log.loginfo[i++] = longflag
+					? (intptr_t)va_arg(ap, ulong_t)
+					: (intptr_t)va_arg(ap, uint_t);
+				break;
+			case 'p':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, void *);
+				break;
+			case 'c':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, int_t);
+				break;
+			case 's':
+				log.loginfo[i++] = (intptr_t)va_arg(ap, const char *);
+				break;
+			case '\0':
+				format--;
+				break;
+			default:
+				break;
+				}
+			}
+		va_end(ap);
+
+#ifdef TARGET_KERNEL_ASP
+
+		return(syslog_wri_log(prio, &log));
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+		return(vwri_log(prio, &log));
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+		}
+	}
+
+#endif	/* of #ifdef USE_NET_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/net_cons.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/net_cons.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/net_cons.cfg	(revision 317)
@@ -0,0 +1,57 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
+¥åºå
+ *  ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_NET_CONS
+
+CRE_SEM(SEM_NET_CONS_PRINTF, { TA_TPRI, 1, 1 });
+CRE_SEM(SEM_NET_CONS_SEND,   { TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef USE_NET_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/net_cons.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/net_cons.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/net_cons.h	(revision 317)
@@ -0,0 +1,67 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
+¥åºå
+ */
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº  */
+
+#define NET_CONS_SWBUF_SIZE	512
+#define NET_CONS_RWBUF_SIZE	512
+
+#ifndef _MACRO_ONLY
+
+/*  TCP éåä¿¡ã¦ã£ã³ããããã¡  */
+
+extern uint8_t net_cons_swbuf[];
+extern uint8_t net_cons_rwbuf[];
+
+/*  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°  */
+
+extern ER	callback_nblk_net_cons(ID cepid, FN fncd, void *p_parblk);
+
+#endif /* _MACRO_ONLY */
Index: asp3_gr_sakura/trunk/tinet/netapp/netapp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/netapp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/netapp.h	(revision 317)
@@ -0,0 +1,111 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NETAPP_H_
+#define _NETAPP_H_
+
+/*
+ *  IPv4 ã¨ IPv6 ã®åæããã¯ã­
+ */
+
+#if defined(SUPPORT_INET6)
+
+#define PUT_IPADDR(p,a,w)	put_ipv6addr(p,a,w)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#define PUT_IPADDR(p,a,w)	put_ipv4addr(p,a,w)
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  ã³ã³ã½ã¼ã«ã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·
+ */
+
+#ifndef CONSOLE_PORTID
+#define	CONSOLE_PORTID		LOGTASK_PORTID
+#endif
+
+/*
+ *  ã³ã³ã½ã¼ã«ã«ç¨ãã LCD ãã¼ãçªå·
+ */
+
+#define	LCD_PORTID		0
+
+/*
+ *  æ°å¤å¤æã®ããã®å¤æè¡¨
+ */
+
+extern const char radhex[];
+extern const char radHEX[];
+
+/*
+ *  é¢æ°
+ */
+
+extern char *skip_blanks (char *line);
+extern int_t cons_getline (ID portid, char *line, int_t size);
+extern char *get_int (int_t *val, char *line);
+extern char *get_xuint (uint_t *val, char *line);
+extern void cons_putchar (ID portid, char ch);
+extern int_t cons_getchar (ID portid);
+extern int_t cons_putnumber (ID portid, ulong_t val, int_t radix,
+                           const char *radchar, int_t width,
+                           bool_t minus, char padchar);
+extern void cons_printf (ID portid, const char *fmt, ...);
+extern int_t put_macaddr (ID portid, uint8_t *mac, int_t width);
+
+#ifdef T_IN4_ADDR_DEFINED
+extern int_t put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width);
+#endif
+#ifdef T_IN6_ADDR_DEFINED
+extern int_t put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width);
+#endif
+
+#endif	/* of #ifndef _NETAPP_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.c	(revision 317)
@@ -0,0 +1,1246 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ãµãã¼ãã«ã¼ãã³
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <syssvc/serial.h>
+#include <syssvc/logtask.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/resolver.h>
+
+#ifdef USE_NETAPP_SUBR
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#if defined(SUPPORT_INET6)
+
+#ifdef USE_TCP_EXTENTIONS
+
+const ID vrid_tcp6_cep[] =
+{
+#if NUM_VRID_TCP6_CEPS >= 1
+	TCP6_RSV_CEPID1,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 2
+	TCP6_RSV_CEPID2,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 3
+	TCP6_RSV_CEPID3,
+#endif
+#if NUM_VRID_TCP6_CEPS >= 4
+	TCP6_RSV_CEPID4,
+#endif
+	};
+
+const ID vrid_tcp6_rep[] =
+{
+#if NUM_VRID_TCP6_REPS >= 1
+	TCP6_RSV_REPID1,
+#endif
+#if NUM_VRID_TCP6_REPS >= 2
+	TCP6_RSV_REPID2,
+#endif
+	};
+
+ID tskid_tcp6_cep[NUM_VRID_TCP6_CEPS];
+ID tskid_tcp6_rep[NUM_VRID_TCP6_REPS];
+
+#endif	/* #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+const ID vrid_udp6_cep[] =
+{
+#if NUM_VRID_UDP6_CEPS >= 1
+	UDP6_RSV_CEPID1,
+#endif
+#if NUM_VRID_UDP6_CEPS >= 2
+	UDP6_RSV_CEPID2,
+#endif
+	};
+
+ID tskid_udp6_cep[NUM_VRID_UDP6_CEPS];
+
+#endif	/* #ifdef USE_UDP_EXTENTIONS */
+
+#undef	TCP_CRE_REP
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	TCP_IS_CEPID
+#undef  ALLOC_TCP_REP
+#undef  ALLOC_TCP_CEP
+#undef  ALLOC_UDP_CEP
+#undef  FREE_TCP_REP
+#undef  FREE_TCP_CEP
+#undef  FREE_UDP_CEP
+#undef	T_TCPN_CREP
+#undef	T_UDPN_CCEP
+#undef	NUM_VRID_TCP_CEPS
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_UDP_CEP
+#undef	VRID_TCP_REP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+#undef	API_IPPROTO
+
+#define TCP_CRE_REP		tcp6_cre_rep
+#define UDP_CRE_CEP		udp6_cre_cep
+#define UDP_DEL_CEP		udp6_del_cep
+
+#define TCP_IS_CEPID		tcp6_is_cepid
+#define ALLOC_TCP_REP		alloc_tcp6_rep
+#define ALLOC_TCP_CEP		alloc_tcp6_cep
+#define ALLOC_UDP_CEP		alloc_udp6_cep
+#define FREE_TCP_REP		free_tcp6_rep
+#define FREE_TCP_CEP		free_tcp6_cep
+#define FREE_UDP_CEP		free_udp6_cep
+#define T_TCPN_CREP		T_TCP6_CREP
+#define T_UDPN_CCEP		T_UDP6_CCEP
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP6_CEPS
+#define NUM_VRID_TCP_REPS	NUM_VRID_TCP6_REPS
+#define NUM_VRID_UDP_CEPS	NUM_VRID_UDP6_CEPS
+#define VRID_TCP_CEP		vrid_tcp6_cep
+#define VRID_TCP_REP		vrid_tcp6_rep
+#define VRID_UDP_CEP		vrid_udp6_cep
+#define TSKID_TCP_CEP		tskid_tcp6_cep
+#define TSKID_TCP_REP		tskid_tcp6_rep
+#define TSKID_UDP_CEP		tskid_udp6_cep
+#define API_IPPROTO		API_PROTO_IPV6
+
+#include <netapp/netappn_subr.c>
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#ifdef USE_TCP_EXTENTIONS
+
+const ID vrid_tcp4_cep[] =
+{
+#if NUM_VRID_TCP4_CEPS >= 1
+	TCP4_RSV_CEPID1,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 2
+	TCP4_RSV_CEPID2,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 3
+	TCP4_RSV_CEPID3,
+#endif
+#if NUM_VRID_TCP4_CEPS >= 4
+	TCP4_RSV_CEPID4,
+#endif
+	};
+
+const ID vrid_tcp4_rep[] =
+{
+#if NUM_VRID_TCP4_REPS >= 1
+	TCP4_RSV_REPID1,
+#endif
+#if NUM_VRID_TCP4_REPS >= 2
+	TCP4_RSV_REPID2,
+#endif
+	};
+
+ID tskid_tcp4_cep[NUM_VRID_TCP4_CEPS];
+ID tskid_tcp4_rep[NUM_VRID_TCP4_REPS];
+
+#endif	/* #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+const ID vrid_udp4_cep[] =
+{
+#if NUM_VRID_UDP4_CEPS >= 1
+	UDP4_RSV_CEPID1,
+#endif
+#if NUM_VRID_UDP4_CEPS >= 2
+	UDP4_RSV_CEPID2,
+#endif
+	};
+
+ID tskid_udp4_cep[NUM_VRID_UDP4_CEPS];
+
+#endif	/* #ifdef USE_UDP_EXTENTIONS */
+
+#undef	TCP_CRE_REP
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	TCP_IS_CEPID
+#undef  ALLOC_TCP_REP
+#undef  ALLOC_TCP_CEP
+#undef  ALLOC_UDP_CEP
+#undef  FREE_TCP_REP
+#undef  FREE_TCP_CEP
+#undef  FREE_UDP_CEP
+#undef	T_TCPN_CREP
+#undef	T_UDPN_CCEP
+#undef	NUM_VRID_TCP_CEPS
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_TCP_REP
+#undef	VRID_UDP_CEP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+#undef	API_IPPROTO
+
+#define TCP_CRE_REP		tcp_cre_rep
+#define UDP_CRE_CEP		udp_cre_cep
+#define UDP_DEL_CEP		udp_del_cep
+#define TCP_IS_CEPID		tcp4_is_cepid
+#define ALLOC_TCP_REP		alloc_tcp4_rep
+#define ALLOC_TCP_CEP		alloc_tcp4_cep
+#define ALLOC_UDP_CEP		alloc_udp4_cep
+#define FREE_TCP_REP		free_tcp4_rep
+#define FREE_TCP_CEP		free_tcp4_cep
+#define FREE_UDP_CEP		free_udp4_cep
+#define T_TCPN_CREP		T_TCP_CREP
+#define T_UDPN_CCEP		T_UDP_CCEP
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP4_CEPS
+#define NUM_VRID_TCP_REPS	NUM_VRID_TCP4_REPS
+#define NUM_VRID_UDP_CEPS	NUM_VRID_UDP4_CEPS
+#define VRID_TCP_CEP		vrid_tcp4_cep
+#define VRID_TCP_REP		vrid_tcp4_rep
+#define VRID_UDP_CEP		vrid_udp4_cep
+#define TSKID_TCP_CEP		tskid_tcp4_cep
+#define TSKID_TCP_REP		tskid_tcp4_rep
+#define TSKID_UDP_CEP		tskid_udp4_cep
+#define API_IPPROTO		API_PROTO_IPV4
+
+#include <netapp/netappn_subr.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#undef	TCP_CRE_REP
+#undef  ALLOC_TCPN_REP
+#undef  ALLOC_TCPN_CEP
+#undef  ALLOC_UDPN_CEP
+#undef  FREE_TCPN_REP
+#undef  FREE_TCPN_CEP
+#undef  FREE_UDPN_CEP
+#undef	T_TCPN_CREP
+#undef	NUM_VRID_TCP_REPS
+#undef	NUM_VRID_UDP_CEPS
+#undef	VRID_TCP_CEP
+#undef	VRID_TCP_REP
+#undef	VRID_UDP_CEP
+#undef	TSKID_TCP_CEP
+#undef	TSKID_TCP_REP
+#undef	TSKID_UDP_CEP
+
+/*
+ *  å¤æ°
+ */
+
+static uint32_t rand_next = ULONG_C(1);
+
+#if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+const T_IN6_ADDR in6_addr_unspecified =
+	IPV6_ADDR_UNSPECIFIED_INIT;
+
+#endif	/* of #if !defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+
+#define EOF		(-1)
+
+/*
+ *  æ°å¤å¤æã®ããã®å¤æè¡¨
+ */
+
+const char radhex[] = "0123456789abcdef";
+const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  netapp_rand -- ä¹±æ°ãè¿ãã
+ */
+
+uint32_t
+netapp_rand (void)
+{
+	rand_next = (rand_next * 99991 + 12345) & ULONG_C(0x7fffffff);
+	return rand_next;
+	}
+
+/*
+ *  srand -- ä¹±æ°ãåæåããã
+ */
+
+void
+netapp_srand (uint32_t seed)
+{
+	SYSTIM now;
+
+	syscall(get_tim(&now));
+	rand_next += now + seed;
+	}
+
+#ifndef USE_NET_CONS
+
+/*
+ *  cons_putchar -- ã·ãªã¢ã«ãã¼ãã¸ã®æå­åºå
+ */
+
+void
+cons_putchar (ID portid, char ch)
+{
+	serial_wri_dat(portid, &ch, 1);
+	}
+
+/*
+ *  cons_getchar -- ã·ãªã¢ã«ãã¼ãããã®æå­å
+¥å
+ */
+
+int_t
+cons_getchar (ID portid)
+{
+	char ch;
+
+	if (serial_rea_dat(portid, &ch, sizeof(ch)) > 0)
+		return ch;
+	else
+		return EOF;
+	}
+
+#endif	/* of #ifndef USE_NET_CONS */
+
+/*
+ *  cons_putnumber -- cons_printf ã®æ°å¤å¤æ
+ */
+
+int_t
+cons_putnumber(ID portid, ulong_t 	val, int_t radix,
+         const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+	bool_t	left;
+
+	if (width < 0) {
+		width = -width;
+		left = true;
+		}
+	else
+		left = false;
+
+	ix = 0;
+	do {
+		digits[ix ++] = radchar[val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	pad = ix;
+	if (!left)	/* å³è©°ã */
+		for ( ; pad < width; pad ++)
+			cons_putchar(portid, padchar);
+
+	while (ix -- > 0)
+		cons_putchar(portid, digits[ix]);
+
+	if (left)	/* å·¦è©°ã */
+		for ( ; pad < width; pad ++)
+			cons_putchar(portid, padchar);
+
+	return pchars;
+	}
+
+/*
+ *  put_ipv4addr -- IPv4 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv4addr (ID portid, T_IN4_ADDR *addr, int_t width)
+{
+	int_t len = 3;	/* 3 ã¯ '.' ã®æå­æ° */
+
+	len += cons_putnumber(portid, (*addr >> 24) & 0xff, 10, radhex, 0, false, ' '); 
+	cons_putchar(portid, '.');
+	len += cons_putnumber(portid, (*addr >> 16) & 0xff, 10, radhex, 0, false, ' '); 
+	cons_putchar(portid, '.');
+	len += cons_putnumber(portid, (*addr >>  8) & 0xff, 10, radhex, 0, false, ' '); 
+	cons_putchar(portid, '.');
+	len += cons_putnumber(portid,  *addr        & 0xff, 10, radhex, 0, false, ' '); 
+
+	for ( ; len < width; len ++)
+		cons_putchar(portid, ' ');
+
+	return len;
+	}
+
+/*
+ *  ipv6addr -- IPv6 ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_ipv6addr (ID portid, const T_IN6_ADDR *addr, int_t width)
+{
+	int_t	len = 0, ix, len6;
+	bool_t	omit = false, zero = false;
+
+	if (addr == NULL || IN6_IS_ADDR_UNSPECIFIED(addr)) {
+		cons_putchar(portid, '0');
+		cons_putchar(portid, ':');
+		cons_putchar(portid, ':');
+		cons_putchar(portid, '0');
+		len = 4;
+		}
+	else {
+		if (in6_is_addr_ipv4mapped(addr))
+			len6 = sizeof(T_IN6_ADDR) / 2 - 2;
+		else
+			len6 = sizeof(T_IN6_ADDR) / 2;
+		for (ix = 0; ix < len6; ix ++) {
+			if (omit) {
+				len += cons_putnumber(portid, ntohs(addr->s6_addr16[ix]), 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					cons_putchar(portid, ':');
+					len ++;
+					}
+				}
+			else if (ix > 0 && ix < 7 && addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					cons_putchar(portid, ':');
+					len ++;
+					}
+				len += cons_putnumber(portid, ntohs(addr->s6_addr16[ix]), 16, radhex, 0, false, ' '); 
+				if (ix < 7) {
+					cons_putchar(portid, ':');
+					len ++;
+					}
+				}
+			}
+
+		if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
+			T_IN4_ADDR ip4addr;
+
+			ip4addr = ntohl(addr->s6_addr32[3]);
+			len += put_ipv4addr(portid, &ip4addr, 0);
+			}
+
+		for ( ; len < width; len ++)
+			cons_putchar(portid, ' ');
+		}
+	return len;
+	}
+
+/*
+ *  put_macaddr -- MAC ã¢ãã¬ã¹åºå
+ */
+
+int_t
+put_macaddr (ID portid, uint8_t *mac, int_t width)
+{
+	int_t oct, len;
+
+	for (oct = 5; oct -- > 0; ) {
+		cons_putnumber(portid, *mac ++, 16, radhex, 2, false, '0'); 
+		cons_putchar(portid, ':');
+		}
+	cons_putnumber(portid, *mac, 16, radhex, 2, false, '0'); 
+
+	for (len = 17; len < width; len ++)
+		cons_putchar(portid, ' ');
+
+	return len;
+	}
+
+/*
+ *  cons_printf -- ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºå
+ */
+
+void
+cons_printf (ID portid, const char *fmt, ...)
+{
+	va_list	ap;
+	long_t	val;
+	char	padchar, *str;
+	int_t	ch, width, longflag, shortflag, left;
+	T_IN4_ADDR	*addr;
+
+	va_start(ap, fmt);
+	while ((ch = *fmt ++) != '\0') {
+		if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+			cons_putchar(portid, (char)ch);
+			continue;
+			}
+
+		width = longflag = shortflag = 0;
+		padchar = ' ';
+
+		if (*fmt == '-') {		/* å·¦è©°ã */
+			fmt ++;
+			left = -1;
+			}
+		else
+			left = 1;
+
+		if ((ch = *fmt ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+			padchar = '0';
+			ch = *fmt ++;
+			}
+
+		while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+			width = width * 10 + ch - '0';
+			ch = *fmt ++;
+			}
+
+		while (ch == 'l') {		/* long (long) ã®æå® */
+			longflag ++;
+			ch = *fmt ++;
+			}
+
+		while (ch == 'h') {		/* short ã®æå® */
+			shortflag ++;
+			ch = *fmt ++;
+			}
+
+		switch (ch) {
+		case 'd':
+			val = longflag ? (ulong_t)va_arg(ap, long_t)
+			               : (ulong_t)va_arg(ap, int_t);
+			if (val >= 0)
+				cons_putnumber(portid,  val, 10, radhex, width * left, false, padchar);
+			else
+				cons_putnumber(portid, -val, 10, radhex, width * left, true, padchar);
+			break;
+
+		case 'u':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			cons_putnumber(portid, val, 10, radhex, width * left, false, padchar);
+			break;
+
+		case 'x':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			cons_putnumber(portid, val, 16, radhex, width * left, false, padchar);
+			break;
+
+		case 'X':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			cons_putnumber(portid, val, 16, radHEX, width * left, false, padchar);
+			break;
+
+		case 'c':
+			ch = va_arg(ap, int_t);
+			cons_putchar(portid, (char)ch);
+			break;
+
+		case 's':
+			str = va_arg(ap, char*);
+			while ((ch = *str ++) != '\0') {
+				cons_putchar(portid, (char)ch);
+				width --;
+				}
+			while (width -- > 0)
+				cons_putchar(portid, ' ');
+			break;
+
+		case 'I':
+
+			if (longflag) {
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+				}
+			else if (shortflag) {
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+				}
+			else {
+
+#if defined(SUPPORT_INET6)
+
+				str = va_arg(ap, char*);
+				put_ipv6addr(portid, (T_IN6_ADDR *)str, width);
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+				addr = va_arg(ap, T_IN4_ADDR *);
+				put_ipv4addr(portid, addr, width);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+				}
+			break;
+
+		case 'M':
+			str = va_arg(ap, char*);
+			put_macaddr(portid, (uint8_t *)str, width);
+			break;
+
+		case '%':
+			cons_putchar(portid, '%');
+			break;
+
+		case '0':
+			fmt --;
+			break;
+
+		default:
+			break;
+			}
+
+		}
+	va_end(ap);
+	}
+
+/*
+ *  host2msg16 -- 16ãããã®å¤ãããã¤ããªã¼ãã¼ãèª¿æ´ãã¦ã¡ãã»ã¼ã¸ã«æ¸ãè¾¼ãã
+ */
+
+void
+host2msg16 (void *msg, uint16_t host_data)
+{
+	uint16_t	msg_data;
+
+	msg_data = htons(host_data);
+	memcpy(msg, &msg_data, sizeof(msg_data));
+	}
+
+/*
+ *  host2msg32 -- 32ãããã®å¤ãããã¤ããªã¼ãã¼ãèª¿æ´ãã¦ã¡ãã»ã¼ã¸ã«æ¸ãè¾¼ãã
+ */
+
+void
+host2msg32 (void *msg, uint32_t host_data)
+{
+	uint32_t	msg_data;
+
+	msg_data = htonl(host_data);
+	memcpy(msg, &msg_data, sizeof(msg_data));
+	}
+
+/*
+ *  msg2host16 -- 16ãããã®å¤ãããã¤ããªã¼ãã¼ãèª¿æ´ãã¦ã¡ãã»ã¼ã¸ããèª­ã¿åºãã
+ */
+
+uint16_t
+msg2host16 (void *msg)
+{
+	uint16_t	host_data;
+
+	memcpy(&host_data, msg, sizeof(host_data));
+	return htons(host_data);
+	}
+
+/*
+ *  msg2host32 -- 32ãããã®å¤ãããã¤ããªã¼ãã¼ãèª¿æ´ãã¦ã¡ãã»ã¼ã¸ããèª­ã¿åºãã
+ */
+
+uint32_t
+msg2host32 (void *msg)
+{
+	uint32_t	host_data;
+
+	memcpy(&host_data, msg, sizeof(host_data));
+	return htonl(host_data);
+	}
+
+/*
+ *  skip_blanks -- ç©ºç½ã¨ TAB ãã¹ã­ããããã
+ */
+
+char *
+skip_blanks (char *line)
+{
+	while (*line == ' ' || *line == '\t')
+		line ++;
+	return line;
+	}
+
+/*
+ *  get_ipv4addr -- æå­åã® IPv4 ã¢ãã¬ã¹ã T_IN4_ADDR å¤ã«å¤æããã
+ */
+
+char *
+get_ipv4addr (T_IN4_ADDR *addr, char *line)
+{
+	int_t oct;
+
+	*addr = IPV4_ADDRANY;
+	while ('0' <= *line && *line <= '9') {
+		oct = 0;
+		while ('0' <= *line && *line <= '9')
+			oct = oct * 10 + (*line ++) - '0';
+		*addr = (*addr << 8) | (oct & 0xff);
+		if (*line == '.')
+			line ++;
+		}
+#if 1
+	return *addr == IPV4_ADDRANY ? NULL : line;
+#else
+	return line;
+#endif
+	}
+
+#if defined(SUPPORT_INET6) || defined(USE_RESOLVER)
+
+/*
+ *  get_ipv6addr -- æå­åã® IPv6 ã¢ãã¬ã¹ã T_IN6_ADDR å¤ã«å¤æããã
+ */
+
+char *
+get_ipv6addr (T_IN6_ADDR *addr, char *line)
+{
+	int_t word, ix = 0, omit = 0, six;
+	char *ipv4line;
+
+	memset(addr, 0, sizeof(T_IN6_ADDR));
+
+	/*
+	 * IPv4 ã¢ãã¬ã¹ï¼æ°å­.ï¼ãæ¤åºããã IPv4 ã¢ãã¬ã¹ã¨ãã¦å
+¥åãã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ã«å¤æããã
+	 */
+	for (ipv4line = line; '0' <= *ipv4line && *ipv4line <= '9'; ipv4line ++)
+		;
+	if (*ipv4line == '.') {
+		T_IN4_ADDR ipv4addr;
+
+		line = get_ipv4addr(&ipv4addr, line);
+		in6_make_ipv4mapped (addr, ipv4addr);
+		}
+	else {
+		while (ix < 8 &&
+		       (('0' <= *line && *line <= '9') ||
+		        ('a' <= *line && *line <= 'f') ||
+		        ('A' <= *line && *line <= 'F'))) {
+			word = 0;
+			while (('0' <= *line && *line <= '9') ||
+ 		               ('a' <= *line && *line <= 'f') ||
+		               ('A' <= *line && *line <= 'F')) {
+				if      ('0' <= *line && *line <= '9')
+					word = (word << 4) + (*line ++) - '0';
+				else if ('a' <= *line && *line <= 'f')
+					word = (word << 4) + (*line ++) - 'a' + 10;
+				else if ('A' <= *line && *line <= 'F')
+					word = (word << 4) + (*line ++) - 'A' + 10;
+				}
+			addr->s6_addr16[ix ++] = htons(word);
+			if (*line == ':') {
+				line ++;
+				if (*line == ':') {
+					omit = ix;
+					line ++;
+					}
+				}
+			}
+		if (omit > 0) {
+			six = 7;
+			while (ix > omit) {
+				addr->s6_addr16[six --] = addr->s6_addr16[-- ix];
+				addr->s6_addr16[ ix   ] = 0;
+				}
+			}
+		}
+	return line;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) || defined(USE_RESOLVER) */
+
+/*
+ *  ãããã°è¡å
+¥å
+ */
+
+int_t
+cons_getline (ID portid, char *line, int_t size)
+{
+	int_t	ch, len;
+
+	len = size;
+	while (size > 0) {
+		if ((ch = cons_getchar(portid)) != EOF) {
+			if (ch == '\r') {
+				cons_putchar(portid, '\n');
+				break;
+				}
+			else if (ch == '\b') {
+				if (size < len) {
+					line --;
+					size ++;
+					}
+				}
+			else {
+				*line ++ = ch;
+				size --;
+				}
+			}
+		}
+	*line = '\0';
+	return len - size;
+	}
+
+/*
+ *  get_int -- æ´æ°å¤æ
+ */
+
+char *
+get_int (int_t *val, char *line)
+{
+	int_t sign = 1;
+
+	line = skip_blanks(line);
+	if (*line == '-') {
+		sign = -1;
+		line ++;
+		}
+	else if (*line == '+')
+		line ++;
+
+	line = skip_blanks(line);
+	*val = 0;
+	while ('0' <= *line && *line <= '9') {
+		*val = *val * 10 + *line - '0';
+		line ++;
+		}
+
+	*val = *val * sign;
+	return line;
+	}
+
+/*
+ *  get_xuint -- ç¬¦å·ãªãæ´æ° (16é²) å¤æ
+ */
+
+char *
+get_xuint (uint_t *val, char *line)
+{
+	line = skip_blanks(line);
+	*val = 0;
+	while (1) {
+		if      ('0' <= *line && *line <= '9')
+			*val = (*val << 4) + *line - '0';
+		else if ('a' <= *line && *line <= 'f')
+			*val = (*val << 4) + *line - 'a' + 10;
+		else if ('A' <= *line && *line <= 'F')
+			*val = (*val << 4) + *line - 'A' + 10;
+		else
+			break;
+		line ++;
+		}
+	return line;
+	}
+
+#ifdef USE_RESOLVER
+
+/*
+ *  dns_strtype -- DNS ã® type ã®æå­åãè¿ãã
+ */
+
+const char *
+dns_strtype (uint_t type)
+{
+	switch (type) {
+	case DNS_TYPE_A:
+		return "A";
+		break;
+	case DNS_TYPE_NS:
+		return "NS";
+		break;
+	case DNS_TYPE_CNAME:
+		return "CNAME";
+		break;
+	case DNS_TYPE_SOA:
+		return "SOA";
+		break;
+	case DNS_TYPE_PTR:
+		return "PTR";
+		break;
+	case DNS_TYPE_AAAA:
+		return "AAAA";
+		break;
+	default:
+		return "unknown type";
+		break;
+		}
+	}
+
+/*
+ *  dns_strclass -- DNS ã® class ãè¡¨ç¤ºããã
+ */
+
+const char *
+dns_strclass (uint_t class)
+{
+	switch (class) {
+	case DNS_CLASS_IN:
+		return "IN";
+		break;
+	default:
+		return "unknown class";
+		break;
+		}
+	}
+
+/*
+ *  resolv_hoststr -- æå­åã®FQDNã»ãã¹ãåã»IPv6/IPv4 ã¢ãã¬ã¹ãè§£æããã
+ */
+
+#define IS_HOSTCH_DIGIT(c)	(('0'<=(c)&&(c)<='9'))
+#define IS_HOSTCH_XDIGIT(c)	(IS_HOSTCH_DIGIT(c)||('a'<=(c)&&(c)<='f')||('A'<=(c)&&(c)<='F'))
+#define IS_HOSTCH_ALPHA(c)	(('a'<=(c)&&(c)<='z')||('A'<=(c)&&(c)<='z'))
+#define IS_HOSTCH_ALNUM(c)	(IS_HOSTCH_ALPHA(c)||IS_HOSTCH_DIGIT(c))
+#define IS_HOSTCH_IPV6ADDR(c)	(IS_HOSTCH_XDIGIT(c)||(c)==':')
+#define IS_HOSTCH_IPV4ADDR(c)	(IS_HOSTCH_DIGIT(c)||(c)=='.')
+#define IS_HOSTCH_IPADDR(c)	(IS_HOSTCH_XDIGIT(c)||(c)==':'||(c)=='.')
+#define IS_HOSTCH_NAME_FIRST(c)	(IS_HOSTCH_ALPHA(c))
+#define IS_HOSTCH_NAME(c)	(IS_HOSTCH_ALNUM(c)||(c)=='-'||(c)=='.')
+#define IS_HOSTCH_BLANK(c)	((c)=='\0'||(c)==' '||(c)=='\t')
+
+char *
+resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line)
+{
+	char *h, *p;
+
+	h = hostname;
+	p = line = skip_blanks(line);
+
+	if (IS_HOSTCH_IPADDR(*p)) {
+		while (IS_HOSTCH_DIGIT(*p)) {
+			if (h - hostname > name_size)
+				return NULL;
+			*h ++ = *p ++;
+			}
+		if (p > line && *p == '.') {
+			while (IS_HOSTCH_IPV4ADDR(*p)) {
+				if (h - hostname > name_size)
+					return NULL;
+				*h ++ = *p ++;
+				}
+			if (IS_HOSTCH_BLANK(*p)) {
+				*flags |= HOSTSTR_IPV4;
+				*h = '\0';
+				return p;
+				}
+			}
+		else if (IS_HOSTCH_IPADDR(*p)) {
+			while (IS_HOSTCH_IPADDR(*p)) {
+				if (h - hostname > name_size)
+					return NULL;
+				*h ++ = *p ++;
+				}
+			if (IS_HOSTCH_BLANK(*p)) {
+				*flags |= HOSTSTR_IPV6;
+				*h = '\0';
+				return p;
+				}
+			}
+		h = hostname;
+		p = line;
+		}
+
+	if (IS_HOSTCH_NAME_FIRST(*p)) {
+		*flags |= HOSTSTR_HOSTNAME;
+		while (IS_HOSTCH_NAME(*p)) {
+			if (h - hostname > name_size)
+				return NULL;
+			if (*p == '.')
+				*flags |= HOSTSTR_FQDN;
+			*h ++ = *p ++;
+			}
+		}
+	else
+		*flags |= HOSTSTR_OTHER;
+
+	*h = '\0';
+	return p;
+	}
+
+/*
+ *  show_dns_domain_name -- DNS ã®ãã¡ã¤ã³åãè¡¨ç¤ºããã
+ */
+
+uint_t
+show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset)
+{
+	uint8_t	*ptr;
+	uint_t	c;
+
+	ptr = hdr + offset;
+	while (*ptr) {
+		if ((*ptr & DNS_MSG_COMP_MARK) == DNS_MSG_COMP_MARK) {
+			show_dns_domain_name(portid, hdr, (*ptr & ~DNS_MSG_COMP_MARK) << 8 | *(ptr + 1));
+			ptr += 2;
+			break;
+			}
+		else {
+			for (c = 1; c <= *ptr; c++)
+				cons_printf(portid, "%c", *(ptr + c));
+			ptr += *ptr + 1;
+			if (*ptr)
+				cons_printf(portid, ".");
+			}
+		}
+	return ptr - hdr;
+	}
+
+/*
+ *  resolv_options -- ã¢ãã¬ã¹è§£æ±ºã®ãªãã·ã§ã³è§£æ
+ */
+
+char *
+resolv_options (uint_t *flags, char *line, char apip)
+{
+#if defined(SUPPORT_INET6)
+	T_IN6_ADDR	in6_addr;
+#endif
+
+#if defined(SUPPORT_INET4)
+	T_IN4_ADDR	in4_addr;
+#endif
+
+	line = skip_blanks(line);
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	*flags |= DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4;
+	if (apip == API_PROTO_IPV4)
+		*flags |= DNS_LUP_FLAGS_QTYPE_A;
+	else
+		*flags |= DNS_LUP_FLAGS_QTYPE_AAAA;
+
+	if (*line == '-') {
+		line ++;
+		if (*line == '6') {
+			line ++;
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
+			}
+		else if (*line == '4') {
+			line ++;
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
+			}
+		if (*line == 'Q' || *line == 'q') {
+			*flags &= ~DNS_LUP_FLAGS_QTYPE_A;
+			line ++;                   
+			}
+		else if (*line == 'A' || *line == 'a') {
+			*flags &= ~DNS_LUP_FLAGS_QTYPE_AAAA;
+			line ++;                   
+			}
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+	*flags = DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_QTYPE_AAAA;
+	if (*line == '-') {
+		line ++;
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	*flags = DNS_LUP_FLAGS_PROTO_IPV4 | DNS_LUP_FLAGS_QTYPE_A;
+	if (*line == '-') {
+		line ++;
+		while (*line && !(*line == ' ' || *line == '\t'))
+			line ++;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET6)
+
+	if (*flags | DNS_LUP_FLAGS_PROTO_IPV6) {
+		/*
+		 *  IPv6 ã§ DNS ãµã¼ãã«ç
+§ä¼ãããã¨ãæå®ããã¦ãã
+		 *  ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãæå®ãå¤ãã
+		 */
+		dns_in6_get_addr(&in6_addr);
+		if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV6;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	if (*flags | DNS_LUP_FLAGS_PROTO_IPV4) {
+		/*
+		 *  IPv4 ã§ DNS ãµã¼ãã«ç
+§ä¼ãããã¨ãæå®ããã¦ãã
+		 *  ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãæå®ãå¤ãã
+		 */
+		dns_in4_get_addr(&in4_addr);
+		if (in4_addr == IPV4_ADDRANY)
+			*flags &= ~DNS_LUP_FLAGS_PROTO_IPV4;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+	return line;
+	}
+
+#endif	/* of #ifdef USE_RESOLVER */
+
+/*
+ *  lookup_ipaddr -- ãã¹ãåã»ãªãã©ã«ã®IPã¢ãã¬ã¹ãIP ã¢ãã¬ã¹ã«å¤æããã
+ */
+
+char *
+lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip)
+{
+
+#ifdef USE_RESOLVER
+
+	static char hostname[DBG_LINE_SIZE + 1];
+
+	ER_UINT	error;
+	uint_t	flags = 0;
+	char	*last;
+
+	line = skip_blanks(resolv_options(&flags, line, apip));
+	if ((last = resolv_hoststr(&flags, hostname, sizeof(hostname), line)) == NULL) {
+		cons_printf(CONSOLE_PORTID, "unknown host: %s.\n", hostname);
+		return NULL;
+		}
+
+	switch (flags & DNS_LUP_FLAGS_NAME_MASK) {
+	case DNS_LUP_FLAGS_NAME_IPV4:
+	case DNS_LUP_FLAGS_NAME_IPV6:
+		line = GET_IPADDR(addr, line);		/* IP Address by Literal */
+		break;
+
+	case DNS_LUP_FLAGS_NAME_HOST:
+	case DNS_LUP_FLAGS_NAME_FQDN:
+		line = last;
+		if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
+			cons_printf(CONSOLE_PORTID, "DNS server not available.\n");
+			return NULL;
+			}
+
+		flags |= DNS_LUP_OPCODE_FORWARD;
+		if ((error = dns_host_addr(flags, hostname, addr)) != E_OK) {
+			cons_printf(CONSOLE_PORTID, "error: %s.\n", itron_strerror(error));
+			return NULL;
+			}
+		break;
+
+		}
+
+	return line;
+
+#else	/* of #ifdef USE_RESOLVER */
+
+	return GET_IPADDR(addr, skip_blanks(line));		/* IP Address by Literal */
+
+#endif	 /* of #ifdef USE_RESOLVER */
+
+	}
+
+#endif	/* of #ifdef USE_NETAPP_SUBR */
Index: asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/netapp_subr.cfg	(revision 317)
@@ -0,0 +1,63 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³å
+±é
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+CRE_SEM(SEM_ALLOC_TCP_REP_LOCK,	{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_ALLOC_TCP_CEP_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_SEM(SEM_ALLOC_UDP_CEP_LOCK,	{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/netapp_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/netapp_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/netapp_var.h	(revision 317)
@@ -0,0 +1,281 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NETAPP_VAR_H_
+#define _NETAPP_VAR_H_
+
+/*
+ *  TOPPERS/JSP ã«ã¼ãã«ãã·ã¹ãã æå» (SYSTIM) ã®å¨æ³¢æ°
+ */
+
+#define SYSTIM_HZ		ULONG_C(1000000)	/* [us]					*/
+
+/*
+ *  IPv6/IPv4 ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  æå®ããããã¯ã­ã«å¯¾ãããµã³ãã«ã¢ããªã±ã¼ã·ã§ã³å
+é¨ã®ãã¯ã­ã®å®ç¾©
+ *
+ *    SUPPORT_INET6		 .   .  ON  ON  ON  ON
+ *    SUPPORT_INET4		ON  ON   .   .  ON  ON
+ *    API_CFG_IP4MAPPED_ADDR	 .  ON   .  ON   .  ON
+ *    ----------------------    ----------------------
+ *    NETAPP_IP6_CFG             .   .  ON  ON  ON  ON
+ *    NETAPP_IP4_CFG            ON  ON   .  ON  ON  ON
+ *    
+ */
+
+#if defined(SUPPORT_INET6)
+
+#define	NETAPP_IP6_CFG
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
+#define NETAPP_IP4_CFG
+#endif
+
+/*
+ *  IPv4 ã¨ IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­
+ */
+
+#define DBG_LINE_SIZE		63
+
+#if defined(SUPPORT_INET6)
+
+#define T_IN_ADDR		T_IN6_ADDR
+#define T_IPEP			T_IPV6EP
+#define IP_ADDRANY		IPV6_ADDRANY
+#define T_TCPN_CREP		T_TCP6_CREP
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#define T_IN_ADDR		T_IN4_ADDR
+#define T_IPEP			T_IPV4EP
+#define IP_ADDRANY		IPV4_ADDRANY
+#define T_TCPN_CREP		T_TCP_CREP
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  API IPãã­ãã³ã«ã®æå®
+ */
+
+#if defined(SUPPORT_INET6)
+#define DEFAULT_API_PROTO	API_PROTO_IPV6
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV4
+#endif
+
+/*
+ *  resolv_hoststr ãè¿ã flags ã®å¤ã®å®ç¾©
+ *
+ *    æ³¨æ:
+ *
+ *      dns.h ã§å®ç¾©ããã¦ãã DNS_OPCODEã
+ *      resolver.h ã§å®ç¾©ããã¦ãã DNS_LUP_FLAGS ã¨éãªããªãäºã
+ */
+
+#define HOSTSTR_OTHER		0x0000U
+#define HOSTSTR_IPV4		DNS_LUP_FLAGS_NAME_IPV4
+#define HOSTSTR_IPV6		DNS_LUP_FLAGS_NAME_IPV6
+#define HOSTSTR_HOSTNAME	DNS_LUP_FLAGS_NAME_HOST
+#define HOSTSTR_FQDN		DNS_LUP_FLAGS_NAME_FQDN
+
+/*
+ *  å®æ°ã®å®ç¾©
+ */
+
+#define DBG_LINE_SIZE		63
+
+#if defined(SUPPORT_INET6)
+
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP6_CEPS
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#define NUM_VRID_TCP_CEPS	NUM_VRID_TCP4_CEPS
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* ã¡ãã»ã¼ã¸ããã®èª­åºã */
+
+#define MSG2HOST16(p)		(msg2host16((void*)&(p)))
+#define MSG2HOST32(p)		(msg2host32((void*)&(p)))
+
+/* ã¡ãã»ã¼ã¸ã¸ã®æ¸è¾¼ã¿ */
+
+#define HOST2MSG16(p,v)		(host2msg16((void*)&(p),(v)))
+#define HOST2MSG32(p,v)		(host2msg32((void*)&(p),(v)))
+
+/*
+ *  ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
+¥åºå
+ */
+
+#ifdef USE_NET_CONS
+
+/* ãªãã¼ã  */
+
+#define syslog		net_syslog
+#define serial_ctl_por	net_serial_ctl_por
+
+/* é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­ */
+
+#define FLUSH_SND_BUFF()	flush_snd_buff()
+#define WAI_NET_CONS_PRINTF()	syscall(wai_sem(SEM_NET_CONS_PRINTF))
+#define SIG_NET_CONS_PRINTF()	sig_sem(SEM_NET_CONS_PRINTF)
+
+#else	/* of #ifdef USE_NET_CONS */
+
+/* é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­ */
+
+#define FLUSH_SND_BUFF()
+#define WAI_NET_CONS_PRINTF()
+#define SIG_NET_CONS_PRINTF()
+
+#endif	/* of #ifdef USE_NET_CONS */
+
+/*
+ *  é¢æ°
+ */
+
+extern const char *in_strtfn (FN fncd);
+extern const char *itron_strerror (ER ercd);
+extern const char *dns_strtype (uint_t type);
+extern const char *dns_strclass (uint_t class);
+extern ER	net_syslog(uint_t prio, const char *format, ...) throw();
+extern ER	net_serial_ctl_por(ID portid, uint_t ioctl) throw();
+extern void	flush_snd_buff (void);
+extern ER	discon_net_cons (void);
+extern void	wup_net_cons (void);
+extern bool_t	tcp6_is_cepid (ID cepid);
+extern ER	alloc_tcp6_rep (ID *repid, ID tskid, T_TCP6_CREP *crep);
+extern ER	alloc_tcp6_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
+extern ER	alloc_udp6_cep (ID *cepid, ID tskid, T_UDP6_CCEP *ccep);
+extern ER	free_tcp6_rep (ID repid, bool_t call_tcp_del_rep);
+extern ER	free_tcp6_cep (ID cepid);
+extern ER	free_udp6_cep (ID cepid, bool_t call_udp_del_cep);
+extern bool_t	tcp4_is_cepid (ID cepid);
+extern ER	alloc_tcp4_rep (ID *repid, ID tskid, T_TCP_CREP *crep);
+extern ER	alloc_tcp4_cep (ID *cepid, ID tskid, T_TCP_CCEP *ccep);
+extern ER	alloc_udp4_cep (ID *cepid, ID tskid, T_UDP_CCEP *ccep);
+extern ER	free_tcp4_rep (ID repid, bool_t call_tcp_del_rep);
+extern ER	free_tcp4_cep (ID cepid);
+extern ER	free_udp4_cep (ID cepid, bool_t call_udp_del_cep);
+extern void	ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t len);
+extern void	ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len);
+extern char	*get_ipv6addr (T_IN6_ADDR *addr, char *line);
+extern char	*get_ipv4addr (T_IN4_ADDR *addr, char *line);
+extern char	*resolv_options (uint_t *flags, char *line, char apip);
+extern char	*resolv_hoststr (uint_t *flags, char *hostname, uint_t name_size, char *line);
+extern char	*lookup_ipaddr (T_IN_ADDR *addr, char *line, char apip);
+extern uint_t	show_dns_domain_name (ID portid, uint8_t *hdr, uint_t offset);
+extern void	host2msg16 (void *msg, uint16_t host_data);
+extern void	host2msg32 (void *msg, uint32_t host_data);
+extern uint16_t	msg2host16 (void *msg);
+extern uint32_t	msg2host32 (void *msg);
+extern uint32_t	netapp_rand (void);
+extern void	netapp_srand (uint32_t seed);
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_CRE_REP(i,r)	tcp6_cre_rep(i,r)
+#define TCP_CRE_CEP(i,c)	tcp6_cre_cep(i,c)
+#define UDP_CRE_CEP(i,c)	udp6_cre_cep(i,c)
+#define TCP_ACP_CEP(c,r,d,t)	tcp6_acp_cep(c,r,d,t)
+#define TCP_CON_CEP(c,m,d,t)	tcp6_con_cep(c,m,d,t)
+
+#define UDP_SND_DAT(c,d,b,l,t)	udp6_snd_dat(c,d,b,l,t)
+#define UDP_RCV_DAT(c,d,b,l,t)	udp6_rcv_dat(c,d,b,l,t)
+
+#define TCP_IS_CEPID(i)		tcp6_is_cepid(i)
+#define ALLOC_TCP_REP(i,t,r)	alloc_tcp6_rep(i,t,r)
+#define ALLOC_TCP_CEP(i,t,c)	alloc_tcp6_cep(i,t,c)
+#define ALLOC_UDP_CEP(i,t,c)	alloc_udp6_cep(i,t,c)
+#define FREE_TCP_REP(i,r)	free_tcp6_rep(i,r)
+#define FREE_TCP_CEP(i)		free_tcp6_cep(i)
+#define FREE_UDP_CEP(i,c)	free_udp6_cep(i,c)
+
+#define IP2STR(s,a)		ipv62str(s,a)
+#define GET_IPADDR(a,l)		get_ipv6addr(a,l)
+#define PING(a,t,l)		ping6(a,t,l)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#define TCP_CRE_REP(i,r)	tcp_cre_rep(i,r)
+#define TCP_CRE_CEP(i,c)	tcp_cre_cep(i,c)
+#define UDP_CRE_CEP(i,c)	udp_cre_cep(i,c)
+#define TCP_ACP_CEP(c,r,d,t)	tcp_acp_cep(c,r,d,t)
+#define TCP_CON_CEP(c,m,d,t)	tcp_con_cep(c,m,d,t)
+
+#define UDP_SND_DAT(c,d,b,l,t)	udp_snd_dat(c,d,b,l,t)
+#define UDP_RCV_DAT(c,d,b,l,t)	udp_rcv_dat(c,d,b,l,t)
+
+#define TCP_IS_CEPID(i)		tcp4_is_cepid(i)
+#define ALLOC_TCP_REP(i,t,r)	alloc_tcp4_rep(i,t,r)
+#define ALLOC_TCP_CEP(i,t,c)	alloc_tcp4_cep(i,t,c)
+#define ALLOC_UDP_CEP(i,t,c)	alloc_udp4_cep(i,t,c)
+#define FREE_TCP_REP(i,r)	free_tcp4_rep(i,r)
+#define FREE_TCP_CEP(i)		free_tcp4_cep(i)
+#define FREE_UDP_CEP(i,c)	free_udp4_cep(i,c)
+
+#define IP2STR(s,a)		ip2str(s,a)
+#define GET_IPADDR(a,l)		get_ipv4addr(a,l)
+#define PING(a,t,l)		ping4(a,t,l)
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #ifndef _NETAPP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/netappn_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/netappn_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/netappn_subr.c	(revision 317)
@@ -0,0 +1,219 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ãããã¯ã¼ã¯å¿ç¨ãã­ã°ã©ã ãµãã¼ãã«ã¼ãã³
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  alloc_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+ER
+ALLOC_TCP_REP (ID *repid, ID tskid, T_TCPN_CREP *crep)
+{
+	int_t	ix;
+
+	*repid = TCP_REP_NONE;
+	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
+	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
+		if (TSKID_TCP_REP[ix] == TSK_NONE) {
+			*repid = VRID_TCP_REP[ix];
+			TSKID_TCP_REP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
+
+	if (*repid == TCP_REP_NONE)
+		return E_NOEXS;
+	else
+		return TCP_CRE_REP(*repid, crep);
+	}
+
+/*
+ *  free_tcp_rep -- TCP åä»å£ãè§£æ¾ããã
+ */
+
+ER
+FREE_TCP_REP (ID repid, bool_t call_tcp_del_rep)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_TCP_REP_LOCK));
+	for (ix = NUM_VRID_TCP_REPS; ix -- > 0; ) {
+		if (repid == VRID_TCP_REP[ix]) {
+			TSKID_TCP_REP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_REP_LOCK));
+
+	if (call_tcp_del_rep)
+		return tcp_del_rep(repid);
+	else
+		return E_OK;
+	}
+
+/*
+ *  tcpn_is_cepid -- TCP éä¿¡ç«¯ç¹ãæå®ããããããã¯ã¼ã¯å±¤ãªã true ãè¿ãã
+ */
+
+bool_t
+TCP_IS_CEPID (ID cepid)
+{
+	int_t	ix;
+
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_TCP_CEP[ix])
+			return true;
+		}
+	return false;
+	}
+
+/*
+ *  alloc_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+ER
+ALLOC_TCP_CEP (ID *cepid, ID tskid, T_TCP_CCEP *ccep)
+{
+	int_t	ix;
+
+	*cepid = TCP_CEP_NONE;
+	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (TSKID_TCP_CEP[ix] == TSK_NONE) {
+			*cepid = VRID_TCP_CEP[ix];
+			TSKID_TCP_CEP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
+
+	if (*cepid == TCP_CEP_NONE)
+		return E_NOEXS;
+	else
+		return tcp_cre_cep(*cepid, ccep);
+	}
+
+/*
+ *  free_tcp_cep -- TCP éä¿¡ç«¯ç¹ãè§£æ¾ããã
+ */
+
+ER
+FREE_TCP_CEP (ID cepid)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_TCP_CEP_LOCK));
+	for (ix = NUM_VRID_TCP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_TCP_CEP[ix]) {
+			TSKID_TCP_CEP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_TCP_CEP_LOCK));
+
+	return tcp_del_cep(cepid);
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+/*
+ *  alloc_udp_cep -- UDP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+ER
+ALLOC_UDP_CEP (ID *cepid, ID tskid, T_UDPN_CCEP *ccep)
+{
+	int_t	ix;
+
+	*cepid = UDP_CEP_NONE;
+	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
+	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
+		if (TSKID_UDP_CEP[ix] == TSK_NONE) {
+			*cepid = VRID_UDP_CEP[ix];
+			TSKID_UDP_CEP[ix] = tskid;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
+
+	if (*cepid == UDP_CEP_NONE)
+		return E_NOEXS;
+	else
+		return UDP_CRE_CEP(*cepid, ccep);
+	}
+
+/*
+ *  free_udp_cep -- UDP éä¿¡ç«¯ç¹ãè§£æ¾ããã
+ */
+
+ER
+FREE_UDP_CEP (ID cepid, bool_t call_udp_del_cep)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ALLOC_UDP_CEP_LOCK));
+	for (ix = NUM_VRID_UDP_CEPS; ix -- > 0; ) {
+		if (cepid == VRID_UDP_CEP[ix]) {
+			TSKID_UDP_CEP[ix] = TSK_NONE;
+			break;
+			}
+		}
+	syscall(sig_sem(SEM_ALLOC_UDP_CEP_LOCK));
+
+	if (call_udp_del_cep)
+		return UDP_DEL_CEP(cepid);
+	else
+		return E_OK;
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/ping.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/ping.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/ping.c	(revision 317)
@@ -0,0 +1,184 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ping -- ICMP ECHO ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/ppp_var.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/icmp_var.h>
+
+#ifdef USE_PING
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  å¤æ°
+ */
+
+#if 0
+static uint16_t	curr_icmp_id;
+static uint16_t	curr_icmp_len;
+#endif
+
+static uint16_t	icmp_id = 0;
+static SYSTIM	icmp_start_time;
+
+/*
+ *  icmp_reply_timeout -- ICMP REPLY ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+icmp_reply_timeout (void *arg)
+{
+	syslog(LOG_NOTICE, "[PING4] request timeout.");
+	}
+
+/*
+ *  icmp_echo_reply -- ICMP ECHO REPLY ã¡ãã»ã¼ã¸ãå¦çããã
+ */
+
+void
+icmp_echo_reply (T_NET_BUF *input, uint_t ihoff)
+{
+	SYSTIM		time;
+	T_IN4_ADDR	addr;
+
+	syscall(get_tim(&time));
+	addr = ntohl(GET_IP4_HDR(input)->src);
+	untimeout(icmp_reply_timeout, NULL);
+	syslog(LOG_NOTICE, "[PING4] reply: %5ld [ms] from: %s",
+	                   (time - icmp_start_time) * 1000 / SYSTIM_HZ,
+	                   ip2str(NULL, &addr));
+	}
+
+/*
+ *  ping4 -- ICMP ECHO ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+void
+ping4 (T_IN4_ADDR *addr, uint_t tmo, uint_t len)
+{
+	T_ICMP4_HDR	*icmp4h;
+	T_NET_BUF	*output;
+	uint8_t		*sdu;
+	int_t		ix;
+
+	/* éä¿¡ç¨ã® IP ãã¼ã¿ã°ã©ã ãç²å¾ããã*/
+	if (in4_get_datagram(&output, ICMP4_HDR_SIZE + len, 0,
+	                     addr, NULL, IPPROTO_ICMP,
+	                     IP4_DEFTTL, NBA_SEARCH_ASCENT, TMO_FEVR) != E_OK)
+		return;
+
+	/* ICMP ããããè¨­å®ããã*/
+	icmp4h			= GET_ICMP4_HDR(output, IF_IP4_ICMP4_HDR_OFFSET);
+	icmp4h->type		= ICMP4_ECHO_REQUEST;
+	icmp4h->code		= 0;
+	icmp4h->data.id_seq.id	= htons(icmp_id);
+	icmp4h->data.id_seq.seq	= 0;
+
+	/* ãã¼ã¿ãè¨­å®ããã*/
+	sdu = GET_ICMP4_SDU(output, IF_IP4_ICMP4_HDR_OFFSET) + len;
+	for (ix = len; ix -- > 0; )
+		*-- sdu = ('0' + icmp_id + ix) & 0xff;
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	icmp4h->sum = 0;
+	icmp4h->sum = in_cksum(icmp4h, ICMP4_HDR_SIZE + len);
+
+	/* å¿ç­ãã§ãã¯ç¨ã®å¤æ°ãè¨­å®ããã*/
+#if 0
+	curr_icmp_id  = icmp_id ++;
+	curr_icmp_len = len;
+#endif
+
+	NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp_stats.icmpOutEchos, 1);
+
+	/* éä¿¡å¾ãç¾å¨ã®æéãè¨æ¶ããã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	ip_output(output, TMO_FEVR);
+
+	syscall(get_tim(&icmp_start_time));
+	timeout(icmp_reply_timeout, NULL, tmo * NET_TIMER_HZ);
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #ifdef USE_PING */
Index: asp3_gr_sakura/trunk/tinet/netapp/ping6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/ping6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/ping6.c	(revision 317)
@@ -0,0 +1,211 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  ping6 -- ICMPv6 ECHO ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/ppp_var.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
+#include <netinet6/nd6.h>
+
+#include <net/if_var.h>
+
+#ifdef USE_PING
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  å¤æ°
+ */
+
+#if 0
+static uint16_t	curr_icmp6_id;
+static uint16_t	curr_icmp6_size;
+#endif
+
+static uint16_t	send_icmp6_id = 0;
+static uint16_t	reply_count;
+static SYSTIM	icmp6_start_time;
+
+/*
+ *  icmp6_reply_timeout -- ICMP6 REPLY ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static void
+icmp6_reply_timeout (void *arg)
+{
+	if (reply_count == 0)
+		syslog(LOG_NOTICE, "[PING6] request timeout.");
+	}
+
+/*
+ *  icmp6_echo_reply -- ICMP6 ECHO REPLY ã¡ãã»ã¼ã¸ãå¦çããã
+ */
+
+void
+icmp6_echo_reply (T_NET_BUF *input, uint_t ihoff)
+{
+	SYSTIM	time;
+
+	syscall(get_tim(&time));
+	untimeout(icmp6_reply_timeout, NULL);
+	syslog(LOG_NOTICE, "[PING6] reply: %5ld [ms] from: %s",
+	                   (time - icmp6_start_time) * 1000 / SYSTIM_HZ,
+	                   ipv62str(NULL, &GET_IP6_HDR(input)->src));
+	reply_count ++;
+	}
+
+/*
+ *  ping6 -- ICMP ECHO ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+void
+ping6 (T_IN6_ADDR *addr, uint_t tmo, uint_t size)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_ICMP6_HDR	*icmp6h;
+	T_NET_BUF	*output;
+	T_IN6_IFADDR	*ia;
+	int_t		ix;
+	uint16_t	ipflags = 0;
+	uint8_t		*sdu;
+
+	/*
+	 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+	 */
+	if ((ia = in6_ifawithifp(ifp, addr)) == NULL)
+		return;
+
+	if (IN6_IS_ADDR_MULTICAST(addr))
+		ipflags = IPV6_OUT_SET_HOP_LIMIT(IPV6_OUT_FLG_HOP_LIMIT, IPV6_DEFHLIM);
+
+	/* éä¿¡ç¨ã® IP ãã¼ã¿ã°ã©ã ãç²å¾ããã*/
+	if (in6_get_datagram(&output, ICMP6_HDR_SIZE + size, 0,
+	                     addr, &ia->addr, IPPROTO_ICMPV6,
+	                     IPV6_DEFHLIM, NBA_SEARCH_ASCENT, TMO_FEVR) != E_OK)
+		return;
+
+	/* ICMP ããããè¨­å®ããã*/
+	icmp6h           = GET_ICMP6_HDR(output, IF_IP6_ICMP6_HDR_OFFSET);
+	icmp6h->type     = ICMP6_ECHO_REQUEST;
+	icmp6h->code     = 0;
+	icmp6h->icmp6_id = htons(send_icmp6_id);
+	icmp6h->icmp6_seq= 0;
+
+	/* ãã¼ã¿ãè¨­å®ããã*/
+	sdu = GET_ICMP6_SDU(output, IF_IP6_ICMP6_HDR_OFFSET) + size;
+	for (ix = size; ix -- > 0; )
+		*-- sdu = ('0' + send_icmp6_id + ix) & 0xff;
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	icmp6h->sum = 0;
+	icmp6h->sum = in6_cksum(output, IPPROTO_ICMPV6,
+	                        (uint8_t*)icmp6h - output->buf, ICMP6_HDR_SIZE + size);
+
+	/* å¿ç­ãã§ãã¯ç¨ã®å¤æ°ãè¨­å®ããã*/
+	reply_count = 0;
+
+#if 0
+	curr_icmp6_id   = send_icmp6_id ++;
+	curr_icmp6_size = size;
+#endif
+
+#if 0
+	syslog(LOG_NOTICE, "[PING6] send: TMO:%d, SIZE:%d, to: %s, from %s",
+	                   tmo, size,
+	                   ipv62str(NULL, addr), ipv62str(NULL, &ia->addr));
+#endif
+
+	/* éä¿¡å¾ãç¾å¨ã®æéãè¨æ¶ããã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+	ip6_output(output, ipflags, TMO_FEVR);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutEchos, 1);
+
+	syscall(get_tim(&icmp6_start_time));
+	timeout(icmp6_reply_timeout, NULL, tmo * NET_TIMER_HZ);
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #ifdef USE_PING */
Index: asp3_gr_sakura/trunk/tinet/netapp/resolver.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/resolver.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/resolver.c	(revision 317)
@@ -0,0 +1,1204 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãã¹ãåââIP ã¢ãã¬ã¹å¤æ
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <t_syslog.h>
+#include <syssvc/logtask.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_config.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/resolver.h>
+
+#if defined(USE_RESOLVER)
+
+/*
+ *  å±æå¤æ°
+ */
+
+static uint8_t	dns_domain_name[DNS_NAME_LENGTH + 1] = RSLV_CFG_DNS_DOMAIN_NAME_STR;
+
+#if defined(SUPPORT_INET6)
+static T_IN6_ADDR in6_addr_dns      = IPV6_ADDR_DNS_INIT;
+static T_IN6_ADDR in6_addr_dns_init = IPV6_ADDR_DNS_INIT;
+#endif
+
+#if defined(SUPPORT_INET4)
+static T_IN4_ADDR in4_addr_dns = IPV4_ADDR_DNS;
+#endif
+
+static uint16_t	dns_msg_id = 0;
+
+/*
+ *  get_dns_header -- DNS ã¡ãã»ã¼ã¸ãã DNS ããããåãåºãã
+ */
+
+static ER_UINT
+get_dns_header (uint8_t *msg, uint_t length, T_RSLV_DNS_MSG *rslv)
+{
+	T_DNS_HDR	*dns_hdr;
+
+	/* DNS ããããåãåºãã*/
+	if (length < sizeof(rslv->dns_hdr))
+		return EV_RSLV_ESIZE;
+	dns_hdr = (T_DNS_HDR*)msg;
+	rslv->dns_hdr.id	= MSG2HOST16(dns_hdr->id);
+	rslv->dns_hdr.code	= MSG2HOST16(dns_hdr->code);
+	rslv->dns_hdr.qdcount	= MSG2HOST16(dns_hdr->qdcount);
+	rslv->dns_hdr.ancount	= MSG2HOST16(dns_hdr->ancount);
+	rslv->dns_hdr.nscount	= MSG2HOST16(dns_hdr->nscount);
+	rslv->dns_hdr.arcount	= MSG2HOST16(dns_hdr->arcount);
+	return sizeof(rslv->dns_hdr);
+	}
+
+/*
+ *  dns_strtype -- DNS ã® type ã®æå­åãè¿ãã
+ */
+
+static const char *
+dns_flag_qtype (uint16_t flags)
+{
+	if      (flags & DNS_LUP_FLAGS_QTYPE_AAAA)
+		return "AAAA";
+	else if (flags & DNS_LUP_FLAGS_QTYPE_A)
+		return "   A";
+	else if (flags & DNS_LUP_FLAGS_QTYPE_PTR)
+		return " PTR";
+	else
+		return "unknown type";
+	}
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  udp6_dns -- UDP/IPv6 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER
+udp6_dns (uint16_t flags, T_IN6_ADDR *addr, uint8_t *msg, uint_t msg_size, uint_t length)
+{
+	T_IPV6EP	ep_dns;
+	ER_UINT		len = E_OK;
+	int		retry;
+
+	/* DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãã©ã¡ã¼ã¿ã¨ã©ã¼ */
+	if (IN6_IS_ADDR_UNSPECIFIED(addr) || (in6_is_addr_ipv4mapped(addr) && addr->s6_addr32[3] == IPV4_ADDRANY)) {
+		syslog(LOG_NOTICE, "[RSLV] undefined IPv6 DNS server address.");
+		return E_PAR;
+		}
+
+	memcpy(&ep_dns.ipaddr, addr, sizeof(*addr));
+	ep_dns.portno = RSLV_CFG_DNS_PORTNO;
+	for (retry = NUM_DNS_UDP_RETRY + 1; retry -- > 0; ) {
+		if ((len = udp6_snd_dat(UDP6_RESOLVER_CEPID, &ep_dns, msg, length, TMO_DNS_UDP_SND)) >= 0) {
+			if ((len = udp6_rcv_dat(UDP6_RESOLVER_CEPID, &ep_dns, msg, msg_size, TMO_DNS_UDP_RCV)) >= 0)
+				return len;
+			}
+		if (flags & DNS_LUP_FLAGS_MSG) {
+			if (len == E_TMOUT)
+				syslog(LOG_NOTICE, "[RSLV] TMOUT: %d, type: %s, server: %s.%d.",
+				       NUM_DNS_UDP_RETRY + 1 - retry,
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] error:  %s, type: %s,\n       server: %s.%d.",
+				       itron_strerror(len),
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+				return len;
+				}
+			}
+		}
+	return E_TMOUT;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  udp4_dns -- UDP/IPv4 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER
+udp4_dns (uint16_t flags, T_IN4_ADDR *addr, uint8_t *msg, uint_t msg_size, uint_t length)
+{
+	T_IPV4EP	ep_dns;
+	ER_UINT		len = E_OK;
+	int		retry;
+
+	/* DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯ãã©ã¡ã¼ã¿ã¨ã©ã¼ */
+	if (*addr == IPV4_ADDRANY) {
+		syslog(LOG_NOTICE, "[RSLV] undefined IPv4 DNS server address.");
+		return E_PAR;
+		}
+
+	memcpy(&ep_dns.ipaddr, addr, sizeof(*addr));
+	ep_dns.portno = RSLV_CFG_DNS_PORTNO;
+	for (retry = NUM_DNS_UDP_RETRY + 1; retry -- > 0; ) {
+		if ((len = udp_snd_dat(UDP4_RESOLVER_CEPID, &ep_dns, msg, length, TMO_DNS_UDP_SND)) >= 0) {
+			if ((len = udp_rcv_dat(UDP4_RESOLVER_CEPID, &ep_dns, msg, msg_size, TMO_DNS_UDP_RCV)) >= 0)
+				return len;
+			}
+		if (flags & DNS_LUP_FLAGS_MSG) {
+			if (len == E_TMOUT)
+				syslog(LOG_NOTICE, "[RSLV] TMOUT: %d, type: %s, server: %s.%d.",
+				       NUM_DNS_UDP_RETRY + 1 - retry,
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] error: %s, type: %s, server: %s.%d.",
+				       itron_strerror(len),
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &ep_dns.ipaddr), ep_dns.portno);
+				return len;
+				}
+			}
+		}
+	return E_TMOUT;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  skip_label -- ã©ãã«ãèª­ã¿é£ã°ãã
+ */
+
+static char *
+skip_label (char *name)
+{
+	while (!(*name == '\0' || *name == '.'))
+		name ++;
+	return name;
+	}
+
+/*
+ *  add_name -- ã¡ãã»ã¼ã¸ã«ååãè¿½å ããã
+ */
+
+static ER_UINT
+add_name (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	uint_t	label_len;
+	char	*tail;
+
+	while (*name != '\0') {
+
+		/* ã¡ãã»ã¼ã¸ãµã¤ãºã«éãã¦ãããã¨ã©ã¼ */
+		if (offset + 1 > size)
+			return E_BOVR;
+
+		/* ã©ãã«ã®çµãããè¦ã¤ããã*/
+		tail = skip_label(name);
+
+		/* ã©ãã«é·ãè¨­å®ããã*/
+		label_len = tail - name;
+		if (label_len > DNS_LABEL_LENGTH) {	/* 63 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] label length(%d) too long > %d.",
+			                   label_len, DNS_LABEL_LENGTH);
+			return E_PAR;
+			}
+
+		*(msg + offset) = (uint8_t)label_len;
+		offset ++;
+
+		/* ã©ãã«åãè¨­å®ããã*/
+		if (offset + label_len > size) {	/* ã¡ãã»ã¼ã¸ãµã¤ãºãè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] message length(%d) too long > %d.",
+			                   offset + label_len, size);
+			return E_BOVR;
+			}
+
+		memcpy((void*)(msg + offset), (void*)name, label_len);
+		offset += label_len;
+
+		/* æ¬¡ã®ã©ãã«ã«ç§»åããã*/
+		if (*tail == '\0')
+			name = tail;
+		else
+			name = tail + 1;	/* '.' ãã¹ã­ããããã*/
+		}
+
+	return offset;
+	}
+
+/*
+ *  add_ipv6addr -- ã¡ãã»ã¼ã¸ã« IPv6 ã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+static ER_UINT
+add_ipv6addr (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	T_IN6_ADDR	addr;
+	ER_UINT		error;
+	uint_t		len;
+	int			col;
+	char		digit[2];
+
+	len = strlen(name);
+	if (len == 0)
+		return E_PAR;
+
+	digit[1] = '\0';
+	get_ipv6addr(&addr, name);
+	for (col = sizeof(T_IN6_ADDR) * 2; -- col >= 0; ) {
+
+		/* 16é²æ° 1æ¡ã®å¤ããååã¨ãã¦è¿½å ããã*/
+		digit[0] = (addr.s6_addr8[col / 2] >> ((1 - (col % 2)) << 2)) & 0x0f;
+		if (digit[0] >= 10)
+			digit[0] += 'a' - 10;
+		else
+			digit[0] += '0';
+		if ((error = add_name(msg, size, offset, digit)) < 0)
+			return error;
+		offset = error;
+		}
+
+	/* "ip6" ãè¿½å ããã*/
+	if ((error = add_name(msg, size, offset, "ip6")) < 0)
+		return error;
+
+	/* "arpa" ãè¿½å ããã*/
+	return add_name(msg, size, error, "arpa");
+	}
+
+/*
+ *  add_ipv4addr -- ã¡ãã»ã¼ã¸ã« IPv4 ã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+static ER_UINT
+add_ipv4addr (uint8_t *msg, uint_t size, uint_t offset, char *name)
+{
+	T_IN4_ADDR	addr;
+	ER_UINT		error;
+	uint_t		len, octet;
+	int			col;
+	char		*op, ostr[4];
+
+	len = strlen(name);
+	if (len == 0)
+		return E_PAR;
+
+	ostr[3] = '\0';
+	get_ipv4addr(&addr, name);
+	for (col = 0; col < sizeof(T_IN4_ADDR); col ++) {
+
+		/* 1ãªã¯ãããã®å¤ããæ´æ°å¤ãããªãã©ã«ã«å¤æããã*/
+		octet = (addr >> (col << 3)) & 0xff;
+		op = &ostr[3];
+		while (octet > 0) {
+			*(-- op) = octet % 10 + '0';
+			octet   /= 10;
+			}
+
+		/* 1ãªã¯ãããã®å¤ããååã¨ãã¦è¿½å ããã*/
+		if ((error = add_name(msg, size, offset, op)) < 0)
+			return error;
+		offset = error;
+		}
+
+	/* "in-addr" ãè¿½å ããã*/
+	if ((error = add_name(msg, size, offset, "in-addr")) < 0)
+		return error;
+
+	/* "arpa" ãè¿½å ããã*/
+	return add_name(msg, size, error, "arpa");
+	}
+
+/*
+ *  setup_dns_msg -- DNS ã¡ãã»ã¼ã¸ãä½æããã
+ */
+
+static ER
+setup_dns_msg (uint16_t flags, char *name, uint8_t *msg, uint_t msg_size)
+{
+	T_DNS_HDR	dns_hdr;
+	ER_UINT		offset;
+
+	memset((void*)&dns_hdr, 0, sizeof(dns_hdr));
+
+	dns_msg_id++;
+	HOST2MSG16(dns_hdr.id,      dns_msg_id);
+	HOST2MSG16(dns_hdr.code,    (flags & DNS_OPCODE_MASK) | DNS_RECURSION_DESIRED);
+	HOST2MSG16(dns_hdr.qdcount, 1);
+
+	memcpy((void*)msg, (void*)&dns_hdr, sizeof(dns_hdr));
+	offset = sizeof(dns_hdr);
+
+	switch (flags & DNS_LUP_FLAGS_NAME_MASK) {
+
+	case DNS_LUP_FLAGS_NAME_HOST:
+	case DNS_LUP_FLAGS_NAME_FQDN:
+
+		/* ãã¹ãåãã¾ãã¯ FQDN ã®æã®å¦çã*/
+		/* ãã¹ãåãè¿½å ããã*/
+		if ((offset = add_name(msg, msg_size, offset, name)) < 0)
+			return offset;
+
+		if (offset - sizeof(dns_hdr) > DNS_NAME_LENGTH) {		/* ååã 255 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[RSLV] name length(%d) too long > %d.",
+			                   offset - sizeof(dns_hdr), DNS_NAME_LENGTH);
+			return E_PAR;
+			}
+
+		/* ãã¹ãåã ãã®æã¯ããã¡ã¤ã³åãè¿½å ããã*/
+		if ((flags & DNS_LUP_FLAGS_NAME_MASK) == DNS_LUP_FLAGS_NAME_HOST) {
+
+			/* ãã¡ã¤ã³åãè¿½å ããã*/
+			if ((offset = add_name(msg, msg_size, offset, (char *)dns_domain_name)) < 0)
+				return offset;
+
+			if (offset - sizeof(dns_hdr) > DNS_NAME_LENGTH) {		/* ååã 255 ãªã¯ããããè¶
+ããã¨ã¨ã©ã¼ */
+				syslog(LOG_NOTICE, "[RSLV] name length(%d) too long > %d.",
+				                   offset - sizeof(dns_hdr), DNS_NAME_LENGTH);
+				return E_PAR;
+				}
+			}
+		break;
+
+	case DNS_LUP_FLAGS_NAME_IPV4:
+		if ((offset = add_ipv4addr(msg, msg_size, offset, name)) < 0)
+			return offset;
+		break;
+
+	case DNS_LUP_FLAGS_NAME_IPV6:
+		if ((offset = add_ipv6addr(msg, msg_size, offset, name)) < 0)
+			return offset;
+		break;
+
+	default:
+		syslog(LOG_NOTICE, "[RSLV] unknown name type: %04x.", flags & DNS_LUP_FLAGS_NAME_MASK);
+		return E_PAR;
+		break;
+
+		}
+
+	/* ååã®çµäºã³ã¼ããTYPEãCLASS ãè¿½å ãã¦ãã¡ãã»ã¼ã¸é·ãè¶
+ããªããã¨ãç¢ºèªããã*/
+	if (offset + sizeof(uint16_t) * 2 + 1 > msg_size) {
+		syslog(LOG_NOTICE, "[RSLV] message length(%d) too long > %d.",
+		                   offset + sizeof(uint16_t) * 2 + 1, msg_size);
+		return E_BOVR;
+		}
+
+	/* ååã®çµäºã³ã¼ããè¨­å®ããã*/
+	*(msg + offset) = '\0';
+	offset ++;
+
+	/* DNS ã® TYPE ãè¨­å®ããã*/
+	if (flags & DNS_LUP_FLAGS_QTYPE_PTR)
+		host2msg16(msg + offset, DNS_TYPE_PTR);
+	else if (flags & DNS_LUP_FLAGS_QTYPE_AAAA)
+		host2msg16(msg + offset, DNS_TYPE_AAAA);
+	else if (flags & DNS_LUP_FLAGS_QTYPE_A)
+		host2msg16(msg + offset, DNS_TYPE_A);
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+		return E_PAR;
+		}
+	offset += sizeof(uint16_t);
+
+	/* DNS ã® CLASS ãè¨­å®ããã*/
+	host2msg16(msg + offset, DNS_CLASS_IN);
+
+	return offset + sizeof(uint16_t);
+	}
+
+/*
+ *  skip_dns_name -- DNS ã¡ãã»ã¼ã¸ã®ååãèª­ã¿é£ã°ãã
+ *
+ *    æ³¨æ: å§ç¸®å½¢å¼ãèæ
+®ãããä¸ä½ 2ãããã 11ãªãå§ç¸®å½¢å¼ã
+ */
+
+static ER_UINT
+skip_dns_name (uint8_t *name, uint_t offset, uint_t length)
+{
+	while (*(name + offset)) {
+		if ((*(name + offset) & 0xc0) == 0xc0) {
+			if (offset + 2 > length)
+				return EV_RSLV_ESIZE;
+			else
+				return offset + 2;
+			}
+		else if (offset + *name + 1 > length)
+			return EV_RSLV_ESIZE;
+		else
+			offset += *name + 1;
+		}
+	return offset + 1;
+	}
+
+/*
+ *  skip_dns_qd -- DNS Question section ãèª­ã¿é£ã°ãã
+ */
+
+static ER_UINT
+skip_dns_qd (uint8_t *msg, uint_t offset, uint_t length, uint_t count)
+{
+	ER_UINT	next;
+
+	while (count != 0) {
+		/* name ãèª­ã¿é£ã°ãã*/
+		if ((next = skip_dns_name(msg, offset, length)) < 0)
+			return next;
+		offset = next;
+
+		/* typeãclass ãèª­ã¿é£ã°ãã*/
+		if ((offset + sizeof(uint16_t) + sizeof(uint16_t)) > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + sizeof(uint16_t);
+
+		count --;
+		}
+
+	return offset;
+	}
+
+/*
+ *  skip_dns_rr -- DNS RR ãèª­ã¿é£ã°ãã
+ */
+
+static ER_UINT
+skip_dns_rr (uint8_t *msg, uint_t offset, uint_t length, uint_t count)
+{
+	ER_UINT		next;
+	uint16_t	len = 0;
+
+	while (count != 0) {
+		/* name ãèª­ã¿é£ã°ãã*/
+		if ((next = skip_dns_name(msg, offset, length)) < 0)
+			return next;
+		offset = next;
+
+		/* typeãclassãTTL ãèª­ã¿é£ã°ãã*/
+		if (offset + sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t) > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + sizeof(uint16_t) + sizeof(uint32_t);
+
+		/* RD length ã¨ RDATA ãèª­ã¿é£ã°ãã*/
+		if (offset + sizeof(uint16_t) > length)
+			return EV_RSLV_ESIZE;
+		len = msg2host16(msg + offset);
+
+		if (offset + sizeof(uint16_t) + len > length)
+			return EV_RSLV_ESIZE;
+		offset += sizeof(uint16_t) + len;
+
+		count --;
+		}
+
+	return offset;
+	}
+
+/*
+ *  dns_analyze_qd -- DNS ã¡ãã»ã¼ã¸ã® question section ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_qd (T_RSLV_QD *qd, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_QD	*dns_qd;
+
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_QD_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_qd = (T_DNS_QD*)(msg + offset);
+	qd->type  = MSG2HOST16(dns_qd->type);
+	qd->class = MSG2HOST16(dns_qd->class);
+
+	return offset + T_DNS_QD_SIZE;
+	}
+
+/*
+ *  dns_analyze_soa -- DNS ã¡ãã»ã¼ã¸ã® SOA RDATA ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_soa (T_RSLV_SOA *soa, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_SOA	*dns_soa;
+
+	/* MNAME ãã¹ã­ããããã*/
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* RNAME ãã¹ã­ããããã*/
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_SOA_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_soa = (T_DNS_SOA*)(msg + offset);
+	soa->serial  = MSG2HOST32(dns_soa->serial);
+	soa->refresh = MSG2HOST32(dns_soa->refresh);
+	soa->retry   = MSG2HOST32(dns_soa->retry);
+	soa->expire  = MSG2HOST32(dns_soa->expire);
+	soa->minimum = MSG2HOST32(dns_soa->minimum);
+
+	return offset + T_DNS_SOA_SIZE;
+	}
+
+/*
+ *  dns_analyze_rr -- DNS ã¡ãã»ã¼ã¸ã® AN/NS/AR section ãè§£æããã
+ */
+
+ER_UINT
+dns_analyze_rr (T_RSLV_RR *rr, uint_t offset, uint8_t *msg, uint_t length)
+{
+	ER_UINT		error;
+	T_DNS_RR	*dns_rr;
+
+	if ((error = skip_dns_name(msg, offset, length)) < 0)
+		return error;
+	offset = error;
+
+	/* DNS ã¡ãã»ã¼ã¸å
+ã®å½¢å¼ã®ãµã¤ãºã§ãã§ãã¯ããã*/
+	if (offset + T_DNS_RR_SIZE > length)
+		return EV_RSLV_ESIZE;
+
+	/*
+	 *  DNS ã¡ãã»ã¼ã¸å
+ã® SOA RDATA ããã¤ããªã¼ãã¼ãèª¿æ´ãã¦
+	 *  å
+é¨æ§é ä½ã«ã³ãã¼ããã
+	 */
+	dns_rr = (T_DNS_RR*)(msg + offset);
+	rr->type	= MSG2HOST16(dns_rr->type);
+	rr->class	= MSG2HOST16(dns_rr->class);
+	rr->ttl		= MSG2HOST32(dns_rr->ttl);
+	rr->rdlength	= MSG2HOST16(dns_rr->rdlength);
+	rr->rdata_offset= offset + sizeof(rr->type) + sizeof(rr->class)
+	                         + sizeof(rr->ttl)  + sizeof(rr->rdlength);
+
+	return offset + T_DNS_RR_SIZE + rr->rdlength;
+	}
+
+/*
+ *  analyze_dns_msg -- DNS ã¡ãã»ã¼ã¸ãè§£æããã
+ */
+
+static ER_UINT
+analyze_dns_msg (uint8_t *msg, uint_t length, T_RSLV_DNS_MSG *rslv)
+{
+	ER_UINT	offset;
+
+	/* DNS ããããåãåºãã*/
+	if ((offset = get_dns_header(msg, length, rslv)) < 0)
+		return offset;
+
+	/* question section ãèª­ã¿é£ã°ãã*/
+	rslv->qd_offset = offset;
+	if ((offset = skip_dns_qd(msg, offset, length, rslv->dns_hdr.qdcount)) < 0)
+		return offset;
+
+	/* answer section ãèª­ã¿é£ã°ãã*/
+	rslv->an_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.ancount)) < 0)
+		return offset;
+
+	/* authority records section ãèª­ã¿é£ã°ãã*/
+	rslv->ns_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.nscount)) < 0)
+		return offset;
+
+	/* additional records  section ãèª­ã¿é£ã°ãã*/
+	rslv->ar_offset = offset;
+	if ((offset = skip_dns_rr(msg, offset, length, rslv->dns_hdr.arcount)) < 0)
+		return offset;
+
+	return E_OK;
+	}
+
+/*
+ *  dns_lookup_host_sub -- DNS ã«ãããã¹ãã®æ
+å ±ãåå¾ããï¼è£å©é¢æ°ï¼ã
+ */
+
+static ER_UINT
+dns_lookup_host_sub (uint16_t flags, char *hostname, uint8_t *msg, 
+                     uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	uint16_t	proto;
+#endif
+	ER_UINT		length;
+	ER		error;
+
+	if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+		return length;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV6) {
+		proto = DNS_LUP_FLAGS_PROTO_IPV6;
+		if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else if (flags & DNS_LUP_FLAGS_PROTO_IPV4) {
+		proto = DNS_LUP_FLAGS_PROTO_IPV4;
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV6) {
+		if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+	if (flags & DNS_LUP_FLAGS_PROTO_IPV4) {
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+	else {
+		syslog(LOG_NOTICE, "[RSLV] unknown lookup protocol: %04x.", flags & DNS_LUP_FLAGS_PROTO_MASK);
+		return E_PAR;
+		}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	if ((error = analyze_dns_msg(msg, length, rslv)) != E_OK)
+		return error;
+	else {
+		if ((rslv->dns_hdr.ancount > 0) && (flags & DNS_LUP_FLAGS_MSG)) {
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+			if (proto & DNS_LUP_FLAGS_PROTO_IPV6) {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &in6_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			else {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &in4_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+			syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+			       dns_flag_qtype(flags),
+			       ipv62str(NULL, &in6_addr_dns),
+			       RSLV_CFG_DNS_PORTNO);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+			syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+			       dns_flag_qtype(flags),
+			       ip2str(NULL, &in4_addr_dns),
+			       RSLV_CFG_DNS_PORTNO);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+			}
+		return length;
+		}
+	}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+/*
+ *  udp64_dns -- DNS/IPv6ãDNS/IPv4 ã«ãã DNS ãµã¼ãããã¡ãã»ã¼ã¸ãåä¿¡ããã
+ */
+
+static ER_UINT
+udp64_dns (uint16_t flags, char *hostname, uint8_t *msg, 
+           uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+	ER_UINT		length;
+	ER		error;
+	uint16_t	proto;
+
+	/* DNS ã¡ãã»ã¼ã¸ãä½æããã*/
+	if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+		return length;
+
+	/* UDP/IPv6 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+	proto = DNS_LUP_FLAGS_PROTO_IPV6;
+	if ((length = udp6_dns(flags, &in6_addr_dns, msg, msg_size, length)) < 0) {
+		/*  UDP/IPv6 ã® DNS ãµã¼ãã¸ã®ç
+§ä¼ãã¨ã©ã¼ã«ãªã£ãæã¯ãUDP/IPv4 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+		if ((length = setup_dns_msg(flags, hostname, msg, msg_size)) < 0)
+			return length;
+
+		/* UDP/IPv4 ã® DNS ãµã¼ãã«ç
+§ä¼ããã*/
+		proto = DNS_LUP_FLAGS_PROTO_IPV4;
+		if ((length = udp4_dns(flags, &in4_addr_dns, msg, msg_size, length)) < 0)
+			return length;
+		}
+
+	/* DNS ã¡ãã»ã¼ã¸ãè§£æããã*/
+	if ((error = analyze_dns_msg(msg, length, rslv)) != E_OK)
+		return error;
+	else {
+		if ((rslv->dns_hdr.ancount > 0) && (flags & DNS_LUP_FLAGS_MSG)) {
+			if (proto & DNS_LUP_FLAGS_PROTO_IPV6) {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ipv62str(NULL, &in6_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			else {
+				syslog(LOG_NOTICE, "[RSLV] reslv:    type: %s, server: %s.%d.",
+				       dns_flag_qtype(flags),
+				       ip2str(NULL, &in4_addr_dns),
+				       RSLV_CFG_DNS_PORTNO);
+				}
+			}
+		return length;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  dns_lookup_host -- DNS ã«ãããã¹ãã®æ
+å ±ãåå¾ããã
+ */
+
+ER_UINT
+dns_lookup_host (uint16_t flags, char *hostname, uint8_t *msg, 
+              uint_t msg_size, T_RSLV_DNS_MSG *rslv)
+{
+	ER	error;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if ((flags & DNS_LUP_FLAGS_PROTO_MASK) == (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) {
+
+		/*
+		 *  IPv6/IPv4 ã®ä¸¡æ¹ãæå®ãããæã®å¦ç
+		 *  ã¾ã type == AAAA ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+		 */
+		if (flags & DNS_LUP_FLAGS_QTYPE_PTR) {
+			if ((error = udp64_dns(flags, hostname, msg, msg_size, rslv)) < 0)
+				return error;
+			}
+		else if (flags & DNS_LUP_FLAGS_QTYPE_AAAA) {
+			if ((error = udp64_dns(flags & ~DNS_LUP_FLAGS_QTYPE_A, hostname, msg, msg_size, rslv)) < 0)
+				return error;
+			}
+		else {
+			HOST2MSG16(rslv->dns_hdr.ancount, 0);
+			error = E_OK;
+			}
+
+		if (rslv->dns_hdr.ancount == 0) {
+
+			/*
+			 *  type == AAAA ã§ã¢ãã¬ã¹è§£æ±ºãã§ããªãã£ãæã®å¦ç
+			 *  type == A ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+			 */
+			if (flags & DNS_LUP_FLAGS_QTYPE_A)
+				return udp64_dns(flags & ~DNS_LUP_FLAGS_QTYPE_AAAA, hostname, msg, msg_size, rslv);
+			else {
+				syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+				return E_PAR;
+				}
+			}
+		else
+			return error;
+		}
+
+	if ((flags & DNS_LUP_FLAGS_QTYPE_MASK) == (DNS_LUP_FLAGS_QTYPE_AAAA | DNS_LUP_FLAGS_QTYPE_A)) {
+
+		/*
+		 *  type == AAAA ã¨ A ã®ä¸¡æ¹ãæå®ãããæã®å¦ç
+		 *  ã¾ã type == AAAA ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+		 */
+		if ((error = dns_lookup_host_sub(flags & ~DNS_LUP_FLAGS_QTYPE_A, hostname, msg, msg_size, rslv)) < 0)
+			return error;
+
+		if (rslv->dns_hdr.ancount == 0) {
+
+			/*
+			 *  type == AAAA ã§ã¢ãã¬ã¹è§£æ±ºãã§ããªãã£ãæã®å¦ç
+			 *  type == A ã§ DNS ãµã¼ãã«ç
+§ä¼ããã
+			 */
+			return dns_lookup_host_sub(flags & ~DNS_LUP_FLAGS_QTYPE_AAAA, hostname, msg, msg_size, rslv);
+			}
+#if 0
+		else {
+			syslog(LOG_NOTICE, "[RSLV] unknown query type: %04x.", flags & DNS_LUP_FLAGS_QTYPE_MASK);
+			return E_PAR;
+			}
+#endif
+		}
+
+	else {
+		/* IPv6/IPv4 ã®ã©ã¡ããä¸æ¹ãæå®ãããæã®å¦ç */
+		error = dns_lookup_host_sub(flags, hostname, msg, msg_size, rslv);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	error = dns_lookup_host_sub(flags, hostname, msg, msg_size, rslv);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return error;
+	}
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  dns_in6_set_dname -- DNS ã® ãã¡ã¤ã³åãè¨­å®ããï¼DHCPv6ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+const uint8_t *
+dns_in6_set_dname (const uint8_t *new, uint_t len)
+{
+	uint8_t	*dst;
+	int	label_len, name_len = DNS_NAME_LENGTH;
+
+	if (new == NULL)
+		strcpy((char *)dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
+	else {
+		dst = dns_domain_name;
+		while ((*new != 0) && (name_len > 0) && (len > 0)) {
+			label_len = *new ++;
+			len --;
+			while ((name_len > 0) && (len > 0) && (label_len > 0)) {
+				*dst ++ = *new ++;
+				name_len  --;
+				len       --;
+				label_len --;
+				}
+			if ((*new != 0) && (name_len > 0)) {
+				*dst ++ = '.';
+				name_len --;
+				}
+			}
+		*dst = '\0';
+		}
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in6_get_dname -- DNS ã® ãã¡ã¤ã³åãå¾ãã
+ */
+
+const uint8_t *
+dns_in6_get_dname (void)
+{
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in6_set_addr -- DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãè¨­å®ããï¼DHCPv6ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+T_IN6_ADDR *
+dns_in6_set_addr (T_IN6_ADDR *new)
+{
+	if (new == NULL)
+		in6_addr_dns = in6_addr_dns_init;
+	else
+		in6_addr_dns = *new;
+	return &in6_addr_dns;
+	}
+
+/*
+ *  dns_in6_get_addr -- DNS ãµã¼ãã® IPv6 ã¢ãã¬ã¹ãå¾ãã
+ */
+
+T_IN6_ADDR *
+dns_in6_get_addr (T_IN6_ADDR *dst)
+{
+	if (dst == NULL)
+		return NULL;
+	else {
+		*dst = in6_addr_dns;
+		return dst;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  dns_in4_set_dname -- DNS ã® ãã¡ã¤ã³åãè¨­å®ããï¼DHCPv4ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+const uint8_t *
+dns_in4_set_dname (const uint8_t *new, uint_t len)
+{
+	uint8_t	*dst;
+	int	name_len = DNS_NAME_LENGTH;
+
+	if (new == NULL)
+		strcpy((char *)dns_domain_name, RSLV_CFG_DNS_DOMAIN_NAME_STR);
+	else {
+		dst = dns_domain_name;
+		while ((name_len -- > 0) && (len -- > 0) && *new)
+			*dst ++ = *new ++;
+		*dst = '\0';
+		}
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in4_get_dname -- DNS ã® ãã¡ã¤ã³åãå¾ãã
+ */
+
+const uint8_t *
+dns_in4_get_dname (void)
+{
+	return dns_domain_name;
+	}
+
+/*
+ *  dns_in4_set_addr -- DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãè¨­å®ããï¼DHCPv4ç¨ï¼ã
+ *
+ *    æ³¨æ: new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+T_IN4_ADDR *
+dns_in4_set_addr (T_IN4_ADDR *new)
+{
+	if (new == NULL)
+		in4_addr_dns = IPV4_ADDR_DNS;
+	else
+		in4_addr_dns = *new;
+	return &in4_addr_dns;
+	}
+
+/*
+ *  dns_in4_get_addr -- DNS ãµã¼ãã® IPv4 ã¢ãã¬ã¹ãå¾ãã
+ */
+
+T_IN4_ADDR *
+dns_in4_get_addr (T_IN4_ADDR *dst)
+{
+	if (dst == NULL)
+		return NULL;
+	else {
+		*dst = in4_addr_dns;
+		return dst;
+		}
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+/*
+ *  dns_host_addr -- ãã¹ãåã IP ã¢ãã¬ã¹ã«å¤æããã
+ */
+
+ER
+dns_host_addr (uint16_t flags, char *hostname, T_IN_ADDR *addr)
+{
+	T_RSLV_DNS_MSG	rslv;
+	T_RSLV_RR	rr;
+	ER_UINT		length, offset;
+	ER		error = E_OK;
+	int		scount;
+	uint8_t 	*msg;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	T_IN4_ADDR	addr4;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK)
+		return error;
+
+	if ((length = dns_lookup_host(flags, hostname, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
+		error = length;
+		goto err_ret;
+		}
+
+	offset = rslv.an_offset;
+	for (scount = 1; scount <= rslv.dns_hdr.ancount; scount ++) {
+		if ((offset = dns_analyze_rr(&rr, offset, msg, length)) < 0) {
+			error = offset;
+			goto err_ret;
+			}
+
+#if defined(SUPPORT_INET6)
+
+		if (rr.type == DNS_TYPE_AAAA && rr.class == DNS_CLASS_IN &&  rr.rdlength == sizeof(*addr)) {
+			memcpy((void*)addr, (void*)(msg + rr.rdata_offset), sizeof(*addr));
+			break;
+			}
+
+#if defined(SUPPORT_INET4)
+
+		if (rr.type == DNS_TYPE_A && rr.class == DNS_CLASS_IN && rr.rdlength == sizeof(addr4)) {
+			addr4 = msg2host32(msg + rr.rdata_offset);
+			in6_make_ipv4mapped(addr, addr4);
+			break;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+		if (rr.type == DNS_TYPE_A && rr.class == DNS_CLASS_IN && rr.rdlength == sizeof(*addr)) {
+			*addr = msg2host32((msg + rr.rdata_offset));
+			break;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+		}
+	if (scount > rslv.dns_hdr.ancount)
+		error = EV_RSLV_UNEXPCT;
+
+err_ret:
+	rel_mpf(MPF_RSLV_SRBUF, (void*)msg);
+	return error;
+	}
+
+#endif	/* of #if defined(USE_RESOLVER) */
Index: asp3_gr_sakura/trunk/tinet/netapp/resolver.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/resolver.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/resolver.h	(revision 317)
@@ -0,0 +1,332 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãã¹ãåââIP ã¢ãã¬ã¹å¤æ
+ */
+
+#ifndef RESOLVER_H
+#define RESOLVER_H
+
+#include <netapp/dns.h>
+
+/*
+ *  ã³ã³ãã¤ã«æã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ã®æå®
+ */
+
+/* ãã¼ãçªå· */
+
+#define RSLV_CFG_DNS_PORTNO	53
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ãå¤
+ */
+
+#define TMO_DNS_UDP_SND		ULONG_C(1*1000)	/* [ms]ãDNS ãµã¼ãã¸ã®   UDP éä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define TMO_DNS_UDP_RCV		ULONG_C(5*1000)	/* [ms]ãDNS ãµã¼ãããã® UDP åä¿¡ã¿ã¤ã ã¢ã¦ã	*/
+#define NUM_DNS_UDP_RETRY	1		/* ãªãã©ã¤åæ°					*/
+
+/*
+ *  ãã¡ã¤ã³å
+ */
+
+
+#if !defined(RSLV_CFG_DNS_DOMAIN_NAME_STR)
+#define RSLV_CFG_DNS_DOMAIN_NAME_STR	""
+#endif
+
+/*
+ *  DNS ãµã¼ãã¼ã® IPã¢ãã¬ã¹
+ */
+
+#if !defined(IPV6_ADDR_DNS_INIT)
+#define IPV6_ADDR_DNS_INIT	IPV6_ADDR_UNSPECIFIED_INIT
+#endif
+
+#if !defined(IPV4_ADDR_DNS)
+#define	IPV4_ADDR_DNS		IPV4_ADDRANY
+#endif
+
+/*
+ *  éåä¿¡ãããã¡æ°
+ */
+
+#define NUM_MPF_RSLV_SRBUF	1
+
+/*
+ *  ãã­ã°ã©ã ã§ä½¿ç¨ããæ
+å ±ã®å®ç¾©
+ */
+
+/*
+ *  ãã­ã°ã©ã ã§ä½¿ç¨ãã DNS ããã
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                      ID                       |
+ *  +--+-----------+--+--+--+--+--------+-----------+
+ *  |QR|   Opcode  |AA|TC|RD|RA|    Z   |   RCODE   |
+ *  +--+--------+--+--+--+--+--+--------+-----------+
+ *  |                    QDCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ANCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    NSCOUNT                    |
+ *  +-----------------------------------------------+
+ *  |                    ARCOUNT                    |
+ *  +-----------------------------------------------+
+ */
+
+typedef struct rslv_dns_hdr {
+	uint16_t	id;		/* ID */
+	uint16_t	code;	/* QR:		1
+				   Opcode:	4
+				   AA:		1
+				   TC:		1
+				   RD:		1
+				   RA:		1
+				   Z:		3
+				   RCODE:	4
+				   */
+	uint16_t	qdcount;	/* question   section */
+	uint16_t	ancount;	/* answer     section */
+	uint16_t	nscount;	/* authority  section */
+	uint16_t	arcount;	/* additional section */
+	} T_RSLV_DNS_HDR;
+
+/*
+ *  DNS message data
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_dns_msg {
+	T_RSLV_DNS_HDR	dns_hdr;	/* DNS heder                            */
+	uint_t		qd_offset;	/* offset of question           section */
+	uint_t		an_offset;	/* offset of answer             section */
+	uint_t		ns_offset;	/* offset of authority  records section */
+	uint_t		ar_offset;	/* offset of additional records section */
+	} T_RSLV_DNS_MSG;
+
+/*
+ *  RR (Resouce Record) å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                      NAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                      TYPE                     |
+ *  +-----------------------------------------------+
+ *  |                      CLASS                    |
+ *  +-----------------------------------------------+
+ *  |                       TTL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    RDLENGTH                   |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RDATA                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ *          ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_rr {
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	uint32_t	ttl;		/* TTL			*/
+	uint16_t	rdlength;	/* RDATA length		*/
+	uint_t		rdata_offset;	/* offset of RDATA	*/
+	} T_RSLV_RR;
+
+/*
+ *  Question section å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     QNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                     QTYPE                     |
+ *  +-----------------------------------------------+
+ *  |                     QCLASS                    |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_qd {
+	uint16_t	type;		/* TYPE			*/
+	uint16_t	class;		/* CLASS		*/
+	} T_RSLV_QD;
+
+/*
+ *  SOA RDATA å½¢å¼
+ *
+ *    0                    7  8                   15
+ *  +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     MNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                       .                       |
+ *  +-----------------      .      -----------------+
+ *  |                     RNAME                     |
+ *  +-----------------      .      -----------------+
+ *  |                       .                       |
+ *  +-----------------------------------------------+
+ *  |                    SERIAL                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    REFRESH                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                     RETRY                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    EXPIRE                     |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *  |                    MINIMUM                    |
+ *  |                                               |
+ *  +-----------------------------------------------+
+ *
+ *    æ³¨æ: offset ã®åç¹ã¯ DNS message ã®å
+é ­
+ *          ã¡ã³ãã¯ãã¹ããã¤ããªã¼ãã¼
+ */
+
+typedef struct rslv_soa {
+	uint32_t	serial;		/* SERIAL		*/
+	uint32_t	refresh;	/* REFRESH		*/
+	uint32_t	retry;		/* RETRY		*/
+	uint32_t	expire;		/* EXPIRE		*/
+	uint32_t	minimum;	/* MINIMUM		*/
+	} T_RSLV_SOA;
+
+/*
+ *  dns_lookup_host ã® flags ã®å®ç¾©
+ *
+ *    æ³¨æ:
+ *      dns.h ã§å®ç¾©ããã¦ãã DNS_OPCODE ã¨éãªããªããã¨ã
+ *      #define DNS_OPCODE_MASK		0x7800U
+ */
+
+#define DNS_LUP_FLAGS_NAME_IPV4		0x0004U
+#define DNS_LUP_FLAGS_NAME_IPV6		0x0006U
+#define DNS_LUP_FLAGS_NAME_HOST		0x0010U
+#define DNS_LUP_FLAGS_NAME_FQDN		0x0011U
+#define DNS_LUP_FLAGS_NAME_MASK		0x001fU
+
+#define DNS_LUP_OPCODE_FORWARD		DNS_OPCODE_FORWARD
+#define DNS_LUP_OPCODE_REVERSE		DNS_OPCODE_REVERSE
+#define DNS_LUP_OPCODE_STATUS		DNS_OPCODE_STATUS
+#define DNS_LUP_OPCODE_MASK		DNS_OPCODE_MASK
+
+#define DNS_LUP_FLAGS_PROTO_IPV4	0x0040U
+#define DNS_LUP_FLAGS_PROTO_IPV6	0x0080U
+#define DNS_LUP_FLAGS_PROTO_MASK	0x00c0U
+
+#define DNS_LUP_FLAGS_QTYPE_A		0x0100U
+#define DNS_LUP_FLAGS_QTYPE_AAAA	0x0200U
+#define DNS_LUP_FLAGS_QTYPE_PTR		0x0400U
+#define DNS_LUP_FLAGS_QTYPE_MASK	0x0700U
+
+#define DNS_LUP_FLAGS_MSG		0x0020U
+
+/*
+ *  ãããã¯ã¼ã¯ã¨ã©ã¼ã³ã¼ã
+ */
+
+#define EV_RSLV_ESIZE			(-100)		/* DNSã¡ãã»ã¼ã¸ã®ååé·ç°å¸¸	*/
+#define EV_RSLV_UNEXPCT			(-101)		/* äºæããªãDNSã¡ãã»ã¼ã¸	*/
+
+/*
+ *  é¢æ°
+ */
+
+extern ER_UINT	dns_lookup_host (uint16_t flags, char *hostname, uint8_t *msg, uint_t msg_len, T_RSLV_DNS_MSG *rslv);
+extern ER	dns_host_addr (uint16_t flags, char *hostname, T_IN_ADDR *addr);
+extern ER_UINT	dns_analyze_qd (T_RSLV_QD *qd, uint_t offset, uint8_t *msg, uint_t length);
+extern ER_UINT	dns_analyze_rr (T_RSLV_RR *rr, uint_t offset, uint8_t *msg, uint_t length);
+extern ER_UINT	dns_analyze_soa (T_RSLV_SOA *soa, uint_t offset, uint8_t *msg, uint_t length);
+
+/*
+ *  æ³¨æ: dns_in6_set_dnameãdns_in4_set_dnameã
+ *        dns_in6_set_addrã dns_in4_set_addr ã§ã
+ *        new ã« NULL ãæå®ããã¨ãåæå¤ã«æ»ãã
+ */
+
+extern const uint8_t *dns_in6_set_dname (const uint8_t *new, uint_t len);
+extern const uint8_t *dns_in6_get_dname (void);
+extern const uint8_t *dns_in4_set_dname (const uint8_t *new, uint_t len);
+extern const uint8_t *dns_in4_get_dname (void);
+extern T_IN6_ADDR *dns_in6_set_addr (T_IN6_ADDR *new);
+extern T_IN6_ADDR *dns_in6_get_addr (T_IN6_ADDR *dst);
+extern T_IN4_ADDR *dns_in4_set_addr (T_IN4_ADDR *new);
+extern T_IN4_ADDR *dns_in4_get_addr (T_IN4_ADDR *dst);
+
+#endif	/* of #ifndef RESOLVER_H */
Index: asp3_gr_sakura/trunk/tinet/netapp/resolver_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/resolver_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/resolver_asp.cfg	(revision 317)
@@ -0,0 +1,66 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ Resolver ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_RSLV_SRBUF, {
+	TA_TFIFO,
+	NUM_MPF_RSLV_SRBUF,
+	DNS_UDP_MSG_LENGTH,
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: asp3_gr_sakura/trunk/tinet/netapp/resolver_jsp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/resolver_jsp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/resolver_jsp.cfg	(revision 317)
@@ -0,0 +1,65 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ Resolver ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* éåä¿¡ãããã¡ */
+
+CRE_MPF(MPF_RSLV_SRBUF, {
+	TA_TFIFO,
+	NUM_MPF_RSLV_SRBUF,
+	DNS_UDP_MSG_LENGTH,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.c	(revision 317)
@@ -0,0 +1,535 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP DISCARD ã¯ã©ã¤ã¢ã³ã
+ *
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»IPv4
+ *    ã»IPv6
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_discard_cli.h>
+
+#ifdef USE_TCP_DISCARD_CLI
+
+/* discard ãµã¼ãã®ãã¼ãçªå· */
+
+#define DISCARD_SRV_PORTNO	UINT_C(9)
+
+/* è¡¨ç¤º */
+
+/*#define SHOW_RCV_RANGE*/
+
+/* éä¿¡éé */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/* èªåå®è¡ */
+
+#if defined(TCP_DISCARD_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#if defined(SUPPORT_INET6)
+#define TCP_DISCARD_CLI_AUTO_RUN_STR	"fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
+#else
+#define TCP_DISCARD_CLI_AUTO_RUN_STR	"172.25.129.142 - 0"
+#endif
+#endif
+#endif
+
+/*
+ *  ãããã¡ãµã¤ãºã®å®ç¾©
+ */
+
+#define NUM_DISCARD		5
+#define NUM_REP_PAT		40
+#define PAT_BEGIN		' '
+#define PAT_END			'~'
+#define SND_BUF_SIZE		((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t tcp_discard_cli_valid;
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_SWBUF_CSAVE_ONLY
+uint8_t tcp_discard_cli_swbuf[TCP_DISCARD_CLI_SWBUF_SIZE];
+#endif
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+static T_IPEP		nblk_src = {
+				IP_ADDRANY,
+				TCP_PORTANY,
+				};
+static T_IPEP		nblk_dst;
+static ER_UINT		nblk_error;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_discard_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	nblk_error = *(ER*)p_parblk;
+
+	switch (fncd) {
+
+	case TFN_TCP_CON_CEP:
+		syscall(sig_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if (nblk_error < 0)
+			syslog(LOG_NOTICE, "[TDCn:%02u CBN] close error: %s", cepid, itron_strerror(nblk_error));
+		syscall(sig_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_ACP_CEP:
+	case TFN_TCP_SND_DAT:
+	case TFN_TCP_GET_BUF:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  send_tcp_discard -- DISCARD/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static ER
+send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
+{
+	static char smsg[SND_BUF_SIZE];
+
+	ER_UINT		slen;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total;
+	uint16_t	soff, discard, rep, scount;
+	uint8_t		pat, *p;
+
+	nblk_dst.ipaddr = *ipaddr;
+	nblk_dst.portno = portno;
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+	if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* æ¥ç¶ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
+
+	if (nblk_error != E_OK)
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(nblk_error));
+	else {
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
+		                   cepid, time / SYSTIM_HZ, IP2STR(NULL, ipaddr), nblk_dst.portno);
+
+		scount = total = 0;
+		for (discard = NUM_DISCARD; discard -- > 0; ) {
+			soff = 0;
+			while (soff < SND_BUF_SIZE) {
+				if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
+					syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s",
+					                   cepid, itron_strerror(slen));
+					goto cls_ret;
+					}
+				soff  += (uint16_t)slen;
+				total +=     slen;
+				scount ++;
+
+#ifdef SHOW_RCV_RANGE
+				syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
+				                   cepid, scount, (uint16_t)slen, soff);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+				syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
+				}
+			}
+
+	cls_ret:
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
+		                   cepid, time / SYSTIM_HZ, scount, total);
+
+		if ((error = tcp_sht_cep(cepid)) < 0)
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
+
+		if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK)
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
+
+		/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_DISCARD_CLI_NBLK_READY));
+		}
+
+	return E_OK;
+	}
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+/*
+ *  send_tcp_discard -- DISCARD/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static ER
+send_tcp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
+{
+	static char smsg[SND_BUF_SIZE];
+	static T_IPEP src = {
+		IP_ADDRANY,
+		TCP_PORTANY,
+		};
+
+	T_IPEP		dst;
+	ER_UINT		slen;
+	ER		error;
+	SYSTIM		time;
+	uint16_t	pat, soff, discard, rep, scount, total;
+	uint8_t		*p;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+	if ((error = TCP_CON_CEP(cepid, &src, &dst, 60 * 1000)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] connect error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDCn:%02u SND] conct: %7lu, to:   %s.%d",
+	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+
+	scount = total = 0;
+	for (discard = NUM_DISCARD; discard -- > 0; ) {
+		soff = 0;
+		while (soff < SND_BUF_SIZE) {
+			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, TMO_FEVR)) < 0) {
+				syslog(LOG_NOTICE, "[TDCn:%02u SND] send error: %s", cepid, itron_strerror(slen));
+				goto cls_ret;
+				}
+			soff  += (uint16_t)slen;
+			total +=     slen;
+			scount ++;
+
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TDCn:%02u SND] send:  %7lu, len: %4u, off: %4u",
+			                   cepid, scount, (uint16_t)slen, soff);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			syscall(dly_tsk(500 + netapp_rand() % SYSTIM_HZ));
+			}
+		}
+
+cls_ret:
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDCn:%02u SND] finsh: %7lu, ttl: %lu",
+	                   cepid, time / SYSTIM_HZ, scount, total);
+
+	if ((error = tcp_sht_cep(cepid)) < 0)
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] shutdown error: %s", cepid, itron_strerror(error));
+
+	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) < 0)
+		syslog(LOG_NOTICE, "[TDCn:%02u SND] close error: %s", cepid, itron_strerror(error));
+
+	return E_OK;
+	}
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#ifdef TCP_DISCARD_CLI_AUTO_RUN_STR
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = TCP_DISCARD_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || (count == 0)) {
+		line = auto_run_str;
+		dly_tsk(3 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_TCP_DISCARD_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDCn:%02u TSK] error: %s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #ifdef TCP_DISCARD_CLI_AUTO_RUN_STR */
+
+void
+tcp_discard_cli_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	T_IN_ADDR	addr;
+	ER		error;
+	uint8_t		*line;
+	int_t		rep, count;
+	bool_t		retry = false;
+	uint16_t	portno;
+	char		apip;
+
+#ifdef USE_TCP_EXTENTIONS
+
+	T_TCP_CCEP	ccep;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
+	dly_tsk(START_DLY);
+#endif
+	get_tid(&tskid);
+
+#if defined(SUPPORT_INET6)
+	apip = API_PROTO_IPV6;
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#endif
+#else
+	apip = API_PROTO_IPV4;
+	syslog(LOG_NOTICE, "[TCP4 DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+#endif
+
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+		if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+		else
+			retry = false;
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else {
+			line ++;
+			portno = DISCARD_SRV_PORTNO;
+			}
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9')	/* Repeat */
+			line = get_int(&rep, line);
+		else
+			rep = 1;
+
+#ifdef USE_TCP_EXTENTIONS
+
+		ccep.cepatr = 0;
+		ccep.sbufsz = TCP_DISCARD_CLI_SWBUF_SIZE;
+		ccep.rbufsz = 0;
+		ccep.rbuf = NADR;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+		ccep.sbuf = NADR;
+#else
+		ccep.sbuf = tcp_discard_cli_swbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_tcp_discard_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP create error: %s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		cepid = (ID)exinf;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		tcp_discard_cli_valid = true;
+		count = 0;
+		while (rep == 0 || count < rep) {
+			if (!tcp_discard_cli_valid) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] canceled.", cepid);
+				break;
+				}
+
+			count ++;
+			if (rep == 0) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d", cepid, count);
+				error = send_tcp_discard(cepid, &addr, portno);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d", cepid, count);
+				}
+			else {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] start:       repeat: %d/%d", cepid, count, rep);
+				error = send_tcp_discard(cepid, &addr, portno);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] finsh:       repeat: %d/%d", cepid, count, rep);
+				}
+
+			if (error != E_OK) {
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] sleep %d.%03u[s], error: %s",
+				                   cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
+				tslp_tsk(SLP_ITV);
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] resume.", cepid);
+				}
+
+#if defined(SND_ITV)
+#if SND_ITV > 0
+			if (count < rep) {
+				uint_t itv;
+				
+				itv = SND_ITV;
+				syslog(LOG_NOTICE, "[TDCn:%02u TSK] interval: %d[s].", cepid, itv / SYSTIM_HZ);
+				syscall(dly_tsk(SND_ITV));
+				}
+#endif
+#endif
+			}
+
+#ifdef USE_TCP_EXTENTIONS
+
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TDCn:%02u TSK] CEP delete error: %s", cepid, itron_strerror(error));
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.cfg	(revision 317)
@@ -0,0 +1,91 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP DISCARD ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_DISCARD_CLI
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+CRE_TSK(TCP_DISCARD_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	tcp_discard_cli_task,
+	TCP_DISCARD_CLI_MAIN_PRIORITY,
+	TCP_DISCARD_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+CRE_TSK(TCP_DISCARD_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	TCP_DISCARD_CLI_CEPID,
+	tcp_discard_cli_task,
+	TCP_DISCARD_CLI_MAIN_PRIORITY,
+	TCP_DISCARD_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_TCP_DISCARD_CLI,  { TA_TFIFO, 1, NULL });
+
+/* ã»ããã© */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+CRE_SEM(SEM_TCP_DISCARD_CLI_NBLK_READY,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_cli.h	(revision 317)
@@ -0,0 +1,100 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_DISCARD_CLI_H_
+#define _TCP_DISCARD_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_DISCARD_CLI_STACK_SIZE	1024		/* TCP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+/* åªå
+åº¦ */
+
+#define TCP_DISCARD_CLI_MAIN_PRIORITY	5	/* TCP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦ */
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_DISCARD_CLI_SWBUF_SIZE	(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  å¤æ°
+ */
+
+extern bool_t	tcp_discard_cli_valid;
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_discard_cli_swbuf[];
+extern uint8_t tcp_discard_cli_rwbuf[];
+
+/* ã¿ã¹ã¯ */
+
+extern void tcp_discard_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_nblk_tcp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _TCP_DISCARD_CLI_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.c	(revision 317)
@@ -0,0 +1,369 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  DISCARD ãµã¼ã
+ *
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4
+ *    ã»IPv6
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_discard_srv.h>
+
+#ifdef USE_TCP_DISCARD_SRV
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+//#define SHOW_RCV_DATA
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_RWBUF_CSAVE_ONLY
+uint8_t tcp_discard_srv_rwbuf[TCP_DISCARD_SRV_RWBUF_SIZE];
+#endif
+
+/*
+ *  TCP DISCARD ãµã¼ãã¿ã¹ã¯
+ */
+
+#define BUF_SIZE	TCP_DISCARD_SRV_RWBUF_SIZE
+
+#ifdef USE_COPYSAVE_API
+
+static ER
+tcp_discard_srv (ID cepid, ID repid)
+{
+	T_IPEP		dst;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total;
+	uint16_t	count;
+	uint8_t		*buf;
+
+#ifdef SHOW_RCV_DATA
+	uint_t	ix;
+#endif	/* of #ifdef SHOW_RCV_DATA */
+
+	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u ACP] accept error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	count = total = 0;
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
+	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	while ((rlen = tcp_rcv_buf(cepid, (void*)&buf, TMO_FEVR)) > 0) {
+		count ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
+		       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+#ifdef SHOW_RCV_DATA
+		for (ix = 0; ix < rlen; ix ++)
+			cons_putchar(CONSOLE_PORTID,  *(buf + ix));
+#endif	/* of #ifdef SHOW_RCV_DATA */
+
+		if ((error = tcp_rel_buf(cepid, rlen)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDSn:%02u RCV] rel buf error: %s",
+			                    cepid, itron_strerror(error));
+			rlen = 0;
+			break;
+			}
+		total += rlen;
+		}
+
+	if (rlen != 0)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv buf error: %s", cepid, itron_strerror(rlen));
+
+	if ((error = tcp_sht_cep(cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
+
+	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
+	                   cepid, time / SYSTIM_HZ, count, total);
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+static ER
+tcp_discard_srv (ID cepid, ID repid)
+{
+	static char buffer[BUF_SIZE];
+
+	T_IPEP		dst;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total;
+	uint16_t	count;
+	uint8_t		*buf = buffer;
+
+	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] accept error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TDSn:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	count = total = 0;
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] conct: %7lu, from: %s.%d",
+	                   cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	while ((rlen = tcp_rcv_dat(cepid, buf, BUF_SIZE - 1, TMO_FEVR)) > 0) {
+		count ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] count: %6lu, len: %4u, data: %02x -> %02x",
+		       cepid, count, (uint16_t)rlen, *buf, *(buf + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		total += rlen;
+		}
+	if (rlen != 0)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] recv error: %s", cepid, itron_strerror(rlen));
+
+	if ((error = tcp_sht_cep(cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] shutdown error: %s", cepid, itron_strerror(error));
+
+	if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
+		syslog(LOG_NOTICE, "[TDSn:%02u RCV] close error: %s", cepid, itron_strerror(error));
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TDSn:%02u RCV] finsh: %7lu, ttl: %lu",
+	                   cepid, time / SYSTIM_HZ, count, total);
+
+	return error;
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  get_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+static ER
+get_tcp_rep (ID *repid)
+{
+	ID		tskid;
+	T_TCPN_CREP	crep;
+
+	get_tid(&tskid);
+
+	crep.repatr = UINT_C(0);
+	crep.myaddr.portno = UINT_C(9);
+
+#if defined(SUPPORT_INET6)
+
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+	crep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+/*
+ *  get_tcp_cep -- TCP éä¿¡ç«¯ç¹ã¨ãç²å¾ããã
+ */
+
+static ER
+get_tcp_cep (ID *cepid)
+{
+	ID		tskid;
+	T_TCP_CCEP	ccep;
+
+	get_tid(&tskid);
+
+	ccep.cepatr = UINT_C(0);
+	ccep.sbuf = NADR;
+	ccep.sbufsz = 0;
+	ccep.rbufsz = TCP_DISCARD_SRV_RWBUF_SIZE;
+	ccep.callback = NULL;
+
+#ifdef TCP_CFG_RWBUF_CSAVE
+	ccep.rbuf = NADR;
+#else
+	ccep.rbuf = tcp_discard_srv_rwbuf;
+#endif
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+	}
+
+/*
+ *  tcp_discard_srv_task -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+tcp_discard_srv_task (intptr_t exinf)
+{
+	ID	tskid, cepid, repid;
+	ER	error = E_OK;
+
+	syscall(get_tid(&tskid));
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d] started.", tskid);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d] started.", tskid);
+#endif
+#else
+	syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d] started.", tskid);
+#endif
+
+	while (true) {
+
+		syscall(slp_tsk());
+		if ((error = get_tcp_cep (&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TDSn:00 EXT] CEP create error: %s", itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			if ((error = get_tcp_rep (&repid)) != E_OK) {
+				syslog(LOG_NOTICE, "[TDSn:00 EXT] REP create error: %s", itron_strerror(error));
+				break;
+				}
+			else if ((error = tcp_discard_srv(cepid, repid)) != E_OK) {
+				error = FREE_TCP_REP(repid, error != E_DLT);
+				break;
+				}
+			}
+
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TDSn:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
+
+		}
+	}
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+void
+tcp_discard_srv_task(intptr_t exinf)
+{
+	ID	tskid;
+
+	get_tid(&tskid);
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+	syslog(LOG_NOTICE, "[TCPn DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#else
+	syslog(LOG_NOTICE, "[TCP6 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#endif
+#else
+	syslog(LOG_NOTICE, "[TCP4 DISCARD SRV:%d,%d] started.", tskid, (ID)exinf);
+#endif
+
+	while (true) {
+		while (tcp_discard_srv((ID)exinf, TCP_DISCARD_SRV_REPID) == E_OK)
+			;
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_DISCARD_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.cfg	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP DISCARD ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_DISCARD_SRV
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+CRE_TSK(TCP_DISCARD_SRV_TASK,  {
+	TA_HLNG | TA_ACT,
+	0,
+	tcp_discard_srv_task,
+	TCP_DISCARD_SRV_MAIN_PRIORITY,
+	TCP_DISCARD_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+CRE_TSK(TCP_DISCARD_SRV_TASK,  {
+	TA_HLNG | TA_ACT,
+	TCP_DISCARD_SRV_CEPID,
+	tcp_discard_srv_task,
+	TCP_DISCARD_SRV_MAIN_PRIORITY,
+	TCP_DISCARD_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_DISCARD_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_discard_srv.h	(revision 317)
@@ -0,0 +1,90 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_DISCARD_SRV_H_
+#define _TCP_DISCARD_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_DISCARD_SRV_STACK_SIZE	1024		/* TCP DISCARD ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+
+/* åªå
+åº¦ */
+
+#define TCP_DISCARD_SRV_MAIN_PRIORITY	5	/* TCP DISCARD ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦ */
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_DISCARD_SRV_RWBUF_SIZE	(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_discard_srv_swbuf[];
+extern uint8_t tcp_discard_srv_rwbuf[];
+
+/* ã¿ã¹ã¯ */
+
+extern void tcp_discard_srv_task(intptr_t exinf);
+
+#endif	/* of #ifndef _TCP_DISCARD_SRV_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.c	(revision 317)
@@ -0,0 +1,509 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ã
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åé¢å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4
+ *    ã»IPv6
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_cli.h>
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* echo ãµã¼ãã®ãã¼ãçªå· */
+
+#define ECHO_SRV_PORTNO		UINT_C(7)
+
+/* ç·æ¥ãã¼ã¿ã®éä¿¡ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+//#define SND_URG_DATA_SIZE	4
+#define SND_URG_COUNT		10
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/* éä¿¡éé */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+//#define SND_DLY		(500)
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define SND_DLY		(500)
+#define START_DLY	(10*SYSTIM_HZ)
+#define SND_ITV		(5*SYSTIM_HZ)
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/* èªåå®è¡ */
+
+#if defined(TCP_ECHO_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#if defined(SUPPORT_INET6)
+#define TCP_ECHO_CLI_AUTO_RUN_STR	"fd90:cce5:25f6:ff81:201:2ff:fe81:e7c9 - 0"
+#else
+#define TCP_ECHO_CLI_AUTO_RUN_STR	"172.25.129.140 - 0"
+#endif
+#endif
+#endif
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+#define API_PROTO		'n'
+#else
+#define API_PROTO		'6'
+#endif
+#else
+#define API_PROTO		'4'
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t	tcp_echo_cli_valid;
+uint_t	tcp_echo_cli_scount;
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_SWBUF_CSAVE
+uint8_t tcp_echo_cli_swbuf[TCP_ECHO_CLI_SWBUF_SIZE];
+#endif
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+uint8_t tcp_echo_cli_rwbuf[TCP_ECHO_CLI_RWBUF_SIZE];
+#endif
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+ER_UINT	tcp_echo_cli_nblk_error;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	ER	error = E_OK;
+
+	tcp_echo_cli_nblk_error = *(ER*)p_parblk;
+
+	switch (fncd) {
+
+	case TFN_TCP_CON_CEP:
+		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_BUF:
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		if (tcp_echo_cli_nblk_error < 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		syscall(sig_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+		break;
+
+	case TFN_TCP_SND_OOB:
+		if (tcp_echo_cli_nblk_error > 0)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] snd urg: %4u",
+			                   API_PROTO, cepid, tcp_echo_cli_nblk_error);
+		else
+			syslog(LOG_NOTICE, "[TEC%c:%02u CBN] error: %s",
+			                   API_PROTO, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		break;
+
+	case TFN_TCP_ACP_CEP:
+	case TFN_TCP_SND_DAT:
+	case TFN_TCP_GET_BUF:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
+
+static char *
+getcomd (ID cepid, bool_t retry, char *apip)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = TCP_ECHO_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || (count == 0)) {
+		line = auto_run_str;
+		dly_tsk(3 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
+
+static char *
+getcomd (ID cepid, bool_t retry, char *apip)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_SND, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (*line == '6') {
+		line ++;
+		*apip = API_PROTO_IPV6;
+		}
+	else if (*line == '4') {
+		line ++;
+		*apip = API_PROTO_IPV4;
+		}
+	else {
+		*apip= DEFAULT_API_PROTO;
+		if (*line && *line != ' ')
+			line ++;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	*apip= DEFAULT_API_PROTO;
+	if (*line && *line != ' ')
+		line ++;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	return line;
+	}
+
+#endif	/* of #ifdef TCP_ECHO_CLI_AUTO_RUN_STR */
+
+/*
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+/*
+ *  IP ã¢ãã¬ã¹ã®æå®
+ */
+
+#define ADDR_IPVn	'n'
+#define ADDR_IPV6	'6'
+#define ADDR_IPV4	'4'
+
+void
+tcp_echo_cli_snd_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	T_IN_ADDR	addr;
+	char		*line;
+	int_t		rep, count;
+	bool_t		retry = false;
+	uint16_t	portno;
+	char		apip;
+
+#ifdef USE_TCP_EXTENTIONS
+
+	T_TCP_CCEP	ccep;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef TCP_ECHO_CLI_AUTO_RUN_STR
+	dly_tsk(START_DLY);
+#endif
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI SND:%d,%d] started.", DEFAULT_API_PROTO, tskid, (ID)exinf);
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry, &apip));
+
+#if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+		if (apip == API_PROTO_IPV4) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) && !defined(SUPPORT_INET4) && !defined(API_CFG_IP4MAPPED_ADDR) */
+
+		if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       API_PROTO, (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+		else
+			retry = false;
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP4_ECHO_CLI)
+
+#else	/* of #if defined(USE_TCP4_ECHO_CLI) */
+
+		if (in6_is_addr_ipv4mapped(&addr))
+			apip = API_PROTO_IPV4;
+		else
+			apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(USE_TCP4_ECHO_CLI) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+		if (apip == API_PROTO_IPV6) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: E_PAR", API_PROTO, (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else {
+			line ++;
+			portno = ECHO_SRV_PORTNO;
+			}
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9')	/* Repeat */
+			line = get_int(&rep, line);
+		else {
+			line ++;
+			rep = 1;
+			}
+
+#ifdef USE_TCP_EXTENTIONS
+
+		ccep.cepatr = 0;
+		ccep.sbufsz = TCP_ECHO_CLI_SWBUF_SIZE;
+		ccep.rbufsz = TCP_ECHO_CLI_RWBUF_SIZE;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+		ccep.sbuf = NADR;
+#else
+		ccep.sbuf = tcp_echo_cli_swbuf;
+#endif
+#ifdef TCP_CFG_RWBUF_CSAVE
+		ccep.rbuf = NADR;
+#else
+		ccep.rbuf = tcp_echo_cli_rwbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_tcp_echo_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+		if (apip == API_PROTO_IPV6) {
+			if ((error = alloc_tcp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+				continue;
+				}
+			}
+		else {
+			if ((error = alloc_tcp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+				continue;
+				}
+			}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+		if ((error = ALLOC_TCP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+		if (apip == API_PROTO_IPV6)
+			cepid = (ID)exinf;
+		else
+			cepid = TCP4_ECHO_CLI_CEPID;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+		cepid = (ID)exinf;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		tcp_echo_cli_valid = true;
+		count = 0;
+		while (rep == 0 || count < rep) {
+			if (!tcp_echo_cli_valid) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] canceled.", apip, cepid);
+				break;
+				}
+
+			count ++;
+			if (rep == 0) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d", apip, cepid, count);
+				error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d", apip, cepid, count);
+				}
+			else {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] start:       repeat: %d/%d", apip, cepid, count, rep);
+				error = tcp_echo_cli_snd(cepid, &addr, portno, apip);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] finsh:       repeat: %d/%d", apip, cepid, count, rep);
+				}
+
+			if (error != E_OK) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] sleep %d.%03u[s], error: %s",
+				                   apip, cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ, itron_strerror(error));
+				tslp_tsk(SLP_ITV);
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] resume.", apip, cepid);
+				}
+
+#if defined(SND_ITV)
+#if SND_ITV > 0
+			if (count < rep) {
+				uint_t itv;
+				
+				itv = SND_ITV;
+				syslog(LOG_NOTICE, "[TEC%c:%02u TSK] interval: %d[s].", apip, cepid, itv / SYSTIM_HZ);
+				syscall(dly_tsk(SND_ITV));
+				}
+#endif
+#endif
+			}
+
+#ifdef USE_TCP_EXTENTIONS
+
+		if ((error = FREE_TCP_CEP(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TEC%c:%02u TSK] error: %s", apip, cepid, itron_strerror(error));
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.cfg	(revision 317)
@@ -0,0 +1,110 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+CRE_TSK(TCP_ECHO_CLI_SND_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	tcp_echo_cli_snd_task,
+	TCP_ECHO_CLI_SND_MAIN_PRIORITY,
+	TCP_ECHO_CLI_SND_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(TCP_ECHO_CLI_RCV_TASK,  {
+	TA_HLNG|TA_ACT,
+	0,
+	tcp_echo_cli_rcv_task,
+	TCP_ECHO_CLI_RCV_MAIN_PRIORITY,
+	TCP_ECHO_CLI_RCV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+CRE_TSK(TCP_ECHO_CLI_SND_TASK, {
+	TA_HLNG|TA_ACT,
+	TCP_ECHO_CLI_CEPID,
+	tcp_echo_cli_snd_task,
+	TCP_ECHO_CLI_SND_MAIN_PRIORITY,
+	TCP_ECHO_CLI_SND_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(TCP_ECHO_CLI_RCV_TASK,  {
+	TA_HLNG|TA_ACT,
+	TCP_ECHO_CLI_CEPID,
+	tcp_echo_cli_rcv_task,
+	TCP_ECHO_CLI_RCV_MAIN_PRIORITY,
+	TCP_ECHO_CLI_RCV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_TCP_ECHO_CLI_SND,  { TA_TFIFO, 1, NULL });
+CRE_DTQ(DTQ_TCP_ECHO_CLI_RCV,  { TA_TFIFO, 1, NULL });
+
+/* ã»ããã© */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+CRE_SEM(SEM_TCP_ECHO_CLI_NBLK_READY,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli.h	(revision 317)
@@ -0,0 +1,133 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TCP_ECHO_CLI_H_
+#define _TCP_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define TCP_ECHO_CLI_RCV_STACK_SIZE	512		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#define TCP_ECHO_CLI_SND_STACK_SIZE	512		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define TCP_ECHO_CLI_RCV_STACK_SIZE	1024		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#define TCP_ECHO_CLI_SND_STACK_SIZE	1024		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_CLI_RCV_MAIN_PRIORITY	5		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯ã®åªå
+åº¦		*/
+#define TCP_ECHO_CLI_SND_MAIN_PRIORITY	5		/* TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(1024)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(512)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_CLI_SWBUF_SIZE		(2048)
+#define TCP_ECHO_CLI_RWBUF_SIZE		(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  ãããã¡ãµã¤ãºã®å®ç¾©
+ */
+
+#define NUM_ECHO		20
+#define NUM_REP_PAT		20
+#define PAT_BEGIN		' '
+#define PAT_END			'~'
+#define SND_BUF_SIZE		((PAT_END - PAT_BEGIN + 1) * NUM_REP_PAT)
+#define RCV_BUF_SIZE		(SND_BUF_SIZE*15/10)
+
+/*
+ *  å¤æ°
+ */
+
+extern bool_t	tcp_echo_cli_valid;
+extern uint_t	tcp_echo_cli_scount;
+extern ER_UINT	tcp_echo_cli_nblk_error;
+
+/* TCP éåä¿¡ãããã¡ */
+
+extern uint8_t tcp_echo_cli_swbuf[];
+extern uint8_t tcp_echo_cli_rwbuf[];
+
+/* ã¿ã¹ã¯*/
+
+extern void	tcp_echo_cli_rcv_task(intptr_t exinf);
+extern void	tcp_echo_cli_snd_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_nblk_tcp_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#ifdef T_IN_ADDR
+extern ER tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip);
+#endif
+
+#endif	/* of #ifndef _TCP_ECHO_CLI_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_rcv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_rcv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_rcv.c	(revision 317)
@@ -0,0 +1,454 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_cli.h>
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* è¡¨ç¤º */
+
+//#define SHOW_TIME_OUT
+//#define SHOW_RCV_RANGE
+
+/* ã¿ã¤ã ã¢ã¦ã */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR					/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR				/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/*
+ *  API IPãã­ãã³ã«ã®æå®
+ */
+
+#undef  DEFAULT_API_PROTO
+
+#if defined(SUPPORT_INET6)
+#if defined(SUPPORT_INET4)
+#define DEFAULT_API_PROTO	API_PROTO_IPVn
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV6
+#endif
+#else
+#define DEFAULT_API_PROTO	API_PROTO_IPV4
+#endif
+
+/*
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãåä¿¡ã¿ã¹ã¯
+ */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total, rcount;
+	uint16_t	roff, rlen;
+	char		*rmsg, head, tail, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK,CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+#ifdef USE_TCP_EXTENTIONS
+
+			apip = API_PROTO_IPVn;
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+				if ((error = tcp_rcv_buf(cepid, (void**)&rmsg, TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
+					break;
+					}
+
+				/* åä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+				if (tcp_echo_cli_nblk_error < 0)
+					break;
+
+				rlen = tcp_echo_cli_nblk_error;
+				head = *rmsg;
+				tail = *(rmsg + rlen - 1);
+				if (rlen > 0) {
+					roff  += rlen;
+					total += rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
+					                   "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, rlen, roff, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+
+				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
+					syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s", 
+					                   apip, cepid, itron_strerror(error));
+				}
+
+			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			/* åæ­ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	static char rmsg[RCV_BUF_SIZE];
+
+	ID		tskid, cepid;
+	ER		error;
+	SYSTIM		time;
+	uint32_t	total, rcount;
+	uint16_t	roff, rlen;
+	char		head, tail, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (NBLK) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+				if ((error = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), TMO_NBLK)) != E_WBLK) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(error));
+					break;
+					}
+
+				/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+				syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+				if (tcp_echo_cli_nblk_error < 0)
+					break;
+
+				rlen = tcp_echo_cli_nblk_error;
+				head = *rmsg;
+				tail = *(rmsg + rlen - 1);
+				rcount ++;
+				if (rlen > 0) {
+					roff  += rlen;
+					total += rlen;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] "
+					                   "count: %7lu, len: %4u, off: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, rlen, roff, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				}
+
+			if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK && error != E_OK)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			/* åæ­ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef USE_COPYSAVE_API
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time, tmo;
+	uint32_t	total = 0, rcount;
+	uint16_t	roff;
+	char		*rmsg, apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI (CS) RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+#ifdef USE_TCP_EXTENTIONS
+
+			if (tcp6_is_cepid(cepid))
+				apip = API_PROTO_IPV6;
+			else
+				apip = API_PROTO_IPV4;
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			}
+		else {
+			roff = rcount = total = 0;
+			while (true) {
+				tmo = RCV_TMO;
+#ifdef SHOW_TIME_OUT
+				syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+				if ((rlen = tcp_rcv_buf(cepid, (void**)&rmsg, tmo)) < 0) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s",
+					                   apip, cepid, itron_strerror(rlen));
+					break;
+					}
+				else if (rlen > 0) {
+					roff  += (uint16_t)rlen;
+					total +=     rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				if ((error = tcp_rel_buf(cepid, rlen)) != E_OK)
+					syslog(LOG_NOTICE, "[TEC%c:%02u REL] error: %s", apip, cepid, itron_strerror(error));
+				}
+
+			tmo = CLS_TMO;
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			if ((error = tcp_cls_cep(cepid, tmo)) < 0)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+void
+tcp_echo_cli_rcv_task (intptr_t exinf)
+{
+	static char rmsg[RCV_BUF_SIZE];
+
+	ID		tskid, cepid;
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		time, tmo;
+	uint32_t	total, rcount;
+	uint16_t	roff;
+	char		apip = DEFAULT_API_PROTO;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP%c ECHO CLI RCV:%d] started.", DEFAULT_API_PROTO, tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s",
+			                   DEFAULT_API_PROTO, cepid, itron_strerror(error));
+			}
+                else {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+			if (cepid == TCP4_ECHO_CLI_CEPID)
+				apip = API_PROTO_IPV4;
+			else
+				apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+			roff = rcount = total = 0;
+			while (true) {
+#ifdef SHOW_TIME_OUT
+				syslog(LOG_NOTICE, "[TEC%c:%02u RCV] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+				tmo = RCV_TMO;
+				if ((rlen = tcp_rcv_dat(cepid, rmsg, sizeof(rmsg), tmo)) < 0) {
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] error: %s", apip, cepid, itron_strerror(rlen));
+					tcp_can_cep(cepid, TFN_TCP_ALL);
+					break;
+					}
+				else if (rlen > 0) {
+					roff  += (uint16_t)rlen;
+					total +=     rlen;
+					rcount ++;
+#ifdef SHOW_RCV_RANGE
+					syslog(LOG_NOTICE, "[TEC%c:%02u RCV] count: %7lu, len: %4u, data: %02x -> %02x",
+					                   apip, cepid, rcount, (uint16_t)rlen, *rmsg, *(rmsg + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+					}
+				else
+					break;
+				}
+
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u CLS] tmo:   %7lu", apip, cepid, tmo);;
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			tmo = CLS_TMO;
+			if ((error = tcp_cls_cep(cepid, tmo)) < 0)
+				syslog(LOG_NOTICE, "[TEC%c:%02u CLS] error: %s", apip, cepid, itron_strerror(error));
+
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[TEC%c:%02u RCV] finsh: %7lu, ttl: %lu",
+			                   apip, cepid, time / SYSTIM_HZ, total);
+			}
+
+		syscall(wup_tsk(TCP_ECHO_CLI_SND_TASK));
+		}
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_snd.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_snd.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_cli_snd.c	(revision 317)
@@ -0,0 +1,499 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡é¢æ°
+ */
+
+#include <stdlib.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_cli.h>
+
+#ifdef USE_TCP_ECHO_CLI
+
+/* è¡¨ç¤º */
+
+//#define SHOW_TIME_OUT
+//#define SHOW_SND_COUNT
+
+/* ã¿ã¤ã ã¢ã¦ã */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CON_TMO		TMO_FEVR
+//#define CON_TMO		(60*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#define CON_TMO		TMO_FEVR
+//#define CON_TMO		(60*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+static T_IPV4EP	nblk_src4 = {
+			IPV4_ADDRANY,
+			TCP_PORTANY,
+			};
+static T_IPV4EP	nblk_dst4;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+static T_IPEP	nblk_src = {
+			IP_ADDRANY,
+			TCP_PORTANY,
+			};
+static T_IPEP	nblk_dst;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+/*
+ *  tcp4_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+static ER
+tcp4_active_open (ID cepid, T_IN4_ADDR ipaddr, uint16_t portno)
+{
+	ER		error;
+	SYSTIM		time;
+
+	nblk_dst4.ipaddr = ipaddr;
+	nblk_dst4.portno = portno;
+
+	if ((error = tcp_con_cep(cepid, &nblk_src4, &nblk_dst4, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[TEC4:%02u CON] error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* æ¥ç¶ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+	if ((error = tcp_echo_cli_nblk_error) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC4:%02u CON] error: %s", cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC4:%02u CON] conct: %7lu,  to: %s.%u",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &nblk_dst4.ipaddr), nblk_dst4.portno);
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+/*
+ *  tcp_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+static ER
+tcp_active_open (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	ER		error;
+	SYSTIM		time;
+
+	nblk_dst.ipaddr = *ipaddr;
+	nblk_dst.portno = portno;
+
+	if ((error = TCP_CON_CEP(cepid, &nblk_src, &nblk_dst, TMO_NBLK)) != E_WBLK) {
+		if (error == E_PAR || error == E_ID)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, API: IPv%c, addr: %s",
+			                   apip, cepid, itron_strerror(error), apip, IP2STR(NULL, ipaddr));
+		else
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s",
+			                   apip, cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* æ¥ç¶ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_CLI_NBLK_READY));
+
+	if ((error = tcp_echo_cli_nblk_error) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s",
+		                   apip, cepid, itron_strerror(tcp_echo_cli_nblk_error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   apip, cepid, time / SYSTIM_HZ,
+	                   IP2STR(NULL, &nblk_dst.ipaddr), nblk_dst.portno);
+	return error;
+	}
+
+/*
+ *  tcp_echo_cli_snd -- ECHO/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+ER
+tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static char smsg[SND_BUF_SIZE];
+
+	ER_UINT		slen;
+	ER		error;
+	uint32_t	total;
+	uint16_t	soff, echo, rep;
+	char		*p, pat;
+
+#ifdef SND_URG_DATA_SIZE
+	int_t	urg = SND_URG_COUNT;
+#endif
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (apip == API_PROTO_IPV6) {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+	else if (in6_is_addr_ipv4mapped(ipaddr)) {
+		if ((error = tcp4_active_open(cepid, ntohl(ipaddr->s6_addr32[3]), portno)) != E_OK)
+			return error;
+		}
+	else {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+		return error;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s", apip, cepid, itron_strerror(error));
+		goto cls_ret;
+		}
+
+	tcp_echo_cli_scount = total = 0;
+	for (echo = NUM_ECHO; echo -- > 0; ) {
+		soff = 0;
+		while (soff < SND_BUF_SIZE) {
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);;
+#endif/* of #ifdef SHOW_TIME_OUT */
+			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u SND] error: %s",
+				                   apip, cepid, itron_strerror(slen));
+				error = slen;
+				goto cls_ret;
+				}
+			soff  += (uint16_t)slen;
+			total +=     slen;
+			tcp_echo_cli_scount ++;
+#ifdef SHOW_SND_COUNT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] count: %7lu, len: %4u, off: %4u",
+			                   apip, cepid, tcp_echo_cli_scount, (uint16_t)slen, soff);
+#endif/* of #ifdef SHOW_SND_COUNT */
+
+#ifdef SND_URG_DATA_SIZE
+			if (urg) {
+				if (urg == 1) {
+					if ((error = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, TMO_NBLK)) != E_WBLK)
+						syslog(LOG_NOTICE, "[TEC%c:%02u OOB] error: %s",
+						                   apip, cepid, itron_strerror(error));
+					}
+				urg --;
+				}
+#endif/* of #ifdef SND_URG_DATA_SIZE */
+
+#if defined(SND_DLY)
+#if SND_DLY > 0
+			syscall(dly_tsk(SND_DLY + netapp_rand() % SYSTIM_HZ));
+#endif
+#endif
+			}
+		}
+
+cls_ret:
+	if ((error = tcp_sht_cep(cepid)) < 0)
+		syslog(LOG_NOTICE, "[TEC%c:%02u SHT] error: %s", apip, cepid, itron_strerror(error));
+
+	/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(slp_tsk());
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+/*
+ *  tcp4_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp4_active_open (ID cepid, T_IN4_ADDR ipaddr, uint16_t portno)
+{
+	static T_IPV4EP src = {
+		IPV4_ADDRANY,
+		TCP_PORTANY,
+		};
+
+	T_IPV4EP	dst;
+	ER		error;
+	SYSTIM		time;
+
+	dst.ipaddr = ipaddr;
+	dst.portno = portno;
+
+#ifdef SHOW_TIME_OUT
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] tmo:   %7lu", API_PROTO_IPV4, cepid, CON_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+	if ((error = tcp_con_cep(cepid, &src, &dst, CON_TMO)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, addr: %s",
+		                   API_PROTO_IPV4, cepid, itron_strerror(error), ip2str(NULL, &ipaddr));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   API_PROTO_IPV4, cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno);
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+/*
+ *  tcp_active_open -- è½åãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp_active_open (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static T_IPEP src = {
+		IP_ADDRANY,
+		TCP_PORTANY,
+		};
+
+	T_IPEP		dst;
+	ER		error;
+	SYSTIM		time;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+
+#ifdef SHOW_TIME_OUT
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] tmo:   %7lu", apip, cepid, CON_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+	if ((error = TCP_CON_CEP(cepid, &src, &dst, CON_TMO)) != E_OK) {
+		if (error == E_PAR || error == E_ID)
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s, API: IPv%c, addr: %s",
+			                   apip, cepid, itron_strerror(error), apip, IP2STR(NULL, ipaddr));
+		else
+			syslog(LOG_NOTICE, "[TEC%c:%02u CON] error: %s", apip, cepid, itron_strerror(error));
+		return error;
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[TEC%c:%02u CON] conct: %7lu,  to: %s.%u",
+	                   apip, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	return error;
+	}
+
+/*
+ *  tcp_echo_cli_snd -- ECHO/TCP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+ER
+tcp_echo_cli_snd (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno, char apip)
+{
+	static char smsg[SND_BUF_SIZE];
+
+	ER_UINT		slen;
+	ER		error;
+	uint32_t	total;
+	uint16_t	soff, echo, rep;
+	char		*p, pat;
+
+#ifdef SND_URG_DATA_SIZE
+	int_t	urg = SND_URG_COUNT;
+#endif
+
+	p = smsg;
+	for (rep = NUM_REP_PAT; rep -- > 0; )
+		for (pat = PAT_BEGIN; pat <= PAT_END; pat ++)
+			*p ++ = pat;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI)
+
+	if (apip == API_PROTO_IPV6) {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+	else if (in6_is_addr_ipv4mapped(ipaddr)) {
+		if ((error = tcp4_active_open(cepid, ntohl(ipaddr->s6_addr32[3]), portno)) != E_OK)
+			return error;
+		}
+	else {
+		if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+			return error;
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = tcp_active_open(cepid, ipaddr, portno, apip)) != E_OK)
+		return error;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_CLI) */
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_CLI_RCV, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TEC%c:%02u DTQ] error: %s", apip, cepid, itron_strerror(error));
+		goto cls_ret;
+		}
+
+	tcp_echo_cli_scount = total = 0;
+	for (echo = NUM_ECHO; echo -- > 0; ) {
+		soff = 0;
+		while (soff < SND_BUF_SIZE) {
+#ifdef SHOW_TIME_OUT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+			if ((slen = tcp_snd_dat(cepid, smsg + soff, sizeof(smsg) - soff, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TEC%c:%02u SND] error: %s", apip, cepid, itron_strerror(slen));
+				error = slen;
+				goto cls_ret;
+				}
+			soff  += (uint16_t)slen;
+			total +=     slen;
+			tcp_echo_cli_scount ++;
+#ifdef SHOW_SND_COUNT
+			syslog(LOG_NOTICE, "[TEC%c:%02u SND] count: %7lu, len: %4u",
+			                   apip, cepid, tcp_echo_cli_scount, (uint16_t)slen);
+#endif	/* of #ifdef SHOW_SND_COUNT */
+
+#ifdef SND_URG_DATA_SIZE
+			if (urg > 0) {
+				if (urg == 1) {
+#ifdef SHOW_TIME_OUT
+					syslog(LOG_NOTICE, "[TEC%c:%02u SND] tmo:   %7lu", apip, cepid, SND_TMO);
+#endif	/* of #ifdef SHOW_TIME_OUT */
+					if ((slen = tcp_snd_oob(cepid, smsg, SND_URG_DATA_SIZE, SND_TMO)) >= 0)
+						syslog(LOG_NOTICE, "[TEC%c:%02u SND] urg:   %7lu",
+						                   apip, cepid, (uint16_6)slen);
+					else
+						syslog(LOG_NOTICE, "[TEC%c:%02u OOB] error: %s",
+						                   apip, cepid, itron_strerror(slen));
+					}
+				urg --;
+				}
+#endif	/* of #ifdef SND_URG_DATA_SIZE */
+
+#if defined(SND_DLY)
+#if SND_DLY > 0
+			syscall(dly_tsk(SND_DLY + netapp_rand() % SYSTIM_HZ));
+#endif
+#endif
+			}
+		}
+
+cls_ret:
+	if ((error = tcp_sht_cep(cepid)) < 0)
+		syslog(LOG_NOTICE, "[TEC%c:%02u SHT] error: %s", apip, cepid, itron_strerror(error));
+
+	/* åä¿¡ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(slp_tsk());
+
+	return error;
+	}
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.c	(revision 317)
@@ -0,0 +1,571 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#if defined(_NET_CFG_BYTE_ORDER)
+#error "net/net.h included."
+#endif
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+#define USE_TCP_SHT_CEP
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR	/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_SWBUF_CSAVE
+uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+#endif
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+#endif
+
+#ifndef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[NUM_TCP_ECHO_SRV_TASKS];
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	{ TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	{ TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+
+#if TNUM_TCP4_REPID > 0
+	T_IPV4EP	dst4;
+#endif
+
+	if (apip == API_PROTO_IPV6) {
+
+#if TNUM_TCP6_REPID > 0
+
+		/* åä»å£ã¯ IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+			return error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+
+		}
+	else {
+
+#if TNUM_TCP4_REPID > 0
+
+		/* åä»å£ã¯ IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
+			return error;
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+
+		}
+
+	return error;
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+		return error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+#ifdef USE_COPYSAVE_API
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ *    USE_COPYSAVE_API		ON
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+	ER		error = E_OK;
+	ER_UINT		rblen, sblen;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, scount, rcount;
+	char		*rbuf, *sbuf;
+
+#ifdef SHOW_RCV_RANGE
+	char		head, tail;
+#endif
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+		return error;
+		}
+
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else {
+		T_IN4_ADDR	addr;
+
+		addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	scount = rcount = total = 0;
+	while (true) {
+		if ((rblen = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, RCV_TMO)) <= 0) {
+			if (rblen != E_OK)
+				syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(rblen));
+			break;
+			}
+
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
+		head = *rbuf;
+		tail = *(rbuf + rblen - 1);
+
+		//syslog(LOG_NOTICE, "[TES%c:%02u RCV] len:   %7lu",
+		//                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)rblen);
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %7lu, len: %6lu, data %02x -> %02x",
+		                   apip, tcp_echo_srv_info[six].cepid, rcount, (uint16_t)rblen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		rlen   = (uint16_t)rblen;
+		total +=     rblen;
+		soff = 0;
+		while (rlen > 0) {
+
+			if ((sblen = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(sblen));
+				goto err_fin;
+				}
+
+			//syslog(LOG_NOTICE, "[TES%c:%02u SND] len:   %7lu",
+			//                   apip, tcp_echo_srv_info[six].cepid, (uint16_t)sblen);
+			scount ++;
+			slen = rlen < (uint16_t)sblen ? rlen : (uint16_t)sblen;
+			memcpy(sbuf, rbuf + soff, slen);
+			if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+				                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+			                   apip, tcp_echo_srv_info[six].cepid, scount, slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+
+		if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rblen)) < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s",
+			                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, CLS_TMO)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+
+	syscall(get_tim(&now));
+#if 1
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+#else
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu, error: %s",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total, itron_strerror(error));
+#endif
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ *    USE_COPYSAVE_API		OFF
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+	ID		cepid;
+	ER		error = E_OK;
+	ER_UINT		rlen, slen;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	soff, scount, rcount;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES%c:%02u OPN] error: %s",
+		                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+		return error;
+		}
+	
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else	{
+		T_IN4_ADDR	addr;
+
+		addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &addr), tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	cepid =  tcp_echo_srv_info[six].cepid;
+	scount = rcount = total = 0;
+	while (true) {
+		if ((rlen = tcp_rcv_dat(cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, RCV_TMO)) <= 0) {
+			if (rlen != E_OK)
+				syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+				                   apip, cepid, itron_strerror(rlen));
+			break;
+			}
+
+		rcount ++;
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x",
+		                   apip, cepid, rcount,
+		                   (uint16_t)rlen, * tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer,
+		                                   *(tcp_echo_srv_info[six].tcp_echo_srv_info[six].buffer + rlen - 1));
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		total += rlen;
+		soff = 0;
+		while (rlen > 0) {
+			scount ++;
+			if ((slen = tcp_snd_dat(cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, SND_TMO)) < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+				                   apip, cepid, itron_strerror(slen));
+				goto err_fin;
+				}
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+			                   apip, cepid, scount, (uint16_t)slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s", 
+		                    apip, cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(cepid, CLS_TMO)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+		                   apip, cepid, itron_strerror(error));
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, cepid, now / SYSTIM_HZ, total);
+
+	return error;
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifndef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_TCP_EXTENTIONS
+
+/*
+ *  tcp_echo_srv_task -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+tcp_echo_srv_task(intptr_t exinf)
+{
+	ID	tskid, cepid;
+	ER	error;
+	uint_t	six;
+	char	apip;
+
+	six = INDEX_SRV_INFO((ID)exinf);
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	if (six >= NUM_TCP4_ECHO_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	apip = API_PROTO_IPV6;
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+	apip = API_PROTO_IPV4;
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	syscall(get_tid(&tskid));
+	cepid = tcp_echo_srv_info[six].cepid;
+	syslog(LOG_NOTICE, "[TCP%c ECHO SRV:%d,%d] started.", apip, tskid, cepid);
+
+	while (true) {
+		while ((error = tcp_echo_srv(six, apip)) == E_OK)
+			;
+		syslog(LOG_NOTICE, "[TES%c:%02u TSK] sleep 60[s], error: %s", apip, cepid, itron_strerror(error));
+		tslp_tsk(60 * 1000 * 1000);
+		syslog(LOG_NOTICE, "[TES%c:%02u TSK] resume.", apip, cepid);
+		}
+	}
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.cfg	(revision 317)
@@ -0,0 +1,185 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ã #1ãéåä¿¡ã¿ã¹ã¯åä¸å
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(TCP_ECHO_SRV_TASK1,  {
+	TA_HLNG | TA_ACT,
+	1,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+CRE_TSK(TCP_ECHO_SRV_TASK2,  {
+	TA_HLNG | TA_ACT,
+	2,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+CRE_TSK(TCP_ECHO_SRV_TASK3,  {
+	TA_HLNG | TA_ACT,
+	3,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+CRE_TSK(TCP_ECHO_SRV_TASK4,  {
+	TA_HLNG | TA_ACT,
+	4,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+CRE_TSK(TCP_ECHO_SRV_TASK5,  {
+	TA_HLNG | TA_ACT,
+	5,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+CRE_TSK(TCP_ECHO_SRV_TASK6,  {
+	TA_HLNG | TA_ACT,
+	6,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+CRE_TSK(TCP_ECHO_SRV_TASK7,  {
+	TA_HLNG | TA_ACT,
+	7,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+CRE_TSK(TCP_ECHO_SRV_TASK8,  {
+	TA_HLNG | TA_ACT,
+	8,
+	tcp_echo_srv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+/* ã»ããã© */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY1,	{ TA_TPRI, 0, 1 });
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY2,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY3,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY4,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY5,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY6,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY7,	{ TA_TPRI, 0, 1 });
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+CRE_SEM(SEM_TCP_ECHO_SRV_NBLK_READY8,	{ TA_TPRI, 0, 1 });
+#endif
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1.h	(revision 317)
@@ -0,0 +1,135 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV1
+
+#ifndef _TCP_ECHO_SRV1_H_
+#define _TCP_ECHO_SRV1_H_
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(512)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/*
+ *  ã¿ã¹ã¯æ°
+ */
+
+#ifndef NUM_TCP_ECHO_SRV_TASKS
+#define NUM_TCP_ECHO_SRV_TASKS		1
+#endif
+
+/* IPv4 ç¨ã® TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯ã¯ 1åã«å¶éããã*/
+
+#ifdef  NUM_TCP4_ECHO_SRV_TASKS
+#undef  NUM_TCP4_ECHO_SRV_TASKS
+#endif
+#define NUM_TCP4_ECHO_SRV_TASKS		1
+
+/*
+ *  å¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+extern uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+extern uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	tcp_echo_srv_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER wakeup_tcp_echo_srv (char apip);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV1_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_ext.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_ext.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_ext.c	(revision 317)
@@ -0,0 +1,381 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+#define USE_TCP_SHT_CEP
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR	/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  å¤æ°
+ */
+
+typedef struct t_tcp_echo_srv_task_info {
+	ID	taskid;		/* ã¿ã¹ã¯ ID		*/
+	bool_t	active;		/* åä½ç¶æ
+		*/
+	char	apip;		/* API IPãã­ãã³ã«	*/
+	} T_TCP_ECHO_SRV_TASK_INFO;
+
+static T_TCP_ECHO_SRV_TASK_INFO tcp_echo_srv_task_info[NUM_TCP_ECHO_SRV_TASKS] = {
+
+				{ TCP_ECHO_SRV_TASK1, false },
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+				{ TCP_ECHO_SRV_TASK2, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+				{ TCP_ECHO_SRV_TASK3, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+				{ TCP_ECHO_SRV_TASK4, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+				{ TCP_ECHO_SRV_TASK5, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+				{ TCP_ECHO_SRV_TASK6, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+				{ TCP_ECHO_SRV_TASK7, false },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+				{ TCP_ECHO_SRV_TASK8, false },
+#endif
+
+			};
+
+/*
+ *  get_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+get_tcp_rep (ID *repid, char apip)
+{
+	ID		tskid;
+	T_TCP6_CREP	crep6;
+	T_TCP_CREP	crep4;
+
+	get_tid(&tskid);
+	if (apip == API_PROTO_IPV6) {
+		crep6.repatr = UINT_C(0);
+		crep6.myaddr.portno = UINT_C(7);
+		memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+		return alloc_tcp6_rep(repid, tskid, &crep6);
+		}
+	else {
+		crep4.repatr = UINT_C(0);
+		crep4.myaddr.portno = UINT_C(7);
+		crep4.myaddr.ipaddr = IPV4_ADDRANY;
+		return alloc_tcp4_rep(repid, tskid, &crep4);
+		}
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+get_tcp_rep (ID *repid, char apip)
+{
+	ID		tskid;
+	T_TCPN_CREP	crep;
+
+	get_tid(&tskid);
+
+	crep.repatr = UINT_C(0);
+	crep.myaddr.portno = UINT_C(7);
+
+#if defined(SUPPORT_INET6)
+
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+	crep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  get_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+static ER
+get_tcp_cep (ID *cepid, char apip)
+{
+	ID		tskid;
+	T_TCP_CCEP	ccep;
+
+	get_tid(&tskid);
+
+	ccep.cepatr = UINT_C(0);
+	ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE;
+	ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	ccep.sbuf = NADR;
+#else
+	ccep.sbuf = tcp_echo_srv_swbuf;
+#endif
+#ifdef TCP_CFG_RWBUF_CSAVE
+	ccep.rbuf = NADR;
+#else
+	ccep.rbuf = tcp_echo_srv_rwbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+	ccep.callback = (FP)callback_nblk_tcp_echo_srv;
+#else
+	ccep.callback = NULL;
+#endif
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		return alloc_tcp6_cep(cepid, tskid, &ccep);
+	else
+		return alloc_tcp4_cep(cepid, tskid, &ccep);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	}
+
+/*
+ *  wakeup_tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯ã®ä¼æ­¢è§£é¤
+ */
+
+ER
+wakeup_tcp_echo_srv (char apip)
+{
+	int	ix;
+
+	for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; )
+		if (!tcp_echo_srv_task_info[ix].active) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] wake up.",
+			                   apip, tcp_echo_srv_task_info[ix].taskid);
+			tcp_echo_srv_task_info[ix].apip   = apip;
+			tcp_echo_srv_task_info[ix].active = true;
+			return syscall(wup_tsk(tcp_echo_srv_task_info[ix].taskid));
+			}
+	syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] wake up error: %s.",
+			   apip, tcp_echo_srv_task_info[ix].taskid, itron_strerror(E_ID));
+	return E_ID;
+	}
+
+/*
+ *  tcp_echo_srv_task -- TCP ã¨ã³ã¼ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+tcp_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+	int	ix;
+	char	apip;
+
+	syscall(get_tid(&tskid));
+	syslog(LOG_NOTICE, "[TCPn ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+		syslog(LOG_NOTICE, "[TCPn ECHO SRV(EXT):%d] goto sleep.", tskid);
+		syscall(slp_tsk());
+
+		for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; ) {
+			if (tcp_echo_srv_task_info[ix].taskid == tskid) {
+				break;
+				}
+			}
+
+		apip = tcp_echo_srv_task_info[ix].apip;
+		if ((error = get_tcp_cep(&tcp_echo_srv_info[ix].cepid, apip)) != E_OK) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] create CEP error: %s",
+		                           apip, tskid, itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			if ((error = get_tcp_rep(&tcp_echo_srv_info[ix].repid, apip)) != E_OK) {
+				syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] create REP error: %s",
+		                                   apip, tskid, itron_strerror(error));
+				break;
+				}
+			else if ((error = tcp_echo_srv(ix, apip)) != E_OK) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (apip == API_PROTO_IPV6)
+					error = free_tcp6_rep(tcp_echo_srv_info[ix].repid, error != E_DLT);
+				else
+					error = free_tcp4_rep(tcp_echo_srv_info[ix].repid, error != E_DLT);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				error = FREE_TCP_REP(tcp_echo_srv_info[ix].repid, error != E_DLT);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (error != E_OK) {
+					syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] delete REP error: %s",
+		                                           apip, tskid, itron_strerror(error));
+					}
+
+				break;
+				}
+			}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		if (apip == API_PROTO_IPV6)
+			error = free_tcp6_cep(tcp_echo_srv_info[ix].cepid);
+		else
+			error = free_tcp4_cep(tcp_echo_srv_info[ix].cepid);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		error = FREE_TCP_CEP(tcp_echo_srv_info[ix].cepid);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if (error != E_OK) {
+			syslog(LOG_NOTICE, "[TCP%c ECHO SRV(EXT):%d] delete CEP error: %s",
+		                           apip, tskid, itron_strerror(error));
+			}
+
+		for (ix = NUM_TCP_ECHO_SRV_TASKS; -- ix >= 0; ) {
+			if (tcp_echo_srv_task_info[ix].taskid == tskid) {
+				tcp_echo_srv_task_info[ix].active = false;
+				break;
+				}
+			}
+
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_nblk.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_nblk.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_nblk.c	(revision 317)
@@ -0,0 +1,656 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #1
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ *    ã»ç·æ¥ãã¼ã¿ã®åä¿¡
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv1.h>
+#include <netapp/tcp_echo_srv1_var.h>
+
+#ifdef USE_TCP_ECHO_SRV1
+
+/*
+ *  è¡¨ç¤º
+ */
+
+//#define SHOW_RCV_RANGE
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+#define USE_TCP_SHT_CEP
+
+/*
+ *  ã¿ã¤ã ã¢ã¦ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+
+#define CLS_TMO		TMO_FEVR		/* Close Wait ã¯æ¨æºã§ 60ç§ */
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(30*SYSTIM_HZ)
+
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+//#define CLS_TMO		TMO_FEVR	/* Close Wait ã¯æ¨æºã§ 60ç§ */
+#define CLS_TMO		(70*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*10)
+//#define RCV_TMO		TMO_FEVR
+#define RCV_TMO		(30*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*30)
+//#define SND_TMO		TMO_FEVR
+#define SND_TMO		(40*SYSTIM_HZ+(netapp_rand()%SYSTIM_HZ)*20)
+
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+
+#ifdef USE_TCP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY2 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY3 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY4 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY5 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY6 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY7 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ 0, 0, SEM_TCP_ECHO_SRV_NBLK_READY8 },
+#endif
+
+	};
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+	{ TCP4_ECHO_SRV_CEPID1, TCP4_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+	{ TCP_ECHO_SRV_CEPID1, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY1 },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+	{ TCP_ECHO_SRV_CEPID2, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY2 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+	{ TCP_ECHO_SRV_CEPID3, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY3 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+	{ TCP_ECHO_SRV_CEPID4, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY4 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+	{ TCP_ECHO_SRV_CEPID5, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY5 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+	{ TCP_ECHO_SRV_CEPID6, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY6 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+	{ TCP_ECHO_SRV_CEPID7, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY7 },
+#endif
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+	{ TCP_ECHO_SRV_CEPID8, TCP_ECHO_SRV_REPID, SEM_TCP_ECHO_SRV_NBLK_READY8 },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  find_srv_info -- æ¥ç¶ç¸æã®æ
+å ±æ§é ä½ãæ¢ç´¢ããã
+ */
+
+static 
+T_TCP_ECHO_SRV_INFO *find_srv_info (ID cepid)
+{
+	T_TCP_ECHO_SRV_INFO	*ri;
+
+	for (ri = &tcp_echo_srv_info[sizeof(tcp_echo_srv_info) / sizeof(T_TCP_ECHO_SRV_INFO)]; ri --; )
+		if (ri->cepid == cepid)
+			return ri;
+	return NULL;
+	}
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER		error = E_OK;
+	T_TCP_ECHO_SRV_INFO	*ri;
+
+	if ((ri = find_srv_info(cepid)) == NULL) {
+		syslog(LOG_NOTICE, "[TESn:%02u CBN] CEPID not found", cepid);
+		return E_PAR;
+		}
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		ri->error = *(ER*)p_parblk;
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->rlen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_SND_DAT:
+		if ((ri->slen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->slen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		if ((ri->error = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->error));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_RCV_BUF:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->rlen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+	case TFN_TCP_GET_BUF:
+		if ((ri->slen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u CBN] error: %s", cepid, itron_strerror(ri->slen));
+		syscall(sig_sem(ri->semid));
+		break;
+
+#ifdef USE_TCP_EXTENTIONS
+
+	case TEV_TCP_RCV_OOB:
+		if ((ri->rlen = *(ER*)p_parblk) < 0)
+			syslog(LOG_NOTICE, "[TESn:%02u OOB] error: %s", cepid, itron_strerror(ri->rlen));
+		else if (ri->rlen > 0) {
+			char ch;
+
+			if ((ri->rlen = tcp_rcv_oob(cepid, &ch, sizeof(ch))) > 0)
+				syslog(LOG_NOTICE, "[TESn:%02u OOB] recv oob: 0x%02x", cepid, ch);
+			else if (ri->rlen < 0)
+				syslog(LOG_NOTICE, "[TESn:%02u OOB] error: %s", cepid, itron_strerror(ri->rlen));
+			}
+		break;
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		break;
+		}
+	return error;
+	}
+
+/*
+ *  tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error;
+	T_IPV4EP	dst4;
+
+	if (apip == API_PROTO_IPV6) {
+		/* åä»å£ã¯ IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_NBLK)) != E_WBLK)
+			return error;
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(info->semid));
+
+		if (info->error != E_OK)
+			return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	else {
+		/* åä»å£ã¯ IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_NBLK)) != E_WBLK)
+			return error;
+
+		/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(info->semid));
+
+		if (info->error != E_OK)
+			return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+		}
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+tcp_passive_open (T_TCP_ECHO_SRV_INFO *info, char apip)
+{
+	ER		error;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_NBLK)) != E_WBLK)
+		return error;
+
+	/* ç¸æããæ¥ç¶ãããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(info->semid));
+
+	if (info->error != E_OK)
+		return info->error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return E_OK;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#ifdef USE_COPYSAVE_API
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ *    USE_COPYSAVE_API		ON
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	T_IN4_ADDR	ipv4addr;
+#endif
+	ER		error;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	rblen, sblen, rlen, slen, soff, scount, rcount;
+	char		*rbuf, *sbuf, head, tail;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else {
+		ipv4addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &ipv4addr),
+		                   tcp_echo_srv_info[six].dst.portno);
+		}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	syslog(LOG_NOTICE, "[TES%c:%02u ACP] conct: %7lu,from: %s.%u",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+	                   tcp_echo_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	rlen = scount = rcount = total = 0;
+	while (true) {
+		if ((error = tcp_rcv_buf(tcp_echo_srv_info[six].cepid, (void**)&rbuf, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		/* åä¿¡ããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+		if (tcp_echo_srv_info[six].rlen < 0) {	/* ã¨ã©ã¼ */
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s", 
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].rlen));
+			break;
+			}
+		else if (tcp_echo_srv_info[six].rlen == 0)	/* åä¿¡çµäº */
+			break;
+
+		rblen = tcp_echo_srv_info[six].rlen;
+
+		/* ãããã¡ã®æ®ãã«ãããåä¿¡é·ãèª¿æ´ããã*/
+		if (rblen > BUF_SIZE - rlen)
+			rblen = BUF_SIZE - rlen;
+		total += rblen;
+		rlen   = rblen;
+
+		head = *rbuf;
+		tail = *(rbuf + rblen - 1);
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] "
+		                   "rcount: %7lu, len: %6lu, data %02x -> %02x",
+	                           apip, tcp_echo_srv_info[six].cepid, rcount, rblen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		memcpy(tcp_echo_srv_info[six].buffer, rbuf, rblen);
+
+		if ((error = tcp_rel_buf(tcp_echo_srv_info[six].cepid, rlen)) < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u REL] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		soff = 0;
+		while (rlen > 0) {
+
+			if ((error = tcp_get_buf(tcp_echo_srv_info[six].cepid, (void**)&sbuf, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+
+			/* éä¿¡ãããã¡ã®ç²å¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+			if (tcp_echo_srv_info[six].slen < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u GET] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].slen));
+				goto err_fin;
+				}
+
+			sblen = tcp_echo_srv_info[six].slen;
+			scount ++;
+			slen = sblen < rlen ? sblen : rlen;
+			memcpy(sbuf, tcp_echo_srv_info[six].buffer + soff, slen);
+
+			if ((error = tcp_snd_buf(tcp_echo_srv_info[six].cepid, slen)) != E_OK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %7lu, len: %4u",
+	                                   apip, cepid, scount, slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, TMO_NBLK)) != E_WBLK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+
+	/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+
+	return error == E_WBLK ? E_OK : error;
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+/*
+ *  tcp_echo_srv -- TCP ã¨ã³ã¼ãµã¼ã
+ *
+ *    USE_TCP_NON_BLOCKING	ON
+ *    USE_COPYSAVE_API		OFF
+ */
+
+ER
+tcp_echo_srv (uint_t six, char apip)
+{
+	T_IN4_ADDR	ipv4addr;
+	ER		error;
+	SYSTIM		now;
+	uint32_t	total;
+	uint16_t	rlen, slen, soff, scount, rcount;
+	char		head, tail;
+
+	if ((error = tcp_passive_open(&tcp_echo_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[TES6:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &tcp_echo_srv_info[six].dst.ipaddr),
+		                   tcp_echo_srv_info[six].dst.portno);
+	else {
+		ipv4addr = ntohl(tcp_echo_srv_info[six].dst.ipaddr.s6_addr32[3]);
+		syslog(LOG_NOTICE, "[TES4:%02u ACP] conct: %7lu,from: %s.%u",
+		                   tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &ipv4addr),
+		                   tcp_echo_srv_info[six].dst.portno);
+		}
+
+	scount = rcount = total = 0;
+	while (true) {
+		if ((error = tcp_rcv_dat(tcp_echo_srv_info[six].cepid, tcp_echo_srv_info[six].buffer, BUF_SIZE - 1, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+			break;
+			}
+
+		/* åä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+		if (tcp_echo_srv_info[six].rlen < 0) {
+			syslog(LOG_NOTICE, "[TES%c:%02u RCV] error: %s",
+	                                   apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].rlen));
+			break;
+			}
+		else if (tcp_echo_srv_info[six].rlen == 0)
+			break;
+
+		rlen = tcp_echo_srv_info[six].rlen;
+		head = * tcp_echo_srv_info[six].buffer;
+		tail = *(tcp_echo_srv_info[six].buffer + rlen - 1);
+		rcount ++;
+
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES%c:%02u RCV] rcount: %4u, len: %4u, data %02x -> %02x",
+	                           apip, tcp_echo_srv_info[six].cepid, rcount, rlen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+		total += rlen;
+		soff = 0;
+		while (rlen > 0) {
+			scount ++;
+			if ((error = tcp_snd_dat(tcp_echo_srv_info[six].cepid, &tcp_echo_srv_info[six].buffer[soff], rlen, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+				goto err_fin;
+				}
+
+			/* éä¿¡å®äºã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+			if (tcp_echo_srv_info[six].slen < 0) {
+				syslog(LOG_NOTICE, "[TES%c:%02u SND] error: %s",
+	                                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(tcp_echo_srv_info[six].slen));
+				goto err_fin;
+				}
+
+			slen = tcp_echo_srv_info[six].slen;
+
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES%c:%02u SND] scount: %4u, len: %4u",
+	                                   apip, tcp_echo_srv_info[six].cepid, scount, slen);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+
+			rlen -= slen;
+			soff += slen;
+			}
+		}
+err_fin:
+
+#ifdef USE_TCP_SHT_CEP
+	if ((error = tcp_sht_cep(tcp_echo_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_NOTICE, "[TES%c:%02u SHT] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+	if ((error = tcp_cls_cep(tcp_echo_srv_info[six].cepid, TMO_NBLK)) != E_WBLK)
+		syslog(LOG_NOTICE, "[TES%c:%02u CLS] error: %s",
+	                           apip, tcp_echo_srv_info[six].cepid, itron_strerror(error));
+
+	/* éæ¾ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(tcp_echo_srv_info[six].semid));
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES%c:%02u FIN] finsh: %7lu, ttl: %lu",
+	                   apip, tcp_echo_srv_info[six].cepid, now / SYSTIM_HZ, total);
+
+	return error == E_WBLK ? E_OK : error;
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv1_var.h	(revision 317)
@@ -0,0 +1,111 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV1
+
+#ifndef _TCP_ECHO_SRV1_VAR_H_
+#define _TCP_ECHO_SRV1_VAR_H_
+
+/*
+ *  æ³¨æ:
+ *
+ *    BUF_SIZE ã¯ TCP ã®
+ *    éä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãº + åä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãºã® 
+ *    3/2 åä»¥ä¸ã®å¤§ããããªããã°ããããã­ãã¯ããå¯è½æ§ãããã
+ */
+
+#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
+                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
+
+/*
+ *  ãµã¼ãæ
+å ±æ§é ä½
+ */
+
+typedef struct t_tcp_echo_srv_info {
+	ID	cepid;		/* éä¿¡ç«¯ç¹ ID		*/
+	ID	repid;		/* åä»å£   ID		*/
+
+#ifdef USE_TCP_NON_BLOCKING
+	ID	semid;		/* NBLK ç¨ ã»ããã©ID	*/
+	ER	error;		/* NBLK ç¨ error	*/
+	ER_UINT	slen;		/* NBLK ç¨ éä¿¡ãã¼ã¿æ°	*/
+	ER_UINT	rlen;		/* NBLK ç¨ åä¿¡ãã¼ã¿æ°	*/
+#endif
+
+	T_IPEP	dst;		/* æ¥ç¶ç¸æã¢ãã¬ã¹æ
+å ±	*/
+
+#ifdef USE_TCP_NON_BLOCKING
+
+	char	buffer[BUF_SIZE];
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifndef USE_COPYSAVE_API
+	char	buffer[BUF_SIZE];
+#endif
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+	} T_TCP_ECHO_SRV_INFO;
+
+#define INDEX_SRV_INFO(id)	((id)-1)
+
+/*
+ *  å¤æ°
+ */
+
+extern T_TCP_ECHO_SRV_INFO tcp_echo_srv_info[];
+
+/*
+ *  é¢æ°
+ */
+
+extern ER tcp_echo_srv (uint_t six, char apip);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV1_VAR_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV1 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.c	(revision 317)
@@ -0,0 +1,787 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  TCP ECHO ãµã¼ã #2
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åé¢å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»IPv4/IPv6
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/tcp_echo_srv2.h>
+
+#ifdef USE_TCP_ECHO_SRV2
+
+/*
+ *  è¡¨ç¤º
+ */
+
+/*#define SHOW_RCV_RANGE*/
+
+/*
+ *  ã³ãã¯ã·ã§ã³åæ­æ¹æ³ã®æå®
+ */
+
+/*#define USE_TCP_SHT_CEP*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_SWBUF_CSAVE
+uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+#endif
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+#endif
+
+/*
+ *  å¤æ°
+ */
+
+/*
+ *  æ³¨æ:
+ *
+ *    BUF_SIZE ã¯ TCP ã®
+ *    éä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãº + åä¿¡ã¦ã¤ã³ãã¦ãããã¡ãµã¤ãºã® 
+ *    3/2 åä»¥ä¸ã®å¤§ããããªããã°ããããã­ãã¯ããå¯è½æ§ãããã
+ */
+
+#define BUF_SIZE	((TCP_ECHO_SRV_SWBUF_SIZE + \
+                          TCP_ECHO_SRV_RWBUF_SIZE) * 3 / 2)
+
+static char	buffer[BUF_SIZE];	/* ãããã¡		*/
+
+static T_IPEP	dst;			/* æ¥ç¶ç¸æ		*/
+static bool_t	ena_rcv;		/* åä¿¡å¯è½ãã©ã°	*/
+static char	*rptr = buffer;		/* åä¿¡ãã¤ã³ã¿		*/
+static char	*sptr = buffer;		/* éä¿¡ãã¤ã³ã¿		*/
+static uint32_t	rcv_total;		/* åä¿¡æå­æ°		*/
+static uint32_t	snd_total;		/* éä¿¡æå­æ°		*/
+static uint16_t	chars;			/* ãããã¡å
+ã®æå­æ°	*/
+static uint16_t	rcv_count;		/* åä¿¡åæ°		*/
+static uint16_t	snd_count;		/* éä¿¡åæ°		*/
+
+#ifdef USE_TCP_NON_BLOCKING
+
+static ER	rcv_error = E_OK;	/* åä¿¡ããã³ãã­ãã­ã³ã°ã³ã¼ã«ã¨ã©ã¼ */
+static ER	snd_error = 1;		/* éä¿¡ããã³ãã­ãã­ã³ã°ã³ã¼ã«ã¨ã©ã¼ */
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER		error = E_OK;
+	ER_UINT		slen, rlen;
+	SYSTIM		now;
+	uint16_t	last;
+	char		head, tail;
+
+	get_tim(&now);
+
+	switch (fncd) {
+
+	case TFN_TCP_ACP_CEP:
+		rcv_error = *(ER*)p_parblk;
+		if (rcv_error == E_OK) {
+			sptr = rptr = buffer;
+			snd_count = snd_total = rcv_count = rcv_total = chars = 0;
+			snd_error = 1;
+			ena_rcv   = true;
+			syslog(LOG_NOTICE, "[TES:%02u CBN] connect: %6lu, from: %s.%d",
+			                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+			}
+		else
+			syslog(LOG_NOTICE, "[TES:%02u CBN] accept error: %s\n", cepid, itron_strerror(rcv_error));
+
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_RCV_READY));
+		break;
+
+	case TFN_TCP_SND_DAT:
+		slen = snd_error = *(ER*)p_parblk;
+		if (slen > 0) {
+			head = *sptr;
+			tail = *(sptr + slen - 1);
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES:%02u CBN] send len: %4u, data %02x -> %02x",
+			                   cepid, (uint16_t)slen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+			snd_count ++;
+			snd_total += slen;
+
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+			/* éä¿¡ãã¤ã³ã¿ãé²ããã*/
+			if (sptr - buffer + slen >= sizeof(buffer))
+				sptr -= sizeof(buffer) - slen;
+			else
+				sptr += slen;
+
+			/* ãããã¡å
+ã®æå­æ°ãæ¸ããã*/
+			last   = chars;
+			chars -= slen;
+
+ 			/* ãããã¡å
+ã«æå­ãããã°ãéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (chars > 0 || (!ena_rcv && chars == 0))
+				sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+ 			/* åä¿¡å¯è½ã§ããããã¡å
+ã«ç©ºããã§ããã°ãåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (ena_rcv && last == sizeof(buffer) && sizeof(buffer) - chars > 0)
+				syscall(sig_sem(SEM_TCP_ECHO_SRV_RCV_READY));
+
+			syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+			}
+		else {
+			syslog(LOG_NOTICE, "[TES:%02u CBN] send error = %s", cepid, itron_strerror(snd_error));
+			sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+			}
+		break;
+
+	case TFN_TCP_RCV_DAT:
+		rlen = rcv_error = *(ER*)p_parblk;
+		if (rlen > 0) {
+			head = *rptr;
+			tail = *(rptr + rlen - 1);
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES:%02u CBN] recv len: %4u, data %02x -> %02x",
+			                   cepid, (uint16_t)rlen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+			rcv_count ++;
+			rcv_total += rlen;
+
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+			/* åä¿¡ãã¤ã³ã¿ãé²ããã*/
+			if (rptr - buffer + rlen >= sizeof(buffer))
+				rptr -= sizeof(buffer) - rlen;
+			else
+				rptr += rlen;
+
+			/* ãããã¡å
+ã®æå­æ°ãå¢ããã*/
+			last   = chars;
+			chars += rlen;
+
+ 			/* ãããã¡å
+ã«æå­ãå
+¥ãã°ãéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (last == 0 && chars > 0)
+				sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+ 			/* ãããã¡å
+ã«ç©ºããããã°ãåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (sizeof(buffer) - chars > 0)
+				sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+
+			syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+			}
+		else {
+			if (rlen < 0)
+				syslog(LOG_NOTICE, "[TES:%02u CBN] recv error = %s", cepid, itron_strerror(rcv_error));
+			sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+			}
+		break;
+
+	case TFN_TCP_CLS_CEP:
+		snd_error = *(ER*)p_parblk;
+		if (snd_error != E_OK)
+			syslog(LOG_NOTICE, "[TES:%02u CBN] close error = %s", cepid, itron_strerror(snd_error));
+
+		syslog(LOG_NOTICE, "[TES:%02u CBN] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
+		                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
+
+		sig_sem(SEM_TCP_ECHO_SRV_CLS_READY);
+		break;
+
+	case TFN_TCP_CON_CEP:
+	case TFN_TCP_GET_BUF:
+	case TFN_TCP_RCV_BUF:
+	case TFN_TCP_SND_OOB:
+	default:
+		error = E_PAR;
+		}
+	return error;
+	}
+
+/*
+ *  TCP ECHO ãµã¼ãåä¿¡ã«ã¼ãã³ (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)
+ */
+
+ER
+tcp_echo_srv_rcv (ID cepid, ID repid)
+{
+	ER		error;
+	uint16_t	blen;
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	/* ã³ãã¯ã·ã§ã³éè¨­å®äºã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_SRV_RCV_READY));
+
+	/* å¾
+ã£ã¦ããéã«ã¨ã©ã¼ã«ãªã£ãããã³ãã¯ã·ã§ã³ã®éè¨­å¾
+ã¡ã«æ»ãã*/
+	if (rcv_error != E_OK)
+		return rcv_error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	while (true) {
+
+		/* åä¿¡ãµã¤ãºãè¨ç®ããã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+		if (sptr > rptr)
+			blen = sptr - rptr;
+		else
+			blen = sizeof(buffer) - (rptr - buffer);
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+		/* åä¿¡ããã*/
+		if ((error = tcp_rcv_dat(cepid, rptr, blen, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s", cepid, itron_strerror(error));
+			break;
+			}
+
+		/* åä¿¡ãããã¡ã«ç©ºãã§ããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_RCV_READY));
+
+		/* å¾
+ã£ã¦ããéã«ãåä¿¡æå­æ°ã 0 ã«ãªãããã¨ã©ã¼ã«ãªã£ããçµäºããã*/
+		if (rcv_error <= 0)
+			break;
+
+		}
+
+	/* åä¿¡å®äº */
+	ena_rcv = false;
+
+	/* åä¿¡ãããã¡ã«æå­ãå
+¥ãã®ãå¾
+ã£ã¦ããéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+	if (chars == 0)
+		sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+	/* ã³ãã¯ã·ã§ã³åæ­å®äºã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_SRV_CLS_READY));
+
+	return error == E_WBLK ? E_OK : error;
+	}
+
+/*
+ *  TCP ECHO ãµã¼ãéä¿¡ã¿ã¹ã¯ (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)
+ */
+
+void
+tcp_echo_srv_snd_task(intptr_t exinf)
+{
+	ER		error;
+	ID		tskid, cepid;
+	uint16_t	blen;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV (NBLK) SND:%d] started.", tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
+			                   cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			/* ãããã¡ã«æå­ãå
+¥ãã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_SND_READY));
+
+			/* å¾
+ã£ã¦ããéã«ã¨ã©ã¼ã«ãªã£ããçµäºããã*/
+			if (snd_error <= 0)
+				break;
+
+			/* åä¿¡å®äºã§ããããã¡ã«æå­ããªããã°çµäºããã*/
+			if (!ena_rcv && chars == 0)
+				break;
+
+			/* éä¿¡ãµã¤ãºãè¨ç®ããã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+			if (rptr > sptr)
+				blen = rptr - sptr;
+			else
+				blen = sizeof(buffer) - (sptr - buffer);
+			syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+			/* éä¿¡ããã*/
+			if ((error = tcp_snd_dat(cepid, sptr, blen, TMO_NBLK)) != E_WBLK) {
+				syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(error));
+				break;
+				}
+			}
+
+		/* åä¿¡ãããã¡ã«ç©ºãã§ãããå¾
+ã£ã¦ããåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+		if (chars == sizeof(buffer))
+			sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+#ifdef USE_TCP_SHT_CEP
+		if ((error = tcp_sht_cep(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TES:%02u SND] shutdown error = %s", cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+		if ((error = tcp_cls_cep(cepid, TMO_NBLK)) != E_WBLK) {
+			syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
+			}
+
+		pol_sem(SEM_TCP_ECHO_SRV_SND_READY);
+		pol_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+		}
+	}
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+/*
+ *  TCP ECHO ãµã¼ãåä¿¡ã«ã¼ãã³
+ */
+
+ER
+tcp_echo_srv_rcv (ID cepid, ID repid)
+{
+	ER_UINT		rlen;
+	ER		error;
+	SYSTIM		now;
+	uint16_t	blen, last;
+	char		head, tail;
+
+	if ((error = psnd_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t)cepid)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u RCV] sync error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+	if ((error = TCP_ACP_CEP(cepid, repid, &dst, TMO_FEVR)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u ACP] accept error = %s", cepid, itron_strerror(error));
+		return error;
+		}
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(repid, true)) != E_OK) {
+		syslog(LOG_NOTICE, "[TES:%02u DEL] REP delete error: %s", cepid, itron_strerror(error));
+		return error;
+		}
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	syscall(get_tim(&now));
+	syslog(LOG_NOTICE, "[TES:%02u ACP] connect: %6lu, from: %s.%d",
+	                   cepid, now / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+	sptr = rptr = buffer;
+	snd_count = snd_total = rcv_count = rcv_total = chars = 0;
+	ena_rcv   = true;
+	while (true) {
+
+		/* åä¿¡ãµã¤ãºãè¨ç®ããã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+		if (sptr > rptr)
+			blen = sptr - rptr;
+		else
+			blen = sizeof(buffer) - (rptr - buffer);
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+		/* åä¿¡ããã*/
+		if ((rlen = tcp_rcv_dat(cepid, rptr, blen, TMO_FEVR)) <= 0) {
+			if (rlen < 0)
+				syslog(LOG_NOTICE, "[TES:%02u RCV] recv error = %s",
+				                   cepid, itron_strerror(rlen));
+			break;
+			}
+		head = *rptr;
+		tail = *(rptr + rlen - 1);
+#ifdef SHOW_RCV_RANGE
+		syslog(LOG_NOTICE, "[TES:%02u RCV] len: %4u, data %02x -> %02x",
+		                   cepid, (uint16_t)rlen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+		rcv_count ++;
+		rcv_total += rlen;
+
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+		/* åä¿¡ãã¤ã³ã¿ãé²ããã*/
+		if (rptr - buffer + rlen >= sizeof(buffer))
+			rptr -= sizeof(buffer) - rlen;
+		else
+			rptr += rlen;
+
+		/* ãããã¡å
+ã®æå­æ°ãå¢ããã*/
+		last   =     chars;
+		chars += (uint16_t)rlen;
+
+ 				/* ãããã¡å
+ã«æå­ãå
+¥ãã°ãéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+		if (last == 0 && chars > 0)
+			sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+ 				/* ãããã¡å
+ã«ç©ºããããã°ãåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+		if (sizeof(buffer) - chars > 0)
+			sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+
+		syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+		/* ãããã¡ã«ç©ºããã§ããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_ECHO_SRV_RCV_READY));
+		}
+
+	/* åä¿¡å®äº */
+	ena_rcv = false;
+
+	/* åä¿¡ãããã¡ã«æå­ãå
+¥ãã®ãå¾
+ã£ã¦ããéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+	if (chars == 0)
+		sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+	/* ã³ãã¯ã·ã§ã³ã®åæ­ãå®äºããã¾ã§å¾
+ã¤ã*/
+	syscall(wai_sem(SEM_TCP_ECHO_SRV_CLS_READY));
+
+	return error;
+	}
+
+/*
+ *  TCP ECHO ãµã¼ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+tcp_echo_srv_snd_task(intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	ER_UINT		slen;
+	SYSTIM		now;
+	uint16_t	blen, last;
+	char		head, tail;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV SND:%d] started.", tskid);
+	while (true) {
+		if ((error = rcv_dtq(DTQ_TCP_ECHO_SRV_SND, (intptr_t*)&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TES:%02u SND] sync error: %s",
+			                   cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			/* ãããã¡ã«æå­ãå
+¥ãã¾ã§å¾
+ã¤ã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_SND_READY));
+
+			/* åä¿¡å®äºã§ããããã¡ã«æå­ããªããã°çµäºããã*/
+			if (!ena_rcv && chars == 0)
+				break;
+
+			/* éä¿¡ãµã¤ãºãè¨ç®ããã*/
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+			if (rptr > sptr)
+				blen = rptr - sptr;
+			else
+				blen = sizeof(buffer) - (sptr - buffer);
+			syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+			if ((slen = tcp_snd_dat(cepid, sptr, blen, TMO_FEVR)) <= 0) {
+				syslog(LOG_NOTICE, "[TES:%02u SND] send error = %s", cepid, itron_strerror(slen));
+				break;
+				}
+
+			head = *sptr;
+			tail = *(sptr + slen - 1);
+#ifdef SHOW_RCV_RANGE
+			syslog(LOG_NOTICE, "[TES:%02u SND] len: %4u, data %02x -> %02x",
+			                   cepid, (uint16_t)slen, head, tail);
+#endif	/* of #ifdef SHOW_RCV_RANGE */
+			snd_count ++;
+			snd_total += slen;
+
+			syscall(wai_sem(SEM_TCP_ECHO_SRV_LOCK));
+
+			/* éä¿¡ãã¤ã³ã¿ãé²ããã*/
+			if (sptr - buffer + slen >= sizeof(buffer))
+				sptr -= sizeof(buffer) - slen;
+			else
+				sptr += slen;
+
+			/* ãããã¡å
+ã®æå­æ°ãæ¸ããã*/
+			last   =     chars;
+			chars -= (uint16_t)slen;
+
+			/* åä¿¡å®äºã§ããããã¡ã«æå­ããªããã°çµäºããã*/
+			if (!ena_rcv && chars == 0) {
+				syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+				break;
+				}
+
+ 			/* ãããã¡å
+ã«æå­ãããã°ãéä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (chars > 0)
+				sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+ 			/* åä¿¡å¯è½ã§ããããã¡å
+ã«ç©ºããã§ããã°ãåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+			if (ena_rcv && last == sizeof(buffer) && sizeof(buffer) - chars > 0)
+				sig_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+
+			syscall(sig_sem(SEM_TCP_ECHO_SRV_LOCK));
+			}
+
+		/* åä¿¡ãããã¡ã«ç©ºãã§ãããå¾
+ã£ã¦ããåä¿¡ã¿ã¹ã¯ãèµ·åºããã*/
+		if (chars == sizeof(buffer))
+			sig_sem(SEM_TCP_ECHO_SRV_SND_READY);
+
+#ifdef USE_TCP_SHT_CEP
+		if ((error = tcp_sht_cep(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TES:%02u SND] shtudown error = %s", cepid, itron_strerror(error));
+#endif	/* of #ifdef USE_TCP_SHT_CEP */
+
+		if ((error = tcp_cls_cep(cepid, TMO_FEVR)) != E_OK)
+			syslog(LOG_NOTICE, "[TES:%02u SND] close error = %s", cepid, itron_strerror(error));
+
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[TES:%02u SND] finish:  %6lu, snd: %4u, rcv: %4u, len: %ld",
+		                   cepid, now / SYSTIM_HZ, snd_count, rcv_count, snd_total);
+
+		sig_sem(SEM_TCP_ECHO_SRV_CLS_READY);
+
+		pol_sem(SEM_TCP_ECHO_SRV_SND_READY);
+		pol_sem(SEM_TCP_ECHO_SRV_RCV_READY);
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  get_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+static ER
+get_tcp_rep (ID *repid)
+{
+	ID		tskid;
+	T_TCP_CREP	crep;
+
+	get_tid(&tskid);
+
+	crep.repatr = UINT_C(0);
+	crep.myaddr.portno = UINT_C(7);
+
+#if defined(SUPPORT_INET4)
+	crep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#if defined(SUPPORT_INET6)
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+#endif
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+/*
+ *  get_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+static ER
+get_tcp_cep (ID *cepid)
+{
+	ID		tskid;
+	T_TCP_CCEP	ccep;
+
+	get_tid(&tskid);
+
+	ccep.cepatr = UINT_C(0);
+	ccep.sbufsz = TCP_ECHO_SRV_SWBUF_SIZE;
+	ccep.rbufsz = TCP_ECHO_SRV_RWBUF_SIZE;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	ccep.sbuf = NADR;
+#else
+	ccep.sbuf = tcp_echo_srv_swbuf;
+#endif
+#ifdef TCP_CFG_RWBUF_CSAVE
+	ccep.rbuf = NADR;
+#else
+	ccep.rbuf = tcp_echo_srv_rwbuf;
+#endif
+#ifdef USE_TCP_NON_BLOCKING
+	ccep.callback = (FP)callback_nblk_tcp_echo_srv;
+#else
+	ccep.callback = NULL;
+#endif
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+	}
+
+/*
+ *  TCP ECHO ãµã¼ãåä¿¡ã¿ã¹ã¯
+ */
+
+void
+tcp_echo_srv_rcv_task (intptr_t exinf)
+{
+	ID	tskid, cepid, repid;
+	ER	error = E_OK;
+
+	syscall(get_tid(&tskid));
+	syslog(LOG_NOTICE, "[TCP ECHO SRV:%d] started.", tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		if ((error = get_tcp_cep (&cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[TES:00 EXT] CEP create error: %s", itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			if ((error = get_tcp_rep (&repid)) != E_OK) {
+				syslog(LOG_NOTICE, "[TES:00 EXT] REP create error: %s", itron_strerror(error));
+				break;
+				}
+			else if ((error = tcp_echo_srv_rcv(cepid, repid)) != E_OK) {
+				error = FREE_TCP_REP(repid, error != E_DLT);
+				break;
+				}
+			}
+
+		if ((error = free_tcp_cep(cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[TES:%02u EXT] CEP delete error: %s", cepid, itron_strerror(error));
+
+		}
+	}
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+void
+tcp_echo_srv_rcv_task(intptr_t exinf)
+{
+	ID	tskid;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP ECHO SRV RCV:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		while (tcp_echo_srv_rcv((ID)exinf, TCP_ECHO_SRV_REPID) == E_OK)
+			;
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV2 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.cfg	(revision 317)
@@ -0,0 +1,108 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ã #2ãéåä¿¡ã¿ã¹ã¯åé¢å
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_ECHO_SRV2
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_TCP_EXTENTIONS
+
+CRE_TSK(TCP_ECHO_SRV_TASK,  {
+	TA_HLNG | TA_ACT,
+	0,
+	tcp_echo_srv_rcv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(TCP_ECHO_SRV_SND_TASK,  {
+	TA_HLNG | TA_ACT,
+	0,
+	tcp_echo_srv_snd_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+CRE_TSK(TCP_ECHO_SRV_TASK,  {
+	TA_HLNG | TA_ACT,
+	TCP_ECHO_SRV_CEPID1,
+	tcp_echo_srv_rcv_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+CRE_TSK(TCP_ECHO_SRV_SND_TASK,  {
+	TA_HLNG | TA_ACT,
+	TCP_ECHO_SRV_CEPID1,
+	tcp_echo_srv_snd_task,
+	TCP_ECHO_SRV_MAIN_PRIORITY,
+	TCP_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_TCP_ECHO_SRV_SND,  { TA_TFIFO, 1, NULL });
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_TCP_ECHO_SRV_LOCK,		{ TA_TPRI, 1, 1 });
+CRE_SEM(SEM_TCP_ECHO_SRV_RCV_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_TCP_ECHO_SRV_SND_READY,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_TCP_ECHO_SRV_CLS_READY,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV2 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tcp_echo_srv2.h	(revision 317)
@@ -0,0 +1,127 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifdef USE_TCP_ECHO_SRV2
+
+#ifndef _TCP_ECHO_SRV2_H_
+#define _TCP_ECHO_SRV2_H_
+
+/* 
+ *  TCP ECHO ãµã¼ã #2
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åé¢å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»IPv4/IPv6
+ */
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define TCP_ECHO_SRV_STACK_SIZE		1024		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define TCP_ECHO_SRV_MAIN_PRIORITY	5		/* TCP ECHO ãµã¼ãã¿ã¹ã¯ã®åªå
+åº¦			*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#elif defined(SUPPORT_INET4)
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(512)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(512)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define TCP_ECHO_SRV_SWBUF_SIZE		(1024)
+#define TCP_ECHO_SRV_RWBUF_SIZE		(1024)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+/* ã¿ã¹ã¯æ° */
+
+#if defined(USE_TCP_ECHO_SRV2)
+#if defined(NUM_TCP_ECHO_SRV_TASKS)
+#undef  NUM_TCP_ECHO_SRV_TASKS
+#endif	/* of #if defined(NUM_TCP_ECHO_SRV_TASKS) */
+#define NUM_TCP_ECHO_SRV_TASKS		1
+#endif	/* of #if defined(USE_TCP_ECHO_SRV2) */
+
+/*
+ *  å¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+extern uint8_t tcp_echo_srv_swbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_SWBUF_SIZE];
+extern uint8_t tcp_echo_srv_rwbuf[NUM_TCP_ECHO_SRV_TASKS][TCP_ECHO_SRV_RWBUF_SIZE];
+
+/*
+ *  ã¿ã¹ã¯
+ */
+
+extern void	tcp_echo_srv_rcv_task(intptr_t exinf);
+extern void	tcp_echo_srv_snd_task(intptr_t exinf);
+
+/*
+ *  é¢æ°
+ */
+
+extern ER callback_nblk_tcp_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _TCP_ECHO_SRV2_H_ */
+
+#endif	/* of #ifdef USE_TCP_ECHO_SRV2 */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_dbg_cons.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_dbg_cons.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_dbg_cons.cfg	(revision 317)
@@ -0,0 +1,155 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã°ã³ã³ã½ã¼ã«
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_DBG_CONS
+
+#ifdef USE_TCP_EXTENTIONS
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+#if NUM_VRID_TCP6_REPS >= 1
+VRID_TCP6_REP (TCP6_RSV_REPID1);
+#endif
+
+#if NUM_VRID_TCP6_REPS >= 2
+VRID_TCP6_REP (TCP6_RSV_REPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#if NUM_VRID_TCP4_REPS >= 1
+VRID_TCP_REP (TCP4_RSV_REPID1);
+#endif
+
+#if NUM_VRID_TCP4_REPS >= 2
+VRID_TCP_REP (TCP4_RSV_REPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#if NUM_VRID_TCP6_CEPS >= 1
+VRID_TCP6_CEP (TCP6_RSV_CEPID1);
+#endif
+
+#if NUM_VRID_TCP6_CEPS >= 2
+VRID_TCP6_CEP (TCP6_RSV_CEPID2);
+#endif
+
+#if NUM_VRID_TCP6_CEPS >= 3
+VRID_TCP6_CEP (TCP6_RSV_CEPID3);
+#endif
+
+#if NUM_VRID_TCP6_CEPS >= 4
+VRID_TCP6_CEP (TCP6_RSV_CEPID4);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#if NUM_VRID_TCP4_CEPS >= 1
+VRID_TCP_CEP (TCP4_RSV_CEPID1);
+#endif
+
+#if NUM_VRID_TCP4_CEPS >= 2
+VRID_TCP_CEP (TCP4_RSV_CEPID2);
+#endif
+
+#if NUM_VRID_TCP4_CEPS >= 3
+VRID_TCP_CEP (TCP4_RSV_CEPID3);
+#endif
+
+#if NUM_VRID_TCP4_CEPS >= 4
+VRID_TCP_CEP (TCP4_RSV_CEPID4);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#if NUM_VRID_UDP6_CEPS >= 1
+VRID_UDP6_CEP (UDP6_RSV_CEPID1);
+#endif
+
+#if NUM_VRID_UDP6_CEPS >= 2
+VRID_UDP6_CEP (UDP6_RSV_CEPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#if NUM_VRID_UDP4_CEPS >= 1
+VRID_UDP_CEP (UDP4_RSV_CEPID1);
+#endif
+
+#if NUM_VRID_UDP4_CEPS >= 2
+VRID_UDP_CEP (UDP4_RSV_CEPID2);
+#endif
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_DBG_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp4_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp4_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp4_cli.cfg	(revision 317)
@@ -0,0 +1,61 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCP ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP4_CLI_CFG
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+UDP_CRE_CEP (UDP4_DHCP_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, DHCP4_CLI_CFG_PORTNO },
+	callback_nblk_dhcp4_cli
+	} );
+
+#endif	/* of #ifdef DHCP4_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp6_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp6_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_dhcp6_cli.cfg	(revision 317)
@@ -0,0 +1,61 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2011 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  DHCP/DHCPv6 ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef DHCP6_CLI_CFG
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+UDP6_CRE_CEP (UDP6_DHCP_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, DHCP6_CLI_CFG_PORTNO },
+	callback_nblk_dhcp6_cli
+	} );
+
+#endif	/* of #ifdef DHCP6_CLI_CFG */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_net_cons.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_net_cons.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_net_cons.cfg	(revision 317)
@@ -0,0 +1,136 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ãããã¯ã¼ã¯çµç±ã³ã³ã½ã¼ã«å
+¥åºå
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_NET_CONS
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (NET_CONS_REPID, {
+	0,
+	{ IPV6_ADDRANY, 23 }
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_REP (NET_CONS_REPID, {
+	0,
+	{ IPV4_ADDRANY, 23 }
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+TCP6_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	NADR,
+	NET_CONS_SWBUF_SIZE,
+	NADR,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+TCP6_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	net_cons_swbuf,
+	NET_CONS_SWBUF_SIZE,
+	net_cons_rwbuf,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+TCP_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	NADR,
+	NET_CONS_SWBUF_SIZE,
+	NADR,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+TCP_CRE_CEP (NET_CONS_CEPID, {
+	0,
+	net_cons_swbuf,
+	NET_CONS_SWBUF_SIZE,
+	net_cons_rwbuf,
+	NET_CONS_RWBUF_SIZE,
+	callback_nblk_net_cons
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifdef USE_NET_CONS */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_resolver.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_resolver.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_resolver.cfg	(revision 317)
@@ -0,0 +1,75 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  RESOLVER ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_RESOLVER
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+UDP6_CRE_CEP (UDP6_RESOLVER_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+UDP_CRE_CEP (UDP4_RESOLVER_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef USE_RESOLVER */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1.cfg	(revision 317)
@@ -0,0 +1,488 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp4_echo_srv1_nblk.cfg	(revision 317)
@@ -0,0 +1,486 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1.cfg	(revision 317)
@@ -0,0 +1,362 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP åä»å£
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS == 1
+ * 
+ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+/*
+ * TCP åä»å£
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (TCP_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV6_ADDRANY, 7 }
+	} );
+
+#if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV)
+
+TCP_CRE_REP (TCP4_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+TCP_CRE_REP (TCP_ECHO_SRV_REPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+/*
+ * TCP éä¿¡ç«¯ç¹
+ *
+ * å®ç¾©ãã TCP éä¿¡ç«¯ç¹ï¼TCP?_ECHO_SRV_CEPID1ï¼ã®é¸æ
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     â    â     â          Ã         TCP4
+ *     â    â     Ã          TCP        Ã
+ *     â    Ã     â          TCP        Ã
+ *     â    Ã     Ã          TCP        Ã
+ *     Ã    â     â          Ã         TCP
+ *     Ã    â     Ã          Ã         TCP
+ *     Ã    Ã     â          Ã         Ã
+ *     Ã    Ã     Ã          Ã         Ã
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP4_ECHO_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp64_echo_srv1_nblk.cfg	(revision 317)
@@ -0,0 +1,320 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS == 1
+ * 
+ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+/*
+ * TCP éä¿¡ç«¯ç¹
+ *
+ * å®ç¾©ãã TCP éä¿¡ç«¯ç¹ï¼TCP?_ECHO_SRV_CEPID1ï¼ã®é¸æ
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     â    â     â          Ã         TCP4
+ *     â    â     Ã          TCP        Ã
+ *     â    Ã     â          TCP        Ã
+ *     â    Ã     Ã          TCP        Ã
+ *     Ã    â     â          Ã         TCP
+ *     Ã    â     Ã          Ã         TCP
+ *     Ã    Ã     â          Ã         Ã
+ *     Ã    Ã     Ã          Ã         Ã
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP4_ECHO_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP4_ECHO_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1.cfg	(revision 317)
@@ -0,0 +1,482 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp6_echo_srv1_nblk.cfg	(revision 317)
@@ -0,0 +1,482 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    USE_TCP_NON_BLOCKING: ON
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP éä¿¡ç«¯ç¹ãNUM_TCP_ECHO_SRV_TASKS >= 2 ä»¥é
+ * 
+ */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_TCP_ECHO_SRV1)
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID2, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[1],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[1],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 2 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 3
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID3, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[2],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[2],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 3 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 4
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID4, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[3],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[3],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 4 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 5
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID5, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[4],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[4],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 5 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 6
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID6, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[5],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[5],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 6 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 7
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID7, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[6],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[6],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 7 */
+
+#if NUM_TCP_ECHO_SRV_TASKS >= 8
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID8, {
+	TA_NULL,
+	tcp_echo_srv_swbuf[7],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[7],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_TCP_ECHO_SRV_TASKS >= 8 */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_TCP_ECHO_SRV1) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_cli.cfg	(revision 317)
@@ -0,0 +1,177 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP DISCARD ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_DISCARD_CLI
+
+#ifndef USE_TCP_EXTENTIONS
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	callback_nblk_tcp_discard_cli
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	NADR,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+TCP_CRE_CEP (TCP_DISCARD_CLI_CEPID, {
+	TA_NULL,
+	tcp_discard_cli_swbuf,
+	TCP_DISCARD_CLI_SWBUF_SIZE,
+	NADR,
+	0,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_discard_srv.cfg	(revision 317)
@@ -0,0 +1,138 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP DISCARD ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_DISCARD_SRV
+
+#ifndef USE_TCP_EXTENTIONS
+
+/* TCP åä»å£ */
+
+#ifdef SUPPORT_INET6
+
+TCP6_CRE_REP (TCP_DISCARD_SRV_REPID, {
+	TA_NULL,
+	{ IPV6_ADDRANY, 9 }
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+TCP_CRE_REP (TCP_DISCARD_SRV_REPID, {
+	TA_NULL,
+	{ IPV4_ADDRANY, 9 }
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	NADR,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+TCP6_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	tcp_discard_srv_rwbuf,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	NADR,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+TCP_CRE_CEP (TCP_DISCARD_SRV_CEPID, {
+	TA_NULL,
+	NADR,
+	0,
+	tcp_discard_srv_rwbuf,
+	TCP_DISCARD_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_DISCARD_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_cli.cfg	(revision 317)
@@ -0,0 +1,419 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_TCP_ECHO_CLI
+
+#ifndef USE_TCP_EXTENTIONS
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#ifdef SUPPORT_INET4
+
+#ifdef USE_TCP4_ECHO_CLI
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP4_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef USE_TCP4_ECHO_CLI */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+#ifdef USE_TCP_NON_BLOCKING
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	callback_nblk_tcp_echo_cli
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	NADR,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_CLI_CEPID, {
+	0,
+	tcp_echo_cli_swbuf,
+	TCP_ECHO_CLI_SWBUF_SIZE,
+	tcp_echo_cli_rwbuf,
+	TCP_ECHO_CLI_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #ifdef USE_TCP_NON_BLOCKING */
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_TCP_ECHO_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_srv2.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_srv2.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_tcp_echo_srv2.cfg	(revision 317)
@@ -0,0 +1,318 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ECHO ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_TCP_ECHO_SRV2)
+
+#ifndef USE_TCP_EXTENTIONS
+
+/* TCP åä»å£ */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (TCP_ECHO_SRV_REPID, {
+	0,
+	{ IPV6_ADDRANY, 7 }
+	} );
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+TCP_CRE_REP (TCP_ECHO_SRV_REPID, {
+	0,
+	{ IPV4_ADDRANY, 7 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_TCP_NON_BLOCKING)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	callback_nblk_tcp_echo_srv
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	NADR,
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	NADR,
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (TCP_ECHO_SRV_CEPID1, {
+	0,
+	tcp_echo_srv_swbuf[0],
+	TCP_ECHO_SRV_SWBUF_SIZE,
+	tcp_echo_srv_rwbuf[0],
+	TCP_ECHO_SRV_RWBUF_SIZE,
+	NULL 
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_TCP_NON_BLOCKING) */
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #ifndef USE_TCP_EXTENTIONS */
+
+#endif	/* of #defined(USE_TCP_ECHO_SRV2) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_cli.cfg	(revision 317)
@@ -0,0 +1,89 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+#if !defined(USE_UDP_EXTENTIONS)
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	callback_nblk_udp4_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	callback_udp4_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+UDP_CRE_CEP (UDP4_ECHO_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_UDP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_udp4_echo_srv.cfg	(revision 317)
@@ -0,0 +1,91 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ *  UDP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv4
+ */
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+#ifndef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	callback_nblk_udp4_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#ifdef USE_UDP_CALL_BACK
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	callback_udp4_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+UDP_CRE_CEP (UDP4_ECHO_SRV_CEPID, {
+	0,
+	{ IPV4_ADDRANY, 7 },
+	NULL
+	} );
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#endif	/* of #ifndef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_cli.cfg	(revision 317)
@@ -0,0 +1,89 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ã¯ã©ã¤ã¢ã³ã
+ *  TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+#if !defined(USE_UDP_EXTENTIONS)
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	callback_nblk_udp6_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	callback_udp6_echo_cli
+	} );
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+UDP6_CRE_CEP (UDP6_ECHO_CLI_CEPID, {
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#endif	/* of #if !defined(USE_UDP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_udp6_echo_srv.cfg	(revision 317)
@@ -0,0 +1,91 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ *  UDP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv6
+ */
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+#ifndef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	callback_nblk_udp6_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#ifdef USE_UDP_CALL_BACK
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	callback_udp6_echo_srv
+	} );
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+UDP6_CRE_CEP (UDP6_ECHO_SRV_CEPID, {
+	0,
+	{ IPV6_ADDRANY, 7 },
+	NULL
+	} );
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+#endif	/* of #ifndef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_udp_discard_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_udp_discard_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_udp_discard_cli.cfg	(revision 317)
@@ -0,0 +1,81 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP DISCARD ã¯ã©ã¤ã¢ã³ã
+ *  UDP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP_DISCARD_CLI
+
+#ifndef USE_UDP_EXTENTIONS
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+#ifdef SUPPORT_INET6
+
+UDP6_CRE_CEP (UDP_DISCARD_CLI_CEPID, { 
+	0,
+	{ IPV6_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#else	/* of #ifdef SUPPORT_INET6 */
+
+#ifdef SUPPORT_INET4
+
+UDP_CRE_CEP (UDP_DISCARD_CLI_CEPID, {
+	0,
+	{ IPV4_ADDRANY, UDP_PORTANY },
+	NULL
+	} );
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifndef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/tinet_wwws.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/tinet_wwws.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/tinet_wwws.cfg	(revision 317)
@@ -0,0 +1,472 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  WWW ãµã¼ãã® TCP/IP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    SUPPORT_INET6
+ *    SUPPORT_INET4
+ *    USE_TCP_NON_BLOCKING: OFF
+ *    USE_TCP_EXTENTIONS:   OFF
+ *    TCP åä»å£
+ *    TCP éä¿¡ç«¯ç¹
+ * 
+ */
+
+#if defined(USE_WWW_SRV)
+
+/*
+ * TCP åä»å£
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#if defined(SUPPORT_INET6)
+
+TCP6_CRE_REP (WWW_SRV_REPID, {
+	0,
+	{ IPV6_ADDRANY, 80 }
+	} );
+
+#if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+TCP_CRE_REP (WWW4_SRV_REPID, {
+	0,
+	{ IPV4_ADDRANY, 80 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET6 */
+
+#if defined(SUPPORT_INET4)
+
+TCP_CRE_REP (WWW_SRV_REPID, {
+	0,
+	{ IPV4_ADDRANY, 80 }
+	} );
+
+#endif	/* of #if defined(SUPPORT_INET4 */
+
+#endif	/* of #if defined(SUPPORT_INET6 */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS */
+
+/*
+ * TCP éä¿¡ç«¯ç¹
+ *
+ * å®ç¾©ãã TCP éä¿¡ç«¯ç¹ï¼WWW?_CEPID1ï¼ã®é¸æ
+ *
+ *   INET6 INET4 USE_TCP4  TCP6_CRE_CEP TCP_CRE_CEP
+ *     â    â     â          Ã         WWW4
+ *     â    â     Ã          WWW        Ã
+ *     â    Ã     â          WWW        Ã
+ *     â    Ã     Ã          WWW        Ã
+ *     Ã    â     â          Ã         WWW
+ *     Ã    â     Ã          Ã         WWW
+ *     Ã    Ã     â          Ã         Ã
+ *     Ã    Ã     Ã          Ã         Ã
+ *
+ */
+
+#if defined(USE_TCP_EXTENTIONS)
+
+#else	/* of #if defined(USE_TCP_EXTENTIONS */
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#if defined(USE_WWW4_SRV)
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW4_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#else	/* of #if defined(USE_WWW4_SRV) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(USE_WWW4_SRV) */
+
+#else	/* of #if defined(SUPPORT_INET4 */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if defined(SUPPORT_INET4 */
+
+#if NUM_WWW_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP6_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#elif defined(SUPPORT_INET4)	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW_SRV_CEPID1, {
+	0,
+	www_srv_swbuf[0],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[0],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if NUM_WWW_SRV_TASKS >= 2
+
+#if defined(TCP_CFG_SWBUF_CSAVE)
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	NADR,
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#if defined(TCP_CFG_RWBUF_CSAVE)
+
+TCP_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	NADR,
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#else	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+TCP_CRE_CEP (WWW_SRV_CEPID2, {
+	0,
+	www_srv_swbuf[1],
+	WWW_SRV_SWBUF_SIZE,
+	www_srv_rwbuf[1],
+	WWW_SRV_RWBUF_SIZE,
+	NULL
+	} );
+
+#endif	/* of #if defined(TCP_CFG_RWBUF_CSAVE) */
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE) */
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#endif	/* of #if defined(USE_TCP_EXTENTIONS) */
+
+#endif	/* of #if defined(USE_WWW_SRV) */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.c	(revision 317)
@@ -0,0 +1,490 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP4 ECHO ã¯ã©ã¤ã¢ã³ã
+ */
+
+#include <string.h>
+
+#if defined(TARGET_KERNEL_ASP)
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+
+#if defined(TARGET_KERNEL_JSP)
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_cli.h>
+
+#if defined(USE_UDP4_ECHO_CLI_TSK)
+
+/* echo ãµã¼ãã®ãã¼ãçªå· */
+
+#define ECHO_SRV_PORTNO		UINT_C(7)
+
+/* éä¿¡éé */
+
+#if defined(TOPPERS_S810_CLG3_85)
+
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+/* èªåå®è¡ */
+
+#if defined(UDP4_ECHO_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#define UDP4_ECHO_CLI_AUTO_RUN_STR	"172.25.193.140 - 1000"
+#endif
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t udp4_echo_cli_valid;
+
+/*
+ * å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+static char		udp_buf[BUF_SIZE];
+static T_IPV4EP		dst;
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+static ER_UINT		nblk_len;
+static ID		nblk_tskid;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	nblk_len = *(ER_UINT*)p_parblk;
+	syscall(wup_tsk(nblk_tskid));
+	return E_OK;
+	}
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	ER_UINT	error;
+	SYSTIM	time;
+	uint_t	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	get_tid(&nblk_tskid);
+	if ((error = udp_snd_dat(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(NBLK)] send:  %7lu,  to: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC4:%02u CBR(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+
+	if ((error = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+	else {
+		udp_buf[nblk_len] = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(NBLK)] recv:  %7lu,from: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		nblk_len = E_OK;
+		}
+
+	return nblk_len;
+	}
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	get_tim(&time);
+	if ((len = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
+		*(udp_buf + len) = '\0';
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(CB)] recv:  %7lu,from: %s.%d\n"
+		                   "                                  msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV(CB)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°ä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len        = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC4:%02u SND(CB)] send:  %7lu,  to: %s.%d\n"
+	                   "                                  msg: %s",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0)
+		syslog(LOG_NOTICE, "[UEC4:%02u SND(CB)] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+/*
+ *  udp4_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°æªä½¿ç¨)ã
+ */
+
+ER
+udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC4:%02u SND] send:  %7lu,  to: %s.%d\n"
+	                   "                              msg: %s",
+	                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0) {
+		syslog(LOG_NOTICE, "[UEC4:%02u SND] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+
+	if ((len = udp_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
+		*(udp_buf + len) = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, time / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		return E_OK;
+		}
+	else {
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC4:%02u RCV] error: %7lu,%s",
+		       cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#if defined(UDP4_ECHO_CLI_AUTO_RUN_STR)
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = UDP4_ECHO_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || count == 0) {
+		line = auto_run_str;
+		dly_tsk(6 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] error:%s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #if defined(UDP4_ECHO_CLI_AUTO_RUN_STR) */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_UDP4_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[UEC4:%02u TSK] error:%s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #if defined(UDP4_ECHO_CLI_AUTO_RUN_STR) */
+
+#define MESSAGE_FORMAT	"MSG 1000000"
+
+/*
+ *  UDP4 ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+udp4_echo_cli_task (intptr_t exinf)
+{
+	static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
+
+	ID		tskid, cepid;
+	ER		error = E_OK;
+	SYSTIM		time;
+	T_IN4_ADDR	addr;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+	T_IN6_ADDR	addr6;
+#endif
+
+	char		*line, *p;
+	int_t		rep;
+	uint32_t	count, msgno;
+	bool_t		retry = false;
+	uint16_t	portno = ECHO_SRV_PORTNO;
+
+#if defined(USE_UDP_EXTENTIONS)
+	T_UDP_CCEP	ccep;
+#endif
+
+	dly_tsk(10*1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		line = lookup_ipaddr(&addr6, line, API_PROTO_IPV4);
+		if (line == NULL || !in6_is_addr_ipv4mapped(&addr6)) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+		addr = ntohl(addr6.s6_addr32[3]);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if ((line = lookup_ipaddr(&addr, line, DEFAULT_API_PROTO)) == NULL) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else if (*line == '-')
+			line ++;
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UDP_PORTANY;
+
+#if defined(SUPPORT_INET6)
+
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+		ccep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+#if defined(USE_UDP_NON_BLOCKING)
+		ccep.callback = (FP)callback_nblk_udp4_echo_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		cepid = (ID)exinf;
+
+#endif/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {				/* Repeat */
+			line = get_int(&rep, line);
+#if 0
+			if (rep > 1000000)
+				rep = 1000000;
+#endif
+			udp4_echo_cli_valid = true;
+			count = 0;
+			while (rep == 0 || count < rep) {
+				if (!udp4_echo_cli_valid) {
+					syslog(LOG_NOTICE, "[UEC4:%02u TSK] canceled.", cepid);
+					break;
+					}
+					
+				count ++;
+				p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
+				for (msgno = count; msgno > 0; msgno /= 10)
+					*(-- p) = msgno % 10 + '0';
+				while (*(p - 2) != 'G')
+					*(-- p) = ' ';
+
+				if ((error = udp4_echo_cli(cepid, &addr, portno, msg)) != E_OK)
+					dly_tsk(30 * SYSTIM_HZ);
+
+				dly_tsk(25 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
+				}
+			}
+
+		else								/* Single Message */
+			error = udp4_echo_cli(cepid, &addr, portno, line);
+
+		if (error != E_OK) {
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[UEC4:%02u SND] error: %7lu,%s",
+			                   cepid, time / SYSTIM_HZ, itron_strerror(error));
+			}
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		if ((error = free_udp4_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+			syslog(LOG_NOTICE, "[UEC4:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP4_ECHO_CLI_TSK) */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.cfg	(revision 317)
@@ -0,0 +1,82 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP4_ECHO_CLI_TSK
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP4_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	udp4_echo_cli_task,
+	UDP4_ECHO_CLI_MAIN_PRIORITY,
+	UDP4_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP4_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP4_ECHO_CLI_CEPID,
+	udp4_echo_cli_task,
+	UDP4_ECHO_CLI_MAIN_PRIORITY,
+	UDP4_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_UDP4_ECHO_CLI,  { TA_TFIFO, 1, NULL });
+
+#endif	/* of #ifdef USE_UDP4_ECHO_CLI_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_cli.h	(revision 317)
@@ -0,0 +1,76 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP4_ECHO_CLI_H_
+#define _UDP4_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP4_ECHO_CLI_STACK_SIZE	1024		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv4ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP4_ECHO_CLI_MAIN_PRIORITY	5		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv4ï¼ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp4_echo_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp4_echo_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp4_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#ifdef T_IN4_ADDR_DEFINED
+extern ER udp4_echo_cli (ID cepid, T_IN4_ADDR *ipaddr, uint16_t portno, char *line);
+#endif
+
+#endif	/* of #ifndef _UDP4_ECHO_CLI_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.c	(revision 317)
@@ -0,0 +1,315 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    IPv4
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_srv.h>
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+/*
+ *  åä¿¡ã¿ã¤ã ã¢ã¦ã
+ */
+
+#define RCV_TMOUT	TMO_FEVR
+//#define RCV_TMOUT	(30*ULONG_C(1000))
+
+#define BUF_SIZE	2048
+
+static char	echo_rcv_buf[BUF_SIZE];
+static T_IPV4EP	dst;
+
+#ifdef USE_UDP_CALL_BACK
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_FEVR)) >= 0) {
+		echo_rcv_buf[len] = '\0';
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u UCB] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES4:%02u UCB] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, len);
+			else
+				syslog(LOG_NOTICE, "[UES4:%02u UCB] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		len = E_OK;
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u UCB] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len;
+	}
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+static ER_UINT		nblk_len;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	now;
+
+	get_tim(&now);
+	nblk_len = *(ER_UINT*)p_parblk;
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UES4:%02u CBR] error,      %7lu,%s, fncd: %s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(nblk_len), in_strtfn(fncd));
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {
+		echo_rcv_buf[nblk_len] = '\0';
+		syslog(LOG_NOTICE, "[UES4:%02u CBR] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		}
+	syscall(wup_tsk(UDP4_ECHO_SRV_TASK));
+	return E_OK;
+	}
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp4_echo_srv (ID cepid)
+{
+	ER	error;
+	SYSTIM	now;
+
+	if ((error = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_NBLK)) != E_WBLK) {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	if (nblk_len < 0)
+		error = nblk_len;
+	else {
+		if ((error = udp_snd_dat(cepid, &dst, echo_rcv_buf, nblk_len, TMO_NBLK)) != E_WBLK) {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES4:%02u SND] error: %7lu,%s",
+			                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+			return error;
+			}
+
+		syscall(slp_tsk());
+		if (nblk_len < 0)
+			error = nblk_len;
+		else {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES4:%02u SND] send:  %7lu, len: %d",
+			                   cepid, now / SYSTIM_HZ, nblk_len);
+			error = E_OK;
+			}
+		}
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp4_echo_srv (ID cepid)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), RCV_TMOUT)) >= 0) {
+		get_tim(&now);
+		echo_rcv_buf[len] = '\0';
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ip2str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES4:%02u SND] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, (uint16_t)len);
+			else
+				syslog(LOG_NOTICE, "[UES4:%02u SND] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES4:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len >= 0 || len == E_TMOUT ? E_OK : len;
+	}
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+void
+udp4_echo_srv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	T_UDP_CCEP	ccep;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		syslog(LOG_NOTICE, "[UDP4 ECHO SRV(EXT):%d] wake up.", tskid);
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UINT_C(7);
+		ccep.myaddr.ipaddr = IPV4_ADDRANY;
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp4_echo_srv;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp4_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UES4:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (error == E_OK) {
+			if ((error = udp4_echo_srv(cepid)) != E_OK) {
+				if ((error = free_udp4_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+					syslog(LOG_NOTICE, "[UES4:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+				break;
+				}
+			}
+
+		}
+	slp_tsk();
+	}
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+void
+udp4_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP4 ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	while (error == E_OK) {
+		error = udp4_echo_srv((ID)exinf);
+		}
+	slp_tsk();
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.cfg	(revision 317)
@@ -0,0 +1,88 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv4
+ */
+
+#ifdef USE_UDP4_ECHO_SRV_TSK
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_CALL_BACK
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP4_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	0,
+	udp4_echo_srv_task,
+	UDP4_ECHO_SRV_MAIN_PRIORITY,
+	UDP4_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP4_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	UDP4_ECHO_SRV_CEPID,
+	udp4_echo_srv_task,
+	UDP4_ECHO_SRV_MAIN_PRIORITY,
+	UDP4_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP4_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp4_echo_srv.h	(revision 317)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP4_ECHO_SRV_H_
+#define _UDP4_ECHO_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP4_ECHO_SRV_STACK_SIZE	1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPV4ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP4_ECHO_SRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPV4ï¼ã®åªå
+åº¦		*/
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp4_echo_srv_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp4_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP4_ECHO_SRV_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.c	(revision 317)
@@ -0,0 +1,460 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP6 ECHO ã¯ã©ã¤ã¢ã³ã
+ */
+
+#include <string.h>
+
+#if defined(TARGET_KERNEL_ASP)
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+
+#if defined(TARGET_KERNEL_JSP)
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp4_echo_cli.h>
+#include <netapp/udp6_echo_cli.h>
+
+#if defined(USE_UDP6_ECHO_CLI_TSK)
+
+/* echo ãµã¼ãã®ãã¼ãçªå· */
+
+#define ECHO_SRV_PORTNO		UINT_C(7)
+
+/* éä¿¡éé */
+
+#if defined(TOPPERS_S810_CLG3_85)
+
+#define SLP_ITV		(30*SYSTIM_HZ)
+
+#else	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+#define SLP_ITV		(60*SYSTIM_HZ)
+
+#endif	/* of #if defined(TOPPERS_S810_CLG3_85) */
+
+/* èªåå®è¡ */
+
+#if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
+#else
+#if 0
+#define UDP6_ECHO_CLI_AUTO_RUN_STR	"fe80::211:2fff:fe8a:e8c0 - 1000"
+#endif
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t udp6_echo_cli_valid;
+
+/*
+ * å¤æ°
+ */
+
+#define BUF_SIZE	2048
+
+static char		udp_buf[BUF_SIZE];
+static T_IPV6EP		dst;
+
+#if defined(USE_UDP_NON_BLOCKING)
+
+static ER_UINT		nblk_len;
+static ID		nblk_tskid;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	nblk_len = *(ER_UINT*)p_parblk;
+	syscall(wup_tsk(nblk_tskid));
+	return E_OK;
+	}
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ãã³ãã­ãã­ã³ã°ã³ã¼ã«ä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	ER_UINT	error;
+	SYSTIM	time;
+	uint_t	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	get_tid(&nblk_tskid);
+	if ((error = udp6_snd_dat(cepid, &dst, line, len, TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u SDN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC6:%02u SDN] send:  %7lu,  to: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC6:%02u CBR] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+
+	if ((error = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_NBLK)) != E_WBLK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	get_tim(&time);
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(nblk_len));
+		return nblk_len;
+		}
+	else {
+		udp_buf[nblk_len] = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RVN] recv:  %7lu,from: %s.%d\n"
+		                   "                                    msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		nblk_len = E_OK;
+		}
+
+	return nblk_len;
+	}
+
+#else	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+#if defined(USE_UDP_CALL_BACK)
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	get_tim(&time);
+	if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), TMO_FEVR)) >= 0) {
+		*(udp_buf + len) = '\0';
+		syslog(LOG_NOTICE, "[UEC6:%02u RVC)] recv:  %7lu,from: %s.%d\n"
+		                   "                                  msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		}
+	else
+		syslog(LOG_NOTICE, "[UEC6:%02u RVC] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°ä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len        = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC6:%02u SDC)] send:  %7lu,  to: %s.%d\n"
+		           "                                  msg: %s",
+	                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0)
+		syslog(LOG_NOTICE, "[UEC6:%02u SDC] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+
+	return E_OK;
+	}
+
+#else	/* of #if defined(USE_UDP_CALL_BACK) */
+
+/*
+ *  udp6_echo_cli -- ECHO/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ãã (ã³ã¼ã«ããã¯é¢æ°æªä½¿ç¨)ã
+ */
+
+static ER
+udp6_echo_cli (ID cepid, T_IN6_ADDR *ipaddr, uint16_t portno, char *line)
+{
+	SYSTIM	time;
+	ER_UINT	len;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+	len         = strlen(line);
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UEC6:%02u SND] send:  %7lu,  to: %s.%d\n"
+		           "                              msg: %s",
+	                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, line);
+	if ((len = udp6_snd_dat(cepid, &dst, line, len, TMO_FEVR)) < 0) {
+		syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
+		                   cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+
+	if ((len = udp6_rcv_dat(cepid, &dst, udp_buf, sizeof(udp_buf), 10*1000)) >= 0) {
+		*(udp_buf + len) = '\0';
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, time / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, udp_buf);
+		return E_OK;
+		}
+	else {
+		get_tim(&time);
+		syslog(LOG_NOTICE, "[UEC6:%02u RCV] error: %7lu,%s",
+		       cepid, time / SYSTIM_HZ, itron_strerror(len));
+		return len;
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP_CALL_BACK) */
+
+#endif	/* of #if defined(USE_UDP_NON_BLOCKING) */
+
+/*
+ *  getcomd -- ã³ãã³ããå¾ãã
+ */
+
+#if defined(UDP6_ECHO_CLI_AUTO_RUN_STR)
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER		error;
+	char		*line = NULL;
+	static char	auto_run_str[] = UDP6_ECHO_CLI_AUTO_RUN_STR;
+	static int_t	count = 0;
+
+	if (retry || count == 0) {
+		line = auto_run_str;
+		dly_tsk(6 * 1000);
+		}
+	else {
+		while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
+			dly_tsk(SLP_ITV);
+			}
+		}
+
+	count ++;
+	return line;
+	}
+
+#else	/* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
+
+static char *
+getcomd (ID cepid, bool_t retry)
+{
+	ER	error;
+	char	*line = NULL;
+
+	while ((error = rcv_dtq(DTQ_UDP6_ECHO_CLI, (intptr_t*)&line)) != E_OK) {
+		syslog(LOG_NOTICE, "[UEC6:%02u TSK] error:%s", cepid, itron_strerror(error));
+		dly_tsk(SLP_ITV);
+		}
+	return line;
+	}
+
+#endif	/* of #if defined(UDP6_ECHO_CLI_AUTO_RUN_STR) */
+
+#define MESSAGE_FORMAT	"MSG 1000000"
+
+/*
+ *  UDP6 ECHO ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+udp6_echo_cli_task (intptr_t exinf)
+{
+	static char msg[sizeof(MESSAGE_FORMAT)] = MESSAGE_FORMAT;
+
+	ID		tskid, cepid;
+	ER		error = E_OK;
+	SYSTIM		time;
+	T_IN6_ADDR	addr;
+	char		*line, *p;
+	int_t		rep;
+	uint32_t	count, msgno;
+	bool_t		retry = false;
+	uint16_t	portno = ECHO_SRV_PORTNO;
+
+#if defined(USE_UDP_EXTENTIONS)
+	T_UDP6_CCEP	ccep;
+#endif
+
+	dly_tsk(10*1000);
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO CLI:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		line = skip_blanks(getcomd((ID)exinf, retry));
+
+		if ((line = lookup_ipaddr(&addr, line, API_PROTO_IPV6)) == NULL) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] sleep %d.%03u[s], unknown host.",
+			       (ID)exinf, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
+			dly_tsk(SLP_ITV);
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] resume.", (ID)exinf);
+			retry = true;
+			continue;
+			}
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {	/* Port No */
+			line = get_int(&rep, line);
+			portno = (uint16_t)rep;
+			}
+		else if (*line == '-')
+			line ++;
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UDP_PORTANY;
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp6_echo_cli;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+#else/* of #ifdef USE_UDP_EXTENTIONS */
+
+		cepid = (ID)exinf;
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		line = skip_blanks(line);
+		if ('0' <= *line && *line <= '9') {				/* Repeat */
+			line = get_int(&rep, line);
+#if 0
+			if (rep > 1000000)
+				rep = 1000000;
+#endif
+			udp6_echo_cli_valid = true;
+			count = 0;
+			while (rep == 0 || count < rep) {
+				if (!udp6_echo_cli_valid) {
+					syslog(LOG_NOTICE, "[UEC6:%02u TSK] canceled.", cepid);
+					break;
+					}
+					
+				count ++;
+				p = &msg[sizeof(MESSAGE_FORMAT)] - 1;
+				for (msgno = count; msgno > 0; msgno /= 10)
+					*(-- p) = msgno % 10 + '0';
+				while (*(p - 2) != 'G')
+					*(-- p) = ' ';
+
+				if ((error = udp6_echo_cli(cepid, &addr, portno, msg)) != E_OK)
+					dly_tsk(30 * SYSTIM_HZ);
+
+				dly_tsk(25 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
+				}
+			}
+
+		else								/* Single Message */
+
+			error = udp6_echo_cli(cepid, &addr, portno, line);
+
+		if (error != E_OK) {
+			get_tim(&time);
+			syslog(LOG_NOTICE, "[UEC6:%02u SND] error: %7lu,%s",
+			                   cepid, time / SYSTIM_HZ, itron_strerror(error));
+			}
+
+#if defined(USE_UDP_EXTENTIONS)
+
+		if ((error = free_udp6_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+			syslog(LOG_NOTICE, "[UEC6:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+
+#endif	/* of #if defined(USE_UDP_EXTENTIONS) */
+
+		}
+	}
+
+#endif	/* of #if defined(USE_UDP6_ECHO_CLI_TSK) */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.cfg	(revision 317)
@@ -0,0 +1,82 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ECHO ãµã¼ãè©¦é¨ãã­ã°ã©ã ã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP6_ECHO_CLI_TSK
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP6_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	udp6_echo_cli_task,
+	UDP6_ECHO_CLI_MAIN_PRIORITY,
+	UDP6_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP6_ECHO_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP6_ECHO_CLI_CEPID,
+	udp6_echo_cli_task,
+	UDP6_ECHO_CLI_MAIN_PRIORITY,
+	UDP6_ECHO_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_UDP6_ECHO_CLI,  { TA_TFIFO, 1, NULL });
+
+#endif	/* of #ifdef USE_UDP6_ECHO_CLI_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_cli.h	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP6_ECHO_CLI_H_
+#define _UDP6_ECHO_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP6_ECHO_CLI_STACK_SIZE	1024		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv6ï¼ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP6_ECHO_CLI_MAIN_PRIORITY	5		/* UDP ECHO ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ï¼IPv6ï¼ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp6_echo_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp6_echo_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp6_echo_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP6_ECHO_CLI_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.c	(revision 317)
@@ -0,0 +1,314 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP ECHO ãµã¼ã
+ *
+ *    IPv6
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp6_echo_srv.h>
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+/*
+ *  åä¿¡ã¿ã¤ã ã¢ã¦ã
+ */
+
+#define RCV_TMOUT	TMO_FEVR
+//#define RCV_TMOUT	(30*ULONG_C(1000))
+
+#define BUF_SIZE	2048
+
+static char	echo_rcv_buf[BUF_SIZE];
+static T_IPV6EP	dst;
+
+#ifdef USE_UDP_CALL_BACK
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_FEVR)) >= 0) {
+		echo_rcv_buf[len] = '\0';
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u UCB] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp6_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES6:%02u UCB] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, len);
+			else
+				syslog(LOG_NOTICE, "[UES6:%02u UCB] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		len = E_OK;
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u UCB] recv:  %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len;
+	}
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_NON_BLOCKING
+
+/*
+ *  å¤æ°
+ */
+
+static ER_UINT		nblk_len;
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã®ã³ã¼ã«ããã¯é¢æ°
+ */
+
+ER
+callback_nblk_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk)
+{
+	SYSTIM	now;
+
+	get_tim(&now);
+	nblk_len = *(ER_UINT*)p_parblk;
+	if (nblk_len < 0) {	/* 0 ä»¥ä¸ã®å ´åã¯ãã¨ã©ã¼ã³ã¼ã */
+		syslog(LOG_NOTICE, "[UES6:%02u CBR] error: %7lu,%s, fncd: %s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(nblk_len), in_strtfn(fncd));
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {
+		echo_rcv_buf[nblk_len] = '\0';
+		syslog(LOG_NOTICE, "[UES6:%02u CBR] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		}
+	syscall(wup_tsk(UDP6_ECHO_SRV_TASK));
+	return E_OK;
+	}
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp6_echo_srv (ID cepid)
+{
+	ER	error;
+	SYSTIM	now;
+
+	if ((error = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), TMO_NBLK)) != E_WBLK) {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] error: %7lu,%s", cepid, now / SYSTIM_HZ, itron_strerror(error));
+		return error;
+		}
+
+	syscall(slp_tsk());
+	if (nblk_len < 0)
+		error = nblk_len;
+	else {
+		if ((error = udp6_snd_dat(cepid, &dst, echo_rcv_buf, nblk_len, TMO_NBLK)) != E_WBLK) {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES6:%02u SND] error  %7lu,%s",
+			                   cepid, now / SYSTIM_HZ, itron_strerror(error));
+			return error;
+			}
+
+		syscall(slp_tsk());
+		if (nblk_len < 0)
+			error = nblk_len;
+		else {
+			get_tim(&now);
+			syslog(LOG_NOTICE, "[UES6:%02u SND] send:  %7lu, len: %d",
+			                   cepid, now / SYSTIM_HZ, nblk_len);
+			error = E_OK;
+			}
+		}
+
+	return error;
+	}
+
+#else	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ã
+ */
+
+ER
+udp6_echo_srv (ID cepid)
+{
+	ER_UINT	len;
+	SYSTIM	now;
+
+	if ((len = udp6_rcv_dat(cepid, &dst, echo_rcv_buf, sizeof(echo_rcv_buf), RCV_TMOUT)) >= 0) {
+		get_tim(&now);
+		echo_rcv_buf[len] = '\0';
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] recv:  %7lu,from: %s.%d\n"
+		                   "                              msg: %s",
+		                   cepid, now / SYSTIM_HZ, ipv62str(NULL, &dst.ipaddr), dst.portno, echo_rcv_buf);
+		if (len > 0) {
+			len = udp6_snd_dat(cepid, &dst, echo_rcv_buf, len, TMO_FEVR);
+			get_tim(&now);
+			if (len >= 0)
+				syslog(LOG_NOTICE, "[UES6:%02u SND] send:  %7lu, len: %d",
+				                   cepid, now / SYSTIM_HZ, (uint16_t)len);
+			else
+				syslog(LOG_NOTICE, "[UES6:%02u SND] error: %7lu,%s",
+				                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+			}
+		}
+	else {
+		get_tim(&now);
+		syslog(LOG_NOTICE, "[UES6:%02u RCV] error: %7lu,%s",
+		                   cepid, now / SYSTIM_HZ, itron_strerror(len));
+		}
+
+	return len >= 0 || len == E_TMOUT ? E_OK : len;
+	}
+
+#endif	/* of #ifdef USE_UDP_NON_BLOCKING */
+
+/*
+ *  UDP ECHO ãµã¼ãã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+void
+udp6_echo_srv_task (intptr_t exinf)
+{
+	ID		tskid, cepid;
+	ER		error;
+	T_UDP6_CCEP	ccep;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO SRV(EXT):%d] started.", tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		syslog(LOG_NOTICE, "[UDP6 ECHO SRV(EXT):%d] wake up.", tskid);
+
+		ccep.cepatr = UINT_C(0);
+		ccep.myaddr.portno = UINT_C(7);
+		memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#ifdef USE_UDP_NON_BLOCKING
+		ccep.callback = (FP)callback_nblk_udp6_echo_srv;
+#else
+		ccep.callback = NULL;
+#endif
+
+		if ((error = alloc_udp6_cep(&cepid, tskid, &ccep)) != E_OK) {
+			syslog(LOG_NOTICE, "[UES6:%02u TSK] CEP create error:%s", cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (error == E_OK) {
+			if ((error = udp6_echo_srv(cepid)) != E_OK) {
+				if ((error = free_udp6_cep(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+					syslog(LOG_NOTICE, "[UES6:%02u TSK] CEP delete error:%s", cepid, itron_strerror(error));
+				break;
+				}
+			}
+
+		}
+	slp_tsk();
+	}
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+void
+udp6_echo_srv_task (intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP6 ECHO SRV:%d,%d] started.", tskid, (ID)exinf);
+	while (error == E_OK) {
+		error = udp6_echo_srv((ID)exinf);
+		}
+	slp_tsk();
+	}
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.cfg	(revision 317)
@@ -0,0 +1,88 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ECHO ãµã¼ãã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ *
+ *    IPv6
+ */
+
+#ifdef USE_UDP6_ECHO_SRV_TSK
+
+/*
+ * ã¿ã¹ã¯
+ */
+
+#ifdef USE_UDP_CALL_BACK
+
+#else	/* of #ifdef USE_UDP_CALL_BACK */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP6_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	0,
+	udp6_echo_srv_task,
+	UDP6_ECHO_SRV_MAIN_PRIORITY,
+	UDP6_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP6_ECHO_SRV_TASK, {
+	TA_HLNG | TA_ACT,
+	UDP6_ECHO_SRV_CEPID,
+	udp6_echo_srv_task,
+	UDP6_ECHO_SRV_MAIN_PRIORITY,
+	UDP6_ECHO_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_UDP_CALL_BACK */
+
+#endif	/* of #ifdef USE_UDP6_ECHO_SRV_TSK */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp6_echo_srv.h	(revision 317)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP6_ECHO_SRV_H_
+#define _UDP6_ECHO_SRV_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP6_ECHO_SRV_STACK_SIZE	1024		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPv6ï¼ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+
+/* åªå
+åº¦ */
+
+#define UDP6_ECHO_SRV_MAIN_PRIORITY	5		/* UDP ECHO ãµã¼ãã¿ã¹ã¯ï¼IPv6ï¼ã®åªå
+åº¦			*/
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp6_echo_srv_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp6_echo_srv (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP6_ECHO_SRV_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.c	(revision 317)
@@ -0,0 +1,251 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  UDP DISCARD ã¯ã©ã¤ã¢ã³ã
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/udp.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/udp_discard_cli.h>
+
+#ifdef USE_UDP_DISCARD_CLI
+
+/* discard ãµã¼ãã®ãã¼ãçªå· */
+
+#define DISCARD_SRV_PORTNO	UINT_C(9)
+
+/*
+ * å¤æ°
+ */
+
+#define PAT_BEGIN	' '
+#define PAT_END		'~'
+
+#if defined(SUPPORT_INET6)
+#define API_PROTO		'6'
+#else
+#define API_PROTO		'4'
+#endif
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+bool_t udp_discard_cli_valid;
+
+/*
+ *  send_udp_discard -- DISCARD/UDP ãµã¼ãã«ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+static ER
+send_udp_discard (ID cepid, T_IN_ADDR *ipaddr, uint16_t portno)
+{
+#if defined(SUPPORT_INET6)
+	static char smsg[IPV6_MMTU - (IP6_HDR_SIZE + UDP_HDR_SIZE)];
+#else
+	static char smsg[IP4_MSS - (IP4_HDR_SIZE + UDP_HDR_SIZE)];
+#endif
+
+	T_IPEP		dst;
+	ER_UINT		len;
+	SYSTIM		time;
+	char		*p;
+	uint32_t	total;
+	uint16_t	pat, slen, scount;
+
+	dst.ipaddr = *ipaddr;
+	dst.portno = portno;
+
+	p = smsg;
+	for (slen = sizeof(smsg); slen > 0; )
+		for (pat = PAT_BEGIN; slen > 0 && pat <= PAT_END; pat ++, slen --)
+			*p ++ = pat;
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, to:   %s.%d",
+	                   API_PROTO, cepid, time / SYSTIM_HZ, IP2STR(NULL, &dst.ipaddr), dst.portno);
+
+	scount = total = 0;
+	udp_discard_cli_valid = true;
+	for (slen = sizeof(smsg); udp_discard_cli_valid && slen > 0; slen --) {
+		scount ++;
+		if ((len = UDP_SND_DAT(cepid, &dst, smsg, slen, TMO_FEVR)) < 0) {
+			syslog(LOG_NOTICE, "[UDC%c:%02u SND] error: %s", API_PROTO, cepid, itron_strerror(len));
+			return len;
+			}
+		else
+			syslog(LOG_NOTICE, "[UDC%c:%02u SND] send:  %7lu, %4u", API_PROTO, cepid, scount, slen);
+		total += len;
+		dly_tsk(10 * SYSTIM_HZ + netapp_rand() % (10 * SYSTIM_HZ));
+		}
+
+	get_tim(&time);
+	syslog(LOG_NOTICE, "[UDC%c:%02u SND] finsh: %7lu, snd: %4u,            len: %ld",
+		           API_PROTO, cepid, time / SYSTIM_HZ, scount, total);
+	return E_OK;
+	}
+
+/*
+ *  UDP DISCARD ã¯ã©ã¤ã¢ã³ãéä¿¡ã¿ã¹ã¯
+ */
+
+void
+udp_discard_cli_task (intptr_t exinf)
+{
+	T_IN_ADDR	addr;
+	ID		tskid, cepid;
+	ER		error;
+	char		*line;
+	int_t		no;
+	uint16_t	portno;
+	char		apip;
+
+#ifdef USE_UDP_EXTENTIONS
+
+#if defined(SUPPORT_INET6)
+	T_UDP6_CCEP	ccep;
+#else
+	T_UDP_CCEP	ccep;
+#endif
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+#if defined(SUPPORT_INET6)
+	apip = API_PROTO_IPV6;
+#else
+	apip = API_PROTO_IPV4;
+#endif
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP DISCARD CLI:%d,%d] started.", tskid, (ID)exinf);
+	while (true) {
+		if (rcv_dtq(DTQ_UDP_DISCARD_CLI, (intptr_t*)&line) == E_OK) {
+			line = skip_blanks(GET_IPADDR(&addr, skip_blanks(line)));	/* IP Address */
+
+			if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] unknown host.", (ID)exinf);
+				continue;
+				}
+
+			if ('0' <= *line && *line <= '9') {				/* Port No */
+				line = get_int(&no, line);
+				portno = (uint16_t)no;
+				}
+			else {
+				line ++;
+				portno = DISCARD_SRV_PORTNO;
+				}
+
+#ifdef USE_UDP_EXTENTIONS
+
+			ccep.cepatr = UINT_C(0);
+			ccep.callback = NULL;
+			ccep.myaddr.portno = UDP_PORTANY;
+
+#if defined(SUPPORT_INET6)
+
+			memcpy(&ccep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+			ccep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+			if ((error = ALLOC_UDP_CEP(&cepid, tskid, &ccep)) != E_OK) {
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP create error: %s", API_PROTO, cepid, itron_strerror(error));
+				continue;
+				}
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+			cepid = (ID)exinf;
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+			if ((error = send_udp_discard(cepid, &addr, portno)) != E_OK)
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] error: %s", API_PROTO, cepid, itron_strerror(error));
+
+#ifdef USE_UDP_EXTENTIONS
+
+			if ((error = FREE_UDP_CEP(cepid, !(error == E_NOEXS || error == E_DLT))) != E_OK)
+				syslog(LOG_NOTICE, "[UDC%c:%02u TSK] CEP delete error: %s", API_PROTO, cepid, itron_strerror(error));
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+			}
+		}
+	}
+
+#endif	/* of #ifdef USE_UDP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.cfg	(revision 317)
@@ -0,0 +1,83 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP DISCARD ã¯ã©ã¤ã¢ã³ã
+ *  ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_UDP_DISCARD_CLI
+
+/* ã¿ã¹ã¯ */
+
+#ifdef USE_UDP_EXTENTIONS
+
+CRE_TSK(UDP_DISCARD_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	0,
+	udp_discard_cli_task,
+	UDP_DISCARD_CLI_MAIN_PRIORITY,
+	UDP_DISCARD_CLI_STACK_SIZE,
+	NULL
+	});
+
+#else	/* of #ifdef USE_UDP_EXTENTIONS */
+
+CRE_TSK(UDP_DISCARD_CLI_TASK, {
+	TA_HLNG|TA_ACT,
+	UDP_DISCARD_CLI_CEPID,
+	udp_discard_cli_task,
+	UDP_DISCARD_CLI_MAIN_PRIORITY,
+	UDP_DISCARD_CLI_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_UDP_EXTENTIONS */
+
+/* ã³ãã³ãã­ã¥ã¼ */
+
+CRE_DTQ(DTQ_UDP_DISCARD_CLI,  { TA_TFIFO, 1, NULL });
+
+#endif	/* of #ifdef USE_UDP_DISCARD_CLI */
Index: asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/udp_discard_cli.h	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _UDP_DISCARD_CLI_H_
+#define _UDP_DISCARD_CLI_H_
+
+/* ã¹ã¿ãã¯ãµã¤ãº */
+
+#define UDP_DISCARD_CLI_STACK_SIZE	1024		/* UDP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+
+/* åªå
+åº¦ */
+
+#define UDP_DISCARD_CLI_MAIN_PRIORITY	5		/* UDP DISCARD ã¯ã©ã¤ã¢ã³ãã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/* å¤æ° */
+
+extern bool_t	udp_discard_cli_valid;
+
+/* ã¿ã¹ã¯ */
+
+extern void	udp_discard_cli_task(intptr_t exinf);
+
+/* é¢æ° */
+
+extern ER callback_udp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+extern ER callback_nblk_udp_discard_cli (ID cepid, FN fncd, void *p_parblk);
+
+#endif	/* of #ifndef _UDP_DISCARD_CLI_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/wwws.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/wwws.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/wwws.c	(revision 317)
@@ -0,0 +1,2067 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/* 
+ *  WWW ãµã¼ã
+ *
+ *    ã»éåä¿¡ã¿ã¹ã¯åä¸å
+ *    ã»ãã³ãã­ãã­ã³ã°ã³ã¼ã«
+ *    ã»çã³ãã¼ API
+ *    ã»IPv4/IPv6
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel/kernel_impl.h"
+#include "target_config.h"
+#include "target_syssvc.h"
+#include "target_stddef.h"
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_itron.h>
+
+#include <netapp/netapp.h>
+#include <netapp/netapp_var.h>
+#include <netapp/wwws.h>
+
+#ifdef USE_WWW_SRV
+
+/*
+ *  éåä¿¡ API ã®é¸æ
+ */
+
+#define EOF		(-1)
+
+typedef struct file {
+	ER		(*func)(ID cepid, T_WWW_RWBUF *srbuf);
+	char		*uri;
+	} T_FILE;
+
+typedef struct status {
+	uint16_t	code;
+	uint8_t		*reason;
+	} T_STATUS;
+
+/*
+ *  é¢æ°
+ */
+
+static ER index_html(ID cepid, T_WWW_RWBUF *srbuf);
+
+#if NET_COUNT_ENABLE
+
+static ER stat_html(ID cepid, T_WWW_RWBUF *srbuf);
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+#ifdef USE_TCP_EXTENTIONS
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+#if NUM_WWW_SRV_TASKS >= 2		/* 2 ãè¶
+ããåæ°ã¯æ³å®ãã¦ããªãã	*/
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK2
+
+#else	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK1
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#define WWW4_SRV_TASK	WWW_SRV_TASK1
+#define WWW6_SRV_TASK	WWW_SRV_TASK1
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifndef TCP_CFG_SWBUF_CSAVE
+uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE];
+#endif
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE];
+#endif
+
+/*
+ *  å¤æ°
+ */
+
+SYSTIM	srv_start;
+
+static const T_FILE file[] = {
+	{ index_html,	"/"		},
+	{ index_html,	"/index.html"	},
+
+#if NET_COUNT_ENABLE
+
+	{ stat_html,	"/stat.html"	},
+
+#endif	/* of #if NET_COUNT_ENABLE */
+	};
+
+#define NUM_FILES	(sizeof(file) / sizeof(T_FILE))
+
+static const char *status[] = {
+	"200 OK",
+	"404 Not Found",
+	};
+
+#define NUM_STATUS	(sizeof(status) / sizeof(T_STATUS))
+
+#define ST_OK		0
+#define ST_NOT_FOUND	1
+
+/*
+ *  æ¥ç¶ç¸æã®æ
+å ±æ§é ä½
+ */
+
+#ifdef  NUM_WWW4_SRV_TASKS
+#undef  NUM_WWW4_SRV_TASKS
+#endif
+#define NUM_WWW4_SRV_TASKS		1
+
+typedef struct t_www_srv_info {
+	ID	cepid;		/* éä¿¡ç«¯ç¹ ID		*/
+	ID	repid;		/* åä»å£   ID		*/
+	T_IPEP	dst;		/* æ¥ç¶ç¸æã¢ãã¬ã¹æ
+å ±	*/
+	} T_WWW_SRV_INFO;
+
+#define INDEX_SRV_INFO(id)	((id)-1)
+
+#ifdef USE_TCP_EXTENTIONS
+
+static T_WWW_SRV_INFO www_srv_info[NUM_WWW_SRV_TASKS];
+					/* 2 ãè¶
+ããåæ°ã¯æ³å®ãã¦ããªãã	*/
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+static T_WWW_SRV_INFO www_srv_info[] = {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	{ WWW4_SRV_CEPID1, WWW4_SRV_REPID },
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	{ WWW_SRV_CEPID1, WWW_SRV_REPID },
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+#if NUM_WWW_SRV_TASKS >= 2		/* 2 ãè¶
+ããåæ°ã¯æ³å®ãã¦ããªãã	*/
+	{ WWW_SRV_CEPID2, WWW_SRV_REPID },
+#endif
+
+	};
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#ifdef USE_COPYSAVE_API
+
+/*
+ *  get_char -- ä¸æå­å
+¥åããã
+ */
+
+static int_t
+get_char (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	int_t	len, ch;
+	ER	error;
+
+	if (srbuf->unget) {
+		ch = srbuf->unget;
+		srbuf->unget = 0;
+		}
+	else  {
+		if (srbuf->rbuf.index >= srbuf->rbuf.len) {
+			if ((error = tcp_rel_buf(cepid, srbuf->rbuf.len)) != E_OK)
+				syslog(LOG_WARNING, "[WWWn:%02u REL] tcp_rel_buf error: %s",
+				       cepid, itron_strerror(error));
+			srbuf->rbuf.index = 0;
+			if ((len = tcp_rcv_buf(cepid, (void**)&srbuf->rbuf.buf, TMO_FEVR)) <= 0) {
+				if (len < 0)
+					syslog(LOG_WARNING, "[WWWn:%02u RCV] tcp_rcv_buf error: %s",
+					       cepid, itron_strerror(len));
+				srbuf->rbuf.len = 0;
+				return EOF;
+				}
+			else
+				srbuf->rbuf.len = len;
+			}
+		ch = srbuf->rbuf.buf[srbuf->rbuf.index ++];
+		}
+	return ch;
+	}
+
+/*
+ *  flush_sbuf -- éä¿¡ãããã¡ããã©ãã·ã¥ããã
+ */
+
+static ER
+flush_sbuf (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	ER_UINT	error;
+
+	error = tcp_snd_buf(cepid, srbuf->sbuf.index);
+	srbuf->sbuf.index = srbuf->sbuf.len = 0;
+
+	return error;
+	}
+
+/*
+ *  put_str -- æå­åãåºåããã
+ */
+
+static uint_t
+put_str (ID cepid, T_WWW_RWBUF *srbuf, const char *str)
+{
+	ER		error;
+	ER_UINT		blen;
+	uint16_t	len, off = 0;
+
+	len = strlen(str);
+	while (len > 0) {
+		if (srbuf->sbuf.index >= srbuf->sbuf.len)
+			if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
+				syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
+			return 0;
+			}
+
+		if (srbuf->sbuf.len == 0) {
+			if ((blen = tcp_get_buf(cepid, (void**)&srbuf->sbuf.buf, TMO_FEVR)) < 0) {
+				syslog(LOG_WARNING, "[WWWn:%02u GET] error: %s", cepid, itron_strerror(srbuf->sbuf.len));
+				return 0;
+				}
+			srbuf->sbuf.len = (uint16_t)blen;
+			}
+
+		if (len > srbuf->sbuf.len - srbuf->sbuf.index)
+			blen = srbuf->sbuf.len - srbuf->sbuf.index;
+		else
+			blen = len;
+		memcpy(&srbuf->sbuf.buf[srbuf->sbuf.index], str + off, blen);
+		srbuf->sbuf.index += (uint16_t)blen;
+		off               += (uint16_t)blen;
+		len               -= (uint16_t)blen;
+		}
+
+	return off;
+	}
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+/*
+ *  get_char -- ä¸æå­å
+¥åããã
+ */
+
+static int_t
+get_char (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	int_t	len, ch;
+
+	if (srbuf->unget) {
+		ch = srbuf->unget;
+		srbuf->unget = 0;
+		}
+	else  {
+		if (srbuf->rbuf.index >= srbuf->rbuf.len) {
+			if ((len = tcp_rcv_dat(cepid, srbuf->rbuf.buf, sizeof(srbuf->rbuf.buf), TMO_FEVR)) <= 0) {
+				if (len < 0) {
+					syslog(LOG_WARNING, "[WWWn:%02u RCV] error: %s",
+					       cepid, itron_strerror(len));
+					}
+				return EOF;
+				}
+			else {
+				srbuf->rbuf.len   = len;
+				srbuf->rbuf.index = 0;
+				}
+			}
+		ch = srbuf->rbuf.buf[srbuf->rbuf.index ++];
+		}
+	return ch;
+	}
+
+/*
+ *  flush_sbuf -- éä¿¡ãããã¡ããã©ãã·ã¥ããã
+ */
+
+static ER
+flush_sbuf (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	ER_UINT		len = E_OK;
+	uint16_t	off = 0;
+
+	while (off < srbuf->sbuf.index) {
+		if ((len = tcp_snd_dat(cepid, srbuf->sbuf.buf + off, srbuf->sbuf.index - off, TMO_FEVR)) < 0)
+			break;
+		off += len;
+		}
+	srbuf->sbuf.index = 0;
+
+	return len < 0 ? len : E_OK;
+	}
+
+/*
+ *  put_str -- æå­åãåºåããã
+ */
+
+static uint16_t
+put_str (ID cepid, T_WWW_RWBUF *srbuf, const char *str)
+{
+	ER		error;
+	uint16_t	blen, len, off = 0;
+
+	len = strlen(str);
+	while (len > 0) {
+		if (srbuf->sbuf.index >= srbuf->sbuf.len)
+			if ((error = flush_sbuf(cepid, srbuf)) != E_OK) {
+				syslog(LOG_WARNING, "[WWWn:%02u SND] error: %s", cepid, itron_strerror(error));
+			return 0;
+			}
+		if (len > srbuf->sbuf.len - srbuf->sbuf.index)
+			blen = srbuf->sbuf.len - srbuf->sbuf.index;
+		else
+			blen = len;
+		memcpy(&srbuf->sbuf.buf[srbuf->sbuf.index], str + off, blen);
+		srbuf->sbuf.index += blen;
+		off               += blen;
+		len               -= blen;
+		}
+
+	return off;
+	}
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+/*
+ *  get_line -- ä¸è¡å
+¥åããã
+ */
+
+static uint16_t
+get_line (ID cepid, T_WWW_LINE *line, T_WWW_RWBUF *srbuf)
+{
+	int_t		ch = 0;
+	uint16_t	len;
+	char		*p, *t;
+
+	p = line->buf;
+	t = line->buf + WWW_LINE_SIZE;
+	while (p < t && (ch = get_char(cepid, srbuf)) != EOF && ch != '\n' && ch != '\r')
+		*p ++ = ch;
+	*p = '\0';
+	len = p - line->buf;
+	if (p >= t) {
+		while ((ch = get_char(cepid, srbuf)) != EOF && ch != '\n' && ch != '\r')
+			len ++;
+		}
+	if (ch == '\r') {
+		len ++;
+		if ((ch = get_char(cepid, srbuf)) != EOF && ch != '\n')
+			srbuf->unget = ch;
+		}
+	if (ch == '\n')
+		len ++;
+	line->len = len;
+	return p - line->buf;
+	}
+
+#if NET_COUNT_ENABLE
+
+#ifdef _int64_
+#define VAL_TYPE	uint64_t
+#else
+#define VAL_TYPE	uint32_t
+#endif
+
+/*
+ *  convert -- æ°å¤å¤æ
+ */
+
+static int_t
+convert (char *buf, VAL_TYPE val, int_t radix, int_t width, bool_t minus, char padchar)
+{
+	static const char radhex[] = "0123456789abcdef";
+
+	char	digits[23], *start;
+	int_t	ix, pad;
+
+	ix = 0;
+	start = buf;
+	do {
+		digits[ix ++] = radhex[val % radix];
+		val /= radix;
+		} while (val != 0);
+	if (minus)
+		digits[ix ++] = '-';
+	for (pad = ix; pad < width; pad ++)
+		*buf ++ = padchar;
+	while (ix -- > 0)
+		*buf ++ = digits[ix];
+	*buf = '\0';
+	return buf - start;
+	}
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+/*
+ * split_fields -- ãã£ã¼ã«ãã«åå²ããã
+ */
+
+static void
+split_fields (T_WWW_LINE *line, char *delim)
+{
+	char	*p, quote;
+	int_t	ix = 0;
+
+	line->off[ix ++] = 0;
+	for (p = line->buf; ix < WWW_NUM_FIELDS && *p; p ++) {
+		if (strchr("\"'`", *p) != NULL) {
+			for (quote = *p ++; *p && *p != quote; p ++)
+				;
+			}
+		else if (strchr(delim, *p) != NULL) {
+			*p = '\0';
+			line->off[ix ++] = (uint8_t)(p - line->buf + 1);
+			}
+		}
+	line->num = ix;
+	}
+
+/*
+ *  put_status -- status line ãåºåããã
+ */
+
+static uint16_t
+put_status (ID cepid, T_WWW_RWBUF *srbuf, int_t index)
+{
+	uint16_t	len = 0;
+
+	len += put_str(cepid, srbuf, "HTTP/1.0 ");
+	len += put_str(cepid, srbuf, status[index]);
+	len += put_str(cepid, srbuf, "\r\n");
+	return len;
+	}
+
+/*
+ *  put_content_length -- Content-length ãåºåããã
+ */
+
+static uint16_t
+put_content_length (ID cepid, T_WWW_RWBUF *srbuf, int_t content_len)
+{
+	uint16_t	len = 0;
+#if 0
+	char		length[TD_DIGITS + 1];
+
+	convert(length, content_len, 10, 0, false, ' ');
+	len += put_str(cepid, srbuf, "Content-length: ");
+	len += put_str(cepid, srbuf, length);
+	len += put_str(cepid, srbuf, "\r\n");
+#endif	/* of #if 0 */
+	return len;
+	}
+
+/*
+ *  get_method -- GET ã¡ã½ããã®å¦ç
+ */
+
+static ER
+get_method (ID cepid, T_WWW_RWBUF *srbuf, T_WWW_LINE *line)
+{
+	int_t	ix;
+
+	for (ix = NUM_FILES; ix -- > 0; ) {
+		if (!strcmp(file[ix].uri, &line->buf[line->off[1]])) {
+			//syslog(LOG_NOTICE, "[WWWn:%02u PTH] '%s'", cepid, &line->buf[line->off[1]]);
+			return (*file[ix].func)(cepid, srbuf);
+			}
+		}
+	put_status(cepid, srbuf, ST_NOT_FOUND);
+	return E_NOEXS;
+	}
+
+/*
+ *  parse_request -- ãªã¯ã¨ã¹ããè§£æããã
+ */
+
+static ER
+parse_request (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	T_WWW_LINE	*method, *line;
+	ER		error = E_OK;
+	int_t		blen = 0;
+
+	if ((error = tget_mpf(MPF_WWW_LINE, (void*)&method, TMO_FEVR)) != E_OK) {
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get line error: %s.",
+		       cepid, itron_strerror(error));
+		return error;
+		}
+
+	if (get_line(cepid, method, srbuf) == 0) {
+		if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
+			       cepid, itron_strerror(error));
+		return error;
+		}
+
+	if ((error = tget_mpf(MPF_WWW_LINE, (void*)&line, TMO_FEVR)) != E_OK) {
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get line buffer error: %s.",
+		       cepid, itron_strerror(error));
+		if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
+			       cepid, itron_strerror(error));
+		return error;
+		}
+
+	while (get_line(cepid, line, srbuf) > 0) {	/* ããããã¹ã­ããããã*/
+		split_fields(line, ": ");
+		if (strcmp("Content-Length", &line->buf[line->off[0]]) == 0)
+			blen = atoi(&line->buf[line->off[1]]);
+		}
+	while (blen > 0 && get_line(cepid, line, srbuf) > 0) {
+		/* ã¨ã³ãã£ãã£ã»ããã£ãã¹ã­ããããã*/
+		blen -= line->len;
+		}
+
+	if ((error = rel_mpf(MPF_WWW_LINE, line)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
+		       cepid, itron_strerror(error));
+	
+	split_fields(method, ": ");
+	if (!strcmp(&method->buf[method->off[0]], "GET"))
+		error = get_method(cepid, srbuf, method);
+
+	flush_sbuf(cepid, srbuf);
+
+	if ((error = rel_mpf(MPF_WWW_LINE, method)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u MPF] release line buffer error: %s.",
+		       cepid, itron_strerror(error));
+
+	return error;
+	}
+
+/*
+ *  index_html -- /index.html ãã¡ã¤ã«
+ */
+
+static ER
+index_html (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	static const char response[] =
+		"\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD html 3.2//EN\">\r\n"
+		"<html><head>\r\n"
+
+#ifdef TOPPERS_S810_CLG3_85
+		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\">\r\n"
+#else
+		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">\r\n"
+#endif
+
+		"<title>TINET TCP/IP Protocol Stack</title>\r\n"
+		"</head><body bgcolor=\"#ffffbb\">\r\n"
+		"<hr>ãã® WWW ãµã¼ãã¯<br>"
+
+#ifdef TARGET_KERNEL_ASP
+		"ASP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") ã¨<br>\r\n"
+#endif
+
+#ifdef TARGET_KERNEL_JSP
+		"JSP Kernel for " TARGET_NAME " (" __DATE__ "," __TIME__ ") ã¨<br>\r\n"
+#endif
+
+		"TINET TCP/IP ãã­ãã³ã«ã¹ã¿ãã¯ã«ãããµã¼ãã¹ãã¦ãã¾ãã<br><hr>\r\n"
+
+#if NET_COUNT_ENABLE
+
+		"<ul><li type=\"square\"><a href=\"stat.html\">ãããã¯ã¼ã¯çµ±è¨æ
+å ±</a></ul><hr>\r\n"
+
+#else	/* of #if NET_COUNT_ENABLE */
+
+		"<ul><li type=\"square\">ãããã¯ã¼ã¯çµ±è¨æ
+å ±</ul><hr>\r\n"
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+		"FreeBSD: Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995<br>\r\n"
+		"The Regents of the University of California.  All rights reserved.<br><br>\r\n"
+
+#ifdef SUPPORT_PPP
+
+		"pppd: Copyright (c) 1989 Carnegie Mellon University.<br>\r\n"
+		"All rights reserved.<br><br>\r\n"
+		"ppp: Written by Toshiharu OHNO (tony-o@iij.ad.jp)<br>\r\n"
+		"Copyright (C) 1993, Internet Initiative Japan, Inc. All rights reserverd.<br><br>\r\n"
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+ 		"if_ed: Copyright (c) 1995, David Greenman<br>\r\n"
+		"All rights reserved.<br><br>\r\n"
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef TARGET_KERNEL_ASP
+		"TOPPERS/ASP Kernel<br>\r\n"
+		"Toyohashi Open Platform for Embedded Real-Time Systems/<br>\r\n"
+		"Advanced Standard Profile Kernel<br>\r\n"
+		"Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory<br>\r\n"
+		"Toyohashi Univ. of Technology, JAPAN<br>\r\n"
+		"Copyright (C) 2004-2008 by Embedded and Real-Time Systems Laboratory<br>\r\n"
+		"Graduate School of Information Science, Nagoya Univ., JAPAN<br><br>\r\n"
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+		"TOPPERS/JSP Kernel<br>\r\n"
+		"Toyohashi Open Platform for Embedded Real-Time Systems/<br>\r\n"
+		"Just Standard Profile Kernel<br>\r\n"
+		"Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory<br>\r\n"
+		"Toyohashi Univ. of Technology, JAPAN<br>\r\n"
+		"Copyright (C) 2005 by Embedded and Real-Time Systems Laboratory<br>\r\n"
+		"Graduate School of Information Science, Nagoya Univ., JAPAN<br><br>\r\n"
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+		"TINET (TCP/IP Protocol Stack)<br>\r\n"
+		"Copyright (C) 2001-2008 by Dep. of Computer Science and Engineering<br>\r\n"
+		"Tomakomai National College of Technology, JAPAN\r\n"
+		"</body></html>\r\n"
+		;
+
+	SYSTIM		start, finish;
+	uint16_t	len = 0;
+
+	get_tim(&start);
+	len += put_status(cepid, srbuf, ST_OK);
+	len += put_content_length(cepid, srbuf, strlen(response) - 2);	/* 2 ã¯æåã® \r\n */
+	len += put_str(cepid, srbuf, response);
+	get_tim(&finish);
+	syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
+	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
+	return E_OK;
+	}
+
+#if NET_COUNT_ENABLE
+
+#define TD_TEMPLATE1	"<tr><td></td><td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td>\r\n<td align=\"right\"></td></tr>\r\n"
+#define TD_TEMPLATE2	"<tr><td></td><td align=\"right\"></td><td align=\"right\"></td></tr>\r\n"
+#define TD_TEMPLATE3	"<tr><td></td><td align=\"right\"></td></tr>\r\n"
+#define TD_TEMPLATE4	"<tr><td></td><td align=\"right\"></td><td align=\"right\"></td><td align=\"right\"></td></tr>\r\n"
+
+#define TD_LEN1(i)	(sizeof(i) +  sizeof(TD_TEMPLATE1) + TD_DIGITS  * 6 - 2)
+#define TD_LEN2(i)	(sizeof(i) +  sizeof(TD_TEMPLATE2) + TD_DIGITS  * 2 - 2)
+#define TD_LEN4(i)	(sizeof(i) +  sizeof(TD_TEMPLATE4) + TD_DIGITS  * 3 - 2)
+#define TD_DIGITS	20
+
+static const char time_prefix[] =
+	"çµéæé: "
+	;
+
+static const char time_suffix[] =
+	"<hr>\r\n"
+	;
+
+static const char table_suffix[] = "</table><br><hr>";
+
+#if defined(SUPPORT_INET4)
+
+static const char table_prefix_ip4[] =
+	"<h2>IPv4</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+static const char table_prefix_ip6[] =
+	"<h2>IPv6</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+static const char table_prefix_icmp6[] =
+	"<h2>ICMPv6</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+static const char table_prefix_nd6[] =
+	"<h2>è¿é£æ¢ç´¢</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+static const char table_prefix_tcp[] =
+	"<h2>TCP</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+static const char table_prefix_net_buf[] =
+	"<h2>ãããã¯ã¼ã¯ãããã¡</h2><table border>\r\n"
+	"<tr><th>ãµã¤ãº</th>"
+	"<th>ç¨ææ°</th>"
+	"<th>å²å½è¦æ±æ°</th>"
+	"<th>å²å½æ°</th>"
+	"<th>å²å½ã¦<br>ã¨ã©ã¼æ°</th></tr>\r\n"
+	;
+
+#ifdef SUPPORT_PPP
+
+static const char table_prefix_ppp[] =
+	"<h2>PPP ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+static const char *ppp_item[NC_PPP_SIZE] = {
+	"åä¿¡ãªã¯ãããæ°",
+	"éä¿¡ãªã¯ãããæ°",
+	"åä¿¡ãã¬ã¼ã æ°",
+	"éä¿¡ãã¬ã¼ã æ°",
+	"åä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
+	"éä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
+	"ãããã¡å²ãå½ã¦å¤±ææ°",
+	};
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+static const char table_prefix_ether_nic[] =
+	"<h2>ã¤ã¼ãµãããã»ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹</h2><table border>\r\n"
+	"<tr><th>é 
+ç®</th><th>ã«ã¦ã³ã</th></tr>\r\n"
+	;
+
+static const char *ether_nic_item[NC_ETHER_NIC_SIZE] = {
+	"ãªã»ããæ°",
+	"éä¿¡ã»ããã©è³æºè¿å´ãªã¼ãã¼æ°",
+	"éä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
+	"è¡çªæ°",
+	"éä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
+	"éä¿¡ãã¬ã¼ã æ°",
+	"éä¿¡ãªã¯ãããæ°",
+	"åä¿¡ã»ããã©è³æºè¿å´ãªã¼ãã¼æ°",
+	"åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
+	"åä¿¡ã¨ã©ã¼ãã¬ã¼ã æ°",
+	"åä¿¡ãã¬ã¼ã æ°",
+	"åä¿¡ãªã¯ãããæ°",
+	};
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(SUPPORT_INET4)
+
+static const char *ip4_item[NC_IP4_SIZE] = {
+	"åå²éä¿¡ããã©ã°ã¡ã³ãæ°",
+	"åå²éä¿¡æ°",
+	"éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
+	"éä¿¡ãã¼ã¿ã°ã©ã æ°",
+	"éä¿¡ãªã¯ãããæ°",
+	"åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
+	"åå²åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
+	"åå²åä¿¡ç ´æ£æ°",
+	"åå²åä¿¡åæ§ææåæ°",
+	"åå²åä¿¡ãã©ã°ã¡ã³ãæ°",
+	"åå²åä¿¡æ°",
+	"ãªãã·ã§ã³å
+¥åæ°",
+	"ãã­ãã³ã«ã¨ã©ã¼æ°",
+	"ã¢ãã¬ã¹ã¨ã©ã¼æ°",
+	"ãã¼ã¸ã§ã³ã¨ã©ã¼æ°",
+	"é·ãã¨ã©ã¼æ°",
+	"ãã§ãã¯ãµã ã¨ã©ã¼æ°",
+	"åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
+	"åä¿¡ãã¼ã¿ã°ã©ã æ°",
+	"åä¿¡ãªã¯ãããæ°",
+	};
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+static const char *ip6_item[NC_IP6_SIZE] = {
+	"åå²éä¿¡ããã©ã°ã¡ã³ãæ°",
+	"åå²éä¿¡æ°",
+	"éä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
+	"éä¿¡ãã¼ã¿ã°ã©ã æ°",
+	"éä¿¡ãªã¯ãããæ°	",
+	"åå²åä¿¡ã¿ã¤ã ã¢ã¦ãæ°",
+	"åå²åä¿¡ãããã¡å²ãå½ã¦å¤±ææ°",
+	"åå²åä¿¡ç ´æ£æ°",
+	"åå²åä¿¡åæ§ææåæ°",
+	"åå²åä¿¡ãã©ã°ã¡ã³ãæ°",
+	"åå²åä¿¡æ°",
+	"ãã­ãã³ã«ã¨ã©ã¼æ°	",
+	"ã¢ãã¬ã¹ã¨ã©ã¼æ°	",
+	"ãã¼ã¸ã§ã³ã¨ã©ã¼æ°	",
+	"é·ãã¨ã©ã¼æ°",
+	"åä¿¡ã¨ã©ã¼ãã¼ã¿ã°ã©ã æ°",
+	"åä¿¡ãã¼ã¿ã°ã©ã æ°",
+	"åä¿¡ãªã¯ãããæ°	",
+	};
+
+static const char *icmp6_item[NC_ICMP6_SIZE] = {
+	"éä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ°	",
+	"éä¿¡ ICMP ãã¼ã¿æ°",
+	"éä¿¡ ICMP ãªã¯ãããæ°",
+	"é·ãã¨ã©ã¼æ°",
+	"åä¿¡ã¨ã©ã¼ ICMP ãã¼ã¿æ°	",
+	"åä¿¡ ICMP ãã¼ã¿æ°",
+	"åä¿¡ ICMP ãªã¯ãããæ°",
+	};
+
+static const char *nd6_item[NC_ND6_SIZE] = {
+	"éè¤ã¢ãã¬ã¹æ¤åºéä¿¡æ°",
+	"è¿é£è¦è«éä¿¡æ°",
+	"è¿é£è¦è«åä¿¡æ°",
+	"è¿é£éç¥éä¿¡æ°",
+	"è¿é£éç¥åä¿¡æ°",
+	"ã«ã¼ã¿è¦è«åºåæ°",
+	"ã«ã¼ã¿éç¥åä¿¡æ°",
+	};
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+static const char *tcp_item[NC_TCP_SIZE] = {
+	"è½åãªã¼ãã³æ°",
+	"ååãªã¼ãã³æ°",
+	"RTT æ´æ°æ°",
+	"éä¿¡ RST æ°",
+	"éä¿¡ ACK æ°",
+	"éä¿¡ç·æ¥ã»ã°ã¡ã³ãæ°",
+	"éä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°",
+	"åéã»ã°ã¡ã³ãæ°",
+	"éä¿¡ã»ã°ã¡ã³ãæ°",
+	"éä¿¡å¶å¾¡ã»ã°ã¡ã³ãæ°",
+	"éä¿¡ãã¼ã¿ãªã¯ãããæ°",
+	"åä¿¡ã­ã¥ã¼è§£æ¾æ°",
+	"åä¿¡å¤éæ°",
+	"åä¿¡ç ´æ£æ°",
+	"åä¿¡ RST æ°",
+	"åä¿¡å¤é ACK æ°",
+	"åä¿¡ ACK æ°",
+	"åä¿¡ãã§ãã¯ãµã ä¸æ­£æ°",
+	"åä¿¡ãããä¸æ­£æ°",
+	"åä¿¡ç·æ¥ã»ã°ã¡ã³ãæ°",
+	"åä¿¡ãã¼ã¿ã»ã°ã¡ã³ãæ°",
+	"åä¿¡ã»ã°ã¡ã³ãæ°",
+	"åä¿¡ãã¼ã¿ãªã¯ãããæ°",
+	"åä¿¡ãªã¯ãããæ°",
+	};
+
+/*
+ *  put_count_item1 -- ã«ã¦ã³ã¿ã®å
+å®¹ãåºåãããã°ã«ã¼ã 1
+ */
+
+static uint16_t
+put_count_item1 (ID cepid, T_WWW_RWBUF *srbuf, const char *item, T_NET_COUNT *counter)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, item);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+
+	convert(buf, counter->in_octets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
+
+	convert(buf, counter->out_octets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
+
+	convert(buf, counter->in_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
+
+	convert(buf, counter->out_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
+
+	convert(buf, counter->in_err_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td>\r\n<td align=\"right\">");
+
+	convert(buf, counter->out_err_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	return len;
+	}
+
+#ifdef SUPPORT_PPP
+
+/*
+ *  put_count_item2 -- ã«ã¦ã³ã¿ã®å
+å®¹ãåºåãããã°ã«ã¼ã 2
+ */
+
+static uint16_t
+put_count_item2 (ID cepid, T_WWW_RWBUF *srbuf, const char *item, uint32_t octets, uint32_t packets)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, item);
+	len += put_str(cepid, srbuf, "</td><td>");
+
+	convert(buf, octets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+
+	convert(buf, packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	return len;
+	}
+
+/*
+ *  td_len_ppp -- put_count_ppp ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_ppp (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_PPP_SIZE; ix -- > 0; )
+		len += strlen(ppp_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_PPP_SIZE;
+	}
+
+/*
+ *  put_count_ppp -- ã«ã¦ã³ã¿ (PPP) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_ppp (ID cepid, T_WWW_RWBUF *srbuf)
+{
+
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+
+	len += put_str(cepid, srbuf, table_prefix_ppp);
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[0]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.in_octets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[1]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.out_octets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[2]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.in_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[3]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.out_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[4]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.in_err_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[5]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp.out_err_packets, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, "<tr><td>");
+	len += put_str(cepid, srbuf, ppp_item[6]);
+	len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+	convert(buf, net_count_ppp_no_bufs, 10, TD_DIGITS, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, "</td></tr>\r\n");
+
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#if defined(SUPPORT_INET4)
+
+/*
+ *  td_len_ip4 -- put_count_ip4 ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_ip4 (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_IP4_SIZE; ix -- > 0; )
+		len += strlen(ip4_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_IP4_SIZE;
+	}
+
+/*
+ *  put_count_ip4 -- ã«ã¦ã³ã¿ (IP4) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_ip4 (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_ip4);
+	for (ix = NC_IP4_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, ip4_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_ip4[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+/*
+ *  td_len_nd6 -- put_count_nd6 ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_nd6 (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_ND6_SIZE; ix -- > 0; )
+		len += strlen(nd6_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ND6_SIZE;
+	}
+
+/*
+ *  put_count_nd6 -- ã«ã¦ã³ã¿ (ND6) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_nd6 (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_nd6);
+	for (ix = NC_ND6_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, nd6_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_nd6[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+/*
+ *  td_len_icmp6 -- put_count_icmp6 ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_icmp6 (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_ICMP6_SIZE; ix -- > 0; )
+		len += strlen(icmp6_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ICMP6_SIZE;
+	}
+
+/*
+ *  put_count_icmp6 -- ã«ã¦ã³ã¿ (ICMP6) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_icmp6 (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_icmp6);
+	for (ix = NC_ICMP6_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, icmp6_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_icmp6[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+/*
+ *  td_len_ip6 -- put_count_ip6 ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_ip6 (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_IP6_SIZE; ix -- > 0; )
+		len += strlen(ip6_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_IP6_SIZE;
+	}
+
+/*
+ *  put_count_ip6 -- ã«ã¦ã³ã¿ (IP6) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_ip6 (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_ip6);
+	for (ix = NC_IP6_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, ip6_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_ip6[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/*
+ *  td_len_tcp -- put_count_tcp ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_tcp (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_TCP_SIZE; ix -- > 0; )
+		len += strlen(tcp_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_TCP_SIZE;
+	}
+
+/*
+ *  put_count_tcp -- ã«ã¦ã³ã¿ (TCP) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_tcp (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_tcp);
+	for (ix = NC_TCP_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, tcp_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_tcp[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+/*
+ *  put_elapse_time -- çµéæéãåºåããã
+ */
+
+static uint16_t
+put_elapse_time (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	SYSTIM		now, elapse;
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+
+	get_tim(&now);
+	elapse = now - srv_start;
+
+	len += put_str(cepid, srbuf, time_prefix);
+
+	convert(buf, elapse / (60 * 60 * SYSTIM_HZ), 10, 4, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, ":");
+
+	convert(buf, (elapse / (60 * SYSTIM_HZ)) % 60, 10, 2, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+	len += put_str(cepid, srbuf, ":");
+
+	convert(buf, (elapse / SYSTIM_HZ) % 60, 10, 2, false, ' ');
+	len += put_str(cepid, srbuf, buf);
+
+	len += put_str(cepid, srbuf, time_suffix);
+
+	return len;
+	}
+
+/*
+ *  put_count_net_buf -- ã«ã¦ã³ã¿ (TCP) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_net_buf (ID cepid, T_WWW_RWBUF *srbuf)
+{
+
+	const T_NET_BUF_ENTRY	*tbl;
+	char			buf[TD_DIGITS + 1];
+	uint16_t		len = 0;
+	int_t			ix;
+
+	len += put_str(cepid, srbuf, table_prefix_net_buf);
+	tbl = nbuf_get_tbl();
+	for (ix = nbuf_get_tbl_size(); ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td align=\"right\">");
+		convert(buf, tbl[ix].size, 10, 4, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, tbl[ix].prepares, 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, tbl[ix].requests, 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, tbl[ix].allocs, 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, tbl[ix].errors, 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  td_len_ether_nic -- put_count_ether_nic ã§åºåããæå­æ°ã
+ */
+
+static uint16_t
+td_len_ether_nic (void)
+{
+	int_t		ix;
+	uint16_t	len = 0;
+
+	for (ix = NC_ETHER_NIC_SIZE; ix -- > 0; )
+		len += strlen(ether_nic_item[ix]);
+	return len + (sizeof(TD_TEMPLATE3) + TD_DIGITS - 1) * NC_ETHER_NIC_SIZE;
+	}
+
+/*
+ *  put_count_ether_nic -- ã«ã¦ã³ã¿ (ETHER_NIC) ã®å
+å®¹ãåºåããã
+ */
+
+static uint16_t
+put_count_ether_nic (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	char		buf[TD_DIGITS + 1];
+	uint16_t	len = 0;
+	int_t		ix;
+
+	len += put_str(cepid, srbuf, table_prefix_ether_nic);
+	for (ix = NC_ETHER_NIC_SIZE; ix -- > 0; ) {
+		len += put_str(cepid, srbuf, "<tr><td>");
+		len += put_str(cepid, srbuf, ether_nic_item[ix]);
+		len += put_str(cepid, srbuf, "</td><td align=\"right\">");
+		convert(buf, net_count_ether_nic[ix], 10, TD_DIGITS, false, ' ');
+		len += put_str(cepid, srbuf, buf);
+		len += put_str(cepid, srbuf, "</td></tr>\r\n");
+		}
+	len += put_str(cepid, srbuf, table_suffix);
+
+	return len;
+	}
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  stat_html -- /stat.html ãã¡ã¤ã«
+ */
+
+static ER
+stat_html (ID cepid, T_WWW_RWBUF *srbuf)
+{
+	static const char res_prefix[] =
+		"\r\n<!DOCTYPE html PUBLIC \"-//W3C//DTD html 3.2//EN\">\r\n"
+		"<html><head>\r\n"
+
+#ifdef TOPPERS_S810_CLG3_85
+		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=Shift_JIS\">\r\n"
+#else
+		"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=EUC-JP\">\r\n"
+#endif
+
+		"<title>ãããã¯ã¼ã¯çµ±è¨æ
+å ±</title>\r\n"
+		"</head><body bgcolor=\"#ffffbb\">\r\n"
+		"<hr><h1 align=\"center\">ãããã¯ã¼ã¯çµ±è¨æ
+å ±</h1><hr>\r\n"
+		;
+
+	static const char res_suffix[] =
+		"</body></html>\r\n"
+		;
+
+	static const char table_prefix1[] =
+		"<h2>ã°ã«ã¼ã 1</h2><table border>\r\n"
+		"<tr><th>é 
+ç®</th>\r\n"
+		"<th>åä¿¡ãªã¯ãããæ°</th>"
+		"<th>éä¿¡ãªã¯ãããæ°</th>\r\n"
+		"<th>åä¿¡ãã±ããæ°</th>"
+		"<th>éä¿¡ãã±ããæ°</th>\r\n"
+		"<th>åä¿¡ã¨ã©ã¼<br>ãã±ããæ°</th>"
+		"<th>éä¿¡ã¨ã©ã¼<br>ãã±ããæ°</th></tr>\r\n"
+		;
+
+#ifdef SUPPORT_PPP
+
+	static const char table_prefix2[] =
+		"<h2>ã°ã«ã¼ã 2</h2><table border>\r\n"
+		"<tr><th>é 
+ç®</th>"
+		"<th>åä¿¡ãªã¯ãããæ°</th>"
+		"<th>åä¿¡ãã¬ã¼ã æ°</th></tr>\r\n"
+		;
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+	uint16_t	content_len, len = 0;
+	SYSTIM		start, finish;
+
+	get_tim(&start);
+	content_len = 0
+
+#ifdef SUPPORT_PPP
+
+	    + TD_LEN1("HDLC")
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_PPP
+
+	    + td_len_ppp()
+	    + TD_LEN2("LCP")
+	    + TD_LEN2("IPCP")
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+	    + TD_LEN1("ARP")
+	    + td_len_ether_nic()
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	    + TD_LEN1("ICMP")
+	    + TD_LEN1("UDP")
+
+#if defined(SUPPORT_INET4)
+
+	    + td_len_ip4()
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+	    + td_len_ip6()
+	    + td_len_nd6()
+	    + td_len_icmp6()
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	    + td_len_tcp()
+	    + TD_LEN4("0123") * nbuf_get_tbl_size();
+	    ;
+
+	len += put_status(cepid, srbuf, ST_OK);
+	len += put_content_length(cepid, srbuf, strlen(res_prefix) 
+	                        + strlen(res_suffix)
+	                        + strlen(time_prefix)
+	                        + strlen("1234:12:12")
+	                        + strlen(time_suffix)
+	                        + strlen(table_prefix1)
+	                        + strlen(table_prefix_net_buf)
+
+#if defined(SUPPORT_INET4)
+
+	                        + strlen(table_prefix_ip4)
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+	                        + strlen(table_prefix_ip6)
+	                        + strlen(table_prefix_nd6)
+	                        + strlen(table_prefix_icmp6)
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+	                        + strlen(table_prefix_tcp)
+	                        + strlen(table_suffix) * 3
+
+#ifdef SUPPORT_PPP
+	                        + strlen(table_prefix2)
+	                        + strlen(table_prefix_ppp)
+	                        + strlen(table_suffix) * 2
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+	                        + strlen(table_prefix_ether_nic)
+	                        + strlen(table_suffix) * 1
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+	                        + content_len
+	                        - 2);	/* 2 ã¯æåã® \r\n */
+
+	len += put_str(cepid, srbuf, res_prefix);
+	len += put_elapse_time(cepid, srbuf);
+	len += put_str(cepid, srbuf, table_prefix1);
+
+#ifdef SUPPORT_PPP
+
+	len += put_count_item1(cepid, srbuf, "HDLC", &net_count_hdlc);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+	len += put_count_item1(cepid, srbuf, "Ethernet", &net_count_ether);
+
+#if defined(SUPPORT_INET4)
+
+	len += put_count_item1(cepid, srbuf, "ARP", &net_count_arp);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(SUPPORT_INET4)
+
+	len += put_count_item1(cepid, srbuf, "ICMP", &net_count_icmp4);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#ifdef SUPPORT_UDP
+
+	len += put_count_item1(cepid, srbuf, "UDP", &net_count_udp);
+
+#endif	/* of #ifdef SUPPORT_UDP */
+
+	len += put_str(cepid, srbuf, table_suffix);
+
+#ifdef SUPPORT_PPP
+
+	len += put_str(cepid, srbuf, table_prefix2);
+	len += put_count_item2(cepid, srbuf, "LCP", 
+	                       net_count_ppp_lcp_in_octets,
+	                       net_count_ppp_lcp_in_packets);
+	len += put_count_item2(cepid, srbuf, "IPCP", 
+	                       net_count_ppp_ipcp_in_octets,
+	                       net_count_ppp_ipcp_in_packets);
+	len += put_str(cepid, srbuf, table_suffix);
+
+	len += put_count_ppp(cepid, srbuf);
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef SUPPORT_ETHER
+
+	len += put_count_ether_nic(cepid, srbuf);
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#if defined(SUPPORT_INET4)
+
+	len += put_count_ip4(cepid, srbuf);
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#if defined(SUPPORT_INET6)
+
+	len += put_count_ip6(cepid, srbuf);
+	len += put_count_nd6(cepid, srbuf);
+	len += put_count_icmp6(cepid, srbuf);
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+	len += put_count_tcp(cepid, srbuf);
+
+	len += put_count_net_buf(cepid, srbuf);
+
+	len += put_str(cepid, srbuf, res_suffix);
+
+	get_tim(&finish);
+	syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
+	                   cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
+	return E_OK;
+	}
+
+#endif	/* of #if NET_COUNT_ENABLE */
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  get_tcp_rep -- TCP åä»å£ãç²å¾ããã
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+get_tcp_rep (ID *repid)
+{
+	ID		tskid;
+	T_TCP6_CREP	crep6;
+	T_TCP_CREP	crep4;
+
+	get_tid(&tskid);
+	if (tskid == WWW4_SRV_TASK) {
+		crep4.repatr = UINT_C(0);
+		crep4.myaddr.portno = UINT_C(80);
+		crep4.myaddr.ipaddr = IPV4_ADDRANY;
+		return alloc_tcp4_rep(repid, tskid, &crep4);
+		}
+	else {
+		crep6.repatr = UINT_C(0);
+		crep6.myaddr.portno = UINT_C(80);
+		memcpy(&crep6.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+		return alloc_tcp6_rep(repid, tskid, &crep6);
+		}
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+get_tcp_rep (ID *repid)
+{
+	ID		tskid;
+	T_TCPN_CREP	crep;
+
+	get_tid(&tskid);
+
+	crep.repatr = UINT_C(0);
+	crep.myaddr.portno = UINT_C(80);
+
+#if defined(SUPPORT_INET6)
+
+	memcpy(&crep.myaddr.ipaddr, &ipv6_addrany, sizeof(T_IN6_ADDR));
+
+#else	/* #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+	crep.myaddr.ipaddr = IPV4_ADDRANY;
+#endif
+
+#endif	/* #if defined(SUPPORT_INET6) */
+
+	return ALLOC_TCP_REP(repid, tskid, &crep);
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  get_tcp_cep -- TCP éä¿¡ç«¯ç¹ãç²å¾ããã
+ */
+
+static ER
+get_tcp_cep (ID *cepid)
+{
+	ID		tskid;
+	T_TCP_CCEP	ccep;
+
+	get_tid(&tskid);
+
+	ccep.cepatr = UINT_C(0);
+	ccep.sbufsz = WWW_SRV_SWBUF_SIZE;
+	ccep.rbufsz = WWW_SRV_RWBUF_SIZE;
+	ccep.callback = NULL;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	ccep.sbuf = NADR;
+#else
+	ccep.sbuf = www_srv_swbuf[0];
+#endif
+#ifdef TCP_CFG_RWBUF_CSAVE
+	ccep.rbuf = NADR;
+#else
+	ccep.rbuf = www_srv_rwbuf[0];
+#endif
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	if (tskid == WWW4_SRV_TASK)
+		return alloc_tcp4_cep(cepid, tskid, &ccep);
+	else
+		return alloc_tcp6_cep(cepid, tskid, &ccep);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	return ALLOC_TCP_CEP(cepid, tskid, &ccep);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  tcp_passive_open -- ååãªã¼ãã³ãå®è¡ããã
+ *
+ *    USE_TCP_NON_BLOCKING	OFF
+ */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+static ER
+tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+	T_IPV4EP	dst4;
+
+	if (apip == API_PROTO_IPV6) {
+		/* åä»å£ã¯ IPv6 */
+		if ((error = tcp6_acp_cep(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+			return error;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp6_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+		}
+	else {
+		/* åä»å£ã¯ IPv4 */
+		if ((error = tcp_acp_cep(info->cepid, info->repid, &dst4, TMO_FEVR)) != E_OK)
+			return error;
+		in6_make_ipv4mapped (&info->dst.ipaddr, dst4.ipaddr);
+		info->dst.portno = dst4.portno;
+
+#ifdef USE_TCP_EXTENTIONS
+		if ((error = free_tcp4_rep(info->repid, true)) != E_OK)
+			return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+		}
+
+	return error;
+	}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+static ER
+tcp_passive_open (T_WWW_SRV_INFO *info, char apip)
+{
+	ER		error = E_OK;
+
+	if ((error = TCP_ACP_CEP(info->cepid, info->repid, &info->dst, TMO_FEVR)) != E_OK)
+		return error;
+
+#ifdef USE_TCP_EXTENTIONS
+	if ((error = FREE_TCP_REP(info->repid, true)) != E_OK)
+		return error;
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+	return error;
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+/*
+ *  WWW ãµã¼ã
+ */
+
+static ER
+www_srv (uint_t six, char apip)
+{
+	T_WWW_RWBUF	*srbuf;
+	ER		error;
+	SYSTIM		now;
+
+	if ((error = tcp_passive_open(&www_srv_info[six], apip)) != E_OK)
+		return error;
+
+	syscall(get_tim(&now));
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (apip == API_PROTO_IPV6)
+		syslog(LOG_NOTICE, "[WWW6:%02u ACP] conct:  %6lu,from: %s.%u",
+		                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ipv62str(NULL, &www_srv_info[six].dst.ipaddr),
+		                   www_srv_info[six].dst.portno);
+	else
+		syslog(LOG_NOTICE, "[WWW4:%02u ACP] conct:  %6lu,from: %s.%u",
+		                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+		                   ip2str(NULL, &www_srv_info[six].dst.ipaddr.s6_addr32[3]),
+		                   www_srv_info[six].dst.portno);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWWn:%02u ACP] conct:  %6lu,from: %s.%u",
+	                   www_srv_info[six].cepid, now / SYSTIM_HZ,
+	                   IP2STR(NULL, &www_srv_info[six].dst.ipaddr),
+	                   www_srv_info[six].dst.portno);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	if ((error = tget_mpf(MPF_WWW_RWBUF, (void*)&srbuf, TMO_FEVR)) != E_OK) {
+		syslog(LOG_CRIT, "[WWWn:%02u MPF] get buffer error: %s.",
+		                 www_srv_info[six].cepid, itron_strerror(error));
+		srbuf = NULL;
+		}
+	else {
+		srbuf->rbuf.len = srbuf->rbuf.index = srbuf->sbuf.index = srbuf->unget = 0;
+
+#ifdef USE_COPYSAVE_API
+
+		srbuf->sbuf.len = 0;
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+		srbuf->sbuf.len = sizeof(srbuf->sbuf.buf);
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+		if ((error = parse_request(www_srv_info[six].cepid, srbuf)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u RCV] parse request error: %s",
+			                    www_srv_info[six].cepid, itron_strerror(error));
+		}
+
+	if ((error = tcp_sht_cep(www_srv_info[six].cepid)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u SHD] shutdown error: %s", 
+		                    www_srv_info[six].cepid, itron_strerror(error));
+
+	if (srbuf != NULL) {
+		while (get_char(www_srv_info[six].cepid, srbuf) != EOF)
+			;
+		if (srbuf != NULL && (error = rel_mpf(MPF_WWW_RWBUF, srbuf)) != E_OK)
+			syslog(LOG_WARNING, "[WWWn:%02u REL] release buffer error: %s.",
+			                    www_srv_info[six].cepid, itron_strerror(error));
+		}
+
+	if ((error = tcp_cls_cep(www_srv_info[six].cepid, TMO_FEVR)) != E_OK)
+		syslog(LOG_WARNING, "[WWWn:%02u CLS] close error: %s",
+ 		                    www_srv_info[six].cepid, itron_strerror(error));
+
+	get_tim(&now);
+	syslog(LOG_NOTICE, "[WWWn:%02u FIN] finsh:  %6lu",
+	                   www_srv_info[six].cepid, now / SYSTIM_HZ);
+
+	return error;
+	}
+
+#ifdef USE_TCP_EXTENTIONS
+
+/*
+ *  WWW ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+www_srv_task(intptr_t exinf)
+{
+	ID	tskid;
+	ER	error = E_OK;
+	uint_t	six;
+	char	apip;
+
+	syscall(get_tid(&tskid));
+	six = INDEX_SRV_INFO((ID)exinf);
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (six >= NUM_WWW4_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	apip = API_PROTO_IPVn;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWW%c:%d] started.", apip, tskid);
+	while (true) {
+
+		syscall(slp_tsk());
+		if ((error = get_tcp_cep(&www_srv_info[six].cepid)) != E_OK) {
+			syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create CEP error: %s",
+				           apip, www_srv_info[six].cepid, itron_strerror(error));
+			continue;
+			}
+
+		while (true) {
+
+			if ((error = get_tcp_rep(&www_srv_info[six].repid)) != E_OK) {
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] create REP error: %02u, %s",
+				                   apip, www_srv_info[six].cepid, www_srv_info[six].repid, itron_strerror(error));
+				break;
+				}
+			else if ((error = www_srv(six, apip)) != E_OK) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+				if (tskid == WWW4_SRV_TASK)
+					error = free_tcp4_rep(www_srv_info[six].repid, error != E_DLT);
+				else
+					error = free_tcp6_rep(www_srv_info[six].repid, error != E_DLT);
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				error = FREE_TCP_REP(www_srv_info[six].repid, error != E_DLT);
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+				if (error != E_OK) {
+					syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete REP error: %02u, %s",
+				                           apip, www_srv_info[six].cepid,
+				                                              www_srv_info[six].repid, itron_strerror(error));
+
+					}
+				break;
+				}
+			}
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+		if (tskid == WWW4_SRV_TASK) {
+			if ((error = free_tcp4_cep(www_srv_info[six].cepid)) != E_OK)
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+					           apip, www_srv_info[six].cepid, itron_strerror(error));
+			}
+		else {
+			if ((error = free_tcp6_cep(www_srv_info[six].cepid)) != E_OK)
+				syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+					           apip, www_srv_info[six].cepid, itron_strerror(error));
+			}
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		if ((error = FREE_TCP_CEP(www_srv_info[six].cepid)) != E_OK)
+			syslog(LOG_NOTICE, "[WWW%c:%02u EXT] delete CEP error: %s",
+				           apip, www_srv_info[six].cepid, itron_strerror(error));
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		}
+	}
+
+/*
+ *  wakeup_www_srv -- WWW ãµã¼ãã¿ã¹ã¯ã®ä¼æ­¢è§£é¤
+ */
+
+ER
+wakeup_www_srv (char apip)
+{
+	ID	taskid;
+
+	if (apip == API_PROTO_IPV6)
+		taskid = WWW6_SRV_TASK;
+	else
+		taskid = WWW4_SRV_TASK;
+	syslog(LOG_NOTICE, "[WWW%c(EXT):%d] wake up.", apip, taskid);
+	return wup_tsk(taskid);
+	}
+
+#else	/* of #ifdef USE_TCP_EXTENTIONS */
+
+/*
+ *  WWW ãµã¼ãã¿ã¹ã¯
+ */
+
+void
+www_srv_task(intptr_t exinf)
+{
+	ID	tskid, cepid;
+	uint_t	six;
+	char	apip;
+
+	get_tim(&srv_start);
+	get_tid(&tskid);
+	six = INDEX_SRV_INFO((ID)exinf);
+	cepid = www_srv_info[INDEX_SRV_INFO((ID)exinf)].cepid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV)
+
+	if (six >= NUM_WWW4_SRV_TASKS)
+		apip = API_PROTO_IPV6;
+	else
+		apip = API_PROTO_IPV4;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	apip = API_PROTO_IPVn;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && defined(USE_WWW4_SRV) */
+
+	syslog(LOG_NOTICE, "[WWW%c SRV:%d,%d] started.", apip, tskid, cepid);
+
+	while (true) {
+		while (www_srv(six, apip) == E_OK)
+			;
+		}
+	}
+
+#endif	/* of #ifdef USE_TCP_EXTENTIONS */
+
+#endif	/* of #ifdef USE_WWW_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/wwws.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/wwws.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/wwws.cfg	(revision 317)
@@ -0,0 +1,76 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  WWW ãµã¼ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef USE_WWW_SRV
+
+/* ã¿ã¹ã¯ */
+
+CRE_TSK(WWW_SRV_TASK1,  {
+	TA_HLNG | TA_ACT,
+	1,
+	www_srv_task,
+	WWW_SRV_MAIN_PRIORITY,
+	WWW_SRV_STACK_SIZE,
+	NULL
+	});
+
+#if NUM_WWW_SRV_TASKS >= 2
+
+CRE_TSK(WWW_SRV_TASK2,  {
+	TA_HLNG | TA_ACT,
+	2,
+	www_srv_task,
+	WWW_SRV_MAIN_PRIORITY,
+	WWW_SRV_STACK_SIZE,
+	NULL
+	});
+
+#endif	/* of #if NUM_WWW_SRV_TASKS >= 2 */
+
+#endif	/* of #ifdef USE_WWW_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/wwws.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/wwws.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/wwws.h	(revision 317)
@@ -0,0 +1,151 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _WWWS_H_
+#define _WWWS_H_
+
+/* 
+ *  WWW ãµã¼ã
+ */
+
+#ifdef TOPPERS_S810_CLG3_85
+#define	WWW_SRV_STACK_SIZE		768		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#else	/* of #ifdef TOPPERS_S810_CLG3_85 */
+#define	WWW_SRV_STACK_SIZE		1024		/* ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#endif	/* of #ifdef TOPPERS_S810_CLG3_85 */
+#define WWW_SRV_MAIN_PRIORITY		5		/* ã¿ã¹ã¯ã®åªå
+åº¦		*/
+
+/*
+ *  TCP éåä¿¡ã¦ã¤ã³ããããã¡ãµã¤ãº
+ */
+
+#if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU)
+
+#if defined(SUPPORT_INET6)
+#define WWW_SRV_SWBUF_SIZE	(1024)
+#elif defined(SUPPORT_INET4)
+#define WWW_SRV_SWBUF_SIZE	(512)
+#endif
+
+#else	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#define WWW_SRV_SWBUF_SIZE	(2048)
+
+#endif	/* of #if defined(USE_TCP_MSS_SEG) || defined(USE_IPV6_MMTU) */
+
+#if defined(SUPPORT_INET6)
+#define WWW_SRV_RWBUF_SIZE	(1024)
+#elif defined(SUPPORT_INET4)
+#define WWW_SRV_RWBUF_SIZE	(512)
+#endif
+
+#define WWW_RBUFF_SIZE		(WWW_SRV_RWBUF_SIZE)
+#define WWW_LINE_SIZE		80
+#define WWW_NUM_FIELDS		4
+
+/*
+ *  ã¿ã¹ã¯æ°
+ */
+
+#ifndef _MACRO_ONLY
+
+typedef struct line {
+	uint8_t		len;
+	uint8_t		num;
+	uint8_t		off[WWW_NUM_FIELDS];
+	char		buf[WWW_LINE_SIZE + 1];
+	} T_WWW_LINE;
+
+#ifdef USE_COPYSAVE_API
+
+typedef struct www_buffer {
+	char		*buf;
+	uint16_t	len;
+	uint16_t	index;
+	} T_WWW_BUFFER;
+
+#else	/* of #ifdef USE_COPYSAVE_API */
+
+typedef struct www_buffer {
+	uint16_t	len;
+	uint16_t	index;
+	char		buf[WWW_RBUFF_SIZE];
+	} T_WWW_BUFFER;
+
+#endif	/* of #ifdef USE_COPYSAVE_API */
+
+typedef struct www_rwbuf {
+	T_WWW_BUFFER	sbuf;
+	T_WWW_BUFFER	rbuf;
+	char		unget;
+	} T_WWW_RWBUF;
+
+/* ã¿ã¹ã¯ */
+
+extern void	www_srv_task (intptr_t exinf);
+
+/*
+ *  å¤æ°
+ */
+
+/* TCP éåä¿¡ã¦ã£ã³ããããã¡ */
+
+#ifdef NUM_WWW_SRV_TASKS
+
+extern uint8_t www_srv_swbuf[NUM_WWW_SRV_TASKS][WWW_SRV_SWBUF_SIZE];
+extern uint8_t www_srv_rwbuf[NUM_WWW_SRV_TASKS][WWW_SRV_RWBUF_SIZE];
+
+#endif	/* of #ifdef NUM_WWW_SRV_TASKS */
+
+/*
+ *  é¢æ°
+ */
+
+extern ER	wakeup_www_srv (char apip);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _WWWS_H_ */
Index: asp3_gr_sakura/trunk/tinet/netapp/wwws_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/wwws_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/wwws_asp.cfg	(revision 317)
@@ -0,0 +1,83 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ASP ç¨ WWW ãµã¼ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é WWW ãµã¼ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+INCLUDE("netapp/wwws.cfg");
+
+#ifdef USE_WWW_SRV
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* åä¿¡ãããã¡ */
+
+CRE_MPF(MPF_WWW_RWBUF, {
+	TA_TFIFO,
+	1,
+	sizeof(T_WWW_RWBUF),
+	NULL,
+	NULL
+	});
+
+/* è¡ãããã¡ */
+
+CRE_MPF(MPF_WWW_LINE, {
+	TA_TFIFO,
+	2,
+	sizeof(T_WWW_LINE),
+	NULL,
+	NULL
+	});
+
+#endif	/* of #ifdef USE_WWW_SRV */
Index: asp3_gr_sakura/trunk/tinet/netapp/wwws_jsp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netapp/wwws_jsp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netapp/wwws_jsp.cfg	(revision 317)
@@ -0,0 +1,81 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  JSP ç¨ WWW ãµã¼ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+/*
+ *  å
+±é WWW ãµã¼ãã®ã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«ã®ã¤ã³ã¯ã«ã¼ã
+ */
+
+#include "netapp/wwws.cfg"
+
+#ifdef USE_WWW_SRV
+
+/*
+ * åºå®ã¡ã¢ãªãã¼ã«
+ */
+
+/* åä¿¡ãããã¡ */
+
+CRE_MPF(MPF_WWW_RWBUF, {
+	TA_TFIFO,
+	1,
+	sizeof(T_WWW_RWBUF),
+	NULL
+	});
+
+/* è¡ãããã¡ */
+
+CRE_MPF(MPF_WWW_LINE, {
+	TA_TFIFO,
+	2,
+	sizeof(T_WWW_LINE),
+	NULL
+	});
+
+#endif	/* of #ifdef USE_WWW_SRV */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/MANIFEST
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/MANIFEST	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/MANIFEST	(revision 317)
@@ -0,0 +1,15 @@
+PACKAGE asp_tinet_netdev_if_rx62n
+
+MANIFEST
+Makefile.tinet
+ether_phy.c
+ether_phy.h
+if_rx62n.c
+if_rx62n.cfg
+if_rx62n.h
+if_rx62nreg.h
+nic.cfg
+nic_asp.cfg
+nic_rename.h
+tinet_nic_config.h
+tinet_nic_defs.h
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/Makefile.tinet
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/Makefile.tinet	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/Makefile.tinet	(revision 317)
@@ -0,0 +1,60 @@
+#
+#   TINET (TCP/IP Protocol Stack)
+#  
+#   Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+#  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#     (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#         å ±åãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+#  
+#   @(#) $Id: Makefile.tinet,v 1.5 2009/12/24 05:46:54 abe Exp abe $
+#
+
+#
+#  ã³ã³ãã¤ã«ãªãã·ã§ã³
+#
+INCLUDES	:= $(INCLUDES) -I$(TINET_ROOT)/netdev/$(NET_DEV)
+TINET_DIRS	:= $(TINET_DIRS):$(TINET_ROOT)/netdev/$(NET_DEV)
+TINET_COBJS	:= $(TINET_COBJS) ether_phy.o if_rx62n.o
+TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netdev/$(NET_DEV)/if_ed.cfg
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.c	(revision 317)
@@ -0,0 +1,363 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014-2017 by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include "ether_phy.h"
+#include <kernel.h>
+#include <tinet_config.h>
+#include <sil.h>
+
+#define PHY_CONTROL_REGISTER	0x00
+
+#define PHY_CONTROL_RESET			0x8000
+#define PHY_CONTROL_LOOPBACK		0x4000
+#define PHY_CONTROL_SPEED_SELECT	0x2000
+#define PHY_CONTROL_A_N_ENABLE		0x1000
+#define PHY_CONTROL_POWER_DOWN		0x0800
+#define PHY_CONTROL_ISOLATE			0x0400
+#define PHY_CONTROL_RESTART_A_N		0x0200
+#define PHY_CONTROL_DUPLEX_MODE		0x0100
+#define PHY_CONTROL_COLLISION_TEST	0x0080
+
+#define PHY_STATUS_REGISTER		0x01
+
+#define PHY_STATUS_100BASE_T4				0x8000
+#define PHY_STATUS_100BASE_TX_FULL_DUPLEX	0x4000
+#define PHY_STATUS_100BASE_TX_HALF_DUPLEX	0x2000
+#define PHY_STATUS_10BASE_T_FULL_DUPLEX		0x1000
+#define PHY_STATUS_10BASE_T_HALF_DUPLEX		0x0800
+#define PHY_STATUS_A_N_COMPLETE				0x0020
+#define PHY_STATUS_REMOTE_FAULT				0x0010
+#define PHY_STATUS_A_N_ABILITY				0x0008
+#define PHY_STATUS_LINK_STATUS				0x0004
+#define PHY_STATUS_JABBER_DETECT			0x0002
+#define PHY_STATUS_EXTENDED_CAPABILITY		0x0001
+
+#define PHY_AN_ADVERTISEMENT_REGISTER	0x04
+
+#define PHY_AN_AD_100BASE_T4				0x0200
+#define PHY_AN_AD_100BASE_TX_FULL_DUPLEX	0x0100
+#define PHY_AN_AD_100BASE_TX_HALF_DUPLEX	0x0080
+#define PHY_AN_AD_10BASE_T_FULL_DUPLEX		0x0040
+#define PHY_AN_AD_10BASE_T_HALF_DUPLEX		0x0020
+#define PHY_AN_AD_SELECTOR_FIELD			0x0001
+
+#define PHY_AN_STATUS_REGISTER	0x05
+
+#define PHY_AN_STATUS_100BASE_T4				0x0200
+#define PHY_AN_STATUS_100BASE_TX_FULL_DUPLEX	0x0100
+#define PHY_AN_STATUS_100BASE_TX_HALF_DUPLEX	0x0080
+#define PHY_AN_STATUS_10BASE_T_FULL_DUPLEX		0x0040
+#define PHY_AN_STATUS_10BASE_T_HALF_DUPLEX		0x0020
+
+static void phy_write_bit(bool_t bit);
+static void phy_release_bus();
+static bool_t phy_read_bit();
+static void phy_single_rel_bus();
+
+void phy_reset(uint8_t phy_addr)
+{
+#ifndef _MSC_VER
+	/* PHYã®ãªã»ãã */
+	phy_write_reg(phy_addr, PHY_CONTROL_REGISTER, PHY_CONTROL_RESET);
+
+	/* 500mså¾
+ã¤ */
+	/* tslp_tsk(500 * 1000); ä¸è¦ï¼ */
+
+	/* ãªã»ããå®äºã®ç¢ºèª */
+	while((phy_read_reg(phy_addr, PHY_CONTROL_REGISTER) & PHY_CONTROL_RESET) != 0)
+		tslp_tsk(100);
+#endif
+}
+
+enum phy_mode_t phy_initialize(uint8_t phy_addr)
+{
+	uint_t result = 0;
+	uint16_t status;
+#ifndef _MSC_VER
+	/* ãªã³ã¯å®äºã®ç¢ºèª */
+	while((phy_read_reg(phy_addr, PHY_STATUS_REGISTER) & PHY_STATUS_LINK_STATUS) == 0)
+		tslp_tsk(100);
+
+	/* ãªã¼ããã´ã·ã¨ã¼ã·ã§ã³ã®ãç¥ãããæå¹ã«è¨­å® */
+	phy_write_reg(phy_addr, PHY_AN_ADVERTISEMENT_REGISTER, 
+		PHY_AN_AD_100BASE_T4 | PHY_AN_AD_100BASE_TX_FULL_DUPLEX | PHY_AN_AD_100BASE_TX_HALF_DUPLEX
+		| PHY_AN_AD_10BASE_T_FULL_DUPLEX | PHY_AN_AD_10BASE_T_HALF_DUPLEX | PHY_AN_AD_SELECTOR_FIELD);
+
+	/* ãªã¼ããã´ã·ã¨ã¼ã·ã§ã³ãæå¹ã«è¨­å® */
+	phy_write_reg(phy_addr, PHY_CONTROL_REGISTER, PHY_CONTROL_SPEED_SELECT | PHY_CONTROL_A_N_ENABLE);
+
+	/* ãªã¼ããã´ã·ã¨ã¼ã·ã§ã³å®äºã®ç¢ºèª */
+	while((phy_read_reg(phy_addr, PHY_STATUS_REGISTER) & PHY_STATUS_A_N_COMPLETE) == 0)
+		tslp_tsk(100);
+
+	status = phy_read_reg(phy_addr, PHY_AN_STATUS_REGISTER);
+
+	if ((status & (PHY_AN_STATUS_10BASE_T_FULL_DUPLEX | PHY_AN_STATUS_100BASE_TX_FULL_DUPLEX)) != 0)
+		result |= 0x01;
+
+	if ((status & (PHY_AN_STATUS_100BASE_TX_FULL_DUPLEX | PHY_AN_STATUS_100BASE_TX_HALF_DUPLEX)) != 0)
+		result |= 0x02;
+#endif
+	return (enum phy_mode_t)result;
+}
+
+bool_t phy_is_link(uint8_t phy_addr)
+{
+#ifndef _MSC_VER
+	/* ãªã³ã¯ã®ç¢ºèª */
+	return (phy_read_reg(phy_addr, PHY_STATUS_REGISTER) & PHY_STATUS_LINK_STATUS) == 0;
+#else
+	return true;
+#endif
+}
+
+uint16_t phy_read_reg(uint8_t phy_addr, uint8_t reg_addr)
+{
+	uint16_t result = 0, bit;
+	int i;
+
+	/* PRE ï¼32åã®é£ç¶ãã1b */
+	for (i = 0; i < 32; i++)
+		phy_write_bit(true);
+
+	/* ST ï¼ãã¬ã¼ã ã®å
+é ­ãç¤ºã01bã®ã©ã¤ã */
+	phy_write_bit(false);
+	phy_write_bit(true);
+
+	/* OP ï¼ã¢ã¯ã»ã¹ç¨®å¥ãç¤ºãã³ã¼ãã®ã©ã¤ã */
+	phy_write_bit(true);
+	phy_write_bit(false);
+
+	/* PHYAD ï¼PHY-LSIã®ã¢ãã¬ã¹ã1çªã®å ´åã00001bãã©ã¤ãï¼MSB ããé æ¬¡ã©ã¤ãï¼ã */
+	phy_write_bit((phy_addr & 0x10) != 0);
+	phy_write_bit((phy_addr & 0x08) != 0);
+	phy_write_bit((phy_addr & 0x04) != 0);
+	phy_write_bit((phy_addr & 0x02) != 0);
+	phy_write_bit((phy_addr & 0x01) != 0);
+
+	/* REGAD ï¼ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ã1çªã®å ´åã00001bãã©ã¤ãï¼MSBããé æ¬¡ã©ã¤ãï¼ã */
+	phy_write_bit((reg_addr & 0x10) != 0);
+	phy_write_bit((reg_addr & 0x08) != 0);
+	phy_write_bit((reg_addr & 0x04) != 0);
+	phy_write_bit((reg_addr & 0x02) != 0);
+	phy_write_bit((reg_addr & 0x01) != 0);
+
+	/* TA ï¼MII/RMIIã¤ã³ã¿ãã§ã¼ã¹ä¸ã§ãã¼ã¿ã®éä¿¡å
+ãåãæ¿ããæé */
+	/* ããã¹è§£æ¾ãï¼Z0ã¨è¡¨è¨ï¼ãè¡ã */
+	phy_release_bus();
+
+	/* DATA ï¼16ãããã®ãã¼ã¿ãMSBããé æ¬¡ãªã¼ã */
+	for (bit = 0x8000; bit != 0; bit >>= 1) {
+		if(phy_read_bit())
+			result |= bit;
+	}
+
+	/* IDLE ï¼æ¬¡ã®MIIç®¡çãã©ã¼ãããå
+¥åã¾ã§ã®å¾
+æ©æé */
+	/* ãã§ã«TAæã«ãã¹è§£æ¾æ¸ã¿ã§ããå¶å¾¡ä¸è¦ */
+	phy_release_bus();
+
+	return result;
+}
+
+void phy_write_reg(uint8_t phy_addr, uint8_t reg_addr, uint16_t reg_data)
+{
+	int i;
+	uint16_t bit;
+
+	/* PRE ï¼32åã®é£ç¶ãã1b */
+	for (i = 0; i < 32; i++)
+		phy_write_bit(true);
+
+	/* ST ï¼ãã¬ã¼ã ã®å
+é ­ãç¤ºã01bã®ã©ã¤ã */
+	phy_write_bit(false);
+	phy_write_bit(true);
+
+	/* OP ï¼ã¢ã¯ã»ã¹ç¨®å¥ãç¤ºãã³ã¼ãã®ã©ã¤ã */
+	phy_write_bit(false);
+	phy_write_bit(true);
+
+	/* PHYAD ï¼PHY-LSIã®ã¢ãã¬ã¹ã1çªã®å ´åã00001bãã©ã¤ãï¼MSB ããé æ¬¡ã©ã¤ãï¼ã */
+	phy_write_bit((phy_addr & 0x10) != 0);
+	phy_write_bit((phy_addr & 0x08) != 0);
+	phy_write_bit((phy_addr & 0x04) != 0);
+	phy_write_bit((phy_addr & 0x02) != 0);
+	phy_write_bit((phy_addr & 0x01) != 0);
+
+	/* REGAD ï¼ã¬ã¸ã¹ã¿ã¢ãã¬ã¹ã1çªã®å ´åã00001bãã©ã¤ãï¼MSBããé æ¬¡ã©ã¤ãï¼ã */
+	phy_write_bit((reg_addr & 0x10) != 0);
+	phy_write_bit((reg_addr & 0x08) != 0);
+	phy_write_bit((reg_addr & 0x04) != 0);
+	phy_write_bit((reg_addr & 0x02) != 0);
+	phy_write_bit((reg_addr & 0x01) != 0);
+
+	/* TA ï¼MII/RMIIã¤ã³ã¿ãã§ã¼ã¹ä¸ã§ãã¼ã¿ã®éä¿¡å
+ãåãæ¿ããæé */
+	/* 10bãã©ã¤ã */
+	phy_write_bit(true);
+	phy_write_bit(false);
+
+	/* DATA ï¼16ãããã®ãã¼ã¿ãMSBããé æ¬¡ã©ã¤ã */
+	for (bit = 0x8000; bit != 0; bit >>= 1) {
+		phy_write_bit((reg_data & bit) != 0);
+	}
+
+	/* IDLE ï¼æ¬¡ã®MIIç®¡çãã©ã¼ãããå
+¥åã¾ã§ã®å¾
+æ©æé */
+	/* ãåç¬ãã¹è§£æ¾ãï¼Xã¨è¡¨è¨ï¼ãè¡ã */
+	phy_single_rel_bus();
+}
+
+#define ETHERC_PIR_WAIT 4
+
+/*
+ * 1 ããããã¼ã¿ã®ã©ã¤ã
+ */
+static void phy_write_bit(bool_t bit)
+{
+	int i;
+	uint32_t data = bit ? ETHERC_PIR_MDO : 0;
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, data | ETHERC_PIR_MMD | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, data | ETHERC_PIR_MMD | ETHERC_PIR_MDC);
+
+	for(i = 2 * ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, data | ETHERC_PIR_MMD | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+}
+
+/*
+ * ãã¹è§£æ¾
+ */
+static void phy_release_bus()
+{
+	int i;
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | ETHERC_PIR_MDC);
+
+	for(i = 2 * ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+}
+
+/*
+ * 1 ããããã¼ã¿ã®ãªã¼ã
+ */
+static bool_t phy_read_bit()
+{
+	bool_t bit;
+	int i;
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | ETHERC_PIR_MDC);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	bit = (sil_rew_mem(ETHERC_PIR) & ETHERC_PIR_MDI) != 0;
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	return bit;
+}
+
+/*
+ * åç¬ãã¹è§£æ¾
+ */
+static void phy_single_rel_bus()
+{
+	int i;
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, ETHERC_PIR_MMD | ETHERC_PIR_MDC);
+
+	for(i = 2 * ETHERC_PIR_WAIT; i > 0; i--);
+
+	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ã¸ã®ã©ã¤ã */
+	sil_wrw_mem(ETHERC_PIR, 0/*ETHERC_PIR_MMD*/ | 0/*ETHERC_PIR_MDC*/);
+
+	for(i = ETHERC_PIR_WAIT; i > 0; i--);
+}
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/ether_phy.h	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef ETHER_PHY
+#define ETHER_PHY
+
+#include "if_rx62nreg.h"
+
+enum phy_mode_t{
+	PHY_MODE_10BASE_HALF	= 0x00,
+	PHY_MODE_10BASE_FULL	= 0x01,
+	PHY_MODE_100BASE_HALF	= 0x02,
+	PHY_MODE_100BASE_FULL	= 0x03,
+};
+
+extern void phy_reset(uint8_t phy_addr);
+extern enum phy_mode_t phy_initialize(uint8_t phy_addr);
+extern bool_t phy_is_link(uint8_t phy_addr);
+extern uint16_t phy_read_reg(uint8_t phy_addr, uint8_t rReg);
+extern void phy_write_reg(uint8_t phy_addr, uint8_t wReg, uint16_t wdata);
+
+#endif
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.c	(revision 317)
@@ -0,0 +1,716 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014-2017 by Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1995, David Greenman
+ * 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 unmodified, 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.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ * 
+ * $FreeBSD: src/sys/i386/isa/if_ed.c,v 1.148.2.4 1999/09/25 13:08:18 nyan Exp $
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#define CAST(type, val)		((type)(val))
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "kernel/kernel_impl.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+#include <net/net_buf.h>
+
+#include "if_rx62nreg.h"
+#include <string.h>
+#include "ether_phy.h"
+
+#ifdef _MSC_VER
+#include <stdlib.h>
+#endif
+
+#ifndef TMO_IF_RX62N_GET_NET_BUF
+#define TMO_IF_RX62N_GET_NET_BUF		ULONG_C(1000000)	/* [us] */
+#endif
+
+uint8_t mac_addr[ETHER_ADDR_LEN];
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããã½ããã¦ã§ã¢æ
+å ± 
+ */
+
+typedef struct t_rx62n_softc {
+	T_RX62N_TX_DESC *tx_write;
+	T_RX62N_RX_DESC *rx_read;
+	bool_t link_pre;
+	bool_t link_now;
+	bool_t over_flow;
+} T_RX62N_SOFTC;
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±
+ */
+
+/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããã½ããã¦ã§ã¢æ
+å ± */
+
+static T_RX62N_SOFTC rx62n_softc;
+
+typedef struct t_rx62n_buf {
+	uint8_t rx_buff[NUM_IF_RX62N_RXBUF][32 * (((int)&((T_NET_BUF *)0)->buf + IF_RX62N_BUF_PAGE_SIZE + 31) / 32)];
+	uint8_t tx_buff[NUM_IF_RX62N_TXBUF][32 * ((IF_RX62N_BUF_PAGE_SIZE + 31) / 32)];
+	T_RX62N_RX_DESC rx_desc[NUM_IF_RX62N_RXBUF];
+	T_RX62N_TX_DESC tx_desc[NUM_IF_RX62N_TXBUF];
+} T_RX62N_BUF;
+
+#if defined(__RX)
+#pragma	section	ETH_MEMORY
+#define __attribute__(x)
+#endif
+T_RX62N_BUF __attribute__((section("ETH_MEMORY"),aligned(16))) rx62n_buf;
+#if defined(__RX)
+#pragma	section
+#endif
+
+/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«ä¾å­ããªãã½ããã¦ã§ã¢æ
+å ± */
+
+T_IF_SOFTC if_softc = {
+	{0,},						/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+	0,							/* éä¿¡ã¿ã¤ã ã¢ã¦ã			*/
+	&rx62n_softc,				/* ãã£ãã¤ã¹ä¾å­ã®ã½ããã¦ã§ã¢æ
+å ±	*/
+	SEM_IF_RX62N_SBUF_READY,	/* éä¿¡ã»ããã©			*/
+	SEM_IF_RX62N_RBUF_READY,	/* åä¿¡ã»ããã©			*/
+
+#ifdef SUPPORT_INET6
+
+	IF_MADDR_INIT,				/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãªã¹ã	*/
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+};
+
+/*
+ *  å±æå¤æ°
+ */
+
+static void rx62n_stop (T_RX62N_SOFTC *sc);
+static void rx62n_init_sub (T_IF_SOFTC *ic);
+static void rx62n_set_ecmr (T_IF_SOFTC *ic, enum phy_mode_t mode);
+
+#ifdef SUPPORT_INET6
+
+static uint32_t ds_crc (uint8_t *addr);
+static void ds_getmcaf (T_IF_SOFTC *ic, uint32_t *mcaf);
+
+/*
+ *  ds_crc -- ã¤ã¼ãµãããã¢ãã¬ã¹ã® CRC ãè¨ç®ããã
+ */
+
+#define POLYNOMIAL	0x04c11db6
+
+static uint32_t
+ds_crc (uint8_t *addr)
+{
+	uint32_t	crc = ULONG_C(0xffffffff);
+	int_t		carry, len, bit;
+	uint8_t		byte;
+
+	for (len = ETHER_ADDR_LEN; len -- > 0; ) {
+		byte = *addr ++;
+		for (bit = 8; bit -- > 0; ) {
+			carry   = ((crc & ULONG_C(0x80000000)) ? 1 : 0) ^ (byte & UINT_C(0x01));
+			crc   <<= 1;
+			byte   >>= 1;
+			if (carry)
+				crc = (crc ^ POLYNOMIAL) | carry;
+		}
+	}
+	return crc;
+}
+
+#undef POLYNOMIAL
+
+/*
+ *  ds_getmcaf -- ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®ãªã¹ããããã«ãã­ã£ã¹ãã¢ãã¬ã¹
+ *                ãã£ã«ã¿ãè¨ç®ããã
+ */
+
+static void
+ds_getmcaf (T_IF_SOFTC *ic, uint32_t *mcaf)
+{
+	uint32_t	count, index;
+	uint8_t		*af = (uint8_t*)mcaf;
+
+	mcaf[0] = mcaf[1] = 0;
+
+	for (count = MAX_IF_MADDR_CNT; count -- > 0; ) {
+		index = ds_crc(ic->maddrs[count].lladdr) >> 26;
+		af[index >> 3] |= 1 << (index & 7);
+	}
+}
+
+/*
+ * rx62n_setrcr -- åä¿¡æ§æã¬ã¸ã¹ã¿ (RCR) ãè¨­å®ããã
+ */
+
+static void
+rx62n_setrcr (T_IF_SOFTC *ic)
+{
+	T_RX62N_SOFTC	*sc = ic->sc;
+}
+
+/*
+ * rx62n_addmulti -- ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+ER
+rx62n_addmulti (T_IF_SOFTC *ic)
+{
+	rx62n_setrcr(ic);
+	return E_OK;
+}
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+/*
+ *  rx62n_stop -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãåæ­¢ããã
+ * 
+ *    æ³¨æ: NIC å²ãè¾¼ã¿ç¦æ­¢ç¶æ
+ã§å¼ã³åºããã¨ã
+ */
+
+static void
+rx62n_stop (T_RX62N_SOFTC *sc)
+{
+	/* åä½ã¢ã¼ãã¯ãªã¢ */
+	sil_wrw_mem(ETHERC_ECMR, 0x00000000);
+}
+
+/*
+ *  rx62n_init_sub -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®åæå
+ * 
+ *    æ³¨æ: NIC å²ãè¾¼ã¿ç¦æ­¢ç¶æ
+ã§å¼ã³åºããã¨ã
+ */
+
+static void
+rx62n_init_sub (T_IF_SOFTC *ic)
+{
+	enum phy_mode_t mode;
+
+	/* MACé¨ã½ããã¦ã¨ã¢ã»ãªã»ãã */
+	sil_wrw_mem(EDMAC_EDMR, sil_rew_mem(EDMAC_EDMR) | EDMAC_EDMR_SWR_BIT);
+
+	dly_tsk(1);
+
+	sil_wrw_mem(ETHERC_MAHR, ((uint32_t)mac_addr[0] << 24)
+		| ((uint32_t)mac_addr[1] << 16) | ((uint32_t)mac_addr[2] << 8 )
+		|  (uint32_t)mac_addr[3]);
+	sil_wrw_mem(ETHERC_MALR, ((uint32_t)mac_addr[4] << 8 )
+		| (uint32_t)mac_addr[5]);
+
+	/* PHYãªã»ãã */
+	phy_reset(0);
+
+	/* Clear all ETHERC status BFR, PSRTO, LCHNG, MPD, ICD */
+	sil_wrw_mem(ETHERC_ECSR, 0x00000037);
+
+	/* ãªã³ã¯å¤åå²ãè¾¼ã¿æå¹ */
+	sil_wrw_mem(ETHERC_ECSIPR, sil_rew_mem(ETHERC_ECSIPR) | ETHERC_ECSIPR_LCHNGIP);
+
+	/* Clear all ETHERC and EDMAC status bits */
+	sil_wrw_mem(EDMAC_EESR, 0x47FF0F9F);
+
+	/* éåä¿¡å²ãè¾¼ã¿æå¹ */
+	sil_wrw_mem(EDMAC_EESIPR, (EDMAC_EESIPR_TCIP | EDMAC_EESIPR_FRIP | EDMAC_EESIPR_RDEIP | EDMAC_EESIPR_FROFIP));
+
+	/* åä¿¡ãã¬ã¼ã é·ä¸éï¼ãããã¡ãµã¤ãºï¼ */
+	sil_wrw_mem(ETHERC_RFLR, IF_RX62N_BUF_PAGE_SIZE);
+
+	/* 96ãããæéï¼åæå¤ï¼ */
+	sil_wrw_mem(ETHERC_IPGR, 0x00000014);
+
+	/* Set little endian mode */
+	sil_wrw_mem(EDMAC_EDMR, sil_rew_mem(EDMAC_EDMR) | EDMAC_EDMR_DE_BIT);
+
+	/* Initialize Rx descriptor list address */
+	sil_wrw_mem(EDMAC_RDLAR, (uint32_t)rx62n_buf.rx_desc);
+	/* Initialize Tx descriptor list address */
+	sil_wrw_mem(EDMAC_TDLAR, (uint32_t)rx62n_buf.tx_desc);
+	/* Copy-back status is RFE & TFE only */
+	sil_wrw_mem(EDMAC_TRSCER, 0x00000000);
+	/* Threshold of Tx_FIFO */
+	sil_wrw_mem(EDMAC_TFTR, 0x00000000);
+	/* Transmit fifo & receive fifo is 2048 bytes */
+	sil_wrw_mem(EDMAC_FDR, 0x00000707);
+	/* RR in EDRRR is under driver control */
+	sil_wrw_mem(EDMAC_RMCR, 0x00000001);
+
+	/* PHYã®åæå */
+	mode = phy_initialize(0);
+
+	/* ECMRã¬ã¸ã¹ã¿ã®è¨­å® */
+	rx62n_set_ecmr(ic, mode);
+
+#if defined(TARGET_KERNEL_ASP)
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã®å²è¾¼ã¿åæå */
+	rx62n_inter_init();
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+
+#if defined(TARGET_KERNEL_JSP) && TKERNEL_PRVER >= 0x1042u	/* JSP-1.4.2 ä»¥é */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã®å²è¾¼ã¿åæå */
+	rx62n_inter_init();
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) && TKERNEL_PRVER >= 0x1042u */
+}
+
+
+/*
+ *  rx62n_set_ecmr -- ECMRã¬ã¸ã¹ã¿ã®è¨­å®
+ */
+
+static void
+rx62n_set_ecmr (T_IF_SOFTC *ic, enum phy_mode_t mode)
+{
+	uint32_t ecmr;
+
+	ecmr = ETHERC_ECMR_RE | ETHERC_ECMR_TE/* | ETHERC_ECMR_PRM*/;
+
+	if ((mode & 0x01) != 0)
+		ecmr |= ETHERC_ECMR_DM;
+	if ((mode & 0x02) != 0)
+		ecmr |= ETHERC_ECMR_RTM;
+
+	/* åä½ã¢ã¼ãè¨­å® */
+	sil_wrw_mem(ETHERC_ECMR, ecmr);
+}
+
+/*
+ * rx62n_reset -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããªã»ããããã
+ */
+
+void
+rx62n_reset (T_IF_SOFTC *ic)
+{
+#ifdef TARGET_KERNEL_JSP
+	IPM	ipm;
+#endif
+
+	/* NIC ããã®å²ãè¾¼ã¿ãç¦æ­¢ããã*/
+#ifdef TARGET_KERNEL_JSP
+	ipm = rx62n_dis_inter();
+#endif
+#ifdef TARGET_KERNEL_ASP
+	syscall(dis_int(INTNO_IF_RX62N_TRX));
+#endif
+
+	NET_COUNT_ETHER_NIC(net_count_ether_nic[NC_ETHER_NIC_RESETS], 1);
+	rx62n_stop(ic->sc);
+	rx62n_init_sub(ic);
+
+	/* NIC ããã®å²ãè¾¼ã¿ãè¨±å¯ããã*/
+#ifdef TARGET_KERNEL_JSP
+	rx62n_ena_inter(ipm);
+#endif
+#ifdef TARGET_KERNEL_ASP
+	syscall(ena_int(INTNO_IF_RX62N_TRX));
+#endif
+}
+
+/*
+ *  get_rx62n_softc -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã½ããã¦ã§ã¢æ
+å ±ãè¿ãã
+ */
+
+T_IF_SOFTC *
+rx62n_get_softc (void)
+{
+	return &if_softc;
+}
+
+/*
+ * rx62n_watchdog -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¯ããããã°ã¿ã¤ã ã¢ã¦ã
+ */
+
+void
+rx62n_watchdog (T_IF_SOFTC *ic)
+{
+	rx62n_reset(ic);
+}
+
+/*
+ * rx62n_probe -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®æ¤åº
+ */
+
+void
+rx62n_probe (T_IF_SOFTC *ic)
+{
+	int i;
+#if defined(TARGET_KERNEL_ASP)
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã®ãã¹ã®åæå */
+	rx62n_bus_init();
+
+#endif	/* of #if defined(TARGET_KERNEL_ASP) */
+#if defined(TARGET_KERNEL_JSP) && TKERNEL_PRVER >= 0x1042u	/* JSP-1.4.2 ä»¥é */
+
+	/* ã¿ã¼ã²ããä¾å­é¨ã®ãã¹ã®åæå */
+	rx62n_bus_init();
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) && TKERNEL_PRVER >= 0x1042u */
+
+	for(i = 0; i < ETHER_ADDR_LEN; i++){
+		ic->ifaddr.lladdr[i] = mac_addr[i];
+	}
+}
+
+/*
+ * rx62n_init -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®åæå
+ */
+
+void
+rx62n_init (T_IF_SOFTC *ic)
+{
+#ifdef TARGET_KERNEL_JSP
+	IPM	ipm;
+#endif
+	T_RX62N_SOFTC *sc = ic->sc;
+	T_RX62N_TX_DESC *tdsc;
+	T_RX62N_RX_DESC *rdsc;
+	int i;
+
+	/* NIC ããã®å²ãè¾¼ã¿ãç¦æ­¢ããã*/
+#ifdef TARGET_KERNEL_JSP
+	ipm = rx62n_dis_inter();
+#endif
+#ifdef TARGET_KERNEL_ASP
+	syscall(dis_int(INTNO_IF_RX62N_TRX));
+#endif
+
+	tdsc = (T_RX62N_TX_DESC *)rx62n_buf.tx_desc;
+	sc->tx_write = tdsc;
+	for ( i=0 ; i < NUM_IF_RX62N_TXBUF ; i++ ) {
+		memset(tdsc, 0, sizeof(*tdsc));
+		tdsc->tbl = 0;
+		tdsc->tba = (uint32_t)&rx62n_buf.tx_buff[i];
+		tdsc++;
+	}
+	tdsc--;
+	tdsc->tdle = 1;
+
+	rdsc = (T_RX62N_RX_DESC *)rx62n_buf.rx_desc;
+	sc->rx_read = rdsc;
+	for ( i=0 ; i < NUM_IF_RX62N_RXBUF ; i++ ) {
+		memset(rdsc, 0, sizeof(*rdsc));
+		rdsc->rbl = IF_RX62N_BUF_PAGE_SIZE;
+		rdsc->rba = (uint32_t)&rx62n_buf.rx_buff[i] + (uint32_t)&((T_NET_BUF *)0)->buf;
+		rdsc->rfl = 0;
+		rdsc->ract = 1;
+		rdsc++;
+	}
+	rdsc--;
+	rdsc->rdle = 1;
+
+	/* rx62n_init æ¬ä½ãå¼ã³åºãã*/
+	rx62n_init_sub(ic);
+
+	if (sil_rew_mem(EDMAC_EDRRR) == 0) {
+		sil_wrw_mem(EDMAC_EDRRR, EDMAC_EDRRR_RR);
+	}
+
+	/* NIC ããã®å²ãè¾¼ã¿ãè¨±å¯ããã*/
+#ifdef TARGET_KERNEL_JSP
+	rx62n_ena_inter(ipm);
+#endif
+#ifdef TARGET_KERNEL_ASP
+	syscall(ena_int(INTNO_IF_RX62N_TRX));
+#endif
+}
+
+/*
+ * rx62n_read -- ãã¬ã¼ã ã®èª­ã¿è¾¼ã¿
+ */
+
+T_NET_BUF *
+rx62n_read (T_IF_SOFTC *ic)
+{
+	T_RX62N_SOFTC *sc = ic->sc;
+	T_RX62N_RX_DESC *desc;
+	uint16_t len;
+	T_NET_BUF *input = NULL;
+	uint16_t align;
+	uint8_t *dst;
+	ER error;
+	enum phy_mode_t mode;
+
+	/* ãªã³ã¯ç¶æ
+ã«å¤åãã */
+	if (sc->link_pre != sc->link_now) {
+		sc->link_pre = sc->link_now;
+
+		if (!phy_is_link(0)) {
+			/* PHYã®åæå */
+			mode = phy_initialize(0);
+
+			/* ECMRã¬ã¸ã¹ã¿ã®è¨­å® */
+			rx62n_set_ecmr(ic, mode);
+		}
+	}
+
+	if (sc->over_flow) {
+		sc->over_flow = false;
+	}
+
+	desc = sc->rx_read;
+
+	if (desc->ract != 0) {
+		return NULL;
+	}
+
+	len = desc->rfl;
+	/*
+	 *  +-----------+--------+---------+---------+
+	 *  | Ehter HDR | IP HDR | TCP HDR | TCP SDU |
+	 *  +-----------+--------+---------+---------+
+	 *        14        20        20        n
+	 *   <----------------- len ---------------->
+	 *              ^
+	 *              t_net_buf ã§ 4 ãªã¯ãããå¢çã«ã¢ã©ã¤ã³ããã¦ããã
+	 *
+	 *  tcp_input ã¨ udp_input ã§ã¯ãæ¬ä¼¼ãããã¨ SDU ã§ãã§ãã¯ãµã ã
+	 *  è¨ç®ããããn ã 4 ãªã¯ãããå¢çã«ãªãããã« SDU ã®å¾ãã« 0 ã
+	 *  ãããã£ã³ã°ããããã®åãèæ
+®ãã¦ net_buf ãç²å¾ããªããã°ãªããªãã
+	 */
+	align = ((((len - sizeof(T_IF_HDR)) + 3) >> 2) << 2) + sizeof(T_IF_HDR);
+
+	if ((error = tget_net_buf(&input, align, TMO_IF_RX62N_GET_NET_BUF)) == E_OK && input != NULL) {
+		dst = input->buf + IF_ETHER_NIC_HDR_ALIGN;
+		memcpy(dst, (void *)desc->rba, len);
+	}
+	else {
+		NET_COUNT_ETHER_NIC(net_count_ether_nic[NC_ETHER_NIC_IN_ERR_PACKETS], 1);
+		NET_COUNT_ETHER_NIC(net_count_ether_nic[NC_ETHER_NIC_NO_BUFS], 1);
+	}
+
+	desc->rfp = 0;
+	desc->ract = 1;
+
+	desc++;
+	if (desc == &rx62n_buf.rx_desc[NUM_IF_RX62N_RXBUF]) {
+		desc = rx62n_buf.rx_desc;
+	}
+	sc->rx_read = desc;
+
+	if (sil_rew_mem(EDMAC_EDRRR) == 0) {
+		sil_wrw_mem(EDMAC_EDRRR, EDMAC_EDRRR_RR);
+	}
+
+	return input;
+}
+
+/*
+ * rx62n_start -- éä¿¡ãã¬ã¼ã ããããã¡ãªã³ã°ããã
+ */
+
+void
+rx62n_start (T_IF_SOFTC *ic, T_NET_BUF *output)
+{
+	T_RX62N_SOFTC *sc = ic->sc;
+	T_RX62N_TX_DESC *desc, *next;
+	uint8_t *buf = NULL;
+	int32_t len, res, pos;
+	uint32_t tfp;
+
+	for ( res = output->len, pos = 0; res > 0; res -= len, pos += len ) {
+		desc = sc->tx_write;
+
+		while (desc->tact != 0) {
+			tslp_tsk(100);
+		}
+
+		buf = (uint8_t *)desc->tba + IF_ETHER_NIC_HDR_ALIGN;
+
+		next = desc + 1;
+		if (next == &rx62n_buf.tx_desc[NUM_IF_RX62N_TXBUF]) {
+			next = rx62n_buf.tx_desc;
+		}
+		sc->tx_write = next;
+
+		len = res;
+		if ( len > IF_RX62N_BUF_PAGE_SIZE ) {
+			len = IF_RX62N_BUF_PAGE_SIZE;
+			tfp = 0x0;
+		}
+		else
+			tfp = 0x1;
+
+		if (pos == 0)
+			tfp |= 0x2;
+
+		memcpy(buf, (uint8_t *)output->buf + pos, len);
+
+		desc->tbl = len;
+		desc->tfp = tfp;
+		desc->tact = 1;
+	}
+
+	if (sil_rew_mem(EDMAC_EDTRR) == 0) {
+		sil_wrw_mem(EDMAC_EDTRR, EDMAC_EDTRR_TR);
+	}
+}
+
+/*
+ *  RX62N Ethernet Controler éåä¿¡å²ãè¾¼ã¿ãã³ãã©
+ */
+
+void
+if_rx62n_trx_handler (void)
+{
+	T_IF_SOFTC *ic;
+	T_RX62N_SOFTC *sc;
+	uint32_t ecsr, eesr, psr;
+
+	ic = &if_softc;
+	sc = ic->sc;
+
+	ecsr = sil_rew_mem(ETHERC_ECSR);
+
+	if (ecsr & ETHERC_ECSR_LCHNG) {
+		/* ETHERCé¨å²ãè¾¼ã¿è¦å ã¯ãªã¢ */
+		sil_wrw_mem(ETHERC_ECSR, ETHERC_ECSR_LCHNG);
+
+		psr = sil_rew_mem(ETHERC_PSR);
+		sc->link_now = (psr & ETHERC_PSR_LMON) != 0;
+
+		/* ãªã³ã¯ç¶æ
+ã«å¤åãã */
+		if (sc->link_pre != sc->link_now) {
+			/* åä¿¡å²ãè¾¼ã¿å¦ç */
+			isig_sem(ic->semid_rxb_ready);
+		}
+	}
+
+	eesr = sil_rew_mem(EDMAC_EESR);
+
+	if (eesr & EDMAC_EESR_FR) {
+		/* DMAé¨å²ãè¾¼ã¿è¦å ã¯ãªã¢ */
+		sil_wrw_mem(EDMAC_EESR, EDMAC_EESR_FR);
+
+		/* åä¿¡å²ãè¾¼ã¿å¦ç */
+		isig_sem(ic->semid_rxb_ready);
+	}
+	if (eesr & EDMAC_EESR_TC) {
+		/* DMAé¨å²ãè¾¼ã¿è¦å ã¯ãªã¢ */
+		sil_wrw_mem(EDMAC_EESR, EDMAC_EESR_TC);
+
+		/* éä¿¡å²ãè¾¼ã¿å¦ç */
+		isig_sem(ic->semid_txb_ready);
+	}
+	if (eesr & (EDMAC_EESR_FROF | EDMAC_EESR_RDE)) {
+		/* DMAé¨å²ãè¾¼ã¿è¦å ã¯ãªã¢ */
+		sil_wrw_mem(EDMAC_EESR, EDMAC_EESR_FROF | EDMAC_EESR_RDE);
+
+		sc->over_flow = true;
+
+		/* åä¿¡å²ãè¾¼ã¿å¦ç */
+		isig_sem(ic->semid_rxb_ready);
+	}
+}
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.cfg	(revision 317)
@@ -0,0 +1,73 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  if_rx62n ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef SUPPORT_ETHER
+
+INCLUDE("<if_rx62nreg.h>");
+
+/* å²ãè¾¼ã¿ãã³ãã© */
+
+DEF_INH(INHNO_IF_RX62N_TRX, { TA_HLNG, if_rx62n_trx_handler });
+
+/* å
+¥åºååæç¨ã»ããã© */
+
+CRE_SEM(SEM_IF_RX62N_SBUF_READY,	{ TA_TPRI, NUM_IF_RX62N_TXBUF, NUM_IF_RX62N_TXBUF });
+CRE_SEM(SEM_IF_RX62N_RBUF_READY,	{ TA_TPRI, 0,                  NUM_IF_RX62N_RXBUF });
+
+#endif	/* of #ifdef SUPPORT_ETHER */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n.h	(revision 317)
@@ -0,0 +1,125 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (C) 1993, David Greenman. This software may be used, modified,
+ *   copied, distributed, and sold, in both source and binary form provided
+ *   that the above copyright and these terms are retained. Under no
+ *   circumstances is the author responsible for the proper functioning
+ *   of this software, nor does the author assume any responsibility
+ *   for damages incurred with its use.
+ */
+
+#ifndef _IF_RX62N_H_
+#define _IF_RX62N_H_
+
+/*
+ *  NIC ã®é¸æãã¯ã­
+ */
+
+#define IF_ETHER_NIC_GET_SOFTC()	rx62n_get_softc()
+#define IF_ETHER_NIC_WATCHDOG(i)	rx62n_watchdog(i)
+#define IF_ETHER_NIC_PROBE(i)		rx62n_probe(i)
+#define IF_ETHER_NIC_INIT(i)		rx62n_init(i)
+#define IF_ETHER_NIC_READ(i)		rx62n_read(i)
+#define IF_ETHER_NIC_RESET(i)		rx62n_reset(i)
+#define IF_ETHER_NIC_START(i,o)		rx62n_start(i,o)
+
+#define T_IF_ETHER_NIC_SOFTC		struct t_rx62n_softc
+
+/* IPv6 é¢ä¿ */
+
+#define IF_ETHER_NIC_IN6_IFID(i,a)	get_mac6_ifid(i,a)	/* ã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ã®è¨­å®		*/
+#define IF_ETHER_NIC_ADDMULTI(s)	rx62n_addmulti(s)		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®ç»é²		*/
+
+#if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY)
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IF_SOFTC_DEFINED
+
+typedef struct t_if_softc T_IF_SOFTC;
+
+#define T_IF_SOFTC_DEFINED
+
+#endif	/* of #ifndef T_IF_SOFTC_DEFINED */
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+/*
+ *  é¢æ°
+ */
+
+extern T_IF_SOFTC *rx62n_get_softc(void);
+extern void rx62n_watchdog(T_IF_SOFTC *ic);
+extern void rx62n_probe(T_IF_SOFTC *ic);
+extern void rx62n_init(T_IF_SOFTC *ic);
+extern void rx62n_reset(T_IF_SOFTC *ic);
+extern T_NET_BUF *rx62n_read(T_IF_SOFTC *ic);
+extern void rx62n_start(T_IF_SOFTC *ic, T_NET_BUF *output);
+extern ER rx62n_addmulti(T_IF_SOFTC *ic);
+extern void if_rx62n_trx_handler(void);
+
+#endif /* #if !defined(TOPPERS_MACRO_ONLY) && !defined(_MACRO_ONLY) */
+
+#endif	/* of #ifndef _IF_RX62N_H_ */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n_sym.def
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n_sym.def	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62n_sym.def	(revision 317)
@@ -0,0 +1,4 @@
+INHNO_IF_RX62N_TRX
+INTNO_IF_RX62N_TRX
+INTATR_IF_RX62N_TRX
+INTPRI_IF_RX62N_TRX
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62nreg.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62nreg.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/if_rx62nreg.h	(revision 317)
@@ -0,0 +1,178 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014-2015 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef RX62NRegH
+#define RX62NRegH
+
+#include "t_stddef.h"
+
+#define EDMAC_EDMR			((uint32_t *)0x000C0000)	/* EDMACã¢ã¼ãã¬ã¸ã¹ã¿ */
+#define EDMAC_EDMR_SWR_BIT	0x00000001
+#define EDMAC_EDMR_DE_BIT	0x00000040
+
+#define EDMAC_EDTRR			((uint32_t *)0x000C0008)	/* EDMACéä¿¡è¦æ±ã¬ã¸ã¹ã¿ */
+#define EDMAC_EDTRR_TR		0x00000001
+
+#define EDMAC_EDRRR			((uint32_t *)0x000C0010)	/* EDMACåä¿¡è¦æ±ã¬ã¸ã¹ã¿ */
+#define EDMAC_EDRRR_RR		0x00000001
+
+#define EDMAC_TDLAR			((uint32_t *)0x000C0018)	/* éä¿¡ãã£ã¹ã¯ãªãã¿ãªã¹ãå
+é ­ã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+#define EDMAC_RDLAR			((uint32_t *)0x000C0020)	/* åä¿¡ãã£ã¹ã¯ãªãã¿ãªã¹ãå
+é ­ã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+
+#define EDMAC_EESR			((uint32_t *)0x000C0028)	/* ETHERC/EDMACã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ */
+#define EDMAC_EESR_FROF		0x00010000
+#define EDMAC_EESR_RDE		0x00020000
+#define EDMAC_EESR_FR		0x00040000
+#define EDMAC_EESR_TC		0x00200000
+#define EDMAC_EESR_TWB		0x40000000
+
+#define EDMAC_EESIPR		((uint32_t *)0x000C0030)	/* ETHERC/EDMACã¹ãã¼ã¿ã¹å²ãè¾¼ã¿è¨±å¯ã¬ã¸ã¹ã¿ */
+#define EDMAC_EESIPR_RMAFIP	0x00000080
+#define EDMAC_EESIPR_FROFIP	0x00010000
+#define EDMAC_EESIPR_RDEIP	0x00020000
+#define EDMAC_EESIPR_FRIP	0x00040000
+#define EDMAC_EESIPR_TCIP	0x00200000
+#define EDMAC_EESIPR_TWBIP	0x40000000
+
+#define EDMAC_TRSCER		((uint32_t *)0x000C0038)	/* éåä¿¡ã¹ãã¼ã¿ã¹ã³ãã¼æç¤ºã¬ã¸ã¹ã¿ */
+#define EDMAC_RMFCR			((uint32_t *)0x000C0040)	/* ãã¹ããã¬ã¼ã ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define EDMAC_TFTR			((uint32_t *)0x000C0048)	/* éä¿¡FIFOãããå¤æå®ã¬ã¸ã¹ã¿ */
+#define EDMAC_FDR			((uint32_t *)0x000C0050)	/* FIFOå®¹éæå®ã¬ã¸ã¹ã¿ */
+#define EDMAC_RMCR			((uint32_t *)0x000C0058)	/* åä¿¡æ¹å¼å¶å¾¡ã¬ã¸ã¹ã¿ */
+#define EDMAC_TFUCR			((uint32_t *)0x000C0064)	/* éä¿¡FIFOã¢ã³ãã©ã³ã«ã¦ã³ã */
+#define EDMAC_RFOCR			((uint32_t *)0x000C0068)	/* åä¿¡FIFOãªã¼ããã­ã¼ã«ã¦ã³ã */
+#define EDMAC_IOSR			((uint32_t *)0x000C006C)	/* åå¥åºåä¿¡å·è¨­å®ã¬ã¸ã¹ã¿ */
+#define EDMAC_FCFTR			((uint32_t *)0x000C0070)	/* ãã­ã¼å¶å¾¡éå§FIFOãããå¤è¨­å®ã¬ã¸ã¹ã¿ */
+#define EDMAC_RPADIR		((uint32_t *)0x000C0078)	/* åä¿¡ãã¼ã¿ããã£ã³ã°æ¿å
+¥è¨­å®ã¬ã¸ã¹ã¿ */
+#define EDMAC_TRIMD			((uint32_t *)0x000C007C)	/* éä¿¡å²ãè¾¼ã¿è¨­å®ã¬ã¸ã¹ã¿ */
+#define EDMAC_RBWAR			((uint32_t *)0x000C00C8)	/* åä¿¡ãããã¡ã©ã¤ãã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+#define EDMAC_RDFAR			((uint32_t *)0x000C00CC)	/* åä¿¡ãã£ã¹ã¯ãªãã¿ãã§ããã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+#define EDMAC_TBRAR			((uint32_t *)0x000C00D4)	/* éä¿¡ãããã¡ãªã¼ãã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+#define EDMAC_TDFAR			((uint32_t *)0x000C00D8)	/* éä¿¡ãã£ã¹ã¯ãªãã¿ãã§ããã¢ãã¬ã¹ã¬ã¸ã¹ã¿ */
+
+#define ETHERC_ECMR			((uint32_t *)0x000C0100)	/* ETHERCã¢ã¼ãã¬ã¸ã¹ã¿ */
+#define ETHERC_ECMR_PRM		0x00000001
+#define ETHERC_ECMR_DM		0x00000002
+#define ETHERC_ECMR_RTM		0x00000004
+#define ETHERC_ECMR_TE		0x00000020
+#define ETHERC_ECMR_RE		0x00000040
+
+#define ETHERC_RFLR			((uint32_t *)0x000C0108)	/* åä¿¡ãã¬ã¼ã é·ä¸éã¬ã¸ã¹ã¿ */
+#define ETHERC_ECSR			((uint32_t *)0x000C0110)	/* ETHERCã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ */
+#define ETHERC_ECSR_LCHNG	0x00000004
+#define ETHERC_ECSIPR		((uint32_t *)0x000C0118)	/* ETHERCå²ãè¾¼ã¿è¨±å¯ã¬ã¸ã¹ã¿ */
+#define ETHERC_ECSIPR_LCHNGIP	0x00000004
+#define ETHERC_PIR			((uint32_t *)0x000C0120)	/* PHYé¨ã¤ã³ã¿ãã§ã¼ã¹ã¬ã¸ã¹ã¿ */
+#define ETHERC_PIR_MDC		0x00000001
+#define ETHERC_PIR_MMD		0x00000002
+#define ETHERC_PIR_MDO		0x00000004
+#define ETHERC_PIR_MDI		0x00000008
+
+#define ETHERC_PSR			((uint32_t *)0x000C0128)	/* PHYé¨ã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ */
+#define ETHERC_PSR_LMON		0x00000001
+
+#define ETHERC_RDMLR		((uint32_t *)0x000C0140)	/* ä¹±æ°çæã«ã¦ã³ã¿ä¸éå¤è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_IPGR			((uint32_t *)0x000C0150)	/* IPGè¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_APR			((uint32_t *)0x000C0154)	/* èªåPAUSEãã¬ã¼ã è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_MPR			((uint32_t *)0x000C0158)	/* æåPAUSEãã¬ã¼ã è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_RFCF			((uint32_t *)0x000C0160)	/* åä¿¡PAUSEãã¬ã¼ã ã«ã¦ã³ã¿ */
+#define ETHERC_TPAUSER		((uint32_t *)0x000C0164)	/* èªåPAUSEãã¬ã¼ã åéåæ°è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_TPAUSECR		((uint32_t *)0x000C0168)	/* PAUSEãã¬ã¼ã åéåæ°ã«ã¦ã³ã¿ */
+#define ETHERC_BCFRR		((uint32_t *)0x000C016C)	/* Broadcastãã¬ã¼ã åä¿¡åæ°è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_MAHR			((uint32_t *)0x000C01C0)	/* MACã¢ãã¬ã¹ä¸ä½è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_MALR			((uint32_t *)0x000C01C8)	/* MACã¢ãã¬ã¹ä¸ä½è¨­å®ã¬ã¸ã¹ã¿ */
+#define ETHERC_TROCR		((uint32_t *)0x000C01D0)	/* éä¿¡ãªãã©ã¤ãªã¼ãã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_CDCR			((uint32_t *)0x000C01D4)	/* é
+å»¶è¡çªæ¤åºã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_LCCR			((uint32_t *)0x000C01D8)	/* ã­ã£ãªã¢æ¶å¤±ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_CNDCR		((uint32_t *)0x000C01DC)	/* ã­ã£ãªã¢æªæ¤åºã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_CEFCR		((uint32_t *)0x000C01E4)	/* CRCã¨ã©ã¼ãã¬ã¼ã åä¿¡ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_FRECR		((uint32_t *)0x000C01E8)	/* ãã¬ã¼ã åä¿¡ã¨ã©ã¼ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_TSFRCR		((uint32_t *)0x000C01EC)	/* 64ãã¤ãæªæºãã¬ã¼ã åä¿¡ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_TLFRCR		((uint32_t *)0x000C01F0)	/* æå®ãã¤ãè¶
+ãã¬ã¼ã åä¿¡ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_RFCR			((uint32_t *)0x000C01F4)	/* ç«¯æ°ããããã¬ã¼ã åä¿¡ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+#define ETHERC_MAFCR		((uint32_t *)0x000C01F8)	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãã¬ã¼ã åä¿¡ã«ã¦ã³ã¿ã¬ã¸ã¹ã¿ */
+
+/* éä¿¡ãã£ã¹ã¯ãªãã¿ */
+typedef struct t_rx62n_tx_desc {
+	uint32_t	tfs : 26;
+	uint32_t	twbi : 1;
+	uint32_t	tfe : 1;
+	uint32_t	tfp : 2;
+	uint32_t	tdle : 1;
+	uint32_t	tact : 1;
+	uint32_t	: 16;
+	uint32_t	tbl : 16;
+	uint32_t	tba;
+	uint32_t	binding;
+} T_RX62N_TX_DESC;
+
+/* åä¿¡ãã£ã¹ã¯ãªãã¿ */
+typedef struct t_rx62n_rx_desc {
+	uint32_t	rfs : 27;
+	uint32_t	rfe : 1;
+	uint32_t	rfp : 2;
+	uint32_t	rdle : 1;
+	uint32_t	ract : 1;
+	uint32_t	rfl : 16;
+	uint32_t	rbl : 16;
+	uint32_t	rba;
+	uint32_t	binding;
+} T_RX62N_RX_DESC;
+
+#endif /* RX62NRegH */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic.cfg	(revision 317)
@@ -0,0 +1,55 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#include "if_rx62n.cfg"
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_asp.cfg	(revision 317)
@@ -0,0 +1,74 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  if_rx62n ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#ifdef SUPPORT_ETHER
+
+#include "if_rx62nreg.h"
+
+/* å²ãè¾¼ã¿ãã³ãã© */
+
+DEF_INH(INHNO_IF_RX62N_TRX, { TA_NULL, if_rx62n_trx_handler });
+CFG_INT(INTNO_IF_RX62N_TRX, { INTATR_IF_RX62N_TRX, INTPRI_IF_RX62N_TRX });
+
+/* å
+¥åºååæç¨ã»ããã© */
+
+CRE_SEM(SEM_IF_RX62N_SBUF_READY,	{ TA_TPRI, NUM_IF_RX62N_TXBUF, NUM_IF_RX62N_TXBUF });
+CRE_SEM(SEM_IF_RX62N_RBUF_READY,	{ TA_TPRI, 0,                  NUM_IF_RX62N_RXBUF });
+
+#endif	/* of #ifdef SUPPORT_ETHER */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_rename.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/nic_rename.h	(revision 317)
@@ -0,0 +1,84 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _NIF_RENAME_H_
+#define _NIF_RENAME_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹å
+é¨åã®ãªãã¼ã 
+ */
+
+/* if_rx62n.c */
+
+#define rx62n_get_softc		_tinet_rx62n_get_softc
+#define rx62n_watchdog		_tinet_rx62n_watchdog
+#define rx62n_probe		_tinet_rx62n_probe
+#define rx62n_init			_tinet_rx62n_init
+#define rx62n_read			_tinet_rx62n_read
+#define rx62n_reset		_tinet_rx62n_reset
+#define rx62n_start		_tinet_rx62n_start
+#define if_softc		_tinet_if_softc
+
+/* config/<cpu>/tinet_cpu_config.c */
+
+#define rx62n_inter_clear	_tinet_rx62n_inter_clear
+
+#ifdef SUPPORT_INET6
+
+#define rx62n_addmulti		_tinet_rx62n_addmulti
+
+#endif	/* of #ifdef SUPPORT_INET6 */
+
+#endif	/* of #ifndef _NIF_RENAME_H_ */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_config.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_config.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_config.h	(revision 317)
@@ -0,0 +1,67 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_NIC_CONFIG_H_
+#define _TINET_NIC_CONFIG_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®å
+é¨è­å¥åã®ãªãã¼ã 
+ */
+
+#include "nic_rename.h"
+
+#include "if_rx62n.h"
+
+#endif	/* of #ifndef _TINET_NIC_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_defs.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_defs.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netdev/if_rx62n/tinet_nic_defs.h	(revision 317)
@@ -0,0 +1,64 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2009 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2014 Cores Co., Ltd. Japan
+ * 
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+ *  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+ *  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+ *      ã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+ *        å ±åãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+ *      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+ *      å
+è²¬ãããã¨ï¼
+ * 
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+ *  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+ *  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+ *  ã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_NIC_DEFS_H_
+#define _TINET_NIC_DEFS_H_
+
+/* 
+ *  T_ETHER_HDR ã§ãã¢ã©ã¤ã³ãèª¿æ´ããå ´åã¯ãèª¿æ´éãæå®ããã
+ *  èª¿æ´ããªãå ´åã¯ã0 ãæå®ããã
+ */
+#define IF_ETHER_NIC_HDR_ALIGN		0
+
+#endif	/* of #ifndef _TINET_NIC_DEFS_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/icmp6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/icmp6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/icmp6.h	(revision 317)
@@ -0,0 +1,535 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet/icmp6.h,v 1.2.2.3 2001/07/06 05:36:35 sumikawa Exp $	*/
+/*	$KAME: icmp6.h,v 1.46 2001/04/27 15:09:48 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _IP_ICMP6_H_
+#define _IP_ICMP6_H_
+
+/*
+ *  ICMPv6 ããã
+ */
+
+typedef struct t_icmp6_hdr {
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		code;		/* ãµãå		*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	union {
+		uint32_t	data32;
+		uint16_t	data16[2];
+		uint8_t		data8[4];
+		} data;
+	} T_ICMP6_HDR;
+
+#define icmp6_data32			data.data32
+#define icmp6_data16			data.data16
+#define icmp6_data8			data.data8
+#define icmp6_pptr			data.data32		/* ãã©ã¡ã¼ã¿ç°å¸¸	*/
+#define icmp6_mtu			data.data32		/* ãã©ã¡ã¼ã¿ç°å¸¸	*/
+#define icmp6_id			data.data16[0]		/* ã¨ã³ã¼è¦æ±ã¨å¿ç­	*/
+#define icmp6_seq			data.data16[1]		/* ã¨ã³ã¼è¦æ±ã¨å¿ç­	*/
+
+#define ICMP6_HDR_SIZE			(sizeof(T_ICMP6_HDR))
+#define IF_IP6_ICMP6_HDR_OFFSET		(IF_IP6_HDR_SIZE)
+
+#define GET_ICMP6_HDR(nbuf,ihoff)	((T_ICMP6_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_ICMP6_SDU(nbuf,ihoff)	((uint8_t*)((nbuf)->buf) + ihoff + ICMP6_HDR_SIZE)
+
+#define GET_IP6_ICMP6_HDR_SIZE(nbuf)	(GET_IP6_HDR_SIZE(nbuf) + ICMP6_HDR_SIZE)
+#define GET_IF_IP6_ICMP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + GET_IP6_ICMP6_HDR_SIZE(nbuf))
+
+/*
+ *  ICMP6 ã¿ã¤ã
+ */
+
+#define ICMP6_DST_UNREACH		UINT_C(1)	/* å®å
+å°éä¸å¯è½		*/
+#define ICMP6_PACKET_TOO_BIG		UINT_C(2)	/* ãã±ãããå¤§ããããã	*/
+#define ICMP6_TIME_EXCEEDED		UINT_C(3)	/* TTL ãè¶
+éããã		*/
+#define ICMP6_PARAM_PROB		UINT_C(4)	/* IPv6 ããããä¸æ­£ã		*/
+
+#define ICMP6_ECHO_REQUEST		UINT_C(128)	/* ã¨ã³ã¼è¦æ±			*/
+#define ICMP6_ECHO_REPLY		UINT_C(129)	/* ã¨ã³ã¼å¿ç­			*/
+
+#define ICMP6_MEMBERSHIP_QUERY		UINT_C(130)	/* ã°ã«ã¼ãã¡ã³ãç
+§ä¼		*/
+#define ICMP6_MEMBERSHIP_REPORT		UINT_C(131)	/* ã°ã«ã¼ãã¡ã³ãå ±å		*/
+#define ICMP6_MEMBERSHIP_REDUCTION	UINT_C(132)	/* ã°ã«ã¼ãã¡ã³ãçµäº		*/
+
+#define MLD_LISTENER_QUERY		UINT_C(130)	/* ãã«ãã­ã£ã¹ãåä¿¡è
+ç
+§ä¼	*/
+#define MLD_LISTENER_REPORT		UINT_C(131)	/* ãã«ãã­ã£ã¹ãåä¿¡è
+å ±å	*/
+#define MLD_LISTENER_DONE		UINT_C(132)	/* ãã«ãã­ã£ã¹ãåä¿¡è
+çµäº	*/
+
+#define ND_ROUTER_SOLICIT		UINT_C(133)	/* ã«ã¼ã¿è¦è«			*/
+#define ND_ROUTER_ADVERT		UINT_C(134)	/* ã«ã¼ã¿éç¥			*/
+#define ND_NEIGHBOR_SOLICIT		UINT_C(135)	/* è¿é£è¦è«			*/
+#define ND_NEIGHBOR_ADVERT		UINT_C(136)	/* è¿é£éç¥			*/
+#define ND_REDIRECT			UINT_C(137)	/* åãç´ã			*/
+
+#define ICMP6_ROUTER_RENUMBERING	UINT_C(138)	/* ã«ã¼ã¿çªå·åè¨­å®		*/
+
+#define ICMP6_WRU_REQUEST		UINT_C(139)	/* è¦æ±ãã¼ãæ¢ç´¢		*/
+#define ICMP6_WRU_REPLY			UINT_C(140)	/* å¿ç­ãã¼ãæ¢ç´¢		*/
+
+#define ICMP6_FQDN_QUERY		UINT_C(139)	/* FQDN ç
+§ä¼			*/
+#define ICMP6_FQDN_REPLY		UINT_C(140)	/* FQDN å¿ç­			*/
+
+#define ICMP6_NI_QUERY			UINT_C(139)	/* ãã¼ãæ
+å ±ç
+§ä¼		*/
+#define ICMP6_NI_REPLY			UINT_C(140)	/* ãã¼ãæ
+å ±å¿ç­		*/
+
+#define ICMP6_MAX_TYPE			UINT_C(203)	/* ICMP6 ã¿ã¤ãã®æå¤§å¤		*/
+
+/*
+ *  ICMP6 ã³ã¼ã
+ */
+
+/* å®å
+å°éä¸å¯è½ */
+
+#define ICMP6_DST_UNREACH_NOROUTE	UINT_C(0)	/* å°éã«ã¼ããªãã		*/
+#define ICMP6_DST_UNREACH_ADMIN		UINT_C(1)	/* ç®¡çè
+ã«ããç¡å¹åä¸­ã	*/
+#define ICMP6_DST_UNREACH_NOTEIGHBOR	UINT_C(2)	/* è¿é£è
+ã§ã¯ãªããªã£ãã	*/
+#define ICMP6_DST_UNREACH_BEYOND_SCOPE	UINT_C(2)	/* ã¹ã³ã¼ããè¶
+ãã¦ããã	*/
+#define ICMP6_DST_UNREACH_ADDR		UINT_C(3)	/* å®å
+ã¢ãã¬ã¹ã«å°éä¸å¯è½ã	*/
+#define ICMP6_DST_UNREACH_NOPORT	UINT_C(4)	/* å®å
+ãã¼ãã«å°éä¸å¯è½ã	*/
+
+/* TTL è¶
+é */
+
+#define ICMP6_TIME_EXCEED_TRANSIT	UINT_C(0)	/* è»¢éæã« TTL==0 ã«ãªã£ãã	*/
+#define ICMP6_TIME_EXCEED_REASSEMBLY	UINT_C(1)	/* IP åæ§æã§ã¿ã¤ã ã¢ã¦ãããã*/
+
+/* ãããä¸æ­£ */
+
+#define ICMP6_PARAMPROB_HEADER		UINT_C(0)	/* ãããã«ä¸æ­£ããã£ãã	*/
+#define ICMP6_PARAMPROB_NEXT_HEADER	UINT_C(1)	/* æ¬¡ããããèªè­ã§ããªãã	*/
+#define ICMP6_PARAMPROB_OPTION		UINT_C(2)	/* ãªãã·ã§ã³ãèªè­ã§ããªãã	*/
+
+/* å
+é¨ä½¿ç¨ */
+#define ND_REDIRECT_ONLINK		UINT_C(0)	/* ãªã³ãªã³ã¯ã¸ã®åãç´ã	*/
+#define ND_REDIRECT_ROUTER		UINT_C(1)	/* ã«ã¼ã¿ã¸ã®åãç´ã		*/
+
+/*
+ *  å¶éå¤
+ */
+
+							/* ICMPv6 ã®æå¤§ãã¤ã­ã¼ãé·	*/
+#define ICMPV6_PAYLOAD_MAXLEN		(IPV6_MMTU - (IP6_HDR_SIZE + ICMP6_HDR_SIZE))
+
+/*
+ *  è¿é£è¦è«
+ */
+
+typedef struct t_neighbor_solicit_hdr {
+	T_ICMP6_HDR	hdr;
+	T_IN6_ADDR	target;
+	/* ãã®å¾ã«ãªãã·ã§ã³ãç¶ã */
+	} T_NEIGHBOR_SOLICIT_HDR;
+
+#define NEIGHBOR_SOLICIT_HDR_SIZE	(sizeof(T_NEIGHBOR_SOLICIT_HDR))
+#define IF_IP6_NEIGHBOR_SOLICIT_HDR_OFFSET	\
+					(IF_IP6_HDR_SIZE)
+
+#define GET_NEIGHBOR_SOLICIT_HDR(nbuf,nhoff)	\
+					((T_NEIGHBOR_SOLICIT_HDR*)((uint8_t*)((nbuf)->buf) + nhoff))
+#define GET_NEIGHBOR_SOLICIT_SDU(nbuf,nhoff)	\
+					((uint8_t*)((nbuf)->buf) + nhoff + NEIGHBOR_SOLICIT_HDR_SIZE)
+
+#define GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)		\
+					(GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_SOLICIT_HDR_SIZE)
+#define GET_IF_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf)	\
+					(GET_IP6_NEIGHBOR_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
+
+/*
+ *  è¿é£éç¥
+ */
+
+typedef struct t_neighbor_advert_hdr {
+	T_ICMP6_HDR	hdr;
+	T_IN6_ADDR	target;
+	/* ãã®å¾ã«ãªãã·ã§ã³ãç¶ã */
+	} T_NEIGHBOR_ADVERT_HDR;
+
+/* ICMP6 ãããã®ãã¼ã¿é¨ã®å®ç¾© */
+
+#define nd_na_flags_reserved		hdr.data.data32
+
+#define NEIGHBOR_ADVERT_HDR_SIZE	(sizeof(T_NEIGHBOR_ADVERT_HDR))
+#define IP6_NEIGHBOR_ADVERT_HDR_SIZE	(IP6_HDR_SIZE + NEIGHBOR_ADVERT_HDR_SIZE)
+#define IF_IP6_NEIGHBOR_ADVERT_HDR_SIZE	\
+					(IF_IP6_HDR_SIZE + NEIGHBOR_ADVERT_HDR_SIZE)
+#define IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET	\
+					(IF_IP6_HDR_SIZE)
+
+#define GET_NEIGHBOR_ADVERT_HDR(nbuf,nhoff)	\
+					((T_NEIGHBOR_ADVERT_HDR*)((uint8_t*)((nbuf)->buf) + nhoff))
+#define GET_NEIGHBOR_ADVERT_SDU(nbuf,nhoff)	\
+					((uint8_t*)((nbuf)->buf) + nhoff + NEIGHBOR_ADVERT_HDR_SIZE)
+
+#define GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)		\
+					(GET_IP6_HDR_SIZE(nbuf) + NEIGHBOR_ADVERT_HDR_SIZE)
+#define GET_IF_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf)	\
+					(GET_IP6_NEIGHBOR_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
+
+/*
+ *  è¿é£éç¥ãã©ã°ãnd_na_flags_reserved (hdr.data32) ã«è¨­å®ããã
+ */
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define ND_NA_FLG_OVERRIDE		ULONG_C(0x20000000)	/* è¿é£ã­ã£ãã·ã¥ä¸æ¸ã	*/
+#define ND_NA_FLG_SOLICITED		ULONG_C(0x40000000)	/* è¿é£è¦è«ã¸ã®å¿ç­	*/
+#define ND_NA_FLG_ROUTER		ULONG_C(0x80000000)	/* ã«ã¼ã¿éç¥		*/
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+#define ND_NA_FLG_OVERRIDE		ULONG_C(0x00000020)	/* è¿é£ã­ã£ãã·ã¥ä¸æ¸ã	*/
+#define ND_NA_FLG_SOLICITED		ULONG_C(0x00000040)	/* è¿é£è¦è«ã¸ã®å¿ç­	*/
+#define ND_NA_FLG_ROUTER		ULONG_C(0x00000080)	/* ã«ã¼ã¿éç¥		*/
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+/*
+ *  ã«ã¼ã¿éç¥
+ *
+ *    RFC4291: IP Version 6 Addressing Architecture
+ *    RFC4941: Privacy Extensions for Stateless Address Autoconfiguration in IPv6
+ *    RFC6106: IPv6 Router Advertisement Options for DNS Configuration
+ */
+
+typedef struct t_router_advert_hdr {
+	T_ICMP6_HDR	hdr;
+	uint32_t	reachable;		/* [ms] å°éå¯è½æé	*/
+	uint32_t	retransmit;		/* [ms] è¿é£è¦è«éä¿¡éé	*/
+	/* ãã®å¾ã«ãªãã·ã§ã³ãç¶ã */
+	} T_ROUTER_ADVERT_HDR;
+
+/* ICMP6 ãããã®ãã¼ã¿é¨ã®å®ç¾© */
+
+#define nd_ra_current_hoplimit		hdr.data.data8[0]
+#define nd_ra_flags			hdr.data.data8[1]
+#define nd_ra_router_lifetime		hdr.data.data16[1]	/* [s] ã«ã¼ã¿æå¹æé	*/
+
+#define ROUTER_ADVERT_HDR_SIZE		(sizeof(T_ROUTER_ADVERT_HDR))
+#define IP6_ROUTER_ADVERT_HDR_SIZE	(IP6_HDR_SIZE + ROUTER_ADVERT_HDR_SIZE)
+#define IF_IP6_ROUTER_ADVERT_HDR_SIZE	(IF_IP6_HDR_SIZE + ROUTER_ADVERT_HDR_SIZE)
+#define IF_IP6_ROUTER_ADVERT_HDR_OFFSET	(IF_IP6_HDR_SIZE)
+
+#define GET_ROUTER_ADVERT_HDR(nbuf,nhoff)	\
+					((T_ROUTER_ADVERT_HDR*)((uint8_t*)((nbuf)->buf) + nhoff))
+#define GET_ROUTER_ADVERT_SDU(nbuf,nhoff)	\
+					((uint8_t*)((nbuf)->buf) + nhoff + ROUTER_ADVERT_HDR_SIZE)
+
+#define GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf)	\
+					(GET_IP6_HDR_SIZE(nbuf) + ROUTER_ADVERT_HDR_SIZE)
+#define GET_IF_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf)	\
+					(GET_IP6_ROUTER_ADVERT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
+
+/*
+ *  ã«ã¼ã¿éç¥ãããã®ãã©ã°
+ */
+
+#define ND_RA_FLAG_MANAGED		UINT_C(0x80)
+#define ND_RA_FLAG_OTHER		UINT_C(0x40)
+#define ND_RA_FLAG_HA			UINT_C(0x20)
+
+/*
+ *  M: RAä»¥å¤ã®æ¹æ³ã§èªåçã«ã¢ãã¬ã¹ãè¨­å®ãããã¨ãè¨±å¯ããã
+ *  O: RAä»¥å¤ã®æ¹æ³ã§èªåçã«ã¢ãã¬ã¹ä»¥å¤ã®æ
+å ±ãè¨­å®ãããã¨ããè¨±å¯ããã
+ *
+ *   M   O
+ *  ON  ON	ã¢ãã¬ã¹ã¨ããä»¥å¤ã®æ
+å ±ãDHCPv6ã§è¨­å®ããï¼statefullï¼
+ *  ON  OFF	ã¢ãã¬ã¹ã¯DHCPv6ã§è¨­å®ããããããä»¥å¤ã¯æåã§è¨­å®ããã
+ *  OFF ON	ã¢ãã¬ã¹ã¯ RA ã§è¨­å®ããããããä»¥å¤ã®æ
+å ±ãDHCPv6ã§è¨­å®ããï¼statelessï¼
+ *  OFF OFF	DHCPv6 ã¯ä½¿ç¨ããªãã
+ */
+
+/*
+ *  ã«ã¼ã¿è¦è«
+ */
+
+typedef struct t_router_solicit_hdr {
+	T_ICMP6_HDR	hdr;
+	} T_ROUTER_SOLICIT_HDR;
+
+/* ICMP6 ãããã®ãã¼ã¿é¨ã®å®ç¾© */
+
+#define nd_rs_reserved			hdr.data.data32
+
+#define ROUTER_SOLICIT_HDR_SIZE		(sizeof(T_ROUTER_SOLICIT_HDR))
+#define IP6_ROUTER_SOLICIT_HDR_SIZE	(IP6_HDR_SIZE + ROUTER_SOLICIT_HDR_SIZE)
+#define IF_IP6_ROUTER_SOLICIT_HDR_SIZE	(IF_IP6_HDR_SIZE + ROUTER_SOLICIT_HDR_SIZE)
+#define IF_IP6_ROUTER_SOLICIT_HDR_OFFSET	\
+					(IF_IP6_HDR_SIZE)
+
+#define GET_ROUTER_SOLICIT_HDR(nbuf,nhoff)	\
+					((T_ROUTER_SOLICIT_HDR*)((uint8_t*)((nbuf)->buf) + nhoff))
+#define GET_ROUTER_SOLICIT_SDU(nbuf,nhoff)	\
+					((uint8_t*)((nbuf)->buf) + nhoff + ROUTER_SOLICIT_HDR_SIZE)
+
+#define GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)		\
+					(GET_IP6_HDR_SIZE(nbuf) + ROUTER_SOLICIT_HDR_SIZE)
+#define GET_IF_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf)	\
+					(GET_IP6_ROUTER_SOLICIT_HDR_SIZE(nbuf) + IF_HDR_SIZE)
+
+/*
+ *  è¿é£æ¢ç´¢ãªãã·ã§ã³
+ */
+
+/* è¿é£æ¢ç´¢ããã */
+
+typedef struct t_neighbor_hdr {
+	T_ICMP6_HDR	hdr;
+	T_IN6_ADDR	target;
+	} T_NEIGHBOR_HDR;
+
+/* è¿é£æ¢ç´¢ãªãã·ã§ã³ããã */
+
+typedef struct t_nd_opt_hdr {
+	uint8_t		type;			/* ãªãã·ã§ã³ã¿ã¤ã			*/
+	uint8_t		len;			/* ãªãã·ã§ã³é·ãåä½ã¯ 8 ãã¤ã	*/
+	} T_ND_OPT_HDR;
+
+#define ND_OPT_HDR_SIZE			(sizeof(T_ND_OPT_HDR))
+
+#define ND_OPT_SOURCE_LINKADDR		UINT_C(1)	/* éä¿¡å
+ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+#define ND_OPT_TARGET_LINKADDR		UINT_C(2)	/* å¯¾è±¡ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+#define ND_OPT_PREFIX_INFORMATION	UINT_C(3)	/* ãã¬ãã£ãã¯ã¹æ
+å ±				*/
+#define ND_OPT_REDIRECTED_HEADER	UINT_C(4)	/* ãªãã¤ã¬ã¯ãã»ããã				*/
+#define ND_OPT_MTU			UINT_C(5)	/* MTU						*/
+
+#define ND_OPT_PREFIX_INFO_COUNT	UINT_C(6)	/* ãã¬ãã£ãã¯ã¹æ
+å ±ã®åæ°			*/
+#define ND_OPT_OFF_ARRAY_SIZE		UINT_C(7)	/* ND ãªãã·ã§ã³ã®ãªãã»ãããè¨é²ããé
+åãµã¤ãº*/
+
+#define ND_OPT_OFF_ARRAY_IX(t)		((t)-1)		/* ãªãã»ããé
+åã®ã¤ã³ããã¯ã¹			*/
+
+/* ãã¬ãã£ãã¯ã¹ãªãã·ã§ã³ */
+
+typedef struct t_nd_opt_prefix_info {
+	uint8_t		type;		/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã¿ã¤ã = 3	*/
+	uint8_t		len;		/* ãªãã·ã§ã³é· = 8Ã4=32	*/
+	uint8_t		prefix_len;	/* ãã¬ãã£ãã¯ã¹é·		*/
+	uint8_t		flags;		/* ãã©ã°			*/
+	uint32_t	valid;		/* [s] æå¹æé			*/
+	uint32_t	preferred;	/* [s] æ¨å¥¨æå¹æé		*/
+	uint32_t	reserved;
+	T_IN6_ADDR	prefix;		/* ãã¬ãã£ãã¯ã¹		*/
+	} T_ND_OPT_PREFIX_INFO;
+
+#define ND_OPT_PI_FLAG_ONLINK	UINT_C(0x80)		/* ãªã³ãªã³ã¯ãã¬ãã£ãã¯ã¹	*/
+#define ND_OPT_PI_FLAG_AUTO	UINT_C(0x40)		/* ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®*/
+
+/* MTU ãªãã·ã§ã³ããã */
+
+typedef struct t_nd_opt_mtu_hdr {
+	uint8_t		type;		/* ãªãã·ã§ã³ã¿ã¤ã		*/
+	uint8_t		len;		/* ãªãã·ã§ã³é·ãåä½ã¯ 8 ãã¤ã*/
+	uint16_t	reserved;
+	uint32_t	mtu;		/* MTU				*/
+	} T_ND_OPT_MTU_HDR;
+
+/*
+ *  åãç´ã
+ */
+
+typedef struct t_nd_redirect_hdr {
+	T_ICMP6_HDR	hdr;
+	T_IN6_ADDR	target;		/* ã«ã¼ã¿ã®ã¢ãã¬ã¹		*/
+	T_IN6_ADDR	dst;		/* åãç´ãã®çµç¹ã¢ãã¬ã¹		*/
+	/* ãã®å¾ã«ãªãã·ã§ã³ãç¶ã */
+	} T_ND_REDIRECT_HDR;
+
+#define ND_REDIRECT_HDR_SIZE		(sizeof(T_ND_REDIRECT_HDR))
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_icmp6_ifstat {
+	uint32_t	ipv6IfIcmpInMsgs;
+	uint32_t	ipv6IfIcmpInErrors;
+	uint32_t	ipv6IfIcmpInDestUnreachs;
+/*	uint32_t	ipv6IfIcmpInAdminProhibs;*/
+	uint32_t	ipv6IfIcmpInTimeExcds;
+	uint32_t	ipv6IfIcmpInParmProblems;
+	uint32_t	ipv6IfIcmpInPktTooBigs;
+	uint32_t	ipv6IfIcmpInEchos;
+	uint32_t	ipv6IfIcmpInEchoReplies;
+/*	uint32_t	ipv6IfIcmpInRouterSolicits;*/
+	uint32_t	ipv6IfIcmpInRouterAdvertisements;
+	uint32_t	ipv6IfIcmpInNeighborSolicits;
+	uint32_t	ipv6IfIcmpInNeighborAdvertisements;
+	uint32_t	ipv6IfIcmpInRedirects;
+/*	uint32_t	ipv6IfIcmpInGroupMembQueries;*/
+/*	uint32_t	ipv6IfIcmpInGroupMembResponses;*/
+/*	uint32_t	ipv6IfIcmpInGroupMembReductions;*/
+	uint32_t	ipv6IfIcmpOutMsgs;
+	uint32_t	ipv6IfIcmpOutErrors;
+	uint32_t	ipv6IfIcmpOutDestUnreachs;
+/*	uint32_t	ipv6IfIcmpOutAdminProhibs;*/
+/*	uint32_t	ipv6IfIcmpOutTimeExcds;*/
+	uint32_t	ipv6IfIcmpOutParmProblems;
+	uint32_t	ipv6IfIcmpOutPktTooBigs;
+	uint32_t	ipv6IfIcmpOutEchos;
+	uint32_t	ipv6IfIcmpOutEchoReplies;
+	uint32_t	ipv6IfIcmpOutRouterSolicits;
+/*	uint32_t	ipv6IfIcmpOutRouterAdvertisements;*/
+	uint32_t	ipv6IfIcmpOutNeighborSolicits;
+	uint32_t	ipv6IfIcmpOutNeighborAdvertisements;
+/*	uint32_t	ipv6IfIcmpOutRedirects;*/
+/*	uint32_t	ipv6IfIcmpOutGroupMembQueries;*/
+/*	uint32_t	ipv6IfIcmpOutGroupMembResponses;*/
+/*	uint32_t	ipv6IfIcmpOutGroupMembReductions;*/
+} T_ICMP6_IFSTAT;
+
+extern T_ICMP6_IFSTAT icmp6_ifstat;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  é¢æ°
+ */
+
+extern uint_t icmp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern void icmp6_error (T_NET_BUF *input, uint8_t type, uint8_t code, uint32_t param);
+
+#ifdef ICMP_CFG_CALLBACK_ECHO_REPLY
+
+extern void icmp6_echo_reply (T_NET_BUF *input, uint_t ihoff);
+
+#endif	/* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
+
+#endif	/* of #ifndef _IP_ICMP6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/icmp_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/icmp_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/icmp_var.h	(revision 317)
@@ -0,0 +1,125 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)icmp_var.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/icmp_var.h,v 1.15.2.2 2001/12/07 09:23:11 ru Exp $
+ */
+
+#ifndef _ICMP_VAR_H_
+#define _ICMP_VAR_H_
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_icmp_stats {
+/*	uint32_t	icmpInMsgs;*/
+	uint32_t	icmpInErrors;
+	uint32_t	icmpInDestUnreachs;
+/*	uint32_t	icmpInTimeExcds;*/
+/*	uint32_t	icmpInParmProbs;*/
+/*	uint32_t	icmpInSrcQuenchs;*/
+	uint32_t	icmpInRedirects;
+	uint32_t	icmpInEchos;
+	uint32_t	icmpInEchoReps;
+/*	uint32_t	icmpInTimestamps;*/
+/*	uint32_t	icmpInTimestampReps;*/
+/*	uint32_t	icmpInAddrMasks;*/
+/*	uint32_t	icmpInAddrMaskReps;*/
+	uint32_t	icmpOutMsgs;
+	uint32_t	icmpOutErrors;
+	uint32_t	icmpOutDestUnreachs;
+/*	uint32_t	icmpOutTimeExcds;*/
+/*	uint32_t	icmpOutParmProbs;*/
+/*	uint32_t	icmpOutSrcQuenchs;*/
+/*	uint32_t	icmpOutRedirects;*/
+	uint32_t	icmpOutEchos;
+	uint32_t	icmpOutEchoReps;
+/*	uint32_t	icmpOutTimestamps;*/
+/*	uint32_t	icmpOutTimestampReps;*/
+/*	uint32_t	icmpOutAddrMasks;*/
+/*	uint32_t	icmpOutAddrMaskReps;*/
+} T_ICMP_STATS;
+
+extern T_ICMP_STATS icmp_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#endif	/* of #ifndef _ICMP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/if_ether.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/if_ether.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/if_ether.c	(revision 317)
@@ -0,0 +1,523 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if_ether.c	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/if_ether.c,v 1.52.2.6 1999/10/18 11:59:31 sheldonh Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
+
+/*
+ *  ARP ã­ã£ãã·ã¥ã¨ã³ããª
+ */
+
+static T_ARP_ENTRY arp_cache[NUM_ARP_ENTRY];
+
+/*
+ *  é¢æ°
+ */
+
+static void in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input);
+static void arp_timer (void *ignore);
+
+/*
+ *  in_arpinput -- TCP/IP ç¨ ARP ã®å
+¥åé¢æ°
+ */
+
+static void
+in_arpinput (T_IF_ADDR *ifaddr, T_NET_BUF *input)
+{
+	T_NET_BUF	*pending;
+	T_ETHER_HDR	*eth;
+	T_ARP_HDR	*arph;
+	T_ETHER_ARP_HDR	*et_arph;
+	T_ARP_ENTRY	*ent;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN4_ADDR	saddr, taddr;
+
+	et_arph = GET_ETHER_ARP_HDR(input);
+
+	ntoahl(saddr, et_arph->sproto);		/* éä¿¡å
+ IP ã¢ãã¬ã¹	*/
+	ntoahl(taddr, et_arph->tproto);		/* è§£æ±ºå¯¾è±¡ IP ã¢ãã¬ã¹	*/
+
+	/*
+	 *  ä»¥ä¸ã®å ´åã¯ã¨ã©ã¼
+	 *    ã»éä¿¡ãã¹ãã®ç©çã¢ãã¬ã¹ãèªå
+	 *    ã»éä¿¡ãã¹ãã®ç©çã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+	 */
+	if (memcmp(et_arph->shost, ifaddr->lladdr,        ETHER_ADDR_LEN) == 0 ||
+	    memcmp(et_arph->shost, ether_broad_cast_addr, ETHER_ADDR_LEN) == 0)
+		goto err_ret;
+
+	/*
+	 *  éä¿¡ãã¹ãã® IP ã¢ãã¬ã¹ãèªåã®å ´åã¯ãéè¤ãã¦ããã®ã§
+	 *  ç¸æã«ãç¥ãããã
+	 *  ãã ããèªåã¨ç¸æã®ã¢ãã¬ã¹ãæªå®ç¾©ï¼IPV4_ADDRANYï¼ã®æã¯ä½ãããªãã
+	 */
+	if ((saddr == ifp->in4_ifaddr.addr) && (saddr != IPV4_ADDRANY)) {
+
+#ifdef ARP_CFG_CALLBACK_DUPLICATED
+
+		if (arp_callback_duplicated(et_arph->shost)) {
+			syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
+			                  ip2str(NULL, &ifp->in4_ifaddr.addr),
+			                  mac2str(NULL, et_arph->shost));
+			taddr = saddr;
+			goto reply;
+			}
+		else
+			goto buf_rel;
+
+#else	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
+
+		syslog(LOG_ERROR, "[ARP] IP address duplicated: %s",
+			          ip2str(NULL, &ifp->in4_ifaddr.addr),
+			          mac2str(NULL, et_arph->shost));
+		taddr = saddr;
+		goto reply;
+
+#endif	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
+
+		}
+
+	/*
+	 *  ä»¥ä¸ã®å ´åã¯ä½ãããªãã
+	 *    ã»è§£æ±ºå¯¾è±¡ IP ã¢ãã¬ã¹ãèªåã§ã¯ãªããæ³¨: å
+ã® FreeBSD ã®
+	 *      å®è£
+ã§ã¯ãARP PROXY ç­ã®ãããèªåä»¥å¤ã® IP ã¢ãã¬ã¹ã®
+	 *      è§£æ±ºãè¡ã£ã¦ããããæ¬å®è£
+ã§ã¯ãèªåä»¥å¤ã® IP
+	 *      ã¢ãã¬ã¹ã®è§£æ±ºã¯è¡ããªãã
+	 */
+	if (taddr != ifp->in4_ifaddr.addr)
+		goto buf_rel;
+
+	/*
+	 *  éä¿¡å
+ IP ã¢ãã¬ã¹ã ARP ã­ã£ãã·ã¥ã«ãããèª¿ã¹ãã
+	 *  ã­ã£ãã·ã¥ã«ãªããã°ãæ°ãã«ã¨ã³ããªãç»é²ããã
+	 */
+	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
+	ent = arp_lookup(saddr, true);
+
+	memcpy(ent->mac_addr, et_arph->shost, ETHER_ADDR_LEN);
+	ent->expire = ARP_CACHE_KEEP;
+
+	/*
+	 *  éä¿¡ããã³ãã³ã°ããã¦ãããã¬ã¼ã ãããã°éä¿¡ããã
+	 */
+	if (ent->hold) {
+
+		/* ãã¬ã¼ã ã® Ethernet ããããè¨­å®ããã*/
+		memcpy(GET_ETHER_HDR(ent->hold)->dhost, ent->mac_addr, ETHER_ADDR_LEN);
+
+		pending = ent->hold;
+		ent->hold = NULL;
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+
+		/* ãã³ãã£ã³ã°ããã¦ãããã¬ã¼ã ãéä¿¡ããã*/
+		IF_RAW_OUTPUT(pending, TMO_FEVR);
+
+		}
+	else
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+
+reply:
+
+	arph = GET_ARP_HDR(input);
+
+	/* ã¢ãã¬ã¹è§£æ±ºè¦æ±ã§ãªããã°çµäº */
+	if (ntohs(arph->opcode) != ARPOP_REQUEST)
+		goto buf_rel;
+
+	/* Ethernet ARP ããããè¨­å®ããã*/
+	memcpy(et_arph->thost, et_arph->shost, ETHER_ADDR_LEN);
+	memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
+	memcpy(et_arph->tproto, (uint8_t*)&et_arph->sproto, sizeof(T_IN_ADDR));
+	ahtonl(et_arph->sproto, taddr);
+
+	/* Ethernet ARP ããããè¨­å®ããã*/
+	arph->opcode = htons(ARPOP_REPLY);
+
+	/* Ethernet ããããè¨­å®ããã*/
+	eth = GET_ETHER_HDR(input);
+	memcpy(eth->dhost, eth->shost,     ETHER_ADDR_LEN);
+	memcpy(eth->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
+
+	/* ARP å¿ç­ãéä¿¡ããã*/
+	IF_RAW_OUTPUT(input, TMO_FEVR);
+	return;
+
+err_ret:
+	NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
+buf_rel:
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  arp_timer -- ARP ã­ã£ãã·ã¥ã®æ´æ°
+ */
+
+static void
+arp_timer (void *ignore)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
+
+	for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
+		if (arp_cache[ix].expire) {
+			arp_cache[ix].expire -= ARP_TIMER_TMO;
+			if (arp_cache[ix].expire == 0) {
+				/* éä¿¡ããã³ãã³ã°ããã¦ãããã¬ã¼ã ãããã°æ¨ã¦ãã*/
+				if (arp_cache[ix].hold) {
+					NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+					syscall(rel_net_buf(arp_cache[ix].hold));
+					}
+				memset(&arp_cache[ix], 0, sizeof(T_ARP_ENTRY));
+				}
+			}
+		}
+
+	syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+	timeout(arp_timer, NULL, ARP_TIMER_TMO);
+	}
+
+/*
+ *  arp_lookup -- ARP ã­ã£ãã·ã¥ã®æ¢ç´¢ã¨ç»é²
+ *
+ *    æ³¨æ: SEM_ARP_CACHE_LOCK ãç²å¾ããç¶æ
+ã§å¼åºããã¨
+ */
+
+T_ARP_ENTRY *
+arp_lookup (T_IN4_ADDR addr, bool_t create)
+{
+	int_t		ix, six;
+	uint16_t	min;
+
+	for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
+		if (arp_cache[ix].expire && arp_cache[ix].ip_addr == addr)
+			return &arp_cache[ix];
+		}
+
+	/* create ãçãªããæ°ããªã¨ã³ããªãç»é²ããã*/
+	if (create) {
+
+		/* ã¾ããç©ºããããã°ããã®ç©ºããå©ç¨ããã*/
+		for (ix = NUM_ARP_ENTRY; ix -- > 0; ) {
+			if (arp_cache[ix].expire == 0) {
+				arp_cache[ix].ip_addr = addr;
+				return &arp_cache[ix];
+				}
+			}
+
+		/*
+		 *  ç©ºãããªããã°ãã¿ã¤ã ã¢ã¦ãã¾ã§æéãæç­ã®
+		 *  ã¨ã³ããªã¼ãç ´æ£ãã¦å©ç¨ããã
+		 */
+		syslog(LOG_NOTICE, "[ARP] cache busy, size=%d", NUM_ARP_ENTRY);
+		min = 0xffff;
+		for (six = ix = NUM_ARP_ENTRY; ix -- > 0; )
+			if (arp_cache[ix].expire < min) {
+				six = ix;
+				min = arp_cache[ix].expire;
+				}
+		arp_cache[six].expire  = 0;
+		arp_cache[six].ip_addr = addr;
+		return &arp_cache[six];
+		}
+	else
+		return NULL;
+	}
+
+/*
+ *  arp_request -- MAC ã¢ãã¬ã¹è§£æ±ºè¦æ±
+ */
+
+ER
+arp_request (T_IF_ADDR *ifaddr, T_IN4_ADDR dst)
+{
+	ER		error;
+	T_IN4_ADDR	src;
+	T_ETHER_HDR	*eth;
+	T_ARP_HDR	*arph;
+	T_ETHER_ARP_HDR	*et_arph;
+	T_NET_BUF	*arp_req;
+
+	NET_COUNT_ARP(net_count_arp.out_octets , IF_ARP_ETHER_HDR_SIZE - IF_HDR_SIZE);
+	NET_COUNT_ARP(net_count_arp.out_packets, 1);
+
+	if ((error = tget_net_buf(&arp_req, IF_ARP_ETHER_HDR_SIZE, TMO_ARP_GET_NET_BUF)) == E_OK) {
+
+		/* ã¤ã¼ãµãããããããè¨­å®ããã*/
+		eth     = GET_ETHER_HDR(arp_req);
+		memcpy(eth->dhost, ether_broad_cast_addr, ETHER_ADDR_LEN);
+		memcpy(eth->shost, ifaddr->lladdr,        ETHER_ADDR_LEN);
+		eth->type = htons(ETHER_TYPE_ARP);
+
+		/* ARP ããããè¨­å®ããã*/
+		arph    = GET_ARP_HDR(arp_req);
+		arph->hrd_addr  = htons(ARPHRD_ETHER);
+		arph->proto     = htons(ETHER_TYPE_IP);
+		arph->hdr_len   = sizeof(et_arph->shost);
+		arph->proto_len = sizeof(et_arph->sproto);
+		arph->opcode    = htons(ARPOP_REQUEST);
+
+		/* ã¤ã¼ãµããã ARP ããããè¨­å®ããã*/
+		et_arph = GET_ETHER_ARP_HDR(arp_req);
+		src     = IF_GET_IFNET()->in4_ifaddr.addr;
+		memcpy(et_arph->shost, ifaddr->lladdr, ETHER_ADDR_LEN);
+		memset(et_arph->thost, 0,              ETHER_ADDR_LEN);
+		ahtonl(et_arph->sproto, src);
+		ahtonl(et_arph->tproto, dst);
+
+		/* éä¿¡ããã*/
+		error = IF_RAW_OUTPUT(arp_req, TMO_ARP_OUTPUT);
+		}
+	if (error != E_OK)
+		NET_COUNT_ARP(net_count_arp.out_err_packets, 1);
+	return error;
+	}
+
+/*
+ *  arp_get_cache -- ARP ã­ã£ãã·ã¥ãç²å¾ããã
+ */
+
+const T_ARP_ENTRY *
+arp_get_cache (void)
+{
+	return arp_cache;
+	}
+
+/*
+ *  arp_input -- ARP ã®å
+¥åé¢æ°
+ */
+
+void
+arp_input (T_IF_ADDR *ifaddr, T_NET_BUF *input)
+{
+	T_ARP_HDR	*arph;
+
+	NET_COUNT_ARP(net_count_arp.in_octets , input->len - IF_HDR_SIZE);
+	NET_COUNT_ARP(net_count_arp.in_packets, 1);
+
+	/* ARP ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < IF_ARP_HDR_SIZE)
+		goto buf_rel;
+
+	arph = GET_ARP_HDR(input);
+
+	/*
+	 *  ç©çã¢ãã¬ã¹ãã©ã¼ãããã Ehternet ä»¥å¤
+	 *  ã¾ãã¯ããã­ãã³ã«ã IP ä»¥å¤ã¯ã¨ã©ã¼ã
+	 */
+	if (ntohs(arph->hrd_addr) != ARPHRD_ETHER ||
+	    ntohs(arph->proto)    != ETHER_TYPE_IP)
+		goto buf_rel;
+
+	/* ARP ããã + Ether ARP ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < IF_ARP_ETHER_HDR_SIZE)
+		goto buf_rel;
+
+	in_arpinput(ifaddr, input);
+	return;
+
+buf_rel:
+	NET_COUNT_ARP(net_count_arp.in_err_packets, 1);
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  arp_resolve -- MAC ã¢ãã¬ã¹è§£æ±º
+ *
+ *    ã¢ãã¬ã¹è§£æ±ºãã§ããã°ãæ»ãå¤ã¯ true ãè¿ããã§ããªããã°
+ *    éä¿¡ããã³ãã£ã³ã°ãã¦ãæ»ãå¤ã¯ false ãè¿ãã
+ */
+
+bool_t
+arp_resolve (T_IF_ADDR *ifaddr, T_NET_BUF *output, T_IN4_ADDR gw)
+{
+	T_ARP_ENTRY	*ent;
+	T_ETHER_HDR	*eth;
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	eth = GET_ETHER_HDR(output);
+
+	/*
+	 *  æ¬¡ã®å ´åã¯ãã¤ã¼ãµãããã®ãã­ã¼ãã­ã£ã¹ãã¢ãã¬ã¹ãè¿ãã
+	 *
+	 *    ã»å
+¨ãããã 1
+	 *    ã»ãã¹ãé¨ã®å
+¨ãããã 1 ã§ããããã¯ã¼ã¯é¨ãã­ã¼ã«ã«ã¢ãã¬ã¹
+	 */
+	if (gw == IPV4_ADDR_BROADCAST ||
+	    gw == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask)) {
+		memcpy(eth->dhost, ether_broad_cast_addr, ETHER_ADDR_LEN);
+		return true;
+		}
+
+	/* éä¿¡å
+ GW ã® IP ã¢ãã¬ã¹ã ARP ã­ã£ãã·ã¥ã«ãããèª¿ã¹ãã*/
+	syscall(wai_sem(SEM_ARP_CACHE_LOCK));
+	ent = arp_lookup(gw, true);
+	if (ent->expire) {
+		memcpy(eth->dhost, ent->mac_addr, ETHER_ADDR_LEN);
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+		return true;
+		}
+	else {
+	 	/* éä¿¡ããã³ãã³ã°ããã¦ãããã¬ã¼ã ãããã°æ¨ã¦ãã*/
+		if (ent->hold) {
+			NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+			syscall(rel_net_buf(ent->hold));
+			}
+
+		/*
+		 *  éä¿¡ããã³ãã£ã³ã°ããã
+		 *  IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ãè¨­å®ããã¦ããã¨ãã¯ã
+		 *  éä¿¡ããã³ãã£ã³ã°ããªãã
+		 */
+		if ((output->flags & NB_FLG_NOREL_IFOUT) == 0)
+			ent->hold = output;
+		else {
+			output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+			ent->hold = NULL;
+			}
+		syscall(sig_sem(SEM_ARP_CACHE_LOCK));
+
+		/* ã¢ãã¬ã¹è§£æ±ºè¦æ±ãéä¿¡ããã*/
+		arp_request(ifaddr, gw);
+		return false;
+		}
+	}
+
+/*
+ *  arp_init -- ARP åæå
+ */
+
+void
+arp_init (void)
+{
+	timeout(arp_timer, NULL, ARP_TIMER_TMO);
+	}
+
+#endif	/* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
Index: asp3_gr_sakura/trunk/tinet/netinet/if_ether.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/if_ether.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/if_ether.cfg	(revision 317)
@@ -0,0 +1,56 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  Ethernet ARP ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#if defined(_IP4_CFG) && defined(SUPPORT_ETHER)
+
+/* ARP ã­ã£ãã·ã¥æ´æ°ç¨ã»ããã© */
+
+CRE_SEM(SEM_ARP_CACHE_LOCK, { TA_TPRI, 1, 1 });
+
+#endif	/* of #if defined(_IP4_CFG) && defined(SUPPORT_ETHER) */
Index: asp3_gr_sakura/trunk/tinet/netinet/if_ether.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/if_ether.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/if_ether.h	(revision 317)
@@ -0,0 +1,141 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)if_ether.h	8.3 (Berkeley) 5/2/95
+ * $FreeBSD: src/sys/netinet/if_ether.h,v 1.21.2.1 1999/08/29 16:29:31 peter Exp $
+ */
+
+#ifndef _IF_ETHER_H_
+#define _IF_ETHER_H_
+
+#ifdef SUPPORT_ETHER
+
+/*
+ *  Ethernet Address Resolution Protocol.
+ *
+ *  RFC 826 åç
+§
+ */
+
+typedef struct t_ether_arp_hdr {
+	uint8_t		shost[ETHER_ADDR_LEN];	/* éä¿¡ãã¹ãã®ç©çã¢ãã¬ã¹	*/
+	uint8_t		sproto[IPV4_ADDR_LEN];	/* éä¿¡ãã¹ãã® IP ã¢ãã¬ã¹	*/
+	uint8_t		thost[ETHER_ADDR_LEN];	/* è§£æ±ºå¯¾è±¡ç©çã¢ãã¬ã¹		*/
+	uint8_t		tproto[IPV4_ADDR_LEN];	/* è§£æ±ºå¯¾è±¡ IP ã¢ãã¬ã¹		*/
+	} T_ETHER_ARP_HDR;
+
+#define ETHER_ARP_HDR_SIZE		(sizeof(T_ETHER_ARP_HDR))
+#define IF_ARP_ETHER_HDR_SIZE		(IF_HDR_SIZE + ARP_HDR_SIZE + ETHER_ARP_HDR_SIZE)
+
+#define GET_ETHER_ARP_HDR(nbuf)		((T_ETHER_ARP_HDR*)((nbuf)->buf + GET_IF_ARP_HDR_SIZE(nbuf)))
+
+/*
+ *  ARP ã­ã£ãã·ã¥ã¨ã³ããª
+ */
+
+typedef struct arp_entry {
+	T_NET_BUF	*hold;		/* ARP ã®è§£æ±ºå¾
+ã¡åºåãã¬ã¼ã 	*/
+	T_IN4_ADDR	ip_addr;	/* IP ã¢ãã¬ã¹			*/
+	uint16_t	expire;		/* ç ´æ£ã¾ã§ã®æéã0 ãªãæªä½¿ç¨	*/
+	uint8_t		mac_addr[ETHER_ADDR_LEN];	/* MAC ã¢ãã¬ã¹	*/
+	} T_ARP_ENTRY;
+
+/*
+ *  é¢æ°
+ */
+
+extern T_ARP_ENTRY *arp_lookup (T_IN4_ADDR addr, bool_t create);
+extern ER arp_request (T_IF_ADDR *ifaddr, T_IN4_ADDR dst);
+extern void arp_input (T_IF_ADDR *ifaddr, T_NET_BUF *input);
+extern bool_t arp_resolve (T_IF_ADDR *ifaddr, T_NET_BUF *output, T_IN4_ADDR gw);
+extern void arp_init (void);
+extern const T_ARP_ENTRY *arp_get_cache (void);
+
+/*
+ *  TINET ç¬èª API
+ */
+
+#ifdef ARP_CFG_CALLBACK_DUPLICATED
+
+extern bool_t arp_callback_duplicated(uint8_t *shost);
+
+#endif	/* of #ifdef ARP_CFG_CALLBACK_DUPLICATED */
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#endif	/* of #ifndef _IF_ETHER_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in.h	(revision 317)
@@ -0,0 +1,192 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in.h	8.3 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
+ */
+ 
+#ifndef _IN_H_
+#define _IN_H_
+
+#include <tinet_kernel_defs.h>
+
+#include <netinet/in4.h>
+#include <netinet6/in6.h>
+
+/*
+ *  TINET ã®ãã¼ã¸ã§ã³æ
+å ±
+ */
+
+#define TINET_PRVER		UINT_C(0x1070)	/* TINET ã®ãã¼ã¸ã§ã³çªå· */
+
+/*
+ *  ã¤ã³ã¿ã¼ãããã·ã¹ãã ã®å®ç¾©ãRFC790 åç
+§
+ */
+
+/*
+ *  ãã­ãã³ã« (RFC1700)
+ */
+
+#define IPPROTO_IP		UINT_C(0)	/* IP ã®ããã¼				*/
+#define IPPROTO_HOPOPTS		UINT_C(0)	/* IPv6 ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³	*/
+#define IPPROTO_ICMP		UINT_C(1)	/* ICMP					*/
+#define IPPROTO_TCP		UINT_C(6)	/* TCP					*/
+#define IPPROTO_UDP		UINT_C(17)	/* UDP					*/
+#define IPPROTO_IPV6		UINT_C(41)	/* IPv6					*/
+#define IPPROTO_ROUTING		UINT_C(43)	/* çµè·¯å¶å¾¡ãªãã·ã§ã³			*/
+#define IPPROTO_FRAGMENT	UINT_C(44)	/* æ­çåãªãã·ã§ã³			*/
+#define IPPROTO_RSVP		UINT_C(46)	/* RSVP					*/
+#define IPPROTO_ESP		UINT_C(50)	/* IPv6 æå·åãªãã·ã§ã³		*/
+#define IPPROTO_AH		UINT_C(51)	/* IPv6 èªè¨¼ãªãã·ã§ã³			*/
+#define IPPROTO_ICMPV6		UINT_C(58)	/* ICMPv6				*/
+#define IPPROTO_NONE		UINT_C(59)	/* IPv6 æ¬¡ãããç¡ã			*/
+#define IPPROTO_DSTOPTS		UINT_C(60)	/* IPv6 çµç¹ãªãã·ã§ã³			*/
+#define IPPROTO_IPCOMP		UINT_C(108)	/* ãã¤ã­ã¼ãå§ç¸®			*/
+#define IPPROTO_DONE		UINT_C(257)	/* IPv6 ã§ä¸ä½ãã­ãã³ã«å
+¥åçµäº	*/
+
+/*
+ *  ãã¼ãã®é·ã
+ */
+
+#define PORT_NUM_LEN		2
+
+/*
+ *  ãã¼ãçªå·ã®å®ç¾©
+ */
+
+#define TCP_PORTANY			UINT_C(0x0000)	/* ITRON TCP/IP æ¨æº	*/
+#define UDP_PORTANY			UINT_C(0x0000)	/* ITRON TCP/IP æ¨æº	*/
+
+#define TCP_PORT_LAST_WELL_KNOWN	UINT_C(1023)	/* Well Known çµäºçªå·	*/
+#define TCP_PORT_FIRST_AUTO		UINT_C(1024)	/* èªåå²ãå½ã¦éå§çªå·	*/
+#define TCP_PORT_LAST_AUTO		UINT_C(4999)	/* èªåå²ãå½ã¦çµäºçªå·	*/
+
+#define UDP_PORT_LAST_WELL_KNOWN	UINT_C(1023)	/* Well Known çµäºçªå·	*/
+#define UDP_PORT_FIRST_AUTO		UINT_C(1024)	/* èªåå²ãå½ã¦éå§çªå·	*/
+#define UDP_PORT_LAST_AUTO		UINT_C(4999)	/* èªåå²ãå½ã¦çµäºçªå·	*/
+
+/*
+ *  API IPãã­ãã³ã«ã®æå®
+ */
+
+#define API_PROTO_IPVn			'n'
+#define API_PROTO_IPV6			'6'
+#define API_PROTO_IPV4			'4'
+
+/*
+ *  åççæç¨ TCP/IPv6 éä¿¡ç«¯ç¹
+ */
+
+#define T_TCP6_CCEP			T_TCP_CCEP
+
+/*
+ *  ãã¤ããªã¼ãé¢æ°ã®å®ç¾©
+ *
+ *    tinet/net/net.h ã§ããã¤ããªã¼ãã®å®ç¾©ãè¡ã£ã¦ãããã
+ *    tinet/net/net.h ãã¤ã³ã¯ã«ã¼ãããªã
+ *    ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ç¨ã«
+ *    ã¿ã¼ã²ããä¾å­ããªããã¤ããªã¼ãé¢æ°ãå®ç¾©ããã
+ */
+
+#if defined(_NET_CFG_BYTE_ORDER)
+
+/*  tinet/net/net.h ãã¤ã³ã¯ã«ã¼ããã¦ããã*/
+
+#else	/* of #if defined(_NET_CFG_BYTE_ORDER) */
+
+extern uint16_t ntohs (uint16_t net);
+extern uint16_t htons (uint16_t host);
+extern uint32_t ntohl (uint32_t net);
+extern uint32_t htonl (uint32_t host);
+
+#define NTOHS(n)	(n=ntohs(n))
+#define HTONS(h)	(h=htons(h))
+#define NTOHL(n)	(n=ntohl(n))
+#define HTONL(h)	(h=htonl(h))
+
+#endif	/* of #if defined(_NET_CFG_BYTE_ORDER) */
+
+/*
+ *  TINET ç¬èª API
+ */
+
+extern const char *in_strtfn (FN fncd);
+
+#endif	/* of #ifndef _IN_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in4.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in4.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in4.h	(revision 317)
@@ -0,0 +1,220 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in.h	8.3 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/in.h,v 1.38.2.3 1999/08/29 16:29:34 peter Exp $
+ */
+ 
+#ifndef _IN4_H_
+#define _IN4_H_
+
+/*
+ *  IPv4 ã¢ãã¬ã¹
+ */
+
+/* åæ¹åç
+§ */
+
+#ifndef T_IN4_ADDR_DEFINED
+
+typedef uint32_t T_IN4_ADDR;
+
+#define T_IN4_ADDR_DEFINED
+
+#endif	/* of #ifndef T_IN4_ADDR_DEFINED */
+
+/*
+ *  ITRON TCP/IPv4 ã¢ãã¬ã¹/ãã¼ãçªå·ã®å®ç¾©
+ */
+
+typedef struct t_ipv4ep {
+	uint32_t	ipaddr;		/* IPv4 ã¢ãã¬ã¹	*/
+	uint16_t	portno;		/* ãã¼ãçªå·		*/
+	} T_IPV4EP;
+
+#define T_IPV4EP_DEFINED
+
+/*
+ *  ã¢ãã¬ã¹ã®é·ã
+ */
+
+#define IPV4_ADDR_LEN		4
+
+/*
+ *  IPv4 ã¢ãã¬ã¹ã®å®ç¾©
+ */
+
+#define IPV4_ADDRANY		ULONG_C(0x00000000)	/* ITRON TCP/IP æ¨æº	*/
+#define IPV4_ADDRBROADCAST	ULONG_C(0xffffffff)
+
+#define IPV4_ADDR_LOOPBACK	ULONG_C(0x7f000001)
+#define IPV4_ADDR_LOOPBACK_MASK	IPV4_CLASS_A_MASK
+#define IPV4_ADDR_BROADCAST	ULONG_C(0xffffffff)
+
+#define IPV4_CLASS_A(i)		(((i) & ULONG_C(0x80000000)) == 0)
+#define IPV4_CLASS_A_NET	ULONG_C(0xff000000)
+#define IPV4_CLASS_A_MASK	ULONG_C(0xff000000)
+#define IPV4_CLASS_A_HOST	ULONG_C(0x00ffffff)
+
+#define IPV4_CLASS_B(i)		(((i) & ULONG_C(0xc0000000)) == ULONG_C(0x80000000))
+#define IPV4_CLASS_B_NET	ULONG_C(0xffff0000)
+#define IPV4_CLASS_B_MASK	ULONG_C(0xffff0000)
+#define IPV4_CLASS_B_HOST	ULONG_C(0x0000ffff)
+
+#define IPV4_CLASS_C(i)		(((i) & ULONG_C(0xe0000000)) == ULONG_C(0xc0000000))
+#define IPV4_CLASS_C_NET	ULONG_C(0xffffff00)
+#define IPV4_CLASS_C_MASK	ULONG_C(0xffffff00)
+#define IPV4_CLASS_C_HOST	ULONG_C(0x000000ff)
+
+#define IPV4_CLASS_D(i)		(((i) & ULONG_C(0xf0000000)) == ULONG_C(0xe0000000))
+
+#define IN4_IS_ADDR_MULTICAST(i)	IPV4_CLASS_D(i)
+
+#define MAKE_IPV4_LOCAL_BROADCAST(i)	(IPV4_CLASS_A(i)?((i)|IPV4_CLASS_A_HOST):\
+					 IPV4_CLASS_B(i)?((i)|IPV4_CLASS_B_HOST):\
+					 IPV4_CLASS_C(i)?((i)|IPV4_CLASS_C_HOST):\
+					 IPV4_ADDR_BROADCAST)
+
+#define MAKE_IPV4_LOCAL_MASK(i)		(IPV4_CLASS_A(i)?IPV4_CLASS_A_MASK:\
+					 IPV4_CLASS_B(i)?IPV4_CLASS_B_MASK:\
+					 IPV4_CLASS_C(i)?IPV4_CLASS_C_MASK:\
+					 IPV4_ADDRANY)
+
+#define MAKE_IPV4_ADDR(a,b,c,d)		((T_IN4_ADDR)(((uint32_t)(a)<<24)|((uint32_t)(b)<<16)|((uint32_t)(c)<<8)|(d)))
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define IN4_ARE_ADDR_EQUAL(dst,src)	(*(dst)==*(src))
+#define IN4_IS_ADDR_ANY(addr)		(*(addr)==IPV4_ADDRANY)
+#define IN4_IS_ADDR_BROADCAST(addr)	(*(addr)==IPV4_ADDRBROADCAST)
+#define ip2str(buf,p_ipaddr)		(ipv42str(buf,p_ipaddr))
+
+/*
+ *  åççæç¨ TCP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_tcp_ccep {
+	/* æ¨æº */
+	ATR		cepatr;		/* éä¿¡ç«¯ç¹å±æ§			*/
+	void		*sbuf;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		sbufsz;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	void		*rbuf;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		rbufsz;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	FP		callback;	/* ã³ã¼ã«ããã¯			*/
+	/* å®è£
+ä¾å­ */
+	} T_TCP_CCEP;
+
+/*
+ *  åççæç¨ TCP åä»å£
+ */
+
+typedef struct t_tcp_crep {
+	/* æ¨æº */
+	ATR		repatr;		/* åä»å£å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+	/* å®è£
+ä¾å­ */
+	} T_TCP_CREP;
+
+/*
+ *  åççæç¨ UDP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_udp_ccep {
+	/* æ¨æº */
+	ATR		cepatr;		/* UDP éä¿¡ç«¯ç¹å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	FP		callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+	/* å®è£
+ä¾å­ */
+	} T_UDP_CCEP;
+
+/*
+ *  TINET ç¬èª API
+ */
+
+extern char *ipv42str (char *buf, const T_IN4_ADDR *p_ipaddr);
+extern uint_t in4_get_maxnum_ifaddr (void);
+extern const T_IN4_ADDR *in4_get_ifaddr (int_t index);
+extern ER in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask);
+extern ER in4_add_route (int_t index, T_IN4_ADDR target,
+                                      T_IN4_ADDR mask, T_IN4_ADDR gateway);
+
+#endif	/* of #ifndef _IN4_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in4_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in4_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in4_subr.c	(revision 317)
@@ -0,0 +1,528 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+//#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG)
+
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in_rtinit -- ã«ã¼ãã£ã³ã°è¡¨ãåæåããã
+ */
+
+void
+in_rtinit (void)
+{
+	int_t ix;
+
+	for (ix = 0; ix < NUM_IN4_STATIC_ROUTE_ENTRY; ix ++)
+		routing4_tbl[ix].flags = IN_RTF_DEFINED;
+
+	for ( ; ix < NUM_IN4_ROUTE_ENTRY; ix ++)
+		routing4_tbl[ix].flags = 0;
+	}
+
+/*
+ *  in_rtnewentry -- æ°ããã¨ã³ããªãç²å¾ããã
+ */
+
+T_IN4_RTENTRY *
+in_rtnewentry (uint8_t flags, uint32_t tmo)
+{
+	SYSTIM		now;
+	T_IN4_RTENTRY	*rt, *frt = NULL;
+	int_t		ix;
+
+	/* ç©ºãã¨ã³ããªãæ¢ãã*/
+	for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+		rt = &routing4_tbl[ix];
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
+			frt = rt;
+			break;
+			}
+		}
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (frt == NULL) {
+		/* ç©ºãããªããã°ãæå¹æéããã£ã¨ãç­ãã¨ã³ããªãç©ºãã«ããã*/
+		T_IN4_RTENTRY	*srt = NULL;
+		int_t		diff, sdiff = INT_MAX;
+
+		syscall(wai_sem(SEM_IN4_ROUTING_TBL));
+		for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++) {
+			rt = &routing4_tbl[ix];
+			diff = (int_t)(rt->expire - now);
+			if (diff <= 0) {	/* rt->expire <= now */
+				/* æ¢ã«ãæå¹æéãéãã¦ããã*/
+				frt = rt;
+				break;
+				}
+			else if (diff < sdiff) {
+				srt = rt;
+				sdiff = diff;
+				}
+			}
+		if (frt == NULL)
+			frt = srt;
+		frt->flags = 0;
+		syscall(sig_sem(SEM_IN4_ROUTING_TBL));
+		}
+
+	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
+	frt->expire = now + tmo / SYSTIM_HZ;
+	return frt;
+	}
+
+/*
+ *  in_rttimer -- ã«ã¼ãã£ã³ã°è¡¨ã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+in_rttimer (void)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	syscall(wai_sem(SEM_IN4_ROUTING_TBL));
+	for (ix = NUM_IN4_STATIC_ROUTE_ENTRY; ix < NUM_IN4_ROUTE_ENTRY; ix ++)
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (int_t)(routing4_tbl[ix].expire - now) <= 0)
+			routing4_tbl[ix].flags = 0;
+	syscall(sig_sem(SEM_IN4_ROUTING_TBL));
+	}
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_get_maxnum_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®å¯è½ãªæå¤§ã¢ãã¬ã¹æ°ãè¿ãã
+ */
+
+uint_t
+in4_get_maxnum_ifaddr (void)
+{
+	return 1;
+	}
+
+/*
+ *  in4_get_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®ããã¦ããã¢ãã¬ã¹ãè¿ãã
+ */
+
+const T_IN4_ADDR *
+in4_get_ifaddr (int_t index)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	return &ifp->in4_ifaddr.addr;
+	}
+
+/*
+ *  in4_set_header -- IPv4 ããããè¨­å®ããã
+ */
+
+ER
+in4_set_header (T_NET_BUF *nbuf, uint_t len,
+                T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl)
+{
+	T_IP4_HDR	*ip4h = GET_IP4_HDR(nbuf);
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	/* IP ããããè¨­å®ããã*/
+	ip4h->vhl	= IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
+	ip4h->len	= htons(IP4_HDR_SIZE + len);
+	ip4h->proto	= proto;
+	ip4h->ttl	= ttl;
+	ip4h->type	= 0;
+	ip4h->id	= ip4h->flg_off = ip4h->sum = 0;
+
+	/* IP ã¢ãã¬ã¹ãè¨­å®ããã*/
+	ip4h->dst	= htonl(*dstaddr);
+
+	if (srcaddr == NULL || *srcaddr == IPV4_ADDRANY)
+		ip4h->src = htonl(ifp->in4_ifaddr.addr);
+	else
+		ip4h->src = htonl(*srcaddr);
+
+	return E_OK;
+	}
+
+/*
+ *  in4_get_datagram -- IPv4 ãã¼ã¿ã°ã©ã ãç²å¾ããããããè¨­å®ããã
+ */
+
+ER
+in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                  T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
+                  uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout)
+{
+	ER	error;
+	uint_t	align;
+
+	/* ãã¼ã¿é·ã 4 ãªã¯ãããå¢çã«èª¿æ´ããã*/
+	align = (len + 3) >> 2 << 2;
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+	if ((error = tget_net_buf_ex(nbuf, (uint_t)(IF_IP4_HDR_SIZE + align),
+	                                   (uint_t)(IF_IP4_HDR_SIZE + maxlen), nbatr, tmout)) != E_OK)
+		return error;
+
+	/*
+	 *  ããå¤§ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ãç²å¾ããå ´åã®ã¿é·ããèª¿æ´ããã
+	 *  ããå°ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã®ç²å¾ã¯ãéä¿¡ã¦ã£ã³ããããã¡ã®
+	 *  çã³ãã¼æ©è½ã§ä½¿ç¨ãããå®éã«éä¿¡ããã¾ã§ããã¼ã¿ãµã¤ãºã¯æ±ºå®ã§ããªãã
+	 */
+	if ((nbatr & NBA_SEARCH_ASCENT) != 0)
+		(*nbuf)->len = (uint16_t)(IF_IP4_HDR_SIZE + len);
+
+	/* IP ããããè¨­å®ããã*/
+	if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
+		return error;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((GET_IP4_SDU(*nbuf) + len), 0, (size_t)(align - len));
+
+	return E_OK;
+	}
+
+/*
+ *  in4_cksum -- IPv4 ã®ãã©ã³ã¹ãã¼ãå±¤ãããã®ãã§ãã¯ãµã ãè¨ç®ããã
+ *
+ *  æ³¨æ: æ»ãå¤ã¯ãããã¯ã¼ã¯ãã¤ããªã¼ã
+ */
+
+uint16_t
+in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len)
+{
+	uint32_t	sum;
+	uint_t		align;
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((uint8_t*)nbuf->buf + off + len, 0, (size_t)(align - len));
+
+	sum = in_cksum_sum(nbuf->buf + off, align)
+	    + in_cksum_sum(&GET_IP4_HDR(nbuf)->src, sizeof(T_IN4_ADDR) * 2)
+	    + len + proto;
+	sum = in_cksum_carry(sum);
+
+	return (uint16_t)(~htons((uint16_t)sum));
+	}
+
+/*
+ *  in_cksum -- ãã§ãã¯ãµã è¨ç®é¢æ°ãIPv4ãICMPv4 ç¨
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ *
+ *        æ»ãå¤ã¯ãããã¯ã¼ã¯ãã¤ããªã¼ã
+ */
+
+uint16_t
+in_cksum (void *data, uint_t len /*ãªã¯ãããåä½*/)
+{
+	uint16_t	sum;
+
+	sum = (uint16_t)in_cksum_carry(in_cksum_sum(data, len));
+	return (uint16_t)(~htons(sum));
+	}
+
+/*
+ *  in4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+
+bool_t
+in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr)
+{
+	if (*myaddr == IPV4_ADDRANY)
+		return ntohl(*dstaddr) == IF_GET_IFNET()->in4_ifaddr.addr;
+	else
+		return ntohl(*dstaddr) == *myaddr;
+	}
+
+/*
+ *  inn4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+
+bool_t
+inn4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *nbuf)
+{
+	T_IP4_HDR	*iph;
+
+	iph  = GET_IP4_HDR(nbuf);
+	if (*myaddr == IPV4_ADDRANY)
+		return ntohl(iph->dst) == IF_GET_IFNET()->in4_ifaddr.addr;
+	else
+		return ntohl(iph->dst) == *myaddr;
+	}
+
+/*
+ * in4_addrwithifp -- å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+ *                   ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
+ *                   in6_addrwithifp ãã·ãã¥ã¬ã¼ãããã ãã§ã
+ *                   ã¨ã©ã¼ãè¿ããã¨ã¯ãªãã
+ */
+
+T_IN4_ADDR *
+in4_addrwithifp (T_IFNET *ifp, T_IN4_ADDR *src, T_IN4_ADDR *dst)
+{
+	*src = ifp->in4_ifaddr.addr;
+	return src;
+	}
+
+/*
+ *  in4_add_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã« IPv4 ã¢ãã¬ã¹ãè¨­å®ããã
+ */
+
+ER
+in4_add_ifaddr (T_IN4_ADDR addr, T_IN4_ADDR mask)
+{
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ifp->in4_ifaddr.addr = addr;
+	ifp->in4_ifaddr.mask = mask;
+	return E_OK;
+	}
+
+#if NUM_IN4_ROUTE_ENTRY > 0
+
+/*
+ *  in4_add_route -- çµè·¯è¡¨ã«ã¨ã³ããªãè¨­å®ããã
+ */
+
+ER
+in4_add_route (int_t index, T_IN4_ADDR target, T_IN4_ADDR mask, T_IN4_ADDR gateway)
+{
+
+	if (0 <= index && index < NUM_IN4_STATIC_ROUTE_ENTRY) {
+		routing4_tbl[index].target  = target;
+		routing4_tbl[index].mask    = mask;
+		routing4_tbl[index].gateway = gateway;
+		return E_OK;
+		}
+	else
+		return E_PAR;
+	}
+
+#endif	/* of #if NUM_IN4_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_rtalloc -- ã«ã¼ãã£ã³ã°è¡¨ãæ¢ç´¢ããã
+ */
+
+T_IN4_ADDR
+in4_rtalloc (T_IN4_ADDR dst)
+{
+	int_t ix;
+
+	for (ix = NUM_IN4_ROUTE_ENTRY; ix --; )
+		if ((routing4_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (dst & routing4_tbl[ix].mask) == routing4_tbl[ix].target) {
+			if (routing4_tbl[ix].gateway == 0)
+				return dst;
+			else {
+				return routing4_tbl[ix].gateway;
+				}
+			}
+	return dst;
+	}
+
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in4_rtredirect -- ã«ã¼ãã£ã³ã°è¡¨ã«ã¨ã³ããªãç»é²ããã
+ *
+ *    æ³¨æ: å¼æ° tmo ã®åä½ã¯ [ms]ã
+ */
+
+void
+in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo)
+{
+	T_IN4_RTENTRY	*frt;
+
+	frt = in_rtnewentry(flags, tmo);
+	frt->gateway    = gateway;
+	frt->target     = target;
+	frt->mask       = 0xffffffff;
+	}
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+/*
+ *  in4_timer -- IPv4 å
+±éã¿ã¤ãã¼
+ *
+ *    1ç§å¨æã§èµ·åãããã
+ */
+
+static void
+in4_timer (void *ignore)
+{
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+	in_rttimer();
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+#ifdef IP4_CFG_FRAGMENT
+
+	ip_frag_timer();
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	timeout(in4_timer, NULL, IN_TIMER_TMO);
+	}
+
+/*
+ *  in4_init -- IPv4 å
+±éæ©è½ãåæåããã
+ */
+
+void
+in4_init (void)
+{
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+	in_rtinit();
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+	timeout(in4_timer, NULL, IN_TIMER_TMO);
+	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: asp3_gr_sakura/trunk/tinet/netinet/in4_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in4_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in4_var.h	(revision 317)
@@ -0,0 +1,215 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/in_var.h,v 1.29.2.1 1999/08/29 16:29:38 peter Exp $
+ */
+ 
+#ifndef _IN4_VAR_H_
+#define _IN4_VAR_H_
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½
+ */
+
+typedef struct t_in4_ifaddr {
+	T_IN4_ADDR		addr;		/* IPv4 ã¢ãã¬ã¹	*/
+	T_IN4_ADDR		mask;		/* ãµãããããã¹ã¯	*/
+	} T_IN4_IFADDR;
+
+/*
+ *  ã«ã¼ãã£ã³ã°è¡¨ã¨ã³ããªæ§é ä½
+ */
+
+typedef struct t_in4_rtentry {
+	T_IN4_ADDR	target;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹			*/
+	T_IN4_ADDR	mask;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹ã®ãµãããããã¹ã¯	*/
+	T_IN4_ADDR	gateway;	/* ã²ã¼ãã¦ã§ã¤ã® IP ã¢ãã¬ã¹			*/
+	uint32_t	expire;		/* æå¹æéãåããæå» [s]			*/
+	uint8_t		flags;		/* ãã©ã°					*/
+	} T_IN4_RTENTRY;
+/*
+ *  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ *
+ *  TINET 1.5 ã¨ã®äºææ§ã®ããã«å®ç¾©ãç¡å¹ã«ããã
+ */
+
+#if 0
+#ifdef NUM_ROUTE_ENTRY
+
+#define NUM_IN4_ROUTE_ENTRY		NUM_ROUTE_ENTRY
+#define NUM_IN4_STATIC_ROUTE_ENTRY	NUM_ROUTE_ENTRY
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	0
+#define T_RT_ENTRY			T_IN4_RTENTRY
+
+#endif	/* of #ifdef NUM_ROUTE_ENTRY */
+#endif
+
+/*
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+#ifdef SUPPORT_INET4
+
+extern T_IN4_RTENTRY routing4_tbl[];
+
+#endif	/* of #ifdef SUPPORT_INET4 */
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_NET_BUF_DEFINED
+typedef struct t_net_buf T_NET_BUF;
+#define T_NET_BUF_DEFINED
+#endif
+
+#ifndef T_IFNET_DEFINED
+typedef struct t_ifnet T_IFNET;
+#define T_IFNET_DEFINED
+#endif
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define IN4_COPY_TO_HOST(dst,nbuf)	(*(dst)=ntohl(GET_IP4_HDR(nbuf)->src))
+
+/*
+ *  é¢æ°
+ */
+
+extern void ip_input (T_NET_BUF *data);
+extern ER in4_set_header (T_NET_BUF *nbuf, uint_t len,
+                          T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr, uint8_t proto, uint8_t ttl);
+extern ER in4_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                            T_IN4_ADDR *dstaddr, T_IN4_ADDR *srcaddr,
+                            uint8_t proto, uint8_t ttl, ATR nbatr, TMO tmout);
+extern uint16_t in4_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
+extern T_IN4_ADDR in4_rtalloc (T_IN4_ADDR dst);
+extern void in4_rtredirect (T_IN4_ADDR gateway, T_IN4_ADDR target, uint8_t flags, uint32_t tmo);
+extern void in4_init (void);
+extern T_IN4_ADDR *in4_addrwithifp (T_IFNET *ifp, T_IN4_ADDR *src, T_IN4_ADDR *dst);
+extern const T_NET_BUF**ip_get_frag_queue (void);
+
+/*
+ *  in4_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ *
+ *    æ³¨æ: dstaddr ã¯ã
+ *          TINET-1.2 ãããããã¯ã¼ã¯ãã¤ããªã¼ãã
+ *          TINET-1.1 ã¾ã§ã¯ããã¹ããã¤ããªã¼ã
+ */
+extern bool_t in4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_IN4_ADDR *dstaddr);
+extern bool_t inn4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input);
+
+/*
+ *  in_cksum -- ãã§ãã¯ãµã è¨ç®é¢æ°ãIPv4ãICMPv4 ç¨
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint16_t in_cksum(void *data, uint_t len /*ãªã¯ãããåä½*/);
+
+/*
+ *  in_cksum_sum -- ãã§ãã¯ãµã ã®åè¨è¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint32_t in_cksum_sum (void *data, uint_t len /*ãªã¯ãããåä½*/);
+
+/*
+ *  in_cksum_carry -- ãã§ãã¯ãµã ã®æ¡ä¸ãè¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+extern uint32_t in_cksum_carry (uint32_t sum);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _IN4_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in_itron.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in_itron.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in_itron.h	(revision 317)
@@ -0,0 +1,155 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+ 
+#ifndef _IN_ITRON_H_
+#define _IN_ITRON_H_
+
+/*
+ *  API æ©è½ã»äºè±¡ã³ã¼ã
+ */
+
+/* TCP é¢ä¿ */
+
+#define TFN_TCP_CRE_REP		(-0x201)
+#define TFN_TCP_DEL_REP		(-0x202)
+#define TFN_TCP_CRE_CEP		(-0x203)
+#define TFN_TCP_DEL_CEP		(-0x204)
+#define TFN_TCP_ACP_CEP		(-0x205)
+#define TFN_TCP_CON_CEP		(-0x206)
+#define TFN_TCP_SHT_CEP		(-0x207)
+#define TFN_TCP_CLS_CEP		(-0x208)
+#define TFN_TCP_SND_DAT		(-0x209)
+#define TFN_TCP_RCV_DAT		(-0x20a)
+#define TFN_TCP_GET_BUF		(-0x20b)
+#define TFN_TCP_SND_BUF		(-0x20c)
+#define TFN_TCP_RCV_BUF		(-0x20d)
+#define TFN_TCP_REL_BUF		(-0x20e)
+#define TFN_TCP_SND_OOB		(-0x20f)
+#define TFN_TCP_RCV_OOB		(-0x210)
+#define TFN_TCP_CAN_CEP		(-0x211)
+#define TFN_TCP_SET_OPT		(-0x212)
+#define TFN_TCP_GET_OPT		(-0x213)
+#define TFN_TCP_ALL		(0)
+
+#define TEV_TCP_RCV_OOB		(-0x201)
+
+/* UDP é¢ä¿ */
+
+#define TFN_UDP_CRE_CEP		(-0x221)
+#define TFN_UDP_DEL_CEP		(-0x222)
+#define TFN_UDP_SND_DAT		(-0x223)
+#define TFN_UDP_RCV_DAT		(-0x224)
+#define TFN_UDP_CAN_CEP		(-0x225)
+#define TFN_UDP_SET_OPT		(-0x226)
+#define TFN_UDP_GET_OPT		(-0x227)
+#define TFN_UDP_ALL		(0)
+
+#define TEV_UDP_RCV_DAT		(-0x221)
+
+/* ä¸è¬ */
+
+#define NADR			((void*)(-1))	/* ç¡å¹ã¢ãã¬ã¹ */
+#define IS_PTR_DEFINED(a)	((void*)(a)!=NADR&&(void*)(a)!=NULL)
+#define TCP_REP_NONE		UINT_C(0)
+#define TCP_CEP_NONE		UINT_C(0)
+#define UDP_CEP_NONE		UINT_C(0)
+
+/*
+ *  é¢æ°
+ */
+
+/* TCP é¢ä¿ */
+
+/* ãæ¨æºæ©è½ã */
+
+extern ER	tcp_acp_cep (ID cepid, ID repid, T_IPV4EP *p_dstaddr, TMO tmout);
+extern ER	tcp_con_cep (ID cepid, T_IPV4EP *p_myaddr, T_IPV4EP *p_dstaddr, TMO tmout);
+extern ER	tcp_sht_cep (ID cepid);
+extern ER	tcp_cls_cep (ID cepid, TMO tmout);
+extern ER_UINT	tcp_snd_dat (ID cepid, void *data, int_t len, TMO tmout);
+extern ER_UINT	tcp_rcv_dat (ID cepid, void *data, int_t len, TMO tmout);
+extern ER_UINT	tcp_get_buf (ID cepid, void **p_buf, TMO tmout);
+extern ER	tcp_snd_buf (ID cepid, int_t len);
+extern ER_UINT	tcp_rcv_buf (ID cepid, void **p_buf, TMO tmout);
+extern ER	tcp_rel_buf (ID cepid, int_t len);
+extern ER	tcp_can_cep (ID cepid, FN fncd);
+
+extern ER	tcp6_acp_cep (ID cepid, ID repid, T_IPV6EP *p_dstaddr, TMO tmout);
+extern ER	tcp6_con_cep (ID cepid, T_IPV6EP *p_myaddr, T_IPV6EP *p_dstaddr, TMO tmout);
+
+/* ãæ¡å¼µæ©è½ã */
+
+extern ER	tcp_del_rep (ID cepid);
+extern ER	tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_crep);
+extern ER	tcp_del_cep (ID cepid);
+extern ER_UINT	tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout);
+extern ER_UINT	tcp_rcv_oob (ID cepid, void *data, int_t len);
+extern ER	tcp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen);
+extern ER	tcp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen);
+extern ER	tcp_cre_rep (ID repid, T_TCP_CREP *pk_crep);
+
+extern ER	tcp6_cre_rep (ID repid, T_TCP6_CREP *pk_crep);
+
+/* UDP é¢ä¿ */
+
+/* ãæ¨æºæ©è½ã */
+
+extern ER_UINT	udp_snd_dat (ID cepid, T_IPV4EP *p_dstaddr, void *data, int_t len, TMO tmout);
+extern ER_UINT	udp_rcv_dat (ID cepid, T_IPV4EP *p_dstaddr, void *data, int_t len, TMO tmout);
+extern ER	udp_can_cep (ID cepid, FN fncd);
+
+extern ER_UINT	udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
+extern ER_UINT	udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
+
+/* ãæ¡å¼µæ©è½ã */
+
+extern ER	udp_del_cep (ID cepid);
+extern ER	udp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen);
+extern ER	udp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen);
+extern ER	udp_cre_cep (ID cepid, T_UDP_CCEP *pk_ccep);
+
+extern ER	udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep);
+
+#endif	/* of #ifndef _IN_ITRON_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in_rename.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in_rename.h	(revision 317)
@@ -0,0 +1,261 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _IN_RENAME_H_
+#define _IN_RENAME_H_
+
+/*
+ *  TCP/IP ãã­ãã³ã«ã¹ã¿ãã¯å
+é¨åã®ãªãã¼ã 
+ */
+
+/* netinet/tcp_input.c */
+
+#define tcp_input		_tinet_tcp_input
+#define tcp_move_twcep		_tinet_tcp_move_twcep
+
+/* netinet/tcp_output.c */
+
+/* netinet/tcp_timer.c */
+
+#define	tcp_cancel_timers	_tinet_tcp_cancel_timers
+#define tcp_slow_timo		_tinet_tcp_slow_timo
+#define tcp_fast_timo		_tinet_tcp_fast_timo
+#define tcp_range_set		_tinet_tcp_range_set
+#define tcp_set_persist_timer	_tinet_tcp_set_persist_timer
+
+/* netinet/tcp_usrrq.c */
+
+#define tcp_user_closed		_tinet_tcp_user_closed
+
+/* netinet/tcp_subr.c */
+
+#define tcp_iss			_tinet_tcp_iss
+#define tcp_init		_tinet_tcp_init
+#define tcp_init_iss		_tinet_tcp_init_iss
+#define tcp_close		_tinet_tcp_close
+#define tcp_drop		_tinet_tcp_drop
+#define tcp_respond		_tinet_tcp_respond
+#define	tcp_get_segment		_tinet_tcp_get_segment
+#define tcp_rexmt_val		_tinet_tcp_rexmt_val
+#define tcp_init_cep		_tinet_tcp_init_cep
+#define tcp_notify		_tinet_tcp_notify
+#define tcp_alloc_auto_port	_tinet_tcp_alloc_auto_port
+#define tcp_alloc_port		_tinet_tcp_alloc_port
+#define tcp_free_reassq		_tinet_tcp_free_reassq
+#define tcp_move_ra2rw		_tinet_tcp_move_ra2rw
+#define tcp_wait_rwbuf		_tinet_tcp_wait_rwbuf
+#define tcp_write_raque		_tinet_tcp_write_raque
+#define tcp_lock_cep		_tinet_tcp_lock_cep
+#define tcp_can_send_more	_tinet_tcp_can_send_more
+#define tcp_can_recv_more	_tinet_tcp_can_recv_more
+#define tcp_output_trace	_tinet_tcp_output_trace
+#define tcp_input_trace		_tinet_tcp_input_trace
+#define tcp_find_cep		_tinet_tcp_find_cep
+#define tcp_find_twcep		_tinet_tcp_find_twcep
+#define tcp_is_addr_accept	_tinet_tcp_is_addr_accept
+#define tcp_move_twcep		_tinet_tcp_move_twcep
+#define tcpn_get_segment	_tinet_tcpn_get_segment
+
+/* netinet/tcp_subr_cs.c */
+
+#define tcp_read_rwbuf		_tinet_tcp_read_rwbuf
+#define tcp_write_rwbuf		_tinet_tcp_write_rwbuf
+#define tcp_drop_rwbuf		_tinet_tcp_drop_rwbuf
+#define tcp_free_rwbufq		_tinet_tcp_free_rwbufq
+#define tcp_get_rwbuf_addr	_tinet_tcp_get_rwbuf_addr
+
+#define tcp_free_rwbufq_cs	_tinet_tcp_free_rwbufq_cs
+#define tcp_get_rwbuf_addr_cs	_tinet_tcp_get_rwbuf_addr_cs
+#define tcp_read_rwbuf_cs	_tinet_tcp_read_rwbuf_cs
+#define tcp_write_rwbuf_cs	_tinet_tcp_write_rwbuf_cs
+#define tcp_drop_rwbuf_cs	_tinet_tcp_drop_rwbuf_cs
+
+#define tcp_wait_swbuf		_tinet_tcp_wait_swbuf
+#define tcp_init_swbuf		_tinet_tcp_init_swbuf
+#define tcp_alloc_swbuf		_tinet_tcp_alloc_swbuf
+#define tcp_is_swbuf_full	_tinet_tcp_is_swbuf_full
+#define tcp_drop_swbuf		_tinet_tcp_drop_swbuf
+#define tcp_free_swbufq		_tinet_tcp_free_swbufq
+#define tcp_read_swbuf		_tinet_tcp_read_swbuf
+#define tcp_write_swbuf		_tinet_tcp_write_swbuf
+#define tcp_pull_res_nbuf	_tinet_tcp_pull_res_nbuf
+#define tcp_push_res_nbuf	_tinet_tcp_push_res_nbuf
+#define tcp_get_swbuf_addr	_tinet_tcp_get_swbuf_addr
+#define tcp_send_swbuf		_tinet_tcp_send_swbuf
+
+#define tcp_get_swbuf_addr_cs	_tinet_tcp_get_swbuf_addr_cs
+#define tcp_wait_swbuf_cs	_tinet_tcp_wait_swbuf_cs
+#define tcp_is_swbuf_full_cs	_tinet_tcp_is_swbuf_full_cs
+#define tcp_alloc_swbuf_cs	_tinet_tcp_alloc_swbuf_cs
+#define tcp_send_swbuf_cs	_tinet_tcp_send_swbuf_cs
+#define tcp_free_swbufq_cs	_tinet_tcp_free_swbufq_cs
+#define tcp_drop_swbuf_cs	_tinet_tcp_drop_swbuf_cs
+#define tcp_write_swbuf_cs	_tinet_tcp_write_swbuf_cs
+
+/* netinet/tcp_subr_ncs.c */
+
+#define tcp_drop_rwbuf_ncs	_tinet_tcp_drop_rwbuf_ncs
+#define tcp_read_rwbuf_ncs	_tinet_tcp_read_rwbuf_ncs
+#define tcp_is_swbuf_full_ncs	_tinet_tcp_is_swbuf_full_ncs
+#define tcp_drop_swbuf_ncs	_tinet_tcp_drop_swbuf_ncs
+#define tcp_read_swbuf_ncs	_tinet_tcp_read_swbuf_ncs
+#define tcp_wait_swbuf_ncs	_tinet_tcp_wait_swbuf_ncs
+#define tcp_write_swbuf_ncs	_tinet_tcp_write_swbuf_ncs
+#define tcp_write_rwbuf_ncs	_tinet_tcp_write_rwbuf_ncs
+#define tcp_get_swbuf_addr_ncs	_tinet_tcp_get_swbuf_addr_ncs
+#define tcp_send_swbuf_ncs	_tinet_tcp_send_swbuf_ncs
+#define tcp_get_rwbuf_addr_ncs	_tinet_tcp_get_rwbuf_addr_ncs
+
+/* tcp_cfg.c */
+
+#define tcp6_rep		_tinet_tcp6_rep
+#define tcp4_rep		_tinet_tcp4_rep
+#define tcp_cep			_tinet_tcp_cep
+#define tcp_twcep		_tinet_tcp_twcep
+#define tmax_tcp_repid		_tinet_tmax_tcp_repid
+#define tmax_tcp_cepid		_tinet_tmax_tcp_cepid
+#define tmax_tcp_crepid		_tinet_tmax_tcp_repid	/* TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾© */
+#define tmax_tcp_ccepid		_tinet_tmax_tcp_cepid	/* TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾© */
+
+/* netinet/udp_input.c */
+
+#define udp6_reply_no_port	_tinet_udp6_reply_no_port
+#define udp6_input_select	_tinet_udp6_input_select
+#define udp6_input		_tinet_udp6_input
+#define udp4_reply_no_port	_tinet_udp4_reply_no_port
+#define udp4_input_select	_tinet_udp4_input_select
+#define udp4_input		_tinet_udp4_input
+
+/* netinet/udp_subr.c */
+
+#define udp6_alloc_port		_tinet_udp6_alloc_port
+#define udp6_alloc_auto_port	_tinet_udp6_alloc_auto_port
+#define udp6_notify		_tinet_udp6_notify
+#define udp6_find_cep		_tinet_udp6_find_cep
+#define udp4_alloc_port		_tinet_udp4_alloc_port
+#define udp4_alloc_auto_port	_tinet_udp4_alloc_auto_port
+#define udp4_notify		_tinet_udp4_notify
+#define udp4_find_cep		_tinet_udp4_find_cep
+
+/* netinet/udp_usrreq.c */
+
+#define udp_send_data		_tinet_udp_send_data
+
+/* netinet/udp_usrreq_nblk.c */
+
+#define udp_can_rcv		_tinet_udp_can_rcv
+#define udp_can_snd		_tinet_udp_can_snd
+
+/* udp_cfg.c */
+
+#define udp6_cep		_tinet_udp6_cep
+#define udp4_cep		_tinet_udp4_cep
+#define tmax_udp_cepid		_tinet_tmax_udp_cepid
+#define tmax_udp_ccepid		_tinet_tmax_udp_cepid	/* TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾© */
+
+/* netinet/ip_icmp.c */
+
+#define icmp_input		_tinet_icmp_input
+#define icmp_error		_tinet_icmp_error
+#define icmp_echo_reply		_tinet_icmp_echo_reply
+
+/* netinet/ip_input.c */
+
+#define ip_input		_tinet_ip_input
+#define ip_init			_tinet_ip_init
+#define ip_frag_timer		_tinet_ip_frag_timer
+#define ip_get_frag_queue	_tinet_ip_get_frag_queue
+#define ip_remove_options	_tinet_ip_remove_options
+
+/* netinet/ip_output.c */
+
+#define ip_output		_tinet_ip_output
+
+/* netinet/in_subr.c */
+
+#define inn_addrwithifp		_tinet_inn_addrwithifp
+#define in_cksum_carry		_tinet_in_cksum_carry
+#define inn_is_addr_multicast	_tinet_inn_is_addr_multicast
+#define inn_get_datagram	_tinet_inn_get_datagram
+#define inn_is_dstaddr_accept	_tinet_inn_is_dstaddr_accept
+#define ip_exchg_addr		_tinet_ip_exchg_addr
+#define inn_copy_to_host	_tinet_inn_copy_to_host
+#define in_cksum_sum		_tinet_in_cksum_sum
+#define inn_are_net_srcaddr_equal	\
+				_tinet_inn_are_net_srcaddr_equal
+
+/* netinet/in4_subr.c */
+
+#define in4_add_ifaddr		_tinet_in4_add_ifaddr
+#define in4_set_header		_tinet_in4_set_header
+#define inn4_is_dstaddr_accept	_tinet_inn4_is_dstaddr_accept
+#define in4_rtredirect		_tinet_in4_rtredirect
+#define in_rtnewentry		_tinet_in_rtnewentry
+#define in_cksum		_tinet_in_cksum
+#define	in4_addrwithifp		_tinet_in4_addrwithifp
+#define in4_rtalloc		_tinet_in4_rtalloc
+#define in4_init		_tinet_in4_init
+#define in_rttimer		_tinet_in_rttimer
+#define in4_get_ifaddr		_tinet_in4_get_ifaddr
+#define in4_get_datagram	_tinet_in4_get_datagram
+#define in4_is_dstaddr_accept	_tinet_in4_is_dstaddr_accept
+#define in4_cksum		_tinet_in4_cksum
+#define in_rtinit		_tinet_in_rtinit
+#define in4_ifawithifp		_tinet_in4_ifawithifp
+
+/* netinet/if_ether.c */
+
+#define arp_request		_tinet_arp_request
+#define arp_input		_tinet_arp_input
+#define arp_resolve		_tinet_arp_resolve
+#define arp_init		_tinet_arp_init
+#define arp_get_cache		_tinet_arp_get_cache
+
+/* netinet6/icmp6.c */
+
+#define icmp6_input		_tinet_icmp6_input
+
+#endif	/* of #ifndef _IN_RENAME_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/in_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in_subr.c	(revision 317)
@@ -0,0 +1,526 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/in_itron.h>
+
+#include <net/if_var.h>
+
+/*
+ *  in_cksum_sum -- ãã§ãã¯ãµã ã®åè¨è¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ *
+ *        æ»ãå¤ã¯ãã¹ããã¤ããªã¼ã
+ */
+
+uint32_t
+in_cksum_sum (void *data, uint_t len /*ãªã¯ãããåä½*/)
+{
+	uint32_t sum = 0;
+
+	for ( ; len > 0; len -= 2) {
+		sum += *((uint16_t*)data);
+		data = (uint8_t*)data + 2;
+		}
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+	return sum;
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+	return ((sum >> 8) & 0xffff) + ((sum & 0xff) << 8) + ((sum >> 24) & 0xff);
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+	}
+
+/*
+ *  in_cksum_carry -- ãã§ãã¯ãµã ã®æ¡ä¸ãè¨ç®é¢æ°
+ *
+ *  æ³¨æ: data ã¯ 4 ãªã¯ãããåä½ã§ããã£ã³ã°ãããã¨ã
+ *        data ã 2 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ããªãã¨
+ *        ä¾å¤ãçºçããå¯è½æ§ãããã
+ *        len  ã¯ 4 ãªã¯ãããåä½ã«ã¢ã©ã¤ã³ããã¦ãããã¨ã
+ */
+
+uint32_t
+in_cksum_carry (uint32_t sum)
+{
+	uint32_t	carry;
+
+	while (sum >= 0x00010000) {
+		carry = sum >> 16;
+		sum   = (sum & 0xffff) + carry;
+		}
+
+	return sum;
+	}
+
+/*
+ *  in_strtfn -- API æ©è½ã³ã¼ãã®æå­è¡¨ç¾ãè¿ãã
+ */
+
+typedef struct t_strtfn {
+	FN		fncd;	/* API æ©è½ã³ã¼ã	*/
+	const char	*str;	/* æå­è¡¨ç¾		*/
+	} T_STRTFN;
+
+const T_STRTFN strtfn[] = {
+	{ TEV_TCP_RCV_OOB,	"TEV_TCP_RCV_OOB" },
+	{ TFN_TCP_DEL_REP,	"TFN_TCP_DEL_REP" },
+	{ TFN_TCP_CRE_CEP,	"TFN_TCP_CRE_CEP" },
+	{ TFN_TCP_DEL_CEP,	"TFN_TCP_DEL_CEP" },
+	{ TFN_TCP_ACP_CEP,	"TFN_TCP_ACP_CEP" },
+	{ TFN_TCP_CON_CEP,	"TFN_TCP_CON_CEP" },
+	{ TFN_TCP_SHT_CEP,	"TFN_TCP_SHT_CEP" },
+	{ TFN_TCP_CLS_CEP,	"TFN_TCP_CLS_CEP" },
+	{ TFN_TCP_SND_DAT,	"TFN_TCP_SND_DAT" },
+	{ TFN_TCP_RCV_DAT,	"TFN_TCP_RCV_DAT" },
+	{ TFN_TCP_GET_BUF,	"TFN_TCP_GET_BUF" },
+	{ TFN_TCP_SND_BUF,	"TFN_TCP_SND_BUF" },
+	{ TFN_TCP_RCV_BUF,	"TFN_TCP_RCV_BUF" },
+	{ TFN_TCP_REL_BUF,	"TFN_TCP_REL_BUF" },
+	{ TFN_TCP_SND_OOB,	"TFN_TCP_SND_OOB" },
+	{ TFN_TCP_RCV_OOB,	"TFN_TCP_RCV_OOB" },
+	{ TFN_TCP_CAN_CEP,	"TFN_TCP_CAN_CEP" },
+	{ TFN_TCP_SET_OPT,	"TFN_TCP_SET_OPT" },
+	{ TFN_TCP_GET_OPT,	"TFN_TCP_GET_OPT" },
+	{ TFN_TCP_ALL,		"TFN_TCP_ALL"     },
+
+	{ TEV_UDP_RCV_DAT,	"TEV_UDP_RCV_DAT" },
+	{ TFN_UDP_DEL_CEP,	"TFN_UDP_DEL_CEP" },
+	{ TFN_UDP_SND_DAT,	"TFN_UDP_SND_DAT" },
+	{ TFN_UDP_RCV_DAT,	"TFN_UDP_RCV_DAT" },
+	{ TFN_UDP_CAN_CEP,	"TFN_UDP_CAN_CEP" },
+	{ TFN_UDP_SET_OPT,	"TFN_UDP_SET_OPT" },
+	{ TFN_UDP_GET_OPT,	"TFN_UDP_GET_OPT" },
+	};
+
+const char *
+in_strtfn (FN fncd)
+{
+	int_t	ix;
+
+	for (ix = sizeof(strtfn) / sizeof(T_STRTFN); ix -- > 0; )
+		if (strtfn[ix].fncd == fncd)
+			return strtfn[ix].str;
+
+	return "unknown TFN";
+	}
+
+#if defined(_IP4_CFG)
+
+/*
+ *  ipv42str -- IPv4 ã¢ãã¬ã¹ãæå­åã«å¤æããã
+ */
+
+char *
+ipv42str (char *buf, const T_IN4_ADDR *ipaddr)
+{
+	static char	addr_sbuf[NUM_IPV4ADDR_STR_BUFF][sizeof("123.123.123.123")];
+	static int_t	bix = NUM_IPV4ADDR_STR_BUFF;
+
+	char *start;
+
+	if (buf == NULL) {
+		syscall(wai_sem(SEM_IP2STR_BUFF_LOCK));
+		buf = addr_sbuf[-- bix];
+		if (bix <= 0)
+			bix = NUM_IPV4ADDR_STR_BUFF;
+		syscall(sig_sem(SEM_IP2STR_BUFF_LOCK));
+		}
+
+	start = buf;
+	buf += convert_hexdigit(buf, (uint_t)((*ipaddr >> 24) & 0xff), 10, 0, ' ');
+	*(buf ++) = '.';
+	buf += convert_hexdigit(buf, (uint_t)((*ipaddr >> 16) & 0xff), 10, 0, ' ');
+	*(buf ++) = '.';
+	buf += convert_hexdigit(buf, (uint_t)((*ipaddr >>  8) & 0xff), 10, 0, ' ');
+	*(buf ++) = '.';
+	buf += convert_hexdigit(buf, (uint_t)((*ipaddr      ) & 0xff), 10, 0, ' ');
+	*buf = '\0';
+	return start;
+	}
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+/*
+ *  in6_is_addr_ipv4mapped -- IPv4 å°å½±ã¢ãã¬ã¹ã§ããäºãæ¤æ»ããã
+ */
+
+bool_t
+in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr)
+{
+	return IN6_IS_ADDR_V4MAPPED(addr);
+	}
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+/*
+ *  ip_exchg_addr -- IP ã¢ãã¬ã¹ãäº¤æããã
+ */
+
+static void
+ip6_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP6_HDR	*iph;
+	T_IN6_ADDR	ipaddr;
+
+	iph  = GET_IP6_HDR(nbuf);
+
+	/* IPv6 ã¢ãã¬ã¹ãäº¤æããã*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+static void
+ip4_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP4_HDR	*iph;
+	T_IN4_ADDR	ipaddr;
+
+	iph  = GET_IP4_HDR(nbuf);
+
+	/* IPv4 ã¢ãã¬ã¹ãäº¤æããã*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+void
+ip_exchg_addr (T_NET_BUF *nbuf)
+{
+	if (GET_IP_VER(nbuf) == 6)
+		ip6_exchg_addr(nbuf);
+	else
+		ip4_exchg_addr(nbuf);
+	}
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+/*
+ *  ip_exchg_addr -- IP ã¢ãã¬ã¹ãäº¤æããã
+ */
+
+void
+ip_exchg_addr (T_NET_BUF *nbuf)
+{
+	T_IP_HDR	*iph;
+	T_IN_ADDR	ipaddr;
+
+	iph  = GET_IP_HDR(nbuf);
+
+	/* IP ã¢ãã¬ã¹ãäº¤æããã*/
+	ipaddr = iph->src;
+	iph->src = iph->dst;
+	iph->dst = ipaddr;
+	}
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+/*
+ *  inn_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ */
+
+bool_t
+inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		return INN6_IS_DSTADDR_ACCEPT(myaddr, nbuf);
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h  = GET_IP4_HDR(nbuf);
+		if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
+			return ntohl(ip4h->dst) == IF_GET_IFNET()->in4_ifaddr.addr;
+		else {
+			T_IN6_ADDR	dstaddr;
+
+			return IN6_ARE_ADDR_EQUAL(myaddr, in6_make_ipv4mapped(&dstaddr, ntohl(ip4h->dst)));
+			}
+		}
+	}
+
+/*
+ *  inn_are_net_srcaddr_equal -- ã¢ãã¬ã¹ãåä¸ããã§ãã¯ããã
+ */
+
+bool_t
+inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		return IN6_ARE_ADDR_EQUAL(ipaddr, &GET_IP6_HDR(nbuf)->src);
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/ {
+
+
+		T_IN6_ADDR	srcaddr;
+
+		return IN6_ARE_ADDR_EQUAL(ipaddr, in6_make_ipv4mapped(&srcaddr, ntohl(GET_IP4_HDR(nbuf)->src)));
+		}
+	}
+
+/*
+ *  inn_copy_to_host -- IP ããããããã¹ãè¡¨ç¾å¤æãã¦ãIP ã¢ãã¬ã¹ãã³ãã¼ããã
+ */
+
+void
+inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf)
+{
+	if        (GET_IP_VER(nbuf)==IPV6_VERSION)
+		memcpy(dst, &GET_IP6_HDR(nbuf)->src, sizeof(T_IN6_ADDR));
+	else /*if (GET_IP_VER(nbuf)==IPV4_VERSION)*/
+		in6_make_ipv4mapped(dst, ntohl(GET_IP4_HDR(nbuf)->src));
+
+	}
+
+/*
+ *  inn_get_datagram -- IPv6/IPv4 ãã¼ã¿ã°ã©ã ãç²å¾ããããããè¨­å®ããã
+ */
+
+ER
+inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
+{
+	if (IN6_IS_ADDR_V4MAPPED(dstaddr)) {
+		T_IN4_ADDR ip4dstaddr, ip4srcaddr;
+
+		ip4dstaddr = ntohl(dstaddr->s6_addr32[3]);
+		if (IN6_IS_ADDR_UNSPECIFIED(srcaddr))
+			ip4srcaddr = IF_GET_IFNET()->in4_ifaddr.addr;
+		else
+			ip4srcaddr = ntohl(srcaddr->s6_addr32[3]);
+
+		return in4_get_datagram(nbuf, len, maxlen, &ip4dstaddr, &ip4srcaddr, next, hlim, nbatr, tmout);
+		}
+	else
+		return in6_get_datagram(nbuf, len, maxlen, dstaddr, srcaddr, next, hlim, nbatr, tmout);
+	}
+
+/*
+ * inn_addrwithifp -- å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+ *                   ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
+ */
+
+T_IN6_ADDR *
+inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst)
+{
+	T_IN6_IFADDR *ifaddr;
+
+	if (IN6_IS_ADDR_V4MAPPED(dst))
+		return in6_make_ipv4mapped (src, ifp->in4_ifaddr.addr);
+	else if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
+		return NULL;
+	else {
+		*src = ifaddr->addr;
+		return src;
+		}
+	}
+
+/*
+ *  inn_is_addr_multicast -- ã¢ãã¬ã¹ããã«ãã­ã£ã¹ãã¢ãã¬ã¹ããã§ãã¯ããã
+ */
+
+bool_t
+inn_is_addr_multicast (T_IN6_ADDR *addr)
+{
+
+	if (IN6_IS_ADDR_V4MAPPED(addr))
+		return IN4_IS_ADDR_MULTICAST(ntohl(addr->s6_addr32[3]));
+	else
+		return IN6_IS_ADDR_MULTICAST(addr);
+	}
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+/*
+ *  ãã¤ããªã¼ãé¢æ°ã®å®ç¾©
+ *
+ *    tinet/net/net.h ã§ããã¤ããªã¼ãã®å®ç¾©ãè¡ã£ã¦ãããã
+ *    tinet/net/net.h ãã¤ã³ã¯ã«ã¼ãããªã
+ *    ã¢ããªã±ã¼ã·ã§ã³ãã­ã°ã©ã ç¨ã«
+ *    ã¿ã¼ã²ããä¾å­ããªããã¤ããªã¼ãé¢æ°ãå®ç¾©ããã
+ */
+
+#if defined(_NET_CFG_BYTE_ORDER)
+
+#undef ntohs
+#undef htons
+#undef ntohl
+#undef htonl
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+uint16_t
+ntohs (uint16_t net)
+{
+	return net;
+	}
+
+uint16_t
+htons (uint16_t host)
+{
+	return host;
+	}
+
+uint32_t
+ntohl (uint32_t net)
+{
+	return net;
+	}
+
+uint32_t
+htonl (uint32_t host)
+{
+	return host;
+	}
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN	/* of #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+uint16_t
+ntohs (uint16_t net)
+{
+	return NET_REV_ENDIAN_HWORD(net);
+	}
+
+uint16_t
+htons (uint16_t host)
+{
+	return NET_REV_ENDIAN_HWORD(host);
+	}
+
+uint32_t
+ntohl (uint32_t net)
+{
+	return NET_REV_ENDIAN_WORD(net);
+	}
+
+uint32_t
+htonl (uint32_t host)
+{
+	return NET_REV_ENDIAN_WORD(host);
+	}
+
+#else	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#error "_NET_CFG_BYTE_ORDER expected."
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #if defined(_NET_CFG_BYTE_ORDER) */
Index: asp3_gr_sakura/trunk/tinet/netinet/in_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/in_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/in_var.h	(revision 317)
@@ -0,0 +1,222 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/in_var.h,v 1.29.2.1 1999/08/29 16:29:38 peter Exp $
+ */
+ 
+#ifndef _IN_VAR_H_
+#define _IN_VAR_H_
+
+#include <netinet/in4_var.h>
+#include <netinet6/in6_var.h>
+
+/*
+ *  ç¬èªã®ã¨ã©ã¼ã³ã¼ã
+ */
+
+#define EV_NOPND		(-97)		/* ãã³ãã£ã³ã°ãã¦ããªã */
+
+/*
+ *  ãããã¯ã¼ã¯ã¨ã©ã¼ã³ã¼ã
+ */
+
+#define EV_MSIZE		(-98)		/* ãã¼ã¿ã°ã©ã é·è¶
+é	*/
+#define EV_NURCH		(-99)		/* ãããã¯ã¼ã¯å°éä¸è½	*/
+#define EV_HDOWN		(-100)		/* ãã¹ããã¦ã³		*/
+#define EV_HURCH		(-101)		/* ãã¹ãå°éä¸è½	*/
+#define EV_CNNRF		(-102)		/* æ¥ç¶ä¸è½		*/
+#define EV_CNRST		(-103)		/* æ¥ç¶ãªã»ãã		*/
+#define EV_REXMTMO		(-104)		/* åéã¿ã¤ã ã¢ã¦ã	*/
+
+/*
+ *  å
+±éã¿ã¤ãã®èµ·åå¨æã®å®ç¾©
+ */
+
+#define IN_TIMER_TMO		(SYSTIM_HZ/NET_TIMER_CYCLE)
+
+/*
+ *  ã«ã¼ãã£ã³ã°ã¨ã³ããªç¶æ
+ãã©ã°
+ */
+
+#define IN_RTF_DEFINED		UINT_C(0x01)	/* å®ç¾©æ¸ã¿			*/
+#define IN_RTF_REDIRECT		UINT_C(0x10)	/* åãç´ãã«ããèªåè¨­å®ããã	*/
+
+/*
+ *  IPv4 ã¨ IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­
+ */
+
+#if defined(_IP6_CFG)
+
+#define T_IN_ADDR			T_IN6_ADDR
+#define T_IPEP				T_IPV6EP
+#define IP_ADDRANY			IPV6_ADDRANY
+
+#elif defined(_IP4_CFG)	/* of #if defined(_IP6_CFG) */
+
+#define T_IN_ADDR			T_IN4_ADDR
+#define T_IPEP				T_IPV4EP
+#define IP_ADDRANY			IPV4_ADDRANY
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+#define IN_CKSUM(nbuf,proto,off,len)	(GET_IP_VER(nbuf)==IPV6_VERSION	\
+					?in6_cksum(nbuf,proto,off,len)	\
+					:in4_cksum(nbuf,proto,off,len))
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					inn_is_dstaddr_accept(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION	\
+					?IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)	\
+					:IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src))
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+		    			inn_are_net_srcaddr_equal(ipaddr,nbuf)
+#define IN_COPY_TO_HOST(dst,nbuf)	inn_copy_to_host(dst,nbuf)
+#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
+					inn_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
+#define IN_IS_ADDR_MULTICAST(addr)	inn_is_addr_multicast(addr)
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
+#define IN_ADDRWITHIFP(ifp,src,dst)	inn_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN6_IS_ADDR_UNSPECIFIED(addr)
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#define IN_CKSUM(nbuf,proto,off,len)	in6_cksum(nbuf,proto,off,len)
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					INN6_IS_DSTADDR_ACCEPT(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	IN6_ARE_ADDR_EQUAL(&GET_IP6_HDR(nbuf)->dst,&GET_IP6_HDR(nbuf)->src)
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+		    			IN6_ARE_ADDR_EQUAL(ipaddr,&GET_IP6_HDR(nbuf)->src)
+#define IN_COPY_TO_HOST(dst,nbuf)	IN6_COPY_TO_HOST(dst, nbuf)
+#define IN_GET_DATAGRAM(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)	\
+					in6_get_datagram(nbuf,len,maxlen,dst,src,next,hlim,nbatr,tmout)
+#define IN_IS_ADDR_MULTICAST(addr)	IN6_IS_ADDR_MULTICAST(addr)
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(nbuf)->dst)
+#define IN_ADDRWITHIFP(ifp,src,dst)	in6_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN6_IS_ADDR_UNSPECIFIED(addr)
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define IN_CKSUM(nbuf,proto,off,len)	in4_cksum(nbuf,proto,off,len)
+#define IN_IS_DSTADDR_ACCEPT(myaddr,nbuf)	\
+					inn4_is_dstaddr_accept(myaddr,nbuf)
+#define IN_ARE_HDR_ADDR_EQUAL(nbuf)	IN4_ARE_ADDR_EQUAL(&GET_IP4_HDR(nbuf)->dst,&GET_IP4_HDR(nbuf)->src)
+#define IN_ARE_NET_SRCADDR_EQUAL(ipaddr,nbuf)	\
+					(*(ipaddr)==ntohl(GET_IP4_HDR(nbuf)->src))
+#define IN_COPY_TO_HOST(dst,nbuf)	IN4_COPY_TO_HOST(dst, nbuf)
+#define IN_GET_DATAGRAM(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)	\
+					in4_get_datagram(nbuf,len,maxlen, dst,src,proto,ttl,nbatr,tmout)
+#define IN_IS_ADDR_MULTICAST(addr)	IN4_IS_ADDR_MULTICAST(*(addr))
+#define IN_IS_NET_ADDR_MULTICAST(nbuf)	IN4_IS_ADDR_MULTICAST(ntohl(GET_IP4_HDR(nbuf)->dst))
+#define IN_ADDRWITHIFP(ifp,src,dst)	in4_addrwithifp(ifp,src,dst)
+#define IN_IS_ADDR_ANY(addr)		IN4_IS_ADDR_ANY(addr)
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#error "not implemented."
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  é¢æ°
+ */
+extern bool_t	inn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *nbuf);
+extern bool_t	inn_is_addr_multicast (T_IN6_ADDR *addr);
+extern bool_t	inn_are_net_srcaddr_equal (T_IN6_ADDR *ipaddr, T_NET_BUF *nbuf);
+extern void	inn_copy_to_host (T_IN6_ADDR *dst, T_NET_BUF *nbuf);
+extern ER	inn_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+		                  T_IN6_ADDR *dstaddr, T_IN6_ADDR *srcaddr,
+		                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
+extern T_IN6_ADDR *inn_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, T_IN6_ADDR *dst);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _IN_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip.cfg	(revision 317)
@@ -0,0 +1,68 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  IPv4 ã§ä½¿ç¨ããã«ã¼ãã«ãªãã¸ã§ã¯ã
+ */
+
+#if defined(_IP4_CFG)
+
+#ifdef IP4_CFG_FRAGMENT
+
+/* ãã¼ã¿ã°ã©ã ã®åå²ã»åæ§æ */
+
+CRE_SEM(SEM_IP4_FRAG_QUEUE, { TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+#if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0
+
+/* ã«ã¼ãã£ã³ã°è¡¨ï¼åãç´ãï¼*/
+
+CRE_SEM(SEM_IN4_ROUTING_TBL, { TA_TPRI, 1, 1 });
+
+#endif	/* of #if NUM_IN4_REDIRECT_ROUTE_ENTRY > 0 */
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip.h	(revision 317)
@@ -0,0 +1,159 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip.h	8.2 (Berkeley) 6/1/94
+ * $FreeBSD: src/sys/netinet/ip.h,v 1.15.2.1 1999/08/29 16:29:38 peter Exp $
+ */
+ 
+#ifndef _IP4_H_
+#define _IP4_H_
+
+#include <netinet/ip6.h>
+
+/*
+ *  IPv4 ã®å®ç¾©ãRFC791 åç
+§
+ */
+
+#define IPV4_VERSION		4
+
+/*
+ *  IPv4 ãããã®å®ç¾©
+ */
+
+typedef struct t_ip4_hdr {
+	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
+					/* length ã¯ 4 octets åä½		*/
+	uint8_t		type;		/* type of services			*/
+	uint16_t	len;		/* total length				*/
+
+	uint16_t	id;		/* identification			*/
+	uint16_t	flg_off;	/* fragment flag & offset		*/
+
+	uint8_t		ttl;		/* time to live				*/
+	uint8_t		proto;		/* protocol				*/
+	uint16_t	sum;		/* checksum				*/
+
+	T_IN4_ADDR	src;		/* source address			*/
+	T_IN4_ADDR	dst;		/* destination address			*/
+	} T_IP4_HDR;
+
+#define IP4_HDR_SIZE		(sizeof(T_IP4_HDR))
+
+/*
+ *  IPv4 ãããæ§é ä½ã¡ã³ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define IP4_MAKE_VHL(v,hl)	((uint8_t)(((uint8_t)(v)<<4)|(hl)))
+#define IP4_VHL_V(vhl)		((uint8_t)((uint8_t)(vhl)>>4))
+#define IP4_VHL_HL(vhl)		((uint8_t)((vhl)&0x0f))
+
+#define IP4_MAKE_FLGOFF(f,o)	((uint16_t)((f)|(o)))
+#define IP4_FLGOFF_FLG(f)	((uint16_t)((f)&~IP4_OFFMASK))
+#define IP4_FLGOFF_OFF(o)	((uint16_t)((o)&IP4_OFFMASK))
+
+/*
+ *  IPv4 ãããã®ãã£ã¼ã«ãã®å¤ã®å®ç¾©
+ */
+
+#define IP4_VHL_BORING	UINT_C(0x45)	/* ãªãã·ã§ã³ããªã VHL å¤	*/
+#define IP4_RF		UINT_C(0x8000)	/* off: äºç´			*/
+#define IP4_DF		UINT_C(0x4000)	/* off: åå²ç¦æ­¢			*/
+#define IP4_MF		UINT_C(0x2000)	/* off: åå²ãã			*/
+#define IP4_OFFMASK	UINT_C(0x1fff)	/* ãªãã»ããé¨ã®ãã¹ã¯å¤		*/
+
+/*
+ *  å¶éå¤
+ */
+
+#define IP4_MAXPACKET	UINT_C(65535)	/* æå¤§ãã±ãããµã¤ãº		*/
+#define IP4_MAXTTL	UINT_C(255)	/* TTL æå¤§å¤			*/
+#define IP4_DEFTTL	UINT_C(64)	/* TTL è¦å®å¤ (RFC1340)		*/
+#define IP4_FRAGTTL	UINT_C(60)	/* åå²ããããã¼ã¿ã°ã©ã ã®çå­æéï¼ç§ï¼*/
+#define IP4_MSS		UINT_C(576)	/* æå¤§ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤	*/
+
+/* IPv4 ã¨ IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­ */
+
+#if !defined(_IP6_CFG) && defined(_IP4_CFG)
+
+#define IP_HDR_SIZE	IP4_HDR_SIZE
+#define T_IP_HDR	T_IP4_HDR
+#define IP_DEFTTL	IP4_DEFTTL
+
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+#endif	/* of #ifndef _IP4_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip4_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip4_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip4_var.h	(revision 317)
@@ -0,0 +1,268 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/ip_var.h,v 1.45.2.1 1999/08/29 16:29:51 peter Exp $
+ */
+ 
+#ifndef _IP4_VAR_H_
+#define _IP4_VAR_H_
+
+/*
+ *  IPv4 ãããã»ãã¤ã­ã¼ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define IF_IP4_HDR_SIZE			(IF_HDR_SIZE + IP4_HDR_SIZE)
+
+#define GET_IP4_HDR(nbuf)		((T_IP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_IP4_SDU(nbuf)		((uint8_t*)((nbuf)->buf) + GET_IF_IP4_HDR_SIZE(nbuf))
+
+#define GET_IP4_HDR_SIZE(nbuf)		((uint8_t)IP4_VHL_HL(GET_IP4_HDR(nbuf)->vhl) << 2)
+#define GET_IP4_SDU_SIZE(nbuf)		(ntohs(GET_IP4_HDR(nbuf)->len) - GET_IP4_HDR_SIZE(nbuf))
+#define GET_IF_IP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP4_HDR_SIZE(nbuf)))
+
+#define SET_IP4_SDU_SIZE(nbuf,slen)	(GET_IP4_HDR(nbuf)->len=(uint16_t)htons((slen) + IP4_HDR_SIZE))
+
+/*
+ *  IP ã® MSS ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf_ip_mss {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_HDR_SIZE + IP4_MSS];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF_IP_MSS;
+
+/*
+ *  65536 ãªã¯ããããµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf4_65536 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_IP4_HDR_SIZE + 65536];
+				/* ãããã¡æ¬ä½		*/
+#if defined(IF_PDU_HDR_PADDING)
+	uint8_t		padding[IF_PDU_HDR_PADDING];
+#endif				/* ãããã®ä½å		*/
+	} T_NET_BUF4_65536;
+
+#ifdef IP4_CFG_FRAGMENT
+
+/*
+ *  åæ§æã­ã¥ã¼ç¨ IPv4 ãããã®å®ç¾©
+ */
+
+typedef struct t_qip4_hdr {
+	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
+					/* length ã¯ 4 octets åä½		*/
+	uint8_t		type;		/* type of services			*/
+	uint16_t	len;		/* total length				*/
+
+	uint16_t	id;		/* identification			*/
+	uint16_t	flg_off;	/* fragment flag & offset		*/
+
+	uint8_t		ttl;		/* time to live				*/
+	uint8_t		proto;		/* protocol				*/
+	uint16_t	sum;		/* checksum				*/
+
+	uint32_t	src;		/* source address			*/
+
+	T_NET_BUF	*next;		/* æ¬¡ã® IPv4 ãã©ã°ã¡ã³ã			*/
+	} T_QIP4_HDR;
+
+#define QIP4_HDR_SIZE			(sizeof(T_QIP4_HDR))
+#define IF_QIP4_HDR_SIZE		(IF_HDR_SIZE + QIP4_HDR_SIZE)
+
+#define GET_QIP4_HDR(nbuf)		((T_QIP4_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_QIP4_SDU(nbuf)		((uint8_t*)(nbuf)->buf + GET_IF_QIP4_HDR_SIZE(nbuf))
+
+#define GET_QIP4_HDR_SIZE(iph)		((uint8_t)IP4_VHL_HL((iph)->vhl) << 2)
+#define GET_IF_QIP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_QIP4_HDR_SIZE(GET_QIP4_HDR(nbuf))))
+
+/*
+ *  ãã¼ã¿ã°ã©ã åæ§æç¨ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf4_reassm {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		align[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IP4_CFG_FRAG_REASSM_SIZE];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF4_REASSM;
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+/*
+ *  TCP ã®åæ§æã­ã¥ã¼ã«ããã IPv4 ãããã®å®ç¾©
+ */
+
+typedef struct t_ip4_tcp_q_hdr {
+	uint8_t		vhl;		/* version << 4 | header length >> 2	*/
+					/* length ã¯ 4 octets åä½		*/
+	uint8_t		type;		/* type of services			*/
+	uint16_t	len;		/* total length				*/
+
+	uint16_t	id;		/* identification			*/
+	uint16_t	flg_off;	/* fragment flag & offset		*/
+
+	uint8_t		ttl;		/* time to live				*/
+	uint8_t		proto;		/* protocol				*/
+	uint16_t	thoff;		/* TCP ãããã®ãªãã»ãã		*/
+
+	T_IN4_ADDR	src;		/* source address			*/
+	T_IN4_ADDR	dst;		/* destination address			*/
+	} T_IP4_TCP_Q_HDR;
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_ip_stats {
+	uint32_t	ipInReceives;
+	uint32_t	ipInHdrErrors;
+	uint32_t	ipInAddrErrors;
+/*	uint32_t	ipForwDatagrams;*/
+	uint32_t	ipInUnknownProtos;
+/*	uint32_t	ipInDiscards;*/
+	uint32_t	ipInDelivers;
+	uint32_t	ipOutRequests;
+	uint32_t	ipOutDiscards;
+/*	uint32_t	ipOutNoRoutes;*/
+
+#ifdef IP4_CFG_FRAGMENT
+
+	uint32_t	ipReasmReqds;
+	uint32_t	ipReasmOKs;
+	uint32_t	ipReasmFails;
+	uint32_t	ipFragOKs;
+	uint32_t	ipFragFails;
+	uint32_t	ipFragCreates;
+
+#else	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	uint32_t	ipReasmReqds;
+/*	uint32_t	ipReasmOKs;*/
+	uint32_t	ipReasmFails;
+/*	uint32_t	ipFragOKs;*/
+/*	uint32_t	ipFragFails;*/
+/*	uint32_t	ipFragCreates;*/
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+} T_IP_STATS;
+
+extern T_IP_STATS ip_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  é¢æ°
+ */
+
+extern void ip_frag_timer (void);
+extern void ip_init (void);
+extern ER ip_remove_options (T_NET_BUF *nbuf);
+extern ER ip_output (T_NET_BUF *nbuf, TMO tmout);
+extern void ip_exchg_addr (T_NET_BUF *nbuf);
+
+#endif	/* of #ifndef _IP4_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip6.h	(revision 317)
@@ -0,0 +1,314 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet/ip6.h,v 1.2.2.2 2001/07/03 11:01:46 ume Exp $	*/
+/*	$KAME: ip6.h,v 1.18 2001/03/29 05:34:30 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip.h	8.1 (Berkeley) 6/10/93
+ */
+ 
+#ifndef _IP6_H_
+#define _IP6_H_
+
+/*
+ *  IPv6 ã®å®ç¾©ãRFC2460 åç
+§
+ */
+
+#define IPV6_VERSION	6
+
+/*
+ *  IPv6 ãããã®å®ç¾©
+ */
+
+typedef struct t_ip6_hdr {
+	uint32_t	vcf;		/* Version:        4 bit		*/
+					/* Traffic Class:  8 bit		*/
+					/* Flow Label:    20 bit		*/
+	uint16_t	plen;		/* Payload Length			*/
+	uint8_t		next;		/* Next Header				*/
+	uint8_t		hlim;		/* Hop Limit				*/
+	T_IN6_ADDR 	src;		/* Source Address			*/
+	T_IN6_ADDR 	dst;		/* Destination Address			*/
+	} T_IP6_HDR;
+
+#define IP6_HDR_SIZE		(sizeof(T_IP6_HDR))
+
+/*
+ *  IPv6 ãããæ§é ä½ã¡ã³ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define IP6_MAKE_VCF(v,cf)	(((uint32_t)(v)<<28)|(cf))
+#define IP6_VCF_V(vcf)		((uint32_t)(vcf)>>28)
+#define IP6_VCF_C(vcf)		(((uint32_t)(vcf)>>20)&ULONG_C(0xff))
+#define IP6_VCF_F(vcf)		((uint32_t)(vcf)&ULONG_C(0x000fffff))
+#define IP6_VCF_CF(vcf)		((uint32_t)(vcf)&ULONG_C(0x0fffffff))
+
+/*
+ *  æ¡å¼µããã
+ */
+
+typedef struct t_ip6_ext_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		len;		/* 8 ãªã¯ãããåä½ã®é·ã	*/
+	} T_IP6_EXT_HDR;
+
+/*
+ *  ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³ããã
+ */
+
+typedef struct t_ip6_hbh_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		len;		/* 8 ãªã¯ãããåä½ã®é·ãããã ãã
+					 * ãã®ãªãã·ã§ã³ãããå
+¨ä½ã®ãªã¯ãããæ°ã
+					 * 8 ã§å²ã£ãå¤ã® - 1 ãå
+¥ãã
+					 */
+	} T_IP6_HBH_HDR;
+
+/*
+ *  çµç¹ (Destination) ãªãã·ã§ã³ããã
+ */
+
+typedef struct t_ip6_dest_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		len;		/* 8 ãªã¯ãããåä½ã®é·ãããã ãã
+					 * ãã®ãªãã·ã§ã³ãããå
+¨ä½ã®ãªã¯ãããæ°ã
+					 * 8 ã§å²ã£ãå¤ã® - 1 ãå
+¥ãã
+					 */
+	} T_IP6_DEST_HDR;
+
+/* ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³ */
+
+#define IP6OPT_PAD1		UINT_C(0x00)	/* 00 0 00000 */
+#define IP6OPT_PADN		UINT_C(0x01)	/* 00 0 00001 */
+#define IP6OPT_JUMBO		UINT_C(0xc2)	/* 11 0 00010 */
+#define IP6OPT_NSAP_ADDR	UINT_C(0xc3)	/* 11 0 00011 */
+#define IP6OPT_TUNNEL_LIMIT	UINT_C(0x04)	/* 00 0 00100 */
+#define IP6OPT_RTR_ALERT	UINT_C(0x05)	/* 00 0 00101 */
+
+#define IP6OPT_MINLEN		2	/* ãªãã·ã§ã³ã®æç­é·		*/
+
+/* æªç¥ã®ãªãã·ã§ã³ã®å¦çã®æå® */
+
+#define IP6OPT_TYPE_SKIP	UINT_C(0x00)	/* ç¡è¦ããã			*/
+#define IP6OPT_TYPE_DISCARD	UINT_C(0x40)	/* ãã¼ã¿ã°ã©ã ãç ´æ£ããã	*/
+#define IP6OPT_TYPE_FORCEICMP	UINT_C(0x80)	/* ç ´æ£ãã¦ãICMP ãè¿éããã	*/
+#define IP6OPT_TYPE_ICMP	UINT_C(0xc0)
+		/* ç ´æ£ãã¦ããã«ãã­ã£ã¹ãã§ãªããã° ICMP ãè¿éããã	*/
+
+#define IP6OPT_TYPE(o)		((o)&UINT_C(0xc0))
+
+/*
+ *  çµè·¯å¶å¾¡ããã
+ */
+
+typedef struct t_ip6_rt_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		len;		/* 8 ãªã¯ãããåä½ã®é·ãããã ãã
+					 * ãã®ãªãã·ã§ã³ãããå
+¨ä½ã®ãªã¯ãããæ°ã
+					 * 8 ã§å²ã£ãå¤ã® - 1 ãå
+¥ãã
+					 */
+	uint8_t		type;		/* çµè·¯å¶å¾¡ã¿ã¤ã		*/
+	uint8_t		segleft;	/* ã»ã°ã¡ã³ãã®æ®ã		*/
+	} T_IP6_RT_HDR;
+
+/*
+ *  ã¿ã¤ã 0 çµè·¯å¶å¾¡ããã
+ */
+
+typedef struct t_ip6_rt0_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		len;		/* 8 ãªã¯ãããåä½ã®é·ãããã ãã
+					 * ãã®ãªãã·ã§ã³ãããå
+¨ä½ã®ãªã¯ãããæ°ã
+					 * 8 ã§å²ã£ãå¤ã® - 1 ãå
+¥ãã
+					 */
+	uint8_t		type;		/* çµè·¯å¶å¾¡ã¿ã¤ã		*/
+	uint8_t		segleft;	/* ã»ã°ã¡ã³ãã®æ®ã		*/
+	uint32_t	reserved;	/* äºç´				*/
+	} T_IP6_RT0_HDR;
+
+/*
+ *  æ­çããã
+ */
+
+typedef struct t_ip6_frag_hdr {
+	uint8_t		next;		/* Next Header			*/
+	uint8_t		reserved;
+	uint16_t	off_flag;	/* ãªãã»ããã¨ãã©ã°		*/
+	uint32_t	ident;		/* åå²è­å¥å­			*/
+	} T_IP6_FRAG_HDR;
+
+/* æ­çãããã®ãªãã»ããã¨ãã©ã° */
+
+#ifdef _NET_CFG_BYTE_ORDER
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define IP6F_OFF_MASK		UINT_C(0xfff8)		/* ãªãã»ãããååºããã¹ã¯	*/
+#define IP6F_RESERVED_MASK	UINT_C(0x0006)		/* äºç´ãååºããã¹ã¯		*/
+#define IP6F_MORE_FRAG		UINT_C(0x0001)		/* ä¸­éãã©ã°ã¡ã³ã		*/
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+#define IP6F_OFF_MASK		UINT_C(0xf8ff)		/* ãªãã»ãããååºããã¹ã¯	*/
+#define IP6F_RESERVED_MASK	UINT_C(0x0600)		/* äºç´ãååºããã¹ã¯		*/
+#define IP6F_MORE_FRAG		UINT_C(0x0100)		/* ä¸­éãã©ã°ã¡ã³ã		*/
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
+
+/*
+ *  å¶éå¤
+ */
+
+#define IPV6_MAXHLIM	UINT_C(255)	/* ããããªãããã®æå¤§å¤				*/
+#define IPV6_DEFHLIM	UINT_C(64)	/* ããããªãããã®è¦å®å¤				*/
+#define IPV6_FRAGTTL	UINT_C(60)	/* åå²ããããã¼ã¿ã°ã©ã ã®çå­æéï¼ç§ï¼	*/
+#define IPV6_MMTU	UINT_C(1280)	/* æå° MTUããã¤ã­ã¼ã (1024) + ããã (256)	*/
+#define IPV6_MAXPACKET	UINT_C(65535)	/* ã¸ã£ã³ããã¤ã­ã¼ããé¤ãæå¤§ãã±ãããµã¤ãº	*/
+
+/*
+ *  IPv6 ã¨ IPv4 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­
+ */
+
+/*
+ *  ããããªãããã®è¦å®å¤ã¯ãã«ã¼ã¿éç¥ã«ããå¤æ´ããããã¨ããã
+ */
+
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+/* ã«ã¼ã¿éç¥ãåä¿¡ããå ´åã¯ãéç¥ãããå¤ */
+
+#define IP6_DEFTTL	ip6_defhlim
+
+#else	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/* ã«ã¼ã¿éç¥ãåä¿¡ããªãå ´åã®å¤ã¯æ¢å®å¤ */
+
+#define IP6_DEFTTL	IPV6_DEFHLIM
+
+#endif	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/* IPv4 ã¨ IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­ */
+
+#ifdef _IP6_CFG
+
+#define IP_HDR_SIZE	IP6_HDR_SIZE
+#define T_IP_HDR	T_IP6_HDR
+#define IP_DEFTTL	IP6_DEFTTL
+
+#endif	/* of #ifdef _IP6_CFG */
+
+#endif	/* of #ifndef _IP6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.c	(revision 317)
@@ -0,0 +1,475 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_icmp.c	8.2 (Berkeley) 1/4/94
+ * $FreeBSD: src/sys/netinet/ip_icmp.c,v 1.33.2.3 1999/10/14 11:49:38 des Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/icmp_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG)
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+T_ICMP_STATS icmp_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  é¢æ°
+ */
+
+static void icmp_echo (T_NET_BUF *input, uint_t ihoff);
+static void icmp_unreach (T_NET_BUF *input, uint_t ihoff);
+
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
+#if NUM_REDIRECT_ROUTE_ENTRY > 0
+
+static void icmp_redirect (T_NET_BUF *input, uint_t ihoff);
+
+#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+/*
+ *  icmp_echo -- ã¨ã³ã¼è¦æ±ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *    input ã«ã¯ IF ãããã¨ IP ããããå«ã¾ãã¦ããã
+ */
+
+static void
+icmp_echo (T_NET_BUF *input, uint_t ihoff)
+{
+	T_IP4_HDR	*ip4h;
+	T_ICMP4_HDR	*icmp4h;
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	NET_COUNT_MIB(icmp_stats.icmpInEchos, 1);
+
+	/* IPv4 ã¢ãã¬ã¹ãæªå®ç¾©ã®æã¯å¿ç­ããªãã*/
+	if (!IN4_IS_ADDR_ANY(&ifp->in4_ifaddr.addr)) {
+
+		/*
+		 *  ã¡ãã»ã¼ã¸ã®åãã¨ã³ã¼è¦æ± (8) ãã
+		 *  ã¨ã³ã¼å¿ç­ (0) ã«å¤æ´ãã¦éãè¿ãã
+		 */
+
+		icmp4h = GET_ICMP4_HDR(input, ihoff);
+		icmp4h->type = ICMP4_ECHO_REPLY;
+
+		/*
+		 *  å®å
+ã¢ãã¬ã¹ã¯åä¿¡ããã¡ãã»ã¼ã¸ã®éä¿¡å
+ã¢ãã¬ã¹ã
+		 *  éä¿¡å
+ã¢ãã¬ã¹ã¯èª IPv4 ã¢ãã¬ã¹ã
+		 */
+		ip4h      = GET_IP4_HDR(input);
+		ip4h->dst = ip4h->src;
+		ip4h->src = htonl(ifp->in4_ifaddr.addr);
+
+		/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+		icmp4h->sum = 0;
+		icmp4h->sum = in_cksum(icmp4h,
+		                       (uint_t)(((input->len - GET_IF_IP4_HDR_SIZE(input)) + 3) >> 2 << 2));
+
+		/* éä¿¡ããã*/
+		NET_COUNT_ICMP4(net_count_icmp4.out_octets,
+		               input->len - GET_IF_IP4_HDR_SIZE(input));
+		NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
+		NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
+		NET_COUNT_MIB(icmp_stats.icmpOutEchoReps, 1);
+		ip_output(input, TMO_ICMP_OUTPUT);
+		}
+	}
+
+/*
+ *  icmp_unreach -- ICMP4_UNREACH ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static const int8_t code2error[] = {
+	EV_HURCH,	/* ICMP4_UNREACH_NET			 0 */
+	EV_HURCH,	/* ICMP4_UNREACH_HOST			 1 */
+	EV_CNNRF,	/* ICMP4_UNREACH_PROTOCOL		 2 */
+	EV_CNNRF,	/* ICMP4_UNREACH_PORT			 3 */
+	EV_MSIZE,	/* ICMP4_UNREACH_FLAG			 4 */
+	EV_HURCH,	/* ICMP4_UNREACH_SRC_FAIL		 5 */
+	EV_HURCH,	/* ICMP4_UNREACH_NET_UNKNOWN		 6 */
+	EV_HURCH,	/* ICMP4_UNREACH_HOST_UNKNOWN		 7 */
+	EV_HURCH,	/* ICMP4_UNREACH_ISOLATED		 8 */
+	EV_HURCH,	/* ICMP4_UNREACH_NET_PROHIB		 9 */
+	EV_HURCH,	/* ICMP4_UNREACH_HOST_PROHIB		10 */
+	EV_HURCH,	/* ICMP4_UNREACH_TOS_NET		11 */
+	EV_HURCH,	/* ICMP4_UNREACH_TOS_HOST		12 */
+	EV_HURCH,	/* ICMP4_UNREACH_FILTER_PROHIB		13 */
+	EV_HURCH,	/* ICMP4_UNREACH_HOST_PRECEDENCE	14 */
+	EV_HURCH,	/* ICMP4_UNREACH_PRECEDENCE_CUTOFF	15 */
+	};
+
+static void
+icmp_unreach (T_NET_BUF *input, uint_t ihoff)
+{
+	T_IP4_HDR	*ip4h;
+	uint8_t		code;
+	ER		error;
+
+	NET_COUNT_MIB(icmp_stats.icmpInDestUnreachs, 1);
+
+	ip4h   = (T_IP4_HDR*)GET_ICMP4_SDU(input, ihoff);
+	code  = GET_ICMP4_HDR(input, ihoff)->code;
+	error = code2error[code];
+
+	/* æçµãããã TCP/UDP ã®ã¿å¯¾å¿ããã*/
+	if (ip4h->proto == IPPROTO_TCP || ip4h->proto == IPPROTO_UDP) {
+
+		memcpy(GET_IP4_HDR(input), ip4h, input->len - (IP4_HDR_SIZE + ICMP4_HDR_SIZE));
+		input->len -= IP4_HDR_SIZE + ICMP4_HDR_SIZE;
+
+#if defined(SUPPORT_TCP)
+
+		if (ip4h->proto == IPPROTO_TCP)
+			tcp_notify(input, error);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0
+
+		if (ip4h->proto == IPPROTO_UDP)
+			udp4_notify(input, error);
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
+
+		}
+	else
+		syslog(LOG_NOTICE, "[ICMP] error, code: %d.", code);
+	}
+
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
+#if NUM_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  icmp_redirect -- åãç´ãã¡ãã»ã¼ã¸ãåä¿¡ããã¨ãã®å¦ç
+ *
+ *    input ã«ã¯ IF ãããã¨ IP ããããå«ã¾ãã¦ããã
+ */
+
+static void
+icmp_redirect (T_NET_BUF *input, uint_t ihoff)
+{
+	T_IP4_HDR	*ip4h, *sip4h;
+	T_ICMP4_HDR	*icmp4h;
+
+	ip4h   = GET_IP4_HDR(input);
+	icmp4h = GET_ICMP4_HDR(input, ihoff);
+	sip4h  = (T_IP4_HDR *)GET_ICMP4_SDU(input, ihoff);
+
+	/*
+	 *  å
+å®¹ãã§ãã¯ãä»¥ä¸ã®å ´åã¯ã¨ã©ã¼
+	 *
+	 *    ã»ICMP ã³ã¼ãããICMP4_REDIRECT_PORT_AND_HOST (3) ä»¥ä¸
+	 *    ã»ãã¼ã¿ã°ã©ã é·ããICMP ã®æå°é·ããç­ã (IP ããã + ICMP ããã + IP ããã + 8)
+	 *    ã»ãã¼ã¿ã°ã©ã é·ããICMP ã®æå¤§é·ããç­ã
+	 *    ã»
+	 */
+	if (icmp4h->code > ICMP4_REDIRECT_PORT_AND_HOST ||
+	    ip4h->len < GET_IP4_ICMP4_HDR_SIZE(input) + 8 + IP4_HDR_SIZE ||
+	    ip4h->len < GET_IP4_ICMP4_HDR_SIZE(input) + 8 + (IP4_VHL_HL(sip4h->vhl) << 2)) {
+		NET_COUNT_ICMP4(net_count_icmp4.in_err_packets, 1);
+		return;
+		}
+
+	in4_rtredirect(icmp4h->data.addr, sip4h->dst, IN_RTF_REDIRECT, TMO_IN_REDIRECT);
+	}
+
+#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+/*
+ *  icmp_input -- ICMP ã®å
+¥åé¢æ°
+ *
+ *    input ã«ã¯ IF ãããã¨ IP ããããå«ã¾ãã¦ããã
+ */
+
+uint_t
+icmp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_ICMP4_HDR	*icmp4h;
+	T_IN4_ADDR	addr;
+	uint_t		len, align;
+
+	NET_COUNT_ICMP4(net_count_icmp4.in_octets,
+	               input->len - GET_IF_IP4_HDR_SIZE(input));
+	NET_COUNT_ICMP4(net_count_icmp4.in_packets, 1);
+
+	/* ICMP ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < IF_IP4_ICMP4_HDR_SIZE) {
+		NET_COUNT_ICMP4(net_count_icmp4.in_err_packets, 1);
+		NET_COUNT_MIB(icmp_stats.icmpInErrors, 1);
+		goto buf_rel;
+		}
+
+	icmp4h = (T_ICMP4_HDR *)(input->buf + *offp);
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
+	len   = input->len - *offp;
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((uint8_t*)input->buf + input->len, 0, (size_t)(align - len));
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	if (in_cksum(icmp4h, align) != 0) {
+		NET_COUNT_ICMP4(net_count_icmp4.in_err_packets, 1);
+		goto buf_rel;
+		}
+
+	/* ã¡ãã»ã¼ã¸ã®åã«ããåå²ããã*/
+	switch (icmp4h->type) {
+	case ICMP4_ECHO_REQUEST:
+		icmp_echo(input, *offp);
+		return IPPROTO_DONE;
+		break;
+	case ICMP4_ECHO_REPLY:
+
+#if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY)
+
+		icmp_echo_reply(input, *offp);
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(ICMP_CFG_CALLBACK_ECHO_REPLY) */
+
+		break;
+	case ICMP4_UNREACH:
+		icmp_unreach(input, *offp);
+		break;
+	case ICMP4_REDIRECT:
+
+#if defined(NUM_REDIRECT_ROUTE_ENTRY)
+#if NUM_REDIRECT_ROUTE_ENTRY > 0
+
+		addr = ntohl(icmp4h->data.addr);
+		syslog(LOG_INFO, "[ICMP] redirect, addr: %s.", ip2str(NULL, &addr));
+		icmp_redirect(input, *offp);
+
+#else	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+
+		addr = ntohl(icmp4h->data.addr);
+		syslog(LOG_INFO, "[ICMP] redirect ignored, addr: %s.", ip2str(NULL, &addr));
+
+#endif	/* of #if NUM_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+		addr = ntohl(icmp4h->data.addr);
+		syslog(LOG_INFO, "[ICMP] redirect ignored, addr: %s.", ip2str(NULL, &addr));
+
+#endif	/* of #if defined(NUM_REDIRECT_ROUTE_ENTRY) */
+
+		break;
+	default:
+		syslog(LOG_INFO, "[ICMP] unknown type: %d.", icmp4h->type);
+		NET_COUNT_ICMP4(net_count_icmp4.in_err_packets, 1);
+		break;
+		}
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+#ifdef ICMP_REPLY_ERROR
+
+/*
+ *  icmp_error -- ICMP ã¨ã©ã¼éä¿¡é¢æ°ã
+ *
+ *    input ã«ã¯ IF ãããã¨ IP ããããå«ã¾ãã¦ããã
+ *    icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ã
+ *    å¼åºãå´ã§ãéæ¾ãã¦ããçµäºããã	
+ */
+
+void
+icmp_error (uint8_t code, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_ICMP4_HDR	*icmp4h;
+	T_NET_BUF	*output;
+	T_IN4_ADDR	saddr;
+	uint_t		len, ip4hl, align;
+
+	ip4h  = GET_IP4_HDR(input);
+	ip4hl = GET_IP4_HDR_SIZE(input);
+
+	/* éä¿¡ç¨ã® IP ãã¼ã¿ã°ã©ã ãç²å¾ããã*/
+	if (input->len - ip4hl < 8)
+		len = input->len - ip4hl;
+	else
+		len = 8;
+	
+	saddr = ntohl(ip4h->src);
+	if (in4_get_datagram(&output, (uint_t)(ICMP4_HDR_SIZE + ip4hl + len), 0,
+	                     &saddr, NULL, IPPROTO_ICMP, IP4_DEFTTL, 
+	                     NBA_SEARCH_ASCENT, TMO_ICMP_OUTPUT) != E_OK)
+		return;
+
+	/* ICMP ããããè¨­å®ããã*/
+	icmp4h		= GET_ICMP4_HDR(output, IF_IP4_ICMP4_HDR_OFFSET);
+	icmp4h->type	= ICMP4_UNREACH;
+	icmp4h->code	= code;
+	icmp4h->data.addr= 0;
+
+	/* ã¨ã©ã¼ãçºçãã IP ãããã¨ ãã¼ã¿ 8 ãªã¯ããããã³ãã¼ããã*/
+	memcpy(GET_ICMP4_SDU(output, IF_IP4_ICMP4_HDR_OFFSET),
+	       GET_IP4_HDR(input), (size_t)(ip4hl + len));
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((uint8_t*)GET_ICMP4_SDU(output, IF_IP4_ICMP4_HDR_OFFSET) + ip4hl + len,
+		       0, (size_t)(align - len));
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	icmp4h->sum = 0;
+	icmp4h->sum = in_cksum(icmp4h, (uint_t)(ICMP4_HDR_SIZE + ip4hl + align));
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP4(net_count_icmp4.out_octets,
+	               output->len - GET_IF_IP4_HDR_SIZE(output));
+	NET_COUNT_ICMP4(net_count_icmp4.out_packets, 1);
+	NET_COUNT_MIB(icmp_stats.icmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp_stats.icmpOutDestUnreachs, 1);
+	ip_output(output, TMO_ICMP_OUTPUT);
+	}
+
+#endif	/* of #ifdef ICMP_REPLY_ERROR */
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip_icmp.h	(revision 317)
@@ -0,0 +1,200 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_icmp.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/ip_icmp.h,v 1.12.2.2 1999/11/18 08:51:44 peter Exp $
+ */
+ 
+#ifndef _IP_ICMP_H_
+#define _IP_ICMP_H_
+
+#include <netinet/icmp6.h>
+
+/*
+ *  ICMP ãããã®å®ç¾©ãRFC 792
+ */
+
+typedef struct t_icmp_hdr {
+	uint8_t		type;		/* ã¡ãã»ã¼ã¸ã®å	*/
+	uint8_t		code;		/* ãµãå		*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	union {
+		struct id_seq {
+			uint16_t	id;
+			uint16_t	seq;
+			} id_seq;
+		T_IN4_ADDR	addr;
+		} data;
+	} T_ICMP4_HDR;
+
+#define ICMP4_HDR_SIZE			(sizeof(T_ICMP4_HDR))
+#define IP4_ICMP4_HDR_SIZE		(IP4_HDR_SIZE + ICMP4_HDR_SIZE)
+#define IF_IP4_ICMP4_HDR_SIZE		(IF_IP4_HDR_SIZE + ICMP4_HDR_SIZE)
+#define IF_IP4_ICMP4_HDR_OFFSET		(IF_IP4_HDR_SIZE)
+
+#define GET_ICMP4_HDR(nbuf,ihoff)	((T_ICMP4_HDR*)((uint8_t*)((nbuf)->buf) + ihoff))
+#define GET_ICMP4_SDU(nbuf,ihoff)	((uint8_t*)((nbuf)->buf) + ihoff + ICMP4_HDR_SIZE)
+
+#define GET_ICMP4_HDR_OFFSET(nbuf)	(GET_IF_IP4_HDR_SIZE(nbuf))
+
+#define GET_IP4_ICMP4_HDR_SIZE(nbuf)	(GET_IP4_HDR_SIZE(nbuf) + ICMP4_HDR_SIZE)
+#define GET_IF_IP4_ICMP4_HDR_SIZE(nbuf)	(IF_HDR_SIZE + GET_IP4_ICMP4_HDR_SIZE(nbuf))
+
+/*
+ *  ã¡ãã»ã¼ã¸ã®å
+ */
+
+#define ICMP4_ECHO_REPLY	UINT_C(0)	/* ã¨ã³ã¼å¿ç­		*/
+#define ICMP4_UNREACH		UINT_C(3)	/* ã¨ã©ã¼		*/
+#define ICMP4_SOURCE_QUENCH	UINT_C(4)	/* çºä¿¡å¶é		*/
+#define ICMP4_REDIRECT		UINT_C(5)	/* æ¹åå¤æ´		*/
+#define ICMP4_ECHO_REQUEST	UINT_C(8)	/* ã¨ã³ã¼è¦æ±		*/
+#define ICMP4_TIME_EXCEEDED	UINT_C(11)	/* çºä¿¡å¶é		*/
+#define ICMP4_PARAMETER		UINT_C(12)	/* ãã©ã¡ã¼ã¿ç°å¸¸	*/
+#define ICMP4_TIME_REQUEST	UINT_C(13)	/* ã¿ã¤ã ã¹ã¿ã³ãè¦æ±	*/
+#define ICMP4_TIME_REPLY	UINT_C(14)	/* ã¿ã¤ã ã¹ã¿ã³ãå¿ç­	*/
+#define ICMP4_MASK_REQUEST	UINT_C(17)	/* ã¢ãã¬ã¹ãã¹ã¯è¦æ±	*/
+#define ICMP4_MASK_REPLY	UINT_C(18)	/* ã¢ãã¬ã¹ãã¹ã¯å¿ç­	*/
+
+/*
+ *  ãµãå
+ */
+
+/* ICMP4_UNREACH (3)	*/
+
+#define ICMP4_UNREACH_NET		UINT_C(0)	/* ãããã¯ã¼ã¯		*/
+#define ICMP4_UNREACH_HOST		UINT_C(1)	/* ãã¹ã		*/
+#define ICMP4_UNREACH_PROTOCOL		UINT_C(2)	/* ãã­ãã³ã«		*/
+#define ICMP4_UNREACH_PORT		UINT_C(3)	/* ãã¼ã		*/
+#define ICMP4_UNREACH_FLAG		UINT_C(4)	/* åå²			*/
+#define ICMP4_UNREACH_SRC_FAIL		UINT_C(5)	/* ã½ã¼ã¹çµè·¯		*/
+#define ICMP4_UNREACH_NET_UNKNOWN	UINT_C(6)	/* ãããã¯ã¼ã¯ä¸æ	*/
+#define ICMP4_UNREACH_HOST_UNKNOWN	UINT_C(7)	/* ãã¹ãä¸æ		*/
+#define ICMP4_UNREACH_ISOLATED		UINT_C(8)	/* åé¢			*/
+#define ICMP4_UNREACH_NET_PROHIB	UINT_C(9)	/* 			*/
+#define ICMP4_UNREACH_HOST_PROHIB	UINT_C(10)	/* 			*/
+#define ICMP4_UNREACH_TOS_NET		UINT_C(11)	/* ãããã¯ã¼ã¯ã¸ã®ä¸æ­£TOS*/
+#define ICMP4_UNREACH_TOS_HOST		UINT_C(12)	/* ãã¹ãã¸ã®ä¸æ­£TOS	*/
+#define ICMP4_UNREACH_FILTER_PROHIB	UINT_C(13)	/* 			*/
+#define ICMP4_UNREACH_HOST_PRECEDENCE	UINT_C(14)	/* 			*/
+#define ICMP4_UNREACH_PRECEDENCE_CUTOFF	UINT_C(15)	/* 			*/
+
+/* ICMP4_REDIRECT (5)	*/
+
+#define ICMP4_REDIRECT_NET		UINT_C(0)	/* ãããã¯ã¼ã¯		*/
+#define ICMP4_REDIRECT_HOST		UINT_C(1)	/* ãã¹ã		*/
+#define ICMP4_REDIRECT_PORT_AND_NET	UINT_C(2)	/* ãã¼ãçªå·ã¨ããã	*/
+#define ICMP4_REDIRECT_PORT_AND_HOST	UINT_C(3)	/* ãã¼ãçªå·ã¨ãã¹ã	*/
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#ifndef ICMP_REPLY_ERROR
+
+#define _tinet_icmp_error(code,data)
+
+#endif	/* of #ifdef ICMP_REPLY_ERROR */
+
+/*
+ *  é¢æ°
+ */
+
+extern uint_t icmp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+#ifdef ICMP_REPLY_ERROR
+
+extern void icmp_error (uint8_t code, T_NET_BUF *data);
+
+#endif	/* of #ifdef ICMP_REPLY_ERROR */
+
+/*
+ *  TINET ç¬èª API
+ */
+
+#ifdef ICMP_CFG_CALLBACK_ECHO_REPLY
+
+extern void icmp_echo_reply (T_NET_BUF *input, uint_t ihoff);
+
+#endif	/* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
+
+#endif	/* of #ifndef _IP_ICMP_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip_input.c	(revision 317)
@@ -0,0 +1,599 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)input.c	8.2 (Berkeley) 1/4/94
+ * $FreeBSD: src/sys/netinet/input.c,v 1.111.2.4 1999/11/01 22:23:53 des Exp $
+ *	$ANA: input.c,v 1.5 1996/09/18 14:34:59 wollman Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#if defined(SUPPORT_IPSEC)
+//#include <stdio.h>
+#include <sys/types.h>
+#include <netinet6/ipsec.h>
+#include <netinet6/esp.h>
+#include <netkey/key.h>
+#include <netkey/key_debug.h>
+#endif /* of defined(SUPPORT_IPSEC) */
+
+#include <net/if_var.h>
+
+#if defined(_IP4_CFG)
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+T_IP_STATS ip_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+#ifdef IP4_CFG_FRAGMENT
+
+/*
+ *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼
+ */
+
+static T_NET_BUF	*ip_frag_queue[NUM_IP4_FRAG_QUEUE];
+static T_IN4_ADDR	    frag_dst  [NUM_IP4_FRAG_QUEUE];
+
+/*
+ *  é¢æ°
+ */
+
+static void ip_freef (int_t ix);
+static T_NET_BUF *ip_reass (T_IP4_HDR *ip4h, T_NET_BUF *input);
+
+/*
+ *  ip_get_frag_queue -- ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãç²å¾ããã
+ */
+
+const T_NET_BUF **
+ip_get_frag_queue (void)
+{
+	return (const T_NET_BUF **)ip_frag_queue;
+	}
+
+/*
+ *  ip_freef -- ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãè§£æ¾ããã
+ */
+
+static void
+ip_freef (int_t ix)
+{
+	T_NET_BUF	*frag, *next;
+
+	frag = ip_frag_queue[ix];
+	while (frag != NULL) {
+		next = GET_QIP4_HDR(frag)->next;
+		syscall(rel_net_buf(frag));
+		frag = next;
+		}
+	ip_frag_queue[ix] = NULL;
+	}
+
+/*
+ *  ip_frag_timer -- ãã¼ã¿ã°ã©ã åæ§æç®¡çã¿ã¤ã
+ */
+
+void
+ip_frag_timer (void)
+{
+	T_NET_BUF	*frag;
+	int_t		ix;
+
+	syscall(wai_sem(SEM_IP4_FRAG_QUEUE));
+	for (ix = NUM_IP4_FRAG_QUEUE; ix -- > 0; ) {
+		frag = ip_frag_queue[ix];
+		if (frag != NULL && GET_QIP4_HDR(frag)->ttl > 0 &&
+		    -- GET_QIP4_HDR(frag)->ttl == 0) {
+			NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_TMOUT], 1);
+			NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_DROP], 1);
+			ip_freef(ix);
+			}
+		}
+	syscall(sig_sem(SEM_IP4_FRAG_QUEUE));
+	}
+
+/*
+ *  ip_reass -- ãã¼ã¿ã°ã©ã ãåæ§æããã
+ */
+
+static T_NET_BUF *
+ip_reass (T_IP4_HDR *ip4h, T_NET_BUF *input)
+{
+	T_NET_BUF	*frag, *prev;
+	T_IN4_ADDR	dst, src;
+	int_t		ix;
+	uint_t		id, off, len;
+
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_FRAGS], 1);
+	NET_COUNT_MIB(ip_stats.ipReasmReqds, 1);
+
+	src = ntohl(ip4h->src);
+	dst = ntohl(ip4h->dst);
+	NTOHS(ip4h->id);
+	NTOHS(ip4h->flg_off);
+	id = ip4h->id;
+	ix = id % NUM_IP4_FRAG_QUEUE;
+
+	syscall(wai_sem(SEM_IP4_FRAG_QUEUE));
+
+	/*
+	 *  IDãIPã¢ãã¬ã¹ãä¸ä½ãã­ãã³ã«ãç°ãªããã©ã°ã¡ã³ããã­ã¥ã¼ã«æãã°ç ´æ£ããã
+	 */
+	frag = ip_frag_queue[ix];
+	if (frag != NULL &&
+	    (id  != GET_IP4_HDR(frag)->id  ||
+	     dst != frag_dst[ix] ||
+	     src != ntohl(GET_IP4_HDR(frag)->src) ||
+	     ip4h->proto != GET_IP4_HDR(frag)->proto)) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_DROP], 1);
+		NET_COUNT_MIB(ip_stats.ipReasmFails, 1);
+		ip_freef(ix);
+		}
+
+	frag = ip_frag_queue[ix];
+	if (frag == NULL) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN], 1);
+
+		/* æ°è¦ã® ID ãªããå®å
+ã¢ãã¬ã¹ãä¿å­ãã¦ãã­ã¥ã¼ã«ã¤ãªãã*/
+		frag_dst  [ix] = dst;
+		ip_frag_queue[ix] = input;
+		((T_QIP4_HDR *)ip4h)->next = NULL;
+		input = NULL;
+
+		/* åæ§æã¿ã¤ã ã¢ã¦ããè¨­å®ããã*/
+		ip4h->ttl = IP4_FRAGTTL;
+		}
+	else {
+
+		/* æ­£ããä½ç½®ã«æ¿å
+¥ããã*/
+		prev = NULL;
+		while (frag != NULL &&
+		       IP4_FLGOFF_OFF(ip4h->flg_off) >
+		       IP4_FLGOFF_OFF(GET_QIP4_HDR(frag)->flg_off)) {
+			prev = frag;
+			frag = GET_QIP4_HDR(frag)->next;
+			}
+		((T_QIP4_HDR *)ip4h)->next = frag;
+		if (prev == NULL) {
+			ip4h->ttl      = GET_QIP4_HDR(frag)->ttl;
+			ip_frag_queue[ix] = input;
+			}
+		else
+			GET_QIP4_HDR(prev)->next = input;
+		input = NULL;
+
+		/* å
+¨ã¦ã®ãã©ã°ã¡ã³ããæã£ã¦ãããèª¿ã¹ãã*/
+		off = 0;
+		for (frag = ip_frag_queue[ix]; frag != NULL; frag = GET_QIP4_HDR(frag)->next) {
+			if ((IP4_FLGOFF_OFF(GET_QIP4_HDR(frag)->flg_off) << 3) != off) {
+				/* éä¸­ãæãã¦ãããçµäºããã*/
+				syscall(sig_sem(SEM_IP4_FRAG_QUEUE));
+				return NULL;
+				}
+			off += ntohs(GET_QIP4_HDR(frag)->len) - (IP4_VHL_HL(GET_QIP4_HDR(frag)->vhl) << 2);
+			prev = frag;				
+			}
+
+		/* å
+¨ã¦ã®ãã©ã°ã¡ã³ããæã£ããåæ§æããã*/
+		if ((GET_QIP4_HDR(prev)->flg_off & IP4_MF) == 0) {
+
+			/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+			if (tget_net_buf(&input, IF_IP4_HDR_SIZE + off, TMO_IP4_FRAG_GET_NET_BUF) == E_OK) {
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_OK], 1);
+				NET_COUNT_MIB(ip_stats.ipReasmOKs, 1);
+
+				/* IPv4 ããããè¨­å®ããã*/
+				frag  = ip_frag_queue[ix];
+				ip4h  = GET_IP4_HDR(input);
+				*ip4h = *GET_IP4_HDR(frag);
+				ip4h->dst     = htonl(frag_dst[ix]);
+				ip4h->len     = htons(IP4_HDR_SIZE + off);
+				ip4h->vhl     = IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
+				ip4h->ttl     = GET_QIP4_HDR(prev)->ttl;
+				ip4h->flg_off = ip4h->id = 0;
+
+				/* ãã¼ã¿ã°ã©ã ãåæ§æããã*/
+				off = IP4_HDR_SIZE;
+				while (frag != NULL) {
+					len = ntohs(GET_QIP4_HDR(frag)->len) - (IP4_VHL_HL(GET_QIP4_HDR(frag)->vhl) << 2);
+					memcpy((uint8_t *)ip4h + off, GET_QIP4_SDU(frag), len);
+					off += len;
+					frag = GET_QIP4_HDR(frag)->next;
+					}
+				}
+			else {
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_NO_BUF], 1);
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_IN_DROP], 1);
+				NET_COUNT_MIB(ip_stats.ipReasmFails, 1);
+				}
+			/* ã­ã¥ã¼ãç©ºã«ããã*/
+			ip_freef(ix);
+			}
+		}
+	syscall(sig_sem(SEM_IP4_FRAG_QUEUE));
+	return input;
+	}
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+/*
+ *  ip_init -- IP ã®åæå
+ */
+
+void
+ip_init (void)
+{
+	in4_init();
+	}
+
+/*
+ *  ip_remove_options -- IPv4 ãããã®ãªãã·ã§ã³ãåé¤ããä»¥éãåã«è©°ããã
+ */
+
+ER
+ip_remove_options (T_NET_BUF *nbuf)
+{
+	T_IP4_HDR	*iph;
+	uint_t		hdr_size;
+
+	iph  = GET_IP4_HDR(nbuf);
+	hdr_size = GET_IP4_HDR_SIZE(nbuf);
+
+	if (hdr_size > IP4_HDR_SIZE) {
+		memmove((char *)iph + IP4_HDR_SIZE, GET_IP4_SDU(nbuf),
+		        (size_t)(iph->len - hdr_size));
+		iph->vhl   = IP4_MAKE_VHL(IPV4_VERSION, IP4_HDR_SIZE >> 2);
+		iph->len  -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
+		nbuf->len -= (uint16_t)(hdr_size - IP4_HDR_SIZE);
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  ip_input -- IP ã®å
+¥åé¢æ°
+ */
+
+#if defined(SUPPORT_IPSEC)
+/*
+ * TODO: IPsec SPãæ¤ç´¢ãããã±ããããªã¸ã§ã¯ããããã©ããå¤å®ããå¦çãå®è£
+ãã
+ */
+#endif /* of defined(SUPPORT_IPSEC) */
+
+void
+ip_input (T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN4_ADDR	dst, src, bc;
+	uint_t		hlen, off;
+
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_OCTETS], input->len - IF_HDR_SIZE);
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_PACKETS], 1);
+	NET_COUNT_MIB(ip_stats.ipInReceives, 1);
+
+	/* IP ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < IF_IP4_HDR_SIZE) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_SHORT], 1);
+		NET_COUNT_MIB(ip_stats.ipInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	ip4h = GET_IP4_HDR(input);
+	hlen = GET_IP4_HDR_SIZE(input);
+
+	/* ãã¼ã¸ã§ã³ããã§ãã¯ããã*/
+	if (IP4_VHL_V(ip4h->vhl) != IPV4_VERSION) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_VER], 1);
+		NET_COUNT_MIB(ip_stats.ipInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	/* IP ãããã®é·ãããã§ãã¯ãããªãã·ã§ã³ãè§£æããã*/
+	if (hlen > IP4_HDR_SIZE) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_OPTS], 1);
+		/* %%% ãªãã·ã§ã³ã®è§£æ %%% */
+		}
+
+	/* ãã¼ã¿ã°ã©ã é·ããã§ãã¯ããã*/
+	if (ntohs(ip4h->len) > input->len - IF_HDR_SIZE) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_SHORT], 1);
+		NET_COUNT_MIB(ip_stats.ipInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	/* ãããã¯ã¼ã¯ãããã¡ã®é·ãããã¼ã¿ã°ã©ã é·ã«èª¿æ´ããã*/
+	input->len = (uint16_t)(ntohs(ip4h->len) + IF_HDR_SIZE);
+
+	/* ãã§ãã¯ãµã ããã§ãã¯ããã*/
+	if (in_cksum(ip4h, hlen) != 0) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_CKSUM], 1);
+		NET_COUNT_MIB(ip_stats.ipInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	/* IP ãããã®é·ãããã§ãã¯ããä¸ä½ã ICMP ä»¥å¤ã¯ãªãã·ã§ã³ãæ¶å»ããã*/
+	if (hlen > IP4_HDR_SIZE && ip4h->proto != IPPROTO_ICMP) {
+		memset((uint8_t*)ip4h + IP4_HDR_SIZE, 0, hlen - IP4_HDR_SIZE);
+		}
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ããã§ãã¯ããã*/
+	src = ntohl(ip4h->src);
+	bc  = (ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask;
+
+#ifdef SUPPORT_LOOP
+
+	if (src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#else	/* of #ifdef SUPPORT_LOOP */
+
+	if (src == ifp->in4_ifaddr.addr || src == bc || src == IPV4_ADDR_BROADCAST || src == IPV4_ADDRANY) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+	/* ãã¦å
+ã¢ãã¬ã¹ããã§ãã¯ããã*/
+	dst = ntohl(ip4h->dst);
+
+#ifdef DHCP_CFG
+
+	/*
+	 *  DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©ã®
+	 *  å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+	 */
+
+	if ((ifp->in4_ifaddr.addr != IPV4_ADDRANY) &&
+	    (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
+	       dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY))) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#else	/* of #ifdef DHCP_CFG */
+
+	if (!(dst == ifp->in4_ifaddr.addr || dst == bc ||
+	      dst == IPV4_ADDR_BROADCAST  || dst == IPV4_ADDRANY)) {
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(ip_stats.ipInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#endif	/* of #ifdef DHCP_CFG */
+
+#ifdef IP4_CFG_FRAGMENT
+
+	/* åå²ããã¦ããããã§ãã¯ããã*/
+	if (ntohs(ip4h->flg_off) & (IP4_MF | IP4_OFFMASK)) {
+		if ((input = ip_reass(ip4h, input)) == NULL)
+			return;
+		}
+
+#else	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	/* åå²ããã¦ããããã§ãã¯ããã*/
+	if (ntohs(ip4h->flg_off) & (IP4_MF | IP4_OFFMASK)) {
+		T_IN4_ADDR	src;
+
+		NET_COUNT_MIB(ip_stats.ipReasmReqds, 1);
+		if ((ntohs(ip4h->flg_off) & IP4_OFFMASK) == 0) {
+			NET_COUNT_MIB(ip_stats.ipReasmFails, 1);
+			}
+		src = ntohl(ip4h->src);
+		syslog(LOG_WARNING, "[IP] flaged src: %s.", ip2str(NULL, &src));
+		goto buf_rel;
+		}
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	off  = (uint_t)(GET_IP4_SDU(input) - input->buf);
+
+#if defined(SUPPORT_IPSEC)
+	/* ããã§ipsec4_in_rejectãå®è¡ãã */
+	if ((ip4h->proto != IPPROTO_ESP) && ipsec4_in_reject (input)) {
+		goto buf_rel;
+	}
+#endif /* of #if defined(SUPPORT_IPSEC) */
+
+	/* ãã­ãã³ã«ãé¸æãã */
+	switch (ip4h->proto) {
+
+#if defined(SUPPORT_TCP)
+	case IPPROTO_TCP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		tcp_input(&input, &off, NULL);
+		return;
+		break;
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && ( (TNUM_UDP4_CEPID > 0) || \
+                             ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
+	case IPPROTO_UDP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		udp4_input(&input, &off, NULL);
+		return;
+		break;
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP4_CEPID > 0 */
+
+	case IPPROTO_ICMP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		icmp_input(&input, &off, NULL);
+		return;
+		break;
+
+#if defined(SUPPORT_IPSEC)
+	case IPPROTO_ESP:
+		NET_COUNT_MIB(ip_stats.ipInDelivers, 1);
+		esp4_input(input, &off);
+		return;
+		break;
+#endif /* of #if defined(SUPPORT_IPSEC) */
+
+	default:
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_PROTO], 1);
+		NET_COUNT_MIB(ip_stats.ipInUnknownProtos, 1);
+
+		/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+		if (dst == ifp->in4_ifaddr.addr) {
+			T_IN4_ADDR	src;
+
+			src = ntohl(ip4h->src);
+			syslog(LOG_INFO, "[IP] unexp proto: %d, src=%s.", ip4h->proto, ip2str(NULL, &src));
+			icmp_error(ICMP4_UNREACH_PROTOCOL, input);
+			}
+		/*
+		 *  icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§
+		 *  éæ¾ãã¦ããçµäºããã
+		 */
+		break;
+		}
+
+buf_rel:
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip_output.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip_output.c	(revision 317)
@@ -0,0 +1,343 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)output.c	8.3 (Berkeley) 1/21/94
+ * $FreeBSD: src/sys/netinet/output.c,v 1.85.2.4 1999/08/29 16:29:49 peter Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/ppp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#if defined(SUPPORT_IPSEC)
+#include <netinet6/ipsec.h>
+#endif
+
+#if defined(_IP4_CFG)
+
+static uint16_t frag_id = 0;
+
+/*
+ *  IP output -- IP ã®åºåé¢æ°
+ *
+ *    æ³¨æ: ãã¼ã¸ã§ã³ã¨ãããé·ã¯ä¸ä½å±¤ã§è¨­å®ããã
+ */
+
+ER
+ip_output (T_NET_BUF *output, TMO tmout)
+{
+	T_IP4_HDR	*ip4h;
+	ER		error = E_OK;
+	T_IN4_ADDR	gw;
+
+#ifdef SUPPORT_IPSEC
+	T_SECPOLICY* sp;
+	int ipsec_error;
+        int policy;
+#endif /* SUPPORT_IPSEC */
+
+	NET_COUNT_MIB(ip_stats.ipOutRequests, 1);
+
+#ifdef SUPPORT_IPSEC
+        /* XXX: IPsecã®å¦çã¯ãã±ããæ­çåã®åã«è¡ããã */
+
+	/* SPDãåå¾ãã */
+	sp = ipsec4_getpolicybyaddr(output, IPSEC_DIR_OUTBOUND, &ipsec_error);
+	if (sp==NULL) {
+                error = ipsec_error;
+                return error;
+        }
+
+        /* ããªã·ããã§ãã¯ãã*/
+#if 0
+        switch (sp->policy) {
+
+        case IPSEC_POLICY_BYPASS:
+        case IPSEC_POLICY_NONE:
+        case IPSEC_POLICY_TCP:
+                goto skip_ipsec;
+
+                break; /* NOTREACHED */
+
+        case  IPSEC_POLICY_IPSEC:
+                /* XXX: SH2ã§ã¯ããã§illegal Instructionãçºçãããã³ã³ãã¤ã©ã®ãã°? */
+                if (sp->req == NULL) {
+                        /* éµäº¤æãã¼ã¢ã³ã«å¯¾ãã¦SAã®åå¾ãè¦æ±ãã */
+                        goto bad;
+                }
+                break;
+
+        default:
+                /* ä¸æ­£ãªããªã· */
+                goto bad;
+                break;
+        }
+#else /* 0 */
+        /* XXX: ã³ã³ãã¤ã©ã®ä¸å
+·ååé¿ã®ãã switchãããifæã§æ¸ãç´ãã */
+        policy = sp->spinitb->policy;
+
+        if (policy == IPSEC_POLICY_BYPASS ||
+            policy == IPSEC_POLICY_NONE ||
+            policy == IPSEC_POLICY_TCP)
+                goto skip_ipsec;
+        else if (policy == IPSEC_POLICY_IPSEC) {
+                if (sp->req == NULL)
+                        /* éµäº¤æãã¼ã¢ã³ã«å¯¾ãã¦SAã®åå¾ãè¦æ±ãã */
+                        goto bad;
+        } else
+                goto bad;
+
+#endif /* 0 */
+
+		{
+			T_IPSEC_OUTPUT_STATE state;
+
+			state.m = output;
+			/* XXX: ipsec4_output()å
+ã§ã¯ãip->{len,off}ããããã¯ã¼ã¯ãã¤ããªã¼ãã¨ãã */
+			error = ipsec4_output (&state, sp, 0 /* flags */ );
+			output = state.m;
+
+			if (error) {
+				/* net_buf ã¯ipsec4_outputã«ãã£ã¦æ¢ã«è§£æ¾ããã¦ãã */
+				switch (error) {
+				default:
+					syslog (LOG_NOTICE, "ip_output:%d error", __LINE__);
+				}
+			}
+		}
+
+        /* ipsec4_outputã«å½±é¿ãåããå¤ãæ´æ°ãã */
+        /* XXX: å¿
+è¦ã? */
+
+skip_ipsec:
+#endif /* SUPPORT_IPSEC */
+
+#ifdef IP4_CFG_FRAGMENT
+
+	ip4h = GET_IP4_HDR(output);
+
+	gw = in4_rtalloc(ntohl(ip4h->dst));
+
+	/*
+	 *  ãã¼ã¿ã°ã©ã ãµã¤ãºããããã¯ã¼ã¯ã® MTU ãè¶
+ãã¦ããã°ã
+	 *  åå²ãã¦éä¿¡ããã
+	 */
+	if (ntohs(ip4h->len) > IF_MTU) {
+		T_NET_BUF	*frag;
+		T_IP4_HDR	*fip4h;
+		uint_t		off, hlen, len, flen, align;
+
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_OUT], 1);
+		NET_COUNT_MIB(ip_stats.ipFragCreates, 1);
+
+		len  = ntohs(ip4h->len);
+		off  = hlen = GET_IP4_HDR_SIZE(output);
+		while (off < len) {
+			if (off + (IF_MTU - IP4_HDR_SIZE) < len)
+				flen = IF_MTU - IP4_HDR_SIZE;
+			else
+				flen = len - off;
+
+			/* ãã¼ã¿é·ã¯ 4 ãªã¯ãããå¢çã«èª¿æ´ããã	*/
+			align = (flen + 3) >> 2 << 2;
+
+			/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+			if (tget_net_buf(&frag, align + IF_IP4_HDR_SIZE, TMO_IP4_FRAG_GET_NET_BUF) == E_OK) {
+
+				/* ãã©ã°ã¡ã³ããã³ãã¼ããã*/
+				memcpy(GET_IP4_SDU(frag), (uint8_t *)ip4h + off, flen);
+
+				/* ããããåããã*/
+				fip4h		= GET_IP4_HDR(frag);
+				*fip4h		= *ip4h;
+				fip4h->flg_off	= htons(IP4_MAKE_FLGOFF(off + flen == len ? 0 : IP4_MF,
+						                       (off - hlen) >> 3));
+				fip4h->len	= htons(flen + IP4_HDR_SIZE);
+				fip4h->id	= htons(frag_id);
+				fip4h->sum	= 0;
+				fip4h->sum	= in_cksum(fip4h, GET_IP4_HDR_SIZE(frag));
+
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(fip4h->len));
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_PACKETS], 1);
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_FRAG_OUT_FRAGS], 1);
+
+				IF_SET_PROTO(frag, IF_PROTO_IP);
+				if ((error = IF_OUTPUT(frag, &gw, NULL, tmout)) != E_OK) {
+					syscall(rel_net_buf(output));
+					NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+					NET_COUNT_MIB(ip_stats.ipFragFails, 1);
+					return error;
+					}
+				}
+			else {
+				/* ç²å¾ã§ããªããã°ãéä¿¡ããããããã*/
+				syscall(rel_net_buf(output));
+				NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+				NET_COUNT_MIB(ip_stats.ipFragFails, 1);
+				return E_NOMEM;
+				}
+
+			off += IF_MTU - IP4_HDR_SIZE;
+			}
+		syscall(rel_net_buf(output));
+		frag_id ++;
+		NET_COUNT_MIB(ip_stats.ipFragOKs, 1);
+		}
+	else {
+
+		/* ããããåããã*/
+		ip4h->id  = htons(frag_id);
+		frag_id ++;
+		ip4h->sum = 0;
+		ip4h->sum = in_cksum(ip4h, GET_IP4_HDR_SIZE(output));
+
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_PACKETS], 1);
+
+		IF_SET_PROTO(output, IF_PROTO_IP);
+		if ((error = IF_OUTPUT(output, &gw, NULL, tmout)) != E_OK)
+			NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+		}
+
+#else	/* of #ifdef IP4_CFG_FRAGMENT */
+
+	ip4h = GET_IP4_HDR(output);
+
+	/* ãã¼ã¿ã°ã©ã ãµã¤ãºããããã¯ã¼ã¯ã® MTU ãè¶
+ãã¦ããã°ã¨ã©ã¼ */
+	if (ntohs(ip4h->len) > IF_MTU)
+		return E_PAR;
+
+	/* ããããåããã*/
+	ip4h->id  = htons(frag_id);
+	frag_id ++;
+	ip4h->sum = 0;
+	ip4h->sum = in_cksum(ip4h, (uint_t)GET_IP4_HDR_SIZE(output));
+
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_OCTETS], ntohs(ip4h->len));
+	NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_PACKETS], 1);
+
+	gw = in4_rtalloc(ntohl(ip4h->dst));
+	IF_SET_PROTO(output, IF_PROTO_IP);
+	if ((error = IF_OUTPUT(output, &gw, NULL, tmout)) != E_OK)
+		NET_COUNT_IP4(net_count_ip4[NC_IP4_OUT_ERR_PACKETS], 1);
+		NET_COUNT_MIB(ip_stats.ipOutDiscards, 1);
+
+#endif	/* of #ifdef IP4_CFG_FRAGMENT */
+
+#ifdef SUPPORT_IPSEC
+	bad:
+#endif /* SUPPORT_IPSEC */
+
+	return error;
+	}
+
+#endif	/* of #if defined(_IP4_CFG) */
Index: asp3_gr_sakura/trunk/tinet/netinet/ip_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/ip_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/ip_var.h	(revision 317)
@@ -0,0 +1,167 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_var.h	8.2 (Berkeley) 1/9/95
+ * $FreeBSD: src/sys/netinet/ip_var.h,v 1.45.2.1 1999/08/29 16:29:51 peter Exp $
+ */
+ 
+#ifndef _IP_VAR_H_
+#define _IP_VAR_H_
+
+#include <netinet/ip4_var.h>
+#include <netinet6/ip6_var.h>
+
+/*
+ *  IPv4 ã¨ IPv6 ãã³ã³ãã¤ã«æã«é¸æããããã®ãã¯ã­
+ */
+
+#define GET_IP_VER(nbuf)		(*(uint8_t*)((nbuf)->buf+IF_HDR_SIZE)>>4)
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+#define IF_IP_HDR_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?IF_IP6_HDR_SIZE:IF_IP4_HDR_SIZE)
+#define IF_IP_NET_HDR_SIZE(addr)	(IN6_IS_ADDR_V4MAPPED(addr)?IF_IP4_HDR_SIZE:IF_IP6_HDR_SIZE)
+
+#define IP_OUTPUT(nbuf,tmout)		(GET_IP_VER(nbuf)==IPV6_VERSION?ip6_output(nbuf,0,tmout):ip_output(nbuf,tmout))
+#define IP_REMOVE_OPTIONS(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?ip6_remove_exthdrs(nbuf):ip_remove_options(nbuf))
+
+#define GET_IP_HDR(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR(nbuf):GET_IP4_HDR(nbuf))
+#define GET_IP_HDR_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_HDR_SIZE(nbuf):GET_IP4_HDR_SIZE(nbuf))
+#define GET_IP_SDU_SIZE(nbuf)		(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IP6_SDU_SIZE(nbuf):GET_IP4_SDU_SIZE(nbuf))
+#define GET_IF_IP_HDR_SIZE(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION?GET_IF_IP6_HDR_SIZE(nbuf):GET_IF_IP4_HDR_SIZE(nbuf))
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(GET_IP_VER(nbuf)==IPV6_VERSION?\
+					((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff:((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
+
+#define SET_IP_CF(nbuf,cf)		(GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_CF(nbuf,cf):(0))
+#define SET_IP_SDU_SIZE(nbuf,len)	(GET_IP_VER(nbuf)==IPV6_VERSION?SET_IP6_SDU_SIZE(nbuf,len):SET_IP4_SDU_SIZE(nbuf,len))
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(GET_IP_VER(nbuf)==IPV6_VERSION\
+						?(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)\
+						:(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff))
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#define IF_IP_HDR_SIZE(nbuf)		IF_IP6_HDR_SIZE
+#define IF_IP_NET_HDR_SIZE(addr)	IF_IP6_HDR_SIZE
+
+#define IP_OUTPUT(nbuf,tmout)		ip6_output(nbuf,0,tmout)
+#define IP_REMOVE_OPTIONS(nbuf)		ip6_remove_exthdrs(nbuf)
+
+#define GET_IP_HDR(nbuf)		GET_IP6_HDR(nbuf)
+#define GET_IP_HDR_SIZE(nbuf)		GET_IP6_HDR_SIZE(nbuf)
+#define GET_IP_SDU_SIZE(nbuf)		GET_IP6_SDU_SIZE(nbuf)
+#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP6_HDR_SIZE(nbuf)
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff)
+
+#define SET_IP_CF(nbuf,cf)		SET_IP6_CF(nbuf,cf)
+#define SET_IP_SDU_SIZE(nbuf,len)	SET_IP6_SDU_SIZE(nbuf,len)
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(((T_IP6_TCP_Q_HDR*)GET_IP6_HDR(nbuf))->thoff=thoff)
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define IF_IP_HDR_SIZE(nbuf)		IF_IP4_HDR_SIZE
+#define IF_IP_NET_HDR_SIZE(addr)	IF_IP4_HDR_SIZE
+
+#define IP_OUTPUT(nbuf,tmout)		ip_output(nbuf,tmout)
+#define IP_REMOVE_OPTIONS(nbuf)		ip_remove_options(nbuf)
+
+#define GET_IP_HDR(nbuf)		GET_IP4_HDR(nbuf)
+#define GET_IP_HDR_SIZE(nbuf)		GET_IP4_HDR_SIZE(nbuf)
+#define GET_IP_SDU_SIZE(nbuf)		GET_IP4_SDU_SIZE(nbuf)
+#define GET_IF_IP_HDR_SIZE(nbuf)	GET_IF_IP4_HDR_SIZE(nbuf)
+#define GET_IP_TCP_Q_HDR_OFFSET(nbuf)	(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff)
+
+#define SET_IP_SDU_SIZE(nbuf,len)	SET_IP4_SDU_SIZE(nbuf,len)
+#define SET_IP_TCP_Q_HDR_OFFSET(nbuf,thoff)	\
+					(((T_IP4_TCP_Q_HDR*)GET_IP4_HDR(nbuf))->thoff=thoff)
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#error "not implemented."
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #ifndef _IP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp.cfg	(revision 317)
@@ -0,0 +1,72 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TCP ã§ä½¿ç¨ããã«ã¼ãã«ãªãã¸ã§ã¯ã
+ */
+
+#ifdef SUPPORT_TCP
+
+/* åºåã¿ã¹ã¯ */
+
+CRE_TSK(TCP_OUTPUT_TASK, {
+	TA_HLNG,
+	0,
+	tcp_output_task,
+	TCP_OUT_TASK_PRIORITY,
+	TCP_OUT_TASK_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_TCP_POST_OUTPUT,	{ TA_TPRI, 0, 1 });
+CRE_SEM(SEM_TCP_CEP,		{ TA_TPRI, 1, 1 });
+
+#ifdef TCP_CFG_TRACE
+CRE_SEM(SEM_TCP_TRACE,		{ TA_TPRI, 1, 1 });
+#endif	/* of #ifdef TCP_CFG_TRACE */
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp.h	(revision 317)
@@ -0,0 +1,192 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/tcp.h,v 1.10.2.1 1999/08/29 16:29:52 peter Exp $
+ */
+ 
+#ifndef _TCP_H_
+#define _TCP_H_
+
+/*
+ *  TCP ããããRFC 793 åç
+§
+ */
+
+typedef struct t_tcp_hdr {
+	uint16_t	sport;		/* éä¿¡å
+ãã¼ãçªå·			*/
+	uint16_t	dport;		/* å®å
+ãã¼ãçªå·			*/
+
+	uint32_t	seq;		/* SEQ çªå·				*/
+
+	uint32_t	ack;		/* ACK çªå·				*/
+
+	uint8_t		doff;		/* ãã¼ã¿ãªãã»ãã(ä¸ä½4ããã)	*/
+	uint8_t		flags;		/* ãã©ã°(ä¸ä½6ããã)			*/
+	uint16_t	win;		/* ã¦ã£ã³ããµã¤ãº			*/
+
+	uint16_t	sum;		/* ãã§ãã¯ãµã 				*/
+	uint16_t	urp;		/* ç·æ¥ãã¤ã³ã¿				*/
+	} T_TCP_HDR;
+
+#define TCP_HDR_SIZE			(sizeof(T_TCP_HDR))
+
+/*
+ *  TCP ãããæ§é ä½ã¡ã³ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define TCP_MAKE_DATA_OFF(o)	((uint8_t)(((uint8_t)(o) << 2) & 0xf0))
+#define TCP_DATA_OFF(o)		(((uint8_t)(o) & UINT_C(0xf0)) >> 2)
+#define TCP_HDR_LEN(o)		(TCP_DATA_OFF(o))
+
+/*
+ *  TCP ãããã®ãã©ã°ãã£ã¼ã«ãã®å¤ã®å®ç¾©
+ */
+
+#define TCP_FLG_FIN		UINT_C(0x01)	/* FIN:	æçµ			*/
+#define TCP_FLG_SYN		UINT_C(0x02)	/* SYN:	åæ			*/
+#define TCP_FLG_RST		UINT_C(0x04)	/* RST:	ã³ãã¯ã·ã§ã³ã®ãªã»ãã	*/
+#define TCP_FLG_PUSH		UINT_C(0x08)	/* PUSH:ããã·ã¥æ©è½		*/
+#define TCP_FLG_ACK		UINT_C(0x10)	/* ACK:	è¯å®å¿ç­		*/
+#define TCP_FLG_URG		UINT_C(0x20)	/* URG:	ç·æ¥æ
+å ±		*/
+
+/*
+ *  TCP ãªãã·ã§ã³ã®å®ç¾©
+ */
+
+/* ãªãã·ã§ã³ã®å */
+
+#define TCP_OPT_EOL		UINT_C(0)	/* æçµ				*/
+#define TCP_OPT_NOP		UINT_C(1)	/* ä½ãããªã			*/
+#define TCP_OPT_MAXSEG		UINT_C(2)	/* æå¤§ã»ã°ã¡ã³ãé·		*/
+#define TCP_OPT_WINDOW		UINT_C(3)	/* ã¦ã£ã³ãã¹ã±ã¼ãªã³ã°		*/
+#define TCP_OPT_SACK_PERM	UINT_C(4)	/* é¸æ ACK è¨±å¯		*/
+#define TCP_OPT_SACK		UINT_C(5)	/* é¸æ ACK			*/
+#define TCP_OPT_TIMESTAMP	UINT_C(8)	/* ã¿ã¤ã ã¹ã¿ã³ã		*/
+#define TCP_OPT_CC		UINT_C(11)	/* æ¥ç¶ã«ã¦ã³ã			*/
+#define TCP_OPT_CCNEW		UINT_C(12)	/* æ¥ç¶ã«ã¦ã³ã			*/
+#define TCP_OPT_CCECHO		UINT_C(13)	/* æ¥ç¶ã«ã¦ã³ã			*/
+
+/* ãªãã·ã§ã³ã®é·ã */
+
+#define TCP_OPT_LEN_MAXSEG	4		/* æå¤§ã»ã°ã¡ã³ãé·		*/
+#define TCP_OPT_LEN_WINDOW	3		/* ã¦ã£ã³ãã¹ã±ã¼ãªã³ã°		*/
+#define TCP_OPT_LEN_SACK_PERM	4		/* é¸æ ACK è¨±å¯		*/
+#define TCP_OPT_LEN_SACK	5		/* é¸æ ACK			*/
+#define TCP_OPT_LEN_TIMESTAMP	10		/* ã¿ã¤ã ã¹ã¿ã³ã		*/
+#define TCP_OPT_LEN_CC		6		/* æ¥ç¶ã«ã¦ã³ã			*/
+#define TCP_OPT_LEN_CCNEW	6		/* æ¥ç¶ã«ã¦ã³ã			*/
+#define TCP_OPT_LEN_CCECHO	6		/* æ¥ç¶ã«ã¦ã³ã			*/
+
+/*
+ *  TCP æå¤§ã»ã°ã¡ã³ããµã¤ãº
+ */
+
+/*
+ *  IPv4 ã® TCP æå¤§ã»ã°ã¡ã³ããµã¤ãº
+ *  IP4_MSS ã¯ 576 ã§ãæ¨æºã® IPv4 ãããé· (20) ã¨
+ *  TCP ãããé· (20) ãå¼ããå¤ 536 ã§ãããã512 ãæ¨æºã¨ããã
+ */
+
+#define TCP_MSS			UINT_C(512)
+
+/*
+ *  IPv6 ã® TCP æå¤§ã»ã°ã¡ã³ããµã¤ãº
+ *  IPV6_MMTU ã¯ 1280 ã§ãæ¨æºã® IPv6 ãããé· (40) ã¨
+ *  TCP ãããé· (20) ãå¼ããå¤ 1220 ã§ãããã1024 ãæ¨æºã¨ããã
+ */
+
+#define TCP6_MSS		UINT_C(1024)
+
+/*
+ *  TCP æå°ã»ã°ã¡ã³ããµã¤ãº
+ *
+ *  256ï¼æå°ãªã³ã¯ MTUï¼- 40 = 216
+ */
+
+#define TCP_MINMSS		UINT_C(216)
+
+/*
+ *  TCP æå¤§ã¦ã£ã³ãã¦ãµã¤ãº
+ */
+
+#define MAX_TCP_WIN_SIZE	UINT_C(65535)
+
+#endif	/* of #ifndef _TCP_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_fsm.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_fsm.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_fsm.h	(revision 317)
@@ -0,0 +1,123 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_fsm.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/tcp_fsm.h,v 1.10.2.3 1999/11/15 02:52:54 green Exp $
+ */
+ 
+#ifndef _TCP_FSM_H_
+#define _TCP_FSM_H_
+
+/*
+ *  TCP FSM ç¶æ
+ã®å®ç¾©ãRFC 793 åç
+§
+ */
+
+#define TCP_FSM_CLOSED		0	/* ã¯ã­ã¼ãº				*/
+#define TCP_FSM_LISTEN		1	/* ååãªã¼ãã³				*/
+#define TCP_FSM_SYN_SENT	2	/* è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿		*/
+#define TCP_FSM_SYN_RECVD	3	/* ååãªã¼ãã³ãSYN åä¿¡æ¸ã¿		*/
+#define TCP_FSM_ESTABLISHED	4	/* ã³ãã¯ã·ã§ã³éè¨­å®äº			*/
+#define TCP_FSM_CLOSE_WAIT	5	/* ç¸æãã FIN åä¿¡ãAPP ã®çµäºå¾
+ã¡	*/
+#define TCP_FSM_FIN_WAIT_1	6	/* APP ãçµäºãFIN éä¿¡æ¸ã¿ãACK å¾
+ã¡	*/
+#define TCP_FSM_CLOSING		7	/* åæã¯ã­ã¼ãºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡	*/
+#define TCP_FSM_LAST_ACK	8	/* APP ãçµäºãACK å¾
+ã¡			*/
+#define TCP_FSM_FIN_WAIT_2	9	/* ç¸æããã® FIN å¾
+ã¡			*/
+#define TCP_FSM_TIME_WAIT	10	/* ç¸æããã® FIN åä¿¡æ¸ã¿ãæéå¾
+ã¡	*/
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define TCP_FSM_HAVE_RCVD_SYN(s)	((s) >= TCP_FSM_SYN_RECVD)
+#define TCP_FSM_HAVE_ESTABLISHED(s)	((s) >= TCP_FSM_ESTABLISHED)
+#define TCP_FSM_HAVE_RCVD_FIN(s)	((s) >= TCP_FSM_TIME_WAIT)
+
+#define TCP_FSM_CAN_SEND_MORE(s)	((s) == TCP_FSM_ESTABLISHED || \
+					 (s) == TCP_FSM_CLOSE_WAIT)
+#define TCP_FSM_CAN_RECV_MORE(s)	((s) == TCP_FSM_ESTABLISHED || \
+					 (s) == TCP_FSM_FIN_WAIT_1  || \
+					 (s) == TCP_FSM_FIN_WAIT_2)
+
+#endif	/* of #ifndef _TCP_FSM_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_input.c	(revision 317)
@@ -0,0 +1,1888 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1994, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_input.c	8.12 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_input.c,v 1.82.2.3 1999/10/14 11:49:38 des Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  æ»ãå¤
+ *
+ *      RET_OK		æ­£å¸¸
+ *	RET_DROP	ã¨ã©ã¼ãã»ã°ã¡ã³ããç ´æ£ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ */
+
+#define RET_OK		(0)
+#define RET_NEED_OUTPUT	(1)
+#define RET_RETURN	(2)
+#define RET_DROP	(-1)
+#define RET_RST_DROP	(-2)
+
+/*
+ *  é¢æ°
+ */
+
+static void close_connection	(T_TCP_CEP *cep, bool_t *needoutput);
+static void set_rexmt_timer	(T_TCP_CEP *cep,  T_TCP_TIME rtt);
+static uint8_t reassemble	(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
+static ER drop_after_ack	(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff);
+static ER listening		(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss);
+static ER proc_ack1		(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, bool_t *needoutput);
+static ER proc_ack2		(T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, bool_t *needoutput);
+static ER syn_sent		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+static void trim_length		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+static void parse_option	(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+static bool_t update_wnd	(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+static void proc_urg		(T_TCP_HDR *tcph,  T_TCP_CEP *cep);
+
+/*
+ *  parse_option -- TCP ãããã®ãªãã·ã§ã³ãè§£æããã
+ */
+
+static void
+parse_option (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+	uint8_t	*opt, type = 0;
+	uint_t	len, ol, ssize;
+
+	opt = (uint8_t*)tcph + TCP_HDR_SIZE;
+	len = (uint_t)(TCP_HDR_LEN(tcph->doff) - TCP_HDR_SIZE);
+	while (len > 0 && (type = *opt) != TCP_OPT_EOL) {
+		if (type == TCP_OPT_NOP)
+			ol = 1u;
+		else {
+			if (len < 2)
+				break;
+			ol = *(opt + 1);
+			if (ol < 2 || ol > len)
+				break;
+			}
+		switch (type) {
+		case TCP_OPT_NOP:
+			break;
+		case TCP_OPT_MAXSEG:
+			if ((ol == TCP_OPT_LEN_MAXSEG) && (tcph->flags & TCP_FLG_SYN)) {
+				ssize = ntohs(*(uint16_t*)(opt + 2));
+				if (ssize > MAX_TCP_SND_SEG)
+					cep->maxseg = MAX_TCP_SND_SEG;
+				else if (ssize < TCP_MINMSS)
+					cep->maxseg = TCP_MINMSS;
+				else
+					cep->maxseg = ssize;
+				}
+			break;
+
+		case TCP_OPT_WINDOW:
+		case TCP_OPT_SACK_PERM:
+		case TCP_OPT_TIMESTAMP:
+		case TCP_OPT_CC:
+		case TCP_OPT_CCNEW:
+		case TCP_OPT_CCECHO:
+			syslog(LOG_INFO, "[TCP] unsup opt: %d.", type);
+			break;
+
+		default:
+			syslog(LOG_NOTICE, "[TCP] unexp opt: %d.", type);
+			break;
+			}
+		opt += ol;
+		len -= ol;
+		}
+	}
+
+/*
+ *  set_rexmt_timer -- æ°ããå¾å¾©æéãåéããåéã¿ã¤ããæ´æ°ããã
+ */
+
+static void
+set_rexmt_timer (T_TCP_CEP *cep, T_TCP_TIME rtt)
+{
+	T_TCP_TIME delta;
+
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_RTT_UPDATES], 1);
+	if (cep->srtt != 0) {
+		/*
+		 *  srtt: å¹³æ»åããã RTT
+		 *
+		 *  è¨æ¸¬ããã RTT (rtt) ã¨ç¾å¨ã®å¹³æ»åããã RTT (srtt) ã®å·® (delta) ãæ±ããã
+		 *
+		 *  delta ã¯ 2 ãããå·¦ã·ãã ( 4 å) ããå¤ã§ä¿æããã
+		 *  srtt  ã¯ 5 ãããå·¦ã·ãã (32 å) ããå¤ã§ä¿æããã¦ããã
+		 *
+		 *    delta = rtt / 8 - srtt / 8
+		 *
+		 *  æ°ãã srtt ã¯
+		 *
+		 *    srtt = rtt / 8 + srtt * 7 / 8
+		 *         = srtt + (rtt / 8 - srtt / 8)
+		 *
+		 *  ã§è¨ç®ããã
+		 *  ãã®ãããrtt ã 2 ãããå·¦ã·ããããsrtt ã (5 - 2) ãããå³ã·ãããã¦ delta ãæ±ããã
+		 */
+		delta = ((rtt - 1) << TCP_DELTA_SHIFT) - (cep->srtt >> (TCP_SRTT_SHIFT - TCP_DELTA_SHIFT));
+		cep->srtt += delta;
+		if (cep->srtt <= 0)
+			cep->srtt = 1;
+
+		/*
+		 *  delta ã®çµ¶å¯¾å¤ | delta | ãæ±ããã
+		 */
+		if (delta < 0)
+			delta = - delta;
+
+		/*
+		 *  rttvar: å¹³æ»åãããåæ£
+		 *
+		 *  rttvar ã¯ 4 ãããå·¦ã·ãã (16 å) ããå¤ã§ä¿æããã¦ããã
+		 *
+		 *    delta = |delta| / 4 - rttvar / 4
+		 *
+		 *  æ°ãã rttvar ã¯
+		 *
+		 *    rttvar = |delta|/ 4 + rttvar * 3 /4
+		 *           = rttvar + (|delta| / 4 - rttvar / 4)
+		 *
+		 *  ã§è¨ç®ããã
+		 */
+		delta -= cep->rttvar >> (TCP_RTTVAR_SHIFT - TCP_DELTA_SHIFT);
+		cep->rttvar += delta;
+		if (cep->rttvar <= 0)
+			cep->rttvar = 1;
+		}
+	else {
+		/*
+		 *  ã¾ã  srtt ã®è¨­å®ãè¡ããã¦ããªãã¨ãã¯ãä»åè¨æ¸¬ããã RTT ãä½¿ç¨ããã
+		 *  å¹³æ»åããã RTT (srtt) ã«ã¯ãRTT ã 5 ãããå·¦ã·ãã (32å) ããå¤ã
+		 *  å¹³æ»åãããåæ£ (rttvar) ã«ã¯ãRTT ã® 1/2 ã 4 ãããå·¦ã·ãã (16å) ããå¤ã
+		 */
+		cep->srtt   = rtt <<  TCP_SRTT_SHIFT;
+		cep->rttvar = rtt << (TCP_RTTVAR_SHIFT - 1);
+		}
+
+	/*
+	 *  rtt ã®æ¸¬å®ãçµäºããåéåæ°ããªã»ããããã
+	 */
+	cep->rtt = cep->rxtshift = 0;
+
+	/*
+	 *  RTT ã«è¨±ãããæå°å¤ ã¨ rtt + 2 ã®å¤§ããªå¤ã®æ¹ãåéã¿ã¤ã ã¢ã¦ãã®æå°å¤ã«ããã
+	 */
+	if (rtt + 2 < TCP_TVAL_MIN)
+		cep->rxtcur = tcp_range_set(tcp_rexmt_val(cep),
+		                            (T_TCP_TIME)TCP_TVAL_MIN,
+		                            (T_TCP_TIME)TCP_TVAL_MAX_REXMT);
+	else
+		cep->rxtcur = tcp_range_set(tcp_rexmt_val(cep),
+		                            (T_TCP_TIME)(rtt + 2),
+		                            (T_TCP_TIME)TCP_TVAL_MAX_REXMT);
+	}
+
+/*
+ *  reassemble -- åä¿¡ã»ã°ã¡ã³ããåæ§æãããé çªéãã«åä¿¡ããã¨ãã®å¦ç
+ */
+
+static uint8_t
+reassemble (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags)
+{
+	T_TCP_Q_HDR 	*qhdr;
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, thoff);
+	if (tcph->sum > cep->rbufsz - cep->rwbuf_count) {
+		/*
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã«ç©ºãããªãã¨ãã¯ç ´æ£ããã
+		 */
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DROP_SEGS], 1);
+		syscall(rel_net_buf(input));
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+		flags &= ~TCP_FLG_FIN;
+		}
+	else if (tcph->seq == cep->rcv_nxt &&
+	         cep->reassq == NULL &&
+	         cep->fsm_state == TCP_FSM_ESTABLISHED) {
+		/*
+		 *  é çªéãã«ã»ã°ã¡ã³ããåä¿¡ããæã®å¦ç
+		 *  åä¿¡ã»ã°ã¡ã³ãã®ä¸¦ã¹æ¿ãã¯ä¸è¦ãªã®ã§
+		 *  ãã®ã¾ã¾åä¿¡ã¦ã£ã³ããããã¡ã«æ¸ãè¾¼ãã
+		 */
+
+#ifdef TCP_CFG_DELAY_ACK
+
+		cep->flags |= TCP_CEP_FLG_DEL_ACK;
+
+#else/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+
+#endif/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		qhdr = GET_TCP_Q_HDR(input, thoff);
+
+		/*  TCP ãããã®ä½ç½®ãä¿å­ããã*/
+		SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
+
+		/* SDU ã®ãªãã»ããï¼å
+ã¯ã¦ã£ã³ããµã¤ãºï¼ããªã»ããããã*/
+		qhdr->soff = 0;
+
+		/* ãã¼ã¿ãåä¿¡ã¦ã£ã³ããããã¡ã«æ¸ãè¾¼ãã*/
+		TCP_WRITE_RWBUF(cep, input, thoff);
+		}
+	else {
+		flags = tcp_write_raque(input, cep, thoff, flags);
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+		}
+	return flags;
+	}
+
+/*
+ *  listening -- ååãªã¼ãã³ãã¦ï¼ç¶æ
+ã LISTEN ã®å¦ç
+ *
+ *    æ»ãå¤:
+ *      RET_OK		æ­£å¸¸
+ *	RET_DROP	ã¨ã©ã¼ãã»ã°ã¡ã³ããç ´æ£ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ */
+
+static ER
+listening (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, T_TCP_SEQ iss)
+{
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, thoff);
+
+	/* 
+	 *  ãã©ã°ã« RST ãã»ããããã¦ããã°ç ´æ£ããã
+	 */
+	if (tcph->flags & TCP_FLG_RST)
+		return RET_DROP;
+
+	/*  
+	 *  ãã©ã°ã« ACK ãã»ãããã¦ãããã°ã
+	 *  ãªã»ãããéã£ã¦ç ´æ£ããã
+	 */
+	if (tcph->flags & TCP_FLG_ACK)
+		return RET_RST_DROP;
+
+	/* 
+	 *  ãã©ã°ã« SYN ãã»ããããã¦ããªããã°ãã°ç ´æ£ããã
+	 */
+	if ((tcph->flags & TCP_FLG_SYN) == 0)
+		return RET_DROP;
+
+	/*
+	 *  åä¿¡å¯è½ãª IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ã§ãããã¨ãç¢ºèªããã
+	 */
+	if (!tcp_is_addr_accept(input, thoff))
+		return RET_DROP;
+
+	/* ç¸æã®ã¢ãã¬ã¹ãè¨é²ããã*/
+	IN_COPY_TO_HOST(&cep->dstaddr.ipaddr, input);
+	cep->dstaddr.portno = tcph->sport;
+
+	/* ãªãã·ã§ã³ãå¦çããã*/
+	parse_option(tcph, cep);
+
+	/* ã·ã¼ã±ã³ã¹çªå·ãåæåããã*/
+	if (tcp_iss == 0)
+		tcp_init_iss();
+
+	/* èªåã®ã·ã¼ã±ã³ã¹çªå·ã®åæå¤ãè¨é²ããã*/
+	if (iss != 0)
+		cep->iss = iss;
+	else
+		cep->iss = tcp_iss;
+
+	tcp_iss += TCP_ISS_INCR() / 4;
+
+	/* ç¸æã®ã·ã¼ã±ã³ã¹çªå·ã®åæå¤ãè¨é²ããã*/
+	cep->irs = tcph->seq;
+
+	/* éåä¿¡ã·ã¼ã±ã³ã¹çªå·ãåæåããã*/
+	init_send_seq(cep);
+	init_receive_seq(cep);
+
+	/* éä¿¡ã¦ã¤ã³ããµã¤ãºãè¨­å®ããã*/
+	cep->snd_wnd = tcph->win;
+
+	/* æçµè¨­å® */
+	cep->flags    |= TCP_CEP_FLG_ACK_NOW;
+	cep->fsm_state = TCP_FSM_SYN_RECVD;
+	cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INIT;
+
+	return RET_OK;
+	}
+
+/*
+ *  syn_sent -- è½åãªã¼ãã³ãã¦ãç¶æ
+ã SYN éä¿¡æ¸ã®å¦ç
+ *
+ *    æ»ãå¤:
+ *      RET_OK		æ­£å¸¸
+ *	RET_DROP	ã¨ã©ã¼ãã»ã°ã¡ã³ããç ´æ£ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ */
+
+static ER
+syn_sent (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+	ER error = RET_OK;
+
+	/*
+	 *  ç¸æããåä¿¡ç¢ºèªãéããã¦æ¥ã¦ãã
+	 *
+	 *    ACK <= iss && éä¿¡ããæå¤§ SEQ (snd_max) < ACK
+	 *
+	 *  ãªãããªã»ãããéã£ã¦ã»ã°ã¡ã³ããç ´æ£ããã
+	 */
+	if ((tcph->flags & TCP_FLG_ACK) &&
+	    (SEQ_LE(tcph->ack, cep->iss) || SEQ_GT(tcph->ack, cep->snd_max)))
+		return RET_RST_DROP;
+
+	/*
+	 *  RST/ACK ãã©ã°ã®å¿ç­ãããã°ããã¼ããéãã¦ããªã
+	 *  ãã¨ãæå³ãã¦ããã
+	 */
+	if (tcph->flags & TCP_FLG_RST) {
+		if (tcph->flags & TCP_FLG_ACK) {
+			cep->net_error = EV_CNNRF;
+			cep = tcp_drop(cep, E_CLS);
+			}
+		return RET_DROP;
+		}
+
+	/*
+	 *  SYN ãã©ã°ããªããã°ã»ã°ã¡ã³ããç ´æ£ããã
+	 */
+	if ((tcph->flags & TCP_FLG_SYN) == 0)
+		return RET_DROP;
+
+	cep->snd_wnd = tcph->win;	/* snd_wnd: ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº	*/
+	cep->irs     = tcph->seq;	/* irs:     ç¸æã®ã·ã¼ã±ã³ã¹çªå·ã®åæå¤	*/
+	init_receive_seq(cep);		/* éåä¿¡ã·ã¼ã±ã³ã¹çªå·ãåæåããã		*/
+
+	if (tcph->flags & TCP_FLG_ACK) {
+		/*
+		 *  ACK ãã©ã°ãããã¨ãã®å¦ç
+		 *
+		 *  åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ (rcv_adv) ã
+		 *  åä¿¡å¯è½ãªã¦ã£ã³ããµã¤ãº (rcv_wnd) åé²ããã
+		 */
+		cep->rcv_adv += cep->rcv_wnd;	/* rcv_adv: åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ	*/
+						/* rcv_wnd: åä¿¡å¯è½ãªã¦ã£ã³ããµã¤ãº		*/
+
+		/* æªç¢ºèªã®æå°éä¿¡ SEQ (snd_una) ã SYN å (1 ãªã¯ããã) é²ããã*/
+		cep->snd_una ++;
+
+#ifdef TCP_CFG_DELAY_ACK
+
+		if (tcph->sum != 0)		/* tcph->sum ã¯ SDU é· */
+			cep->flags |= TCP_CEP_FLG_DEL_ACK;
+		else
+			cep->flags |= TCP_CEP_FLG_ACK_NOW;
+
+#else/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+
+#endif/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		if (cep->flags & TCP_CEP_FLG_NEED_FIN) {
+			/*
+			 *  CEP ã§ FIN éä¿¡ãè¦æ±ããã¦ããã°ã
+			 *  åæ­å¦çãéå§ãã
+			 *  CEP ã®ç¶æ
+ã FIN Wait 1 ã«ããã
+			 */
+			cep->fsm_state = TCP_FSM_FIN_WAIT_1;
+			cep->flags  &= ~TCP_CEP_FLG_NEED_FIN;
+			tcph->flags &= ~TCP_FLG_SYN;
+			}
+		else {
+			/*
+			 *  ç¸æãã ACK ãå¿ç­ãããã®ã§ã
+			 *  CEP ã®ç¶æ
+ã ã³ãã¯ã·ã§ã³éè¨­å®äºç¶æ
+ã«ããã
+			 */
+			cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_IDLE;
+			cep->fsm_state  = TCP_FSM_ESTABLISHED;
+			NET_COUNT_MIB(tcp_stats.tcpActiveOpens, 1);
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_ESTABLISHED));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			if (cep->snd_nblk_tfn == TFN_TCP_CON_CEP) {
+
+				/* ç¸æã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+				*cep->p_dstaddr = cep->dstaddr;
+
+				if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, E_OK);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					ER	error = E_OK;
+
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					}
+				else {
+					syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+					error = RET_RST_DROP;
+					}
+				cep->p_dstaddr = NULL;
+				cep->snd_tskid = TA_NULL;
+				cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+				}
+			else
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+				NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+			}
+		}
+	else {
+		/* ACK ãã©ã°ããªãã¨ãã¯ãACK ãéã£ã¦ãCEP ã®ç¶æ
+ã SYN åä¿¡æ¸ã¿ã«ããã*/
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+		cep->timer[TCP_TIM_REXMT] = 0;
+		cep->fsm_state  = TCP_FSM_SYN_RECVD;
+		}
+
+	return error;
+	}
+
+/*
+ *  trim_length -- åä¿¡ãã SDU é·ãèª¿æ´ããã
+ */
+
+static void
+trim_length (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+	tcph->seq ++;
+	if (tcph->sum > cep->rcv_wnd) {		/* æ³¨æ: tcph->sum ã¯ SDU é· */
+		/*
+		 *  SDU é·ãåä¿¡ã¦ã£ã³ããµã¤ãºããå¤§ããã¨ãã¯ãåä¿¡ã¦ã£ã³ããµã¤ãºä»¥éã¯
+		 *  ç ´æ£ããFIN ã«å¿ç­ããªããã¨ã§ãç ´æ£ãããã¼ã¿ãåéãããã
+		 */
+		tcph->sum    = (uint16_t)cep->rcv_wnd;
+		tcph->flags &= ~TCP_FLG_FIN;
+		}
+	cep->snd_wl1 = tcph->seq - 1;		/* cep->snd_wl1: ã¦ã£ã³ãæ´æ° SEQ çªå·	*/
+
+#ifdef TCP_CFG_EXTENTIONS
+	cep->rcv_up  = tcph->seq;		/* cep->rcv_up : åä¿¡ããç·æ¥ãã¤ã³ã¿	*/
+#endif
+	}
+
+/*
+ *  proc_ack2 -- ACK ã®å¦ç (2)
+ *
+ *    æ»ãå¤
+ *
+ *      RET_OK		æ­£å¸¸
+ *      RET_RETURN	æ­£å¸¸ããªã¿ã¼ã³ããã
+ *	RET_DROP	ã¨ã©ã¼ãã»ã°ã¡ã³ããç ´æ£ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ */
+
+static ER
+proc_ack2 (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, bool_t *needoutput)
+{
+	T_TCP_HDR	*tcph;
+	ER		ret = RET_OK;
+	uint32_t	acked;
+	bool_t		ourfinisacked = false;
+
+	tcph = GET_TCP_HDR(input, thoff);
+
+	/*
+	 *  ç¸æã«åä¿¡ç¢ºèªããã ACK ãããã¾ã ç¢ºèªããã¦ããªã
+	 *  æå°éä¿¡ SEQ (snd_una) ãå¼ãã¨ãéä¿¡ã¦ã£ã³ããããã¡ãã
+	 *  åé¤ãã¦ãããªã¯ãããæ° (acked) ã«ãªãã
+	 */
+	acked = tcph->ack - cep->snd_una;
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_ACKS], 1);
+
+	/*
+	 *  å¾å¾©æéè¨æ¸¬ (rtt) ãè¨­å®ããã¦ãã¦ãè¨æ¸¬éå§ SEQ ãã
+	 *  å¾ã® ACK ãåä¿¡ããããã¿ã¤ãããã¯ãªããã­ã£ã³ã»ã«ãã
+	 *  åéã¿ã¤ããåè¨­å®ããã
+	 */
+	if (cep->rtt && SEQ_GT(tcph->ack, cep->rtseq)) {
+		set_rexmt_timer(cep, cep->rtt);
+		}
+
+	/*
+	 *  å
+¨ã¦ã®æªç¢ºèªãã¼ã¿ã ACK ãããããåéã¿ã¤ããåæ­¢ãã
+	 *  åéãè¨æ¶ãã (ããã«åºåãæç¶)ã
+	 *  ãããACK ãã¹ããããã«å¤ãã®ãã¼ã¿ããããªããåéã¿ã¤ãã«
+	 *  ç¾å¨ã®åéã¿ã¤ã ã¢ã¦ããè¨­å®ããã
+	 */
+	if (tcph->ack == cep->snd_max) {	/* cep->snd_max: éä¿¡ããæå¤§ SEQ */
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+		/*
+		 * éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã®å ´åã¯ã
+		 * éä¿¡æ¸ã¿ã§ãACKãå®äºããã¾ã§åéã¿ã¤ããå¤æ´ããªãã
+		 */
+		if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_ACKED)
+			cep->timer[TCP_TIM_REXMT] = 0;
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		cep->timer[TCP_TIM_REXMT] = 0;
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		*needoutput = true;
+		}
+	else if (cep->timer[TCP_TIM_PERSIST] == 0) {
+	 	cep->timer[TCP_TIM_REXMT] = cep->rxtcur;	/* cep->rxtcur: ç¾å¨ã®åéã¿ã¤ã ã¢ã¦ã */
+		}
+
+	/* ç¸æãåä¿¡ç¢ºèªãããã¼ã¿ãããã¨ãã®å¦ç */
+	if (acked) {
+		uint32_t cw   = cep->snd_cwnd;	/* cep->snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº	*/
+		uint32_t incr = cep->maxseg;		/* cep->maxseg:   æå¤§ã»ã°ã¡ã³ããµã¤ãº	*/
+
+		/*
+		 *  æ°ãã«ç¸æãåä¿¡ç¢ºèªãããã¼ã¿ããã£ãã¨ãã¯ã
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãºãå¤§ããããã
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãº (snd_cwnd) ã
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãºã®ãããå¤ (snd_ssthresh) ããå¤§ããã¨ãã¯
+		 *  è¼»è¼³åé¿å¶å¾¡ãè¡ãã
+		 *
+		 *    snd_cwnd = snd_cwnd + maxseg * maxseg / snd_cwnd;
+		 *
+		 *  ç­ãããå°ããã¨ãã¯ãã¹ã­ã¼ã¹ã¿ã¼ãå¶å¾¡ãè¡ãã
+		 *
+		 *    snd_cwnd = snd_cwnd + maxseg
+		 *
+		 */
+		if (cw > cep->snd_ssthresh)
+			/* è¼»è¼³åé¿å¶å¾¡ */
+			incr = incr * incr / cw;
+
+		if (cw + incr < MAX_TCP_WIN_SIZE)
+			cep->snd_cwnd = (uint16_t)(cw + incr);
+		else
+			cep->snd_cwnd = MAX_TCP_WIN_SIZE;
+
+		/*
+		 *  éä¿¡ã¦ã£ã³ããããã¡ãããç¸æãåä¿¡ç¢ºèªãããã¼ã¿æ° (acked) ã®ãã¼ã¿ãåé¤ããã
+		 */
+		if (acked > cep->swbuf_count) {
+			cep->snd_wnd -= cep->swbuf_count;
+			TCP_DROP_SWBUF(cep, (uint_t)cep->swbuf_count);
+			ourfinisacked = true;
+			}
+		else {
+			cep->snd_wnd -= (uint16_t)acked;
+			TCP_DROP_SWBUF(cep, (uint_t)acked);
+			ourfinisacked = false;
+			}
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããã§ãããã¨ãç¥ãããã*/
+		syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+
+		/*
+		 *  ééç¢ºèªããã¦ããªãæå°éä¿¡ SEQ (snd_una) ã
+		 *  ä»åééç¢ºèªããã ACK ã¾ã§é²ãã
+		 *  æ¬¡ã®éä¿¡ãã¼ã¿ã® SEQ (snd_nxt) ããæ°ãã
+		 *  ééç¢ºèªããã¦ããªãæå°éä¿¡ SEQ (snd_una)
+		 *  ã¾ã§é²ããã
+		 */
+		cep->snd_una += acked;
+		if (SEQ_LT(cep->snd_nxt, cep->snd_una))
+			cep->snd_nxt = cep->snd_una;
+
+		/*
+		 *  ç¶æ
+ã«ããåå²
+		 */
+		switch (cep->fsm_state) {
+		case TCP_FSM_FIN_WAIT_1:	/* APP ãçµäºãFIN éä¿¡æ¸ã¿ãACK å¾
+ã¡ */
+			if (ourfinisacked) {
+				cep->fsm_state = TCP_FSM_FIN_WAIT_2;
+				cep->timer[TCP_TIM_2MSL] = TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL;
+				}
+			break;
+		case TCP_FSM_CLOSING:		/* åæã¯ã­ã¼ãºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡ */
+			if (ourfinisacked) {
+				/*
+				 *  éä¿¡ãã FIN ãç¢ºèªããã¦ããã°ç¶æ
+ãå¤æ´ãã
+				 *  ãã¹ã¦ã®ã¿ã¤ãããªã»ããããå¾ã2MSL ã¿ã¤ããè¨­å®ããã
+				 */
+				cep->fsm_state = TCP_FSM_TIME_WAIT;
+				tcp_cancel_timers(cep);
+				cep->timer[TCP_TIM_2MSL] = 2 * TCP_TVAL_MSL;
+				}
+			break;
+		case TCP_FSM_LAST_ACK:		/* APP ãçµäºãACK å¾
+ã¡ */
+			if (ourfinisacked) {
+				/*
+				 *  éä¿¡ãã FIN ãç¢ºèªããã¦ããã°ãcep ãã¯ã­ã¼ãºãã
+				 *  ã»ã°ã¡ã³ããç ´æ£ããã
+				 */
+				cep = tcp_close(cep);
+				ret = RET_DROP;
+				}
+			break;
+		case TCP_FSM_TIME_WAIT:		/* ç¸æããã® FIN åä¿¡æ¸ã¿ãæéå¾
+ã¡ */
+			/*
+			 *  ç¸æãã FIN ãåéããããããä¸åº¦2MSL ã¿ã¤ããè¨­å®ãã
+			 *  ACK éä¿¡å¾ãã»ã°ã¡ã³ããç ´æ£ããã
+			 */
+			cep->timer[TCP_TIM_2MSL] = 2 * TCP_TVAL_MSL;
+			return drop_after_ack(input, cep, thoff);
+			}
+		}
+
+	return ret;
+	}
+
+/*
+ *  proc_ack1 -- ACK ã®å¦ç (1)
+ *
+ *    æ»ãå¤:
+ *      RET_OK		æ­£å¸¸
+ *      RET_RETURN	æ­£å¸¸ããªã¿ã¼ã³ããã
+ *	RET_DROP	ã¨ã©ã¼ãã»ã°ã¡ã³ããç ´æ£ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ *
+ */
+
+static ER
+proc_ack1 (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, bool_t *needoutput)
+{
+	T_TCP_HDR *tcph = GET_TCP_HDR(input, thoff);
+
+	switch (cep->fsm_state) {
+	case TCP_FSM_SYN_RECVD:		/* SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿	*/
+
+		/* ç¶æ
+ãå¤æ´ããã*/
+		if (cep->flags & TCP_CEP_FLG_NEED_FIN) {
+			cep->fsm_state  = TCP_FSM_FIN_WAIT_1;
+			cep->flags &= ~TCP_CEP_FLG_NEED_FIN;
+			}
+		else {
+			cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_IDLE;
+			cep->fsm_state  = TCP_FSM_ESTABLISHED;
+
+			/* TCP éä¿¡ç«¯ç¹ããTCP åä»å£ãè§£æ¾ããã*/
+			cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+			cep->rep4 = NULL;
+#endif
+
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_ESTABLISHED));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			if (cep->rcv_nblk_tfn == TFN_TCP_ACP_CEP) {
+
+				/* ç¸æã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+				if (cep->flags & TCP_CEP_FLG_IPV4) {
+					(*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+					(*cep->p_dstaddr4).portno = cep->dstaddr.portno;
+					}
+				else
+					*cep->p_dstaddr = cep->dstaddr;
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+				*cep->p_dstaddr = cep->dstaddr;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+				if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+					NET_COUNT_MIB(tcp_stats.tcpPassiveOpens, 1);
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_ACCEPTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, E_OK);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					ER	error = E_OK;
+
+					NET_COUNT_MIB(tcp_stats.tcpPassiveOpens, 1);
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_ACCEPTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					cep->p_dstaddr = NULL;
+					cep->rcv_tskid = TA_NULL;
+					cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+					}
+				else {
+					syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+					cep->p_dstaddr = NULL;
+					cep->rcv_tskid = TA_NULL;
+					cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+					return RET_RST_DROP;
+					}
+				}
+
+			if (cep->snd_nblk_tfn == TFN_TCP_CON_CEP) {
+
+				/* ç¸æã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+				*cep->p_dstaddr = cep->dstaddr;
+
+				if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+					NET_COUNT_MIB(tcp_stats.tcpActiveOpens, 1);
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, E_OK);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					ER	error = E_OK;
+
+					NET_COUNT_MIB(tcp_stats.tcpActiveOpens, 1);
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					cep->p_dstaddr = NULL;
+					cep->snd_tskid = TA_NULL;
+					cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+					}
+				else {
+					syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+					cep->p_dstaddr = NULL;
+					cep->snd_tskid = TA_NULL;
+					cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+					return RET_RST_DROP;
+					}
+				}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			if (cep->rcv_tfn == TFN_TCP_ACP_CEP) {
+				NET_COUNT_MIB(tcp_stats.tcpPassiveOpens, 1);
+				NET_COUNT_TCP(net_count_tcp[NC_TCP_ACCEPTS], 1);
+				}
+
+			if (cep->snd_tfn == TFN_TCP_CON_CEP) {
+				NET_COUNT_MIB(tcp_stats.tcpActiveOpens, 1);
+				NET_COUNT_TCP(net_count_tcp[NC_TCP_CONNECTS], 1);
+				}
+			}
+
+		/*
+		 *  SDU ããªã FIN ãã¤ãã¦ããªããã°ãtcp_move_ra2rw() ãå¼åºãã
+		 */
+		if (tcph->sum == 0 && (tcph->flags & TCP_FLG_FIN) == 0)		/* tcph->sum ã¯ SDU é· */
+			tcph->flags = tcp_move_ra2rw(cep, tcph->flags);
+		
+		cep->snd_wl1 = tcph->seq - 1;	/* snd_wl1: ã¦ã£ã³ãæ´æ° SEQ */
+
+		/* break; ä¸ã«è½ã¡ãã*/
+	
+	case TCP_FSM_ESTABLISHED:	/* ã³ãã¯ã·ã§ã³éè¨­å®äº		*/
+	case TCP_FSM_FIN_WAIT_1:	/* çµäºãã¦ãFIN éä¿¡æ¸ã¿		*/
+	case TCP_FSM_FIN_WAIT_2:	/* çµäºãFIN ä¼éç¢ºèªåä¿¡ãFINå¾
+ã¡*/
+	case TCP_FSM_CLOSE_WAIT:	/* FIN åä¿¡ãã¯ã­ã¼ãºå¾
+ã¡		*/
+	case TCP_FSM_CLOSING:		/* çµäºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡	*/
+	case TCP_FSM_LAST_ACK:		/* FIN åä¿¡ãçµäºãACK å¾
+ã¡	*/
+	case TCP_FSM_TIME_WAIT:		/* çµäºãæéå¾
+ã¡		*/
+
+		if (SEQ_LE(tcph->ack, cep->snd_una)) {
+
+			/*
+			 *  åä¿¡ç¢ºèª ACK ã æªç¢ºèªã®æå°éä¿¡ SEQ (snd_una) ã¨åããä»¥åã®ã¨ãã®å¦ç
+			 *  ã¤ã¾ããå¤éã« ACK ãåä¿¡ãããã¨ãæå³ãã¦ããã
+			 */
+
+			if (tcph->sum == 0 && tcph->win == cep->snd_wnd) {	/* tcph->sum ã¯ SDU é· */
+
+				/*
+				 *  SDU ããªããç¸æã®ã¦ã£ã³ããµã¤ãºãå¤æ´ããã¦ããªããã°ã
+				 *  ãã§ã«éä¿¡ããã»ã°ã¡ã³ãã®ä¸­ã§ãACK (tcph->ack) ã¨
+				 *  åã SEQ ããå§ã¾ãã»ã°ã¡ã³ãããéä¸­ã§æ¶å¤±ããå¯è½æ§ãããã
+				 *  ãã®å ´åã¯ãé«éåè»¢éã¨é«éãªã«ããªãè¡ãã
+				 */
+				NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DUP_ACKS], 1);
+
+				if (cep->timer[TCP_TIM_REXMT] == 0 || tcph->ack != cep->snd_una) {
+
+					/*
+					 *  åéã¿ã¤ããã»ããããã¦ããªãã¨ãã
+					 *  ã¾ãã¯ãACK (tcph->ack) ã¨æªç¢ºèªã®æå°éä¿¡ SEQã
+					 *  ä¸è´ããªãã¨ãã¯ãå¤é ACK æ°ã 0 ã«ããã
+					 */
+					cep->dupacks = 0;
+					}
+
+				else if (++ cep->dupacks == MAX_TCP_REXMT_THRESH) {
+
+					/*
+					 *  å¤é ACK æ°ããããå¤ (æ¨æº 3) ã«ãªã£ãã
+					 *  é«éåè»¢éå¦çãéå§ããã
+					 */
+					uint_t		win;
+
+					/*
+					 *  è¼»è¼³ã¦ã£ã³ããµã¤ãº(snd_cwnd)ã®ãããå¤ãè¨­å®ããã
+					 *
+					 *    ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº (snd_wnd) ã
+					 *    è¼»è¼³ã¦ã£ã³ããµã¤ãº (snd_cwnd) ã® 1/2ã
+					 *    ãã ãã2 * maxseg ä»¥ä¸ã
+					 *
+					 */
+					if (cep->snd_wnd < cep->snd_cwnd)
+						win = cep->snd_wnd / 2 / cep->maxseg;
+					else
+						win = cep->snd_cwnd / 2 / cep->maxseg;
+					if (win < 2)
+						win = 2;
+					cep->snd_ssthresh = win * cep->maxseg;
+
+					/* åéã¿ã¤ãã¨å¾å¾©æéããªã»ããããã*/
+					cep->timer[TCP_TIM_REXMT] = 0;
+					cep->rtt = 0;
+
+					/* æ¶å¤±ããã»ã°ã¡ã³ããéä¿¡ããã*/
+					cep->snd_old_nxt = cep->snd_nxt;
+					cep->snd_nxt     = tcph->ack;
+					cep->snd_cwnd    = cep->maxseg;
+
+					/*
+					 *  snd_nxt ãå
+ã«æ»ãããã«è¨­å®ãã¦
+					 *  éä¿¡ãæç¤ºããã
+					 */
+					cep->flags |=  TCP_CEP_FLG_POST_OUTPUT |
+					               TCP_CEP_FLG_FORCE       |
+					               TCP_CEP_FLG_FORCE_CLEAR |
+					               TCP_CEP_FLG_RESTORE_NEXT_OUTPUT;
+					sig_sem(SEM_TCP_POST_OUTPUT);
+
+					/* è¼»è¼³ã¦ã£ã³ããµã¤ãºãæ´æ°ããã*/
+					cep->snd_cwnd = (uint16_t)(cep->snd_ssthresh
+					                   + cep->maxseg * cep->dupacks);
+					
+					return RET_DROP;
+					}
+
+				else if (cep->dupacks > MAX_TCP_REXMT_THRESH) {
+
+					/*
+					 *  å¤é ACK æ°ããããå¤ (æ¨æº 3) ãè¶
+ããã
+					 *  è¼»è¼³ã¦ã£ã³ããµã¤ãºãå¢å ããªããåéããã
+					 */
+					cep->snd_cwnd += cep->maxseg;
+
+					/* éä¿¡ãæç¤ºããã*/
+					cep->flags |=  TCP_CEP_FLG_POST_OUTPUT;
+					sig_sem(SEM_TCP_POST_OUTPUT);
+
+					return RET_DROP;
+					}
+				} 
+			else
+				cep->dupacks = 0;
+			break;
+			}
+
+		/*
+		 *  åä¿¡ç¢ºèª ACK ã æªç¢ºèªã®æå°éä¿¡ SEQ (snd_una) ä»¥éã®ã¨ãã®å¦ç
+		 */
+		if (cep->dupacks >= MAX_TCP_REXMT_THRESH && cep->snd_cwnd > cep->snd_ssthresh)
+		 	/*
+			 *  é«éåè»¢éãè¡ã£ã¦ããã¨ãã¯ãè¼»è¼³ã¦ã£ã³ããµã¤ãºããããå¤ã¾ã§æ»ãã
+			 */
+			cep->snd_cwnd = (uint16_t)cep->snd_ssthresh;
+	
+		cep->dupacks = 0;
+
+		if (SEQ_GT(tcph->ack, cep->snd_max))
+			/*
+			 *  åä¿¡ãã ACK ãéä¿¡ããæå¤§ SEQ ãè¶
+ãã¦ããã¨ãã®å¦ç
+			 */
+			return drop_after_ack(input, cep, thoff);
+
+		if (cep->flags & TCP_CEP_FLG_NEED_SYN) {
+			/*
+			 *  SYN éä¿¡è¦æ±ãåãæ¶ãã¦ãæªç¢ºèªã®æå°éä¿¡ SEQ ãé²ããã
+			 */
+			cep->flags &= ~TCP_CEP_FLG_NEED_SYN;
+			cep->snd_una ++;
+			}
+		
+		return proc_ack2(input, cep, thoff, needoutput);
+		break;
+		}
+	return RET_OK;
+	}
+
+/*
+ *  update_wnd -- ã¦ã£ã³ããµã¤ãºãæ´æ°ããã
+ *
+ *    æ»ãå¤: éä¿¡ãå¿
+è¦ãªã true ãè¿ãã
+ */
+
+static bool_t
+update_wnd (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+
+	/*
+	 *  æ´æ°æ¡ä»¶
+	 *
+	 *    ACK ãã©ã°ãã»ããããã¦ãã &&
+	 *    (ååã¦ã£ã³ããæ´æ°ãã SEQ (snd_wl1) ã SEQ ããå ||
+	 *     ååã¦ã£ã³ããæ´æ°ãã SEQ (snd_wl1) ã SEQ ã¨åã &&
+	 *     (ååã¦ã£ã³ããæ´æ°ãã ACK (snd_wl2) ã ACK ããå ||
+	 *      (ååã¦ã£ã³ããæ´æ°ãã ACK (snd_wl2) ã ACK ã¨åã &&
+	 *       WIN ãç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº (snd_wnd) ããå¤§ãã
+	 *       )
+	 *      )
+	 *     )
+	 */
+	if ((tcph->flags & TCP_FLG_ACK) &&
+	    (SEQ_LT(cep->snd_wl1, tcph->seq) ||
+	     (cep->snd_wl1 == tcph->seq &&
+	      (SEQ_LT(cep->snd_wl2, tcph->ack) ||
+	       (cep->snd_wl2 == tcph->ack && tcph->win > cep->snd_wnd))))) {
+
+		cep->snd_wnd = tcph->win;
+		cep->snd_wl1 = tcph->seq;
+		cep->snd_wl2 = tcph->ack;
+
+		if (cep->snd_wnd > cep->max_sndwnd)
+			/* ä»ã¾ã§ã®æå¤§éä¿¡ã¦ã£ã³ããµã¤ãºãæ´æ°ããã*/
+			cep->max_sndwnd = cep->snd_wnd;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+		if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_WOPEN_PEND) {
+
+			/*
+			 *  éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡å²ãå½ã¦ä¸­ã§ã
+			 *  ç¸æã®åä¿¡ã¦ã£ã³ããç©ºãã®ãå¾
+ã£ã¦ããã¨ãã®å¦ç
+			 */
+			if (cep->snd_wnd > 0) {
+
+				/*
+				 *  ç¸æã®åä¿¡ã¦ã£ã³ããç©ºããã¨ãã¯ã
+				 *  éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡å²ãå½ã¦ãåéããã
+				 */
+				cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK)
+				                         |  TCP_CEP_FLG_WBCS_FREE |  TCP_CEP_FLG_POST_OUTPUT;
+				sig_sem(SEM_TCP_POST_OUTPUT);
+				}
+			}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		return true;
+		}
+	else
+		return false;
+	}
+
+/*
+ *  proc_urg -- ç·æ¥ãã¼ã¿ã¤ãã®ã»ã°ã¡ã³ãã®å¦ç
+ */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+static void
+proc_urg (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+	if ((tcph->flags & TCP_FLG_URG) && VALID_URG_POINTER(tcph->urp) &&
+	    TCP_FSM_HAVE_RCVD_FIN(cep->fsm_state) == 0) {
+
+		/* ç·æ¥ãã¼ã¿ã¤ãã®ã»ã°ã¡ã³ãã®å¦ç */
+
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_URG_SEGS], 1);
+		if (tcph->urp + cep->rwbuf_count > cep->rbufsz) {
+
+			/*
+			 *  ç·æ¥ãã¤ã³ã¿ã®ä½ç½®ãåä¿¡ã¦ã£ã³ããããã¡ã®
+			 *  ç¯å²ãè¶
+ããã¨ãã¯ä½ãããªãã
+			 */
+			tcph->urp    = 0;
+			tcph->flags &= ~TCP_FLG_URG;
+			}
+
+		if (SEQ_GT(tcph->seq + tcph->urp, cep->rcv_up))
+			/* ç·æ¥ãã¤ã³ã¿ãæ´æ°ãããã¨ãã®å¦ç */
+			cep->rcv_up = tcph->seq + tcph->urp;
+
+		if ((tcph->flags & TCP_FLG_URG) && (tcph->urp + TCP_CFG_URG_OFFSET) < tcph->sum) {	/* tcph->sum ã¯ TCP ã® SDU é· */
+
+			/*
+			 *  ç·æ¥ãã¤ã³ã¿ã®ä½ç½®ããä»ååä¿¡ããã»ã°ã¡ã³ãå
+ã®å ´åã¯ã
+			 *  ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã
+			 */
+			cep->urg_tcph = tcph;
+			if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+				(*cep->callback)(GET_TCP_CEPID(cep), TEV_TCP_RCV_OOB, (void*)(uint32_t)1);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				uint32_t	len = 1;
+
+				(*cep->callback)(GET_TCP_CEPID(cep), TEV_TCP_RCV_OOB, (void*)&len);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				}
+			else {
+				syslog(LOG_WARNING, "[TCP] no call back for OOB, CEP: %d.", GET_TCP_CEPID(cep));
+				}
+
+			if (cep->urg_tcph != NULL) {
+				/* ã³ã¼ã«ããã¯é¢æ°å
+ã§ tcp_rcv_oob() ãå¼åºããªãã£ãã*/
+				cep->urg_tcph = NULL;
+				tcph->urp = 0;
+				}
+			else {
+				/* 
+				 *  ã³ã¼ã«ããã¯é¢æ°å
+ã§ tcp_rcv_oob() ãå¼åºããæã¯ã
+				 *  SDU é·ã®è£æ­£å¤ãè¨­å®ããã
+				 */
+				tcph->urp = 1;
+				}
+			}
+		else if (tcph->urp > 0) {
+			tcph->urp = 0;
+			}
+
+		}
+	else if (SEQ_GT(cep->rcv_nxt, cep->rcv_up)) {
+		cep->rcv_up = cep->rcv_nxt;
+		tcph->urp = 0;
+		}
+	}
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+static void
+proc_urg (T_TCP_HDR *tcph, T_TCP_CEP *cep)
+{
+	tcph->urp = 0;
+	}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+/*
+ *  drop_after_ack -- åä¿¡ã»ã°ã¡ã³ããç ´æ£ããå¾ãACK ãè¿ã (æ³¨æ: ååã¨ã¯åã£ã¦ããªã)ã
+ *
+ *    æ»ãå¤:
+ *      RET_RETURN	æ­£å¸¸ããªã¿ã¼ã³ããã
+ *	RET_RST_DROP	ã¨ã©ã¼ãRST ãéä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+ */
+
+static ER
+drop_after_ack (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff)
+{
+	T_TCP_HDR *tcph = GET_TCP_HDR(input, thoff);
+
+	/*
+	 *    SYN åä¿¡ç¶æ
+ã§ãACK ãééç¢ºèªããã¦ããªãæå°éä¿¡ SEQ (snd_una) ãã
+	 *    åã®å¤ããéä¿¡ãããæå¤§ SEQ (snd_max) ããå¾ã®å¤ã®å ´åã¯ãç¸æã« RST ã
+	 *    éã£ã¦çµäºãããããã¯ã"LAND" DoS æ»æã¸ã®é²å¾¡ã§ãããå½é ããã SYN
+	 *    ã»ã°ã¡ã³ããéä¿¡ãã¤ã¥ãããã¼ãéã§ã® ACK ã¹ãã¼ã ãé²ãã
+	 */
+	if (cep->fsm_state == TCP_FSM_SYN_RECVD && (tcph->flags & TCP_FLG_ACK) &&
+	    (SEQ_GT(cep->snd_una, tcph->ack) ||
+	     SEQ_GT(tcph->ack, cep->snd_max)))
+		return RET_RST_DROP;
+
+	syscall(rel_net_buf(input));
+
+	/* éä¿¡ãæç¤ºããã*/
+	cep->flags |=  TCP_CEP_FLG_ACK_NOW | TCP_CEP_FLG_POST_OUTPUT;
+	sig_sem(SEM_TCP_POST_OUTPUT);
+	return RET_RETURN;
+	}
+
+/*
+ *  close_connection -- ã³ãã¯ã·ã§ã³éæ¾å¦çãç¸æãã FIN ãåä¿¡ããã
+ */
+
+static void
+close_connection (T_TCP_CEP *cep, bool_t *needoutput)
+{
+	if (TCP_FSM_HAVE_RCVD_FIN(cep->fsm_state) == 0) {
+
+#ifdef TCP_CFG_DELAY_ACK
+
+		if (cep->flags & TCP_CEP_FLG_NEED_SYN)
+			cep->flags |= TCP_CEP_FLG_DEL_ACK;
+		else
+			cep->flags |= TCP_CEP_FLG_ACK_NOW;
+
+#else/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+
+#endif/* of #ifdef TCP_CFG_DELAY_ACK */
+
+		cep->rcv_nxt ++;
+		}
+
+	switch (cep->fsm_state) {
+	case TCP_FSM_SYN_RECVD:		/* SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿	*/
+	case TCP_FSM_ESTABLISHED:	/* ã³ãã¯ã·ã§ã³éè¨­å®äº		*/
+		cep->fsm_state = TCP_FSM_CLOSE_WAIT;
+		syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_RWBUF_READY));
+		break;
+
+	case TCP_FSM_FIN_WAIT_1:	/* APP ãçµäºãFIN éä¿¡æ¸ã¿ãACK å¾
+ã¡ */
+		cep->fsm_state = TCP_FSM_CLOSING;
+		break;
+
+	case TCP_FSM_FIN_WAIT_2:	/* ç¸æããã® FIN å¾
+ã¡ */
+		cep->fsm_state = TCP_FSM_TIME_WAIT;
+		tcp_cancel_timers(cep);
+		cep->timer[TCP_TIM_2MSL] = 2 * TCP_TVAL_MSL;
+
+		/*
+		 *  FIN WAIT 2 ç¶æ
+ã§ã¯ã
+		 *  åä¿¡ã¯å¯è½ã§ãããããã§ã«éä¿¡ã¯çµäºãã¦ããã
+		 *  ç¸æã®éä¿¡ãçµäºããã®ã§ãå
+¥åã¿ã¹ã¯ã®ã¿èµ·åºããã
+		 */
+		syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+		/* ç¸æããã® FIN ã«å¯¾ãã¦å¿ç­ãè¿ãã*/
+		tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una,
+		            cep->rbufsz - cep->rwbuf_count, TCP_FLG_ACK);
+		cep->flags &= ~TCP_CEP_FLG_ACK_NOW;
+		*needoutput = false;
+
+		/*
+		 *  å¿
+è¦ãªæ
+å ±ã Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã«ç§»ãã¦ã
+		 *  æ¨æºã® TCP éä¿¡ç«¯ç¹ãéæ¾ããã
+		 */
+		tcp_move_twcep(cep);
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+		break;
+
+	case TCP_FSM_TIME_WAIT:		/* ç¸æããã® FIN åä¿¡æ¸ã¿ãæéå¾
+ã¡ */
+		cep->timer[TCP_TIM_2MSL] = 2 * TCP_TVAL_MSL;
+		break;
+		}
+	}
+
+/*
+ *  tcp_input -- TCP ã®å
+¥åé¢æ°
+ *
+ *	æ³¨æ: input ã«ã¯ IF ãããã¨ IP ããããå
+é ­ã«ããã
+ */
+
+uint_t
+tcp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_TCP_HDR	*tcph;
+	T_TCP_CEP	*cep = NULL;
+	T_TCP_SEQ	iss = 0;
+	ER		ret;
+	bool_t		needoutput = false;
+	int_t		rbfree;
+	int32_t		todrop, win;
+	uint16_t	seglen;
+	uint8_t		flags;
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+	T_TCP_TWCEP	*twcep;
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_OCTETS],
+	              input->len - GET_IF_IP_HDR_SIZE(input));
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_SEGS], 1);
+	NET_COUNT_MIB(tcp_stats.tcpInSegs, 1);
+
+	/* ãããé·ããã§ãã¯ããã*/
+	if (input->len < IF_IP_TCP_HDR_SIZE(input)) {
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_BAD_HEADERS], 1);
+		goto drop;
+		}
+
+	tcph = GET_TCP_HDR(input, *offp);
+
+	seglen  = input->len - *offp;				/* TCP ã®ã»ã°ã¡ã³ãé· */
+
+	if (IN_CKSUM(input, IPPROTO_TCP, *offp, (uint_t)seglen) != 0) {
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_BAD_CKSUMS], 1);
+		goto drop;
+		}
+
+	/* TCP ãããé·ããã§ãã¯ããã*/
+	if (TCP_HDR_LEN(tcph->doff) < TCP_HDR_SIZE || TCP_HDR_LEN(tcph->doff) > seglen) {
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_BAD_HEADERS], 1);
+		goto drop;
+		}
+	tcph->sum = seglen - TCP_HDR_LEN(tcph->doff);		/* ãããã tcph->sum ã¯ TCP ã® SDU é· */
+
+	/*
+	 *  SYN ã¨ FIN ã®ä¸¡ããããã»ããããã¦ããã°ç ´æ£ãããnmap ç­ã®å¯¾ç­
+	 *  ãã ããRFC1644 T/TCP æ¡å¼µæ©è½ã¨ç«¶åããã
+	 */
+	if ((tcph->flags & (TCP_FLG_SYN | TCP_FLG_FIN)) == (TCP_FLG_SYN | TCP_FLG_FIN))
+		goto drop;
+
+	/* ãããã¯ã¼ã¯ãªã¼ãã¼ãããã¹ããªã¼ãã¼ã«å¤æããã*/
+
+	NTOHL(tcph->seq);
+	NTOHL(tcph->ack);
+	NTOHS(tcph->win);
+	NTOHS(tcph->urp);
+	NTOHS(tcph->sport);
+	NTOHS(tcph->dport);
+
+find_cep:
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	/*
+	 *  ç¶æ
+ã Time Wait ä¸­ã® CEP ãæ¢ç´¢ããã
+	 */
+	twcep = tcp_find_twcep(input, *offp);
+	if (twcep != NULL) {
+
+		if (tcph->flags & TCP_FLG_RST)		/* RST ãã©ã°ãåä¿¡ããã¨ãã¯ç¡è¦ããã*/
+			goto drop;
+		else {
+
+			/*
+			 *    TCP éä¿¡ç«¯ç¹ã Time Wait ã®æãç¸æãã¹ãããã»ã°ã¡ã³ããæ¥ãã¨ãã¯ã
+			 *    ç¸æãã¹ãã® FIN ã«å¯¾ããèªãã¹ãã® ACK ã»ã°ã¡ã³ããéä¸­ã§
+			 *    æå¤±ãããã¨ãæå³ãã¦ããã®ã§ãACK ã»ã°ã¡ã³ããåéããã
+			 */
+
+			/* ãã¹ããªã¼ãã¼ãããããã¯ã¼ã¯ãªã¼ãã¼ã«æ»ãã*/
+			HTONS(tcph->sport);
+			HTONS(tcph->dport);
+
+			tcp_respond(input, NULL, twcep->rcv_nxt, twcep->snd_una, twcep->rbufsz - twcep->rwbuf_count, TCP_FLG_ACK);
+			}
+		return IPPROTO_DONE;
+		}
+	else
+		/* æ¨æºã® TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+		cep = tcp_find_cep(input, *offp);
+
+#else	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = tcp_find_cep(input, *offp);
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	/*
+	 *  TCP éä¿¡ç«¯ç¹ããªãå ´åã¨ CEP ã®ç¶æ
+ãã¯ã­ã¼ãºãªãç ´æ£ããã
+	 */
+	if (cep == NULL) {
+		syslog(LOG_INFO, "[TCP] unexp port: %d.", tcph->dport);
+		goto reset_drop;
+		}
+
+#ifdef TCP_CFG_TRACE
+
+	tcp_input_trace(input, cep);
+
+#endif	/* of #ifdef TCP_CFG_TRACE */
+
+
+	if (cep->fsm_state == TCP_FSM_CLOSED)
+		goto drop;
+
+	/*
+	 *  ã³ãã¯ã·ã§ã³éè¨­æ¸ã¿ã§ã»ã°ã¡ã³ããåä¿¡ããã¨ãã¯ã
+	 *  ã¢ã¤ãã«æéã¨çå­ç¢ºèªã¿ã¤ãããªã»ããããã
+	 */
+	cep->idle = 0;
+	if (TCP_FSM_HAVE_ESTABLISHED(cep->fsm_state)) {
+		cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_IDLE;
+		}
+
+	/* CEP ã®ç¶æ
+ã LISTEN ä»¥å¤ã®æã¯ããªãã·ã§ã³ãå¦çããã*/
+	if (cep->fsm_state != TCP_FSM_LISTEN)
+		parse_option(tcph, cep);
+
+	/*
+	 *  åä¿¡å¯è½ã¦ã£ã³ããµã¤ãºãè¨ç®ããã
+	 *
+	 *  rcv_nxt:     åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQï¼ããä»¥åã¯åä¿¡æ¸ã¿ï¼
+	 *  rcv_adv:     åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ
+	 *  rbufsz:      åä¿¡ã¦ã£ã³ããããã¡ãµã¤ãº
+	 *  rwbuf_count:  åä¿¡ã¦ã£ã³ããããã¡ã«ãããã¼ã¿é
+	 *  tcph->sum:   ä»ååä¿¡ãã SDU ãµã¤ãº
+	 *
+	 *  ä»ååä¿¡ããã»ã°ã¡ã³ããé åºæ´åã­ã¥ã¼ã«é£çµãã
+	 *  å¯è½æ§ãããã®ã§ tcph->sum ãèæ
+®ããã
+	 *
+	 */
+	win = cep->rbufsz - (cep->rwbuf_count + tcph->sum);
+	if (win < 0)
+		win = 0;
+	if (win > (int32_t)(cep->rcv_adv - cep->rcv_nxt))
+		cep->rcv_wnd = win;
+	else
+		cep->rcv_wnd = cep->rcv_adv - cep->rcv_nxt;
+
+	/* CEP ã®ç¶æ
+ã«ããå¦çãè¡ãã*/
+
+	if (cep->fsm_state == TCP_FSM_LISTEN) {		/* ååãªã¼ãã³ (LISTEN) ã®å¦çã*/
+		if ((ret = listening(input, cep, *offp, iss)) == RET_RST_DROP)
+			goto reset_drop;
+		else if (ret == RET_DROP)
+			goto drop;
+		trim_length(tcph, cep);			/* åä¿¡ãã SDU é·ãèª¿æ´ããã*/
+
+		if (tcph->flags & TCP_FLG_ACK) {	/* ACK ãã©ã°ã®å¦ç */
+			if ((ret = proc_ack2(input, cep, *offp, &needoutput)) == RET_DROP)
+				goto drop;
+			else if (ret == RET_RST_DROP)
+				goto reset_drop;
+			else if (ret == RET_RETURN)
+				return IPPROTO_DONE;
+			}
+		}
+	else if (cep->fsm_state == TCP_FSM_SYN_SENT) {	/* è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿	*/
+		if ((ret = syn_sent(tcph, cep)) == RET_RST_DROP)
+			goto reset_drop;
+		else if (ret == RET_DROP)
+			goto drop;
+		trim_length(tcph, cep);			/* åä¿¡ãã SDU é·ãèª¿æ´ããã*/
+
+		if (tcph->flags & TCP_FLG_ACK) {	/* ACK ãã©ã°ã®å¦ç */
+			if ((ret = proc_ack2(input, cep, *offp, &needoutput)) == RET_DROP)
+				goto drop;
+			else if (ret == RET_RST_DROP)
+				goto reset_drop;
+			else if (ret == RET_RETURN)
+				return IPPROTO_DONE;
+			}
+		}
+	else {
+		if (cep->fsm_state == TCP_FSM_SYN_RECVD) {	/* SYN ãåä¿¡ãSYN éä¿¡æ¸ã¿	*/
+			/*
+			 *  ç¸æããåä¿¡ç¢ºèªãéããã¦æ¥ã¦ãã
+			 *
+			 *    ACK <= æªç¢ºèªã®æå°éä¿¡ SEQ (snd_una) &&
+			 *           éä¿¡ããæå¤§     SEQ (snd_max) < ACK
+			 *
+			 *  ãªãããªã»ãããéã£ã¦ã»ã°ã¡ã³ããç ´æ£ããã
+			 */
+			if ((tcph->flags & TCP_FLG_ACK) &&
+			    (SEQ_LE(tcph->ack, cep->snd_una) ||
+			     SEQ_GT(tcph->ack, cep->snd_max)))
+			     	goto reset_drop;
+			}
+
+		/* 
+		 *  RST ãã©ã°ãåä¿¡ããã¨ãã®å¦ç (ç°å¸¸åæ­)
+		 */
+		if (tcph->flags & TCP_FLG_RST) {
+			if (SEQ_GE(tcph->seq, cep->last_ack_sent) &&
+			    SEQ_LT(tcph->seq, cep->last_ack_sent + cep->rcv_wnd)) {
+				/*
+				 *  åä¿¡ããã»ã°ã¡ã³ãã® SEQ ããæå¾ã«éä¿¡ãã ACK (last_ack_sent)
+				 *  ãããåä¿¡ã¦ã¤ã³ãã¦ãµã¤ãºã¾ã§ã®éã®å¦ç
+				 */
+				switch (cep->fsm_state) {
+				case TCP_FSM_SYN_RECVD:		/* SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿		*/
+
+					cep->net_error = EV_CNNRF;	/* æ¥ç¶ä¸è½ */
+					cep->error     = E_CLS;
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_RSTS], 1);
+					NET_COUNT_MIB(tcp_stats.tcpAttemptFails, 1);
+					cep = tcp_close(cep);
+					break;
+
+				case TCP_FSM_ESTABLISHED:	/* ã³ãã¯ã·ã§ã³éè¨­å®äº			*/
+				case TCP_FSM_CLOSE_WAIT:	/* FIN åä¿¡ãã¯ã­ã¼ãºå¾
+ã¡		*/
+					NET_COUNT_MIB(tcp_stats.tcpEstabResets, 1);
+					/* fallthrough */
+
+				case TCP_FSM_FIN_WAIT_1:	/* çµäºãã¦ãFIN éä¿¡æ¸ã¿		*/
+				case TCP_FSM_FIN_WAIT_2:	/* çµäºãFIN ä¼éç¢ºèªåä¿¡ãFINå¾
+ã¡	*/
+
+					cep->net_error = EV_CNRST;	/* æ¥ç¶ãªã»ãã */
+					cep->error     = E_CLS;
+					NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_RSTS], 1);
+					/* no break; */
+
+				case TCP_FSM_CLOSING:		/* çµäºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡	*/
+				case TCP_FSM_LAST_ACK:		/* FIN åä¿¡ãçµäºãACK å¾
+ã¡	*/
+
+					cep = tcp_close(cep);
+					break;
+					}
+				}
+			goto drop;
+			}
+
+		/*
+		 *  CEP ã®ç¶æ
+ã SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿ã®å ´åã¯ã
+		 *  åä¿¡ã¦ã£ã³ãã«åã¾ãããã«ãã¼ã¿ã
+		 *  èª¿æ´ããåã«ããã®æ¥ç¶ã«ãããã±ãããã©ãããæ¤è¨¼ããã
+		 *
+		 *    åä¿¡ããç¸æã® SEQ < ç¸æã® SEQ ã®åæå¤ (irs)
+		 *
+		 *  ããã¯ã"LAND" DoS æ»æã®é²å¾¡ã§ããã
+		 */
+		if (cep->fsm_state == TCP_FSM_SYN_RECVD && SEQ_LT(tcph->seq, cep->irs)) {
+			goto reset_drop;
+			}
+
+		/*
+		 *  åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ (rcv_nxt) - åä¿¡ããç¸æã® SEQ ã
+		 *  æ­£ãªããrcv_nxt ä»¥åã®ãã¼ã¿ã¯ãã§ã«åä¿¡ãã¦ããã®ã§ããã®é¨åã
+		 *  åé¤ããã
+		 *                           <---------- rcv_wnd --------->
+		 *                           rcv_nxt                      rcv_nxt + rcv_wnd
+		 *                           v                            v
+		 *                      -----+----------------------------+-----
+		 *                           |                            |
+		 *                      -----+----------------------------+-----
+		 *           +----------------------+
+		 *           |***************|      |
+		 *           +----------------------+
+		 *           ^                      ^
+		 *           seq                    seq + len
+		 *           <---------------> åé¤ããã
+		 */
+		todrop = cep->rcv_nxt - tcph->seq;
+		if (todrop > 0) {
+
+			/*
+			 *  SYN ãã©ã°ãã¤ãã¦ããã¨ãã¯ããã®å (1 ãªã¯ããã)
+			 *  SEQ ãé²ããç·æ¥ãã¤ã³ã¿ã¨åé¤ããé·ããèª¿æ´ããã
+			 */
+			if (tcph->flags & TCP_FLG_SYN) {
+				tcph->flags &= ~TCP_FLG_SYN;
+				tcph->seq ++;
+				if (tcph->urp > 1)
+					tcph->urp --;
+				else
+					tcph->flags &= ~TCP_FLG_URG;
+				todrop --;
+				}
+
+			/*
+			 *  åé¤ããé·ãã SDU ããé·ããã¤ã¾ããåä¿¡ãæå¾
+ãã¦ãã
+			 *  æå°ã® SEQ (rcv_nxt) ã«éãã¦ããªããã
+			 *  åé¤ããé·ãã SDU ã¨åãã§ãFIN ãã©ã°ãã¤ãã¦ãªããã°
+			 *  å
+¨ã¦åé¤ããã
+			 */
+			if ( todrop >  tcph->sum ||		/* tcph->sum ã¯ TCP ã® SDU é· */
+			    (todrop == tcph->sum && (tcph->flags & TCP_FLG_FIN) == 0)) {
+				tcph->flags &= ~TCP_FLG_FIN;
+				cep->flags |= TCP_CEP_FLG_ACK_NOW;
+				todrop = tcph->sum;		/* tcph->sum ã¯ TCP ã® SDU é· */
+				}
+
+			/*
+			 *  SDU ãåã«è©°ããã
+			 */
+			if (todrop < tcph->sum) {		/* tcph->sum ã¯ TCP ã® SDU é· */
+				memcpy(GET_TCP_SDU(input, *offp),
+				       GET_TCP_SDU(input, *offp) + todrop, (size_t)(tcph->sum - todrop));
+				}
+
+			/*
+			 *  SEQ ã¨ SDU é·ãèª¿æ´ããã
+			 */
+			tcph->seq +=     todrop;
+			tcph->sum -= (uint16_t)todrop;	/* tcph->sum ã¯ TCP ã® SDU é· */
+
+			/*
+			 *  ç·æ¥ãã¤ã³ã¿ãèª¿æ´ããã
+			 */
+			if (tcph->urp > todrop)
+				tcph->urp -= (uint16_t)todrop;
+			else {
+				tcph->flags &= ~TCP_FLG_URG;
+				tcph->urp = 0;
+				}
+
+			NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DUP_SEGS], 1);
+			}
+
+		/*  
+		 *  ããã¦ã¼ã¶ã¿ã¹ã¯ãçµäºããå¾ã«ããã¼ã¿ãåä¿¡ãã
+		 *  å ´åã¯ãRST ãéãã
+		 */
+		if (cep->fsm_state == TCP_FSM_LAST_ACK && tcph->sum > 0) {	/* tcph->sum ã¯ TCP ã® SDU é· */
+			cep = tcp_close(cep);
+			goto reset_drop;
+			}
+
+		/*
+		 *  åä¿¡ã»ã°ã¡ã³ããåä¿¡ã¦ã£ã³ããè¶
+ããå ´åã¯ã
+		 *  è¶
+ããåãåãã
+		 *
+		 *       <---------- rcv_wnd --------->
+		 *       rcv_nxt                      (rcv_nxt + rcv_wnd)
+		 *       v                            v
+		 *  -----+----------------------------+-----
+		 *       |                            |
+		 *  -----+----------------------------+-----
+		 *                    +----------------------+
+		 *                    |               |******|
+		 *                    +----------------------+
+		 *                    ^                      ^
+		 *                    seq                    seq + len
+		 *                                     <-----> åé¤ããã
+		 */
+		todrop = (tcph->seq + tcph->sum) - (cep->rcv_nxt + cep->rcv_wnd);	/* tcph->sum ã¯ TCP ã® SDU é· */
+		if (todrop > 0) {
+			if (todrop > tcph->sum) {					/* tcph->sum ã¯ TCP ã® SDU é· */
+				/*
+				 *  åä¿¡ãã SDU ã®å
+¨ã¦ãåä¿¡ã¦ã£ã³ããè¶
+ããå ´åã
+				 *
+				 *  TIME_WAIT ä¸­ã«ãæ°ããªæ¥ç¶è¦æ±ãåä¿¡ããã
+				 *  å¤ãæ¥ç¶ãç ´æ£ããæ°ããªæ¥ç¶ãéå§ããã
+				 *  ãã ããSEQ ã¯åããé²ãã§ããªããã°ãªããªãã
+				 */
+				if ((tcph->flags & TCP_FLG_SYN) &&
+				    cep->fsm_state == TCP_FSM_TIME_WAIT &&
+				    SEQ_GT(tcph->seq, cep->rcv_nxt)) {
+					iss = cep->snd_nxt + TCP_ISS_INCR();
+					tcp_close(cep);
+					syscall(dly_tsk(0));
+					goto find_cep;
+				    	}
+
+				/*
+				 *  åä¿¡ã¦ã£ã³ãã 0 ã§ãåä¿¡ãã SEQ ã¨
+				 *  åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ ãä¸è´ããã¨ãã¯
+				 *  ACK ãè¿ããããä»¥å¤ã¯ãã¼ã¿ãç ´æ£ããACK ãè¿ãã
+				 */
+				if (cep->rcv_wnd == 0 && (tcph->seq == cep->rcv_nxt || tcph->sum == 0)) {
+					cep->flags |= TCP_CEP_FLG_ACK_NOW;
+					}
+				else if (drop_after_ack(input, cep, *offp) == RET_RST_DROP)
+					goto reset_drop;
+				else {
+					return IPPROTO_DONE;
+					}
+				}
+			tcph->sum -= (uint16_t)todrop;	/* tcph->sum ã¯ TCP ã® SDU é· */
+			tcph->flags &= ~(TCP_FLG_PUSH | TCP_FLG_FIN);
+			}
+
+		/*
+		 *  ãããSYN ãã»ããããã¦ããã°ã
+		 *  ã¨ã©ã¼ãªã®ã§ RST ãéããæ¥ç¶ãç ´æ£ããã
+		 */
+		if (tcph->flags & TCP_FLG_SYN) {
+			cep->net_error = EV_CNRST;
+			cep = tcp_drop(cep, E_CLS);
+			goto reset_drop;
+			}
+
+		/*
+		 *  ãããACK ãã»ããããã¦ããªãå ´åã¯ã
+		 *  ç¶æ
+ã SYN åä¿¡æ¸ã¿ã
+		 *  SYN ãéä¿¡ãããã¨ãã¦ããã°ãå¦çãç¶ãããã
+		 *  ããä»¥å¤ã¯ã»ã°ã¡ã³ããç ´æ£ãã¦çµäºããã
+		 */
+		if ((tcph->flags & TCP_FLG_ACK) == 0) {
+			if (!(cep->fsm_state == TCP_FSM_SYN_RECVD || (cep->flags & TCP_CEP_FLG_NEED_SYN)))
+				goto drop;
+			}
+		else {
+			/*
+			 * ACK ã®å¦ç
+			 */
+			ret = proc_ack1(input, cep, *offp, &needoutput);
+			if (ret == RET_DROP)
+				goto drop;
+			else if (ret == RET_RST_DROP)
+				goto reset_drop;
+			else if (ret == RET_RETURN)
+				return IPPROTO_DONE;
+			}
+		}
+
+/* step 6 */
+
+	/* éä¿¡ã¦ã£ã³ããæ´æ°ããã*/
+	if (update_wnd(tcph, cep) == true)
+		needoutput = true;
+
+	/* ç·æ¥ãã¼ã¿ãå¦çããã*/
+	proc_urg(tcph, cep);
+
+/* do data */
+
+	/*
+	 *  SDU ãããããFIN ãæªåä¿¡ã®ç¶æ
+ã§ãæåã« FIN ãåä¿¡ããã¨ãã
+	 *  åä¿¡ã»ã°ã¡ã³ãã­ã¥ã¼ã« net_buf ãè¿½å ããã
+	 *  ããä»¥å¤ã®å ´åã¯ãã»ã°ã¡ã³ããç ´æ£ããã
+	 */
+	flags = tcph->flags;
+	if ((tcph->sum > 0 || (flags & TCP_FLG_FIN)) &&		/* tcph->sum ã¯ TCP ã® SDU é· */
+	    TCP_FSM_HAVE_RCVD_FIN(cep->fsm_state) == 0) {
+		flags = reassemble(input, cep, *offp, flags);
+		}
+	else {
+		syscall(rel_net_buf(input));
+		flags &= ~TCP_FLG_FIN;
+		}
+
+	/*
+	 *  FIN ãåä¿¡ãããã³ãã¯ã·ã§ã³ãã¯ã­ã¼ãºããã
+	 */
+	if (flags & TCP_FLG_FIN)
+		close_connection(cep, &needoutput);
+
+	/* åºåãè¡ã£ãå¾çµäºããã*/
+	if (needoutput == true || (cep->flags & TCP_CEP_FLG_ACK_NOW)) {
+		/* éä¿¡ãæç¤ºããã*/
+		cep->flags |=  TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+
+	return IPPROTO_DONE;
+
+reset_drop:
+	/*
+	 *  RST éä¿¡å¦ç
+	 */
+
+	if ((tcph->flags & TCP_FLG_RST) || IN_IS_NET_ADDR_MULTICAST(input))
+		goto drop;
+
+	/* ãã¹ããªã¼ãã¼ãããããã¯ã¼ã¯ãªã¼ãã¼ã«æ»ãã*/
+
+	HTONS(tcph->sport);
+	HTONS(tcph->dport);
+
+	if (cep == NULL)
+		rbfree = 0;
+	else
+		rbfree = cep->rbufsz - cep->rwbuf_count;
+
+	if (tcph->flags & TCP_FLG_ACK)
+		tcp_respond(input, cep, 0, tcph->ack, rbfree, TCP_FLG_RST);
+	else {
+		if (tcph->flags & TCP_FLG_SYN)
+			tcph->sum ++;		/* tcph->sum ã¯ SDU é· */
+		tcp_respond(input, cep, tcph->seq + tcph->sum, 0, rbfree, TCP_FLG_RST | TCP_FLG_ACK);
+		}
+
+	/* input ã¯ tcp_respoond ã§è¿å´ãããã*/
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_RSTS], 1);
+	NET_COUNT_MIB(tcp_stats.tcpOutRsts, 1);
+	return IPPROTO_DONE;
+
+drop:
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DROP_SEGS], 1);
+	NET_COUNT_MIB(tcp_stats.tcpInErrs, 1);
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_output.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_output.c	(revision 317)
@@ -0,0 +1,1157 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_output.c	8.4 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_output.c,v 1.32.2.2 1999/08/29 16:29:55 peter Exp $
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  é¢æ°
+ */
+
+static ER send_segment (bool_t *sendalot, T_TCP_CEP *cep, uint_t doff, uint_t win, uint_t len, uint8_t flags);
+static void tcp_output (T_TCP_CEP *cep);
+
+/*
+ *  å¤æ°
+ */
+
+/* åºåæã®ãã©ã°ã FSM ç¶æ
+ã«ããé¸æããããã®è¡¨ */
+
+const static uint8_t tcp_outflags[] = {
+	TCP_FLG_RST | TCP_FLG_ACK,	/*  0, ã¯ã­ã¼ãº				*/
+	0,				/*  1, ååãªã¼ãã³			*/
+	TCP_FLG_SYN,			/*  2, è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿	*/
+	TCP_FLG_SYN | TCP_FLG_ACK,	/*  3, SYM ãåä¿¡ããSYN éä¿¡æ¸ã¿	*/
+	TCP_FLG_ACK,			/*  4, ã³ãã¯ã·ã§ã³éè¨­å®äº		*/
+	TCP_FLG_ACK,			/*  5, FIN åä¿¡ãã¯ã­ã¼ãºå¾
+ã¡		*/
+	TCP_FLG_FIN | TCP_FLG_ACK,	/*  6, çµäºãã¦ãFIN éä¿¡æ¸ã¿		*/
+	TCP_FLG_FIN | TCP_FLG_ACK,	/*  7, çµäºãFIN äº¤ææ¸ã¿ãACK å¾
+ã¡	*/
+	TCP_FLG_FIN | TCP_FLG_ACK,	/*  8, FIN åä¿¡ãçµäºãACK å¾
+ã¡		*/
+	TCP_FLG_ACK,			/*  9, çµäºãFIN ä¼éç¢ºèªåä¿¡ãFINå¾
+ã¡	*/
+	TCP_FLG_ACK,			/* 10, çµäºãæéå¾
+ã¡			*/
+	};
+
+/*
+ *  send_segment -- TCP åºåå¦ç
+ */
+
+static ER
+send_segment (bool_t *sendalot, T_TCP_CEP *cep, uint_t doff, uint_t win, uint_t len, uint8_t flags)
+{
+	T_NET_BUF	*output;
+	T_TCP_HDR	*tcph;
+	uint_t		optlen, hdr_offset;
+	ER		error;
+
+#ifdef TCP_CFG_OPT_MSS
+
+	uint8_t		*optp;
+
+	if (flags & TCP_FLG_SYN)
+		optlen = TCP_OPT_LEN_MAXSEG;
+	else
+		optlen = 0;
+
+#else/* of #ifdef TCP_CFG_OPT_MSS */
+
+	optlen = 0;
+
+#endif/* of #ifdef TCP_CFG_OPT_MSS */
+
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_SEGS], 1);
+	NET_COUNT_MIB(tcp_stats.tcpOutSegs, 1);
+
+	/*
+	 *  ã»ã°ã¡ã³ãé·ããç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ãé·ã«èª¿æ´ããã
+	 *  ãããè¶
+ãã¦ããå ´åã¯ãè¶
+ããåãå¾ã§éä¿¡ããã
+	 *  ãã®ãããFIN ããããã¯ãªã¢ããã
+	 *
+	 *  ãªãªã¸ãã«ã§ã¯ãt_maxopd ãå¶éé·ã«ãã¦ãããã
+	 *  æ¬å®è£
+ã§ã¯ãç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ãã«ããã
+	 */
+	if (len + optlen > cep->maxseg) {
+		flags &= ~TCP_FLG_FIN;
+		len = cep->maxseg - optlen;
+		*sendalot = true;
+		}
+
+	/*
+	 *  éä¿¡ãããã¡ãç©ºã«ãªãã¨ãã¯ PUSH ãã©ã°ãè¨­å®ããã
+	 */
+	if (len && doff + len >= cep->swbuf_count)
+		flags |= TCP_FLG_PUSH;
+
+#if defined(TCP_CFG_SWBUF_CSAVE_ONLY)
+		
+	if (len > 0 && ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY ||
+	                (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SENT)) {
+
+		/*
+		 *  éä¿¡ã¦ã¤ã³ããããã¡ãéæ¾ãããªãããã«ãã¦ã
+		 *  ãããã¯ã¼ã¯ãããã¡ãåºåã«ç§»ãã
+		 */
+		cep->swbufq->flags |= NB_FLG_NOREL_IFOUT;
+		output = cep->swbufq; 
+		}
+	else {
+
+		/*
+		 *  ACK å®äºç¶æ
+ã§ããã®é¢æ°ãå¼ã³åºããããã¨ãããã
+		 *  ãã®æã¯ãlen ã 0 ã«ãã¦ãå¦çãç¶ç¶ããã
+		 */
+		len = 0;
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+	                                    len, (uint_t)net_buf_max_siz(),
+	                                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
+			if (cep->timer[TCP_TIM_REXMT] == 0)
+				cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+			goto err_ret;
+			}
+		}
+
+#elif defined(TCP_CFG_SWBUF_CSAVE)	/* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
+
+	if (IS_PTR_DEFINED(cep->sbuf)) {
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+		                             len, (uint_t)net_buf_max_siz(),
+		                             NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
+			if (cep->timer[TCP_TIM_REXMT] == 0)
+				cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+			goto err_ret;
+			}
+		}
+	else if (len > 0 && ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY ||
+	                     (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SENT)) {
+
+		/*
+		 *  éä¿¡ã¦ã¤ã³ããããã¡ãéæ¾ãããªãããã«ãã¦ã
+		 *  ãããã¯ã¼ã¯ãããã¡ãåºåã«ç§»ãã
+		 */
+		cep->swbufq->flags |= NB_FLG_NOREL_IFOUT;
+		output = cep->swbufq; 
+		}
+	else {
+
+		/*
+		 *  ACK å®äºç¶æ
+ã§ããã®é¢æ°ãå¼ã³åºããããã¨ãããã
+		 *  ãã®æã¯ãlen ã 0 ã«ãã¦ãå¦çãç¶ç¶ããã
+		 */
+		len = 0;
+		if ((error = tcpn_get_segment(&output, cep, optlen,
+	                                    len, (uint_t)net_buf_max_siz(),
+	                                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
+			if (cep->timer[TCP_TIM_REXMT] == 0)
+				cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+			goto err_ret;
+			}
+		}
+
+#else	/* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
+
+	if ((error = tcpn_get_segment(&output, cep, optlen,
+	                             len, (uint_t)net_buf_max_siz(),
+	                             NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF)) != E_OK) {
+		if (cep->timer[TCP_TIM_REXMT] == 0)
+			cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+		goto err_ret;
+		}
+
+#endif	/* of #if defined(TCP_CFG_SWBUF_CSAVE_ONLY) */
+
+	/*
+	 *  TCP ãªãã·ã§ã³ã®è¨­å®ãè¡ãã
+	 *  æ¬å®è£
+ã§ã¯ãæå¤§ã»ã°ã¡ã³ããµã¤ãºã®ã¿è¨­å®ããã
+	 */
+	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
+	if (flags & TCP_FLG_SYN) {
+		cep->snd_nxt = cep->iss;
+
+#ifdef TCP_CFG_OPT_MSS
+
+		optp = GET_TCP_OPT(output, hdr_offset);
+		*optp ++ = TCP_OPT_MAXSEG;
+		*optp ++ = TCP_OPT_LEN_MAXSEG;
+		*(uint16_t*)optp = htons(DEF_TCP_RCV_SEG);
+
+#endif/* of #ifdef TCP_CFG_OPT_MSS */
+
+		}
+
+	/* TCP SDU ã«éä¿¡ãã¼ã¿ãã³ãã¼ããã*/
+
+	if (len > 0) {
+		if (SEQ_LT(cep->snd_nxt, cep->snd_max)) {
+			NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_REXMIT_SEGS], 1);
+			NET_COUNT_MIB(tcp_stats.tcpRetransSegs, 1);
+			}
+		TCP_READ_SWBUF(cep, output, len, doff);
+		}
+	else {
+		if (cep->flags & TCP_CEP_FLG_ACK_NOW)
+			NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_ACKS], 1);
+		if (flags & (TCP_FLG_FIN | TCP_FLG_SYN | TCP_FLG_RST))
+			NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_CNTL_SEGS],  1);
+
+
+#ifdef TCP_CFG_EXTENTIONS
+
+		if (SEQ_LT(cep->snd_up, cep->snd_una))
+			NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_URG_SEGS], 1);
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+		}
+
+	/*
+	 * snd_max: éä¿¡ããæå¤§ SEQ
+	 * snd_nxt: æ¬¡ã«éä¿¡ãã SEQ
+	 *
+	 *  ç¸æãã FIN ãåä¿¡ããã¾ã  FIN ãéä¿¡ãã¦ããªããã
+	 *  éããã¼ã¿ããªãã¨ãã¯ãFIN ãç¸æã«å±ããããã
+	 *  ã»ã°ã¡ã³ããéä¿¡ããããSEQ ã¯é²ããªãã
+	 */
+	if ((flags & TCP_FLG_FIN) && (cep->flags & TCP_CEP_FLG_SENT_FIN) &&
+	    cep->snd_nxt == cep->snd_max) {
+		cep->snd_nxt --;
+		}
+
+	tcph = GET_TCP_HDR(output, hdr_offset);
+
+	/*
+	 *  SEQãACKããã©ã°ã®è¨­å®ã
+	 */
+	if (len > 0 || (flags & (TCP_FLG_SYN | TCP_FLG_FIN)) || cep->timer[TCP_TIM_PERSIST] != 0)
+		tcph->seq = htonl(cep->snd_nxt);
+	else
+		tcph->seq = htonl(cep->snd_max);
+
+	/*
+	 *  rcv_nxt: åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ
+	 */
+	tcph->ack   = htonl(cep->rcv_nxt);
+	tcph->flags = flags;
+
+	/*
+	 *  åä¿¡ã¦ã£ã³ãã®è¨ç®
+	 *
+	 *  rbufsz: åä¿¡ç¨ãããã¡ãµã¤ãº
+	 *  maxseg: ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº	
+	 */
+	if (win < (cep->rbufsz / 4) && win < cep->maxseg)
+		win = 0;
+
+	/*
+	 *  rcv_nxt: åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ
+	 *  rcv_adv: åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ
+	 */
+	if ((int32_t)win < (int32_t)(cep->rcv_adv - cep->rcv_nxt))
+		win = (uint_t)(cep->rcv_adv - cep->rcv_nxt);
+
+	tcph->win = htons(win);
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	/*
+	 *  ç·æ¥ãã¤ã³ã¿ã®è¨­å®
+	 */
+	if (SEQ_GT(cep->snd_up, cep->snd_nxt)) {
+		if (TCP_CFG_URG_OFFSET)
+			tcph->urp    = htons((uint16_t)(cep->snd_up - cep->snd_nxt));
+		else
+			tcph->urp    = htons((uint16_t)(cep->snd_up - cep->snd_nxt - 1));
+		tcph->flags |= TCP_FLG_URG;
+		}
+	else
+		cep->snd_up  = cep->snd_una;
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	/*
+	 *  ãã§ãã¯ãµã ãè¨­å®ããã
+	 */
+	tcph->sum = 0;
+	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, GET_TCP_HDR_SIZE(output, hdr_offset) + len);
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)(GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset) + len);
+
+	/*
+	 *  ã¿ã¤ãã®èª¿æ´
+	 */
+	if ((cep->flags & TCP_CEP_FLG_FORCE) == 0 || cep->timer[TCP_TIM_PERSIST] == 0) {
+		T_TCP_SEQ startseq = cep->snd_nxt;
+
+		/*
+		 *  æ¬¡ã«éä¿¡ãã SEQ (snd_nxt) ãä»åéä¿¡ãããã¼ã¿æ°åé²ããã
+		 */
+		if (flags & TCP_FLG_SYN)
+			cep->snd_nxt ++;
+		if (flags & TCP_FLG_FIN) {
+			cep->flags |= TCP_CEP_FLG_SENT_FIN;
+			cep->snd_nxt ++;
+			}
+
+		cep->snd_nxt += len;
+
+		/*
+		 *  æ¬¡ã«éä¿¡ãã SEQ (snd_nxt) ã
+		 *  éä¿¡ããæå¤§ SEQ (snd_max) ããé²ãã§ããã°ã
+		 *  éä¿¡ããæå¤§ SEQ (snd_max) ãæ´æ°ããã
+		 */
+		if (SEQ_GT(cep->snd_nxt, cep->snd_max)) {
+			cep->snd_max = cep->snd_nxt;
+			/*
+			 *  ãããå¾å¾©æéè¨æ¸¬ãè¡ã£ã¦ããªããã°ã
+			 *  ãã®éä¿¡ã«æéãåãããã
+			 */
+			if (cep->rtt == 0) {
+				cep->rtt   = 1;
+				cep->rtseq = startseq;	/* æ´æ°åã® cep->snd_nxt */
+				}
+			}
+
+		/*
+		 *  ããè¨­å®ããã¦ããªãããACK ã¾ãã¯ä¿çãçºçãã¦ããªããã°ã
+		 *  åéã¿ã¤ããè¨­å®ãããè¨­å®ããåæå¤ã¯ã
+		 * ãæ»ãããªå¾å¾©æé + 2 Ã å¾å¾©æéå¤åãã§ããã
+		 *  åéæéã®ããã¯ãªãã«ä½¿ãããã·ããã«ã¦ã³ããåæåããã
+		 */
+		if (cep->timer[TCP_TIM_REXMT] == 0 && cep->snd_nxt != cep->snd_una) {
+			cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+			if (cep->timer[TCP_TIM_PERSIST] != 0) {
+				cep->timer[TCP_TIM_PERSIST] = 0;
+				cep->rxtshift = 0;
+				}
+			}
+		}
+
+	/*
+	 *  æ¬¡ã«éä¿¡ãã SEQ (snd_nxt) + ä»åéä¿¡ãããã¼ã¿æ° (len) ã
+	 *  éä¿¡ããæå¤§ SEQ (snd_max) ããé²ãã§ããã°ã
+	 *  éä¿¡ããæå¤§ SEQ (snd_max) ãæ´æ°ããã
+	 */
+	else if (SEQ_GT(cep->snd_nxt + len, cep->snd_max))
+		cep->snd_max = cep->snd_nxt + len;
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SEND_READY)
+		cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_SENT;
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#ifdef TCP_CFG_TRACE
+
+	tcp_output_trace(output, cep);
+
+#endif	/* of #ifdef TCP_CFG_TRACE */
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	if ((error = IP_OUTPUT(output, TMO_TCP_OUTPUT)) != E_OK)
+		goto err_ret;
+
+	/*
+	 *  ç¸æã«ä¼ããã¦ã£ã³ãã¦ãµã¤ãº (win) ã 0 ä»¥ä¸ã§ã
+	 *  åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ (rcv_nxt) + win ã
+	 *  åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ (rcv_adv) ããé²ãã§ããã°
+	 *  åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ ãæ´æ°ããã
+	 */
+	if (win > 0 && SEQ_GT(cep->rcv_nxt + win, cep->rcv_adv)) {
+		cep->rcv_adv = cep->rcv_nxt + win;
+		}
+
+	/*
+	 *  æå¾ã«éä¿¡ãã ACK (last_ack_sent) ãæ´æ°ããã
+	 */
+	cep->last_ack_sent = cep->rcv_nxt;
+
+	/*
+	 *  ãã©ã°ã®è¨­å®ãè¡ãã
+	 */
+	cep->flags &= ~(TCP_CEP_FLG_ACK_NOW | TCP_CEP_FLG_DEL_ACK);
+	if (cep->flags & TCP_CEP_FLG_FORCE_CLEAR)
+		cep->flags &= ~(TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR);
+
+	return E_OK;
+
+err_ret:
+	/*
+	 * ä»¥ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
+	 * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+	 * ã»åçãªéä¿¡ç«¯ç¹ã®çæã»åé¤æ©è½
+	 */
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
+
+	return error;
+	}
+
+/*
+ *  tcp_output -- TCP åºåå¦ç
+ */
+
+void
+tcp_output (T_TCP_CEP *cep)
+{
+	bool_t	sendalot = true, idle;
+	ER	error = E_OK;
+	int32_t	len;
+	uint_t	doff, win;
+	uint8_t	flags;
+
+	/*
+	 *  snd_una: æªç¢ºèªã®æå°éä¿¡ SEQ	 ã¾ãã¯ãç¢ºèªãããæå¤§éä¿¡ SEQ
+	 *  snd_max: éä¿¡ããæå¤§ SEQ
+	 */
+	idle = (cep->snd_max == cep->snd_una);
+
+	/*
+	 *  idle:   ã¢ã¤ãã«æé
+	 *  rxtcur: ç¾å¨ã®åéã¿ã¤ã ã¢ã¦ã
+	 */
+	if (idle && cep->idle >= cep->rxtcur)
+
+		/*
+		 *  snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº
+		 *  maxseg  : ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº
+		 *
+		 *  é·æéã¢ã¤ãã«ã ã£ãã®ã§ã¹ã­ã¼ã¹ã¿ã¼ãå¶å¾¡ã«è¨­å®ããã
+		 */
+		cep->snd_cwnd = cep->maxseg;
+
+	while (error == E_OK && sendalot) {
+		sendalot = false;
+
+		/*
+		 *  snd_nxt: æ¬¡ã«éä¿¡ãã SEQããã®æç¹ã§ã¯ãååéä¿¡ãã SEQ
+		 *  snd_una: æªç¢ºèªã®æå°éä¿¡ SEQãã¾ãã¯ç¢ºèªãããæå¤§éä¿¡ SEQ
+		 *
+		 *  doff: éä¿¡ãéå§ãããªãã»ããã
+		 *                                    swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
+		 *    0                               V
+		 *    +-------------------------------------------+
+		 *    |                    sbuf                   |
+		 *    +-------------------------------------------+
+		 *    ^               ^
+		 *    |<------------->snd_nxt (ååéä¿¡ãã SEQ)
+		 *    |       doff
+		 *    snd_una (ã¾ã ç¢ºèªããã¦ããªã)
+		 */
+		doff = (uint_t)(cep->snd_nxt - cep->snd_una);
+
+		/*
+		 *  snd_wnd:  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
+		 *  snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº
+		 *
+		 *  win: ã©ã¡ããå°ããã¦ã£ã³ããµã¤ãºã«è¨­å®ããã
+		 */
+		win   = cep->snd_wnd < cep->snd_cwnd ? cep->snd_wnd : cep->snd_cwnd;
+	
+		/* åºåãã©ã°ã®è¨­å® */
+		flags = tcp_outflags[cep->fsm_state];
+		if (cep->flags & TCP_CEP_FLG_NEED_FIN)
+			flags |= TCP_FLG_FIN;
+		if (cep->flags & TCP_CEP_FLG_NEED_SYN)
+			flags |= TCP_FLG_SYN;
+		if (cep->flags & TCP_CEP_FLG_FORCE) {
+
+			/*
+			 *  ãããéä¿¡ã¦ã¤ã³ããµã¤ãº (win) ã 0 ãªã 1 ãªã¯ãããéä¿¡ããã
+			 *  ããã§ãªããã°ãæç¶ã¿ã¤ã ã¢ã¦ããã­ã£ã³ã»ã«ãã
+			 *  åéä¿¡åæ° (rxtshift) ã 0 ã«ããã
+			 */
+			if (win == 0) {
+
+				/*
+				 *  doff:        éä¿¡ãããªã¯ãããæ°ã
+				 *  swbuf_count: éä¿¡ãããã¡ã®ä½¿ç¨ä¸­ãµã¤ãº
+				 *
+				 *  éä¿¡ãããã¡ã«æ®ã£ã¦ãããªã¯ããããããããã
+				 *  éä¿¡ãããã¨ãã¦ãããªã¯ãããæ°ããå¤ããã°
+				 *  FIN ãã©ã°ãã¯ãªã¢ããã
+				 */
+				if (doff < cep->swbuf_count)
+					flags &=~TCP_FLG_FIN;
+				win = 1;
+				}
+			else {
+				/*
+				 *  TCP_TIM_PERSIST: æç¶ã¿ã¤ã
+				 *  rxtshift:        åéä¿¡åæ°ã® log(2)
+				 */
+				cep->timer[TCP_TIM_PERSIST] = 0;
+				cep->rxtshift = 0;
+				}
+		 	}
+
+		/*
+		 *  len: ä»åéä¿¡ãããªã¯ãããæ°
+		 *        swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
+		 *                                    |
+		 *    0                               V
+		 *    +-------------------------------------------+
+		 *    |                    sbuf       |           |
+		 *    +-------------------------------------------+
+		 *    ^               ^<------------->
+		 *    |               |      len
+		 *    |<------------->snd_nxt (ååéä¿¡ãã SEQ)
+		 *    |       doff
+		 *    snd_una (ã¾ã ç¢ºèªããã¦ããªã)
+		 */
+		if (cep->swbuf_count < win)
+			len = (int32_t)cep->swbuf_count - doff;
+		else
+			len = (int32_t)win - doff;
+
+		/*
+		 *  ãã§ã«éä¿¡ããã¦ããã°ãSYN ãããããªãããã
+		 *  ããããä»¥ä¸ã®æ¡ä»¶ã§ã¯éä¿¡ãæ§ããã
+		 *
+		 *    ã»ç¶æ
+ã SYN éä¿¡ã
+		 *    ã»ã»ã°ã¡ã³ãããã¼ã¿ãå«ãã§ããã
+		 */
+		if ((flags & TCP_FLG_SYN) && SEQ_GT(cep->snd_nxt, cep->snd_una)) {
+			flags &= ~TCP_FLG_SYN;
+			doff --;		/* -1 ã¯ SYN ãã©ã°å */
+			len ++;			/* +1 ã¯ SYN ãã©ã°å */
+			if (len > 0 && cep->fsm_state == TCP_FSM_SYN_SENT)
+				break;
+			}
+
+		if (flags & TCP_FLG_SYN) {
+			len = 0;
+			flags &= ~TCP_FLG_FIN;
+			}
+
+		if (len < 0) {
+
+			/*
+			 *  len ã 0 ä»¥ä¸ãªãã0 ã«è¨­å®ããã
+			 *  ãããéä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã 0 ãªãã
+			 *  åéä¿¡ã¿ã¤ããã­ã£ã³ã»ã«ãã
+			 *  ååéä¿¡ãã SEQ (snd_nxt) ã
+			 *  ç¢ºèªãããæå¤§éä¿¡ SEQ (snd_una) ã«æ»ãã
+			 *  ããã¦ãæç¶ã¿ã¤ãã¼ãæ­¢ã¾ã£ã¦ããã°ãåè¨­å®ããã
+			 */
+			len = 0;
+			if (win == 0) {
+				cep->timer[TCP_TIM_REXMT] = 0;
+				cep->rxtshift = 0;
+				cep->snd_nxt  = cep->snd_una;
+				if (cep->timer[TCP_TIM_PERSIST] == 0)
+					tcp_set_persist_timer(cep);
+				}
+			}
+
+
+		/*
+		 *  ä»åéä¿¡ãããªã¯ãããæ° (len) ã¯ã
+		 *  ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ãè¶
+ããªãããã«ããã
+		 */
+		if (len > cep->maxseg) {
+			len = cep->maxseg;
+			sendalot = true;
+			}
+
+		/*
+                 *        swbuf_count (éä¿¡ãããã¡ã«ãããªã¯ãããæ°)
+                 *                                           |
+		 *    0                                      V
+		 *    +-------------------------------------------+
+		 *    |                    sbuf       |           |
+		 *    +-------------------------------------------+
+		 *    ^               ^<------------->
+		 *    |               |      len
+		 *    |<------------->snd_nxt (ååéä¿¡ãã SEQ)
+		 *    |       doff
+		 *    snd_una (ã¾ã ç¢ºèªããã¦ããªã)
+		 *
+		 *  ä»åéä¿¡å¾ããéä¿¡ãããã¡ã«ãã¼ã¿ãæ®ã£ã¦ããã°
+		 *  FIN ãã©ã°ãã¯ãªã¢ããã
+		 */
+		if (SEQ_LT(cep->snd_nxt + len, cep->snd_una + cep->swbuf_count))
+			flags &= ~TCP_FLG_FIN;
+
+		/*
+		 *  ãããã win ã¯ãåä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã
+		 *  åä¿¡ãããã¡ã®ç©ºãå®¹é
+		 */
+		win = cep->rbufsz - cep->rwbuf_count;
+
+		/*
+		 *  æããªã¦ã£ã³ãã¦ã»ã·ã³ãã­ã¼ã ã®åé¿å¦ç (éä¿¡å´)
+		 *
+		 *  ä»¥ä¸ã®æ¡ä»¶ã§ãéä¿¡ãè¡ãã
+		 *
+		 *    ã»ãã«ãµã¤ãº (maxseg) ã®ã»ã°ã¡ã³ããéããã¨ãã§ããã
+		 *    ã»ç¸æã®æå¤§ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã® 1/2 ã®ãã¼ã¿ã
+		 *      éããã¨ãã§ããã
+		 *    ã»éä¿¡ãããã¡ãç©ºã«ã§ããã¢ã¤ãã«ãéé
+å»¶ãªãã·ã§ã³ãæå¹ãªã¨ãã
+		 */
+		if (len) {
+
+			/*
+			 *  ä»åéä¿¡ãããªã¯ãããæ° (len) ã
+			 *  ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ã«
+			 *  ä¸è´ããã¨ãã¯éä¿¡ããã
+			 */
+			if (len == cep->maxseg) {
+				error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+				continue;
+				}
+
+			/*
+			 *  ä»åã®éä¿¡ã§ãéä¿¡ãããã¡ãç©ºã«ã§ãã
+			 *  ã¢ã¤ãã«ãé PUSH ãªãã·ã§ã³ãæå¹ãªã¨ãã
+			 */
+			if ((idle || (cep->flags & TCP_CEP_FLG_NO_DELAY)) &&
+			    (cep->flags & TCP_CEP_FLG_NO_PUSH) == 0 &&
+			    len + doff >= cep->swbuf_count) {
+				error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+				continue;
+				}
+
+			/*
+			 *  max_sndwnd: ä»ã¾ã§ã®æå¤§éä¿¡ã¦ã£ã³ããµã¤ãº
+			 *  snd_nxt:    æ¬¡ã«éä¿¡ãã SEQ
+			 *  snd_max:    éä¿¡ããæå¤§ SEQ
+			 *
+			 *  æ¬¡ã®æ¡ä»¶ã§ã¯éä¿¡ãè¡ãã
+			 *
+			 *    ã»å¼·å¶éä¿¡ãã©ã°ãã»ããããã¦ããã
+			 *    ã»ãã¼ã¿é·ãç¸æã®æå¤§ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã® 1/2 ä»¥ä¸ã§ã
+			 *      ç¸æã®æå¤§ã®åä¿¡ã¦ã£ã³ãã¦ãµã¤ãºã 0 ããå¤§ããã
+			 *    ã»æ¬¡ã«éä¿¡ãã SEQ ãéä¿¡ããæå¤§ SEQ ããå°ããã
+			 *      ã¤ã¾ããåéããã¨ãã
+			 */
+			if ((cep->flags & TCP_CEP_FLG_FORCE) ||
+			    (len >= cep->max_sndwnd / 2 && cep->max_sndwnd > 0) ||
+			    SEQ_LT(cep->snd_nxt, cep->snd_max)) {
+				error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+				continue;
+				}
+			}
+
+
+		/*
+		 *  æããªã¦ã£ã³ãã¦ã»ã·ã³ãã­ã¼ã ã®åé¿å¦ç (åä¿¡å´)
+		 *
+		 *  ã¦ã£ã³ãã¦ãµã¤ãºããã«ãµã¤ãºã® 2 åã®ã»ã°ã¡ã³ãããããã¯
+		 *  åä¿¡ãããã¡å®¹éã® 1/2 ã®ãããããå°ããã»ãã®
+		 *  ãµã¤ãºã§å¢å ãããå ´åã¯ãã¦ã£ã³ãã¦ãµã¤ãºã®æ´æ°ãè¡ãã
+		 */
+		if (win > 0) {
+			long adv;
+
+			/*
+			 *  win:              åä¿¡ãããã¡ã®ç©ºãå®¹é
+			 *  MAX_TCP_WIN_SIZE: TCP ãããã® win ãã£ã¼ã«ãã«è¨­å®ã§ããæå¤§å¤
+			 *  rcv_adv:          åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ
+			 *  rcv_nxt:          åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ
+			 */
+			if (win < MAX_TCP_WIN_SIZE)
+				adv = win - (cep->rcv_adv - cep->rcv_nxt);
+			else
+				adv = MAX_TCP_WIN_SIZE - (cep->rcv_adv - cep->rcv_nxt);
+
+			if (adv     >= (long)(cep->maxseg * 2) ||
+			    adv * 2 >= (long) cep->rbufsz) {
+				error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+				continue;
+				}
+			}
+	
+		/*
+		 *  ACK ãéä¿¡ããã
+		 */
+		if (cep->flags & TCP_CEP_FLG_ACK_NOW) {
+			error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+			continue;
+			}
+
+		if ( (flags & TCP_FLG_RST) ||
+		    ((flags & TCP_FLG_SYN) && (cep->flags & TCP_CEP_FLG_NEED_SYN) == 0)) {
+			error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+			continue;
+			}
+
+#ifdef TCP_CFG_EXTENTIONS
+
+		if (SEQ_GT(cep->snd_up, cep->snd_una)) {
+			error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+			continue;
+			}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+		/*
+		 *  snd_nxt: æ¬¡ã«éä¿¡ãã SEQ
+		 *  snd_una: æªç¢ºèªã®æå°éä¿¡ SEQãã¾ãã¯ç¢ºèªãããæå¤§éä¿¡ SEQ
+		 *
+		 *  ç¸æãã FIN ãåä¿¡ããã¾ã  FIN ãéä¿¡ãã¦ããªããã
+		 *  éããã¼ã¿ããªãã¨ãã¯ãFIN ãç¸æã«å±ããããã
+		 *  ã»ã°ã¡ã³ããéä¿¡ããã
+		 */
+		if ((flags & TCP_FLG_FIN) &&
+		    ((cep->flags & TCP_CEP_FLG_SENT_FIN) == 0 || cep->snd_nxt == cep->snd_una)) {
+			error = send_segment(&sendalot, cep, doff, win, (uint_t)len, flags);
+			continue;
+			}
+
+		/*
+		 *  éä¿¡ãã¹ããã¼ã¿ããããåéã¿ã¤ãã¨æç¶ã¿ã¤ããåãã¦ããã¨ãã¯
+		 *  æç¶ã¿ã¤ããè¨­å®ããã
+		 */
+		if (cep->swbuf_count && cep->timer[TCP_TIM_REXMT  ] == 0 &&
+		                        cep->timer[TCP_TIM_PERSIST] == 0) {
+			cep->rxtshift = 0;
+			tcp_set_persist_timer(cep);
+			break;
+			}
+		
+		}
+	}
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+/*
+ *  tcptsk_alloc_swbufq -- éä¿¡ã¦ã£ã³ããããã¡å²ãå½ã¦
+ */
+
+static void
+tcptsk_alloc_swbufq (T_TCP_CEP *cep)
+{
+ 	ER	error;
+	uint_t	win;
+
+	/*
+	 *  snd_wnd:  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
+	 *  snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº
+	 *
+	 *  win: ã©ã¡ããå°ããã¦ã£ã³ããµã¤ãºã«è¨­å®ããã
+	 */
+	win = cep->snd_wnd < cep->snd_cwnd ? cep->snd_wnd : cep->snd_cwnd;
+
+	/*
+	 *  ç¸æã®åä¿¡ã¦ã£ã³ããéãã¦ããå ´åã¯ãéãã¾ã§å¾
+æ©ããã
+	 */
+	if (win == 0) {
+		cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_WOPEN_PEND;
+		}
+	else {
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+		if (!IS_PTR_DEFINED(cep->callback)) {
+			syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+			/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+			cep->snd_tskid = TA_NULL;
+			cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+			return;
+			}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
+		                             (uint_t)TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
+		                             (uint_t)TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
+		                             (ATR)(NBA_SEARCH_DESCENT |
+		                                   NBA_RESERVE_TCP    |
+		                                   (GET_TCP_CEPID(cep) & NBA_ID_MASK)), TMO_POL)) != E_OK) {
+
+			/* ãããã¯ã¼ã¯ãããã¡ãäºç´ããã*/
+			cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_NBUF_PEND;
+			}
+		else {
+
+			/* éä¿¡ã¦ã£ã³ããããã¡ãåæåããã*/
+			tcp_init_swbuf(cep);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			if (cep->snd_nblk_tfn == TFN_TCP_GET_BUF) {
+
+				uint_t len;
+
+				/* éä¿¡ã¦ã£ã³ããããã¡ã®æ¸ãè¾¼ã¿ã¢ãã¬ã¹ãè¨­å®ããã*/
+				len = TCP_GET_SWBUF_ADDR(cep, cep->snd_p_buf);
+
+				/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
+#endif
+
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->snd_tskid = TA_NULL;
+				cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+			else {	/* cep->snd_nblk_tfn == TFN_TCP_SND_DAT || */
+				/* cep->snd_nblk_tfn == TFN_TCP_SND_OOB    */
+
+				uint_t len;
+
+				/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+				len = TCP_WRITE_SWBUF(cep, cep->snd_data, (uint_t)cep->snd_len);
+
+#ifdef TCP_CFG_EXTENTIONS
+
+				/* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨­å®ããã*/
+			        if (cep->snd_nblk_tfn == TFN_TCP_SND_OOB)
+					cep->snd_up = cep->snd_una + len;
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+				/* ãã©ã°ããéä¿¡å¯è½ã«è¨­å®ããå¼·å¶çã«éä¿¡ããã*/
+				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT;
+
+				/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
+#endif
+
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->snd_tskid = TA_NULL;
+				cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			}
+		}
+	}
+
+/*
+ *  tcptsk_free_swbufq -- éä¿¡ã¦ã£ã³ããããã¡éæ¾
+ */
+
+static void
+tcptsk_free_swbufq (T_TCP_CEP *cep)
+{
+	/*
+	 *  åä¿¡ç¢ºèªãå®äºãããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããã®
+	 *  åºåãå®äºããã¨ãã¯ãéä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ãè§£æ¾ããã
+	 */
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãºããªã»ããããã*/
+	cep->swbuf_count = 0;
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+	syscall(rel_net_buf(cep->swbufq));
+	cep->swbufq = NULL;
+
+	/* ãã©ã°ãç©ºãã«è¨­å®ããã*/
+	cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_FREE;
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããã§ãããã¨ãç¥ãããã*/
+	syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãå¾
+ã¡ã®ã¨ãã¯ãTCP åºåã¿ã¹ã¯ãèµ·åããã*/
+	if ((cep->flags & TCP_CEP_FLG_WBCS_NBUF_REQ) != 0) {
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+/*
+ *  TCP åºåã¿ã¹ã¯
+ */
+
+void
+tcp_output_task (intptr_t exinf)
+{
+	static int_t last_ix = 0;
+
+	T_TCP_CEP	*cep;
+	ID		tskid;
+ 	int_t		ix, sel_ix;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[TCP OUTPUT:%d] started.", tskid);
+
+	tcp_init();
+
+#ifdef _IP6_CFG
+
+	/* IPv6 ã®ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®ãå®è¡ããã*/
+	in6_if_up(IF_GET_IFNET());
+
+#endif	/* of #ifdef _IP6_CFG */
+
+	while (true) {
+
+		/* åºåããã¹ããããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_TCP_POST_OUTPUT));
+
+		if (++ last_ix == tmax_tcp_cepid)
+			last_ix = 0;
+		sel_ix = ix = last_ix;
+		do {
+			cep = &tcp_cep[ix];
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+			if ((cep->flags & TCP_CEP_FLG_WBCS_NBUF_REQ) != 0 &&
+			    ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_FREE ||
+			     (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_RSVD)) {
+				tcptsk_alloc_swbufq(cep);
+				sel_ix = ix;
+				}
+
+			if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_ACKED &&
+			    (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) == 0) {
+				tcptsk_free_swbufq(cep);
+				sel_ix = ix;
+				}
+
+			/*
+			 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããéä¿¡ãçµãã£ã¦ããªãã¨ãã¯ã
+			 *  éä¿¡ãäºç´ããã
+			 */
+			if (cep->flags & TCP_CEP_FLG_POST_OUTPUT &&
+			   (cep->flags & TCP_CEP_FLG_WBCS_MASK) >= TCP_CEP_FLG_WBCS_SENT) {
+				syscall(wai_sem(cep->semid_lock));
+				if (cep->swbufq == NULL)
+					cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
+				else if (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) {
+					cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
+					cep->flags |=  TCP_CEP_FLG_RESERVE_OUTPUT;
+					}
+				syscall(sig_sem(cep->semid_lock));
+				}
+
+			/*
+			 *  éä¿¡äºç´ä¸­ã«ããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããéä¿¡ãçµäºãããã
+			 *  éä¿¡ãéå§ããããã ããå®å
+¨ã«éä¿¡ãçµäºããã¨ãã¯ä½ãããªãã
+			 */
+			if (cep->flags & TCP_CEP_FLG_RESERVE_OUTPUT) {
+				syscall(wai_sem(cep->semid_lock));
+				if (cep->swbufq != NULL && (cep->swbufq->flags & NB_FLG_NOREL_IFOUT) == 0) {
+					cep->flags |=  TCP_CEP_FLG_POST_OUTPUT;
+					}
+				syscall(sig_sem(cep->semid_lock));
+				cep->flags &= ~TCP_CEP_FLG_RESERVE_OUTPUT;
+				}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+			if (cep->flags & TCP_CEP_FLG_POST_OUTPUT) {
+
+				cep->flags &= ~TCP_CEP_FLG_POST_OUTPUT;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+				if (cep->snd_nblk_tfn == TFN_TCP_CON_CEP && cep->myaddr.portno == TCP_PORTANY) {
+				 	ER	error;
+
+					/*
+					 *  tcp_con_cep ã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ã
+					 *  æªå²å½ã®ã®å ´åã¯ããã¼ãçªå·ãå²ãå½ã¦ãã
+					 *  p_myaddr ã NADR (-1) ãã
+					 *  èªãã¼ãçªå·ã TCP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+					 */
+					if (cep->p_myaddr == NADR || cep->p_myaddr->portno == TCP_PORTANY)
+						tcp_alloc_auto_port(cep);
+					else if ((error = tcp_alloc_port(cep, cep->p_myaddr->portno)) != E_OK) {
+
+						if (IS_PTR_DEFINED(cep->callback))
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+							(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
+#else
+							(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
+#endif
+						else
+							syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+						/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+						cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+						cep->snd_tskid = TA_NULL;
+						continue;
+						}
+					}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+				tcp_output(cep);
+
+				if (cep->flags & TCP_CEP_FLG_CLOSE_AFTER_OUTPUT) {
+					/* ã³ãã¯ã·ã§ã³ãéããã*/
+					tcp_close(cep);
+					cep->flags &= ~TCP_CEP_FLG_CLOSE_AFTER_OUTPUT;
+					}
+
+				if (cep->flags & TCP_CEP_FLG_RESTORE_NEXT_OUTPUT) {
+					/* snd_nxt ãå
+ã«æ»ãã*/
+					if (SEQ_GT(cep->snd_old_nxt, cep->snd_nxt))
+						cep->snd_nxt = cep->snd_old_nxt;
+					cep->flags &= ~TCP_CEP_FLG_RESTORE_NEXT_OUTPUT;
+					}
+
+				sel_ix = ix;
+				}
+
+			if (++ ix == tmax_tcp_cepid)
+				ix = 0;
+			} while (ix != last_ix);
+
+		/* æ¬¡åã¯ãå¦çããéä¿¡ç«¯ç¹ãå¾åãã«ããã*/
+		last_ix = sel_ix;
+		}
+	}
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_seq.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_seq.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_seq.h	(revision 317)
@@ -0,0 +1,135 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_seq.h	8.3 (Berkeley) 6/21/95
+ * $FreeBSD: src/sys/netinet/tcp_seq.h,v 1.8.4.1 1999/08/29 16:29:55 peter Exp $
+ */
+ 
+#ifndef _TCP_SEQ_H_
+#define _TCP_SEQ_H_
+
+/*
+ *  SEQ ã¨ ACK çªå·ã¯ã32 ãããç¬¦å·ä»æ´æ°ã§æ¯è¼ããã
+ */
+
+#define SEQ_LT(a,b)		((int32_t)((a)-(b)) <  0)
+#define SEQ_LE(a,b)		((int32_t)((a)-(b)) <= 0)
+#define SEQ_GT(a,b)		((int32_t)((a)-(b)) >  0)
+#define SEQ_GE(a,b)		((int32_t)((a)-(b)) >= 0)
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define	TCP_ISS_INCR()	((T_TCP_SEQ)122*1024 + (((T_TCP_SEQ)net_rand() >> 14) & 0x3ffff))
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+extern T_TCP_SEQ tcp_iss;		/* TCP ã® SEQ ã®åæå¤ */
+
+/*
+ *  ã¤ã³ã©ã¤ã³é¢æ°
+ */
+
+/*
+ *  init_receive_seq -- åä¿¡ SEQ çªå·ãåæåããã
+ */
+
+Inline void
+init_receive_seq (T_TCP_CEP *cep)
+{
+	cep->rcv_adv = cep->rcv_nxt = cep->irs + 1;
+	}
+
+/*
+ *  init_send_seq -- éä¿¡ SEQ çªå·ãåæåããã
+ */
+
+Inline void
+init_send_seq (T_TCP_CEP *cep)
+{
+	cep->snd_una = cep->snd_nxt = cep->snd_max = cep->iss;
+
+#ifdef TCP_CFG_EXTENTIONS
+	cep->snd_up = cep->iss;
+#endif
+	}
+
+#endif	/* of #ifndef _TCP_SEQ_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_subr.c	(revision 317)
@@ -0,0 +1,1988 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_subr.c	8.2 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.49.2.4 1999/08/29 16:29:55 peter Exp $
+ */
+
+#include <stdarg.h>
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <syssvc/serial.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/*
+ *  TCP ã® SEQ ã®åæå¤ããã­ã°ã©ã ãèµ·åãã¦ãæåã« TCP ã»ã°ã¡ã³ãã
+ *  éåä¿¡ããã¨ãã«ãget_tim() ã«ããåæåããã
+ */
+T_TCP_SEQ tcp_iss = 0;
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+T_TCP_STATS tcp_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  å±æå¤æ°
+ */
+
+static uint16_t tcp_port_auto = TCP_PORT_FIRST_AUTO;	/* èªåå²ãå½ã¦çªå·	*/
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+/*
+ *  ã¿ã¹ã¯ããã® Time Wait ç¶æ
+ CEP åé¢æ©è½
+ */
+
+/*
+ *  å¤æ°
+ */
+
+T_TCP_TWCEP tcp_twcep[NUM_TCP_TW_CEP_ENTRY];
+
+/*
+ *  tcp_move_twcep -- å¿
+è¦ãªæ
+å ±ã Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã«ç§»ãã¦ã
+ *                    æ¨æºã® TCP éä¿¡ç«¯ç¹ãéæ¾ããã
+ */
+
+void
+tcp_move_twcep (T_TCP_CEP *cep)
+{
+	T_TCP_TWCEP*	twcep;
+
+	/* ç©ºãã® Time Wait ç¨ TCP éä¿¡ç«¯ç¹ãæ¢ç´¢ããã*/
+	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
+		if (twcep->fsm_state != TCP_FSM_TIME_WAIT) {
+
+			/*
+			 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+			 *  å¿
+è¦ãªæ
+å ±ã Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã«ç§»ãã
+			 */
+			syscall(wai_sem(cep->semid_lock));
+			twcep->flags		= (uint8_t)cep->flags;
+			twcep->rbufsz		= cep->rbufsz;
+			twcep->dstaddr		= cep->dstaddr;
+			twcep->myaddr		= cep->myaddr;
+			twcep->snd_una		= cep->snd_una;
+			twcep->rcv_nxt		= cep->rcv_nxt;
+			twcep->rwbuf_count	= cep->rwbuf_count;
+			twcep->fsm_state	= cep->fsm_state;
+			twcep->timer_2msl	= cep->timer[TCP_TIM_2MSL];
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* æ¨æº TCP éä¿¡ç«¯ç¹ãéæ¾ããã*/
+			tcp_close(cep);
+
+			break;
+			}
+		}
+	}
+
+/*
+ *  tcp_find_twcep -- ãã¼ãçªå·ãã Time Wait ç¨ TCP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+T_TCP_TWCEP*
+tcp_find_twcep (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_TWCEP*	twcep;
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+	
+	/*
+	 *  ç¶æ
+ã TIME WAIT ã§ã
+	 *  IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ãä¸è´ããéä¿¡ç«¯ç¹ãæ¢ç´¢ããã
+	 */
+	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; ) {
+		if (twcep->fsm_state == TCP_FSM_TIME_WAIT                   &&
+		    IN_IS_DSTADDR_ACCEPT    (&twcep->myaddr.ipaddr,  input) &&
+		    IN_ARE_NET_SRCADDR_EQUAL(&twcep->dstaddr.ipaddr, input) &&
+		    tcph->dport == twcep->myaddr.portno                     &&
+		    tcph->sport == twcep->dstaddr.portno)
+			return twcep;
+		}
+
+	return NULL;
+	}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+/*
+ *  tcp_find_cep -- ãã¼ãçªå·ãã TCP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+T_TCP_CEP*
+tcp_find_cep (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_CEP*	cep;
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+	
+	/*
+	 *  ç¶æ
+ã SYN éä¿¡æ¸ã¿ä»¥å¾ã¯ã
+	 *  IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ãä¸è´ãã TCP éä¿¡ç«¯ç¹ãæ¢ç´¢ããã
+	 */
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+		if (cep->fsm_state >= TCP_FSM_SYN_SENT                    &&
+		    IN_IS_DSTADDR_ACCEPT    (&cep->myaddr.ipaddr,  input) &&
+		    IN_ARE_NET_SRCADDR_EQUAL(&cep->dstaddr.ipaddr, input) &&
+		    tcph->dport == cep->myaddr.portno                     &&
+		    tcph->sport == cep->dstaddr.portno)
+			return cep;
+		}
+
+	/* IPv4 ã§ååãªã¼ãã³ä¸­ã® TCP éä¿¡ç«¯ç¹ãå
+ã«æ¢ç´¢ããã*/	
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+		if ((cep->flags & TCP_CEP_FLG_IPV4)                   &&
+		     cep->fsm_state == TCP_FSM_LISTEN                 &&
+		     GET_IP_VER(input) == IPV4_VERSION                &&
+		     IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		     tcph->dport == cep->myaddr.portno)
+			return cep;
+		}
+
+	/* ååãªã¼ãã³ä¸­ã® TCP éä¿¡ç«¯ç¹ãæ¢ç´¢ããã*/	
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+
+		if (cep->flags & TCP_CEP_FLG_IPV4) {
+			if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+		            GET_IP_VER(input) == IPV4_VERSION                &&
+			    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+			}
+		else {
+
+#if defined(API_CFG_IP4MAPPED_ADDR)
+
+			if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+			    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+
+#else	/* of #if defined(API_CFG_IP4MAPPED_ADDR) */
+
+			if (cep->fsm_state == TCP_FSM_LISTEN                   &&
+			    INN6_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+			    tcph->dport == cep->myaddr.portno)
+				return cep;
+
+#endif	/* of #if defined(API_CFG_IP4MAPPED_ADDR) */
+
+			}
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+		if (cep->fsm_state == TCP_FSM_LISTEN                 &&
+		    IN_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		    tcph->dport == cep->myaddr.portno)
+			return cep;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
+		}
+
+	return NULL;
+	}
+
+/*
+ *  tcp_is_addr_accept -- åä¿¡å¯è½ãª IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ã§ãããã¨ãç¢ºèªããã
+ */
+
+bool_t
+tcp_is_addr_accept (T_NET_BUF *input, uint_t off)
+{
+	T_TCP_HDR	*tcph;
+
+	tcph = GET_TCP_HDR(input, off);
+
+#if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP)
+
+	/*
+	 *  æ¬¡ã®ã¨ãã¯ç ´æ£ããã
+	 *    ã»ãã¼ãçªå·ãåä¸ã§ãéåä¿¡ IP ã¢ãã¬ã¹ ãåä¸ã
+	 *      ãã ããéä¿¡å
+ IP ã¢ãã¬ã¹ãã­ã¼ã«ã«ã«ã¼ãããã¯ãªãè¯ãã
+	 *    ã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹
+	 */
+
+	if (tcph->dport == tcph->sport && 
+	    (IN4_ARE_HDR_ADDR_EQUAL(input) && !IN4_ARE_NET_ADDR_EQUAL(&GET_IP4_HDR(input)->dst, &IPV4_ADDR_LOOPBACK)))
+		return RET_DROP;
+
+#else	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
+
+	/*
+	 *  æ¬¡ã®ã¨ãã¯ãåä¿¡å¯è½ã§ã¯ãªãã
+	 *    ã»ãã¼ãçªå·ãåä¸ã§ãéåä¿¡ IP ã¢ãã¬ã¹ ãåä¸ã
+	 *    ã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹
+	 */
+	if (tcph->dport == tcph->sport && IN_ARE_HDR_ADDR_EQUAL(input))
+		return false;
+
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) && defined(SUPPORT_LOOP) */
+
+	if (IN_IS_NET_ADDR_MULTICAST(input))
+		return false;
+	else
+		return true;
+	}
+
+/*
+ *  tcp_free_reassq -- åä¿¡åæ§æã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+ *
+ *    æ³¨æ:
+ *      å¿
+è¦ã§ããã°ããã®é¢æ°ãå¼ã³åºãåã«ãéä¿¡ç«¯ç¹ãã­ãã¯ãã
+ *      æ»ã£ãå¾ãè§£é¤ããå¿
+è¦ãããã
+ */
+
+void
+tcp_free_reassq (T_TCP_CEP *cep)
+{
+	T_NET_BUF	*q, *nq;
+
+	for (q = cep->reassq; q != NULL; q = nq) {
+		nq = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q))->next;
+		syscall(rel_net_buf(q));
+		}
+	cep->reassq  = NULL;
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_FREE_RCV_QUEUE],   1);
+	}
+
+/*
+ *  tcp_alloc_auto_port -- èªåå²ãå½ã¦ãã¼ãçªå·ãè¨­å®ããã
+ */
+
+void
+tcp_alloc_auto_port (T_TCP_CEP *cep)
+{
+	int_t		ix;
+	uint16_t	portno;
+
+	while (true) {
+		portno = tcp_port_auto ++;
+		if (tcp_port_auto > TCP_PORT_LAST_AUTO)
+			tcp_port_auto = TCP_PORT_FIRST_AUTO;
+
+#if defined(TNUM_TCP6_REPID)
+#if TNUM_TCP6_REPID > 0
+
+		for (ix = tmax_tcp6_repid; ix -- > 0; ) {
+
+#ifdef TCP_CFG_EXTENTIONS
+
+			if (VALID_TCP_REP(&tcp6_rep[ix]) && tcp6_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			if (tcp6_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			}
+
+#endif	/* of #if TNUM_TCP6_REPID > 0 */
+#endif	/* of #if defined(TNUM_TCP6_REPID) */
+
+#if defined(TNUM_TCP4_REPID)
+#if TNUM_TCP4_REPID > 0
+
+		for (ix = tmax_tcp4_repid; ix -- > 0; ) {
+
+#ifdef TCP_CFG_EXTENTIONS
+
+			if (VALID_TCP_REP(&tcp4_rep[ix]) && tcp4_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			if (tcp4_rep[ix].myaddr.portno == portno) {
+				portno = TCP_PORTANY;
+				break;
+				}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+			}
+
+#endif	/* of #if TNUM_TCP4_REPID > 0 */
+#endif	/* of #if defined(TNUM_TCP4_REPID) */
+
+		if (portno != TCP_PORTANY) {
+
+			syscall(wai_sem(SEM_TCP_CEP));
+			for (ix = tmax_tcp_cepid; ix -- > 0; ) {
+				if (VALID_TCP_CEP(&tcp_cep[ix]) && tcp_cep[ix].myaddr.portno == portno) {
+					portno = TCP_PORTANY;
+					break;
+					}
+				}
+
+			if (portno != TCP_PORTANY) {
+				cep->myaddr.portno = portno;
+				syscall(sig_sem(SEM_TCP_CEP));
+				return;
+				}
+			syscall(sig_sem(SEM_TCP_CEP));
+			}
+		}
+	}
+
+/*
+ *  tcp_alloc_port -- æå®ããããã¼ãçªå·ãè¨­å®ããã
+ */
+
+ER
+tcp_alloc_port (T_TCP_CEP *cep, uint16_t portno)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_TCP_CEP));
+	for (ix = tmax_tcp_cepid; ix -- > 0; )
+		if (VALID_TCP_CEP(cep) && tcp_cep[ix].myaddr.portno == portno) {
+			syscall(sig_sem(SEM_TCP_CEP));
+			return E_PAR;
+			}
+	cep->myaddr.portno = portno;
+	syscall(sig_sem(SEM_TCP_CEP));
+	return E_OK;
+	}
+
+/*
+ *  tcp_init -- TCP ã¢ã¸ã¥ã¼ã«ã®åæå
+ */
+
+void
+tcp_init (void)
+{
+	timeout(tcp_slow_timo, NULL, TCP_SLOW_TMO);
+
+#ifdef TCP_CFG_DELAY_ACK
+
+	timeout(tcp_fast_timo, NULL, TCP_FAST_TMO);
+
+#endif/* of #ifdef TCP_CFG_DELAY_ACK */
+	}
+
+/*
+ * tcp_init_iss ã·ã¼ã±ã³ã¹çªå·ãåæåããã
+ */
+
+void
+tcp_init_iss (void)
+{
+	SYSTIM now;
+
+	syscall(get_tim(&now));
+	net_srand(now);
+	tcp_iss = net_rand();
+	}
+
+/*
+ *  tcp_close -- ã³ãã¯ã·ã§ã³ãéæ¾ããã
+ */
+
+T_TCP_CEP *
+tcp_close (T_TCP_CEP *cep)
+{
+	/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+	tcp_cancel_timers(cep);
+
+	/* 
+	 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+	 *  åä¿¡åæ§æã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+	 */
+	syscall(wai_sem(cep->semid_lock));
+	tcp_free_reassq(cep);
+	syscall(sig_sem(cep->semid_lock));
+
+	/* ç¶æ
+ãæªä½¿ç¨ã«ããã*/
+	cep->fsm_state = TCP_FSM_CLOSED;
+
+	/*
+	 * ä»¥ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
+	 * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+	 * ã»åçãªéä¿¡ç«¯ç¹ã®çæã»åé¤æ©è½
+	 * ã»éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«
+	 */
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	if (cep->snd_nblk_tfn != TFN_TCP_UNDEF || cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+		if (!IS_PTR_DEFINED(cep->callback))
+			syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+		else {
+			if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
+				ER_UINT len;
+
+				switch (cep->rcv_nblk_tfn) {
+
+				case TFN_TCP_ACP_CEP:
+					/* TCP éä¿¡ç«¯ç¹ããTCP åä»å£ãè§£æ¾ããã*/
+					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_CLS);
+					break;
+
+				case TFN_TCP_RCV_BUF:
+
+					/* åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
+					len = TCP_GET_RWBUF_ADDR(cep, cep->rcv_p_buf);
+
+					/* ç°å¸¸åæ­ç­ã®ã¨ã©ã¼ãè¨­å®ããã*/
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else if (cep->error < 0)
+						len = cep->error;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
+					break;
+
+				case TFN_TCP_RCV_DAT:
+
+					/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+					len = TCP_READ_RWBUF(cep, cep->rcv_data, (uint_t)cep->rcv_len);
+
+					/* ç°å¸¸åæ­ç­ã®ã¨ã©ã¼ãè¨­å®ããã*/
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else if (cep->error != E_OK)
+						len = cep->error;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
+					break;
+
+				case TFN_TCP_CLS_CEP:
+
+					if (cep->error == E_TMOUT)
+						(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_CLS);
+					else
+						(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)cep->error);
+					break;
+
+				default:
+					syslog(LOG_WARNING, "[TCP] unexp TFN: %s.", in_strtfn((FN)cep->rcv_nblk_tfn));
+					break;
+					}
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->rcv_tskid = TA_NULL;
+				cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+			if (cep->snd_nblk_tfn != TFN_TCP_UNDEF) {
+
+				switch (cep->snd_nblk_tfn) {
+
+				case TFN_TCP_CON_CEP:
+					/* TCP éä¿¡ç«¯ç¹ãã TCP åä»å£ãè§£æ¾ããã*/
+					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_CLS);
+					break;
+
+				case TFN_TCP_SND_DAT:
+				case TFN_TCP_GET_BUF:
+					if (cep->error == E_TMOUT)
+						(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_CLS);
+					else
+						(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)cep->error);
+					break;
+
+				default:
+					syslog(LOG_WARNING, "[TCP] unexp TFN: %s.", in_strtfn((FN)cep->snd_nblk_tfn));
+					break;
+					}
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->snd_tskid = TA_NULL;
+				cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+			}
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		if (!IS_PTR_DEFINED(cep->callback))
+			syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+		else {
+			if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
+				ER_UINT len;
+
+				switch (cep->rcv_nblk_tfn) {
+
+				case TFN_TCP_ACP_CEP:
+
+					/* TCP éä¿¡ç«¯ç¹ããTCP åä»å£ãè§£æ¾ããã*/
+					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					/* æ¥ç¶ã¨ã©ã¼ãè¨­å®ããã*/
+					len      = E_CLS;
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+					break;
+
+				case TFN_TCP_RCV_BUF:
+
+					/* åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
+					len = TCP_GET_RWBUF_ADDR(cep, cep->rcv_p_buf);
+
+					/* ç°å¸¸åæ­ç­ã®ã¨ã©ã¼ãè¨­å®ããã*/
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else if (cep->error < 0)
+						len = cep->error;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+					break;
+
+				case TFN_TCP_RCV_DAT:
+
+					/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+					len = TCP_READ_RWBUF(cep, cep->rcv_data, (uint_t)cep->rcv_len);
+
+					/* ç°å¸¸åæ­ç­ã®ã¨ã©ã¼ãè¨­å®ããã*/
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else if (cep->error != E_OK)
+						len = cep->error;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+					break;
+
+				case TFN_TCP_CLS_CEP:
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else
+						len = cep->error;
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+					break;
+
+				default:
+					syslog(LOG_WARNING, "[TCP] unexp TFN: %s.", in_strtfn((FN)cep->rcv_nblk_tfn));
+					break;
+					}
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->rcv_tskid = TA_NULL;
+				cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+			if (cep->snd_nblk_tfn != TFN_TCP_UNDEF) {
+				ER_UINT len;
+
+				switch (cep->snd_nblk_tfn) {
+
+				case TFN_TCP_CON_CEP:
+
+					/* TCP éä¿¡ç«¯ç¹ããTCP åä»å£ãè§£æ¾ããã*/
+					cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+					cep->rep4 = NULL;
+#endif
+
+					/* æ¥ç¶ã¨ã©ã¼ãè¨­å®ããã*/
+					len      = E_CLS;
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
+					break;
+
+				case TFN_TCP_SND_DAT:
+				case TFN_TCP_GET_BUF:
+					if (cep->error == E_TMOUT)
+						len = E_CLS;
+					else
+						len = cep->error;
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+					break;
+
+				default:
+					syslog(LOG_WARNING, "[TCP] unexp TFN: %s.", in_strtfn((FN)cep->snd_nblk_tfn));
+					break;
+					}
+
+				/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+				cep->snd_tskid = TA_NULL;
+				cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+			}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		/* 
+		 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+		 *  éåä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+		 */
+		syscall(wai_sem(cep->semid_lock));
+		TCP_FREE_RWBUFQ(cep);
+		TCP_FREE_SWBUFQ(cep);
+		syscall(sig_sem(cep->semid_lock));
+
+		/* æªä½¿ç¨ã«ãªã£ããã¨ãç¥ãããã*/
+		syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+		}
+	else {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->snd_tskid = cep->rcv_tskid = TA_NULL;
+		cep->snd_tfn   = cep->rcv_tfn   = TFN_TCP_UNDEF;
+
+		/* 
+		 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+		 *  éåä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+		 */
+		syscall(wai_sem(cep->semid_lock));
+		TCP_FREE_RWBUFQ(cep);
+		TCP_FREE_SWBUFQ(cep);
+		syscall(sig_sem(cep->semid_lock));
+
+		/* æªä½¿ç¨ã«ãªã£ããã¨ãç¥ãããã*/
+		syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+
+		/*
+		 * å
+¥åºåã¿ã¹ã¯ãèµ·åºãã¦ã
+		 * éåä¿¡ä¸å¯ã«ãªã£ããã¨ãç¥ãããã
+		 */
+		syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+		syscall(set_flg(cep->rcv_flgid, TCP_CEP_EVT_RWBUF_READY));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	return NULL;
+	}
+
+/*
+ *  tcp_drop -- TCP æ¥ç¶ãç ´æ£ããã
+ */
+
+T_TCP_CEP *
+tcp_drop (T_TCP_CEP *cep, ER errno)
+{
+#ifdef SUPPORT_MIB
+
+	if ((cep->fsm_state == TCP_FSM_SYN_SENT) || (cep->fsm_state == TCP_FSM_SYN_RECVD)) {
+		NET_COUNT_MIB(tcp_stats.tcpAttemptFails, 1);
+		}
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+	cep->error = errno;
+	if (TCP_FSM_HAVE_RCVD_SYN(cep->fsm_state)) {
+		cep->fsm_state = TCP_FSM_CLOSED;
+
+		/* éä¿¡ã¨ãéä¿¡å¾ã³ãã¯ã·ã§ã³ã®åæ­ãæç¤ºããã*/
+		cep->flags |=  TCP_CEP_FLG_POST_OUTPUT | TCP_CEP_FLG_CLOSE_AFTER_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	else {
+		cep = tcp_close(cep);
+		}
+	return cep;
+	}
+
+/*
+ *  tcp_respond -- TCP ã®åä¸ã¡ãã»ã¼ã¸ãéä¿¡ããã
+ */
+
+void
+tcp_respond (T_NET_BUF *output, T_TCP_CEP *cep,
+             T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags)
+{
+	T_TCP_HDR	*tcph;
+	uint_t		win = 0;
+	uint_t		hdr_offset;
+
+	if ((flags & TCP_FLG_RST) == 0)
+		win = rbfree;
+
+	/*
+	 *  output ã NULL ã§ãªããã°ãããã¯å
+¥åããã»ã°ã¡ã³ãã®
+	 *  net_buf ã§ããã®ã¾ã¾åå©ç¨ããã
+	 */
+	if (output != NULL) {
+		uint16_t	portno;
+
+		/*
+		 * IPv4 ã§ã¯ãIP ãããã®ãªãã·ã§ã³ãåé¤ããã
+		 * IPv6 ã§ã¯ãæ¡å¼µããããåé¤ããã
+		 */
+		if (IP_REMOVE_OPTIONS(output) != E_OK) {
+			syscall(rel_net_buf(output));
+			return;
+			}
+
+		ip_exchg_addr(output);
+
+#if defined(_IP6_CFG)
+
+		/* ãã©ããã¯ã¯ã©ã¹ã¨ãã­ã¼ã©ãã«ãã¯ãªã¢ããã*/
+		SET_IP_CF(output, 0);
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+		/* TCP SDU é·ã 0 ã«ããã*/
+		SET_IP_SDU_SIZE(output, TCP_HDR_SIZE);
+
+		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
+
+		/* ãã¼ãçªå·ãäº¤æããã*/
+		portno = tcph->sport;
+		tcph->sport = tcph->dport;
+		tcph->dport = portno;
+
+		/* TCP ãããã«æ
+å ±ãè¨­å®ããã*/
+		tcph->doff = TCP_MAKE_DATA_OFF(TCP_HDR_SIZE);
+		}
+	
+	/* cep ã NULL ã§ããã°ãä½ãããªãã§çµäºããã*/
+	else if (cep == NULL)
+		return;
+	else {
+		if (tcpn_get_segment(&output, cep, 0,
+		                    0, (uint_t)net_buf_max_siz(),
+		                    NBA_SEARCH_ASCENT, TMO_TCP_GET_NET_BUF) != E_OK)
+			return;
+		tcph = GET_TCP_HDR(output, IF_IP_TCP_HDR_OFFSET(output));
+		flags |= TCP_FLG_ACK;
+		}
+
+	tcph->seq   = htonl(seq);
+	tcph->ack   = htonl(ack);
+	tcph->win   = htons(win);
+	tcph->flags = flags;
+	tcph->urp   = tcph->sum = 0;
+
+	/*
+	 *  ãã§ãã¯ãµã ãè¨­å®ããã
+	 */
+	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
+	tcph->sum = IN_CKSUM(output, IPPROTO_TCP, hdr_offset, 
+	                     (uint_t)GET_TCP_HDR_SIZE(output, hdr_offset));
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)GET_IF_IP_TCP_HDR_SIZE(output, hdr_offset);
+
+#ifdef TCP_CFG_TRACE
+
+	tcp_output_trace(output, cep);
+
+#endif	/* of #ifdef TCP_CFG_TRACE */
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	IP_OUTPUT(output, TMO_TCP_OUTPUT);
+	}
+#if 0
+/*
+ *  tcp_get_segment -- TCP ã»ã°ã¡ã³ããç²å¾ããããããè¨­å®ããã
+ *
+ *    æ»ãå¤	ã¨ã©ã¼ã³ã¼ã
+ *    optlen	ãªãã·ã§ã³ãµã¤ãºã4 ãªã¯ãããåä½
+ *    maxlen	æå¤§ã»ã°ã¡ã³ããµã¤ãºï¼IF/IP/TCP ããããµã¤ãºãå«ã¾ãªãï¼
+ *    len	TCP SDU ãµã¤ãº
+ */
+
+ER
+tcp_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                 uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
+{
+	T_TCP_HDR	*tcph;
+	ER		error;
+
+	/* IP ãã¼ã¿ã°ã©ã ãç²å¾ããã*/
+	if ((error = IN_GET_DATAGRAM(nbuf,
+	                             (uint_t)(TCP_HDR_SIZE + optlen + len),
+	                             (uint_t)(TCP_HDR_SIZE + maxlen),
+	                             &cep->dstaddr.ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
+		syslog(LOG_WARNING, "[TCP] NET BUF busy, len: %d, CEP: %d.",
+		                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
+		return error;
+		}
+
+	/* TCP ãããã«æ
+å ±ãè¨­å®ããã*/
+
+	/* TCP ãããã«æ
+å ±ãè¨­å®ããã*/
+	tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
+	tcph->sport	= htons(cep->myaddr.portno);
+	tcph->dport	= htons(cep->dstaddr.portno);
+	tcph->doff	= TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
+	tcph->sum	= tcph->flags = 0;
+
+	return E_OK;
+	}
+#endif
+/*
+ *  tcpn_get_segment -- TCP ã»ã°ã¡ã³ããç²å¾ããããããè¨­å®ããã
+ *
+ *    æ»ãå¤	ã¨ã©ã¼ã³ã¼ã
+ *    optlen	ãªãã·ã§ã³ãµã¤ãºã4 ãªã¯ãããåä½
+ *    maxlen	æå¤§ã»ã°ã¡ã³ããµã¤ãºï¼IF/IP/TCP ããããµã¤ãºãå«ãï¼
+ *    len	TCP SDU ãµã¤ãº
+ */
+
+ER
+tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                 uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout)
+{
+	T_TCP_HDR	*tcph;
+	ER		error;
+
+	/* IP ãã¼ã¿ã°ã©ã ãç²å¾ããã*/
+	if ((error = IN_GET_DATAGRAM(nbuf,
+	                             (uint_t)(TCP_HDR_SIZE + optlen + len),
+	                             (uint_t)(maxlen - IF_IP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)),
+	                             &cep->dstaddr.ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_TCP, IP_DEFTTL, nbatr, tmout)) != E_OK) {
+		syslog(LOG_WARNING, "[TCP] NET BUF busy,  len:%4d, CEP: %d.",
+		                    (uint16_t)(TCP_HDR_SIZE + optlen + len), GET_TCP_CEPID(cep));
+		return error;
+		}
+
+	/* TCP ãããã«æ
+å ±ãè¨­å®ããã*/
+
+	/* TCP ãããã«æ
+å ±ãè¨­å®ããã*/
+	tcph = GET_TCP_HDR(*nbuf, IF_IP_TCP_HDR_OFFSET(*nbuf));
+	tcph->sport	= htons(cep->myaddr.portno);
+	tcph->dport	= htons(cep->dstaddr.portno);
+	tcph->doff	= TCP_MAKE_DATA_OFF(TCP_HDR_SIZE + optlen);
+	tcph->sum	= tcph->flags = 0;
+
+	return E_OK;
+	}
+
+/*
+ *  tcp_can_send_more -- éä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã
+ */
+
+ER
+tcp_can_send_more (T_TCP_CEP *cep, FN fncd, TMO tmout)
+{
+	ER	error;
+
+	/* éä¿¡ã§ããããCEP ã® FSM ç¶æ
+ãè¦ãã*/
+	if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state)) {
+		if ((error = cep->error) == E_OK)
+			error = E_OBJ;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+		if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+			if (!IS_PTR_DEFINED(cep->callback))
+				error = E_OBJ;
+			else {
+				/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
+#endif
+				error = E_WBLK;
+				}
+			}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		}
+	else {
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+		error = E_OK;
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		if (!IS_PTR_DEFINED(cep->sbuf)) {
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+			if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+				if (!IS_PTR_DEFINED(cep->callback))
+					error = E_OBJ;
+				else {
+					error = E_OBJ;
+
+					/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
+#else
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)&error);
+#endif
+					error = E_WBLK;
+					}
+				}
+			else
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+				error = E_OBJ;
+			}
+		else
+			error = E_OK;
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+		}
+
+	return error;
+	}
+
+/*
+ *  tcp_can_recv_more -- åä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã
+ *
+ *  æ³¨æ: æ»ãå¤
+ *
+ *	E_OK	åä¿¡å¯è½
+ *	E_OBJ	ç¸æããåæ­ãããããã¨ã©ã¼ãçºçããã
+ */
+
+ER
+tcp_can_recv_more (ER *error, T_TCP_CEP *cep, FN fncd, TMO tmout)
+{
+	/*
+	 *  åä¿¡ã§ããããfsm_state ãè¦ããåä¿¡ã§ããªãå ´åã¯
+	 *  é·ã 0ãã¾ãã¯ã¨ã©ã¼ãè¿ãã
+	 */
+	if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state) &&
+	    cep->rwbuf_count == 0 && cep->reassq == NULL) {
+		*error = cep->error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+		if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+			if (!IS_PTR_DEFINED(cep->callback))
+				*error = E_OBJ;
+			else {
+				/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
+#endif
+				*error = E_WBLK;
+				}
+			}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/*
+		 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+		 */
+		syscall(wai_sem(cep->semid_lock));
+		TCP_FREE_RWBUFQ(cep);
+		syscall(sig_sem(cep->semid_lock));
+
+		return E_OBJ;
+		}
+	else {
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+
+		if (!IS_PTR_DEFINED(cep->rbuf)) {
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+			if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+				if (!IS_PTR_DEFINED(cep->callback))
+					*error = E_OBJ;
+				else {
+					*error = E_OBJ;
+
+					/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)*error);
+#else
+					(*cep->callback)(GET_TCP_CEPID(cep), fncd, (void*)error);
+#endif
+					*error = E_WBLK;
+					}
+				}
+			else
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+				*error = E_OBJ;
+
+			return E_OBJ;
+			}
+
+#endif	/* of #ifndef TCP_CFG_RWBUF_CSAVE */
+
+		return E_OK;
+		}
+	}
+
+/*
+ *  tcp_wait_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãå
+¥ãã®ãå¾
+ã¤ã
+ */
+
+ER
+tcp_wait_rwbuf (T_TCP_CEP *cep, TMO tmout)
+{
+	ER	error;
+	FLGPTN	flag;
+
+	if (cep->rwbuf_count == 0) {
+		/* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ããªããã°ãå
+¥åãããã¾ã§å¾
+ã¤ã*/
+		while (cep->rwbuf_count == 0) {
+			if ((error = twai_flg(cep->rcv_flgid, TCP_CEP_EVT_RWBUF_READY, TWF_ORW, &flag, tmout)) != E_OK) {
+				return error;
+				}
+			syscall(clr_flg(cep->rcv_flgid, (FLGPTN)(~TCP_CEP_EVT_RWBUF_READY)));
+
+			/*
+			 *  åä¿¡ã§ããããfsm_state ãè¦ããåä¿¡ã§ããªãç¶æ
+ã§ã
+			 *  åä¿¡ã¦ã£ã³ããããã¡ã«æå­ããªãå ´åã¯çµäºããã
+			 */
+			if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state) &&
+			    cep->rwbuf_count == 0 && cep->reassq == NULL) {
+
+				/*
+				 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+				 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+				 */
+				syscall(wai_sem(cep->semid_lock));
+				TCP_FREE_RWBUFQ(cep);
+				syscall(sig_sem(cep->semid_lock));
+
+				return cep->error;
+				}
+			}
+		}
+	else {
+		syscall(clr_flg(cep->rcv_flgid, (FLGPTN)(~TCP_CEP_EVT_RWBUF_READY)));
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  tcp_move_ra2rw -- åä¿¡åæ§æã­ã¥ã¼ã§åæ§æããã»ã°ã¡ã³ããåä¿¡ã¦ã£ã³ããããã¡ã«æ¸ãè¾¼ãã
+ */
+
+uint8_t
+tcp_move_ra2rw (T_TCP_CEP *cep, uint8_t flags)
+{
+	T_NET_BUF	*q;
+	T_TCP_Q_HDR	*qhdr;
+
+	/*
+	 *  åä¿¡ãã¼ã¿ãåä¿¡ã¦ã£ã³ããããã¡ã«æ¸ãè¾¼ã¿ã
+	 *  rcv_nxt ãå®äºãã SEQ ã ãé²ããã
+	 */
+	if (TCP_FSM_HAVE_ESTABLISHED(cep->fsm_state)) {
+		while (cep->reassq != NULL) {
+			q = cep->reassq;
+			qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
+			if (qhdr->seq != cep->rcv_nxt)
+				break;
+
+			/* æ¬¡ã®ã»ã°ã¡ã³ãã«é²ãã*/
+			cep->reassq = qhdr->next;
+
+			/* FIN ãã©ã°ã®ã¿æ®ãã*/
+			flags &= TCP_FLG_FIN;
+
+			/* ãã¼ã¿ãåä¿¡ã¦ã£ã³ããããã¡ã«æ¸ãè¾¼ãã*/
+			TCP_WRITE_RWBUF(cep, q, (uint_t)(GET_IP_TCP_Q_HDR_OFFSET(q)));
+			}
+		}
+	if (cep->reassq != NULL) {
+		cep->flags |= TCP_CEP_FLG_ACK_NOW;
+		flags &= ~TCP_FLG_FIN;
+		}
+	return flags;
+	}
+
+/*
+ *  tcp_write_raque -- åä¿¡ã»ã°ã¡ã³ããåæ§æãã¦ãåä¿¡åæ§æã­ã¥ã¼ã«ç¹ãã
+ */
+
+uint8_t
+tcp_write_raque (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags)
+{
+	T_NET_BUF	*new;
+	T_NET_BUF	*p, *q, *nq;
+	T_TCP_Q_HDR	*qhdr, *inqhdr = GET_TCP_Q_HDR(input, thoff);
+	int32_t		len;
+
+	/*  TCP ãããã®ä½ç½®ãä¿å­ããã*/
+	SET_IP_TCP_Q_HDR_OFFSET(input, thoff);
+
+	/*
+	 *  MAX_TCP_REALLOC_SIZE ä»¥ä¸ã®å ´åã¯ãæ°ãã«ãããã¯ã¼ã¯ãããã¡ã
+	 *  å²å½ã¦ã¦ããã¼ã¿ãã³ãã¼ããã
+	 *  ãã®ã¨ããIP ã®ãªãã·ã§ã³ï¼æ¡å¼µãããï¼ã¨ TCP ã®ãªãã·ã§ã³ã¯åé¤ããã
+	 */
+	len  = IF_IP_TCP_HDR_SIZE(input) + inqhdr->slen;
+
+	if (len <= MAX_TCP_REALLOC_SIZE) {
+
+		/*
+		 *  ãããã¯ã¼ã¯ãããã¡ãç¢ºä¿ã§ããªãã¨ãã¯å²å½ã¦ãªãã
+		 */
+		if (tget_net_buf(&new, (uint_t)len, TMO_TCP_GET_NET_BUF) != E_OK)
+			new = NULL;
+		}
+	else
+		new = NULL;
+
+	/*
+	 *    inqhdr->seq               
+	 *    |
+	 *    |<------- inqhdr->slen ------->|
+	 *    v                              v
+	 *    +------------------------------+
+	 *    |             input            |
+	 *    +------------------------------+
+	 *        ^                  ^
+	 *        |<----- slen ----->|
+	 *        |
+	 *        soff
+	 *
+	 */
+	inqhdr->soff = 0;
+
+	/*
+	 *  ä»åè¿½å ããã»ã°ã¡ã³ãããå(p)ã¨å¾(q)ã®ã»ã°ã¡ã³ããæ¢ãã
+	 *
+	 *    +-------------------------+
+	 *    |            p            |
+	 *    +-------------------------+
+	 *    ^              +---------------------------+
+	 *    p->seq         |            input          |
+	 *                   +---------------------------+
+	 *                   ^                      +-------------------------+
+	 *                   inqhdr->seq            |            q            |
+	 *                                          +-------------------------+
+	 *                                          ^
+	 *                                          q->seq
+	 */
+	for (q = cep->reassq, p = NULL; q != NULL; ) {
+		qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
+		if (SEQ_GT(qhdr->seq, inqhdr->seq))
+			break;
+		p = q;
+		q = qhdr->next;
+		}
+
+	/*
+	 *  å(p)ã®ã»ã°ã¡ã³ããããã°ãæ¢ã«ãä»åã¨åãã»ã°ã¡ã³ãã
+	 *  ãããã¨ãããããã®å ´åã¯ããã®é¨åã¾ãã¯å
+¨ã¦ãç ´æ£ããã
+	 *
+	 *    qhdr->seq
+	 *    |
+	 *    |<----- qhdr->slen ------>|
+	 *    v                         v
+	 *    +-------------------------+
+	 *    |            p            |
+	 *    +-------------------------+
+	 *                    <--len -->
+	 *                   +---------------------------+
+	 *                   |            input          |
+	 *                   +---------------------------+
+	 *                   ^
+	 *                   inqhdr->seq
+	 */
+	if (p != NULL) {
+		qhdr = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p));
+		len = qhdr->seq + qhdr->slen - inqhdr->seq;
+		if (len > 0) {
+
+			/*
+			 *  len ãæ­£ã§ããã°ãå(p) ã®ã»ã°ã¡ã³ãã¨ä»åã®
+			 *  ã»ã°ã¡ã³ããéãªã£ã¦ããã
+			 */
+			if (len >= inqhdr->slen) {
+
+				/*
+				 *  len ãä»åã®ã»ã°ã¡ã³ãã¨åããªã
+				 *  ã¾ã£ããåãã»ã°ã¡ã³ããªã®ã§ä½ãããªãã
+				 */
+				if (new != NULL) {
+					syscall(rel_net_buf(new));
+					}
+
+				syscall(rel_net_buf(input));
+				return flags;
+				}
+
+			/*
+			 *  è¿½å ããã»ã°ã¡ã³ãã® SDU ã len ååã«è©°ããã
+			 */
+			inqhdr->seq  += len;
+			inqhdr->soff += (uint16_t)len;
+			inqhdr->slen -= (uint16_t)len;
+			}
+		}
+
+	/*
+	 *  ã­ã¥ã¼ã«ã¤ãªãåã«ãæ°ãããããã¯ã¼ã¯ãããã¡ã«ãã¼ã¿ãç§»ãã
+	 *  TCP ã®ãªãã·ã§ã³ã¯åé¤ããã
+	 */
+	if (new != NULL) {
+		memcpy(new->buf, input->buf, (size_t)(thoff + TCP_HDR_SIZE));
+		memcpy((uint8_t*)GET_TCP_HDR(new, thoff) + TCP_HDR_SIZE,
+		                 GET_TCP_SDU(input, thoff), (size_t)(inqhdr->slen));
+		syscall(rel_net_buf(input));
+		input = new;
+		inqhdr = GET_TCP_Q_HDR(input, thoff);
+		inqhdr->doff = (uint8_t)TCP_MAKE_DATA_OFF(TCP_HDR_SIZE);
+		}
+
+	/*
+	 *  éãªãå¾(q)ã®ã»ã°ã¡ã³ããèª¿æ´ããã
+	 *
+	 *    inqhdr->seq
+	 *    |
+	 *    |<----- inqhdr->slen ---->|
+	 *    v                         v
+	 *    +-------------------------+
+	 *    |          input          |
+	 *    +-------------------------+
+	 *                    <--len -->
+	 *                   +---------------------------+
+	 *                   |              q            |
+	 *                   +---------------------------+
+	 *                   ^
+	 *                   qhdr->seq
+	 */
+	while (q != NULL) {
+		qhdr = GET_TCP_Q_HDR(q, GET_IP_TCP_Q_HDR_OFFSET(q));
+		len = inqhdr->seq + inqhdr->slen - qhdr->seq;
+		if (len <= 0)
+			/* len ãè² ãªãéãªã£ã¦ããªãã*/
+			break;
+		else if (len < qhdr->slen) {
+
+			/*
+			 *  å¾ãã§éãªã£ã¦ããã»ã°ã¡ã³ãã® SDU ã len ååã«è©°ããã
+			 *
+			 *    inqhdr->seq
+			 *    |
+			 *    |<----- inqhdr->slen ---->|
+			 *    v                         v
+			 *    +-------------------------+
+			 *    |          input          |
+			 *    +-------------------------+
+			 *                    <--len -->
+			 *            +------+---------------------------+
+			 *            |      |              q            |
+			 *            +------+---------------------------+
+			 *                   ^--------->
+			 *                   qhdr->seq
+			 *                   qhdr->soff
+			 */
+			qhdr->seq  += len;
+			qhdr->soff += (uint16_t)len;
+			qhdr->slen -= (uint16_t)len;
+			break;
+			}
+		nq = qhdr->next;
+		if (p)
+			GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = nq;
+		else
+			cep->reassq = nq;
+		syscall(rel_net_buf(q));
+		q = nq;
+		}
+
+	if (p == NULL) {
+		inqhdr->next = cep->reassq;
+		cep->reassq = input;
+		}
+	else {
+		inqhdr->next = GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next;
+		GET_TCP_Q_HDR(p, GET_IP_TCP_Q_HDR_OFFSET(p))->next = input;
+		}
+
+	return tcp_move_ra2rw(cep, flags);
+	}
+
+/*
+ *  tcp_rexmt_val -- åéã¿ã¤ã ã¢ã¦ãå¤ãè¿ãã
+ */
+
+T_TCP_TIME
+tcp_rexmt_val (T_TCP_CEP *cep)
+{
+	T_TCP_TIME val;
+
+	val = ((cep->srtt >> (TCP_SRTT_SHIFT - TCP_DELTA_SHIFT)) + cep->rttvar) >> TCP_DELTA_SHIFT;
+	if (val < TCP_TVAL_MIN)
+		return TCP_TVAL_MIN;
+	else
+		return val;
+	}
+
+/*
+ *  tcp_init_cep -- éä¿¡ç«¯ç¹ãåæåããã
+ */
+
+void
+tcp_init_cep (T_TCP_CEP *cep)
+{
+
+#ifdef TCP_CFG_RWBUF_CSAVE
+	/*
+	 * åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã«ããå ´åã
+	 * åä¿¡ã¦ã£ã³ããããã¡ãå
+¨ã¦è§£æ¾ãããªããã¨ãããã®ã§ã
+	 * ããã§è§£æ¾ããã
+	 */
+	if (cep->rwbufq != NULL) {
+		cep->rwbuf_count = 0;
+		TCP_FREE_RWBUFQ(cep);
+		}
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+
+
+	memset((uint8_t*)cep + offsetof(T_TCP_CEP, timer), 0,
+	       sizeof(T_TCP_CEP) - offsetof(T_TCP_CEP, timer));
+
+	cep->sbuf_rptr	= cep->sbuf_wptr = cep->sbuf;
+	cep->rbuf_rptr	= cep->rbuf_wptr = cep->rbuf;
+
+	cep->maxseg	= DEF_TCP_SND_SEG;		/* éä¿¡æå¤§ã»ã°ã¡ã³ããµã¤ãº		*/
+	cep->srtt	= TCP_TVAL_SRTT_BASE;		/* æ»ãããªç§»åå¹³å			*/
+	cep->rttvar	= ((TCP_TVAL_RTO_BASE - TCP_TVAL_SRTT_BASE) << TCP_RTTVAR_SHIFT) / 4;
+							/* æ»ãããªåæ£				*/
+	cep->rxtcur	= TCP_TVAL_RTO_BASE;		/* ç¾å¨ã®åéå¤				*/
+	cep->snd_cwnd	=  MAX_TCP_WIN_SIZE;		/* è¼»è¼³ã¦ã£ã³ããµã¤ãº			*/
+	cep->snd_ssthresh= MAX_TCP_WIN_SIZE;		/* è¼»è¼³ã¦ã£ã³ããµã¤ãº(snd_cwnd)ã®	å¶éå¤	*/
+
+	/*
+	 * ä»¥ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
+	 * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+	 * ã»åçãªéä¿¡ç«¯ç¹ã®çæã»åé¤æ©è½
+	 * ã»éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«
+	 */
+	cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
+
+	/* ã»ããã©ãåæåããã*/
+	sig_sem(cep->semid_lock);
+
+	/* ãã©ã°ãåæåããã*/
+	syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+	syscall(clr_flg(cep->rcv_flgid, TCP_CEP_EVT_RWBUF_READY));
+	}
+
+/*
+ *  tcp_notify -- ICMP ã¨ã©ã¼ã®å¦ç
+ */
+
+void
+tcp_notify (T_NET_BUF *input, ER error)
+{
+	T_TCP_CEP	*cep;
+
+	if ((cep = tcp_find_cep(input, GET_TCP_HDR_OFFSET(input))) != NULL) {
+
+		/*
+		 *  ã³ãã¯ã·ã§ã³éè¨­æ¸ã§ããã¹ãå°éä¸è½ã¨ã©ã¼ã®å ´åã¯ã
+		 *  åéã«ããå¦çããã
+		 */
+		if (cep->fsm_state == TCP_FSM_ESTABLISHED &&
+		    (error == EV_NURCH || error == EV_HURCH || error == EV_HDOWN))
+			return;
+
+		/*
+		 *  ã³ãã¯ã·ã§ã³éè¨­ä¸­ãåãã¨ã©ã¼ãä½åº¦ãåä¿¡ããå ´åã¯ã
+		 *  å¾
+ã¡ç¶æ
+ãè§£é¤ããå¯¾å¿ããé¢æ°ã«ã¨ã©ã¼ãè¿ãããã
+		 */
+		if (cep->fsm_state < TCP_FSM_ESTABLISHED && cep->rxtshift > 3 && cep->net_error != E_OK) {
+			cep->error = E_CLS;
+			tcp_close(cep);
+			}
+		else {
+			cep->net_error = error;
+
+			/* éä¿¡ãæç¤ºããã*/
+			cep->flags |=  TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+		}
+	}
+
+/*
+ *  tcp_lock_cep -- TCP éä¿¡ç«¯ç¹ãã­ãã¯ããã
+ */
+
+ER
+tcp_lock_cep (ID cepid, T_TCP_CEP **p_cep, FN tfn)
+{
+	T_TCP_CEP	*cep;
+	ER		error = E_OK;
+
+	*p_cep = NULL;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* TCP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEP(cep)) {
+		syscall(sig_sem(cep->semid_lock));
+		return E_NOEXS;
+		}
+
+	/*
+	 *  API æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if (IS_TFN_TCP_RCV(tfn)) {
+		if (cep->rcv_tfn != TFN_TCP_UNDEF ||
+		    (tfn == TFN_TCP_ACP_CEP && cep->snd_tfn == TFN_TCP_CON_CEP)) 
+			error = E_OBJ;
+		else {
+			get_tid(&(cep->rcv_tskid));
+			cep->rcv_tfn = tfn;
+			}
+		}
+	else {
+		if (cep->snd_tfn != TFN_TCP_UNDEF ||
+		    (tfn == TFN_TCP_CON_CEP && cep->rcv_tfn == TFN_TCP_ACP_CEP) ||
+		    (tfn == TFN_TCP_CON_CEP && cep->rcv_tfn == TFN_TCP_CLS_CEP))
+			error = E_OBJ;
+		else {
+			get_tid(&(cep->snd_tskid));
+			cep->snd_tfn = tfn;
+			}
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	*p_cep = cep;
+	return error;
+	}
+
+#ifdef TCP_CFG_TRACE
+
+/*
+ *  ãã¬ã¼ã¹åºåã«ç¨ããã·ãªã¢ã«ãã¼ãçªå·
+ */
+
+#ifndef CONSOLE_PORTID
+#define	CONSOLE_PORTID		LOGTASK_PORTID
+#endif
+
+/*
+ *  ã³ãã¯ã·ã§ã³ã®ç¶æ
+
+ */
+
+static const char tcp_strfsm[][3] = {
+	{ 'C', 'D', '\0' },
+	{ 'L', 'I', '\0' },
+	{ 'S', 'S', '\0' },
+	{ 'S', 'R', '\0' },
+	{ 'E', 'S', '\0' },
+	{ 'C', 'W', '\0' },
+	{ 'F', '1', '\0' },
+	{ 'C', 'G', '\0' },
+	{ 'L', 'A', '\0' },
+	{ 'F', '2', '\0' },
+	{ 'T', 'W', '\0' },
+	};
+
+/*
+ *  trace_putchar -- ã·ãªã¢ã«ãã¼ãã¸ã®æå­åºå
+ */
+
+static void
+trace_putchar (ID portid, char ch)
+{
+	serial_wri_dat(portid, &ch, 1);
+	/*cpu_putc(ch);*/
+	}
+
+/*
+ *  ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºåã©ã¤ãã©ãª
+ */
+
+/*
+ *  æ°å¤å¤æã®ããã®å¤æè¡¨
+ */
+
+static const char radhex[] = "0123456789abcdef";
+static const char radHEX[] = "0123456789ABCDEF";
+
+/*
+ *  convert -- trace_printf ã®æ°å¤å¤æ
+ */
+
+static int_t
+convert (ID portid, long_t val, int_t radix,
+         const char *radchar, int_t width, bool_t minus, char padchar)
+{
+	char	digits[24];
+	int_t	ix, pad, pchars;
+
+	ix = 0;
+	do {
+		if (minus)
+			digits[ix ++] = radchar[val % radix];
+		else
+			digits[ix ++] = radchar[(ulong_t)val % radix];
+		val /= radix;
+		} while (val != 0);
+
+	if (minus)
+		digits[ix ++] = '-';
+
+	if (width > ix)
+		pchars = width;
+	else
+		pchars = ix;
+
+	for (pad = ix; pad < width; pad ++)
+		trace_putchar(portid, padchar);
+
+	while (ix -- > 0)
+		trace_putchar(portid, digits[ix]);
+
+	return pchars;
+	}
+
+/*
+ *  trace_printf -- ã·ãªã¢ã«ãã¼ãã¸ã®æ¸å¼ä»æå­ååºå
+ */
+
+static void
+trace_printf (ID portid, const char *fmt, ...)
+{
+	va_list	ap;
+	ulong_t	val;
+	char	padchar, *str;
+	int_t	ch, width, longflag;
+
+	va_start(ap, fmt);
+	while ((ch = *fmt ++) != '\0') {
+		if (ch != '%') {		/* æ¸å¼æå®ä»¥å¤ */
+			trace_putchar(portid, (char)ch);
+			continue;
+			}
+
+		width = longflag = 0;
+		padchar = ' ';
+		if ((ch = *fmt ++) == '0') {	/* ä¸ä½æ¡ã® 0 */
+			padchar = '0';
+			ch = *fmt ++;
+			}
+
+		while ('0' <= ch && ch <= '9') {	/* åºåå¹
+ */
+			width = width * 10 + ch - '0';
+			ch = *fmt ++;
+			}
+
+		while (ch == 'l') {		/* long (long) ã®æå® */
+			longflag ++;
+			ch = *fmt ++;
+			}
+
+		switch (ch) {
+		case 'd':
+			val = longflag ? (ulong_t)va_arg(ap, long_t)
+			               : (ulong_t)va_arg(ap, int_t);
+			if (val >= 0)
+				convert(portid,  val, 10, radhex, width, false, padchar);
+			else
+				convert(portid, -val, 10, radhex, width, true, padchar);
+			break;
+
+		case 'u':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			convert(portid, val, 10, radhex, width, false, padchar);
+			break;
+
+		case 'x':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			convert(portid, val, 16, radhex, width, false, padchar);
+			break;
+
+		case 'X':
+			val = longflag ? (ulong_t)va_arg(ap, ulong_t)
+			               : (ulong_t)va_arg(ap, uint_t);
+			convert(portid, val, 16, radHEX, width, false, padchar);
+			break;
+
+		case 'c':
+			ch = va_arg(ap, int_t);
+			trace_putchar(portid, (char)ch);
+			break;
+
+		case 's':
+			str = va_arg(ap, char*);
+			while ((ch = *str ++) != '\0')
+				trace_putchar(portid, (char)ch);
+			break;
+
+		case '%':
+			trace_putchar(portid, '%');
+			break;
+
+		case '0':
+			fmt --;
+			break;
+
+		default:
+			break;
+			}
+
+		}
+	va_end(ap);
+	}
+
+/*
+ *  TCP ãã©ã°æå­å
+ */
+
+static char *
+get_tcp_flag_str (char *buf, uint8_t flags)
+{
+	static char tcp_flag_str[] = "FSRPAU";
+
+	int_t	bit, mask = 1;
+
+	for (bit = 0; bit < sizeof(tcp_flag_str); bit ++) {
+		buf[sizeof(tcp_flag_str) - bit - 1] = (char)((flags & mask) ? tcp_flag_str[bit] : '-');
+		mask <<= 1;
+		}
+	buf[sizeof(tcp_flag_str)] = '\0';
+	return buf;
+	}
+
+/*
+ *  éä¿¡ TCP ãããã®ãã¬ã¼ã¹åºå
+ */
+
+void
+tcp_output_trace (T_NET_BUF *output, T_TCP_CEP *cep)
+{
+	SYSTIM		time;
+	T_TCP_HDR	*tcph;
+	char		buf[9];
+
+	if (!(TCP_CFG_TRACE_LPORTNO == TCP_PORTANY || cep->myaddr.portno  == TCP_CFG_TRACE_LPORTNO) ||
+	    !(TCP_CFG_TRACE_RPORTNO == TCP_PORTANY || cep->dstaddr.portno == TCP_CFG_TRACE_RPORTNO))
+		return;
+
+#if defined(_IP4_CFG)
+
+#if defined(_IP6_CFG)
+
+	if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
+	     ((cep->flags & TCP_CEP_FLG_IPV4) && 
+	      IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
+	      (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
+		return;
+
+#else	/* of #if defined(_IP6_CFG) */
+
+	if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
+		return;
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	syscall(wai_sem(SEM_TCP_TRACE));
+	syscall(get_tim(&time));
+	tcph = GET_TCP_HDR(output, GET_TCP_HDR_OFFSET(output));
+	if (time > 99999999)
+		trace_printf(CONSOLE_PORTID, "=O%10d", time / 1000);
+	else
+		trace_printf(CONSOLE_PORTID, "=O%6d.%03d", time / 1000, time % 1000);
+	if (cep == NULL)
+		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
+	else
+		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
+		                             GET_TCP_CEPID(cep),
+		                             tcp_strfsm[cep->fsm_state], cep->flags);
+	trace_printf(CONSOLE_PORTID, ":%s", get_tcp_flag_str(buf, tcph->flags));
+	if (cep->fsm_state >= TCP_FSM_ESTABLISHED)
+		trace_printf(CONSOLE_PORTID, " s:%10u a:%10u",
+		                             ntohl(tcph->seq) - cep->iss,
+		                             ntohl(tcph->ack) - cep->irs);
+	else
+		trace_printf(CONSOLE_PORTID, " s:%10u a:%10u",
+		                             ntohl(tcph->seq), ntohl(tcph->ack));
+	trace_printf(CONSOLE_PORTID, " w:%5d l:%4d>\n", 
+	                             ntohs(tcph->win),
+	                             GET_IP_SDU_SIZE(output) - TCP_HDR_LEN(tcph->doff));
+	syscall(sig_sem(SEM_TCP_TRACE));
+	}
+
+/*
+ *  åä¿¡ TCP ãããã®ãã¬ã¼ã¹åºå
+ *
+ *    æ³¨æ: TCP ãããå
+ã¯ããã§ã«ãã¹ããã¤ããªã¼ã
+ */
+
+void
+tcp_input_trace (T_NET_BUF *input, T_TCP_CEP *cep)
+{
+	SYSTIM		time;
+	T_TCP_HDR	*tcph;
+	char		buf[9];
+
+	if (!(TCP_CFG_TRACE_LPORTNO == TCP_PORTANY || cep->myaddr.portno  == TCP_CFG_TRACE_LPORTNO) ||
+	    !(TCP_CFG_TRACE_RPORTNO == TCP_PORTANY || cep->dstaddr.portno == TCP_CFG_TRACE_RPORTNO))
+		return;
+
+#if defined(_IP4_CFG)
+
+#if defined(_IP6_CFG)
+
+	if (!((TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY) ||
+	     ((cep->flags & TCP_CEP_FLG_IPV4) && 
+	      IN6_IS_ADDR_V4MAPPED(&cep->dstaddr.ipaddr) &&
+	      (ntohl(cep->dstaddr.ipaddr.s6_addr32[3]) == TCP_CFG_TRACE_IPV4_RADDR))))
+		return;
+
+#else	/* of #if defined(_IP6_CFG) */
+
+	if (!(TCP_CFG_TRACE_IPV4_RADDR == IPV4_ADDRANY || cep->dstaddr.ipaddr == TCP_CFG_TRACE_IPV4_RADDR))
+		return;
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	syscall(wai_sem(SEM_TCP_TRACE));
+	syscall(get_tim(&time));
+	tcph = GET_TCP_HDR(input, GET_TCP_HDR_OFFSET(input));
+	if (time > 99999999)
+		trace_printf(CONSOLE_PORTID, "<I%10d", time / 1000);
+	else
+		trace_printf(CONSOLE_PORTID, "<I%6d.%03d", time / 1000, time % 1000);
+	if (cep == NULL)
+		trace_printf(CONSOLE_PORTID, "=c:-- s:-- f:--------");
+	else
+		trace_printf(CONSOLE_PORTID, "=c:%2d s:%s f:%08x",
+		                             GET_TCP_CEPID(cep),
+		                             tcp_strfsm[cep->fsm_state], cep->flags);
+	trace_printf(CONSOLE_PORTID, ":%s", get_tcp_flag_str(buf, tcph->flags));
+	if (cep->fsm_state >= TCP_FSM_SYN_RECVD)
+		trace_printf(CONSOLE_PORTID, " a:%10u s:%10u", tcph->ack - cep->iss, tcph->seq - cep->irs);
+	else
+		trace_printf(CONSOLE_PORTID, " a:%10u s:%10u", tcph->ack, tcph->seq);
+	trace_printf(CONSOLE_PORTID, " w:%5d l:%4d=\n", 
+	                             tcph->win, GET_IP_SDU_SIZE(input) - TCP_HDR_LEN(tcph->doff));
+	syscall(sig_sem(SEM_TCP_TRACE));
+	}
+
+#endif	/* of #ifdef TCP_CFG_TRACE */
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_cs.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_cs.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_cs.c	(revision 317)
@@ -0,0 +1,1139 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_subr.c	8.2 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.49.2.4 1999/08/29 16:29:55 peter Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ãªå ´å
+ *  ãã ããéä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ï¼cep->sbufï¼ã®å¤ã«ããã
+ *  TCP éä¿¡ç«¯ç¹æ¯ã«éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãä½¿ç¨ãããã
+ *  ä½¿ç¨ããªãããåãæ¿ããã
+ */
+
+/*
+ *  tcp_drop_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããååé¤ããï¼é¸æï¼ã
+ */
+
+void
+tcp_drop_swbuf (T_TCP_CEP *cep, uint_t len)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		tcp_drop_swbuf_ncs(cep, len);
+	else
+		tcp_drop_swbuf_cs(cep, len);
+	}
+
+/*
+ *  tcp_write_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãï¼é¸æï¼ã
+ */
+
+ER_UINT
+tcp_write_swbuf (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		return tcp_write_swbuf_ncs(cep, data, len);
+	else
+		return tcp_write_swbuf_cs(cep, data, len);
+	}
+
+/*
+ *  tcp_read_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãèª­ã¿åºãï¼é¸æï¼ã
+ */
+
+void
+tcp_read_swbuf (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		tcp_read_swbuf_ncs(cep, output, len, doff);
+	}
+
+/*
+ *  tcp_wait_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ã¨ç¸æã®åä¿¡ã¦ã£ã³ããéãã®ãå¾
+ã¤ï¼é¸æï¼ã
+ */
+
+ER
+tcp_wait_swbuf (T_TCP_CEP *cep, TMO tmout)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		return tcp_wait_swbuf_ncs(cep, tmout);
+	else
+		return tcp_wait_swbuf_cs(cep, tmout);
+	}
+
+/*
+ *  tcp_get_swbuf_addr -- éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããï¼é¸æï¼ã
+ */
+
+ER_UINT
+tcp_get_swbuf_addr (T_TCP_CEP *cep, void **p_buf)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		return tcp_get_swbuf_addr_ncs(cep, p_buf);
+	else
+		return tcp_get_swbuf_addr_cs(cep, p_buf);
+	}
+
+/*
+ *  tcp_send_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ãéä¿¡å¯è½ã«ããï¼é¸æï¼ã
+ */
+
+void
+tcp_send_swbuf (T_TCP_CEP *cep, uint_t len)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		tcp_send_swbuf_ncs(cep, len);
+	else
+		tcp_send_swbuf_cs(cep, len);
+	}
+
+/*
+ *  tcp_free_swbufq -- éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®è§£æ¾ãæç¤ºããï¼é¸æï¼ã
+ */
+
+void
+tcp_free_swbufq (T_TCP_CEP *cep)
+{
+	if (!IS_PTR_DEFINED(cep->sbuf))
+		tcp_free_swbufq_cs(cep);
+	}
+
+/*
+ *  tcp_alloc_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡ã®å²ãå½ã¦ãæç¤ºããï¼é¸æï¼ã
+ */
+
+void
+tcp_alloc_swbuf (T_TCP_CEP *cep)
+{
+	if (!IS_PTR_DEFINED(cep->sbuf))
+		tcp_alloc_swbuf_cs(cep);
+	}
+
+/*
+ *  tcp_is_swbuf_full -- éä¿¡ã¦ã£ã³ããããã¡ãæºæ¯ããã§ãã¯ããï¼é¸æï¼ã
+ */
+
+bool_t
+tcp_is_swbuf_full (T_TCP_CEP *cep)
+{
+	if (IS_PTR_DEFINED(cep->sbuf))
+		return tcp_is_swbuf_full_ncs(cep);
+	else
+		return tcp_is_swbuf_full_cs(cep);
+	}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+/*
+ *  tcp_drop_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããååé¤ããï¼å°ç¨ï¼ã
+ */
+
+void
+tcp_drop_swbuf_cs (T_TCP_CEP *cep, uint_t len)
+{
+
+	/*éä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããååé¤ããã*/
+	cep->swbuf_count -= (uint16_t)len;
+
+	/* éä¿¡æ¸ã¿ã§ãACKå¾
+ã¡ã®æã¯ãACKå®äºã«å¤æ´ããã*/
+	if (len > 0 && (cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_SENT) {
+		cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_ACKED;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	}
+
+/*
+ *  tcp_write_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãï¼å°ç¨ï¼ã
+ */
+
+ER_UINT
+tcp_write_swbuf_cs (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	ER_UINT	error;
+	uint_t	hdr_size = IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if ((error = net_buf_siz(cep->swbufq)) > 0 && error >= hdr_size) {
+
+		/*
+		 *  +-----------+--------+---------+---------+
+		 *  | Ehter HDR | IP HDR | TCP HDR | TCP SDU |
+		 *  +-----------+--------+---------+---------+
+		 *        14        20        20        n
+		 *   <---------------- error --------------->
+		 *              ^
+		 *              net_buf ã§ 4 ãªã¯ãããå¢çã«ã¢ã©ã¤ã³ããã¦ããã
+		 *
+		 *  tcp_output ã¨ ip_output ã§ããã§ãã¯ãµã ãè¨ç®ããã¨ãã
+		 *  n ã 4 ãªã¯ãããå¢çã«ãªãããã« SDU ã®å¾ãã« 0 ã
+		 *  ãããã£ã³ã°ããããã®åãèæ
+®ãã¦éä¿¡ã¦ã£ã³ããããã¡ã®
+		 *  ç©ºããµã¤ãºã 4 ãªã¯ãããå¢çã«èª¿æ´ããã
+		 */
+		error = (uint_t)(((error - hdr_size) >> 2 << 2) + hdr_size);
+
+		if (len > cep->sbufsz - cep->swbuf_count)
+			len = (uint_t)(cep->sbufsz - cep->swbuf_count);
+		if (len > (error - hdr_size))
+			len = (uint_t)(error - hdr_size);
+
+		/* éä¿¡ã¦ã¤ã³ããµã¤ãºã«ãããµã¤ãºãèª¿æ´ããã*/
+		if (len > cep->snd_wnd) 
+			len = cep->snd_wnd;
+		if (len > cep->snd_cwnd)
+			len = cep->snd_cwnd;
+
+		/* ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ãè¶
+ããªãããã«ããã*/
+		if (len > cep->maxseg) 
+			len = cep->maxseg;
+
+		/* ãã¼ã¿ãç§»ãã*/
+		memcpy(cep->sbuf_wptr, (void*)((uint8_t*)data), (size_t)len);
+		cep->sbuf_wptr   += len;
+		cep->swbuf_count += len;
+		error             = len;
+
+		/* ãããã¯ã¼ã¯ãããã¡é·ã¨ IP ãã¼ã¿ã°ã©ã é·ãè¨­å®ããã*/
+		cep->swbufq->len = (uint16_t)(cep->swbuf_count + hdr_size);
+		SET_IP_SDU_SIZE(cep->swbufq, cep->swbuf_count + TCP_HDR_SIZE);
+
+		/* ãã©ã°ããéä¿¡å¯è½ã«è¨­å®ããã*/
+		cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_SEND_READY;
+		}
+
+	else {	/* éä¿¡ã¦ã¤ã³ããããã¡ãä¸æ­£ */
+		syslog(LOG_WARNING, "[TCP] illegal window buff for send, CEP: %d, %4d < %4d.",
+		                    GET_TCP_CEPID(cep), error, hdr_size);
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		tcp_free_swbufq_cs(cep);
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  tcp_wait_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ã¨ç¸æã®åä¿¡ã¦ã£ã³ããéãã®ãå¾
+ã¤ï¼å°ç¨ï¼ã
+ */
+
+ER
+tcp_wait_swbuf_cs (T_TCP_CEP *cep, TMO tmout)
+{
+	FLGPTN	flag;
+	SYSTIM	before, after;
+	ER	error;
+	int_t	win;
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ãå²å½ã¦æ¸ã¿ã§ãç©ºããããã°çµäºããã*/
+	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_READY &&
+	    (cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) < net_buf_siz(cep->swbufq))
+		return E_OK;
+
+	/* éä¿¡ä¸­ã§ããã°ãçµäºããã¾ã§å¾
+æ©ããã*/
+	while ((cep->flags & TCP_CEP_FLG_WBCS_MASK) != TCP_CEP_FLG_WBCS_FREE) {
+
+		/* éä¿¡å¾
+ã¡ã®æéã tmout ããæ¸ããã*/
+		if (!(tmout == TMO_POL || tmout == TMO_FEVR))
+			syscall(get_tim(&before));
+
+		if ((error = twai_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY,
+		                      TWF_ORW, &flag, tmout)) != E_OK)
+			return error;
+		syscall(clr_flg(cep->snd_flgid, (FLGPTN)(~TCP_CEP_EVT_SWBUF_READY)));
+
+		/* éä¿¡å¾
+ã¡ã®æéã tmout ããæ¸ããã*/
+		if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
+			syscall(get_tim(&after));
+			if (after - before > tmout)
+				return E_TMOUT;
+			tmout -= (TMO)(after - before);
+			}
+
+		/*
+		 *  éä¿¡ã§ããããCEP ã® FSM ç¶æ
+ãè¦ãã
+		 *  éä¿¡ã¦ã¤ã³ããããã¡ãç©ºãã¾ã§å¾
+ã¤éã«ãéä¿¡ä¸è½ã«ãªã£ãå ´åã¯ã
+		 *  ã³ãã¯ã·ã§ã³ãåæ­ããããã¨ãæå³ãã¦ããã
+		 */
+		if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state))
+			return E_CLS;
+		}
+
+	/* ç¸æã®åä¿¡ã¦ã£ã³ããéãã¦ããå ´åã¯ãéãã¾ã§å¾
+æ©ããã*/
+	while (true) {
+
+		/*
+		 *  snd_wnd:  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
+		 *  snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº
+		 *
+		 *  win: ã©ã¡ããå°ããã¦ã£ã³ããµã¤ãºã«è¨­å®ããã
+		 */
+		win = cep->snd_wnd < cep->snd_cwnd ? cep->snd_wnd : cep->snd_cwnd;
+		if (win > 0)
+			break;
+
+		/* éãå¾
+ã¡ã®æéã tmout ããæ¸ããã*/
+		if (!(tmout == TMO_POL || tmout == TMO_FEVR))
+			syscall(get_tim(&before));
+
+		if ((error = twai_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY,
+		                      TWF_ORW, &flag, tmout)) != E_OK)
+			return error;
+		syscall(clr_flg(cep->snd_flgid, (FLGPTN)(~TCP_CEP_EVT_SWBUF_READY)));
+
+		/* éãå¾
+ã¡ã®æéã tmout ããæ¸ããã*/
+		if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
+			syscall(get_tim(&after));
+			if (after - before > tmout)
+				return E_TMOUT;
+			tmout -= (TMO)(after - before);
+			}
+
+		/*
+		 *  éä¿¡ã§ããããCEP ã® FSM ç¶æ
+ãè¦ãã
+		 *  éä¿¡ã¦ã¤ã³ããããã¡ãç©ºãã¾ã§å¾
+ã¤éã«ãéä¿¡ä¸è½ã«ãªã£ãå ´åã¯ã
+		 *  ã³ãã¯ã·ã§ã³ãåæ­ããããã¨ãæå³ãã¦ããã
+		 */
+		if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state))
+			return E_CLS;
+		}
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+	if ((error = tcpn_get_segment(&cep->swbufq, cep, 0,
+	                             TCP_CFG_SWBUF_CSAVE_MIN_SIZE,
+	                             TCP_CFG_SWBUF_CSAVE_MAX_SIZE,
+	                             NBA_SEARCH_DESCENT, tmout)) != E_OK)
+		return error;
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ãåæåããã*/
+	tcp_init_swbuf(cep);
+
+	return E_OK;
+	}
+
+/*
+ *  tcp_get_swbuf_addr_cs -- éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããï¼å°ç¨ï¼ã
+ */
+
+ER_UINT
+tcp_get_swbuf_addr_cs (T_TCP_CEP *cep, void **p_buf)
+{
+	ER_UINT	error;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if ((error = net_buf_siz(cep->swbufq)) > 0) {
+
+		/*
+		 *  +-----------+--------+---------+---------+
+		 *  | Ehter HDR | IP HDR | TCP HDR | TCP SDU |
+		 *  +-----------+--------+---------+---------+
+		 *        14        20        20        n
+		 *   <---------------- error --------------->
+		 *              ^
+		 *              net_buf ã§ 4 ãªã¯ãããå¢çã«ã¢ã©ã¤ã³ããã¦ããã
+		 *
+		 *  tcp_output ã¨ ip_output ã§ããã§ãã¯ãµã ãè¨ç®ããã¨ãã
+		 *  n ã 4 ãªã¯ãããå¢çã«ãªãããã« SDU ã®å¾ãã« 0 ã
+		 *  ãããã£ã³ã°ããããã®åãèæ
+®ãã¦éä¿¡ã¦ã£ã³ããããã¡ã®
+		 *  ç©ºããµã¤ãºã 4 ãªã¯ãããå¢çã«èª¿æ´ããã
+		 */
+		error = (uint_t)(((error - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr)) >> 2 << 2) - cep->swbuf_count);
+
+		/* éä¿¡ã¦ã¤ã³ããµã¤ãºã«ãããµã¤ãºãèª¿æ´ããã*/
+		if (error > cep->snd_wnd) 
+			error = cep->snd_wnd;
+		if (error > cep->snd_cwnd)
+			error = cep->snd_cwnd;
+
+		/* ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ãè¶
+ããªãããã«ããã*/
+		if (error > cep->maxseg) 
+			error = cep->maxseg;
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºããã¼ã¿é·ãè¨­å®ãããã®å¤ãè¿ãã*/
+		cep->get_buf_len = error;
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ã®å
+é ­ãè¨­å®ããã*/
+		*p_buf = cep->sbuf_wptr;
+		}
+
+	else {	/* ãããã¯ã¼ã¯ãããã¡ãä¸æ­£ */
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		tcp_free_swbufq_cs(cep);
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  tcp_send_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ãéä¿¡å¯è½ã«ããï¼å°ç¨ï¼ã
+ */
+
+void
+tcp_send_swbuf_cs (T_TCP_CEP *cep, uint_t len)
+{
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	cep->sbuf_wptr  += len;
+	cep->swbuf_count += len;
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ã¨ IP ãã¼ã¿ã°ã©ã é·ãè¨­å®ããã*/
+	cep->swbufq->len = (uint16_t)(cep->swbuf_count + IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr));
+	SET_IP_SDU_SIZE(cep->swbufq, len + TCP_HDR_SIZE);
+
+	/* tcp_get_buf ã®å²å½ã¦é·ããªã»ããããã*/
+	cep->get_buf_len = 0;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* ãã©ã°ããéä¿¡å¯è½ã«è¨­å®ããå¼·å¶çã«éä¿¡ããã*/
+	cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_SEND_READY
+	                                               | TCP_CEP_FLG_FORCE
+	                                               | TCP_CEP_FLG_FORCE_CLEAR
+	                                               | TCP_CEP_FLG_POST_OUTPUT;
+	}
+
+/*
+ *  tcp_free_swbufq_cs -- éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®è§£æ¾ãæç¤ºããï¼å°ç¨ï¼ã
+ *
+ *    æ³¨æ:
+ *      å¿
+è¦ã§ããã°ããã®é¢æ°ãå¼ã³åºãåã«ãéä¿¡ç«¯ç¹ãã­ãã¯ãã
+ *      æ»ã£ãå¾ãè§£é¤ããå¿
+è¦ãããã
+ */
+
+void
+tcp_free_swbufq_cs (T_TCP_CEP *cep)
+{
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãå¾
+ã¡ãåãæ¶ãã*/
+	cep->flags &= ~TCP_CEP_FLG_WBCS_NBUF_REQ;
+
+	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) != TCP_CEP_FLG_WBCS_FREE) {
+		/*
+		 *  éä¿¡ã¦ã£ã³ããããã¡ãåé¤ããããã«ããã©ã°ã ACK å®äºã«è¨­å®ãã
+		 *  TCP åºåã¿ã¹ã¯ãèµ·åããã
+		 */
+		cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_ACKED;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	}
+
+/*
+ *  tcp_alloc_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡ã®å²ãå½ã¦ãæç¤ºããï¼å°ç¨ï¼ã
+ */
+
+void
+tcp_alloc_swbuf_cs (T_TCP_CEP *cep)
+{
+	cep->flags |= TCP_CEP_FLG_WBCS_NBUF_REQ;
+
+	/*
+	 *  éä¿¡ã¦ã£ã³ããããã¡ãæªä½¿ç¨ã®å ´åã®ã¿ã
+	 *  éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡ã®å²ãå½ã¦ãæç¤ºããã
+	 */
+	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_FREE)
+		sig_sem(SEM_TCP_POST_OUTPUT);
+	}
+
+/*
+ *  tcp_is_swbuf_full_cs -- éä¿¡ã¦ã£ã³ããããã¡ãæºæ¯ããã§ãã¯ããï¼å°ç¨ï¼ã
+ */
+
+bool_t
+tcp_is_swbuf_full_cs (T_TCP_CEP *cep)
+{
+	return (cep->flags & TCP_CEP_FLG_WBCS_MASK) != TCP_CEP_FLG_WBCS_NBUF_READY ||
+	        cep->swbuf_count >= cep->swbufq->len - IF_IP_TCP_NET_HDR_SIZE(&cep->dstaddr.ipaddr);
+	}
+
+/*
+ *  tcp_init_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ãåæåããï¼å°ç¨ï¼ã
+ *
+ *    æ³¨æ: tcp_get_segment ã§ãããã¯ã¼ã¯ãããã¡ãç²å¾ãã
+ *          ç´å¾ã«å¼ã³åºããã¨ã
+ */
+
+void
+tcp_init_swbuf (T_TCP_CEP *cep)
+{
+	/* éä¿¡ã¦ã¤ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãºããªã»ããããã*/
+	cep->swbuf_count = 0;
+
+	/* éä¿¡ã¦ã¤ã³ããããã¡ã®ã¢ãã¬ã¹ãè¨­å®ããã*/
+	cep->sbuf_wptr = cep->sbuf_rptr = GET_TCP_SDU(cep->swbufq, IF_IP_TCP_NET_HDR_OFFSET(&cep->dstaddr.ipaddr));
+
+	/* ãã©ã°ãããããã¯ã¼ã¯ãããã¡å²å½ã¦æ¸ã¿ã«è¨­å®ããã*/
+	cep->flags = (cep->flags & ~(TCP_CEP_FLG_WBCS_NBUF_REQ | TCP_CEP_FLG_WBCS_MASK))
+	                         |   TCP_CEP_FLG_WBCS_NBUF_READY;
+	}
+
+/*
+ *  tcp_push_res_nbuf -- ãããã¯ã¼ã¯ãããã¡ãäºç´ããï¼å°ç¨ï¼ã
+ */
+
+T_NET_BUF *
+tcp_push_res_nbuf (T_NET_BUF *nbuf)
+{
+	static int_t last_ix = 0;
+
+	T_TCP_CEP	*cep;
+ 	int_t		ix, sel_ix;
+
+	if (++ last_ix == tmax_tcp_cepid)
+		last_ix = 0;
+	sel_ix = ix = last_ix;
+	do {
+		cep = &tcp_cep[ix];
+		if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_PEND) {
+
+			/* ãããã¯ã¼ã¯ãããã¡ãäºç´ããã*/
+			cep->swbufq = nbuf;
+			nbuf = NULL;
+
+			/* ãã©ã°ãäºç´ã«è¨­å®ããã*/
+			cep->flags = (cep->flags & ~TCP_CEP_FLG_WBCS_MASK) | TCP_CEP_FLG_WBCS_NBUF_RSVD;
+			sel_ix = ix;
+			break;
+			}
+		if (++ ix == tmax_tcp_cepid)
+			ix = 0;
+		} while (ix != last_ix);
+
+	last_ix = sel_ix;
+
+	return nbuf;
+	}
+
+/*
+ *  tcp_pull_res_nbuf -- äºç´ãã¦ãããããã¯ã¼ã¯ãããã¡è¿ãï¼å°ç¨ï¼ã
+ */
+
+T_NET_BUF *
+tcp_pull_res_nbuf (ATR nbatr)
+{
+	T_NET_BUF	*nbuf;
+	T_TCP_CEP	*cep;
+
+	cep = GET_TCP_CEP(nbatr & NBA_ID_MASK);
+	if ((cep->flags & TCP_CEP_FLG_WBCS_MASK) == TCP_CEP_FLG_WBCS_NBUF_RSVD) {
+
+		/* äºç´ãã¦ãããããã¯ã¼ã¯ãããã¡ãè¿ãã*/
+		nbuf = cep->swbufq;
+		cep->swbufq = NULL;
+
+		/* TCP åºåã¿ã¹ã¯ãèµ·åããã*/
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	else
+		nbuf = NULL;
+
+	return nbuf;
+	}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#ifdef TCP_CFG_RWBUF_CSAVE 
+
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ãªå ´å
+ *  ãã ããéä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ï¼cep->rbufï¼ã®å¤ã«ããã
+ *  TCP éä¿¡ç«¯ç¹æ¯ã«åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãä½¿ç¨ãããã
+ *  ä½¿ç¨ããªãããåãæ¿ããã
+ */
+
+/*
+ *  tcp_drop_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æåã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+ */
+
+void
+tcp_drop_rwbuf (T_TCP_CEP *cep, uint_t len)
+{
+	if (IS_PTR_DEFINED(cep->rbuf))
+		tcp_drop_rwbuf_ncs(cep, len);
+	else
+		tcp_drop_rwbuf_cs(cep, len);
+	}
+
+/*
+ *  tcp_read_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããåèª­ã¿åºãã
+ */
+
+uint_t
+tcp_read_rwbuf (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	if (IS_PTR_DEFINED(cep->rbuf))
+		return tcp_read_rwbuf_ncs(cep, data, len);
+	else
+		return tcp_read_rwbuf_cs(cep, data, len);
+	}
+
+/*
+ *  tcp_get_rwbuf_addr -- åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããã
+ */
+
+uint_t
+tcp_get_rwbuf_addr (T_TCP_CEP *cep, void **p_buf)
+{
+	if (IS_PTR_DEFINED(cep->rbuf))
+		return tcp_get_rwbuf_addr_ncs(cep, p_buf);
+	else
+		return tcp_get_rwbuf_addr_cs(cep, p_buf);
+	}
+
+/*
+ *  tcp_free_rwbufq -- åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ãè§£æ¾ããã
+ */
+
+void
+tcp_free_rwbufq (T_TCP_CEP *cep)
+{
+	if (!IS_PTR_DEFINED(cep->rbuf))
+		tcp_free_rwbufq_cs(cep);
+	}
+
+/*
+ *  tcp_write_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã
+ */
+
+void
+tcp_write_rwbuf (T_TCP_CEP *cep, T_NET_BUF *input, uint_t thoff)
+{
+	if (IS_PTR_DEFINED(cep->rbuf))
+		tcp_write_rwbuf_ncs(cep, input, thoff);
+	else
+		tcp_write_rwbuf_cs(cep, input, thoff);
+	}
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹
+ */
+
+/*
+ *  tcp_drop_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æåã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+ */
+
+void
+tcp_drop_rwbuf_cs (T_TCP_CEP *cep, uint_t len)
+{
+	T_TCP_Q_HDR	*qhdr;
+
+	if (cep->rwbufq != NULL) {
+
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
+		cep->rwbuf_count -= len;
+
+		/* ãããã¯ã¼ã¯ãããã¡ã«ãã¼ã¿ãç¡ããªã£ããè§£æ¾ããã*/
+		if (len == qhdr->slen) {
+			T_NET_BUF *next;
+
+#ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES
+
+			cep->rwbufq_entries --;
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES */
+
+			next = qhdr->next;
+			syscall(rel_net_buf(cep->rwbufq));
+			cep->rwbufq = next;
+			}
+		else {
+			qhdr->slen -= len;
+			qhdr->soff += len;
+			}
+		}
+	}
+
+/*
+ *  tcp_read_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããåèª­ã¿åºãã
+ */
+
+uint_t
+tcp_read_rwbuf_cs (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	T_TCP_Q_HDR	*qhdr;
+	uint_t		blen, rlen = 0;
+	uint8_t		*buf = (uint8_t*)data;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã«ãããã¯ã¼ã¯ãããã¡ãç¡ããªãã
+	 *  len ã 0 ã«ãªãã¾ã§ç¶ããã
+	 */
+	while (cep->rwbufq != NULL && len > 0) {
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
+
+		/*
+		 *  len ã¨åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®å
+é ­ãããã¯ã¼ã¯ãããã¡ã®
+		 *  ãã¼ã¿æ°ã®å°ããæ¹ãç§»ããã¼ã¿æ°ã«ããã
+		 */
+		if (len > qhdr->slen)
+			blen = qhdr->slen;
+		else
+			blen = len;
+
+		memcpy(buf,
+		       GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff,
+		       (size_t)blen);
+
+		/*
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ã«
+		 *  ãã¼ã¿ãç¡ããªã£ããè§£æ¾ããã
+		 */
+		tcp_drop_rwbuf_cs(cep, blen);
+
+		buf  += blen;
+		rlen += blen;
+		len  -= blen;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return rlen;
+	}
+
+/*
+ *  tcp_get_rwbuf_addr -- åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããã
+ */
+
+uint_t
+tcp_get_rwbuf_addr_cs (T_TCP_CEP *cep, void **p_buf)
+{
+	T_TCP_Q_HDR	*qhdr;
+	uint_t		len;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (cep->rwbufq == NULL) {
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ãå
+¨ã¦éæ¾ããã¦ããã¨ãã*/
+		*p_buf = NULL;
+		len = 0;
+		}
+	else {
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ã®ã¢ãã¬ã¹ã®å
+é ­ãè¨­å®ããã*/
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
+		*p_buf = GET_TCP_SDU(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿é·ãè¨ç®ããã*/
+		len = qhdr->slen;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿é·ãè¨­å®ãããã®å¤ãè¿ãã*/
+	cep->rcv_buf_len = len;
+	return len;
+	}
+
+/*
+ *  tcp_free_rwbufq -- åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ãè§£æ¾ããã
+ *
+ *    æ³¨æ:
+ *      å¿
+è¦ã§ããã°ããã®é¢æ°ãå¼ã³åºãåã«ãéä¿¡ç«¯ç¹ãã­ãã¯ãã
+ *      æ»ã£ãå¾ãè§£é¤ããå¿
+è¦ãããã
+ */
+
+void
+tcp_free_rwbufq_cs (T_TCP_CEP *cep)
+{
+	T_NET_BUF *next;
+
+	if (cep->rwbuf_count == 0 && cep->reassq == NULL) {
+		while (cep->rwbufq != NULL) {
+			next = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq))->next;
+
+#ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES
+
+			cep->rwbufq_entries --;
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES */
+
+			syscall(rel_net_buf(cep->rwbufq));
+			cep->rwbufq = next;
+			}
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãºããªã»ããããã*/
+		cep->rwbuf_count = 0;
+		}
+	}
+
+/*
+ *  tcp_write_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã
+ *
+ *    æ³¨æ:
+ *	å
+¥å input ã¯ãT_TCP_Q_HDR ã«ãããªã³ã¯ããã
+ *	ä¸¦ã¹æ¿ããçµäºãã¦ããªããã°ãªããªããã¾ãã
+ *	è¿½å ãããã¼ã¿ã¯ãåä¿¡ã¦ã£ã³ããããã¡ã«åã¾ããã¨ã
+ */
+
+void
+tcp_write_rwbuf_cs (T_TCP_CEP *cep, T_NET_BUF *input, uint_t thoff)
+{
+	T_TCP_Q_HDR	*qhdr;
+	T_NET_BUF	**nextp;
+	uint_t		inlen, last;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	qhdr  = (T_TCP_Q_HDR*)GET_TCP_HDR(input, thoff);
+
+	inlen = qhdr->slen;
+
+#ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES
+
+	if (cep->rwbufq_entries >= TCP_CFG_RWBUF_CSAVE_MAX_QUEUES &&
+	    inlen > 0 && (qhdr->flags & TCP_FLG_FIN) == 0) {
+
+		/*
+		 *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¤§ã¨ã³ããªæ°ãè¶
+ããã¨ãã¯ã
+		 *  åä¿¡ããã»ã°ã¡ã³ããç ´æ£ããã
+		 *  ãã ããSDU é·ã 0 ã®ã»ã°ã¡ã³ãã¨ FIN ã»ã°ã¡ã³ãã¯ç ´æ£ããªãã
+		 *  ãªããæ­£å¸¸ã«åä¿¡ããã»ã°ã¡ã³ããç ´æ£ãããããåéåæ°ãå¢å ããã
+		 */
+		syscall(rel_net_buf(input));
+
+		/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		return;
+		}
+
+	cep->rwbufq_entries ++;
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_MAX_QUEUES */
+
+	qhdr  = (T_TCP_Q_HDR*)GET_TCP_HDR(input, thoff);
+
+	/* åä¿¡æ¸ã¿ã·ã¼ã±ã³ã¹çªå·ãæ´æ°ããã*/
+	cep->rcv_nxt += inlen;
+
+	/* ç·æ¥ãã¼ã¿ã® SDU è£æ­£ãè¡ãã*/
+	if (qhdr->urp > 0 && inlen > 0) {
+		inlen      -= qhdr->urp;
+		qhdr->slen -= qhdr->urp;
+		qhdr->urp   = 0;
+		}
+
+	last  = cep->rwbuf_count;
+
+	/* ãããã¯ã¼ã¯ãããã¡ãåä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®æå¾ã«é£çµããã*/
+	qhdr->next = NULL;
+	nextp = &cep->rwbufq;
+	while (*nextp)
+		nextp = &GET_TCP_Q_HDR(*nextp, GET_IP_TCP_Q_HDR_OFFSET(*nextp))->next;
+	*nextp = input;
+
+	/*
+	 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+	 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+	 *  ããªããã¨ãç¥ãããããã§ããã
+	 */
+	if (inlen > 0) {
+		cep->rwbuf_count += inlen;
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DATA_SEGS],   1);
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DATA_OCTETS], inlen);
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	if (cep->rcv_nblk_tfn == TFN_TCP_RCV_BUF) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		int_t	len;
+
+		qhdr = GET_TCP_Q_HDR(cep->rwbufq, GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq));
+		len = qhdr->slen;
+
+		/*
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if (len > 0 || inlen == 0) {
+
+			/* tcp_rcv_buf ã®å²å½ã¦é·ãè¨­å®ããã*/
+			cep->rcv_buf_len = len;
+
+			/* åä¿¡ã¦ã£ã³ããããã¡ã®ã¢ãã¬ã¹ãè¿ãã*/
+			*cep->rcv_p_buf = GET_TCP_SDU(cep->rwbufq,
+			                  GET_IP_TCP_Q_HDR_OFFSET(cep->rwbufq)) + qhdr->soff;
+
+			if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+#endif
+			else
+				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+			if (len == 0) {
+
+				/*
+				 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+				 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+				 */
+				syscall(wai_sem(cep->semid_lock));
+				tcp_free_rwbufq_cs(cep);
+				syscall(sig_sem(cep->semid_lock));
+				}
+			}
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->rcv_tskid = TA_NULL;
+		cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+		}
+
+	else if (cep->rcv_nblk_tfn == TFN_TCP_RCV_DAT) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+		int_t	len;
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+		if ((len = tcp_read_rwbuf_cs(cep, cep->rcv_data, (uint_t)cep->rcv_len)) > 0) {
+			/* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+
+		/*
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if (len > 0 || inlen == 0) {
+
+			if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+#endif
+			else
+				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+			}
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->rcv_tskid = TA_NULL;
+		cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		if (inlen == 0 && cep->rwbuf_count == 0) {
+			/*
+			 *  åä¿¡ã¦ã£ã³ããããã¡å
+ã®ãã¼ã¿æ°ã 0 ã§ã
+			 *  ç¸æãã FIN ãã©ã°ãä»ããã»ã°ã¡ã³ããåä¿¡ããã¨ãã¯ã
+			 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+			 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+			 */
+			syscall(wai_sem(cep->semid_lock));
+			tcp_free_rwbufq_cs(cep);
+			syscall(sig_sem(cep->semid_lock));
+			}
+
+		/*
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãå
+¥ããã inlen == 0 ã®æãå
+¥åã¿ã¹ã¯ãèµ·åºããã
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if ((last == 0 && cep->rwbuf_count > 0) || inlen == 0) {
+			syscall(set_flg(cep->rcv_flgid, TCP_CEP_EVT_RWBUF_READY));
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	}
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_ncs.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_ncs.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_subr_ncs.c	(revision 317)
@@ -0,0 +1,739 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_subr.c	8.2 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_subr.c,v 1.49.2.4 1999/08/29 16:29:55 peter Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+#ifndef TCP_CFG_SWBUF_CSAVE_ONLY
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãç¡å¹
+ */
+
+/*
+ *  tcp_read_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãèª­ã¿åºãã
+ */
+
+void
+tcp_read_swbuf_ncs (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff)
+{
+	uint8_t	*wptr, *rptr;
+	uint_t	sdu_size   = GET_IP_SDU_SIZE(output);
+	uint_t	hdr_offset = IF_IP_TCP_HDR_OFFSET(output);
+
+	/* SDU ã®å¤§ããããã§ãã¯ããã*/
+	if (sdu_size < GET_TCP_HDR_SIZE(output, hdr_offset) + len) {
+		syslog(LOG_INFO, "[TCP] shrink SUD len: %d -> %d",
+		       (uint16_t)len, (uint16_t)(sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset)));
+		len = sdu_size - GET_TCP_HDR_SIZE(output, hdr_offset);
+		}
+
+	wptr = GET_TCP_SDU(output, hdr_offset);
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	rptr = cep->sbuf_rptr + doff;
+	if (rptr - (uint8_t*)cep->sbuf > cep->sbufsz) {
+
+		/* è»¢ééå§ãéä¿¡ã¦ã£ã³ããããã¡ã®çµãããè¶
+ããã¨ãã®å¦çã*/
+		rptr = (uint8_t*)cep->sbuf_rptr - (cep->sbufsz - doff);
+		}
+	else if (len + (rptr - (uint8_t*)cep->sbuf) > cep->sbufsz) {
+		uint_t sub;
+
+		/* è»¢éç¯å²ãã©ã¦ã³ãããã¨ãã®å¦ç */
+		sub = (uint_t)(cep->sbufsz - (rptr - (uint8_t*)cep->sbuf));
+		memcpy((void*)wptr, rptr, (size_t)sub);
+		len  -= sub;
+		wptr += sub;
+		rptr  = (uint8_t*)cep->sbuf;
+		}
+	memcpy((void*)wptr, rptr, (size_t)len);
+
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_DATA_SEGS],   1);
+	NET_COUNT_TCP(net_count_tcp[NC_TCP_SEND_DATA_OCTETS], len);
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+	}
+
+/*
+ *  tcp_drop_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããååé¤ããã
+ */
+
+void
+tcp_drop_swbuf_ncs (T_TCP_CEP *cep, uint_t len)
+{
+	uint_t	last;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	last = cep->swbuf_count;
+
+	if (cep->sbuf_rptr + len > (uint8_t*)cep->sbuf + cep->sbufsz)
+		/* ã©ã¦ã³ãããã¨ãã®è¨ç® */
+		cep->sbuf_rptr -= cep->sbufsz - len;
+	else
+		cep->sbuf_rptr += len;
+	cep->swbuf_count -= (uint16_t)len;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	if (cep->snd_nblk_tfn == TFN_TCP_GET_BUF) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		/* éä¿¡ãã¼ã¿é·ãè¨ç®ããã*/
+		if (cep->sbufsz - cep->swbuf_count > cep->sbufsz - (cep->sbuf_wptr - (uint8_t*)cep->sbuf))
+			/* æ¸è¾¼ã¿ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã¯ãæ¸è¾¼ã¿ãã¤ã³ã¿ããéä¿¡ã¦ã£ã³ããããã¡ã®çµããã¾ã§ */
+			len = (uint_t)(cep->sbufsz - (cep->sbuf_wptr - (uint8_t*)cep->sbuf));
+		else
+			len = cep->sbufsz - cep->swbuf_count;
+
+		/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		if (len > 0) {
+
+			/* tcp_get_buf ã®å²å½ã¦é·ãè¨­å®ããã*/
+			cep->get_buf_len = len;
+
+			/* éä¿¡ã¦ã£ã³ããããã¡ã®ã¢ãã¬ã¹ãè¿ãã*/
+			*cep->snd_p_buf = cep->sbuf_wptr;
+
+			if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)(uint32_t)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&len);
+#endif
+			else
+				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+			/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+			cep->snd_tskid = TA_NULL;
+			cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+			}
+		}
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	else if (cep->snd_nblk_tfn == TFN_TCP_SND_DAT ||
+	         cep->snd_nblk_tfn == TFN_TCP_SND_OOB) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	else if (cep->snd_nblk_tfn == TFN_TCP_SND_DAT) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+		ER_UINT	error;
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+		error = TCP_WRITE_SWBUF(cep, cep->snd_data, (uint_t)cep->snd_len);
+
+#ifdef TCP_CFG_EXTENTIONS
+
+		/* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨­å®ããã*/
+	        if (cep->snd_nblk_tfn == TFN_TCP_SND_OOB)
+			cep->snd_up = cep->snd_una + error;
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
+#endif
+		else
+			syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->snd_tskid = TA_NULL;
+		cep->snd_tfn   = cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããåºæ¥ããåºåã¿ã¹ã¯ãèµ·åºããã*/
+		if (last == cep->sbufsz && cep->swbuf_count < cep->sbufsz)
+			syscall(set_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	if (cep->swbuf_count > 0) {
+		/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãããã°åºåããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+	}
+
+/*
+ *  tcp_write_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã
+ */
+
+ER_UINT
+tcp_write_swbuf_ncs (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	uint_t	offset;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* len ã¨éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã®å°ããæ¹ãç§»ããã¼ã¿æ°ã«ããã*/
+	if (len > (cep->sbufsz - cep->swbuf_count))
+		len = cep->sbufsz - cep->swbuf_count;
+
+	/* æ¸ãè¾¼ã¿ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã®å¦ç */
+	if (len > cep->sbufsz - (cep->sbuf_wptr - (uint8_t*)cep->sbuf)) {
+		offset = (uint_t)(cep->sbufsz - (cep->sbuf_wptr -(uint8_t*)cep->sbuf));
+		memcpy(cep->sbuf_wptr, data, (size_t)offset);
+		cep->sbuf_wptr  = (uint8_t*)cep->sbuf;
+		cep->swbuf_count += offset;
+		}
+	else
+		offset = 0;
+
+	memcpy(cep->sbuf_wptr, (void*)((uint8_t*)data + offset), (size_t)(len - offset));
+	cep->sbuf_wptr  += len - offset;
+	cep->swbuf_count += len - offset;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return (ER_UINT)len;
+	}
+
+/*
+ *  tcp_wait_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã®ãå¾
+ã¤ã
+ */
+
+ER
+tcp_wait_swbuf_ncs (T_TCP_CEP *cep, TMO tmout)
+{
+	ER	error;
+	FLGPTN	flag;
+
+	while (cep->swbuf_count >= cep->sbufsz) {
+		/*
+		 *  éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãããªããã°ãåºåããã¹ããã¦ã
+		 *  éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã¾ã§å¾
+ã¤ã
+		 */
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+
+		if ((error = twai_flg(cep->snd_flgid, TCP_CEP_EVT_SWBUF_READY, TWF_ORW, &flag, tmout)) != E_OK) {
+			return error;
+			}
+		syscall(clr_flg(cep->snd_flgid, (FLGPTN)(~TCP_CEP_EVT_SWBUF_READY)));
+
+		/*
+		 *  éä¿¡ã§ããããCEP ã® FSM ç¶æ
+ãè¦ãã
+		 *  éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã¾ã§å¾
+ã¤éã«ãéä¿¡ä¸è½ã«ãªã£ãå ´åã¯ã
+		 *  ã³ãã¯ã·ã§ã³ãåæ­ããããã¨ãæå³ãã¦ããã
+		 */
+		if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state)) {
+			return E_CLS;
+			}
+		}
+
+	return E_OK;
+	}
+/*
+ *  tcp_get_swbuf_addr -- éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããã
+ */
+
+ER_UINT
+tcp_get_swbuf_addr_ncs (T_TCP_CEP *cep, void **p_buf)
+{
+	uint_t	len;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ã®å
+é ­ãè¨­å®ããã*/
+	*p_buf = cep->sbuf_wptr;
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºããµã¤ãºãè¨ç®ããã*/
+	if (cep->sbufsz - cep->swbuf_count > cep->sbufsz - (cep->sbuf_wptr - (uint8_t*)cep->sbuf))
+		/* æ¸è¾¼ã¿ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã¯ãæ¸è¾¼ã¿ãã¤ã³ã¿ããéä¿¡ã¦ã£ã³ããããã¡ã®çµããã¾ã§ */
+		len = (uint_t)(cep->sbufsz - (cep->sbuf_wptr - (uint8_t*)cep->sbuf));
+	else
+		len = cep->sbufsz - cep->swbuf_count;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºããã¼ã¿é·ãè¨­å®ãããã®å¤ãè¿ãã*/
+	cep->get_buf_len = len;
+	return (ER_UINT)len;
+	}
+
+/*
+ *  tcp_send_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ãéä¿¡å¯è½ã«ããã
+ */
+
+void
+tcp_send_swbuf_ncs (T_TCP_CEP *cep, uint_t len)
+{
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	cep->sbuf_wptr  += len;
+	cep->swbuf_count += len;
+
+	/* æ¸è¾¼ã¿ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã®å¦ç */
+	if (cep->sbuf_wptr >= (uint8_t*)cep->sbuf + cep->sbufsz)
+		cep->sbuf_wptr  = (uint8_t*)cep->sbuf;
+
+	/* tcp_get_buf ã®å²å½ã¦é·ããªã»ããããã*/
+	cep->get_buf_len = 0;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ããã«ã®ã¨ãã¯å¼·å¶çã«éä¿¡ããã*/
+	if (cep->swbuf_count >= cep->sbufsz)
+		cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
+	}
+
+/*
+ *  tcp_is_swbuf_full -- éä¿¡ã¦ã£ã³ããããã¡ãæºæ¯ããã§ãã¯ããã
+ */
+
+bool_t
+tcp_is_swbuf_full_ncs (T_TCP_CEP *cep)
+{
+	return cep->swbuf_count >= cep->sbufsz;
+	}
+
+#endif	/* of #ifndef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#ifndef TCP_CFG_RWBUF_CSAVE_ONLY
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãç¡å¹
+ */
+
+/*
+ *  tcp_drop_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããååé¤ããã
+ */
+
+void
+tcp_drop_rwbuf_ncs (T_TCP_CEP *cep, uint_t len)
+{
+	cep->rwbuf_count -= len;
+	cep->rbuf_rptr  += len;
+
+	/* èª­ã¿åºããã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã®å¦ç */
+	if (cep->rbuf_rptr >= (uint8_t*)cep->rbuf + cep->rbufsz)
+		cep->rbuf_rptr  = (uint8_t*)cep->rbuf;
+	}
+
+/*
+ *  tcp_read_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ããæå®ããããªã¯ãããåèª­ã¿åºãã
+ */
+
+uint_t
+tcp_read_rwbuf_ncs (T_TCP_CEP *cep, void *data, uint_t len)
+{
+	uint_t	offset;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* len ã¨åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿æ°ã®å°ããæ¹ãåãåºããã¼ã¿æ°ã«ããã*/
+	if (len > cep->rwbuf_count)
+		len = cep->rwbuf_count;
+
+	/* èª­ã¿åºããã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã®å¦ç */
+	if (len > cep->rbufsz - (cep->rbuf_rptr - (uint8_t*)cep->rbuf)) {
+		offset = (uint_t)(cep->rbufsz - (cep->rbuf_rptr -(uint8_t*)cep->rbuf));
+		memcpy(data, cep->rbuf_rptr, (size_t)offset);
+		cep->rwbuf_count -= offset;
+		cep->rbuf_rptr   = (uint8_t*)cep->rbuf;
+		}
+	else
+		offset = 0;
+
+	memcpy((void*)((uint8_t*)data + offset), cep->rbuf_rptr, (size_t)(len - offset));
+	cep->rwbuf_count -= len - offset;
+	cep->rbuf_rptr  += len - offset;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return len;
+	}
+
+/*
+ *  tcp_get_rwbuf_addr -- åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºãã¢ãã¬ã¹ãç²å¾ããã
+ */
+
+uint_t
+tcp_get_rwbuf_addr_ncs (T_TCP_CEP *cep, void **p_buf)
+{
+	uint_t	len;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿é·ãè¨ç®ããã*/
+	if (cep->rwbuf_count > cep->rbufsz - (cep->rbuf_rptr - (uint8_t*)cep->rbuf))
+		/* ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã¯åä¿¡ã¦ã£ã³ããããã¡ã®çµããã¾ã§ */
+		len = (uint_t)(cep->rbufsz - (cep->rbuf_rptr - (uint8_t*)cep->rbuf));
+	else
+		len = cep->rwbuf_count;
+
+	/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ã®ã¢ãã¬ã¹ã®å
+é ­ãè¨­å®ããã*/
+	*p_buf = cep->rbuf_rptr;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* åä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿é·ãè¨­å®ãããã®å¤ãè¿ãã*/
+	cep->rcv_buf_len = len;
+	return len;
+	}
+
+/*
+ *  tcp_write_rwbuf -- åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã
+ *
+ *    æ³¨æ:
+ *	å
+¥å input ã¯ãT_TCP_Q_HDR ã«ãããªã³ã¯ããã
+ *	ä¸¦ã¹æ¿ããçµäºãã¦ããªããã°ãªããªããã¾ãã
+ *	è¿½å ãããã¼ã¿ã¯ãåä¿¡ã¦ã£ã³ããããã¡ã«åã¾ããã¨ã
+ */
+
+void
+tcp_write_rwbuf_ncs (T_TCP_CEP *cep, T_NET_BUF *input, uint_t thoff)
+{
+	T_TCP_Q_HDR	*qhdr;
+	uint_t		offset, inlen, last;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	qhdr  = (T_TCP_Q_HDR*)GET_TCP_HDR(input, thoff);
+
+	/* åä¿¡æ¸ã¿ã·ã¼ã±ã³ã¹çªå·ãæ´æ°ããã*/
+	cep->rcv_nxt += qhdr->slen;
+
+	last  = cep->rwbuf_count;
+	inlen = qhdr->slen;
+
+	/* ç·æ¥ãã¼ã¿ã® SDU è£æ­£ãè¡ãã*/
+	if (qhdr->urp > 0 && inlen > 0) {
+		inlen      -= qhdr->urp;
+		qhdr->slen -= qhdr->urp;
+		qhdr->urp   = 0;
+		}
+
+	/*
+	 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+	 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+	 *  ããªããã¨ãç¥ãããããã§ããã
+	 */
+	if (inlen > 0) {
+
+		/* æ¸ãè¾¼ã¿ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã®å¦ç */
+		if (inlen > cep->rbufsz - (cep->rbuf_wptr - (uint8_t*)cep->rbuf)) {
+			offset = (uint_t)(cep->rbufsz - (cep->rbuf_wptr - (uint8_t*)cep->rbuf));
+			memcpy(cep->rbuf_wptr, (void*)(GET_TCP_SDU(input, thoff) + qhdr->soff), (size_t)offset);
+			cep->rbuf_wptr   = (uint8_t*)cep->rbuf;
+			cep->rwbuf_count += offset;
+			inlen           -= offset;
+			}
+		else
+			offset	= 0;
+
+		memcpy(cep->rbuf_wptr, (void*)(GET_TCP_SDU(input, thoff) + qhdr->soff + offset), (size_t)inlen);
+		cep->rbuf_wptr  += inlen;
+		cep->rwbuf_count += inlen;
+
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DATA_SEGS],   1);
+		NET_COUNT_TCP(net_count_tcp[NC_TCP_RECV_DATA_OCTETS], inlen);
+		}
+
+	syscall(rel_net_buf(input));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	if (cep->rcv_nblk_tfn == TFN_TCP_RCV_BUF) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		int_t	len;
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºããã¼ã¿é·ãè¨ç®ããã*/
+		if (cep->rwbuf_count > cep->rbufsz - (cep->rbuf_rptr - (uint8_t*)cep->rbuf)) {
+			/* ãã¤ã³ã¿ãã©ã¦ã³ãããã¨ãã¯åä¿¡ã¦ã£ã³ããããã¡ã®çµããã¾ã§ */
+			len = (uint_t)(cep->rbufsz - (cep->rbuf_rptr - (uint8_t*)cep->rbuf));
+			}
+		else
+			len = cep->rwbuf_count;
+
+		/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/*
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if (len > 0 || inlen == 0) {
+
+			/* tcp_rcv_buf ã®å²å½ã¦é·ãè¨­å®ããã*/
+			cep->rcv_buf_len = len;
+
+			/* åä¿¡ã¦ã£ã³ããããã¡ã®ã¢ãã¬ã¹ãè¿ãã*/
+			*cep->rcv_p_buf = cep->rbuf_rptr;
+
+
+			if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+#endif
+			else
+				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+
+			if (len == 0) {
+
+				/*
+				 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+				 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+				 */
+				syscall(wai_sem(cep->semid_lock));
+				TCP_FREE_RWBUFQ(cep);
+				syscall(sig_sem(cep->semid_lock));
+				}
+			}
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->rcv_tskid = TA_NULL;
+		cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+		}
+
+	else if (cep->rcv_nblk_tfn == TFN_TCP_RCV_DAT) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+		ER_UINT	len;
+
+		/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+		if ((len = TCP_READ_RWBUF(cep, cep->rcv_data, (uint_t)cep->rcv_len)) > 0) {
+			/* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+
+		/*
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if (len > 0 || inlen == 0) {
+
+			if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)(uint32_t)len);
+#else
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&len);
+#endif
+			else
+				syslog(LOG_WARNING, "[TCP] no call back, CEP: %d.", GET_TCP_CEPID(cep));
+			}
+
+		/* è¨æ¶ããã¦ããã¿ã¹ã¯ ID ã¨ API æ©è½ã³ã¼ããã¯ãªã¢ã¼ããã*/
+		cep->rcv_tskid = TA_NULL;
+		cep->rcv_tfn   = cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		if (inlen == 0 && cep->rwbuf_count == 0) {
+			/*
+			 *  åä¿¡ã¦ã£ã³ããããã¡å
+ã®ãã¼ã¿æ°ã 0 ã§ã
+			 *  ç¸æãã FIN ãã©ã°ãä»ããã»ã°ã¡ã³ããåä¿¡ããã¨ãã¯ã
+			 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã¦ã
+			 *  åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+			 */
+			syscall(wai_sem(cep->semid_lock));
+			TCP_FREE_RWBUFQ(cep);
+			syscall(sig_sem(cep->semid_lock));
+			}
+
+		/*
+		 *  åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãå
+¥ããã inlen == 0 ã®æãå
+¥åã¿ã¹ã¯ãèµ·åºããã
+		 *  FIN ãã©ã°ãä»ããã»ã°ã¡ã³ãã¯ inlen == 0 ã«ãªããã¨ãããã
+		 *  ããã¯ãã¢ããªã±ã¼ã·ã§ã³ã«ãç¸æããããä»¥ä¸ãã¼ã¿ãéããã¦
+		 *  ããªããã¨ãç¥ãããããã§ããã
+		 */
+		if ((last == 0 && cep->rwbuf_count > 0) || inlen == 0)
+			syscall(set_flg(cep->rcv_flgid, TCP_CEP_EVT_RWBUF_READY));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	}
+
+#endif	/* of #ifndef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.c	(revision 317)
@@ -0,0 +1,527 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_timer.c	8.2 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_timer.c,v 1.28.2.1 1999/08/29 16:29:56 peter Exp $
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  å±æé¢æ°
+ */
+
+static T_TCP_CEP *tcp_timers (T_TCP_CEP *cep, int_t tix);
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+static void tcp_tw_timo (void);
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+/*
+ *  ããã¯ãªãæé
+ *
+ *  åéãè¡ããã³ã«ãã¿ã¤ã ã¢ã¦ãã®æéãå»¶é·ããã
+ */
+
+const static uint8_t tcp_back_off[] = {
+	UINT_C(1), 	UINT_C(2), 	UINT_C(4), 	UINT_C(8),
+	UINT_C(16), 	UINT_C(32), 	UINT_C(64), 	UINT_C(64),
+	UINT_C(64), 	UINT_C(64), 	UINT_C(64), 	UINT_C(64), 
+	UINT_C(64)
+	};
+
+#define TCP_TOTAL_BACK_OFF	511	/* ããã¯ãªãæéã®åè¨ */
+
+/*
+ *  tcp_timers -- ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+static T_TCP_CEP *
+tcp_timers (T_TCP_CEP *cep, int_t tix)
+{
+	uint16_t	win;
+
+
+	switch (tix) {
+
+	/*
+	 *  åéã¿ã¤ã
+	 */
+	case TCP_TIM_REXMT:
+	
+		/*
+		 *  æå¤§åéåæ° (TCP_MAX_REXMT_SHIFTãæ¨æº 12 å) ã«ãªã£ãã¨ãã¯ã
+		 *  ã³ãã¯ã·ã§ã³ãåæ­ããã
+		 */
+		if (++ cep->rxtshift > TCP_MAX_REXMT_SHIFT) {
+			cep->rxtshift  = TCP_MAX_REXMT_SHIFT;
+			cep->net_error = EV_REXMTMO;
+			cep = tcp_drop(cep, E_CLS);
+			break;
+			}
+
+		/*
+		 *  åéã¿ã¤ã ã¢ã¦ããè¨ç®ããã
+		 */
+		cep->rxtcur = tcp_range_set((T_TCP_TIME)(tcp_rexmt_val(cep) * tcp_back_off[cep->rxtshift]),
+		                            (T_TCP_TIME)TCP_TVAL_MIN, 
+		                            (T_TCP_TIME)TCP_TVAL_MAX_REXMT);
+		cep->timer[TCP_TIM_REXMT] = cep->rxtcur;
+
+		/*
+		 *  srtt:   å¹³æ»åããã RTT
+		 *  rttvar: å¹³æ»åãããåæ£
+		 *
+		 *  åéåæ°ãæå¤§åéåæ°ã® 1/4 ã«ãªã£ãã¨ãã¯ã
+		 *  å¹³æ»åãããåæ£ (rttvar) ã« srtt ãå ç®ãã
+		 *  å¹³æ»åããã RTT ã 0 ã«ããã
+		 *  
+		 */
+		if (cep->rxtshift > TCP_MAX_REXMT_SHIFT / 4) {
+			cep->rttvar += (cep->srtt >> TCP_SRTT_SHIFT);
+			cep->srtt    = 0;
+			}
+
+		/*
+		 *  snd_nxt: æ¬¡ã«éä¿¡ãã SEQããã®æç¹ã§ã¯ãååéä¿¡ãã SEQ
+		 *  snd_una: æªç¢ºèªã®æå°éä¿¡ SEQ	 ã¾ãã¯ãç¢ºèªãããæå¤§éä¿¡ SEQ
+		 *
+		 *  ååéä¿¡ãã SEQ (snd_nxt) ã 
+		 *  ç¢ºèªãããæå¤§éä¿¡ SEQ (snd_una) ã¾ã§æ»ãã
+		 */
+		cep->snd_nxt = cep->snd_una;
+		cep->flags  |= TCP_CEP_FLG_ACK_NOW;
+
+		/*
+		 *  rtt: å¾å¾©æéã®è¨æ¸¬ãä¸­æ­¢ããã
+		 */
+		cep->rtt     = 0;
+
+		/*
+		 *  éä¿¡ã¦ã¤ã³ãã®è¨­å®
+		 *
+		 *  snd_wnd:  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº
+		 *  snd_cwnd: è¼»è¼³ã¦ã£ã³ããµã¤ãº
+		 *  maxseg  : ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº
+		 *
+		 *  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº (snd_wnd) ãã
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãº (snd_cwnd) ã®
+		 *  ã©ã¡ããå°ãããµã¤ãºã® 1/2 ããæ´ã«
+		 *  ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº (maxseg) ã§å²ã£ãå¤ã
+		 *  ãã ãã2 ä»¥ä¸
+		 */
+		if (cep->snd_wnd < cep->snd_cwnd)
+			win = cep->snd_wnd / 2 / cep->maxseg;
+		else
+			win = cep->snd_cwnd / 2 / cep->maxseg;
+
+		if (win < 2)
+			win = 2;
+
+		/*
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãº (snd_cwnd) ã¯
+		 *  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº (snd_wnd) ã«ã
+		 *  è¼»è¼³ã¦ã£ã³ããµã¤ãºã®ãããå¤ (snd_ssthresh) ã¯
+		 *  ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº (snd_wnd) ã® win åã«
+		 *  è¨­å®ããã
+		 */
+		cep->snd_cwnd     = cep->maxseg;
+		cep->snd_ssthresh = win * cep->maxseg;
+		cep->dupacks      = 0;
+
+		/* åºåããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		break;
+
+	/*
+	 *  æç¶ã¿ã¤ã	
+	 */
+	case TCP_TIM_PERSIST:
+
+		/*
+		 *  æå¤§åéåæ° (TCP_MAX_REXMT_SHIFTãæ¨æº 12 å) ãè¶
+ãã¦ãã¦ã
+		 *  ã¢ã¤ãã«æéããä¿çã¿ã¤ãã®æ¨æºå¤ (TCP_TVAL_KEEP_IDLEã
+		 *  æ¨æº 2 * 60 * 60 ç§) ä»¥ä¸ãã
+		 *  åéã¿ã¤ã ã¢ã¦ãå¤ * ããã¯ãªãæéã®åè¨ä»¥ä¸ãªã
+		 *  ã³ãã¯ã·ã§ã³ãåæ­ããã
+		 */
+		if (cep->rxtshift > TCP_MAX_REXMT_SHIFT &&
+		    (cep->idle >= TCP_TVAL_KEEP_IDLE ||
+		     cep->idle >= tcp_rexmt_val(cep) * TCP_TOTAL_BACK_OFF)) {
+			cep->net_error = EV_REXMTMO;
+			cep = tcp_drop(cep, E_CLS);
+			break;
+			}
+
+		/* æç¶ã¿ã¤ããåè¨­å®ããåºåããã¹ãããã*/
+		tcp_set_persist_timer(cep);
+
+		cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR | TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		break;
+
+	/*
+	 *  ä¿ç (keep alive) ã¿ã¤ã
+	 */
+	case TCP_TIM_KEEP:
+
+		/*
+		 *  ã³ãã¯ã·ã§ã³ãéè¨­ãããã¾ã§ã«ã¿ã¤ã ã¢ã¦ãããã
+		 *  ã³ãã¯ã·ã§ã³ã®éè¨­ãä¸­æ­¢ããã
+		 */
+		if (cep->fsm_state < TCP_FSM_ESTABLISHED) {
+			cep->net_error = EV_REXMTMO;
+			cep = tcp_drop(cep, E_CLS);
+			break;
+			}
+
+#ifdef TCP_CFG_ALWAYS_KEEP
+
+		else if (cep->fsm_state < TCP_FSM_CLOSING) {
+			if (cep->idle >= TCP_TVAL_KEEP_IDLE + 
+			                 TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL) {
+				cep->net_error = EV_REXMTMO;
+				cep = tcp_drop(cep, E_CLS);
+				break;
+				}
+			else
+				tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una - 1,
+				                       cep->rbufsz - cep->rwbuf_count, 0);
+			cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INTERVAL;
+			}
+		else
+			cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_IDLE;
+
+#else	/* of #ifdef TCP_CFG_ALWAYS_KEEP */
+
+		cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_IDLE;
+
+#endif	/* of #ifdef TCP_CFG_ALWAYS_KEEP */
+
+		break;
+
+	/*
+	 *  2MSL ã¿ã¤ã		
+	 */
+	case TCP_TIM_2MSL:
+
+		if (cep->fsm_state != TCP_FSM_TIME_WAIT &&
+		    cep->idle  <= TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL)
+			cep->timer[TCP_TIM_2MSL] = TCP_TVAL_KEEP_INTERVAL;
+		else
+			cep = tcp_close(cep);
+		break;
+		}
+
+	return cep;
+	}
+
+/*
+ *  tcp_cancel_timers -- å
+¨ã¦ã®ã¿ã¤ããã­ã£ã³ã»ã«ããã
+ */
+
+void
+tcp_cancel_timers (T_TCP_CEP *cep)
+{
+	int_t ix;
+
+	for (ix = NUM_TCP_TIMERS; ix -- > 0; )
+		cep->timer[ix] = 0;
+	}
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+/*
+ *  tcp_tw_timo -- Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã®ã¿ã¤ã ã¢ã¦ãå¦ç
+ */
+
+void
+tcp_tw_timo (void)
+{
+	T_TCP_CEP	*cep, *lcep;
+	T_TCP_TWCEP*	twcep;
+	T_TCP_TIME	longer;
+	int_t		frees, waits;
+
+	/*
+	 *  Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã§ã¿ã¤ã ã¢ã¦ãã®ã¨ã³ããªãæ¢ç´¢ãã
+	 *  æ¢ç´¢ããã¨ã³ããªãç©ºãã«ããã
+	 */
+	frees = 0;
+	for (twcep = &tcp_twcep[NUM_TCP_TW_CEP_ENTRY]; twcep -- != tcp_twcep; )
+		if (twcep->fsm_state == TCP_FSM_TIME_WAIT && -- twcep->timer_2msl == 0) {
+			twcep->fsm_state = TCP_FSM_CLOSED;
+			frees ++;
+			}
+
+	/*
+	 *  Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã®ç©ºãã¨ã³ããªãçºçããã
+	 *  æ¨æº TCP éä¿¡ç«¯ç¹ã§ Time Wait ä¸­ã® TCP éä¿¡ç«¯ç¹ãæ¢ç´¢ãã
+	 *  å¿
+è¦ãªæ
+å ±ã Time Wait ç¨ TCP éä¿¡ç«¯ç¹ã«ç§»ãã¦ã
+	 *  æ¨æºã® TCP éä¿¡ç«¯ç¹ãéæ¾ããã
+	 */
+	if (frees > 0) {
+		waits = 0;
+		for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; )
+			if (cep->fsm_state == TCP_FSM_TIME_WAIT)
+				waits ++;
+		if (waits > frees)
+			waits = frees;
+
+		/*
+		 *  ãã£ã¨ãé·ãé Time Wait ãã¦ãã TCP éä¿¡ç«¯ç¹ãéæ¾ããã
+		 */
+		while (waits > 0) {
+			longer = TCP_TVAL_MSL * 2;
+			lcep   = NULL;
+			for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; )
+				if (cep->fsm_state == TCP_FSM_TIME_WAIT && cep->timer[TCP_TIM_2MSL] < longer) {
+					longer = cep->timer[TCP_TIM_2MSL];
+					lcep   = cep;
+					}
+			if (lcep != NULL) {
+				tcp_move_twcep(lcep);
+				waits --;
+				}
+			else
+				break;
+			}
+		}
+	}
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+/*
+ *  tcp_slow_timo -- 500 [ms] æ¯ã«å¼åºããã TCP ã¿ã¤ã ã¢ã¦ãé¢æ°
+ */
+
+void
+tcp_slow_timo (void *ignore)
+{
+	T_TCP_CEP	*cep;
+	int_t		cix, tix;
+
+	for (cix = tmax_tcp_cepid; cix -- > 0; ) {
+		cep = &tcp_cep[cix];
+		if (!(cep->fsm_state == TCP_FSM_CLOSED || cep->fsm_state == TCP_FSM_LISTEN)) {
+			for (tix = NUM_TCP_TIMERS; cep != NULL && tix -- > 0; ) {
+				if (cep->timer[tix] != 0 && -- cep->timer[tix] == 0) {
+					cep = tcp_timers(cep, tix);
+					}
+				}
+			if (cep != NULL) {
+				cep->idle ++;
+				if (cep->rtt) {
+					cep->rtt ++;
+					}
+				}
+			}
+		}
+
+#if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0
+
+	tcp_tw_timo();
+
+#endif	/* of #if defined(NUM_TCP_TW_CEP_ENTRY) && NUM_TCP_TW_CEP_ENTRY > 0 */
+
+	if (tcp_iss != 0) {
+		tcp_iss += TCP_ISS_INCR() / TCP_SLOW_HZ;
+		}
+
+	timeout(tcp_slow_timo, NULL, TCP_SLOW_TMO);
+	}
+
+#ifdef TCP_CFG_DELAY_ACK
+
+/*
+ *  tcp_fast_timo -- 200 [ms] æ¯ã«å¼åºããã TCP ã¿ã¤ã ã¢ã¦ãé¢æ°
+ */
+
+void
+tcp_fast_timo (void *ignore)
+{
+	T_TCP_CEP	*cep;
+	int_t		cix;
+
+	for (cix = tmax_tcp_cepid; cix -- > 0; ) {
+		cep = &tcp_cep[cix];
+		if (cep->flags & TCP_CEP_FLG_DEL_ACK) {
+			cep->flags &= ~TCP_CEP_FLG_DEL_ACK;
+			cep->flags |=  TCP_CEP_FLG_ACK_NOW | TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+		}
+
+	timeout(tcp_fast_timo, NULL, TCP_FAST_TMO);
+	}
+
+#endif/* of #ifdef TCP_CFG_DELAY_ACK */
+
+/*
+ *  tcp_range_set -- æéãæå®ããç¯å²ã«è¨­å®ããã
+ */
+
+T_TCP_TIME
+tcp_range_set (T_TCP_TIME value, T_TCP_TIME tvmin, T_TCP_TIME tvmax)
+{
+	if ((uint32_t)value < (uint32_t)tvmin)
+		return tvmin;
+	else if ((uint32_t)value > (uint32_t)tvmax)
+		return tvmax;
+	else
+		return value;
+	}
+
+/*
+ *  tcp_set_persist_timer -- æç¶ã¿ã¤ãã®è¨­å®
+ */
+
+void
+tcp_set_persist_timer (T_TCP_CEP *cep)
+{
+	T_TCP_TIME time;
+
+	/*
+	 *  srtt:   å¹³æ»åããã RTT
+	 *  rttvar: å¹³æ»åãããåæ£
+	 */
+	time = ((cep->srtt >> 2) + cep->rttvar) >> 1;
+
+	/*
+	 *  åéã¿ã¤ããè¨­å®ããã¦ããã°åå¾©ä¸è½ã¨ã©ã¼
+	 */
+	if (cep->timer[TCP_TIM_REXMT])
+		/* %%% panic("tcp_output REXMT"); %%% */;
+
+	/*
+	 *  æç¶ã¿ã¤ããè¨­å®ããã
+	 */
+	cep->timer[TCP_TIM_PERSIST] = tcp_range_set((T_TCP_TIME)(time * tcp_back_off[cep->rxtshift]),
+	                                            (T_TCP_TIME)TCP_TVAL_MIN_PERSIST,
+	                                            (T_TCP_TIME)TCP_TVAL_MAX_PERSIST);
+
+	/*
+	 *  åéåæ°ãæ´æ°ããã
+	 */
+	if (cep->rxtshift < TCP_MAX_REXMT_SHIFT)
+		cep->rxtshift ++;
+	}
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_timer.h	(revision 317)
@@ -0,0 +1,159 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_timer.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/tcp_timer.h,v 1.13.2.1 1999/08/29 16:29:56 peter Exp $
+ */
+ 
+#ifndef _TCP_TIMER_H_
+#define _TCP_TIMER_H_
+
+/* TCP ã¿ã¤ãå¤æ° */
+
+//#define NUM_TCP_TIMERS		4	/* TCP ã®ã¿ã¤ãæ°	*/
+
+#define TCP_TIM_REXMT		0	/* åéã¿ã¤ã		*/
+#define TCP_TIM_PERSIST		1	/* æç¶ã¿ã¤ã		*/
+#define TCP_TIM_KEEP		2	/* ä¿ç (keep alive) ã¿ã¤ã*/
+#define TCP_TIM_2MSL		3	/* 2MSL ã¿ã¤ã		*/
+
+/* MSL: Maximum Segment Lifetime, æå¤§ã»ã°ã¡ã³ãçå­æé 		*/
+
+/*
+ *  TCP/IP ã®ã¿ã¤ãã®å®ç¾©
+ */
+
+#define TCP_SLOW_TMO		(ULONG_C(500)/NET_TIMER_CYCLE)	/* 500 [ms]	*/
+#define TCP_FAST_TMO		(ULONG_C(200)/NET_TIMER_CYCLE)	/* 200 [ms]	*/
+
+#define TCP_SLOW_HZ		(ULONG_C(1000)/TCP_SLOW_TMO/NET_TIMER_CYCLE)	/* Hz	*/
+
+/* TCP ã¿ã¤ãå¤ */
+
+#define TCP_TVAL_MSL		(TCP_SLOW_HZ * 30)
+					/* æå¤§ã»ã°ã¡ã³ãçå­æé	*/
+
+#define TCP_TVAL_SRTT_BASE	0	/* æ»ãããªå¾å¾©æéã®åºæºå¤*/
+
+#define TCP_TVAL_RTO_BASE	(TCP_SLOW_HZ * 3)
+		/* æ
+å ±ãå¾ãããªãå ´åã®åéã¿ã¤ã ã¢ã¦ãã®åºæºå¤	*/
+
+#define TCP_TVAL_MIN_PERSIST	(TCP_SLOW_HZ * 5)
+				/* æç¶ã¿ã¤ã ã¢ã¦ãã®æå°å¤	*/
+#define TCP_TVAL_MAX_PERSIST	(TCP_SLOW_HZ * 60)
+				/* æç¶ã¿ã¤ã ã¢ã¦ãã®æå¤§å¤	*/
+
+#define TCP_TVAL_KEEP_INIT	(TCP_SLOW_HZ * 75)
+					/* ä¿çã¿ã¤ãã®åæå¤	*/
+#define TCP_TVAL_KEEP_IDLE	(TCP_SLOW_HZ * 2 * 60 * 60)
+					/* ä¿çã¿ã¤ãèµ·åã¾ã§ã®æ¨æºå¤*/
+#define TCP_TVAL_KEEP_INTERVAL	(TCP_SLOW_HZ * 75)
+					/* ä¿çã¿ã¤ãã¤ã³ã¿ã¼ãã«ã®æ¨æºå¤*/
+#define TCP_TVAL_KEEP_COUNT	8	/* ä¿çã¿ã¤ã ã¢ã¦ãã®æå¤§å¤*/
+
+#define TCP_TVAL_MIN		(TCP_SLOW_HZ * 3)
+					/* æéã®æå°åä½	*/
+#define TCP_TVAL_MAX_REXMT	(TCP_SLOW_HZ * 64)
+					/* æå¤§åéæé		*/
+
+/*
+ *  ä»¥ä¸ã®å¤æ°ã®å¤ã¯ãã¯ã­ã§è¨­å®ããã
+ *
+ *  tcp_maixidle   = tcp_keepcnt * tcp_keepintvl
+ *                 = TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL
+ *  tcp_keepcnt    = TCP_TVAL_KEEP_COUNT
+ *  tcp_keepintval = TCP_TVAL_KEEP_INTERVAL
+ *
+ */
+
+/*
+ *  ãã®ä»ã®å®æ°
+ */
+
+#define TCP_MAX_REXMT_SHIFT	12	/* æå¤§åéåæ°		*/
+
+/*
+ *  é¢æ°
+ */
+
+extern void tcp_slow_timo (void *ignore);
+extern void tcp_fast_timo (void *ignore);
+
+extern T_TCP_TIME tcp_range_set (T_TCP_TIME value, T_TCP_TIME tvmin, T_TCP_TIME tvmax);
+
+#endif	/* of #ifndef _TCP_TIMER_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_usrreq.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_usrreq.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_usrreq.c	(revision 317)
@@ -0,0 +1,1631 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	From: @(#)tcp_usrreq.c	8.2 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.40.2.3 1999/08/29 16:29:57 peter Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/tcp_fsm.h>
+#include <netinet/tcp_seq.h>
+#include <netinet/tcp_timer.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_TCP
+
+/*
+ *  TINET ãã©ã¤ãã©ãªåããªãå ´åã¯ãå
+¨ã¦ã®æ©è½ã
+ *  ãªãã¸ã§ã¯ããã¡ã¤ã«ã«åºåããããããã¯ã­ãæå¹ã«ããã
+ */
+
+#ifndef TCP_CFG_LIBRARY
+
+#define __tcp_cre_rep
+#define __tcp_del_rep
+#define __tcp_cre_cep
+#define __tcp_del_cep
+#define __tcp_acp_cep
+#define __tcp_con_cep
+#define __tcp_sht_cep
+#define __tcp_cls_cep
+#define __tcp_snd_dat
+#define __tcp_rcv_dat
+#define __tcp_snd_oob
+#define __tcp_rcv_oob
+#define __tcp_get_buf
+#define __tcp_snd_buf
+#define __tcp_rcv_buf
+#define __tcp_rel_buf
+#define __tcp_can_cep
+#define __tcp_set_opt
+#define __tcp_get_opt
+
+#endif	/* of #ifndef TCP_CFG_LIBRARY */
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#if defined(SUPPORT_INET6)
+
+#define T_IPEP			T_IPV6EP
+#define TCP_ACP_CEP		tcp6_acp_cep
+#define TCP_CON_CEP		tcp6_con_cep
+#define TCP_FIND_CEP_REP	tcp6_find_cep_rep
+
+#if defined(SUPPORT_INET4)
+
+#undef	T_TCP_REP
+#define T_TCP_REP		T_TCP6_REP
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#define TCP_CRE_REP		tcp6_cre_rep
+#define TCP_DEL_REP_BODY	tcp6_del_rep_body
+#define GET_TCP_REP		GET_TCP6_REP
+#define VALID_TCP_REPID		VALID_TCP6_REPID
+#define T_TCPN_CREP		T_TCP6_CREP
+#define API_PROTO		API_PROTO_IPV6
+
+#include <netinet/tcpn_usrreq.c>
+
+#undef  T_IPEP
+#undef  TCP_ACP_CEP
+#undef  TCP_CON_CEP
+#undef	TCP_FIND_CEP_REP
+
+#undef  TCP_CRE_REP
+#undef	TCP_DEL_REP_BODY
+#undef	GET_TCP_REP
+#undef	VALID_TCP_REPID
+#undef	T_TCPN_CREP
+#undef  API_PROTO
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#define T_IPEP			T_IPV4EP
+#define TCP_ACP_CEP		tcp_acp_cep
+#define TCP_CON_CEP		tcp_con_cep
+#define TCP_FIND_CEP_REP	tcp4_find_cep_rep
+
+#if defined(SUPPORT_INET6)
+
+#undef	T_TCP_REP
+#define T_TCP_REP		T_TCP4_REP
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+#define TCP_CRE_REP		tcp_cre_rep
+#define TCP_DEL_REP_BODY	tcp4_del_rep_body
+#define GET_TCP_REP		GET_TCP4_REP
+#define VALID_TCP_REPID		VALID_TCP4_REPID
+#define T_TCPN_CREP		T_TCP_CREP
+#define API_PROTO		API_PROTO_IPV4
+
+#include <netinet/tcpn_usrreq.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#ifdef __tcp_cls_cep
+
+/*
+ *  tcp_user_closed -- ã¦ã¼ã¶ããã®ã³ãã¯ã·ã§ã³ã®éæ¾
+ */
+
+T_TCP_CEP *
+tcp_user_closed (T_TCP_CEP *cep)
+{
+	switch (cep->fsm_state) {
+
+	case TCP_FSM_CLOSED:		/* ã¯ã­ã¼ãº	*/
+	case TCP_FSM_LISTEN:		/* ååãªã¼ãã³	*/
+		cep->fsm_state = TCP_FSM_CLOSED;
+		cep = tcp_close(cep);
+		break;
+
+	case TCP_FSM_SYN_SENT:		/* è½åãªã¼ãã³ãSYN éä¿¡æ¸ã¿	*/
+	case TCP_FSM_SYN_RECVD:		/* SYN ãåä¿¡ããSYN éä¿¡æ¸ã¿	*/
+		cep->flags |= TCP_CEP_FLG_NEED_FIN;
+		break;
+
+	case TCP_FSM_ESTABLISHED:	/* ã³ãã¯ã·ã§ã³éè¨­å®äº	*/
+		cep->fsm_state = TCP_FSM_FIN_WAIT_1;
+		break;
+
+	case TCP_FSM_CLOSE_WAIT:	/* ç¸æãã FIN åä¿¡ãAPP ã®çµäºå¾
+ã¡ */
+		cep->fsm_state = TCP_FSM_LAST_ACK;
+		break;
+		}
+
+	if (cep != NULL && cep->fsm_state == TCP_FSM_FIN_WAIT_2)
+		cep->timer[TCP_TIM_2MSL] = TCP_TVAL_KEEP_COUNT * TCP_TVAL_KEEP_INTERVAL;
+	return cep;
+	}
+
+/*
+ *  tcp_cls_cep -- éä¿¡ç«¯ç¹ã®ã¯ã­ã¼ãºãæ¨æºæ©è½ã
+ */
+
+ER
+tcp_cls_cep (ID cepid, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER		error = E_OK;
+	FLGPTN		flag;
+
+#ifndef TCP_CFG_NON_BLOCKING
+
+	/* tmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifndef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CLS_CEP)) != E_OK)
+		return error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {				/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		if (!IS_PTR_DEFINED(cep->callback))
+			error = E_OBJ;
+		else if (cep->fsm_state == TCP_FSM_CLOSED) {	/* ãã§ã«ã¯ã­ã¼ãºããã¦ããã¨ã */
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_CLS_CEP, E_OK);
+			error = E_WBLK;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+			ER	error = E_OK;
+
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_CLS_CEP, (void*)&error);
+			error = E_WBLK;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+			}
+		else {
+			/* NBLK ã®API æ©è½ã³ã¼ããè¨­å®ããã*/
+			cep->rcv_nblk_tfn = TFN_TCP_CLS_CEP;
+
+			if ((cep = tcp_user_closed(cep)) != NULL) {	/* ã³ãã¯ã·ã§ã³ãåæ­ããã*/
+				/* åæ­ã»ã°ã¡ã³ãåºåããã¹ãããã*/
+				cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+				sig_sem(SEM_TCP_POST_OUTPUT);
+				}
+
+			/*  cep ã NULL ã§æ»ã£ã¦ããå ´åã¯ã
+			 *  æ¢ã«ã³ãã¯ã·ã§ã³ãåæ­ããã¦ãããã¨ãæå³ãã¦ããã
+			 *  ã¾ãããã®å ´åã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºããã¦ããã
+			 */
+			return E_WBLK;
+			}
+		}
+	else {							/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		if ((cep = tcp_user_closed(cep)) == NULL) {	/* ã³ãã¯ã·ã§ã³ãåæ­ããã*/
+
+			/*  cep ã NULL ã§æ»ã£ã¦ããå ´åã¯ã
+			 *  æ¢ã«ã³ãã¯ã·ã§ã³ãåæ­ããã¦ãããã¨ãæå³ãã¦ããã
+			 */
+			return error;
+			}
+		else {
+			/* åæ­ã»ã°ã¡ã³ãåºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+
+			/* ã¤ãã³ããã©ã°ã CLOSED ã«ãªãã¾ã§å¾
+ã¤ã*/
+			error = twai_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED, TWF_ORW, &flag, tmout);
+			if (error == E_OK && cep->error != E_OK)
+				error = cep->error;
+
+			if (error != E_OK) {
+				if (error == E_RLWAI) {
+					/* tcp_cls_cep ãã­ã£ã³ã»ã«ãããã¨ãã¯ãRST ãéä¿¡ããã*/
+					tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una - 1, 
+					            cep->rbufsz - cep->rwbuf_count, TCP_FLG_RST);
+					}
+
+				/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+				tcp_cancel_timers(cep);
+
+				/* 
+				 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+				 *  åä¿¡åæ§æã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+				 */
+				syscall(wai_sem(cep->semid_lock));
+				tcp_free_reassq(cep);
+				syscall(sig_sem(cep->semid_lock));
+
+				/* ç¶æ
+ãæªä½¿ç¨ã«ããã*/
+				cep->fsm_state = TCP_FSM_CLOSED;
+
+				/*
+				 * ä»¥ä¸ã«é¢ä¿ããªããã©ã°ãã¯ãªã¢ã¼ããã
+				 * ã»éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+				 * ã»åçãªéä¿¡ç«¯ç¹ã®çæã»åé¤æ©è½
+				 */
+				cep->flags &= TCP_CEP_FLG_NOT_CLEAR;
+
+				/* 
+				 *  éä¿¡ç«¯ç¹ãã­ãã¯ãã
+				 *  éåä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã
+				 */
+				cep->rwbuf_count = 0;
+				syscall(wai_sem(cep->semid_lock));
+				TCP_FREE_RWBUFQ(cep);
+				TCP_FREE_SWBUFQ(cep);
+				syscall(sig_sem(cep->semid_lock));
+
+				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+				}
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_cls_cep */
+
+#ifdef __tcp_sht_cep
+
+/*
+ *  tcp_sht_cep  -- ãã¼ã¿éä¿¡ã®çµäºãæ¨æºæ©è½ã
+ */
+
+ER
+tcp_sht_cep (ID cepid)
+{
+	T_TCP_CEP	*cep;
+	ER		error = E_OK;
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SHT_CEP)) != E_OK)
+		return error;
+
+	/* TCP éä¿¡ç«¯ç¹ã®ã³ãã¯ã·ã§ã³ãç¢ºç«ç¶æ
+ã§ãªããã°ã¨ã©ã¼ */
+	if (!TCP_FSM_HAVE_ESTABLISHED(cep->fsm_state)) {
+		if ((error = cep->error) == E_OK)
+			error = E_OBJ;
+		}
+
+	else if ((cep = tcp_user_closed(cep)) != NULL) {		/* ã³ãã¯ã·ã§ã³ãåæ­ããã*/
+
+		/* åæ­ã»ã°ã¡ã³ãåºåããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		}
+
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_sht_cep */
+
+#ifdef __tcp_snd_dat
+
+/*
+ *  tcp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+tcp_snd_dat (ID cepid, void *data, int_t len, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_DAT)) != E_OK)
+		return error;
+
+	/* éä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	if ((error = tcp_can_send_more(cep, TFN_TCP_SND_DAT, tmout)) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		if (!TCP_IS_SWBUF_FULL(cep)) {
+
+		 	/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+			error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
+
+			/* åºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+
+			/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_DAT, (void*)&error);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->snd_data     = data;
+			cep->snd_len      = len;
+			cep->snd_nblk_tfn = TFN_TCP_SND_DAT;
+			TCP_ALLOC_SWBUF(cep);
+
+			return E_WBLK;
+			}
+		}
+	else {		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã®ãå¾
+ã¤ã*/
+		if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
+			goto err_ret;
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+		if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
+
+			/* ãã¼ã¿ãéä¿¡ãããéä¿¡ã¦ã£ã³ããããã¡ããã«ã®ã¨ãã¯å¼·å¶çã«éä¿¡ããã*/
+			if (TCP_IS_SWBUF_FULL(cep))
+				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
+
+			/* åºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_snd_dat */
+
+#ifdef __tcp_get_buf
+
+/*
+ *  tcp_get_buf -- éä¿¡ç¨ãããã¡ã®ç²å¾ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+tcp_get_buf (ID cepid, void **p_buf, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* p_buf ã NULL ãªãã¨ã©ã¼ */
+	if (p_buf == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* p_buf ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_buf == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_GET_BUF)) != E_OK)
+		return error;
+
+	/* éä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	if ((error = tcp_can_send_more(cep, TFN_TCP_GET_BUF, tmout)) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		if (!TCP_IS_SWBUF_FULL(cep)) {
+
+			/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+			error = TCP_GET_SWBUF_ADDR(cep, p_buf);
+
+			/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_GET_BUF, (void*)&error);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->snd_p_buf    = p_buf;
+			cep->snd_nblk_tfn = TFN_TCP_GET_BUF;
+			TCP_ALLOC_SWBUF(cep);
+			return E_WBLK;
+			}
+		}
+
+	else {		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã®ãå¾
+ã¤ã*/
+		if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
+			goto err_ret;
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
+		error = TCP_GET_SWBUF_ADDR(cep, p_buf);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_get_buf */
+
+#ifdef __tcp_snd_buf
+
+/*
+ *  tcp_snd_buf -- ãããã¡å
+ã®ãã¼ã¿ã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER
+tcp_snd_buf (ID cepid, int_t len)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* éä¿¡ããé·ã len ããã§ãã¯ããã*/
+	if (len < 0)
+		return E_PAR;
+
+	/* éä¿¡ããé·ãlen ã 0 ã§ããã°ãä½ãããªãã§æ»ãã*/
+	if (len == 0)
+		return E_OK;
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_BUF)) != E_OK)
+		return error;
+
+	/* éä¿¡ããé·ã len ããã§ãã¯ããã*/
+	if (len > cep->get_buf_len) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+
+	/* éä¿¡ã§ããããCEP ã® FSM ç¶æ
+ãè¦ãã*/
+	if (!TCP_FSM_CAN_SEND_MORE(cep->fsm_state)) {
+		if ((error = cep->error) == E_OK)
+			error = E_OBJ;
+		goto err_ret;
+		}
+
+	/* éä¿¡ã¦ã£ã³ããããã¡ã®ãã¼ã¿ãéä¿¡å¯è½ã«ããã*/
+	TCP_SEND_SWBUF(cep, (uint_t)len);
+
+	/* åºåããã¹ãããã*/
+	cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+	sig_sem(SEM_TCP_POST_OUTPUT);
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_snd_buf */
+
+#ifdef __tcp_rcv_dat
+
+/*
+ *  tcp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+tcp_rcv_dat (ID cepid, void *data, int_t len, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_RCV_DAT)) != E_OK)
+		return error;
+
+	/* åä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	if (tcp_can_recv_more(&error, cep, TFN_TCP_RCV_DAT, tmout) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		if (cep->rwbuf_count > 0) {
+
+			/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+			len = TCP_READ_RWBUF(cep, data, (uint_t)len);
+
+			/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)(uint32_t)len);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_DAT, (void*)&len);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->rcv_data     = data;
+			cep->rcv_len      = len;
+			cep->rcv_nblk_tfn = TFN_TCP_RCV_DAT;
+			return E_WBLK;
+			}
+		}
+	else {		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ããªããã°ãå
+¥åãããã¾ã§å¾
+ã¤ã*/
+		if ((error = tcp_wait_rwbuf(cep, tmout)) != E_OK)
+			goto err_ret;
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãåãåºãã*/
+		error = TCP_READ_RWBUF(cep, data, (uint_t)len);
+
+		/* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_rcv_dat */
+
+#ifdef __tcp_rcv_buf
+
+/*
+ *  tcp_rcv_buf -- åä¿¡ãããã¼ã¿ã®å
+¥ã£ããããã¡ã®ç²å¾ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+tcp_rcv_buf (ID cepid, void **p_buf, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* p_buf ã NULL ãªãã¨ã©ã¼ */
+	if (p_buf == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* p_buf ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_buf == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_RCV_BUF)) != E_OK)
+		return error;
+
+	/* åä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	if (tcp_can_recv_more(&error, cep, TFN_TCP_RCV_DAT, tmout) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		if (cep->rwbuf_count > 0) {
+
+		 	/* åä¿¡ã¦ã£ã³ããããã¡ã®ç©ºã¢ãã¬ã¹ãç²å¾ããã*/
+			error = TCP_GET_RWBUF_ADDR(cep, p_buf);
+
+			/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_RCV_BUF, (void*)&error);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->rcv_p_buf    = p_buf;
+			cep->rcv_nblk_tfn = TFN_TCP_RCV_BUF;
+			return E_WBLK;
+			}
+		}
+	else {		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ããªããã°ãå
+¥åãããã¾ã§å¾
+ã¤ã*/
+		if ((error = tcp_wait_rwbuf(cep, tmout)) != E_OK) {
+			cep->rwbuf_count = 0;
+			goto err_ret;
+			}
+
+	 	/* åä¿¡ã¦ã£ã³ããããã¡ã®ã¢ãã¬ã¹ãç²å¾ããã*/
+		error = TCP_GET_RWBUF_ADDR(cep, p_buf);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_rcv_buf */
+
+#ifdef __tcp_rel_buf
+
+/*
+ *  tcp_rel_buf -- åä¿¡ç¨ãããã¡ã®è§£æ¾ãæ¨æºæ©è½ã
+ */
+
+ER
+tcp_rel_buf (ID cepid, int_t len)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* è§£æ¾ããé·ã len ããã§ãã¯ããã*/
+	if (len < 0)
+		return E_PAR;
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_REL_BUF)) != E_OK)
+		return error;
+
+	/* è§£æ¾ããé·ã len ããã§ãã¯ããã*/
+	if (len > cep->rcv_buf_len) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/* åä¿¡ã¦ã£ã³ããããã¡ããåä¿¡ãããªã¯ããããåé¤ããã*/
+	TCP_DROP_RWBUF(cep, (uint_t)len);
+
+	/* tcp_rcv_buf ã®å²å½ã¦é·ããªã»ããããã*/
+	cep->rcv_buf_len = 0;
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	/* ç¸æã«ã¦ã£ã³ãã¦ãµã¤ãºãå¤ãã£ããã¨ãç¥ãããããåºåããã¹ãããã*/
+	cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+	sig_sem(SEM_TCP_POST_OUTPUT);
+
+err_ret:
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_rel_buf */
+
+#ifdef __tcp_can_cep
+
+/*
+ *  tcp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+static ER
+tcp_can_snd (T_TCP_CEP *cep, FN fncd)
+{
+	ER	error = E_OK;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 *  snd_tskid ã TA_NULL ãªãã
+	 *  ãã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
+	 */
+	if (cep->snd_tskid == TA_NULL)
+		error = EV_NOPND;
+
+	/* ãã³ãã£ã³ã°ä¸­ã® API æ©è½ã³ã¼ãã¨ä¸è´ããªããã°ã¨ã©ã¼ */
+	else if (fncd != TFN_TCP_ALL && fncd != cep->snd_tfn)
+		error = E_OBJ;
+
+	/* å¦çãã­ã£ã³ã»ã«ããã*/
+	else {
+
+		/* åä¿¡åæ§æã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		tcp_free_reassq(cep);
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		cep->rwbuf_count = 0;
+		TCP_FREE_RWBUFQ(cep);
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		TCP_FREE_SWBUFQ(cep);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		if (cep->snd_nblk_tfn != TFN_TCP_UNDEF) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+			switch (cep->snd_nblk_tfn) {
+
+			case TFN_TCP_CON_CEP:
+				/*
+				 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+				 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+				 */
+				cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+				cep->rep4 = NULL;
+#endif
+
+				cep->fsm_state = TCP_FSM_CLOSED;
+				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+				break;
+
+			case TFN_TCP_SND_DAT:
+			case TFN_TCP_GET_BUF:
+			case TFN_TCP_SND_OOB:
+				break;
+				}
+
+			if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)E_RLWAI);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				ER	error = E_RLWAI;
+
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->snd_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				}
+			else
+				error = E_OBJ;
+			cep->snd_nblk_tfn = TFN_TCP_UNDEF;
+			}
+		else
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			error = rel_wai(cep->snd_tskid);
+
+		cep->snd_tskid = TA_NULL;
+		cep->snd_tfn   = TFN_TCP_UNDEF;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  tcp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+static ER
+tcp_can_rcv (T_TCP_CEP *cep, FN fncd)
+{
+	ER	error = E_OK;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 *  rcv_tskid ã TA_NULL ãªãã
+	 *  ãã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
+	 */
+	if (cep->rcv_tskid == TA_NULL)
+		error = EV_NOPND;
+
+	/* ãã³ãã£ã³ã°ä¸­ã® API æ©è½ã³ã¼ãã¨ä¸è´ããªããã°ã¨ã©ã¼ */
+	else if (fncd != TFN_TCP_ALL && fncd != cep->rcv_tfn)
+		error = E_OBJ;
+
+	/* å¦çãã­ã£ã³ã»ã«ããã*/
+	else {
+
+		/* åä¿¡åæ§æã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		tcp_free_reassq(cep);
+
+		/* åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		cep->rwbuf_count = 0;
+		TCP_FREE_RWBUFQ(cep);
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ãããã¯ã¼ã¯ãããã¡ãè§£æ¾ããã*/
+		TCP_FREE_SWBUFQ(cep);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+			switch (cep->rcv_nblk_tfn) {
+
+			case TFN_TCP_ACP_CEP:
+				/*
+				 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+				 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+				 */
+				cep->rep = NULL;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+				cep->rep4 = NULL;
+#endif
+
+				cep->fsm_state = TCP_FSM_CLOSED;
+				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+				break;
+
+			case TFN_TCP_RCV_DAT:
+			case TFN_TCP_RCV_BUF:
+				break;
+
+			case TFN_TCP_CLS_CEP:
+				cep->fsm_state = TCP_FSM_CLOSED;
+				tcp_respond(NULL, cep, cep->rcv_nxt, cep->snd_una - 1,
+				            cep->rbufsz - cep->rwbuf_count, TCP_FLG_RST);
+				syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+				break;
+				}
+
+			if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_RLWAI);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				ER	error = E_RLWAI;
+
+				(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+				}
+			else
+				error = E_OBJ;
+			cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+			}
+		else
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			error = rel_wai(cep->rcv_tskid);
+
+		cep->rcv_tskid = TA_NULL;
+		cep->rcv_tfn   = TFN_TCP_UNDEF;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  tcp_can_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çã®ã­ã£ã³ã»ã«ãæ¨æºæ©è½ã
+ */
+
+ER
+tcp_can_cep (ID cepid, FN fncd)
+{
+	T_TCP_CEP	*cep;
+	ER		error = E_OK, snd_err, rcv_err;
+
+	/* API æ©è½ã³ã¼ãããã§ãã¯ããã*/
+	if (!VALID_TFN_TCP_CAN(fncd))
+		return E_PAR;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEP(cep))
+		return E_NOEXS;
+
+	if (fncd == TFN_TCP_ALL) {		/* TFN_TCP_ALL ã®å¦ç */
+		snd_err = tcp_can_snd(cep, fncd);
+		rcv_err = tcp_can_rcv(cep, fncd);
+
+		/*
+		 *  snd_err ã¨ rcv_err ã®ã©ã¡ãã EV_NOPND
+		 *  ãªãããã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
+		 */
+		if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
+			error = E_OBJ;
+		else {
+			if (snd_err == EV_NOPND)
+				snd_err = E_OK;
+			if (rcv_err == EV_NOPND)
+				rcv_err = E_OK;
+
+			if (snd_err != E_OK)
+				error = snd_err;
+			else if (rcv_err != E_OK)
+				error = rcv_err;
+			}
+		}
+
+	else if (IS_TFN_TCP_RCV(fncd)) {	/* åä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = tcp_can_rcv(cep, fncd)) == EV_NOPND)
+			error = E_OBJ;
+		}
+
+	else {					/* éä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = tcp_can_snd(cep, fncd)) == EV_NOPND)
+			error = E_OBJ;
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_can_cep */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#ifdef __tcp_cre_cep
+
+/*
+ *  tcp_cre_cep -- TCP éä¿¡ç«¯ç¹ã®çæãæ¡å¼µæ©è½ã
+ */
+
+ER
+tcp_cre_cep (ID cepid, T_TCP_CCEP *pk_ccep)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* pk_ccep ã NULL ãªãã¨ã©ã¼ */
+	if (pk_ccep == NULL)
+		return E_PAR;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * TCP éä¿¡ç«¯ç¹ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
+	 */
+	if (VALID_TCP_CEP(cep))
+		error = E_OBJ;
+	else {
+
+		/* TCP éä¿¡ç«¯ç¹çææ
+å ±ãã³ãã¼ããã*/
+		cep->cepatr   = pk_ccep->cepatr;		/* éä¿¡ç«¯ç¹å±æ§			*/
+		cep->sbuf     = pk_ccep->sbuf;			/* éä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+		cep->sbufsz   = pk_ccep->sbufsz;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+		cep->rbuf     = pk_ccep->rbuf;			/* åä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+		cep->rbufsz   = pk_ccep->rbufsz;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+		cep->callback = (void*)pk_ccep->callback;	/* ã³ã¼ã«ããã¯			*/
+
+		/* TCP éä¿¡ç«¯ç¹ãçææ¸ã¿ã«ããã*/
+		cep->flags |= TCP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_cre_cep */
+
+/*
+ *  tcp_del_cep -- TCP éä¿¡ç«¯ç¹ã®åé¤ãæ¡å¼µæ©è½ã
+ */
+
+#ifdef __tcp_del_cep
+
+ER
+tcp_del_cep (ID cepid)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * TCP éä¿¡ç«¯ç¹ããã§ãã¯ãããä»¥ä¸ã®å ´åã¯ã¨ã©ã¼
+	 * ã»æªçæã
+	 * ã»ä½¿ç¨ä¸­ã
+	 */
+	if (!VALID_TCP_CEP(cep))
+		error = E_NOEXS;
+	else if (cep->fsm_state != TCP_FSM_CLOSED)
+		error = E_OBJ;
+	else {
+
+		/* TCP éä¿¡ç«¯ç¹ãæªçæã«ããã*/
+		cep->flags &= ~TCP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_del_cep */
+
+#ifdef __tcp_snd_oob
+
+/*
+ *  tcp_snd_oob -- ç·æ¥ãã¼ã¿ã®éä¿¡ãæ¡å¼µæ©è½ã
+ */
+
+ER_UINT
+tcp_snd_oob (ID cepid, void *data, int_t len, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER_UINT		error;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* data ã NULLãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_SND_OOB)) != E_OK)
+		return error;
+
+	/* éä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	if ((error = tcp_can_send_more(cep, TFN_TCP_SND_OOB, tmout)) != E_OK)
+		goto err_ret;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ã¦ã£ã³ããããã¡ã«ç©ºããããã°ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		if (!TCP_IS_SWBUF_FULL(cep)) {
+
+		 	/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+			error = TCP_WRITE_SWBUF(cep, data, (uint_t)len);
+
+			/* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨­å®ããã*/
+			cep->snd_up = cep->snd_una + cep->swbuf_count;
+
+			/* åºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+
+			/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)error);
+#else
+			(*cep->callback)(GET_TCP_CEPID(cep), TFN_TCP_SND_OOB, (void*)&error);
+#endif
+			error = E_WBLK;
+			goto err_ret;
+			}
+		else {
+			cep->snd_data     = data;
+			cep->snd_len      = len;
+			cep->snd_nblk_tfn = TFN_TCP_SND_OOB;
+			TCP_ALLOC_SWBUF(cep);
+
+			return E_WBLK;
+			}
+		}
+	else {		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ãç©ºãã®ãå¾
+ã¤ã*/
+		if ((error = TCP_WAIT_SWBUF(cep, tmout)) != E_OK)
+			goto err_ret;
+
+	 	/* éä¿¡ã¦ã£ã³ããããã¡ã«ãã¼ã¿ãæ¸ãè¾¼ãã*/
+		if ((error = TCP_WRITE_SWBUF(cep, data, (uint_t)len)) > 0) {
+
+			/* éä¿¡ç·æ¥ãã¤ã³ã¿ãè¨­å®ããã*/
+			cep->snd_up = cep->snd_una + cep->swbuf_count;
+
+			/* ãã¼ã¿ãéä¿¡ãããéä¿¡ã¦ã£ã³ããããã¡ããã«ã®ã¨ãã¯å¼·å¶çã«éä¿¡ããã*/
+			if (TCP_IS_SWBUF_FULL(cep))
+				cep->flags |= TCP_CEP_FLG_FORCE | TCP_CEP_FLG_FORCE_CLEAR;
+
+			/* åºåããã¹ãããã*/
+			cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_TCP_POST_OUTPUT);
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_snd_oob */
+
+#ifdef __tcp_rcv_oob
+
+/*
+ *  tcp_rcv_oob -- ç·æ¥ãã¼ã¿ã®åä¿¡ãæ¡å¼µæ©è½ã
+ *
+ *    æ³¨æ: éä¿¡å´ãè¤æ°ãªã¯ãããã®ãã¼ã¿ãéä¿¡ãã¦ãã
+ *          ç·æ¥ãã¤ã³ã¿ãæã 1 ãªã¯ãããã®ãã¼ã¿ã®ã¿åä¿¡ããã
+ */
+
+ER_UINT
+tcp_rcv_oob (ID cepid, void *data, int_t len)
+{
+	T_TCP_CEP	*cep;
+	uint8_t		*urg;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (data == NULL || len < 0)
+		return E_PAR;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* åä¿¡ã§ããããéä¿¡ç«¯ç¹ã®ç¶æ
+ãè¦ãã*/
+	/* åä¿¡ã§ããããfsm_state ãè¦ãã*/
+	if (!TCP_FSM_CAN_RECV_MORE(cep->fsm_state))
+		return E_OBJ;
+
+	/*
+	 *  ç·æ¥ãã¼ã¿å
+¥ãã®ã»ã°ã¡ã³ãã® TCP ãããã
+	 *  è¨­å®ããã¦ããªããã°ãç·æ¥ãã¼ã¿ãåä¿¡ãã¦ããªãã
+	 */
+	if (cep->urg_tcph == NULL)
+		return E_OBJ;
+
+	/* len == 0 ãªããããã¡ãªã¼ãã¼ãã­ã¼ */
+	if (len == 0)
+		return E_BOVR;
+
+	/* ç·æ¥ãã¤ã³ã¿ãæã 1 ãªã¯ãããã®ãã¼ã¿ãèª­ã¿åãã*/
+	urg = (uint8_t*)cep->urg_tcph + TCP_DATA_OFF(cep->urg_tcph->doff) + cep->urg_tcph->urp + TCP_CFG_URG_OFFSET;
+	*(uint8_t*)data = *urg;
+
+	/* èª­ã¿åã£ããã¼ã¿ããå¾ãã® SDU ãåã«è©°ããã*/
+	memcpy(urg, urg + 1, cep->urg_tcph->sum - (cep->urg_tcph->urp + TCP_CFG_URG_OFFSET) - 1);
+
+	/* tcp_rcv_oob() ãå¼åºããããã¨ç¥ãããããã«ãNULL ãè¨­å®ããã*/
+	cep->urg_tcph = NULL;
+
+	return 1;
+	}
+
+#endif	/* of #ifdef __tcp_rcv_oob */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#ifdef __tcp_del_rep
+
+/*
+ *  tcp_del_rep -- TCP åä»å£ã®åé¤ãæ¡å¼µæ©è½ã
+ */
+
+#if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0
+
+#if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/*
+	 *  TCP åä»å£ ID ããã§ãã¯ããã
+	 *  IPv6 ç¨ TCP åä»å£ã§ããã°ã
+	 *  IPv6 ç¨ã®ãTCP åä»å£ã®åé¤é¢æ°ï¼æ¬ä½ï¼ããå¼åºãã
+	 */
+	//NET_DEBUG_TCP3("tcp_del_rep1[r=%d,n=%d,x=%d]\n",
+	//               repid, TMIN_TCP6_REPID, tmax_tcp6_repid);
+	//NET_DEBUG_TCP3("tcp_del_rep2[r=%d,n=%d,x=%d]\n",
+	//               repid, TMIN_TCP4_REPID, tmax_tcp4_repid);
+	if (VALID_TCP6_REPID(repid))
+		return tcp6_del_rep_body(repid);
+
+	/*
+	 *  TCP åä»å£ ID ããã§ãã¯ããã
+	 *  IPv4 ç¨ TCP åä»å£ã§ããã°ã
+	 *  IPv4 ç¨ã®ãTCP åä»å£ã®åé¤é¢æ°ï¼æ¬ä½ï¼ããå¼åºãã
+	 */
+	else if (VALID_TCP4_REPID(repid))
+		return tcp4_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#else	/* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/* TCP åä»å£ ID ããã§ãã¯ããã*/
+	if (VALID_TCP6_REPID(repid))
+		return tcp6_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_TCP4_REPID > 0 */
+
+#else	/* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
+
+ER
+tcp_del_rep (ID repid)
+{
+
+	/* TCP åä»å£ ID ããã§ãã¯ããã*/
+	if (VALID_TCP4_REPID(repid))
+		return tcp4_del_rep_body(repid);
+	else
+		return E_ID;
+
+	}
+
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_TCP6_REPID > 0 */
+
+#endif	/* of #ifdef __tcp_del_rep */
+
+/*
+ *  tcp_set_opt -- TCP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®è¨­å®ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª TCP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+#ifdef __tcp_set_opt
+
+ER
+tcp_set_opt (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_TCP_CEP	*cep;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEP(cep))
+		return E_NOEXS;
+
+	return E_PAR;
+	}
+
+#endif	/* of #ifdef __tcp_set_opt */
+
+/*
+ *  tcp_get_opt -- TCP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®è¨­å®ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª TCP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+#ifdef __tcp_get_opt
+
+ER
+tcp_get_opt (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_TCP_CEP	*cep;
+
+	/* TCP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEPID(cepid))
+		return E_ID;
+
+	/* TCP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_TCP_CEP(cepid);
+
+	/* TCP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_TCP_CEP(cep))
+		return E_NOEXS;
+
+	return E_PAR;
+	}
+
+#endif	/* of #ifdef __tcp_get_opt */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#endif	/* of #ifdef SUPPORT_TCP */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcp_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcp_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcp_var.h	(revision 317)
@@ -0,0 +1,984 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993, 1994, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)tcp_var.h	8.4 (Berkeley) 5/24/95
+ * $FreeBSD: src/sys/netinet/tcp_var.h,v 1.49.2.1 1999/08/29 16:29:57 peter Exp $
+ */
+ 
+#ifndef _TCP_VAR_H_
+#define _TCP_VAR_H_
+
+/*
+ *  TCP ãããã»ãã¤ã­ã¼ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define GET_TCP_HDR(nbuf,thoff)		((T_TCP_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
+#define GET_TCP_OPT(nbuf,thoff)		((uint8_t*)((nbuf)->buf) + thoff + TCP_HDR_SIZE)
+#define GET_TCP_SDU(nbuf,thoff)		((uint8_t*)((nbuf)->buf) + thoff + GET_TCP_HDR_SIZE(nbuf,thoff))
+
+#define GET_TCP_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
+
+#define GET_TCP_HDR_SIZE(nbuf,thoff)	(TCP_HDR_LEN(GET_TCP_HDR(nbuf,thoff)->doff))
+
+#define GET_IP_TCP_HDR_SIZE(nbuf,thoff) (GET_IP_HDR_SIZE(nbuf) + GET_TCP_HDR_SIZE(nbuf,thoff))
+#define GET_IF_IP_TCP_HDR_SIZE(nbuf,thoff) \
+					(IF_HDR_SIZE + GET_IP_TCP_HDR_SIZE(nbuf,thoff))
+#define IF_IP_TCP_HDR_SIZE(nbuf)	(IF_IP_HDR_SIZE(nbuf) + TCP_HDR_SIZE)
+#define IF_IP_TCP_HDR_OFFSET(nbuf)	(IF_IP_HDR_SIZE(nbuf))
+#define IF_IP_TCP_NET_HDR_SIZE(addr)	(IF_IP_NET_HDR_SIZE(addr) + TCP_HDR_SIZE)
+#define IF_IP_TCP_NET_HDR_OFFSET(addr)	(IF_IP_NET_HDR_SIZE(addr))
+
+/*
+ *  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#if !defined(_IP6_CFG) && defined(_IP4_CFG)
+
+#define IP4_TCP_HDR_SIZE		IP_TCP_HDR_SIZE
+#define IF_IP4_TCP_HDR_SIZE		IF_IP_TCP_HDR_SIZE
+#define GET_IP4_TCP_HDR_SIZE(nbuf)	GET_IP_TCP_HDR_SIZE1(nbuf)	
+#define GET_IF_IP4_TCP_HDR_SIZE(nbuf)	GET_IF_IP_TCP_HDR_SIZE1(nbuf)	
+
+#endif	/* of #if !defined(_IP6_CFG) && defined(_IP4_CFG) */
+
+/*
+ *  TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#define	TMIN_TCP_CREPID			TMIN_TCP_REPID
+#define	TNUM_TCP_CREPID			TNUM_TCP_REPID
+
+#define	TMIN_TCP_CCEPID			TMIN_TCP_CEPID
+#define	TNUM_TCP_CCEPID			TNUM_TCP_CEPID
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°ã®å®ç¾©
+ */
+
+typedef ER	(*t_tcp_callback)(ID cepid, FN fncd, void *p_parblk);
+
+/*
+ * TCP ã§ä½¿ç¨ããå¤æ°ã®åã®å®ç¾©
+ */
+
+typedef uint32_t T_TCP_SEQ;
+typedef uint16_t T_TCP_SEG;
+typedef uint16_t T_TCP_WND;
+typedef int16_t T_TCP_TIME;
+
+/*
+ *  TCP ã¿ã¤ãå¤æ°
+ */
+
+#define NUM_TCP_TIMERS		4	/* TCP ã®ã¿ã¤ãæ°	*/
+
+/*
+ *  TCP åä»å£
+ */
+
+/* IPv6 ç¨ TCP åä»å£ */
+
+typedef struct t_tcp6_rep {
+
+	/*
+	 * ITRON TCP/IP APIãTCP åä»å£ã¨åãã¡ã³ã
+	 */
+	ATR		repatr;		/* åä»å£å±æ§		*/
+	T_IPV6EP	myaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+
+#ifdef TCP_CFG_EXTENTIONS
+	uint16_t	flags;		/* åä»å£ãã©ã°		*/
+	ID		semid_lock;	/* åä»å£ã­ãã¯		*/
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	} T_TCP6_REP;
+
+/* IPv4 ç¨ TCP åä»å£ */
+
+typedef struct t_tcp4_rep {
+
+	/*
+	 * ITRON TCP/IP APIãTCP åä»å£ã¨åãã¡ã³ã
+	 */
+	ATR		repatr;		/* åä»å£å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+
+#ifdef TCP_CFG_EXTENTIONS
+	uint16_t	flags;		/* åä»å£ãã©ã°		*/
+	ID		semid_lock;	/* åä»å£ã­ãã¯		*/
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	} T_TCP4_REP;
+
+#if defined(_IP6_CFG)
+
+#define T_TCP_REP	T_TCP6_REP
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define T_TCP_REP	T_TCP4_REP
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+#define T_TCP_REP_DEFINED
+
+/*
+ *  åä»å£ãã©ã°
+ */
+
+#define TCP_REP_FLG_DYNAMIC	UINT_C(0x0400)	/* åççæã»åé¤å¯è½åä»å£ã	*/
+#define TCP_REP_FLG_VALID	UINT_C(0x0800)	/* çææ¸ã¿ã§æå¹ãªåä»å£ã	*/
+
+/*
+ *  TCP éä¿¡ç«¯ç¹
+ */
+
+#ifndef T_NET_BUF_DEFINED
+
+typedef struct t_net_buf T_NET_BUF;
+
+#define T_NET_BUF_DEFINED
+
+#endif	/* of #ifndef T_NET_BUF_DEFINED */
+
+typedef struct t_tcp_cep {
+
+	/*
+	 * ITRON TCP/IP APIãTCP éä¿¡ç«¯ç¹ã¨åãã¡ã³ã
+	 */
+	ATR		cepatr;		/* éä¿¡ç«¯ç¹å±æ§			*/
+	void		*sbuf;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		sbufsz;		/* éä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	void		*rbuf;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡	*/
+	int_t		rbufsz;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	t_tcp_callback	callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+
+	/*
+	 * TINET ç¬èªã®ã¡ã³ã
+	 */
+	uint32_t	flags;		/* éä¿¡ç«¯ç¹ãã©ã°		*/
+	ID		semid_lock;	/* éä¿¡ç«¯ç¹ã­ãã¯		*/
+	ID		est_flgid;	/* ã³ãã¯ã·ã§ã³ç¶æ
+ã¤ãã³ããã©ã°	*/
+	ID		snd_flgid;	/* éä¿¡ã¤ãã³ããã©ã°		*/
+	ID		rcv_flgid;	/* åä¿¡ã¤ãã³ããã©ã°		*/
+	ID		snd_tskid;	/* éä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	ID		rcv_tskid;	/* åä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	uint8_t		*sbuf_rptr;	/* éä¿¡ç¨èª­ã¿åºããã¤ã³ã¿	*/
+	uint8_t		*sbuf_wptr;	/* éä¿¡ç¨æ¸ãè¾¼ã¿ãã¤ã³ã¿	*/
+	uint8_t		*rbuf_rptr;	/* åä¿¡ç¨èª­ã¿åºããã¤ã³ã¿	*/
+	uint8_t		*rbuf_wptr;	/* åä¿¡ç¨æ¸ãè¾¼ã¿ãã¤ã³ã¿	*/
+	T_TCP_SEQ	snd_ssthresh;	/* è¼»è¼³ã¦ã£ã³ããµã¤ãº(snd_cwnd)	*/
+					/* ã®ãããå¤			*/
+	T_TCP_TIME	rxtcur;		/* ç¾å¨ã®åéã¿ã¤ã ã¢ã¦ã	*/
+	T_TCP_TIME	srtt;		/* å¹³æ»åããã RTT		*/
+	T_TCP_TIME	rttvar;		/* å¹³æ»åãããåæ£		*/
+	T_TCP_WND	snd_cwnd;	/* è¼»è¼³ã¦ã£ã³ããµã¤ãº		*/
+
+	/*
+	 *  ç¸æã®æå¤§åä¿¡ã»ã°ã¡ã³ããµã¤ãº	
+	 *
+	 *    ãªãªã¸ãã«ã§ã¯ãä¸è¬ã®ã»ã°ã¡ã³ãã®æå¤§ãµã¤ãº (t_maxseg) ã¨ã
+	 *    ãªãã·ã§ã³ä»ãã®ã»ã°ã¡ã³ãã®æå¤§ãµã¤ãº (t_maxopd) ãå¥ã«
+	 *    ãªã£ã¦ãããããã¯ãç¾å¨ã®ã¤ã³ã¿ã¼ãããã§ã¯ããªãã·ã§ã³ä»ãã®
+	 *    ã»ã°ã¡ã³ãã®ã»ããå¤ãããã¨èª¬æããã¦ããããã§ããã
+	 *    æ¬å®è£
+ã§ã¯ãæå¤§ã»ã°ã¡ã³ããµã¤ãºãªãã·ã§ã³ä»¥å¤ã®ãªãã·ã§ã³ã¯
+	 *    å®è£
+ããªãã®ã§ãt_maxseg ã®ä½¿ç¨ããã
+	 */
+	T_TCP_SEG	maxseg;
+
+	int16_t		snd_tfn;	/* éä¿¡åä½ä¸­ã® API æ©è½ã³ã¼ã	*/
+	int16_t		rcv_tfn;	/* åä¿¡åä½ä¸­ã® API æ©è½ã³ã¼ã	*/
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	T_IPEP 		*p_dstaddr;	/* ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿	*/
+	T_IPEP	 	*p_myaddr;	/* èªåã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿	*/
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG)
+	T_IPV4EP	*p_dstaddr4;	/* ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿	*/
+	T_IPV4EP 	*p_myaddr4;	/* èªåã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿	*/
+#endif
+	
+	int16_t		snd_nblk_tfn;	/* éä¿¡åä½ä¸­ã® API æ©è½ã³ã¼ã	*/
+	int16_t		rcv_nblk_tfn;	/* åä¿¡åä½ä¸­ã® API æ©è½ã³ã¼ã	*/
+	void		*snd_data;	/* éä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		snd_len;	/* éä¿¡ãã¼ã¿é åã®é·ã		*/
+	void		*rcv_data;	/* åä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		rcv_len;	/* åä¿¡ãã¼ã¿é åã®é·ã		*/
+	void		**snd_p_buf;	/* éä¿¡ãããã¡ã¸ã®ãã¤ã³ã¿	*/
+	void		**rcv_p_buf;	/* åä¿¡ãããã¡ã¸ã®ãã¤ã³ã¿	*/
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+	T_NET_BUF	*swbufq;	/* éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼	*/
+#endif
+
+	/*
+	 *  ããä»¥éã®ã¡ã³ãã¼ã¯ tcp_init_cep() é¢æ°ã§ã¼ã­ã¯ãªã¢ã¼ãããã
+	 */
+
+	T_TCP_TIME	timer[NUM_TCP_TIMERS];	/* TCP ã®ã¿ã¤ã		*/
+	T_IPEP		dstaddr;	/* ç¸æã®ã¢ãã¬ã¹		*/
+	T_IPEP		myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	T_NET_BUF	*reassq;	/* åä¿¡åæ§æã­ã¥ã¼		*/
+
+#if defined(_IP6_CFG)
+
+#if defined(_IP4_CFG)
+
+	T_TCP4_REP	*rep4;		/* IPv4 ç¨åä»å£		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	T_TCP6_REP	*rep;		/* IPv6 ç¨åä»å£		*/
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+	T_TCP4_REP	*rep;		/* IPv4 ç¨åä»å£		*/
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+
+#ifdef TCP_CFG_RWBUF_CSAVE
+	T_NET_BUF	*rwbufq;	/* åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼	*/
+#endif
+
+#ifdef TCP_CFG_EXTENTIONS
+	T_TCP_HDR	*urg_tcph;	/* ç·æ¥ãã¼ã¿å
+¥ãã®ã»ã°ã¡ã³ãã® TCP ããã	*/
+	T_TCP_SEQ	snd_up;		/* éä¿¡ããç·æ¥ãã¤ã³ã¿		*/
+	T_TCP_SEQ	rcv_up;		/* åä¿¡ããç·æ¥ãã¤ã³ã¿		*/
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	T_TCP_SEQ	snd_una;	/* æªç¢ºèªã®æå°éä¿¡ SEQ ã¤ã¾ã	*/
+					/* ç¢ºèªãããæå¤§éä¿¡ SEQ	*/
+	T_TCP_SEQ	snd_max;	/* éä¿¡ããæå¤§ SEQ		*/
+	T_TCP_SEQ	snd_nxt;	/* æ¬¡ã«éä¿¡ãã SEQ		*/
+	T_TCP_SEQ	snd_old_nxt;	/* å
+ã® snd_nxt			*/
+	T_TCP_SEQ	snd_wl1;	/* ååã¦ã£ã³ããæ´æ°ãã SEQ	*/
+	T_TCP_SEQ	snd_wl2;	/* ååã¦ã£ã³ããæ´æ°ãã ACK	*/
+	T_TCP_SEQ	iss;		/* èªåã® SEQ ã®åæå¤		*/
+	T_TCP_SEQ	irs;		/* ç¸æã® SEQ ã®åæå¤		*/
+	T_TCP_SEQ	rcv_nxt;	/* åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ	*/
+	T_TCP_SEQ	rcv_adv;	/* åä¿¡ãæå¾
+ãã¦ããæå¤§ã® SEQ	*/
+	T_TCP_SEQ	rcv_wnd;	/* åä¿¡å¯è½ãªã¦ã£ã³ããµã¤ãº	*/
+	T_TCP_SEQ	rtseq;		/* æéè¨æ¸¬ãå§ãã SEQ		*/
+	T_TCP_SEQ	last_ack_sent;	/* æå¾ã«éä¿¡ãã ACK		*/
+	T_TCP_TIME	idle;		/* ã¢ã¤ãã«æé			*/
+	ER		error;		/* éåæã«çºçããã¨ã©ã¼	*/
+	ER		net_error;	/* ãããã¯ã¼ã¯ã®ã¨ã©ã¼ç¶æ
+	*/
+	T_TCP_WND	snd_wnd;	/* ç¸æã®åä¿¡å¯è½ã¦ã£ã³ããµã¤ãº	*/
+	T_TCP_WND	max_sndwnd;	/* ä»ã¾ã§ã®æå¤§éä¿¡ã¦ã£ã³ããµã¤ãº	*/
+	T_TCP_TIME	rtt;		/* å¾å¾©æé				*/
+	uint16_t	swbuf_count;	/* éä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãº	*/
+	uint16_t	rwbuf_count;	/* åä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãº	*/
+	uint16_t	rcv_buf_len;	/* tcp_rcv_buf ã®å²å½ã¦é·	*/
+	uint16_t	get_buf_len;	/* tcp_rcv_buf ã®å²å½ã¦é·	*/
+	uint8_t		rxtshift;	/* åéä¿¡åæ°ã® log(2)		*/
+	uint8_t		fsm_state;	/* FSM ç¶æ
+			*/
+	uint8_t		dupacks;	/* åé ACK æ°			*/
+
+#if defined(TCP_CFG_RWBUF_CSAVE) && defined(TCP_CFG_RWBUF_CSAVE_MAX_QUEUES)
+	uint16_t	rwbufq_entries;	/* åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ã®ã¨ã³ããªæ°	*/
+#endif
+
+	} T_TCP_CEP;
+
+#define T_TCP6_CEP	T_TCP_CEP
+#define T_TCP4_CEP	T_TCP_CEP
+
+/*
+ * Time Wait ç¨ TCP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_tcp_twcep {
+	int_t		rbufsz;		/* åä¿¡ç¨ã¦ã£ã³ããããã¡ãµã¤ãº	*/
+	T_TCP_TIME	timer_2msl;	/* 2MSL ã¿ã¤ã			*/
+	T_IPEP		dstaddr;	/* ç¸æã®ã¢ãã¬ã¹		*/
+	T_IPEP		myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	T_TCP_SEQ	snd_una;	/* æªç¢ºèªã®æå°éä¿¡ SEQ ã¤ã¾ã	*/
+					/* ç¢ºèªãããæå¤§éä¿¡ SEQ	*/
+	T_TCP_SEQ	rcv_nxt;	/* åä¿¡ãæå¾
+ãã¦ããæå°ã® SEQ	*/
+	uint16_t	rwbuf_count;	/* åä¿¡ã¦ã£ã³ããããã¡ã®ä½¿ç¨ä¸­ãµã¤ãº	*/
+	uint8_t		fsm_state;	/* FSM ç¶æ
+			*/
+	uint8_t	flags;			/* éä¿¡ç«¯ç¹ãã©ã°		*/
+
+	} T_TCP_TWCEP;
+
+#define T_TCP_CEP_DEFINED
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®ç¶æ
+ãã©ã°
+ */
+
+#define TCP_CEP_FLG_IPV4		ULONG_C(0x00000001)	/* IPv4 ç¨ã			*/
+#define TCP_CEP_FLG_ACK_NOW		ULONG_C(0x00000100)	/* ç´ã¡ã«ç¸æã« ACK ãéãã	*/
+#define TCP_CEP_FLG_DEL_ACK		ULONG_C(0x00000200)	/* ACK ãé
+å»¶ããã		*/
+#define TCP_CEP_FLG_SENT_FIN		ULONG_C(0x00000400)	/* FIN ãéã£ã¦ããã		*/
+#define TCP_CEP_FLG_NEED_SYN		ULONG_C(0x00000800)	/* SYN ãéä¿¡ããã		*/
+#define TCP_CEP_FLG_NEED_FIN		ULONG_C(0x00001000)	/* FIN ãéä¿¡ããã		*/
+#define TCP_CEP_FLG_FORCE		ULONG_C(0x00002000)	/* å¼·å¶éä¿¡ã			*/
+#define TCP_CEP_FLG_NO_PUSH		ULONG_C(0x00004000)	/* push ããªãã		*/
+#define TCP_CEP_FLG_NO_DELAY		ULONG_C(0x00008000)	/* é
+å»¶ããªãã			*/
+#define TCP_CEP_FLG_FORCE_CLEAR		ULONG_C(0x00010000)	/* å¼·å¶éä¿¡ããå¾ãã©ã°ãã¯ãªã¢ã¼ããã*/
+#define TCP_CEP_FLG_POST_OUTPUT		ULONG_C(0x00020000)	/* éä¿¡ãéå§ããã		*/
+#define TCP_CEP_FLG_RESERVE_OUTPUT	ULONG_C(0x00040000)	/* éä¿¡ãäºç´ããã		*/
+#define TCP_CEP_FLG_DYNAMIC		ULONG_C(0x00100000)	/* åççæã»åé¤å¯è½éä¿¡ç«¯ç¹ã	*/
+#define TCP_CEP_FLG_VALID		ULONG_C(0x00200000)	/* çææ¸ã¿ã§æå¹ãªéä¿¡ç«¯ç¹ã	*/
+#define TCP_CEP_FLG_CLOSE_AFTER_OUTPUT	ULONG_C(0x00400000)	/* éä¿¡ããå¾ã³ãã¯ã·ã§ã³ãéããã*/
+#define TCP_CEP_FLG_RESTORE_NEXT_OUTPUT	ULONG_C(0x00800000)	/* éä¿¡ããå¾ãsnd_nxt ãå
+ã«æ»ãã*/
+
+/* éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ */
+#define TCP_CEP_FLG_WBCS_NBUF_REQ	ULONG_C(0x80000000)	/* ãããã¯ã¼ã¯ãããã¡å²å½ã¦è¦æ±*/
+#define TCP_CEP_FLG_WBCS_MASK		ULONG_C(0x70000000)	/* ãã¹ã¯			*/
+#define TCP_CEP_FLG_WBCS_FREE		ULONG_C(0x00000000)	/* éä¿¡ã¦ã£ã³ããããã¡æªä½¿ç¨	*/
+#define TCP_CEP_FLG_WBCS_WOPEN_PEND	ULONG_C(0x10000000)	/* ç¸æã®åä¿¡ã¦ã£ã³ãã®éãå¾
+ã¡	*/
+#define TCP_CEP_FLG_WBCS_NBUF_PEND	ULONG_C(0x20000000)	/* ãããã¯ã¼ã¯ãããã¡äºç´å¾
+ã¡	*/
+#define TCP_CEP_FLG_WBCS_NBUF_RSVD	ULONG_C(0x30000000)	/* ãããã¯ã¼ã¯ãããã¡äºç´æ¸ã¿	*/
+#define TCP_CEP_FLG_WBCS_NBUF_READY	ULONG_C(0x40000000)	/* ãããã¯ã¼ã¯ãããã¡å²å½ã¦æ¸ã¿*/
+#define TCP_CEP_FLG_WBCS_SEND_READY	ULONG_C(0x50000000)	/* éä¿¡å¯è½			*/
+#define TCP_CEP_FLG_WBCS_SENT		ULONG_C(0x60000000)	/* éä¿¡æ¸ã¿ã§ãACKå¾
+ã¡		*/
+#define TCP_CEP_FLG_WBCS_ACKED		ULONG_C(0x70000000)	/* éä¿¡æ¸ã¿ã§ãACKå®äº		*/
+
+/* åæåããé¤å¤ãããã©ã°ã®å®ç¾© */
+#define TCP_CEP_FLG_NOT_CLEAR		(TCP_CEP_FLG_WBCS_NBUF_REQ|TCP_CEP_FLG_WBCS_MASK|\
+					 TCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4)
+
+/*
+ *  éä¿¡ç«¯ç¹ã¤ãã³ããã©ã°
+ */
+
+#define TCP_CEP_EVT_ESTABLISHED		ULONG_C(0x00000001)	/* ã³ãã¯ã·ã§ã³ç¢ºç«		*/
+#define TCP_CEP_EVT_CLOSED		ULONG_C(0x00000002)	/* æªä½¿ç¨ç¶æ
+			*/
+#define TCP_CEP_EVT_SWBUF_READY		ULONG_C(0x00000004)	/* éä¿¡ã¦ã£ã³ããããã¡ç©ºã	*/
+#define TCP_CEP_EVT_RWBUF_READY		ULONG_C(0x00000008)	/* éä¿¡ã¦ã£ã³ããããã¡ãã¼ã¿ãã*/
+#define TCP_CEP_EVT_ALL			ULONG_C(0xffffffff)	/* å
+¨ã¤ãã³ã			*/
+
+/*
+ *  è¿½å  API æ©è½ã»äºè±¡ã³ã¼ã
+ */
+
+/* TCP é¢ä¿ */
+
+#define TFN_TCP_UNDEF		(0)
+
+/*
+ *  srtt:   å¹³æ»åããã RTT
+ *  rttvar: å¹³æ»åãããåæ£
+ *  rtt:    æ¸¬å®ãããå¾å¾©æé
+ *
+ *  å¹³æ»åããã RTT (srtt) ã¨å¹³æ»åãããåæ£ (rttvar) ã
+ *  æ´æ°åã§è¨ç®ããããã«ãå·¦ã·ãããã¦ã¹ã±ã¼ã«ããã
+ *  srtt ã¯ 2 é²å°æ°ç¹ä»¥ä¸ 3 ãããã
+ *  rttvar ã¯ 2 é²å°æ°ç¹ä»¥ä¸ 2 ããããä¿æããã
+ */
+
+#define TCP_DELTA_SHIFT		2
+			/* å·®å = rtt/8 + srtt*7/8 ã®è¨ç®ã®ããã®ã·ããå¤	*/
+#define TCP_SRTT_SHIFT		(TCP_DELTA_SHIFT + 3)
+					/* srtt ã®ã·ããå¤ã3(+2)ããã	*/
+#define TCP_RTTVAR_SHIFT	(TCP_DELTA_SHIFT + 2)
+					/* rttvar ã®ã·ããå¤ã2(+2)ããã	*/
+#define TCP_SRTT_SCALE		(1<<TCP_SRTT_SHIFT)
+#define TCP_RTTVAR_SCALE	(1<<TCP_RTTVAR_SHIFT)
+
+/*
+ *  é«éåè»¢éãéå§ããåé ACK æ°ã®ãããå¤
+ */
+
+#define MAX_TCP_REXMT_THRESH	3
+
+/*
+ *  åä¿¡åæ§æã­ã¥ã¼ã§ã® TCP ããã
+ */
+
+typedef struct t_tcp_q_hdr {
+	uint16_t	sport;		/* éä¿¡å
+ãã¼ãçªå·			*/
+	uint16_t	dport;		/* å®å
+ãã¼ãçªå·			*/
+
+	uint32_t	seq;		/* SEQ çªå·				*/
+
+	T_NET_BUF 	*next;		/* æ¬¡ã®ã»ã°ã¡ã³ããå
+ã¯ ACK çªå·(ack)	*/
+
+	uint8_t		doff;		/* ãã¼ã¿ãªãã»ãã(ä¸ä½4ããã)	*/
+	uint8_t		flags;		/* ãã©ã°(ä¸ä½6ããã)			*/
+	uint16_t	soff;		/* SDU ãªãã»ãããå
+ã¯ã¦ã£ã³ããµã¤ãº(win)	*/
+
+	uint16_t	slen;		/* SDU é·ãå
+ã¯ãã§ãã¯ãµã (sum)	*/
+	uint16_t	urp;		/* ç·æ¥ãã¤ã³ã¿ï¼SDU é·è£æ­£ï¼		*/
+	} T_TCP_Q_HDR;
+
+#define GET_TCP_Q_HDR(nbuf,thoff)	((T_TCP_Q_HDR*)((uint8_t*)((nbuf)->buf) + thoff))
+
+/*
+ *  ãªãã¸ã§ã¯ã ID ã®æå°å¤ã®å®ç¾©
+ */
+
+#define	TMIN_TCP_REPID		1			/* TCP      åä»å£ ID ã®æå°å¤			*/
+#define	TMIN_TCP6_REPID		1			/* TCP/IPv6 åä»å£ ID ã®æå°å¤			*/
+#define	TMIN_TCP4_REPID		(TNUM_TCP6_REPID+1)	/* TCP/IPv4 åä»å£ ID ã®æå°å¤			*/
+
+#define	TMIN_TCP_CEPID		1			/* TCP      éä¿¡ç«¯ç¹ ID ã®æå°å¤			*/
+#define	TMIN_TCP6_CEPID		1			/* TCP/IPv6 éä¿¡ç«¯ç¹ ID ã®æå°å¤			*/
+#define	TMIN_TCP4_CEPID		(TNUM_TCP6_CEPID+1)	/* TCP/IPv4 éä¿¡ç«¯ç¹ ID ã®æå°å¤			*/
+
+#define	TMIN_TCP_TWCEPID	1			/* Time Wait ç¨ TCP éä¿¡ç«¯ç¹ ID ã®æå°å¤	*/
+
+/*
+ *  å¶å¾¡ã»ã°ã¡ã³ãï¼ãã¼ã¿ãªãï¼ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+#if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE)
+
+typedef struct t_net_buf_cseg {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_HDR_SIZE + IP_HDR_SIZE + TCP_HDR_SIZE];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF_CSEG;
+
+#endif	/* of #if defined(IF_HDR_SIZE) && defined(IP_HDR_SIZE) */
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_tcp_stats {
+	uint32_t	tcpActiveOpens;
+	uint32_t	tcpPassiveOpens;
+	uint32_t	tcpAttemptFails;
+	uint32_t	tcpEstabResets;
+/*	uint32_t	tcpCurrEstab;*/
+	uint32_t	tcpInSegs;
+	uint32_t	tcpOutSegs;
+	uint32_t	tcpRetransSegs;
+	uint32_t	tcpInErrs;
+	uint32_t	tcpOutRsts;
+} T_TCP_STATS;
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+/* TCP åä»å£ */
+
+#define VALID_TCP6_REPID(id)	(TMIN_TCP6_REPID<=(id)&&(id)<=tmax_tcp6_repid)
+#define VALID_TCP4_REPID(id)	(TMIN_TCP4_REPID<=(id)&&(id)<=tmax_tcp4_repid)
+
+#define INDEX_TCP6_REP(id)	((id)-TMIN_TCP6_REPID)
+#define INDEX_TCP4_REP(id)	((id)-TMIN_TCP4_REPID)
+
+#define GET_TCP6_REP(id)	(&(tcp6_rep[INDEX_TCP6_REP(id)]))
+#define GET_TCP4_REP(id)	(&(tcp4_rep[INDEX_TCP4_REP(id)]))
+
+#define GET_TCP6_REPID(rep)	((ID)(((rep)-tcp6_rep)+TMIN_TCP6_REPID))
+#define GET_TCP4_REPID(rep)	((ID)(((rep)-tcp4_rep)+TMIN_TCP4_REPID))
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#define VALID_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_VALID)!=0)
+#define DYNAMIC_TCP_REP(rep)	(((rep)->flags&TCP_REP_FLG_DYNAMIC)!=0)
+
+#else	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#define VALID_TCP_REP(rep)	(true)
+#define DYNAMIC_TCP_REP(rep)	(false)
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+#define VALID_TCP_CEPID(id)	(TMIN_TCP_CEPID<=(id)&&(id)<=tmax_tcp_cepid)
+#define INDEX_TCP_CEP(id)	((id)-TMIN_TCP_CEPID)
+
+#define GET_TCP_CEP(id)		(&(tcp_cep[INDEX_TCP_CEP(id)]))
+
+#define GET_TCP_CEPID(cep)	((ID)(((cep)-tcp_cep)+TMIN_TCP_CEPID))
+#define GET_TCP_TWCEPID(cep)	((ID)(((cep)-tcp_twcep)+TMIN_TCP_TWCEPID))
+
+#define VALID_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_VALID)!=0)
+#define DYNAMIC_TCP_CEP(cep)	(((cep)->flags&TCP_CEP_FLG_DYNAMIC)!=0)
+#define TCP_IS_CEP_IPV6(cep)	(((cep)->flags&TCP_CEP_FLG_IPV4)==0)
+#define TCP_IS_CEP_IPV4(cep)	(((cep)->flags&TCP_CEP_FLG_IPV4)!=0)
+
+#define IS_TFN_TCP_RCV(t)	((t)==TFN_TCP_ACP_CEP||(t)==TFN_TCP_RCV_DAT||\
+				 (t)==TFN_TCP_CLS_CEP||\
+				 (t)==TFN_TCP_RCV_BUF||(t)==TFN_TCP_REL_BUF||\
+				 (t)==TFN_TCP_RCV_OOB)
+
+#define VALID_TFN_TCP_CAN(t)	((t)==TFN_TCP_ACP_CEP||(t)==TFN_TCP_CON_CEP||\
+				 (t)==TFN_TCP_CLS_CEP||\
+				 (t)==TFN_TCP_SND_DAT||(t)==TFN_TCP_RCV_DAT||\
+				 (t)==TFN_TCP_GET_BUF||(t)==TFN_TCP_RCV_BUF||\
+				 (t)==TFN_TCP_SND_OOB||\
+				 (t)==TFN_TCP_ALL)
+
+#define VALID_URG_POINTER(urg)	(TCP_CFG_URG_OFFSET==0||urg!=0)
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+extern uint8_t tcp_initialized;
+
+extern T_TCP_STATS tcp_stats;
+
+/* TCP åä»å£ */
+
+extern T_TCP6_REP tcp6_rep[];
+extern T_TCP4_REP tcp4_rep[];
+
+#if defined(SUPPORT_INET6)
+#define tcp_rep	tcp6_rep
+#elif defined(SUPPORT_INET4)
+#define tcp_rep	tcp4_rep
+#endif
+
+extern const ID tmax_tcp_repid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_tcp6_repid;
+extern const ID tmax_tcp4_repid;
+#else
+#define tmax_tcp6_repid	tmax_tcp_repid
+#define tmax_tcp4_repid	tmax_tcp_repid
+#endif
+
+/* TCP éä¿¡ç«¯ç¹ */
+
+extern T_TCP_CEP tcp_cep[];
+extern T_TCP_TWCEP tcp_twcep[];
+
+extern const ID tmax_tcp_cepid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_tcp6_cepid;
+extern const ID tmax_tcp4_cepid;
+#else
+#define tmax_tcp6_cepid	tmax_tcp_cepid
+#define tmax_tcp4_cepid	tmax_tcp_cepid
+#endif
+
+/*
+ *  Inline é¢æ°
+ */
+
+#ifndef TCP_CFG_RWBUF_CSAVE
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã
+ *  ç¡å¹ã®å ´åã¯ä½ãããªãããã®ããã¼ã®é¢æ°
+ */
+
+/*
+ *  tcp_free_rwbufq -- åä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ãè§£æ¾ããã
+ */
+
+Inline void
+tcp_free_rwbufq_ncs (T_TCP_CEP *cep)
+{
+	}
+
+#endif	/* of #ifndef TCP_CFG_RWBUF_CSAVE */
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®ã¿ã
+ *  æå¹ã®å ´åã¯ä½ãããªãããã®ããã¼ã®é¢æ°
+ */
+
+/*
+ *  tcp_read_swbuf_cs -- éä¿¡ã¦ã£ã³ããããã¡ãããã¼ã¿ãèª­ã¿åºãã
+ */
+
+Inline void
+tcp_read_swbuf_cs (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff)
+{
+	}
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#ifndef TCP_CFG_SWBUF_CSAVE
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã
+ *  ç¡å¹ã®å ´åã¯ä½ãããªãããã®ããã¼ã®é¢æ°
+ */
+
+/*
+ *  tcp_free_swbufq -- éä¿¡ã¦ã£ã³ããããã¡ã­ã¥ã¼ãè§£æ¾ããã
+ */
+
+Inline void
+tcp_free_swbufq_ncs (T_TCP_CEP *cep)
+{
+	}
+
+/*
+ *  tcp_alloc_swbuf -- éä¿¡ã¦ã£ã³ããããã¡ç¨ã®ãããã¯ã¼ã¯ãããã¡ã®å²ãå½ã¦ãæç¤ºããã
+ */
+
+Inline void
+tcp_alloc_swbuf_ncs (T_TCP_CEP *cep)
+{
+	}
+
+/*
+ *  tcp_push_res_nbuf -- ãããã¯ã¼ã¯ãããã¡ãäºç´ããã
+ */
+
+Inline T_NET_BUF *
+tcp_push_res_nbuf_ncs (T_NET_BUF *nbuf)
+{
+	return nbuf;
+	}
+
+/*
+ *  tcp_pull_res_nbuf -- äºç´ãã¦ãããããã¯ã¼ã¯ãããã¡è¿ãã
+ */
+
+Inline T_NET_BUF *
+tcp_pull_res_nbuf_ncs (ATR nbatr)
+{
+	return NULL;
+	}
+
+#endif	/* of #ifndef TCP_CFG_SWBUF_CSAVE */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®åãæ¿ããã¯ã­
+ */
+
+#ifdef TCP_CFG_RWBUF_CSAVE
+
+#ifdef TCP_CFG_RWBUF_CSAVE_ONLY
+
+#define TCP_FREE_RWBUFQ(cep)			tcp_free_rwbufq_cs(cep)
+#define TCP_DROP_RWBUF(cep,len)			tcp_drop_rwbuf_cs(cep,len)
+#define TCP_READ_RWBUF(cep,data,len)		tcp_read_rwbuf_cs(cep,data,len)
+#define TCP_GET_RWBUF_ADDR(cep,buf)		tcp_get_rwbuf_addr_cs(cep,buf)
+#define TCP_WRITE_RWBUF(cep,input,thoff)	tcp_write_rwbuf_cs(cep,input,thoff)
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#define TCP_FREE_RWBUFQ(cep)			tcp_free_rwbufq(cep)
+#define TCP_DROP_RWBUF(cep,len)			tcp_drop_rwbuf(cep,len)
+#define TCP_READ_RWBUF(cep,data,len)		tcp_read_rwbuf(cep,data,len)
+#define TCP_GET_RWBUF_ADDR(cep,buf)		tcp_get_rwbuf_addr(cep,buf)
+#define TCP_WRITE_RWBUF(cep,input,thoff)	tcp_write_rwbuf(cep,input,thoff)
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+
+#define TCP_FREE_RWBUFQ(cep)			tcp_free_rwbufq_ncs(cep)
+#define TCP_DROP_RWBUF(cep,len)			tcp_drop_rwbuf_ncs(cep,len)
+#define TCP_READ_RWBUF(cep,data,len)		tcp_read_rwbuf_ncs(cep,data,len)
+#define TCP_GET_RWBUF_ADDR(cep,buf)		tcp_get_rwbuf_addr_ncs(cep,buf)
+#define TCP_WRITE_RWBUF(cep,input,thoff)	tcp_write_rwbuf_ncs(cep,input,thoff)
+
+#endif	/* of #ifdef TCP_CFG_RWBUF_CSAVE */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ã®åãæ¿ããã¯ã­
+ */
+
+#ifdef TCP_CFG_SWBUF_CSAVE
+
+#define TCP_PUSH_RES_NBUF(nbuf)			tcp_push_res_nbuf(nbuf)
+#define TCP_PULL_RES_NBUF(atr)			tcp_pull_res_nbuf(atr)
+
+#ifdef TCP_CFG_SWBUF_CSAVE_ONLY
+
+#define TCP_FREE_SWBUFQ(cep)			tcp_free_swbufq_cs(cep)
+#define TCP_ALLOC_SWBUF(cep)			tcp_alloc_swbuf_cs(cep)
+#define TCP_DROP_SWBUF(cep,len)			tcp_drop_swbuf_cs(cep,len)
+#define TCP_WRITE_SWBUF(cep,data,len)		tcp_write_swbuf_cs(cep,data,len)
+#define TCP_READ_SWBUF(cep,output,len,doff)	tcp_read_swbuf_cs(cep,output,len,doff)
+#define TCP_WAIT_SWBUF(cep,tmout)		tcp_wait_swbuf_cs(cep,tmout)
+#define TCP_GET_SWBUF_ADDR(cep,buf)		tcp_get_swbuf_addr_cs(cep,buf)
+#define TCP_SEND_SWBUF(cep,len)			tcp_send_swbuf_cs(cep,len)
+#define TCP_IS_SWBUF_FULL(cep)			tcp_is_swbuf_full_cs(cep)
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#define TCP_FREE_SWBUFQ(cep)			tcp_free_swbufq(cep)
+#define TCP_ALLOC_SWBUF(cep)			tcp_alloc_swbuf(cep)
+#define TCP_DROP_SWBUF(cep,len)			tcp_drop_swbuf(cep,len)
+#define TCP_WRITE_SWBUF(cep,data,len)		tcp_write_swbuf(cep,data,len)
+#define TCP_READ_SWBUF(cep,output,len,doff)	tcp_read_swbuf(cep,output,len,doff)
+#define TCP_WAIT_SWBUF(cep,tmout)		tcp_wait_swbuf(cep,tmout)
+#define TCP_GET_SWBUF_ADDR(cep,buf)		tcp_get_swbuf_addr(cep,buf)
+#define TCP_SEND_SWBUF(cep,len)			tcp_send_swbuf(cep,len)
+#define TCP_IS_SWBUF_FULL(cep)			tcp_is_swbuf_full(cep)
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#else	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+#define TCP_READ_SWBUF(cep,output,len,doff)	tcp_read_swbuf_ncs(cep,output,len,doff)
+#define TCP_FREE_SWBUFQ(cep)			tcp_free_swbufq_ncs(cep)
+#define TCP_ALLOC_SWBUF(cep)			tcp_alloc_swbuf_ncs(cep)
+#define TCP_PUSH_RES_NBUF(nbuf)			tcp_push_res_nbuf_ncs(nbuf)
+#define TCP_PULL_RES_NBUF(atr)			tcp_pull_res_nbuf_ncs(atr)
+#define TCP_DROP_SWBUF(cep,len)			tcp_drop_swbuf_ncs(cep,len)
+#define TCP_WRITE_SWBUF(cep,data,len)		tcp_write_swbuf_ncs(cep,data,len)
+#define TCP_WAIT_SWBUF(cep,tmout)		tcp_wait_swbuf_ncs(cep,tmout)
+#define TCP_GET_SWBUF_ADDR(cep,buf)		tcp_get_swbuf_addr_ncs(cep,buf)
+#define TCP_SEND_SWBUF(cep,len)			tcp_send_swbuf_ncs(cep,len)
+#define TCP_IS_SWBUF_FULL(cep)			tcp_is_swbuf_full_ncs(cep)
+
+#endif	/* of #ifdef TCP_CFG_SWBUF_CSAVE */
+
+/*
+ *  é¢æ°
+ */
+
+extern uint_t tcp_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern void tcp_init (void);
+extern void tcp_init_iss (void);
+extern T_TCP_CEP *tcp_close (T_TCP_CEP *cep);
+extern T_TCP_CEP *tcp_drop  (T_TCP_CEP *cep, ER errno);
+extern void tcp_respond (T_NET_BUF *nbuf, T_TCP_CEP *cep,
+                         T_TCP_SEQ ack, T_TCP_SEQ seq, uint_t rbfree, uint8_t flags);
+extern ER tcp_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                           uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
+extern ER tcpn_get_segment (T_NET_BUF **nbuf, T_TCP_CEP *cep,
+                            uint_t optlen, uint_t len, uint_t maxlen, ATR nbatr, TMO tmout);
+extern void tcp_init_cep (T_TCP_CEP *cep);
+extern void tcp_notify (T_NET_BUF *input, int code);
+extern T_TCP_TIME tcp_rexmt_val (T_TCP_CEP *cep);
+extern void tcp_set_persist_timer (T_TCP_CEP *cep);
+extern void tcp_cancel_timers (T_TCP_CEP *cep);
+extern void tcp_alloc_auto_port (T_TCP_CEP *cep);
+extern ER tcp_alloc_port (T_TCP_CEP *cep, uint16_t portno);
+extern ER tcp_lock_cep (ID cepid, T_TCP_CEP **p_cep, FN tfn);
+extern void tcp_free_reassq (T_TCP_CEP *cep);
+extern ER tcp_can_send_more (T_TCP_CEP *cep, FN fncd, TMO tmout);
+extern ER tcp_can_recv_more (ER *error, T_TCP_CEP *cep, FN fncd, TMO tmout);
+extern uint8_t tcp_move_ra2rw (T_TCP_CEP *cep, uint8_t flags);
+extern uint8_t tcp_write_raque (T_NET_BUF *input, T_TCP_CEP *cep, uint_t thoff, uint8_t flags);
+extern ER tcp_wait_rwbuf (T_TCP_CEP *cep, TMO tmout);
+extern T_TCP_CEP *tcp_user_closed (T_TCP_CEP *cep);
+extern T_TCP_CEP *tcp_find_cep (T_NET_BUF *input, uint_t off);
+extern T_TCP_TWCEP*tcp_find_twcep (T_NET_BUF *input, uint_t off);
+extern bool_t tcp_is_addr_accept (T_NET_BUF *input, uint_t off);
+extern void tcp_move_twcep (T_TCP_CEP *cep);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ç¨é¢æ°
+ */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã®å ´åã
+ *  é¢æ°ã®é¸æã«ä½¿ç¨ããã
+ */
+
+extern void tcp_free_rwbufq (T_TCP_CEP *cep);
+extern void tcp_drop_rwbuf (T_TCP_CEP *cep, uint_t len);
+extern void tcp_write_rwbuf (T_TCP_CEP *cep, T_NET_BUF *input, uint_t tcpoff);
+extern uint_t tcp_read_rwbuf (T_TCP_CEP *cep, void *data, uint_t len);
+extern uint_t tcp_get_rwbuf_addr (T_TCP_CEP *cep, void **p_buf);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ç¨é¢æ°
+ */
+
+extern void tcp_free_rwbufq_cs (T_TCP_CEP *cep);
+extern void tcp_drop_rwbuf_cs (T_TCP_CEP *cep, uint_t len);
+extern void tcp_write_rwbuf_cs (T_TCP_CEP *cep, T_NET_BUF *input, uint_t tcpoff);
+extern uint_t tcp_read_rwbuf_cs (T_TCP_CEP *cep, void *data, uint_t len);
+extern uint_t tcp_get_rwbuf_addr_cs (T_TCP_CEP *cep, void **p_buf);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®åä¿¡ã¦ã£ã³ããããã¡ã®ãéãçã³ãã¼æ©è½ç¨é¢æ°
+ */
+
+extern void tcp_free_rwbufq_ncs (T_TCP_CEP *cep);
+extern void tcp_drop_rwbuf_ncs (T_TCP_CEP *cep, uint_t len);
+extern void tcp_write_rwbuf_ncs (T_TCP_CEP *cep, T_NET_BUF *input, uint_t tcpoff);
+extern uint_t tcp_read_rwbuf_ncs (T_TCP_CEP *cep, void *data, uint_t len);
+extern uint_t tcp_get_rwbuf_addr_ncs (T_TCP_CEP *cep, void **p_buf);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ç¨é¢æ°
+ */
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ãæå¹ã®å ´åã
+ *  é¢æ°ã®é¸æã«ä½¿ç¨ããã
+ */
+
+extern void tcp_free_swbufq (T_TCP_CEP *cep);
+extern void tcp_drop_swbuf (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_write_swbuf (T_TCP_CEP *cep, void *data, uint_t len);
+extern void tcp_read_swbuf (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff);
+extern void tcp_send_swbuf (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_get_swbuf_addr (T_TCP_CEP *cep, void **p_buf);
+extern ER tcp_wait_swbuf (T_TCP_CEP *cep, TMO tmout);
+extern T_NET_BUF *tcp_push_res_nbuf (T_NET_BUF *buf);
+extern T_NET_BUF *tcp_pull_res_nbuf (ATR nbatr);
+extern void tcp_alloc_swbuf (T_TCP_CEP *cep);
+extern bool_t tcp_is_swbuf_full (T_TCP_CEP *cep);
+extern void tcp_init_swbuf (T_TCP_CEP *cep);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½ç¨é¢æ°
+ */
+
+extern void tcp_free_swbufq_cs (T_TCP_CEP *cep);
+extern void tcp_drop_swbuf_cs (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_write_swbuf_cs (T_TCP_CEP *cep, void *data, uint_t len);
+extern void tcp_read_swbuf_cs (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff);
+extern void tcp_send_swbuf_cs (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_get_swbuf_addr_cs (T_TCP_CEP *cep, void **p_buf);
+extern ER tcp_wait_swbuf_cs (T_TCP_CEP *cep, TMO tmout);
+extern void tcp_alloc_swbuf_cs (T_TCP_CEP *cep);
+extern bool_t tcp_is_swbuf_full_cs (T_TCP_CEP *cep);
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éä¿¡ã¦ã£ã³ããããã¡ã®ãéãçã³ãã¼æ©è½ç¨é¢æ°
+ */
+
+extern void tcp_free_swbufq_ncs (T_TCP_CEP *cep);
+extern void tcp_drop_swbuf_ncs (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_write_swbuf_ncs (T_TCP_CEP *cep, void *data, uint_t len);
+extern void tcp_read_swbuf_ncs (T_TCP_CEP *cep, T_NET_BUF *output, uint_t len, uint_t doff);
+extern void tcp_send_swbuf_ncs (T_TCP_CEP *cep, uint_t len);
+extern ER_UINT tcp_get_swbuf_addr_ncs (T_TCP_CEP *cep, void **p_buf);
+extern ER tcp_wait_swbuf_ncs (T_TCP_CEP *cep, TMO tmout);
+extern T_NET_BUF *tcp_push_res_nbuf_ncs (T_NET_BUF *buf);
+extern T_NET_BUF *tcp_pull_res_nbuf_ncs (ATR nbatr);
+extern void tcp_alloc_swbuf_ncs (T_TCP_CEP *cep);
+extern bool_t tcp_is_swbuf_full_ncs (T_TCP_CEP *cep);
+
+/*
+ *  TCP ãããã®ãã¬ã¼ã¹åºåæ©è½ç¨é¢æ°
+ */
+extern void tcp_output_trace (T_NET_BUF *output, T_TCP_CEP *cep);
+extern void tcp_input_trace  (T_NET_BUF *input,  T_TCP_CEP *cep);
+
+/* TCP åºåã¿ã¹ã¯ */
+
+extern void	tcp_output_task(intptr_t exinf);
+
+#endif	/* of #ifndef _TCP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/tcpn_usrreq.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/tcpn_usrreq.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/tcpn_usrreq.c	(revision 317)
@@ -0,0 +1,777 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	From: @(#)tcp_usrreq.c	8.2 (Berkeley) 1/3/94
+ * $FreeBSD: src/sys/netinet/tcp_usrreq.c,v 1.40.2.3 1999/08/29 16:29:57 peter Exp $
+ */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+#if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0)
+
+/*
+ *  tcp_cre_rep -- TCP åä»å£ã®çæãæ¡å¼µæ©è½ã
+ */
+
+#ifdef __tcp_cre_rep
+
+ER
+TCP_CRE_REP (ID repid, T_TCPN_CREP *pk_crep)
+{
+	T_TCP_REP	*rep;
+	ER		error;
+
+	/* TCP åä»å£ ID ããã§ãã¯ããã*/
+	if (!VALID_TCP_REPID(repid))
+		return E_ID;
+
+	/* pk_crep ã NULL ãªãã¨ã©ã¼ */
+	if (pk_crep == NULL)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&pk_crep->myaddr.ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* TCP åä»å£ãå¾ãã*/
+	rep = GET_TCP_REP(repid);
+
+	/* TCP åä»å£ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_REP(rep))
+		return E_ID;
+
+	/* åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/*
+	 * TCP åä»å£ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
+	 */
+	if (VALID_TCP_REP(rep))
+		error = E_OBJ;
+	else {
+
+		/* TCP åä»å£çææ
+å ±ãã³ãã¼ããã*/
+		rep->repatr = pk_crep->repatr;			/* åä»å£å±æ§		*/
+		rep->myaddr.ipaddr = pk_crep->myaddr.ipaddr;	/* èªåã®ã¢ãã¬ã¹	*/
+		rep->myaddr.portno = pk_crep->myaddr.portno;	/* èªåã®ã¢ãã¬ã¹	*/
+
+		/* TCP åä»å£ãçææ¸ã¿ã«ããã*/
+		rep->flags |= TCP_REP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_cre_rep */
+
+#ifdef __tcp_del_rep
+
+/*
+ *  tcp_find_cep_rep -- TCP åä»å£ããªã³ã¯ãã¦ãã TCP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+static T_TCP_CEP*
+TCP_FIND_CEP_REP (T_TCP_REP* rep)
+{
+	T_TCP_CEP*	cep;
+
+	for (cep = &tcp_cep[tmax_tcp_cepid]; cep -- != tcp_cep; ) {
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+		if (cep->rep4 == rep)
+#else
+		if (cep->rep == rep)
+#endif
+			return cep;
+		}
+
+	return NULL;
+	}
+
+/*
+ *  tcp_del_rep_body -- TCP åä»å£ã®åé¤ãæ¡å¼µæ©è½ãã®æ¬ä½
+ */
+
+static ER
+TCP_DEL_REP_BODY (ID repid)
+{
+	T_TCP_CEP	*cep;
+	T_TCP_REP	*rep;
+	ER		error = E_OK;
+
+	/* TCP åä»å£ ID ã®ãã§ãã¯ã¯çµäºãã¦ããã*/
+
+	/* TCP åä»å£ãå¾ãã*/
+	rep = GET_TCP_REP(repid);
+
+	/* TCP åä»å£ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_TCP_REP(rep))
+		return E_ID;
+
+	/* åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/* TCP åä»å£ããã§ãã¯ãããæªçæã®å ´åã¯ã¨ã©ã¼ */
+	if (!VALID_TCP_REP(rep))
+		error = E_NOEXS;
+	else {
+		if ((cep = TCP_FIND_CEP_REP(rep)) != NULL) {
+			/*
+			 * ãã§ã«ååãªã¼ãã³ãã¦ããã¨ã
+			 *ï¼tcp_acp_cep ãå¼ã°ãã¦ããã¨ãï¼ã¯ã
+			 * tcp_acp_cep ãçµäºãããã
+			 */
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+			syscall(wai_sem(cep->semid_lock));
+
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			cep->error = E_DLT;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+			if (cep->rcv_nblk_tfn != TFN_TCP_UNDEF) {
+				if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)E_DLT);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					ER	error = E_DLT;
+
+					(*cep->callback)(GET_TCP_CEPID(cep), cep->rcv_nblk_tfn, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+					}
+				else
+					error = E_OBJ;
+				cep->rcv_nblk_tfn = TFN_TCP_UNDEF;
+				}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+			cep->rcv_tskid = TA_NULL;
+			cep->rcv_tfn   = TFN_TCP_UNDEF;
+
+			/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			}
+		else
+			error = E_OK;
+
+		/* TCP åä»å£ãæªçæã«ããã*/
+		rep->flags &= ~TCP_REP_FLG_VALID;
+		}
+
+	/* åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_del_rep */
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0) */
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+#if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0)
+
+/*
+ *  tcp_acp_cep -- æ¥ç¶è¦æ±å¾
+ã¡ (ååãªã¼ãã³)ãæ¨æºæ©è½ã
+ */
+
+#ifdef __tcp_acp_cep
+
+ER
+TCP_ACP_CEP (ID cepid, ID repid, T_IPEP *p_dstaddr, TMO tmout)
+{
+	T_TCP_REP	*rep;
+	T_TCP_CEP	*cep;
+	ER		error;
+	FLGPTN		flag;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	/*
+	 * API (tcp6_acp_cep ã¨ tcp_acp_cep) ã¨ã
+	 * TCPéä¿¡ç«¯ç¹ã®ãã­ãã³ã«ãçç¾ãã¦ããã°ã¨ã©ã¼
+	 */
+
+#if API_PROTO == API_PROTO_IPV6
+
+	if (GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	if ((GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4) == 0)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	/* TCP åä»å£ããã§ãã¯ããã*/
+	if (!VALID_TCP_REPID(repid))
+		return E_ID;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* p_dstaddr ã NULL ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/* p_dstaddr ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_ACP_CEP)) != E_OK)
+		return error;
+
+	/* CEP ã® FSM ãã¯ã­ã¼ãºç¶æ
+ã§ãªããã°ã¨ã©ã¼ã*/
+	if (cep->fsm_state != TCP_FSM_CLOSED) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
+
+	/* TCP éä¿¡ç«¯ç¹ãåæåããã*/
+	tcp_init_cep(cep);
+
+	/* TCP åä»å£ãå¾ãã*/
+
+	rep = GET_TCP_REP(repid);
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	/* TCP åä»å£ãã­ãã¯ããã*/
+	syscall(wai_sem(rep->semid_lock));
+
+	/* TCP åä»å£ããã§ãã¯ããã*/
+	if (!VALID_TCP_REP(rep)) {
+		syscall(sig_sem(rep->semid_lock));
+		error = E_NOEXS;
+		goto err_ret;
+		}
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	/* TCP éä¿¡ç«¯ç¹ã«TCPåä»å£ãè¨é²ããã*/
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV6
+
+	cep->rep = rep;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+	cep->rep4 = rep;
+
+#endif	/*of #if API_PROTO == API_PROTO_IPV6 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	cep->rep = rep;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+#ifdef TCP_CFG_EXTENTIONS
+
+	/* TCP åä»å£ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(rep->semid_lock));
+
+#endif	/* of #ifdef TCP_CFG_EXTENTIONS */
+
+	/* TCP åä»å£ã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (rep->myaddr.ipaddr == IPV4_ADDRANY)
+		memcpy(&cep->myaddr.ipaddr, &in6_addr_unspecified,
+		                      sizeof(in6_addr_unspecified));
+	else
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, rep->myaddr.ipaddr);
+	cep->myaddr.portno = rep->myaddr.portno;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	cep->myaddr = rep->myaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	/* TCP éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ãè¨­å®ããã*/
+	cep->flags |= TCP_CEP_FLG_IPV4;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+	/* éä¿¡ç«¯ç¹ãè¨­å®ããã*/
+	cep->fsm_state = TCP_FSM_LISTEN;
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV4
+
+		cep->p_dstaddr4   = p_dstaddr;
+		cep->p_dstaddr    = NULL;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+		cep->p_dstaddr4   = NULL;
+		cep->p_dstaddr    = p_dstaddr;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->p_dstaddr    = p_dstaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->rcv_nblk_tfn = TFN_TCP_ACP_CEP;
+		return E_WBLK;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/*
+		 *  FSM ã ESTABLISHED ã«ãªãã¾ã§å¾
+ã¤ã
+		 *  FSM ã CLOSED ã«ãªã£ãå ´åã¯ãã¨ã©ã¼ãçºçãããã¨ãæå³ãã¦ããã
+		 */
+		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
+		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
+		if (error == E_OK) {
+			if (cep->error != E_OK)
+				error = cep->error;
+			else if (cep->fsm_state == TCP_FSM_CLOSED)
+				error = E_TMOUT;
+			}
+
+		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
+
+		if (error == E_OK) {
+			/* ç¸æã®ã¢ãã¬ã¹ãã³ãã¼ããã*/
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+			p_dstaddr->ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
+			p_dstaddr->portno = cep->dstaddr.portno;
+#else
+			*p_dstaddr = cep->dstaddr;
+#endif
+			}
+		else {
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->rcv_tskid = TA_NULL;
+	cep->rcv_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_acp_cep */
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6 && TNUM_TCP6_REPID > 0) || (API_PROTO == API_PROTO_IPV4 && TNUM_TCP4_REPID > 0) */
+
+/*
+ *  tcp_con_cep -- æ¥ç¶è¦æ± (è½åãªã¼ãã³)ãæ¨æºæ©è½ã
+ */
+
+#ifdef __tcp_con_cep
+
+ER
+TCP_CON_CEP (ID cepid, T_IPEP *p_myaddr, T_IPEP *p_dstaddr, TMO tmout)
+{
+	T_TCP_CEP	*cep;
+	ER		error;
+	FLGPTN		flag;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+	/*
+	 * API (tcp6_acp_cep ã¨ tcp_acp_cep) ã¨ã
+	 * TCPéä¿¡ç«¯ç¹ã®ãã­ãã³ã«ãçç¾ãã¦ããã°ã¨ã©ã¼
+	 */
+
+#if API_PROTO == API_PROTO_IPV6
+
+	if (GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV6 */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	if ((GET_TCP_CEP(cepid)->flags & TCP_CEP_FLG_IPV4) == 0)
+		return E_ID;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+	/*
+	 *  ãã¦å
+ããã«ãã­ã£ã¹ãã¢ãã¬ã¹ãªãã¨ã©ã¼
+	 */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (IN4_IS_ADDR_MULTICAST(p_dstaddr->ipaddr))
+		return E_PAR;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	if (IN_IS_ADDR_MULTICAST(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/*
+	 *  p_dstaddr ã¾ãã¯ p_myaddr ã NULL ãªãã¨ã©ã¼
+	 */
+	if (p_myaddr == NULL || p_dstaddr == NULL)
+		return E_PAR;
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  p_dstaddr ã¾ãã¯ p_myaddr ã NULL ã
+	 *  tmout ã TMO_NBLK ãªãã¨ã©ã¼
+	 */
+	if (p_myaddr == NULL || p_dstaddr == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+	/*
+	 *  CEP ãã­ãã¯ããAPI æ©è½ã³ã¼ãã¨ã¿ã¹ã¯è­å¥å­ãè¨é²ããã
+	 *  ãã§ã«è¨é²ããã¦ããã°ããã³ãã£ã³ã°ä¸­ãªã®ã§ã¨ã©ã¼
+	 */
+	if ((error = tcp_lock_cep(cepid, &cep, TFN_TCP_CON_CEP)) != E_OK)
+		return error;
+
+	/* CEP ã® FSM ãã¯ã­ã¼ãºç¶æ
+ã§ãªããã°ã¨ã©ã¼ã*/
+	if (cep->fsm_state != TCP_FSM_CLOSED) {
+		error = E_OBJ;
+		goto err_ret;
+		}
+	syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_CLOSED)));
+
+	/* ã·ã¼ã±ã³ã¹çªå·ãåæåããã*/
+	if (tcp_iss == 0)
+		tcp_init_iss();
+
+	/* éä¿¡ç«¯ç¹ãåæåããã*/
+	tcp_init_cep(cep);
+
+	/*
+	 *  IP ã¢ãã¬ã¹ãè¨­å®ããã
+	 *  p_myaddr ã NADR (-1) ã§ã¯ãªããèª IP ã¢ãã¬ã¹ã ANY ã§ãªããã°ã
+	 *  æå®ããã IP ã¢ãã¬ã¹ãå²ãå½ã¦ãã
+	 */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4)
+
+	if (p_myaddr != NADR && !IN4_IS_ADDR_ANY(&p_myaddr->ipaddr))
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, p_myaddr->ipaddr);
+	else
+		in6_make_ipv4mapped(&cep->myaddr.ipaddr, IF_GET_IFNET()->in4_ifaddr.addr);
+
+	in6_make_ipv4mapped(&cep->dstaddr.ipaddr, p_dstaddr->ipaddr);
+	cep->dstaddr.portno = p_dstaddr->portno;
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+	if (p_myaddr != NADR && !IN_IS_ADDR_ANY(&p_myaddr->ipaddr))
+		cep->myaddr.ipaddr = p_myaddr->ipaddr;
+	else {
+		if (IN_ADDRWITHIFP(IF_GET_IFNET(), &cep->myaddr.ipaddr, &p_dstaddr->ipaddr) == NULL) {
+			error = E_PAR;
+			goto err_ret;
+			}
+		}
+
+	cep->dstaddr   = *p_dstaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) && (API_PROTO == API_PROTO_IPV4) */
+
+#if API_PROTO == API_PROTO_IPV4
+
+	/* TCP éä¿¡ç«¯ç¹ã®ãããã¯ã¼ã¯å±¤ãã­ãã³ã«ãè¨­å®ããã*/
+	cep->flags |= TCP_CEP_FLG_IPV4;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+	/* éä¿¡ç«¯ç¹ãè¨­å®ããã*/
+	//NET_DEBUG_TCP5("tcp_con_cep3[c=%d,d=%lI.%d,s=%lI.%d]\n",
+	cep->fsm_state = TCP_FSM_SYN_SENT;
+	cep->iss       = tcp_iss;
+	cep->timer[TCP_TIM_KEEP] = TCP_TVAL_KEEP_INIT;
+	tcp_iss += TCP_ISS_INCR() / 2;
+	init_send_seq(cep);
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+	/* ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã*/
+	if (tmout == TMO_NBLK) {
+		/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+
+#if API_PROTO == API_PROTO_IPV4
+
+		cep->p_dstaddr4   = p_dstaddr;
+		cep->p_myaddr4    = p_myaddr;
+		cep->p_dstaddr    = NULL;
+		cep->p_myaddr     = NULL;
+
+#else	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+		cep->p_dstaddr4   = NULL;
+		cep->p_myaddr4    = NULL;
+		cep->p_dstaddr    = p_dstaddr;
+		cep->p_myaddr     = p_myaddr;
+
+#endif	/* of #if API_PROTO == API_PROTO_IPV4 */
+
+#else	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->p_dstaddr    = p_dstaddr;
+		cep->p_myaddr     = p_myaddr;
+
+#endif	/* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
+
+		cep->snd_nblk_tfn = TFN_TCP_CON_CEP;
+
+		/* ã³ãã¯ã·ã§ã³ã®éè¨­ããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+		return E_WBLK;
+		}
+	else {
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+		/*
+		 *  p_myaddr ã NADR (-1) ãã
+		 *  èªãã¼ãçªå·ã TCP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+		 */
+		if (p_myaddr == NADR || p_myaddr->portno == TCP_PORTANY)
+			tcp_alloc_auto_port(cep);
+		else if ((error = tcp_alloc_port(cep, p_myaddr->portno)) != E_OK)
+			goto err_ret;
+
+		/* ã³ãã¯ã·ã§ã³ã®éè¨­ããã¹ãããã*/
+		cep->flags |= TCP_CEP_FLG_POST_OUTPUT;
+		sig_sem(SEM_TCP_POST_OUTPUT);
+
+		/*
+		 *  ã¤ãã³ãã ESTABLISHED ã«ãªãã¾ã§å¾
+ã¤ã
+		 *  ã¤ãã³ãã CLOSED ã«ãªã£ãå ´åã¯ãä½ããã®ã¨ã©ã¼ãçºçãããã
+		 *  æ¥ç¶è¦æ±ãæå¦ããããã¨ãæå³ãã¦ããã
+		 */
+		error = twai_flg(cep->est_flgid, (TCP_CEP_EVT_CLOSED |
+		                                  TCP_CEP_EVT_ESTABLISHED), TWF_ORW, &flag, tmout);
+		if (error == E_OK) {
+			if (cep->error != E_OK)
+				error = cep->error;
+			else if (cep->fsm_state == TCP_FSM_CLOSED)
+				error = E_CLS;
+			}
+
+		syscall(clr_flg(cep->est_flgid, (FLGPTN)(~TCP_CEP_EVT_ESTABLISHED)));
+
+		if (error != E_OK) {
+			/*
+			 *  éä¿¡ç«¯ç¹ããåä»å£ãè§£æ¾ãã
+			 *  ã¤ãã³ããã©ã°ãã¯ã­ã¼ãºã«è¨­å®ããã
+			 */
+			cep->rep = NULL;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+			cep->rep4 = NULL;
+#endif
+
+			cep->fsm_state = TCP_FSM_CLOSED;
+			syscall(set_flg(cep->est_flgid, TCP_CEP_EVT_CLOSED));
+			}
+
+#ifdef TCP_CFG_NON_BLOCKING
+
+		}
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING */
+
+err_ret:
+	cep->snd_tskid = TA_NULL;
+	cep->snd_tfn   = TFN_TCP_UNDEF;
+	return error;
+	}
+
+#endif	/* of #ifdef __tcp_con_cep */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp.cfg	(revision 317)
@@ -0,0 +1,75 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  UDP ã§ä½¿ç¨ããã«ã¼ãã«ãªãã¸ã§ã¯ã
+ */
+
+#ifdef SUPPORT_UDP
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãè¡ãå ´åã«çµã¿è¾¼ãã¿ã¹ã¯ã¨ã»ããã©
+ */
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+CRE_TSK(UDP_OUTPUT_TASK, {
+	TA_HLNG,
+	0,
+	udp_output_task,
+	UDP_OUT_TASK_PRIORITY,
+	UDP_OUT_TASK_STACK_SIZE,
+	NULL
+	});
+
+/* ã»ããã© */
+
+CRE_SEM(SEM_UDP_POST_OUTPUT,	{ TA_TPRI, 0, 1 });
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+CRE_SEM(SEM_UDP_CEP,		{ TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp.h	(revision 317)
@@ -0,0 +1,102 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/udp.h,v 1.6.4.1 1999/08/29 16:29:58 peter Exp $
+ */
+ 
+#ifndef _UDP_H_
+#define _UDP_H_
+
+/*
+ *  UDP ããããRFC768 åç
+§
+ */
+
+typedef struct t_udp_hdr {
+	uint16_t	sport;		/* éä¿¡å
+ãã¼ãçªå·	*/
+	uint16_t	dport;		/* å®å
+ãã¼ãçªå·	*/
+
+	uint16_t	ulen;		/* ãã¼ã¿ã°ã©ã é·	*/
+	uint16_t	sum;		/* ãã§ãã¯ãµã 		*/
+	} T_UDP_HDR;
+
+#define UDP_HDR_SIZE			(sizeof(T_UDP_HDR))
+
+#endif	/* of #ifndef _UDP_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp4_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp4_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp4_input.c	(revision 317)
@@ -0,0 +1,106 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ *  udp_reply_no_port -- éä¿¡å
+ã«ãã¼ããå®ç¾©ããã¦ããªããã¨ãéç¥ããã
+ */
+
+void
+UDP_REPLY_NO_PORT (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+
+	/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+	if (ntohl(GET_IP4_HDR(input)->dst) == IF_GET_IFNET()->in4_ifaddr.addr) {
+		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+		icmp_error(ICMP4_UNREACH_PORT, input);
+		/* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
+	
+		}
+	syscall(rel_net_buf(input));
+
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+	}
Index: asp3_gr_sakura/trunk/tinet/netinet/udp4_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp4_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp4_subr.c	(revision 317)
@@ -0,0 +1,135 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifdef DHCP_CFG
+
+/*
+ *  udp4_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IFNET	*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+
+	if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+	    ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+	    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+
+#else	/* of #ifdef DHCP_CFG */
+
+/*
+ *  udp4_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp4_is_dstaddr_accept (T_IN4_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP4_HDR	*ip4h;
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	ip4h = GET_IP4_HDR(input);
+
+	if (ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+	    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+		return true;
+	else
+		return inn4_is_dstaddr_accept(myaddr, input);
+	}
+
+#endif	/* of #ifdef DHCP_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_input.c	(revision 317)
@@ -0,0 +1,188 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_UDP
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+T_UDP_STATS udp_stats;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#undef	IN_COPY_TO_HOST
+
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
+
+#define UDP_INPUT		udp6_input
+#define UDP_INPUT_SELECT	udp6_input_select
+#define UDP_REPLY_NO_PORT	udp6_reply_no_port
+#define UDP_FIND_CEP		udp6_find_cep
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(_IP4_CFG)
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
+
+#include <netinet6/udp6_input.c>
+#include <netinet/udpn_input.c>
+
+#undef	UDP_INPUT
+#undef	UDP_INPUT_SELECT
+#undef	UDP_REPLY_NO_PORT
+#undef	UDP_FIND_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef	IN_COPY_TO_HOST
+#undef  API_PROTO
+
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \
+                          ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
+
+#define UDP_INPUT		udp4_input
+#define UDP_INPUT_SELECT	udp4_input_select
+#define UDP_REPLY_NO_PORT	udp4_reply_no_port
+#define UDP_FIND_CEP		udp4_find_cep
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
+#define API_PROTO		API_PROTO_IPV4
+
+#include <netinet/udp4_input.c>
+#include <netinet/udpn_input.c>
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_output.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_output.c	(revision 317)
@@ -0,0 +1,224 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#ifdef SUPPORT_UDP
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#undef	IN_GET_DATAGRAM
+
+#if defined(_IP6_CFG) 
+
+#define UDP_OUTPUT		udp6_output
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(_IP4_CFG)
+#define	IN_GET_DATAGRAM		inn_get_datagram
+#else
+#define	IN_GET_DATAGRAM		in6_get_datagram
+#endif
+
+#include <netinet/udpn_output.c>
+
+#undef	UDP_OUTPUT
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef  API_PROTO
+#undef	IN_GET_DATAGRAM
+
+#endif	/* of #if defined(_IP6_CFG)  */
+
+#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
+
+#define UDP_OUTPUT		udp4_output
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define API_PROTO		API_PROTO_IPV4
+
+#define	IN_GET_DATAGRAM		in4_get_datagram
+
+#include <netinet/udpn_output.c>
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
+
+/*
+ *  UDP åºåã¿ã¹ã¯
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãçµã¿è¾¼ãã ã¨ãä½¿ç¨ããã
+ */
+
+void
+udp_output_task (intptr_t exinf)
+{
+	ID	tskid;
+	int_t	ix;
+
+	get_tid(&tskid);
+	syslog(LOG_NOTICE, "[UDP OUTPUT:%d] started.", tskid);
+
+
+#if defined(_IP6_CFG) && !defined(SUPPORT_TCP)
+
+	/* IPv6 ã®ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®ãå®è¡ããã*/
+	in6_if_up(IF_GET_IFNET());
+
+#endif	/* of #if defined(_IP6_CFG) && !defined(SUPPORT_TCP) */
+
+	while (true) {
+
+		/* åºåããã¹ããããã¾ã§å¾
+ã¤ã*/
+		syscall(wai_sem(SEM_UDP_POST_OUTPUT));
+
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
+
+		for (ix = tmax_udp6_cepid; ix -- > 0; ) {
+
+			if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
+				udp6_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
+				udp6_output(&udp6_cep[ix]);
+				}
+			}
+
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
+
+		for (ix = tmax_udp4_cepid; ix -- > 0; ) {
+
+			if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
+				udp4_cep[ix].flags &= ~UDP_CEP_FLG_POST_OUTPUT;
+				udp4_output(&udp4_cep[ix]);
+				}
+			}
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
+
+		}
+	}
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_subr.c	(revision 317)
@@ -0,0 +1,207 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp_ipcp.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#include <net/if_var.h>
+
+#ifdef SUPPORT_UDP
+
+/*
+ *  å±æå¤æ°
+ */
+
+#if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0)
+
+static uint16_t udp_port_auto = UDP_PORT_FIRST_AUTO;	/* èªåå²ãå½ã¦çªå·	*/
+
+#endif	/* of #if (defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0) || (defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0) */
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
+
+#if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR)
+
+#define UDP_IS_DSTADDR_ACCEPT	udpn_is_dstaddr_accept
+
+#else	/* of #if defined(_IP4_CFG) */
+
+#define UDP_IS_DSTADDR_ACCEPT	udp6_is_dstaddr_accept
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#define UDP_SEND_DATA		udp6_send_data
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_ALLOC_PORT		udp6_alloc_port
+#define UDP_FIND_CEP		udp6_find_cep
+#define UDP_NOTIFY		udp6_notify
+#define TMAX_UDP_CEPID		tmax_udp6_cepid
+#define UDP_CEP			udp6_cep
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
+
+#include <netinet6/udp6_subr.c>
+#include <netinet/udpn_subr.c>
+
+#undef	UDP_SEND_DATA
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_ALLOC_PORT
+#undef	UDP_FIND_CEP
+#undef	UDP_NOTIFY
+#undef	UDP_IS_DSTADDR_ACCEPT
+#undef	TMAX_UDP_CEPID
+#undef	UDP_CEP
+#undef	T_UDP_CEP
+#undef  T_IPEP
+#undef  API_PROTO
+
+#endif	/* of #if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(_IP4_CFG) && ( (TNUM_UDP4_CEPID > 0) || \
+                          ((TNUM_UDP6_CEPID > 0) && defined(API_CFG_IP4MAPPED_ADDR)))
+
+#define UDP_IS_DSTADDR_ACCEPT	udp4_is_dstaddr_accept
+
+#define UDP_SEND_DATA		udp4_send_data
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_ALLOC_PORT		udp4_alloc_port
+#define UDP_FIND_CEP		udp4_find_cep
+#define UDP_NOTIFY		udp4_notify
+#define TMAX_UDP_CEPID		tmax_udp4_cepid
+#define T_UDP_CEP		T_UDP4_CEP
+#define UDP_CEP			udp4_cep
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
+
+#include <netinet/udp4_subr.c>
+#include <netinet/udpn_subr.c>
+
+#endif	/* of #if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0 */
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq.c	(revision 317)
@@ -0,0 +1,283 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+/*
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãçµè¾¼ã¾ãªãå ´åã«ãªã³ã¯ãããé¢æ°ã®å®ç¾©
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp_ipcp.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#ifdef SUPPORT_UDP
+
+/*
+ *  TINET ãã©ã¤ãã©ãªåããªãå ´åã¯ãå
+¨ã¦ã®æ©è½ã
+ *  ãªãã¸ã§ã¯ããã¡ã¤ã«ã«åºåããããããã¯ã­ãæå¹ã«ããã
+ */
+
+#ifndef UDP_CFG_LIBRARY
+
+#define __udp_send_data
+#define __udp_cre_cep
+#define __udp_del_cep
+#define __udp_can_cep
+#define __udp_set_opt
+#define __udp_get_opt
+#define __udp_can_snd
+#define __udp_can_rcv
+#define __udp_snd_dat
+#define __udp_rcv_dat
+
+#endif	/* of #ifndef UDP_CFG_LIBRARY */
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#undef	IN_GET_DATAGRAM
+#undef	IN_COPY_TO_HOST
+
+#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
+
+#define UDP_CANCEL_CEP		udp6_cancel_cep
+#define UDP_DELETE_CEP		udp6_delete_cep
+#define UDP_SET_OPTION		udp6_set_option
+#define UDP_GET_OPTION		udp6_get_option
+#define UDP_CRE_CEP		udp6_cre_cep
+#define UDP_DEL_CEP		udp6_del_cep
+#define UDP_SET_OPT		udp6_set_opt
+#define UDP_GET_OPT		udp6_get_opt
+#define UDP_SND_DAT		udp6_snd_dat
+#define UDP_RCV_DAT		udp6_rcv_dat
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_ALLOC_PORT		udp6_alloc_port
+#define UDP_SEND_DATA		udp6_send_data
+#define VALID_UDP_CEPID		VALID_UDP6_CEPID
+#define GET_UDP_CEP		GET_UDP6_CEP
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_UDPN_CCEP		T_UDP6_CCEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(_IP4_CFG)
+#define	IN_GET_DATAGRAM		inn_get_datagram
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define	IN_GET_DATAGRAM		in6_get_datagram
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
+
+#include <netinet/udpn_usrreq.c>
+
+#undef	UDP_CANCEL_CEP
+#undef	UDP_DELETE_CEP
+#undef	UDP_SET_OPTION
+#undef	UDP_GET_OPTION
+#undef	UDP_CRE_CEP
+#undef	UDP_DEL_CEP
+#undef	UDP_SET_OPT
+#undef	UDP_GET_OPT
+#undef	UDP_SND_DAT
+#undef	UDP_RCV_DAT
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_ALLOC_PORT
+#undef	UDP_SEND_DATA
+#undef	VALID_UDP_CEPID
+#undef	GET_UDP_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef	T_UDPN_CCEP
+#undef  T_IPEP
+#undef  API_PROTO
+#undef	IN_GET_DATAGRAM
+#undef	IN_COPY_TO_HOST
+
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
+
+#define UDP_CANCEL_CEP		udp4_cancel_cep
+#define UDP_DELETE_CEP		udp4_delete_cep
+#define UDP_SET_OPTION		udp4_set_option
+#define UDP_GET_OPTION		udp4_get_option
+#define UDP_CRE_CEP		udp_cre_cep
+#define UDP_DEL_CEP		udp_del_cep
+#define UDP_SET_OPT		udp_set_opt
+#define UDP_GET_OPT		udp_get_opt
+#define UDP_SND_DAT		udp_snd_dat
+#define UDP_RCV_DAT		udp_rcv_dat
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_ALLOC_PORT		udp4_alloc_port
+#define UDP_SEND_DATA		udp4_send_data
+#define VALID_UDP_CEPID		VALID_UDP4_CEPID
+#define GET_UDP_CEP		GET_UDP4_CEP
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define T_UDPN_CCEP		T_UDP_CCEP
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
+
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
+#define	IN_GET_DATAGRAM		in4_get_datagram
+
+#include <netinet/udpn_usrreq.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
+
+#if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0)
+
+/*
+ *  udp_can_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çã®ã­ã£ã³ã»ã«ãæ¨æºæ©è½ã
+ */
+
+#ifdef __udp_can_cep
+
+ER
+udp_can_cep (ID cepid, FN fncd)
+{
+	/* IPv6 ç¨ã® UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (VALID_UDP6_CEPID(cepid)) {
+
+		/* UDP éä¿¡ç«¯ç¹ãå¾ã¦ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+		return udp6_cancel_cep(GET_UDP6_CEP(cepid), fncd);
+		}
+
+	/* IPv4 ç¨ã® UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	else if (VALID_UDP4_CEPID(cepid)) {
+
+		/* UDP éä¿¡ç«¯ç¹ãå¾ã¦ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+		return udp4_cancel_cep(GET_UDP4_CEP(cepid), fncd);
+		}
+
+	else
+		return E_ID;
+	}
+
+#endif	/* of #ifdef __udp_can_cep */
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq_nblk.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq_nblk.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_usrreq_nblk.c	(revision 317)
@@ -0,0 +1,211 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+#include <net/ppp_ipcp.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/udp.h>
+#include <netinet/udp_var.h>
+
+#ifdef SUPPORT_UDP
+
+/*
+ *  TINET ãã©ã¤ãã©ãªåããªãå ´åã¯ãå
+¨ã¦ã®æ©è½ã
+ *  ãªãã¸ã§ã¯ããã¡ã¤ã«ã«åºåããããããã¯ã­ãæå¹ã«ããã
+ */
+
+#ifndef UDP_CFG_LIBRARY
+
+#define __udp_can_snd_nblk
+#define __udp_can_rcv_nblk
+#define __udp_snd_dat_nblk
+#define __udp_rcv_dat_nblk
+
+#endif	/* of #ifndef UDP_CFG_LIBRARY */
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+/*
+ *  IPv6 ã¨ IPv4 ã§å¼æ°ãç°ãªãé¢æ°ã®ã³ã³ãã¤ã«
+ */
+
+#undef	IN_COPY_TO_HOST
+
+#if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0
+
+#define UDP_SND_DAT		udp6_snd_dat
+#define UDP_RCV_DAT		udp6_rcv_dat
+#define UDP_CAN_SND		udp6_can_snd
+#define UDP_CAN_RCV		udp6_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp6_alloc_auto_port
+#define UDP_SEND_DATA		udp6_send_data
+#define VALID_UDP_CEPID		VALID_UDP6_CEPID
+#define GET_UDP_CEP		GET_UDP6_CEP
+#define GET_UDP_CEPID		GET_UDP6_CEPID
+#define T_UDP_CEP		T_UDP6_CEP
+#define T_IPEP			T_IPV6EP
+#define API_PROTO		API_PROTO_IPV6
+
+#if defined(SUPPORT_INET4)
+#define IN_COPY_TO_HOST		inn_copy_to_host
+#else
+#define IN_COPY_TO_HOST		IN6_COPY_TO_HOST
+#endif
+
+#include <netinet/udpn_usrreq_nblk.c>
+
+#undef	UDP_SND_DAT
+#undef	UDP_RCV_DAT
+#undef	UDP_CAN_SND
+#undef	UDP_CAN_RCV
+#undef	UDP_ALLOC_AUTO_PORT
+#undef	UDP_SEND_DATA
+#undef	VALID_UDP_CEPID
+#undef	GET_UDP_CEP
+#undef	GET_UDP_CEPID
+#undef	T_UDP_CEP
+#undef  T_IPEP
+#undef  API_PROTO
+#undef	IN_COPY_TO_HOST
+
+#endif	/* of #if defined(SUPPORT_INET6) && TNUM_UDP6_CEPID > 0 */
+
+#if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0
+
+#define UDP_SND_DAT		udp_snd_dat
+#define UDP_RCV_DAT		udp_rcv_dat
+#define UDP_CAN_SND		udp4_can_snd
+#define UDP_CAN_RCV		udp4_can_rcv
+#define UDP_ALLOC_AUTO_PORT	udp4_alloc_auto_port
+#define UDP_SEND_DATA		udp4_send_data
+#define VALID_UDP_CEPID		VALID_UDP4_CEPID
+#define GET_UDP_CEP		GET_UDP4_CEP
+#define GET_UDP_CEPID		GET_UDP4_CEPID
+#define T_UDP_CEP		T_UDP4_CEP
+#define T_IPEP			T_IPV4EP
+#define API_PROTO		API_PROTO_IPV4
+
+#define IN_COPY_TO_HOST		IN4_COPY_TO_HOST
+
+#include <netinet/udpn_usrreq_nblk.c>
+
+#endif	/* of #if defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0 */
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#endif	/* of #ifdef SUPPORT_UDP */
Index: asp3_gr_sakura/trunk/tinet/netinet/udp_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udp_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udp_var.h	(revision 317)
@@ -0,0 +1,334 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1989, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp_var.h	8.1 (Berkeley) 6/10/93
+ * $FreeBSD: src/sys/netinet/udp_var.h,v 1.16.2.2 1999/08/29 16:29:59 peter Exp $
+ */
+ 
+#ifndef _UDP_VAR_H_
+#define _UDP_VAR_H_
+
+/*
+ *  UDP ãããã»ãã¤ã­ã¼ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define GET_UDP_HDR(nbuf,uhoff)		((T_UDP_HDR*)((uint8_t*)((nbuf)->buf) + uhoff))
+#define GET_UDP_HDR_OFFSET(nbuf)	(GET_IF_IP_HDR_SIZE(nbuf))
+#define GET_UDP_SDU(nbuf,uhoff)		((uint8_t*)((nbuf)->buf) + uhoff+ UDP_HDR_SIZE)
+
+#define IF_IP_UDP_HDR_SIZE(nbuf)	(IF_IP_HDR_SIZE(nbuf) + UDP_HDR_SIZE)
+#define IF_IP_UDP_HDR_OFFSET(nbuf)	(IF_IP_HDR_SIZE(nbuf))
+
+/*
+ *  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#if defined(_IP4_CFG)
+
+#define IP4_UDP_HDR_SIZE		IP_UDP_HDR_SIZE
+#define IF_IP4_UDP_HDR_SIZE		IF_IP_UDP_HDR_SIZE
+#define GET_IP4_UDP_HDR_SIZE(nbuf)	GET_IP_UDP_HDR_SIZE(nbuf)	
+#define GET_IF_IP4_UDP_HDR_SIZE(nbuf)	GET_IF_IP_UDP_HDR_SIZE(nbuf)
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+/*
+ *  ã³ã¼ã«ããã¯é¢æ°ã®å®ç¾©
+ */
+
+typedef ER	(*t_udp_callback)(ID cepid, FN fncd, void *p_parblk);
+
+/*
+ *  UDP éä¿¡ç«¯ç¹
+ */
+
+/* IPv6 ç¨ UDP éä¿¡ç«¯ç¹ */
+
+typedef struct t_udp6_cep {
+
+	/*
+	 * ITRON TCP/IP APIãTCP éä¿¡ç«¯ç¹ã¨åãã¡ã³ã
+	 */
+	ATR		cepatr;		/* UDP éä¿¡ç«¯ç¹å±æ§		*/
+	T_IPV6EP	myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	t_udp_callback	callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+
+	/*
+	 * TINET ç¬èªã®ã¡ã³ã
+	 */
+	uint16_t	flags;		/* éä¿¡ç«¯ç¹ãã©ã°		*/
+	ID		semid_lock;	/* éä¿¡ç«¯ç¹ã­ãã¯		*/
+	ID		snd_tskid;	/* éä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	ID		rcv_tskid;	/* åä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	ID		rcvqid;		/* éã³ã¼ã«ããã¯ç¨åä¿¡ã­ã¥ã¼è­å¥å­*/
+	T_NET_BUF	*cb_netbuf;	/* ã³ã¼ã«ããã¯ç¨åä¿¡ãããã¯ã¼ã¯ãããã¡*/
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+	T_IPV6EP 	*snd_p_dstaddr;	/* éä¿¡ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿*/
+	T_IPV6EP 	*rcv_p_dstaddr;	/* åä¿¡ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿*/
+	void		*snd_data;	/* éä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		snd_len;	/* éä¿¡ãã¼ã¿é åã®é·ã		*/
+	void		*rcv_data;	/* åä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		rcv_len;	/* åä¿¡ãã¼ã¿é åã®é·ã		*/
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#ifdef UDP_CFG_EXTENTIONS
+	ER		error;		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼	*/
+#endif
+
+	} T_UDP6_CEP;
+
+/* IPv4 ç¨ UDP éä¿¡ç«¯ç¹ */
+
+typedef struct t_udp4_cep {
+
+	/*
+	 * ITRON TCP/IP APIãTCP éä¿¡ç«¯ç¹ã¨åãã¡ã³ã
+	 */
+	ATR		cepatr;		/* UDP éä¿¡ç«¯ç¹å±æ§		*/
+	T_IPV4EP	myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	t_udp_callback	callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+
+	/*
+	 * TINET ç¬èªã®ã¡ã³ã
+	 */
+	uint16_t	flags;		/* éä¿¡ç«¯ç¹ãã©ã°		*/
+	ID		semid_lock;	/* éä¿¡ç«¯ç¹ã­ãã¯		*/
+	ID		snd_tskid;	/* éä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	ID		rcv_tskid;	/* åä¿¡ã¿ã¹ã¯è­å¥å­		*/
+	ID		rcvqid;		/* éã³ã¼ã«ããã¯ç¨åä¿¡ã­ã¥ã¼è­å¥å­*/
+	T_NET_BUF	*cb_netbuf;	/* ã³ã¼ã«ããã¯ç¨åä¿¡ãããã¯ã¼ã¯ãããã¡*/
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+	T_IPV4EP 	*snd_p_dstaddr;	/* éä¿¡ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿*/
+	T_IPV4EP	*rcv_p_dstaddr;	/* åä¿¡ç¸æã®ã¢ãã¬ã¹ã¸ã®ãã¤ã³ã¿*/
+	void		*snd_data;	/* éä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		snd_len;	/* éä¿¡ãã¼ã¿é åã®é·ã		*/
+	void		*rcv_data;	/* åä¿¡ãã¼ã¿é åã®å
+é ­ã¢ãã¬ã¹	*/
+	int_t		rcv_len;	/* åä¿¡ãã¼ã¿é åã®é·ã		*/
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#ifdef UDP_CFG_EXTENTIONS
+	ER		error;		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼	*/
+#endif
+
+	} T_UDP4_CEP;
+
+#if defined(_IP6_CFG)
+
+#define T_UDP_CEP	T_UDP6_CEP
+
+#else	/* of #if defined(_IP6_CFG) */
+
+#if defined(_IP4_CFG)
+
+#define T_UDP_CEP	T_UDP4_CEP
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+#endif	/* of #if defined(_IP6_CFG) */
+
+/*
+ *  UDP éä¿¡ç«¯ç¹ãã©ã°
+ */
+
+#define UDP_CEP_FLG_POST_OUTPUT	UINT_C(0x0200)	/* éä¿¡ãéå§ããã		*/
+#define UDP_CEP_FLG_DYNAMIC	UINT_C(0x0400)	/* åççæã»åé¤å¯è½éä¿¡ç«¯ç¹ã	*/
+#define UDP_CEP_FLG_VALID	UINT_C(0x0800)	/* çææ¸ã¿ã§æå¹ãªéä¿¡ç«¯ç¹ã	*/
+
+/*
+ *  ãªãã¸ã§ã¯ã ID ã®æå°å¤ã®å®ç¾©
+ */
+
+#define	TMIN_UDP_CEPID		1			/* UDP      éä¿¡ç«¯ç¹ ID ã®æå°å¤ */
+#define	TMIN_UDP6_CEPID		1			/* UDP/IPv6 éä¿¡ç«¯ç¹ ID ã®æå°å¤ */
+#define	TMIN_UDP4_CEPID		(TNUM_UDP6_CEPID+1)	/* UDP/IPv4 éä¿¡ç«¯ç¹ ID ã®æå°å¤ */
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_udp_stats {
+	uint32_t	udpInDatagrams;
+	uint32_t	udpNoPorts;
+	uint32_t	udpInErrors;
+	uint32_t	udpOutDatagrams;
+} T_UDP_STATS;
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define VALID_UDP6_CEPID(id)	(TMIN_UDP6_CEPID<=(id)&&(id)<=tmax_udp6_cepid)
+#define VALID_UDP4_CEPID(id)	(TMIN_UDP4_CEPID<=(id)&&(id)<=tmax_udp4_cepid)
+
+#define INDEX_UDP6_CEP(id)	((id)-TMIN_UDP6_CEPID)
+#define INDEX_UDP4_CEP(id)	((id)-TMIN_UDP4_CEPID)
+
+#define GET_UDP6_CEP(id)	(&(udp6_cep[INDEX_UDP6_CEP(id)]))
+#define GET_UDP4_CEP(id)	(&(udp4_cep[INDEX_UDP4_CEP(id)]))
+
+#define GET_UDP6_CEPID(cep)	((ID)(((cep)-udp6_cep)+TMIN_UDP6_CEPID))
+#define GET_UDP4_CEPID(cep)	((ID)(((cep)-udp4_cep)+TMIN_UDP4_CEPID))
+
+#define VALID_TFN_UDP_CAN(t)	((t)==TFN_UDP_SND_DAT||(t)==TFN_UDP_RCV_DAT||\
+				 (t)==TFN_UDP_ALL)
+
+#define VALID_UDP_CEP(cep)	(((cep)->flags&UDP_CEP_FLG_VALID)!=0)
+#define DYNAMIC_UDP_CEP(cep)	(((cep)->flags&UDP_CEP_FLG_DYNAMIC)!=0)
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+extern T_UDP_STATS udp_stats;
+
+/* UDP éä¿¡ç«¯ç¹ */
+
+extern T_UDP6_CEP udp6_cep[];
+extern T_UDP4_CEP udp4_cep[];
+
+#if defined(SUPPORT_INET6)
+#define udp_cep	udp6_cep
+#elif defined(SUPPORT_INET4)
+#define udp_cep	udp4_cep
+#endif
+
+extern const ID tmax_udp_cepid;
+
+#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
+extern const ID tmax_udp6_cepid;
+extern const ID tmax_udp4_cepid;
+#else
+#define tmax_udp6_cepid	tmax_udp_cepid
+#define tmax_udp4_cepid	tmax_udp_cepid
+#endif
+
+/*
+ *  TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#define	TMIN_UDP_CCEPID		TMIN_UDP_CEPID
+#define	TNUM_UDP_CCEPID		TNUM_UDP_CEPID
+
+/*
+ *  é¢æ°
+ */
+
+/* IPv6 */
+
+extern uint_t udp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern ER_UINT udp6_send_data (T_UDP6_CEP *cep, T_IPV6EP *p_dstaddr,
+                               void *data, int_t len, TMO tmout);
+extern ER udp6_can_snd (T_UDP6_CEP *cep, ER error);
+extern ER udp6_can_rcv (T_UDP6_CEP *cep, ER error);
+extern ER udp6_alloc_auto_port (T_UDP6_CEP *cep);
+extern ER udp6_alloc_port (T_UDP6_CEP *cep, uint16_t portno);
+extern T_UDP6_CEP*udp6_find_cep (T_NET_BUF *input, uint_t off);
+extern void udp6_notify (T_NET_BUF *input, ER error);
+extern void udp6_input_select (T_UDP6_CEP *cep, T_NET_BUF *input, uint_t off);
+
+/* IPv4 */
+
+extern uint_t udp4_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern ER_UINT udp4_send_data (T_UDP4_CEP *cep, T_IPV4EP *p_dstaddr,
+                               void *data, int_t len, TMO tmout);
+extern ER udp4_can_snd (T_UDP4_CEP *cep, ER error);
+extern ER udp4_can_rcv (T_UDP4_CEP *cep, ER error);
+extern ER udp4_alloc_auto_port (T_UDP4_CEP *cep);
+extern ER udp4_alloc_port (T_UDP4_CEP *cep, uint16_t portno);
+extern T_UDP4_CEP*udp4_find_cep (T_NET_BUF *input, uint_t off);
+extern void udp4_notify (T_NET_BUF *input, ER error);
+extern void udp4_input_select (T_UDP4_CEP *cep, T_NET_BUF *input, uint_t off);
+
+/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãè¡ãå ´åã«çµã¿è¾¼ãã¿ã¹ã¯ */
+
+extern void	udp_output_task(intptr_t exinf);
+
+#endif	/* of #ifndef _UDP_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet/udpn_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udpn_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udpn_input.c	(revision 317)
@@ -0,0 +1,252 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#if (API_PROTO == API_PROTO_IPV6) || (TNUM_UDP4_CEPID > 0)
+
+/*
+ *  udp_input_select -- UDP ã®å
+¥åå¦çã®é¸æ
+ */
+
+void
+UDP_INPUT_SELECT (T_UDP_CEP *cep, T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+	uint_t		len;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+	len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
+
+	if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (psnd_dtq(cep->rcvqid, (intptr_t)input) != E_OK) {
+			NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+			NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+			syscall(rel_net_buf(input));
+			}
+		}
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+	else if (cep->rcv_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+		/* p_dstaddr ãè¨­å®ããã*/
+		cep->rcv_p_dstaddr->portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&cep->rcv_p_dstaddr->ipaddr, input);
+
+		/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+		memcpy(cep->rcv_data, GET_UDP_SDU(input, off),
+		       (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
+		syscall(rel_net_buf(input));
+
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
+#endif
+		else
+			syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+		cep->rcv_p_dstaddr = NULL;
+		}
+
+#endif/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+	else if (IS_PTR_DEFINED(cep->callback)) {
+
+		/* ã³ã¼ã«ããã¯é¢æ°ãå¼ã³åºãã*/
+		cep->cb_netbuf = input;
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
+#else
+		(*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
+#endif
+		/*
+		 *  ãããã¯ã¼ã¯ãããã¡ããã®ã¾ã¾ã§ããã°ãã³ã¼ã«ããã¯é¢æ°å
+ã§
+		 *  ãã¼ã¿ãèª­ã¿åºããªãã£ããã¨ã«ãªãã®ã§ãæ¨ã¦ãã
+		 */
+		if (cep->cb_netbuf != NULL)
+			syscall(rel_net_buf(cep->cb_netbuf));
+		}
+	else {
+		NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+		NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+		syscall(rel_net_buf(input));
+		}
+
+	}
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) || (TNUM_UDP4_CEPID > 0) */
+
+/*
+ *  udp_input -- UDP ã®å
+¥åé¢æ°
+ */
+
+uint_t
+UDP_INPUT (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	uint_t		hlen, ulen;
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4
+	T_UDP6_CEP	*cep6;
+#endif
+
+	hlen = (uint_t)GET_IF_IP_HDR_SIZE(input);
+
+	NET_COUNT_UDP(net_count_udp.in_octets,  input->len - hlen);
+	NET_COUNT_UDP(net_count_udp.in_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInDatagrams, 1);
+
+	/* ãããé·ããã§ãã¯ããã*/
+	if (input->len < hlen + UDP_HDR_SIZE)
+		goto buf_rel;
+
+	udph = (T_UDP_HDR *)(input->buf + *offp);
+
+	/* ãã¼ã¿ã°ã©ã é·ããã§ãã¯ãã */
+	ulen  = ntohs(udph->ulen);
+	if (ulen != input->len - hlen)
+		goto buf_rel;
+
+	/* å®å
+ãã¼ãã 0 ã®ãã¼ã¿ã°ã©ã ã¯ç ´æ£ãããRFC768 */
+	if (udph->dport == 0)
+		goto buf_rel;
+
+#ifdef UDP_CFG_IN_CHECKSUM
+
+	/* ãã§ãã¯ãµã ããã§ãã¯ãã */
+	if (udph->sum && IN_CKSUM(input, IPPROTO_UDP, *offp, ulen) != 0)
+		goto buf_rel;
+
+#endif	/* of #ifdef UDP_CFG_IN_CHECKSUM */
+
+#if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4
+
+#if TNUM_UDP4_CEPID > 0
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = udp4_find_cep(input, *offp);
+
+	if (cep != NULL)
+		udp4_input_select(cep, input, *offp);
+	else if ((cep6 = udp6_find_cep(input, *offp)) != NULL)
+		udp6_input_select(cep6, input, *offp);
+	else
+		udp4_reply_no_port(input, *offp);
+
+	return IPPROTO_DONE;
+
+#else	/* of #if TNUM_UDP4_CEPID > 0 */
+
+	cep = 0;	/* warning åé¿ç¨ã®ããã¼ */
+	if ((cep6 = udp6_find_cep(input, *offp)) != NULL)
+		udp6_input_select(cep6, input, *offp);
+	else
+		udp4_reply_no_port(input, *offp);
+
+	return IPPROTO_DONE;
+
+#endif	/* of #if TNUM_UDP4_CEPID > 0 */
+
+#else	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4 */
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = UDP_FIND_CEP(input, *offp);
+
+	if (cep != NULL)
+		UDP_INPUT_SELECT(cep, input, *offp);
+	else
+		UDP_REPLY_NO_PORT(input, *offp);
+
+	return IPPROTO_DONE;
+
+#endif	/* of #if defined(_IP6_CFG) && defined(_IP4_CFG) && API_PROTO == API_PROTO_IPV4 */
+
+buf_rel:
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
Index: asp3_gr_sakura/trunk/tinet/netinet/udpn_output.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udpn_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udpn_output.c	(revision 317)
@@ -0,0 +1,175 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ *  udp_output -- UDP ã®åºåé¢æ°
+ *  ãã³ãã­ãã­ã³ã°ã³ã¼ã«ãçµã¿è¾¼ãã ã¨ãä½¿ç¨ããã
+ */
+
+static void
+UDP_OUTPUT (T_UDP_CEP *cep)
+{
+	T_NET_BUF	*output;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+	uint16_t	sum;
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* IP ãã¼ã¿ã°ã©ã ãå²ãå½ã¦ãã*/
+	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + cep->snd_len), 0,
+	                             &cep->snd_p_dstaddr->ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_UDP, IP_DEFTTL, 
+	                             NBA_SEARCH_ASCENT, TMO_UDP_OUTPUT)) != E_OK) {
+		goto err_ret;
+		}
+
+	/* UDP ãããã«æ
+å ±ãè¨­å®ããã*/
+	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET(output));
+	udph->sport	= htons(cep->myaddr.portno);
+	udph->dport	= htons(cep->snd_p_dstaddr->portno);
+	udph->ulen	= htons(UDP_HDR_SIZE + cep->snd_len);
+	udph->sum	= 0;
+
+	/* ãã¼ã¿ãã³ãã¼ããã*/
+	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET(output)),
+	       cep->snd_data, (size_t)cep->snd_len);
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+
+	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET(output),
+	               (uint_t)(UDP_HDR_SIZE + cep->snd_len));
+
+	/* è¨ç®ãããã§ãã¯ãµã ã®å¤ã 0 ãªã 0xffff ãå
+¥ããã*/
+	if (sum == 0)
+		sum = UINT_C(0xffff);
+	udph->sum = sum;
+
+#endif/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE(output) + cep->snd_len);
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	if ((error = IP_OUTPUT(output, TMO_UDP_OUTPUT)) != E_OK)
+		goto err_ret;
+
+
+	NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
+
+	if (IS_PTR_DEFINED(cep->callback)) {
+
+		if (error == E_OK)
+			error = cep->snd_len;
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
+#else
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+#endif
+		}
+	else
+		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+	cep->snd_p_dstaddr = NULL;
+	return;
+
+err_ret:
+	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
+	if (IS_PTR_DEFINED(cep->callback)) {
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)E_NOMEM);
+
+#else	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		error = E_NOMEM;
+		(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+
+#endif	/* of #ifdef TCP_CFG_NON_BLOCKING_COMPAT14 */
+
+		}
+	else
+		syslog(LOG_WARNING, "[UDP] no call back, CEP: %d.", GET_UDP_CEPID(cep));
+	cep->snd_p_dstaddr = NULL;
+	return;
+	}
Index: asp3_gr_sakura/trunk/tinet/netinet/udpn_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udpn_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udpn_subr.c	(revision 317)
@@ -0,0 +1,170 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ *  udp_alloc_auto_port -- èªåå²ãå½ã¦ãã¼ãçªå·ãè¨­å®ããã
+ */
+
+ER
+UDP_ALLOC_AUTO_PORT (T_UDP_CEP *cep)
+{
+	int_t	ix;
+	uint16_t	portno, portno_start;
+
+	portno_start = udp_port_auto;
+	do {
+		portno = udp_port_auto ++;
+		if (udp_port_auto > UDP_PORT_LAST_AUTO)
+			udp_port_auto = UDP_PORT_FIRST_AUTO;
+
+		syscall(wai_sem(SEM_UDP_CEP));
+		for (ix = TMAX_UDP_CEPID; ix -- > 0; ) {
+			if (VALID_UDP_CEP(&UDP_CEP[ix]) && UDP_CEP[ix].myaddr.portno == portno) {
+				portno = UDP_PORTANY;
+				break;
+				}
+			}
+
+		if (portno != UDP_PORTANY) {
+			cep->myaddr.portno = portno;
+			syscall(sig_sem(SEM_UDP_CEP));
+			return E_OK;
+			}
+		syscall(sig_sem(SEM_UDP_CEP));
+
+		} while (portno_start != udp_port_auto);
+
+	return E_NOID;
+	}
+
+/*
+ *  udp_alloc_port -- æå®ããããã¼ãçªå·ãè¨­å®ããã
+ */
+
+ER
+UDP_ALLOC_PORT (T_UDP_CEP *cep, uint16_t portno)
+{
+	int_t	ix;
+
+	syscall(wai_sem(SEM_UDP_CEP));
+	for (ix = TMAX_UDP_CEPID; ix -- > 0; )
+		if (VALID_UDP_CEP(&UDP_CEP[ix]) && UDP_CEP[ix].myaddr.portno == portno) {
+			syscall(sig_sem(SEM_UDP_CEP));
+			return E_PAR;
+			}
+	cep->myaddr.portno = portno;
+	syscall(sig_sem(SEM_UDP_CEP));
+	return E_OK;
+	}
+
+/*
+ *  udp_find_cep -- ãã¼ãçªå·ãã UDP éä¿¡ç«¯ç¹ãå¾ãã
+ */
+
+T_UDP_CEP*
+UDP_FIND_CEP (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_CEP*	cep;
+	T_UDP_HDR	*udph;
+
+	udph = GET_UDP_HDR(input, off);
+	
+	/*
+	 *  IP ã¢ãã¬ã¹ã¨ãã¼ãçªå·ãä¸è´ããéä¿¡ç«¯ç¹ãæ¢ç´¢ããã
+	 */
+	for (cep = &UDP_CEP[TMAX_UDP_CEPID]; cep -- != UDP_CEP; ) {
+		if (VALID_UDP_CEP(cep)                                &&
+		    UDP_IS_DSTADDR_ACCEPT(&cep->myaddr.ipaddr, input) &&
+		    ntohs(udph->dport) == cep->myaddr.portno)
+			return cep;
+		}
+
+	return NULL;
+	}
+
+/*
+ *  udp_notify -- ICMP ã¨ã©ã¼ã®å¦ç
+ */
+
+void
+UDP_NOTIFY (T_NET_BUF *input, ER error)
+{
+	if (UDP_FIND_CEP(input, GET_UDP_HDR_OFFSET(input)) != NULL) {
+		syslog(LOG_NOTICE, "[UDP] error, code: %d.", error);
+		}
+	}
Index: asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq.c	(revision 317)
@@ -0,0 +1,776 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+#ifdef __udp_send_data
+
+/*
+ *  udp_send_data -- ãã±ããéä¿¡ã®ä¸»è¦é¨
+ */
+
+ER_UINT
+UDP_SEND_DATA (T_UDP_CEP *cep, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*output;
+	T_UDP_HDR	*udph;
+	SYSTIM		before, after;
+	ER		error = E_OK;
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+	uint16_t	sum;
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	NET_COUNT_UDP(net_count_udp.out_octets,  len);
+	NET_COUNT_UDP(net_count_udp.out_packets, 1);
+
+	/* IP ãã¼ã¿ã°ã©ã å²ãå½ã¦ã®æéã tmout ããæ¸ããã*/
+	if (!(tmout == TMO_POL || tmout == TMO_FEVR))
+		syscall(get_tim(&before));
+
+	/* IP ãã¼ã¿ã°ã©ã ãå²ãå½ã¦ãã*/
+	if ((error = IN_GET_DATAGRAM(&output, (uint_t)(UDP_HDR_SIZE + len), 0,
+	                             &p_dstaddr->ipaddr,
+	                             &cep->myaddr.ipaddr,
+	                             IPPROTO_UDP, IP_DEFTTL, 
+	                             NBA_SEARCH_ASCENT, tmout)) != E_OK)
+		goto err_ret;
+
+	/* IP ãã¼ã¿ã°ã©ã å²ãå½ã¦ã®æéã tmout ããæ¸ããã*/
+	if (!(tmout == TMO_POL || tmout == TMO_FEVR)) {
+		syscall(get_tim(&after));
+		if (after - before > tmout) {
+			syscall(rel_net_buf(output));
+			error = E_TMOUT;
+			goto err_ret;
+			}
+		tmout -= (TMO)(after - before);
+		}
+
+	/* UDP ãããã«æ
+å ±ãè¨­å®ããã*/
+	udph		= GET_UDP_HDR(output, IF_IP_UDP_HDR_OFFSET(output));
+	udph->sport	= htons(cep->myaddr.portno);
+	udph->dport	= htons(p_dstaddr->portno);
+	udph->ulen	= htons(UDP_HDR_SIZE + len);
+	udph->sum	= 0;
+
+	/* ãã¼ã¿ãã³ãã¼ããã*/
+	memcpy((void*)GET_UDP_SDU(output, IF_IP_UDP_HDR_OFFSET(output)), data, (size_t)len);
+
+#ifdef UDP_CFG_OUT_CHECKSUM
+
+	sum = IN_CKSUM(output, IPPROTO_UDP, IF_IP_UDP_HDR_OFFSET(output), (uint_t)(UDP_HDR_SIZE + len));
+
+	/* è¨ç®ãããã§ãã¯ãµã ã®å¤ã 0 ãªã 0xffff ãå
+¥ããã*/
+	if (sum == 0)
+		sum = 0xffff;
+	udph->sum = sum;
+
+#endif	/* of #ifdef UDP_CFG_OUT_CHECKSUM */
+
+	/* ãããã¯ã¼ã¯ãããã¡é·ãèª¿æ´ããã*/
+	output->len = (uint16_t)(IF_IP_UDP_HDR_SIZE(output) + len);
+
+	/* ãããã¯ã¼ã¯å±¤ (IP) ã®åºåé¢æ°ãå¼ã³åºãã*/
+	if ((error = IP_OUTPUT(output, tmout)) == E_OK) {
+		NET_COUNT_MIB(udp_stats.udpOutDatagrams, 1);
+		cep->snd_tskid = TA_NULL;
+		return len;
+		}
+
+err_ret:
+	NET_COUNT_UDP(net_count_udp.out_err_packets, 1);
+	cep->snd_tskid = TA_NULL;
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_send_data */
+
+/*
+ *  udp_cancel_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çãã­ã£ã³ã»ã«ããã
+ *
+ *    udp_can_cep ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+#ifdef __udp_can_cep
+
+static ER
+UDP_CANCEL_CEP (T_UDP_CEP *cep, FN fncd)
+{
+	ER	error = E_OK, snd_err, rcv_err;
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* API æ©è½ã³ã¼ãããã§ãã¯ããã*/
+	if (!VALID_TFN_UDP_CAN(fncd))
+		return E_PAR;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (fncd == TFN_UDP_ALL) {	/* TFN_UDP_ALL ã®å¦ç */
+
+		snd_err = UDP_CAN_SND(cep, E_RLWAI);
+		rcv_err = UDP_CAN_RCV(cep, E_RLWAI);
+
+		/*
+		 *  snd_err ã¨ rcv_err ã®ã©ã¡ãã EV_NOPND
+		 *  ãªãããã³ãã£ã³ã°ãã¦ããªãã®ã§ã¨ã©ã¼
+		 */
+		if (snd_err == EV_NOPND && rcv_err == EV_NOPND)
+			error = E_OBJ;
+		else {
+			if (snd_err == EV_NOPND)
+				snd_err = E_OK;
+			if (rcv_err == EV_NOPND)
+				rcv_err = E_OK;
+
+			if (snd_err != E_OK)
+				error = snd_err;
+			else if (rcv_err != E_OK)
+				error = rcv_err;
+			}
+		}
+	else if (fncd == TFN_UDP_SND_DAT) {	/* éä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = UDP_CAN_SND(cep, E_RLWAI)) == EV_NOPND)
+			error = E_OBJ;
+		}
+	else if (fncd == TFN_UDP_RCV_DAT) {	/* åä¿¡å¦çã®ã­ã£ã³ã»ã« */
+		if ((error = UDP_CAN_RCV(cep, E_RLWAI)) == EV_NOPND)
+			error = E_OBJ;
+		}
+	else
+		error = E_PAR;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_cep */
+
+#if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0)
+
+#else	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
+
+/*
+ *  udp_can_cep -- ãã³ãã£ã³ã°ãã¦ããå¦çã®ã­ã£ã³ã»ã«ãæ¨æºæ©è½ã
+ */
+
+#ifdef __udp_can_cep
+
+ER
+udp_can_cep (ID cepid, FN fncd)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_CANCEL_CEP(cep, fncd);
+	}
+
+#endif	/* of #ifdef __udp_can_cep */
+
+#endif	/* of #if defined(SUPPORT_INET6) && (defined(SUPPORT_INET4) && TNUM_UDP4_CEPID > 0) */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+/*
+ *  udp_cre_cep -- UDP éä¿¡ç«¯ç¹ã®çæãæ¡å¼µæ©è½ã
+ */
+
+#ifdef __udp_cre_cep
+
+ER
+UDP_CRE_CEP (ID cepid, T_UDPN_CCEP *pk_ccep)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* pk_ccep ã NULL ãªãã¨ã©ã¼ */
+	if (pk_ccep == NULL)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&pk_ccep->myaddr.ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (VALID_UDP_CEP(cep))
+		return E_OBJ;
+
+	/* UDP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_UDP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * UDP éä¿¡ç«¯ç¹ããã§ãã¯ãããçææ¸ã¿ã§ããã°ã¨ã©ã¼
+	 */
+	if (VALID_UDP_CEP(cep))
+		error = E_OBJ;
+	else {
+
+		/*
+		 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+		 */
+		if (pk_ccep->myaddr.portno == UDP_PORTANY)
+			error = UDP_ALLOC_AUTO_PORT(cep);
+		else 
+			error = UDP_ALLOC_PORT(cep, pk_ccep->myaddr.portno);
+		
+                if (error == E_OK) {
+
+			/* UDP éä¿¡ç«¯ç¹çææ
+å ±ãã³ãã¼ããã*/
+			cep->cepatr        = pk_ccep->cepatr;			/* éä¿¡ç«¯ç¹å±æ§		*/
+			cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+			cep->callback      = (void*)pk_ccep->callback;		/* ã³ã¼ã«ããã¯		*/
+
+			/* UDP éä¿¡ç«¯ç¹ãçææ¸ã¿ã«ããã*/
+			cep->flags |= UDP_CEP_FLG_VALID;
+			}
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_cre_cep */
+
+#ifdef __udp_del_cep
+
+/*
+ *  udp_delete_cep -- UDP éä¿¡ç«¯ç¹ãåé¤ããã
+ *
+ *    udp_del_cep ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_DELETE_CEP (T_UDP_CEP *cep)
+{
+	ER	error;
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* UDP éä¿¡ç«¯ç¹ããåççæç¨ã§ãªããã°ã¨ã©ã¼ */
+	if (!DYNAMIC_UDP_CEP(cep))
+		return E_ID;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	/*
+	 * UDP éä¿¡ç«¯ç¹ããã§ãã¯ãããæªçæã®å ´åã¯ã¨ã©ã¼
+	 * ã»æªçæã
+	 */
+	if (!VALID_UDP_CEP(cep))
+		error = E_NOEXS;
+	else {
+		UDP_CAN_SND(cep, E_DLT);
+		UDP_CAN_RCV(cep, E_DLT);
+
+		/* UDP éä¿¡ç«¯ç¹ãæªçæã«ããã*/
+		cep->flags &= ~UDP_CEP_FLG_VALID;
+		error = E_OK;
+		}
+
+	/* éä¿¡ç«¯ç¹ã®ã­ãã¯ãè§£é¤ããã*/
+	syscall(sig_sem(cep->semid_lock));
+
+	return error;
+	}
+
+/*
+ *  udp_del_cep -- UDP éä¿¡ç«¯ç¹ã®åé¤ãæ¡å¼µæ©è½ã
+ */
+
+ER
+UDP_DEL_CEP (ID cepid)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_DELETE_CEP(cep);
+	}
+
+#endif	/* of #ifdef __udp_del_cep */
+
+#ifdef __udp_set_opt
+
+/*
+ *  udp_set_option -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ãè¨­å®ããã
+ *
+ *    udp_set_opt ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_SET_OPTION (T_UDP_CEP *cep, int_t optname, void *optval, int_t optlen)
+{
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	return E_PAR;
+	}
+
+/*
+ *  udp_set_opt -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®è¨­å®ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+ER
+UDP_SET_OPT (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_SET_OPTION(cep, optname, optval, optlen);
+	}
+
+#endif	/* of #ifdef __udp_set_opt */
+
+#ifdef __udp_get_opt
+
+/*
+ *  udp_get_option -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ãç²å¾ããã
+ *
+ *    udp_get_opt ããå¼åºãããã¡ã¤ã³é¢æ°
+ */
+
+static ER
+UDP_GET_OPTION (T_UDP_CEP *cep, int_t optname, void *optval, int_t optlen)
+{
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	return E_PAR;
+	}
+
+/*
+ *  udp_get_opt -- UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã®ç²å¾ãæ¡å¼µæ©è½ã
+ *
+ *  æ³¨æ: è¨­å®å¯è½ãª UDP éä¿¡ç«¯ç¹ãªãã·ã§ã³ã¯ç¡ããããE_PAR ãè¿ãããã
+ */
+
+ER
+UDP_GET_OPT (ID cepid, int_t optname, void *optval, int_t optlen)
+{
+	T_UDP_CEP	*cep;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* ã¡ã¤ã³é¢æ°ãå¼ã³åºãã*/
+	return UDP_GET_OPTION(cep, optname, optval, optlen);
+	}
+
+#endif	/* of #ifdef __udp_get_opt */
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+#ifdef UDP_CFG_NON_BLOCKING
+
+#else	/* of #ifdef UDP_CFG_NON_BLOCKING */
+
+#ifdef __udp_can_snd
+
+/*
+ *  udp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_SND (T_UDP_CEP *cep, ER error)
+{
+	if (cep->snd_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->snd_tskid);
+		cep->snd_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_snd */
+
+#ifdef __udp_can_rcv
+
+/*
+ *  udp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_RCV (T_UDP_CEP *cep, ER error)
+{
+	if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->rcv_tskid);
+		cep->rcv_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_rcv */
+
+#ifdef __udp_snd_dat
+
+/*
+ *  udp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || tmout == TMO_NBLK)
+		return E_PAR;
+
+	/* ãã¼ã¿é·ããã§ãã¯ããã*/
+	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+	 */
+	if (cep->myaddr.portno == UDP_PORTANY) {
+		if ((error = UDP_ALLOC_AUTO_PORT(cep)) != E_OK)
+			return error;
+		}
+	
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (cep->snd_tskid != TA_NULL) {
+
+		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		error = E_QOVR;
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		}
+	else {
+		/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+		get_tid(&(cep->snd_tskid));
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ããªã»ããããã*/
+		cep->error = E_OK;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/* ãã±ãããéä¿¡ããã*/
+		error = UDP_SEND_DATA(cep, p_dstaddr, data, len, tmout);
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¿ãã*/
+		if (error == E_RLWAI)
+			error = cep->error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_snd_dat */
+
+#ifdef __udp_rcv_dat
+
+/*
+ *  udp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*input;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+	uint_t		ulen, uhoff;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ãlen < 0 ããtmout ã TMO_NBLK ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || len < 0 || tmout == TMO_NBLK)
+		return E_PAR;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+	syscall(wai_sem(cep->semid_lock));
+
+	if (cep->rcv_tskid != TA_NULL) {
+
+		/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		error = E_QOVR;
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		}
+	else {
+
+		/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+		get_tid(&(cep->rcv_tskid));
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ããªã»ããããã*/
+		cep->error = E_OK;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+
+		/* å
+¥åãããã¾ã§å¾
+ã¤ã*/
+		if (cep->cb_netbuf != NULL) {
+
+			/*
+			 *  ããã«ããå ´åã¯ãã³ã¼ã«ããã¯é¢æ°ã®ä¸­ãã
+			 *  udp_rcv_dat ãå¼ã³åºãã¦ãããã¨ã«ãªãã
+			 *  ãã§ã«å
+¥åæ¸ã¿ã§ããã
+			 */
+			input = cep->cb_netbuf;
+			cep->cb_netbuf = NULL;
+			}
+		else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
+
+#ifdef UDP_CFG_EXTENTIONS
+
+			/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¿ãã*/
+			if (error == E_RLWAI)
+				error = cep->error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+			cep->rcv_tskid = TA_NULL;
+			return error;
+			}
+
+		/* p_dstaddr ãè¨­å®ããã*/
+		uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
+		udph = GET_UDP_HDR(input, uhoff);
+		p_dstaddr->portno = ntohs(udph->sport);
+		IN_COPY_TO_HOST(&p_dstaddr->ipaddr, input);
+
+		/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+		ulen = ntohs(udph->ulen);
+		if (ulen - UDP_HDR_SIZE > len)
+			error = E_BOVR;
+		else {
+			len   =    (uint_t)(ulen - UDP_HDR_SIZE);
+			error = (ER_UINT)(ulen - UDP_HDR_SIZE);
+			}
+
+		memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
+
+		syscall(rel_net_buf(input));
+
+		cep->rcv_tskid = TA_NULL;
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_rcv_dat */
+
+#endif	/* of #ifdef UDP_CFG_NON_BLOCKING */
Index: asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq_nblk.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq_nblk.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet/udpn_usrreq_nblk.c	(revision 317)
@@ -0,0 +1,427 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)udp_usrreq.c	8.6 (Berkeley) 5/23/95
+ * $FreeBSD: src/sys/netinet/udp_usrreq.c,v 1.49.2.2 1999/08/29 16:29:58 peter Exp $
+ */
+
+#ifdef __udp_can_snd_nblk
+
+/*
+ *  udp_can_snd -- ãã³ãã£ã³ã°ãã¦ããéä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_SND (T_UDP_CEP *cep, ER error)
+{
+	if (cep->snd_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)error);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_SND_DAT, (void*)&error);
+#endif
+		else
+			error = E_OBJ;
+		cep->snd_p_dstaddr = NULL;
+		}
+	else if (cep->snd_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->snd_tskid);
+		cep->snd_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_snd_nblk */
+
+#ifdef __udp_can_rcv_nblk
+
+/*
+ *  udp_can_rcv -- ãã³ãã£ã³ã°ãã¦ããåä¿¡ã®ã­ã£ã³ã»ã«
+ */
+
+ER
+UDP_CAN_RCV (T_UDP_CEP *cep, ER error)
+{
+	if (cep->rcv_p_dstaddr != NULL) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+		if (IS_PTR_DEFINED(cep->callback))
+
+#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
+#else
+			(*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
+#endif
+		else
+			error = E_OBJ;
+		cep->rcv_p_dstaddr = NULL;
+		}
+	else if (cep->rcv_tskid != TA_NULL) {	/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+
+#ifdef UDP_CFG_EXTENTIONS
+
+		/* å¾
+ã¡ä¸­ã«çºçããã¨ã©ã¼æ
+å ±ãè¨­å®ããã*/
+		cep->error = error;
+
+#endif	/* of #ifdef UDP_CFG_EXTENTIONS */
+
+		error = rel_wai(cep->rcv_tskid);
+		cep->rcv_tskid = TA_NULL;
+		}
+	else					/* ã©ã¡ãã§ããªããªããã³ãã£ã³ã°ãã¦ããªã */
+		error = EV_NOPND;
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_can_rcv_nblk */
+
+#ifdef __udp_snd_dat_nblk
+
+/*
+ *  udp_snd_dat -- ãã±ããã®éä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_SND_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_UDP_CEP	*cep;
+	ER		error;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL)
+		return E_PAR;
+
+	/* ãã¼ã¿é·ããã§ãã¯ããã*/
+	if (len < 0 || len + IP_HDR_SIZE + UDP_HDR_SIZE > IF_MTU)
+		return E_PAR;
+
+#if (API_PROTO == API_PROTO_IPV6) && !defined(API_CFG_IP4MAPPED_ADDR)
+
+	/*
+	 * API ã IPv6 ã§ IPv4 å°å½±ã¢ãã¬ã¹ãèªãããã¦ããªãã®ã«ããããããã
+	 * IPv4 å°å½±ã¢ãã¬ã¹ãæå®ããããã¨ã©ã¼
+	 */
+	if (in6_is_addr_ipv4mapped(&p_dstaddr->ipaddr))
+		return E_PAR;
+
+#endif	/* of #if (API_PROTO == API_PROTO_IPV6) && !defined(DAPI_CFG_IP4MAPPED_ADDR) */
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 *  èªãã¼ãçªå·ã UDP_PORTANY ãªããèªåã§å²ãå½ã¦ãã
+	 */
+	if (cep->myaddr.portno == UDP_PORTANY) {
+		if ((error = UDP_ALLOC_AUTO_PORT(cep)) != E_OK)
+			return error;
+		}
+
+	/*
+	 * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
+	 */
+	if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->snd_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->snd_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			cep->snd_p_dstaddr = p_dstaddr;
+			cep->snd_data	= data;
+			cep->snd_len	= len;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			cep->flags |= UDP_CEP_FLG_POST_OUTPUT;
+			sig_sem(SEM_UDP_POST_OUTPUT);
+			error = E_WBLK;
+			}
+		}
+	else {				/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+	
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->snd_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->snd_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+			get_tid(&(cep->snd_tskid));
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* ãã±ãããéä¿¡ããã*/
+			error = UDP_SEND_DATA(cep, p_dstaddr, data, len, tmout);
+			}
+		}
+
+	return error;
+	}
+
+#endif	/* of #ifdef __udp_snd_dat_nblk */
+
+#ifdef __udp_rcv_dat_nblk
+
+/*
+ *  udp_rcv_dat -- ãã±ããã®åä¿¡ãæ¨æºæ©è½ã
+ */
+
+ER_UINT
+UDP_RCV_DAT (ID cepid, T_IPEP *p_dstaddr, void *data, int_t len, TMO tmout)
+{
+	T_NET_BUF	*input;
+	T_UDP_CEP	*cep;
+	T_UDP_HDR	*udph;
+	ER_UINT		error;
+	uint_t		ulen, uhoff;
+
+	/* p_dstaddr ã¾ãã¯ data ã NULL ããlen < 0 ãªãã¨ã©ã¼ */
+	if (p_dstaddr == NULL || data == NULL || len < 0)
+		return E_PAR;
+
+	/* UDP éä¿¡ç«¯ç¹ ID ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEPID(cepid))
+		return E_ID;
+
+	/* UDP éä¿¡ç«¯ç¹ãå¾ãã*/
+	cep = GET_UDP_CEP(cepid);
+
+	/* UDP éä¿¡ç«¯ç¹ããã§ãã¯ããã*/
+	if (!VALID_UDP_CEP(cep))
+		return E_NOEXS;
+
+	/*
+	 * ã¿ã¤ã ã¢ã¦ãããã§ãã¯ããã
+	 */
+
+	if (tmout == TMO_NBLK) {	/* ãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->rcv_p_dstaddr != NULL)
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+		else if (cep->rcv_tskid != TA_NULL)
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+		else {
+			cep->rcv_p_dstaddr = p_dstaddr;
+			cep->rcv_data	= data;
+			cep->rcv_len	= len;
+			error = E_WBLK;
+			}
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+		syscall(sig_sem(cep->semid_lock));
+		return error;
+		}
+	else {				/* éãã³ãã­ãã­ã³ã°ã³ã¼ã« */
+
+		/* éä¿¡ç«¯ç¹ãã­ãã¯ããã*/
+		syscall(wai_sem(cep->semid_lock));
+
+		if (cep->rcv_p_dstaddr != NULL) {
+
+			/* ãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_OBJ;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else if (cep->rcv_tskid != TA_NULL) {
+
+			/* éãã³ãã­ãã­ã³ã°ã³ã¼ã«ã§ãã³ãã£ã³ã°ä¸­ */
+			error = E_QOVR;
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+			}
+		else {
+
+			/* ç¾å¨ã®ã¿ã¹ã¯è­å¥å­ãè¨é²ããã*/
+			get_tid(&(cep->rcv_tskid));
+
+			/* éä¿¡ç«¯ç¹ãã­ãã¯ãè§£é¤ããã*/
+			syscall(sig_sem(cep->semid_lock));
+
+			/* å
+¥åãããã¾ã§å¾
+ã¤ã*/
+			if (cep->cb_netbuf != NULL) {
+
+				/*
+				 *  ããã«ããå ´åã¯ãã³ã¼ã«ããã¯é¢æ°ã®ä¸­ãã
+				 *  udp_rcv_dat ãå¼ã³åºãã¦ãããã¨ã«ãªãã
+				 *  ãã§ã«å
+¥åæ¸ã¿ã§ããã
+				 */
+				input = cep->cb_netbuf;
+				cep->cb_netbuf = NULL;
+				}
+			else if ((error = trcv_dtq(cep->rcvqid, (intptr_t*)&input, tmout)) != E_OK) {
+				cep->rcv_tskid = TA_NULL;
+				return error;
+				}
+
+			/* p_dstaddr ãè¨­å®ããã*/
+			uhoff = (uint_t)GET_UDP_HDR_OFFSET(input);
+			udph = GET_UDP_HDR(input, uhoff);
+			p_dstaddr->portno = ntohs(udph->sport);
+			IN_COPY_TO_HOST(&p_dstaddr->ipaddr, input);
+
+			/* ãã¼ã¿ããããã¡ã«ç§»ãã*/
+			ulen = ntohs(udph->ulen);
+			if (ulen - UDP_HDR_SIZE > len)
+				error = E_BOVR;
+			else {
+				len   =     (int_t)(ulen - UDP_HDR_SIZE);
+				error = (ER_UINT)(ulen - UDP_HDR_SIZE);
+				}
+
+			memcpy(data, GET_UDP_SDU(input, uhoff), (size_t)len);
+
+			syscall(rel_net_buf(input));
+
+			cep->rcv_tskid = TA_NULL;
+			}
+		return error;
+		}
+	}
+
+#endif	/* of #ifdef __udp_rcv_dat_nblk */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ah.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ah.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ah.h	(revision 317)
@@ -0,0 +1,95 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ah.h,v 1.7 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: ah.h,v 1.16 2001/09/04 08:43:19 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _AH_H_
+#define _AH_H_
+
+/*
+ *  RFC2402 èªè¨¼ããã
+ */
+
+typedef struct t_ip6_ah_hdr {
+	uint8_t		next;	/* Next Header				*/
+	uint8_t		len;	
+	/* 4 ãªã¯ãããåä½ã®é·ãããã ãããã¼ã¿é· + 1 ãå
+¥ãã	*/
+	uint16_t	reserved;
+	uint32_t	spi;	/* Security Parameter Index (SPI)	*/
+	uint32_t	seq;	/* ã·ã¼ã±ã³ã¹çªå·			*/
+	} T_IP6_AH_HDR;
+
+#endif	/* of #ifndef _AH_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ah6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ah6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ah6.h	(revision 317)
@@ -0,0 +1,87 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ah6.h,v 1.4 2001/06/11 12:39:03 ume Exp $	*/
+/*	$KAME: ah.h,v 1.13 2000/10/18 21:28:00 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _AH6_H_
+#define _AH6_H_
+
+/*
+ *  é¢æ°
+ */
+
+extern uint_t ah6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+#endif	/* of #ifndef _AH6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ah_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ah_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ah_input.c	(revision 317)
@@ -0,0 +1,132 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ah_input.c,v 1.12 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: ah_input.c,v 1.67 2002/01/07 11:39:56 kjc Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet6/nd6.h>
+#include <netinet6/ah.h>
+#include <netinet6/ah6.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  ah6_input -- èªè¨¼ãããã®å
+¥åé¢æ°
+ *
+ *    æ¬å®è£
+ã§ã¯ããã¼ã¿ã°ã©ã ãç ´æ£ããã
+ */
+
+uint_t
+ah6_input (T_NET_BUF **input, uint_t *offp, uint_t *nextp)
+{
+	syscall(rel_net_buf(*input));
+	return IPPROTO_DONE;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/dest6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/dest6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/dest6.c	(revision 317)
@@ -0,0 +1,180 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/dest6.c,v 1.7 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: dest6.c,v 1.34 2002/01/08 02:40:55 k-sugyou Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet6/nd6.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  dest6_input -- çµç¹ãªãã·ã§ã³ãããã®å
+¥åé¢æ°
+ *
+ *    æ¬å®è£
+ã§ã¯ãããã£ã³ã°ä»¥å¤ã®ãªãã·ã§ã³ãå
+¨ã¦æªç¥ãªãã·ã§ã³ã¨ãã¦å¦çããã
+ */
+
+uint_t
+dest6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_IP6_DEST_HDR	*desth;
+	ER_UINT		optlen;
+	uint_t		len, off = *offp;
+	uint8_t		*opt;
+
+	/* ãããã¯ã¼ã¯ãããã¡ã®æ®ãã®é·ãããã§ãã¯ããã*/
+	if (input->len - off < sizeof(T_IP6_DEST_HDR))
+		goto buf_rel;
+
+	desth  = (T_IP6_DEST_HDR *)(input->buf + off);
+	len    = (desth->len + 1) << 3;
+
+	/* çµç¹ãªãã·ã§ã³ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < off + len)
+		goto buf_rel;
+
+	*nextp = *offp - IF_HDR_SIZE + offsetof(T_IP6_DEST_HDR, next);
+	*offp += len;
+	opt    = (uint8_t *)desth + sizeof(T_IP6_DEST_HDR);
+
+	for (len -= sizeof(T_IP6_DEST_HDR); len > 0; len -= optlen) {
+		switch (*opt) {
+		case IP6OPT_PAD1:
+			optlen = 1;
+			break;
+		case IP6OPT_PADN:
+			if (len < IP6OPT_MINLEN)
+				goto buf_rel;
+			optlen = *(opt + 1) + 2;
+			break;
+		default:
+			if (len < IP6OPT_MINLEN)
+				goto buf_rel;
+			optlen = ip6_unknown_opt(input, opt);
+			if (optlen == IP6_OPT_RET_ERR)
+				goto buf_rel;
+			else if (optlen == IP6_OPT_RET_REL)
+				return IPPROTO_DONE;
+			optlen += 2;
+			break;
+			}
+
+		opt += optlen;
+		}
+
+	return desth->next;
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/esp.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/esp.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/esp.h	(revision 317)
@@ -0,0 +1,141 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/esp.h,v 1.6 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: esp.h,v 1.19 2001/09/04 08:43:19 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _ESP_H_
+#define _ESP_H_
+
+/*
+ *  RFC2406 æå·åããã
+ */
+
+typedef struct t_esp_hdr {
+	int32_t	spi;	/* Security Parameter Index (SPI)	*/
+	int32_t	seq;	/* ã·ã¼ã±ã³ã¹çªå·			*/
+	} T_ESP_HDR;
+
+typedef struct t_esp_tail {
+	int8_t	padlen;	/* ããã£ã³ã°é·				*/	
+	int8_t	next;	/* Next Header				*/
+	} T_ESP_TAIL;
+
+struct t_secas_var;
+
+struct t_esp_algorithm {
+	size_t padbound;	/* pad boundary, in byte */
+	int_t ivlenval;		/* iv length, in byte */
+	int_t (*mature) (struct t_secas_var *);
+	int_t keymin;	/* in bits */
+	int_t keymax;	/* in bits */
+	//int_t (*schedlen) (const struct t_esp_algorithm *);
+	int32_t (*schedlen) (const struct t_esp_algorithm *);
+	const char *name;
+	int_t (*ivlen) (const struct t_esp_algorithm *, struct t_secas_var *);
+	int_t (*decrypt) (T_NET_BUF *, size_t,
+		struct t_secas_var *, const struct t_esp_algorithm *, int_t,
+			T_NET_BUF *, size_t);
+	int_t (*encrypt) (T_NET_BUF *, size_t, size_t, int8_t*,
+		struct t_secas_var *, const struct t_esp_algorithm *, int_t,
+			T_NET_BUF *, size_t);
+	/* not supposed to be called directly */
+	int_t (*schedule) (const struct t_esp_algorithm *, struct t_secas_var *);
+	int_t (*blockdecrypt) (const struct t_esp_algorithm *,
+		struct t_secas_var *, int8_t *, int8_t *);
+	int_t (*blockencrypt) (const struct t_esp_algorithm *,
+		struct t_secas_var *, int8_t *, int8_t *);
+};
+
+typedef struct t_esp_algorithm T_ESP_ALGORITHM;
+
+#define MAXIVLEN	16
+
+/*
+ * é¢æ°
+ */
+
+extern const struct t_esp_algorithm *esp_algorithm_lookup (int_t);
+extern int_t esp_max_ivlen (void);
+extern int_t esp_schedule (const struct t_esp_algorithm *, struct t_secas_var *);
+extern int_t esp4_input(T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+#ifdef T_IPSEC_REQUEST_DEFINED
+
+extern int_t esp4_output(T_NET_BUF *m, T_IPSEC_REQUEST *isr, T_NET_BUF** result);
+
+#endif	/* of #ifdef T_IPSEC_REQUEST_DEFINED */
+
+#endif	/* of #ifndef _ESP_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/esp6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/esp6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/esp6.h	(revision 317)
@@ -0,0 +1,87 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/esp6.h,v 1.4 2001/06/11 12:39:04 ume Exp $	*/
+/*	$KAME: esp.h,v 1.16 2000/10/18 21:28:00 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _ESP6_H_
+#define _ESP6_H_
+
+/*
+ *  é¢æ°
+ */
+
+extern uint_t esp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+#endif	/* of #ifndef _ESP6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/esp_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/esp_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/esp_input.c	(revision 317)
@@ -0,0 +1,139 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/esp_input.c,v 1.14 2002/08/24 04:48:13 ume Exp $	*/
+/*	$KAME: esp_input.c,v 1.62 2002/01/07 11:39:57 kjc Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet6/nd6.h>
+#include <netinet6/ah.h>
+#include <netinet6/ah6.h>
+#include <netinet6/esp.h>
+#include <netinet6/esp6.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  esp6_input -- æå·åãããã®å
+¥åé¢æ°
+ *
+ *    æ¬å®è£
+ã§ã¯ããã¼ã¿ã°ã©ã ãç ´æ£ããã
+ */
+
+uint_t
+esp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+#if 0
+	*nextp = <T_ESP_TAIL ã® next ãã£ã¼ã«ãã®ä½ç½®ï¼IPv6 ãããã®å
+é ­ããã®ãªãã»ããï¼>;
+	*offp  = <æ¬¡ãããã®ä½ç½®ï¼input->buf ããã®ãªãã»ããï¼>;
+#endif
+	syscall(rel_net_buf(*inputp));
+	return IPPROTO_DONE;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/frag6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/frag6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/frag6.c	(revision 317)
@@ -0,0 +1,725 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/frag6.c,v 1.9 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: frag6.c,v 1.33 2002/01/07 11:34:48 kjc Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_var.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet6/nd6.h>
+
+#ifdef _IP6_CFG
+
+#ifdef IP6_CFG_FRAGMENT
+
+/*
+ *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼é
+å
+ */
+
+static T_NET_BUF	*ip6_frag_queue[NUM_IP6_FRAG_QUEUE];
+static T_IN6_ADDR	 ip6_frag_dest [NUM_IP6_FRAG_QUEUE];
+
+/*
+ *  ip6_get_frag_queue -- ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãç²å¾ããã
+ */
+
+const T_NET_BUF **
+ip6_get_frag_queue (void)
+{
+	return (const T_NET_BUF **)ip6_frag_queue;
+	}
+
+/*
+ *  frag6_free_queue -- ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãè§£æ¾ããã
+ *
+ *    æ³¨æ: ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼é
+åãã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static void
+frag6_free_queue (T_NET_BUF **queue)
+{
+	T_NET_BUF 	*frag, *next;
+	T_QIP6_HDR	*qip6h;
+
+	frag = *queue;
+	while (frag != NULL) {
+		qip6h = GET_QIP6_HDR(frag);
+		next  = qip6h->next_frag;
+		syscall(rel_net_buf(frag));
+		frag = next;
+		}
+	*queue = NULL;
+	}
+
+/*
+ *  frag6_timer -- ãã¼ã¿ã°ã©ã åæ§æç®¡çã¿ã¤ã
+ */
+
+void
+frag6_timer (void)
+{
+	T_NET_BUF	*frag;
+	T_QIP6_HDR	*qip6h;
+	T_IP6_FRAG_HDR	*qip6fh;
+	int_t		ix;
+
+	syscall(wai_sem(SEM_IP6_FRAG_QUEUE));
+	for (ix = NUM_IP6_FRAG_QUEUE; ix -- > 0; ) {
+		frag = ip6_frag_queue[ix];
+		if (frag != NULL) {
+			qip6h = GET_QIP6_HDR(frag);
+			if (qip6h->ftim > 0 && -- qip6h->ftim == 0) {
+
+				qip6fh = (T_IP6_FRAG_HDR *)(frag->buf + qip6h->foff);
+				if (ntohs(qip6fh->off_flag & IP6F_OFF_MASK) == 0) {
+
+					/*
+					 *  å
+é ­ã®æ­çã®ãªãã»ããã 0 ã®æã®ã¿
+					 *  ICMPv6 ã¨ã©ã¼ã¡ãã»ã¼ã¸ãéä¿¡ããã
+					 */
+
+					/* å
+é ­ã®æ­çããã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ããå¤ãã*/
+					ip6_frag_queue[ix] = qip6h->next_frag;
+
+					/* ãã¦å
+ã¢ãã¬ã¹ãå
+ã«æ»ãã*/
+					GET_IP6_HDR(frag)->dst = ip6_frag_dest[ix];
+
+					/* ICMPv6 ã¨ã©ã¼ã¡ãã»ã¼ã¸ãéä¿¡ããã*/
+					icmp6_error(frag, ICMP6_TIME_EXCEEDED,
+					                  ICMP6_TIME_EXCEED_REASSEMBLY, 0);
+					}
+
+				/* ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãè§£æ¾ããã*/
+				NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_IN_TMOUT], 1);
+				NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_IN_DROP], 1);
+				frag6_free_queue(&ip6_frag_queue[ix]);
+				}
+			}
+		}
+	syscall(sig_sem(SEM_IP6_FRAG_QUEUE));
+	}
+
+#endif	/* #ifdef IP6_CFG_FRAGMENT */
+
+/*
+ *  frag6_input -- æ­çãããã®å
+¥åé¢æ°
+ */
+
+uint_t
+frag6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_IP6_HDR	*ip6h;
+	T_IP6_FRAG_HDR	*ip6fh;
+	T_NET_BUF	*input = *inputp;
+	uint_t		off = *offp;
+
+#ifdef IP6_CFG_FRAGMENT
+
+	T_QIP6_HDR	*qip6h, *rip6h;
+	T_IP6_FRAG_HDR	*qip6fh = NULL;
+	T_NET_BUF	**ip6fq = NULL, *prev, *next, *frag;
+	int_t		ix;
+	int32_t		unfraglen, diff;
+	uint16_t	fragpartlen, qfragpartlen, fragoff, qfragoff, plen;
+	uint8_t		ftim, *prev_next;
+	uint_t		nextproto = IPPROTO_DONE;
+
+#endif	/* #ifdef IP6_CFG_FRAGMENT */
+
+	/* ãããã¯ã¼ã¯ãããã¡ã®æ®ãã®é·ãããã§ãã¯ããã*/
+	if (input->len - off < sizeof(T_IP6_FRAG_HDR))
+		goto buf_rel;
+
+	/* 
+	 *  å·¨å¤§ãã¤ã­ã¼ããªãã·ã§ã³ã¨æ­çããããåæã«ä½¿ç¨ãããã¨ã¯
+	 *  ã§ããªãããã¤ã­ã¼ãé·ãã 0 ãªããå·¨å¤§ãã¤ã­ã¼ããªãã·ã§ã³ã
+	 *  æå®ããã¦ãããã¨ã«ãªãã®ã§ ICMP ã§ã¨ã©ã¼ãéä¿¡è
+ã«
+	 *  éç¥ããã
+	 */
+	ip6h = GET_IP6_HDR(input);
+	if (ip6h->plen == 0) {
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   off - IF_HDR_SIZE);
+		NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmFails, 1);
+		return IPPROTO_DONE;
+		}
+
+	/*
+	 *  ãªãã»ããã 0 ã§ãæçµãã©ã°ã¡ã³ãã§ããã°ã
+	 *  åå²ä¸è¦ã®ãã¼ã¿ã°ã©ã ãªã®ã§ã
+	 *  æ¬¡ããããæãå¤æ°ãèª¿æ´ãã¦çµäºããã
+	 */
+	ip6fh = (T_IP6_FRAG_HDR *)(input->buf + off);
+	if (ip6fh->off_flag == 0) {
+		*nextp = *offp - IF_HDR_SIZE + offsetof(T_IP6_FRAG_HDR, next);
+		*offp = off + sizeof(T_IP6_FRAG_HDR);
+		return ip6fh->next;
+		}
+
+#ifdef IP6_CFG_FRAGMENT
+
+	/*
+	 *  ãã¤ã­ã¼ãé·ããã§ãã¯ããã
+	 */
+	if ((ip6fh->off_flag & IP6F_MORE_FRAG) && 
+	    ((ntohs(ip6h->plen) - (off - IF_HDR_SIZE)) & 0x7) != 0) {
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   offsetof(T_IP6_HDR, plen));
+		NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmFails, 1);
+		return nextproto;
+		}
+	NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmReqds, 1);
+
+	syscall(wai_sem(SEM_IP6_FRAG_QUEUE));
+
+	/*
+ 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼é
+åãããå¯¾å¿ããã¨ã³ããªãæ¢ãã
+ 	 */
+	for (ix = NUM_IP6_FRAG_QUEUE; ix -- > 0; ) {
+		if (ip6_frag_queue[ix] != NULL) {
+			qip6h  = GET_QIP6_HDR(ip6_frag_queue[ix]);
+			qip6fh = (T_IP6_FRAG_HDR *)(ip6_frag_queue[ix]->buf + qip6h->foff);
+			if (ip6fh->ident == qip6fh->ident               &&
+			    IN6_ARE_ADDR_EQUAL(&ip6h->src, &qip6h->src) &&
+			    IN6_ARE_ADDR_EQUAL(&ip6h->dst, &ip6_frag_dest[ix])) {
+				ip6fq = &ip6_frag_queue[ix];
+			    	break;
+			    	}
+			}
+		}
+
+ 	if (ip6fq == NULL) {
+
+		/*
+	 	 *  æ­çã®æ­£å½æ§ããã§ãã¯ããã
+		 */
+		unfraglen = 0;
+		fragoff = ntohs(ip6fh->off_flag & IP6F_OFF_MASK);
+		if (fragoff == 0) {
+
+			/*
+		 	 *  å
+¥åããæ­çãå
+é ­ã®æ­ç
+			 *  åå²ã§ããªãé¨åã®é·ã unfraglen ãè¨ç®ããã
+			 */
+			unfraglen = (off - IF_HDR_SIZE) - sizeof(T_IP6_HDR);
+			}
+
+		/*
+		 *             off
+		 *  |<--------------------------->|
+		 *  |          off - IF_HDR_SIZE  |
+		 *  |        |<------------------>|
+		 *  |        | off - IF_HDR_SIZE + IP6_FRAG_HDR_SIZE |
+		 *  |        |<------------------------------------->|
+		 *  +--------+----------+---------+------------------+-------------+
+		 *  | IF HDR | IPv6 HDR | EXT HDR |     FRAG HDR     |   Payload   |
+		 *  +--------+----------+---------+------------------+-------------+
+		 *                      |<---------------------------------------->|
+		 *                      |             Payload Size                 |
+		 *           |<--------------------------------------------------->|
+		 *           |         IP6_HDR_SIZE + Payload Size                 |
+		 *                                                   |<----------->|
+		 *                                                   | fragpartlen |
+		 */
+		fragpartlen = sizeof(T_IP6_HDR) + ntohs(ip6h->plen) - (off - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+		if (unfraglen + fragoff + fragpartlen > IPV6_MAXPACKET) {
+			icmp6_error(input, ICMP6_PARAM_PROB,
+			                   ICMP6_PARAMPROB_HEADER,
+			                   (off - IF_HDR_SIZE) +
+			                   offsetof(T_IP6_FRAG_HDR, off_flag));
+			goto sig_ret;
+			}
+
+		/*
+	 	 *  ip6fq == NULL ã§ããã°ãå¯¾å¿ããã¨ã³ããªã¯ç¡ãã®ã§ã
+	 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼é
+åã«ãã¨ã³ããªãè¿½å ããã
+	 	 */
+		for (ix = NUM_IP6_FRAG_QUEUE; ix -- > 0; ) {
+
+			/* ç©ºãã¨ã³ããªãæ¢ãã*/
+			if (ip6_frag_queue[ix] == NULL) {
+				ip6fq = &ip6_frag_queue[ix];
+				break;
+				}
+			}
+
+		/*
+		 *  ip6fq == NULL ã§ããã°ãç©ºãã¨ã³ããªãç¡ãã®ã§ã
+		 *  ã¿ã¤ã ã¢ã¦ãï¼hlimï¼ãç­ãã¨ã³ããªãéæ¾ããã
+		 */
+ 		if (ip6fq == NULL) {
+
+		 	ftim = IPV6_MAXHLIM;
+			for (ix = NUM_IP6_FRAG_QUEUE; ix -- > 0; ) {
+				if (ip6_frag_queue[ix] != NULL) {
+					rip6h  = GET_QIP6_HDR(ip6_frag_queue[ix]);
+					if (rip6h->ftim < ftim) {
+						ftim  = rip6h->ftim;
+						ip6fq = &ip6_frag_queue[ix];
+						}
+					}
+				}
+			frag6_free_queue(ip6fq);
+			}
+
+		/*
+		 *  ã¨ã³ããªãè¨­å®ããã
+		 */
+		*ip6fq = input; 
+		ip6_frag_dest[ip6fq - ip6_frag_queue] = ip6h->dst;
+		qip6h  = GET_QIP6_HDR(*ip6fq);
+		qip6h->ftim = IPV6_FRAGTTL;
+		qip6h->foff = off;
+		qip6h->flen = fragpartlen;
+		qip6h->next_frag = NULL;
+ 		}
+ 	else {
+
+		/*
+	 	 *  æ­çã®æ­£å½æ§ããã§ãã¯ããã
+		 */
+		unfraglen = 0;
+		fragoff = ntohs(((T_IP6_FRAG_HDR *)((*ip6fq)->buf + GET_QIP6_HDR(*ip6fq)->foff))->off_flag & IP6F_OFF_MASK);
+		if (fragoff == 0) {
+
+			/*
+		 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ã®æåã®æ­çãå
+é ­ã®æ­ç
+			 *  åå²ã§ããªãé¨åã®é·ã unfraglen ãè¨ç®ããã
+			 */
+			unfraglen = (GET_QIP6_HDR(*ip6fq)->foff - IF_HDR_SIZE) - sizeof(T_IP6_HDR);
+			}
+
+		fragoff = ntohs(ip6fh->off_flag & IP6F_OFF_MASK);
+		if (fragoff == 0) {
+
+			/*
+		 	 *  å
+¥åããæ­çãå
+é ­ã®æ­ç
+			 *  åå²ã§ããªãé¨åã®é·ã unfraglen ãè¨ç®ããã
+			 */
+			unfraglen = (off - IF_HDR_SIZE) - sizeof(T_IP6_HDR);
+			}
+
+		/*
+		 *             off
+		 *  |<--------------------------->|
+		 *  |          off - IF_HDR_SIZE  |
+		 *  |        |<------------------>|
+		 *  |        | off - IF_HDR_SIZE + IP6_FRAG_HDR_SIZE |
+		 *  |        |<------------------------------------->|
+		 *  +--------+----------+---------+------------------+-------------+
+		 *  | IF HDR | IPv6 HDR | EXT HDR |     FRAG HDR     |   Payload   |
+		 *  +--------+----------+---------+------------------+-------------+
+		 *                      |<---------------------------------------->|
+		 *                      |             Payload Size                 |
+		 *           |<--------------------------------------------------->|
+		 *           |         IP6_HDR_SIZE + Payload Size                 |
+		 *                                                   |<----------->|
+		 *                                                   | fragpartlen |
+		 */
+		fragpartlen = sizeof(T_IP6_HDR) + ntohs(ip6h->plen) - (off - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+		if (unfraglen + fragoff + fragpartlen > IPV6_MAXPACKET) {
+			icmp6_error(input, ICMP6_PARAM_PROB,
+			                   ICMP6_PARAMPROB_HEADER,
+			                   (off - IF_HDR_SIZE) +
+			                   offsetof(T_IP6_FRAG_HDR, off_flag));
+			goto sig_ret;
+			}
+		
+		if (ntohs(ip6fh->off_flag & IP6F_OFF_MASK) == 0) {
+
+			/*
+		 	 *  å
+¥åããæ­çãå
+é ­ã®æ­ç
+		 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ã®æå¾ã®æ­çãã
+		 	 *  ãã¼ã¿ã°ã©ã ã®æå¤§é·ãè¶
+ãã¦ããªãããã§ãã¯ããã
+			 */
+
+			/* æå¾ã®æ­çãæ¢ç´¢ããã*/
+			next = *ip6fq;
+			while ((qip6h = GET_QIP6_HDR(next))->next_frag != NULL)
+				next = qip6h->next_frag;
+
+			/* æå¾ã®æ­çã®ãªãã»ããã¨æ­çãµã¤ãºãè¨ç®ããã*/
+			qip6fh = (T_IP6_FRAG_HDR *)(next->buf + qip6h->foff);
+			fragoff = ntohs(qip6fh->off_flag & IP6F_OFF_MASK);
+			fragpartlen = sizeof(T_IP6_HDR) + ntohs(qip6h->plen) - (qip6h->foff - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+			if (unfraglen + fragoff + fragpartlen > IPV6_MAXPACKET) {
+
+				/*
+				 *  ãã¼ã¿ã°ã©ã ã®æå¤§é·ãè¶
+ãã¦ããå ´åã¯ã
+			 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼å
+¨ä½ãç ´æ£ããã
+			 	 */
+				frag6_free_queue(ip6fq);
+				syscall(rel_net_buf(input));
+				goto sig_ret;
+				}
+			}
+
+		/* ECN ã®æ­£å½æ§ãã§ãã¯ã¯æªå®è£
+ */
+
+		/*
+		 *  æ­çãã¨ã³ããªã«æ¿å
+¥ããã
+	 	 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãããå
+¥åããæ­çããåã®æ­çãæ¢ç´¢ããã
+		 */
+		prev = NULL;
+		next = *ip6fq;
+		while (next != NULL) {
+			qip6h  = GET_QIP6_HDR(next);
+			qip6fh = (T_IP6_FRAG_HDR *)(next->buf + qip6h->foff);
+			if (ntohs(ip6fh->off_flag & IP6F_OFF_MASK) <= ntohs(qip6fh->off_flag & IP6F_OFF_MASK))
+				break;
+			prev = next;
+			next = qip6h->next_frag;
+			}
+
+		/*
+		 *  prev ã¯ãå
+¥åããæ­çããåã®æ­çããã ã NULL ã®å ´åã¯ã
+		 *  å
+¥åããæ­çããã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ã®ä¸­ã§æãåã®æ­çã
+		 *  next ã¯ãå
+¥åããæ­çããå¾ã®æ­çããã ã NULL ã®å ´åã¯ã
+		 *  å
+¥åããæ­çããã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ã®ä¸­ã§æãå¾ã®æ­çã
+		 */
+		fragoff = ntohs(ip6fh->off_flag & IP6F_OFF_MASK);
+		if (prev != NULL) {
+
+			/*
+			 *  åã®æ­çã¨ãå
+¥åããæ­çãéãªã£ã¦ããªãããã§ãã¯ããã
+			 *
+			 *    qfragoff
+			 *    |   qfragparglen
+			 *    |<------------------>|
+			 *    +--------------------+
+			 *    |        prev        |
+			 *    +--------------------+
+			 *
+			 *                         +--------------------+
+			 *                         |        input       |
+			 *                         +--------------------+
+			 *                         |
+			 *                         fragoff
+			 */
+			qip6h  = GET_QIP6_HDR(prev);
+			qip6fh = (T_IP6_FRAG_HDR *)(prev->buf + qip6h->foff);
+			qfragoff = ntohs(qip6fh->off_flag & IP6F_OFF_MASK);
+			qfragpartlen = sizeof(T_IP6_HDR) + ntohs(qip6h->plen) - (off - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+
+			diff = ((int32_t)qfragoff + qfragpartlen) - fragoff;
+			if (diff > 0) {
+
+				/* éãªã£ã¦ããã°ãå
+¥åããæ­çãç ´æ£ãã¦çµäºããã*/
+				syscall(rel_net_buf(input));
+				goto sig_ret;
+				}
+			}
+
+		if (next != NULL) {
+
+			/*
+			 *  å¾ã®æ­çã¨ãå
+¥åããæ­çãéãªã£ã¦ããªãããã§ãã¯ããã
+			 *
+			 *    fragoff
+			 *    |    fragparglen
+			 *    |<------------------>|
+			 *    +--------------------+
+			 *    |       input        |
+			 *    +--------------------+
+			 *
+			 *                         +--------------------+
+			 *                         |         next       |
+			 *                         +--------------------+
+			 *                         |
+			 *                         qfragoff
+			 */
+			qip6h  = GET_QIP6_HDR(next);
+			qip6fh = (T_IP6_FRAG_HDR *)(next->buf + qip6h->foff);
+			qfragoff = ntohs(qip6fh->off_flag & IP6F_OFF_MASK);
+			fragpartlen = sizeof(T_IP6_HDR) + ntohs(ip6h->plen) - (off - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+
+			diff = ((int32_t)fragoff + fragpartlen) - qfragoff;
+			if (diff > 0) {
+
+				/* éãªã£ã¦ããã°ãå
+¥åããæ­çãç ´æ£ãã¦çµäºããã*/
+				syscall(rel_net_buf(input));
+				goto sig_ret;
+				}
+			}
+
+		/* å
+¥åããæ­çãè¨­å®ããã*/
+		qip6h  = GET_QIP6_HDR(input);
+		qip6h->foff = off;
+		qip6h->flen = sizeof(T_IP6_HDR) + ntohs(qip6h->plen) - (off - IF_HDR_SIZE + sizeof(T_IP6_FRAG_HDR));
+
+		if (prev == NULL) {
+			*ip6fq = input;
+			qip6h->ftim = IPV6_FRAGTTL;
+			}
+		else
+			GET_QIP6_HDR(prev)->next_frag = input;
+		qip6h->next_frag = next;
+
+		/*
+		 *  å
+¨ã¦ã®æ­çãåä¿¡ããããã§ãã¯ããã
+		 */
+		plen = 0;
+		frag = *ip6fq;
+		while (frag != NULL) {
+			qip6h  = GET_QIP6_HDR(frag);
+			qip6fh = (T_IP6_FRAG_HDR *)(frag->buf + qip6h->foff);
+			if (ntohs(qip6fh->off_flag & IP6F_OFF_MASK) != plen) {
+
+				/* æ­çãé£ç¶ãã¦ããªãã*/
+				goto sig_ret;
+				}
+			plen += qip6h->flen;
+			frag = qip6h->next_frag;
+			}
+		if (ntohs(qip6fh->off_flag & IP6F_MORE_FRAG) != 0) {
+
+			/* æå¾ã®æ­çãåä¿¡ãã¦ããªãã*/
+			goto sig_ret;
+			}
+
+		/*
+		 *  å
+¨ã¦ã®æ­çãåä¿¡ããã®ã§ãåæ§æããã
+		 */
+
+		/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+		qip6h  = GET_QIP6_HDR(*ip6fq);
+		qip6fh = (T_IP6_FRAG_HDR *)((*ip6fq)->buf + qip6h->foff);
+		if (tget_net_buf(inputp, qip6h->foff + plen, TMO_IP6_FRAG_GET_NET_BUF) == E_OK) {
+
+			/*
+			 *  æ­çãããã®ç´åã®ãããã® NEXT ãã£ã¼ã«ãã®ã¢ãã¬ã¹ãç²å¾ãã
+			 *  å
+ã«æ»ãã
+			 */
+			if ((prev_next = ip6_get_prev_hdr(*ip6fq, qip6h->foff)) == NULL) {
+				syscall(rel_net_buf(input));
+				goto sig_ret;
+				}
+			*prev_next = qip6fh->next;
+			input = *inputp;
+
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_IN_OK], 1);
+			NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmOKs, 1);
+
+			/*
+			 *  IPv6 ãããã¨åå²ã§ããªãé¨åã
+			 *  ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ã®ä¸­ã®å
+é ­ã®æ­çããã³ãã¼ããã
+			 */
+			memcpy(input->buf, (*ip6fq)->buf, qip6h->foff);
+
+			/* éä¿¡å
+ã¢ãã¬ã¹ãå
+ã«æ»ãã*/
+			ip6h = GET_IP6_HDR(input);
+			ip6h->dst = ip6_frag_dest[ip6fq - ip6_frag_queue];
+
+			/* offp ããåæ§æããæ­çã®å
+é ­ã«è¨­å®ããã*/
+			*offp = qip6h->foff;
+
+			/* ãããã¯ã¼ã¯ãããã¡é·ãè¨­å®ããã*/
+			input->len = plen + qip6h->foff;
+
+			/*
+			 *  å
+¨ã¦ã®æ­çãã³ãã¼ããã
+			 */
+			frag = *ip6fq;
+			off  = qip6h->foff;
+			while (frag != NULL) {
+				qip6h  = GET_QIP6_HDR(frag);
+				memcpy(input->buf + off,
+				       frag->buf + qip6h->foff + sizeof(T_IP6_FRAG_HDR),
+				       qip6h->flen);
+				off += qip6h->flen;
+				frag = qip6h->next_frag;
+				}
+
+			/* ãã¤ã­ã¼ãé·ãè¨­å®ããã*/
+			ip6h->plen = htons(plen);
+
+			*nextp = offsetof(T_IP6_HDR, next);
+			nextproto = ip6h->next;
+			}
+		else {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_IN_NO_BUF], 1);
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_IN_DROP], 1);
+			NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmFails, 1);
+			}
+
+		/* ãã¼ã¿ã°ã©ã åæ§æã­ã¥ã¼ãè§£æ¾ããã*/
+		frag6_free_queue(ip6fq);
+ 		}
+
+sig_ret:
+	syscall(sig_sem(SEM_IP6_FRAG_QUEUE));
+	return nextproto;
+
+#else	/* #ifdef IP6_CFG_FRAGMENT */
+
+	/*
+	 *  ãã¼ã¿ã°ã©ã ã®åå²ã»åæ§æè¡ããªãå ´åã¯ãå
+¨æ­çãç ´æ£ãã
+	 *  æå¾ã®æ­çãåä¿¡ããã¨ãã
+	 *  ICMP ã¨ã©ã¼ãéä¿¡è
+ã«éç¥ããã
+	 */
+	if ((ip6fh->off_flag & IP6F_MORE_FRAG) == 0) {
+		icmp6_error(input, ICMP6_TIME_EXCEEDED,
+		                   ICMP6_TIME_EXCEED_REASSEMBLY, 0);
+		NET_COUNT_MIB(in6_stats.ipv6IfStatsReasmFails, 1);
+		return IPPROTO_DONE;
+		}
+
+#endif	/* #ifdef IP6_CFG_FRAGMENT */
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/icmp6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/icmp6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/icmp6.c	(revision 317)
@@ -0,0 +1,750 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/icmp66.c,v 1.6.2.6 2001/07/10 09:44:16 ume Exp $	*/
+/*	$KAME: icmp66.c,v 1.211 2001/04/04 05:56:20 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_icmp6.c	8.2 (Berkeley) 1/4/94
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+#include <netinet6/nd6.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  å¤æ°
+ */
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+T_ICMP6_IFSTAT icmp6_ifstat;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  icmp6_output -- ICMP6 ãã±ãããéä¿¡ããã
+ */
+
+static void
+icmp6_output (T_NET_BUF *output, uint_t off)
+{
+	T_IN6_IFADDR	*ia;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IP6_HDR	*ip6h;
+	T_ICMP6_HDR	*icmp6h;
+
+	/*
+	 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+	 */
+	ip6h = GET_IP6_HDR(output);
+	if ((ia = in6_ifawithifp(ifp, &ip6h->dst)) == NULL) {
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutErrors, 1);
+		syscall(rel_net_buf(output));
+		return;
+		}
+	ip6h->src = ia->addr;
+
+	icmp6h = GET_ICMP6_HDR(output, off);
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	icmp6h->sum = 0;
+	icmp6h->sum = in6_cksum(output, IPPROTO_ICMPV6, (uint8_t*)icmp6h - output->buf, 
+	                        ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE));
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_OUT_OCTETS],
+	               output->len - GET_IF_IP6_HDR_SIZE(output));
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	ip6_output(output, 0, TMO_ICMP_OUTPUT);
+	}
+
+/*
+ *  icmp6_echo_request -- ã¨ã³ã¼è¦æ±ãåä¿¡ããã¨ãã®å¦ç
+ */
+
+static void
+icmp6_echo_request (T_NET_BUF *input, uint_t off)
+{
+	T_IP6_HDR	*ip6h;
+	T_ICMP6_HDR	*icmp6h;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	T_IN6_ADDR	dst;
+	uint_t		diff;
+
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInEchos, 1);
+
+	ip6h       = GET_IP6_HDR(input);
+
+	/*
+	 *  IPv6 ãããã¨ ICMPv6 ãããéã®æ¡å¼µããããé¤å»ããã
+	 */
+	diff = off - IF_IP6_HDR_SIZE;
+	if (diff > 0) {
+		/* ICMPv6 ããããåã«è©°ããã*/
+		memmove(input->buf + IF_IP6_HDR_SIZE, input->buf + off, input->len - off);
+		off = IF_IP6_HDR_SIZE;
+
+		/* ãã¤ã­ã¼ãé·ãèª¿æ´ããã*/
+		ip6h->plen  = htons(ntohs(ip6h->plen) - diff);
+		input->len -= diff;
+		}
+
+	icmp6h = GET_ICMP6_HDR(input, off);
+	if (icmp6h->code != 0) {
+		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
+		syscall(rel_net_buf(input));
+		return;
+		}
+
+	/*
+	 *  ã¡ãã»ã¼ã¸ã®åãã¨ã³ã¼è¦æ± (128) ãã
+	 *  ã¨ã³ã¼å¿ç­ (129) ã«å¤æ´ãã¦éãè¿ãã
+	 */
+	icmp6h->type = ICMP6_ECHO_REPLY;
+
+	/* IPv6 ãããã®çºä¿¡å
+ã¢ãã¬ã¹ã¨å®å
+ã¢ãã¬ã¹ãå
+¥æ¿ããã*/
+	dst 	  = ip6h->dst;
+	ip6h->dst = ip6h->src;
+	ip6h->src = dst;
+
+	/*
+	 *  å
+ã®å®å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ãã®å ´åã¯ã
+	 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+	 */
+	if (IN6_IS_ADDR_MULTICAST(&dst)) {
+		if ((ia = in6_ifawithifp(ifp, &ip6h->dst)) == NULL) {
+			syscall(rel_net_buf(input));
+			return;
+			}
+		else
+			ip6h->src = ia->addr;
+		}
+
+	/* æ¬¡ãããã¨ããããªããããè¨­å®ããã*/
+	ip6h->next = IPPROTO_ICMPV6;
+	ip6h->hlim = IP6_DEFTTL;
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	icmp6h->sum = 0;
+	icmp6h->sum = in6_cksum(input, IPPROTO_ICMPV6, (uint8_t*)icmp6h - input->buf, 
+	                        ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE));
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_OUT_OCTETS],
+	               input->len - GET_IF_IP6_HDR_SIZE(input));
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutEchoReplies, 1);
+	ip6_output(input, 0, TMO_ICMP_OUTPUT);
+	}
+
+/*
+ *  icmp6_notify_error -- ã¨ã©ã¼ãéç¥ããã
+ */
+
+static void
+icmp6_notify_error(T_NET_BUF *input, uint_t poff)
+{
+	T_ICMP6_HDR	*icmp6h;
+	ER_UINT		loff;
+	uint_t		len, next;
+
+	len  = input->len - poff;
+
+	/* ãã¼ã¿ã°ã©ã é·ã ICMP6 ãããé· + IP6 ãããé·ä»¥ä¸ãªãä½ãããªãã*/
+	if (len < ICMP6_HDR_SIZE + IP6_HDR_SIZE)
+		return;
+
+	icmp6h = GET_ICMP6_HDR(input, poff);
+
+	/* æçµããããæ¢ç´¢ããã*/
+	loff = ip6_lasthdr(input, poff + ICMP6_HDR_SIZE, IPPROTO_IPV6, &next);
+
+	/* æçµãããã TCP/UDP ã®ã¿å¯¾å¿ããã*/
+	if (loff >= 0 && (next == IPPROTO_TCP || next == IPPROTO_UDP)) {
+
+		memcpy(GET_IP6_HDR(input), input->buf + (loff + ICMP6_HDR_SIZE),
+		                           input->len - (loff + ICMP6_HDR_SIZE));
+		input->len -= loff + ICMP6_HDR_SIZE;
+
+#if defined(SUPPORT_TCP)
+
+		if (next == IPPROTO_TCP)
+
+			tcp_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+		if (next == IPPROTO_UDP)
+
+			udp6_notify(input, icmp6h->code == ICMP6_DST_UNREACH_NOPORT ? EV_CNNRF : EV_HURCH);
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
+
+		}
+	else
+		syslog(LOG_NOTICE, "[ICMP6] error code: %d.", icmp6h->code);
+	}
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+/*
+ *  icmp6_mtudisc_update -- Path MTU ãæ´æ°ããã
+ */
+
+static void
+icmp6_mtudisc_update(T_NET_BUF *input, uint_t off, uint32_t mtu)
+{
+	T_IP6_HDR	*pip6h;
+
+	pip6h = (T_IP6_HDR*)GET_ICMP6_SDU(input, off);
+
+	if (mtu < IP6_HDR_SIZE + sizeof(T_IP6_FRAG_HDR) + 8)
+		return;
+
+	if (mtu > IF_MTU)
+		return;
+
+	in6_hostcache_update(&pip6h->dst, mtu);
+	}
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  icmp6_redirect_input -- åãç´ãã¡ãã»ã¼ã¸ã®å¦ç
+ */
+
+static void
+icmp6_redirect_input (T_NET_BUF *input, uint_t off)
+{
+	T_IP6_HDR		*ip6h;
+	const T_IN6_ADDR	*gw;
+	T_ND_REDIRECT_HDR	*rdh;
+	T_ND_OPT_HDR		*opth;
+	T_IFNET			*ifp = IF_GET_IFNET();
+	bool_t			router, onlink;
+	uint_t			lladdr_len = 0;
+	uint8_t			*lladdr = NULL;
+	uint8_t			nd_opt_off[ND_OPT_OFF_ARRAY_SIZE];
+
+	ip6h = GET_IP6_HDR(input);
+
+	/*
+	 *  IP ãããã®ãã§ãã¯ãä»¥ä¸ã®å ´åã¯ç ´æ£ããã
+	 *    ã»ãªã³ã¯ã­ã¼ã«ã«ä»¥å¤ããéããã¦ããã¡ãã»ã¼ã¸
+	 *    ã»ããããªãããã IPV6_MAXHLIM (255) ä»¥å¤
+	 */
+	if (!IN6_IS_ADDR_LINKLOCAL(&ip6h->src) || ip6h->hlim != IPV6_MAXHLIM)
+		goto err_ret;
+
+	rdh  = (T_ND_REDIRECT_HDR *)(input->buf + off);
+
+	/* åãç´ãã®çµç¹ã¢ãã¬ã¹ããã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®å ´åã¯ç ´æ£ããã*/
+	if (IN6_IS_ADDR_MULTICAST(&rdh->dst))
+		goto err_ret;
+
+	/* ã¿ã¼ã²ããã¢ãã¬ã¹ãçµè·¯è¡¨ã«ç»é²ããã¦ããããã§ãã¯ããã*/
+	if ((gw = in6_rtalloc(ifp, &rdh->dst)) != NULL) {
+		/* GW ã¢ãã¬ã¹ã¨éä¿¡å
+ã¢ãã¬ã¹ãç°ãªã£ã¦ããã°ç ´æ£ããã*/
+		if (!IN6_ARE_ADDR_EQUAL(gw, &ip6h->src))
+			goto err_ret;
+		}
+	else	/* çµè·¯è¡¨ã«ãªããã°ç ´æ£ããã*/
+		goto err_ret;
+
+	router = onlink = false;
+
+	/*
+	 *  ã¿ã¼ã²ããã¢ãã¬ã¹ããªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã§ããã°ã
+	 *  ã¿ã¼ã²ããã¯ã«ã¼ã¿
+	 */
+	if (IN6_IS_ADDR_LINKLOCAL(&rdh->target))
+		router = true;
+
+	/*
+	 *  ã¿ã¼ã²ããã¢ãã¬ã¹ã¨çµç¹ã¢ãã¬ã¹ãåä¸ã§ããã°ããªã³ãªã³ã¯
+	 */
+	if (IN6_ARE_ADDR_EQUAL(&rdh->target, &rdh->dst))
+		onlink = true;
+		
+	/*
+	 *  ã«ã¼ã¿ã§ãããªã³ãªã³ã¯ã§ããªããã°ã¨ã©ã¼
+	 */
+	if (!router && !onlink)
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã®ãªãã»ãããè¨é²ããã*/
+	if (nd6_options(nd_opt_off, input->buf +  off + ND_REDIRECT_HDR_SIZE,
+	                            input->len - (off + ND_REDIRECT_HDR_SIZE)) != E_OK)
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ (åãç´ãã®ã«ã¼ã¿ã®ãªã³ã¯ã¢ãã¬ã¹) */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_TARGET_LINKADDR)]) {
+		opth = (T_ND_OPT_HDR *)((uint8_t *)(input->buf + off + ND_REDIRECT_HDR_SIZE) +
+		                        nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_TARGET_LINKADDR)] - 8);
+	 	/* æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã*/
+		lladdr     = (uint8_t *)(opth + 1);
+		lladdr_len = (opth->len << 3);
+		}
+
+	/*
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹é·ãä¸è´ããªããã°ã¨ã©ã¼
+	 */
+	if (lladdr && lladdr_len != ((sizeof(T_IF_ADDR) + sizeof(T_ND_OPT_HDR) + 7) & ~7))
+		goto err_ret;
+
+	/* åãç´ãã®ã«ã¼ã¿ã®ãªã³ã¯ã¢ãã¬ã¹ãè¿é£ã­ã£ãã·ã¥ã«ç»é²ããã*/
+	nd6_cache_lladdr(ifp, &rdh->target, (T_IF_ADDR *)lladdr, ND_REDIRECT, 
+	                 onlink ? ND_REDIRECT_ONLINK : ND_REDIRECT_ROUTER);
+
+	/* ã«ã¼ãã£ã³ã°è¡¨ã«ç»é²ããã*/
+	in6_rtredirect(&rdh->target, &rdh->dst, 128, IN_RTF_REDIRECT, TMO_IN_REDIRECT);
+
+	syscall(rel_net_buf(input));
+	return;
+
+err_ret:
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+	}
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
+
+/*
+ *  icmp6_input -- ICMP6 ã®å
+¥åé¢æ°
+ */
+
+uint_t
+icmp6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_IP6_HDR	*ip6h;
+	T_ICMP6_HDR	*icmp6h;
+	uint_t		len, off = *offp;
+	uint8_t		code;
+
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_OCTETS],
+	               input->len - GET_IF_IP6_HDR_SIZE(input));
+	NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInMsgs, 1);
+
+	/* ICMP6 ãããã®é·ãããã§ãã¯ããã*/
+	len  = input->len - off;
+	if (len < ICMP6_HDR_SIZE) {
+		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
+		goto buf_rel;
+		}
+
+	ip6h   = GET_IP6_HDR(input);
+	icmp6h = GET_ICMP6_HDR(input, off);
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	if ((in6_cksum(input, IPPROTO_ICMPV6, off, ntohs(ip6h->plen) - (off - IF_IP6_HDR_SIZE)) & 0xffff) != 0) {
+		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
+		goto buf_rel;
+		}
+
+	code = icmp6h->code;
+
+	/* ã¡ãã»ã¼ã¸ã®åã«ããåå²ããã*/
+	switch (icmp6h->type) {
+
+	case ICMP6_DST_UNREACH:			/* å®å
+å°éä¸å¯è½		*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInDestUnreachs, 1);
+		icmp6_notify_error(input, off);
+		break;
+
+	case ICMP6_ECHO_REQUEST:		/* ã¨ã³ã¼è¦æ±			*/
+		icmp6_echo_request(input, off);
+		return IPPROTO_DONE;
+		break;
+
+	case ICMP6_ECHO_REPLY:			/* ã¨ã³ã¼å¿ç­			*/
+
+#ifdef ICMP_CFG_CALLBACK_ECHO_REPLY
+
+		icmp6_echo_reply(input, off);
+
+#endif	/* of #ifdef ICMP_CFG_CALLBACK_ECHO_REPLY */
+
+		break;
+
+	case ND_ROUTER_ADVERT:			/* ã«ã¼ã¿éç¥			*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRouterAdvertisements, 1);
+		if (code != 0 || len < ROUTER_ADVERT_HDR_SIZE)
+			goto buf_rel;
+		nd6_ra_input(input, off);
+		return IPPROTO_DONE;
+		break;
+
+	case ND_NEIGHBOR_SOLICIT:		/* è¿é£è¦è«			*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInNeighborSolicits, 1);
+		if (code != 0 || len < NEIGHBOR_SOLICIT_HDR_SIZE)
+			goto buf_rel;
+		nd6_ns_input(input, off);
+		return IPPROTO_DONE;
+		break;
+
+	case ND_NEIGHBOR_ADVERT:		/* è¿é£éç¥			*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInNeighborAdvertisements, 1);
+		if (code != 0 || len < NEIGHBOR_ADVERT_HDR_SIZE)
+			goto buf_rel;
+		nd6_na_input(input, off);
+		return IPPROTO_DONE;
+		break;
+
+	case ND_REDIRECT:			/* åãç´ã			*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInRedirects, 1);
+
+#if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY)
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+		if (code != 0 || len < ND_REDIRECT_HDR_SIZE)
+			goto buf_rel;
+		icmp6_redirect_input(input, off);
+		return IPPROTO_DONE;
+
+#else	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+
+		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+#else	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
+
+		syslog(LOG_WARNING, "[ICMP6] redirect ignored.");
+
+#endif	/* of #if defined(NUM_IN6_REDIRECT_ROUTE_ENTRY) */
+
+		break;
+
+	case ICMP6_PACKET_TOO_BIG:		/* ãã±ãããå¤§ããããã	*/
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+		icmp6_mtudisc_update(input, off, ntohl(icmp6h->icmp6_mtu));
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInPktTooBigs, 1);
+		break;
+
+	case ICMP6_TIME_EXCEEDED:		/* TTL ãè¶
+éããã		*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInTimeExcds, 1);
+		break;
+
+	case ICMP6_PARAM_PROB:			/* IPv6 ããããä¸æ­£ã		*/
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInParmProblems, 1);
+		break;
+
+	case MLD_LISTENER_QUERY:		/* ãã«ãã­ã£ã¹ãåä¿¡è
+ç
+§ä¼	*/
+	case MLD_LISTENER_REPORT:		/* ãã«ãã­ã£ã¹ãåä¿¡è
+å ±å	*/
+	case MLD_LISTENER_DONE:			/* ãã«ãã­ã£ã¹ãåä¿¡è
+çµäº	*/
+	case ND_ROUTER_SOLICIT:			/* ã«ã¼ã¿è¦è«			*/
+	case ICMP6_ROUTER_RENUMBERING:		/* ã«ã¼ã¿çªå·åè¨­å®		*/
+	case ICMP6_FQDN_QUERY:			/* FQDN ç
+§ä¼			*/
+	case ICMP6_FQDN_REPLY:			/* FQDN å¿ç­			*/
+		syslog(LOG_INFO, "[ICMP6] unsupported type: %d.", icmp6h->type);
+		break;
+
+	default:
+		syslog(LOG_WARNING, "[ICMP6] unknown type: %d.", icmp6h->type);
+		NET_COUNT_ICMP6(net_count_icmp6[NC_ICMP6_IN_ERR_PACKETS], 1);
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpInErrors, 1);
+		break;
+		}
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+/*
+ *  icmp6_error -- ICMP6 ã¨ã©ã¼éä¿¡é¢æ°
+ */
+
+void
+icmp6_error (T_NET_BUF *input, uint8_t type, uint8_t code, uint32_t param)
+{
+	T_NET_BUF	*output;
+	T_IP6_HDR	*ip6h;
+	T_ICMP6_HDR	*icmp6h;
+	ER_UINT		off;
+	uint_t		next, len;
+
+	ip6h = GET_IP6_HDR(input);
+
+	/*
+	 *  å®å
+ã¢ãã¬ã¹ãããã«ãã­ã£ã¹ãã®å ´åã¯ã
+	 *  ä»¥ä¸ã®æ¡ä»¶ä»¥å¤ã®ã¨ãã¯å¦çãè¡ããªãã
+	 *
+	 *    ã»ãã¼ã¿ã°ã©ã ãå¤§ããããã
+	 *    ã»IPv6 ãããã®ä¸æ­£ã§ããªãã·ã§ã³ãèªè­ã§ããªãã
+	 */
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst) &&
+	    !((type == ICMP6_PACKET_TOO_BIG) ||
+	      (type == ICMP6_PARAM_PROB && code == ICMP6_PARAMPROB_OPTION)))
+		goto buf_rel;
+
+	/*
+	 *  å§ç¹ã¢ãã¬ã¹ããä»¥ä¸ã®å ´åã¯å¦çãè¡ããªãã
+	 *
+	 *    ã»ç¡æå®
+	 *    ã»ãã«ãã­ã£ã¹ã
+	 */
+	if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src) ||
+	    IN6_IS_ADDR_MULTICAST  (&ip6h->src))
+		goto buf_rel;
+
+	/* æå¾ã®ããããæ¢ç´¢ããã*/
+	off = ip6_lasthdr(input, 0, IPPROTO_IPV6, &next);
+
+	/*
+	 *  ã¿ã¤ãããã¨ã©ã¼ãåãç´ãã® ICMP6 ãã±ããã®ã¨ã©ã¼ã«ã¯è¿ç­ããªãã
+	 */
+	if (off >= 0 && next == IPPROTO_ICMPV6) {
+		T_ICMP6_HDR	*icmp6h;
+
+		if (input->len - off < ICMP6_HDR_SIZE)
+			goto buf_rel;
+
+		icmp6h = GET_ICMP6_HDR(input, off);
+		if (icmp6h->type <  ICMP6_ECHO_REQUEST ||
+		    icmp6h->type == ND_REDIRECT)
+			goto buf_rel;
+		}
+
+	/* DoS æ»æã«å¯¾ããé²å¾¡ã¯æªå®è£
+ */
+
+	/*
+	 *  éãè¿ãã¡ãã»ã¼ã¸é·ããICMPv6 ã®æå¤§ãã¤ã­ã¼ãé·ã«èª¿æ´ããã
+	 *  IPV6_MMTU - (IP6_HDR_SIZE + ICMP6_HDR_SIZE)
+	 */
+	if (input->len - IF_HDR_SIZE > IPV6_MMTU - (IP6_HDR_SIZE + ICMP6_HDR_SIZE))
+		len = IPV6_MMTU - (IP6_HDR_SIZE + ICMP6_HDR_SIZE);
+	else
+		len = input->len - IF_HDR_SIZE;
+
+	/* éä¿¡ç¨ã®ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+	if (in6_get_datagram(&output, len + ICMP6_HDR_SIZE, 0,
+	                     &ip6h->src, &in6_addr_unspecified,
+	                     IPPROTO_ICMPV6, IPV6_MAXHLIM,
+	                     NBA_SEARCH_ASCENT, TMO_ICMP_OUTPUT) != E_OK)
+		goto buf_rel;
+
+	/* ICMP6 ããããè¨­å®ããã*/
+ 	icmp6h = GET_ICMP6_HDR(output, IF_IP6_ICMP6_HDR_OFFSET);
+ 	icmp6h->type       = type;
+ 	icmp6h->code       = code;
+ 	icmp6h->icmp6_pptr = htonl(param);
+ 
+ 	/* ã¨ã©ã¼ãã¼ã¿ãè¨­å®ããã*/
+ 	memcpy(GET_ICMP6_SDU(output, IF_IP6_ICMP6_HDR_OFFSET), (uint8_t *)ip6h, len);
+
+#ifdef SUPPORT_MIB
+
+	switch (type) {
+	case ICMP6_DST_UNREACH:
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutDestUnreachs, 1);
+		break;
+
+	case ICMP6_PARAM_PROB:
+		NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutParmProblems, 1);
+		break;
+
+	default:
+		break;
+
+		}
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+	/* éä¿¡ããã*/
+	icmp6_output(output, IF_IP6_HDR_SIZE);
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.c	(revision 317)
@@ -0,0 +1,133 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_timer.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/if_ether.h>
+
+#include <netinet6/in6.h>
+#include <netinet6/in6_var.h>
+
+#include <net/if_var.h>
+
+#if defined(_IP6_CFG) && defined(SUPPORT_ETHER)
+
+/*
+ *  ether_map_ipv6_multicast -- IPv6 ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ããã¤ã¼ãµãããã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã¸ã®å¤æ
+ */
+
+void
+ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr)
+{
+	eaddr->lladdr[0] = UINT_C(0x33);
+	eaddr->lladdr[1] = UINT_C(0x33);
+	eaddr->lladdr[2] = maddr->s6_addr8[12];
+	eaddr->lladdr[3] = maddr->s6_addr8[13];
+	eaddr->lladdr[4] = maddr->s6_addr8[14];
+	eaddr->lladdr[5] = maddr->s6_addr8[15];
+	}
+
+#endif /* of #if defined(_IP6_CFG) && defined(SUPPORT_ETHER) */
Index: asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/if6_ether.h	(revision 317)
@@ -0,0 +1,88 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#ifndef _IF6_ETHER_H_
+#define _IF6_ETHER_H_
+
+/*
+ *  é¢æ°
+ */
+
+extern void ether_map_ipv6_multicast (T_ETHER_ADDR *eaddr, const T_IN6_ADDR *maddr);
+
+#endif	/* of #ifndef _IF6_ETHER_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6.c	(revision 317)
@@ -0,0 +1,547 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6.c,v 1.21 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: in6.c,v 1.259 2002/01/21 11:37:50 keiichi Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1991, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in.c	8.2 (Berkeley) 11/15/93
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_types.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#include <netinet6/in6.h>
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+#include <netinet6/in6_ifattach.h>
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+const T_IN6_ADDR in6_addr_unspecified =
+	IPV6_ADDR_UNSPECIFIED_INIT;
+
+const T_IN6_ADDR in6_addr_linklocal_allnodes =
+	IPV6_ADDR_LINKLOCAL_ALLNODES_INIT;
+
+const T_IN6_ADDR in6_addr_linklocal_allrouters =
+	IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT;
+
+/*
+ *  in6_addmulti -- ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãç»é²ããã
+ */
+
+static ER
+in6_addmulti (T_IFNET *ifp, T_IN6_ADDR *maddr)
+{
+	ER	error = E_OK;
+
+	if ((error = if_addmulti(ifp, maddr, AT_INET6)) != E_OK)
+		return error;
+
+	return error;
+	}
+
+/*
+ *  in6_ifinit -- ã¤ã³ã¿ãã§ã¼ã¹ã«ã¢ãã¬ã¹æ
+å ±ãè¨­å®ããåæåããã
+ */
+
+static ER
+in6_ifinit (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr, uint_t prefix_len)
+{
+	/* ã¢ãã¬ã¹ã¨ãã¬ãã£ãã¯ã¹é·ãè¨­å®ããã*/
+	ia->addr       = *addr;
+	ia->prefix_len = prefix_len;
+
+	/* ãã©ã°ãåæåããã*/
+	ia->flags = 0;
+
+	/*
+	 *  åãã¦ã¢ãã¬ã¹ãè¨­å®ãããã¨ããã¤ã³ã¿ãã§ã¼ã¹ç¬èªã®åæåãè¡ãã
+	 */
+
+	return E_OK;
+	}
+
+/*
+ *  in6_ifainit -- ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½ã®åæå
+ */
+
+void
+in6_ifainit (void)
+{
+	T_IN6_IFADDR	*ia = NULL;
+	T_IFNET		*ifp = IF_GET_IFNET();
+	int_t 		ix;
+
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		memset(ia, sizeof(T_IN6_IFADDR), 0);
+		ia->router_index = IN6_RTR_IX_UNREACH;
+		ia->prefix_index = ND6_PREFIX_IX_INVALID;
+		}
+	}
+
+/*
+ *  in6_if2idlen -- ã¤ã³ã¿ãã§ã¼ã¹ ID é·ãè¿ãã
+ */
+
+int_t
+in6_if2idlen (T_IFNET *ifp)
+{
+#if IF_TYPE == IFT_ETHER
+	return 64;
+#else
+	return 64;
+#endif
+	}
+
+/*
+ *  in6_addr2ifaix -- ã¢ãã¬ã¹ããã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ
+å ±ã®ã¤ã³ããã¯ã¹ã«å¤æããã
+ */
+
+int_t
+in6_addr2ifaix (const T_IN6_ADDR *addr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	int_t 		ix;
+
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
+		    in6_are_prefix_equal(addr, &ia->addr, ia->prefix_len))
+			return ix;
+		}
+
+	return IPV6_IFADDR_IX_INVALID;
+	}
+
+/*
+ *  in6_addr2maix -- ã¢ãã¬ã¹ãããã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®ã¤ã³ããã¯ã¹ã«å¤æããã
+ */
+
+int_t
+in6_addr2maix (const T_IN6_ADDR *addr)
+{
+	if (addr->s6_addr8[0] == 0xff) {
+		if (addr->s6_addr8[1] == 0x02) {
+			if (addr->s6_addr8[11] == 0x01 && addr->s6_addr8[12] == 0xff)
+				return IPV6_MADDR_IX_SOL_NODE;
+			else
+				return IPV6_MADDR_IX_LL_ALL_NODE;
+			}
+		else
+			return IPV6_MADDR_IX_EXTRA;
+		}
+	else
+		return IPV6_MADDR_IX_EXTRA;
+	}
+
+/*
+ *  in6_update_ifa -- ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹æ
+å ±ãæ´æ°ããã
+ */
+
+ER
+in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
+                uint_t prefix_len, uint32_t vltime, uint32_t pltime,
+                int_t router_index, int_t prefix_index, uint_t flags)
+{
+	T_IN6_ADDR	llsol;
+	ER		error = E_OK;
+	SYSTIM		now;
+
+	/* å¼æ°ããã§ãã¯ããã*/
+	if (addr == NULL)
+		return E_PAR;
+
+	/*
+	 *  æå¹æéããã§ãã¯ããã
+	 *  vltime (æå¹æé) ã¨ pltime (æ¨å¥¨æå¹æé) ã®åä½ã¯ [s]ã
+	 */
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (((vltime != ND6_INFINITE_LIFETIME) && (vltime + now < now)) || vltime == 0)
+		return E_PAR;
+
+	if ((pltime != ND6_INFINITE_LIFETIME) && (pltime + now < now))
+		return E_PAR;
+
+	/* ã¤ã³ã¿ãã§ã¼ã¹ãåæåããã*/
+	if ((error = in6_ifinit(ifp, ia, addr, prefix_len)) != E_OK)
+		return error;
+
+	if (IN6_IS_ADDR_LINKLOCAL(addr)) {
+
+		/* è¦è«ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãç»é²ããã*/
+		llsol.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
+		llsol.s6_addr32[1] = 0x00000000;
+		llsol.s6_addr32[2] = IPV6_ADDR_INT32_ONE;
+		llsol.s6_addr32[3] = addr->s6_addr32[3];
+		llsol.s6_addr8[12] = 0xff;
+		if ((error = in6_addmulti(ifp, &llsol)) != E_OK)
+			return error;
+
+		/* å
+¨ãã¼ãã»ãªã³ã¯ã­ã¼ã«ã«ã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãç»é²ããã*/
+		llsol.s6_addr32[2] = 0x00000000;
+		llsol.s6_addr32[3] = IPV6_ADDR_INT32_ONE;
+		if ((error = in6_addmulti(ifp, &llsol)) != E_OK)
+			return error;
+
+		}
+
+	/* ã«ã¼ã¿ã¤ã³ããã¯ã¹ãè¨­å®ããã*/
+	ia->router_index = router_index;
+
+	/* ãã¬ãã£ãã¯ã¹ã¤ã³ããã¯ã¹ãè¨­å®ããã*/
+	ia->prefix_index = prefix_index;
+
+	/* ãã©ã°ãè¨­å®ããã*/
+	ia->flags  = flags & ~(IN6_IFF_DUPLICATED | IN6_IFF_NODAD);
+	ia->flags |= IN6_IFF_DEFINED;
+
+ 	/*
+ 	 *  ã¢ãã¬ã¹æå¹æéãè¨­å®ããã
+	 *  vltime (æå¹æé) ã¨ pltime (æ¨å¥¨æå¹æé) ã®åä½ã¯ [s]ã
+ 	 */
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+ 	ia->lifetime.vltime = vltime;
+ 	if (vltime != ND6_INFINITE_LIFETIME)
+ 		ia->lifetime.expire = now + vltime;
+ 	else
+ 		ia->lifetime.expire = 0;
+
+ 	ia->lifetime.pltime = pltime;
+ 	if (pltime != ND6_INFINITE_LIFETIME)
+ 		ia->lifetime.preferred = now + pltime;
+ 	else
+ 		ia->lifetime.preferred = 0;
+
+	/* è¿é£æ¢ç´¢ã®åæè¨­å®ãè¡ãã*/
+	nd6_ifattach(ifp);
+
+	/* éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã*/
+	if ((flags & IN6_IFF_NODAD) == 0) {
+		ia->flags |= IN6_IFF_TENTATIVE;
+		nd6_dad_start(ifp, ia, NULL);
+		}
+
+	return error;
+	}
+
+/*
+ * in6ifa_ifpwithix -- ã¤ã³ããã¯ã¹çªå·ããããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«
+ *                     å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãæ¢ç´¢ããã
+ */
+
+T_IN6_IFADDR *
+in6ifa_ifpwithix (T_IFNET *ifp, int_t ix)
+{
+	return ix < NUM_IN6_IFADDR_ENTRY? &ifp->in6_ifaddrs[ix] : NULL;
+	}
+
+/*
+ * in6ifa_ifpwithrtrix -- ã«ã¼ã¿ã®ã¤ã³ããã¯ã¹çªå·ããããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«
+ *                        å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãæ¢ç´¢ããã
+ */
+
+T_IN6_IFADDR *
+in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t router_index)
+{
+	int_t ix;
+
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
+		if (ifp->in6_ifaddrs[ix].router_index == router_index)
+			return &ifp->in6_ifaddrs[ix];
+	return NULL;
+	}
+
+/*
+ * in6_ifawithifp -- å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹æ
+å ±ãã
+ *                   ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
+ */
+
+T_IN6_IFADDR *
+in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst)
+{
+	uint_t	scope;
+	int_t	ix;
+
+	/* å®å
+ã¢ãã¬ã¹ã¨åãã¹ã³ã¼ãã®ã¢ãã¬ã¹ãè¿ãã*/
+	if ((ix = in6_addr2ifaix(dst)) != IPV6_IFADDR_IX_INVALID)
+		return &ifp->in6_ifaddrs[ix];
+	else if ((ix = in6_addr2maix(dst)) == IPV6_MADDR_IX_SOL_NODE ||
+	          ix                       == IPV6_MADDR_IX_LL_ALL_NODE)
+		return &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	else {
+		scope = in6_addrscope(dst);
+		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+			if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+			    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_DETACHED) == 0 &&
+			    in6_addrscope(&ifp->in6_ifaddrs[ix].addr) == scope) {
+				return &ifp->in6_ifaddrs[ix];
+				}
+			}
+		return NULL;
+		}
+	}
+
+/*
+ * in6_addrwithifp -- å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+ *                    ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ããã
+ */
+
+const T_IN6_ADDR *
+in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst)
+{
+	T_IN6_IFADDR *ifaddr;
+
+	if ((ifaddr = in6_ifawithifp(ifp, dst)) == NULL)
+		return NULL;
+	else {
+		*src = ifaddr->addr;
+		return src;
+		}
+	}
+
+/*
+ * in6_if_up -- ã¤ã³ã¿ãã§ã¼ã¹èµ·åå¾ã®éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã
+ */
+
+void
+in6_if_up (T_IFNET *ifp)
+{
+#if 0						/* ä¿ç */
+	int_t dad_delay, ix;
+#endif	/* of #if 0 */
+
+	in6_ifattach(ifp);
+
+#if 0						/* ä¿ç */
+	/* éè¤ã¢ãã¬ã¹æ¤åºãè¡ãã*/
+	dad_delay = 0;
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; )
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    (ifp->in6_ifaddrs[ix].flags & IN6_IFF_TENTATIVE))
+			nd6_dad_start(ifp, &ifp->in6_ifaddrs[ix], &dad_delay);
+#endif	/* of #if 0 */
+
+#if NUM_ND6_RTR_SOL_RETRY > 0
+
+	/* ã«ã¼ã¿è¦è«ãåºåããã*/
+	nd6_rtrsol_ctl();
+
+#endif	/* of #if NUM_ND6_RTR_SOL_RETRY > 0 */
+	}
+
+/*
+ *  in6_are_prefix_equal -- ãã¬ãã£ãã¯ã¹ãåä¸ãèª¿ã¹ãã
+ */
+
+bool_t
+in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix, uint_t prefix_len)
+{
+	uint_t bitlen, bytelen;
+
+	bytelen = prefix_len / 8;
+	if (memcmp(&addr->s6_addr, &prefix->s6_addr, bytelen))
+		return false;
+
+	bitlen = prefix_len % 8;
+	if (  addr->s6_addr[bytelen] >> (8 - bitlen) !=
+	    prefix->s6_addr[bytelen] >> (8 - bitlen))
+		return false;
+
+	return true;
+	}
+
+/*
+ *  in6_ifaddr_timer -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+in6_ifaddr_timer (T_IFNET *ifp)
+{
+	T_IN6_IFADDR	*ia;
+	SYSTIM		now;
+	int_t		ix;
+
+	syscall(get_tim(&now));
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+
+		if ((ia->flags & IN6_IFF_DEFINED) == 0)
+			;
+		else if (IFA6_IS_INVALID(ia, now)) {
+
+			/*
+			 *  æå¹æéãéããã®ã§åé¤ããã
+			 */
+			ia->flags &= ~IN6_IFF_DEFINED;
+			}
+
+		else if (IFA6_IS_DEPRECATED(ia, now)) {
+
+			/*
+			 *  æ¨å¥¨æå¹æéãéããã®ã§éæ¨å¥¨ã«ããã
+			 */
+			ia->flags |= IN6_IFF_DEPRECATED;
+			}
+		}
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6.h	(revision 317)
@@ -0,0 +1,320 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6.h,v 1.7.2.4 2001/07/04 09:45:23 ume Exp $	*/
+/*	$KAME: in6.h,v 1.89 2001/05/27 13:28:35 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in.h	8.3 (Berkeley) 1/3/94
+ */
+ 
+#ifndef _IN6_H_
+#define _IN6_H_
+
+/*
+ *  IPv6 ã¢ãã¬ã¹æ§é 
+ *
+ *    RFC4291ï¼RFC1884ãRFC2373ãRFC3513 ã®ã¢ãããã¼ãï¼
+ */
+
+/*
+ *  IPv6 ã¢ãã¬ã¹
+ */
+
+struct t_in6_addr {
+	union {
+		uint8_t		__u6_addr8[16];
+		uint16_t	__u6_addr16[8];
+		uint32_t	__u6_addr32[4];
+		} __u6_addr;
+	};
+
+#define s6_addr		__u6_addr.__u6_addr8
+#define s6_addr8	__u6_addr.__u6_addr8
+#define s6_addr16	__u6_addr.__u6_addr16
+#define s6_addr32	__u6_addr.__u6_addr32
+
+#ifndef T_IN6_ADDR_DEFINED
+
+typedef struct t_in6_addr T_IN6_ADDR;
+
+#define T_IN6_ADDR_DEFINED
+
+#endif	/* of #ifndef T_IN6_ADDR_DEFINED */
+
+/*
+ *  IPv6 ã¢ãã¬ã¹ã®åæåãã¼ã¿
+ */
+
+#define IPV6_ADDR_UNSPECIFIED_INIT	\
+	{{{ UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00) }}}
+
+#define IPV6_ADDR_LINKLOCAL_ALLNODES_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x01) }}}
+
+#define IPV6_ADDR_LINKLOCAL_ALLROUTERS_INIT	\
+	{{{ UINT_C(0xff), UINT_C(0x02), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), \
+	    UINT_C(0x00), UINT_C(0x00), UINT_C(0x00), UINT_C(0x02) }}}
+
+/*
+ *  ç¹å¥ãªã¢ãã¬ã¹ã®ãã§ãã¯
+ */
+
+/* ç¡æå® */
+
+#define IN6_IS_ADDR_UNSPECIFIED(a)	\
+	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR)) == 0)
+
+/* ã«ã¼ãããã¯ */
+
+#define IN6_IS_ADDR_LOOPBACK(a)		\
+	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0 && \
+	 (a)->s6_addr8[15] == 0x01)
+
+/*
+ *  ã¹ã³ã¼ã ID
+ */
+
+#define IPV6_ADDR_SCOPE_NODELOCAL	UINT_C(0x01)
+#define IPV6_ADDR_SCOPE_LINKLOCAL	UINT_C(0x02)
+#define IPV6_ADDR_SCOPE_SITELOCAL	UINT_C(0x05)
+#define IPV6_ADDR_SCOPE_ORGLOCAL	UINT_C(0x08)
+#define IPV6_ADDR_SCOPE_GLOBAL		UINT_C(0x0e)
+
+/*
+ *  ã¦ãã­ã£ã¹ãã»ã¹ã³ã¼ã
+ *
+ *  æ³¨æ: ä¸ä½ 10 ãããã®ã¿ãã§ãã¯ããªããã°ãªããªããRFC2373 åç
+§
+ */
+
+/* ãªã³ã¯ã­ã¼ã«ã« */
+
+#define IN6_IS_ADDR_LINKLOCAL(a)	\
+	(((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0x80)))
+
+/* ãµã¤ãã­ã¼ã«ã« */
+
+#define IN6_IS_ADDR_SITELOCAL(a)	\
+	(((a)->s6_addr8[0] == UINT_C(0xfe)) && (((a)->s6_addr8[1] & UINT_C(0xc0)) == UINT_C(0xc0)))
+
+/* éç´å¯è½ã¦ãã­ã£ã¹ã (ã°ã­ã¼ãã«) */
+
+#define IN6_IS_ADDR_AGGREGATE_UNICAST(a)	\
+	(((a)->s6_addr8[0] & UINT_C(0xe0)) == UINT_C(0x20))
+
+/*
+ *  ãã«ãã­ã£ã¹ã
+ */
+
+#define IN6_IS_ADDR_MULTICAST(a)	((a)->s6_addr8[0] == UINT_C(0xff))
+
+/*
+ *  åä¸ã®ãã§ãã¯
+ */
+
+#define IN6_ARE_ADDR_EQUAL(a,b)		(memcmp((a), (b), sizeof(T_IN6_ADDR)) == 0)
+
+/*
+ *  çµè·¯å¶å¾¡ç¨å®ç¾©
+ */
+
+#define IPV6_RTHDR_TYPE_0		UINT_C(0)	/* IPv6 çµè·¯å¶å¾¡ãããã¿ã¤ã 0	*/
+
+/*
+ *  è¦å®å¤ã¨å¶éå¤
+ */
+
+#define IPV6_DEFAULT_MULTICAST_HOPS	1	/* ãã«ãã­ã£ã¹ãæã®ããããªãããã®è¦å®å¤	*/
+#define ND6_INFINITE_LIFETIME		0xffffffff	/* ã¢ãã¬ã¹ã®ç¡å¶éæå¹æé		*/
+
+/*
+ *  ITRON TCP/IPv6 ã¢ãã¬ã¹/ãã¼ãçªå·ã®å®ç¾©
+ */
+
+typedef struct t_ipv6ep {
+	T_IN6_ADDR	ipaddr;		/* IPv6 ã¢ãã¬ã¹	*/
+	uint16_t	portno;		/* ãã¼ãçªå·	*/
+	} T_IPV6EP;
+
+#define T_IPV6EP_DEFINED
+
+/*
+ *  ITRON/TCP/IP ç¨ IP ã¢ãã¬ã¹ã®å®ç¾©
+ */
+
+#define IPV6_ADDRANY		IPV6_ADDR_UNSPECIFIED_INIT
+
+/*
+ *  åççæç¨ IPv6 TCP åä»å£
+ */
+
+typedef struct t_tcp6_crep {
+	/* æ¨æº */
+	ATR		repatr;		/* åä»å£å±æ§		*/
+	T_IPV6EP	myaddr;		/* èªåã®ã¢ãã¬ã¹	*/
+	/* å®è£
+ä¾å­ */
+	} T_TCP6_CREP;
+
+/*
+ *  åççæç¨ IPv6 UDP éä¿¡ç«¯ç¹
+ */
+
+typedef struct t_udp6_ccep {
+	/* æ¨æº */
+	ATR		cepatr;		/* UDP éä¿¡ç«¯ç¹å±æ§		*/
+	T_IPV6EP	myaddr;		/* èªåã®ã¢ãã¬ã¹		*/
+	FP		callback;	/* ã³ã¼ã«ããã¯é¢æ°		*/
+	/* å®è£
+ä¾å­ */
+	} T_UDP6_CCEP;
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+extern const T_IN6_ADDR in6_addr_unspecified;
+extern const T_IN6_ADDR in6_addr_linklocal_allnodes;
+extern const T_IN6_ADDR in6_addr_linklocal_allrouters;
+
+#define ipv6_addrany	in6_addr_unspecified
+
+/*
+ *  TINET ç¬èª API
+ */
+
+extern char *ipv62str (char *buf, const T_IN6_ADDR *p_addr);
+extern uint_t in6_get_maxnum_ifaddr (void);
+extern const T_IN6_ADDR *in6_get_ifaddr (int_t index);
+extern ER in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefixlen,
+                          uint32_t vltime, uint32_t pltime);
+extern ER in6_del_ifaddr (T_IN6_ADDR *addr);
+extern T_IN6_ADDR *in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src);
+extern bool_t in6_is_addr_ipv4mapped (const T_IN6_ADDR *addr);
+
+#endif	/* of #ifndef _IN6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.c	(revision 317)
@@ -0,0 +1,213 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6_ifattach.c,v 1.2.2.5 2001/08/13 16:26:17 ume Exp $	*/
+/*	$KAME: in6_ifattach.c,v 1.118 2001/05/24 07:44:00 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#include <netinet6/in6.h>
+#include <netinet6/in6_var.h>
+#include <netinet6/nd6.h>
+#include <netinet6/in6_ifattach.h>
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ * EUI64 ã®å®ç¾©
+ */
+
+#define EUI64_UBIT		0x02
+
+#ifdef SUPPORT_ETHER
+
+/*
+ * get_mac6_ifid -- MAC (6 ãªã¯ããã) ã¢ãã¬ã¹ã§ãã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ãè¨­å®ããã
+ */
+
+static ER
+get_mac6_ifid (T_IFNET *ifp, T_IN6_ADDR *ifra_addr)
+{
+	ifra_addr->s6_addr[ 8] = ifp->ic->ifaddr.lladdr[0] ^ EUI64_UBIT;
+	ifra_addr->s6_addr[ 9] = ifp->ic->ifaddr.lladdr[1];
+	ifra_addr->s6_addr[10] = ifp->ic->ifaddr.lladdr[2];
+	ifra_addr->s6_addr[11] = UINT_C(0xff);
+	ifra_addr->s6_addr[12] = UINT_C(0xfe);
+	ifra_addr->s6_addr[13] = ifp->ic->ifaddr.lladdr[3];
+	ifra_addr->s6_addr[14] = ifp->ic->ifaddr.lladdr[4];
+	ifra_addr->s6_addr[15] = ifp->ic->ifaddr.lladdr[5];
+
+	return E_OK;
+	}
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#ifdef SUPPORT_PPP
+
+/*
+ * get_rand_ifid -- ä¹±æ°ã«ãããã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ãè¨­å®ããã
+ */
+
+static ER
+get_rand_ifid (T_IFNET *ifp, T_IN6_ADDR *ifra_addr)
+{
+	return E_OK;
+	}
+
+#endif	/* of #ifdef SUPPORT_PPP */
+
+#ifdef IP6_CFG_AUTO_LINKLOCAL
+
+/*
+ *  in6_ifattach_linklocal -- ã¤ã³ã¿ãã§ã¼ã¹ã«ãªã³ã¯ã­ã¼ã«ã«ã»ã¢ãã¬ã¹ãå²ãå½ã¦ãã
+ */
+
+static ER
+in6_ifattach_linklocal (T_IFNET *ifp)
+{
+	T_IN6_ADDR	addr;
+	ER		error = E_OK;
+
+	/*
+	 *  ãªã³ã¯ã­ã¼ã«ã«ã»ãã¬ãã£ãã¯ã¹ fe80::/64 ãè¨­å®ããã
+	 */
+	addr.s6_addr32[0] = IPV6_ADDR_INT32_ULL;
+	addr.s6_addr32[1] = ULONG_C(0);
+
+	/* ã¤ã³ã¿ãã§ã¼ã¹è­å¥å­ãè¨­å®ããã*/
+	if ((error = IF_IN6_IFID(ifp, &addr)) != E_OK)
+		return error;
+
+	/* ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹æ
+å ±ãæ´æ°ããã*/
+	if ((error = in6_update_ifa(ifp, &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL],
+	                            &addr, 64, ND6_INFINITE_LIFETIME,
+	                                       ND6_INFINITE_LIFETIME, 
+	                                       IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0)) != E_OK)
+		return error;
+
+	return error;
+	}
+
+#endif	/* of #ifdef IP6_CFG_AUTO_LINKLOCAL */
+
+/*
+ *  in6_ifattach -- ã¤ã³ã¿ãã§ã¼ã¹ã«ã¢ãã¬ã¹ãå²ãå½ã¦ãã
+ */
+
+ER
+in6_ifattach (T_IFNET *ifp)
+{
+	ER error = E_OK;
+
+#ifdef IP6_CFG_AUTO_LINKLOCAL
+
+	if ((ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL].flags & IN6_IFF_DEFINED) == 0)
+		if ((error = in6_ifattach_linklocal(ifp)) != E_OK)
+			return error;
+
+#endif	/* of #ifdef IP6_CFG_AUTO_LINKLOCAL */
+
+	return error;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6_ifattach.h	(revision 317)
@@ -0,0 +1,87 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6_ifattach.h,v 1.3 2001/06/11 12:39:05 ume Exp $	*/
+/*	$KAME: in6_ifattach.h,v 1.14 2001/02/08 12:48:39 jinmei Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _IN6_IFATTACH_H_
+#define _IN6_IFATTACH_H_
+
+/*
+ *  é¢æ°
+ */
+
+extern ER in6_ifattach (T_IFNET *ifp);
+
+#endif	/* of #ifndef _IN6_IFATTACH_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6_rename.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6_rename.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6_rename.h	(revision 317)
@@ -0,0 +1,193 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _IN6_RENAME_H_
+#define _IN6_RENAME_H_
+
+/*
+ *  TCP/IPv6 ãã­ãã³ã«ã¹ã¿ãã¯å
+é¨åã®ãªãã¼ã 
+ */
+
+/* netinet6/in6.c */
+
+#define in6_are_prefix_equal	_tinet_in6_are_prefix_equal
+#define in6ifa_ifpwithrtrix	_tinet_in6ifa_ifpwithrtrix
+#define in6_if_up		_tinet_in6_if_up
+#define in6_if2idlen		_tinet_in6_if2idlen
+#define in6_ifaddr_timer	_tinet_in6_ifaddr_timer
+#define in6ifa_ifpwithix	_tinet_in6ifa_ifpwithix
+#define in6_addr2maix		_tinet_in6_addr2maix
+#define in6_ifawithifp		_tinet_in6_ifawithifp
+#define in6_addr2ifaix		_tinet_in6_addr2ifaix
+#define in6_update_ifa		_tinet_in6_update_ifa
+#define in6_ifainit		_tinet_in6_ifainit
+#define in6_addrwithifp		_tinet_in6_addrwithifp
+#define in6_addr_loopback	_tinet_in6_addr_loopback
+
+/* netinet6/in6_ifattach.c */
+
+#define in6_ifattach		_tinet_in6_ifattach
+
+/* netinet6/in6_subr.c */
+
+#define inn6_is_dstaddr_accept	_tinet_inn6_is_dstaddr_accept
+#define in6_lookup_ifaddr	_tinet_in6_lookup_ifaddr
+#define in6_rtalloc		_tinet_in6_rtalloc
+#define in6_get_ifaddr		_tinet_in6_get_ifaddr
+#define in6_cksum		_tinet_in6_cksum
+#define in6_gateway_lookup	_tinet_in6_gateway_lookup
+#define in6_is_dstaddr_accept	_tinet_in6_is_dstaddr_accept
+#define in6_hostcache_getmtu	_tinet_in6_hostcache_getmtu
+#define in6_set_header		_tinet_in6_set_header
+#define in6_get_datagram	_tinet_in6_get_datagram
+#define in6_rtredirect		_tinet_in6_rtredirect
+#define get_ip6_hdr_size	_tinet_get_ip6_hdr_size
+#define in6_plen2pmask		_tinet_in6_plen2pmask
+#define in6_rtnewentry		_tinet_in6_rtnewentry
+#define in6_rtinit		_tinet_in6_rtinit
+#define in6_rttimer		_tinet_in6_rttimer
+#define in6_lookup_multi	_tinet_in6_lookup_multi
+#define in6_hostcache_update	_tinet_in6_hostcache_update
+#define in6_init		_tinet_in6_init
+
+/* netinet6/if6_ether.c */
+
+#define ether_map_ipv6_multicast	\
+				_tinet_ether_map_ipv6_multicast
+
+/* netinet6/ip6_input.c */
+
+#define ip6_input		_tinet_ip6_input
+#define ip6_lasthdr		_tinet_ip6_lasthdr
+#define ip6_unknown_opt		_tinet_ip6_unknown_opt
+#define ip6_init		_tinet_ip6_init
+#define ip6_nexthdr		_tinet_ip6_nexthdr
+#define ip6_remove_exthdrs	_tinet_ip6_remove_exthdrs
+#define ip6_get_prev_hdr	_tinet_ip6_get_prev_hdr
+
+/* netinet6/ip6_output.c */
+
+#define ip6_output		_tinet_ip6_output
+#define linkmtu			_tinet_linkmtu
+
+/* netinet6/dest6.c */
+
+#define dest6_input		_tinet_dest6_input
+
+/* netinet6/rout6.c */
+
+#define route6_input		_tinet_route6_input
+
+/* netinet6/frag6.c */
+
+#define frag6_input		_tinet_frag6_input
+#define frag6_timer		_tinet_frag6_timer
+#define ip6_get_frag_queue	_tinet_ip6_get_frag_queue
+
+/* netinet6/ah_input.c */
+
+#define ah6_input		_tinet_ah6_input
+
+/* netinet6/esp_input.c */
+
+#define esp6_input		_tinet_esp6_input
+
+/* netinet6/icmp6.c */
+
+#define icmp6_input		_tinet_icmp6_input
+#define icmp6_error		_tinet_icmp6_error
+#define icmp6_echo_reply	_tinet_icmp6_echo_reply
+
+/* netinet6/nd6.c */
+
+#define nd6_ifattach		_tinet_nd6_ifattach
+#define nd6_is_addr_neighbor	_tinet_nd6_is_addr_neighbor
+#define nd6_cache_lladdr	_tinet_nd6_cache_lladdr
+#define nd6_output_hold		_tinet_nd6_output_hold
+#define nd6_init		_tinet_nd6_init
+#define nd6_output		_tinet_nd6_output
+#define nd6_options		_tinet_nd6_options
+#define nd6_storelladdr		_tinet_nd6_storelladdr
+#define nd6_lookup		_tinet_nd6_lookup
+#define nd6_get_drl		_tinet_nd6_get_drl
+#define nd6_get_cache		_tinet_nd6_get_cache
+#define nd6_timer		_tinet_nd6_timer
+
+/* netinet6/nd6_nbr.c */
+
+#define nd6_dad_start		_tinet_nd6_dad_start
+#define nd6_ns_input		_tinet_nd6_ns_input
+#define nd6_na_input		_tinet_nd6_na_input
+#define nd6_ns_output		_tinet_nd6_ns_output
+#define nd6_na_output		_tinet_nd6_na_output
+
+/* netinet6/nd6_rtr.c */
+
+#define nd6_get_prl		_tinet_nd6_get_prl
+#define nd6_router_lookup	_tinet_nd6_router_lookup
+#define nd6_onlink_prefix_lookup	\
+				_tinet_nd6_onlink_prefix_lookup
+#define nd6_defrtrlist_del	_tinet_nd6_defrtrlist_del
+#define nd6_prefix_onlink	_tinet_nd6_prefix_onlink
+#define nd6_get_drl		_tinet_nd6_get_drl
+#define nd6_rtrsol_ctl		_tinet_nd6_rtrsol_ctl
+#define nd6_defrtrlist_timer	_tinet_nd6_defrtrlist_timer
+#define nd6_ra_input		_tinet_nd6_ra_input
+#define nd6_prelist_timer	_tinet_nd6_prelist_timer
+#define nd6_prefix_offlink	_tinet_nd6_prefix_offlink
+#define nd6_defrtrlist_lookup	_tinet_nd6_defrtrlist_lookup
+#define ip6_defhlim		_tinet_ip6_defhlim
+#define nd6_reachable_time	_tinet_nd6_reachable_time
+#define nd6_base_reachable_time	_tinet_nd6_base_reachable_time
+#define nd6_recalc_reachtm_interval	\
+				_tinet_nd6_recalc_reachtm_interval
+#define nd6_retrans_time	_tinet_nd6_retrans_time
+
+/* netinet6/scope6.c */
+
+#define in6_addrscope		_tinet_in6_addrscope
+
+#endif	/* of #ifndef _IN6_RENAME_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6_subr.c	(revision 317)
@@ -0,0 +1,963 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+
+#include <netinet6/nd6.h>
+#include <netinet6/ah.h>
+
+#include <net/if_var.h>
+
+/*
+ *  in6_make_ipv4mapped -- IPv4 å°å½±ã¢ãã¬ã¹ãçæããã
+ *
+ *  æ³¨æ:
+ *    src ã¯ãã¹ããã¤ããªã¼ãã¼
+ *
+ */
+
+T_IN6_ADDR *
+in6_make_ipv4mapped (T_IN6_ADDR *dst, T_IN4_ADDR src)
+{
+	dst->s6_addr32[0] = ULONG_C(0x00000000);
+	dst->s6_addr32[1] = ULONG_C(0x00000000);
+	dst->s6_addr32[2] = IPV6_ADDR_INT32_0000FFFF;
+	dst->s6_addr32[3] = htonl(src);
+
+	return dst;
+	}
+
+#ifdef _IP6_CFG
+
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in6_rtinit -- ã«ã¼ãã£ã³ã°è¡¨ãåæåããã
+ */
+
+void
+in6_rtinit (void)
+{
+	int_t ix;
+
+	for (ix = 0; ix < NUM_IN6_STATIC_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = IN_RTF_DEFINED;
+
+	for ( ; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		routing6_tbl[ix].flags = 0;
+	}
+
+/*
+ *  in6_rtnewentry -- æ°ããã¨ã³ããªãç²å¾ããã
+ */
+
+T_IN6_RTENTRY *
+in6_rtnewentry (uint8_t flags, uint32_t tmo)
+{
+	SYSTIM		now;
+	T_IN6_RTENTRY	*rt, *frt = NULL;
+	int_t		ix;
+
+	/* ç©ºãã¨ã³ããªãæ¢ãã*/
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+		rt = &routing6_tbl[ix];
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) == 0) {
+			frt = rt;
+			break;
+			}
+		}
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (frt == NULL) {
+		/* ç©ºãããªããã°ãæå¹æéããã£ã¨ãç­ãã¨ã³ããªãç©ºãã«ããã*/
+		T_IN6_RTENTRY	*srt = NULL;
+		int_t		diff, sdiff = INT_MAX;
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++) {
+			rt = &routing6_tbl[ix];
+			diff = (int_t)(rt->expire - now);
+			if (diff <= 0) {	/* rt->expire <= now */
+				/* æ¢ã«ãæå¹æéãéãã¦ããã*/
+				frt = rt;
+				break;
+				}
+			else if (diff < sdiff) {
+				srt = rt;
+				sdiff = diff;
+				}
+			}
+		if (frt == NULL)
+			frt = srt;
+		frt->flags = 0;
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+		}
+
+	frt->flags  = (uint8_t)(flags | IN_RTF_DEFINED);
+	frt->expire = now + tmo / SYSTIM_HZ;
+	return frt;
+	}
+
+/*
+ *  in6_rttimer -- ã«ã¼ãã£ã³ã°è¡¨ã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+in6_rttimer (void)
+{
+	SYSTIM	now;
+	int_t	ix;
+
+	/* expire ã®åä½ã¯ [s]ã*/
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+	for (ix = NUM_IN6_STATIC_ROUTE_ENTRY; ix < NUM_IN6_ROUTE_ENTRY; ix ++)
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    (int_t)(routing6_tbl[ix].expire - now) <= 0)
+			routing6_tbl[ix].flags = 0;
+	syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+	}
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+/*
+ *  ãã¹ãã­ã£ãã·ã¥
+ */
+
+static T_IN6_HOSTCACHE_ENTRY in6_hostcache[NUM_IN6_HOSTCACHE_ENTRY];
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+/*
+ *  in6_lookup_ifaddr -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãæ¢ç´¢ããã
+ */
+
+T_IN6_IFADDR *
+in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr)
+{
+	int_t ix;
+
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+		if ((ifp->in6_ifaddrs[ix].flags & IN6_IFF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(addr, &ifp->in6_ifaddrs[ix].addr))
+			return &ifp->in6_ifaddrs[ix];
+		}
+	return NULL;
+	}
+
+/*
+ *  in6_lookup_multi -- ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãæ¤ç´¢ããã
+ */
+
+bool_t
+in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr)
+{
+	int_t ix;
+
+	for (ix = MAX_IN6_MADDR_CNT; ix -- > 0; )
+		if (IN6_ARE_ADDR_EQUAL(maddr, &ifp->in6_maddrs[ix]))
+			return true;
+	return false;
+	}
+
+/*
+ *  in6_set_header -- IPv6 ããããè¨­å®ããã
+ */
+
+ER
+in6_set_header (T_NET_BUF *nbuf, uint_t len,
+                const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
+                uint8_t next, uint8_t hlim)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IP6_HDR	*ip6h;
+	T_IN6_IFADDR	*ia;
+
+	/*
+	 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+	 */
+	if (srcaddr == NULL || !IN6_IS_ADDR_UNSPECIFIED(srcaddr))
+		;
+	else if ((ia = in6_ifawithifp(ifp, dstaddr)) == NULL)
+		return E_SYS;
+	else
+		srcaddr = &ia->addr;
+
+	/* IPv6 ããããè¨­å®ããã*/
+	ip6h		= GET_IP6_HDR(nbuf);
+	ip6h->vcf	= htonl(IP6_MAKE_VCF(IPV6_VERSION, 0));
+	ip6h->plen	= htons(len);
+	ip6h->next	= next;
+	ip6h->hlim	= hlim;
+
+	if (dstaddr == NULL)
+		memset(&ip6h->dst, 0, sizeof(T_IN6_ADDR));
+	else
+		ip6h->dst = *dstaddr;
+
+	if (srcaddr == NULL)
+		memset(&ip6h->src, 0, sizeof(T_IN6_ADDR));
+	else
+		ip6h->src = *srcaddr;
+
+	return E_OK;
+	}
+
+/*
+ *  in6_get_datagram -- IPv6 ãã¼ã¿ã°ã©ã ãç²å¾ããããããè¨­å®ããã
+ */
+
+ER
+in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                  const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
+                  uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout)
+{
+	ER		error;
+	uint_t		align;
+
+	/* ãã¼ã¿é·ã¯ 4 ãªã¯ãããå¢çã«èª¿æ´ããã	*/
+	align = (len + 3) >> 2 << 2;
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã	*/
+	if ((error = tget_net_buf_ex(nbuf, IF_IP6_HDR_SIZE + align,
+	                                   IF_IP6_HDR_SIZE + maxlen, nbatr, tmout)) != E_OK)
+		return error;
+
+	/*
+	 *  ããå¤§ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ãç²å¾ããå ´åã®ã¿é·ããèª¿æ´ããã
+	 *  ããå°ããªãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡ã®ç²å¾ã¯ãéä¿¡ã¦ã£ã³ããããã¡ã®
+	 *  çã³ãã¼æ©è½ã§ä½¿ç¨ãããå®éã«éä¿¡ããã¾ã§ããã¼ã¿ãµã¤ãºã¯æ±ºå®ã§ããªãã
+	 */
+	if ((nbatr & NBA_SEARCH_ASCENT) != 0)
+		(*nbuf)->len = IF_IP6_HDR_SIZE + len;
+
+	/* IPv6 ããããè¨­å®ããã*/
+	if ((error = in6_set_header(*nbuf, len, dstaddr, srcaddr, next, hlim)) != E_OK)
+		return error;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset(GET_IP6_SDU(*nbuf) + len, 0, align - len);
+
+	return E_OK;
+	}
+
+/*
+ *  in6_get_maxnum_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®å¯è½ãªæå¤§ã¢ãã¬ã¹æ°ãè¿ãã
+ */
+
+uint_t
+in6_get_maxnum_ifaddr (void)
+{
+	return NUM_IN6_IFADDR_ENTRY;
+	}
+
+/*
+ *  in6_get_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®ããã¦ããã¢ãã¬ã¹ãè¿ãã
+ */
+
+const T_IN6_ADDR *
+in6_get_ifaddr (int_t index)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+
+	if (index < NUM_IN6_IFADDR_ENTRY &&
+	    (ifp->in6_ifaddrs[index].flags & IN6_IFF_DEFINED))
+		return &ifp->in6_ifaddrs[index].addr;
+	else
+		return NULL;
+	}
+
+/*
+ *  ipv62str -- IPv6 ã¢ãã¬ã¹ãæå­åã«å¤æããã
+ */
+
+char *
+ipv62str (char *buf, const T_IN6_ADDR *p_addr)
+{
+	static char	addr_sbuf[NUM_IPV6ADDR_STR_BUFF][sizeof("0123:4567:89ab:cdef:0123:4567:255.255.255.255")];
+	static int_t	bix = NUM_IPV6ADDR_STR_BUFF;
+
+	bool_t	omit = false, zero = false;
+	char	*start;
+	int_t	ix, len6;
+
+	if (buf == NULL) {
+		syscall(wai_sem(SEM_IP2STR_BUFF_LOCK));
+		buf = addr_sbuf[-- bix];
+		if (bix <= 0)
+			bix = NUM_IPV6ADDR_STR_BUFF;
+		syscall(sig_sem(SEM_IP2STR_BUFF_LOCK));
+		}
+
+	start = buf;
+	if (p_addr == NULL || IN6_IS_ADDR_UNSPECIFIED(p_addr)) {
+		*buf ++ = '0';
+		*buf ++ = ':';
+		*buf ++ = ':';
+		*buf ++ = '0';
+		}
+	else {
+		if (IN6_IS_ADDR_V4MAPPED(p_addr))
+			len6 = sizeof(T_IN6_ADDR) / 2 - 2;
+		else
+			len6 = sizeof(T_IN6_ADDR) / 2;
+		for (ix = 0; ix < len6; ix ++) {
+			if (omit) {
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
+				if (ix < 7)
+					*buf ++ = ':';
+				}
+			else if (ix > 0 && ix < 7 && p_addr->s6_addr16[ix] == 0)
+				zero = true;
+			else {
+				if (zero) {
+					omit = true;
+					*buf ++ = ':';
+					}
+				buf += convert_hexdigit(buf, ntohs(p_addr->s6_addr16[ix]), 16, 0, ' '); 
+				if (ix < 7)
+					*buf ++ = ':';
+				}
+			}
+
+		if (len6 == sizeof(T_IN6_ADDR) / 2 - 2) {
+			T_IN4_ADDR ipv4addr;
+
+			ipv4addr = ntohl(p_addr->s6_addr32[3]);
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 24) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >> 16) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr >>  8) & 0xff), 10, 0, ' ');
+			*(buf ++) = '.';
+			buf += convert_hexdigit(buf, (uint_t)((ipv4addr      ) & 0xff), 10, 0, ' ');
+			}
+		}
+	*buf = '\0';
+	return start;
+	}
+
+/*
+ *  in6_cksum -- IPv6 ã®ãã©ã³ã¹ãã¼ãå±¤ãããã®ãã§ãã¯ãµã ãè¨ç®ããã
+ *
+ *  æ³¨æ: æ»ãå¤ã¯ãããã¯ã¼ã¯ãã¤ããªã¼ã
+ */
+
+uint16_t
+in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len)
+{
+	uint32_t	sum;
+	uint_t		align;
+
+	/* 4 ãªã¯ãããå¢çã®ãã¼ã¿é· */
+	align = (len + 3) >> 2 << 2;
+
+	/* 4 ãªã¯ãããå¢çã¾ã§ããã£ã³ã°ã§åããã*/
+	if (align > len)
+		memset((uint8_t*)nbuf->buf + off + len, 0, align - len);
+
+	sum = in_cksum_sum(nbuf->buf + off, align)
+	    + in_cksum_sum(&GET_IP6_HDR(nbuf)->src, sizeof(T_IN6_ADDR) * 2)
+	    + len + proto;
+	sum = in_cksum_carry(sum);
+
+	return ~htons((uint16_t)sum);
+	}
+
+/*
+ *  get_ip6_hdr_size -- æ¡å¼µããããå«ãã IPv6 ãããé·ãè¿ãã
+ */
+
+uint_t
+get_ip6_hdr_size (T_NET_BUF *nbuf)
+{
+	T_IP6_HDR	*iph = GET_IP6_HDR(nbuf);
+	uint_t		size = IP6_HDR_SIZE, hsize;
+	uint8_t		curr = iph->next, next;
+	uint8_t		*hdr = ((uint8_t *)iph) + IP6_HDR_SIZE;
+
+	while (1) {
+		next = *hdr;
+		if (curr ==IPPROTO_NONE)		/* æ¬¡ãããç¡ã			*/
+			break;
+		else if (curr == IPPROTO_FRAGMENT)	/* æ­çå			*/
+			hsize = sizeof(T_IP6_FRAG_HDR);
+		else if (curr == IPPROTO_AH)		/* IPv6 èªè¨¼			*/
+			hsize = (((T_IP6_AH_HDR *)hdr)->len + 2) * 4;
+		else if (curr == IPPROTO_HOPOPTS ||	/* ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³	*/
+		         curr == IPPROTO_DSTOPTS ||	/* IPv6 çµç¹ãªãã·ã§ã³		*/
+		         curr == IPPROTO_ROUTING)	/* çµè·¯å¶å¾¡			*/
+			hsize = (((T_IP6_EXT_HDR *)hdr)->len + 1) * 8;
+		else
+			break;
+		size += hsize;
+		hdr  += hsize;
+		curr = next;
+		}
+	return size;
+	}
+
+/*
+ *  in6_plen2pmask -- ãã¬ãã£ãã¯ã¹é·ãããã¹ã¯ãçæããã
+ */
+
+void
+in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len)
+{
+	uint8_t	*ptr, bit;
+
+	memset(mask->s6_addr + prefix_len / 8, 0, (128 - prefix_len + 7) / 8);
+	for (ptr = mask->s6_addr; prefix_len > 0; ptr ++) {
+		for (bit = 0x80; bit && (prefix_len > 0); prefix_len --) {
+			*ptr |= bit;
+			bit >>= 1;
+			}
+		}
+	}
+
+/*
+ *  in6_rtalloc -- ã«ã¼ãã£ã³ã°è¡¨ãæ¢ç´¢ããã
+ */
+
+const T_IN6_ADDR *
+in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst)
+{
+	if (IN6_IS_ADDR_LINKLOCAL(dst) || IN6_IS_ADDR_MULTICAST(dst))
+		return dst;
+	else {
+		T_IN6_IFADDR	*ia;
+		SYSTIM		now;
+		int_t		ix;
+
+		/*
+		 *  ãµã¤ãã­ã¼ã«ã«ã¢ãã¬ã¹ãéç´å¯è½ï¼ã°ã­ã¼ãã«ï¼ã¢ãã¬ã¹ã®å ´åã¯ã
+		 *  åä¸ãªã³ã¯å
+ã®ãã¼ãã§ãããããã§ãã¯ããã
+		 */
+
+		syscall(get_tim(&now));
+		now /= SYSTIM_HZ;
+
+		/* æ¨å¥¨æå¹æéå
+ã®ã¢ãã¬ã¹ãæ¢ç´¢ããã*/
+		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+			ia = &ifp->in6_ifaddrs[ix];
+			if (IFA6_IS_READY(ia) &&
+			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
+			    (int32_t)(ia->lifetime.preferred - now) > 0) {
+		                   /* ia->lifetime.preferred > now */
+				return dst;
+				}
+			}
+
+		/* æå¹æéå
+ã®ã¢ãã¬ã¹ãæ¢ç´¢ããã*/
+		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+			ia = &ifp->in6_ifaddrs[ix];
+			if (IFA6_IS_READY(ia) &&
+			    in6_are_prefix_equal(dst, &ia->addr, ia->prefix_len) &&
+			    (int32_t)(ia->lifetime.expire - now) > 0)
+		                   /* ia->lifetime.expire > now */
+				return dst;
+			}
+
+		/*
+		 *  ãã¬ãã£ãã¯ã¹ãæ¢ç´¢ããã
+		 */
+		if (nd6_onlink_prefix_lookup (dst) != NULL)
+			return dst;
+
+		/*
+		 *  éççµè·¯è¡¨ãæ¢ç´¢ããã
+		 */
+
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+		syscall(wai_sem(SEM_IN6_ROUTING_TBL));
+		for (ix = NUM_IN6_ROUTE_ENTRY; ix --; ) {
+			if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+			    in6_are_prefix_equal(dst, &routing6_tbl[ix].target,
+			                               routing6_tbl[ix].prefix_len)) {
+
+				/*
+				 *  åãç´ãã«ããã¨ã³ããªã¯ãæå¹æéãåããæå»ãå»¶é·ããã
+				 *  expire ã®åä½ã¯ [s]ã
+				 *  TMO_IN_REDIRECT ã®åä½ã¯ [ms]ã
+				 */
+				if (ix > NUM_IN6_STATIC_ROUTE_ENTRY) {
+					SYSTIM	now;
+
+					syscall(get_tim(&now));
+					routing6_tbl[ix].expire = now / SYSTIM_HZ + TMO_IN_REDIRECT / 1000;
+					}
+
+				syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+				return &routing6_tbl[ix].gateway;
+				}
+			}
+		syscall(sig_sem(SEM_IN6_ROUTING_TBL));
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
+
+		/*
+		 *  ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ããæ¢ç´¢ããã
+		 */
+		return nd6_router_lookup();
+		}
+	}
+
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+/*
+ *  in6_gateway_lookup -- ã«ã¼ãã£ã³ã°è¡¨ã®ã«ã¼ã¿ãæ¢ç´¢ããã
+ */
+
+T_IN6_RTENTRY *
+in6_gateway_lookup (const T_IN6_ADDR *gw)
+{
+	int_t	ix;
+
+	for (ix = NUM_IN6_ROUTE_ENTRY; ix --; )
+		if ((routing6_tbl[ix].flags & IN_RTF_DEFINED) &&
+		    IN6_ARE_ADDR_EQUAL(&routing6_tbl[ix].gateway, gw))
+			return &routing6_tbl[ix];
+	return NULL;
+	}
+
+/*
+ *  in6_rtredirect -- ã«ã¼ãã£ã³ã°è¡¨ã«ã¨ã³ããªãç»é²ããã
+ *
+ *    æ³¨æ: å¼æ° tmo ã®åä½ã¯ [ms]ã
+ */
+
+void
+in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target, uint_t prefix_len, uint8_t flags, uint32_t tmo)
+{
+	T_IN6_RTENTRY	*frt;
+
+	frt = in6_rtnewentry(flags, tmo);
+	frt->gateway    = *gateway;
+	frt->target     = *target;
+	frt->prefix_len = prefix_len;
+	}
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+/*
+ *  in6_hostcache_lookup -- IPv6 ãã¹ãã­ã£ãã·ã¥ãæ¢ç´¢ããã
+ */
+
+static T_IN6_HOSTCACHE_ENTRY*
+in6_hostcache_lookup (const T_IN6_ADDR *dst)
+{
+	int_t ix;
+
+	for (ix = NUM_IN6_HOSTCACHE_ENTRY; ix -- > 0; ) {
+		if (IN6_ARE_ADDR_EQUAL(dst, &in6_hostcache[ix].dst))
+			return &in6_hostcache[ix];
+		}
+	return NULL;
+	}
+
+/*
+ *  in6_hostcache_update -- IPv6 ãã¹ãã­ã£ãã·ã¥ãæ´æ°ããã
+ */
+
+void
+in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu)
+{
+	T_IN6_HOSTCACHE_ENTRY	*hc;
+	SYSTIM	now, old;
+	int_t	ix, oix;
+
+	syscall(get_tim(&now));
+
+	/* æ¢ã«ç»é²ããã¦ãããæ¢ç´¢ããã*/
+	if ((hc = in6_hostcache_lookup (dst)) == NULL) {
+
+		/* ç©ºãã®ãã¹ãã­ã£ãã·ã¥ãæ¢ãã*/
+		for (ix = NUM_IN6_HOSTCACHE_ENTRY; ix -- > 0; ) {
+			if (IN6_IS_HOSTCACHE_FREE(&in6_hostcache[ix]))
+				break;
+			}
+
+		if (ix < 0) {
+			/*
+			 *  ç©ºããç¡ãæã¯ãæå¹æéã®åããæéãã
+			 *  æãç­ããã¹ãã­ã£ãã·ã¥ãç½®æããã
+			 */
+			old = now - 1;
+			oix = 0;
+			for (ix = NUM_IN6_HOSTCACHE_ENTRY; ix -- > 0; ) {
+				hc = &in6_hostcache[ix];
+				if (IN6_IS_HOSTCACHE_BUSY(hc) && (int32_t)(hc->expire - old) < 0) {
+				                                        /* hc->expire < old */
+					oix = ix;
+					old = hc->expire;
+					}
+				}
+			ix = oix;
+			}
+		hc = &in6_hostcache[ix];
+		}
+	else if (mtu > hc->mtu &&
+	         (int32_t)(hc->expire - now) >= (IN6_HOSTCACHE_EXPIRE - IN6_HOSTCACHE_INCREASE)) {
+
+		/*
+		 *  æ¢ã«ç»é²ããã¦ãã¦ãæ°ãã MTU ããç»é²ããã¦ãã MTU ããå¤§ããã¨ãã
+		 *  IN6_HOSTCACHE_INCREASEï¼æ¨å¥¨ 10 åï¼éã¯æ´æ°ããªãã
+		 */
+		return;
+		}
+	hc->dst    = *dst;
+	hc->expire = now + IN6_HOSTCACHE_EXPIRE;
+	hc->mtu    = mtu;
+	}
+
+/*
+ *  in6_hostcache_getmtu -- IPv6 ãã¹ãã­ã£ãã·ã¥ããã MTU ãåå¾ããã
+ *
+ *    æ»ãå¤ã 0 ã§ããã°ããã¹ãã­ã£ãã·ã¥ã«ç»é²ããã¦ããªãã
+ */
+
+uint32_t
+in6_hostcache_getmtu (const T_IN6_ADDR *dst)
+{
+	T_IN6_HOSTCACHE_ENTRY	*hc;
+
+	/* æ¢ã«ç»é²ããã¦ãããæ¢ç´¢ããã*/
+	if ((hc = in6_hostcache_lookup(dst)) == NULL)
+		return 0;
+	else
+		return hc->mtu;
+	}
+
+/*
+ *  in6_hostcache_timer -- IPv6 ãã¹ãã­ã£ãã·ã¥æ´æ°ã¿ã¤ãã¼
+ *
+ *    1ç§å¨æã§èµ·åãããã
+ */
+
+static void
+in6_hostcache_timer (void)
+{
+	static int_t interval = IN6_HOSTCACHE_PRUNE / SYSTIM_HZ;
+
+	SYSTIM	now;
+
+	interval --;
+	if (interval <= 0) {
+		syscall(get_tim(&now));
+		interval = IN6_HOSTCACHE_PRUNE / SYSTIM_HZ;
+		}
+	}
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+/*
+ *  in6_timer -- IPv6 å
+±éã¿ã¤ãã¼
+ *
+ *    1ç§å¨æã§èµ·åãããã
+ */
+
+static void
+in6_timer (void)
+{
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rttimer();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+
+#ifdef IP6_CFG_FRAGMENT
+
+	frag6_timer();
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+	in6_hostcache_timer();
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+	timeout((callout_func)in6_timer, NULL, IN_TIMER_TMO);
+	}
+
+/*
+ *  in6_init -- IPv6 å
+±éæ©è½ãåæåããã
+ */
+
+void
+in6_init (void)
+{
+#if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0
+
+	in6_rtinit();
+
+#endif	/* of #if NUM_IN6_REDIRECT_ROUTE_ENTRY > 0 */
+
+	timeout((callout_func)nd6_timer, NULL, ND6_TIMER_TMO);
+	timeout((callout_func)in6_timer, NULL, IN_TIMER_TMO);
+	}
+
+/*
+ *  in6_is_dstaddr_accept -- å®å
+ã¢ãã¬ã¹ã¨ãã¦æ­£ããããã§ãã¯ããã
+ */
+
+bool_t
+in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr)
+{
+	if (IN6_IS_ADDR_UNSPECIFIED(myaddr))
+		return in6_lookup_ifaddr(IF_GET_IFNET(), dstaddr) != NULL;
+	else
+		return IN6_ARE_ADDR_EQUAL(dstaddr, myaddr);
+	}
+
+#if defined(DHCP6_CLI_CFG)
+
+/*
+ *  in6_add_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã« IPv6 ã¢ãã¬ã¹ãè¨­å®ããã
+ *
+ *    vltime ã¨ pltime ã®åä½ã¯[s]
+ */
+
+static ER
+in6_add_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia = NULL;
+	int_t		ix;
+
+	/* ç©ºãã®ã¨ã³ããªã¼ãæ¢ãã*/
+	ix = 0;
+	while (true) {
+		ia = in6ifa_ifpwithix(ifp, ix ++);
+
+		/* ç©ºããç¡ããã°ã¨ã©ã¼ */
+		if (ia == NULL)
+			return E_OBJ;
+
+		if ((ia->flags & IN6_IFF_DEFINED) == 0)
+			break;
+		}
+
+	/* ç»é²ããã*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_upd_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®ããã¦ãã IPv6 ã¢ãã¬ã¹ãæ´æ°ããã
+ *
+ *    ç»é²ããã¦ããªããã°ãè¿½å ããã
+ *    vltime ã¨ pltime ã®åä½ã¯[s]
+ */
+
+ER
+in6_upd_ifaddr (T_IN6_ADDR *addr, uint_t prefix_len,
+                uint32_t vltime, uint32_t pltime)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	int_t		ix;
+
+	/*
+	 *  ã¢ãã¬ã¹ãä¸è´ããã¨ã³ããªã¼ãæ¢ãã
+	 *  ç¡ããã°ç»é²ããã
+	 */
+	if ((ix = in6_addr2ifaix(addr)) == IPV6_IFADDR_IX_INVALID)
+		return in6_add_ifaddr(addr, prefix_len, vltime, pltime);
+
+	/*
+	 *  ã¤ã³ããã¯ã¹çªå·ãããã¨ã³ããªã¼ã«å¤æããã
+	 *  ã¨ã©ã¼ã«ãªããªãã¯ãã§ããããç¢ºèªããã
+	 */
+	if ((ia = in6ifa_ifpwithix (ifp, ix)) == NULL)
+		return E_OBJ;
+
+	/* æ´æ°ããã*/
+	return in6_update_ifa(ifp, ia, addr, prefix_len, vltime, pltime,
+	                      IN6_RTR_IX_UNREACH, ND6_PREFIX_IX_INVALID, 0);
+	}
+
+/*
+ *  in6_del_ifaddr -- ã¤ã³ã¿ãã§ã¼ã¹ã«è¨­å®ããã¦ãã IPv6 ã¢ãã¬ã¹ãåé¤ããã
+ */
+
+ER
+in6_del_ifaddr (T_IN6_ADDR *addr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	int_t		ix;
+
+	/* ã¢ãã¬ã¹ãä¸è´ããã¨ã³ããªã¼ãæ¢ãã*/
+	if ((ix = in6_addr2ifaix(addr)) != IPV6_IFADDR_IX_INVALID) {
+
+		/* ã¨ã³ããªã¼ãç¡å¹ã«ããã*/
+		ifp->in6_ifaddrs[ix].flags &= ~IN6_IFF_DEFINED;
+		return E_OK;
+		}
+	return E_PAR;
+	}
+
+#endif	/* of #if defined(DHCP6_CLI_CFG) */
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/in6_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/in6_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/in6_var.h	(revision 317)
@@ -0,0 +1,390 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6_var.h,v 1.3.2.2 2001/07/03 11:01:52 ume Exp $	*/
+/*	$KAME: in6_var.h,v 1.56 2001/03/29 05:34:31 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1985, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in_var.h	8.1 (Berkeley) 6/10/93
+ */
+
+#ifndef _IN6_VAR_H_
+#define _IN6_VAR_H_
+
+/*
+ *  ã¢ãã¬ã¹ã®å®ç¾©
+ */
+
+#ifdef _NET_CFG_BYTE_ORDER
+
+#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x00000001)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x00000002)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0x0000ffff)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0xff010000)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0xff020000)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0xfe800000)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0xfe80)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xfec0)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0xff02)
+
+#elif _NET_CFG_BYTE_ORDER == _NET_CFG_LITTLE_ENDIAN
+
+#define IPV6_ADDR_INT32_ONE		ULONG_C(0x01000000)
+#define IPV6_ADDR_INT32_TWO		ULONG_C(0x02000000)
+#define IPV6_ADDR_INT32_0000FFFF	ULONG_C(0xffff0000)
+#define IPV6_ADDR_INT32_MNL		ULONG_C(0x000001ff)
+#define IPV6_ADDR_INT32_MLL		ULONG_C(0x000002ff)
+#define IPV6_ADDR_INT32_ULL		ULONG_C(0x000080fe)
+#define IPV6_ADDR_INT16_ULL		UINT_C(0x80fe)
+#define IPV6_ADDR_INT16_USL		UINT_C(0xc0fe)
+#define IPV6_ADDR_INT16_MLL		UINT_C(0x02ff)
+
+#endif	/* #if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN */
+
+#endif	/* of #ifdef _NET_CFG_BYTE_ORDER */
+
+/*
+ *  ç¹å¥ãªã¢ãã¬ã¹ã®ãã§ãã¯
+ */
+
+/* IPv4 äºæ */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4COMPAT(a)		\
+	(memcmp((void *)(a), (void *)&in6_addr_unspecified, sizeof(T_IN6_ADDR) - 4) == 0 && \
+	 (a)->s6_addr32[3] > IPV6_ADDR_INT32_ONE)
+#endif
+
+/* IPv4 å°å½± */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_V4MAPPED(a)		\
+	(((a)->s6_addr32[0] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_0000FFFF))
+#endif
+
+/* è¦è«ãã«ãã­ã£ã¹ã */
+
+#ifdef _NET_CFG_BYTE_ORDER
+#define IN6_IS_ADDR_NS_MULTICAST(a)	\
+	(((a)->s6_addr32[0] == IPV6_ADDR_INT32_MLL) && \
+	 ((a)->s6_addr32[1] == ULONG_C(0x00000000)) && \
+	 ((a)->s6_addr32[2] == IPV6_ADDR_INT32_ONE) && \
+	 ((a)->s6_addr8[12] == UINT_C(0xff)))
+#endif
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ã¢ãã¬ã¹æå¹æéæ§é ä½
+ */
+
+typedef struct in6_addr_lifetime {
+
+	/*
+	 * expire ã¨ perferred ã¯ãã·ã¹ãã ãèµ·åãã¦ããã®çµéæé
+	 */
+	uint32_t	expire;		/* æå¹æéãåããæå» [s]	*/
+	uint32_t	preferred;	/* æ¨å¥¨æå¹æéãåããæå» [s]	*/
+
+	/*
+	 * vltime ã¨ pltime ã¯ãè¿½å /å¤æ´ãã¦ããã®ç¸å¯¾æé
+	 */
+	uint32_t	vltime;		/* æå¹æé [ms]			*/
+	uint32_t	pltime;		/* æ¨å¥¨æå¹æé [ms]		*/
+	} T_IN6_ADDR_LIFETIME;
+
+/*
+ *  ã¤ã³ã¿ãã§ã¼ã¹ã¢ãã¬ã¹æ§é ä½
+ */
+
+typedef struct t_in6_ifaddr {
+	T_IN6_ADDR		addr;		/* IPv6 ã¢ãã¬ã¹		*/
+	T_IN6_ADDR_LIFETIME	lifetime;	/* æå¹æé		*/
+	uint8_t			flags;		/* ãã©ã°		*/
+	uint8_t			prefix_len;	/* ãã¬ãã£ãã¯ã¹é·	*/
+	uint8_t			router_index;	/* ã«ã¼ã¿ã¤ã³ããã¯ã¹	*/
+	uint8_t			prefix_index;	/* ãã¬ãã£ãã¯ã¹ã¤ã³ããã¯ã¹	*/
+	uint8_t			na_icount;	/* éè¤ã¢ãã¬ã¹æ¤åº (DAD) éç¥ã®å
+¥ååæ°	*/
+	uint8_t			ns_icount;	/* éè¤ã¢ãã¬ã¹æ¤åº (DAD) è¦è«ã®å
+¥ååæ°	*/
+	uint8_t			ns_ocount;	/* éè¤ã¢ãã¬ã¹æ¤åº (DAD) è¦è«ã®åºååæ°	*/
+	} T_IN6_IFADDR;
+
+/*
+ *  ã¢ãã¬ã¹ç¶æ
+ãã©ã°
+ */
+
+#define IN6_IFF_ANYCAST		UINT_C(0x01)	/* ã¨ãã¼ã­ã£ã¹ã	*/
+#define IN6_IFF_DEFINED		UINT_C(0x02)	/* å®ç¾©æ¸ã¿		*/
+#define IN6_IFF_TENTATIVE	UINT_C(0x04)	/* éè¤æ¤åºä¸­		*/
+#define IN6_IFF_DUPLICATED	UINT_C(0x08)	/* éè¤ãæ¤åºãã	*/
+#define IN6_IFF_DEPRECATED	UINT_C(0x10)	/* éæ¨å¥¨		*/
+#define IN6_IFF_NODAD		UINT_C(0x20)	/* éè¤æ¤åºä¸è¦		*/
+#define IN6_IFF_AUTOCONF	UINT_C(0x40)	/* èªåè¨­å®ããã	*/
+#define IN6_IFF_DETACHED	UINT_C(0x80)	/* éä½¿ç¨		*/
+
+/*
+ *  ã¢ãã¬ã¹ã®æå¹æ§ãã§ãã¯
+ */
+
+#define IFA6_IS_READY(a)	(((a)->flags & IN6_IFF_DEFINED) != 0 && \
+				 ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) == 0)
+#define IFA6_IS_NOTREADY(a)	(((a)->flags & IN6_IFF_DEFINED) == 0 ||	\
+				 ((a)->flags & (IN6_IFF_TENTATIVE|IN6_IFF_DUPLICATED|IN6_IFF_DETACHED)) != 0)
+
+#define IFA6_IS_DEPRECATED(a,n)	\
+	((a)->lifetime.preferred != 0 && (int32_t)((a)->lifetime.preferred - ((n / SYSTIM_HZ))) < 0)
+
+#define IFA6_IS_INVALID(a,n)	\
+	((a)->lifetime.expire != 0 && (int32_t)((a)->lifetime.expire - ((n / SYSTIM_HZ))) < 0)
+
+/*
+ *  ã«ã¼ã¿ã®ã¤ã³ããã¯ã¹
+ */
+
+#define IN6_RTR_IX_UNREACH	0xff
+
+/*
+ *  å¶éå¤
+ */
+
+#define IP6_HDR_NEST_LIMIT	50	/* IPv6 ãããã®ãã¹ãå¶éå¤	*/
+
+/*
+ *  ã¢ãã¬ã¹æ
+å ±é
+åã®ã¤ã³ããã¯ã¹
+ */
+
+#define IPV6_IFADDR_IX_LINKLOCAL	0
+#define IPV6_IFADDR_IX_INVALID		0xff
+
+/*
+ *  IPv6 ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®ã¤ã³ããã¯ã¹
+ */
+
+#define IPV6_MADDR_IX_SOL_NODE		0	/* è¦è«ãã«ãã­ã£ã¹ãã»ã¢ãã¬ã¹			*/
+#define IPV6_MADDR_IX_LL_ALL_NODE	1	/* å
+¨ãã¼ãã»ãªã³ã¯ã­ã¼ã«ã«ã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹	*/
+#define IPV6_MADDR_IX_EXTRA		2
+
+#define MAX_IN6_MADDR_CNT		MAX_IF_MADDR_CNT
+						/* IPv6 ãã«ãã­ã£ã¹ãã¢ãã¬ã¹é
+åã®æå¤§ãµã¤ãº	*/
+
+/* ã«ã¼ãã£ã³ã°è¡¨ã¨ã³ããªæ§é ä½ */
+
+typedef struct t_in6_rtentry {
+	T_IN6_ADDR	target;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹	*/
+	T_IN6_ADDR	gateway;	/* ã²ã¼ãã¦ã§ã¤ã® IP ã¢ãã¬ã¹	*/
+	uint32_t	expire;		/* æå¹æéãåããæå» [s]	*/
+	uint8_t		flags;		/* ãã©ã°			*/
+	uint8_t		prefix_len;	/* ãã¬ãã£ãã¯ã¹é·		*/
+	} T_IN6_RTENTRY;
+
+/*
+ *  ãã¹ãã­ã£ãã·ã¥
+ */
+
+/* ãã¹ãã­ã£ãã·ã¥æ§é ä½ */
+
+typedef struct t_in6_hostcache_entry {
+	T_IN6_ADDR	dst;		/* ç®æ¨ãããã¯ã¼ã¯ã¢ãã¬ã¹	*/
+	uint32_t	expire;		/* æå¹æéãåããæå» [s]	*/
+	uint32_t	mtu;		/* Path MTU			*/
+	} T_IN6_HOSTCACHE_ENTRY;
+
+#define IN6_HOSTCACHE_EXPIRE	(60*60*SYSTIM_HZ)	/* æå¹æé	*/
+#define IN6_HOSTCACHE_PRUNE	(5*60*SYSTIM_HZ)	/* æ´æ°éé	*/
+#define IN6_HOSTCACHE_INCREASE	(10*60*SYSTIM_HZ)	/* å¢å ããå ´åã®ä¿è­·æé	*/
+
+#define IN6_IS_HOSTCACHE_FREE(e)	IN6_IS_ADDR_UNSPECIFIED(&((e)->dst))
+#define IN6_IS_HOSTCACHE_BUSY(e)	(!IN6_IS_HOSTCACHE_FREE(e))
+
+/*
+ *  ã«ã¼ãã£ã³ã°è¡¨
+ */
+
+extern T_IN6_RTENTRY routing6_tbl[];
+
+/*
+ *  åæ¹åç
+§
+ */
+
+#ifndef T_IFNET_DEFINED
+
+typedef struct t_ifnet T_IFNET;
+
+#define T_IFNET_DEFINED
+
+#endif	/* of #ifndef T_IFNET_DEFINED */
+
+/*
+ *  å¤æ°
+ */
+
+extern uint32_t linkmtu;
+
+/*
+ *  é¢æ°ã·ãã¥ã¬ã¼ã·ã§ã³ãã¯ã­
+ */
+
+#define IN6_COPY_TO_HOST(dst,nbuf)	memcpy(dst,&GET_IP6_HDR(nbuf)->src,sizeof(T_IN6_ADDR))
+#define INN6_IS_DSTADDR_ACCEPT(addr,nbuf)	\
+					in6_is_dstaddr_accept(addr,&GET_IP6_HDR(nbuf)->dst)
+
+/*
+ *  é¢æ°
+ */
+
+extern void in6_ifainit (void);
+extern int_t in6_addr2maix (const T_IN6_ADDR *addr);
+extern ER in6_update_ifa (T_IFNET *ifp, T_IN6_IFADDR *ia, const T_IN6_ADDR *addr,
+                          uint_t prefix_len, uint32_t vltime, uint32_t pltime,
+                          int_t router_index, int_t prefix_index, uint_t flags);
+extern ER in6_set_header (T_NET_BUF *nbuf, uint_t len,
+                          const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
+                          uint8_t next, uint8_t hlim);
+extern ER in6_get_datagram (T_NET_BUF **nbuf, uint_t len, uint_t maxlen,
+                            const T_IN6_ADDR *dstaddr, const T_IN6_ADDR *srcaddr,
+                            uint8_t next, uint8_t hlim, ATR nbatr, TMO tmout);
+extern uint16_t in6_cksum (T_NET_BUF *nbuf, uint8_t proto, uint_t off, uint_t len);
+extern T_IN6_IFADDR *in6ifa_ifpwithix (T_IFNET *ifp, int_t ix);
+extern T_IN6_IFADDR *in6ifa_ifpwithrtrix (T_IFNET *ifp, int_t rtr_ix);
+extern T_IN6_IFADDR *in6_ifawithifp (T_IFNET *ifp, const T_IN6_ADDR *dst);
+extern const T_IN6_ADDR *in6_addrwithifp (T_IFNET *ifp, T_IN6_ADDR *src, const T_IN6_ADDR *dst);
+extern void ip6_input (T_NET_BUF *input);
+extern T_IN6_IFADDR *in6_lookup_ifaddr (T_IFNET *ifp, const T_IN6_ADDR *addr);
+extern bool_t in6_lookup_multi (T_IFNET *ifp, const T_IN6_ADDR *maddr);
+extern bool_t in6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, const T_IN6_ADDR *dstaddr);
+extern bool_t inn6_is_dstaddr_accept (const T_IN6_ADDR *myaddr, T_NET_BUF *input);
+extern const T_IN6_ADDR *in6_rtalloc (T_IFNET *ifp, const T_IN6_ADDR *dst);
+extern int_t in6_if2idlen (T_IFNET *ifp);
+extern int_t in6_addr2ifaix (const T_IN6_ADDR *addr);
+extern void in6_plen2pmask (T_IN6_ADDR *mask, uint_t prefix_len);
+extern bool_t in6_are_prefix_equal (const T_IN6_ADDR *addr, const T_IN6_ADDR *prefix,
+                                  uint_t prefix_len);
+extern void in6_ifaddr_timer (T_IFNET *ifp);
+extern T_IN6_RTENTRY *in6_gateway_lookup (const T_IN6_ADDR *src);
+extern void in6_rtredirect (const T_IN6_ADDR *gateway, const T_IN6_ADDR *target,
+                            uint_t prefix_len, uint8_t flags, uint32_t tmo);
+extern void in6_init (void);
+extern void in6_if_up (T_IFNET *ifp);
+extern void in6_hostcache_update (T_IN6_ADDR *dst, uint32_t mtu);
+extern uint32_t in6_hostcache_getmtu (const T_IN6_ADDR *dst);
+extern uint_t in6_addrscope (const T_IN6_ADDR *addr);
+extern const T_NET_BUF**ip6_get_frag_queue (void);
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+#endif	/* of #ifndef _IN6_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ip6.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ip6.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ip6.cfg	(revision 317)
@@ -0,0 +1,80 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  IPv6 ã§ä½¿ç¨ããã«ã¼ãã«ãªãã¸ã§ã¯ã
+ */
+
+#ifdef _IP6_CFG
+
+/* è¿é£ã­ã£ãã·ã¥ */
+
+CRE_SEM(SEM_ND6_CACHE, { TA_TPRI, 1, 1 });
+
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+/* ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ã */
+
+CRE_SEM(SEM_ND6_DEFRTRLIST, { TA_TPRI, 1, 1 });
+
+#endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+#ifdef IP6_CFG_FRAGMENT
+
+/* åå²ããã */
+
+CRE_SEM(SEM_IP6_FRAG_QUEUE, { TA_TPRI, 1, 1 });
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+#if NUM_IN6_ROUTE_ENTRY > 0
+
+/* ã«ã¼ãã£ã³ã°è¡¨ */
+
+CRE_SEM(SEM_IN6_ROUTING_TBL, { TA_TPRI, 1, 1 });
+
+#endif	/* of #if NUM_IN6_ROUTE_ENTRY > 0 */
+
+#endif	/* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ip6_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ip6_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ip6_input.c	(revision 317)
@@ -0,0 +1,686 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ip6_input.c,v 1.11.2.10 2001/07/24 19:10:18 brooks Exp $	*/
+/*	$KAME: ip6_input.c,v 1.194 2001/05/27 13:28:35 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_input.c	8.2 (Berkeley) 1/4/94
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "tinet_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "tinet_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+#include <netinet6/nd6.h>
+#include <netinet6/ah6.h>
+#include <netinet6/esp6.h>
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  é¢æ°
+ */
+
+static uint_t ip6_no_header_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+
+/*
+ *  ä¸ä½ãã­ãã³ã«é¸ææ§é ä½
+ */
+
+typedef struct t_proto_switch {
+	uint_t (*func)(T_NET_BUF **, uint_t *, uint_t *);	/* å
+¥åé¢æ°		*/
+	uint_t proto;						/* ãã­ãã³ã«çªå·	*/
+	} T_PROTO_SWITCH;
+
+static const T_PROTO_SWITCH proto_switch[] = {
+	{ esp6_input,	IPPROTO_ESP		},	/* IPv6 æå·åããã	*/
+	{ ah6_input,	IPPROTO_AH		},	/* IPv6 èªè¨¼ããã	*/
+	{ frag6_input,	IPPROTO_FRAGMENT	},	/* æ­çããã		*/
+	{ route6_input,	IPPROTO_ROUTING		},	/* çµè·¯å¶å¾¡ããã	*/
+	{ dest6_input,	IPPROTO_DSTOPTS		},	/* IPv6 çµç¹ãªãã·ã§ã³	*/
+	{ ip6_no_header_input,
+			IPPROTO_NONE		},	/* æ¬¡ãããç¡ã		*/
+	{ icmp6_input,	IPPROTO_ICMPV6		},
+
+#if defined(SUPPORT_TCP)
+
+	{ tcp_input,	IPPROTO_TCP		},
+
+#endif	/* of #if defined(SUPPORT_TCP) */
+
+#if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0
+
+	{ udp6_input,	IPPROTO_UDP		},
+
+#endif	/* of #if defined(SUPPORT_UDP) && TNUM_UDP6_CEPID > 0 */
+
+	};
+
+#ifdef SUPPORT_MIB
+
+T_IN6_IFSTAT in6_ifstat;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  get_upper_proto -- ä¸ä½ãã­ãã³ã«å¦çé¢æ°ãè¿ãã
+ */
+
+static uint_t (*
+get_upper_proto(uint_t proto))(T_NET_BUF **, uint_t *, uint_t *)
+{
+	int_t ix;
+
+	for (ix = sizeof(proto_switch) / sizeof(T_PROTO_SWITCH); ix -- > 0; )
+		if (proto_switch[ix].proto == proto)
+			return proto_switch[ix].func;
+	return NULL;
+	}
+
+/*
+ *  ip6_no_header_input -- æ¬¡ããããç¡ãã®å ´åã®å
+¥åå¦ç
+ */
+
+static uint_t
+ip6_no_header_input (T_NET_BUF **input, uint_t *offp, uint_t *nextp)
+{
+	syscall(rel_net_buf(*input));
+	return IPPROTO_DONE;
+	}
+
+/*
+ *  ip6_hopopts_input -- ä¸­ç¶ç¹ãªãã·ã§ã³å
+¥åå¦ç
+ *
+ *    æ¬å®è£
+ã§ã¯ãããã£ã³ã°ä»¥å¤ã®ãªãã·ã§ã³ãå
+¨ã¦æªç¥ãªãã·ã§ã³ã¨ãã¦å¦çããã
+ *
+ *    æ»ãå¤:
+ *
+ *      0 ä»¥ä¸ 		æ­£å¸¸
+ *      IP6_OPT_RET_ERR (-1)	ã¨ã©ã¼ãå¼åºå´ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããã
+ *      IP6_OPT_RET_REL (-2)	ã¨ã©ã¼ããããã¯ã¼ã¯ãããã¡ã¯éæ¾ããã¦ããã
+ */
+
+static ER_UINT
+ip6_hopopts_input (T_NET_BUF *input, uint_t *offp, uint_t *nextp)
+{
+	T_IP6_HBH_HDR	*hbh;
+	ER_UINT		optlen;
+	uint_t		len;
+	uint8_t		*opt;
+
+	hbh    = (T_IP6_HBH_HDR *)(input->buf + *offp);
+	len    = (hbh->len + 1) << 3;
+	*nextp = *offp - IF_HDR_SIZE + offsetof(T_IP6_HBH_HDR, next);
+	*offp += len;
+	opt    = (uint8_t *)hbh + sizeof(T_IP6_HBH_HDR);
+
+	for (len -= sizeof(T_IP6_HBH_HDR); len > 0; len -= optlen) {
+		switch (*opt) {
+		case IP6OPT_PAD1:
+			optlen = 1;
+			break;
+		case IP6OPT_PADN:
+			if (len < IP6OPT_MINLEN)
+				return IP6_OPT_RET_ERR;
+			optlen = *(opt + 1) + 2;
+			break;
+		case IP6OPT_JUMBO:
+		case IP6OPT_NSAP_ADDR:
+		case IP6OPT_TUNNEL_LIMIT:
+		case IP6OPT_RTR_ALERT:
+		default:
+			if (len < IP6OPT_MINLEN)
+				return IP6_OPT_RET_ERR;
+			optlen = ip6_unknown_opt(input, opt);
+			if (optlen < 0)
+				return optlen;
+			optlen += 2;
+			break;
+			}
+
+		opt += optlen;
+		}
+
+	return *offp;
+	}
+
+/*
+ *  ip6_get_prev_hdr -- ç´åã®æ¡å¼µãããã® next ãã£ã¼ã«ãã®ã¢ãã¬ã¹ãè¿ãã
+ *
+ *    æ³¨æ: off ã«ã¯ IF_HDR_SIZE ãå«ã¾ãã¦ããã
+ */
+
+uint8_t *
+ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off)
+{
+	T_IP6_HDR	*ip6h;
+	T_IP6_EXT_HDR	*ip6eh;
+	uint_t		len;
+	uint8_t		next;
+
+	ip6h = GET_IP6_HDR(nbuf);
+	if (off == IF_HDR_SIZE + sizeof(T_IP6_HDR))
+		return &ip6h->next;
+	else {
+		next  = ip6h->next;
+		len   = IF_HDR_SIZE + sizeof(T_IP6_HDR);
+		ip6eh = NULL;
+
+		while (len < off) {
+			ip6eh = (T_IP6_EXT_HDR *)(nbuf->buf + len);
+
+			switch (next) {
+			case IPPROTO_FRAGMENT:
+				len += sizeof(T_IP6_FRAG_HDR);
+				break;
+			case IPPROTO_AH:
+				len += (ip6eh->len + 2) << 2;
+				break;
+			default:
+				len += (ip6eh->len + 2) << 3;
+				break;
+				}
+			next  = ip6eh->next;
+			}
+
+		if (ip6eh == NULL)
+			return NULL;
+		else
+			return &ip6eh->next;
+		}
+	}
+
+/*
+ *  ip6_init -- IPv6 ã®åæåé¢æ°
+ */
+
+void
+ip6_init (void)
+{
+	in6_init();
+	in6_ifainit();
+	}
+
+/*
+ *  ip6_input -- IPv6 ã®å
+¥åé¢æ°
+ */
+
+void
+ip6_input (T_NET_BUF *input)
+{
+	T_IP6_HDR	*ip6h;
+	T_IN6_IFADDR	*ia6;
+	T_IFNET		*ifp;
+	ER_UINT		noff;
+	uint_t		next, nest, plen, offp, nextp;
+	uint_t		(*func)(T_NET_BUF **, uint_t *, uint_t *);
+
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_OCTETS], input->len - IF_HDR_SIZE);
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_PACKETS], 1);
+	NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInReceives, 1);
+
+	/* IP ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < IF_IP6_HDR_SIZE) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_SHORT], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	ip6h = GET_IP6_HDR(input);
+
+	/* ãã¼ã¸ã§ã³ããã§ãã¯ããã*/
+	if (IP6_VCF_V(ntohl(ip6h->vcf)) != IPV6_VERSION) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_VER], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInHdrErrors, 1);
+		goto buf_rel;
+		}
+
+	/*
+	 *  æ¬¡ã®ãã¼ã¿ã°ã©ã ã¯ç ´æ£ããã
+	 *
+	 *    ã»å§ç¹ã¢ãã¬ã¹ããã«ãã­ã£ã¹ã
+	 *    ã»çµç¹ã¢ãã¬ã¹ãæªå®ç¾©
+	 *
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ãã«ã¼ãããã¯ã§ãªãã¨ãã
+	 *  æ¬¡ã®ãã¼ã¿ã°ã©ã ãç ´æ£ããã
+	 *
+	 *    ã»å§ç¹ã¢ãã¬ã¹ãã«ã¼ãããã¯
+	 *    ã»çµç¹ã¢ãã¬ã¹ãã«ã¼ãããã¯
+	 *
+	 *  æªæã®ããã¦ã¼ã¶ã TCP/UDP ã¹ã¿ãã¯ã®æ··ä¹±ã
+	 *  ã»ã­ã¥ãªãã£ãã§ãã¯ããã¤ãã¹ãããããIPv4
+	 *  ãããã¢ãã¬ã¹ãæªç¨ãããã¨ãé²ããã
+	 *  ä»¥ä¸ã®ãã¼ã¿ã°ã©ã ã¯ç ´æ£ããã  
+	 *
+	 *    ã»å§ç¹ã¢ãã¬ã¹ã ::ffff:127.0.0.1
+	 *    ã»çµç¹ã¢ãã¬ã¹ã ::ffff:127.0.0.1
+	 */
+
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->src) ||
+	    IN6_IS_ADDR_UNSPECIFIED(&ip6h->dst)) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+	if (IN6_IS_ADDR_V4MAPPED(&ip6h->src) ||
+	    IN6_IS_ADDR_V4MAPPED(&ip6h->dst)) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#ifdef SUPPORT_LOOP
+
+#else	/* of #ifdef SUPPORT_LOOP */
+
+	if (IN6_IS_ADDR_LOOPBACK(&ip6h->src) ||
+	    IN6_IS_ADDR_LOOPBACK(&ip6h->dst)) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+		goto buf_rel;
+		}
+
+#endif	/* of #ifdef SUPPORT_LOOP */
+
+	ifp = IF_GET_IFNET();
+
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst)) {
+		/* å®å
+ããã«ãã­ã£ã¹ãã®å ´åã®å¦ç */
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInMcastPkts, 1);
+		if (!in6_lookup_multi(ifp, &ip6h->dst)) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+			goto buf_rel;
+			}
+		}
+	else {
+		if ((ia6 = in6_lookup_ifaddr(ifp, &ip6h->dst)) == NULL) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+			goto buf_rel;
+			}
+
+		/*  ã¢ãã¬ã¹ãæªè§£æ±ºã®å ´åã¯ãã¼ã¿ã°ã©ã ãç ´æ£ããã*/
+		if (IFA6_IS_NOTREADY(ia6)) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_ADDR], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInAddrErrors, 1);
+			goto buf_rel;
+			}
+		}
+
+	/* ãªãã»ãããè¨­å®ããã*/
+	offp  = GET_IP6_NEXT_HDR(input) - input->buf;
+
+	/* ãã¤ã­ã¼ãé·ãåãåºãã*/
+	plen = ntohs(ip6h->plen);
+
+
+	/* æ¬¡ãããã®ä½ç½®ãåæåããã*/
+	nextp = offsetof(T_IP6_HDR, next);
+
+	/*
+	 *  ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³ãããã®ãã§ãã¯
+	 */
+	if (ip6h->next == IPPROTO_HOPOPTS) {
+
+		/* ä¸­ç¶ç¹ãããã®é·ãããã§ãã¯ããã*/
+		if (plen < sizeof(T_IP6_HBH_HDR)) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_SHORT], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInHdrErrors, 1);
+			goto buf_rel;
+			}
+
+		if ((noff = ip6_hopopts_input(input, &offp, &nextp)) < 0) {
+			if (noff == IP6_OPT_RET_ERR) {
+				NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PACKETS], 1);
+				NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInHdrErrors, 1);
+				goto buf_rel;
+				}
+			else if (noff == IP6_OPT_RET_REL) {
+				NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PACKETS], 1);
+				NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInHdrErrors, 1);
+				return;
+				}
+			}
+
+		/*
+		 *  ãã¤ã­ã¼ãé·ã 0 ã§ãä¸­ç¶ç¹ãªãã·ã§ã³ãããã¨ãã¯ã
+		 *  å·¨å¤§ãã¤ã­ã¼ãã»ãªãã·ã§ã³ãå«ã¾ããªããã°ãªããªãã
+		 *  ãã®ã¨ããå·¨å¤§ãã¤ã­ã¼ãã»ãªãã·ã§ã³ã«ãã
+		 *  ãã¤ã­ã¼ãé·ããã§ãã¯ããå¿
+è¦ãããããæ¬å®è£
+ã§ã¯ã
+		 *  å·¨å¤§ãã¤ã­ã¼ãã»ãªãã·ã§ã³ãæªç¥ã®ãªãã·ã§ã³ã¨ãã¦
+		 *  æ±ãã®ã§ãä½ãããªãã
+		 */
+		next = ((T_IP6_HBH_HDR *)(ip6h + 1))->next;
+		}
+	else
+		next = ip6h->next;
+
+	/* IPv6 ãã¼ã¿ã°ã©ã é·ããã§ãã¯ããã*/
+	if (input->len - IF_IP6_HDR_SIZE < plen) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_SHORT], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInTruncatedPkts, 1);
+		goto buf_rel;
+		}
+	else if (input->len > IF_IP6_HDR_SIZE + plen)
+		input->len = IF_IP6_HDR_SIZE + plen;
+
+	/* ä¸ä½ãã­ãã³ã«å¦çé¢æ°ãå¼ã³åºãã*/
+	nest = 0;
+	while (next != IPPROTO_DONE) {
+		if (++ nest > IP6_HDR_NEST_LIMIT) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PROTO], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInUnknownProtos, 1);
+			goto buf_rel;
+			}
+		else if ((func = get_upper_proto(next)) == NULL) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PROTO], 1);
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PACKETS], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsInUnknownProtos, 1);
+
+			/* icmp6_error ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããã*/
+			icmp6_error(input, ICMP6_PARAM_PROB,
+			                   ICMP6_PARAMPROB_NEXT_HEADER, nextp);
+			return;
+			}
+		else {
+			next = (*func)(&input, &offp, &nextp);
+			}
+		}
+	return;
+
+buf_rel:
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  ip6_nexthdr -- æ¬¡ã®ãããã®ãªãã»ãããè¿ãã
+ *
+ *    æ»ãå¤ == -1 : æå¾ã®ããããã¾ãã¯ã¨ã©ã¼ã
+ *    æ»ãå¤ >   0 : ããã«ããããç¶ãã
+ */
+
+ER_UINT
+ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp)
+{
+	T_IP6_FRAG_HDR	*ip6fh;
+	T_IP6_EXT_HDR	*ip6eh;
+
+	switch (proto) {
+
+	case IPPROTO_IPV6:				/* IPv6 */
+		if (nbuf->len < off + IP6_HDR_SIZE)
+			return (ER_UINT)-1;
+		*nextp = ((T_IP6_HDR *)(nbuf->buf + off))->next;
+		return off + IP6_HDR_SIZE;
+		break;
+
+	case IPPROTO_FRAGMENT:			/* æ­çããã */
+		if (nbuf->len < off + sizeof(T_IP6_FRAG_HDR))
+			return (ER_UINT)-1;
+
+		/* ä¸­éã®ãã©ã°ã¡ã³ãã®å ´åã¯å¦çããããã*/
+		ip6fh = (T_IP6_FRAG_HDR *)(nbuf->buf + off);
+		if (ntohs(ip6fh->off_flag) & IP6F_MORE_FRAG)
+			return (ER_UINT)-1;
+
+		*nextp = ip6fh->next;
+		return off + sizeof(T_IP6_FRAG_HDR);
+		break;
+
+	case IPPROTO_AH:		/* IPv6 èªè¨¼ããã			*/
+	case IPPROTO_HOPOPTS:		/* IPv6 ä¸­ç¶ç¹ (Hop-by-Hop) ãªãã·ã§ã³	*/
+	case IPPROTO_ROUTING:		/* çµè·¯å¶å¾¡ããã			*/
+	case IPPROTO_DSTOPTS:		/* IPv6 çµç¹ãªãã·ã§ã³			*/
+		if (nbuf->len < off + sizeof(T_IP6_EXT_HDR))
+			return (ER_UINT)-1;
+
+		ip6eh = (T_IP6_EXT_HDR *)(nbuf->buf + off);
+		*nextp =  ip6eh->next;
+		if (proto == IPPROTO_AH)
+			return off + ((ip6eh->len + 2) << 2);
+		else
+			return off + ((ip6eh->len + 1) << 3);
+		break;
+		}
+
+	return (ER_UINT)-1;
+	}
+
+/*
+ *  ip6_lasthdr -- æå¾ã®ãããã®ãªãã»ãããè¿ãã
+ */
+
+ER_UINT
+ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp)
+{
+	ER_UINT	newoff;
+
+	while (1) {
+		newoff = ip6_nexthdr(nbuf, off, proto, nextp);
+		if (newoff < 0)
+			return (ER_UINT)off;
+		off   = newoff;
+		proto = *nextp;
+		}
+	return (ER_UINT)0u;
+	}
+
+/*
+ *  ip6_unknown_opt -- æªç¥ã®ãªãã·ã§ã³ã®å¦ç
+ *
+ *    æ»ãå¤:
+ *
+ *      0 ä»¥ä¸ 			æ­£å¸¸ããªãã·ã§ã³é·ã
+ *      IP6_OPT_RET_ERR (-1)	ã¨ã©ã¼ãå¼åºå´ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããã
+ *      IP6_OPT_RET_REL (-2)	ã¨ã©ã¼ããããã¯ã¼ã¯ãããã¡ã¯éæ¾ããã¦ããã
+ */
+
+ER_UINT
+ip6_unknown_opt (T_NET_BUF *input, uint8_t *opt)
+{
+	switch (IP6OPT_TYPE(*opt)) {
+	case IP6OPT_TYPE_SKIP:		/* ç¡è¦ããã			*/
+		return *(opt + 1);
+		break;
+	case IP6OPT_TYPE_ICMP:		/* ç ´æ£ãã¦ããã«ãã­ã£ã¹ãã§ãªããã° ICMP ãè¿éããã	*/
+		if (IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst))
+			return IP6_OPT_RET_ERR;
+		/* no break; */
+	case IP6OPT_TYPE_FORCEICMP:	/* ç ´æ£ãã¦ãICMP ãè¿éããã	*/
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_OPTION,
+		                   (opt - input->buf) - IF_HDR_SIZE);
+		return IP6_OPT_RET_REL;
+		break;
+	/*case IP6OPT_TYPE_DISCARD:	ãã¼ã¿ã°ã©ã ãç ´æ£ããã	*/
+		}
+
+	return IP6_OPT_RET_ERR;
+	}
+
+/*
+ *  ip6_remove_exthdrs -- IPv6 æ¡å¼µããããåé¤ããä»¥éãåã«è©°ããã
+ */
+
+ER
+ip6_remove_exthdrs (T_NET_BUF *nbuf)
+{
+	ER_UINT	off;
+	uint_t	next;
+
+	/* éå§ãªãã»ããã IP ãããã«è¨­å®ããã*/
+	off = ((uint8_t *)GET_IP6_HDR(nbuf)) - nbuf->buf;
+
+	/* æçµããããæ¢ç´¢ããã*/
+	off = ip6_lasthdr(nbuf, off, IPPROTO_IPV6, &next);
+
+	if (off <= 0)
+		return E_OBJ;
+	else {
+		uint_t sdu;
+
+		sdu = GET_IP6_SDU(nbuf) - nbuf->buf;
+		if (off > sdu) {
+			memmove(nbuf->buf + sdu, nbuf->buf + off, off - sdu);
+			GET_IP6_HDR(nbuf)->plen -= off - sdu;
+			nbuf->len              -= off - sdu;
+			}
+		}
+	return E_OK;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ip6_output.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ip6_output.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ip6_output.c	(revision 317)
@@ -0,0 +1,393 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ip6_output.c,v 1.43 2002/10/31 19:45:48 ume Exp $	*/
+/*	$KAME: ip6_output.c,v 1.279 2002/01/26 06:12:30 jinmei Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_output.c	8.3 (Berkeley) 1/21/94
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
+#include <netinet6/nd6.h>
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+/* ãªã³ã¯ MTU */
+
+uint32_t	linkmtu = IF_MTU;
+
+/*
+ *  å±æå¤æ°
+ */
+
+#ifdef IP6_CFG_FRAGMENT
+
+static uint32_t	ip6_id;
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+/*
+ *  ip6_output -- IPv6 ã®åºåé¢æ°
+ */
+
+ER
+ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout)
+{
+	T_IP6_HDR		*ip6h;
+	const T_IN6_ADDR	*gw;
+	T_IFNET			*ifp = IF_GET_IFNET();
+	ER			error = E_OK;
+
+#ifdef IP6_CFG_FRAGMENT
+
+	T_IP6_HDR	*fip6h;
+	T_IP6_FRAG_HDR	*fip6f;
+	T_NET_BUF	*frag;
+	uint32_t	mtu, id;
+	uint16_t	plen, foff, flen;
+	uint8_t		nextproto;
+	bool_t		alwaysfrag = false;
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+	ip6h = GET_IP6_HDR(output);
+
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_OCTETS],
+	              GET_IP6_HDR_SIZE(output) + GET_IP6_SDU_SIZE(output));
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutRequests, 1);
+
+	/*
+	 *  éè¤ã¢ãã¬ã¹æ¤åºè¦è«ä»¥å¤ã«ã¯ãéä¿¡å
+ã¢ãã¬ã¹ã«
+	 *  ç¡æå®ãæå®ã§ããªãã
+	 */
+	if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src) && (flags & IPV6_OUT_FLG_DAD) == 0) {
+		error = E_PAR;
+		goto drop;
+		}
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã«ã¯ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãæå®ã§ããªãã*/
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->src)) {
+		error = E_PAR;
+		goto drop;
+		}
+
+	/*
+	 *  çµè·¯é¸æãè¡ãã
+	 */
+	if ((gw = in6_rtalloc(ifp, &ip6h->dst)) == NULL) {
+		error = E_PAR;
+		goto drop;
+		}
+
+	if (!IN6_IS_ADDR_MULTICAST(&ip6h->dst)) {
+		/* ã¦ãã­ã£ã¹ãã¢ãã¬ã¹ã®å¦ç */
+		}
+	else {
+		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã®å¦ç */
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutMcastPkts, 1);
+		if (flags & IPV6_OUT_FLG_HOP_LIMIT)
+			ip6h->hlim = IPV6_OUT_GET_HOP_LIMIT(flags);
+		else
+			ip6h->hlim = IPV6_DEFAULT_MULTICAST_HOPS;
+		}
+
+	/* Traffic Class ã¨ Flow Label ããµãã¼ãããªãã®ã§ 0 ã«è¨­å®ããã*/
+	ip6h->vcf = htonl(IP6_MAKE_VCF(IPV6_VERSION, 0));
+
+#ifdef IP6_CFG_FRAGMENT
+
+
+#if NUM_IN6_HOSTCACHE_ENTRY > 0
+
+	mtu = in6_hostcache_getmtu(&ip6h->dst);
+
+	if (0 < mtu && mtu <= IPV6_MMTU) {
+
+		/*
+		 *  Path MTU ãç»é²ããã¦ããå ´åã
+		 *  MTU ã IPv6 MMTUï¼1280 ãªã¯ãããï¼ä»¥ä¸ã®å ´åã¯ã
+		 *  MTU ã IPv6 MMTU ã«è¨­å®ãåå²ãã¦éä¿¡ããã
+		 */
+		mtu = IPV6_MMTU;
+		alwaysfrag = true;
+		}
+	else if (mtu == 0)
+		mtu  = linkmtu;
+
+#else	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+	mtu  = linkmtu;
+
+#endif	/* of #if NUM_IN6_HOSTCACHE_ENTRY > 0 */
+
+	plen = ntohs(ip6h->plen);
+	if (plen + IP6_HDR_SIZE <= mtu && !alwaysfrag) {
+
+		/* åå²ããå¿
+è¦ããªãã¨ãã®å¦ç */
+		if ((error = nd6_output(ifp, output, gw, NULL, tmout)) != E_OK) {
+			NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_ERR_PACKETS], 1);
+			NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutDiscards, 1);
+			}
+		}
+	else {
+
+		/* æ­ç ID ãè¨­å®ããã*/
+		id = ip6_id ++;
+
+		/* MTU ã IPv6 ã®æå¤§ãã±ãããµã¤ãºãè¶
+ããªãããã«ããã*/
+		if (mtu > IPV6_MAXPACKET)
+			mtu = IPV6_MAXPACKET;
+
+		/*
+		 *  MTU ãããåå²ä¸è½é¨åï¼TINET-1.4 ã§ã¯ãåå²ãããä»¥å¤ã®
+		 *  æ¡å¼µãããã®åºåã¯æªå®è£
+ã®ãã 0 ãªã¯ãããï¼
+		 *  ã¨æ­çãããã®ãµã¤ãºãå¼ããã¨ãã8 ãªã¯ãããä»¥ä¸ãªããã°
+		 *  åå²ãã¦éä¿¡ã§ããªãããã¨ã©ã¼ã«ããã
+		 */
+		if (((mtu - sizeof(T_IP6_FRAG_HDR)) & ~7) < 8) {
+			error = E_PAR;
+			goto drop;
+			}
+
+		/*
+		 *  IPv6 ãããã® next ãã£ã¼ã«ãã«è¨­å®ããå¤ã¯ãæ­çãããã
+		 *  æ­çãããã®  next ãã£ã¼ã«ãã«è¨­å®ããå¤ã¯ã
+		 *  å
+ã®ãã¼ã¿ã°ã©ã ã® next ãã£ã¼ã«ãã®å¤ã
+		 */
+		nextproto  = ip6h->next;
+		ip6h->next = IPPROTO_FRAGMENT;
+
+		/* åå²ãã¦éä¿¡ããã*/
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_OUT], 1);
+		for (foff = 0; foff < plen; foff += flen) {
+
+			/* æ­çã®é·ããè¨ç®ãã8 ãªã¯ãããå¢çã«èª¿æ´ããã*/
+			if (foff + (mtu - (IP6_HDR_SIZE + sizeof(T_IP6_FRAG_HDR))) < plen)
+				flen = (mtu - (IP6_HDR_SIZE + sizeof(T_IP6_FRAG_HDR))) >> 3 << 3;
+			else
+				flen = plen - foff;
+
+			/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããã*/
+			if (tget_net_buf(&frag, flen + IF_IP6_HDR_SIZE + sizeof(T_IP6_FRAG_HDR), TMO_IP6_FRAG_GET_NET_BUF) == E_OK) {
+
+				/* IPv6 ããããã³ãã¼ããã*/
+				fip6h = GET_IP6_HDR(frag);
+				*fip6h = *ip6h;
+
+				/* IPv6 ããããåããã*/
+				fip6h->plen	= htons(flen + sizeof(T_IP6_FRAG_HDR));
+
+				/* æ­çããããåããã*/
+				fip6f = (T_IP6_FRAG_HDR *)GET_IP6_NEXT_HDR(frag);
+				fip6f->off_flag	= htons((uint16_t)(foff & ~7));
+				if (foff + (mtu - (IP6_HDR_SIZE + sizeof(T_IP6_FRAG_HDR))) < plen)
+					fip6f->off_flag	|= IP6F_MORE_FRAG;
+				fip6f->reserved	= 0;
+				fip6f->ident	= htonl(id);
+				fip6f->next	= nextproto;
+
+				/* SDU ãã³ãã¼ããã*/
+				memcpy((uint8_t*)(fip6f + 1), GET_IP6_NEXT_HDR(output) + foff, flen);
+				NET_COUNT_IP6(net_count_ip6[NC_IP6_FRAG_OUT_FRAGS], 1);
+				NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutFragCreates, 1);
+
+				/* éä¿¡ããã*/
+				if ((error = nd6_output(ifp, frag, gw, NULL, tmout)) != E_OK) {
+					NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutFragFails, 1);
+					goto drop;
+					}
+				}
+			else {
+				/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ã§ããªããã°ãéä¿¡ããããããã*/
+				error = E_NOMEM;
+				goto drop;
+				}
+			}
+
+		/* IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ããã§ãã¯ããã*/
+		if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+			syscall(rel_net_buf(output));
+			}
+		else
+			output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutFragOKs, 1);
+		}
+
+#else	/* #ifdef IP6_CFG_FRAGMENT */
+
+	if ((error = nd6_output(ifp, output, gw, NULL, tmout)) != E_OK) {
+		NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_ERR_PACKETS], 1);
+		NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutDiscards, 1);
+		}
+
+#endif	/* #ifdef IP6_CFG_FRAGMENT */
+
+	return error;
+
+drop:
+	/* IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ããã§ãã¯ããã*/
+	if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+		syscall(rel_net_buf(output));
+		}
+	else
+		output->flags &= (uint8_t)~NB_FLG_NOREL_IFOUT;
+
+	NET_COUNT_IP6(net_count_ip6[NC_IP6_OUT_ERR_PACKETS], 1);
+	NET_COUNT_MIB(in6_ifstat.ipv6IfStatsOutDiscards, 1);
+	return error;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ip6_var.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ip6_var.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ip6_var.h	(revision 317)
@@ -0,0 +1,323 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/ip6_var.h,v 1.10 2002/10/16 01:54:45 sam Exp $	*/
+/*	$KAME: ip6_var.h,v 1.62 2001/05/03 14:51:48 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)ip_var.h	8.1 (Berkeley) 6/10/93
+ */
+ 
+#ifndef _IP6_VAR_H_
+#define _IP6_VAR_H_
+
+/*
+ *  IPv6 ãããã»ãã¤ã­ã¼ãã¢ã¯ã»ã¹ãã¯ã­
+ */
+
+#define IF_IP6_HDR_SIZE			(IF_HDR_SIZE + IP6_HDR_SIZE)
+
+#define GET_IP6_HDR(nbuf)		((T_IP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_IP6_SDU(nbuf)		((uint8_t*)((nbuf)->buf) + GET_IF_IP6_HDR_SIZE(nbuf))
+#define GET_IP6_NEXT_HDR(nbuf)		((uint8_t*)((nbuf)->buf) + IF_IP6_HDR_SIZE)
+
+#define GET_IP6_HDR_SIZE(nbuf)		(get_ip6_hdr_size(nbuf))
+#define GET_IP6_SDU_SIZE(nbuf)		(ntohs(GET_IP6_HDR(nbuf)->plen))
+#define GET_IF_IP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_IP6_HDR_SIZE(nbuf)))
+
+#define SET_IP6_CF(nbuf,cf)		(GET_IP6_HDR(nbuf)->vcf=htonl(IP6_MAKE_VCF(IP6_VCF_V(ntohl(GET_IP6_HDR(nbuf)->vcf)),cf)))
+#define SET_IP6_SDU_SIZE(nbuf,slen)	(GET_IP6_HDR(nbuf)->plen=htons(slen))
+
+/* ip6_output ã®ãã©ã° */
+
+#define IPV6_OUT_FLG_DAD		0x0100	/* éè¤ã¢ãã¬ã¹æ¤åº	*/
+#define IPV6_OUT_FLG_HOP_LIMIT		0x0200	/* ããããªãããæå®	*/
+
+/* ããããªããããã©ã°ãä»ãæãããããªãããå¤ãæä½ãããã¯ã­ */
+
+#define IPV6_OUT_GET_HOP_LIMIT(f)	((f)&0x00ff)
+#define IPV6_OUT_SET_HOP_LIMIT(f,l)	((f)|(l))
+
+/*
+ *  ip6_unknown_opt -- æªç¥ã®ãªãã·ã§ã³ã®å¦ç
+ *
+ *    æ»ãå¤:
+ *
+ *      0 ä»¥ä¸ 			æ­£å¸¸ããªãã·ã§ã³é·ã
+ *      IP6_OPT_RET_ERR (-1)	ã¨ã©ã¼ãå¼åºå´ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããã
+ *      IP6_OPT_RET_REL (-2)	ã¨ã©ã¼ããããã¯ã¼ã¯ãããã¡ã¯éæ¾ããã¦ããã
+ */
+
+#define IP6_OPT_RET_ERR		(-1)
+#define IP6_OPT_RET_REL		(-2)
+
+/*
+ *  IPv6 ã® MMTU ãµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+#if defined(IF_HDR_SIZE)
+
+typedef struct t_net_buf_ipv6_mmtu {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		unit;	/* ã¤ã³ã¿ãã§ã¼ã¹çªå·	*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_HDR_SIZE + IPV6_MMTU];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF_IPV6_MMTU;
+
+#endif	/* of #if defined(IF_HDR_SIZE) */
+
+/*
+ *  65536 ãªã¯ããããµã¤ãºã®ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf6_65536 {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		halign[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IF_IP6_HDR_SIZE + 65536];
+				/* ãããã¡æ¬ä½		*/
+#if defined(IF_PDU_HDR_PADDING)
+	uint8_t		padding[IF_PDU_HDR_PADDING];
+#endif				/* ãããã®ä½å		*/
+	} T_NET_BUF6_65536;
+
+#ifdef IP6_CFG_FRAGMENT
+
+/*
+ *  åæ§æã­ã¥ã¼ç¨ IPv6 ãããã®å®ç¾©
+ */
+
+typedef struct t_qip6_hdr {
+	uint32_t		vcf;		/* Version:        4 bit		*/
+					/* Traffic Class:  8 bit		*/
+					/* Flow Label:    20 bit		*/
+	uint16_t	plen;		/* Payload Length			*/
+	uint8_t		next;		/* Next Header				*/
+	uint8_t		hlim;		/* Hop Limit				*/
+	T_IN6_ADDR	src;		/* Source Address			*/
+	T_NET_BUF	*next_frag;	/* æ¬¡ã® IPv6 ãã©ã°ã¡ã³ã	*/
+	uint16_t	foff;		/* æ­çãããã®ãªãã»ãã		*/
+	uint16_t	flen;		/* æ­çé·				*/
+	uint16_t	ftim;		/* åæ§æã¿ã¤ã ã¢ã¦ã			*/
+	uint16_t	dummy1;
+	uint8_t		dummy2[sizeof(T_IN6_ADDR) - (sizeof(T_NET_BUF*) + sizeof(uint16_t) * 4)];
+	} T_QIP6_HDR;
+
+#define QIP6_HDR_SIZE			(sizeof(T_QIP6_HDR))
+#define IF_QIP6_HDR_SIZE		(IF_HDR_SIZE + QIP6_HDR_SIZE)
+
+#define GET_QIP6_HDR(nbuf)		((T_QIP6_HDR*)((nbuf)->buf + IF_HDR_SIZE))
+#define GET_QIP6_SDU(nbuf)		((uint8_t*)(nbuf)->buf + GET_IF_QIP6_HDR_SIZE(nbuf))
+
+#define GET_QIP6_HDR_SIZE(iph)		((uint8_t)IP6_VHL_HL((iph)->vhl) << 2)
+#define GET_IF_QIP6_HDR_SIZE(nbuf)	(IF_HDR_SIZE + (GET_QIP6_HDR_SIZE(GET_QIP6_HDR(nbuf))))
+
+/*
+ *  ãã¼ã¿ã°ã©ã åæ§æç¨ãããã¯ã¼ã¯ãããã¡
+ */
+
+typedef struct t_net_buf6_reassm {
+	uint16_t	len;	/* ãã¼ã¿ã®é·ã		*/
+	uint8_t		idix;	/* mpfid ã®ã¤ã³ããã¯ã¹	*/
+	uint8_t		flags;	/* ãã©ã°		*/
+#ifdef IF_ETHER_NIC_NET_BUF_ALIGN
+	uint8_t		nalign[IF_ETHER_NIC_NET_BUF_ALIGN];
+#endif
+#if CPU_NET_ALIGN == 4 && IF_HDR_ALIGN != 4
+	uint8_t		align[4 - IF_HDR_ALIGN];
+#endif
+	uint8_t		buf[IP6_CFG_FRAG_REASSM_SIZE];
+				/* ãããã¡æ¬ä½		*/
+	} T_NET_BUF6_REASSM;
+
+#endif	/* of #ifdef IP6_CFG_FRAGMENT */
+
+/*
+ *  TCP ã®åæ§æã­ã¥ã¼ã«ããã IPv6 ãããã®å®ç¾©
+ */
+
+typedef struct t_ip6_tcp_q_hdr {
+	uint8_t vc;		/* Version:        4 bit		*/
+	uint8_t cf;		/* Traffic Class:  8 bit		*/
+			/* Flow Label:     4 bit (20 bit)	*/
+	uint16_t thoff;	/* TCP ãããã®ãªãã»ãã		*/
+	uint16_t plen;	/* Payload Length			*/
+	uint8_t next;	/* Next Header				*/
+	uint8_t hlim;	/* Hop Limit				*/
+	T_IN6_ADDR src;	/* Source Address			*/
+	T_IN6_ADDR dst;	/* Destination Address			*/
+	} T_IP6_TCP_Q_HDR;
+
+#ifdef SUPPORT_MIB
+
+/*
+ *  SNMP ã® ç®¡çæ
+å ±ãã¼ã¹ (MIB)
+ */
+
+typedef struct t_in6_ifstat {
+	uint32_t	ipv6IfStatsInReceives;
+	uint32_t	ipv6IfStatsInHdrErrors;
+/*	uint32_t	ipv6IfStatsInTooBigErrors;*/
+/*	uint32_t	ipv6IfStatsInNoRoutes;*/
+	uint32_t	ipv6IfStatsInAddrErrors;
+	uint32_t	ipv6IfStatsInUnknownProtos;
+	uint32_t	ipv6IfStatsInTruncatedPkts;
+/*	uint32_t	ipv6IfStatsInDiscards;*/
+/*	uint32_t	ipv6IfStatsInDelivers;*/
+/*	uint32_t	ipv6IfStatsOutForwDatagrams;*/
+	uint32_t	ipv6IfStatsOutRequests;
+	uint32_t	ipv6IfStatsOutDiscards;
+	uint32_t	ipv6IfStatsOutFragOKs;
+	uint32_t	ipv6IfStatsOutFragFails;
+	uint32_t	ipv6IfStatsOutFragCreates;
+	uint32_t	ipv6IfStatsReasmReqds;
+	uint32_t	ipv6IfStatsReasmOKs;
+	uint32_t	ipv6IfStatsReasmFails;
+	uint32_t	ipv6IfStatsInMcastPkts;
+	uint32_t	ipv6IfStatsOutMcastPkts;
+} T_IN6_IFSTAT;
+
+extern T_IN6_IFSTAT in6_ifstat;
+
+#endif	/* of #ifdef SUPPORT_MIB */
+
+/*
+ *  å¤æ°
+ */
+
+extern uint8_t	ip6_defhlim;
+
+/*
+ *  é¢æ°
+ */
+
+extern ER ip6_output (T_NET_BUF *output, uint16_t flags, TMO tmout);
+extern void ip6_init (void);
+extern uint8_t *ip6_get_prev_hdr (T_NET_BUF *nbuf, uint_t off);
+extern uint_t get_ip6_hdr_size (T_NET_BUF *nbuf);
+extern ER_UINT ip6_nexthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
+extern ER_UINT ip6_lasthdr (T_NET_BUF *nbuf, uint_t off, uint_t proto, uint_t *nextp);
+extern ER_UINT ip6_unknown_opt (T_NET_BUF *input, uint8_t *opt);
+extern uint_t dest6_input  (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern uint_t route6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern uint_t frag6_input  (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp);
+extern void frag6_timer (void);
+extern ER ip6_remove_exthdrs (T_NET_BUF *nbuf);
+
+#endif	/* of #ifndef _IP6_VAR_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/ipsec.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/ipsec.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/ipsec.cfg	(revision 317)
@@ -0,0 +1,54 @@
+
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *  Copyright (C) 2008-2009 by Hokkaido Industrial Research Institute, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  IPsec ã§ä½¿ç¨ããã«ã¼ãã«ãªãã¸ã§ã¯ã
+ */
+
+#ifdef SUPPORT_IPSEC
+
+#endif	/* of #ifdef SUPPORT_IPSEC */
Index: asp3_gr_sakura/trunk/tinet/netinet6/nd6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/nd6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/nd6.c	(revision 317)
@@ -0,0 +1,731 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/nd6.c,v 1.20 2002/08/02 20:49:14 rwatson Exp $	*/
+/*	$KAME: nd6.c,v 1.144 2001/05/24 07:44:00 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * XXX
+ * KAME 970409 note:
+ * BSD/OS version heavily modifies this code, related to llinfo.
+ * Since we don't have BSD/OS version of net/route.c in our hand,
+ * I left the code mostly as it was in 970310.  -- itojun
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
+#include <netinet6/nd6.h>
+
+#include <net/if_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  è¿é£ã­ã£ãã·ã¥
+ */
+
+static T_LLINFO_ND6 nd6_cache[NUM_ND6_CACHE_ENTRY];
+
+/*
+ *  nd6_free -- ã«ã¼ã¿ãåé¤ããã
+ */
+
+static void
+nd6_free (T_LLINFO_ND6	*ln)
+{
+	T_DEF_ROUTER	*dr;
+
+	dr = nd6_defrtrlist_lookup(&ln->addr);
+	if (dr != NULL) {
+		ln->state = ND6_LLINFO_INCOMPLETE;
+
+		/* ãã¬ãã£ãã¯ã¹ã»ãªã¹ãããã«ã¼ã¿ãåé¤ããã*/
+		nd6_defrtrlist_del(dr);
+		}
+	}
+
+/*
+ *  nd6_timer -- è¿é£æ¢ç´¢ç®¡çã¿ã¤ãã¼
+ */
+
+void
+nd6_timer (void)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_LLINFO_ND6	*ln;
+	SYSTIM		now;
+	int_t		ix;
+
+	/* è¿é£ã­ã£ãã·ã¥ã®å¦ç */
+	syscall(wai_sem(SEM_ND6_CACHE));
+	syscall(get_tim(&now));
+	for (ix = NUM_ND6_CACHE_ENTRY; ix -- > 0; ) {
+		ln = &nd6_cache[ix];
+		if (ln->state >= ND6_LLINFO_NO_STATE && (int32_t)(ln->expire - now) < 0) {
+		                                               /* ln->expire < now */
+
+			switch (ln->state) {
+
+			case ND6_LLINFO_INCOMPLETE:	/* æªè§£æ±º		*/
+				if (ln->asked < ND6_MAX_MCAST_QUERY) {
+					/*
+					 *  ãã«ãã­ã£ã¹ãã¢ãã¬ã¹è¦è«ã®åéåæ°ä»¥ä¸ã®å ´åã®å¦ç
+					 */
+					ln->asked ++;
+					ln->expire = now + ND6_RETRANS_TIME;	/* è¿é£æ¢ç´¢éä¿¡éé */
+					nd6_ns_output(ifp, &in6_addr_unspecified, &ln->addr, ln, false);
+					}
+				else  {
+					if (ln->hold != NULL) {
+						/*
+						 *  æçµçã«ã¯ãä¿çããã¦ãããããã¯ã¼ã¯ãããã¡ã
+						 *  ããã°ãICMP6 ERROR ãèªåèªèº«ã«è¿ãããã¨ã
+						 *  ãããã¯ã¼ã¯ãããã¡ãéæ¾ããã
+						 *  ããããç¾å¨ãicmp6_error ã®å®è£
+ãä¸å®å
+¨ã®ããã
+						 *  ãããã¯ã¼ã¯ãããã¡ã®éæ¾ã®ã¿è¡ãã
+						 */
+#if 0	/* ä¿ç */
+						icmp6_error(ln->hold, ICMP6_DST_UNREACH,
+						                      ICMP6_DST_UNREACH_ADDR, 0);
+#endif	/* #if 0 */
+						syscall(rel_net_buf(ln->hold));
+						ln->hold = NULL;
+						}
+					nd6_free(ln);
+					memset((void*)ln, 0, sizeof(*ln));
+					}
+				break;
+
+			case ND6_LLINFO_REACHABLE:	/* å°éå¯è½		*/
+				if (ln->expire) {
+					ln->expire = now + ND6_GCOLLECTION_TIME;
+					ln->state = ND6_LLINFO_STALE;
+					}
+				break;
+
+			case ND6_LLINFO_STALE:		/* å°éå¯è½æ§ã¯æªç¢ºèª	*/
+				if (ln->expire) {
+					if (ln->hold != NULL) {
+						syscall(rel_net_buf(ln->hold));
+						ln->hold = NULL;
+						}
+					nd6_free(ln);
+					memset((void*)ln, 0, sizeof(*ln));
+					}
+				break;
+
+			case ND6_LLINFO_DELAY:		/* å°éå¯è½æ§ã®ç¢ºèªå¾
+æ©	*/
+				ln->asked = 1;
+				ln->expire = now + ND6_RETRANS_TIME;		/* è¿é£æ¢ç´¢éä¿¡éé */
+				ln->state = ND6_LLINFO_PROBE;
+				nd6_ns_output(ifp, &ln->addr, &ln->addr, ln, false);
+				break;
+
+			case ND6_LLINFO_PROBE:		/* å°éå¯è½æ§ãç¢ºèªä¸­	*/
+				if (ln->asked < ND6_MAX_UCAST_QUERY) {
+					/*
+					 *  ã¦ãã­ã£ã¹ãã¢ãã¬ã¹è¦è«ã®åéåæ°ä»¥ä¸ã®å ´åã®å¦ç
+					 */
+					ln->asked ++;
+					ln->expire += ND6_RETRANS_TIME;	/* è¿é£æ¢ç´¢éä¿¡éé */
+					nd6_ns_output(ifp, &ln->addr, &ln->addr, ln, false);
+					}
+				else {
+					if (ln->hold != NULL) {
+						syscall(rel_net_buf(ln->hold));
+						ln->hold = NULL;
+						}
+					nd6_free(ln);
+					memset((void*)ln, 0, sizeof(*ln));
+					}
+				break;
+
+				}
+			}
+		}
+	syscall(sig_sem(SEM_ND6_CACHE));
+
+	/* ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãã®å¦ç */
+	nd6_defrtrlist_timer();
+
+	/* ãã¬ãã£ãã¯ã¹ã»ãªã¹ãã®å¦ç */
+	nd6_prelist_timer();
+
+	/* ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ã®å¦ç */
+	in6_ifaddr_timer(ifp);
+
+	/*
+	 *  å°éå¯è½ç¶æ
+ã®æå¹æéã®æ´æ°
+	 */
+	if ((int32_t)(nd6_recalc_reachtm_interval - now) < 0) {
+	           /* nd6_recalc_reachtm_interval < now */
+		nd6_recalc_reachtm_interval	= now + ND6_RECALC_REACHTM_INTERVAL;
+		nd6_reachable_time		= ND6_CALC_REACH_TIME(nd6_base_reachable_time);
+		}
+	timeout((callout_func)nd6_timer, NULL, ND6_TIMER_TMO);
+	}
+
+/*
+ *  nd6_get_cache -- è¿é£ã­ã£ãã·ã¥ãç²å¾ããã
+ */
+
+const T_LLINFO_ND6 *
+nd6_get_cache (void)
+{
+	return nd6_cache;
+	}
+
+/*
+ *  nd6_ifattach -- è¿é£æ¢ç´¢ã®åæè¨­å®ãè¡ãã
+ */
+
+void
+nd6_ifattach (T_IFNET *ifp)
+{
+	}
+
+/*
+ *  nd6_output_hold -- è¿é£æ¢ç´¢ã­ã£ãã·ã¥ã«ä¿çããã¦ãã
+ *                     ã¢ãã¬ã¹è§£æ±ºå¾
+ã¡ã®ãã¼ã¿ã°ã©ã ãããã°éä¿¡ããã
+ *
+ *    æ³¨æ: ã»ããã© SEM_ND6_CACHE ã«ããã­ãã¯ç¶æ
+ã§å¼åºããã¨ã
+ */
+
+ER
+nd6_output_hold (T_IFNET *ifp, T_LLINFO_ND6 *ln)
+{
+	SYSTIM now;
+
+	/* ã¢ãã¬ã¹è§£æ±ºå¾
+ã¡ã®ãã¼ã¿ã°ã©ã ãããã°éä¿¡ããã*/
+	if (ln->hold) {
+
+		/* ã¿ã¤ã ã¢ã¦ãã®å¦ç */
+		if (ln->tmout != TMO_FEVR) {
+
+			/*
+			 *  ã¿ã¤ã ã¢ã¦ãã®æå®ãæ°¸ä¹
+ã§ãªããæéãéãã¦ããã°ã
+			 *  åºåããªãã§çµäºããã
+			 */
+			syscall(get_tim(&now));
+			if ((int32_t)(ln->tmout - now) < 0) {
+			           /* ln->tmout < now */
+				syscall(rel_net_buf(ln->hold));
+				ln->hold = NULL;
+				return E_TMOUT;
+				}
+			}
+				
+		nd6_output(ifp, ln->hold, &ln->addr, ln, TMO_FEVR);
+		ln->hold = NULL;
+		}
+	return E_OK;
+	}
+
+/*
+ *  nd6_lookup -- è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãæ¢ç´¢ããã
+ *
+ *    æ³¨æ: ã»ããã© SEM_ND6_CACHE ã«ããã­ãã¯ç¶æ
+ã§å¼åºããã¨ã
+ *
+ */
+
+T_LLINFO_ND6 *
+nd6_lookup (const T_IN6_ADDR *addr, bool_t create)
+{
+	SYSTIM	min = 0xffffffff;
+	int_t	ix, fix = -1, mix = -1;
+
+	for (ix = NUM_ND6_CACHE_ENTRY; ix -- > 0; ) {
+		if (nd6_cache[ix].state == 0) {
+			/* æªä½¿ç¨ã¨ã³ããªã®ã¤ã³ããã¯ã¹ãè¨é²ããã*/
+			if (fix == -1)
+				fix = ix;
+			}
+		else if (IN6_ARE_ADDR_EQUAL(addr, &nd6_cache[ix].addr)) {
+			return &nd6_cache[ix];
+			}
+		else if ((int32_t)(nd6_cache[ix].expire - min) < 0) {	/* nd6_cache[ix].expire < min */
+			/* æå¹æéãæç­ã¨ã³ããªã®ã¤ã³ããã¯ã¹ãè¨é²ããã*/
+			min = nd6_cache[ix].expire;
+			mix = ix;
+			}
+		}
+
+	if (create) {
+		if (fix == -1)  {
+			if (nd6_cache[mix].hold != NULL) {
+				syscall(rel_net_buf(nd6_cache[mix].hold));
+				}
+			fix = mix;
+			}
+		syscall(get_tim(&nd6_cache[fix].expire));
+		nd6_cache[fix].addr   = *addr;
+		nd6_cache[fix].state  = ND6_LLINFO_NO_STATE;
+		return &nd6_cache[fix];
+		}
+	else
+		return NULL;
+	}
+
+/*
+ *  nd6_cache_lladdr -- è¿é£æ¢ç´¢ã­ã£ãã·ã¥ã«ç»é²ããã
+ */
+
+T_LLINFO_ND6 *
+nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from,
+                  T_IF_ADDR *lladdr, uint8_t type, uint8_t code)
+{
+	T_LLINFO_ND6	*ln;
+	SYSTIM		now;
+	bool_t		newentry, olladdr, llchange, doupdate;
+	int_t		newstate = ND6_LLINFO_INCOMPLETE;
+
+	/* ã¢ãã¬ã¹ãç¡æå®ãªãä½ãããªãã*/
+	if (IN6_IS_ADDR_UNSPECIFIED(from))
+		return NULL;
+
+	/* è¿é£ã­ã£ãã·ã¥ã«ç»é²ããã*/
+	syscall(wai_sem(SEM_ND6_CACHE));
+	if ((ln = nd6_lookup(from, false)) == NULL) {
+		ln = nd6_lookup(from, true);
+		newentry = true;
+		}
+	else
+		newentry = false;
+
+	olladdr = ln->state > ND6_LLINFO_INCOMPLETE;
+	if (!olladdr || lladdr == NULL)
+		llchange = false;
+	else if (memcmp(lladdr, &ln->ifaddr, sizeof(T_IF_ADDR)))
+		llchange = true;
+	else
+		llchange = false;
+
+	/*
+	 *  ç¶æ
+é·ç§»è¡¨
+	 *
+	 *  nd_na_flags
+	 *  newnetry olladdr lladdr llchange å¦ç (L: lladdr ãç»é²ãã)
+	 *
+	 *      F       F       N       -    (1)
+	 *      F       T       N       -    (2)
+	 *      F       F       Y       -    (3) L * -> STALE
+	 *      F       T       Y       F    (4) L
+	 *      F       T       Y       T    (5) L * -> STALE
+	 *      T       -       N       -    (6)   * -> NO_STATE
+	 *      T       -       Y       -    (7) L * -> STALE
+	 */
+
+	/* ãã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ãéç¥ããã¦ããã°æ´æ°ããã*/
+	if (lladdr != NULL) {
+		ln->ifaddr = *(T_IF_ADDR *)lladdr;
+		}
+
+	if (newentry) {
+		if (lladdr != NULL)					/* (7) */
+			newstate = ND6_LLINFO_STALE;
+		else							/* (6) */
+			newstate = ND6_LLINFO_NO_STATE;
+		doupdate = true;
+		}
+	else {
+		if ((!olladdr && lladdr != NULL) ||			/* (3) */
+		    ( olladdr && lladdr != NULL && llchange)) {		/* (5) */
+			newstate = ND6_LLINFO_STALE;
+			doupdate = true;
+			}
+		else							/* (1),(2),(4) */
+			doupdate = false;
+		}
+
+	/* è¿é£ã­ã£ãã·ã¥ã¨ã³ããªãæ´æ°ããã*/
+	if (doupdate) {
+		ln->state = newstate;
+
+		syscall(get_tim(&now));
+		if (ln->state == ND6_LLINFO_STALE) {
+			ln->expire = now + ND6_GCOLLECTION_TIME;
+
+			/* ã¢ãã¬ã¹è§£æ±ºå¾
+ã¡ã®ãã¼ã¿ã°ã©ã ãããã°éä¿¡ããã*/
+			nd6_output_hold(ifp, ln);
+			}
+		else if (ln->state == ND6_LLINFO_INCOMPLETE)
+			ln->expire = now;
+		}
+	syscall(sig_sem(SEM_ND6_CACHE));
+
+
+	/* ã«ã¼ã¿éç¥ã®å¦ç */
+	switch (type) {
+
+	case ND_NEIGHBOR_SOLICIT:
+		if (newentry)
+			ln->flags &= ~ND6_LLIF_ROUTER;
+		break;
+
+	case ND_REDIRECT:
+		if (code == ND_REDIRECT_ROUTER)
+			ln->flags |=  ND6_LLIF_ROUTER;
+		else if (newentry)
+			ln->flags &= ~ND6_LLIF_ROUTER;
+		break;
+
+	case ND_ROUTER_SOLICIT:
+		ln->flags &= ~ND6_LLIF_ROUTER;
+		break;
+
+	case ND_ROUTER_ADVERT:
+		if ((!newentry && (olladdr || lladdr != NULL)) ||
+		    ( newentry && lladdr))
+			ln->flags |=  ND6_LLIF_ROUTER;
+		break;
+		}
+
+	return ln;
+	}
+
+/*
+ *  nd6_is_addr_neighbor -- æå®ãããã¢ãã¬ã¹ã®ãã¼ããåä¸ãªã³ã¯ã«ããããã§ãã¯ããã
+ */
+
+bool_t
+nd6_is_addr_neighbor (T_IFNET *ifp, const T_IN6_ADDR *addr)
+{
+	if (IN6_IS_ADDR_LINKLOCAL(addr))
+		return true;
+
+	if (nd6_onlink_prefix_lookup(addr) != NULL)
+		return true;
+
+	if (nd6_lookup(addr, false) != NULL)
+		return true;
+
+	return false;
+	}
+
+/*
+ *  nd6_output -- è¿é£æ¢ç´¢ã®åºåé¢æ°
+ *
+ *    æ³¨æ: ã»ããã© SEM_ND6_CACHE ã«ããã­ãã¯ç¶æ
+ã§å¼åºããã¨ã
+ */
+
+ER
+nd6_output (T_IFNET *ifp, T_NET_BUF *output, const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout)
+{
+	ER	error = E_OK;
+	SYSTIM	now;
+
+	/*
+	 *  ãã¦å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ãããè¿é£ã­ã£ãã·ã¥ã
+	 *  ä¸è¦ã®å ´åã¯ç´ã¡ã«éä¿¡ããã
+	 */
+	if (!(IN6_IS_ADDR_MULTICAST(dst) || !IF_IN6_NEED_CACHE(ifp))) {
+		if (ln == NULL) {
+			/* è¿é£ã­ã£ãã·ã¥ãæªå®ç¾©ã®å ´å */
+			if (nd6_is_addr_neighbor(ifp, dst)) {
+				/*
+				 *  æå®ãããã¢ãã¬ã¹ã®ãã¼ããåä¸ãªã³ã¯ã«ããæã¯ã
+				 *  è¿é£ã­ã£ãã·ã¥ãæ¢ç´¢ããæªå®ç¾©ã®å ´åã¯ç»é²ããã
+				 */
+				ln = nd6_lookup(dst, true);
+				}
+			else {
+				error = E_CLS;
+				goto err_ret;
+				}
+			}
+
+		/*
+		 *  è¿é£ã­ã£ãã·ã¥ã®ç¶æ
+ãããã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ãåãã£ã¦ãã¦ãã
+		 *  å°éå¯è½æ§ãç¢ºèªããã¦ããªãã¨ãã¯ãå°éä¸è½éç¥ãéå§ããã
+		 */
+		if (ln->state == ND6_LLINFO_STALE) {
+			syscall(get_tim(&now));
+			ln->expire = now + ND6_DELAY_TIME;
+			ln->asked = 0;
+			ln->state = ND6_LLINFO_DELAY;
+			}
+
+		/*
+		 *  è¿é£ã­ã£ãã·ã¥ã®ç¶æ
+ãããã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹æªè§£æ±ºã®å ´åã¯
+		 *  è¿é£æ¢ç´¢ãè¡ãã
+		 */
+		if (ln->state <= ND6_LLINFO_INCOMPLETE) {
+
+			/* ã¿ã¤ã ã¢ã¦ãã®æå®ããã¼ãªã³ã°ãªãã¿ã¤ã ã¢ã¦ãã§çµäºããã*/
+			if (tmout == TMO_POL) {
+				error = E_TMOUT;
+				goto err_ret;
+				}
+
+			if (ln->state == ND6_LLINFO_NO_STATE)
+				ln->state = ND6_LLINFO_INCOMPLETE;
+
+			/* ãã§ã«ãæªè§£æ±ºã®ãããã¯ã¼ã¯ãããã¡ãããã°ãéæ¾ããã*/
+			if (ln->hold != NULL) {
+				syscall(rel_net_buf(ln->hold));
+				}
+
+			/*
+			 *  éä¿¡ããã³ãã£ã³ã°ããã
+			 *  IF ã§ãããã¯ã¼ã¯ãããã¡ãéæ¾ããªããã©ã°ãè¨­å®ããã¦ããã¨ãã¯ã
+			 *  éä¿¡ããã³ãã£ã³ã°ããªãã
+			 */
+			if ((output->flags & NB_FLG_NOREL_IFOUT) == 0) {
+				ln->hold = output;
+
+				/* ã¿ã¤ã ã¢ã¦ãã®è¨­å® */
+				if (tmout == TMO_FEVR)
+					ln->tmout = tmout;
+				else {
+					syscall(get_tim(&now));
+					ln->tmout = now + tmout;
+					}
+				}
+			else {
+				output->flags &= ~NB_FLG_NOREL_IFOUT;
+				syscall(get_tim(&now));
+				ln->tmout = now + tmout;
+				}
+
+			if (ln->expire) {
+				if (ln->asked < ND6_MAX_MCAST_QUERY) {
+					syscall(get_tim(&now));
+					if ((int32_t)(ln->expire - now) < 0) {
+					           /* ln->expire < now */
+						ln->expire += ND6_RETRANS_TIME;	/* è¿é£æ¢ç´¢éä¿¡éé */
+						ln->asked ++;
+						nd6_ns_output(ifp, &in6_addr_unspecified, dst, ln, false);
+						}
+					}
+				}
+			return error;
+			}
+		}
+
+	/*
+	 *  éè¤ãæ¤åºãããã¤ã³ã¿ãã§ã¼ã¹ã«ã¯åºåããªãã
+	 */
+	if ((ifp->flags & ND6_IFF_IFDISABLED) != 0) {
+		return E_OK;
+		}
+
+	IF_SET_PROTO(output, IF_PROTO_IPV6);
+	error = IF_OUTPUT(output, dst, ln ? & ln->ifaddr : NULL, tmout);
+	return error;
+
+err_ret:
+	syscall(rel_net_buf(output));
+	return error;
+	}
+
+/*
+ *  nd6_storelladdr -- åºåãããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ãè¿ãã
+ */
+
+ER
+nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa)
+{
+	if (IN6_IS_ADDR_MULTICAST(dst)) {
+		IF_IN6_RESOLVE_MULTICAST(out, dst);
+		}
+	else {
+		*out = *ifa;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  nd6_option -- è¿é£æ¢ç´¢ãªãã·ã§ã³ã®å¦ç
+ *
+ *    æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã
+ */
+
+ER
+nd6_options (uint8_t *opt, void *nh, uint_t len)
+{
+	T_ND_OPT_HDR	*opth;
+	ER		error = E_OK;
+	int_t		pi_count = 0;	/* ãã¬ãã£ãã¯ã¹æ
+å ±ã®åæ° */
+
+	opth = (T_ND_OPT_HDR *)nh;
+	memset(opt, 0, ND_OPT_OFF_ARRAY_SIZE);
+
+	while (error == E_OK && ((uint8_t *)opth - (uint8_t *)nh) < (256 - 8) && len > 0) {
+
+		/* ãªãã·ã§ã³é·ã 0 ã®æã¯ãä¸æ­£ãªãªãã·ã§ã³ã¨ãã¦å¦çããã*/
+		if (opth->len == 0) {
+			error = E_PAR;
+			break;
+			}
+
+		/* ãªãã·ã§ã³ã®ã¿ã¤ãã«ããåå²ããã*/
+		switch (opth->type) {
+		case ND_OPT_SOURCE_LINKADDR:		/* éä¿¡å
+ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+		case ND_OPT_TARGET_LINKADDR:		/* å¯¾è±¡ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹	*/
+		case ND_OPT_REDIRECTED_HEADER:		/* ãªãã¤ã¬ã¯ãã»ããã				*/
+		case ND_OPT_MTU:			/* MTU						*/
+			if (opt[ND_OPT_OFF_ARRAY_IX(opth->type)]) {
+				/* ãã¬ãã£ãã¯ã¹æ
+å ±ä»¥å¤ã®åããªãã·ã§ã³ãè¤æ°æå®ããã¦ããã*/
+				error = E_PAR;
+				}
+			else {
+				opt[ND_OPT_OFF_ARRAY_IX(opth->type)] = (uint8_t *)opth - (uint8_t *)nh + 8;
+				}
+			break;
+		case ND_OPT_PREFIX_INFORMATION:		/* ãã¬ãã£ãã¯ã¹æ
+å ±				*/
+			if (!opt[ND_OPT_OFF_ARRAY_IX(ND_OPT_PREFIX_INFORMATION)]) {
+				/*
+				 *  ãã¬ãã£ãã¯ã¹æ
+å ±ã¯æåã«ç¾ãããªãã»ããã®ã¿è¨é²ããã
+				 */
+				opt[ND_OPT_OFF_ARRAY_IX(opth->type)] = (uint8_t *)opth - (uint8_t *)nh + 8;
+				}
+			pi_count ++;
+			break;
+		default:
+			/*
+			 *  å°æ¥å®ç¾©ããããã­ãã³ã«ã¸ã®æ¡å¼µã«å¯¾å¿ããããã
+			 *  èªè­ã§ããªããªãã·ã§ã³ã¯åã«ç¡è¦ããå¦çãç¶è¡ããã
+			 */
+			break;
+			}
+		len -= opth->len << 3;		/* ãªãã·ã§ã³é·ã®åä½ã¯ 8 ãã¤ã */
+		opth = (T_ND_OPT_HDR *)((uint8_t *)opth + (opth->len << 3));
+		}
+
+	opt[ND_OPT_OFF_ARRAY_IX(ND_OPT_PREFIX_INFO_COUNT)] = pi_count;
+	return error;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/nd6.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/nd6.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/nd6.h	(revision 317)
@@ -0,0 +1,297 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/nd6.h,v 1.10 2002/04/19 04:46:23 suz Exp $	*/
+/*	$KAME: nd6.h,v 1.76 2001/12/18 02:10:31 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+ 
+#ifndef _ND6_H_
+#define _ND6_H_
+
+/*
+ *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹æ§é ä½ï¼T_IFNETï¼ã®ãã©ã°
+ */
+
+#define ND6_IFF_IFDISABLED	UINT_C(0x01)	/* ã¤ã³ã¿ãã§ã¼ã¹ãç¡å¹ã«ããã*/
+
+/*
+ *  è¿é£ã­ã£ãã·ã¥ 
+ */
+
+typedef struct t_llinfo_nd6 {
+	T_IN6_ADDR	addr;
+	T_NET_BUF	*hold;
+	TMO		tmout;
+	SYSTIM		expire;		/* [ms] æå¹æéãåããæå»	*/
+	T_IF_ADDR	ifaddr;
+	uint8_t		state;
+	uint8_t		asked;
+	uint8_t		flags;
+	} T_LLINFO_ND6;
+
+/* è¿é£ã­ã£ãã·ã¥ã®ç¶æ
+ */
+
+#define ND6_LLINFO_FREE			0	/* æªä½¿ç¨		*/
+#define ND6_LLINFO_NO_STATE		1	/* ç¶æ
+æªå®ç¾©		*/
+#define ND6_LLINFO_INCOMPLETE		2	/* æªè§£æ±º		*/
+#define ND6_LLINFO_REACHABLE		3	/* å°éå¯è½		*/
+#define ND6_LLINFO_STALE		4	/* å°éå¯è½æ§ã¯æªç¢ºèª	*/
+#define ND6_LLINFO_DELAY		5	/* å°éå¯è½æ§ã®ç¢ºèªå¾
+æ©	*/
+#define ND6_LLINFO_PROBE		6	/* å°éå¯è½æ§ãç¢ºèªä¸­	*/
+
+#define ND6_IS_LLINFO_PROBREACH(n)	((n)->state > ND6_LLINFO_INCOMPLETE)
+
+/* è¿é£ã­ã£ãã·ã¥ã®å¶å¾¡ããã */
+
+#define ND6_LLIF_ROUTER			UINT_C(0x80)	/* ã«ã¼ã¿		*/
+#define ND6_LLIF_ASKED			UINT_C(0x40)	/* éç¥æ¸ã¿		*/
+#define ND6_LLIF_STATE_MASK		UINT_C(0x07)	/* ç¶æ
+ãã¹ã¯		*/
+
+/* è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãæå¹æéã®å®ç¾© */
+
+#define ND6_SLOW_TMO			((60*60)/NET_TIMER_HZ)
+							/* 1 [æé]				*/
+							/* è¿é£æ¢ç´¢ã­ã£ãã·ã¥æ´æ°ã¿ã¤ã ã¢ã¦ã	*/
+
+#define ND6_MAX_DAD_TRY			15		/* éè¤ã¢ãã¬ã¹æ¤åºã®åéåæ°		*/
+#define ND6_MAX_MCAST_QUERY		3		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹è¦è«ã®åéåæ°	*/
+#define ND6_MAX_UCAST_QUERY		3		/* ã¦ãã­ã£ã¹ãã¢ãã¬ã¹è¦è«ã®åéåæ°	*/
+
+#define ND6_GCOLLECTION_TIME		(60*60*24*SYSTIM_HZ)
+							/* ã´ãæ¾ãå¨æã1 æ¥			*/
+#define	ND6_DELAY_TIME			(5*SYSTIM_HZ)	/* ç¢ºèªå¾
+æ©é
+å»¶				*/
+#define ND6_FIRST_DAD_DELAY_TIME	(1*SYSTIM_HZ)	/* æåã®éè¤ã¢ãã¬ã¹æ¤åºéä¿¡é
+å»¶	*/
+#define ND6_DAD_DELAY_TIME		(5*SYSTIM_HZ/10)
+							/* éè¤ã¢ãã¬ã¹æ¤åºéä¿¡é
+å»¶		*/
+
+/* è¿é£æ¢ç´¢ç¨ã¿ã¤ãã®è¨­å® */
+
+#define ND6_TIMER_TMO			((SYSTIM_HZ/NET_TIMER_CYCLE)/5)	/* 0.2[s] éé		*/
+
+/*
+ *  å°éå¯è½ç¶æ
+ã®æå¹æé
+ */
+
+#define	ND6_DEF_REACHABLE_TIME		(30*SYSTIM_HZ)	/* å°éå¯è½ç¶æ
+ã®æå¹æéã®æ¢å®å¤		*/
+#define	ND6_MAX_REACHABLE_TIME		(60*60*SYSTIM_HZ)
+							/* å°éå¯è½ç¶æ
+ã®æå¹æéã®æ¢å®å¤		*/
+#define	ND6_RECALC_REACHTM_INTERVAL	(60*60*2*SYSTIM_HZ)
+							/* å°éå¯è½ç¶æ
+ã®æå¹æéåè¨ç®éé	*/
+
+#define	ND6_MIN_REACHTM_RAND_FACTOR	512		/* æå°ä¹±æ°è£æ­£å¤ã1,024 * 0.5		*/
+
+#if 1							/* ã¿ã¤ãã¼ã®èµ·åééãèæ
+®ããè¦å®ããç­ãè¨­å®	*/
+#define	ND6_MAX_REACHTM_RAND_FACTOR	1484		/* æå°ä¹±æ°è£æ­£å¤ã1,024 * 1.45			*/
+#else
+#define	ND6_MAX_REACHTM_RAND_FACTOR	1536		/* æå°ä¹±æ°è£æ­£å¤ã1,024 * 1.5			*/
+#endif
+
+/* å°éå¯è½ç¶æ
+ã®æå¹æéã®è¨ç®ãã¯ã­ */
+
+#define ND6_CALC_REACH_TIME(b)		\
+	 ((ND6_MIN_REACHTM_RAND_FACTOR * ((uint32_t)(b) >> 10)) + \
+	  (net_rand() & ((ND6_MAX_REACHTM_RAND_FACTOR - ND6_MIN_REACHTM_RAND_FACTOR) * ((uint32_t)(b) >> 10))))
+
+/*
+ *  è¿é£æ¢ç´¢ã®éä¿¡éé
+ */
+
+#define ND6_DEF_RETRANS_TIME		(1*SYSTIM_HZ)
+
+/*
+ *  ã«ã¼ã¿éç¥ã«ããå¤æ´ããããã¨ãããå¤
+ */
+
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+/* ã«ã¼ã¿éç¥ãåä¿¡ããå ´åã¯ãéç¥ãããå¤ */
+
+#define	ND6_REACHABLE_TIME		nd6_reachable_time
+#define ND6_RETRANS_TIME		nd6_retrans_time
+
+#else	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/* ã«ã¼ã¿éç¥ãåä¿¡ããªãå ´åã®å¤ã¯æ¢å®å¤ */
+
+#define	ND6_REACHABLE_TIME		ND6_DEF_REACHABLE_TIME
+#define ND6_RETRANS_TIME		ND6_DEF_RETRANS_TIME
+
+#endif	/* #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/*
+ *  ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ã
+ */
+
+typedef struct t_def_router {
+	T_IN6_ADDR	addr;
+	SYSTIM		expire;		/* [ms] æå¹æéãåããæå»	*/
+	uint32_t	lifetime;	/* [ms] æå¹æé			*/
+	uint16_t	plistmap;	/* ãã¬ãã£ãã¯ã¹ããã		*/
+	uint8_t		flags;		/* ã«ã¼ã¿éç¥ã®ãã©ã°		*/
+	uint8_t		state;
+	} T_DEF_ROUTER;
+
+/* ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãã®ç¶æ
+ */
+
+#define ND6_DEF_RTR_BUSY		0xff	/* ä½¿ç¨ä¸­		*/
+
+/* ãã¬ãã£ãã¯ã¹ã®ã¤ã³ããã¯ã¹ */
+
+#define ND6_PREFIX_IX_INVALID		0xff
+
+/*
+ *  ãã¬ãã£ãã¯ã¹ã»ãªã¹ã
+ */
+
+typedef struct t_nd6_prefix {
+	T_IN6_ADDR	prefix;		/* ãã¬ãã£ãã¯ã¹		*/
+	uint32_t	expire;		/* [s] æå¹æéãåããæå»	*/
+	uint32_t	preferred;	/* [s] æ¨å¥¨æå¹æéãåããæå»	*/
+	uint32_t	vltime;		/* [s] æå¹æé			*/
+	uint32_t	pltime;		/* [s] æ¨å¥¨æå¹æé		*/
+	uint16_t	routermap;	/* ã«ã¼ã¿ããã			*/
+	uint8_t		flags;		/* ãã©ã°			*/
+	uint8_t		prefix_len;	/* ãã¬ãã£ãã¯ã¹é·		*/
+	} T_ND6_PREFIX;
+
+/* ãã©ã° */
+
+#define ND6_PREFIX_FLAG_ONLINK		UINT_C(0x80)	/* ãªã³ãªã³ã¯ãã¬ãã£ãã¯ã¹	*/
+#define ND6_PREFIX_FLAG_AUTO		UINT_C(0x40)	/* ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®*/
+
+#define ND6_PREFIX_STATE_BUSY		UINT_C(0x01)	/* ä½¿ç¨ä¸­		*/
+#define ND6_PREFIX_STATE_ONLINK		UINT_C(0x02)	/* ãªã³ãªã³ã¯ç¶æ
+	*/
+#define ND6_PREFIX_STATE_DETACHED	UINT_C(0x04)	/* éä½¿ç¨ç¶æ
+	*/
+
+/*
+ *  å¤æ°
+ */
+
+extern SYSTIM	nd6_base_reachable_time;
+extern SYSTIM	nd6_reachable_time;
+extern SYSTIM	nd6_recalc_reachtm_interval;
+extern SYSTIM	nd6_retrans_time;
+
+/*
+ *  é¢æ°
+ */
+
+extern void nd6_ifattach (T_IFNET *ifp);
+extern void nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad);
+extern void nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+                           const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr);
+extern void nd6_dad_start (T_IFNET *ifp, T_IN6_IFADDR *ia, int_t *tick);
+extern ER nd6_output (T_IFNET *ifp, T_NET_BUF *output,
+                      const T_IN6_ADDR *dst, T_LLINFO_ND6 *ln, TMO tmout);
+extern void nd6_na_input (T_NET_BUF *input, uint_t off);
+extern void nd6_ns_input (T_NET_BUF *input, uint_t off);
+extern void nd6_ra_input (T_NET_BUF *input, uint_t off);
+extern ER nd6_storelladdr (T_IF_ADDR *out, const T_IN6_ADDR *dst, T_IF_ADDR *ifa);
+extern ER nd6_options (uint8_t *opt, void *nh, uint_t len);
+extern T_LLINFO_ND6 *nd6_lookup (const T_IN6_ADDR *addr, bool_t create);
+extern ER nd6_output_hold (T_IFNET *ifp, T_LLINFO_ND6 *ln);
+extern T_LLINFO_ND6 *nd6_cache_lladdr (T_IFNET *ifp, const T_IN6_ADDR *from, 
+                                       T_IF_ADDR *lladdr, uint8_t type, uint8_t code);
+extern void nd6_defrtrlist_timer (void);
+extern void nd6_prelist_timer (void);
+extern void nd6_rtrsol_ctl (void);
+extern const T_IN6_ADDR *nd6_router_lookup (void);
+extern T_DEF_ROUTER *nd6_defrtrlist_lookup (const T_IN6_ADDR *src);
+extern void nd6_defrtrlist_del (T_DEF_ROUTER *dr);
+extern void nd6_timer (void);
+extern const T_DEF_ROUTER *nd6_get_drl (uint_t *count);
+extern const T_ND6_PREFIX *nd6_get_prl (void);
+extern const T_LLINFO_ND6 *nd6_get_cache (void);
+extern ER nd6_prefix_onlink (T_ND6_PREFIX *pr);
+extern ER nd6_prefix_offlink (T_ND6_PREFIX *pr);
+extern T_ND6_PREFIX *nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst);
+
+#endif	/* of #ifndef _ND6_H_ */
Index: asp3_gr_sakura/trunk/tinet/netinet6/nd6_nbr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/nd6_nbr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/nd6_nbr.c	(revision 317)
@@ -0,0 +1,891 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/nd6_nbr.c,v 1.13 2002/10/16 01:54:45 sam Exp $	*/
+/*	$KAME: nd6_nbr.c,v 1.86 2002/01/21 02:33:04 jinmei Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
+#include <netinet6/nd6.h>
+
+#include <net/if6_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  å±æé¢æ°
+ */
+
+static void nd6_dad_timer (T_IN6_IFADDR *ifa);
+static void nd6_dad_duplicated (T_IFNET *ifp, T_IN6_IFADDR *ifa);
+static void nd6_dad_ns_output (T_IFNET *ifp, T_IN6_IFADDR *ifa);
+static void nd6_dad_ns_input (T_IFNET *ifp, T_IN6_IFADDR *ifa);
+static void nd6_dad_na_input (T_IFNET *ifp, T_IN6_IFADDR *ifa);
+
+/*
+ *  nd6_dad_duplicated -- éè¤ã¢ãã¬ã¹ãæ¤åºããæã®å¦ç
+ */
+
+static void
+nd6_dad_duplicated (T_IFNET *ifp, T_IN6_IFADDR *ifa)
+{
+	if ((ifa->flags & IN6_IFF_TENTATIVE) == 0)
+		syslog(LOG_ERROR, "[ND6 DAD DUP] no pending.");
+	else {
+		syslog(LOG_ERROR, "[ND6 DAD DUP] dup IPv6 addr: %s.", ipv62str(NULL, &ifa->addr));
+		ifa->flags &= ~IN6_IFF_TENTATIVE;
+		ifa->flags |=  IN6_IFF_DUPLICATED;
+
+		/* ã¿ã¤ãã¼ãåæ­¢ããã*/
+		untimeout((callout_func)nd6_dad_timer, ifa);
+
+		/*
+		 *  ãã IPv6 ã¢ãã¬ã¹ããã¦ãã¼ã¯ã«å²ãå½ã¦ãã
+		 * ï¼ã¤ã¼ãµãããç¨ã® EUI-64ï¼ãã¼ãã¦ã§ã¢ã¢ãã¬ã¹ããã¼ã¹ã¨ãã
+		 *  ã¤ã³ã¿ãã§ã¼ã¹ ID ã§çæãããã®ã§ããã°ã
+		 *  ãã®ã¤ã³ã¿ãã§ã¼ã¹ã§ã® IPv6 ã®åä½ã¯ç¡å¹ã«ãã¹ãã§ãã
+		 * ï¼RFC2462bis-03 ã»ã¯ã·ã§ã³ 5.4.5ï¼ã
+		 */
+		if (IN6_IS_ADDR_LINKLOCAL(&ifa->addr))
+			ifp->flags |= ND6_IFF_IFDISABLED;
+		}
+	}
+
+/*
+ *  nd6_dad_ns_output -- éè¤ã¢ãã¬ã¹æ¤åº (DAD) è¦è«ãåºåããã
+ */
+
+static void
+nd6_dad_ns_output (T_IFNET *ifp, T_IN6_IFADDR *ifa)
+{
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_DAD_OUT_PACKETS], 1);
+
+	ifa->ns_ocount ++;
+	nd6_ns_output(ifp, &in6_addr_unspecified, &ifa->addr, NULL, true);
+	}
+
+/*
+ *  nd6_dad_ns_input -- éè¤ã¢ãã¬ã¹æ¤åº (DAD) è¦è«å
+¥å
+ */
+
+static void
+nd6_dad_ns_input (T_IFNET *ifp, T_IN6_IFADDR *ifa)
+{
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NS_IN_PACKETS], 1);
+
+	/*
+	 *  ã¾ã ãéè¤ã¢ãã¬ã¹æ¤åºè¦è«ãåºåãã¦ããªãå ´å
+	 */
+	if (ifa->ns_ocount == 0)
+		nd6_dad_duplicated(ifp, ifa);
+	else
+		ifa->ns_icount ++;
+	}
+
+/*
+ *  nd6_dad_na_input -- éè¤ã¢ãã¬ã¹æ¤åº (DAD) éç¥å
+¥å
+ */
+
+static void
+nd6_dad_na_input (T_IFNET *ifp, T_IN6_IFADDR *ifa)
+{
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NA_IN_PACKETS], 1);
+	ifa->na_icount ++;
+	nd6_dad_duplicated(ifp, ifa);
+	}
+
+/*
+ *  nd6_dad_timer -- éè¤ã¢ãã¬ã¹æ¤åº (DAD) ã¿ã¤ãã¼
+ */
+
+static void
+nd6_dad_timer (T_IN6_IFADDR *ifa)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if (ifa->flags & IN6_IFF_DUPLICATED) {
+		syslog(LOG_ERROR, "[ND6 DAD] dup IPv6 addr: %s.", ipv62str(NULL, &ifa->addr));
+		return;
+		}
+
+	if ((ifa->flags & IN6_IFF_TENTATIVE) == 0) {
+		syslog(LOG_ERROR, "[ND6 DAD] no tentative IPv6 addr: %s.", ipv62str(NULL, &ifa->addr));
+		return;
+		}
+
+	if (ifa->ns_ocount < NUM_IP6_DAD_COUNT) {
+		nd6_dad_ns_output(ifp, ifa);
+
+		/* ã¿ã¤ã ã¢ã¦ããè¿é£æ¢ç´¢ã®éä¿¡ééã«è¨­å®ããã*/
+		timeout((callout_func)nd6_dad_timer, ifa, ND6_RETRANS_TIME * NET_TIMER_HZ / SYSTIM_HZ);
+		}
+	else if (ifa->na_icount || ifa->ns_icount)
+		nd6_dad_duplicated(ifp, ifa);
+	else {
+		ifa->flags &= ~IN6_IFF_TENTATIVE;
+		syslog(LOG_NOTICE, "[ND6 DAD] no dup IPv6 addr: %s.", ipv62str(NULL, &ifa->addr));
+		}
+	}
+
+/*
+ *  nd6_ns_input -- è¿é£è¦è«ã®å
+¥åå¦çã
+ */
+
+void
+nd6_ns_input (T_NET_BUF *input, uint_t off)
+{
+	T_IFNET			*ifp = IF_GET_IFNET();
+	T_IP6_HDR		*ip6h;
+	T_NEIGHBOR_SOLICIT_HDR	*nsh;
+	T_ND_OPT_HDR		*opth;
+	T_IN6_IFADDR		*ifa;
+	bool_t			tlladdr;
+	uint_t			lladdr_len = 0;
+	uint32_t		flags;
+	uint8_t			*lladdr = NULL;
+	uint8_t			nd_opt_off[ND_OPT_OFF_ARRAY_SIZE];
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NS_IN_PACKETS], 1);
+
+	ip6h = GET_IP6_HDR(input);
+
+	/*
+	 *  ãããã®ãã§ãã¯ãä»¥ä¸ã®å ´åã¯ç ´æ£ããã
+	 *    ã»ããããªãããã IPV6_MAXHLIM (255) ä»¥å¤
+	 *    ã»ãããé·ãç­ã
+	 */
+	if (ip6h->hlim != IPV6_MAXHLIM || input->len - off < NEIGHBOR_SOLICIT_HDR_SIZE)
+		goto err_ret;
+
+	nsh  = (T_NEIGHBOR_SOLICIT_HDR *)(input->buf + off);
+
+	if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src)) {
+		/*
+		 *  å§ç¹ã¢ãã¬ã¹ãç¡æå®ãªããéè¤ã¢ãã¬ã¹æ¤åº
+		 *  ãã¦å
+ã¢ãã¬ã¹ã¯ãè¦è«ãã«ãã­ã£ã¹ãã§ãªããã°ãªããªãã
+		 */
+		if (!IN6_IS_ADDR_NS_MULTICAST(&ip6h->dst))
+			goto err_ret;
+		}
+
+	/* ç®çã¢ãã¬ã¹ããã«ãã­ã£ã¹ããªãã¨ã©ã¼ */
+	if (IN6_IS_ADDR_MULTICAST(&nsh->target))
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã®ãªãã»ãããè¨é²ããã*/
+	if (nd6_options(nd_opt_off, input->buf + (off + NEIGHBOR_SOLICIT_HDR_SIZE),
+	                            input->len - (off + NEIGHBOR_SOLICIT_HDR_SIZE)) != E_OK)
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ (å§ç¹ãªã³ã¯ã¢ãã¬ã¹) */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_SOURCE_LINKADDR)]) {
+		opth = (T_ND_OPT_HDR *)((uint8_t *)(input->buf + off + NEIGHBOR_SOLICIT_HDR_SIZE) +
+		                        nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_SOURCE_LINKADDR)] - 8);
+	 	/* æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã*/
+		lladdr     = (uint8_t *)(opth + 1);
+		lladdr_len = (opth->len << 3);
+		}
+
+	if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src) && lladdr != NULL)
+		goto err_ret;
+
+	/* å®å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ããªãè¿é£éç¥ã«ãã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ãä»ããã*/
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst))
+		tlladdr = true;
+	else
+		tlladdr = false;
+
+	/*
+	 *  ç®çã¢ãã¬ã¹ããèªåã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«
+	 *  å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ãèª¿ã¹ãã
+	 *  ãªããä»£çãµã¼ãã¹ã¯å®è£
+ãã¦ããªãã
+	 */
+	ifa = in6_lookup_ifaddr(ifp, &nsh->target);
+
+	if (ifa == NULL)
+		goto free_ret;
+
+	/* æ¢ç´¢çµæã¢ãã¬ã¹ãéè¤ãã¦ããã°å¿ç­ããªãã§çµäºããã*/
+	if (ifa->flags & IN6_IFF_DUPLICATED)
+		goto err_ret;
+
+	/*
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹é·ãä¸è´ããªããã°ã¨ã©ã¼
+	 */
+	if (lladdr && lladdr_len != ((sizeof(T_IF_ADDR) + sizeof(T_ND_OPT_HDR) + 7) & ~7))
+		goto err_ret;
+
+	/*
+	 *  å§ç¹ã¢ãã¬ã¹ãèªåã®ã¢ãã¬ã¹ã¨ä¸è´ããã°éè¤ãã¦ããã
+	 */
+	if (IN6_ARE_ADDR_EQUAL(&ifa->addr, &ip6h->src))
+		goto free_ret;
+
+	/* éè¤æ¤åºä¸­ã«ãè¿é£è¦è«ãåä¿¡ããã¨ãã®å¦ç */
+	if (ifa->flags & IN6_IFF_TENTATIVE) {
+		if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src))
+			nd6_dad_ns_input(ifp, ifa);
+		goto free_ret;
+		}
+
+	if ((ifa->flags & IN6_IFF_ANYCAST) || !tlladdr)
+		flags = 0;
+	else
+		flags = ND_NA_FLG_OVERRIDE;
+
+	/*
+	 *  å§ç¹ã¢ãã¬ã¹ãç¡æå®ãªããéä¿¡ç¸æã¯éè¤ã¢ãã¬ã¹æ¤åºä¸­ã§ã
+	 *  ç´æ¥éä¿¡ãããã¨ã¯ã§ããªãã®ã§ãå
+¨ãã¼ããã«ãã­ã£ã¹ã
+	 *  ã¢ãã¬ã¹ã«éä¿¡ããã
+	 */
+	if (IN6_IS_ADDR_UNSPECIFIED(&ip6h->src)) {
+		nd6_na_output(ifp, &in6_addr_linklocal_allnodes, &nsh->target, flags, tlladdr);
+		goto free_ret;
+		}
+
+	/* è¿é£ã­ã£ãã·ã¥ã«ç»é²ããã*/
+	nd6_cache_lladdr(ifp, &ip6h->src, (T_IF_ADDR *)lladdr, ND_NEIGHBOR_SOLICIT, 0);
+
+	nd6_na_output(ifp, &ip6h->src, &nsh->target, flags | ND_NA_FLG_SOLICITED, tlladdr);
+
+free_ret:
+	syscall(rel_net_buf(input));
+	return;
+
+err_ret:
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  nd6_ns_output -- è¿é£è¦è«ãåºåããã
+ */
+
+void
+nd6_ns_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, T_LLINFO_ND6 *ln, bool_t dad)
+{
+	T_NEIGHBOR_SOLICIT_HDR	*nsh;
+	T_NET_BUF		*output;
+	T_IP6_HDR		*ip6h;
+	T_IF_ADDR		*mac = NULL;
+	uint_t			len;
+	uint16_t		ipflags = 0;
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NS_OUT_PACKETS], 1);
+
+	if (IN6_IS_ADDR_MULTICAST(taddr))
+		return;
+
+	/* è¿é£è¦è«ãã¤ã­ã¼ãé·ãè¨ç®ããã*/
+	if (!dad && IF_SOFTC_TO_IFADDR(ifp->ic))
+		len = (NEIGHBOR_SOLICIT_HDR_SIZE + ND_OPT_HDR_SIZE + sizeof(T_IF_ADDR) + 7) >> 3 << 3;
+	else
+		len = (NEIGHBOR_SOLICIT_HDR_SIZE + 7) >> 3 << 3;
+
+	/*
+	 *  è¦è«ãã«ãã­ã£ã¹ãã»ã¢ãã¬ã¹å®ã®è¿é£æ¢ç´¢ã§ã¯ã
+	 *  ä»ã®ãªã³ã¯ããã®å½é ããããã¼ã¿ã°ã©ã ã
+	 *  æé¤ãããããããããªãããã« IPV6_MAXHLIM (255) ãè¨­å®ããã
+	 */
+	if (IN6_IS_ADDR_UNSPECIFIED(daddr) || IN6_IS_ADDR_MULTICAST(daddr))
+		ipflags = IPV6_OUT_SET_HOP_LIMIT(IPV6_OUT_FLG_HOP_LIMIT, IPV6_MAXHLIM);
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããIPv6 ããããè¨­å®ããã*/
+	if (in6_get_datagram(&output, len, 0, daddr, NULL,
+	                     IPPROTO_ICMPV6, IPV6_MAXHLIM,
+	                     NBA_SEARCH_ASCENT, TMO_ND6_NS_OUTPUT) != E_OK)
+		return;
+
+	ip6h = GET_IP6_HDR(output);
+
+	if (IN6_IS_ADDR_UNSPECIFIED(daddr)) {
+
+		/* å®å
+ã¢ãã¬ã¹ãç¡æå®ã®å ´åã¯ãè¦è«ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãè¨­å®ããã*/
+		ip6h->dst.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
+		ip6h->dst.s6_addr32[2] = IPV6_ADDR_INT32_ONE;
+		ip6h->dst.s6_addr32[3] = taddr->s6_addr32[3];
+		ip6h->dst.s6_addr8[12] = 0xff;
+		}
+
+	/* éä¿¡å
+ã¢ãã¬ã¹ã®è¨­å® */
+	if (!dad) {
+
+		/* éè¤ã¢ãã¬ã¹æ¤åºã§ã¯ãªãæã®éä¿¡å
+ã¢ãã¬ã¹æ±ºå®å¦çã*/
+		T_IN6_ADDR *saddr;
+
+		if (ln && ln->hold) {
+			/*
+			 * éä¿¡ããã³ãã£ã³ã°ããã¦ãããã¼ã¿ã°ã©ã ã®
+			 * éä¿¡å
+ã¢ãã¬ã¹ãå©ç¨ããã
+			 */
+			if (ln->hold->len > IF_IP6_HDR_SIZE)
+				saddr = &GET_IP6_HDR(ln->hold)->src;
+			else
+				saddr = NULL;
+			}
+		else
+			saddr = NULL;
+
+		if (saddr && in6_lookup_ifaddr(ifp, saddr))
+			ip6h->src = *saddr;
+		else {
+			/*
+			 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+			 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+			 */
+			T_IN6_IFADDR *ifa;
+
+			if ((ifa = in6_ifawithifp(ifp, &ip6h->dst)) == NULL) {
+				syscall(rel_net_buf(output));
+				return;
+				}
+			ip6h->src = ifa->addr;
+			}
+		}
+	else {
+
+		/* éè¤ã¢ãã¬ã¹æ¤åºæã®éä¿¡å
+ã¢ãã¬ã¹ã¯ç¡æå®ã*/
+		memset(&ip6h->src, 0, sizeof(T_IN6_ADDR));
+		}
+
+ 	/* è¿é£è¦è«ããããè¨­å®ããã*/
+ 	nsh = GET_NEIGHBOR_SOLICIT_HDR(output, IF_IP6_NEIGHBOR_SOLICIT_HDR_OFFSET);
+ 	nsh->hdr.type        = ND_NEIGHBOR_SOLICIT;
+ 	nsh->hdr.code        = 0;
+ 	nsh->hdr.data.data32 = 0;
+ 	nsh->target          = *taddr;
+
+	if (!dad && (mac = IF_SOFTC_TO_IFADDR(ifp->ic)) != NULL) {
+
+		/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã¨ãã¦ãæ¢ç´¢ç®æ¨ã® MAC ã¢ãã¬ã¹ãè¨­å®ããã*/
+		T_ND_OPT_HDR	*opth;
+		uint_t		optlen;
+
+		opth   = (T_ND_OPT_HDR *)GET_NEIGHBOR_SOLICIT_SDU(output, IF_IP6_NEIGHBOR_SOLICIT_HDR_OFFSET);
+		optlen = (ND_OPT_HDR_SIZE + sizeof(T_IF_ADDR) + 7) >> 3 << 3;
+		memset(opth, 0, optlen);
+		opth->type = ND_OPT_SOURCE_LINKADDR;
+		opth->len  = optlen >> 3;
+		memcpy((uint8_t *)opth + sizeof(T_ND_OPT_HDR), mac, sizeof(T_IF_ADDR));
+		}
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	nsh->hdr.sum = 0;
+	nsh->hdr.sum = in6_cksum(output, IPPROTO_ICMPV6, (uint8_t*)nsh - output->buf, len);
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_OCTETS],
+	               output->len - GET_IF_IP6_HDR_SIZE(output));
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutNeighborSolicits, 1);
+	ip6_output(output, ipflags | IPV6_OUT_FLG_DAD, TMO_ND6_NS_OUTPUT);
+	}
+
+/*
+ *  nd6_na_input -- è¿é£éç¥ã®å
+¥åå¦çã
+ */
+
+void
+nd6_na_input (T_NET_BUF *input, uint_t off)
+{
+	T_IFNET			*ifp = IF_GET_IFNET();
+	T_IP6_HDR		*ip6h;
+	T_NEIGHBOR_ADVERT_HDR	*nah;
+	T_ND_OPT_HDR		*opth;
+	T_IN6_IFADDR		*ifa;
+	T_LLINFO_ND6		*ln;
+	SYSTIM			now;
+	bool_t			llchange;
+	uint_t			lladdr_len = 0;
+	uint8_t			*lladdr = NULL;
+	uint8_t			nd_opt_off[ND_OPT_OFF_ARRAY_SIZE];
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NS_IN_PACKETS], 1);
+
+	ip6h = GET_IP6_HDR(input);
+
+	/*
+	 *  ãããã®ãã§ãã¯ãä»¥ä¸ã®å ´åã¯ç ´æ£ããã
+	 *    ã»ããããªãããã IPV6_MAXHLIM (255) ä»¥å¤
+	 *    ã»ãããé·ãç­ã
+	 */
+	if (ip6h->hlim != IPV6_MAXHLIM || input->len - off < NEIGHBOR_ADVERT_HDR_SIZE)
+		goto err_ret;
+
+	nah  = (T_NEIGHBOR_ADVERT_HDR *)(input->buf + off);
+
+	/* ç®çã¢ãã¬ã¹ããã«ãã­ã£ã¹ããªãã¨ã©ã¼ */
+	if (IN6_IS_ADDR_MULTICAST(&nah->target))
+		goto err_ret;
+
+	/* è¿é£è¦è«ã¸ã®å¿ç­ã§ãå®å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ããªãã¨ã©ã¼ */
+	if ((nah->nd_na_flags_reserved & ND_NA_FLG_SOLICITED) &&
+	    IN6_IS_ADDR_MULTICAST(&ip6h->dst))
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã®ãªãã»ãããè¨é²ããã*/
+	if (nd6_options(nd_opt_off, input->buf + (off + NEIGHBOR_ADVERT_HDR_SIZE), 
+	                            input->len - (off + NEIGHBOR_ADVERT_HDR_SIZE)) != E_OK)
+		goto err_ret;
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ (ç®çãªã³ã¯ã¢ãã¬ã¹) */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_TARGET_LINKADDR)]) {
+		opth = (T_ND_OPT_HDR *)((uint8_t *)(input->buf + off + NEIGHBOR_ADVERT_HDR_SIZE) +
+		                        nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_TARGET_LINKADDR)] - 8);
+	 	/* æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã*/
+		lladdr     = (uint8_t *)(opth + 1);
+		lladdr_len = (opth->len << 3);
+		}
+
+	ifa = in6_lookup_ifaddr(ifp, &nah->target);
+
+	/*
+	 *  ç®çã¢ãã¬ã¹ãèªåã®ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã«å²ãå½ã¦ããã¦ããã¢ãã¬ã¹ã®
+	 *  ããããã«ä¸è´ããã¨ãã¯ãéè¤ãã¦ãããã¨ãæå³ãã¦ããã
+	 */
+	if (ifa) {
+		if (ifa->flags & IN6_IFF_TENTATIVE)
+			nd6_dad_na_input(ifp, ifa);
+		else
+			syslog(LOG_ERROR, "[ND6 NA INPUT] dup IPv6 addr: %s.", ipv62str(NULL, &ifa->addr));
+		goto err_ret;
+		}
+
+	/*
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹é·ãä¸è´ããªããã°ã¨ã©ã¼
+	 */
+	if (lladdr && lladdr_len != ((sizeof(T_IF_ADDR) + sizeof(T_ND_OPT_HDR) + 7) & ~7))
+		goto err_ret;
+
+	/* è¿é£ã­ã£ãã·ã¥ãæ¢ç´¢ããã*/
+	syscall(wai_sem(SEM_ND6_CACHE));
+	if ((ln = nd6_lookup(&nah->target, false)) == NULL)
+		goto free_ret;
+
+	/* è¿é£ã­ã£ãã·ã¥ã®ç¶æ
+ãããã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹æªè§£æ±ºã®å ´å */
+	if (ln->state == ND6_LLINFO_INCOMPLETE) {
+		/* éç¥ããããã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ã®é·ãã 0 ã®å ´å */
+		if (lladdr == NULL)
+			goto free_ret;
+
+		ln->ifaddr = *(T_IF_ADDR *)lladdr;
+		if (nah->nd_na_flags_reserved & ND_NA_FLG_SOLICITED) {
+			ln->state = ND6_LLINFO_REACHABLE;
+			/*ln->byhint = 0*/;
+			if (ln->expire) {
+				syscall(get_tim(&now));
+				ln->expire = now + ND6_REACHABLE_TIME;
+				}
+			}
+		else {
+			syscall(get_tim(&now));
+			ln->expire = now + ND6_GCOLLECTION_TIME;
+			ln->state  = ND6_LLINFO_STALE;
+			}
+
+		if ((nah->nd_na_flags_reserved & ND_NA_FLG_ROUTER) != 0)
+			ln->flags |=  ND6_LLIF_ROUTER;
+		else
+			ln->flags &= ~ND6_LLIF_ROUTER;
+		if ((ln->flags & ND6_LLIF_ROUTER) != 0)
+			/*pfxlist_onlink_check()*/;
+		}
+	else {
+		if (lladdr == NULL)
+			llchange = false;
+		else if (memcmp(lladdr, &ln->ifaddr, sizeof(T_IF_ADDR)))
+			llchange = true;
+		else
+			llchange = false;
+
+		/*
+		 *  ç¶æ
+é·ç§»è¡¨
+		 *
+		 *  nd_na_flags_reserved
+		 *  OVERRIDE    SOLICTED lladdr llchange å¦ç (L: lladdr ãç»é²ãã)
+		 *
+		 *      F           F       N      -    (2c)
+		 *      F           F       Y      F    (2b) L
+		 *      F           F       Y      T    (1)    REACHABLE -> STALE
+		 *      F           T       N      -    (2c)           * -> REACHABLE
+		 *      F           T       Y      F    (2b) L         * -> REACHABLE
+		 *      F           T       Y      T    (1)    REACHABLE -> STALE
+		 *      T           F       N      -    (2a)
+		 *      T           F       Y      F    (2a) L
+		 *      T           F       Y      T    (2a) L         *-> STALE
+		 *      T           T       N      -    (2a)           * -> REACHABLE
+		 *      T           T       Y      F    (2a) L         * -> REACHABLE
+		 *      T           T       Y      T    (2a) L         * -> REACHABLE
+		 */
+		if ((nah->nd_na_flags_reserved & ND_NA_FLG_OVERRIDE) == 0 && (lladdr != NULL && llchange)) {	/* (1) */
+			/* ç¶æ
+ã REACHABLE ãªã STALE ã«é·ç§»ããã*/
+			if (ln->state == ND6_LLINFO_REACHABLE) {
+				syscall(get_tim(&now));
+				ln->expire = now + ND6_GCOLLECTION_TIME;
+				ln->state  = ND6_LLINFO_STALE;
+				}
+			goto free_ret;
+			}
+		else if ((nah->nd_na_flags_reserved & ND_NA_FLG_OVERRIDE) ||						/* (2a) */
+		         ((nah->nd_na_flags_reserved & ND_NA_FLG_OVERRIDE) == 0 && (lladdr != NULL && !llchange)) ||	/* (2b) */
+		         lladdr == NULL) {										/* (2c) */
+
+			/* ãã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ãéç¥ããã¦ããã°æ´æ°ããã*/
+			if (lladdr != NULL)
+				ln->ifaddr = *(T_IF_ADDR *)lladdr;
+
+			/* è¿é£è¦è«ã¸ã®å¿ç­ãªã REACHABLE ã«é·ç§»ããã*/
+			if (nah->nd_na_flags_reserved & ND_NA_FLG_SOLICITED) {
+				ln->state = ND6_LLINFO_REACHABLE;
+				/*ln->byhint = 0*/;
+				if (ln->expire) {
+					syscall(get_tim(&now));
+					ln->expire = now + ND6_REACHABLE_TIME;
+					}
+				}
+			/*
+			 *  ãã¼ã¿ãªã³ã¯å±¤ã®ã¢ãã¬ã¹ãéç¥ããã
+			 *  ç°ãªãã¢ãã¬ã¹ãªãæ´æ°ããã
+			 */
+			else if (lladdr != NULL && llchange) {
+				syscall(get_tim(&now));
+				ln->expire = now + ND6_GCOLLECTION_TIME;
+				ln->state  = ND6_LLINFO_STALE;
+				}
+			}
+
+		/* ã«ã¼ã¿éç¥ãã©ã°ã®å¦ç */
+		if ((ln->flags        & ND6_LLIF_ROUTER ) != 0 &&
+		    (nah->nd_na_flags_reserved & ND_NA_FLG_ROUTER) == 0) {
+			/*
+			 *  éä¿¡ç¸æãã«ã¼ã¿éç¥ãã©ã°ãç¡å¹ã«ããå ´åã
+			 *  ãã£ãã©ã«ãã»ã«ã¼ã¿ãªã¹ãããå¯¾è±¡ã®ã«ã¼ã¿ãåé¤ãã
+			 *  è¿é£æ¢ç´¢ã­ã£ãã·ã¥ãæ´æ°ããã
+			 */
+			T_DEF_ROUTER	*dr = NULL;
+
+			syscall(wai_sem(SEM_ND6_DEFRTRLIST));
+			if ((dr = nd6_defrtrlist_lookup(&ln->addr)) != NULL) {
+				nd6_defrtrlist_del(dr);
+				}
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			}
+		if ((nah->nd_na_flags_reserved & ND_NA_FLG_ROUTER) != 0)
+			ln->flags |=  ND6_LLIF_ROUTER;
+		else
+			ln->flags &= ~ND6_LLIF_ROUTER;
+		}
+
+	ln->asked = 0;
+
+	/* ã¢ãã¬ã¹è§£æ±ºå¾
+ã¡ã®ãã¼ã¿ã°ã©ã ãããã°éä¿¡ããã*/
+	nd6_output_hold(ifp, ln);
+
+free_ret:
+	syscall(sig_sem(SEM_ND6_CACHE));
+	syscall(rel_net_buf(input));
+	return;
+
+err_ret:
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+	}
+
+/*
+ *  nd6_na_output -- è¿é£éç¥ãåºåããã
+ */
+
+void
+nd6_na_output (T_IFNET *ifp, const T_IN6_ADDR *daddr,
+               const T_IN6_ADDR *taddr, uint32_t flags, bool_t tlladdr)
+{
+	T_NEIGHBOR_ADVERT_HDR	*nah;
+	T_NET_BUF		*output;
+	T_IP6_HDR		*ip6h;
+	T_IN6_IFADDR		*ifa;
+	T_IF_ADDR		*mac = NULL;
+	uint_t			len;
+	uint16_t		ipflags = 0;
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_NA_OUT_PACKETS], 1);
+
+	/*
+	 *  è¿é£éç¥ãã¤ã­ã¼ãé·ãè¨ç®ããã
+	 *  tlladdr ãçãªããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ãè¿½å ããã
+	 */
+	if (tlladdr && IF_SOFTC_TO_IFADDR(ifp->ic))
+		len = (NEIGHBOR_ADVERT_HDR_SIZE + ND_OPT_HDR_SIZE + sizeof(T_IF_ADDR) + 7) >> 3 << 3;
+	else
+		len = (NEIGHBOR_ADVERT_HDR_SIZE + 7) >> 3 << 3;
+
+	/*
+	 *  ä»ã®ãªã³ã¯ããã®å½é ããããã¼ã¿ã°ã©ã ã
+	 *  æé¤ãããããããããªãããã« IPV6_MAXHLIM (255) ãè¨­å®ããã
+	 */
+	ipflags = IPV6_OUT_SET_HOP_LIMIT(IPV6_OUT_FLG_HOP_LIMIT, IPV6_MAXHLIM);
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããIPv6 ããããè¨­å®ããã*/
+	if (in6_get_datagram(&output, len, 0, daddr, NULL,
+	                     IPPROTO_ICMPV6, IPV6_MAXHLIM,
+	                     NBA_SEARCH_ASCENT, TMO_ND6_NA_OUTPUT) != E_OK)
+		return;
+
+	ip6h = GET_IP6_HDR(output);
+
+	if (IN6_IS_ADDR_UNSPECIFIED(daddr)) {
+		/*
+		 *  å®å
+ã¢ãã¬ã¹ãç¡æå®ã®å ´åã¯ã
+		 *  ãªã³ã¯ã­ã¼ã«ã«å
+¨ãã¼ãã»ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ãè¨­å®ããã
+		 */
+		ip6h->dst.s6_addr32[0] = IPV6_ADDR_INT32_MLL;
+		ip6h->dst.s6_addr32[1] = 0;
+		ip6h->dst.s6_addr32[2] = 0;
+		ip6h->dst.s6_addr32[3] = IPV6_ADDR_INT32_ONE;
+		flags &= ~ND_NA_FLG_SOLICITED;
+		}
+	else
+		ip6h->dst = *daddr;
+
+	/*
+	 *  å®å
+ã¢ãã¬ã¹ã«ãµããããéä¿¡å
+ã¢ãã¬ã¹ãã
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ããæ¢ç´¢ãã¦å©ç¨ããã
+	 */
+	if ((ifa = in6_ifawithifp(ifp, &ip6h->dst)) == NULL) {
+		syscall(rel_net_buf(output));
+		return;
+		}
+	ip6h->src = ifa->addr;
+
+ 	/* è¿é£éç¥ããããè¨­å®ããã*/
+ 	nah = GET_NEIGHBOR_ADVERT_HDR(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
+ 	nah->hdr.type        = ND_NEIGHBOR_ADVERT;
+ 	nah->hdr.code        = 0;
+ 	nah->target          = *taddr;
+
+	/* tlladdr ãçãªããããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹ãè¿½å ããã*/
+	if (tlladdr && (mac = IF_SOFTC_TO_IFADDR(ifp->ic)) != NULL) {
+
+		T_ND_OPT_HDR	*opth;
+		uint_t		optlen;
+
+		opth   = (T_ND_OPT_HDR *)GET_NEIGHBOR_ADVERT_SDU(output, IF_IP6_NEIGHBOR_ADVERT_HDR_OFFSET);
+		optlen = (ND_OPT_HDR_SIZE + sizeof(T_IF_ADDR) + 7) >> 3 << 3;
+		memset(opth, 0, optlen);
+		opth->type = ND_OPT_TARGET_LINKADDR;
+		opth->len  = optlen >> 3;
+		memcpy((uint8_t *)opth + sizeof(T_ND_OPT_HDR), mac, sizeof(T_IF_ADDR));
+		}
+	else
+		flags &= ~ND_NA_FLG_OVERRIDE;
+
+	nah->nd_na_flags_reserved = flags;
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	nah->hdr.sum = 0;
+	nah->hdr.sum = in6_cksum(output, IPPROTO_ICMPV6, (uint8_t*)nah - output->buf, len);
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_OCTETS],
+	               output->len - GET_IF_IP6_HDR_SIZE(output));
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutNeighborAdvertisements, 1);
+	ip6_output(output, ipflags, TMO_ND6_NS_OUTPUT);
+	}
+
+/*
+ *  nd6_dad_start -- éè¤ã¢ãã¬ã¹æ¤åº (DAD) ãéå§ããã
+ *
+ *    ç¬¬3å¼æ°ã®tick ã¯ãã¤ã³ã¿ãã§ã¼ã¹ãèµ·åããã¦ãããéè¤æ¤åºã
+ *    éä¿¡ããã¾ã§ã®æå°é
+å»¶å¤ã§ããã
+ */
+
+void
+nd6_dad_start (T_IFNET *ifp, T_IN6_IFADDR *ifa, int_t *tick)
+{
+	/* ãã©ã°ããã§ãã¯ããã*/
+	if (!(ifa->flags & IN6_IFF_TENTATIVE))
+		return;
+
+#if NUM_IP6_DAD_COUNT == 0
+
+	ifa->flags &= ~IN6_IFF_TENTATIVE;
+
+#else	/* of #if NUM_IP6_DAD_COUNT == 0 */
+
+	if (ifa->flags & IN6_IFF_ANYCAST) {
+		ifa->flags &= ~IN6_IFF_TENTATIVE;
+		return;
+		}
+	else if ((ifa->flags & IN6_IFF_TENTATIVE) == 0)
+		return;
+
+	/* éè¤ã¢ãã¬ã¹æ¤åºã«ã¦ã³ã¿ããªã»ããããã*/
+	ifa->ns_icount = ifa->na_icount = ifa->ns_ocount = 0;
+
+	/*
+	 *  éè¤ã¢ãã¬ã¹æ¤åºè¦è«ãéä¿¡ããããã ããã¤ã³ã¿ãã§ã¼ã¹ã
+	 *  åæåããç´å¾ã«ãæåã«éä¿¡ããå ´åã¯ãã©ã³ãã ãªé
+å»¶ãè¡ãã
+	 */
+	if (tick == NULL) {
+		nd6_dad_ns_output(ifp, ifa);
+
+		/* ã¿ã¤ã ã¢ã¦ããè¿é£æ¢ç´¢ã®éä¿¡ééã«è¨­å®ããã*/
+		timeout((callout_func)nd6_dad_timer, ifa, ND6_RETRANS_TIME * NET_TIMER_HZ / SYSTIM_HZ);
+		}
+	else {
+		int_t ntick;
+
+		if (*tick == 0)	/* æåã®éä¿¡ */
+			ntick = net_rand() % (ND6_FIRST_DAD_DELAY_TIME * NET_TIMER_HZ / SYSTIM_HZ);
+		else
+			ntick = *tick + net_rand() % (ND6_DAD_DELAY_TIME * NET_TIMER_HZ / SYSTIM_HZ);
+		*tick = ntick;
+		timeout((callout_func)nd6_dad_timer, ifa, ntick);
+		}
+
+#endif	/* of #if NUM_IP6_DAD_COUNT == 0 */
+
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/nd6_rtr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/nd6_rtr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/nd6_rtr.c	(revision 317)
@@ -0,0 +1,1490 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/nd6_rtr.c,v 1.11 2002/04/19 04:46:23 suz Exp $	*/
+/*	$KAME: nd6_rtr.c,v 1.111 2001/04/27 01:37:15 jinmei Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+#include <t_syslog.h>
+#include "kernel_cfg.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+#include "kernel_id.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_var.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+
+#include <netinet6/nd6.h>
+#include <netinet6/in6_ifattach.h>
+
+#include <net/if_var.h>
+
+/*
+ *  å¤é¨é¢æ°ã®å®ç¾©
+ */
+
+extern const char *itron_strerror (ER ercd);
+
+#ifdef _IP6_CFG
+
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+/*
+ *  å
+¨åå¤æ°
+ */
+
+SYSTIM	nd6_base_reachable_time		= ND6_DEF_REACHABLE_TIME;	/* ã«ã¼ã¿ããéç¥ãããå¤		*/
+SYSTIM	nd6_reachable_time		= ND6_DEF_REACHABLE_TIME;	/* ã«ã¼ã¿ããéç¥ãããå¤ã®è£æ­£å¤	*/
+SYSTIM	nd6_recalc_reachtm_interval	= ND6_RECALC_REACHTM_INTERVAL;	/* å°éå¯è½ç¶æ
+ã®æå¹æéåè¨ç®éé	*/
+SYSTIM	nd6_retrans_time		= ND6_DEF_RETRANS_TIME;		/* è¿é£æ¢ç´¢ã®éä¿¡éé			*/
+uint8_t	ip6_defhlim			= IPV6_DEFHLIM;			/* ããããªãããã®è¦å®å¤		*/
+
+/*
+ *  å±æå¤æ°
+ */
+
+/*
+ *  ãã¬ãã£ãã¯ã¹ã»ãªã¹ã
+ */
+
+static T_ND6_PREFIX nd6_prefix[NUM_ND6_PREFIX_ENTRY];
+
+/*
+ *  ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ã
+ */
+
+static T_DEF_ROUTER	nd6_def_router[NUM_ND6_DEF_RTR_ENTRY];
+static uint_t		def_router_count = 0;				/* ãªã¹ãã«ããã«ã¼ã¿æ° */
+
+/*
+ *  make_mask -- ãããç¨ã®ãã¹ã¯ãçæããã
+ */
+
+static uint_t
+make_mask (int_t index)
+{
+	uint_t	mask;
+	int_t	ix;
+
+	/* ãã¹ã¯ãçæããã*/
+	mask = 1;
+	for (ix = index; ix -- > 0; )
+		mask <<= 1;
+
+	return mask;
+	}
+
+/*
+ *  find_pfxlist_reachable_router --
+ *      æå®ãããã¬ãã£ãã¯ã¹ãéç¥ããã«ã¼ã¿ããªã³ã¯ä¸ã«å­å¨ããããã§ãã¯ããã
+ */
+
+static T_DEF_ROUTER *
+find_pfxlist_reachable_router (T_ND6_PREFIX *pr)
+{
+	T_DEF_ROUTER	*dr = NULL;
+	T_LLINFO_ND6	*ln;
+	uint_t		mask;
+	int_t		ix;
+
+	mask = 1;
+	for (ix = 0; ix < def_router_count; ix ++) {
+		if ((pr->routermap & mask) != 0) {
+			if ((ln = nd6_lookup(&nd6_def_router[ix].addr, false)) != NULL &&
+			    ND6_IS_LLINFO_PROBREACH(ln))
+				return dr;
+			}
+		mask <<= 1;
+		}
+	return NULL;
+	}
+
+/*
+ *  pfxlist_onlink_check -- ãã¬ãã£ãã¯ã¹ã»ãªã¹ãã®ãªã³ãªã³ã¯ç¶æ
+ããã§ãã¯ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static void
+pfxlist_onlink_check (void)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_ND6_PREFIX	*pr = NULL;
+	T_IN6_IFADDR	*ia;
+	ER		error;
+	int_t		ix;
+
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) != 0 &&
+		    find_pfxlist_reachable_router(pr))
+			break;
+		}
+
+	if (ix >= 0) {
+		/*
+		 *  ãªã³ãªã³ã¯ç¶æ
+ã®ãã¬ãã£ãã¯ã¹ãæä½ä¸ã¤å­å¨ããã¨ãã®å¦çã
+		 *  åãã¬ãã£ãã¯ã¹ã®ãªã³ãªã³ã¯ç¶æ
+ããããããéç¥ãã¦ããã«ã¼ã¿ã®
+		 *  ç¶æ
+ã«å¾ã£ã¦è¨­å®ããã
+		 */
+
+		
+		for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+			pr = &nd6_prefix[ix];
+
+			if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0)
+				continue;
+
+			if ((pr->flags & ND6_PREFIX_STATE_DETACHED) == 0 &&
+			    find_pfxlist_reachable_router(pr) == NULL)
+				pr->flags |= ND6_PREFIX_STATE_DETACHED;
+
+			if ((pr->flags & ND6_PREFIX_STATE_DETACHED) != 0 &&
+			    find_pfxlist_reachable_router(pr) != NULL)
+				pr->flags &= ~ND6_PREFIX_STATE_DETACHED;
+			}
+		}
+	else {
+		/*
+		 *  ã©ã®ãã¬ãã£ãã¯ã¹ããªã³ãªã³ã¯ã§ã¯ãªãã
+		 *  ãã£ãã©ã«ãã«ã¼ã¿ãå­å¨ããªãã¨ãã®å¦çã
+		 *  ãã¹ã¦ã®ãã¬ãã£ãã¯ã¹ãä½¿ç¨å¯è½ç¶æ
+ã«è¨­å®ããã
+		 */
+
+		
+		for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+			pr = &nd6_prefix[ix];
+
+			if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0)
+				continue;
+
+			if ((pr->flags & ND6_PREFIX_STATE_DETACHED) != 0)
+				pr->flags &= ~ND6_PREFIX_STATE_DETACHED;
+			}
+		}
+
+	/*
+	 *  åãã¬ãã£ãã¯ã¹æ¯ã«ãéç¥ãã¦ããã«ã¼ã¿ã®ç¶æ
+ã¨
+	 *  ãªã³ãªã³ã¯ã®ç¶æ
+ãä¸è´ããªããã°ããªã³ãªã³ã¯ç¶æ
+ãæ´æ°ããã
+	 */
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+
+		if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0)
+			continue;
+
+		if ((pr->flags & ND6_PREFIX_STATE_DETACHED) != 0 &&
+		    (pr->flags & ND6_PREFIX_STATE_ONLINK  ) != 0) {
+			if ((error = nd6_prefix_offlink(pr)) != E_OK)
+				syslog(LOG_ERROR, "[ND6 RTR] prefix offlink failed: %s", itron_strerror(error));
+			}
+
+		if ((pr->flags & ND6_PREFIX_STATE_DETACHED) == 0 &&
+		    (pr->flags & ND6_PREFIX_STATE_ONLINK  ) == 0 &&
+		    (pr->flags & ND6_PREFIX_FLAG_ONLINK   ) == 0) {
+			if ((error = nd6_prefix_onlink(pr)) != E_OK)
+				syslog(LOG_ERROR, "[ND6 RTR] prefix onlink failed: %s", itron_strerror(error));
+			}
+		}
+
+	/*
+	 *  ãªã³ã¯ä¸ã«ãã¬ãã£ãã¯ã¹ãéç¥ãã¦ããã«ã¼ã¿ã
+	 *  å°ãªãã¨ã 1 å°å­å¨ãããç¢ºèªããã
+	 */
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
+		     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
+			pr = &nd6_prefix[ia->prefix_index];
+			if (find_pfxlist_reachable_router(pr) != NULL)
+				break;
+			}
+		}
+
+	if (ix >= 0) {
+		/*
+		 *  ãªã³ã¯ä¸ã«ãã¬ãã£ãã¯ã¹ãéç¥ãã¦ããã«ã¼ã¿ã
+		 *  å°ãªãã¨ã 1 å°å­å¨ããæã®å¦çã
+		 */
+		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+			ia = &ifp->in6_ifaddrs[ix];
+			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0 &&
+			     ia->prefix_index != ND6_PREFIX_IX_INVALID) {
+				pr = &nd6_prefix[ia->prefix_index];
+				if (find_pfxlist_reachable_router(pr) != NULL)
+					ia->flags &= ~IN6_IFF_DETACHED;
+				else
+					ia->flags |= IN6_IFF_DETACHED;
+				}
+			}
+		}
+	else {
+		/*
+		 *  ãªã³ã¯ä¸ã«ãã¬ãã£ãã¯ã¹ãéç¥ãã¦ããã«ã¼ã¿ã
+		 *  1 å°å­å¨ããªãæã¯å
+¨ã¦ã®ã¢ãã¬ã¹ãå©ç¨ã§ããããã«ããã
+		 */
+		for (ix = NUM_IN6_IFADDR_ENTRY; ix -- > 0; ) {
+			ia = &ifp->in6_ifaddrs[ix];
+			if ((ia->flags & (IN6_IFF_DEFINED | IN6_IFF_AUTOCONF)) != 0)
+				ia->flags &= ~IN6_IFF_DETACHED;
+			}
+		}
+	}
+
+/*
+ *  pfxrtr_add -- ãã¬ãã£ãã¯ã¹ã¨ã³ããªã¨ãã£ãã©ã«ãã«ã¼ã¿ã»ã¨ã³ããªããªã³ã¯ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static void
+pfxrtr_add (int_t prefix_index, int_t rtr_index)
+{
+	/*  ãã¬ãã£ãã¯ã¹ã¨ã³ããªã¨ãã£ãã©ã«ãã«ã¼ã¿ã»ã¨ã³ããªããªã³ã¯ããã*/
+	nd6_prefix[prefix_index].routermap |= make_mask(rtr_index);
+	nd6_def_router[rtr_index].plistmap |= make_mask(prefix_index);
+
+	pfxlist_onlink_check();
+	}
+
+/*
+ *  nd6_pfxrtr_lookup -- ãã¬ãã£ãã¯ã¹ã¨ã³ããªããã«ã¼ã¿ãæ¢ç´¢ããã
+ */
+
+static uint_t
+pfxrtr_lookup (const T_ND6_PREFIX *pr, int_t rtr_index)
+{
+	return (pr->routermap & make_mask(rtr_index)) == 0 ? IN6_RTR_IX_UNREACH : rtr_index;
+	}
+
+/*
+ *  defrouter_select -- åªå
+ãã£ãã©ã«ãã»ã«ã¼ã¿ãé¸æããªããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static void
+defrouter_select (void)
+{
+	T_DEF_ROUTER	*dr = NULL, router;
+	T_LLINFO_ND6	*ln;
+	int_t		ix, tix;
+
+	for (ix = 0; ix < def_router_count; ix ++) {
+		dr = &nd6_def_router[ix];
+		if ((ln = nd6_lookup(&dr->addr, false)) != NULL && ND6_IS_LLINFO_PROBREACH(ln)) {
+		
+			/* é¸æããã«ã¼ã¿ãå
+é ­ã«ç§»ãã*/
+			router = *dr;
+			for (tix = ix; tix > 0; tix --)
+				nd6_def_router[tix] = nd6_def_router[tix - 1];
+			nd6_def_router[0] = router;
+			break;
+			}
+		}
+	}
+
+/*
+ *  defrtrlist_update -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ããæ´æ°ããã
+ *
+ *  	æ»ãå¤ã¯ãã«ã¼ã¿ã®ã¤ã³ããã¯ã¹ã
+ *      ãã ããå¤ã -1 ãªãããã¬ãã£ãã¯ã¹ã»ãªã¹ãã¯æ´æ°ããªãã
+ */
+
+static int_t
+defrtrlist_update (T_IN6_ADDR *src, uint32_t lifetime, uint8_t flags)
+{
+	T_DEF_ROUTER	*dr, *fdr = NULL;
+	SYSTIM		now;
+	int_t		ix;
+
+	syscall(get_tim(&now));
+	syscall(wai_sem(SEM_ND6_DEFRTRLIST));
+
+	/* ç»é²æ¸ãèª¿ã¹ãã*/
+	if ((fdr = nd6_defrtrlist_lookup(src)) != NULL) {
+		/* ç»é²æ¸ã¿ã®å ´åã®å¦ç */
+		if (lifetime == 0) {
+			nd6_defrtrlist_del(fdr);
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			return -1;
+			}
+		else {
+			fdr->lifetime = lifetime * SYSTIM_HZ;		/* lifetime ã®åä½ã¯ç§ */
+			fdr->flags    = flags;
+			fdr->expire   = now + fdr->lifetime;
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			return fdr - nd6_def_router;
+			}
+		}
+	else if (lifetime == 0) {
+		syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+		return -1;
+		}
+
+	if (fdr == NULL && def_router_count < NUM_ND6_DEF_RTR_ENTRY) {
+		/*
+		 *  def_router_count < NUM_ND6_DEF_RTR_ENTRY ã§ããã°ã
+		 *  nd6_def_router[def_router_count]; ãç©ºãã¨ã³ããª
+		 */
+		fdr = &nd6_def_router[def_router_count];
+		}
+
+	/* ç©ºãã¨ã³ããªããªããã°ãæå¹æéãç­ãã¨ã³ããªãåé¤ããã*/
+	if (fdr == NULL) {
+		T_DEF_ROUTER	*sdr = NULL;
+		int32_t		diff, sdiff = 0xffffffff;
+
+		for (ix = def_router_count; ix -- > 0; ) {
+			dr = &nd6_def_router[ix];
+			diff = (int32_t)(dr->expire - now);
+			if (diff <= 0) {	/* dr->expire <= now */
+				/* æ¢ã«ãæå¹æéãéãã¦ããã*/
+				sdr = dr;
+				break;
+				}
+			else if (diff < sdiff)
+				sdr = dr;
+			}
+		if (sdr != NULL) {
+			fdr = sdr;
+			nd6_defrtrlist_del(fdr);
+			}
+		}
+
+	/* åã¡ã³ãã«å¤ãè¨­å®ããã*/
+	fdr->plistmap = 0;
+	fdr->addr     = *src;
+	fdr->lifetime = lifetime * SYSTIM_HZ;		/* lifetime ã®åä½ã¯ç§ */
+	fdr->flags    = flags;
+	fdr->expire   = now + fdr->lifetime;
+	fdr->state    = ND6_DEF_RTR_BUSY;
+	def_router_count ++;
+
+	/*
+	 *  ãã£ãã©ã«ãã«ã¼ã¿ã¨ãã¦ç»é²ãããã
+	 *  æ¢ã«ãã£ãã©ã«ãã«ã¼ã¿ãããã°é¸æããªãããªãã
+	 */
+	if (fdr - nd6_def_router != 0)
+		defrouter_select();
+
+	syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+	return fdr - nd6_def_router;
+	}
+
+/*
+ *  in6_ifadd -- ã¤ã³ã¿ãã§ã¼ã¹ã«ã¢ãã¬ã¹ãè¿½å ããã
+ */
+
+static ER
+in6_ifadd (T_ND6_PREFIX *pr, T_IN6_IFADDR *ia, int_t router_index)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_ADDR	mask, addr;
+	T_IN6_IFADDR	*lla;
+	int_t		ix;
+
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+
+	/*
+	 *  ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªç»é²ã§ããã°ä½ãããªãã
+	 */
+	if ((lla->flags & IN6_IFF_DEFINED) == 0)
+		return E_OBJ;
+
+	/*
+	 *  ã«ã¼ã¿ããéç¥ããããã¬ãã£ãã¯ã¹é·ãã
+	 *  ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã®ãã¬ãã£ãã¯ã¹é·ã¨
+	 *  ç°ãªã£ã¦ããã°ã¨ã©ã¼
+	 */
+	if (lla->prefix_len != pr->prefix_len)
+		return E_PAR;
+
+	/* ãã¬ãã£ãã¯ã¹ãã¹ã¯ãçæããã*/
+	in6_plen2pmask(&mask, pr->prefix_len);
+
+	/* ã¢ãã¬ã¹ãçæããã*/
+	for (ix = 0; ix < 4; ix ++)
+		addr.s6_addr32[ix] = (pr->prefix.s6_addr32[ix] &  mask.s6_addr32[ix])
+		                   | ( lla->addr.s6_addr32[ix] & ~mask.s6_addr32[ix]);
+
+	/* ãã©ã°ãåæåããã*/
+	ia->flags = 0;
+
+	return in6_update_ifa(ifp, ia, &addr,
+	                      pr->prefix_len, pr->vltime, pr->pltime,
+	                      router_index, pr - nd6_prefix, IN6_IFF_AUTOCONF);
+	}
+
+/*
+ *  nd6_prefix_lookup -- ãã¬ãã£ãã¯ã¹ãæ¢ç´¢ããã
+ */
+
+static T_ND6_PREFIX *
+nd6_prefix_lookup (const T_IN6_ADDR *prefix, uint_t plen)
+{
+	T_ND6_PREFIX	*pr;
+	int_t		ix;
+
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_STATE_BUSY) &&
+		     pr->prefix_len == plen && IN6_ARE_ADDR_EQUAL(&pr->prefix, prefix))
+			return pr;
+		}
+
+	return NULL;
+	}
+
+/*
+ *  prelist_remove -- ãã¬ãã£ãã¯ã¹ãªã¹ããããã¬ãã£ãã¯ã¹ãåé¤ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static void
+prelist_remove (T_ND6_PREFIX *pr)
+{
+	ER	error = E_OK;
+	uint_t	mask;
+	int_t	rix;
+
+	/* æå¹æéåãã«ããã*/
+	pr->vltime = 0;
+	pr->pltime = 0;
+
+	if ((pr->flags & ND6_PREFIX_STATE_ONLINK) != 0 &&
+	    (error = nd6_prefix_offlink(pr)) != E_OK) {
+		syslog(LOG_ERROR, "[ND6 RTR] prefix remove failed: %s", itron_strerror(error));
+		return;
+		}
+
+	/*  ãã¬ãã£ãã¯ã¹ã¨ã³ããªã¨ãã£ãã©ã«ãã«ã¼ã¿ã»ã¨ã³ããªã®ãªã³ã¯ãè§£é¤ããã*/
+	pr->routermap = 0;
+	mask = make_mask(pr - nd6_prefix);
+	for (rix = def_router_count; rix --; )
+		nd6_def_router[rix].plistmap &= ~mask;
+
+	/* ãã¬ãã£ãã¯ã¹ãç¡å¹ã«ããã*/
+	pr->flags &= ~ND6_PREFIX_STATE_BUSY;
+
+	pfxlist_onlink_check();
+	}
+
+/*
+ *  nd6_prefix_onlink -- ãã¬ãã£ãã¯ã¹ããªã³ãªã³ã¯ã«è¨­å®ããã¢ãã¬ã¹ãä½¿ç¨å¯è½ã«ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+ER
+nd6_prefix_onlink (T_ND6_PREFIX *pr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*lla, *ia = NULL;
+	int_t		ix;
+
+	/* æ¢ã«ãªã³ãªã³ã¯ç¶æ
+ã«ãªã£ã¦ããå ´åã¯ã¨ã©ã¼ã*/
+	if ((pr->flags & ND6_PREFIX_STATE_ONLINK) != 0)
+		return E_OBJ;
+
+	/* ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªç»é²ã§ããã°ä½ãããªãã*/
+	lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+	if ((lla->flags & IN6_IFF_DEFINED) == 0)
+		return E_OK;
+
+	/*
+	 *  æå®ããããã¬ãã£ãã¯ã¹ãå²ãå½ã¦ããã¦ããã¤ã³ã¿ãã§ã¼ã¹ã®
+	 *  ã¢ãã¬ã¹æ
+å ±ãæ¢ãã
+	 */
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		if (ia->prefix_index == (pr - nd6_prefix))
+			break;
+		}
+
+	if (ix >= 0) {
+
+		/* ã¢ãã¬ã¹æ
+å ±ãä½¿ç¨å¯è½ã«ããã*/
+		ia->flags &= ~IN6_IFF_DETACHED;
+
+		/* ãã¬ãã£ãã¯ã¹ããªã³ãªã³ã¯ã«è¨­å®ããã*/
+		pr->flags |= ND6_PREFIX_STATE_ONLINK;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  nd6_prefix_offlink -- ãã¬ãã£ãã¯ã¹ããªããªã³ã¯ã«è¨­å®ããã¢ãã¬ã¹ãä½¿ç¨ä¸å¯ã«ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+ER
+nd6_prefix_offlink (T_ND6_PREFIX *pr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia = NULL;
+	int_t		ix;
+
+	/* æ¢ã«ãªããªã³ã¯ç¶æ
+ã«ãªã£ã¦ããå ´åã¯ã¨ã©ã¼ã*/
+	if ((pr->flags & ND6_PREFIX_STATE_ONLINK) == 0)
+		return E_OBJ;
+
+	/*
+	 *  æå®ããããã¬ãã£ãã¯ã¹ãå²ãå½ã¦ããã¦ããã¤ã³ã¿ãã§ã¼ã¹ã®
+	 *  ã¢ãã¬ã¹æ
+å ±ãæ¢ãã
+	 */
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		if (ia->prefix_index == (pr - nd6_prefix))
+			break;
+		}
+
+	if (ix >= 0) {
+
+		/* ã¢ãã¬ã¹æ
+å ±ãä½¿ç¨ä¸å¯ã«ããã*/
+		ia->flags |= IN6_IFF_DETACHED;
+
+		/* ãã¬ãã£ãã¯ã¹ããªããªã³ã¯ã«è¨­å®ããã*/
+		pr->flags &= ~ND6_PREFIX_STATE_ONLINK;
+		}
+
+	return E_OK;
+	}
+
+/*
+ *  in6_init_prefix_ltimes -- ãã¬ãã£ãã¯ã¹ã®æå¹æéãè¨­å®ããã
+ */
+
+static ER
+in6_init_prefix_ltimes (T_ND6_PREFIX *pr)
+{
+	SYSTIM		now;
+
+	/* æ¨å¥¨æå¹æéãæå¹æéããé·ãã¨ãã¯ã¨ã©ã¼ */
+	if (pr->pltime > pr->vltime)
+		return E_PAR;
+
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	if (pr->pltime == ND6_INFINITE_LIFETIME)
+		pr->preferred = 0;
+	else
+		pr->preferred = pr->pltime + now;
+
+	if (pr->vltime == ND6_INFINITE_LIFETIME)
+		pr->expire = 0;
+	else
+		pr->expire = pr->vltime + now;
+
+	return E_OK;
+	}
+
+/*
+ *  nd6_prelist_add -- ãã¬ãã£ãã¯ã¹ãªã¹ãã«ãã¬ãã£ãã¯ã¹ãè¿½å ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+static T_ND6_PREFIX *
+nd6_prelist_add (T_ND_OPT_PREFIX_INFO *pi, int_t rtr_index)
+{
+	T_ND6_PREFIX	*pr = NULL;
+	int_t		ix;
+
+	/* ãã¬ãã£ãã¯ã¹ãªã¹ãããç©ºãã®ãã¬ãã£ãã¯ã¹ã¨ã³ããªãæ¢ç´¢ããã*/
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix --; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_STATE_BUSY) == 0)
+			break;
+		}
+
+	/* ãã¬ãã£ãã¯ã¹ãªã¹ãã«ç©ºãããªããã°ã¨ã©ã¼ */
+	if (ix < 0)
+		return NULL;
+
+	pr->flags |= ND6_PREFIX_STATE_BUSY;
+
+	/* ãã¬ãã£ãã¯ã¹ãè¿½å ããã*/
+	pr->prefix     = pi->prefix;
+	pr->prefix_len = pi->prefix_len;
+
+	/* ãã©ã°ãè¨­å®ããã*/
+	if ((pi->flags & ND_OPT_PI_FLAG_ONLINK) != 0)
+		pr->flags |= ND6_PREFIX_FLAG_ONLINK;
+	if ((pi->flags & ND_OPT_PI_FLAG_AUTO) != 0)
+		pr->flags |= ND6_PREFIX_FLAG_AUTO;
+
+	/* ãã¬ãã£ãã¯ã¹ã®æå¹æéãè¨­å®ããã*/
+	pr->vltime = ntohl(pi->valid);
+	pr->pltime = ntohl(pi->preferred);
+	in6_init_prefix_ltimes(pr);
+
+	if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) != 0) {
+		if (nd6_prefix_onlink(pr) != E_OK)
+			return NULL;
+		}
+
+	/* ã«ã¼ã¿ããããåæåããã*/
+	pr->routermap = 0;
+
+	/* ã«ã¼ã¿ãè¿½å ããã*/
+	pfxrtr_add(pr - nd6_prefix, rtr_index);
+
+	return pr;
+	}
+
+/*
+ *  prelist_update -- ãã¬ãã£ãã¯ã¹ã»ãªã¹ããæ´æ°ããã
+ */
+
+static void
+prelist_update (T_ND_OPT_PREFIX_INFO *pi, uint_t router_index)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_ND6_PREFIX	*pr;
+	T_IN6_IFADDR	*ia = NULL;
+	int_t		ix, ifidlen;
+
+	syscall(wai_sem(SEM_ND6_DEFRTRLIST));
+	if ((pr = nd6_prefix_lookup(&pi->prefix, pi->prefix_len)) != NULL) {
+		/*
+		 *  ç»é²æ¸ã¿ã®å ´åã¯ããã¬ãã£ãã¯ã¹ãªã¹ããæ´æ°ããã
+		 */
+
+		/*
+		 *  ãã©ã°ã®æ´æ°ã®æ³¨æ:
+		 *    on-link ãããã¨ autonomous ãããã¯
+		 *    1 ãã 0 ã«å¤æ´ãã¦ã¯ãªããªãã
+		 */
+
+		if ((pi->flags & ND_OPT_PI_FLAG_ONLINK) != 0)
+			pr->flags |= ND6_PREFIX_FLAG_ONLINK;
+		if ((pi->flags & ND_OPT_PI_FLAG_AUTO) != 0)
+			pr->flags |= ND6_PREFIX_FLAG_AUTO;
+
+		if ((pi->flags & ND_OPT_PI_FLAG_ONLINK) != 0) {
+			/*
+			 *  éç¥ããããã¬ãã£ãã¯ã¹ããªã³ãªã³ã¯ã®æã¯ã
+			 *  æå¹æéãæ´æ°ããã
+			 */
+			pr->vltime = ntohl(pi->valid);
+			pr->pltime = ntohl(pi->preferred);
+			in6_init_prefix_ltimes(pr);
+			}
+
+		if ((pi->flags & ND_OPT_PI_FLAG_ONLINK  ) != 0 &&
+		    (pr->flags & ND6_PREFIX_STATE_ONLINK) == 0) {
+			/*
+			 *  ãªããªã³ã¯ã®ãã¬ãã£ãã¯ã¹ããªã³ãªã³ã¯ã«ãªã£ãæã®å¦çãå®è¡ããã
+			 */
+			if (nd6_prefix_onlink(pr) != E_OK) {
+				syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+				syslog(LOG_ERROR, "[ND6 RTR] prefix update failed.");
+				return;
+				}
+			}
+
+		if (router_index != IN6_RTR_IX_UNREACH && pfxrtr_lookup(pr, router_index) == IN6_RTR_IX_UNREACH)
+			pfxrtr_add(pr - nd6_prefix, router_index);
+		}
+	else {	/* æªç»é²ã®å ´å */
+
+		/* æå¹æé 0 ã®ãã¬ãã£ãã¯ã¹ã¯è¿½å ããªãã*/
+		if (pi->valid == 0) {
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			return;
+			}
+
+		/* ãªããªã³ã¯ã§ã¢ãã¬ã¹èªåè¨­å®ã«ä½¿ç¨ããªããã°è¿½å ããªãã*/
+		if ((pi->flags & (ND_OPT_PI_FLAG_ONLINK | ND_OPT_PI_FLAG_AUTO)) !=
+		                 (ND_OPT_PI_FLAG_ONLINK | ND_OPT_PI_FLAG_AUTO)) {
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			return;
+			}
+
+		/* ãã¬ãã£ãã¯ã¹ãè¿½å ããã*/
+		if ((pr = nd6_prelist_add(pi, router_index)) == NULL) {
+			syslog(LOG_ERROR, "[ND6 RTR] prefix add failed.");
+			syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+			return;
+			}
+
+#if 1		/* ãã¬ãã£ãã¯ã¹ãæªç»é²ã®å ´åã ãè¡¨ç¤ºããã*/
+		syslog(LOG_NOTICE, "[ND6 RTR] add prefix: flags[MOH]: %02x, addr: %s\n"
+		                   "                                      from: %s.",
+		                   nd6_def_router[router_index].flags,
+		                   ipv62str(NULL, &pi->prefix),
+		                   ipv62str(NULL, &nd6_def_router[router_index].addr));
+#endif
+		if ((pr->flags & ND6_PREFIX_FLAG_ONLINK) == 0) {
+			/*
+			 *  ãªããªã³ã¯ã»ãã¬ãã£ãã¯ã¹ã®å ´åã¯ãæå¹æéã 0 ã«è¨­å®ããã
+			 *  ãã¨ã§æå¹æéåãã¨ãªãããªã¹ãããåé¤ãããã
+			 */
+			pr->vltime = 0;
+			pr->pltime = 0;
+			in6_init_prefix_ltimes(pr);
+			}
+		}
+
+	/*
+	 *  ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®ãè¡ãã
+	 */
+	if ((pr->flags & ND6_PREFIX_FLAG_AUTO) == 0) {
+		syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+		return;
+		}
+
+	/*
+	 *  éç¥ããããã¬ãã£ãã¯ã¹ãå²ãå½ã¦ããã¦ããã¤ã³ã¿ãã§ã¼ã¹ã®
+	 *  ã¢ãã¬ã¹æ
+å ±ãæ¢ãã
+	 */
+	for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
+		ia = &ifp->in6_ifaddrs[ix];
+		if ((ia->flags & IN6_IFF_DEFINED) != 0 &&
+		    ia->prefix_len == pr->prefix_len &&
+		    in6_are_prefix_equal(&ia->addr, &pr->prefix, pr->prefix_len))
+			break;
+		}
+
+	if (ix >= 0) {	/* ç»é²æ¸ã¿ã®ã¨ã */
+		if ((ia->flags & IN6_IFF_AUTOCONF) == 0) {
+			/*
+			 *  ã¹ãã¼ãã¬ã¹ã»ã¢ãã¬ã¹èªåè¨­å®ã«ãã
+			 *  è¨­å®ããã¦ããªããã°æ´æ°ããªãã
+			 */
+			;
+			}
+		else if (ia->flags & IN6_IFF_TENTATIVE) {
+			/*
+			 *  éè¤æ¤åºä¸­ãªãæ´æ°ããªãã
+			 */
+			;
+			}
+		else {
+			T_IN6_ADDR	mask, addr;
+			T_IN6_IFADDR	*lla;
+			uint32_t		vltime;
+			SYSTIM		now;
+			int_t		ix;
+
+			/* æå¹æéãè¨­å®ããã*/
+			syscall(get_tim(&now));
+
+			if (ia->lifetime.vltime == ND6_INFINITE_LIFETIME)
+				vltime = ND6_INFINITE_LIFETIME;
+			else if (IFA6_IS_INVALID(ia, now))
+				vltime = 0;
+			else
+				vltime = ia->lifetime.expire - now / SYSTIM_HZ;
+
+			if (pr->vltime > (2 * 60 * 60) || pr->vltime > vltime) {
+				/*
+				 *  lifetime.expireãpi->valid (æå¹æé) ã¨
+				 *  pi->preferred (æ¨å¥¨æå¹æé) ã®åä½ã¯ [s]ã
+				 *  éç¥ãããæå¹æéã 2 æéä»¥ä¸ããç¾å¨ã®æ®ãæéãã
+				 *  é·ããã°ãæ°ããæå¹æéã«ã¯ãéç¥ãããæå¹æéãè¨­å®ããã
+				 */
+				vltime = pr->vltime;
+				}
+			else if (vltime <= (2 * 60 * 60))
+				;
+			else {
+				/*
+				 *  IPsec ã¯æªå®è£
+ã®ããã2 æéãè¨­å®ããã
+				 */
+				vltime = 2 * 60 * 60;
+				}
+
+			lla = &ifp->in6_ifaddrs[IPV6_IFADDR_IX_LINKLOCAL];
+
+			/* ãã¬ãã£ãã¯ã¹ãã¹ã¯ãçæããã*/
+			in6_plen2pmask(&mask, pr->prefix_len);
+
+			/* ã¢ãã¬ã¹ãçæããã*/
+			for (ix = 0; ix < 4; ix ++)
+				addr.s6_addr32[ix] = (pr->prefix.s6_addr32[ix] &  mask.s6_addr32[ix])
+				                   | ( lla->addr.s6_addr32[ix] & ~mask.s6_addr32[ix]);
+
+			in6_update_ifa(ifp, ia, &addr, pr->prefix_len, vltime,
+			               pr->pltime, router_index, pr - nd6_prefix,
+			               IN6_IFF_AUTOCONF | IN6_IFF_NODAD);
+			}
+		}
+
+	else { /* æªç»é²ã®ã¨ã */
+
+		/*
+		 *  ãã¬ãã£ãã¯ã¹é·ããã§ãã¯ããã
+		 *  ããããã¬ãã£ãã¯ã¹é·ã¨ã¤ã³ã¿ãã§ã¼ã¹ ID ã®åè¨ã
+		 *  128 ãããã«ä¸è´ããªãæã¯ããã¬ãã£ãã¯ã¹æ
+å ±ãç¡è¦ããã
+		 */
+		if ((ifidlen = in6_if2idlen(ifp)) < 0)
+			syslog(LOG_ERROR, "[ND6 RTR] IFID undefined.");
+		else if (ifidlen + pr->prefix_len != 128)
+			syslog(LOG_NOTICE, "[ND6 RTR] invalid prefix len: %d.", pr->prefix_len);
+		else {
+
+			for (ix = NUM_IN6_IFADDR_ENTRY; ix --; ) {
+				ia = &ifp->in6_ifaddrs[ix];
+				if ((ia->flags & IN6_IFF_DEFINED) == 0) {
+					in6_ifadd(pr, ia, router_index);
+					pfxlist_onlink_check();
+					break;
+					}
+				}
+
+			if (ix < 0)
+				syslog(LOG_ERROR, "[ND6 RTR] prefix update failed.");
+			}
+		}
+	syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+	}
+
+/*
+ *  nd6_prelist_timer -- ãã¬ãã£ãã¯ã¹ã»ãªã¹ãã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+nd6_prelist_timer (void)
+{
+	T_ND6_PREFIX	*pr;
+	SYSTIM		now;
+	int_t		ix;
+
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;		/* æå¹æéã®åä½ã¯ [s] */
+
+	syscall(wai_sem(SEM_ND6_DEFRTRLIST));
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_STATE_BUSY) != 0 && (int32_t)(pr->expire - now) <= 0)
+		                                                       /* pr->expire <= now */
+			prelist_remove(pr);
+		}
+	syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+	}
+
+/*
+ *  nd6_rs_output -- ã«ã¼ã¿è¦è«ãåºåããã
+ */
+
+static void
+nd6_rs_output (void)
+{
+	T_ROUTER_SOLICIT_HDR	*rsh;
+	T_NET_BUF		*output;
+	T_IN6_IFADDR		*ifa;
+	const T_IN6_ADDR	*saddr;
+	uint16_t		len;
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_RS_OUT_PACKETS], 1);
+
+	/*
+	 *  éä¿¡å
+ã¢ãã¬ã¹ã«ã¯ããªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ãè¨­å®ãããã
+	 *  ã¾ã è¨­å®ããããªããã°ãç¡æå®ãè¨­å®ããã
+	 */
+	if ((ifa = in6ifa_ifpwithix(IF_GET_IFNET(), IPV6_IFADDR_IX_LINKLOCAL)) != NULL && !IFA6_IS_NOTREADY(ifa))
+		saddr = &ifa->addr;
+	else
+		saddr = &in6_addr_unspecified;
+
+	len = (ROUTER_SOLICIT_HDR_SIZE + 7) >> 3 << 3;
+
+	/* ãããã¯ã¼ã¯ãããã¡ãç²å¾ããIPv6 ããããè¨­å®ããã*/
+	if (in6_get_datagram(&output, len, 0, &in6_addr_linklocal_allrouters,
+	                     saddr, IPPROTO_ICMPV6,
+	                     IPV6_MAXHLIM, NBA_SEARCH_ASCENT, TMO_ND6_RS_OUTPUT) != E_OK)
+		return;
+
+ 	/* ã«ã¼ã¿è¦è«ããããè¨­å®ããã*/
+ 	rsh = GET_ROUTER_SOLICIT_HDR(output, IF_IP6_ROUTER_SOLICIT_HDR_OFFSET);
+ 	rsh->hdr.type       = ND_ROUTER_SOLICIT;
+ 	rsh->hdr.code       = 0;
+ 	rsh->nd_rs_reserved = 0;
+
+	/* ãã§ãã¯ãµã ãè¨ç®ããã*/
+	rsh->hdr.sum = 0;
+	rsh->hdr.sum = in6_cksum(output, IPPROTO_ICMPV6, (uint8_t*)rsh - output->buf, len);
+
+	/* éä¿¡ããã*/
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_OCTETS],
+	               output->len - GET_IF_IP6_HDR_SIZE(output));
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_OUT_PACKETS], 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutMsgs, 1);
+	NET_COUNT_MIB(icmp6_ifstat.ipv6IfIcmpOutRouterSolicits, 1);
+	ip6_output(output, IPV6_OUT_SET_HOP_LIMIT(IPV6_OUT_FLG_HOP_LIMIT, IPV6_MAXHLIM), TMO_ND6_RS_OUTPUT);
+	}
+
+/*
+ *  nd6_defrtrlist_lookup -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ããæ¢ç´¢ããã
+ */
+
+T_DEF_ROUTER *
+nd6_defrtrlist_lookup (const T_IN6_ADDR *src)
+{
+	T_DEF_ROUTER	*dr = NULL;
+	int_t		ix;
+
+	for (ix = def_router_count; ix -- > 0; ) {
+		dr = &nd6_def_router[ix];
+		if (IN6_ARE_ADDR_EQUAL(&dr->addr, src)) {
+			return dr;
+			}
+		}
+	return NULL;
+	}
+
+/*
+ *  nd6_router_lookup -- ã«ã¼ã¿ã®ã¢ãã¬ã¹ãè¿ãã
+ *
+ */
+
+const T_IN6_ADDR *
+nd6_router_lookup (void)
+{
+	if (def_router_count > 0)
+		return &nd6_def_router[0].addr;
+	else
+		return NULL;
+	}
+
+/*
+ *  nd6_defrtrlist_del -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãããã«ã¼ã¿ãåé¤ããã
+ *
+ *    æ³¨æ: ãã®é¢æ°ãå¼ã³åºãã¨ãã¯ãSEM_ND6_DEFRTRLIST ã§ã
+ *          ã­ãã¯ãã¦ããå¼ã³åºããã¨ã
+ */
+
+void
+nd6_defrtrlist_del (T_DEF_ROUTER *dr)
+{
+	T_IFNET		*ifp = IF_GET_IFNET();
+	T_IN6_IFADDR	*ia;
+	T_ND6_PREFIX	*pr;
+	uint_t		mask;
+	int_t		ix, rix, pix, rtrix = dr - nd6_def_router;
+
+	if ((ia = in6ifa_ifpwithrtrix(ifp, rtrix)) != NULL) {
+		/*
+		 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ãã¬ãã£ãã¯ã¹ãéç¥ãã
+		 *  ã«ã¼ã¿ãå°éä¸è½ã«ããã
+		 */
+		ia->router_index = IN6_RTR_IX_UNREACH;
+		}
+
+	/* ãã¬ãã£ãã¯ã¹ãªã¹ãããã«ã¼ã¿ãåé¤ããã*/
+	mask = make_mask(rtrix);
+	for (pix = NUM_ND6_PREFIX_ENTRY; pix --; )
+		nd6_prefix[pix].routermap &= ~mask;
+
+	/* åé¤ããã«ã¼ã¿ä»¥éãåã«è©°ããã*/
+	for (rix = rtrix + 1; rix < def_router_count; rix ++)
+		nd6_def_router[rix - 1] = nd6_def_router[rix];
+
+	/* ãã¬ãã£ãã¯ã¹ãªã¹ãã®ã«ã¼ã¿ãæ´æ°ããã*/
+	if (dr != nd6_def_router) {
+
+		/* ãã¹ã¯ãçæããã*/
+		mask = 1;
+		for (ix = rtrix - 1; ix -- > 0; )
+			mask = (mask << 1) | 1;
+
+		for (pix = NUM_ND6_PREFIX_ENTRY; pix --; ) {
+			pr = &nd6_prefix[pix];
+			pr->routermap = (pr->routermap & mask) | (((pr->routermap & ~mask) >> 1) & ~mask);
+			}
+		}
+	def_router_count --;
+
+	/* ãã¬ãã£ãã¯ã¹ã®ãªã³ãªã³ã¯ç¶æ
+ãç¢ºèªããã*/
+	pfxlist_onlink_check();
+
+	/*
+	 *  åé¤ããã«ã¼ã¿ãåªå
+ãã£ãã©ã«ãã«ã¼ã¿ã®å ´åã¯ã
+	 *  åªå
+ãã£ãã©ã«ãã«ã¼ã¿ãé¸æããªããã
+	 */
+	if (rtrix == 0)
+		defrouter_select();
+	}
+
+/*
+ *  nd6_defrtrlist_timer -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãã®ç®¡çã¿ã¤ãã¼
+ */
+
+void
+nd6_defrtrlist_timer (void)
+{
+	T_DEF_ROUTER	*dr;
+	SYSTIM		now;
+	int_t		ix;
+
+	syscall(get_tim(&now));
+
+	syscall(wai_sem(SEM_ND6_DEFRTRLIST));
+	for (ix = def_router_count; ix -- > 0; ) {
+		dr = &nd6_def_router[ix];
+		if ((int32_t)(dr->expire - now) <= 0) {
+		           /* dr->expire <= now */
+			nd6_defrtrlist_del(dr);
+			}
+		}
+	syscall(sig_sem(SEM_ND6_DEFRTRLIST));
+	}
+
+/*
+ *  nd6_get_drl -- ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ããç²å¾ããã
+ */
+
+const T_DEF_ROUTER *
+nd6_get_drl (uint_t *count)
+{
+	*count = def_router_count;
+	return nd6_def_router;
+	}
+
+/*
+ *  nd6_get_prl -- ãã¬ãã£ãã¯ã¹ã»ãªã¹ããç²å¾ããã
+ */
+
+const T_ND6_PREFIX *
+nd6_get_prl (void)
+{
+	return nd6_prefix;
+	}
+
+#endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+/*
+ *  nd6_ra_input -- ã«ã¼ã¿éç¥ã®å
+¥åå¦çã
+ */
+
+void
+nd6_ra_input (T_NET_BUF *input, uint_t off)
+{
+#if NUM_ND6_DEF_RTR_ENTRY > 0
+
+	T_IFNET			*ifp = IF_GET_IFNET();
+	T_IP6_HDR		*ip6h;
+	T_ROUTER_ADVERT_HDR	*rah;
+	T_ND_OPT_HDR		*opth;
+	SYSTIM			now;
+	int_t			rix;
+	uint_t			lladdr_len = 0;
+	uint32_t		advrea;
+	uint8_t			*lladdr = NULL;
+	uint8_t			nd_opt_off[ND_OPT_OFF_ARRAY_SIZE];
+
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_RA_IN_PACKETS], 1);
+
+	ip6h = GET_IP6_HDR(input);
+
+	/*
+	 *  ãããã®ãã§ãã¯ãä»¥ä¸ã®å ´åã¯ç ´æ£ããã
+	 *    ã»ããããªãããã IPV6_MAXHLIM (255) ä»¥å¤
+	 *    ã»ãããé·ãç­ã
+	 *    ã»å§ç¹ã¢ãã¬ã¹ãããªã³ã¯ã­ã¼ã«ã«ã§ã¯ãªã (RFC2461)
+	 */
+	if (ip6h->hlim != IPV6_MAXHLIM                ||
+	    input->len - off < ROUTER_ADVERT_HDR_SIZE ||
+	    !IN6_IS_ADDR_LINKLOCAL(&ip6h->src))
+		goto err_ret;
+
+	rah  = GET_ROUTER_ADVERT_HDR(input, off);
+
+	/* è¿é£æ¢ç´¢ãªãã·ã§ã³ã®ãªãã»ãããè¨é²ããã*/
+	if (nd6_options(nd_opt_off, input->buf + (off + ROUTER_ADVERT_HDR_SIZE),
+	                            input->len - (off + ROUTER_ADVERT_HDR_SIZE)) != E_OK)
+		goto err_ret;
+	/*
+	 *  å°éå¯è½ç¶æ
+ã®æå¹æéã®æ´æ°
+
+	 */
+	if (rah->reachable) {
+		advrea = ntohl(rah->reachable) * SYSTIM_HZ / 1000;	/* rah->reachable ã®åä½ã¯ ms */
+		if (advrea <= ND6_MAX_REACHABLE_TIME &&
+		    advrea != nd6_base_reachable_time) {
+			syscall(get_tim(&now));
+			nd6_recalc_reachtm_interval
+				= now + ND6_RECALC_REACHTM_INTERVAL;
+			nd6_base_reachable_time	= advrea;
+			nd6_reachable_time
+				= ND6_CALC_REACH_TIME(nd6_base_reachable_time);
+			}
+		}
+
+	/* è¿é£æ¢ç´¢ã®éä¿¡ééã®æ´æ° */
+	if (rah->retransmit) {
+		nd6_retrans_time = ntohl(rah->retransmit) * SYSTIM_HZ / 1000;
+									/* rah->retransmit ã®åä½ã¯ ms */
+		}
+
+	/* ããããªãããã®è¦å®å¤ã®æ´æ° */
+	if (rah->nd_ra_current_hoplimit) {
+		ip6_defhlim = rah->nd_ra_current_hoplimit;
+		}
+
+	/* ãã£ãã©ã«ãã«ã¼ã¿ãªã¹ãã®æ´æ° */
+	rix = defrtrlist_update(&ip6h->src,
+	                       ntohs(rah->nd_ra_router_lifetime),
+	                       rah->nd_ra_flags);		/* rah->nd_ra_router_lifetime ã®åä½ã¯ç§ */
+
+	/* ãã¬ãã£ãã¯ã¹ãªã¹ãã®æ´æ° */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_PREFIX_INFO_COUNT)]) {
+		T_ND_OPT_PREFIX_INFO	*pi;
+		uint_t			pi_off, pi_count;
+
+		pi_count = nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_PREFIX_INFO_COUNT)];
+		pi_off   = off + ROUTER_ADVERT_HDR_SIZE
+		               + nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_PREFIX_INFORMATION)] - 8;
+	 	/* æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã*/
+		while (pi_count -- > 0) {
+			pi = (T_ND_OPT_PREFIX_INFO*)(input->buf + pi_off);
+			if (pi->type != ND_OPT_PREFIX_INFORMATION)
+				/* ãªãã·ã§ã³ã¿ã¤ãããã¬ãã£ãã¯ã¹æ
+å ±ã§ãªããã°ä½ãããªãã*/
+				;
+			else if (pi->len != 4)
+			    	/* ãã¬ãã£ãã¯ã¹æ
+å ±ã®é·ãã 32 (8Ã4) ã§ãªããã°ä¸æ­£ */
+				syslog(LOG_NOTICE, "[ND6 RTR] prefix opt len: %d.", pi->len);
+			else if (pi->prefix_len > 128)
+				/* ãã¬ãã£ãã¯ã¹é·ã¯ 128 ãããä»¥ä¸ */
+				syslog(LOG_NOTICE, "[ND6 RTR] prefix len: %d.", pi->prefix_len);
+			else if (IN6_IS_ADDR_MULTICAST(&pi->prefix) ||
+			         IN6_IS_ADDR_LINKLOCAL(&pi->prefix))
+				/* ãã«ãã­ã£ã¹ãã¨ãªã³ã¯ã­ã¼ã«ã«ã¯ä¸æ­£ */
+				syslog(LOG_NOTICE, "[ND6 RTR] invalid addr: %s from %s.",
+				                   ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#if 0	/* FreeBSD 6.3 ã§åé¤ããã¦ããã*/
+			else if (IN6_IS_ADDR_AGGREGATE_UNICAST(&pi->prefix) &&		
+			         (pi->prefix_len != 64)                       )
+				/* éç´å¯è½ã¦ãã­ã£ã¹ãã§ããã¬ãã£ãã¯ã¹é·ã 64 ãããä»¥å¤ã¯ä¸æ­£ */
+				syslog(LOG_NOTICE, "[ND6 RTR] invalid prefix len for global: %d.", pi->prefix_len);
+#endif
+			else if (ntohl(pi->preferred) > ntohl(pi->valid))
+				/* æ¨å¥¨æå¹æéãæå¹æéããé·ããã°ä¸æ­£ */
+				syslog(LOG_NOTICE, "[ND6 RTR] preferred(%d) > valid time(%d).", ntohl(pi->preferred), ntohl(pi->valid));
+			else {
+#if 0	/* ãã¬ãã£ãã¯ã¹ãæªç»é²ã®å ´åã ãè¡¨ç¤ºããã*/
+				syslog(LOG_NOTICE, "[ND6 RTR] update prefix: flags[MOH]: %02x, addr: %s\n"
+				                   "                                         from: %s.",
+				                   rah->nd_ra_flags, ipv62str(NULL, &pi->prefix), ipv62str(NULL, &ip6h->src));
+#endif
+				if (rix >= 0) {
+					/*
+					 *  defrtrlist_update ã®æ»ãå¤ã¯ãã«ã¼ã¿ã®ã¤ã³ããã¯ã¹ã
+					 *  ãã ããå¤ã -1 ãªãããã¬ãã£ãã¯ã¹ã»ãªã¹ãã¯æ´æ°ããªãã
+					 */
+					prelist_update(pi, rix);	/* ãã¬ãã£ãã¯ã¹ã»ãªã¹ããæ´æ°ããã*/
+					}
+				}
+			pi_off += pi->len << 3;		/* ãªãã·ã§ã³é·ã®åä½ã¯ 8 ãã¤ã */
+			}
+		}
+
+	/* MTU ã®æ´æ° */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_MTU)]) {
+		T_ND_OPT_MTU_HDR	*optmtuh;
+		uint32_t			mtu;
+
+		optmtuh = (T_ND_OPT_MTU_HDR *)((uint8_t *)(input->buf + off + ROUTER_ADVERT_HDR_SIZE) +
+		                               nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_MTU)] - 8);
+
+		/*
+		 *  å¤ã®ãã§ãã¯
+		 *
+		 *    ãªãã·ã§ã³é·: 1
+		 *    äºç´:         0
+		 */
+		if (optmtuh->len != 1 || optmtuh->reserved != 0)
+			goto err_ret;
+
+		/* MTU ã IPv6 MMTUï¼1280 ãªã¯ãããï¼ä»¥ä¸ãªãç¡è¦ããã*/
+		mtu = ntohl(optmtuh->mtu);
+		if (mtu >= IPV6_MMTU) {
+			if (mtu <= (linkmtu > IF_MTU ? linkmtu : IF_MTU))
+				linkmtu = mtu;
+			}
+		}
+
+	/*
+	 *  ã«ã¼ã¿ã®å§ç¹ãªã³ã¯ã¢ãã¬ã¹ãè¿é£ã­ã£ãã·ã¥ã«ç»é²ããã
+	 */
+	if (nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_SOURCE_LINKADDR)]) {
+		opth = (T_ND_OPT_HDR *)((uint8_t *)(input->buf + off + ROUTER_ADVERT_HDR_SIZE) +
+		                        nd_opt_off[ND_OPT_OFF_ARRAY_IX(ND_OPT_SOURCE_LINKADDR)] - 8);
+	 	/* æ³¨æ: ãªãã·ã§ã³ãªãã»ããé
+åã«ã¯ããªãã»ãã + 8 ãè¨­å®ããã¦ããã*/
+		lladdr     = (uint8_t *)(opth + 1);
+		lladdr_len = (opth->len << 3);
+		}
+
+	/*
+	 *  ãããã¯ã¼ã¯ã¤ã³ã¿ãã§ã¼ã¹ã®ã¢ãã¬ã¹é·ãä¸è´ããªããã°ã¨ã©ã¼
+	 */
+	if (lladdr && lladdr_len != ((sizeof(T_IF_ADDR) + sizeof(T_ND_OPT_HDR) + 7) & ~7))
+		goto err_ret;
+
+	/* è¿é£ã­ã£ãã·ã¥ã«ç»é²ããã*/
+	nd6_cache_lladdr(ifp, &ip6h->src, (T_IF_ADDR *)lladdr, ND_ROUTER_ADVERT, 0);
+
+	/*
+	 *  ã«ã¼ã¿ã®å§ç¹ãªã³ã¯ã¢ãã¬ã¹ãè¿é£ã­ã£ãã·ã¥ã«ç»é²ããã®ã§ã
+	 *  ãªã³ãªã³ã¯ç¶æ
+ãå¤åããå¯è½æ§ããããããããããã§ãã¯ããã
+	 */
+	pfxlist_onlink_check();
+
+	syscall(rel_net_buf(input));
+	return;
+
+err_ret:
+	NET_COUNT_ICMP6(net_count_nd6[NC_ICMP6_IN_ERR_PACKETS], 1);
+	syscall(rel_net_buf(input));
+
+#else	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+
+	/*
+	 *  ã«ã¼ã¿éç¥ãåä¿¡ããªãå ´åã¯ãç ´æ£ãã¦çµäºããã
+	 */
+	NET_COUNT_ICMP6(net_count_nd6[NC_ND6_RA_IN_PACKETS], 1);
+	syscall(rel_net_buf(input));
+
+#endif	/* of #if NUM_ND6_DEF_RTR_ENTRY > 0 */
+	}
+
+#if NUM_ND6_RTR_SOL_RETRY > 0
+
+/*
+ *  nd6_rtrsol_ctl -- ã«ã¼ã¿è¦è«åºåã®å¶å¾¡
+ */
+
+void
+nd6_rtrsol_ctl (void)
+{
+	T_IN6_IFADDR	*ifa;
+	int_t		try;
+
+	/* ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã®ã¢ãã¬ã¹æ
+å ±ãå¾ãã*/
+	if ((ifa = in6ifa_ifpwithix(IF_GET_IFNET(), IPV6_IFADDR_IX_LINKLOCAL)) == NULL)
+		return;
+
+	/* ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã®éè¤æ¤åºçµäºãå¾
+ã¤ã*/
+	do {
+		/* ãªã³ã¯ã­ã¼ã«ã«ã¢ãã¬ã¹ã®éè¤æ¤åºçµäºå¾
+ã¡æéãè¨­å®ããã*/
+		syscall(dly_tsk(net_rand() % TMO_ND6_RTR_SOL_DELAY));
+
+		/* å¾
+ã£ã¦ããéã«éè¤ãæ¤åºããããçµäºããã*/
+		if (ifa->flags & IN6_IFF_DUPLICATED)
+			return;
+
+		} while (!((ifa->flags & IN6_IFF_DEFINED) && (ifa->flags & IN6_IFF_TENTATIVE) == 0));
+
+	for (try = 0; try < NUM_ND6_RTR_SOL_RETRY; try ++) {
+
+		/* ãã£ãã©ã«ãã«ã¼ã¿ã»ãªã¹ãã«ã¨ã³ããªãããã°çµäº */
+		if (def_router_count > 0)
+			return;
+
+		/* ã«ã¼ã¿è¦è«ãåºåããã*/
+		nd6_rs_output();
+
+		/* åºåã® 2 åç®ä»¥éã®é
+å»¶æéãè¨­å®ããã*/
+		syscall(dly_tsk(TMO_ND6_RTR_SOL_INTERVAL));
+		}
+	}
+
+#endif	/* of #if NUM_ND6_RTR_SOL_RETRY > 0 */
+
+/*
+ *  nd6_onlink_prefix_lookup -- ãã¬ãã£ãã¯ã¹ãæ¢ç´¢ããã
+ */
+
+T_ND6_PREFIX *
+nd6_onlink_prefix_lookup (const T_IN6_ADDR *dst)
+{
+	SYSTIM		now;
+	T_ND6_PREFIX	*pr;
+	int_t		ix;
+
+	syscall(get_tim(&now));
+	now /= SYSTIM_HZ;
+
+	/* æ¨å¥¨æå¹æéå
+ã®ãã¬ãã£ãã¯ã¹ãæ¢ç´¢ããã*/
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_STATE_BUSY)  &&
+		    (pr->flags & ND6_PREFIX_FLAG_ONLINK) &&
+		    in6_are_prefix_equal(dst, &pr->prefix, pr->prefix_len) &&
+		    (int32_t)(pr->preferred - now) > 0) {
+		           /* pr->preferred > now */
+			return pr;
+			}
+		}
+
+	/* æå¹æéå
+ã®ãã¬ãã£ãã¯ã¹ãæ¢ç´¢ããã*/
+	for (ix = NUM_ND6_PREFIX_ENTRY; ix -- > 0; ) {
+		pr = &nd6_prefix[ix];
+		if ((pr->flags & ND6_PREFIX_STATE_BUSY)  &&
+		    (pr->flags & ND6_PREFIX_FLAG_ONLINK) &&
+		    in6_are_prefix_equal(dst, &pr->prefix, pr->prefix_len) &&
+		    (int32_t)(pr->expire - now) > 0) {
+		           /* pr->expire > now */
+			return pr;
+			}
+		}
+
+	return NULL;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/route6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/route6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/route6.c	(revision 317)
@@ -0,0 +1,249 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/route6.c,v 1.6 2002/10/16 01:54:45 sam Exp $	*/
+/*	$KAME: route6.c,v 1.24 2001/03/14 03:07:05 itojun Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/if.h>
+#include <net/if_loop.h>
+#include <net/if_ppp.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/ppp_ipcp.h>
+#include <net/net_buf.h>
+#include <net/net_count.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/ip_icmp.h>
+#include <netinet6/nd6.h>
+
+#ifdef _IP6_CFG
+
+#if 0
+/*
+ *  éä¿¡å¸¯åãé£ãã¤ã¶ãæ»æã¸ã®å¯¾å¿ã®ããã
+ *  ã¿ã¤ã 0 çµè·¯å¶å¾¡ãããã®å¦çãè¡ããªãã
+ */
+
+/*
+ *  ip6_rthdr0 -- ã¿ã¤ã 0 çµè·¯å¶å¾¡ãããã®å
+¥åé¢æ°
+ */
+
+static ER
+ip6_rthdr0 (T_NET_BUF *input, T_IP6_RT0_HDR *rt0h)
+{
+	if (rt0h->segleft == 0) {
+		/* ä¸­ç¶ãã¼ãæ°ã¯ 0 ãªã®ã§ãçµç¹ãã¼ã */
+		return E_OK;
+		}
+
+	/* len ã¨ segleft ã®æ­£å½æ§ãã§ãã¯ */
+#ifdef IP6_CFG_COMPAT_RFC1883
+	if ((rt0h->len % 2) || (rt0h->len > 46)) {
+#else
+	if (rt0h->len % 2) {
+#endif
+		/*
+		 *  len ã¯å¶æ°ã§ã(23 * 2) ã¾ã§ã
+		 *  ãã ãã(23 * 2) ã®å¶éã¯ RFC 2462 ã§åé¤ããã¦ããã
+		 */
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   ((uint8_t*)&rt0h->len - input->buf) - IF_HDR_SIZE);
+		return E_PAR;
+		}
+
+	/* len ãä¸­ç¶ãã¼ãæ°ã¨çç¾ãã¦ããªãããã§ãã¯ããã*/
+	if ((rt0h->len / 2) < rt0h->segleft) {
+		/*
+		 *  len ã¯ 8ãªã¯ãããåä½ãsegleft ã¯ 16ãªã¯ãããåä½ãªã®ã§ã
+		 *  len / 2 == segleft ã¨ãªãã¯ãã
+		 *  len / 2 <  segleft ã¯ã¨ã©ã¼ã
+		 */
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   ((uint8_t*)&rt0h->segleft - input->buf) - IF_HDR_SIZE);
+		return E_PAR;
+		}
+
+	/*
+	 *  æ®ãã®ä¸­ç¶ãã¼ãæ°ã 1 ä»¥ä¸ã§ããã°ããã®ãã¼ãã¯æçµçãª
+	 *  çµç¹ãã¼ãã§ã¯ãªããæ¬å®è£
+ã§ã¯ãä¸­ç¶ãããªãã®ã§ã
+	 *  å
+¥åãã¼ã¿ã°ã©ã ã®å¦çãçµäºããã
+	 */
+	syscall(rel_net_buf(input));
+	return E_PAR;
+	}
+
+#endif
+
+/*
+ *  route6_input -- çµè·¯å¶å¾¡ãããã®å
+¥åé¢æ°
+ */
+
+uint_t
+route6_input (T_NET_BUF **inputp, uint_t *offp, uint_t *nextp)
+{
+	T_NET_BUF	*input = *inputp;
+	T_IP6_RT_HDR	*rth;
+	uint_t		len, off = *offp;
+
+	/* ãããã¯ã¼ã¯ãããã¡ã®æ®ãã®é·ãããã§ãã¯ããã*/
+	if (input->len - off < sizeof(T_IP6_RT_HDR))
+		goto buf_rel;
+
+	rth = (T_IP6_RT_HDR *)(input->buf + off);
+	len = (rth->len + 1) << 3;
+
+	/* çµè·¯å¶å¾¡ãããã®é·ãããã§ãã¯ããã*/
+	if (input->len < off + len)
+		goto buf_rel;
+
+#if 0
+	/*
+	 *  éä¿¡å¸¯åãé£ãã¤ã¶ãæ»æã¸ã®å¯¾å¿ã®ããã
+	 *  ã¿ã¤ã 0 çµè·¯å¶å¾¡ãããã®å¦çãè¡ããªãã
+	 */
+	if (rth->type == IPV6_RTHDR_TYPE_0) {
+		if (ip6_rthdr0(input, (T_IP6_RT0_HDR*)rth) != E_OK) {
+
+			/* ã¨ã©ã¼ã®å ´åã¯ãip6_rthdr0 ã§ãããã¡ãéæ¾ãã¦ããã*/
+			return IPPROTO_DONE;
+			}
+		}
+	else if (rth->segleft != 0) {
+
+		/*
+		 *  æ®ãã®ä¸­ç¶ãã¼ãæ°ã 1 ä»¥ä¸ã§ããã°ããã®ãã¼ãã¯æçµçãª
+		 *  çµç¹ãã¼ãã§ã¯ãªããæ¬å®è£
+ã§ã¯ãä¸­ç¶ãããªãã®ã§ã
+		 *  ICMP6 ã¨ã©ã¼ãè¿éãã¦å¦çãçµäºããã
+		 */
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   ((uint8_t*)&rth->type - input->buf) - IF_HDR_SIZE);
+		return IPPROTO_DONE;
+		}
+#else
+	if (rth->segleft != 0) {
+
+		/*
+		 *  æ®ãã®ä¸­ç¶ãã¼ãæ°ã 1 ä»¥ä¸ã§ããã°ããã®ãã¼ãã¯æçµçãª
+		 *  çµç¹ãã¼ãã§ã¯ãªããæ¬å®è£
+ã§ã¯ãä¸­ç¶ãããªãã®ã§ã
+		 *  ICMP6 ã¨ã©ã¼ãè¿éãã¦å¦çãçµäºããã
+		 */
+		icmp6_error(input, ICMP6_PARAM_PROB,
+		                   ICMP6_PARAMPROB_HEADER,
+		                   ((uint8_t*)&rth->type - input->buf) - IF_HDR_SIZE);
+		return IPPROTO_DONE;
+		}
+#endif
+
+	*nextp = *offp - IF_HDR_SIZE + offsetof(T_IP6_RT_HDR, next);
+	*offp += len;
+	return rth->next;
+
+buf_rel:
+	syscall(rel_net_buf(input));
+	return IPPROTO_DONE;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/scope6.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/scope6.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/scope6.c	(revision 317)
@@ -0,0 +1,186 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*	$FreeBSD: src/sys/netinet6/in6.c,v 1.21 2002/04/19 04:46:22 suz Exp $	*/
+/*	$KAME: in6.c,v 1.259 2002/01/21 11:37:50 keiichi Exp $	*/
+
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * 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 project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1991, 1993
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *	@(#)in.c	8.2 (Berkeley) 11/15/93
+ */
+
+#include <string.h>
+
+#ifdef TARGET_KERNEL_ASP
+
+#include <kernel.h>
+#include <sil.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include <s_services.h>
+#include <t_services.h>
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+
+#include <netinet6/in6.h>
+#include <netinet6/in6_var.h>
+
+#ifdef _IP6_CFG
+
+/*
+ *  in6_addrscope -- ã¢ãã¬ã¹ã®ã¹ã³ã¼ã ID ãè¿ãã
+ */
+
+uint_t
+in6_addrscope (const T_IN6_ADDR *addr)
+{
+	uint_t scope;
+
+	if (addr->s6_addr8[0] == 0xfe) {
+		if      ((addr->s6_addr8[1] & 0xc0) == 0x80)
+			return IPV6_ADDR_SCOPE_LINKLOCAL;
+		else if ((addr->s6_addr8[1] & 0xc0) == 0xc0)
+			return IPV6_ADDR_SCOPE_SITELOCAL;
+		else
+			return IPV6_ADDR_SCOPE_GLOBAL;
+		}
+
+	else if (addr->s6_addr8[0] == 0xff) {
+		scope = addr->s6_addr8[1] & 0x0f;
+		if (scope == IPV6_ADDR_SCOPE_NODELOCAL ||
+		    scope == IPV6_ADDR_SCOPE_SITELOCAL ||
+		    scope == IPV6_ADDR_SCOPE_SITELOCAL)
+			return scope;
+		else
+			return IPV6_ADDR_SCOPE_GLOBAL;
+		}
+
+	else if (memcmp(addr, &in6_addr_unspecified, sizeof(T_IN6_ADDR) - 1) == 0) {
+		if      (addr->s6_addr8[15] == 1)
+			return IPV6_ADDR_SCOPE_NODELOCAL;
+		else if (addr->s6_addr8[15] == 0)
+			return IPV6_ADDR_SCOPE_LINKLOCAL;
+		}
+
+	return IPV6_ADDR_SCOPE_GLOBAL;
+	}
+
+#endif /* of #ifdef _IP6_CFG */
Index: asp3_gr_sakura/trunk/tinet/netinet6/udp6_input.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/udp6_input.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/udp6_input.c	(revision 317)
@@ -0,0 +1,136 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ *  udp_reply_no_port -- éä¿¡å
+ã«ãã¼ããå®ç¾©ããã¦ããªããã¨ãéç¥ããã
+ */
+
+void
+UDP_REPLY_NO_PORT (T_NET_BUF *input, uint_t off)
+{
+	T_UDP_HDR	*udph;
+
+	udph = (T_UDP_HDR *)(input->buf + off);
+
+#if defined(_IP4_CFG)
+
+	if (GET_IP_VER(input)==IPV6_VERSION) {
+
+		/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+		if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+			icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+			}
+		else
+			syscall(rel_net_buf(input));
+		}
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+
+		/* ã­ã¼ã«ã« IP ã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã®ã¿ ICMP ã¨ã©ã¼ãéç¥ããã*/
+		if (ntohl(GET_IP4_HDR(input)->dst) == IF_GET_IFNET()->in4_ifaddr.addr) {
+			syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+			icmp_error(ICMP4_UNREACH_PORT, input);
+			/* icmp_error ã§ã¯ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããªãã®ã§ä¸ã¸æããã*/
+			}
+		syscall(rel_net_buf(input));
+		}
+
+#else	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+
+	/* ãã«ãã­ã£ã¹ãã¢ãã¬ã¹ã«å±ãããã¼ã¿ã°ã©ã ã¯ ICMP ã¨ã©ã¼ãéç¥ããªãã*/
+	if (!IN6_IS_ADDR_MULTICAST(&GET_IP6_HDR(input)->dst)) {
+		syslog(LOG_INFO, "[UDP] unexp port: %d.", ntohs(udph->dport));
+
+		/* icmp6_error ã§ããããã¯ã¼ã¯ãããã¡ input ãè¿å´ããã*/
+		icmp6_error(input, ICMP6_DST_UNREACH, ICMP6_DST_UNREACH_NOPORT, 0);
+		}
+	else
+		syscall(rel_net_buf(input));
+
+#endif	/* of #if defined(_IP4_CFG) */
+
+	NET_COUNT_UDP(net_count_udp.in_err_packets, 1);
+	NET_COUNT_MIB(udp_stats.udpInErrors, 1);
+	NET_COUNT_MIB(udp_stats.udpNoPorts, 1);
+	}
Index: asp3_gr_sakura/trunk/tinet/netinet6/udp6_subr.c
===================================================================
--- asp3_gr_sakura/trunk/tinet/netinet6/udp6_subr.c	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/netinet6/udp6_subr.c	(revision 317)
@@ -0,0 +1,172 @@
+/*
+ *  TINET (UDP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1988, 1990, 1993, 1995
+ *	The Regents of the University of California.  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 ceproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ */
+
+/*
+ *  udp6_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã«ãã­ã£ã¹ã
+ */
+
+static bool_t
+udp6_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IP6_HDR	*ip6h;
+
+	ip6h = GET_IP6_HDR(input);
+
+	if (IN6_IS_ADDR_MULTICAST(&ip6h->dst))
+		return true;
+	else
+		return INN6_IS_DSTADDR_ACCEPT(myaddr, input);
+	}
+
+#if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR)
+
+#ifdef DHCP_CFG
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    DHCP_CFG ãå®ç¾©ããã¦ããã¨ãã¯ãä»¥ä¸ã®ãã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ *      ã»ã­ã¼ã«ã«ã¢ãã¬ã¹ãæªå®ç¾©
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input)==IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input)==IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ifp->in4_ifaddr.addr == IPV4_ADDRANY    ||
+		    ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#else	/* of #ifdef DHCP_CFG */
+
+/*
+ *  udpn_is_dstaddr_accept -- UDP ã®ãã¦å
+ã¢ãã¬ã¹ãæ­£ããããã§ãã¯ããã
+ *
+ *    ä»¥ä¸ã®å ´åããã¼ã¿ã°ã©ã ãåä¿¡ããã
+ *
+ *      ã»ãã¦å
+ã¢ãã¬ã¹ããã­ã¼ãã­ã£ã¹ã
+ */
+
+static bool_t
+udpn_is_dstaddr_accept (T_IN6_ADDR *myaddr, T_NET_BUF *input)
+{
+	T_IFNET *ifp = IF_GET_IFNET();
+
+	if        (GET_IP_VER(input) == IPV6_VERSION)
+		return udp6_is_dstaddr_accept(myaddr, input);
+	else /*if (GET_IP_VER(input) == IPV4_VERSION)*/ {
+		T_IP4_HDR	*ip4h;
+
+		ip4h = GET_IP4_HDR(input);
+
+		if (ntohl(ip4h->dst) == IPV4_ADDR_BROADCAST ||
+		    ntohl(ip4h->dst) == ((ifp->in4_ifaddr.addr & ifp->in4_ifaddr.mask) | ~ifp->in4_ifaddr.mask))
+			return true;
+		else
+			return inn_is_dstaddr_accept(myaddr, input);
+		}
+	}
+
+#endif	/* of #ifdef DHCP_CFG */
+
+#endif	/* of #if defined(_IP4_CFG) && defined(API_CFG_IP4MAPPED_ADDR) */
Index: asp3_gr_sakura/trunk/tinet/tcpip_api.def
===================================================================
--- asp3_gr_sakura/trunk/tinet/tcpip_api.def	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tcpip_api.def	(revision 317)
@@ -0,0 +1,12 @@
+TCP_CRE_REP  #tcp4_repid* { .tcp4_repatr { &ipv4addr &portno } }  
+TCP6_CRE_REP #tcp6_repid* { .tcp6_repatr { &ipv6addr &portno } }  
+TCP_CRE_CEP  #tcp4_cepid* { .tcp4_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }  
+TCP6_CRE_CEP #tcp6_cepid* { .tcp6_cepatr &sbuf &sbufsz &rbuf &rbufsz &callback }  
+UDP_CRE_CEP  #udp4_cepid* { .udp4_cepatr { &ipv4addr &portno } &callback }  
+UDP6_CRE_CEP #udp6_cepid* { .udp6_cepatr { &ipv6addr &portno } &callback }  
+VRID_TCP_REP  #vrid_tcp4_repid*  
+VRID_TCP_CEP  #vrid_tcp4_cepid*  
+VRID_TCP6_REP #vrid_tcp6_repid*  
+VRID_TCP6_CEP #vrid_tcp6_cepid*  
+VRID_UDP_CEP  #vrid_udp4_cepid*  
+VRID_UDP6_CEP #vrid_udp6_cepid*  
Index: asp3_gr_sakura/trunk/tinet/tcpip_sym.def
===================================================================
--- asp3_gr_sakura/trunk/tinet/tcpip_sym.def	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tcpip_sym.def	(revision 317)
@@ -0,0 +1,81 @@
+TA_HLNG
+TA_TFIFO
+TA_WSGL
+NUM_IPV4ADDR_STR_BUFF
+NUM_IPV4ADDR_STR_BUFF
+NUM_IPV6ADDR_STR_BUFF
+NUM_MACADDR_STR_BUFF
+NUM_MACADDR_STR_BUFF
+TMO_IP4_FRAG_GET_NET_BUF
+TMO_IP6_FRAG_GET_NET_BUF
+TMO_PPP_GET_NET_BUF
+TMO_ARP_GET_NET_BUF
+TMO_TCP_GET_NET_BUF
+TMO_TCP_OUTPUT
+TMO_UDP_OUTPUT
+TMO_ICMP_OUTPUT
+TMO_ND6_NS_OUTPUT
+TMO_ND6_NA_OUTPUT
+TMO_ND6_RS_OUTPUT
+TMO_ARP_OUTPUT
+TMO_ND6_RTR_SOL_DELAY
+TMO_ND6_RTR_SOL_INTERVAL
+TMO_IN_REDIRECT
+TCP_OUT_TASK_STACK_SIZE
+UDP_OUT_TASK_STACK_SIZE
+PPP_INPUT_STACK_SIZE
+PPP_OUTPUT_STACK_SIZE
+ETHER_INPUT_STACK_SIZE
+ETHER_OUTPUT_STACK_SIZE
+LOOP_INPUT_STACK_SIZE
+LOOP_OUTPUT_STACK_SIZE
+NET_TIMER_STACK_SIZE
+TCP_OUT_TASK_PRIORITY
+UDP_OUT_TASK_PRIORITY
+PPP_INPUT_PRIORITY
+PPP_OUTPUT_PRIORITY
+ETHER_INPUT_PRIORITY
+ETHER_OUTPUT_PRIORITY
+LOOP_INPUT_PRIORITY
+LOOP_OUTPUT_PRIORITY
+NET_TIMER_PRIORITY
+NUM_DTQ_UDP_RCVQ
+NUM_DTQ_UDP_OUTPUT
+NUM_DTQ_PPP_OUTPUT
+NUM_DTQ_ETHER_OUTPUT
+NUM_DTQ_LOOP_INPUT
+NUM_DTQ_LOOP_OUTPUT
+TCP_REP_FLG_DYNAMIC
+TCP_REP_FLG_VALID
+TCP_CEP_FLG_IPV4
+TCP_CEP_FLG_ACK_NOW
+TCP_CEP_FLG_DEL_ACK
+TCP_CEP_FLG_SENT_FIN
+TCP_CEP_FLG_NEED_SYN
+TCP_CEP_FLG_NEED_FIN
+TCP_CEP_FLG_FORCE
+TCP_CEP_FLG_NO_PUSH
+TCP_CEP_FLG_NO_DELAY
+TCP_CEP_FLG_FORCE_CLEAR
+TCP_CEP_FLG_POST_OUTPUT
+TCP_CEP_FLG_RESERVE_OUTPUT
+TCP_CEP_FLG_DYNAMIC
+TCP_CEP_FLG_VALID
+TCP_CEP_FLG_CLOSE_AFTER_OUTPUT
+TCP_CEP_FLG_RESTORE_NEXT_OUTPUT
+TCP_CEP_FLG_WBCS_NBUF_REQ
+TCP_CEP_FLG_WBCS_MASK
+TCP_CEP_FLG_WBCS_FREE
+TCP_CEP_FLG_WBCS_WOPEN_PEND
+TCP_CEP_FLG_WBCS_NBUF_PEND
+TCP_CEP_FLG_WBCS_NBUF_RSVD
+TCP_CEP_FLG_WBCS_NBUF_READY
+TCP_CEP_FLG_WBCS_SEND_READY
+TCP_CEP_FLG_WBCS_SENT
+TCP_CEP_FLG_WBCS_ACKED
+TCP_CEP_FLG_NOT_CLEAR
+TCP_CEP_EVT_ESTABLISHED
+TCP_CEP_EVT_CLOSED
+TCP_CEP_EVT_SWBUF_READY
+TCP_CEP_EVT_RWBUF_READY
+TCP_CEP_EVT_ALL
Index: asp3_gr_sakura/trunk/tinet/tinet.trb
===================================================================
--- asp3_gr_sakura/trunk/tinet/tinet.trb	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tinet.trb	(revision 317)
@@ -0,0 +1,607 @@
+# ======================================================================
+# 
+#   TINET (TCP/IP Protocol Stack)
+# 
+#   Copyright (C) 2001-2007 by Dep. of Computer Science and Engineering
+#                    Tomakomai National College of Technology, JAPAN
+#  
+#   ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#   ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#   å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#   (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#       æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#       ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#   (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#       è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#       ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#       ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#       ã¨ï¼
+#     (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#         ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#   (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#       å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#       ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#       ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#       å
+è²¬ãããã¨ï¼
+#  
+#   æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#   ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#   ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#   ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#   ã®è²¬ä»»ãè² ããªãï¼
+# 
+#   @(#) $Id: tinet.tf 824 2015-12-22 10:05:13Z coas-nagasima $
+#  
+# =====================================================================
+
+# =====================================================================
+# tinet_cfg.h ã®çæ
+# =====================================================================
+
+$tinetCfgH = GenFile.new("tinet_cfg.h")
+$tinetCfgH.add("/* tinet_cfg.h */")
+$tinetCfgH.add("#ifndef _TINET_CFG_H_")
+$tinetCfgH.add("#define _TINET_CFG_H_")
+$tinetCfgH.add()
+
+$tinetCfgH.add("#define TNUM_TCP6_REPID	#{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+$tinetCfgH.add("#define TNUM_TCP4_REPID	#{$cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
+$tinetCfgH.add("#define TNUM_TCP_REPID	#{$cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size + $cfgData[:TCP_CRE_REP].size + $cfgData[:VRID_TCP_REP].size}")
+$tinetCfgH.add()
+
+$tinetCfgH.add("#define TNUM_TCP6_CEPID	#{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+$tinetCfgH.add("#define TNUM_TCP4_CEPID	#{$cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
+$tinetCfgH.add("#define TNUM_TCP_CEPID	#{$cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size + $cfgData[:TCP_CRE_CEP].size + $cfgData[:VRID_TCP_CEP].size}")
+$tinetCfgH.add()
+
+$tinetCfgH.add("#define TNUM_UDP6_CEPID	#{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
+$tinetCfgH.add("#define TNUM_UDP4_CEPID	#{$cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
+$tinetCfgH.add("#define TNUM_UDP_CEPID	#{$cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size + $cfgData[:UDP_CRE_CEP].size + $cfgData[:VRID_UDP_CEP].size}")
+$tinetCfgH.add()
+
+$cfgData[:TCP6_CRE_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp6_repid]}	#{params[:tcp6_repid].val}")
+end
+$cfgData[:VRID_TCP6_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_repid]}	#{params[:vrid_tcp6_repid].val + $cfgData[:TCP6_CRE_REP].size}")
+end
+$cfgData[:TCP_CRE_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp4_repid]}	#{params[:tcp4_repid].val + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+end
+$cfgData[:VRID_TCP_REP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_repid]}	#{params[:vrid_tcp4_repid].val + $cfgData[:TCP_CRE_REP].size + $cfgData[:TCP6_CRE_REP].size + $cfgData[:VRID_TCP6_REP].size}")
+end
+$tinetCfgH.add()
+
+$cfgData[:TCP6_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp6_cepid]}	#{params[:tcp6_cepid].val}")
+end
+$cfgData[:VRID_TCP6_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp6_cepid]}	#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}")
+end
+$cfgData[:TCP_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:tcp4_cepid]}	#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+end
+$cfgData[:VRID_TCP_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_tcp4_cepid]}	#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}")
+end
+$tinetCfgH.add()
+
+$cfgData[:UDP6_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:udp6_cepid]}	#{params[:udp6_cepid].val}")
+end
+$cfgData[:VRID_UDP6_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_udp6_cepid]}	#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}")
+end
+$cfgData[:UDP_CRE_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:udp4_cepid]}	#{params[:udp4_cepid].val + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
+end
+$cfgData[:VRID_UDP_CEP].each do |key, params|
+	$tinetCfgH.add("#define #{params[:vrid_udp4_cepid]}	#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size + $cfgData[:UDP6_CRE_CEP].size + $cfgData[:VRID_UDP6_CEP].size}")
+end
+$tinetCfgH.add()
+$tinetCfgH.add("#endif /* _TINET_CFG_H_ */")
+
+# =====================================================================
+# tinet_cfg.c ã®çæ
+# =====================================================================
+
+$tinetCfgC = GenFile.new("tinet_cfg.c")
+$tinetCfgC.add(<<EOS)
+/* tinet_cfg.c */
+
+#include <kernel.h>
+#include <sil.h>
+#include "kernel_cfg.h"
+#include "tinet_cfg.h"
+#include <tinet_defs.h>
+#include <tinet_config.h>
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/net.h>
+#include <net/net_buf.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/in_itron.h>
+#include <netinet/ip.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+EOS
+# 
+#  ã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ãã£ãï¼#includeï¼
+# 
+$tinetCfgC.add()
+$tinetCfgC.add("/*")
+$tinetCfgC.add(" *  Include Directives (#include)")
+$tinetCfgC.add(" */")
+$tinetCfgC.add()
+$includeFiles.each do |file|
+  $tinetCfgC.add("#include #{file}")
+end
+
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_tcp_repid = (TMIN_TCP_REPID + TNUM_TCP6_REPID + TNUM_TCP4_REPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_tcp6_repid = (TMIN_TCP6_REPID + TNUM_TCP6_REPID - 1);")
+$tinetCfgC.add("const ID tmax_tcp4_repid = (TMIN_TCP4_REPID + TNUM_TCP4_REPID - 1);")
+$tinetCfgC.add("#endif")
+
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_tcp_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID + TNUM_TCP4_CEPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_tcp6_cepid = (TMIN_TCP_CEPID + TNUM_TCP6_CEPID - 1);")
+$tinetCfgC.add("const ID tmax_tcp4_cepid = (TMIN_TCP_CEPID + TNUM_TCP4_CEPID - 1);")
+$tinetCfgC.add("#endif")
+
+$tinetCfgC.add()
+$tinetCfgC.add("const ID tmax_udp_cepid = (TMIN_UDP_CEPID + TNUM_UDP6_CEPID + TNUM_UDP4_CEPID - 1);")
+
+$tinetCfgC.add()
+$tinetCfgC.add("#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)")
+$tinetCfgC.add("const ID tmax_udp6_cepid = (TMIN_UDP6_CEPID + TNUM_UDP6_CEPID - 1);")
+$tinetCfgC.add("const ID tmax_udp4_cepid = (TMIN_UDP4_CEPID + TNUM_UDP4_CEPID - 1);")
+$tinetCfgC.add("#endif")
+
+#	// TCP (IPv6) åä»å£
+$sem_tcp_rep_lock_id = 0
+if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_TCP6_REP tcp6_rep[TNUM_TCP6_REPID] = {")
+	$cfgData[:TCP6_CRE_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp6_repatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
+		$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+		$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP6_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, TCP_PORTANY },")
+	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+	$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$tinetCfgC.add("\t};")
+end
+
+#	// TCP (IPv4) åä»å£
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_TCP4_REP tcp4_rep[TNUM_TCP4_REPID] = {")
+	$cfgData[:TCP_CRE_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp4_repatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv4addr]}, #{params[:portno]} },")
+	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+	$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP_REP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV4_ADDRANY, TCP_PORTANY },")
+	$tinetCfgC.add("#if defined(TCP_CFG_EXTENTIONS)")
+			$tinetCfgC.add("\t\tTCP_REP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id},")
+	$tinetCfgC.add("#endif")
+			$tinetCfgC.add("\t\t},")
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$tinetCfgC.add("\t};")
+end
+
+#	// TCP éä¿¡ç«¯ç¹
+if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0 || $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_TCP_CEP tcp_cep[TNUM_TCP6_CEPID + TNUM_TCP4_CEPID] = {")
+	$cfgData[:TCP6_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp6_cepatr]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
+			$tinetCfgC.add("\t\t#{params[:sbufsz]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
+			$tinetCfgC.add("\t\t#{params[:rbufsz]},")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp6_cepid].val},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp6_cepid].val},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp6_cepid].val},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp6_cepid].val},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_TCP6_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:TCP_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:tcp4_cepatr]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:sbuf]},")
+			$tinetCfgC.add("\t\t#{params[:sbufsz]},")
+			$tinetCfgC.add("\t\t(void*)#{params[:rbuf]},")
+			$tinetCfgC.add("\t\t#{params[:rbufsz]},")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_VALID|TCP_CEP_FLG_IPV4,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_TCP_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(void*)NULL,")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t(t_tcp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tTCP_CEP_FLG_DYNAMIC|TCP_CEP_FLG_IPV4,")
+			$tinetCfgC.add("\t\tSEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\tFLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+		$tinetCfgC.add("\t};")
+end
+
+#	// UDP (IPv6) éä¿¡ç«¯ç¹
+if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_UDP6_CEP udp6_cep[TNUM_UDP6_CEPID] = {")
+	$cfgData[:UDP6_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:udp6_cepatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv6addr]}, #{params[:portno]} },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:udp6_cepid].val},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_UDP6_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV6_ADDRANY, UDP_PORTANY },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+		$tinetCfgC.add("\t};")
+end
+
+#	// UDP (IPv4) éä¿¡ç«¯ç¹
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
+	$tinetCfgC.add()
+	$tinetCfgC.add("T_UDP4_CEP udp4_cep[TNUM_UDP4_CEPID] = {")
+	$cfgData[:UDP_CRE_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t#{params[:udp4_cepatr]},")
+			$tinetCfgC.add("\t\t{ #{params[:ipv4addr]}, #{params[:portno]} },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)#{params[:callback]},")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_VALID,")
+			$tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:udp4_cepid].val},")
+			$tinetCfgC.add("\t\t},")
+	end
+	$cfgData[:VRID_UDP_CEP].each do |key, params|
+		$tinetCfgC.add("\t{")
+			$tinetCfgC.add("\t\t0,")
+			$tinetCfgC.add("\t\t{ IPV4_ADDRANY, UDP_PORTANY },")
+			$tinetCfgC.add("\t\t(t_udp_callback)(FP)NULL,")
+			$tinetCfgC.add("\t\tUDP_CEP_FLG_DYNAMIC,")
+			$tinetCfgC.add("\t\tSEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tTA_NULL,")
+			$tinetCfgC.add("\t\tDTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size},")
+			$tinetCfgC.add("\t\t},")
+	end
+		$tinetCfgC.add("\t};")
+end
+
+# =====================================================================
+# tinet_kern.cfg ã®çæ
+# =====================================================================
+
+#	// TCP (IPv6) åä»å£
+$sem_tcp_rep_lock_id = 0
+if $cfgData[:TCP6_CRE_REP].size > 0 || $cfgData[:VRID_TCP6_REP].size > 0
+	$cfgData[:TCP6_CRE_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP6_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+end
+
+#	// TCP (IPv4) åä»å£
+if $cfgData[:TCP_CRE_REP].size > 0 || $cfgData[:VRID_TCP_REP].size > 0
+	$cfgData[:TCP_CRE_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+	$cfgData[:VRID_TCP_REP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_REP_LOCK#{$sem_tcp_rep_lock_id}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		$sem_tcp_rep_lock_id = $sem_tcp_rep_lock_id + 1
+	end
+end
+
+#	// TCP (IPv6) éä¿¡ç«¯ç¹
+if $cfgData[:TCP6_CRE_CEP].size > 0 || $cfgData[:VRID_TCP6_CEP].size > 0
+	$cfgData[:TCP6_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp6_cepid].val}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp6_cepid].val}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp6_cepid].val}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp6_cepid].val}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_TCP6_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp6_cepid].val + $cfgData[:TCP6_CRE_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
+
+#	// TCP (IPv4) éä¿¡ç«¯ç¹
+if $cfgData[:TCP_CRE_CEP].size > 0 || $cfgData[:VRID_TCP_CEP].size > 0
+	$cfgData[:TCP_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:tcp4_cepid].val + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_TCP_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_TCP_CEP_LOCK#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_EST#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_CLOSED, "TCP_CEP_EVT_CLOSED")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_SND#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = NumStr.new($TCP_CEP_EVT_SWBUF_READY, "TCP_CEP_EVT_SWBUF_READY")
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_FLG" }
+		cfgInfo["flgid"] = "FLG_TCP_CEP_RCV#{params[:vrid_tcp4_cepid].val + $cfgData[:TCP_CRE_CEP].size + $cfgData[:TCP6_CRE_CEP].size + $cfgData[:VRID_TCP6_CEP].size}"
+		cfgInfo["flgatr"] = NumStr.new($TA_TFIFO | $TA_WSGL, "TA_TFIFO|TA_WSGL")
+		cfgInfo["iflgptn"] = 0
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
+
+#	// UDP (IPv6) éä¿¡ç«¯ç¹
+if $cfgData[:UDP6_CRE_CEP].size > 0 || $cfgData[:VRID_UDP6_CEP].size > 0
+	$cfgData[:UDP6_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:udp6_cepid].val}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_DTQ" }
+		cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:udp6_cepid].val}"
+		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
+		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
+		#cfgInfo["dtqmb"] = NumStr.new($NULL, "NULL")
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_UDP6_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP6_CEP_LOCK#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_DTQ" }
+		cfgInfo["dtqid"] = "DTQ_UDP6_RCVQ#{params[:vrid_udp6_cepid].val + $cfgData[:UDP6_CRE_CEP].size}"
+		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
+		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
+		#cfgInfo["dtqmb"] = NumStr.new($NULL, "NULL")
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
+
+#	// UDP (IPv4) éä¿¡ç«¯ç¹
+if $cfgData[:UDP_CRE_CEP].size > 0 || $cfgData[:VRID_UDP_CEP].size > 0
+	$cfgData[:UDP_CRE_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:udp4_cepid].val}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_DTQ" }
+		cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:udp4_cepid].val}"
+		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
+		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
+		#cfgInfo["dtqmb"] = NumStr.new($NULL, "NULL")
+		$cfgFileInfo.push(cfgInfo)
+	end
+	$cfgData[:VRID_UDP_CEP].each do |key, params|
+		cfgInfo = { APINAME: "CRE_SEM" }
+		cfgInfo["semid"] = "SEM_UDP4_CEP_LOCK#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+		cfgInfo["sematr"] = NumStr.new($TA_TPRI, "TA_TPRI")
+		cfgInfo["isemcnt"] = 1
+		cfgInfo["maxsem"] = 1
+		$cfgFileInfo.push(cfgInfo)
+
+		cfgInfo = { APINAME: "CRE_DTQ" }
+		cfgInfo["dtqid"] = "DTQ_UDP4_RCVQ#{params[:vrid_udp4_cepid].val + $cfgData[:UDP_CRE_CEP].size}"
+		cfgInfo["dtqatr"] = NumStr.new($TA_TFIFO, "TA_TFIFO")
+		cfgInfo["dtqcnt"] = NumStr.new($NUM_DTQ_UDP_RCVQ, "NUM_DTQ_UDP_RCVQ")
+		#cfgInfo["dtqmb"] = NumStr.new($NULL, "NULL")
+		$cfgFileInfo.push(cfgInfo)
+	end
+end
Index: asp3_gr_sakura/trunk/tinet/tinet_asp.cfg
===================================================================
--- asp3_gr_sakura/trunk/tinet/tinet_asp.cfg	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tinet_asp.cfg	(revision 317)
@@ -0,0 +1,90 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  TINET ã®æ¨æºã·ã¹ãã ã³ã³ãã£ã®ã¥ã¬ã¼ã·ã§ã³ãã¡ã¤ã«
+ */
+
+#include "target_sil.h"
+
+#include <itron.h>
+
+#include <tinet_defs.h>
+#include <tinet_config.h>
+
+#include <net/if.h>
+#include <net/if_ppp.h>
+#include <net/if_loop.h>
+#include <net/ethernet.h>
+#include <net/if_arp.h>
+#include <net/net.h>
+#include <net/net_endian.h>
+#include <net/net_buf.h>
+#include <net/net_timer.h>
+#include <net/ppp_var.h>
+#include <net/ether_var.h>
+#include <netinet/in.h>
+#include <netinet/in_var.h>
+#include <netinet/ip.h>
+#include <netinet/ip_var.h>
+#include <netinet/tcp.h>
+#include <netinet/tcp_var.h>
+#include <netinet/udp_var.h>
+
+/*
+ *  TINET ãã­ãã³ã«ã¹ã¿ãã¯å
+é¨ã®ã«ã¼ãã«ãªãã¸ã§ã¯ãã®æå®
+ */
+
+INCLUDE("nic_asp.cfg");
+
+INCLUDE("net/net_asp.cfg");
+INCLUDE("net/ethernet.cfg");
+
+INCLUDE("netinet/if_ether.cfg");
+INCLUDE("netinet/ip.cfg");
+INCLUDE("netinet/tcp.cfg");
+INCLUDE("netinet/udp.cfg");
+INCLUDE("netinet6/ip6.cfg");
Index: asp3_gr_sakura/trunk/tinet/tinet_config.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/tinet_config.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tinet_config.h	(revision 317)
@@ -0,0 +1,518 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_CONFIG_H_
+#define _TINET_CONFIG_H_
+
+/*
+ *  TINET 1.2 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+/* TCPã®ååãªã¼ãã³ããµãã¼ããããTINET 1.7 ä»¥éä¸è¦ã«ãªã£ããã*/
+
+#if 0
+#define TCP_CFG_PASSIVE_OPEN
+#endif
+
+/* TCPã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½ãçµè¾¼ãã*/
+
+#define TCP_CFG_NON_BLOCKING
+
+/* UDPã®ãã³ãã­ãã­ã³ã°ã³ã¼ã«æ©è½ãçµè¾¼ãã*/
+
+#define UDP_CFG_NON_BLOCKING
+
+/*
+ *  NICãã·ã¹ãã ãCPUãå¿ç¨ãã­ã°ã©ã ã«
+ *  ä¾å­ããå®ç¾©ãã¡ã¤ã«ãã¤ã³ã¯ã«ã¼ãããã
+ */
+
+#if defined(TARGET_KERNEL_JSP)
+
+#ifdef SUPPORT_ETHER
+
+#include "tinet_nic_config.h"
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#include "tinet_sys_config.h"
+#include "tinet_cpu_config.h"
+#include "tinet_app_config.h"
+
+#elif defined(TARGET_KERNEL_ASP)
+
+#ifdef SUPPORT_ETHER
+
+#include "tinet_nic_config.h"
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+#include "tinet_target_config.h"
+#include "tinet_app_config.h"
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+/*
+ *  TINET 1.1 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#ifdef  TMO_ICMP4_OUTPUT
+#define TMO_ICMP_OUTPUT	TMO_ICMP4_OUTPUT
+#endif
+
+/*
+ *  TINET 1.2 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+#ifdef  NUM_MPF_NET_BUF_4096
+#define NUM_MPF_NET_BUF_REASSM	NUM_MPF_NET_BUF_4096
+#endif
+
+/*
+ *  TINET 1.3 ã¨ã®äºææ§ã®ããã®å®ç¾©
+
+#ifdef  NUM_MPF_NET_BUF_REASSM
+#define NUM_MPF_NET_BUF4_REASSM	NUM_MPF_NET_BUF_REASSM
+#endif
+ */
+
+/*
+ *  TINET 1.5 ã¨ã®äºææ§ã®ããã®å®ç¾©
+ */
+
+/* ã«ã¼ãã£ã³ã°è¡¨ã®ã¨ã³ããªæ°ã®å®ç¾© */
+
+#define NUM_IN6_ROUTE_ENTRY			\
+	(NUM_IN6_STATIC_ROUTE_ENTRY + NUM_IN6_REDIRECT_ROUTE_ENTRY)
+					/* ã«ã¼ãã£ã³ã°è¡¨ã®ã¨ã³ããªæ°	*/
+
+#define NUM_IN4_ROUTE_ENTRY		\
+	(NUM_IN4_STATIC_ROUTE_ENTRY + NUM_IN4_REDIRECT_ROUTE_ENTRY)
+					/* ã«ã¼ãã£ã³ã°è¡¨ã®ã¨ã³ããªæ°	*/
+
+#if defined(SUPPORT_INET6)
+
+#if defined(SUPPORT_INET4)
+
+#else	/* #if defined(SUPPORT_INET4) */
+
+#ifndef NUM_IN6_STATIC_ROUTE_ENTRY
+#define NUM_IN6_STATIC_ROUTE_ENTRY	NUM_STATIC_ROUTE_ENTRY
+#endif
+
+#ifndef NUM_IN6_REDIRECT_ROUTE_ENTRY
+#define NUM_IN6_REDIRECT_ROUTE_ENTRY	NUM_REDIRECT_ROUTE_ENTRY
+#endif
+
+#ifdef  NUM_ROUTE_ENTRY
+#undef  NUM_ROUTE_ENTRY
+#endif
+#define NUM_ROUTE_ENTRY			NUM_IN6_ROUTE_ENTRY
+
+#endif	/* #if defined(SUPPORT_INET4) */
+
+#else	/* of #if defined(SUPPORT_INET6) */
+
+#if defined(SUPPORT_INET4)
+
+#ifndef NUM_IN4_STATIC_ROUTE_ENTRY
+#define NUM_IN4_STATIC_ROUTE_ENTRY	NUM_STATIC_ROUTE_ENTRY
+#endif
+
+#ifndef NUM_IN4_REDIRECT_ROUTE_ENTRY
+#define NUM_IN4_REDIRECT_ROUTE_ENTRY	NUM_REDIRECT_ROUTE_ENTRY
+#endif
+
+#ifdef  NUM_ROUTE_ENTRY
+#undef  NUM_ROUTE_ENTRY
+#endif
+#define NUM_ROUTE_ENTRY			NUM_IN4_ROUTE_ENTRY
+
+#endif	/* of #if defined(SUPPORT_INET4) */
+
+#endif	/* of #if defined(SUPPORT_INET6) */
+
+/* DHCP ã®å®ç¾© */
+
+#ifdef  DHCP4_CLI_CFG
+#define DHCP_CFG
+#endif
+
+/*
+ *  IPv6/IPv4 ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  æå®ããããã¯ã­ã«å¯¾ãã TINET å
+é¨ã®ãã¯ã­ã®å®ç¾©
+ *
+ *    SUPPORT_INET6		 .   .  ON  ON  ON  ON
+ *    SUPPORT_INET4		ON  ON   .   .  ON  ON
+ *    API_CFG_IP4MAPPED_ADDR	 .  ON   .  ON   .  ON
+ *    ----------------------    ----------------------
+ *    _IP6_CFG                   .   .  ON  ON  ON  ON
+ *    _IP4_CFG                  ON  ON   .  ON  ON  ON
+ *    
+ */
+
+#if !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
+#error option selection: !defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR)
+#endif
+
+#if defined(SUPPORT_INET6)
+#define	_IP6_CFG
+#endif
+
+#if defined(SUPPORT_INET4) || (defined(SUPPORT_INET6) && defined(API_CFG_IP4MAPPED_ADDR))
+#define _IP4_CFG
+#endif
+
+/*
+ *  TCP ã«é¢ããå®ç¾©
+ */
+
+/*
+ *  MAX_TCP_RCV_SEG: åä¿¡ã»ã°ã¡ã³ããµã¤ãºã®æå¤§å¤
+ *
+ *    æ³¨æ: å¤æ´ãã¹ãã§ã¯ãªãã
+ */
+
+#ifndef MAX_TCP_RCV_SEG
+#define MAX_TCP_RCV_SEG		(IF_MTU - (IP_HDR_SIZE + TCP_HDR_SIZE))
+#endif
+
+/*
+ *  DEF_TCP_SND_SEG: éä¿¡ã»ã°ã¡ã³ããµã¤ãºã®è¦å®å¤
+ */
+
+#ifndef DEF_TCP_SND_SEG
+#define DEF_TCP_SND_SEG		MAX_TCP_SND_SEG
+#endif
+
+/*
+ *  TCP éä¿¡ç«¯ç¹ã®éåä¿¡ã¦ã£ã³ããããã¡ã®çã³ãã¼æ©è½
+ */
+
+#ifdef  TCP_CFG_SWBUF_CSAVE_ONLY
+#ifndef TCP_CFG_SWBUF_CSAVE
+#define TCP_CFG_SWBUF_CSAVE
+#endif
+#endif	/* of #ifdef  TCP_CFG_SWBUF_CSAVE_ONLY */
+
+#ifdef  TCP_CFG_RWBUF_CSAVE_ONLY
+#ifndef TCP_CFG_RWBUF_CSAVE
+#define TCP_CFG_RWBUF_CSAVE
+#endif
+#endif	/* of #ifdef  TCP_CFG_RWBUF_CSAVE_ONLY */
+
+/*
+ *  TCP_CFG_URG_OFFSET: ç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®ãªãã»ãã
+ *
+ *    -1: BSD ã®å®è£
+ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ãã®æ¬¡ã®ãã¤ããå·®ãã
+ *     0: RFC1122 ã®è¦å®ãç·æ¥ãã¤ã³ã¿ã¯ãç·æ¥ãã¼ã¿ã®æå¾ã®ãã¤ããå·®ãã
+ */
+
+#ifndef TCP_CFG_URG_OFFSET
+#define TCP_CFG_URG_OFFSET	-1
+#endif
+
+/*
+ *  ARP ã«é¢ããå®ç¾©
+ */
+
+#ifndef ARP_CACHE_KEEP
+#define ARP_CACHE_KEEP		(20*60*NET_TIMER_HZ)	/* ARP ã­ã£ãã·ã¥ã®ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+/*
+ *  ã«ã¼ãããã¯ã¤ã³ã¿ãã§ã¼ã¹ã«é¢ããå®ç¾©
+ */
+
+#ifndef LOMTU
+#define LOMTU			1500	/* ã«ã¼ãããã¯ã® MTU			*/
+#endif
+
+/*
+ * TINET ãµãã¼ãé¢æ°ã«é¢ããå®ç¾©
+ */
+
+#ifndef NUM_IPV4ADDR_STR_BUFF		/* ip2str ã«ããã IP ã¢ãã¬ã¹æå­åç¨ãããã¡æ° */
+
+#if defined(SUPPORT_PPP)
+
+#define NUM_IPV4ADDR_STR_BUFF	2
+
+#else	/* of #if defined(SUPPORT_PPP) */
+
+#define NUM_IPV4ADDR_STR_BUFF	1
+
+#endif	/* of #if defined(SUPPORT_PPP) */
+
+#endif	/* of #ifndef NUM_IPV4ADDR_STR_BUFF */
+
+#ifndef NUM_IPV6ADDR_STR_BUFF
+#define NUM_IPV6ADDR_STR_BUFF	2	/* ip62str ã«ããã IP ã¢ãã¬ã¹æå­åç¨ãããã¡æ° */
+#endif
+
+#ifndef NUM_MACADDR_STR_BUFF		/* macstr ã«ããã MAC ã¢ãã¬ã¹æå­åç¨ãããã¡æ° */
+
+#if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) && defined(ETHER_CFG_MCAST_WARNING)
+
+#define NUM_MACADDR_STR_BUFF	2
+
+#else	/* of #if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) && defined(ETHER_CFG_MCAST_WARNING) */
+
+#define NUM_MACADDR_STR_BUFF	1
+
+#endif	/* of #if defined(SUPPORT_INET4) && defined(ETHER_CFG_ACCEPT_ALL) && defined(ETHER_CFG_MCAST_WARNING) */
+
+#endif	/* of #ifndef NUM_MACADDR_STR_BUFF */
+
+/*
+ *  TINET å
+é¨ã®ã¿ã¤ã ã¢ã¦ãå¤ã®è¨­å®
+ */
+
+#ifndef TMO_IP4_FRAG_GET_NET_BUF
+#define TMO_IP4_FRAG_GET_NET_BUF	ULONG_C(1000000)	/* [us]ãIPv4 ãã¼ã¿ã°ã©ã åæ§æç¨ãããã¯ã¼ã¯ãããã¡ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+#ifndef TMO_IP6_FRAG_GET_NET_BUF
+#define TMO_IP6_FRAG_GET_NET_BUF	ULONG_C(1000000)	/* [us]ãIPv6 ãã¼ã¿ã°ã©ã åæ§æç¨ãããã¯ã¼ã¯ãããã¡ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+#ifndef TMO_PPP_GET_NET_BUF
+#define TMO_PPP_GET_NET_BUF		ULONG_C(1000000)	/* [us]ãPPP åä¿¡ç¨ãããã¯ã¼ã¯ãããã¡ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+#ifndef TMO_ARP_GET_NET_BUF
+#define TMO_ARP_GET_NET_BUF		ULONG_C(1000000)	/* [us]ãARP ã®ãããã¯ã¼ã¯ãããã¡ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+#ifndef TMO_TCP_GET_NET_BUF
+#define TMO_TCP_GET_NET_BUF		ULONG_C(1000000)	/* [us]ãTCP ã®ãããã¯ã¼ã¯ãããã¡ç²å¾ã¿ã¤ã ã¢ã¦ã	*/
+#endif
+
+#ifndef TMO_TCP_OUTPUT
+#define TMO_TCP_OUTPUT			ULONG_C(1000000)	/* [us]ãTCP åºåã¿ã¤ã ã¢ã¦ã				*/
+#endif
+
+#ifndef TMO_UDP_OUTPUT
+#define TMO_UDP_OUTPUT			ULONG_C(1000000)	/* [us]ãUDP åºåã¿ã¤ã ã¢ã¦ã				*/
+#endif
+
+#ifndef TMO_ICMP_OUTPUT
+#define TMO_ICMP_OUTPUT			ULONG_C(1000000)	/* [us]ãICMP åºåã¿ã¤ã ã¢ã¦ã				*/
+#endif
+
+#ifndef TMO_ND6_NS_OUTPUT
+#define TMO_ND6_NS_OUTPUT		ULONG_C(1000000)	/* [us]ãè¿é£è¦è«åºåã¿ã¤ã ã¢ã¦ã			*/
+#endif
+
+#ifndef TMO_ND6_NA_OUTPUT
+#define TMO_ND6_NA_OUTPUT		ULONG_C(1000000)	/* [us]ãè¿é£éç¥åºåã¿ã¤ã ã¢ã¦ã			*/
+#endif
+
+#ifndef TMO_ND6_RS_OUTPUT
+#define TMO_ND6_RS_OUTPUT		ULONG_C(1000000)	/* [us]ãã«ã¼ã¿è¦è«åºåã¿ã¤ã ã¢ã¦ã			*/
+#endif
+
+#ifndef TMO_ARP_OUTPUT
+#define TMO_ARP_OUTPUT			ULONG_C(1000000)	/* [us]ãã¢ãã¬ã¹è§£æ±ºè¦æ±åºåã¿ã¤ã ã¢ã¦ã		*/
+#endif
+
+#ifndef TMO_ND6_RTR_SOL_DELAY
+#define TMO_ND6_RTR_SOL_DELAY		ULONG_C(1000000)	/* [us]ãã«ã¼ã¿è¦è«åºåé
+å»¶				*/
+#endif
+
+#ifndef TMO_ND6_RTR_SOL_INTERVAL
+#define TMO_ND6_RTR_SOL_INTERVAL	ULONG_C(4000000)	/* [us]ãã«ã¼ã¿è¦è«åºåéé				*/
+#endif
+
+#ifndef TMO_IN_REDIRECT
+					/* [s]ãåãç´ãã«ã¼ãã£ã³ã°ã¨ã³ããªã¿ã¤ã ã¢ã¦ã*/
+#define TMO_IN_REDIRECT			(10*60*NET_TIMER_HZ)
+#endif
+
+/*
+ *  TINET å
+é¨ã®ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãºã®è¨­å®
+ */
+
+#ifndef TCP_OUT_TASK_STACK_SIZE
+#define	TCP_OUT_TASK_STACK_SIZE	1024	/* TCP åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#endif
+
+#ifndef UDP_OUT_TASK_STACK_SIZE
+#define	UDP_OUT_TASK_STACK_SIZE	1024	/* UDP åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº			*/
+#endif
+
+#ifndef PPP_INPUT_STACK_SIZE
+#define	PPP_INPUT_STACK_SIZE	1024	/* PPP ã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#endif
+
+#ifndef PPP_OUTPUT_STACK_SIZE
+#define	PPP_OUTPUT_STACK_SIZE	1024	/* PPP åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº		*/
+#endif
+
+#ifndef ETHER_INPUT_STACK_SIZE
+#define	ETHER_INPUT_STACK_SIZE	1024	/* Ethernet å
+¥åã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#endif
+
+#ifndef ETHER_OUTPUT_STACK_SIZE
+#define	ETHER_OUTPUT_STACK_SIZE	1024	/* Ethernet åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#endif
+
+#ifndef LOOP_INPUT_STACK_SIZE
+#define	LOOP_INPUT_STACK_SIZE	1024	/* ã«ã¼ãããã¯å
+¥åã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#endif
+
+#ifndef LOOP_OUTPUT_STACK_SIZE
+#define	LOOP_OUTPUT_STACK_SIZE	1024	/* ã«ã¼ãããã¯åºåã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº	*/
+#endif
+
+#ifndef NET_TIMER_STACK_SIZE
+#define	NET_TIMER_STACK_SIZE	1024	/* ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ã®ã¹ã¿ãã¯ãµã¤ãº */
+#endif
+
+/*
+ *  TINET å
+é¨ã®ã¿ã¹ã¯ã®åªå
+åº¦ã®è¨­å®
+ */
+
+#ifndef TCP_OUT_TASK_PRIORITY
+#define TCP_OUT_TASK_PRIORITY	5	/* TCP åºåã¿ã¹ã¯ã®åªå
+åº¦			*/
+#endif
+
+#ifndef UDP_OUT_TASK_PRIORITY
+#define UDP_OUT_TASK_PRIORITY	5	/* UDP åºåã¿ã¹ã¯ã®åªå
+åº¦				*/
+#endif
+
+#ifndef PPP_INPUT_PRIORITY
+#define PPP_INPUT_PRIORITY	5	/* PPP ã¿ã¹ã¯ã®åªå
+åº¦			*/
+#endif
+
+#ifndef PPP_OUTPUT_PRIORITY
+#define PPP_OUTPUT_PRIORITY	5	/* PPP ã¿ã¹ã¯ã®åªå
+åº¦			*/
+#endif
+
+#ifndef ETHER_INPUT_PRIORITY
+#define ETHER_INPUT_PRIORITY	5	/* Ethernet å
+¥åã¿ã¹ã¯ã®åªå
+åº¦		*/
+#endif
+
+#ifndef ETHER_OUTPUT_PRIORITY
+#define ETHER_OUTPUT_PRIORITY	5	/* Ethernet åºåã¿ã¹ã¯ã®åªå
+åº¦		*/
+#endif
+
+#ifndef LOOP_INPUT_PRIORITY
+#define LOOP_INPUT_PRIORITY	5	/* ã«ã¼ãããã¯å
+¥åã¿ã¹ã¯ã®åªå
+åº¦		*/
+#endif
+
+#ifndef LOOP_OUTPUT_PRIORITY
+#define LOOP_OUTPUT_PRIORITY	5	/* ã«ã¼ãããã¯åºåã¿ã¹ã¯ã®åªå
+åº¦		*/
+#endif
+
+#ifndef NET_TIMER_PRIORITY
+#define NET_TIMER_PRIORITY	5	/* ãããã¯ã¼ã¯ã¿ã¤ãã¿ã¹ã¯ã®åªå
+åº¦ */
+#endif
+
+/*
+ *  TINET å
+é¨ã®ãã¼ã¿ã­ã¥ã¼ã®ã¨ã³ããªæ°ã®è¨­å®
+ */
+
+/* UDP åä¿¡ã­ã¥ã¼ãµã¤ãº */
+
+#ifndef NUM_DTQ_UDP_RCVQ
+#define NUM_DTQ_UDP_RCVQ	1	/* éã³ã¼ã«ããã¯ç¨	*/
+#endif
+
+#ifndef NUM_DTQ_UDP_OUTPUT
+#define NUM_DTQ_UDP_OUTPUT	1	/* UDP åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãº			*/
+#endif
+
+#ifndef NUM_DTQ_PPP_OUTPUT
+#define NUM_DTQ_PPP_OUTPUT	2	/* PPP åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãºã2 ä»¥ä¸	*/
+#endif
+
+#ifndef NUM_DTQ_ETHER_OUTPUT
+#define NUM_DTQ_ETHER_OUTPUT	2	/* Ethernet åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãº	*/
+#endif
+
+#ifndef NUM_DTQ_LOOP_INPUT
+#define NUM_DTQ_LOOP_INPUT	0	/* ã«ã¼ãããã¯å
+¥åãã¼ã¿ã­ã¥ã¼ãµã¤ãº	*/
+#endif
+
+#ifndef NUM_DTQ_LOOP_OUTPUT
+#define NUM_DTQ_LOOP_OUTPUT	0	/* ã«ã¼ãããã¯åºåãã¼ã¿ã­ã¥ã¼ãµã¤ãº	*/
+#endif
+
+/*
+ *  TINET ãã­ãã³ã«ã¹ã¿ãã¯å
+é¨ã®ãªãã¼ã 
+ */
+
+#include <net/net_rename.h>
+#include <netinet/in_rename.h>
+#include <netinet6/in6_rename.h>
+
+#endif /* _TINET_CONFIG_H_ */
Index: asp3_gr_sakura/trunk/tinet/tinet_defs.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/tinet_defs.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tinet_defs.h	(revision 317)
@@ -0,0 +1,75 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+#ifndef _TINET_DEFS_H_
+#define _TINET_DEFS_H_
+
+#include "tinet_kernel_defs.h"
+
+#ifdef SUPPORT_ETHER
+
+#include "tinet_nic_defs.h"
+
+#endif	/* of #ifdef SUPPORT_ETHER */
+
+/*
+ *  ã«ã¼ãã«ã®è­å¥
+ */
+
+#ifdef TARGET_KERNEL_JSP
+
+#include "tinet_cpu_defs.h"
+
+#else	/* of #ifdef TARGET_KERNEL_JSP */
+
+#ifdef TARGET_KERNEL_ASP
+
+#include "tinet_target_defs.h"
+
+#endif	/* of #ifdef TARGET_KERNEL_ASP */
+
+#endif	/* of #ifdef TARGET_KERNEL_JSP */
+
+#endif /* _TINET_DEFS_H_ */
Index: asp3_gr_sakura/trunk/tinet/tinet_kernel_defs.h
===================================================================
--- asp3_gr_sakura/trunk/tinet/tinet_kernel_defs.h	(revision 317)
+++ asp3_gr_sakura/trunk/tinet/tinet_kernel_defs.h	(revision 317)
@@ -0,0 +1,126 @@
+/*
+ *  TINET (TCP/IP Protocol Stack)
+ * 
+ *  Copyright (C) 2001-2017 by Dep. of Computer Science and Engineering
+ *                   Tomakomai National College of Technology, JAPAN
+ *
+ *  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã® (1)ï½(4) ã®æ¡ä»¶ãï¼Free Software Foundation 
+ *  ã«ãã£ã¦å
+¬è¡¨ããã¦ãã GNU General Public License ã® Version 2 ã«è¨
+ *  è¿°ããã¦ããæ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§ã¢ï¼æ¬ã½ããã¦ã§ã¢
+ *  ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼
+ *  å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+ *  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+ *      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+ *      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+ *  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+ *      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+ *      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+ *      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®æ¡ä»¶ãæºãããã¨ï¼
+ *    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+ *        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+ *  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+ *      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+ *
+ *  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+ *  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ãã®é©ç¨å¯è½æ§ã
+ *  å«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´
+ *  æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ãã®è²¬ä»»ãè² ããªãï¼
+ * 
+ *  @(#) $Id$
+ */
+
+/*
+ *  ã«ã¼ãã«ã«é¢ããäºææ§å®ç¾©ãã¡ã¤ã«
+ */
+
+#ifndef _TINET_KERNEL_DEFS_H_
+#define _TINET_KERNEL_DEFS_H_
+
+#if defined(TARGET_KERNEL_JSP)
+
+#ifndef _MACRO_ONLY
+
+/*
+ *  ãã¼ã¿åã®å®ç¾©ï¼inttype.hï¼
+ */
+
+#ifdef _int8_
+typedef _int8_			int8_t;		/* ç¬¦å·ä»ã 8 ãããæ´æ° */
+typedef unsigned _int8_		uint8_t;	/* ç¬¦å·ç¡ã 8 ãããæ´æ° */
+#endif	/* of #ifdef _int8_ */
+
+#ifdef _int16_
+typedef _int16_			int16_t;	/* ç¬¦å·ä»ã 16 ãããæ´æ° */
+typedef unsigned _int16_	uint16_t;	/* ç¬¦å·ç¡ã 16 ãããæ´æ° */
+#endif	/* of #ifdef _int16_ */
+
+#ifdef _int32_
+typedef _int32_			int32_t;	/* ç¬¦å·ä»ã 32 ãããæ´æ° */
+typedef unsigned _int32_	uint32_t;	/* ç¬¦å·ç¡ã 32 ãããæ´æ° */
+#endif	/* of #ifdef _int32_ */
+
+#ifdef _int64_
+typedef unsigned _int64_	uint64_t;	/* ç¬¦å·ç¡ã 64 ãããæ´æ° */
+#endif	/* of #ifdef _int64_ */
+
+typedef signed int		int_t;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ä»ãæ´æ° */
+typedef unsigned int		uint_t;		/* èªç¶ãªãµã¤ãºã®ç¬¦å·ç¡ãæ´æ° */
+
+typedef signed long		long_t;		/* é·ãã®ãµã¤ãºã®ç¬¦å·ä»ãæ´æ° */
+typedef unsigned long		ulong_t;	/* é·ãã®ãµã¤ãºã®ç¬¦å·ç¡ãæ´æ° */
+
+#ifdef _vp_int_
+typedef _vp_int_		intptr_t;	/* ãã¤ã³ã¿ã¾ãã¯ç¬¦å·ä»ãæ´æ° */
+#else	/* of #ifdef _vp_int_ */
+typedef VP			intptr_t;	/* ãã¤ã³ã¿ã¾ãã¯ç¬¦å·ä»ãæ´æ° */
+#endif	/* of #ifdef _vp_int_ */
+
+typedef int			bool_t;		/* çå½å¤ */
+
+#ifndef true
+#define true			1		/* ç */
+#endif /* true */
+
+#ifndef false
+#define false			0		/* å½ */
+#endif /* false */
+
+#endif	/* of #ifndef _MACRO_ONLY */
+
+/* æ§é ä½ structure ä¸­ã®ãã£ã¼ã«ã field ã®ãã¤ãä½ç½®ãè¿ããã¯ã­ */
+#ifndef offsetof
+#define offsetof(structure, field) ((size_t) &(((structure *) 0)->field))
+#endif	/* of #ifndef offsetof */
+
+/*
+ *  æ´æ°å®æ°ãä½ããã¯ã­
+ */
+#ifndef UINT_C
+#define UINT_C(val)		(val ## U)	/* uint_tåã®å®æ°ãä½ããã¯ã­ */
+#endif /* UINT_C */
+
+#ifndef ULONG_C
+#define ULONG_C(val)		(val ## UL)	/* ulong_tåã®å®æ°ãä½ããã¯ã­ */
+#endif /* ULONG_C */
+
+#elif defined(TARGET_KERNEL_ASP)
+
+#define syscall(api)		(api)
+
+#endif	/* of #if defined(TARGET_KERNEL_JSP) */
+
+#endif	/* of #ifndef _TINET_KERNEL_DEFS_H_ */
Index: asp3_gr_sakura/trunk/utils/applyrename.rb
===================================================================
--- asp3_gr_sakura/trunk/utils/applyrename.rb	(revision 317)
+++ asp3_gr_sakura/trunk/utils/applyrename.rb	(revision 317)
@@ -0,0 +1,138 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Software
+#      Toyohashi Open Platform for Embedded Real-Time Systems
+# 
+#  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2004-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: applyrename.rb 562 2016-01-21 14:24:34Z ertl-hiro $
+# 
+
+require "fileutils"
+
+#
+#  ãã¡ã¤ã«ã«ãªãã¼ã ãé©ç¨ãã
+#
+def applyRename(inFileName, syms)
+  symsRegexp = syms.join("|")
+  outFileName = inFileName + ".new"
+
+  begin
+    inFile = File.open(inFileName)
+    outFile = File.open(outFileName, "w")
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  inFile.each do |line|
+    line.gsub!(/\b(_?)(#{symsRegexp})\b/, "\\1_kernel_\\2")
+    outFile.print line
+  end
+
+  inFile.close
+  outFile.close
+
+  if FileUtils.cmp(inFileName, outFileName)
+    # ãã¡ã¤ã«ã®å
+å®¹ãå¤åããªãã£ãå ´å
+    FileUtils.remove(outFileName)
+  else
+    # ãã¡ã¤ã«ã®å
+å®¹ãå¤åããå ´å
+    FileUtils.move(inFileName, inFileName + ".bak")
+    FileUtils.move(outFileName, inFileName)
+    puts("Modified: #{inFileName}")
+  end
+end
+
+#
+#  ã¨ã©ã¼ãã§ãã¯
+#
+if ARGV.length < 1
+  abort("Usage: ruby appyrename.rb <prefix> <filelists>")
+end
+
+#
+#  åæå
+#
+syms = []
+name = ARGV.shift
+
+#
+#  ã·ã³ãã«ãªã¹ããèª­ã¿è¾¼ã
+#
+defFileName = name + "_rename.def"
+
+begin
+  defFile = File.open(defFileName)
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+defFile.each do |line|
+  line.chomp!
+  if /^#\s*(.*)$/ =~ line
+    # do nothing
+  elsif /^INCLUDE\s+(.*)$/ =~ line
+    # do nothing
+  elsif line != ""
+    syms.push(line)
+  end
+end
+
+#
+#  ãã¡ã¤ã«ã«ãªãã¼ã ãé©ç¨ãã
+#
+ARGV.each do |inFileName|
+  if inFileName != defFileName && File.readable?(inFileName)
+    applyRename(inFileName, syms)
+  end
+end
Index: asp3_gr_sakura/trunk/utils/genrename.rb
===================================================================
--- asp3_gr_sakura/trunk/utils/genrename.rb	(revision 317)
+++ asp3_gr_sakura/trunk/utils/genrename.rb	(revision 317)
@@ -0,0 +1,199 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Software
+#      Toyohashi Open Platform for Embedded Real-Time Systems
+# 
+#  Copyright (C) 2003 by Embedded and Real-Time Systems Laboratory
+#                              Toyohashi Univ. of Technology, JAPAN
+#  Copyright (C) 2005-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: genrename.rb 566 2016-01-29 16:55:57Z ertl-hiro $
+# 
+
+#
+#  å
+é ­ã«ã¤ããæå­å
+#
+def prefixString(sym)
+  if sym =~ /[a-z]/
+    return("_kernel_")
+  else
+    return("_KERNEL_")
+  end
+end
+
+#
+#  ãªãã¼ã å®ç¾©ãçæãã
+#
+def generateDefine(outFile, sym, prefix)
+  outFile.print("#define #{prefix}#{sym}");
+  outFile.print("\t" * [(6 - (sym.length + prefix.length) / 4), 0].max);
+  outFile.print("\t#{prefix}#{prefixString(sym)}#{sym}\n");
+end
+
+#
+#  ãªãã¼ã è§£é¤ãçæãã
+#
+def generateUndef(outFile, sym, prefix)
+  outFile.print("#undef #{prefix}#{sym}\n");
+end
+
+#
+#  ã³ã¡ã³ããçæãã
+#
+def generateComment(outFile, comment)
+  outFile.print("/*\n")
+  outFile.print(" *  #{comment}\n")
+  outFile.print(" */\n")
+end
+
+#
+#  ã¨ã©ã¼ãã§ãã¯
+#
+if ARGV.length < 1
+  abort("Usage: ruby genrename.rb <prefix>")
+end
+
+#
+#  åæå
+#
+syms = []
+name = ARGV.shift
+NAME = name.upcase
+
+inFileName = name + "_rename.def"
+headerDefineSymbol = "TOPPERS_" + NAME + "_RENAME_H"
+
+#
+#  ã·ã³ãã«ãªã¹ããèª­ã¿è¾¼ã
+#
+begin
+  inFile = File.open(inFileName)
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+inFile.each do |line|
+  syms.push(line.chomp)
+end
+
+#
+#  ???_rename.h ãçæãã
+#
+begin
+  outFile = File.open(name + "_rename.h", "w")
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+outFile.print <<EOS
+/* This file is generated from #{inFileName} by genrename. */
+
+#ifndef #{headerDefineSymbol}
+#define #{headerDefineSymbol}
+
+EOS
+
+includes = ""
+syms.each do |sym|
+  if /^#\s*(.*)$/ =~ sym
+    generateComment(outFile, $1)
+  elsif /^INCLUDE\s+(.*)$/ =~ sym
+    fileName = $1.sub(/([>"])$/, "_rename.h\\1")
+    includes += "#include #{fileName}\n"
+  elsif sym != ""
+    generateDefine(outFile, sym, "")
+  else
+    outFile.print("\n")
+  end
+end
+
+outFile.print <<EOS
+
+#{includes}
+#endif /* #{headerDefineSymbol} */
+EOS
+
+#
+#  ???_unrename.h ãçæãã
+#
+begin
+  outFile = File.open(name + "_unrename.h", "w")
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+outFile.print <<EOS
+/* This file is generated from #{inFileName} by genrename. */
+
+/* This file is included only when #{name}_rename.h has been included. */
+#ifdef #{headerDefineSymbol}
+#undef #{headerDefineSymbol}
+
+EOS
+
+includes = ""
+syms.each do |sym|
+  if /^#\s*(.*)$/ =~ sym
+    generateComment(outFile, $1)
+  elsif /^INCLUDE\s+(.*)$/ =~ sym
+    fileName = $1.sub(/([>"])$/, "_unrename.h\\1")
+    includes += "#include #{fileName}\n"
+  elsif sym != ""
+    generateUndef(outFile, sym, "")
+  else
+    outFile.print("\n")
+  end
+end
+
+outFile.print <<EOS
+
+#{includes}
+#endif /* #{headerDefineSymbol} */
+EOS
Index: asp3_gr_sakura/trunk/utils/gentest.rb
===================================================================
--- asp3_gr_sakura/trunk/utils/gentest.rb	(revision 317)
+++ asp3_gr_sakura/trunk/utils/gentest.rb	(revision 317)
@@ -0,0 +1,487 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Software
+#      Toyohashi Open Platform for Embedded Real-Time Systems
+# 
+#  Copyright (C) 2007-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: gentest.rb 743 2016-04-10 16:00:40Z ertl-hiro $
+# 
+
+#
+#		ãã¹ããã­ã°ã©ã çæãã¼ã«
+#
+	
+#
+#  çæåä½ãæ±ºããããã®è¨­å®
+#
+$parameterDefinition = {
+  "get_tst" => { 2 => "STAT" },
+  "get_pri" => { 2 => "PRI" },
+  "get_inf" => { 1 => "intptr_t" },
+  "ref_tsk" => { 2 => "T_RTSK" },
+  "ref_sem" => { 2 => "T_RSEM" },
+  "wai_flg" => { 4 => "FLGPTN" },
+  "pol_flg" => { 4 => "FLGPTN" },
+  "twai_flg" => { 4 => "FLGPTN" },
+  "ref_flg" => { 2 => "T_RFLG" },
+  "rcv_dtq" => { 2 => "intptr_t" },
+  "prcv_dtq" => { 2 => "intptr_t" },
+  "trcv_dtq" => { 2 => "intptr_t" },
+  "ref_dtq" => { 2 => "T_RDTQ" },
+  "rcv_pdq" => { 2 => "intptr_t" , 3 => "PRI" },
+  "prcv_pdq" => { 2 => "intptr_t" , 3 => "PRI" },
+  "trcv_pdq" => { 2 => "intptr_t" , 3 => "PRI" },
+  "ref_pdq" => { 2 => "T_RPDQ" },
+  "ref_mtx" => { 2 => "T_RMTX" },
+  "ref_mbf" => { 2 => "T_RMBF" },
+  "get_mpf" => { 2 => "void *" },
+  "pget_mpf" => { 2 => "void *" },
+  "tget_mpf" => { 2 => "void *" },
+  "ref_mpf" => { 2 => "T_RMPF" },
+  "get_tim" => { 1 => "SYSTIM" },
+  "ref_cyc" => { 2 => "T_RCYC" },
+  "ref_alm" => { 2 => "T_RALM" },
+  "ref_ovr" => { 2 => "T_ROVR" },
+  "get_tid" => { 1 => "ID" },
+  "get_did" => { 1 => "ID" },
+  "get_lod" => { 2 => "uint_t" },
+  "mget_lod" => { 3 => "uint_t" },
+  "get_nth" => { 3 => "ID" },
+  "mget_nth" => { 4 => "ID" },
+  "get_ipm" => { 1 => "PRI" },
+  "get_som" => { 1 => "ID" }
+}
+
+$functionParameters = {
+  "target_hrt_set_event" => "HRTCNT hrtcnt"
+}
+  
+$functionValue = {
+  "target_hrt_get_current" => "HRTCNT"
+}
+  
+$functionReturn = {
+  "target_hrt_get_current" => "0U"
+}
+  
+$functionCheckParameter = {
+  "target_hrt_set_event" => "hrtcnt"
+}
+
+#
+#  å¦çåä½ã®ã³ã¼ããæ ¼ç´ããã¯ã©ã¹
+#
+class PUCode
+  # åæå
+  def initialize(puName)
+    @puName = puName						# å¦çåä½ã®åå
+    @currentCount = ""						# å¦çã«ã¦ã³ã
+    @countFlag = false						# å¦çã«ã¦ã³ããä½¿ãããã
+    @code = Hash.new { |h,k| h[k] = [] }	# å¦çåä½ã®ã³ã¼ã
+    @variableList = {}						# å¦çåä½ã®å¤æ°
+    @silFlag = false						# SILãä½¿ãããã
+
+    # å¦çã«ã¦ã³ãå¤æ°åã®çæ
+    case puName
+    when /^TASK([0-9]*)$/
+      @count_var = "task#{$1}_count"
+    when /^CYC([0-9]*)$/
+      @count_var = "cyclic#{$1}_count"
+    when /^ALM([0-9]*)$/
+      @count_var = "alarm#{$1}_count"
+    when /^OVR$/
+      @count_var = "overrun_count"
+    when /^ISR([0-9]*)$/
+      @count_var = "isr#{$1}_count"
+    when /^INTHDR([0-9]*)$/
+      @count_var = "inthdr#{$1}_count"
+    when /^CPUEXC([0-9]*)$/
+      @count_var = "cpuexc#{$1}_count"
+    when /^EXTSVC([0-9]*)$/
+      @count_var = "extsvc#{$1}_count"
+    else
+      @count_var = puName + "_count"
+    end
+  end
+
+  # å¦çã«ã¦ã³ãã®è¨­å®
+  def setCount(count)
+    @countFlag = true if count != ""
+    @currentCount = count
+  end
+
+  # å¦çã«ã¦ã³ãã®ã¤ã³ã¯ãªã¡ã³ã
+  def incrementCount
+    if @currentCount != ""
+      @currentCount = (@currentCount.to_i + 1).to_s
+    end
+  end
+
+  # ã³ã¼ãã®è¿½å 
+  def append(*lines)
+    lines.each do |line|
+      @code[@currentCount].push(line)
+        end
+  end
+
+  # å¤æ°ã®è¿½å 
+  def addVariable(varName, typeName)
+    @variableList[varName] = typeName
+  end
+
+  # SILã®ä½¿ç¨
+  def useSil
+    @silFlag = true
+  end
+
+  # å¦çåä½ã®ã³ã¼ãã®åºå
+  def generateCode
+    # ä¸è¦ãªå¦çåä½ã®å¤å®
+    return if @code.length == 0
+
+    # å¦çã«ã¦ã³ãå¤æ°ã®çæ
+    if @countFlag
+      print("\nstatic uint_t\t#{@count_var} = 0;\n")
+    end
+
+    # é¢æ°ãããã®çæ
+    case @puName
+    when /^TASK([0-9]*)$/
+      print("\nvoid\n")
+      print("task#{$1}(intptr_t exinf)\n")
+    when /^CYC([0-9]*)$/
+      print("\nvoid\n")
+      print("cyclic#{$1}_handler(intptr_t exinf)\n")
+    when /^ALM([0-9]*)$/
+      print("\nvoid\n")
+      print("alarm#{$1}_handler(intptr_t exinf)\n")
+    when /^OVR$/
+      print("\nvoid\n")
+      print("overrun_handler(ID tskid, intptr_t exinf)\n")
+    when /^ISR([0-9]*)$/
+      print("\nvoid\n")
+      print("isr#{$1}(intptr_t exinf)\n")
+    when /^INTHDR([0-9]*)$/
+      print("\nvoid\n")
+      print("inthdr#{$1}_handler(void)\n")
+    when /^CPUEXC([0-9]*)$/
+      print("\nvoid\n")
+      print("cpuexc#{$1}_handler(void *p_excinf)\n")
+    when /^EXTSVC([0-9]*)$/
+      print("\nER_UINT\n")
+      print("extsvc#{$1}_routine")
+      print("(intptr_t par1, intptr_t par2, intptr_t par3,\n")
+      print("\t\t\t\t\t\t\t\tintptr_t par4, intptr_t par5, ID cdmid)\n")
+    else
+      if $functionValue[@puName]
+        print("\n#{$functionValue[@puName]}\n")
+      else
+        print("\nvoid\n")
+      end
+      print(@puName)
+      if $functionParameters[@puName]
+        print("(#{$functionParameters[@puName]})\n")
+      else
+        print("(void)\n")
+      end
+    end
+
+    print("{\n")
+
+    @variableList.each do |varName, varType|
+      if /^(.+)\w*\*$/ =~ varType
+        varBaseType = $1
+        print("\t#{varBaseType}")
+        print(varBaseType.length < 4 ? "\t\t*" : "\t*")
+      else
+        print("\t#{varType}")
+        print(varType.length < 4 ? "\t\t" : "\t")
+      end
+      print("#{varName};\n")
+    end
+    if @silFlag
+      print("\tSIL_PRE_LOC;\n")
+    end
+    print("\n")
+
+    if @countFlag
+      print("\tswitch (++#{@count_var}) {\n")
+      @code.keys.sort_by { |c| c.to_i }.each do |count|
+        print("\tcase #{count}:\n")
+        @code[count].each do |line|
+          print("\t",line) if line != ""
+          print("\n")
+        end
+        print("\t\tcheck_point(0);\n\n")
+      end
+      print("\tdefault:\n")
+      print("\t\tcheck_point(0);\n")
+      print("\t}\n")
+    else
+      @code[""].each do |line|
+        print(line,"\n")
+      end
+    end
+
+    print("\tcheck_point(0);\n")
+    if /^EXTSVC([0-9]*)$/ =~ @puName
+      print("\treturn(E_SYS);\n")
+    elsif $functionReturn[@pu_nama]
+      print("\treturn(#{$functionReturn[@puName]});\n")
+    end
+    print("}\n")
+  end
+end
+
+#
+#  ãµã¼ãã¹ã³ã¼ã«å¼ã³åºãã®èª­ã¿è¾¼ã¿
+#
+def genServiceCall(pu, svc_call, error_code)
+  pu.addVariable("ercd", "ER_UINT")
+  pu.append("\tercd = #{svc_call};")
+
+  if /^([a-z_]+)\((.*)\)$/ =~ svc_call
+    svcName = $1;
+    params = $2.split(/\s*,\s*/)
+
+    if $parameterDefinition.has_key?(svcName)
+      $parameterDefinition[svcName].each do |pos, type|
+        if params.size >= pos
+          varName = params[pos - 1].sub(/^\&/, "")
+          pu.addVariable(varName, type)
+        end
+      end
+    end
+  end
+
+  if !error_code
+    # E_OKãè¿ãå ´å
+    pu.append("\tcheck_ercd(ercd, E_OK);", "")
+  elsif error_code == "noreturn"
+    # ãªã¿ã¼ã³ããªãå ´å
+    pu.append("")
+  else
+    pu.append("\tcheck_ercd(ercd, #{error_code});", "")
+  end
+end
+
+#
+#  ãã¹ãéå§ã³ã¼ãã®çæ
+#
+def testStartCode(pu)
+  # ãã¹ãéå§ã³ã¼ãã¯ä¸åº¦ã®ã¿åºåãã
+  if $startFlag == 0
+    pu.append("\ttest_start(__FILE__);", "")
+    $startFlag = 1
+  end
+end
+
+#
+#  ã¿ã¼ã²ããä¾å­é¨é¢æ°ã®æ¯ãèãã®èª­ã¿è¾¼ã¿
+#
+def targetFunction(line, checkNum)
+  if /^([a-zA-Z_]+)\s*(.*)$/ =~ line
+    functionName = $1
+    line = $2
+    if (pu = $puList[functionName]).nil?
+      # æ°ããå¦çåä½ã®çæ
+      pu = $puList[functionName] = PUCode.new(functionName)
+      pu.setCount("1")
+      testStartCode(pu)
+    end
+  end
+
+  if /\-\>\s*([^\s]+)\s*(.*)$/ =~ line
+    retval = $1
+    line = $2
+  end
+  if /\<\-\s*([^\s]+)\s*(.*)$/ =~ line
+    param = $1
+    line = $2
+  end
+
+  pu.append("\tcheck_point(#{checkNum});");
+  if param && $functionCheckParameter[functionName]
+    pu.append(sprintf("\tcheck_assert(%s == %s);",
+					$functionCheckParameter[functionName], param), "")
+  end
+  if retval
+    pu.append("\treturn(#{retval});", "")
+  else
+    pu.append("\treturn;", "")
+  end
+  pu.incrementCount()
+end
+
+#
+#  ãã¹ãã¹ã¯ãªããã®èª­ã¿è¾¼ã¿
+#
+def parseLine(line)
+  if /^==\s*(([a-zA-Z_]+)[0-9]*)(.*)$/ =~ line
+    # å¦çåä½ã®éå§
+    $procFlag = 1
+    puName = $1
+    line2 = $3
+    if (pu = $puList[puName]).nil?
+      # æ°ããå¦çåä½ã®çæ
+      pu = $puList[puName] = PUCode.new(puName)
+    end
+    $currentPu = pu
+
+    case line2
+    when /^\-([0-9]+)(.*)$/
+      pu.setCount($1)
+    when /^\-[nN](.*)$/
+      # do nothing.
+    else
+      pu.setCount("")
+    end
+    testStartCode(pu) if /^START/ !~ puName
+  elsif $procFlag != 0
+    pu = $currentPu
+    if /^([0-9]+\:)\s*(.*)$/ =~ line
+      # ãã§ãã¯ãã¤ã³ãçªå·ã®å¦ç
+      originalCheckNum = $1
+      line = $2
+      checkNum = ($lastCheckPoint += 1).to_s
+      $outputLine.sub!(/#{originalCheckNum}/, "#{checkNum}:")
+
+      case line
+      when /^END$/
+        pu.append("\tcheck_finish(#{checkNum});")
+        $procFlag = 0
+        return
+      when /^HOOK\((.*)\)$/
+        pu.append(sprintf("\t#{$1};", checkNum))
+        return
+      when /^\[(.*)\]$/
+        targetFunction($1, checkNum)
+        return
+      else
+        pu.append("\tcheck_point(#{checkNum});")
+      end
+    end
+
+    case line
+    when /^((assert|state|ipm)\(.*\))$/
+      pu.append("\tcheck_#{$1};", "")
+    when /^(call|DO)\((.*)\)$/
+      call_string = $2
+      pu.append("\t#{call_string};", "")
+      pu.useSil() if /^SIL_..._INT\(\)$/ =~ call_string
+    when /^RETURN((\(.*\))?)$/
+      pu.append("\treturn#{$1};", "")
+      pu.incrementCount()
+    when /^GOTO\((.*)\)$/
+      pu.append("\tgoto #{$1};", "")
+    when /^LABEL\((.*)\)$/
+      pu.append("#{$1}:", "")
+    when /^([a-z_]+\(.*\))\s*(\-\>\s*([A-Za-z0-9_]*))?\s*$/
+      genServiceCall(pu, $1, $3)
+    else
+      warn("Error: #{line}")
+    end
+  end
+end
+
+#
+#  ã¨ã©ã¼ãã§ãã¯
+#
+if ARGV.length < 1
+  abort("Usage: ruby gentest.rb <test_program>")
+end
+
+#
+#  åæå
+#
+inFileName = ARGV.shift
+
+#
+#  ã¹ã¯ãªãããã¡ã¤ã«èª­ã¿è¾¼ã¿å¦ç
+#
+$lastCheckPoint = 0		# æå¾ã®ãã§ãã¯ãã¤ã³ãçªå·
+$procFlag = 0				# ã¹ã¯ãªããå¦çä¸­ãã©ã°
+$startFlag = 0			# ãã¹ãéå§ã³ã¼ãã®åºåãã©ã°
+$currentPu = nil			# èª­ã¿è¾¼ã¿ä¸­ã®å¦çåä½
+$puList = {}				# å¦çåä½ã®ãªã¹ã
+
+begin
+  inFile = File.open(inFileName)
+rescue Errno::ENOENT, Errno::EACCES => ex
+  abort(ex.message)
+end
+
+while line = inFile.gets do
+  $outputLine = line.dup
+  line.chomp!
+  line.sub!(/^\s*\*\s*/, "")
+  line.sub!(/\s*\/\/.*$/, "")
+  line.sub!(/\s*\.\.\..*$/, "")
+
+  while line.sub!(/\\$/, "") do
+    line1 = inFile.gets
+    $outputLine += line1.dup
+    line1.chomp!
+    line1.sub!(/^\s*\*\s*/, "")
+    line1.sub!(/\s*\/\/.*$/, "")
+    line1.sub!(/\s*\.\.\..*$/, "")
+    line += line1
+  end
+  parseLine(line) if line != ""
+  print($outputLine)
+  break if /DO NOT DELETE THIS LINE/ =~ $outputLine
+end
+
+#
+#  ãã¹ããã­ã°ã©ã åºåå¦ç
+#
+$puList.keys.sort.each do |puName|
+  $puList[puName].generateCode()
+end
Index: asp3_gr_sakura/trunk/utils/makerelease.rb
===================================================================
--- asp3_gr_sakura/trunk/utils/makerelease.rb	(revision 317)
+++ asp3_gr_sakura/trunk/utils/makerelease.rb	(revision 317)
@@ -0,0 +1,186 @@
+#!/usr/bin/env ruby
+# -*- coding: utf-8 -*-
+#
+#  TOPPERS Software
+#      Toyohashi Open Platform for Embedded Real-Time Systems
+# 
+#  Copyright (C) 2006-2016 by Embedded and Real-Time Systems Laboratory
+#              Graduate School of Information Science, Nagoya Univ., JAPAN
+# 
+#  ä¸è¨èä½æ¨©è
+ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
+#  ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ãä½¿ç¨ã»è¤è£½ã»æ¹
+#  å¤ã»åé
+å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
+#  (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
+#      æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
+#      ã¹ã³ã¼ãä¸­ã«å«ã¾ãã¦ãããã¨ï¼
+#  (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨
+#      è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
+#      ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#  (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
+#      ç¨ã§ããªãå½¢ã§åé
+å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
+#      ã¨ï¼
+#    (a) åé
+å¸ã«ä¼´ããã­ã¥ã¡ã³ãï¼å©ç¨è
+ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
+#        ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
+#    (b) åé
+å¸ã®å½¢æ
+ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSãã­ã¸ã§ã¯ãã«
+#        å ±åãããã¨ï¼
+#  (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
+#      å®³ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ããå
+è²¬ãããã¨ï¼
+#      ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
+#      ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
+ããã³TOPPERSãã­ã¸ã§ã¯ãã
+#      å
+è²¬ãããã¨ï¼
+# 
+#  æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
+ã
+#  ãã³TOPPERSãã­ã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
+#  ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
+#  ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæå®³ã«é¢ãã¦ãï¼ã
+#  ã®è²¬ä»»ãè² ããªãï¼
+# 
+#  $Id: makerelease.rb 567 2016-01-30 00:49:03Z ertl-hiro $
+# 
+
+require "shell"
+
+#
+#  ".."ãå«ããã¹ã®æ´å½¢
+#
+#  ä¾ï¼"yyy/../zzz" â "zzz"
+#  ä¾ï¼"xxx/yyy/../zzz" â "xxx/zzz"
+#
+def canonicalPath(path)
+  while path.sub!(/([^\/]+\/\.\.\/)/, "") do end
+  return(path)
+end
+
+#
+#  ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+#
+def readFile(inFileName)
+  baseDirectory = File.dirname(inFileName)
+  if (baseDirectory == ".")
+    baseDirectory = ""
+  else
+    baseDirectory += "/"
+  end
+
+  begin
+    inFile = File.open(inFileName)
+  rescue Errno::ENOENT, Errno::EACCES => ex
+    abort(ex.message)
+  end
+
+  inFile.each do |line|
+    line.chomp!
+    line.sub!(/\s*\#.*$/, "")
+    next if /^\s*$/ =~ line
+
+    if /^E_PACKAGE[ \t]+(.*)$/ =~ line
+      if $package != ""
+        abort("Duplicated E_PACKAGE directive.")
+      else
+        $package = $1
+        $e_package = 1
+      end
+    elsif /^PACKAGE[ \t]+(.*)$/ =~ line
+      if $package != ""
+        if !$e_package && $package != $1
+          abort("Inconsistent PACKAGE directive.")
+        end
+      else
+        $package = $1
+      end
+    elsif /^VERSION[ \t]+(.*)$/ =~ line
+      if $version != ""
+        if !$e_package && $version != $1
+          abort("Inconsistent VERSION directive.")
+        end
+      else
+        $version = $1
+        if /%date/ =~ $version
+          currentTime = Time.now.localtime
+          vdate = sprintf("%04d%02d%02d", currentTime.year,
+									currentTime.month, currentTime.day)
+          $version.sub!(/%date/, vdate)
+        end
+      end
+    elsif /^INCLUDE[ \t]+(.*)$/ =~ line
+      readFile(canonicalPath(baseDirectory + $1))
+    else
+      fileName = $prefix + "/" + canonicalPath(baseDirectory + line)
+      if !File.file?("../" + fileName)
+        abort("#{fileName} is not a file.")
+      elsif $fileList.index(fileName)
+        abort("#{fileName} is duplicated.")
+      else 
+        $fileList.push(fileName)
+      end
+    end
+  end
+end
+
+#
+#  åæå
+#
+$package = ""
+$e_package = 0
+$version = ""
+$fileList = []
+
+#
+#  ããªãã£ãã¯ã¹ï¼./ã«ã¬ã³ããã£ã¬ã¯ããªåï¼ã®åãåºã
+#
+cwd = Shell.new.cwd
+$prefix = "./" + File.basename(cwd)
+
+#
+#  ãã©ã¡ã¼ã¿ã®åãåºã
+#
+if ARGV.length >= 1
+  arg = ARGV.shift.dup
+  arg.sub!(/\/$/, "/MANIFEST")
+  arg.sub!(/^\.\//, "")
+else
+  arg = "MANIFEST"
+end
+
+#
+#  ãã¡ã¤ã«ã®èª­ã¿è¾¼ã¿
+#
+readFile(arg)
+if $package == ""
+  abort("PACKAGE/E_PACKAGE directive not found.")
+end
+if $version == ""
+  abort("VERSION directive not found.")
+end
+
+#
+#  RELEASEãã£ã¬ã¯ããªã®ä½æ
+#
+if !File.directory?("RELEASE")
+  Dir.mkdir("RELEASE")
+end
+
+#
+#  ã¢ã¼ã«ã¤ãï¼.tar.gzï¼ã®ä½æ
+#
+archiveName = $package + "-" + $version + ".tar.gz"
+fileListStr = $fileList.join(" ")
+command = "tar cvfz RELEASE/#{archiveName} -C .. #{fileListStr}\n";
+system(command)
+puts("== RELEASE/#{archiveName} is generated. ==\n")
Index: asp3_gr_sakura/trunk/utils/move-if-change
===================================================================
--- asp3_gr_sakura/trunk/utils/move-if-change	(revision 317)
+++ asp3_gr_sakura/trunk/utils/move-if-change	(revision 317)
@@ -0,0 +1,13 @@
+#! /bin/sh
+if test -r $2
+  then
+  if cmp -s $1 $2
+  then
+    echo $2 is unchanged
+    rm -f $1
+  else
+    mv -f $1 $2
+  fi
+else
+  mv -f $1 $2
+fi
