Ignore:
Timestamp:
Apr 5, 2019, 9:26:53 PM (5 years ago)
Author:
coas-nagasima
Message:

mbed関連を更新
シリアルドライバをmbedのHALを使うよう変更
ファイルディスクリプタの処理を更新

Location:
asp3_tinet_ecnl_rx/trunk
Files:
104 added
5 deleted
175 edited
4 moved

Legend:

Unmodified
Added
Removed
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/Debug/Makefile

    r373 r374  
    158158
    159159#
     160#  mbedサービスの定義
     161#
     162
     163include $(SRCDIR)/mbed/Makefile.mbed
     164
     165#
    160166#  共通コンパイルオプションの定義
    161167#
     
    193199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    194200APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    195 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    196202
    197203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/DebugCitrus/Makefile

    r373 r374  
    158158
    159159#
     160#  mbedサービスの定義
     161#
     162
     163include $(SRCDIR)/mbed/Makefile.mbed
     164
     165#
    160166#  共通コンパイルオプションの定義
    161167#
     
    193199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    194200APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    195 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    196202
    197203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/DebugEther/Makefile

    r373 r374  
    158158
    159159#
     160#  mbedサービスの定義
     161#
     162
     163include $(SRCDIR)/mbed/Makefile.mbed
     164
     165#
    160166#  共通コンパイルオプションの定義
    161167#
     
    193199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    194200APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    195 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    196202
    197203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/src/client.c

    r371 r374  
    3333 *  の責任を負わない.
    3434 *
    35  *  @(#) $Id: client.c 1729 2019-01-09 14:44:36Z coas-nagasima $
     35 *  @(#) $Id$
    3636 */
    3737#include <lib/curl_config.h>
     
    4747#include "kernel_cfg.h"
    4848#include "ff.h"
    49 #include "util/ntstdio.h"
     49#include <stdio.h>
    5050#include "client.h"
    5151#include "jsonsl.h"
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/src/client.h

    r371 r374  
    3333 *  の責任を負わない.
    3434 *
    35  *  @(#) $Id: client.h 1784 2019-02-06 01:11:25Z coas-nagasima $
     35 *  @(#) $Id$
    3636 */
    3737
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/src/main.c

    r371 r374  
    6868#include "core/ntshell.h"
    6969#include "core/ntlibc.h"
    70 #include "util/ntstdio.h"
     70#include <stdio.h>
    7171#include "usrcmd.h"
    7272#include "util/ntopt.h"
    7373#include "socket_stub.h"
    74 #include "mbed_api.h"
     74#include "gpio_api.h"
    7575#include "usb_hbth.h"
    7676#include "ntshell_main.h"
     
    188188{
    189189        FILINFO fno;
    190 #if _USE_LFN
    191         char lfn[_MAX_LFN + 1];
     190#if FF_USE_LFN
     191        char lfn[FF_MAX_LFN + 1];
    192192        fno.lfname = lfn;
    193         fno.lfsize = _MAX_LFN + 1;
     193        fno.lfsize = FF_MAX_LFN + 1;
    194194#endif
    195195        ER ret;
    196196
    197 #ifdef TOPPERS_OMIT_TECS
    198         serial_opn_por(SIO_PORTID);
    199 #endif
    200         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    201 
    202197        //wolfSSL_Debugging_ON();
    203198
    204         ntshell_task_init(uart_read, uart_write, &main_obj);
     199        ntshell_task_init(SIO_PORTID);
    205200
    206201        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app2_light/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app2_light/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app2_light/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
     
    182188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    183189APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    184 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    185191
    186192#
  • asp3_tinet_ecnl_rx/trunk/app2_light/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
     
    182188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    183189APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    184 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    185191
    186192#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  gdicサービスの定義
    158164#
     
    190196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    193199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    194200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  gdicサービスの定義
    158164#
     
    190196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    193199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    194200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  gdicサービスの定義
    156162#
     
    188194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189195APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    192198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  gdicサービスの定義
    158164#
     
    190196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    193199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    194200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  gdicサービスの定義
    158164#
     
    190196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    193199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    194200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  gdicサービスの定義
    156162#
     
    188194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189195APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    191197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    192198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
     
    182188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    183189APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    184 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    185191
    186192#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/Debug/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/DebugCitrus/Makefile

    r364 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    184190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    185191APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    186 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    187193
    188194#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/DebugEther/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
     
    182188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    183189APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    184 APPL_COBJS := $(APPL_COBJS) mbed_api.o netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    185191
    186192#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/src/main.c

    r364 r374  
    6767#include "core/ntshell.h"
    6868#include "core/ntlibc.h"
    69 #include "util/ntstdio.h"
     69#include <stdio.h>
    7070#include "usrcmd.h"
    7171#include "util/ntopt.h"
    7272#include "socket_stub.h"
    73 #include "mbed_api.h"
     73#include "gpio_api.h"
    7474#include "usb_hbth.h"
    7575#include "ntshell_main.h"
     
    183183{
    184184        FILINFO fno;
    185 #if _USE_LFN
    186         char lfn[_MAX_LFN + 1];
     185#if FF_USE_LFN
     186        char lfn[FF_MAX_LFN + 1];
    187187        fno.lfname = lfn;
    188         fno.lfsize = _MAX_LFN + 1;
     188        fno.lfsize = FF_MAX_LFN + 1;
    189189#endif
    190190        ER ret;
    191191
    192 #ifdef TOPPERS_OMIT_TECS
    193         serial_opn_por(SIO_PORTID);
    194 #endif
    195         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    196 
    197         ntshell_task_init(uart_read, uart_write, &main_obj);
     192        ntshell_task_init(SIO_PORTID);
    198193
    199194        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/Debug/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/DebugCitrus/Makefile

    r364 r374  
    153153
    154154#
     155#  mbedサービスの定義
     156#
     157
     158include $(SRCDIR)/mbed/Makefile.mbed
     159
     160#
    155161#  共通コンパイルオプションの定義
    156162#
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/arch/rx630_gcc/tSCIF.c

    r337 r374  
    4747#include "tSCIF_tecsgen.h"
    4848#include "scif.h"
     49#include "target_kernel_impl.h"
    4950
    5051/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/cfg/pass1.rb

    r337 r374  
    727727  #
    728728  def self.OutLineNumber(cfgInfo)
    729     @cfg1Out.add("#line #{cfgInfo[:_LINE_]} \"#{cfgInfo[:_FILE_]}\"")
     729    @cfg1Out.add("#line #{cfgInfo[:_LINE_]} \"#{cfgInfo[:_FILE_].gsub('\\', '/')}\"")
    730730  end
    731731
     
    734734  #
    735735  def self.OutClassLineNumber(cfgInfo)
    736     @cfg1Out.add("#line #{cfgInfo[:CLASS_LINE_]} \"#{cfgInfo[:CLASS_FILE_]}\"")
     736    @cfg1Out.add("#line #{cfgInfo[:CLASS_LINE_]} \"#{cfgInfo[:CLASS_FILE_].gsub('\\', '/')}\"")
    737737  end
    738738
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/gdic/adafruit_ssd1306/adafruit_ssd1306.h

    r364 r374  
    2222#include <stdbool.h>
    2323#include <time.h>
    24 #include "mbed_api.h"
     24#include "gpio_api.h"
     25#include "spi_api.h"
     26#include "i2c_api.h"
    2527#include "gfxfont.h"
    2628
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/Makefile.target

    r337 r374  
    1313#  コンパイルオプション
    1414#
    15 INCLUDES := $(INCLUDES) -I$(TARGETDIR) -I$(SRCDIR)/pdic
     15INCLUDES := $(INCLUDES) -I$(TARGETDIR) -I$(SRCDIR)/mbed
    1616
    1717#
     
    2525#  システムサービスに関する定義
    2626#
    27 SYSSVC_DIRS := $(SYSSVC_DIRS)
     27SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed
    2828SYSSVC_COBJS := $(SYSSVC_COBJS)
    2929
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/gr_citrus.h

    r337 r374  
    7171 *  ボーレート設定
    7272 */
    73 #define BAUD_19200BPS           UINT_C( 78 )
    74 #define BAUD_38400BPS           UINT_C( 39 )
    75 #define BAUD_57600BPS           UINT_C( 25 )
    76 #define BAUD_115200BPS          UINT_C( 12 )
    77 
    78 #define UART_BAUDRATE           BAUD_115200BPS
     73#define UART_BAUDRATE           115200
    7974
    8075/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/tSIOPortGRCitrus.cdl

    r337 r374  
    5151 */
    5252import_C("gr_citrus.h");
    53 import_C("rx630.h");
     53import_C("device.h");
    5454
    5555/*
    5656 *  FIFO内蔵シリアルコミュニケーションインタフェース用 簡易SIOドライバ
    5757 */
    58 import("tSCIF.cdl");
     58import("tMbedSerial.cdl");
    5959
    6060/*
     
    7474        call                    sSIOPort        cSIOPort;
    7575        [inline] entry  siSIOCBR        eiSIOCBR;
    76 
    77         /*
    78          *  割込み要求ライン操作のための結合
    79          */
    80         call    sInterruptRequest       cRxInterruptRequest;
    81         call    sInterruptRequest       cTxInterruptRequest;
    8276};
    8377
     
    8680 *  ト)のセルタイプ
    8781 */
    88 [active]
    8982composite tSIOPortGRCitrus {
    9083        /*
     
    9891         */
    9992        attr {
    100                 uintptr_t       baseAddress;                            /* ベースアドレス */
    101                 INTNO           rxInterruptNumber;                      /* 受信割込み番号 */
    102                 INTNO           txInterruptNumber;                      /* 送信割込み番号 */
    103                 PRI                     isrPriority = 1;                        /* ISR優先度 */
    104                 PRI                     interruptPriority = -4;         /* 割込み優先度 */
     93                int32_t tx;                                                             /* 送信Pin */
     94                int32_t rx;                                                             /* 受信Pin */
    10595                uint32_t        baudRate = 115200;                      /* ボーレートの設定値 */
    10696        };
     
    10999         *  SIOドライバ
    110100         */
    111         cell tSCIF SCIF {
    112                 baseAddress = composite.baseAddress;
     101        cell tMbedSerial MbedSerial {
     102                tx          = composite.tx;
     103                rx          = composite.rx;
    113104                baudRate    = composite.baudRate;
    114105                ciSIOCBR    = SIOPortMain.eiSIOCBR;
     
    120111        cell tSIOPortGRCitrusMain SIOPortMain {
    121112                ciSIOCBR            => composite.ciSIOCBR;
    122                 cSIOPort            = SCIF.eSIOPort;
    123                 cRxInterruptRequest = RxInterruptRequest.eInterruptRequest;
    124                 cTxInterruptRequest = TxInterruptRequest.eInterruptRequest;
     113                cSIOPort            = MbedSerial.eSIOPort;
    125114        };
    126115        composite.eSIOPort => SIOPortMain.eSIOPort;
    127 
    128         /*
    129          *  SIOの受信割込みサービスルーチンと割込み要求ライン
    130          */
    131         cell tISR RxISRInstance {
    132                 interruptNumber = composite.rxInterruptNumber;
    133                 isrPriority     = composite.isrPriority;
    134                 ciISRBody       = SCIF.eiRxISR;
    135         };
    136         cell tInterruptRequest RxInterruptRequest {
    137                 interruptNumber   = composite.rxInterruptNumber;
    138                 interruptPriority = composite.interruptPriority;
    139         };
    140 
    141         /*
    142          *  SIOの受信割込みサービスルーチンと割込み要求ライン
    143          */
    144         cell tISR TxISRInstance {
    145                 interruptNumber = composite.txInterruptNumber;
    146                 isrPriority     = composite.isrPriority;
    147                 ciISRBody       = SCIF.eiTxISR;
    148         };
    149         cell tInterruptRequest TxInterruptRequest {
    150                 interruptNumber   = composite.txInterruptNumber;
    151                 interruptPriority = composite.interruptPriority;
    152         };
    153116};
    154117
     
    158121 *  サンプルプログラムが使うポートが,SIOPortTarget1に固定されているた
    159122 *  め,ポート1とポート3を入れ換えている.具体的には,SIOPortTarget1は
    160  *  SCIFのチャネル2(チャネル番号は0から始まるので,ポート3のこと)に,
    161  *  SIOPortTarget3はSCIFのチャネル0につながっている.
     123 *  MbedSerialのチャネル2(チャネル番号は0から始まるので,ポート3のこと)に,
     124 *  SIOPortTarget3はMbedSerialのチャネル0につながっている.
    162125 */
    163126[prototype]
    164127cell tSIOPortGRCitrus SIOPortTarget1 {
    165128        /* 属性の設定 */
    166         baseAddress       = C_EXP("SCI0_BASE");
    167         rxInterruptNumber = C_EXP("INT_SCI0_RXI");
    168         txInterruptNumber = C_EXP("INT_SCI0_TEI");
     129        tx = C_EXP("P20");              /* PIN_IO0 */
     130        rx = C_EXP("P21");              /* PIN_IO1 */
    169131};
    170132
     
    172134cell tSIOPortGRCitrus SIOPortTarget2 {
    173135        /* 属性の設定 */
    174         baseAddress       = C_EXP("SCI1_BASE");
    175         rxInterruptNumber = C_EXP("INT_SCI1_RXI");
    176         txInterruptNumber = C_EXP("INT_SCI1_TEI");
     136        tx = C_EXP("P50");              /* PIN_IO5 */
     137        rx = C_EXP("P52");              /* PIN_IO6 */
    177138};
    178139
     
    180141cell tSIOPortGRCitrus SIOPortTarget3 {
    181142        /* 属性の設定 */
    182         baseAddress       = C_EXP("SCI2_BASE");
    183         rxInterruptNumber = C_EXP("INT_SCI2_RXI");
    184         txInterruptNumber = C_EXP("INT_SCI2_TEI");
     143        tx = C_EXP("P32");              /* PIN_IO7 */
     144        rx = C_EXP("P33");              /* PIN_IO8 */
    185145};
    186146
     
    188148cell tSIOPortGRCitrus SIOPortTarget4 {
    189149        /* 属性の設定 */
    190         baseAddress       = C_EXP("SCI3_BASE");
    191         rxInterruptNumber = C_EXP("INT_SCI3_RXI");
    192         txInterruptNumber = C_EXP("INT_SCI3_TEI");
     150        tx = C_EXP("PC7");              /* PIN_IO12 */
     151        rx = C_EXP("PC6");              /* PIN_IO11 */
    193152};
    194153
     
    196155cell tSIOPortGRCitrus SIOPortTarget5 {
    197156        /* 属性の設定 */
    198         baseAddress       = C_EXP("SCI4_BASE");
    199         rxInterruptNumber = C_EXP("INT_SCI4_RXI");
    200         txInterruptNumber = C_EXP("INT_SCI4_TEI");
     157        tx = C_EXP("P26");              /* PIN_IO26 */
     158        rx = C_EXP("P30");              /* PIN_IO22 */
    201159};
    202160
     
    204162cell tSIOPortGRCitrus SIOPortTarget6 {
    205163        /* 属性の設定 */
    206         baseAddress       = C_EXP("SCI5_BASE");
    207         rxInterruptNumber = C_EXP("INT_SCI5_RXI");
    208         txInterruptNumber = C_EXP("INT_SCI5_TEI");
     164        tx = C_EXP("PB5");              /* PIN_IO29 */
     165        rx = C_EXP("P25");              /* PIN_IO23 */
    209166};
    210167
     
    212169cell tSIOPortGRCitrus SIOPortTarget7 {
    213170        /* 属性の設定 */
    214         baseAddress       = C_EXP("SCI6_BASE");
    215         rxInterruptNumber = C_EXP("INT_SCI6_RXI");
    216         txInterruptNumber = C_EXP("INT_SCI6_TEI");
     171        tx = C_EXP("PA0");              /* PIN_IO33 */
     172        rx = C_EXP("PC2");              /* PIN_IO4 */
    217173};
    218174
     
    220176cell tSIOPortGRCitrus SIOPortTarget8 {
    221177        /* 属性の設定 */
    222         baseAddress       = NULL;
    223         rxInterruptNumber = NULL;
    224         txInterruptNumber = NULL;
     178        rx = NULL;
     179        tx = NULL;
    225180};
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/tSIOPortGRCitrusMain_inline.h

    r337 r374  
    5757         */
    5858        cSIOPort_open();
    59 
    60         /*
    61          *  SIOの割込みマスクを解除する.
    62          */
    63         cRxInterruptRequest_enable();
    64         cTxInterruptRequest_enable();
    6559}
    6660
     
    7771         */
    7872        cSIOPort_close();
    79 
    80         /*
    81          *  SIOの割込みをマスクする.
    82          */
    83         cRxInterruptRequest_disable();
    84         cTxInterruptRequest_disable();
    8573}
    8674
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_kernel_impl.c

    r364 r374  
    5353#include "syssvc/serial.h"
    5454#ifdef TOPPERS_OMIT_TECS
    55 #include "rx630_uart.h"
     55#include "serial_api.h"
     56#endif
     57
     58#ifdef TOPPERS_OMIT_TECS
     59serial_t log_serial;
    5660#endif
    5761
     
    7579                sil_reb_mem(PORTA_PDR_ADDR) & ~PORT_PDR_B7_BIT);
    7680
     81#ifdef TOPPERS_OMIT_TECS
    7782        /*
    7883         *  シリアルポートの設定
    7984         */
    80 
    81         /* ポートP20をTxD0, ポートP21をRxD0に */
    82         sil_wrb_mem(PORT2_PMR_ADDR, 0x03);
    83 
    84         /* データディレクションレジスタ(PDR)の設定 P21(RxD0)を入力ポートにする */
    85         sil_wrb_mem(PORT2_PDR_ADDR,
    86                 sil_reb_mem(PORT2_PDR_ADDR) & ~PORT_PDR_B1_BIT);
    87 
    88         /* データディレクションレジスタ(PDR)の設定 P20(TxD0)を出力ポートにする */
    89         sil_wrb_mem(PORT2_PDR_ADDR,
    90                 sil_reb_mem(PORT2_PDR_ADDR) | PORT_PDR_B0_BIT);
     85        serial_init(&log_serial, P20, P21);
     86        serial_baud(&log_serial, UART_BAUDRATE);
     87        serial_format(&log_serial, 8, ParityNone, 1);
     88#endif
    9189
    9290        /* ポートP40~P47を周辺機器に */
     
    149147{
    150148        if (c == '\n') {
    151                 rx630_uart_pol_putc('\r', TARGET_PUTC_PORTID);
     149                serial_putc(&log_serial, '\r');
    152150        }
    153151
    154         rx630_uart_pol_putc(c, TARGET_PUTC_PORTID);
     152        serial_putc(&log_serial, c);
    155153}
    156154#endif
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_serial.c

    r337 r374  
    33 *      Toyohashi Open Platform for Embedded Real-Time Systems/
    44 *      Advanced Standard Profile Kernel
    5  * 
     5 *
    66 *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    77 *                              Toyohashi Univ. of Technology, JAPAN
     
    1212 *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    1313 *  Copyright (C) 2013      by Mitsuhiro Matsuura
    14  * 
     14 *
    1515 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    1616 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    3535 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    3636 *      免責すること.
    37  * 
     37 *
    3838 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3939 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    4141 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    4242 *  の責任を負わない.
    43  * 
     43 *
    4444 *  @(#) $Id$
    4545 */
     
    5151#include <sil.h>
    5252#include "target_serial.h"
     53#include "hal/serial_api.h"
     54#include "target_syssvc.h"
     55#include "syssvc/serial.h"
     56
     57/*
     58 *  シリアルI/Oポート初期化ブロックの定義
     59 */
     60typedef struct sio_port_initialization_block {
     61        PinName tx;
     62        PinName rx;
     63} SIOPINIB;
     64
     65/*
     66 *  シリアルI/Oポート管理ブロックの定義
     67 */
     68struct sio_port_control_block {
     69        const SIOPINIB *p_siopinib;
     70        intptr_t exinf;
     71        bool_t openflag;
     72        serial_t serial;
     73};
     74
     75/*
     76 *  シリアルI/Oポート管理ブロックのエリア
     77 */
     78SIOPCB siopcb_table[TNUM_PORT];
     79
     80static const SIOPINIB siopinib_table[TNUM_SIOP] =
     81{
     82        { P20, P21 },
     83#if TNUM_SIOP > 1
     84        { P50, P52 },
     85#endif
     86#if TNUM_SIOP > 2
     87        { P32, P33 },
     88#endif
     89#if TNUM_SIOP > 3
     90        { PC7, PC6 },
     91#endif
     92#if TNUM_SIOP > 4
     93        { P26, P30 },
     94#endif
     95#if TNUM_SIOP > 5
     96        { PB5, P25 },
     97#endif
     98#if TNUM_SIOP > 6
     99        { PA0, PC2 },
     100#endif
     101};
     102
     103/*
     104 *  シリアルI/OポートIDから管理ブロックを取り出すためのマクロ
     105 */
     106#define INDEX_SIOP(siopid)       ((uint_t)((siopid) - 1))
     107#define get_siopcb(siopid)       (&(siopcb_table[INDEX_SIOP(siopid)]))
     108#define get_siopinib(siopid) (&(siopinib_table[INDEX_SIOP(siopid)]))
     109
     110static void mbed_serial_irq_handler(uint32_t id, SerialIrq event);
    53111
    54112/*
     
    58116sio_initialize(intptr_t exinf)
    59117{
    60         rx630_uart_initialize();
     118        SIOPCB  *p_siopcb;
     119        uint_t  i;
     120
     121        /*
     122         *  シリアルI/Oポート管理ブロックの初期化
     123         */
     124        for (p_siopcb = siopcb_table, i = 0; i < TNUM_SIOP; p_siopcb++, i++) {
     125                p_siopcb->p_siopinib = &(siopinib_table[i]);
     126                p_siopcb->openflag = false;
     127        }
    61128}
    62129
     
    69136        SIOPCB  *p_siopcb = NULL;
    70137        ER      ercd;
    71         INTNO   intno_sio_tx, intno_sio_rx;
    72        
    73         /*
    74          *  シリアルI/O割込みをマスクする.
    75          *  (dis_int関数は、"\kernel\interrupt.c"に記述)
    76          */
    77         p_siopcb = rx630_uart_get_siopcb(siopid);
    78         intno_sio_tx = rx630_uart_intno_tx(p_siopcb);
    79         intno_sio_rx = rx630_uart_intno_rx(p_siopcb);
    80         ercd = dis_int(intno_sio_tx);
    81         assert(ercd == E_OK);
    82         ercd = dis_int(intno_sio_rx);
    83         assert(ercd == E_OK);
    84        
    85         p_siopcb =
    86                 rx630_uart_opn_por(siopid , exinf , UART_BAUDRATE , UART_CLKSRC);
    87 
    88         /*
    89          *  シリアルI/O割込みをマスク解除する.
    90          *  (ena_int関数は、"\kernel\interrupt.c"に記述)
    91          */
    92         ercd = ena_int(intno_sio_tx);
    93         assert(ercd == E_OK);
    94         ercd = ena_int(intno_sio_rx);
    95         assert(ercd == E_OK);
    96 
    97         return(p_siopcb);
     138        serial_t *serial;
     139
     140        if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
     141                return NULL;
     142        p_siopcb = get_siopcb(siopid);
     143
     144        if (p_siopcb->openflag)
     145                return NULL;
     146        p_siopcb->openflag = true;
     147        p_siopcb->exinf = exinf;
     148
     149        serial = &p_siopcb->serial;
     150        serial_init(serial, p_siopcb->p_siopinib->tx, p_siopcb->p_siopinib->rx);
     151        serial_baud(serial, UART_BAUDRATE);
     152        serial_format(serial, 8, ParityNone, 1);
     153
     154        serial_irq_handler(serial, mbed_serial_irq_handler, siopid);
     155
     156        return p_siopcb;
    98157}
    99158
     
    105164{
    106165        ER        ercd;
    107         INTNO   intno_sio_tx, intno_sio_rx;
     166        serial_t *serial = &p_siopcb->serial;
    108167
    109168        /*
    110169         *  デバイス依存のクローズ処理.
    111170         */
    112         rx630_uart_cls_por(p_siopcb);
    113        
    114         /*
    115          *  シリアルI/O割込みをマスクする.
    116          */
    117         intno_sio_tx = rx630_uart_intno_tx(p_siopcb);
    118         intno_sio_rx = rx630_uart_intno_rx(p_siopcb);
    119         ercd = dis_int(intno_sio_tx);
    120         assert(ercd == E_OK);
    121         ercd = dis_int(intno_sio_rx);
    122         assert(ercd == E_OK);
     171        serial_free(serial);
     172        p_siopcb->openflag = false;
     173}
     174
     175/*
     176 *  シリアルI/Oポートへの文字送信
     177 */
     178bool_t
     179sio_snd_chr(SIOPCB *p_siopcb, char c)
     180{
     181        serial_t *serial = &p_siopcb->serial;
     182        if (!serial_writable(serial))
     183                return false;
     184        serial_putc(serial, c);
     185        return true;
     186}
     187
     188/*
     189 *  シリアルI/Oポートからの文字受信
     190 */
     191int_t
     192sio_rcv_chr(SIOPCB *p_siopcb)
     193{
     194        serial_t *serial = &p_siopcb->serial;
     195        if (!serial_readable(serial))
     196                return -1;
     197        return serial_getc(serial);
     198}
     199
     200/*
     201 *  シリアルI/Oポートからのコールバックの許可
     202 */
     203void
     204sio_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
     205{
     206        serial_t *serial = &p_siopcb->serial;
     207        switch (cbrtn) {
     208        case SIO_RDY_SND:
     209                serial_irq_set(serial, TxIrq, true);
     210                break;
     211        case SIO_RDY_RCV:
     212                serial_irq_set(serial, RxIrq, true);
     213                break;
     214        }
     215}
     216
     217/*
     218 *  シリアルI/Oポートからのコールバックの禁止
     219 */
     220void
     221sio_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
     222{
     223        serial_t *serial = &p_siopcb->serial;
     224        switch (cbrtn) {
     225        case SIO_RDY_SND:
     226                serial_irq_set(serial, TxIrq, false);
     227                break;
     228        case SIO_RDY_RCV:
     229                serial_irq_set(serial, RxIrq, false);
     230                break;
     231        }
     232}
     233
     234/*
     235 *  シリアルI/Oポートからの送信可能コールバック
     236 */
     237void
     238serial_irdy_snd(SIOPCB  *p_siopcb)
     239{
     240        /* 共通部(syssvc\serial.c)にあるsio_irdy_snd関数を呼び出し*/
     241        sio_irdy_snd(p_siopcb->exinf);
     242}
     243
     244/*
     245 *  シリアルI/Oポートからの受信通知コールバック
     246 */
     247void
     248serial_irdy_rcv(SIOPCB  *p_siopcb)
     249{
     250        /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
     251        sio_irdy_rcv(p_siopcb->exinf);
    123252}
    124253
     
    126255 *  SIOの割込みハンドラ
    127256 */
    128 void sio_tx_isr(intptr_t exinf)
    129 {
    130         rx630_uart_tx_isr(exinf);
    131 }
    132 
    133 /*
    134  *  SIOの割込みハンドラ
    135  */
    136 void sio_rx_isr(intptr_t exinf)
    137 {
    138         rx630_uart_rx_isr(exinf);
    139 }
    140 
    141 /*
    142  *  シリアルI/Oポートへの文字送信
    143  */
    144 bool_t
    145 sio_snd_chr(SIOPCB *siopcb, char c)
    146 {
    147         return(rx630_uart_snd_chr(siopcb, c));
    148 }
    149 
    150 /*
    151  *  シリアルI/Oポートからの文字受信
    152  */
    153 int_t
    154 sio_rcv_chr(SIOPCB *siopcb)
    155 {
    156         return(rx630_uart_rcv_chr(siopcb));
    157 }
    158 
    159 /*
    160  *  シリアルI/Oポートからのコールバックの許可
    161  */
    162 void
    163 sio_ena_cbr(SIOPCB *siopcb, uint_t cbrtn)
    164 {
    165         rx630_uart_ena_cbr(siopcb, cbrtn);
    166 }
    167 
    168 /*
    169  *  シリアルI/Oポートからのコールバックの禁止
    170  */
    171 void
    172 sio_dis_cbr(SIOPCB *siopcb, uint_t cbrtn)
    173 {
    174         rx630_uart_dis_cbr(siopcb, cbrtn);
    175 }
    176 
    177 /*
    178  *  シリアルI/Oポートからの送信可能コールバック
    179  */
    180 void
    181 rx630_uart_irdy_snd(intptr_t exinf)
    182 {
    183         /* 共通部(syssvc\serial.c)にあるsio_irdy_snd関数を呼び出し*/
    184         sio_irdy_snd(exinf);
    185 }
    186 
    187 /*
    188  *  シリアルI/Oポートからの受信通知コールバック
    189  */
    190 void
    191 rx630_uart_irdy_rcv(intptr_t exinf)
    192 {
    193         /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
    194         sio_irdy_rcv(exinf);
    195 }
    196 
     257void
     258mbed_serial_irq_handler(uint32_t siopid, SerialIrq event)
     259{
     260        SIOPCB  *p_siopcb;
     261
     262        if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
     263                return;
     264        p_siopcb = get_siopcb(siopid);
     265
     266        if (!p_siopcb->openflag)
     267                return;
     268
     269        switch (event) {
     270        case TxIrq:
     271                serial_irdy_snd(p_siopcb);
     272                break;
     273        case RxIrq:
     274                serial_irdy_rcv(p_siopcb);
     275                break;
     276        }
     277}
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_serial.cfg

    r337 r374  
    44
    55#include <target_serial.h>
     6
    67ATT_INI({ TA_NULL, 0, sio_initialize });
    7 CFG_INT(INTNO_SIO_TX, { INTATR_SIO, INTPRI_SIO });
    8 CFG_INT(INTNO_SIO_RX, { INTATR_SIO, INTPRI_SIO });
    98
    10 CRE_ISR(INTNO_SIO_TX_ISR, {TA_NULL, SIO_PORTID, INTNO_SIO_TX, sio_tx_isr, 1});
    11 CRE_ISR(INTNO_SIO_RX_ISR, {TA_NULL, SIO_PORTID, INTNO_SIO_RX, sio_rx_isr, 1});
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_serial.h

    r337 r374  
    5353
    5454#include "gr_citrus.h"
    55 #include "rx630_uart.h"
     55#include "serial_api.h"
    5656
    57 /*
    58  *  SIOの割込みハンドラのベクタ番号
    59  */
    60 #define INHNO_SIO_TX    INT_SCI1_TEI                    /* 割込みハンドラ番号 */
    61 #define INTNO_SIO_TX    INT_SCI1_TEI                    /* 割込み番号 */
    62 #define INHNO_SIO_RX    INT_SCI1_RXI                    /* 割込みハンドラ番号 */
    63 #define INTNO_SIO_RX    INT_SCI1_RXI                    /* 割込み番号 */
    64 #define INTPRI_SIO              -4                                              /* 割込み優先度 */
    65 #define INTATR_SIO              (TA_NULL)                               /* 割込み属性 */
     57#define SIO_RDY_SND 1
     58#define SIO_RDY_RCV 2
    6659
    6760#ifndef TOPPERS_MACRO_ONLY
    6861
     62typedef struct sio_port_control_block SIOPCB;
    6963
    7064/*
     
    8276 */
    8377extern void             sio_cls_por(SIOPCB *p_siopcb);
    84 
    85 /*
    86  *  SIOの割込みハンドラ
    87  */
    88 extern void     sio_tx_isr(intptr_t exinf);
    89 extern void     sio_rx_isr(intptr_t exinf);
    9078
    9179/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_syssvc.h

    r337 r374  
    113113
    114114/*
     115 *  使用するシリアルポートのPinName
     116 */
     117#define STDIO_UART_TX P20
     118#define STDIO_UART_RX P21
     119
     120/*
    115121 *  システムログタスク関連の定数の定義
    116122 *
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/Makefile.target

    r337 r374  
    1313#  コンパイルオプション
    1414#
    15 INCLUDES := $(INCLUDES) -I$(TARGETDIR) -I$(SRCDIR)/pdic
     15INCLUDES := $(INCLUDES) -I$(TARGETDIR) -I$(SRCDIR)/mbed
    1616
    1717#
     
    2525#  システムサービスに関する定義
    2626#
    27 SYSSVC_DIRS := $(SYSSVC_DIRS)
     27SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed
    2828SYSSVC_COBJS := $(SYSSVC_COBJS)
    2929
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/gr_sakura.h

    r337 r374  
    7171 *  ボーレート設定
    7272 */
    73 #define BAUD_19200BPS           UINT_C( 78 )
    74 #define BAUD_38400BPS           UINT_C( 39 )
    75 #define BAUD_57600BPS           UINT_C( 25 )
    76 #define BAUD_115200BPS          UINT_C( 12 )
    77 
    78 #define UART_BAUDRATE           BAUD_115200BPS
     73#define UART_BAUDRATE           115200
    7974
    8075/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/tSIOPortGRSakura.cdl

    r337 r374  
    5151 */
    5252import_C("gr_sakura.h");
    53 import_C("rx630.h");
     53import_C("device.h");
    5454
    5555/*
    5656 *  FIFO内蔵シリアルコミュニケーションインタフェース用 簡易SIOドライバ
    5757 */
    58 import("tSCIF.cdl");
     58import("tMbedSerial.cdl");
    5959
    6060/*
     
    7474        call                    sSIOPort        cSIOPort;
    7575        [inline] entry  siSIOCBR        eiSIOCBR;
    76 
    77         /*
    78          *  割込み要求ライン操作のための結合
    79          */
    80         call    sInterruptRequest       cRxInterruptRequest;
    81         call    sInterruptRequest       cTxInterruptRequest;
    8276};
    8377
     
    8680 *  ト)のセルタイプ
    8781 */
    88 [active]
    8982composite tSIOPortGRSakura {
    9083        /*
     
    9891         */
    9992        attr {
    100                 uintptr_t       baseAddress;                            /* ベースアドレス */
    101                 INTNO           rxInterruptNumber;                      /* 受信割込み番号 */
    102                 INTNO           txInterruptNumber;                      /* 送信割込み番号 */
    103                 PRI                     isrPriority = 1;                        /* ISR優先度 */
    104                 PRI                     interruptPriority = -4;         /* 割込み優先度 */
     93                int32_t tx;                                                             /* 送信Pin */
     94                int32_t rx;                                                             /* 受信Pin */
    10595                uint32_t        baudRate = 115200;                      /* ボーレートの設定値 */
    10696        };
     
    10999         *  SIOドライバ
    110100         */
    111         cell tSCIF SCIF {
    112                 baseAddress = composite.baseAddress;
     101        cell tMbedSerial MbedSerial {
     102                tx          = composite.tx;
     103                rx          = composite.rx;
    113104                baudRate    = composite.baudRate;
    114105                ciSIOCBR    = SIOPortMain.eiSIOCBR;
     
    120111        cell tSIOPortGRSakuraMain SIOPortMain {
    121112                ciSIOCBR            => composite.ciSIOCBR;
    122                 cSIOPort            = SCIF.eSIOPort;
    123                 cRxInterruptRequest = RxInterruptRequest.eInterruptRequest;
    124                 cTxInterruptRequest = TxInterruptRequest.eInterruptRequest;
     113                cSIOPort            = MbedSerial.eSIOPort;
    125114        };
    126115        composite.eSIOPort => SIOPortMain.eSIOPort;
    127 
    128         /*
    129          *  SIOの受信割込みサービスルーチンと割込み要求ライン
    130          */
    131         cell tISR RxISRInstance {
    132                 interruptNumber = composite.rxInterruptNumber;
    133                 isrPriority     = composite.isrPriority;
    134                 ciISRBody       = SCIF.eiRxISR;
    135         };
    136         cell tInterruptRequest RxInterruptRequest {
    137                 interruptNumber   = composite.rxInterruptNumber;
    138                 interruptPriority = composite.interruptPriority;
    139         };
    140 
    141         /*
    142          *  SIOの受信割込みサービスルーチンと割込み要求ライン
    143          */
    144         cell tISR TxISRInstance {
    145                 interruptNumber = composite.txInterruptNumber;
    146                 isrPriority     = composite.isrPriority;
    147                 ciISRBody       = SCIF.eiTxISR;
    148         };
    149         cell tInterruptRequest TxInterruptRequest {
    150                 interruptNumber   = composite.txInterruptNumber;
    151                 interruptPriority = composite.interruptPriority;
    152         };
    153116};
    154117
     
    158121 *  サンプルプログラムが使うポートが,SIOPortTarget1に固定されているた
    159122 *  め,ポート1とポート3を入れ換えている.具体的には,SIOPortTarget1は
    160  *  SCIFのチャネル2(チャネル番号は0から始まるので,ポート3のこと)に,
    161  *  SIOPortTarget3はSCIFのチャネル0につながっている.
     123 *  MbedSerialのチャネル2(チャネル番号は0から始まるので,ポート3のこと)に,
     124 *  SIOPortTarget3はMbedSerialのチャネル0につながっている.
    162125 */
    163126[prototype]
    164127cell tSIOPortGRSakura SIOPortTarget1 {
    165128        /* 属性の設定 */
    166         baseAddress       = C_EXP("SCI0_BASE");
    167         rxInterruptNumber = C_EXP("INT_SCI0_RXI");
    168         txInterruptNumber = C_EXP("INT_SCI0_TEI");
     129        tx = C_EXP("P20");              /* PIN_IO1 */
     130        rx = C_EXP("P21");              /* PIN_IO0 */
    169131};
    170132
     
    172134cell tSIOPortGRSakura SIOPortTarget2 {
    173135        /* 属性の設定 */
    174         baseAddress       = C_EXP("SCI1_BASE");
    175         rxInterruptNumber = C_EXP("INT_SCI1_RXI");
    176         txInterruptNumber = C_EXP("INT_SCI1_TEI");
     136        tx = C_EXP("P32");              /* PIN_IO6 */
     137        rx = C_EXP("P33");              /* PIN_IO7 */
    177138};
    178139
     
    180141cell tSIOPortGRSakura SIOPortTarget3 {
    181142        /* 属性の設定 */
    182         baseAddress       = C_EXP("SCI2_BASE");
    183         rxInterruptNumber = C_EXP("INT_SCI2_RXI");
    184         txInterruptNumber = C_EXP("INT_SCI2_TEI");
     143        tx = C_EXP("P50");              /* PIN_IO24 */
     144        rx = C_EXP("P52");              /* PIN_IO26 */
    185145};
    186146
     
    188148cell tSIOPortGRSakura SIOPortTarget4 {
    189149        /* 属性の設定 */
    190         baseAddress       = C_EXP("SCI3_BASE");
    191         rxInterruptNumber = C_EXP("INT_SCI3_RXI");
    192         txInterruptNumber = C_EXP("INT_SCI3_TEI");
     150        tx = C_EXP("P23");              /* PIN_IO3 */
     151        rx = C_EXP("P25");              /* PIN_IO5 */
    193152};
    194153
     
    196155cell tSIOPortGRSakura SIOPortTarget5 {
    197156        /* 属性の設定 */
    198         baseAddress       = C_EXP("SCI4_BASE");
    199         rxInterruptNumber = C_EXP("INT_SCI4_RXI");
    200         txInterruptNumber = C_EXP("INT_SCI4_TEI");
     157        tx = C_EXP("PC3");              /* PIN_IO9 */
     158        rx = C_EXP("PC2");              /* PIN_IO8 */
    201159};
    202160
     
    204162cell tSIOPortGRSakura SIOPortTarget6 {
    205163        /* 属性の設定 */
    206         baseAddress       = C_EXP("SCI5_BASE");
    207         rxInterruptNumber = C_EXP("INT_SCI5_RXI");
    208         txInterruptNumber = C_EXP("INT_SCI5_TEI");
     164        tx = C_EXP("PC7");              /* PIN_IO12 */
     165        rx = C_EXP("PC6");              /* PIN_IO11 */
    209166};
    210167
     
    212169cell tSIOPortGRSakura SIOPortTarget7 {
    213170        /* 属性の設定 */
    214         baseAddress       = C_EXP("SCI6_BASE");
    215         rxInterruptNumber = C_EXP("INT_SCI6_RXI");
    216         txInterruptNumber = C_EXP("INT_SCI6_TEI");
     171        tx = C_EXP("P26");              /* PIN_IO58 */
     172        rx = C_EXP("P30");              /* PIN_IO60 */
    217173};
    218174
     
    220176cell tSIOPortGRSakura SIOPortTarget8 {
    221177        /* 属性の設定 */
    222         baseAddress       = NULL;
    223         rxInterruptNumber = NULL;
    224         txInterruptNumber = NULL;
     178        tx = NULL;
     179        rx = NULL;
    225180};
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/tSIOPortGRSakuraMain_inline.h

    r337 r374  
    5757         */
    5858        cSIOPort_open();
    59 
    60         /*
    61          *  SIOの割込みマスクを解除する.
    62          */
    63         cRxInterruptRequest_enable();
    64         cTxInterruptRequest_enable();
    6559}
    6660
     
    7771         */
    7872        cSIOPort_close();
    79 
    80         /*
    81          *  SIOの割込みをマスクする.
    82          */
    83         cRxInterruptRequest_disable();
    84         cTxInterruptRequest_disable();
    8573}
    8674
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_kernel_impl.c

    r364 r374  
    5353#include "syssvc/serial.h"
    5454#ifdef TOPPERS_OMIT_TECS
    55 #include "rx630_uart.h"
     55#include "serial_api.h"
     56#endif
     57
     58#ifdef TOPPERS_OMIT_TECS
     59serial_t log_serial;
    5660#endif
    5761
     
    7882                sil_reb_mem(PORTA_PDR_ADDR) & ~PORT_PDR_B7_BIT);
    7983
     84#ifdef TOPPERS_OMIT_TECS
    8085        /*
    8186         *  シリアルポートの設定
    8287         */
    83 
    84         /* ポートP20をTxD0, ポートP21をRxD0に */
    85         sil_wrb_mem(PORT2_PMR_ADDR, 0x03);
    86 
    87         /* データディレクションレジスタ(PDR)の設定 P21(RxD0)を入力ポートにする */
    88         sil_wrb_mem(PORT2_PDR_ADDR,
    89                 sil_reb_mem(PORT2_PDR_ADDR) & ~PORT_PDR_B1_BIT);
    90 
    91         /* データディレクションレジスタ(PDR)の設定 P20(TxD0)を出力ポートにする */
    92         sil_wrb_mem(PORT2_PDR_ADDR,
    93                 sil_reb_mem(PORT2_PDR_ADDR) | PORT_PDR_B0_BIT);
     88        serial_init(&log_serial, P20, P21);
     89        serial_baud(&log_serial, UART_BAUDRATE);
     90        serial_format(&log_serial, 8, ParityNone, 1);
     91#endif
    9492
    9593        /* ポートP40~P47を周辺機器に */
     
    152150{
    153151        if (c == '\n') {
    154                 rx630_uart_pol_putc('\r', TARGET_PUTC_PORTID);
     152                serial_putc(&log_serial, '\r');
    155153        }
    156154
    157         rx630_uart_pol_putc(c, TARGET_PUTC_PORTID);
     155        serial_putc(&log_serial, c);
    158156}
    159157#endif
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_serial.c

    r337 r374  
    33 *      Toyohashi Open Platform for Embedded Real-Time Systems/
    44 *      Advanced Standard Profile Kernel
    5  * 
     5 *
    66 *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    77 *                              Toyohashi Univ. of Technology, JAPAN
     
    1212 *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    1313 *  Copyright (C) 2013      by Mitsuhiro Matsuura
    14  * 
     14 *
    1515 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    1616 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    3535 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    3636 *      免責すること.
    37  * 
     37 *
    3838 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3939 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    4141 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    4242 *  の責任を負わない.
    43  * 
     43 *
    4444 *  @(#) $Id$
    4545 */
     
    5151#include <sil.h>
    5252#include "target_serial.h"
     53#include "hal/serial_api.h"
     54#include "target_syssvc.h"
     55#include "syssvc/serial.h"
     56
     57/*
     58 *  シリアルI/Oポート初期化ブロックの定義
     59 */
     60typedef struct sio_port_initialization_block {
     61        PinName tx;
     62        PinName rx;
     63} SIOPINIB;
     64
     65/*
     66 *  シリアルI/Oポート管理ブロックの定義
     67 */
     68struct sio_port_control_block {
     69        const SIOPINIB *p_siopinib;
     70        intptr_t exinf;
     71        bool_t openflag;
     72        serial_t serial;
     73};
     74
     75/*
     76 *  シリアルI/Oポート管理ブロックのエリア
     77 */
     78SIOPCB siopcb_table[TNUM_PORT];
     79
     80static const SIOPINIB siopinib_table[TNUM_SIOP] =
     81{
     82        { P20, P21 },
     83#if TNUM_SIOP > 1
     84        { P32, P33 },
     85#endif
     86#if TNUM_SIOP > 2
     87        { P50, P52 },
     88#endif
     89#if TNUM_SIOP > 3
     90        { P23, P25 },
     91#endif
     92#if TNUM_SIOP > 4
     93        { PC3, PC2 },
     94#endif
     95#if TNUM_SIOP > 5
     96        { PC7, PC6 },
     97#endif
     98#if TNUM_SIOP > 6
     99        { P26, P30 },
     100#endif
     101};
     102
     103/*
     104 *  シリアルI/OポートIDから管理ブロックを取り出すためのマクロ
     105 */
     106#define INDEX_SIOP(siopid)       ((uint_t)((siopid) - 1))
     107#define get_siopcb(siopid)       (&(siopcb_table[INDEX_SIOP(siopid)]))
     108#define get_siopinib(siopid) (&(siopinib_table[INDEX_SIOP(siopid)]))
     109
     110static void mbed_serial_irq_handler(uint32_t id, SerialIrq event);
    53111
    54112/*
     
    58116sio_initialize(intptr_t exinf)
    59117{
    60         rx630_uart_initialize();
     118        SIOPCB  *p_siopcb;
     119        uint_t  i;
     120
     121        /*
     122         *  シリアルI/Oポート管理ブロックの初期化
     123         */
     124        for (p_siopcb = siopcb_table, i = 0; i < TNUM_SIOP; p_siopcb++, i++) {
     125                p_siopcb->p_siopinib = &(siopinib_table[i]);
     126                p_siopcb->openflag = false;
     127        }
    61128}
    62129
     
    69136        SIOPCB  *p_siopcb = NULL;
    70137        ER      ercd;
    71         INTNO   intno_sio_tx, intno_sio_rx;
    72        
    73         /*
    74          *  シリアルI/O割込みをマスクする.
    75          *  (dis_int関数は、"\kernel\interrupt.c"に記述)
    76          */
    77         p_siopcb = rx630_uart_get_siopcb(siopid);
    78         intno_sio_tx = rx630_uart_intno_tx(p_siopcb);
    79         intno_sio_rx = rx630_uart_intno_rx(p_siopcb);
    80         ercd = dis_int(intno_sio_tx);
    81         assert(ercd == E_OK);
    82         ercd = dis_int(intno_sio_rx);
    83         assert(ercd == E_OK);
    84        
    85         p_siopcb =
    86                 rx630_uart_opn_por(siopid , exinf , UART_BAUDRATE , UART_CLKSRC);
    87 
    88         /*
    89          *  シリアルI/O割込みをマスク解除する.
    90          *  (ena_int関数は、"\kernel\interrupt.c"に記述)
    91          */
    92         ercd = ena_int(intno_sio_tx);
    93         assert(ercd == E_OK);
    94         ercd = ena_int(intno_sio_rx);
    95         assert(ercd == E_OK);
    96 
    97         return(p_siopcb);
     138        serial_t *serial;
     139
     140        if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
     141                return NULL;
     142        p_siopcb = get_siopcb(siopid);
     143
     144        if (p_siopcb->openflag)
     145                return NULL;
     146        p_siopcb->openflag = true;
     147        p_siopcb->exinf = exinf;
     148
     149        serial = &p_siopcb->serial;
     150        serial_init(serial, p_siopcb->p_siopinib->tx, p_siopcb->p_siopinib->rx);
     151        serial_baud(serial, UART_BAUDRATE);
     152        serial_format(serial, 8, ParityNone, 1);
     153
     154        serial_irq_handler(serial, mbed_serial_irq_handler, siopid);
     155
     156        return p_siopcb;
    98157}
    99158
     
    105164{
    106165        ER        ercd;
    107         INTNO   intno_sio_tx, intno_sio_rx;
     166        serial_t *serial = &p_siopcb->serial;
    108167
    109168        /*
    110169         *  デバイス依存のクローズ処理.
    111170         */
    112         rx630_uart_cls_por(p_siopcb);
    113        
    114         /*
    115          *  シリアルI/O割込みをマスクする.
    116          */
    117         intno_sio_tx = rx630_uart_intno_tx(p_siopcb);
    118         intno_sio_rx = rx630_uart_intno_rx(p_siopcb);
    119         ercd = dis_int(intno_sio_tx);
    120         assert(ercd == E_OK);
    121         ercd = dis_int(intno_sio_rx);
    122         assert(ercd == E_OK);
     171        serial_free(serial);
     172        p_siopcb->openflag = false;
     173}
     174
     175/*
     176 *  シリアルI/Oポートへの文字送信
     177 */
     178bool_t
     179sio_snd_chr(SIOPCB *p_siopcb, char c)
     180{
     181        serial_t *serial = &p_siopcb->serial;
     182        if (!serial_writable(serial))
     183                return false;
     184        serial_putc(serial, c);
     185        return true;
     186}
     187
     188/*
     189 *  シリアルI/Oポートからの文字受信
     190 */
     191int_t
     192sio_rcv_chr(SIOPCB *p_siopcb)
     193{
     194        serial_t *serial = &p_siopcb->serial;
     195        if (!serial_readable(serial))
     196                return -1;
     197        return serial_getc(serial);
     198}
     199
     200/*
     201 *  シリアルI/Oポートからのコールバックの許可
     202 */
     203void
     204sio_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
     205{
     206        serial_t *serial = &p_siopcb->serial;
     207        switch (cbrtn) {
     208        case SIO_RDY_SND:
     209                serial_irq_set(serial, TxIrq, true);
     210                break;
     211        case SIO_RDY_RCV:
     212                serial_irq_set(serial, RxIrq, true);
     213                break;
     214        }
     215}
     216
     217/*
     218 *  シリアルI/Oポートからのコールバックの禁止
     219 */
     220void
     221sio_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
     222{
     223        serial_t *serial = &p_siopcb->serial;
     224        switch (cbrtn) {
     225        case SIO_RDY_SND:
     226                serial_irq_set(serial, TxIrq, false);
     227                break;
     228        case SIO_RDY_RCV:
     229                serial_irq_set(serial, RxIrq, false);
     230                break;
     231        }
     232}
     233
     234/*
     235 *  シリアルI/Oポートからの送信可能コールバック
     236 */
     237void
     238serial_irdy_snd(SIOPCB  *p_siopcb)
     239{
     240        /* 共通部(syssvc\serial.c)にあるsio_irdy_snd関数を呼び出し*/
     241        sio_irdy_snd(p_siopcb->exinf);
     242}
     243
     244/*
     245 *  シリアルI/Oポートからの受信通知コールバック
     246 */
     247void
     248serial_irdy_rcv(SIOPCB  *p_siopcb)
     249{
     250        /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
     251        sio_irdy_rcv(p_siopcb->exinf);
    123252}
    124253
     
    126255 *  SIOの割込みハンドラ
    127256 */
    128 void sio_tx_isr(intptr_t exinf)
    129 {
    130         rx630_uart_tx_isr(exinf);
    131 }
    132 
    133 /*
    134  *  SIOの割込みハンドラ
    135  */
    136 void sio_rx_isr(intptr_t exinf)
    137 {
    138         rx630_uart_rx_isr(exinf);
    139 }
    140 
    141 /*
    142  *  シリアルI/Oポートへの文字送信
    143  */
    144 bool_t
    145 sio_snd_chr(SIOPCB *siopcb, char c)
    146 {
    147         return(rx630_uart_snd_chr(siopcb, c));
    148 }
    149 
    150 /*
    151  *  シリアルI/Oポートからの文字受信
    152  */
    153 int_t
    154 sio_rcv_chr(SIOPCB *siopcb)
    155 {
    156         return(rx630_uart_rcv_chr(siopcb));
    157 }
    158 
    159 /*
    160  *  シリアルI/Oポートからのコールバックの許可
    161  */
    162 void
    163 sio_ena_cbr(SIOPCB *siopcb, uint_t cbrtn)
    164 {
    165         rx630_uart_ena_cbr(siopcb, cbrtn);
    166 }
    167 
    168 /*
    169  *  シリアルI/Oポートからのコールバックの禁止
    170  */
    171 void
    172 sio_dis_cbr(SIOPCB *siopcb, uint_t cbrtn)
    173 {
    174         rx630_uart_dis_cbr(siopcb, cbrtn);
    175 }
    176 
    177 /*
    178  *  シリアルI/Oポートからの送信可能コールバック
    179  */
    180 void
    181 rx630_uart_irdy_snd(intptr_t exinf)
    182 {
    183         /* 共通部(syssvc\serial.c)にあるsio_irdy_snd関数を呼び出し*/
    184         sio_irdy_snd(exinf);
    185 }
    186 
    187 /*
    188  *  シリアルI/Oポートからの受信通知コールバック
    189  */
    190 void
    191 rx630_uart_irdy_rcv(intptr_t exinf)
    192 {
    193         /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
    194         sio_irdy_rcv(exinf);
    195 }
    196 
     257void
     258mbed_serial_irq_handler(uint32_t siopid, SerialIrq event)
     259{
     260        SIOPCB  *p_siopcb;
     261
     262        if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
     263                return;
     264        p_siopcb = get_siopcb(siopid);
     265
     266        if (!p_siopcb->openflag)
     267                return;
     268
     269        switch (event) {
     270        case TxIrq:
     271                serial_irdy_snd(p_siopcb);
     272                break;
     273        case RxIrq:
     274                serial_irdy_rcv(p_siopcb);
     275                break;
     276        }
     277}
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_serial.cfg

    r337 r374  
    44
    55#include <target_serial.h>
     6
    67ATT_INI({ TA_NULL, 0, sio_initialize });
    7 CFG_INT(INTNO_SIO_TX, { INTATR_SIO, INTPRI_SIO });
    8 CFG_INT(INTNO_SIO_RX, { INTATR_SIO, INTPRI_SIO });
    98
    10 CRE_ISR(INTNO_SIO_TX_ISR, {TA_NULL, SIO_PORTID, INTNO_SIO_TX, sio_tx_isr, 1});
    11 CRE_ISR(INTNO_SIO_RX_ISR, {TA_NULL, SIO_PORTID, INTNO_SIO_RX, sio_rx_isr, 1});
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_serial.h

    r337 r374  
    5353
    5454#include "gr_sakura.h"
    55 #include "rx630_uart.h"
     55#include "serial_api.h"
    5656
    57 /*
    58  *  SIOの割込みハンドラのベクタ番号
    59  */
    60 #define INHNO_SIO_TX    INT_SCI0_TEI                    /* 割込みハンドラ番号 */
    61 #define INTNO_SIO_TX    INT_SCI0_TEI                    /* 割込み番号 */
    62 #define INHNO_SIO_RX    INT_SCI0_RXI                    /* 割込みハンドラ番号 */
    63 #define INTNO_SIO_RX    INT_SCI0_RXI                    /* 割込み番号 */
    64 #define INTPRI_SIO              -4                                              /* 割込み優先度 */
    65 #define INTATR_SIO              (TA_NULL)                               /* 割込み属性 */
     57#define SIO_RDY_SND 1
     58#define SIO_RDY_RCV 2
    6659
    6760#ifndef TOPPERS_MACRO_ONLY
    6861
     62typedef struct sio_port_control_block SIOPCB;
    6963
    7064/*
     
    8276 */
    8377extern void             sio_cls_por(SIOPCB *p_siopcb);
    84 
    85 /*
    86  *  SIOの割込みハンドラ
    87  */
    88 extern void     sio_tx_isr(intptr_t exinf);
    89 extern void     sio_rx_isr(intptr_t exinf);
    9078
    9179/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_syssvc.h

    r337 r374  
    113113
    114114/*
     115 *  使用するシリアルポートのPinName
     116 */
     117#define STDIO_UART_TX P20
     118#define STDIO_UART_RX P21
     119
     120/*
    115121 *  システムログタスク関連の定数の定義
    116122 *
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/MANIFEST_tecsgen_body

    r337 r374  
    11MANIFEST_tecsgen_body
     2
    23Makefile
    3 
     4tecscde
     5tecscde.rb
     6tecsgen
     7tecsgen.rb
     8tecsgen_rcov.rb
     9tecsmerge
     10tecsmerge.rb
    411cdelib/Makefile
    512cdelib/cell_plugin_dialog.rb
     
    1118cdelib/tview.rb
    1219cdelib/version.rb
    13 
    1420tecs/TECSInfo/TECSInfo.cdl
     21tecs/TECSInfo/TECSInfoAccessor.cdl
    1522tecs/TECSInfo/nTECSInfo_tArrayTypeInfo.c
    16 tecs/TECSInfo/nTECSInfo_tAttrVarInfo.c
    1723tecs/TECSInfo/nTECSInfo_tBoolTypeInfo.c
    1824tecs/TECSInfo/nTECSInfo_tCallInfo.c
     
    2834tecs/TECSInfo/nTECSInfo_tParamInfo.c
    2935tecs/TECSInfo/nTECSInfo_tPtrTypeInfo.c
     36tecs/TECSInfo/nTECSInfo_tRawEntryDescriptorInfo.c
    3037tecs/TECSInfo/nTECSInfo_tRegionInfo.c
    3138tecs/TECSInfo/nTECSInfo_tSignatureInfo.c
    3239tecs/TECSInfo/nTECSInfo_tStructTypeInfo.c
     40tecs/TECSInfo/nTECSInfo_tTECSInfoAccessor.c
    3341tecs/TECSInfo/nTECSInfo_tTECSInfoSub.c
    3442tecs/TECSInfo/nTECSInfo_tTECSInfo_inline.h
     
    3644tecs/TECSInfo/nTECSInfo_tVarDeclInfo.c
    3745tecs/TECSInfo/nTECSInfo_tVoidTypeInfo.c
     46tecs/TECSInfo/tTECSInfoAccessor.c
    3847tecs/TLSFMalloc/README-TLSF.txt
    3948tecs/TLSFMalloc/tTLSFMalloc.cdl
     
    6170tecs/mruby/nMruby_tMruby.c
    6271tecs/mruby/nMruby_tMrubyCyclicTaskBody.c
     72tecs/mruby/nMruby_tMrubyProc.c
    6373tecs/mruby/nMruby_tMrubyTaskBody.c
    6474tecs/mruby/nMruby_tMrubyVM.c
     
    8797tecs/rpc/tDataqueueAdaptor_inline.h
    8898tecs/rpc/tDataqueueOWChannel.cdl
     99tecs/rpc/tMessageBufferCEP.cdl
     100tecs/rpc/tMessageBufferCEP_inline.h
     101tecs/rpc/tMessageBufferChannel.cdl
    89102tecs/rpc/tNBOTDR_inline.h
    90103tecs/rpc/tPPAllocator.c
     
    105118tecs/tecs.h
    106119tecs/tecs.xsd
    107 
    108 tecscde
    109 tecscde.rb
    110 tecsgen
    111 tecsgen.rb
    112 tecsgen_rcov
    113 tecsgen_rcov.rb
    114120tecslib/core/C_parser.tab.rb
    115121tecslib/core/C_parser.y.rb
     
    132138tecslib/core/tool_info.rb
    133139tecslib/core/types.rb
     140tecslib/core/unjoin_plugin.rb
    134141tecslib/core/value.rb
    135142tecslib/messages/messages_console_en_US.rb
     
    165172tecslib/plugin/HRP2SemaphorePlugin.rb
    166173tecslib/plugin/HRP2TaskPlugin.rb
     174tecslib/plugin/HRPHandlerPlugin.rb
     175tecslib/plugin/HRPKernelObjectManager.rb
     176tecslib/plugin/HRPKernelObjectPlugin.rb
     177tecslib/plugin/HRPObjectPlugin.rb
     178tecslib/plugin/HRPPlugin.rb
     179tecslib/plugin/HRPRPCPlugin.rb
     180tecslib/plugin/HRPSVCPlugin.rb
     181tecslib/plugin/HRPTaskPlugin.rb
    167182tecslib/plugin/Mruby2CBridgePlugin.rb
    168183tecslib/plugin/MrubyBridgeCellPlugin.rb
    169184tecslib/plugin/MrubyBridgeCelltypePlugin.rb
     185tecslib/plugin/MrubyBridgeCompositePlugin.rb
    170186tecslib/plugin/MrubyBridgePlugin.rb
    171187tecslib/plugin/MrubyBridgeSignaturePlugin.rb
     
    175191tecslib/plugin/OpaqueRPCPlugin.rb
    176192tecslib/plugin/RPCPlugin.rb
     193tecslib/plugin/RepeatCellPlugin.rb
     194tecslib/plugin/RepeatJoinPlugin.rb
    177195tecslib/plugin/SharedOpaqueRPCPlugin.rb
    178196tecslib/plugin/SharedRPCPlugin.rb
     
    186204tecslib/plugin/lib/GenParamCopy.rb
    187205tecslib/plugin/lib/GenTransparentMarshaler.rb
     206tecslib/plugin/lib/MrubyBridgeCelltypePluginModule.rb
    188207tecslib/version.rb
    189 
    190 tecsmerge
    191 tecsmerge.rb
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/mruby/TECSPointer.h

    r359 r374  
    102102        {                                                                                                                                       \
    103103                if( sizeof( type ) > sizeof( mrb_int ) ){                                               \
    104                         if( val >= (((type)1) << (sizeof(mrb_int)*8-1))                         \
    105                                 || val < -(((type)1) << (sizeof(mrb_int)*8-1)) )                \
     104                        if( val > TYPE ## _MAX                          \
     105                                || val < TYPE ## _MIN )         \
    106106                                /* '=' unecessary for negative value    */                              \
    107107                                /* ignore warning on int32_t */                                                 \
     
    126126        {                                                                                                                                       \
    127127                if( sizeof( type ) > sizeof( mrb_int ) ){                                               \
    128                         if( val >= (((type)1) << (sizeof(mrb_int)*8)))                          \
     128      if( val > TYPE ## _MAX )                        \
    129129                                /* '=' unecessary for negative value    */                              \
    130130                                /* ignore warning on int32_t */                                                 \
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/mruby/mrubyVMs.cdl

    r359 r374  
    3737
    3838/*
    39  * tools/mruby/mruby.c から cInit_initializeBridge( mrb ) を呼び出すように変更したもの
     39 * POSIX 環境用の VM
     40 * mrbgems の mrbgems/mruby-bin-mruby/tools/mruby/mruby.c を参考に作成したもの
    4041 */
    4142namespace nMruby{
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/mruby/tecs_mruby.h

    r359 r374  
    11/*
    2  *  Copyright (C) 2008-2017 by TOPPERS Project
     2 *  Copyright (C) 2008-2019 by TOPPERS Project
    33 *
    44 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4646#include "mruby/irep.h"
    4747#include "mruby/dump.h"
     48#include "mruby/proc.h"
    4849
    4950#include "TECSPointer.h"
    5051#include "TECSStruct.h"
    5152
    52 #if  ! defined( MRUBY_RELEASE_MAJOR ) || MRUBY_RELEASE_MAJOR == 1 && MRUBY_RELEASE_MINOR < 2
    53 #ifndef MRB_ARGS_REQ
    54 #define MRB_ARGS_REQ(n)     ARGS_REQ(n)
    55 #define MRB_ARGS_OPT(n)     ARGS_OPT(n)
    56 #define MRB_ARGS_ARG(n1,n2) ARGS_ARG(n1,n2)
    57 #define MRB_ARGS_REST()     ARGS_REST()
    58 #define MRB_ARGS_POST(n)    ARGS_POST(n)
    59 #define MRB_ARGS_KEY(n1,n2) ARGS_KEY(n1,n2)
    60 #define MRB_ARGS_BLOCK()    ARGS_BLOCK()
    61 #define MRB_ARGS_ANY()      ARGS_ANY()
    62 #define MRB_ARGS_NONE()     ARGS_NONE()
    63 #endif /* MRB_ARGS_REQ */
    64 #endif
    6553
    66 #if  ! defined( MRUBY_RELEASE_MAJOR )
    67 #define mrb_float_value( mrb, val )  mrb_float_value( val )
    68 #endif
    69 
    70 #else
     54#else /* TECSGEN */
    7155
    7256/*
    73  * fake tecsgen because tecsgen cannot accept actual mruby.h in case of below.
     57 * fake definition because tecsgen cannot accept actual mruby.h in case of below.
    7458 *   types:   long long, long long int
    7559 *   special keyword __attribute__(x), __extension__
     
    7862typedef int mrb_irep;
    7963typedef int mrb_context;
    80 struct  RClass {int dummy;};
    81 struct  RProc  {int dummy;};
     64struct  RClass {uint32_t gcnext;};  // actual definition: struct RBasic *gcnext
     65struct  RProc  {uint32_t gcnext;};  // actual definition: struct RBasic *gcnext
    8266
    8367typedef int CELLCB;
     68
     69#define GET_SET_BOOL( Type, type )
     70#define GET_SET_CHAR( Type, type )
     71#define GET_SET_INT( Type, type )
     72#define GET_SET_FLOAT( Type, type )
     73#define POINTER_CLASS( Type, type )
     74#define CHECK_AND_GET_POINTER( Type, type )
    8475
    8576#endif /* TECSGEN */
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/rpc/TDR.cdl

    r337 r374  
    6868        ER      sendSOP( [in]bool_t b_client );     /* StartOfPacket magic を送信 */
    6969        ER      receiveSOP( [in]bool_t b_client );  /* StartOfPacket magic を受信 */
    70                                                  /* b_client: クライアント側なら true, サーバー側なら false */
    71 
    72         /* マジックコードの送受信 */
    73         //      ER      sendSHSOP( [in]bool_t b_client );     /* StartOfPacket magic を送信 */
    74         //      ER      receiveSHSOP( [in]bool_t b_client );  /* StartOfPacket magic を受信 */
    7570                                                 /* b_client: クライアント側なら true, サーバー側なら false */
    7671
     
    150145};
    151146
    152 // Straight Order TECS Data Representation (Straight means no endian-conversion is done)
     147// Straight Byte Order TECS Data Representation (Data are always sent in native endian)
    153148celltype tTDR {
    154149        call    sChannel        cChannel;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/rpc/sChannel.cdl

    r337 r374  
    5858};
    5959
     60/*
     61 * size に uint16_t ではなく int16_t を用いるのは、下位層が ER_INT を返す場合を想定したもの.
     62 *
     63 * sChannel は TECS RPC の TDR の下位層である通信チャンネルとのインタフェースである.
     64 * 通信チャンネルは、高水準 I/O のように、バッファリングされることを想定する.
     65 * TDR からは、int8_t, int16_t, int32_t, int64_t, (int128_t), float32_t, double64_t bool_t, char_t のような基本型(無符号を含む)が渡される。
     66 * 配列や構造体の場合であっても要素ごとに渡される。
     67 */
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecs/rpc/tTDR_inline.h

    r337 r374  
    7575                return(E_ID);
    7676        }
     77  (void)p_cellcb;   // to avoid unused warning
    7778
    7879        syslog( LOG_INFO, "TDR: resetting channel" );
     
    102103                return(E_ID);
    103104        }
     105  (void)p_cellcb;   // to avoid unused warning
    104106
    105107        /* ここに処理本体を記述します #_TEFB_# */
     
    151153                return(E_ID);
    152154        }
     155  (void)p_cellcb;   // to avoid unused warning
    153156
    154157        /* ここに処理本体を記述します #_TEFB_# */
     
    157160#endif
    158161
    159     if( b_client )
     162  if( b_client )
    160163                p_sopMagic = &SOP_MAGIC2;
    161164        else
     
    198201                return(E_ID);
    199202        }
     203  (void)p_cellcb;   // to avoid unused warning
    200204
    201205        /* ここに処理本体を記述します #_TEFB_# */
     
    234238                return(E_ID);
    235239        }
     240  (void)p_cellcb;   // to avoid unused warning
    236241
    237242        /* ここに処理本体を記述します #_TEFB_# */
     
    267272                return(E_ID);
    268273        }
     274  (void)p_cellcb;   // to avoid unused warning
    269275
    270276        /* ここに処理本体を記述します #_TEFB_# */
     
    287293                return(E_ID);
    288294        }
     295  (void)p_cellcb;   // to avoid unused warning
    289296
    290297        /* ここに処理本体を記述します #_TEFB_# */
     
    307314                return(E_ID);
    308315        }
     316  (void)p_cellcb;   // to avoid unused warning
    309317
    310318        /* ここに処理本体を記述します #_TEFB_# */
     
    327335                return(E_ID);
    328336        }
     337  (void)p_cellcb;   // to avoid unused warning
    329338
    330339        /* ここに処理本体を記述します #_TEFB_# */
     
    347356                return(E_ID);
    348357        }
     358  (void)p_cellcb;   // to avoid unused warning
    349359
    350360        /* ここに処理本体を記述します #_TEFB_# */
     
    368378                return(E_ID);
    369379        }
     380  (void)p_cellcb;   // to avoid unused warning
    370381
    371382        /* ここに処理本体を記述します #_TEFB_# */
     
    390401                return(E_ID);
    391402        }
     403  (void)p_cellcb;   // to avoid unused warning
    392404
    393405        /* ここに処理本体を記述します #_TEFB_# */
     
    412424                return(E_ID);
    413425        }
     426  (void)p_cellcb;   // to avoid unused warning
    414427
    415428        /* ここに処理本体を記述します #_TEFB_# */
     
    434447                return(E_ID);
    435448        }
     449  (void)p_cellcb;   // to avoid unused warning
    436450
    437451        /* ここに処理本体を記述します #_TEFB_# */
     
    456470                return(E_ID);
    457471        }
     472  (void)p_cellcb;   // to avoid unused warning
    458473
    459474        /* ここに処理本体を記述します #_TEFB_# */
     
    477492                return(E_ID);
    478493        } /* end if VALID_IDX(idx) */
     494  (void)p_cellcb;   // to avoid unused warning
    479495
    480496        /* ここに処理本体を記述します #_TEFB_# */
     
    497513                return(E_ID);
    498514        } /* end if VALID_IDX(idx) */
     515  (void)p_cellcb;   // to avoid unused warning
    499516
    500517        /* ここに処理本体を記述します #_TEFB_# */
     
    517534                return(E_ID);
    518535        } /* end if VALID_IDX(idx) */
     536  (void)p_cellcb;   // to avoid unused warning
    519537
    520538        /* ここに処理本体を記述します #_TEFB_# */
     
    537555                return(E_ID);
    538556        } /* end if VALID_IDX(idx) */
     557  (void)p_cellcb;   // to avoid unused warning
    539558
    540559        /* ここに処理本体を記述します #_TEFB_# */
     
    557576                return(E_ID);
    558577        } /* end if VALID_IDX(idx) */
     578  (void)p_cellcb;   // to avoid unused warning
    559579
    560580        /* ここに処理本体を記述します #_TEFB_# */
     
    578598                return(E_ID);
    579599        } /* end if VALID_IDX(idx) */
     600  (void)p_cellcb;   // to avoid unused warning
    580601
    581602        /* ここに処理本体を記述します #_TEFB_# */
     
    600621                return(E_ID);
    601622        } /* end if VALID_IDX(idx) */
     623  (void)p_cellcb;   // to avoid unused warning
    602624
    603625        /* ここに処理本体を記述します #_TEFB_# */
     
    622644                return(E_ID);
    623645        } /* end if VALID_IDX(idx) */
     646  (void)p_cellcb;   // to avoid unused warning
    624647
    625648        /* ここに処理本体を記述します #_TEFB_# */
     
    644667                return(E_ID);
    645668        } /* end if VALID_IDX(idx) */
     669  (void)p_cellcb;   // to avoid unused warning
    646670
    647671        /* ここに処理本体を記述します #_TEFB_# */
     
    666690                return(E_ID);
    667691        } /* end if VALID_IDX(idx) */
     692  (void)p_cellcb;   // to avoid unused warning
    668693
    669694        /* ここに処理本体を記述します #_TEFB_# */
     
    688713                return(E_ID);
    689714        } /* end if VALID_IDX(idx) */
     715  (void)p_cellcb;   // to avoid unused warning
    690716
    691717        /* ここに処理本体を記述します #_TEFB_# */
     
    705731        ER              ercd = E_OK;
    706732        CELLCB  *p_cellcb;
    707         uint8_t val;
    708         if (VALID_IDX(idx)) {
    709                 p_cellcb = GET_CELLCB(idx);
    710         }
    711         else {
    712                 return(E_ID);
    713         } /* end if VALID_IDX(idx) */
     733        uint8_t val = 0;
     734        if (VALID_IDX(idx)) {
     735                p_cellcb = GET_CELLCB(idx);
     736        }
     737        else {
     738                return(E_ID);
     739        } /* end if VALID_IDX(idx) */
     740  (void)p_cellcb;   // to avoid unused warning
    714741
    715742        /* ここに処理本体を記述します #_TEFB_# */
     
    737764                return(E_ID);
    738765        }
     766  (void)p_cellcb;   // to avoid unused warning
    739767
    740768        /* ここに処理本体を記述します #_TEFB_# */
     
    757785                return(E_ID);
    758786        }
     787  (void)p_cellcb;   // to avoid unused warning
    759788
    760789        /* ここに処理本体を記述します #_TEFB_# */
     
    778807                return(E_ID);
    779808        }
     809  (void)p_cellcb;   // to avoid unused warning
    780810
    781811        /* ここに処理本体を記述します #_TEFB_# */
     
    800830                return(E_ID);
    801831        }
     832  (void)p_cellcb;   // to avoid unused warning
    802833
    803834        /* ここに処理本体を記述します #_TEFB_# */
     
    821852                return(E_ID);
    822853        }
     854  (void)p_cellcb;   // to avoid unused warning
    823855
    824856        /* ここに処理本体を記述します #_TEFB_# */
     
    863895                return(E_ID);
    864896        } /* end if VALID_IDX(idx) */
     897  (void)p_cellcb;   // to avoid unused warning
    865898
    866899        /* ここに処理本体を記述します #_TEFB_# */
     
    883916                return(E_ID);
    884917        }
     918  (void)p_cellcb;   // to avoid unused warning
    885919
    886920        /* ここに処理本体を記述します #_TEFB_# */
     
    903937                return(E_ID);
    904938        }
     939  (void)p_cellcb;   // to avoid unused warning
    905940
    906941        /* ここに処理本体を記述します #_TEFB_# */
     
    923958                return(E_ID);
    924959        }
     960  (void)p_cellcb;   // to avoid unused warning
    925961
    926962        /* ここに処理本体を記述します #_TEFB_# */
     
    944980                return(E_ID);
    945981        } /* end if VALID_IDX(idx) */
     982  (void)p_cellcb;   // to avoid unused warning
    946983
    947984        /* ここに処理本体を記述します #_TEFB_# */
     
    9661003                return(E_ID);
    9671004        }
     1005  (void)p_cellcb;   // to avoid unused warning
    9681006
    9691007        /* ここに処理本体を記述します #_TEFB_# */
     
    9881026                return(E_ID);
    9891027        }
     1028  (void)p_cellcb;   // to avoid unused warning
    9901029
    9911030        /* ここに処理本体を記述します #_TEFB_# */
     
    10101049                return(E_ID);
    10111050        }
     1051  (void)p_cellcb;   // to avoid unused warning
    10121052
    10131053        /* ここに処理本体を記述します #_TEFB_# */
     
    10311071                return(E_ID);
    10321072        } /* end if VALID_IDX(idx) */
     1073  (void)p_cellcb;   // to avoid unused warning
    10331074
    10341075        /* ここに処理本体を記述します #_TEFB_# */
     
    10511092                return(E_ID);
    10521093        } /* end if VALID_IDX(idx) */
     1094  (void)p_cellcb;   // to avoid unused warning
    10531095
    10541096        /* ここに処理本体を記述します #_TEFB_# */
     
    10711113                return(E_ID);
    10721114        } /* end if VALID_IDX(idx) */
     1115  (void)p_cellcb;   // to avoid unused warning
    10731116
    10741117        /* ここに処理本体を記述します #_TEFB_# */
     
    10911134                return(E_ID);
    10921135        } /* end if VALID_IDX(idx) */
     1136  (void)p_cellcb;   // to avoid unused warning
    10931137
    10941138        /* ここに処理本体を記述します #_TEFB_# */
     
    11121156                return(E_ID);
    11131157        } /* end if VALID_IDX(idx) */
     1158  (void)p_cellcb;   // to avoid unused warning
    11141159
    11151160        /* ここに処理本体を記述します #_TEFB_# */
     
    11341179                return(E_ID);
    11351180        } /* end if VALID_IDX(idx) */
     1181  (void)p_cellcb;   // to avoid unused warning
    11361182
    11371183        /* ここに処理本体を記述します #_TEFB_# */
     
    11561202                return(E_ID);
    11571203        } /* end if VALID_IDX(idx) */
     1204  (void)p_cellcb;   // to avoid unused warning
    11581205
    11591206        /* ここに処理本体を記述します #_TEFB_# */
     
    11781225                return(E_ID);
    11791226        } /* end if VALID_IDX(idx) */
     1227  (void)p_cellcb;   // to avoid unused warning
    11801228
    11811229        /* ここに処理本体を記述します #_TEFB_# */
     
    11991247                return(E_ID);
    12001248        }
     1249  (void)p_cellcb;   // to avoid unused warning
    12011250
    12021251        /* ここに処理本体を記述します #_TEFB_# */
     
    12201269                return(E_ID);
    12211270        }
     1271  (void)p_cellcb;   // to avoid unused warning
    12221272
    12231273        /* ここに処理本体を記述します #_TEFB_# */
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecsgen.rb

    r359 r374  
    55#      Generator for TOPPERS Embedded Component System
    66
    7 #   Copyright (C) 2008-2017 by TOPPERS Project
     7#   Copyright (C) 2008-2019 by TOPPERS Project
    88#--
    99#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    5454#  Authors list is in i-ro-ha order.
    5555#Version::   see version.rb
    56 $Copyright = "Copyright(c) 2008-2017, TOPPERS project. All rights reserved."
     56$Copyright = "Copyright(c) 2008-2019, TOPPERS project. All rights reserved."
    5757$License   = "TOPPERS License"
    5858
     
    223223    analyze_option addtional_option_parser
    224224    load_modules
    225     setup
     225    if ! $TECSFLOW then
     226      setup
     227    end
    226228       
    227229    dbgPrint  "tecspath: #{$tecsgen_base_path}, __FILE__=#{__FILE__}\n"
     
    284286    ARGV.each { |a| $arguments += " " + a }
    285287
    286     $unopt     = false     # bool:   disable optimizing
     288    $unopt     = false     # bool:   disable optimizing both call and entry port
     289    $unopt_entry= false    # bool:   disable optimizing entry port
    287290    $gen_base  = "gen"     # string: folder path to place generated files
    288291    $gen       = $gen_base # string: folder path to place generated files
     
    385388        $unopt = true
    386389      }
     390      parser.on('--unoptimize-entry', 'unoptimize entry port') {
     391        $unopt_entry = true
     392      }
    387393      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' ){
    388394        |arg|
     
    465471    }
    466472
    467     if ARGV.empty? && ! $print_version && ! $unit_test
     473    if ARGV.empty? && ! $print_version && ! $unit_test && ! $TECSFLOW
    468474      ARGV.options{|parser|
    469475        puts parser.help
     
    482488    # このファイルを誤って読み込むと、異なるバージョン名を表示してしまう
    483489    require_tecsgen_lib 'tecslib/version.rb'
    484     if $tecscde_version then
    485       STDERR << "tecscde version #{$tecscde_version} (tecsgen version #{$version})  #{$Copyright}\n"
     490    if $title then
     491      STDERR << "#{$title} version #{$tool_version} (tecsgen version #{$version})  #{$Copyright}\n"
    486492    elsif ! $no_banner || $print_version
    487493      STDERR << "tecsgen  version #{$version}  #{$Copyright}\n"
     
    490496      STDERR << "ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE} patchlevel #{RUBY_PATCHLEVEL}) [#{RUBY_PLATFORM}]\n"
    491497    end
    492     if $print_version && ARGV.empty?
     498    if $print_version && ARGV.empty? && ! $TECSFLOW
    493499      exit
    494500    end
     
    518524    require_tecsgen_lib 'tecslib/core/tool_info.rb'
    519525    require_tecsgen_lib 'tecslib/core/tecsinfo.rb'
     526    require_tecsgen_lib 'tecslib/core/unjoin_plugin.rb'
    520527    require_tecsgen_lib 'tecslib/plugin/CelltypePlugin.rb'
    521528    require_tecsgen_lib 'tecslib/plugin/CompositePlugin.rb'
     
    601608#  クラス変数のリセットを確実に行う必要がある
    602609
    603 if $TECSCDE != true then
     610if $TECSCDE != true && $TECSFLOW != true then
    604611  begin
    605612    TECSGEN.init
     
    607614    tecsgen.run1
    608615    tecsgen.run2
     616    tecsgen.dump_tecsgen_rbdmp
    609617  rescue => evar
    610618    print_exception( evar )
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecsgen_rcov.rb

    r337 r374  
    4444# Usage: tecsgen_rcov.rb [options] CDL-file.cdl
    4545#
     46
     47$:.unshift(File.dirname(__FILE__))
     48
    4649require 'simplecov'
    47 SimpleCov.command_name "tecsgen#{$$}"
     50SimpleCov.command_name "tecsgen#{Time.now.to_f}"
    4851SimpleCov.root File.dirname( File.expand_path __FILE__ )
    4952SimpleCov.at_exit do
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.tab.rb

    r337 r374  
    11#
    22# DO NOT MODIFY!!!!
    3 # This file is automatically generated by Racc 1.4.14
     3# This file is automatically generated by Racc 1.4.9
    44# from Racc grammer file "".
    55#
     
    88class C_parser < Racc::Parser
    99
    10 module_eval(<<'...end C_parser.y.rb/module_eval...', 'C_parser.y.rb', 727)
    11 
    12   RESERVED = {
    13     # keyword
    14     'typedef' => :TYPEDEF,
    15     'struct' => :STRUCT,
    16     'union' => :UNION,
    17     'sizeof' => :SIZEOF,
    18     'throw' => :THROW,
    19 
    20     # specifier
    21     # types
    22     'void'    => :VOID,
    23     'char'    => :CHAR,
    24     'short'   => :SHORT,
    25 
    26     'volatile'=> :VOLATILE,
    27     'const'   => :CONST,
    28     'extern'   => :EXTERN,
    29 
    30     'long'    => :LONG,
    31     'float'   => :FLOAT,
    32     'double'  => :DOUBLE,
    33     'signed'  => :SIGNED,
    34     'unsigned'=> :UNSIGNED,
    35 
    36     'int'     => :INT,
    37     'enum'    => :ENUM,
    38 
    39     'if'      => :IF,
    40     'else'    => :ELSE,
    41     'while'   => :WHILE,
    42     'do'      => :DO,
    43     'for'     => :FOR,
    44     'case'    => :CASE,
    45     'default' => :DEFAULT,
    46     'goto'    => :GOTO,
    47     'continue' => :CONTINUE,
    48     'break'   => :BREAK,
    49     'return'  => :RETURN,
    50     '__inline__'  => :__INLINE__,
    51     'inline'  => :INLINE,
    52     '__inline'  => :__INLINE,
    53     'Inline'  => :CINLINE,        # inline starting with Capital letter
    54     'static'  => :STATIC,
    55     'register' => :REGISTER,
    56     'auto'    => :AUTO,
    57     '__extension__'    => :EXTENSION,
    58 
    59   }
    60 
    61   @@generator_nest = -1
    62   @@generator_stack = []
    63   @@current_locale = []
    64 
    65   def finalize
    66 
    67     # mikan Namespace.pop
    68     Celltype.pop
    69     Cell.pop
    70     CompositeCelltype.pop
    71     Region.pop
    72 
    73   end
    74 
    75   def set_plugin( plugin )
    76     @plugin = plugin
    77   end
    78 
    79   def self.get_plugin
    80     @@generator_stack[@@generator_nest].get_plugin
    81   end
    82 
    83   def get_plugin
    84     @plugin
    85   end
    86 
    87   def parse(files)
    88 
    89     # mikan Namespace.push
    90     Celltype.push
    91     Cell.push
    92     CompositeCelltype.push
    93     Region.push
    94 
    95     @@generator_nest += 1
    96     @@generator_stack[@@generator_nest] = self
    97     @b_no_type_name = false
    98 
    99    begin
    100 
    101     @q = []
    102     comment = false
    103 
    104     # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策
    105     TECS_LANG::set_kcode_binary
    106 
    107     # 800U, 0xffLL など (整数リテラルに共通の修飾子)
    108     integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
    109 
    110     files.each {|file|
    111       lineno = 1
    112      begin
    113 #2.0       IO.foreach(file) {|line|
    114        TECSIO.foreach(file) {|line|
    115         col = 1
    116         line.rstrip!
    117 
    118         until line.empty?
    119 
    120           if comment
    121             case line
    122             # コメント終了
    123             when /\A\*\//
    124               comment = false
    125             when /\A./
    126               ;
    127             end
    128           else
    129             case line
    130             # 空白、プリプロセスディレクティブ
    131             when /\A\s+/
    132               ;
    133             # 識別子
    134             when /\A[a-zA-Z_]\w*/
    135               word = $&
    136               @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
    137             # 16 進数定数
    138             when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
    139               @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
    140             # 8 進数定数
    141             when /\A0[0-7]+#{integer_qualifier}/
    142               @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
    143             # 浮動小数定数
    144             when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
    145               @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
    146             # 整数定数
    147             when /\A\d+#{integer_qualifier}/
    148             # when /\A\d+/
    149               @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
    150             # 文字
    151             when /\A'(?:[^'\\]|\\.)'/
    152               @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
    153             # 文字列
    154 #              "#include  #include #include \"../systask/logtask.cfg\"       最後の " 忘れ)で無限ループ
    155 #            when /\A"(?:[^"\\]+|\\.)*"/
    156             when /\A"(?:[^"\\]|\\.)*"/   # これはうまく行くようだ
    157               @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
    158             # 行コメント
    159             when /\A\/\/.*$/
    160               # 読み飛ばすだけ
    161             # コメント開始
    162             when /\A\/\*/
    163               comment = true
    164             when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
    165               @q << [$&, Token.new($&, file, lineno, col)]
    166             when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
    167               @q << [$&, Token.new($&, file, lineno, col)]
    168             when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
    169               @q << [$&, Token.new($&, file, lineno, col)]
    170             when /\A./
    171               @q << [$&, Token.new($&, file, lineno, col)]
    172             else
    173               raise
    174             end
    175           end
    176 
    177           line = $'
    178           col += $&.length
    179         end
    180 
    181         lineno += 1
    182       }
    183 
    184      rescue => evar
    185        Generator.error( "B1002 while open or reading \'$1\'" , file )
    186        print_exception( evar )
    187      end
    188     }
    189 
    190     # 終了の印
    191     @q << nil
    192 
    193     @yydebug = true
    194     do_parse
    195 
    196    ensure
    197     @@generator_nest -= 1
    198     TECS_LANG::reset_kcode
    199    end
    200 
    201   end
    202 
    203 
    204   def next_token
    205     token = @q.shift
    206 
    207     if token then
    208       @@current_locale[@@generator_nest] = token[1].locale
    209 
    210       case token[1].val
    211       when ";", ":", ",", "(", ")", "{", "}"
    212         set_no_type_name false
    213       when ".", "->"
    214         set_no_type_name true
    215       end
    216 
    217       # TYPE_NAME トークンへ置き換え
    218       if @b_no_type_name == false
    219         if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
    220           token[0] = :TYPE_NAME
    221           locale = @@current_locale[@@generator_nest]
     10module_eval(<<'...end C_parser.y.rb/module_eval...', 'C_parser.y.rb', 784)
     11
     12        RESERVED = {
     13                # keyword
     14                'typedef' => :TYPEDEF,
     15                'struct' => :STRUCT,
     16                'union' => :UNION,
     17                'sizeof' => :SIZEOF,
     18                'throw' => :THROW,
     19
     20                # specifier
     21                # types
     22                'void'    => :VOID,
     23                'char'    => :CHAR,
     24                'short'   => :SHORT,
     25
     26                'volatile'=> :VOLATILE,
     27                'restrict'=> :RESTRICT,
     28                'const'   => :CONST,
     29                'extern'   => :EXTERN,
     30
     31                'long'    => :LONG,
     32                'float'   => :FLOAT,
     33                'double'  => :DOUBLE,
     34                'signed'  => :SIGNED,
     35                'unsigned'=> :UNSIGNED,
     36
     37                'int'     => :INT,
     38                'enum'    => :ENUM,
     39
     40                'if'      => :IF,
     41                'else'    => :ELSE,
     42                'while'   => :WHILE,
     43                'do'      => :DO,
     44                'for'     => :FOR,
     45                'switch'  => :SWITCH,
     46                'case'    => :CASE,
     47                'default' => :DEFAULT,
     48                'goto'    => :GOTO,
     49                'continue' => :CONTINUE,
     50                'break'   => :BREAK,
     51                'return'  => :RETURN,
     52                '__inline__'  => :__INLINE__,
     53                'inline'  => :INLINE,
     54                '__inline'  => :__INLINE,
     55                'Inline'  => :CINLINE,        # inline starting with Capital letter
     56                'static'  => :STATIC,
     57                'register' => :REGISTER,
     58                'auto'    => :AUTO,
     59                '__extension__'    => :EXTENSION,
     60                '__asm__' => :_ASM,
     61                'asm' =>     :_ASM
     62
     63        }
     64
     65        @@generator_nest = -1
     66        @@generator_stack = []
     67        @@current_locale = []
     68
     69        def finalize
     70
     71                # mikan Namespace.pop
     72                Celltype.pop
     73                Cell.pop
     74                CompositeCelltype.pop
     75                Region.pop
     76
     77        end
     78
     79        def set_plugin( plugin )
     80                @plugin = plugin
     81        end
     82
     83        def self.get_plugin
     84                @@generator_stack[@@generator_nest].get_plugin
     85        end
     86
     87        def get_plugin
     88                @plugin
     89        end
     90
     91        def parse(files)
     92
     93                # mikan Namespace.push
     94                Celltype.push
     95                Cell.push
     96                CompositeCelltype.push
     97                Region.push
     98
     99                @@generator_nest += 1
     100                @@generator_stack[@@generator_nest] = self
     101                @b_no_type_name = false
     102
     103        begin
     104
     105                @q = []
     106                comment = false
     107#               b_asm   = false
     108
     109                # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策
     110                TECS_LANG::set_kcode_binary
     111
     112                # 800U, 0xffLL など (整数リテラルに共通の修飾子)
     113                integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
     114
     115                files.each {|file|
     116                        lineno = 1
     117                begin
     118#2.0            IO.foreach(file) {|line|
     119                        TECSIO.foreach(file) {|line|
     120                        col = 1
     121                        line.rstrip!
     122
     123                        until line.empty?
     124
     125                                if comment
     126                                        case line
     127                                        # コメント終了
     128                                        when /\A\*\//
     129                                                comment = false
     130                                        when /\A./
     131                                                ;
     132                                        end
     133                                else
     134                                        case line
     135                                        # 空白、プリプロセスディレクティブ
     136                                        when /\A\s+/
     137                                                ;
     138                                        # 識別子
     139                                        when /\A[a-zA-Z_]\w*/
     140                                                word = $&
     141                                                @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
     142                                        # 16 進数定数
     143                                        when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
     144                                                @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
     145                                        # 8 進数定数
     146                                        when /\A0[0-7]+#{integer_qualifier}/
     147                                                @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
     148                                        # 浮動小数定数
     149                                        when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
     150                                                @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
     151                                        # 整数定数
     152                                        when /\A\d+#{integer_qualifier}/
     153                                        # when /\A\d+/
     154                                                @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
     155                                        # 文字
     156                                        when /\A'(?:[^'\\]|\\.)'/
     157                                                @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
     158                                        # 文字列
     159#                                       "#include  #include #include \"../systask/logtask.cfg\"       最後の " 忘れ)で無限ループ
     160#                                       when /\A"(?:[^"\\]+|\\.)*"/
     161                                        when /\A"(?:[^"\\]|\\.)*"/   # これはうまく行くようだ
     162                                                @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
     163                                        # 行コメント
     164                                        when /\A\/\/.*$/
     165                                                # 読み飛ばすだけ
     166                                        # コメント開始
     167                                        when /\A\/\*/
     168                                                comment = true
     169                                        when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
     170                                                @q << [$&, Token.new($&, file, lineno, col)]
     171                                        when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
     172                                                @q << [$&, Token.new($&, file, lineno, col)]
     173                                        when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
     174                                                @q << [$&, Token.new($&, file, lineno, col)]
     175                                        when /\A\|\|/, /\A\&\&/
     176                                                @q << [$&, Token.new($&, file, lineno, col)]
     177                                        when /\A./
     178                                                @q << [$&, Token.new($&, file, lineno, col)]
     179                                        else
     180                                                raise
     181                                        end
     182                                end
     183
     184                                line = $'
     185                                col += $&.length
     186                        end
     187
     188                        lineno += 1
     189                }
     190
     191                rescue => evar
     192                        Generator.error( "B1002 while open or reading \'$1\'" , file )
     193                        print_exception( evar )
     194                end
     195        }
     196
     197        # 終了の印
     198        @q << nil
     199
     200        @yydebug = true
     201        do_parse
     202
     203                ensure
     204                        @@generator_nest -= 1
     205                        TECS_LANG::reset_kcode
     206                end
     207
     208        end
     209
     210
     211        def next_token
     212                token = @q.shift
     213
     214                if token then
     215                        @@current_locale[@@generator_nest] = token[1].locale
     216
     217                        case token[1].val
     218                        when ";", ":", ",", "(", ")", "{", "}"
     219                        set_no_type_name false
     220                        when ".", "->"
     221                        set_no_type_name true
     222                        end
     223
     224                        # TYPE_NAME トークンへ置き換え
     225                        if @b_no_type_name == false
     226                                if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
     227                                        token[0] = :TYPE_NAME
     228                                        locale = @@current_locale[@@generator_nest]
    222229#print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}: type_name'\n" )
    223         end
    224       end
    225 
    226       if $debug then     # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生)
    227         locale = @@current_locale[@@generator_nest]
    228         if token then
    229           print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
    230         else
    231           print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
    232         end
    233       end
    234     end
    235 
    236     token
    237   end
    238 
    239   def on_error(t, v, vstack)
    240     if v == "$" then
    241      Generator.error( "B1003 Unexpected EOF"  )
    242     else
    243      Generator.error( "B1004 syntax error near \'$1\'" , v.val )
    244     end
    245 
    246   end
    247 
    248   def self.current_locale
    249     @@current_locale[ @@generator_nest ]
    250   end
    251 
    252   @@n_error = 0
    253   @@n_warning = 0
    254   @@n_info = 0
    255 
    256   # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切)
    257   def self.error( msg )
    258     @@n_error += 1
    259     locale = @@current_locale[ @@generator_nest ]
    260 
    261     if locale then
    262       Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
    263     else
    264       Console.puts "error: #{msg}"
    265     end
    266   end
    267 
    268   # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切)
    269   def self.warning( msg )
    270     @@n_warning += 1
    271     locale = @@current_locale[ @@generator_nest ]
    272     Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
    273   end
    274 
    275   # このメソッドは構文解析、意味解析からのみ呼出し可
    276   def self.info( msg )
    277     @@n_info += 1
    278     locale = @@current_locale[ @@generator_nest ]
    279     Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
    280   end
    281 
    282   def self.get_n_error
    283     @@n_error
    284   end
    285 
    286   def self.get_n_warning
    287     @@n_warning
    288   end
    289 
    290   def self.get_nest
    291     @@generator_nest
    292   end
    293 
    294   def set_no_type_name b_no_type_name
    295     locale = @@current_locale[ @@generator_nest ]
     230                                end
     231                        end
     232
     233                        if $debug then     # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生)
     234                                locale = @@current_locale[@@generator_nest]
     235                                if token then
     236                                        print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
     237                                else
     238                                        print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
     239                                end
     240                        end
     241                end
     242
     243                token
     244        end
     245
     246        def on_error(t, v, vstack)
     247                if v == "$" then
     248                        Generator.error( "B1003 Unexpected EOF"  )
     249                else
     250                        Generator.error( "B1004 syntax error near \'$1\'" , v.val )
     251                end
     252
     253        end
     254
     255        def self.current_locale
     256                @@current_locale[ @@generator_nest ]
     257        end
     258
     259        @@n_error = 0
     260        @@n_warning = 0
     261        @@n_info = 0
     262
     263        # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切)
     264        def self.error( msg )
     265                @@n_error += 1
     266                locale = @@current_locale[ @@generator_nest ]
     267
     268                if locale then
     269                        Console.puts "#{locale[0]}:#{locale[1]}: error: #{msg}"
     270                else
     271                        Console.puts "error: #{msg}"
     272                end
     273        end
     274
     275        # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切)
     276        def self.warning( msg )
     277                @@n_warning += 1
     278                locale = @@current_locale[ @@generator_nest ]
     279                Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     280        end
     281
     282        # このメソッドは構文解析、意味解析からのみ呼出し可
     283        def self.info( msg )
     284                @@n_info += 1
     285                locale = @@current_locale[ @@generator_nest ]
     286                Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     287        end
     288
     289        def self.get_n_error
     290                @@n_error
     291        end
     292
     293        def self.get_n_warning
     294                @@n_warning
     295        end
     296
     297        def self.get_nest
     298                @@generator_nest
     299        end
     300
     301        def set_no_type_name b_no_type_name
     302                locale = @@current_locale[ @@generator_nest ]
    296303#print "b_no_type_name=#{b_no_type_name} #{locale[0]}: line #{locale[1]}\n"
    297     @b_no_type_name = b_no_type_name
    298   end
     304                @b_no_type_name = b_no_type_name
     305        end
    299306
    300307...end C_parser.y.rb/module_eval...
     
    302309
    303310clist = [
    304 '106,107,108,109,110,112,70,113,68,181,302,143,55,118,119,208,117,120',
    305 '121,122,123,124,125,106,107,108,109,110,112,337,113,209,336,210,143',
    306 '76,118,119,170,117,120,121,122,123,124,125,305,69,301,67,350,28,29,106',
    307 '107,108,109,110,112,75,113,28,29,162,143,77,118,119,170,117,120,121',
    308 '122,123,124,125,169,79,205,206,353,306,307,308,309,310,311,312,313,314',
    309 '315,264,55,144,8,9,10,11,15,16,17,18,19,20,21,174,267,23,25,27,28,29',
    310 '197,198,375,263,144,106,107,108,109,110,112,346,113,342,197,198,143',
    311 '173,118,119,153,117,120,121,122,123,124,125,106,107,108,109,110,112',
    312 '144,113,357,341,3,143,274,118,119,253,117,120,121,122,123,124,125,106',
    313 '107,108,109,110,112,54,113,199,200,361,143,53,118,119,98,117,120,121',
    314 '122,123,124,125,106,107,108,109,110,112,345,113,363,83,364,143,82,118',
    315 '119,346,117,120,121,122,123,124,125,81,144,249,83,274,253,82,253,53',
    316 '106,107,108,109,110,112,337,113,55,336,365,236,366,118,119,144,117,120',
    317 '121,122,123,124,125,54,249,367,194,253,97,53,53,195,196,81,199,200,55',
    318 '55,144,230,89,8,9,10,11,15,16,17,18,19,20,21,79,372,23,25,27,28,29,199',
    319 '200,144,231,88,232,233,234,235,87,237,238,240,241,242,243,194,377,194',
    320 '199,200,195,196,195,196,378,39,40,41,42,43,44,45,46,144,106,107,108',
    321 '109,110,112,379,113,205,206,380,143,381,118,119,382,117,120,121,122',
    322 '123,124,125,106,107,108,109,110,112,384,113,197,198,385,143,386,118',
    323 '119,65,117,120,121,122,123,124,125,106,107,108,109,110,112,62,113,391',
    324 '37,392,143,393,118,119,394,117,120,121,122,123,124,125,106,107,108,109',
    325 '110,112,61,113,211,212,396,143,398,118,119,280,117,120,121,122,123,124',
    326 '125,47,144,279,36,277,8,9,10,11,15,16,17,18,19,20,21,271,37,23,25,27',
    327 '28,29,270,144,38,8,9,10,11,15,16,17,18,19,20,21,199,200,23,25,27,28',
    328 '29,269,97,256,144,255,39,40,41,42,43,44,45,46,36,247,8,9,10,11,15,16',
    329 '17,18,19,20,21,144,246,23,25,27,28,29,245,32,38,106,107,108,109,110',
    330 '112,216,113,215,210,209,143,208,118,119,207,117,120,121,122,123,124',
    331 '125,39,40,41,42,43,44,45,46,303,106,107,108,109,110,112,316,113,317',
    332 '319,320,236,321,118,119,323,117,120,121,122,123,124,125,54,54,54,324',
    333 '54,325,53,53,53,326,53,329,176,55,55,55,230,55,8,9,10,11,15,16,17,18',
    334 '19,20,21,79,175,23,25,27,28,29,77,97,144,231,171,232,233,234,235,163',
    335 '237,238,240,241,242,243,183,348,184,349,185,186,187,207,,,39,40,41,42',
    336 '43,44,45,46,144,106,107,108,109,110,112,,113,,,,143,,118,119,,117,120',
    337 '121,122,123,124,125,,,106,107,108,109,110,112,,113,,,,236,,118,119,',
    338 '117,120,121,122,123,124,125,54,54,54,,54,,53,53,53,,53,,,55,55,55,230',
    339 '55,8,9,10,11,15,16,17,18,19,20,21,79,,23,25,27,28,29,,,,231,,232,233',
    340 '234,235,144,237,238,240,241,242,243,201,202,203,204,201,202,203,204',
    341 ',,39,40,41,42,43,44,45,46,144,106,107,108,109,110,112,,113,,,,236,,118',
    342 '119,,117,120,121,122,123,124,125,54,201,202,203,204,,53,,,,,,,55,,,230',
    343 ',8,9,10,11,15,16,17,18,19,20,21,79,,23,25,27,28,29,,,,231,,232,233,234',
    344 '235,,237,238,240,241,242,243,,,,,,,,,,,39,40,41,42,43,44,45,46,144,106',
    345 '107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124,125',
    346 '106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124',
    347 '125,106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123',
    348 '124,125,106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122',
    349 '123,124,125,,144,,,,,,,,106,107,108,109,110,112,,113,,,,143,,118,119',
    350 '144,117,120,121,122,123,124,125,106,107,108,109,110,112,,113,,368,,143',
    351 ',118,119,144,117,120,121,122,123,124,125,,,,,,,,106,107,108,109,110',
    352 '112,,113,144,,,236,,118,119,,117,120,121,122,123,124,125,,,,,,,,,,,',
    353 ',,,,,230,144,8,9,10,11,15,16,17,18,19,20,21,79,,23,25,27,28,29,,,,231',
    354 '144,232,233,234,235,,237,238,240,241,242,243,,,,,,,,,,,39,40,41,42,43',
    355 '44,45,46,144,106,107,108,109,110,112,,113,,,,236,,118,119,,117,120,121',
    356 '122,123,124,125,,,,,,,,,,,,,,,,,230,,8,9,10,11,15,16,17,18,19,20,21',
    357 '79,,23,25,27,28,29,,,,231,,232,233,234,235,,237,238,240,241,242,243',
    358 ',,,,,,,,,,39,40,41,42,43,44,45,46,144,106,107,108,109,110,112,,113,',
    359 ',,236,,118,119,,117,120,121,122,123,124,125,,,,,,,,,,,,,,,,,230,,8,9',
    360 '10,11,15,16,17,18,19,20,21,79,,23,25,27,28,29,,,,231,,232,233,234,235',
    361 ',237,238,240,241,242,243,,,,,,,,,,,39,40,41,42,43,44,45,46,144,106,107',
    362 '108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124,125,106',
    363 '107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124,125',
    364 '106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124',
    365 '125,106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123',
    366 '124,125,,144,,,,,141,,,,,,,142,106,107,108,109,110,112,,113,,147,144',
    367 '143,,118,119,,117,120,121,122,123,124,125,106,107,108,109,110,112,,113',
    368 ',,144,143,,118,119,,117,120,121,122,123,124,125,106,107,108,109,110',
    369 '112,,113,,,144,143,,118,119,,117,120,121,122,123,124,125,106,107,108',
    370 '109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124,125,,144,',
    371 ',,,,,,106,107,108,109,110,112,,113,,,,143,,118,119,144,117,120,121,122',
    372 '123,124,125,106,107,108,109,110,112,,113,,,,143,,118,119,144,117,120',
    373 '121,122,123,124,125,106,107,108,109,110,112,,113,,,,143,,118,119,144',
    374 '117,120,121,122,123,124,125,106,107,108,109,110,112,,113,,,,143,,118',
    375 '119,,117,120,121,122,123,124,125,,144,,,,,141,351,,,,,,142,106,107,108',
    376 '109,110,112,,113,,,144,143,,118,119,,117,120,121,122,123,124,125,106',
    377 '107,108,109,110,112,,113,,,144,143,,118,119,,117,120,121,122,123,124',
    378 '125,106,107,108,109,110,112,,113,,,144,143,,118,119,,117,120,121,122',
    379 '123,124,125,106,107,108,109,110,112,,113,,,,143,,118,119,,117,120,121',
    380 '122,123,124,125,,144,,,,,,,,106,107,108,109,110,112,,113,,,,143,,118',
    381 '119,144,117,120,121,122,123,124,125,106,107,108,109,110,112,,113,,,',
    382 '143,,118,119,144,117,120,121,122,123,124,125,106,107,108,109,110,112',
    383 ',113,,,,143,,118,119,144,117,120,121,122,123,124,125,,,,,,,,,,106,107',
    384 '108,109,110,112,,113,,,,236,,118,119,144,117,120,121,122,123,124,125',
    385 ',,,,,,,,,,,,,,,144,230,,8,9,10,11,15,16,17,18,19,20,21,79,239,23,25',
    386 '27,28,29,,,144,231,,232,233,234,235,,237,238,240,241,242,243,,,,,,,',
    387 ',,,39,40,41,42,43,44,45,46,144,106,107,108,109,110,112,,113,,338,,143',
    388 ',118,119,,117,120,121,122,123,124,125,106,107,108,109,110,112,,113,',
    389 ',,143,,118,119,,117,120,121,122,123,124,125,8,9,10,11,15,16,17,18,19',
    390 '20,21,,,23,25,27,28,29,8,9,10,11,15,16,17,18,19,20,21,,,23,25,27,28',
    391 '29,,106,107,108,109,110,112,,113,,,144,143,,118,119,,117,120,121,122',
    392 '123,124,125,106,107,108,109,110,112,,113,,,144,143,,118,119,,117,120',
    393 '121,122,123,124,125,106,107,108,109,110,112,,113,,,,143,,118,119,,117',
    394 '120,121,122,123,124,125,106,107,108,109,110,189,,113,,,,143,,118,119',
    395 ',117,120,121,122,123,124,125,,144,,,,,,,,106,107,108,109,110,191,,113',
    396 ',,,143,,118,119,144,117,120,121,122,123,124,125,106,107,108,109,110',
    397 '191,,113,,,,143,,118,119,144,117,120,121,122,123,124,125,106,107,108',
    398 '109,110,112,,113,,,,143,,118,119,144,117,120,121,122,123,124,125,106',
    399 '107,108,109,110,112,,113,,,,143,,118,119,,117,120,121,122,123,124,125',
    400 ',144,,,,,141,,,,,,,142,,,328,,106,107,108,109,110,112,144,113,,,,143',
    401 ',118,119,,117,120,121,122,123,124,125,,,,,,,144,,,,,,,,,,,106,107,108',
    402 '109,110,112,,113,,,,236,144,118,119,,117,120,121,122,123,124,125,,,',
    403 ',,,,,,,,,,,,,230,,8,9,10,11,15,16,17,18,19,20,21,79,144,23,25,27,28',
    404 '29,,,,231,,232,233,234,235,,237,238,240,241,242,243,,,,,,,274,334,,253',
    405 '39,40,41,42,43,44,45,46,144,55,,,,,249,334,,253,,,53,,,,,,,55,,,,,8',
    406 '9,10,11,15,16,17,18,19,20,21,,,23,25,27,28,29,8,9,10,11,15,16,17,18',
    407 '19,20,21,,,23,25,27,28,29,370,,,,,,,,39,40,41,42,43,44,45,46,,,149,',
    408 ',,,,,,39,40,41,42,43,44,45,46,,8,9,10,11,15,16,17,18,19,20,21,,,23,25',
    409 '27,28,29,8,9,10,11,15,16,17,18,19,20,21,,,23,25,27,28,29,,,,330,,,,',
    410 '39,40,41,42,43,44,45,46,,,,,,,,,,,39,40,41,42,43,44,45,46,8,9,10,11',
    411 '15,16,17,18,19,20,21,,,23,25,27,28,29,8,9,10,11,15,16,17,18,19,20,21',
    412 ',,23,25,27,28,29,,,,,,,,,39,40,41,42,43,44,45,46,,,,,,,,,,,39,40,41',
    413 '42,43,44,45,46,8,9,10,11,15,16,17,18,19,20,21,,340,23,25,27,28,29,8',
    414 '9,10,11,15,16,17,18,19,20,21,,164,23,25,27,28,29,,,,,,,,,39,40,41,42',
    415 '43,44,45,46,,,,,,,,,,,39,40,41,42,43,44,45,46,8,9,10,11,15,16,17,18',
    416 '19,20,21,,,23,25,27,28,29,8,9,10,11,15,16,17,18,19,20,21,,,23,25,27',
    417 '28,29,,,,,,,,,39,40,41,42,43,44,45,46,,,,,,,,,,,39,40,41,42,43,44,45',
    418 '46,8,9,10,11,15,16,17,18,19,20,21,,,23,25,27,28,29,8,9,10,11,15,16,17',
    419 '18,19,20,21,,257,23,25,27,28,29,,,,,,,,,39,40,41,42,43,44,45,46,,,,',
    420 ',,,,,,39,40,41,42,43,44,45,46,8,9,10,11,15,16,17,18,19,20,21,,,23,25',
    421 '27,28,29,8,9,10,11,15,16,17,18,19,20,21,,262,23,25,27,28,29,,,,,,,,',
    422 '39,40,41,42,43,44,45,46,,,,,,,,,,,39,40,41,42,43,44,45,46,8,9,10,11',
    423 '15,16,17,18,19,20,21,,,23,25,27,28,29,8,9,10,11,15,16,17,18,19,20,21',
    424 ',,23,25,27,28,29,,,,,,,,,39,40,41,42,43,44,45,46,,,,,,,,,,,39,40,41',
    425 '42,43,44,45,46,8,9,10,11,15,16,17,18,19,20,21,,,23,25,27,28,29' ]
    426         racc_action_table = arr = ::Array.new(2875, nil)
     311'111,112,113,114,115,117,294,118,56,298,55,163,54,123,124,82,54,262,122',
     312'125,126,127,128,129,130,111,112,113,114,115,117,217,118,271,391,101',
     313'163,91,123,124,82,271,271,122,125,126,127,128,129,130,56,70,171,72,82',
     314'69,397,71,80,32,33,34,224,309,271,223,216,226,84,227,228,229,84,392',
     315'101,325,272,171,298,312,80,164,165,172,393,173,174,175,176,177,178,179',
     316'180,149,181,101,218,79,308,369,388,32,33,34,265,266,164,165,172,73,173',
     317'174,175,176,177,178,179,180,149,181,111,112,113,114,115,117,384,118',
     318'32,33,34,163,78,123,124,82,440,402,122,125,126,127,128,129,130,55,219',
     319'271,271,383,101,54,332,248,325,387,55,298,249,250,56,382,54,111,112',
     320'113,114,115,117,56,118,56,171,331,163,395,123,124,82,276,210,122,125',
     321'126,127,128,129,130,420,55,378,210,248,377,396,54,330,249,250,393,92',
     322'164,165,172,56,173,174,175,176,177,178,179,180,149,181,171,9,10,11,12',
     323'13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,355,356',
     324'213,164,165,172,204,173,174,175,176,177,178,179,180,149,181,111,112',
     325'113,114,115,117,404,118,93,378,203,163,377,123,124,82,193,271,122,125',
     326'126,127,128,129,130,111,112,113,114,115,117,290,118,101,86,55,163,85',
     327'123,124,82,54,291,122,125,126,127,128,129,130,56,357,171,13,14,15,16',
     328'17,18,19,20,21,22,26,28,30,31,32,33,34,248,86,322,438,85,249,250,171',
     329'434,435,370,164,165,172,271,173,174,175,176,177,178,179,180,149,181',
     330'259,260,261,321,255,256,257,258,315,316,262,164,165,172,271,173,174',
     331'175,176,177,178,179,180,149,181,111,112,113,114,115,117,403,118,317',
     332'318,263,163,264,123,124,82,320,271,122,125,126,127,128,129,130,13,14',
     333'15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,437,111,112,113,114,115',
     334'117,360,118,400,171,271,163,368,123,124,82,166,103,122,125,126,127,128',
     335'129,130,102,55,255,256,257,258,310,54,255,256,257,258,405,164,165,172',
     336'56,173,174,175,176,177,178,179,180,149,181,171,9,10,11,12,13,14,15,16',
     337'17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,259,260,301,164,165',
     338'172,300,173,174,175,176,177,178,179,180,149,181,111,112,113,114,115',
     339'117,408,118,253,254,292,163,409,123,124,82,253,254,122,125,126,127,128',
     340'129,130,111,112,113,114,115,117,410,118,253,254,55,163,289,123,124,82',
     341'54,288,122,125,126,127,128,129,130,56,415,171,13,14,15,16,17,18,19,20',
     342'21,22,26,28,30,31,32,33,34,253,254,253,254,251,252,261,171,211,212,285',
     343'164,165,172,284,173,174,175,176,177,178,179,180,149,181,237,238,239',
     344'240,241,242,243,244,245,246,247,164,165,172,283,173,174,175,176,177',
     345'178,179,180,149,181,111,112,113,114,115,117,282,118,251,252,389,163',
     346'389,123,124,82,251,252,122,125,126,127,128,129,130,111,112,113,114,115',
     347'117,101,118,67,82,55,163,64,123,124,82,54,63,122,125,126,127,128,129',
     348'130,56,55,171,55,55,294,280,54,298,54,54,54,279,430,431,432,56,433,56',
     349'56,56,365,436,278,263,275,264,171,273,270,48,164,165,172,444,173,174',
     350'175,176,177,178,179,180,149,181,269,3,,,,,,,,,,164,165,172,,173,174',
     351'175,176,177,178,179,180,149,181,111,112,113,114,115,117,,118,,,,163',
     352',123,124,82,,,122,125,126,127,128,129,130,111,112,113,114,115,117,,118',
     353',,,148,,123,124,,,,122,125,126,127,128,129,130,,,171,111,112,113,114',
     354'115,117,,118,,,,148,,123,124,,,,122,125,126,127,128,129,130,,,,164,165',
     355'172,,173,174,175,176,177,178,179,180,149,181,,,,,,,111,112,113,114,115',
     356'117,,118,,411,,148,,123,124,,,149,122,125,126,127,128,129,130,,,,111',
     357'112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129',
     358'130,111,112,113,114,115,117,,118,,,,148,,123,124,,,,122,125,126,127',
     359'128,129,130,,,171,,,,,,,,,,,,,149,,111,112,113,114,115,117,,118,,,171',
     360'148,,123,124,,,,122,125,126,127,128,129,130,,149,,,,,,,,111,112,113',
     361'114,115,117,,118,,,,148,,123,124,146,398,149,122,125,126,127,128,129',
     362'130,111,112,113,114,115,117,,118,,,,148,,123,124,,,,122,125,126,127',
     363'128,129,130,111,112,113,114,115,117,,118,,149,,148,,123,124,389,,,122',
     364'125,126,127,128,129,130,,,,147,,,111,112,113,114,115,117,,118,,,,148',
     365'149,123,124,,,,122,125,126,127,128,129,130,111,112,113,114,115,117,',
     366'118,,379,,148,149,123,124,,,,122,125,126,127,128,129,130,,,,,,,,,,,',
     367',149,,,,,111,112,113,114,115,117,,118,,,,148,,123,124,,,,122,125,126',
     368'127,128,129,130,,149,,,,,,,,,,,,,,,,,,,,,,,,,149,171,9,10,11,12,13,14',
     369'15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,111,112,113',
     370'114,115,117,,118,,,,148,,123,124,149,,,122,125,126,127,128,129,130,111',
     371'112,113,114,115,117,,118,,,,148,,123,124,146,,,122,125,126,127,128,129',
     372'130,111,112,113,114,115,117,,118,,,,148,,123,124,,,,122,125,126,127',
     373'128,129,130,,111,112,113,114,115,117,,118,,,,148,,123,124,,,149,122',
     374'125,126,127,128,129,130,,,147,,,111,112,113,114,115,117,,118,,,,148',
     375'149,123,124,,,,122,125,126,127,128,129,130,111,112,113,114,115,117,',
     376'118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,,111,112,113,114',
     377'115,117,,118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,111,112',
     378'113,114,115,117,,118,,,,148,,123,124,146,,149,122,125,126,127,128,129',
     379'130,111,112,113,114,115,117,427,118,,,,148,,123,124,,,149,122,125,126',
     380'127,128,129,130,,111,112,113,114,115,117,,118,,,,148,,123,124,,,149',
     381'122,125,126,127,128,129,130,,,147,,,111,112,113,114,115,117,,118,,185',
     382',148,149,123,124,,,,122,125,126,127,128,129,130,111,112,113,114,115',
     383'117,,118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,,111,112',
     384'113,114,115,117,,118,,,,148,149,123,124,,,,122,125,126,127,128,129,130',
     385'111,112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128',
     386'129,130,111,112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126',
     387'127,128,129,130,,111,112,113,114,115,117,,118,,,,148,,123,124,,,149',
     388'122,125,126,127,128,129,130,111,112,113,114,115,117,,118,,,,148,,123',
     389'124,,,149,122,125,126,127,128,129,130,111,112,113,114,115,117,,118,',
     390',,148,,123,124,,,149,122,125,126,127,128,129,130,,111,112,113,114,115',
     391'117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,111,112,113',
     392'114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,111',
     393'112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129',
     394'130,,111,112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126',
     395'127,128,129,130,111,112,113,114,115,117,,118,,,,148,,123,124,,,149,122',
     396'125,126,127,128,129,130,111,112,113,114,115,117,,118,,,,148,,123,124',
     397',,149,122,125,126,127,128,129,130,,111,112,113,114,115,117,,118,,,,148',
     398',123,124,,,149,122,125,126,127,128,129,130,111,112,113,114,115,117,',
     399'118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,111,112,113,114',
     400'115,117,,118,,,,148,,123,124,146,,149,122,125,126,127,128,129,130,,111',
     401'112,113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129',
     402'130,,,,,,,,,,,,,,,,,,149,,,,,,,,,,147,,,111,112,113,114,115,117,,118',
     403',,,148,149,123,124,,,,122,125,126,127,128,129,130,,111,112,113,114,115',
     404'117,,118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,,,,,,,13',
     405'14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,,,111,112,113,114,115',
     406'117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,,111,112',
     407'113,114,115,231,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130',
     408'111,112,113,114,115,233,,118,,,,148,,123,124,,,,122,125,126,127,128',
     409'129,130,111,112,113,114,115,233,,118,,,,148,,123,124,,,149,122,125,126',
     410'127,128,129,130,,,,,,,,,,,,,111,112,113,114,115,117,149,118,,,,148,',
     411'123,124,,,,122,125,126,127,128,129,130,111,112,113,114,115,117,149,118',
     412',,,148,,123,124,,,,122,125,126,127,128,129,130,,,,,,,149,13,14,15,16',
     413'17,18,19,20,21,22,26,28,30,31,32,33,34,,,111,112,113,114,115,117,,118',
     414',,,148,,123,124,,,149,122,125,126,127,128,129,130,111,112,113,114,115',
     415'117,327,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,,,,,,',
     416',13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,,,111,112,113,114',
     417'115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130,111,112',
     418'113,114,115,117,,118,,,,148,,123,124,,,149,122,125,126,127,128,129,130',
     419'111,112,113,114,115,117,,118,,,,148,,123,124,,,,122,125,126,127,128',
     420'129,130,,111,112,113,114,115,117,429,118,,,,148,,123,124,,,149,122,125',
     421'126,127,128,129,130,,287,,,,111,112,113,114,115,117,,118,,,,148,149',
     422'123,124,146,442,,122,125,126,127,128,129,130,111,112,113,114,115,117',
     423',118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,,111,112,113',
     424'114,115,117,,118,,,,148,149,123,124,,,,122,125,126,127,128,129,130,',
     425',147,,,,,,,,,,,,,,46,149,,,,,,,,,,,,,,,,,,,,,,,,,149,,,46,,,,,,,,,,',
     426',,,,,,,,,,,,149,45,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30',
     427'31,32,33,34,35,36,37,38,,,47,45,9,10,11,12,13,14,15,16,17,18,19,20,21',
     428'22,26,28,30,31,32,33,34,35,36,37,38,,41,47,294,375,,298,,,54,,,,,,,',
     429',56,,,,,,,,,,325,375,,298,,,,,,,,,,,,56,,,,,,,,9,10,11,12,13,14,15,16',
     430'17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13,14',
     431'15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,188,,,,,192',
     432',,,,,,,,,,,,,,,,,,,413,,,,,,,,,,,,,,,,,,,,,,9,10,11,12,13,14,15,16,17',
     433'18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13,14,15',
     434'16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,371,9,10,11,12',
     435'13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,,,,,',
     436'205,,,,,,,,,,,,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30,31',
     437'32,33,34,35,36,37,38,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28',
     438'30,31,32,33,34,35,36,37,38,307,,,,,,,,,,,,,,,,,,,,,,,,,381,,,,,,,,,',
     439',,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36',
     440'37,38,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34',
     441'35,36,37,38,302,9,10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30,31',
     442'32,33,34,35,36,37,38,,,,,,,,,,,,9,10,11,12,13,14,15,16,17,18,19,20,21',
     443'22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13,14,15,16,17,18,19',
     444'20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13,14,15,16,17',
     445'18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13,14,15',
     446'16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11,12,13',
     447'14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9,10,11',
     448'12,13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37,38,9',
     449'10,11,12,13,14,15,16,17,18,19,20,21,22,26,28,30,31,32,33,34,35,36,37',
     450'38' ]
     451        racc_action_table = arr = ::Array.new(3198, nil)
    427452        idx = 0
    428453        clist.each do |str|
     
    434459
    435460clist = [
    436 '210,210,210,210,210,210,26,210,24,114,213,210,55,210,210,297,210,210',
    437 '210,210,210,210,210,211,211,211,211,211,211,332,211,298,332,299,211',
    438 '48,211,211,95,211,211,211,211,211,211,211,217,26,213,24,300,55,55,189',
    439 '189,189,189,189,189,48,189,114,114,90,189,50,189,189,172,189,189,189',
    440 '189,189,189,189,95,50,132,132,303,217,217,217,217,217,217,217,217,217',
    441 '217,166,85,210,189,189,189,189,189,189,189,189,189,189,189,101,172,189',
    442 '189,189,189,189,287,287,347,166,211,394,394,394,394,394,394,347,394',
    443 '259,288,288,394,101,394,394,84,394,394,394,394,394,394,394,181,181,181',
    444 '181,181,181,189,181,318,259,1,181,273,181,181,273,181,181,181,181,181',
    445 '181,181,194,194,194,194,194,194,51,194,289,289,322,194,51,194,194,70',
    446 '194,194,194,194,194,194,194,195,195,195,195,195,195,275,195,324,52,327',
    447 '195,52,195,195,275,195,195,195,195,195,195,195,51,394,248,80,180,248',
    448 '80,180,248,392,392,392,392,392,392,252,392,180,252,330,392,333,392,392',
    449 '181,392,392,392,392,392,392,392,342,152,335,286,152,69,342,152,286,286',
    450 '248,290,290,342,152,194,392,66,392,392,392,392,392,392,392,392,392,392',
    451 '392,392,339,392,392,392,392,392,291,291,195,392,64,392,392,392,392,63',
    452 '392,392,392,392,392,392,285,354,128,292,292,285,285,128,128,355,392',
    453 '392,392,392,392,392,392,392,392,381,381,381,381,381,381,356,381,295',
    454 '295,357,381,358,381,381,359,381,381,381,381,381,381,381,380,380,380',
    455 '380,380,380,365,380,129,129,369,380,371,380,380,22,380,380,380,380,380',
    456 '380,380,196,196,196,196,196,196,14,196,382,32,387,196,389,196,196,390',
    457 '196,196,196,196,196,196,196,197,197,197,197,197,197,12,197,137,137,393',
    458 '197,397,197,197,185,197,197,197,197,197,197,197,3,381,184,32,182,32',
    459 '32,32,32,32,32,32,32,32,32,32,178,2,32,32,32,32,32,177,380,32,72,72',
    460 '72,72,72,72,72,72,72,72,72,130,130,72,72,72,72,72,175,170,157,196,156',
    461 '32,32,32,32,32,32,32,32,2,150,2,2,2,2,2,2,2,2,2,2,2,197,148,2,2,2,2',
    462 '2,146,2,2,198,198,198,198,198,198,144,198,142,136,135,198,134,198,198',
    463 '133,198,198,198,198,198,198,198,2,2,2,2,2,2,2,2,215,379,379,379,379',
    464 '379,379,231,379,232,234,235,379,236,379,379,238,379,379,379,379,379',
    465 '379,379,160,94,54,240,264,241,160,94,54,242,264,244,111,160,94,54,379',
    466 '264,379,379,379,379,379,379,379,379,379,379,379,379,105,379,379,379',
    467 '379,379,104,98,198,379,97,379,379,379,379,91,379,379,379,379,379,379',
    468 '115,278,115,281,115,115,115,296,,,379,379,379,379,379,379,379,379,379',
    469 '171,171,171,171,171,171,,171,,,,171,,171,171,,171,171,171,171,171,171',
    470 '171,,,378,378,378,378,378,378,,378,,,,378,,378,378,,378,378,378,378',
    471 '378,378,378,76,4,74,,174,,76,4,74,,174,,,76,4,74,378,174,378,378,378',
    472 '378,378,378,378,378,378,378,378,378,,378,378,378,378,378,,,,378,,378',
    473 '378,378,378,171,378,378,378,378,378,378,294,294,294,294,131,131,131',
    474 '131,,,378,378,378,378,378,378,378,378,378,361,361,361,361,361,361,,361',
    475 ',,,361,,361,361,,361,361,361,361,361,361,361,218,293,293,293,293,,218',
    476 ',,,,,,218,,,361,,361,361,361,361,361,361,361,361,361,361,361,361,,361',
    477 '361,361,361,361,,,,361,,361,361,361,361,,361,361,361,361,361,361,,,',
    478 ',,,,,,,361,361,361,361,361,361,361,361,361,199,199,199,199,199,199,',
    479 '199,,,,199,,199,199,,199,199,199,199,199,199,199,350,350,350,350,350',
    480 '350,,350,,,,350,,350,350,,350,350,350,350,350,350,350,346,346,346,346',
    481 '346,346,,346,,,,346,,346,346,,346,346,346,346,346,346,346,191,191,191',
    482 '191,191,191,,191,,,,191,,191,191,,191,191,191,191,191,191,191,,199,',
    483 ',,,,,,200,200,200,200,200,200,,200,,,,200,,200,200,350,200,200,200,200',
    484 '200,200,200,336,336,336,336,336,336,,336,,336,,336,,336,336,346,336',
    485 '336,336,336,336,336,336,,,,,,,,323,323,323,323,323,323,,323,191,,,323',
    486 ',323,323,,323,323,323,323,323,323,323,,,,,,,,,,,,,,,,,323,200,323,323',
    487 '323,323,323,323,323,323,323,323,323,323,,323,323,323,323,323,,,,323',
    488 '336,323,323,323,323,,323,323,323,323,323,323,,,,,,,,,,,323,323,323,323',
    489 '323,323,323,323,323,321,321,321,321,321,321,,321,,,,321,,321,321,,321',
    490 '321,321,321,321,321,321,,,,,,,,,,,,,,,,,321,,321,321,321,321,321,321',
    491 '321,321,321,321,321,321,,321,321,321,321,321,,,,321,,321,321,321,321',
    492 ',321,321,321,321,321,321,,,,,,,,,,,321,321,321,321,321,321,321,321,321',
    493 '398,398,398,398,398,398,,398,,,,398,,398,398,,398,398,398,398,398,398',
    494 '398,,,,,,,,,,,,,,,,,398,,398,398,398,398,398,398,398,398,398,398,398',
    495 '398,,398,398,398,398,398,,,,398,,398,398,398,398,,398,398,398,398,398',
    496 '398,,,,,,,,,,,398,398,398,398,398,398,398,398,398,320,320,320,320,320',
    497 '320,,320,,,,320,,320,320,,320,320,320,320,320,320,320,319,319,319,319',
    498 '319,319,,319,,,,319,,319,319,,319,319,319,319,319,319,319,77,77,77,77',
    499 '77,77,,77,,,,77,,77,77,,77,77,77,77,77,77,77,317,317,317,317,317,317',
    500 ',317,,,,317,,317,317,,317,317,317,317,317,317,317,,320,,,,,77,,,,,,',
    501 '77,82,82,82,82,82,82,,82,,82,319,82,,82,82,,82,82,82,82,82,82,82,183',
    502 '183,183,183,183,183,,183,,,77,183,,183,183,,183,183,183,183,183,183',
    503 '183,316,316,316,316,316,316,,316,,,317,316,,316,316,,316,316,316,316',
    504 '316,316,316,304,304,304,304,304,304,,304,,,,304,,304,304,,304,304,304',
    505 '304,304,304,304,,82,,,,,,,,201,201,201,201,201,201,,201,,,,201,,201',
    506 '201,183,201,201,201,201,201,201,201,202,202,202,202,202,202,,202,,,',
    507 '202,,202,202,316,202,202,202,202,202,202,202,302,302,302,302,302,302',
    508 ',302,,,,302,,302,302,304,302,302,302,302,302,302,302,277,277,277,277',
    509 '277,277,,277,,,,277,,277,277,,277,277,277,277,277,277,277,,201,,,,,302',
    510 '302,,,,,,302,203,203,203,203,203,203,,203,,,202,203,,203,203,,203,203',
    511 '203,203,203,203,203,209,209,209,209,209,209,,209,,,302,209,,209,209',
    512 ',209,209,209,209,209,209,209,212,212,212,212,212,212,,212,,,277,212',
    513 ',212,212,,212,212,212,212,212,212,212,204,204,204,204,204,204,,204,',
    514 ',,204,,204,204,,204,204,204,204,204,204,204,,203,,,,,,,,271,271,271',
    515 '271,271,271,,271,,,,271,,271,271,209,271,271,271,271,271,271,271,205',
    516 '205,205,205,205,205,,205,,,,205,,205,205,212,205,205,205,205,205,205',
    517 '205,206,206,206,206,206,206,,206,,,,206,,206,206,204,206,206,206,206',
    518 '206,206,206,,,,,,,,,,145,145,145,145,145,145,,145,,,,145,,145,145,271',
    519 '145,145,145,145,145,145,145,,,,,,,,,,,,,,,,205,145,,145,145,145,145',
    520 '145,145,145,145,145,145,145,145,145,145,145,145,145,145,,,206,145,,145',
    521 '145,145,145,,145,145,145,145,145,145,,,,,,,,,,,145,145,145,145,145,145',
    522 '145,145,145,253,253,253,253,253,253,,253,,253,,253,,253,253,,253,253',
    523 '253,253,253,253,253,112,112,112,112,112,112,,112,,,,112,,112,112,,112',
    524 '112,112,112,112,112,112,38,38,38,38,38,38,38,38,38,38,38,,,38,38,38',
    525 '38,38,112,112,112,112,112,112,112,112,112,112,112,,,112,112,112,112',
    526 '112,,207,207,207,207,207,207,,207,,,253,207,,207,207,,207,207,207,207',
    527 '207,207,207,208,208,208,208,208,208,,208,,,112,208,,208,208,,208,208',
    528 '208,208,208,208,208,116,116,116,116,116,116,,116,,,,116,,116,116,,116',
    529 '116,116,116,116,116,116,117,117,117,117,117,117,,117,,,,117,,117,117',
    530 ',117,117,117,117,117,117,117,,207,,,,,,,,118,118,118,118,118,118,,118',
    531 ',,,118,,118,118,208,118,118,118,118,118,118,118,119,119,119,119,119',
    532 '119,,119,,,,119,,119,119,116,119,119,119,119,119,119,119,141,141,141',
    533 '141,141,141,,141,,,,141,,141,141,117,141,141,141,141,141,141,141,243',
    534 '243,243,243,243,243,,243,,,,243,,243,243,,243,243,243,243,243,243,243',
    535 ',118,,,,,141,,,,,,,141,,,243,,237,237,237,237,237,237,119,237,,,,237',
    536 ',237,237,,237,237,237,237,237,237,237,,,,,,,141,,,,,,,,,,,233,233,233',
    537 '233,233,233,,233,,,,233,243,233,233,,233,233,233,233,233,233,233,,,',
    538 ',,,,,,,,,,,,,233,,233,233,233,233,233,233,233,233,233,233,233,233,237',
    539 '233,233,233,233,233,,,,233,,233,233,233,233,,233,233,233,233,233,233',
    540 ',,,,,,274,274,,274,233,233,233,233,233,233,233,233,233,274,,,,,249,249',
    541 ',249,,,249,,,,,,,249,,,,,274,274,274,274,274,274,274,274,274,274,274',
    542 ',,274,274,274,274,274,249,249,249,249,249,249,249,249,249,249,249,,',
    543 '249,249,249,249,249,337,,,,,,,,274,274,274,274,274,274,274,274,,,83',
    544 ',,,,,,,249,249,249,249,249,249,249,249,,337,337,337,337,337,337,337',
    545 '337,337,337,337,,,337,337,337,337,337,83,83,83,83,83,83,83,83,83,83',
    546 '83,,,83,83,83,83,83,,,,247,,,,,337,337,337,337,337,337,337,337,,,,,',
    547 ',,,,,83,83,83,83,83,83,83,83,247,247,247,247,247,247,247,247,247,247',
    548 '247,,,247,247,247,247,247,5,5,5,5,5,5,5,5,5,5,5,,,5,5,5,5,5,,,,,,,,',
    549 '247,247,247,247,247,247,247,247,,,,,,,,,,,5,5,5,5,5,5,5,5,254,254,254',
    550 '254,254,254,254,254,254,254,254,,254,254,254,254,254,254,92,92,92,92',
    551 '92,92,92,92,92,92,92,,92,92,92,92,92,92,,,,,,,,,254,254,254,254,254',
    552 '254,254,254,,,,,,,,,,,92,92,92,92,92,92,92,92,155,155,155,155,155,155',
    553 '155,155,155,155,155,,,155,155,155,155,155,89,89,89,89,89,89,89,89,89',
    554 '89,89,,,89,89,89,89,89,,,,,,,,,155,155,155,155,155,155,155,155,,,,,',
    555 ',,,,,89,89,89,89,89,89,89,89,88,88,88,88,88,88,88,88,88,88,88,,,88,88',
    556 '88,88,88,158,158,158,158,158,158,158,158,158,158,158,,158,158,158,158',
    557 '158,158,,,,,,,,,88,88,88,88,88,88,88,88,,,,,,,,,,,158,158,158,158,158',
    558 '158,158,158,67,67,67,67,67,67,67,67,67,67,67,,,67,67,67,67,67,161,161',
    559 '161,161,161,161,161,161,161,161,161,,161,161,161,161,161,161,,,,,,,',
    560 ',67,67,67,67,67,67,67,67,,,,,,,,,,,161,161,161,161,161,161,161,161,7',
    561 '7,7,7,7,7,7,7,7,7,7,,,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,,,6,6,6,6,6,,',
    562 ',,,,,,7,7,7,7,7,7,7,7,,,,,,,,,,,6,6,6,6,6,6,6,6,73,73,73,73,73,73,73',
    563 '73,73,73,73,,,73,73,73,73,73' ]
    564         racc_action_check = arr = ::Array.new(2875, nil)
     461'440,440,440,440,440,440,293,440,56,293,52,440,293,440,440,440,52,139',
     462'440,440,440,440,440,440,440,438,438,438,438,438,438,106,438,354,326',
     463'103,438,65,438,438,438,151,326,438,438,438,438,438,438,438,88,29,440',
     464'31,51,29,354,31,109,56,56,56,120,207,286,120,106,120,293,120,120,120',
     465'52,328,212,324,151,438,324,212,51,440,440,440,328,440,440,440,440,440',
     466'440,440,440,440,440,318,110,49,207,286,318,88,88,88,142,142,438,438',
     467'438,31,438,438,438,438,438,438,438,438,438,438,436,436,436,436,436,436',
     468'304,436,120,120,120,436,49,436,436,436,428,362,436,436,436,436,436,436',
     469'436,98,116,428,362,304,316,98,227,340,222,316,309,222,340,340,98,304',
     470'309,167,167,167,167,167,167,222,167,309,436,226,167,333,167,167,167',
     471'167,98,167,167,167,167,167,167,167,394,4,297,309,339,297,334,4,225,339',
     472'339,394,66,436,436,436,4,436,436,436,436,436,436,436,436,436,436,167',
     473'167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167',
     474'167,167,167,167,167,167,167,167,267,267,101,167,167,167,95,167,167,167',
     475'167,167,167,167,167,167,167,429,429,429,429,429,429,364,429,68,373,94',
     476'429,373,429,429,429,87,364,429,429,429,429,429,429,429,427,427,427,427',
     477'427,427,187,427,71,83,217,427,83,427,427,427,217,187,427,427,427,427',
     478'427,427,427,217,269,429,75,75,75,75,75,75,75,75,75,75,75,75,75,75,75',
     479'75,75,133,53,221,426,53,133,133,427,418,418,291,429,429,429,426,429',
     480'429,429,429,429,429,429,429,429,429,137,137,350,220,136,136,136,136',
     481'214,214,351,427,427,427,220,427,427,427,427,427,427,427,427,427,427',
     482'175,175,175,175,175,175,363,175,215,215,352,175,353,175,175,175,218',
     483'363,175,175,175,175,175,175,175,76,76,76,76,76,76,76,76,76,76,76,76',
     484'76,76,76,76,76,425,82,82,82,82,82,82,274,82,357,175,425,82,283,82,82',
     485'82,82,73,82,82,82,82,82,82,82,72,201,347,347,347,347,209,201,348,348',
     486'348,348,365,175,175,175,201,175,175,175,175,175,175,175,175,175,175',
     487'82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82,82',
     488'82,82,82,349,349,198,82,82,82,197,82,82,82,82,82,82,82,82,82,82,273',
     489'273,273,273,273,273,371,273,135,135,189,273,374,273,273,273,346,346',
     490'273,273,273,273,273,273,273,404,404,404,404,404,404,376,404,345,345',
     491'79,404,186,404,404,404,79,184,404,404,404,404,404,404,404,79,380,273',
     492'47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,47,344,344,343,343,342',
     493'342,138,404,99,99,179,273,273,273,178,273,273,273,273,273,273,273,273',
     494'273,273,131,131,131,131,131,131,131,131,131,131,131,404,404,404,177',
     495'404,404,404,404,404,404,404,404,404,404,402,402,402,402,402,402,176',
     496'402,341,341,395,402,396,402,402,402,134,134,402,402,402,402,402,402',
     497'402,275,275,275,275,275,275,102,275,27,403,77,275,25,275,275,275,77',
     498'23,275,275,275,275,275,275,275,77,55,402,152,384,191,174,55,191,152',
     499'384,191,173,408,412,414,55,416,152,384,191,281,422,172,140,165,141,275',
     500'163,149,3,402,402,402,437,402,402,402,402,402,402,402,402,402,402,147',
     501'1,,,,,,,,,,275,275,275,,275,275,275,275,275,275,275,275,275,275,360',
     502'360,360,360,360,360,,360,,,,360,,360,360,360,,,360,360,360,360,360,360',
     503'360,249,249,249,249,249,249,,249,,,,249,,249,249,,,,249,249,249,249',
     504'249,249,249,,,360,383,383,383,383,383,383,,383,,,,383,,383,383,,,,383',
     505'383,383,383,383,383,383,,,,360,360,360,,360,360,360,360,360,360,360',
     506'360,360,360,,,,,,,377,377,377,377,377,377,,377,,377,,377,,377,377,,',
     507'249,377,377,377,377,377,377,377,,,,367,367,367,367,367,367,,367,,,,367',
     508',367,367,,,383,367,367,367,367,367,367,367,366,366,366,366,366,366,',
     509'366,,,,366,,366,366,,,,366,366,366,366,366,366,366,,,367,,,,,,,,,,,',
     510',377,,393,393,393,393,393,393,,393,,,366,393,,393,393,,,,393,393,393',
     511'393,393,393,393,,367,,,,,,,,356,356,356,356,356,356,,356,,,,356,,356',
     512'356,356,356,366,356,356,356,356,356,356,356,330,330,330,330,330,330',
     513',330,,,,330,,330,330,,,,330,330,330,330,330,330,330,322,322,322,322',
     514'322,322,,322,,393,,322,,322,322,322,,,322,322,322,322,322,322,322,,',
     515',356,,,310,310,310,310,310,310,,310,,,,310,356,310,310,,,,310,310,310',
     516'310,310,310,310,298,298,298,298,298,298,,298,,298,,298,330,298,298,',
     517',,298,298,298,298,298,298,298,,,,,,,,,,,,,322,,,,,282,282,282,282,282',
     518'282,,282,,,,282,,282,282,,,,282,282,282,282,282,282,282,,310,,,,,,,',
     519',,,,,,,,,,,,,,,,,298,282,282,282,282,282,282,282,282,282,282,282,282',
     520'282,282,282,282,282,282,282,282,282,282,282,282,282,282,280,280,280',
     521'280,280,280,,280,,,,280,,280,280,282,,,280,280,280,280,280,280,280,146',
     522'146,146,146,146,146,,146,,,,146,,146,146,146,,,146,146,146,146,146,146',
     523'146,278,278,278,278,278,278,,278,,,,278,,278,278,,,,278,278,278,278',
     524'278,278,278,,397,397,397,397,397,397,,397,,,,397,,397,397,,,280,397',
     525'397,397,397,397,397,397,,,146,,,405,405,405,405,405,405,,405,,,,405',
     526'146,405,405,,,,405,405,405,405,405,405,405,271,271,271,271,271,271,',
     527'271,,,,271,278,271,271,,,,271,271,271,271,271,271,271,,266,266,266,266',
     528'266,266,,266,,,,266,397,266,266,,,,266,266,266,266,266,266,266,80,80',
     529'80,80,80,80,,80,,,,80,,80,80,80,,405,80,80,80,80,80,80,80,406,406,406',
     530'406,406,406,406,406,,,,406,,406,406,,,271,406,406,406,406,406,406,406',
     531',265,265,265,265,265,265,,265,,,,265,,265,265,,,266,265,265,265,265',
     532'265,265,265,,,80,,,85,85,85,85,85,85,,85,,85,,85,80,85,85,,,,85,85,85',
     533'85,85,85,85,264,264,264,264,264,264,,264,,,,264,406,264,264,,,,264,264',
     534'264,264,264,264,264,,263,263,263,263,263,263,,263,,,,263,265,263,263',
     535',,,263,263,263,263,263,263,263,262,262,262,262,262,262,,262,,,,262,',
     536'262,262,,,85,262,262,262,262,262,262,262,261,261,261,261,261,261,,261',
     537',,,261,,261,261,,,264,261,261,261,261,261,261,261,,260,260,260,260,260',
     538'260,,260,,,,260,,260,260,,,263,260,260,260,260,260,260,260,259,259,259',
     539'259,259,259,,259,,,,259,,259,259,,,262,259,259,259,259,259,259,259,258',
     540'258,258,258,258,258,,258,,,,258,,258,258,,,261,258,258,258,258,258,258',
     541'258,,257,257,257,257,257,257,,257,,,,257,,257,257,,,260,257,257,257',
     542'257,257,257,257,256,256,256,256,256,256,,256,,,,256,,256,256,,,259,256',
     543'256,256,256,256,256,256,255,255,255,255,255,255,,255,,,,255,,255,255',
     544',,258,255,255,255,255,255,255,255,,254,254,254,254,254,254,,254,,,,254',
     545',254,254,,,257,254,254,254,254,254,254,254,253,253,253,253,253,253,',
     546'253,,,,253,,253,253,,,256,253,253,253,253,253,253,253,252,252,252,252',
     547'252,252,,252,,,,252,,252,252,,,255,252,252,252,252,252,252,252,,251',
     548'251,251,251,251,251,,251,,,,251,,251,251,,,254,251,251,251,251,251,251',
     549'251,250,250,250,250,250,250,,250,,,,250,,250,250,,,253,250,250,250,250',
     550'250,250,250,389,389,389,389,389,389,,389,,,,389,,389,389,389,,252,389',
     551'389,389,389,389,389,389,,248,248,248,248,248,248,,248,,,,248,,248,248',
     552',,251,248,248,248,248,248,248,248,,,,,,,,,,,,,,,,,,250,,,,,,,,,,389',
     553',,117,117,117,117,117,117,,117,,,,117,389,117,117,,,,117,117,117,117',
     554'117,117,117,,236,236,236,236,236,236,,236,,,,236,248,236,236,,,,236',
     555'236,236,236,236,236,236,,,,,,,117,117,117,117,117,117,117,117,117,117',
     556'117,117,117,117,117,117,117,,,121,121,121,121,121,121,,121,,,,121,,121',
     557'121,,,117,121,121,121,121,121,121,121,,122,122,122,122,122,122,,122',
     558',,,122,,122,122,,,236,122,122,122,122,122,122,122,123,123,123,123,123',
     559'123,,123,,,,123,,123,123,,,,123,123,123,123,123,123,123,124,124,124',
     560'124,124,124,,124,,,,124,,124,124,,,121,124,124,124,124,124,124,124,',
     561',,,,,,,,,,,233,233,233,233,233,233,122,233,,,,233,,233,233,,,,233,233',
     562'233,233,233,233,233,223,223,223,223,223,223,123,223,,,,223,,223,223',
     563',,,223,223,223,223,223,223,223,,,,,,,124,233,233,233,233,233,233,233',
     564'233,233,233,233,233,233,233,233,233,233,,,231,231,231,231,231,231,,231',
     565',,,231,,231,231,,,233,231,231,231,231,231,231,231,224,224,224,224,224',
     566'224,224,224,,,,224,,224,224,,,223,224,224,224,224,224,224,224,,,,,,',
     567',231,231,231,231,231,231,231,231,231,231,231,231,231,231,231,231,231',
     568',,213,213,213,213,213,213,,213,,,,213,,213,213,,,231,213,213,213,213',
     569'213,213,213,210,210,210,210,210,210,,210,,,,210,,210,210,,,224,210,210',
     570'210,210,210,210,210,180,180,180,180,180,180,,180,,,,180,,180,180,,,',
     571'180,180,180,180,180,180,180,,407,407,407,407,407,407,407,407,,,,407',
     572',407,407,,,213,407,407,407,407,407,407,407,,180,,,,435,435,435,435,435',
     573'435,,435,,,,435,210,435,435,435,435,,435,435,435,435,435,435,435,164',
     574'164,164,164,164,164,,164,,,,164,180,164,164,,,,164,164,164,164,164,164',
     575'164,,279,279,279,279,279,279,,279,,,,279,407,279,279,,,,279,279,279',
     576'279,279,279,279,,,435,,,,,,,,,,,,,,41,435,,,,,,,,,,,,,,,,,,,,,,,,,164',
     577',,2,,,,,,,,,,,,,,,,,,,,,,,279,41,41,41,41,41,41,41,41,41,41,41,41,41',
     578'41,41,41,41,41,41,41,41,41,41,41,41,41,,,41,2,2,2,2,2,2,2,2,2,2,2,2',
     579'2,2,2,2,2,2,2,2,2,2,2,2,2,2,,2,2,294,294,,294,,,294,,,,,,,,,294,,,,',
     580',,,,,325,325,,325,,,,,,,,,,,,325,,,,,,,,294,294,294,294,294,294,294',
     581'294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294,294',
     582'294,325,325,325,325,325,325,325,325,325,325,325,325,325,325,325,325',
     583'325,325,325,325,325,325,325,325,325,86,,,,,86,,,,,,,,,,,,,,,,,,,,378',
     584',,,,,,,,,,,,,,,,,,,,,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86,86',
     585'86,86,86,86,86,86,86,86,86,378,378,378,378,378,378,378,378,378,378,378',
     586'378,378,378,378,378,378,378,378,378,378,378,378,378,378,292,7,7,7,7',
     587'7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,,,,,,96,,,,,,,,,,,,292,292',
     588'292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,292,292',
     589'292,292,292,292,292,292,96,96,96,96,96,96,96,96,96,96,96,96,96,96,96',
     590'96,96,96,96,96,96,96,96,96,96,202,,,,,,,,,,,,,,,,,,,,,,,,,299,,,,,,',
     591',,,,,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202,202',
     592'202,202,202,202,202,202,202,202,202,299,299,299,299,299,299,299,299',
     593'299,299,299,299,299,299,299,299,299,299,299,299,299,299,299,299,299',
     594'199,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92,92',
     595'92,92,92,,,,,,,,,,,,199,199,199,199,199,199,199,199,199,199,199,199',
     596'199,199,199,199,199,199,199,199,199,199,199,199,199,8,8,8,8,8,8,8,8',
     597'8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,196,196,196,196,196,196,196,196,196',
     598'196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,196,6,6',
     599'6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5',
     600'5,5,5,5,5,5,5,5,5,5,5,5,5,5,93,93,93,93,93,93,93,93,93,93,93,93,93,93',
     601'93,93,93,93,93,93,93,93,93,93,93,69,69,69,69,69,69,69,69,69,69,69,69',
     602'69,69,69,69,69,69,69,69,69,69,69,69,69' ]
     603        racc_action_check = arr = ::Array.new(3198, nil)
    565604        idx = 0
    566605        clist.each do |str|
     
    572611
    573612racc_action_pointer = [
    574    nil,   150,   420,   404,   652,  2412,  2762,  2744,   nil,   nil,
    575    nil,   nil,   346,   nil,   323,   nil,   nil,   nil,   nil,   nil,
    576    nil,   nil,   337,   nil,    -5,   nil,    -7,   nil,   nil,   nil,
    577    nil,   nil,   366,   nil,   nil,   nil,   nil,   nil,  1848,   nil,
    578    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    18,   nil,
    579     23,   162,   188,   nil,   534,    -8,   nil,   nil,   nil,   nil,
    580    nil,   nil,   nil,   232,   227,   nil,   204,  2674,   nil,   233,
    581    124,   nil,   387,  2814,   653,   nil,   651,  1303,   nil,   nil,
    582    205,   nil,  1363,  2342,   124,    72,   nil,   nil,  2604,  2552,
    583     22,   543,  2482,   nil,   533,    21,   nil,   537,   563,   nil,
    584    nil,    88,   nil,   nil,   533,   474,   nil,   nil,   nil,   nil,
    585    nil,   542,  1866,   nil,     2,   581,  1972,  1995,  2027,  2050,
    586    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   275,   322,
    587    414,   685,    45,   480,   461,   458,   456,   351,   nil,   nil,
    588    nil,  2073,   485,   nil,   477,  1749,   470,   nil,   467,   nil,
    589    445,   nil,   235,   nil,   nil,  2534,   411,   409,  2622,   nil,
    590    532,  2692,   nil,   nil,   nil,   nil,    74,   nil,   nil,   nil,
    591    436,   608,    51,   nil,   655,   435,   nil,   419,   412,   nil,
    592    206,   138,   401,  1386,   393,   383,   nil,   nil,   nil,    51,
    593    nil,   890,   nil,   nil,   161,   184,   356,   379,   482,   821,
    594    922,  1464,  1487,  1570,  1639,  1694,  1717,  1926,  1949,  1593,
    595     -2,    21,  1616,    -7,   nil,   506,   nil,     4,   745,   nil,
     613   nil,   732,  2528,   716,   182,  3068,  3043,  2752,  2993,   nil,
    596614   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    597    nil,   515,   517,  2177,   518,   519,   488,  2137,   491,   nil,
    598    529,   503,   507,  2096,   509,   nil,   nil,  2394,   204,  2271,
    599    nil,   nil,   217,  1843,  2464,   nil,   nil,   nil,   nil,   108,
    600    nil,   nil,   nil,   nil,   536,   nil,   nil,   nil,   nil,   nil,
    601    nil,  1671,   nil,   145,  2253,   184,   nil,  1533,   581,   nil,
    602    nil,   586,   nil,   nil,   nil,   273,   224,    91,   105,   144,
    603    225,   250,   269,   724,   681,   287,   579,   -20,    -5,    -4,
    604     10,   nil,  1510,    72,  1432,   nil,   nil,   nil,   nil,   nil,
    605    nil,   nil,   nil,   nil,   nil,   nil,  1409,  1326,    82,  1280,
    606   1257,  1069,   133,   975,   153,   nil,   nil,   155,   nil,   nil,
    607    216,   nil,    22,   222,   nil,   235,   945,  2324,   nil,   260,
    608    nil,   nil,   234,   nil,   nil,   nil,   867,   106,   nil,   nil,
    609    844,   nil,   nil,   nil,   253,   294,   310,   315,   283,   319,
    610    nil,   727,   nil,   nil,   nil,   329,   nil,   nil,   nil,   334,
    611    nil,   339,   nil,   nil,   nil,   nil,   nil,   nil,   633,   514,
    612    333,   310,   296,   nil,   nil,   nil,   nil,   303,   nil,   362,
    613    332,   nil,   216,   350,   115,   nil,   nil,   385,  1163,   nil ]
     615   nil,   nil,   nil,   624,   nil,   619,   nil,   656,   nil,    38,
     616   nil,    40,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     617   nil,  2499,   nil,   nil,   nil,   nil,   nil,   510,   nil,    78,
     618   nil,    37,     3,   322,   nil,   680,   -14,   nil,   nil,   nil,
     619   nil,   nil,   nil,   nil,   nil,    20,   183,   nil,   249,  3118,
     620   nil,   278,   429,   421,   nil,   252,   344,   664,   nil,   544,
     621  1392,   nil,   419,   285,   nil,  1473,  2701,   266,    28,   nil,
     622   nil,   nil,  2932,  3093,   214,   193,  2819,   nil,   138,   576,
     623   nil,   200,   654,    22,   nil,   nil,    12,   nil,   nil,    15,
     624     1,   nil,   nil,   nil,   nil,   nil,   137,  1959,   nil,   nil,
     625    55,  2035,  2061,  2086,  2111,   nil,   nil,   nil,   nil,   nil,
     626   nil,   568,   nil,   306,   629,   495,   326,   318,   571,   -20,
     627   672,   673,    64,   nil,   nil,   nil,  1235,   724,   nil,   702,
     628   nil,    22,   682,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     629   nil,   nil,   nil,   672,  2431,   669,   nil,   161,   nil,   nil,
     630   nil,   nil,   702,   691,   685,   376,   635,   612,   546,   542,
     631  2350,   nil,   nil,   nil,   547,   nil,   545,   281,   nil,   507,
     632   nil,   684,   nil,   nil,   nil,   nil,  3018,   451,   447,  2968,
     633   nil,   440,  2881,   nil,   nil,   nil,   nil,    44,   nil,   410,
     634  2325,   nil,    61,  2300,   343,   368,   nil,   286,   381,   nil,
     635   348,   322,   147,  2173,  2249,   189,   160,   139,   nil,   nil,
     636   nil,  2224,   nil,  2148,   nil,   nil,  1985,   nil,   nil,   nil,
     637   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,  1904,   779,
     638  1853,  1828,  1802,  1777,  1752,  1726,  1701,  1676,  1650,  1625,
     639  1600,  1574,  1549,  1524,  1498,  1443,  1367,   223,   nil,   300,
     640   nil,  1341,   nil,   514,   385,   659,   nil,   nil,  1260,  2457,
     641  1210,   619,  1132,   379,   nil,   nil,    45,   nil,   nil,   nil,
     642   nil,   325,  2794,    -1,  2604,   nil,   nil,   183,  1090,  2906,
     643   nil,   nil,   nil,   nil,   107,   nil,   nil,   nil,   nil,   149,
     644  1065,   nil,   nil,   nil,   nil,   nil,   137,   nil,    82,   nil,
     645   nil,   nil,  1034,   nil,    68,  2629,    23,   nil,    65,   nil,
     646  1009,   nil,   nil,   167,   186,   nil,   nil,   nil,   nil,   170,
     647   131,   621,   567,   559,   557,   520,   503,   417,   423,   464,
     648   334,   326,   350,   351,    14,   nil,   984,   421,   nil,   nil,
     649   754,   nil,   129,   376,   256,   451,   908,   883,   nil,   nil,
     650   nil,   510,   nil,   260,   520,   nil,   539,   855,  2726,   nil,
     651   556,   nil,   nil,   807,   683,   nil,   nil,   nil,   nil,  1878,
     652   nil,   nil,   nil,   950,   180,   629,   631,  1286,   nil,   nil,
     653   nil,   nil,   634,   653,   539,  1316,  1417,  2376,   687,   nil,
     654   nil,   nil,   689,   nil,   693,   nil,   649,   nil,   318,   nil,
     655   nil,   nil,   622,   nil,   nil,   412,   323,   281,   128,   256,
     656   nil,   nil,   nil,   nil,   nil,  2406,   118,   666,    23,   nil,
     657    -2,   nil,   nil,   nil,   nil,   nil,   nil ]
    614658
    615659racc_action_default = [
    616   -176,  -243,    -1,  -243,  -243,   -70,   -71,   -72,   -80,   -81,
    617    -82,   -83,   -84,   -85,   -86,   -87,   -88,   -89,   -90,   -91,
    618    -92,   -93,   -96,   -99,  -243,  -116,  -243,  -129,  -134,  -135,
    619   -177,  -178,  -243,  -180,  -181,  -184,  -185,  -186,  -243,  -232,
    620   -233,  -234,  -235,  -236,  -237,  -238,  -239,   400,  -243,   -76,
    621    -78,  -243,  -137,  -139,  -243,  -145,   -73,   -84,   -86,   -74,
    622    -75,  -183,  -182,   -98,  -243,  -102,  -115,  -243,  -119,  -243,
    623   -128,  -179,  -106,  -108,  -243,   -69,  -243,  -243,  -190,  -191,
    624   -136,  -138,  -243,  -243,  -243,  -146,  -147,   -94,  -243,  -243,
    625    -84,   -85,  -243,  -117,  -243,  -243,  -130,  -132,  -243,  -107,
    626   -109,  -243,  -188,   -77,   -78,    -2,    -3,    -4,    -5,    -6,
    627     -7,    -8,  -243,   -10,   -12,   -23,  -243,  -243,  -243,  -243,
    628    -29,   -30,   -31,   -32,   -33,   -34,   -35,   -37,   -41,   -44,
    629    -47,   -52,   -55,   -57,   -59,   -61,   -63,   -65,   -68,   -79,
    630   -170,  -243,  -243,  -240,  -243,  -243,  -243,  -142,  -243,  -144,
    631   -149,  -151,  -155,  -140,  -148,  -243,   -84,   -85,  -243,  -100,
    632   -243,  -243,  -122,  -121,  -114,  -118,  -243,  -123,  -125,  -126,
    633   -243,  -243,  -243,  -187,  -243,  -243,   -11,  -243,  -243,   -67,
    634   -156,   -20,  -243,  -243,  -243,  -243,   -18,   -19,   -24,  -243,
    635    -25,  -243,   -27,   -28,  -243,  -243,  -243,  -243,  -243,  -243,
    636   -243,  -243,  -243,  -243,  -243,  -243,  -243,  -243,  -243,  -243,
    637   -243,  -243,  -243,  -243,  -174,  -243,  -241,   -35,  -243,  -192,
    638   -193,  -194,  -195,  -196,  -197,  -198,  -199,  -200,  -201,  -202,
    639   -203,  -243,  -243,  -243,  -243,  -243,  -240,  -243,  -243,  -213,
    640   -243,  -243,  -243,  -243,  -243,  -141,  -143,  -243,  -158,  -243,
    641   -153,  -154,  -159,  -243,  -243,  -105,  -104,   -97,  -101,  -243,
    642   -110,  -112,  -113,  -120,  -243,  -131,  -133,  -127,  -189,  -242,
    643     -9,  -243,  -157,  -158,  -243,  -243,   -21,   -20,  -243,   -16,
    644    -17,  -243,   -38,   -39,   -40,   -42,   -43,   -45,   -46,   -48,
    645    -49,   -50,   -51,   -53,   -54,   -56,   -58,   -60,   -62,   -64,
    646   -243,  -171,  -243,  -243,  -243,  -221,  -222,  -223,  -224,  -225,
    647   -226,  -227,  -228,  -229,  -230,  -231,  -243,  -243,  -243,  -243,
    648   -243,  -243,  -243,  -243,  -243,  -215,  -216,  -243,  -218,  -219,
    649   -243,  -152,  -160,  -243,  -166,  -243,  -243,  -243,  -162,  -243,
    650    -95,  -103,  -243,  -124,   -36,   -13,  -243,  -243,   -15,   -26,
    651   -243,  -172,  -175,  -173,  -243,  -243,  -243,  -243,  -243,  -243,
    652   -210,  -243,  -212,  -214,  -217,  -243,  -161,  -167,  -164,  -243,
    653   -168,  -243,  -163,  -111,   -22,   -14,   -66,  -220,  -243,  -243,
    654   -243,  -243,  -243,  -211,  -150,  -165,  -169,  -204,  -206,  -243,
    655   -243,  -209,  -243,  -243,  -243,  -205,  -207,  -243,  -243,  -208 ]
     660  -215,  -269,    -1,  -269,  -269,   -86,   -88,   -90,   -92,   -98,
     661   -99,  -100,  -101,  -102,  -103,  -104,  -105,  -106,  -107,  -108,
     662  -109,  -110,  -111,  -112,  -113,  -114,  -115,  -118,  -121,  -269,
     663  -139,  -269,  -163,  -164,  -165,  -166,  -167,  -168,  -169,  -216,
     664  -217,  -269,  -219,  -220,  -223,  -224,  -225,  -269,   447,  -269,
     665   -94,   -96,  -269,  -171,  -173,  -269,  -180,   -87,  -112,  -114,
     666   -89,   -91,   -93,  -222,  -221,  -120,  -269,  -124,  -138,  -269,
     667  -142,  -269,  -155,  -158,  -218,  -130,  -132,  -269,   -85,  -269,
     668  -269,  -229,  -269,  -170,  -172,  -269,  -269,  -269,  -181,  -182,
     669  -184,  -116,  -269,  -269,  -112,  -113,  -269,  -140,  -269,  -269,
     670  -159,  -161,  -269,  -269,  -129,  -131,  -269,  -227,   -95,   -96,
     671    -2,    -3,    -4,    -5,    -6,    -7,    -8,  -269,   -10,   -12,
     672   -25,  -269,  -269,  -269,  -269,   -31,   -32,   -33,   -34,   -35,
     673   -36,   -37,   -39,   -43,   -46,   -49,   -54,   -57,   -59,   -61,
     674   -63,   -65,   -67,   -69,   -97,  -209,  -269,  -269,  -265,  -269,
     675   -82,  -269,  -269,  -230,  -231,  -232,  -233,  -234,  -235,  -236,
     676  -237,  -238,  -239,  -265,  -269,  -269,  -243,  -269,  -245,  -247,
     677  -248,  -249,  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -269,
     678  -269,  -268,   -37,   -84,  -269,  -176,  -269,  -269,  -179,  -186,
     679  -188,  -192,  -193,  -174,  -183,  -185,  -269,  -112,  -113,  -269,
     680  -122,  -269,  -269,  -145,  -144,  -137,  -141,  -269,  -146,  -148,
     681  -269,  -151,  -269,  -269,  -269,  -269,  -226,  -269,  -269,   -11,
     682  -269,  -269,  -195,  -269,  -269,  -269,  -269,  -269,   -19,   -20,
     683   -26,  -269,   -27,  -269,   -29,   -30,  -269,   -71,   -72,   -73,
     684   -74,   -75,   -76,   -77,   -78,   -79,   -80,   -81,  -269,  -269,
     685  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -269,
     686  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -213,  -269,
     687  -266,  -269,  -250,  -269,  -269,  -269,  -244,  -246,  -269,  -269,
     688  -269,  -269,  -269,  -269,  -261,  -262,  -269,  -263,  -175,  -177,
     689  -178,  -269,  -269,  -197,  -269,  -190,  -191,  -198,  -269,  -269,
     690  -128,  -127,  -119,  -123,  -269,  -133,  -135,  -136,  -143,  -269,
     691  -269,  -149,  -153,  -160,  -162,  -152,  -269,  -156,  -269,  -228,
     692  -267,    -9,  -269,  -196,  -197,  -269,  -269,   -14,  -269,   -23,
     693  -269,   -17,   -18,  -269,  -269,   -70,   -40,   -41,   -42,   -44,
     694   -45,   -47,   -48,   -50,   -51,   -52,   -53,   -55,   -56,   -58,
     695   -60,   -62,   -64,   -66,  -269,  -210,  -269,  -269,   -83,  -240,
     696  -269,  -242,  -269,  -269,  -269,  -269,  -269,  -269,  -260,  -264,
     697  -194,  -269,  -189,  -199,  -269,  -205,  -269,  -269,  -269,  -201,
     698  -269,  -117,  -125,  -269,  -269,  -147,  -150,  -154,  -157,  -269,
     699   -38,   -13,   -15,  -269,  -269,   -28,  -269,  -269,  -211,  -214,
     700  -212,  -241,  -269,  -269,  -269,  -269,  -269,  -269,  -269,  -200,
     701  -206,  -203,  -269,  -207,  -269,  -202,  -269,  -134,  -269,   -24,
     702   -16,   -68,  -251,  -253,  -254,  -269,  -269,  -269,  -269,  -269,
     703  -187,  -204,  -208,  -126,   -21,  -269,  -269,  -269,  -269,  -256,
     704  -269,  -258,   -22,  -252,  -255,  -257,  -259 ]
    656705
    657706racc_goto_table = [
    658     50,     4,   177,   146,    56,    59,    60,   190,   192,   193,
    659    148,    86,   139,   138,   260,    80,   167,   188,   138,   158,
    660    275,   258,   178,    35,    31,   165,   332,    73,    12,    74,
    661     14,     4,   287,   288,    91,   217,    95,   293,   294,   251,
    662    304,   154,   219,     2,    85,   295,    92,   285,   286,   296,
    663     72,   332,   297,    35,    71,   157,    91,   298,    12,    91,
    664     14,    73,    73,    99,   100,   172,    94,   272,   161,   299,
    665    102,   276,   104,   278,   103,    63,   214,   138,   155,   177,
    666     64,   177,   152,   259,    72,    72,   254,   160,    94,    66,
    667    168,    94,   266,    90,   165,   282,   283,   284,   166,   281,
    668    265,    73,   300,   182,   331,   213,    30,   138,   248,   289,
    669    290,   291,   292,   101,   156,    90,   347,   258,    90,    78,
    670    145,     1,   157,   217,    72,   157,   nil,   nil,    91,   nil,
    671    318,   nil,   nil,   327,   nil,   nil,   273,   nil,   nil,   nil,
    672    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   250,   nil,
    673    nil,   nil,   nil,   nil,   160,   nil,   261,   160,   322,   nil,
    674     94,   nil,   nil,   nil,   nil,   nil,   nil,   276,   nil,   nil,
    675    268,   nil,   344,   138,   339,   nil,   nil,   nil,    73,   nil,
    676    nil,   156,   nil,   nil,   156,   nil,   343,    90,   nil,   138,
    677    nil,   nil,   nil,   nil,   354,   nil,   373,   nil,   nil,   nil,
    678    nil,    72,   nil,   nil,   nil,   248,   355,   356,   nil,   358,
    679    359,   217,    80,   217,   104,   nil,   nil,   nil,   360,   nil,
    680    362,   157,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    681    273,   nil,   nil,   nil,   nil,   nil,   374,   352,   138,   nil,
    682    nil,   nil,   nil,   nil,   nil,   nil,   152,   nil,   152,   nil,
    683    nil,   217,   nil,   160,   nil,   nil,   nil,   369,   383,   nil,
    684    168,   nil,   nil,   nil,   371,   nil,   nil,   nil,   217,   217,
    685    389,   390,   138,   152,   nil,   387,   388,   nil,   nil,   nil,
    686    156,   nil,   217,   nil,   397,   nil,   376,   nil,   217,   395,
    687    nil,   nil,   nil,   nil,   nil,   399,   nil,   nil,   nil,   nil,
     707    51,   144,   145,    81,   183,   182,   184,   281,   186,    23,
     708   267,    95,   208,    83,   206,   305,   303,   313,   328,   169,
     709    25,     4,   199,   230,    57,    60,    61,    62,    75,    89,
     710    40,    99,   168,   221,   198,    95,   296,    77,    95,   220,
     711   373,   182,   232,   234,   235,    65,    96,   207,    23,    76,
     712   304,   366,   343,   344,   345,   346,    75,    75,    90,    25,
     713     4,   194,   214,   215,    66,   104,   105,   323,   145,    74,
     714   202,   373,   196,   107,    68,   109,    94,    76,    76,   347,
     715   348,   339,   340,   183,   182,   274,   341,   342,    98,   108,
     716   195,   236,   187,    88,   209,   372,   353,   352,    75,   197,
     717    94,   152,   286,    94,   169,   359,    39,   361,   351,   106,
     718   350,   201,    98,   349,     2,    98,   303,   277,   167,    76,
     719   206,   313,   225,   313,   394,     1,   299,   nil,   nil,   183,
     720   182,   311,   183,   182,   314,   406,   407,   nil,   198,   nil,
     721   nil,   198,   nil,   nil,    95,   326,   329,   333,   109,   334,
     722   336,   337,   338,   220,   nil,   220,   nil,   nil,   335,   nil,
     723   nil,   nil,   nil,   nil,   293,   nil,   nil,   nil,   182,   182,
     724   182,   182,   182,   182,   182,   182,   182,   182,   182,   182,
     725   182,   182,   182,   182,   182,   182,   152,   295,   354,   nil,
     726   nil,   nil,   401,   358,   nil,   324,   nil,   306,   417,   nil,
     727   362,   363,   364,   197,   nil,   nil,   197,   nil,   nil,    94,
     728   nil,   nil,    75,   319,    75,   201,   nil,   nil,   201,   367,
     729   380,    98,   nil,   385,   390,   nil,   nil,   nil,   nil,   183,
     730   182,   386,   nil,    76,   422,    76,   424,   nil,   nil,   nil,
     731   nil,   198,   182,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     732   nil,   nil,   329,   418,    83,   nil,   nil,   nil,   nil,   439,
     733   nil,   441,   nil,   nil,   nil,   nil,   nil,   293,   443,   nil,
     734   445,   nil,   446,   nil,   nil,   nil,   nil,   399,   145,   nil,
     735   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     736   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   324,   412,
     737   414,   152,   183,   182,   416,   209,   197,   nil,   nil,   nil,
     738   nil,   145,   nil,   nil,   nil,   419,   421,   182,   201,   nil,
     739   nil,   nil,   nil,   nil,   nil,   nil,   nil,   425,   426,   428,
    688740   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    689741   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    690    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    691    nil,   nil,   nil,   nil,   nil,   nil,   152,   nil,   261 ]
    692 
    693 racc_goto_check = [
    694     32,    27,     6,    25,    27,    27,    27,    10,    10,    10,
    695     57,    55,    33,    24,    45,    56,    51,    12,    24,    39,
    696      8,    42,    13,    26,    64,    49,    61,     9,    34,    44,
    697     36,    27,    15,    15,    35,    10,    53,    17,    17,    60,
    698     79,    55,    70,     2,     9,    18,    48,    14,    14,    19,
    699     30,    61,    20,    26,    64,    35,    35,    21,    34,    35,
    700     36,     9,     9,    44,    44,    53,    27,    60,    48,    22,
    701     32,     6,    32,     6,    31,    38,    33,    24,    40,     6,
    702     41,     6,    27,    43,    30,    30,    39,    27,    27,    47,
    703     32,    27,    25,    34,    49,    12,    12,    12,    50,    13,
    704     54,     9,     6,     9,    59,    62,    63,    24,    55,    16,
    705     16,    16,    16,    67,    34,    34,     8,    42,    34,    68,
    706     69,     1,    35,    10,    30,    35,   nil,   nil,    35,   nil,
    707     70,   nil,   nil,     6,   nil,   nil,    55,   nil,   nil,   nil,
    708    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    32,   nil,
    709    nil,   nil,   nil,   nil,    27,   nil,    32,    27,    25,   nil,
    710     27,   nil,   nil,   nil,   nil,   nil,   nil,     6,   nil,   nil,
    711     32,   nil,    12,    24,    25,   nil,   nil,   nil,     9,   nil,
    712    nil,    34,   nil,   nil,    34,   nil,    51,    34,   nil,    24,
    713    nil,   nil,   nil,   nil,     6,   nil,    45,   nil,   nil,   nil,
    714    nil,    30,   nil,   nil,   nil,    55,     6,     6,   nil,     6,
    715      6,    10,    56,    10,    32,   nil,   nil,   nil,    70,   nil,
    716     70,    35,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    717     55,   nil,   nil,   nil,   nil,   nil,     6,    33,    24,   nil,
    718    nil,   nil,   nil,   nil,   nil,   nil,    27,   nil,    27,   nil,
    719    nil,    10,   nil,    27,   nil,   nil,   nil,    25,    70,   nil,
    720     32,   nil,   nil,   nil,    57,   nil,   nil,   nil,    10,    10,
    721      6,     6,    24,    27,   nil,    70,    70,   nil,   nil,   nil,
    722     34,   nil,    10,   nil,     6,   nil,    24,   nil,    10,    70,
    723    nil,   nil,   nil,   nil,   nil,    70,   nil,   nil,   nil,   nil,
     742   nil,   nil,   nil,   nil,   nil,   423,   399,   145,   nil,   nil,
    724743   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    725744   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     745   306 ]
     746
     747racc_goto_check = [
     748    36,    37,    12,    72,    26,    13,    28,    73,    60,    38,
     749    11,    39,    55,    59,    53,    49,    46,    57,     8,    29,
     750    40,    30,    43,    15,    30,    30,    30,    30,    33,    58,
     751    68,    56,    84,    10,    39,    39,    65,    48,    39,     6,
     752    66,    13,    13,    13,    13,    42,    52,    54,    38,     9,
     753    47,    75,    18,    18,    18,    18,    33,    33,     9,    40,
     754    30,    58,    56,    56,    45,    48,    48,    65,    12,    68,
     755    52,    66,    44,    36,    51,    36,    38,     9,     9,    19,
     756    19,    16,    16,    26,    13,    28,    17,    17,    30,    35,
     757     9,    27,    61,    62,    36,    64,    24,    23,    33,    38,
     758    38,    30,     6,    38,    29,    73,    67,    73,    22,    71,
     759    21,    30,    30,    20,     2,    30,    46,    84,    83,     9,
     760    53,    57,     9,    57,     8,     1,    43,   nil,   nil,    26,
     761    13,    28,    26,    13,    28,    75,    75,   nil,    39,   nil,
     762   nil,    39,   nil,   nil,    39,     6,    12,    10,    36,    10,
     763    15,    15,    15,     6,   nil,     6,   nil,   nil,    12,   nil,
     764   nil,   nil,   nil,   nil,    58,   nil,   nil,   nil,    13,    13,
     765    13,    13,    13,    13,    13,    13,    13,    13,    13,    13,
     766    13,    13,    13,    13,    13,    13,    30,    36,     6,   nil,
     767   nil,   nil,    73,    12,   nil,    58,   nil,    36,    49,   nil,
     768     6,     6,     6,    38,   nil,   nil,    38,   nil,   nil,    38,
     769   nil,   nil,    33,    36,    33,    30,   nil,   nil,    30,    29,
     770    12,    30,   nil,    55,    15,   nil,   nil,   nil,   nil,    26,
     771    13,    28,   nil,     9,    73,     9,    73,   nil,   nil,   nil,
     772   nil,    39,    13,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     773   nil,   nil,    12,    11,    59,   nil,   nil,   nil,   nil,    73,
     774   nil,    73,   nil,   nil,   nil,   nil,   nil,    58,    73,   nil,
     775    73,   nil,    73,   nil,   nil,   nil,   nil,    37,    12,   nil,
    726776   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    727    nil,   nil,   nil,   nil,   nil,   nil,    27,   nil,    32 ]
     777   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    58,    12,
     778    60,    30,    26,    13,    28,    36,    38,   nil,   nil,   nil,
     779   nil,    12,   nil,   nil,   nil,    12,    26,    13,    30,   nil,
     780   nil,   nil,   nil,   nil,   nil,   nil,   nil,     6,     6,     6,
     781   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     782   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     783   nil,   nil,   nil,   nil,   nil,    72,    37,    12,   nil,   nil,
     784   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     785   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     786    36 ]
    728787
    729788racc_goto_pointer = [
    730    nil,   121,    43,   nil,   nil,   nil,  -110,   nil,  -161,   -11,
    731   -110,   nil,   -99,   -90,  -150,  -167,   -92,  -168,  -162,  -159,
    732   -157,  -153,  -142,   nil,   -64,   -79,    21,    -1,   nil,   nil,
    733     12,    -2,    -4,   -65,    26,   -33,    28,   nil,    53,   -69,
    734     -9,    58,  -137,   -77,    -9,  -146,   nil,    65,   -21,   -67,
    735      4,   -78,   nil,   -33,   -70,   -44,   -36,   -73,   nil,  -143,
    736   -113,  -222,   -36,   104,    22,   nil,   nil,    39,    69,    41,
    737   -103,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,  -177 ]
     789   nil,   125,   114,   nil,   nil,   nil,   -78,   nil,  -206,     2,
     790   -84,  -136,   -78,   -80,   nil,   -98,  -170,  -167,  -203,  -180,
     791  -148,  -152,  -155,  -167,  -169,   nil,   -81,   -40,   -79,   -63,
     792    19,   nil,   nil,   -19,   nil,    10,    -4,   -79,     7,   -58,
     793    18,   nil,    18,   -70,   -19,    37,  -183,  -151,   -10,  -186,
     794   nil,    45,   -23,   -82,   -51,   -86,   -40,  -195,   -27,   -39,
     795   -78,     6,    37,   nil,  -197,  -155,  -253,   104,    28,   nil,
     796   nil,    32,   -48,  -168,   nil,  -231,   nil,   nil,   nil,   nil,
     797   nil,   nil,   nil,    36,   -50 ]
    738798
    739799racc_goto_default = [
    740    nil,   nil,   nil,   114,   105,   111,   244,   115,   nil,     7,
    741    126,   116,   127,   nil,   128,   129,   130,   131,   132,   133,
    742    134,   135,   136,   137,   179,   140,   220,   218,    48,     5,
    743      6,    49,    84,   nil,    57,    13,    58,    22,   nil,   nil,
    744    nil,   nil,   159,   nil,   180,   nil,    24,   nil,   nil,    93,
    745    nil,   nil,    26,   nil,    96,    51,    52,   335,   150,   151,
    746    333,   252,   nil,   nil,   nil,    33,    34,   nil,   227,   nil,
    747    nil,   221,   222,   223,   224,   225,   226,   228,   229,   nil ]
     800   nil,   nil,   nil,   119,   110,   116,   151,   120,   nil,     7,
     801   nil,   nil,   150,   131,   121,   132,   133,   134,   135,   136,
     802   137,   138,   139,   140,   141,   142,   143,   nil,   nil,    44,
     803   191,    49,     5,     6,     8,    50,    87,   268,    58,    24,
     804    59,    27,   nil,   nil,   nil,   nil,   200,   nil,   222,   nil,
     805    29,   nil,   nil,    97,   nil,   nil,   nil,   100,    52,    53,
     806   376,   nil,   nil,   189,   190,   374,   297,   nil,   nil,    42,
     807    43,   nil,   154,   170,   153,   155,   156,   157,   158,   159,
     808   160,   161,   162,   nil,   nil ]
    748809
    749810racc_reduce_table = [
    750811  0, 0, :racc_error,
    751   1, 97, :_reduce_none,
    752   1, 99, :_reduce_2,
    753   1, 99, :_reduce_3,
    754   1, 99, :_reduce_4,
    755   1, 99, :_reduce_5,
    756   1, 99, :_reduce_6,
    757   1, 99, :_reduce_7,
    758   1, 99, :_reduce_8,
    759   3, 99, :_reduce_9,
    760   1, 101, :_reduce_10,
    761   2, 101, :_reduce_11,
    762   1, 103, :_reduce_none,
    763   4, 103, :_reduce_none,
    764   5, 103, :_reduce_none,
    765   4, 103, :_reduce_15,
    766   3, 103, :_reduce_16,
    767   3, 103, :_reduce_17,
    768   2, 103, :_reduce_18,
    769   2, 103, :_reduce_19,
    770   0, 104, :_reduce_none,
     812  1, 98, :_reduce_none,
     813  1, 100, :_reduce_2,
     814  1, 100, :_reduce_3,
     815  1, 100, :_reduce_4,
     816  1, 100, :_reduce_5,
     817  1, 100, :_reduce_6,
     818  1, 100, :_reduce_7,
     819  1, 100, :_reduce_8,
     820  3, 100, :_reduce_9,
     821  1, 102, :_reduce_10,
     822  2, 102, :_reduce_11,
    771823  1, 104, :_reduce_none,
     824  4, 104, :_reduce_13,
    772825  3, 104, :_reduce_none,
    773   1, 106, :_reduce_none,
    774   2, 106, :_reduce_24,
    775   2, 106, :_reduce_25,
    776   4, 106, :_reduce_26,
    777   2, 106, :_reduce_27,
    778   2, 106, :_reduce_28,
    779   1, 107, :_reduce_29,
    780   1, 107, :_reduce_30,
    781   1, 107, :_reduce_31,
    782   1, 107, :_reduce_32,
    783   1, 107, :_reduce_33,
    784   1, 107, :_reduce_34,
    785   1, 108, :_reduce_none,
    786   4, 108, :_reduce_36,
     826  4, 104, :_reduce_none,
     827  5, 104, :_reduce_none,
     828  3, 104, :_reduce_17,
     829  3, 104, :_reduce_18,
     830  2, 104, :_reduce_19,
     831  2, 104, :_reduce_20,
     832  6, 104, :_reduce_none,
     833  7, 104, :_reduce_none,
     834  1, 105, :_reduce_none,
     835  3, 105, :_reduce_none,
    787836  1, 110, :_reduce_none,
    788   3, 110, :_reduce_38,
    789   3, 110, :_reduce_39,
    790   3, 110, :_reduce_40,
    791   1, 111, :_reduce_none,
    792   3, 111, :_reduce_42,
    793   3, 111, :_reduce_43,
     837  2, 110, :_reduce_26,
     838  2, 110, :_reduce_27,
     839  4, 110, :_reduce_28,
     840  2, 110, :_reduce_29,
     841  2, 110, :_reduce_30,
     842  1, 111, :_reduce_31,
     843  1, 111, :_reduce_32,
     844  1, 111, :_reduce_33,
     845  1, 111, :_reduce_34,
     846  1, 111, :_reduce_35,
     847  1, 111, :_reduce_36,
    794848  1, 112, :_reduce_none,
    795   3, 112, :_reduce_45,
    796   3, 112, :_reduce_46,
     849  4, 112, :_reduce_38,
    797850  1, 113, :_reduce_none,
    798   3, 113, :_reduce_48,
    799   3, 113, :_reduce_49,
    800   3, 113, :_reduce_50,
    801   3, 113, :_reduce_51,
     851  3, 113, :_reduce_40,
     852  3, 113, :_reduce_41,
     853  3, 113, :_reduce_42,
    802854  1, 114, :_reduce_none,
    803   3, 114, :_reduce_53,
    804   3, 114, :_reduce_54,
     855  3, 114, :_reduce_44,
     856  3, 114, :_reduce_45,
    805857  1, 115, :_reduce_none,
    806   3, 115, :_reduce_56,
     858  3, 115, :_reduce_47,
     859  3, 115, :_reduce_48,
    807860  1, 116, :_reduce_none,
    808   3, 116, :_reduce_58,
     861  3, 116, :_reduce_50,
     862  3, 116, :_reduce_51,
     863  3, 116, :_reduce_52,
     864  3, 116, :_reduce_53,
    809865  1, 117, :_reduce_none,
    810   3, 117, :_reduce_60,
     866  3, 117, :_reduce_55,
     867  3, 117, :_reduce_56,
    811868  1, 118, :_reduce_none,
    812   3, 118, :_reduce_62,
     869  3, 118, :_reduce_58,
    813870  1, 119, :_reduce_none,
    814   3, 119, :_reduce_64,
     871  3, 119, :_reduce_60,
    815872  1, 120, :_reduce_none,
    816   5, 120, :_reduce_66,
    817   1, 102, :_reduce_67,
    818   1, 121, :_reduce_68,
    819   3, 122, :_reduce_none,
    820   1, 123, :_reduce_70,
     873  3, 120, :_reduce_62,
     874  1, 121, :_reduce_none,
     875  3, 121, :_reduce_64,
     876  1, 122, :_reduce_none,
     877  3, 122, :_reduce_66,
    821878  1, 123, :_reduce_none,
    822   1, 123, :_reduce_72,
    823   2, 123, :_reduce_73,
    824   2, 123, :_reduce_74,
    825   2, 123, :_reduce_75,
    826   1, 124, :_reduce_76,
    827   3, 124, :_reduce_77,
     879  5, 123, :_reduce_68,
     880  1, 109, :_reduce_none,
     881  3, 109, :_reduce_none,
     882  1, 124, :_reduce_none,
     883  1, 124, :_reduce_none,
     884  1, 124, :_reduce_none,
     885  1, 124, :_reduce_none,
     886  1, 124, :_reduce_none,
     887  1, 124, :_reduce_none,
     888  1, 124, :_reduce_none,
     889  1, 124, :_reduce_none,
     890  1, 124, :_reduce_none,
     891  1, 124, :_reduce_none,
     892  1, 124, :_reduce_none,
     893  1, 103, :_reduce_82,
     894  3, 103, :_reduce_83,
     895  1, 125, :_reduce_84,
     896  3, 126, :_reduce_none,
     897  1, 127, :_reduce_86,
     898  2, 127, :_reduce_87,
    828899  1, 127, :_reduce_none,
    829   3, 127, :_reduce_79,
    830   1, 126, :_reduce_80,
    831   1, 126, :_reduce_81,
    832   1, 126, :_reduce_82,
    833   1, 126, :_reduce_83,
    834   1, 126, :_reduce_84,
    835   1, 126, :_reduce_85,
    836   1, 126, :_reduce_86,
    837   1, 126, :_reduce_87,
    838   1, 126, :_reduce_88,
    839   1, 126, :_reduce_89,
    840   1, 126, :_reduce_90,
    841   1, 126, :_reduce_91,
    842   1, 126, :_reduce_92,
    843   1, 126, :_reduce_93,
    844   0, 136, :_reduce_94,
    845   6, 130, :_reduce_95,
    846   0, 137, :_reduce_96,
    847   5, 130, :_reduce_97,
    848   2, 130, :_reduce_98,
    849   1, 133, :_reduce_99,
    850   1, 135, :_reduce_none,
    851   2, 135, :_reduce_none,
    852   1, 134, :_reduce_102,
    853   3, 138, :_reduce_103,
    854   2, 138, :_reduce_none,
    855   2, 138, :_reduce_none,
     900  2, 127, :_reduce_89,
     901  1, 127, :_reduce_90,
     902  2, 127, :_reduce_91,
     903  1, 127, :_reduce_none,
     904  2, 127, :_reduce_none,
     905  1, 128, :_reduce_94,
     906  3, 128, :_reduce_95,
     907  1, 132, :_reduce_none,
     908  3, 132, :_reduce_97,
     909  1, 129, :_reduce_none,
     910  1, 129, :_reduce_none,
     911  1, 129, :_reduce_none,
     912  1, 129, :_reduce_none,
     913  1, 130, :_reduce_102,
     914  1, 130, :_reduce_103,
     915  1, 130, :_reduce_104,
     916  1, 130, :_reduce_105,
     917  1, 130, :_reduce_106,
     918  1, 130, :_reduce_107,
     919  1, 130, :_reduce_108,
     920  1, 130, :_reduce_109,
     921  1, 130, :_reduce_110,
     922  1, 130, :_reduce_111,
     923  1, 130, :_reduce_112,
     924  1, 130, :_reduce_113,
     925  1, 130, :_reduce_114,
     926  1, 130, :_reduce_115,
     927  0, 141, :_reduce_116,
     928  6, 135, :_reduce_117,
     929  0, 142, :_reduce_118,
     930  5, 135, :_reduce_119,
     931  2, 135, :_reduce_120,
     932  1, 138, :_reduce_121,
    856933  1, 140, :_reduce_none,
    857   2, 140, :_reduce_107,
    858   1, 140, :_reduce_108,
    859   2, 140, :_reduce_109,
    860   1, 139, :_reduce_110,
    861   3, 139, :_reduce_111,
    862   1, 141, :_reduce_none,
    863   5, 131, :_reduce_none,
    864   4, 131, :_reduce_none,
    865   2, 131, :_reduce_none,
    866   1, 142, :_reduce_116,
    867   1, 144, :_reduce_none,
    868   2, 144, :_reduce_none,
    869   1, 143, :_reduce_none,
    870   3, 145, :_reduce_none,
    871   2, 145, :_reduce_none,
    872   2, 145, :_reduce_none,
     934  2, 140, :_reduce_none,
     935  1, 139, :_reduce_124,
     936  3, 143, :_reduce_125,
     937  5, 143, :_reduce_126,
     938  2, 143, :_reduce_none,
     939  2, 143, :_reduce_none,
     940  2, 145, :_reduce_129,
     941  1, 145, :_reduce_none,
     942  2, 145, :_reduce_131,
     943  1, 145, :_reduce_132,
     944  1, 144, :_reduce_133,
     945  3, 144, :_reduce_134,
    873946  1, 146, :_reduce_none,
    874   3, 146, :_reduce_none,
    875   1, 147, :_reduce_none,
    876   4, 132, :_reduce_none,
    877   5, 132, :_reduce_none,
    878   2, 132, :_reduce_none,
    879   1, 148, :_reduce_129,
     947  5, 136, :_reduce_none,
     948  4, 136, :_reduce_none,
     949  2, 136, :_reduce_none,
     950  1, 147, :_reduce_139,
    880951  1, 149, :_reduce_none,
    881   3, 149, :_reduce_none,
    882   1, 150, :_reduce_none,
     952  2, 149, :_reduce_none,
     953  1, 148, :_reduce_none,
    883954  3, 150, :_reduce_none,
    884   1, 105, :_reduce_134,
    885   1, 105, :_reduce_135,
    886   2, 128, :_reduce_136,
    887   1, 128, :_reduce_none,
    888   2, 128, :_reduce_138,
    889   1, 152, :_reduce_139,
    890   3, 152, :_reduce_140,
    891   4, 152, :_reduce_141,
    892   3, 152, :_reduce_142,
    893   4, 152, :_reduce_143,
    894   3, 152, :_reduce_144,
    895   1, 151, :_reduce_145,
    896   2, 151, :_reduce_146,
    897   2, 151, :_reduce_147,
    898   3, 151, :_reduce_148,
     955  2, 150, :_reduce_none,
     956  2, 150, :_reduce_none,
     957  1, 151, :_reduce_none,
     958  3, 151, :_reduce_none,
     959  1, 152, :_reduce_none,
     960  2, 152, :_reduce_none,
     961  3, 152, :_reduce_none,
     962  4, 137, :_reduce_none,
     963  5, 137, :_reduce_none,
     964  5, 137, :_reduce_none,
     965  6, 137, :_reduce_none,
     966  2, 137, :_reduce_none,
     967  5, 137, :_reduce_none,
     968  6, 137, :_reduce_none,
     969  2, 137, :_reduce_none,
    899970  1, 153, :_reduce_none,
    900   5, 153, :_reduce_none,
     971  3, 153, :_reduce_none,
    901972  1, 154, :_reduce_none,
    902973  3, 154, :_reduce_none,
    903   2, 155, :_reduce_none,
    904   2, 155, :_reduce_none,
    905   1, 155, :_reduce_none,
    906   1, 109, :_reduce_none,
    907   2, 109, :_reduce_none,
    908   1, 156, :_reduce_none,
    909   1, 156, :_reduce_none,
    910   2, 156, :_reduce_none,
    911   3, 157, :_reduce_none,
    912   2, 157, :_reduce_none,
    913   3, 157, :_reduce_none,
    914   3, 157, :_reduce_none,
    915   4, 157, :_reduce_none,
    916   2, 157, :_reduce_166,
    917   3, 157, :_reduce_none,
    918   3, 157, :_reduce_168,
    919   4, 157, :_reduce_none,
    920   1, 129, :_reduce_170,
    921   3, 129, :_reduce_171,
    922   4, 129, :_reduce_172,
    923   4, 129, :_reduce_173,
    924   1, 158, :_reduce_174,
    925   3, 158, :_reduce_175,
    926   0, 98, :_reduce_none,
    927   2, 98, :_reduce_none,
     974  1, 106, :_reduce_163,
     975  1, 106, :_reduce_none,
     976  1, 106, :_reduce_165,
     977  1, 131, :_reduce_none,
     978  1, 131, :_reduce_none,
     979  1, 131, :_reduce_none,
     980  1, 131, :_reduce_none,
     981  2, 133, :_reduce_170,
     982  1, 133, :_reduce_none,
     983  2, 133, :_reduce_172,
     984  1, 156, :_reduce_173,
     985  3, 156, :_reduce_174,
     986  4, 156, :_reduce_175,
     987  3, 156, :_reduce_176,
     988  4, 156, :_reduce_177,
     989  4, 156, :_reduce_none,
     990  3, 156, :_reduce_179,
     991  1, 155, :_reduce_180,
     992  2, 155, :_reduce_181,
     993  2, 155, :_reduce_182,
     994  3, 155, :_reduce_183,
    928995  1, 159, :_reduce_none,
    929996  2, 159, :_reduce_none,
     997  1, 157, :_reduce_none,
     998  5, 157, :_reduce_none,
    930999  1, 160, :_reduce_none,
    931   1, 160, :_reduce_none,
    932   2, 160, :_reduce_none,
    933   2, 160, :_reduce_none,
    934   1, 160, :_reduce_none,
    935   1, 160, :_reduce_none,
    936   1, 160, :_reduce_none,
    937   4, 161, :_reduce_187,
    938   1, 163, :_reduce_188,
    939   3, 163, :_reduce_189,
    940   3, 162, :_reduce_none,
    941   0, 165, :_reduce_none,
     1000  3, 160, :_reduce_none,
     1001  2, 161, :_reduce_none,
     1002  2, 161, :_reduce_none,
     1003  1, 161, :_reduce_none,
     1004  1, 158, :_reduce_none,
     1005  3, 158, :_reduce_none,
     1006  1, 107, :_reduce_none,
     1007  2, 107, :_reduce_none,
     1008  1, 162, :_reduce_none,
     1009  1, 162, :_reduce_none,
     1010  2, 162, :_reduce_none,
     1011  3, 163, :_reduce_none,
     1012  2, 163, :_reduce_none,
     1013  3, 163, :_reduce_none,
     1014  3, 163, :_reduce_none,
     1015  4, 163, :_reduce_none,
     1016  2, 163, :_reduce_205,
     1017  3, 163, :_reduce_none,
     1018  3, 163, :_reduce_207,
     1019  4, 163, :_reduce_none,
     1020  1, 134, :_reduce_209,
     1021  3, 134, :_reduce_210,
     1022  4, 134, :_reduce_211,
     1023  4, 134, :_reduce_212,
     1024  1, 108, :_reduce_213,
     1025  3, 108, :_reduce_214,
     1026  0, 99, :_reduce_none,
     1027  2, 99, :_reduce_none,
     1028  1, 164, :_reduce_none,
     1029  2, 164, :_reduce_none,
     1030  1, 165, :_reduce_none,
     1031  1, 165, :_reduce_none,
    9421032  2, 165, :_reduce_none,
    943   1, 166, :_reduce_none,
    944   1, 166, :_reduce_none,
    945   1, 166, :_reduce_none,
    946   1, 166, :_reduce_none,
    947   1, 166, :_reduce_none,
    948   1, 166, :_reduce_none,
    949   1, 166, :_reduce_none,
    950   1, 166, :_reduce_none,
    951   1, 166, :_reduce_none,
    952   1, 166, :_reduce_none,
    953   1, 166, :_reduce_none,
    954   5, 167, :_reduce_none,
    955   7, 167, :_reduce_none,
    956   5, 168, :_reduce_none,
    957   7, 169, :_reduce_none,
    958   9, 170, :_reduce_none,
    959   5, 171, :_reduce_none,
    960   3, 172, :_reduce_none,
    961   4, 172, :_reduce_none,
    962   3, 172, :_reduce_none,
    963   3, 164, :_reduce_none,
    964   3, 173, :_reduce_none,
    965   2, 173, :_reduce_none,
    966   2, 173, :_reduce_none,
    967   3, 173, :_reduce_none,
    968   2, 173, :_reduce_none,
    969   2, 174, :_reduce_none,
    970   4, 174, :_reduce_none,
    971   1, 175, :_reduce_none,
    972   1, 175, :_reduce_none,
    973   1, 175, :_reduce_none,
    974   1, 175, :_reduce_none,
    975   1, 175, :_reduce_none,
    976   1, 175, :_reduce_none,
    977   1, 175, :_reduce_none,
    978   1, 175, :_reduce_none,
    979   1, 175, :_reduce_none,
    980   1, 175, :_reduce_none,
    981   1, 175, :_reduce_none,
    982   1, 125, :_reduce_none,
    983   1, 125, :_reduce_none,
    984   1, 125, :_reduce_none,
    985   1, 125, :_reduce_none,
    986   1, 125, :_reduce_none,
    987   1, 125, :_reduce_none,
    988   1, 125, :_reduce_none,
    989   1, 125, :_reduce_none,
    990   1, 100, :_reduce_240,
    991   2, 100, :_reduce_241,
    992   3, 100, :_reduce_242 ]
    993 
    994 racc_reduce_n = 243
    995 
    996 racc_shift_n = 400
     1033  2, 165, :_reduce_none,
     1034  1, 165, :_reduce_none,
     1035  1, 165, :_reduce_none,
     1036  1, 165, :_reduce_none,
     1037  4, 166, :_reduce_226,
     1038  1, 168, :_reduce_227,
     1039  3, 168, :_reduce_228,
     1040  3, 167, :_reduce_none,
     1041  1, 170, :_reduce_none,
     1042  1, 170, :_reduce_none,
     1043  1, 170, :_reduce_none,
     1044  1, 170, :_reduce_none,
     1045  1, 170, :_reduce_none,
     1046  1, 170, :_reduce_none,
     1047  1, 170, :_reduce_none,
     1048  1, 170, :_reduce_none,
     1049  1, 170, :_reduce_none,
     1050  1, 170, :_reduce_none,
     1051  3, 171, :_reduce_none,
     1052  4, 171, :_reduce_none,
     1053  3, 171, :_reduce_none,
     1054  2, 169, :_reduce_none,
     1055  3, 169, :_reduce_none,
     1056  1, 180, :_reduce_none,
     1057  2, 180, :_reduce_none,
     1058  1, 181, :_reduce_none,
     1059  1, 181, :_reduce_none,
     1060  1, 172, :_reduce_none,
     1061  2, 172, :_reduce_none,
     1062  5, 173, :_reduce_none,
     1063  7, 173, :_reduce_none,
     1064  5, 177, :_reduce_none,
     1065  5, 174, :_reduce_none,
     1066  7, 175, :_reduce_none,
     1067  6, 176, :_reduce_none,
     1068  7, 176, :_reduce_none,
     1069  6, 176, :_reduce_none,
     1070  7, 176, :_reduce_none,
     1071  3, 178, :_reduce_none,
     1072  2, 178, :_reduce_none,
     1073  2, 178, :_reduce_none,
     1074  2, 178, :_reduce_none,
     1075  3, 178, :_reduce_none,
     1076  1, 101, :_reduce_265,
     1077  2, 101, :_reduce_266,
     1078  3, 101, :_reduce_267,
     1079  1, 179, :_reduce_268 ]
     1080
     1081racc_reduce_n = 269
     1082
     1083racc_shift_n = 447
    9971084
    9981085racc_token_table = {
     
    10141101  "++" => 15,
    10151102  "--" => 16,
    1016   "," => 17,
    1017   :SIZEOF => 18,
    1018   "&" => 19,
    1019   "*" => 20,
    1020   "+" => 21,
    1021   "-" => 22,
    1022   "~" => 23,
    1023   "!" => 24,
    1024   "/" => 25,
    1025   "%" => 26,
    1026   "<<" => 27,
    1027   ">>" => 28,
    1028   "<" => 29,
    1029   ">" => 30,
    1030   "<=" => 31,
    1031   ">=" => 32,
    1032   "==" => 33,
    1033   "!=" => 34,
    1034   "^" => 35,
    1035   "|" => 36,
    1036   "&&" => 37,
    1037   "||" => 38,
    1038   "?" => 39,
    1039   ":" => 40,
    1040   ";" => 41,
    1041   "=" => 42,
    1042   :VOID => 43,
    1043   :FLOAT => 44,
    1044   :DOUBLE => 45,
    1045   :BOOL => 46,
    1046   :TYPE_NAME => 47,
    1047   :CHAR => 48,
    1048   :SHORT => 49,
    1049   :INT => 50,
    1050   :LONG => 51,
    1051   :SIGNED => 52,
    1052   :UNSIGNED => 53,
    1053   "{" => 54,
    1054   "}" => 55,
    1055   :STRUCT => 56,
    1056   :UNION => 57,
    1057   :ENUM => 58,
    1058   :CONST => 59,
    1059   :VOLATILE => 60,
    1060   :C_EXP => 61,
    1061   :EXTENSION => 62,
    1062   :TYPEDEF => 63,
    1063   :IF => 64,
    1064   :ELSE => 65,
    1065   :WHILE => 66,
    1066   :DO => 67,
    1067   :FOR => 68,
    1068   :SWITCH => 69,
    1069   :infunc_statment => 70,
    1070   :CASE => 71,
    1071   :DEFAULT => 72,
    1072   :GOTO => 73,
    1073   :CONTINUE => 74,
    1074   :BREAK => 75,
    1075   :RETURN => 76,
    1076   "+=" => 77,
    1077   "-=" => 78,
    1078   "*=" => 79,
    1079   "/=" => 80,
    1080   "%=" => 81,
    1081   "<<=" => 82,
    1082   ">>=" => 83,
    1083   "&=" => 84,
    1084   "|=" => 85,
    1085   "^=" => 86,
    1086   :__INLINE__ => 87,
    1087   :INLINE => 88,
    1088   :__INLINE => 89,
    1089   :CINLINE => 90,
    1090   :EXTERN => 91,
    1091   :STATIC => 92,
    1092   :AUTO => 93,
    1093   :REGISTER => 94,
    1094   "::" => 95 }
    1095 
    1096 racc_nt_base = 96
     1103  "{" => 17,
     1104  "}" => 18,
     1105  "," => 19,
     1106  :SIZEOF => 20,
     1107  "&" => 21,
     1108  "*" => 22,
     1109  "+" => 23,
     1110  "-" => 24,
     1111  "~" => 25,
     1112  "!" => 26,
     1113  "/" => 27,
     1114  "%" => 28,
     1115  "<<" => 29,
     1116  ">>" => 30,
     1117  "<" => 31,
     1118  ">" => 32,
     1119  "<=" => 33,
     1120  ">=" => 34,
     1121  "==" => 35,
     1122  "!=" => 36,
     1123  "^" => 37,
     1124  "|" => 38,
     1125  "&&" => 39,
     1126  "||" => 40,
     1127  "?" => 41,
     1128  ":" => 42,
     1129  "=" => 43,
     1130  "+=" => 44,
     1131  "-=" => 45,
     1132  "*=" => 46,
     1133  "/=" => 47,
     1134  "%=" => 48,
     1135  "<<=" => 49,
     1136  ">>=" => 50,
     1137  "&=" => 51,
     1138  "|=" => 52,
     1139  "^=" => 53,
     1140  ";" => 54,
     1141  :EXTERN => 55,
     1142  :STATIC => 56,
     1143  :AUTO => 57,
     1144  :REGISTER => 58,
     1145  :VOID => 59,
     1146  :CHAR => 60,
     1147  :SHORT => 61,
     1148  :INT => 62,
     1149  :LONG => 63,
     1150  :FLOAT => 64,
     1151  :DOUBLE => 65,
     1152  :SIGNED => 66,
     1153  :UNSIGNED => 67,
     1154  :BOOL => 68,
     1155  :TYPE_NAME => 69,
     1156  :STRUCT => 70,
     1157  :UNION => 71,
     1158  :ENUM => 72,
     1159  :CONST => 73,
     1160  :RESTRICT => 74,
     1161  :VOLATILE => 75,
     1162  :__INLINE__ => 76,
     1163  :INLINE => 77,
     1164  :__INLINE => 78,
     1165  :CINLINE => 79,
     1166  :C_EXP => 80,
     1167  :EXTENSION => 81,
     1168  :TYPEDEF => 82,
     1169  :CASE => 83,
     1170  :DEFAULT => 84,
     1171  :IF => 85,
     1172  :ELSE => 86,
     1173  :SWITCH => 87,
     1174  :WHILE => 88,
     1175  :DO => 89,
     1176  :FOR => 90,
     1177  :GOTO => 91,
     1178  :CONTINUE => 92,
     1179  :BREAK => 93,
     1180  :RETURN => 94,
     1181  "::" => 95,
     1182  :_ASM => 96 }
     1183
     1184racc_nt_base = 97
    10971185
    10981186racc_use_result_var = true
     
    11321220  "\"++\"",
    11331221  "\"--\"",
     1222  "\"{\"",
     1223  "\"}\"",
    11341224  "\",\"",
    11351225  "SIZEOF",
     
    11561246  "\"?\"",
    11571247  "\":\"",
    1158   "\";\"",
    11591248  "\"=\"",
    1160   "VOID",
    1161   "FLOAT",
    1162   "DOUBLE",
    1163   "BOOL",
    1164   "TYPE_NAME",
    1165   "CHAR",
    1166   "SHORT",
    1167   "INT",
    1168   "LONG",
    1169   "SIGNED",
    1170   "UNSIGNED",
    1171   "\"{\"",
    1172   "\"}\"",
    1173   "STRUCT",
    1174   "UNION",
    1175   "ENUM",
    1176   "CONST",
    1177   "VOLATILE",
    1178   "C_EXP",
    1179   "EXTENSION",
    1180   "TYPEDEF",
    1181   "IF",
    1182   "ELSE",
    1183   "WHILE",
    1184   "DO",
    1185   "FOR",
    1186   "SWITCH",
    1187   "infunc_statment",
    1188   "CASE",
    1189   "DEFAULT",
    1190   "GOTO",
    1191   "CONTINUE",
    1192   "BREAK",
    1193   "RETURN",
    11941249  "\"+=\"",
    11951250  "\"-=\"",
     
    12021257  "\"|=\"",
    12031258  "\"^=\"",
     1259  "\";\"",
     1260  "EXTERN",
     1261  "STATIC",
     1262  "AUTO",
     1263  "REGISTER",
     1264  "VOID",
     1265  "CHAR",
     1266  "SHORT",
     1267  "INT",
     1268  "LONG",
     1269  "FLOAT",
     1270  "DOUBLE",
     1271  "SIGNED",
     1272  "UNSIGNED",
     1273  "BOOL",
     1274  "TYPE_NAME",
     1275  "STRUCT",
     1276  "UNION",
     1277  "ENUM",
     1278  "CONST",
     1279  "RESTRICT",
     1280  "VOLATILE",
    12041281  "__INLINE__",
    12051282  "INLINE",
    12061283  "__INLINE",
    12071284  "CINLINE",
    1208   "EXTERN",
    1209   "STATIC",
    1210   "AUTO",
    1211   "REGISTER",
     1285  "C_EXP",
     1286  "EXTENSION",
     1287  "TYPEDEF",
     1288  "CASE",
     1289  "DEFAULT",
     1290  "IF",
     1291  "ELSE",
     1292  "SWITCH",
     1293  "WHILE",
     1294  "DO",
     1295  "FOR",
     1296  "GOTO",
     1297  "CONTINUE",
     1298  "BREAK",
     1299  "RETURN",
    12121300  "\"::\"",
     1301  "_ASM",
    12131302  "$start",
    12141303  "all",
     
    12191308  "expression",
    12201309  "postfix_expression",
    1221   "argument_list",
     1310  "argument_expression_list",
    12221311  "type_qualifier",
     1312  "type_name",
     1313  "initializer_list",
     1314  "assignment_expression",
    12231315  "unary_expression",
    12241316  "unary_operator",
    12251317  "cast_expression",
    1226   "type_name",
    12271318  "multiplicative_expression",
    12281319  "additive_expression",
     
    12361327  "logical_or_expression",
    12371328  "conditional_expression",
     1329  "assignment_operator",
    12381330  "constant_expression",
    12391331  "declaration",
    12401332  "declaration_specifiers",
    12411333  "init_declarator_list",
    1242   "storage_class",
     1334  "storage_class_specifier",
    12431335  "type_specifier",
     1336  "function_specifier",
    12441337  "init_declarator",
    12451338  "declarator",
     
    12551348  "struct_declaration",
    12561349  "struct_declarator_list",
    1257   "type_specifier_qualifier_list",
     1350  "specifier_qualifier_list",
    12581351  "struct_declarator",
    12591352  "union_term",
     
    12631356  "union_declarator_list",
    12641357  "union_declarator",
    1265   "enum_type",
    12661358  "enumerator_list",
    12671359  "enumerator",
     
    12691361  "direct_declarator",
    12701362  "parameter_type_list",
     1363  "identifier_list",
     1364  "type_qualifier_list",
    12711365  "parameter_list",
    12721366  "parameter_declaration",
    12731367  "abstract_declarator",
    12741368  "direct_abstract_declarator",
    1275   "initializer_list",
    12761369  "extension_statement",
    1277   "statement",
     1370  "cdl_statement",
    12781371  "typedef",
    12791372  "func_def",
    12801373  "declarator_list",
    1281   "compoundstatement",
    1282   "infunc_statement_list",
    1283   "infunc_statement",
     1374  "compound_statement",
     1375  "statement",
     1376  "labeled_statement",
     1377  "expression_statement",
    12841378  "ifstatement",
    12851379  "whilestatement",
     
    12871381  "forstatement",
    12881382  "switchstatement",
    1289   "labelstatement",
    1290   "gotostatement",
    1291   "expressionstatement",
    1292   "assignment_operator" ]
     1383  "jump_statement",
     1384  "asm_statement",
     1385  "block_item_list",
     1386  "block_item" ]
    12931387
    12941388Racc_debug_parser = false
     
    13001394# reduce 1 omitted
    13011395
    1302 module_eval(<<'.,.,', 'C_parser.y.rb', 52)
     1396module_eval(<<'.,.,', 'C_parser.y.rb', 57)
    13031397  def _reduce_2(val, _values, result)
    13041398     result = [ :IDENTIFIER, val[0] ]
     
    13071401.,.,
    13081402
    1309 module_eval(<<'.,.,', 'C_parser.y.rb', 60)
     1403module_eval(<<'.,.,', 'C_parser.y.rb', 65)
    13101404  def _reduce_3(val, _values, result)
    13111405     result = [ :INTEGER_CONSTANT, val[0] ]
     
    13141408.,.,
    13151409
    1316 module_eval(<<'.,.,', 'C_parser.y.rb', 62)
     1410module_eval(<<'.,.,', 'C_parser.y.rb', 67)
    13171411  def _reduce_4(val, _values, result)
    13181412     result = [ :FLOATING_CONSTANT, val[0] ]
     
    13211415.,.,
    13221416
    1323 module_eval(<<'.,.,', 'C_parser.y.rb', 64)
     1417module_eval(<<'.,.,', 'C_parser.y.rb', 69)
    13241418  def _reduce_5(val, _values, result)
    13251419     result = [ :OCTAL_CONSTANT, val[0] ]
     
    13281422.,.,
    13291423
    1330 module_eval(<<'.,.,', 'C_parser.y.rb', 66)
     1424module_eval(<<'.,.,', 'C_parser.y.rb', 71)
    13311425  def _reduce_6(val, _values, result)
    13321426     result = [ :HEX_CONSTANT, val[0] ]
     
    13351429.,.,
    13361430
    1337 module_eval(<<'.,.,', 'C_parser.y.rb', 68)
     1431module_eval(<<'.,.,', 'C_parser.y.rb', 73)
    13381432  def _reduce_7(val, _values, result)
    13391433     result = [ :CHARACTER_LITERAL, val[0] ]
     
    13421436.,.,
    13431437
    1344 module_eval(<<'.,.,', 'C_parser.y.rb', 70)
     1438module_eval(<<'.,.,', 'C_parser.y.rb', 75)
    13451439  def _reduce_8(val, _values, result)
    13461440     result = [ :STRING_LITERAL_LIST, val[0] ]
     
    13491443.,.,
    13501444
    1351 module_eval(<<'.,.,', 'C_parser.y.rb', 72)
     1445module_eval(<<'.,.,', 'C_parser.y.rb', 77)
    13521446  def _reduce_9(val, _values, result)
    13531447     result = [ :PARENTHESES, val[1].get_elements ]
     
    13561450.,.,
    13571451
    1358 module_eval(<<'.,.,', 'C_parser.y.rb', 76)
     1452module_eval(<<'.,.,', 'C_parser.y.rb', 81)
    13591453  def _reduce_10(val, _values, result)
    13601454     result = [val[0]]
     
    13631457.,.,
    13641458
    1365 module_eval(<<'.,.,', 'C_parser.y.rb', 78)
     1459module_eval(<<'.,.,', 'C_parser.y.rb', 83)
    13661460  def _reduce_11(val, _values, result)
    13671461     result << val[1]
     
    13721466# reduce 12 omitted
    13731467
    1374 # reduce 13 omitted
     1468module_eval(<<'.,.,', 'C_parser.y.rb', 89)
     1469  def _reduce_13(val, _values, result)
     1470     result = [ :OP_SUBSC, val[0], val[2] ]
     1471    result
     1472  end
     1473.,.,
    13751474
    13761475# reduce 14 omitted
    13771476
    1378 module_eval(<<'.,.,', 'C_parser.y.rb', 86)
    1379   def _reduce_15(val, _values, result)
    1380      result = [ :OP_SUBSC, val[0], val[2] ]
    1381     result
    1382   end
    1383 .,.,
    1384 
    1385 module_eval(<<'.,.,', 'C_parser.y.rb', 88)
    1386   def _reduce_16(val, _values, result)
     1477# reduce 15 omitted
     1478
     1479# reduce 16 omitted
     1480
     1481module_eval(<<'.,.,', 'C_parser.y.rb', 94)
     1482  def _reduce_17(val, _values, result)
    13871483     result = [ :OP_DOT, val[0], val[2] ]
    13881484    result
     
    13901486.,.,
    13911487
    1392 module_eval(<<'.,.,', 'C_parser.y.rb', 90)
    1393   def _reduce_17(val, _values, result)
     1488module_eval(<<'.,.,', 'C_parser.y.rb', 96)
     1489  def _reduce_18(val, _values, result)
    13941490     result = [ :OP_REF, val[0], val[2] ]
    13951491    result
     
    13971493.,.,
    13981494
    1399 module_eval(<<'.,.,', 'C_parser.y.rb', 91)
    1400   def _reduce_18(val, _values, result)
    1401      result = val[0]
    1402     result
    1403   end
    1404 .,.,
    1405 
    1406 module_eval(<<'.,.,', 'C_parser.y.rb', 92)
     1495module_eval(<<'.,.,', 'C_parser.y.rb', 97)
    14071496  def _reduce_19(val, _values, result)
    14081497     result = val[0]
     
    14111500.,.,
    14121501
    1413 # reduce 20 omitted
     1502module_eval(<<'.,.,', 'C_parser.y.rb', 98)
     1503  def _reduce_20(val, _values, result)
     1504     result = val[0]
     1505    result
     1506  end
     1507.,.,
    14141508
    14151509# reduce 21 omitted
     
    14191513# reduce 23 omitted
    14201514
    1421 module_eval(<<'.,.,', 'C_parser.y.rb', 104)
    1422   def _reduce_24(val, _values, result)
     1515# reduce 24 omitted
     1516
     1517# reduce 25 omitted
     1518
     1519module_eval(<<'.,.,', 'C_parser.y.rb', 111)
     1520  def _reduce_26(val, _values, result)
    14231521     result = [ val[0], val[1] ]
    14241522    result
     
    14261524.,.,
    14271525
    1428 module_eval(<<'.,.,', 'C_parser.y.rb', 106)
    1429   def _reduce_25(val, _values, result)
     1526module_eval(<<'.,.,', 'C_parser.y.rb', 113)
     1527  def _reduce_27(val, _values, result)
    14301528     result = [ :OP_SIZEOF_EXPR, val[1] ]
    14311529    result
     
    14331531.,.,
    14341532
    1435 module_eval(<<'.,.,', 'C_parser.y.rb', 108)
    1436   def _reduce_26(val, _values, result)
     1533module_eval(<<'.,.,', 'C_parser.y.rb', 115)
     1534  def _reduce_28(val, _values, result)
    14371535     result = [ :OP_SIZEOF_TYPE, val[1] ]
    14381536    result
     
    14401538.,.,
    14411539
    1442 module_eval(<<'.,.,', 'C_parser.y.rb', 109)
    1443   def _reduce_27(val, _values, result)
     1540module_eval(<<'.,.,', 'C_parser.y.rb', 116)
     1541  def _reduce_29(val, _values, result)
    14441542     result = val[1]
    14451543    result
     
    14471545.,.,
    14481546
    1449 module_eval(<<'.,.,', 'C_parser.y.rb', 110)
    1450   def _reduce_28(val, _values, result)
     1547module_eval(<<'.,.,', 'C_parser.y.rb', 117)
     1548  def _reduce_30(val, _values, result)
    14511549     result = val[1]
    14521550    result
     
    14541552.,.,
    14551553
    1456 module_eval(<<'.,.,', 'C_parser.y.rb', 113)
    1457   def _reduce_29(val, _values, result)
     1554module_eval(<<'.,.,', 'C_parser.y.rb', 120)
     1555  def _reduce_31(val, _values, result)
    14581556     result = :OP_U_AMP
    14591557    result
     
    14611559.,.,
    14621560
    1463 module_eval(<<'.,.,', 'C_parser.y.rb', 114)
    1464   def _reduce_30(val, _values, result)
     1561module_eval(<<'.,.,', 'C_parser.y.rb', 121)
     1562  def _reduce_32(val, _values, result)
    14651563     result = :OP_U_ASTER
    14661564    result
     
    14681566.,.,
    14691567
    1470 module_eval(<<'.,.,', 'C_parser.y.rb', 115)
    1471   def _reduce_31(val, _values, result)
     1568module_eval(<<'.,.,', 'C_parser.y.rb', 122)
     1569  def _reduce_33(val, _values, result)
    14721570     result = :OP_U_PLUS
    14731571    result
     
    14751573.,.,
    14761574
    1477 module_eval(<<'.,.,', 'C_parser.y.rb', 116)
    1478   def _reduce_32(val, _values, result)
     1575module_eval(<<'.,.,', 'C_parser.y.rb', 123)
     1576  def _reduce_34(val, _values, result)
    14791577     result = :OP_U_MINUS
    14801578    result
     
    14821580.,.,
    14831581
    1484 module_eval(<<'.,.,', 'C_parser.y.rb', 117)
    1485   def _reduce_33(val, _values, result)
     1582module_eval(<<'.,.,', 'C_parser.y.rb', 124)
     1583  def _reduce_35(val, _values, result)
    14861584     result = :OP_U_TILDE
    14871585    result
     
    14891587.,.,
    14901588
    1491 module_eval(<<'.,.,', 'C_parser.y.rb', 118)
    1492   def _reduce_34(val, _values, result)
     1589module_eval(<<'.,.,', 'C_parser.y.rb', 125)
     1590  def _reduce_36(val, _values, result)
    14931591     result = :OP_U_EXCLAM
    14941592    result
     
    14961594.,.,
    14971595
    1498 # reduce 35 omitted
    1499 
    1500 module_eval(<<'.,.,', 'C_parser.y.rb', 123)
    1501   def _reduce_36(val, _values, result)
     1596# reduce 37 omitted
     1597
     1598module_eval(<<'.,.,', 'C_parser.y.rb', 130)
     1599  def _reduce_38(val, _values, result)
    15021600      result = [ :CAST, val[1], val[3] ]
    15031601    result
     
    15051603.,.,
    15061604
    1507 # reduce 37 omitted
    1508 
    1509 module_eval(<<'.,.,', 'C_parser.y.rb', 128)
    1510   def _reduce_38(val, _values, result)
     1605# reduce 39 omitted
     1606
     1607module_eval(<<'.,.,', 'C_parser.y.rb', 135)
     1608  def _reduce_40(val, _values, result)
    15111609     result = [ :OP_MULT, val[0], val[2] ] 
    15121610    result
     
    15141612.,.,
    15151613
    1516 module_eval(<<'.,.,', 'C_parser.y.rb', 130)
    1517   def _reduce_39(val, _values, result)
     1614module_eval(<<'.,.,', 'C_parser.y.rb', 137)
     1615  def _reduce_41(val, _values, result)
    15181616     result = [ :OP_DIV, val[0], val[2] ] 
    15191617    result
     
    15211619.,.,
    15221620
    1523 module_eval(<<'.,.,', 'C_parser.y.rb', 132)
    1524   def _reduce_40(val, _values, result)
     1621module_eval(<<'.,.,', 'C_parser.y.rb', 139)
     1622  def _reduce_42(val, _values, result)
    15251623     result = [ :OP_REMAIN, val[0], val[2] ] 
    15261624    result
     
    15281626.,.,
    15291627
    1530 # reduce 41 omitted
    1531 
    1532 module_eval(<<'.,.,', 'C_parser.y.rb', 137)
    1533   def _reduce_42(val, _values, result)
     1628# reduce 43 omitted
     1629
     1630module_eval(<<'.,.,', 'C_parser.y.rb', 144)
     1631  def _reduce_44(val, _values, result)
    15341632     result = [ :OP_ADD, val[0], val[2] ] 
    15351633    result
     
    15371635.,.,
    15381636
    1539 module_eval(<<'.,.,', 'C_parser.y.rb', 139)
    1540   def _reduce_43(val, _values, result)
     1637module_eval(<<'.,.,', 'C_parser.y.rb', 146)
     1638  def _reduce_45(val, _values, result)
    15411639     result = [ :OP_SUB, val[0], val[2] ] 
    15421640    result
     
    15441642.,.,
    15451643
    1546 # reduce 44 omitted
    1547 
    1548 module_eval(<<'.,.,', 'C_parser.y.rb', 144)
    1549   def _reduce_45(val, _values, result)
     1644# reduce 46 omitted
     1645
     1646module_eval(<<'.,.,', 'C_parser.y.rb', 151)
     1647  def _reduce_47(val, _values, result)
    15501648     result = [ :OP_LSFT, val[0], val[2] ] 
    15511649    result
     
    15531651.,.,
    15541652
    1555 module_eval(<<'.,.,', 'C_parser.y.rb', 146)
    1556   def _reduce_46(val, _values, result)
     1653module_eval(<<'.,.,', 'C_parser.y.rb', 153)
     1654  def _reduce_48(val, _values, result)
    15571655     result = [ :OP_RSFT, val[0], val[2] ] 
    15581656    result
     
    15601658.,.,
    15611659
    1562 # reduce 47 omitted
    1563 
    1564 module_eval(<<'.,.,', 'C_parser.y.rb', 151)
    1565   def _reduce_48(val, _values, result)
     1660# reduce 49 omitted
     1661
     1662module_eval(<<'.,.,', 'C_parser.y.rb', 158)
     1663  def _reduce_50(val, _values, result)
    15661664     result = [ :OP_LT, val[0], val[2] ] 
    15671665    result
     
    15691667.,.,
    15701668
    1571 module_eval(<<'.,.,', 'C_parser.y.rb', 153)
    1572   def _reduce_49(val, _values, result)
     1669module_eval(<<'.,.,', 'C_parser.y.rb', 160)
     1670  def _reduce_51(val, _values, result)
    15731671     result = [ :OP_GT, val[0], val[2] ] 
    15741672    result
     
    15761674.,.,
    15771675
    1578 module_eval(<<'.,.,', 'C_parser.y.rb', 155)
    1579   def _reduce_50(val, _values, result)
     1676module_eval(<<'.,.,', 'C_parser.y.rb', 162)
     1677  def _reduce_52(val, _values, result)
    15801678     result = [ :OP_LE, val[0], val[2] ] 
    15811679    result
     
    15831681.,.,
    15841682
    1585 module_eval(<<'.,.,', 'C_parser.y.rb', 157)
    1586   def _reduce_51(val, _values, result)
     1683module_eval(<<'.,.,', 'C_parser.y.rb', 164)
     1684  def _reduce_53(val, _values, result)
    15871685     result = [ :OP_GE, val[0], val[2] ] 
    15881686    result
     
    15901688.,.,
    15911689
    1592 # reduce 52 omitted
    1593 
    1594 module_eval(<<'.,.,', 'C_parser.y.rb', 162)
    1595   def _reduce_53(val, _values, result)
     1690# reduce 54 omitted
     1691
     1692module_eval(<<'.,.,', 'C_parser.y.rb', 169)
     1693  def _reduce_55(val, _values, result)
    15961694     result = [ :OP_EQ, val[0], val[2] ] 
    15971695    result
     
    15991697.,.,
    16001698
    1601 module_eval(<<'.,.,', 'C_parser.y.rb', 164)
    1602   def _reduce_54(val, _values, result)
     1699module_eval(<<'.,.,', 'C_parser.y.rb', 171)
     1700  def _reduce_56(val, _values, result)
    16031701     result = [ :OP_NE, val[0], val[2] ] 
    16041702    result
     
    16061704.,.,
    16071705
    1608 # reduce 55 omitted
    1609 
    1610 module_eval(<<'.,.,', 'C_parser.y.rb', 169)
    1611   def _reduce_56(val, _values, result)
     1706# reduce 57 omitted
     1707
     1708module_eval(<<'.,.,', 'C_parser.y.rb', 176)
     1709  def _reduce_58(val, _values, result)
    16121710     result = [ :OP_AND, val[0], val[2] ] 
    16131711    result
     
    16151713.,.,
    16161714
    1617 # reduce 57 omitted
    1618 
    1619 module_eval(<<'.,.,', 'C_parser.y.rb', 174)
    1620   def _reduce_58(val, _values, result)
     1715# reduce 59 omitted
     1716
     1717module_eval(<<'.,.,', 'C_parser.y.rb', 181)
     1718  def _reduce_60(val, _values, result)
    16211719     result = [ :OP_EOR, val[0], val[2] ] 
    16221720    result
     
    16241722.,.,
    16251723
    1626 # reduce 59 omitted
    1627 
    1628 module_eval(<<'.,.,', 'C_parser.y.rb', 179)
    1629   def _reduce_60(val, _values, result)
     1724# reduce 61 omitted
     1725
     1726module_eval(<<'.,.,', 'C_parser.y.rb', 186)
     1727  def _reduce_62(val, _values, result)
    16301728     result = [ :OP_OR, val[0], val[2] ] 
    16311729    result
     
    16331731.,.,
    16341732
    1635 # reduce 61 omitted
    1636 
    1637 module_eval(<<'.,.,', 'C_parser.y.rb', 184)
    1638   def _reduce_62(val, _values, result)
     1733# reduce 63 omitted
     1734
     1735module_eval(<<'.,.,', 'C_parser.y.rb', 191)
     1736  def _reduce_64(val, _values, result)
    16391737     result = [ :OP_LAND, val[0], val[2] ] 
    16401738    result
     
    16421740.,.,
    16431741
    1644 # reduce 63 omitted
    1645 
    1646 module_eval(<<'.,.,', 'C_parser.y.rb', 189)
    1647   def _reduce_64(val, _values, result)
     1742# reduce 65 omitted
     1743
     1744module_eval(<<'.,.,', 'C_parser.y.rb', 196)
     1745  def _reduce_66(val, _values, result)
    16481746     result = [ :OP_LOR, val[0], val[2] ] 
    16491747    result
     
    16511749.,.,
    16521750
    1653 # reduce 65 omitted
    1654 
    1655 module_eval(<<'.,.,', 'C_parser.y.rb', 194)
    1656   def _reduce_66(val, _values, result)
     1751# reduce 67 omitted
     1752
     1753module_eval(<<'.,.,', 'C_parser.y.rb', 201)
     1754  def _reduce_68(val, _values, result)
    16571755     result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ] 
    16581756    result
     
    16601758.,.,
    16611759
    1662 module_eval(<<'.,.,', 'C_parser.y.rb', 201)
    1663   def _reduce_67(val, _values, result)
     1760# reduce 69 omitted
     1761
     1762# reduce 70 omitted
     1763
     1764# reduce 71 omitted
     1765
     1766# reduce 72 omitted
     1767
     1768# reduce 73 omitted
     1769
     1770# reduce 74 omitted
     1771
     1772# reduce 75 omitted
     1773
     1774# reduce 76 omitted
     1775
     1776# reduce 77 omitted
     1777
     1778# reduce 78 omitted
     1779
     1780# reduce 79 omitted
     1781
     1782# reduce 80 omitted
     1783
     1784# reduce 81 omitted
     1785
     1786module_eval(<<'.,.,', 'C_parser.y.rb', 223)
     1787  def _reduce_82(val, _values, result)
    16641788                        result = Expression.new( val[0] )
    16651789                        # result.print
     
    16691793.,.,
    16701794
    1671 module_eval(<<'.,.,', 'C_parser.y.rb', 208)
    1672   def _reduce_68(val, _values, result)
     1795module_eval(<<'.,.,', 'C_parser.y.rb', 228)
     1796  def _reduce_83(val, _values, result)
     1797                        result = Expression.new( val[2] )    # ',' の後ろを採用
     1798               
     1799    result
     1800  end
     1801.,.,
     1802
     1803module_eval(<<'.,.,', 'C_parser.y.rb', 234)
     1804  def _reduce_84(val, _values, result)
    16731805                        result = Expression.new( val[0] )
    16741806                        # result.print
     
    16851817.,.,
    16861818
    1687 # reduce 69 omitted
    1688 
    1689 module_eval(<<'.,.,', 'C_parser.y.rb', 237)
    1690   def _reduce_70(val, _values, result)
     1819# reduce 85 omitted
     1820
     1821module_eval(<<'.,.,', 'C_parser.y.rb', 261)
     1822  def _reduce_86(val, _values, result)
    16911823                        result = CIntType.new( -3 )    # storage class は無視
    16921824               
     
    16951827.,.,
    16961828
    1697 # reduce 71 omitted
    1698 
    1699 module_eval(<<'.,.,', 'C_parser.y.rb', 242)
    1700   def _reduce_72(val, _values, result)
     1829module_eval(<<'.,.,', 'C_parser.y.rb', 265)
     1830  def _reduce_87(val, _values, result)
     1831                        result = val[1]                # storage class は無視
     1832               
     1833    result
     1834  end
     1835.,.,
     1836
     1837# reduce 88 omitted
     1838
     1839module_eval(<<'.,.,', 'C_parser.y.rb', 270)
     1840  def _reduce_89(val, _values, result)
     1841                        result = val[1].merge val[0]
     1842               
     1843    result
     1844  end
     1845.,.,
     1846
     1847module_eval(<<'.,.,', 'C_parser.y.rb', 274)
     1848  def _reduce_90(val, _values, result)
    17011849                        result = CIntType.new( -3 )
    17021850                        result.set_qualifier val[0]
     
    17061854.,.,
    17071855
    1708 module_eval(<<'.,.,', 'C_parser.y.rb', 247)
    1709   def _reduce_73(val, _values, result)
    1710                         result = val[1]                # storage class は無視
    1711                
    1712     result
    1713   end
    1714 .,.,
    1715 
    1716 module_eval(<<'.,.,', 'C_parser.y.rb', 251)
    1717   def _reduce_74(val, _values, result)
    1718                         result = val[1].merge val[0]
    1719                
    1720     result
    1721   end
    1722 .,.,
    1723 
    1724 module_eval(<<'.,.,', 'C_parser.y.rb', 255)
    1725   def _reduce_75(val, _values, result)
     1856module_eval(<<'.,.,', 'C_parser.y.rb', 279)
     1857  def _reduce_91(val, _values, result)
    17261858                        val[1].set_qualifier val[0]
    1727                         result = val[1]
    1728                
    1729     result
    1730   end
    1731 .,.,
    1732 
    1733 module_eval(<<'.,.,', 'C_parser.y.rb', 262)
    1734   def _reduce_76(val, _values, result)
     1859                                                result = val[1]
     1860               
     1861    result
     1862  end
     1863.,.,
     1864
     1865# reduce 92 omitted
     1866
     1867# reduce 93 omitted
     1868
     1869module_eval(<<'.,.,', 'C_parser.y.rb', 287)
     1870  def _reduce_94(val, _values, result)
    17351871     result = [val[0]]
    17361872    result
     
    17381874.,.,
    17391875
    1740 module_eval(<<'.,.,', 'C_parser.y.rb', 264)
    1741   def _reduce_77(val, _values, result)
     1876module_eval(<<'.,.,', 'C_parser.y.rb', 289)
     1877  def _reduce_95(val, _values, result)
    17421878     result << val[2]
    17431879    result
     
    17451881.,.,
    17461882
    1747 # reduce 78 omitted
    1748 
    1749 module_eval(<<'.,.,', 'C_parser.y.rb', 269)
    1750   def _reduce_79(val, _values, result)
     1883# reduce 96 omitted
     1884
     1885module_eval(<<'.,.,', 'C_parser.y.rb', 294)
     1886  def _reduce_97(val, _values, result)
    17511887     val[0].set_initializer( val[2] )
    17521888    result
     
    17541890.,.,
    17551891
    1756 module_eval(<<'.,.,', 'C_parser.y.rb', 272)
    1757   def _reduce_80(val, _values, result)
     1892# reduce 98 omitted
     1893
     1894# reduce 99 omitted
     1895
     1896# reduce 100 omitted
     1897
     1898# reduce 101 omitted
     1899
     1900module_eval(<<'.,.,', 'C_parser.y.rb', 304)
     1901  def _reduce_102(val, _values, result)
    17581902     set_no_type_name true; result = CVoidType.new
    17591903    result
     
    17611905.,.,
    17621906
    1763 module_eval(<<'.,.,', 'C_parser.y.rb', 273)
    1764   def _reduce_81(val, _values, result)
     1907module_eval(<<'.,.,', 'C_parser.y.rb', 306)
     1908  def _reduce_103(val, _values, result)
     1909     set_no_type_name true; result = CIntType.new(-11 )
     1910    result
     1911  end
     1912.,.,
     1913
     1914module_eval(<<'.,.,', 'C_parser.y.rb', 308)
     1915  def _reduce_104(val, _values, result)
     1916     set_no_type_name true; result = CIntType.new( -2 )
     1917    result
     1918  end
     1919.,.,
     1920
     1921module_eval(<<'.,.,', 'C_parser.y.rb', 310)
     1922  def _reduce_105(val, _values, result)
     1923     set_no_type_name true; result = CIntType.new( -3 )
     1924    result
     1925  end
     1926.,.,
     1927
     1928module_eval(<<'.,.,', 'C_parser.y.rb', 312)
     1929  def _reduce_106(val, _values, result)
     1930     set_no_type_name true; result = CIntType.new( -4 )
     1931    result
     1932  end
     1933.,.,
     1934
     1935module_eval(<<'.,.,', 'C_parser.y.rb', 314)
     1936  def _reduce_107(val, _values, result)
    17651937     set_no_type_name true; result = CFloatType.new(-32)
    17661938    result
     
    17681940.,.,
    17691941
    1770 module_eval(<<'.,.,', 'C_parser.y.rb', 274)
    1771   def _reduce_82(val, _values, result)
     1942module_eval(<<'.,.,', 'C_parser.y.rb', 316)
     1943  def _reduce_108(val, _values, result)
    17721944     set_no_type_name true; result = CFloatType.new(-64)
    17731945    result
     
    17751947.,.,
    17761948
    1777 module_eval(<<'.,.,', 'C_parser.y.rb', 275)
    1778   def _reduce_83(val, _values, result)
    1779      set_no_type_name true; result = CBoolType.new
    1780     result
    1781   end
    1782 .,.,
    1783 
    1784 module_eval(<<'.,.,', 'C_parser.y.rb', 276)
    1785   def _reduce_84(val, _values, result)
    1786      set_no_type_name true; result = val[0]
    1787     result
    1788   end
    1789 .,.,
    1790 
    1791 module_eval(<<'.,.,', 'C_parser.y.rb', 277)
    1792   def _reduce_85(val, _values, result)
    1793      set_no_type_name true; result = CVoidType.new
    1794     result
    1795   end
    1796 .,.,
    1797 
    1798 module_eval(<<'.,.,', 'C_parser.y.rb', 278)
    1799   def _reduce_86(val, _values, result)
    1800      set_no_type_name true; result = CVoidType.new
    1801     result
    1802   end
    1803 .,.,
    1804 
    1805 module_eval(<<'.,.,', 'C_parser.y.rb', 279)
    1806   def _reduce_87(val, _values, result)
    1807      set_no_type_name true; result = CDefinedType.new( val[0].val )
    1808     result
    1809   end
    1810 .,.,
    1811 
    1812 module_eval(<<'.,.,', 'C_parser.y.rb', 281)
    1813   def _reduce_88(val, _values, result)
    1814      set_no_type_name true; result = CIntType.new(-11 )
    1815     result
    1816   end
    1817 .,.,
    1818 
    1819 module_eval(<<'.,.,', 'C_parser.y.rb', 282)
    1820   def _reduce_89(val, _values, result)
    1821      set_no_type_name true; result = CIntType.new( -2 )
    1822     result
    1823   end
    1824 .,.,
    1825 
    1826 module_eval(<<'.,.,', 'C_parser.y.rb', 283)
    1827   def _reduce_90(val, _values, result)
    1828      set_no_type_name true; result = CIntType.new( -3 )
    1829     result
    1830   end
    1831 .,.,
    1832 
    1833 module_eval(<<'.,.,', 'C_parser.y.rb', 284)
    1834   def _reduce_91(val, _values, result)
    1835      set_no_type_name true; result = CIntType.new( -4 )
    1836     result
    1837   end
    1838 .,.,
    1839 
    1840 module_eval(<<'.,.,', 'C_parser.y.rb', 287)
    1841   def _reduce_92(val, _values, result)
     1949module_eval(<<'.,.,', 'C_parser.y.rb', 319)
     1950  def _reduce_109(val, _values, result)
    18421951                        set_no_type_name true
    18431952                        result = CIntType.new( -3 )
     
    18481957.,.,
    18491958
    1850 module_eval(<<'.,.,', 'C_parser.y.rb', 293)
    1851   def _reduce_93(val, _values, result)
     1959module_eval(<<'.,.,', 'C_parser.y.rb', 325)
     1960  def _reduce_110(val, _values, result)
    18521961                        set_no_type_name true
    18531962                        result = CIntType.new( -3 )
     
    18581967.,.,
    18591968
    1860 module_eval(<<'.,.,', 'C_parser.y.rb', 302)
    1861   def _reduce_94(val, _values, result)
     1969module_eval(<<'.,.,', 'C_parser.y.rb', 330)
     1970  def _reduce_111(val, _values, result)
     1971     set_no_type_name true; result = CBoolType.new
     1972    result
     1973  end
     1974.,.,
     1975
     1976module_eval(<<'.,.,', 'C_parser.y.rb', 332)
     1977  def _reduce_112(val, _values, result)
     1978     set_no_type_name true; result = val[0]
     1979    result
     1980  end
     1981.,.,
     1982
     1983module_eval(<<'.,.,', 'C_parser.y.rb', 334)
     1984  def _reduce_113(val, _values, result)
     1985     set_no_type_name true; result = CVoidType.new
     1986    result
     1987  end
     1988.,.,
     1989
     1990module_eval(<<'.,.,', 'C_parser.y.rb', 336)
     1991  def _reduce_114(val, _values, result)
     1992     set_no_type_name true; result = CVoidType.new
     1993    result
     1994  end
     1995.,.,
     1996
     1997module_eval(<<'.,.,', 'C_parser.y.rb', 338)
     1998  def _reduce_115(val, _values, result)
     1999     set_no_type_name true; result = CDefinedType.new( val[0].val )
     2000    result
     2001  end
     2002.,.,
     2003
     2004module_eval(<<'.,.,', 'C_parser.y.rb', 344)
     2005  def _reduce_116(val, _values, result)
    18622006     StructType.set_define( true ) 
    18632007    result
     
    18652009.,.,
    18662010
    1867 module_eval(<<'.,.,', 'C_parser.y.rb', 305)
    1868   def _reduce_95(val, _values, result)
     2011module_eval(<<'.,.,', 'C_parser.y.rb', 347)
     2012  def _reduce_117(val, _values, result)
    18692013                        StructType.end_of_parse
    18702014                        result = val[1]
     
    18742018.,.,
    18752019
    1876 module_eval(<<'.,.,', 'C_parser.y.rb', 311)
    1877   def _reduce_96(val, _values, result)
     2020module_eval(<<'.,.,', 'C_parser.y.rb', 353)
     2021  def _reduce_118(val, _values, result)
    18782022                        result = CStructType.new()
    18792023                        StructType.set_define( true )
     
    18832027.,.,
    18842028
    1885 module_eval(<<'.,.,', 'C_parser.y.rb', 316)
    1886   def _reduce_97(val, _values, result)
     2029module_eval(<<'.,.,', 'C_parser.y.rb', 358)
     2030  def _reduce_119(val, _values, result)
    18872031                        StructType.end_of_parse
    18882032                        result = val[1]
     
    18922036.,.,
    18932037
    1894 module_eval(<<'.,.,', 'C_parser.y.rb', 322)
    1895   def _reduce_98(val, _values, result)
     2038module_eval(<<'.,.,', 'C_parser.y.rb', 364)
     2039  def _reduce_120(val, _values, result)
    18962040                        StructType.set_define( false )
    18972041                        StructType.end_of_parse
     
    19022046.,.,
    19032047
    1904 module_eval(<<'.,.,', 'C_parser.y.rb', 328)
    1905   def _reduce_99(val, _values, result)
     2048module_eval(<<'.,.,', 'C_parser.y.rb', 370)
     2049  def _reduce_121(val, _values, result)
    19062050     set_no_type_name true
    19072051    result
     
    19092053.,.,
    19102054
    1911 # reduce 100 omitted
    1912 
    1913 # reduce 101 omitted
    1914 
    1915 module_eval(<<'.,.,', 'C_parser.y.rb', 337)
    1916   def _reduce_102(val, _values, result)
     2055# reduce 122 omitted
     2056
     2057# reduce 123 omitted
     2058
     2059module_eval(<<'.,.,', 'C_parser.y.rb', 379)
     2060  def _reduce_124(val, _values, result)
    19172061                        result = CStructType.new( val[0].val )
    19182062                        set_no_type_name true
     
    19222066.,.,
    19232067
    1924 module_eval(<<'.,.,', 'C_parser.y.rb', 346)
    1925   def _reduce_103(val, _values, result)
     2068module_eval(<<'.,.,', 'C_parser.y.rb', 388)
     2069  def _reduce_125(val, _values, result)
    19262070                        val[1].each { |i|       # i: Decl
    19272071                                i.set_type( val[0] )
     
    19362080.,.,
    19372081
    1938 # reduce 104 omitted
    1939 
    1940 # reduce 105 omitted
    1941 
    1942 # reduce 106 omitted
    1943 
    1944 module_eval(<<'.,.,', 'C_parser.y.rb', 365)
    1945   def _reduce_107(val, _values, result)
     2082module_eval(<<'.,.,', 'C_parser.y.rb', 399)
     2083  def _reduce_126(val, _values, result)
     2084                        val[1].each { |i|       # i: Decl
     2085                                i.set_type( val[0] )
     2086                                i.set_kind( :MEMBER )
     2087                                i.check
     2088                                CStructType.new_member( i )
     2089                        }
     2090                        result = val[1]
     2091               
     2092    result
     2093  end
     2094.,.,
     2095
     2096# reduce 127 omitted
     2097
     2098# reduce 128 omitted
     2099
     2100module_eval(<<'.,.,', 'C_parser.y.rb', 417)
     2101  def _reduce_129(val, _values, result)
    19462102                        result = val[1].merge val[0]
    19472103               
     
    19502106.,.,
    19512107
    1952 module_eval(<<'.,.,', 'C_parser.y.rb', 369)
    1953   def _reduce_108(val, _values, result)
     2108# reduce 130 omitted
     2109
     2110module_eval(<<'.,.,', 'C_parser.y.rb', 422)
     2111  def _reduce_131(val, _values, result)
     2112                        val[1].set_qualifier val[0]
     2113                                                result = val[1]
     2114               
     2115    result
     2116  end
     2117.,.,
     2118
     2119module_eval(<<'.,.,', 'C_parser.y.rb', 427)
     2120  def _reduce_132(val, _values, result)
    19542121                        result = CIntType.new( -3 )
    19552122                        result.set_qualifier val[0]
     
    19592126.,.,
    19602127
    1961 module_eval(<<'.,.,', 'C_parser.y.rb', 374)
    1962   def _reduce_109(val, _values, result)
    1963                         val[1].set_qualifier val[0]
    1964                         result = val[1]
    1965                
    1966     result
    1967   end
    1968 .,.,
    1969 
    1970 module_eval(<<'.,.,', 'C_parser.y.rb', 380)
    1971   def _reduce_110(val, _values, result)
     2128module_eval(<<'.,.,', 'C_parser.y.rb', 433)
     2129  def _reduce_133(val, _values, result)
    19722130     result = [ val[0] ]
    19732131    result
     
    19752133.,.,
    19762134
    1977 module_eval(<<'.,.,', 'C_parser.y.rb', 382)
    1978   def _reduce_111(val, _values, result)
     2135module_eval(<<'.,.,', 'C_parser.y.rb', 435)
     2136  def _reduce_134(val, _values, result)
    19792137     result << val[2]
    19802138    result
     
    19822140.,.,
    19832141
    1984 # reduce 112 omitted
    1985 
    1986 # reduce 113 omitted
    1987 
    1988 # reduce 114 omitted
    1989 
    1990 # reduce 115 omitted
    1991 
    1992 module_eval(<<'.,.,', 'C_parser.y.rb', 399)
    1993   def _reduce_116(val, _values, result)
     2142# reduce 135 omitted
     2143
     2144# reduce 136 omitted
     2145
     2146# reduce 137 omitted
     2147
     2148# reduce 138 omitted
     2149
     2150module_eval(<<'.,.,', 'C_parser.y.rb', 452)
     2151  def _reduce_139(val, _values, result)
    19942152     set_no_type_name true
    19952153    result
     
    19972155.,.,
    19982156
    1999 # reduce 117 omitted
    2000 
    2001 # reduce 118 omitted
    2002 
    2003 # reduce 119 omitted
    2004 
    2005 # reduce 120 omitted
    2006 
    2007 # reduce 121 omitted
    2008 
    2009 # reduce 122 omitted
    2010 
    2011 # reduce 123 omitted
    2012 
    2013 # reduce 124 omitted
    2014 
    2015 # reduce 125 omitted
    2016 
    2017 # reduce 126 omitted
    2018 
    2019 # reduce 127 omitted
    2020 
    2021 # reduce 128 omitted
    2022 
    2023 module_eval(<<'.,.,', 'C_parser.y.rb', 430)
    2024   def _reduce_129(val, _values, result)
    2025      result = CEnumType.new( -1 )
    2026     result
    2027   end
    2028 .,.,
    2029 
    2030 # reduce 130 omitted
    2031 
    2032 # reduce 131 omitted
    2033 
    2034 # reduce 132 omitted
    2035 
    2036 # reduce 133 omitted
    2037 
    2038 module_eval(<<'.,.,', 'C_parser.y.rb', 446)
    2039   def _reduce_134(val, _values, result)
     2157# reduce 140 omitted
     2158
     2159# reduce 141 omitted
     2160
     2161# reduce 142 omitted
     2162
     2163# reduce 143 omitted
     2164
     2165# reduce 144 omitted
     2166
     2167# reduce 145 omitted
     2168
     2169# reduce 146 omitted
     2170
     2171# reduce 147 omitted
     2172
     2173# reduce 148 omitted
     2174
     2175# reduce 149 omitted
     2176
     2177# reduce 150 omitted
     2178
     2179# reduce 151 omitted
     2180
     2181# reduce 152 omitted
     2182
     2183# reduce 153 omitted
     2184
     2185# reduce 154 omitted
     2186
     2187# reduce 155 omitted
     2188
     2189# reduce 156 omitted
     2190
     2191# reduce 157 omitted
     2192
     2193# reduce 158 omitted
     2194
     2195# reduce 159 omitted
     2196
     2197# reduce 160 omitted
     2198
     2199# reduce 161 omitted
     2200
     2201# reduce 162 omitted
     2202
     2203module_eval(<<'.,.,', 'C_parser.y.rb', 495)
     2204  def _reduce_163(val, _values, result)
    20402205     result = :CONST
    20412206    result
     
    20432208.,.,
    20442209
    2045 module_eval(<<'.,.,', 'C_parser.y.rb', 447)
    2046   def _reduce_135(val, _values, result)
     2210# reduce 164 omitted
     2211
     2212module_eval(<<'.,.,', 'C_parser.y.rb', 498)
     2213  def _reduce_165(val, _values, result)
    20472214     result = :VOLATILE
    20482215    result
     
    20502217.,.,
    20512218
    2052 module_eval(<<'.,.,', 'C_parser.y.rb', 452)
    2053   def _reduce_136(val, _values, result)
     2219# reduce 166 omitted
     2220
     2221# reduce 167 omitted
     2222
     2223# reduce 168 omitted
     2224
     2225# reduce 169 omitted
     2226
     2227module_eval(<<'.,.,', 'C_parser.y.rb', 509)
     2228  def _reduce_170(val, _values, result)
    20542229                        val[1].set_type( val[0] )
    20552230                        result = val[1]
     
    20592234.,.,
    20602235
    2061 # reduce 137 omitted
    2062 
    2063 module_eval(<<'.,.,', 'C_parser.y.rb', 458)
    2064   def _reduce_138(val, _values, result)
     2236# reduce 171 omitted
     2237
     2238module_eval(<<'.,.,', 'C_parser.y.rb', 515)
     2239  def _reduce_172(val, _values, result)
    20652240                        result = Decl.new( val[1].val )
    20662241                        result.set_type( val[0] )
     
    20702245.,.,
    20712246
    2072 module_eval(<<'.,.,', 'C_parser.y.rb', 464)
    2073   def _reduce_139(val, _values, result)
     2247module_eval(<<'.,.,', 'C_parser.y.rb', 521)
     2248  def _reduce_173(val, _values, result)
    20742249     result = Decl.new( val[0].val )
    20752250    result
     
    20772252.,.,
    20782253
    2079 module_eval(<<'.,.,', 'C_parser.y.rb', 466)
    2080   def _reduce_140(val, _values, result)
     2254module_eval(<<'.,.,', 'C_parser.y.rb', 523)
     2255  def _reduce_174(val, _values, result)
    20812256     result = val[1]
    20822257    result
     
    20842259.,.,
    20852260
    2086 module_eval(<<'.,.,', 'C_parser.y.rb', 469)
    2087   def _reduce_141(val, _values, result)
     2261module_eval(<<'.,.,', 'C_parser.y.rb', 526)
     2262  def _reduce_175(val, _values, result)
    20882263                        val[0].set_type( CArrayType.new( val[2] ) )
    20892264                        result = val[0]
     
    20932268.,.,
    20942269
    2095 module_eval(<<'.,.,', 'C_parser.y.rb', 474)
    2096   def _reduce_142(val, _values, result)
     2270module_eval(<<'.,.,', 'C_parser.y.rb', 531)
     2271  def _reduce_176(val, _values, result)
    20972272                        val[0].set_type( CArrayType.new )
    20982273                        result = val[0]
     
    21022277.,.,
    21032278
    2104 module_eval(<<'.,.,', 'C_parser.y.rb', 479)
    2105   def _reduce_143(val, _values, result)
     2279module_eval(<<'.,.,', 'C_parser.y.rb', 536)
     2280  def _reduce_177(val, _values, result)
    21062281                #       Generator.warning( "W6001 need 'void' for no parameter"  )
    21072282                        val[0].set_type( CFuncType.new )
     
    21122287.,.,
    21132288
    2114 module_eval(<<'.,.,', 'C_parser.y.rb', 487)
    2115   def _reduce_144(val, _values, result)
     2289# reduce 178 omitted
     2290
     2291module_eval(<<'.,.,', 'C_parser.y.rb', 543)
     2292  def _reduce_179(val, _values, result)
    21162293                #       Generator.warning( "W6002 need 'void' for no parameter"  )
    21172294                        val[0].set_type( CFuncType.new )
     
    21222299.,.,
    21232300
    2124 module_eval(<<'.,.,', 'C_parser.y.rb', 494)
    2125   def _reduce_145(val, _values, result)
     2301module_eval(<<'.,.,', 'C_parser.y.rb', 550)
     2302  def _reduce_180(val, _values, result)
    21262303     result = CPtrType.new
    21272304    result
     
    21292306.,.,
    21302307
    2131 module_eval(<<'.,.,', 'C_parser.y.rb', 497)
    2132   def _reduce_146(val, _values, result)
     2308module_eval(<<'.,.,', 'C_parser.y.rb', 553)
     2309  def _reduce_181(val, _values, result)
    21332310                        result = CPtrType.new
    21342311                        result.set_qualifier( val[1] )
     
    21382315.,.,
    21392316
    2140 module_eval(<<'.,.,', 'C_parser.y.rb', 502)
    2141   def _reduce_147(val, _values, result)
     2317module_eval(<<'.,.,', 'C_parser.y.rb', 558)
     2318  def _reduce_182(val, _values, result)
    21422319                        val[1].set_type(CPtrType.new)
    21432320                        result = val[1]
     
    21472324.,.,
    21482325
    2149 module_eval(<<'.,.,', 'C_parser.y.rb', 507)
    2150   def _reduce_148(val, _values, result)
     2326module_eval(<<'.,.,', 'C_parser.y.rb', 563)
     2327  def _reduce_183(val, _values, result)
    21512328                        ptrtype = CPtrType.new
    21522329                        ptrtype.set_qualifier( val[1] )
     
    21582335.,.,
    21592336
    2160 # reduce 149 omitted
    2161 
    2162 # reduce 150 omitted
    2163 
    2164 # reduce 151 omitted
    2165 
    2166 # reduce 152 omitted
    2167 
    2168 # reduce 153 omitted
    2169 
    2170 # reduce 154 omitted
    2171 
    2172 # reduce 155 omitted
    2173 
    2174 # reduce 156 omitted
    2175 
    2176 # reduce 157 omitted
    2177 
    2178 # reduce 158 omitted
    2179 
    2180 # reduce 159 omitted
    2181 
    2182 # reduce 160 omitted
    2183 
    2184 # reduce 161 omitted
    2185 
    2186 # reduce 162 omitted
    2187 
    2188 # reduce 163 omitted
    2189 
    2190 # reduce 164 omitted
    2191 
    2192 # reduce 165 omitted
    2193 
    2194 module_eval(<<'.,.,', 'C_parser.y.rb', 571)
    2195   def _reduce_166(val, _values, result)
     2337# reduce 184 omitted
     2338
     2339# reduce 185 omitted
     2340
     2341# reduce 186 omitted
     2342
     2343# reduce 187 omitted
     2344
     2345# reduce 188 omitted
     2346
     2347# reduce 189 omitted
     2348
     2349# reduce 190 omitted
     2350
     2351# reduce 191 omitted
     2352
     2353# reduce 192 omitted
     2354
     2355# reduce 193 omitted
     2356
     2357# reduce 194 omitted
     2358
     2359# reduce 195 omitted
     2360
     2361# reduce 196 omitted
     2362
     2363# reduce 197 omitted
     2364
     2365# reduce 198 omitted
     2366
     2367# reduce 199 omitted
     2368
     2369# reduce 200 omitted
     2370
     2371# reduce 201 omitted
     2372
     2373# reduce 202 omitted
     2374
     2375# reduce 203 omitted
     2376
     2377# reduce 204 omitted
     2378
     2379module_eval(<<'.,.,', 'C_parser.y.rb', 630)
     2380  def _reduce_205(val, _values, result)
    21962381                        Generator.warning( "W6003 need 'void' for no parameter"  )
    21972382               
     
    22002385.,.,
    22012386
    2202 # reduce 167 omitted
    2203 
    2204 module_eval(<<'.,.,', 'C_parser.y.rb', 576)
    2205   def _reduce_168(val, _values, result)
     2387# reduce 206 omitted
     2388
     2389module_eval(<<'.,.,', 'C_parser.y.rb', 635)
     2390  def _reduce_207(val, _values, result)
    22062391                        Generator.warning( "W6004 need 'void' for no parameter"  )
    22072392               
     
    22102395.,.,
    22112396
    2212 # reduce 169 omitted
    2213 
    2214 module_eval(<<'.,.,', 'C_parser.y.rb', 583)
    2215   def _reduce_170(val, _values, result)
     2397# reduce 208 omitted
     2398
     2399module_eval(<<'.,.,', 'C_parser.y.rb', 642)
     2400  def _reduce_209(val, _values, result)
    22162401     result = val[0]
    22172402    result
     
    22192404.,.,
    22202405
    2221 module_eval(<<'.,.,', 'C_parser.y.rb', 585)
    2222   def _reduce_171(val, _values, result)
     2406module_eval(<<'.,.,', 'C_parser.y.rb', 644)
     2407  def _reduce_210(val, _values, result)
    22232408     result = val[1]
    22242409    result
     
    22262411.,.,
    22272412
    2228 module_eval(<<'.,.,', 'C_parser.y.rb', 587)
    2229   def _reduce_172(val, _values, result)
     2413module_eval(<<'.,.,', 'C_parser.y.rb', 646)
     2414  def _reduce_211(val, _values, result)
    22302415     result = val[1]
    22312416    result
     
    22332418.,.,
    22342419
    2235 module_eval(<<'.,.,', 'C_parser.y.rb', 589)
    2236   def _reduce_173(val, _values, result)
     2420module_eval(<<'.,.,', 'C_parser.y.rb', 648)
     2421  def _reduce_212(val, _values, result)
    22372422     result = C_EXP.new( val[2] )
    22382423    result
     
    22402425.,.,
    22412426
    2242 module_eval(<<'.,.,', 'C_parser.y.rb', 594)
    2243   def _reduce_174(val, _values, result)
     2427module_eval(<<'.,.,', 'C_parser.y.rb', 653)
     2428  def _reduce_213(val, _values, result)
    22442429                        result = [ val[0] ]
    22452430               
     
    22482433.,.,
    22492434
    2250 module_eval(<<'.,.,', 'C_parser.y.rb', 598)
    2251   def _reduce_175(val, _values, result)
     2435module_eval(<<'.,.,', 'C_parser.y.rb', 657)
     2436  def _reduce_214(val, _values, result)
    22522437                        val[0] << val[2]
    22532438                        result = val[0]
     
    22572442.,.,
    22582443
    2259 # reduce 176 omitted
    2260 
    2261 # reduce 177 omitted
    2262 
    2263 # reduce 178 omitted
    2264 
    2265 # reduce 179 omitted
    2266 
    2267 # reduce 180 omitted
    2268 
    2269 # reduce 181 omitted
    2270 
    2271 # reduce 182 omitted
    2272 
    2273 # reduce 183 omitted
    2274 
    2275 # reduce 184 omitted
    2276 
    2277 # reduce 185 omitted
    2278 
    2279 # reduce 186 omitted
    2280 
    2281 module_eval(<<'.,.,', 'C_parser.y.rb', 626)
    2282   def _reduce_187(val, _values, result)
     2444# reduce 215 omitted
     2445
     2446# reduce 216 omitted
     2447
     2448# reduce 217 omitted
     2449
     2450# reduce 218 omitted
     2451
     2452# reduce 219 omitted
     2453
     2454# reduce 220 omitted
     2455
     2456# reduce 221 omitted
     2457
     2458# reduce 222 omitted
     2459
     2460# reduce 223 omitted
     2461
     2462# reduce 224 omitted
     2463
     2464# reduce 225 omitted
     2465
     2466module_eval(<<'.,.,', 'C_parser.y.rb', 685)
     2467  def _reduce_226(val, _values, result)
    22832468                        val[2].each{ |i|
    22842469                           i.set_kind( :TYPEDEF )
     
    22912476.,.,
    22922477
    2293 module_eval(<<'.,.,', 'C_parser.y.rb', 635)
    2294   def _reduce_188(val, _values, result)
     2478module_eval(<<'.,.,', 'C_parser.y.rb', 694)
     2479  def _reduce_227(val, _values, result)
    22952480     result = [ val[0] ]
    22962481    result
     
    22982483.,.,
    22992484
    2300 module_eval(<<'.,.,', 'C_parser.y.rb', 637)
    2301   def _reduce_189(val, _values, result)
     2485module_eval(<<'.,.,', 'C_parser.y.rb', 696)
     2486  def _reduce_228(val, _values, result)
    23022487     result << val[2]
    23032488    result
     
    23052490.,.,
    23062491
    2307 # reduce 190 omitted
    2308 
    2309 # reduce 191 omitted
    2310 
    2311 # reduce 192 omitted
    2312 
    2313 # reduce 193 omitted
    2314 
    2315 # reduce 194 omitted
    2316 
    2317 # reduce 195 omitted
    2318 
    2319 # reduce 196 omitted
    2320 
    2321 # reduce 197 omitted
    2322 
    2323 # reduce 198 omitted
    2324 
    2325 # reduce 199 omitted
    2326 
    2327 # reduce 200 omitted
    2328 
    2329 # reduce 201 omitted
    2330 
    2331 # reduce 202 omitted
    2332 
    2333 # reduce 203 omitted
    2334 
    2335 # reduce 204 omitted
    2336 
    2337 # reduce 205 omitted
    2338 
    2339 # reduce 206 omitted
    2340 
    2341 # reduce 207 omitted
    2342 
    2343 # reduce 208 omitted
    2344 
    2345 # reduce 209 omitted
    2346 
    2347 # reduce 210 omitted
    2348 
    2349 # reduce 211 omitted
    2350 
    2351 # reduce 212 omitted
    2352 
    2353 # reduce 213 omitted
    2354 
    2355 # reduce 214 omitted
    2356 
    2357 # reduce 215 omitted
    2358 
    2359 # reduce 216 omitted
    2360 
    2361 # reduce 217 omitted
    2362 
    2363 # reduce 218 omitted
    2364 
    2365 # reduce 219 omitted
    2366 
    2367 # reduce 220 omitted
    2368 
    2369 # reduce 221 omitted
    2370 
    2371 # reduce 222 omitted
    2372 
    2373 # reduce 223 omitted
    2374 
    2375 # reduce 224 omitted
    2376 
    2377 # reduce 225 omitted
    2378 
    2379 # reduce 226 omitted
    2380 
    2381 # reduce 227 omitted
    2382 
    2383 # reduce 228 omitted
    2384 
    23852492# reduce 229 omitted
    23862493
     
    24052512# reduce 239 omitted
    24062513
    2407 module_eval(<<'.,.,', 'C_parser.y.rb', 718)
    2408   def _reduce_240(val, _values, result)
     2514# reduce 240 omitted
     2515
     2516# reduce 241 omitted
     2517
     2518# reduce 242 omitted
     2519
     2520# reduce 243 omitted
     2521
     2522# reduce 244 omitted
     2523
     2524# reduce 245 omitted
     2525
     2526# reduce 246 omitted
     2527
     2528# reduce 247 omitted
     2529
     2530# reduce 248 omitted
     2531
     2532# reduce 249 omitted
     2533
     2534# reduce 250 omitted
     2535
     2536# reduce 251 omitted
     2537
     2538# reduce 252 omitted
     2539
     2540# reduce 253 omitted
     2541
     2542# reduce 254 omitted
     2543
     2544# reduce 255 omitted
     2545
     2546# reduce 256 omitted
     2547
     2548# reduce 257 omitted
     2549
     2550# reduce 258 omitted
     2551
     2552# reduce 259 omitted
     2553
     2554# reduce 260 omitted
     2555
     2556# reduce 261 omitted
     2557
     2558# reduce 262 omitted
     2559
     2560# reduce 263 omitted
     2561
     2562# reduce 264 omitted
     2563
     2564module_eval(<<'.,.,', 'C_parser.y.rb', 761)
     2565  def _reduce_265(val, _values, result)
    24092566     result = NamespacePath.new( val[0].val, false )
    24102567    result
     
    24122569.,.,
    24132570
    2414 module_eval(<<'.,.,', 'C_parser.y.rb', 719)
    2415   def _reduce_241(val, _values, result)
     2571module_eval(<<'.,.,', 'C_parser.y.rb', 762)
     2572  def _reduce_266(val, _values, result)
    24162573     result = NamespacePath.new( val[1].val, true )
    24172574    result
     
    24192576.,.,
    24202577
    2421 module_eval(<<'.,.,', 'C_parser.y.rb', 721)
    2422   def _reduce_242(val, _values, result)
     2578module_eval(<<'.,.,', 'C_parser.y.rb', 764)
     2579  def _reduce_267(val, _values, result)
    24232580     result = val[0].append!( val[2].val )
     2581    result
     2582  end
     2583.,.,
     2584
     2585module_eval(<<'.,.,', 'C_parser.y.rb', 768)
     2586  def _reduce_268(val, _values, result)
     2587                while true
     2588                        # ';' が表れるまで、トークンを読み飛ばす。
     2589                        # gcc の構文拡張に対応すべきだが、単純な実装として、';' まで読み飛ばす。
     2590                        # トークン単位で読み飛ばしているので、文字列やコメント内の ';' は対象にならない。
     2591                        token = next_token
     2592                        if token[1].val == ";"
     2593                                break
     2594                        end
     2595                        # p "skip: #{token[1].val}"
     2596                end
     2597               
    24242598    result
    24252599  end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.y.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    8 #   上記著作権者は,以下の(1)(4)の条件を満たす場合に限り,本ソフトウェ
     8#   上記著作権者は,以下の(1)(4)の条件を満たす場合に限り,本ソフトウェ
    99#   ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
    1010#   変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
     
    4848# argument_expression_list(関数引数), assignment_expression(代入)がない
    4949# 式の result は、すべて配列で第一要素が識別シンボル、第二要素以下が引数
     50#
     51# 2019/3/28 長島 下記のC99の構文に近づくよう変更
     52#(読めないヘッダーファイルがあったため)
     53# http://www.quut.com/c/ANSI-C-grammar-y-1999.html
     54# 元々のコメントと合わなくなっています
    5055
    5156primary_expression
    52         : namespace_identifier
     57                : namespace_identifier
    5358                { result = [ :IDENTIFIER, val[0] ] }     #1ok
    5459#        : IDENTIFIER   # mikan namespace への対応
     
    5863#        | FALSE
    5964#               { result = [ :BOOL_CONSTANT, false ] }
    60         | INTEGER_CONSTANT
     65                | INTEGER_CONSTANT
    6166                { result = [ :INTEGER_CONSTANT, val[0] ] }
    62         | FLOATING_CONSTANT
     67                | FLOATING_CONSTANT
    6368                { result = [ :FLOATING_CONSTANT, val[0] ] }
    64         | OCTAL_CONSTANT
     69                | OCTAL_CONSTANT
    6570                { result = [ :OCTAL_CONSTANT, val[0] ] }
    66         | HEX_CONSTANT
     71                | HEX_CONSTANT
    6772                { result = [ :HEX_CONSTANT, val[0] ] }
    68         | CHARACTER_LITERAL
     73                | CHARACTER_LITERAL
    6974                { result = [ :CHARACTER_LITERAL, val[0] ] }
    70         | string_literal_list
     75                | string_literal_list
    7176                { result = [ :STRING_LITERAL_LIST, val[0] ] }
    72         | '(' expression ')'
     77                | '(' expression ')'
    7378                { result = [ :PARENTHESES, val[1].get_elements ] }
    7479
    7580string_literal_list
    76         : STRING_LITERAL
     81                : STRING_LITERAL
    7782                { result = [val[0]] }
    78         | string_literal_list STRING_LITERAL
     83                | string_literal_list STRING_LITERAL
    7984                { result << val[1] }
    8085
    8186# 関数呼び出しと後置インクリメント、デクリメント演算子がない
    8287postfix_expression
    83         : primary_expression
    84         | primary_expression '(' argument_list ')'
    85         | primary_expression type_qualifier '(' argument_list ')'    # intended __asm volatile ( "   MNEMONIC  OPERAND" );
    86         | postfix_expression '[' expression ']'
     88                : primary_expression
     89                | postfix_expression '[' expression ']'
    8790                { result = [ :OP_SUBSC, val[0], val[2] ] }
    88         | postfix_expression '.' IDENTIFIER
     91                | postfix_expression '(' ')'
     92                | postfix_expression '(' argument_expression_list ')'
     93                | postfix_expression type_qualifier '(' argument_expression_list ')'    # intended __asm volatile ( "   MNEMONIC  OPERAND" );
     94                | postfix_expression '.' IDENTIFIER
    8995                { result = [ :OP_DOT, val[0], val[2] ] }
    90         | postfix_expression '->' IDENTIFIER
     96                | postfix_expression '->' IDENTIFIER
    9197                { result = [ :OP_REF, val[0], val[2] ] }
    92         | postfix_expression '++'       { result = val[0] }   # ++, -- は無視する
    93         | postfix_expression '--'       { result = val[0] }
    94 
    95 argument_list
    96         :
    97         | expression
    98         | argument_list ',' expression
     98                | postfix_expression '++'       { result = val[0] }   # ++, -- は無視する
     99                | postfix_expression '--'       { result = val[0] }
     100                | '(' type_name ')' '{' initializer_list '}'
     101                | '(' type_name ')' '{' initializer_list ',' '}'
     102
     103argument_expression_list
     104                : assignment_expression
     105                | argument_expression_list ',' assignment_expression
    99106
    100107
    101108# 前置インクリメント、デクリメント演算子がない
    102109unary_expression
    103         : postfix_expression
    104         | unary_operator cast_expression
     110                : postfix_expression
     111                | unary_operator cast_expression
    105112                { result = [ val[0], val[1] ] }
    106         | SIZEOF unary_expression
     113                | SIZEOF unary_expression
    107114                { result = [ :OP_SIZEOF_EXPR, val[1] ] }
    108         | SIZEOF '(' type_name ')'
     115                | SIZEOF '(' type_name ')'
    109116                { result = [ :OP_SIZEOF_TYPE, val[1] ] }
    110117                | '++' unary_expression                 { result = val[1] }   # ++, -- は無視する
     
    112119
    113120unary_operator
    114         : '&'   { result = :OP_U_AMP }
    115         | '*'   { result = :OP_U_ASTER }
    116         | '+'   { result = :OP_U_PLUS }
    117         | '-'   { result = :OP_U_MINUS }
    118         | '~'   { result = :OP_U_TILDE }
    119         | '!'   { result = :OP_U_EXCLAM }
     121                : '&'   { result = :OP_U_AMP }
     122                | '*'   { result = :OP_U_ASTER }
     123                | '+'   { result = :OP_U_PLUS }
     124                | '-'   { result = :OP_U_MINUS }
     125                | '~'   { result = :OP_U_TILDE }
     126                | '!'   { result = :OP_U_EXCLAM }
    120127
    121128cast_expression
    122         : unary_expression
    123         | '(' type_name ')' cast_expression
     129                : unary_expression
     130                | '(' type_name ')' cast_expression
    124131                {  result = [ :CAST, val[1], val[3] ] }
    125132
    126133multiplicative_expression
    127         : cast_expression
    128         | multiplicative_expression '*' cast_expression
     134                : cast_expression
     135                | multiplicative_expression '*' cast_expression
    129136                { result = [ :OP_MULT, val[0], val[2] ]  }
    130         | multiplicative_expression '/' cast_expression
     137                | multiplicative_expression '/' cast_expression
    131138                { result = [ :OP_DIV, val[0], val[2] ]  }
    132         | multiplicative_expression '%' cast_expression
     139                | multiplicative_expression '%' cast_expression
    133140                { result = [ :OP_REMAIN, val[0], val[2] ]  }
    134141
    135142additive_expression
    136         : multiplicative_expression
    137         | additive_expression '+' multiplicative_expression
     143                : multiplicative_expression
     144                | additive_expression '+' multiplicative_expression
    138145                { result = [ :OP_ADD, val[0], val[2] ]  }
    139         | additive_expression '-' multiplicative_expression
     146                | additive_expression '-' multiplicative_expression
    140147                { result = [ :OP_SUB, val[0], val[2] ]  }
    141148
    142149shift_expression
    143         : additive_expression
    144         | shift_expression '<<' additive_expression
     150                : additive_expression
     151                | shift_expression '<<' additive_expression
    145152                { result = [ :OP_LSFT, val[0], val[2] ]  }
    146         | shift_expression '>>' additive_expression
     153                | shift_expression '>>' additive_expression
    147154                { result = [ :OP_RSFT, val[0], val[2] ]  }
    148155
    149156relational_expression
    150         : shift_expression
    151         | relational_expression '<' shift_expression
     157                : shift_expression
     158                | relational_expression '<' shift_expression
    152159                { result = [ :OP_LT, val[0], val[2] ]  }
    153         | relational_expression '>' shift_expression
     160                | relational_expression '>' shift_expression
    154161                { result = [ :OP_GT, val[0], val[2] ]  }
    155         | relational_expression '<=' shift_expression
     162                | relational_expression '<=' shift_expression
    156163                { result = [ :OP_LE, val[0], val[2] ]  }
    157         | relational_expression '>=' shift_expression
     164                | relational_expression '>=' shift_expression
    158165                { result = [ :OP_GE, val[0], val[2] ]  }
    159166
    160167equality_expression
    161         : relational_expression
    162         | equality_expression '==' relational_expression
     168                : relational_expression
     169                | equality_expression '==' relational_expression
    163170                { result = [ :OP_EQ, val[0], val[2] ]  }
    164         | equality_expression '!=' relational_expression
     171                | equality_expression '!=' relational_expression
    165172                { result = [ :OP_NE, val[0], val[2] ]  }
    166173
    167174and_expression
    168         : equality_expression
    169         | and_expression '&' equality_expression
     175                : equality_expression
     176                | and_expression '&' equality_expression
    170177                { result = [ :OP_AND, val[0], val[2] ]  }
    171178
    172179exclusive_or_expression
    173         : and_expression
    174         | exclusive_or_expression '^' and_expression
     180                : and_expression
     181                | exclusive_or_expression '^' and_expression
    175182                { result = [ :OP_EOR, val[0], val[2] ]  }
    176183
    177184inclusive_or_expression
    178         : exclusive_or_expression
    179         | inclusive_or_expression '|' exclusive_or_expression
     185                : exclusive_or_expression
     186                | inclusive_or_expression '|' exclusive_or_expression
    180187                { result = [ :OP_OR, val[0], val[2] ]  }
    181188
    182189logical_and_expression
    183         : inclusive_or_expression
    184         | logical_and_expression '&&' inclusive_or_expression
     190                : inclusive_or_expression
     191                | logical_and_expression '&&' inclusive_or_expression
    185192                { result = [ :OP_LAND, val[0], val[2] ]  }
    186193
    187194logical_or_expression
    188         : logical_and_expression
    189         | logical_or_expression '||' logical_and_expression
     195                : logical_and_expression
     196                | logical_or_expression '||' logical_and_expression
    190197                { result = [ :OP_LOR, val[0], val[2] ]  }
    191198
    192199conditional_expression
    193         : logical_or_expression
    194         | logical_or_expression '?' expression ':' conditional_expression
     200                : logical_or_expression
     201                | logical_or_expression '?' expression ':' conditional_expression
    195202                { result = [ :OP_CEX, val[0], val[2].get_elements, val[4] ]  }
    196203
    197 
    198 # コンマ演算子が使えない
     204assignment_expression
     205                : conditional_expression
     206                | unary_expression assignment_operator assignment_expression
     207
     208assignment_operator
     209                : '='
     210                | '+='
     211                | '-='
     212                | '*='
     213                | '/='
     214                | '%='
     215                | '<<='
     216                | '>>='
     217                | '&='
     218                | '|='
     219                | '^='
     220
    199221expression
    200         : conditional_expression
     222                : assignment_expression
    201223                {
    202224                        result = Expression.new( val[0] )
    203225                        # result.print
    204226                }
     227                | expression ',' assignment_expression
     228                {
     229                        result = Expression.new( val[2] )    # ',' の後ろを採用
     230                }
    205231
    206232constant_expression
    207         : conditional_expression
     233                : conditional_expression
    208234                {
    209235                        result = Expression.new( val[0] )
     
    218244                }
    219245
    220 
    221 
    222246# Types
    223247##########################  宣言  ##########################
     
    227251# K&Rとの違い: storage classが指定できない、型が省略できない
    228252declaration
    229         : declaration_specifiers init_declarator_list ';'
    230 #        : type_specifier_qualifier_list init_declarator_list ';'
     253                : declaration_specifiers init_declarator_list ';'
     254#        : specifier_qualifier_list init_declarator_list ';'
    231255
    232256# declaration_specifiersは関数のパラメータで使われるが、
    233 # type_specifier_qualifier_listで十分かもしれない
     257# specifier_qualifier_listで十分かもしれない
    234258
    235259declaration_specifiers
    236         : storage_class
     260                : storage_class_specifier
    237261                {
    238262                        result = CIntType.new( -3 )    # storage class は無視
    239263                }
    240         | type_specifier
    241         | type_qualifier
     264                | storage_class_specifier declaration_specifiers
     265                {
     266                        result = val[1]                # storage class は無視
     267                }
     268                | type_specifier
     269                | type_specifier declaration_specifiers
     270                {
     271                        result = val[1].merge val[0]
     272                }
     273                | type_qualifier
    242274                {
    243275                        result = CIntType.new( -3 )
    244276                        result.set_qualifier val[0]
    245277                }
    246         | storage_class declaration_specifiers
    247                 {
    248                         result = val[1]                # storage class は無視
    249                 }
    250         | type_specifier declaration_specifiers
    251                 {
    252                         result = val[1].merge val[0]
    253                 }
    254         | type_qualifier declaration_specifiers
     278                | type_qualifier declaration_specifiers
    255279                {
    256280                        val[1].set_qualifier val[0]
    257                         result = val[1]
    258                 }
    259 
     281                                                result = val[1]
     282                }
     283                | function_specifier
     284                | function_specifier declaration_specifiers
    260285
    261286init_declarator_list
    262         : init_declarator
     287                : init_declarator
    263288                { result = [val[0]] }
    264         | init_declarator_list ',' init_declarator
     289                | init_declarator_list ',' init_declarator
    265290                { result << val[2] }
    266291
    267292init_declarator
    268         : declarator
    269         | declarator '=' initializer
     293                : declarator
     294                | declarator '=' initializer
    270295                { val[0].set_initializer( val[2] ) }
    271296
     297storage_class_specifier
     298                : EXTERN
     299                | STATIC
     300                | AUTO
     301                | REGISTER
     302
    272303type_specifier
    273         : VOID  { set_no_type_name true; result = CVoidType.new }
    274         | FLOAT { set_no_type_name true; result = CFloatType.new(-32) }
    275         | DOUBLE        { set_no_type_name true; result = CFloatType.new(-64) }
    276         | BOOL  { set_no_type_name true; result = CBoolType.new }
    277         | struct_specifier      { set_no_type_name true; result = val[0] } # set_no_type_name true は struct_tag でも呼ばれる
    278         | union_specifier       { set_no_type_name true; result = CVoidType.new }  # void が宣言されたとする
    279         | enum_specifier        { set_no_type_name true; result = CVoidType.new }  # void が宣言されたとする
    280         | TYPE_NAME     { set_no_type_name true; result = CDefinedType.new( val[0].val ) }
    281 
    282         | CHAR  { set_no_type_name true; result = CIntType.new(-11 ) }
    283         | SHORT { set_no_type_name true; result = CIntType.new( -2 ) }
    284         | INT           { set_no_type_name true; result = CIntType.new( -3 ) }
    285         | LONG  { set_no_type_name true; result = CIntType.new( -4 ) }
    286         | SIGNED
     304                : VOID
     305                { set_no_type_name true; result = CVoidType.new }
     306                | CHAR
     307                { set_no_type_name true; result = CIntType.new(-11 ) }
     308                | SHORT
     309                { set_no_type_name true; result = CIntType.new( -2 ) }
     310                | INT
     311                { set_no_type_name true; result = CIntType.new( -3 ) }
     312                | LONG
     313                { set_no_type_name true; result = CIntType.new( -4 ) }
     314                | FLOAT
     315                { set_no_type_name true; result = CFloatType.new(-32) }
     316                | DOUBLE
     317                { set_no_type_name true; result = CFloatType.new(-64) }
     318                | SIGNED
    287319                {
    288320                        set_no_type_name true
     
    290322                        result.set_sign :SIGNED
    291323                }
    292         | UNSIGNED
     324                | UNSIGNED
    293325                {
    294326                        set_no_type_name true
     
    296328                        result.set_sign :UNSIGNED
    297329                }
     330                | BOOL
     331                { set_no_type_name true; result = CBoolType.new }
     332                | struct_specifier
     333                { set_no_type_name true; result = val[0] } # set_no_type_name true は struct_tag でも呼ばれる
     334                | union_specifier
     335                { set_no_type_name true; result = CVoidType.new }  # void が宣言されたとする
     336                | enum_specifier
     337                { set_no_type_name true; result = CVoidType.new }  # void が宣言されたとする
     338                | TYPE_NAME
     339                { set_no_type_name true; result = CDefinedType.new( val[0].val ) }
    298340
    299341# mikan K&Rのstruct_or_union_specifierに相当するが、unionは使えない, bit field にも対応しない
    300342struct_specifier                # mikan
    301343#        : STRUCT struct_tag '{'
    302         : struct_term struct_tag '{'
     344                : struct_term struct_tag '{'
    303345                { StructType.set_define( true )  }
    304            struct_declaration_list '}'
     346                struct_declaration_list '}'
    305347                {
    306348                        StructType.end_of_parse
     
    308350                }
    309351#        | STRUCT
    310         | struct_term
     352                | struct_term
    311353                {
    312354                        result = CStructType.new()
    313355                        StructType.set_define( true )
    314356                }
    315            '{' struct_declaration_list '}'
     357                '{' struct_declaration_list '}'
    316358                {
    317359                        StructType.end_of_parse
     
    319361                }
    320362#        | STRUCT struct_tag   # mikan struct_tag は namespace 対応が必要
    321         | struct_term struct_tag   # mikan struct_tag は namespace 対応が必要
     363                | struct_term struct_tag   # mikan struct_tag は namespace 対応が必要
    322364                {
    323365                        StructType.set_define( false )
     
    327369
    328370struct_term
    329         : STRUCT { set_no_type_name true }
     371                : STRUCT { set_no_type_name true }
    330372
    331373struct_declaration_list
    332         : struct_declaration
    333         | struct_declaration_list struct_declaration
     374                : struct_declaration
     375                | struct_declaration_list struct_declaration
    334376
    335377struct_tag:
    336         IDENTIFIER
     378                IDENTIFIER
    337379                {
    338380                        result = CStructType.new( val[0].val )
     
    342384# ポインタ修飾子を追加
    343385struct_declaration
    344         : declaration_specifiers struct_declarator_list ';'
    345 #        :                                type_specifier_qualifier_list struct_declarator_list ';'
     386                : declaration_specifiers struct_declarator_list ';'
     387#        :                                specifier_qualifier_list struct_declarator_list ';'
    346388                {
    347389                        val[1].each { |i|       # i: Decl
     
    353395                        result = val[1]
    354396                }
    355         | union_specifier ';'                       # 無名
    356         | struct_specifier ';'                       # 無名
     397                # ビットフィールドを読み飛ばし
     398                | declaration_specifiers struct_declarator_list ':' constant_expression ';'
     399                {
     400                        val[1].each { |i|       # i: Decl
     401                                i.set_type( val[0] )
     402                                i.set_kind( :MEMBER )
     403                                i.check
     404                                CStructType.new_member( i )
     405                        }
     406                        result = val[1]
     407                }
     408                | union_specifier ';'                       # 無名
     409                | struct_specifier ';'                       # 無名
    357410
    358411
     
    360413# K&Rのspecifier_qualifier_listと同じ
    361414# 名前がまぎらわしかったのでtype_を付けた
    362 type_specifier_qualifier_list
    363         : type_specifier
    364         | type_specifier type_specifier_qualifier_list
     415specifier_qualifier_list
     416                : type_specifier specifier_qualifier_list
    365417                {
    366418                        result = val[1].merge val[0]
    367419                }
    368         | type_qualifier
     420                | type_specifier
     421                | type_qualifier specifier_qualifier_list
     422                {
     423                        val[1].set_qualifier val[0]
     424                                                result = val[1]
     425                }
     426                | type_qualifier
    369427                {
    370428                        result = CIntType.new( -3 )
    371429                        result.set_qualifier val[0]
    372430                }
    373         | type_qualifier type_specifier_qualifier_list
    374                 {
    375                         val[1].set_qualifier val[0]
    376                         result = val[1]
    377                 }
    378431
    379432struct_declarator_list
    380         : struct_declarator
     433                : struct_declarator
    381434                { result = [ val[0] ] }
    382         | struct_declarator_list ',' struct_declarator
     435                | struct_declarator_list ',' struct_declarator
    383436                { result << val[2] }
    384437
    385438# ビットフィールドは使えない
    386439struct_declarator
    387         : declarator
    388 
    389 
     440                : declarator
     441#               | ':' constant_expression
     442#               | declarator ':' constant_expression
    390443
    391444union_specifier
     
    393446#        | UNION '{' union_declaration_list '}'
    394447#        | UNION union_tag   # mikan struct_tag は namespace 対応が必要
    395         : union_term union_tag '{' union_declaration_list '}'
    396         | union_term '{' union_declaration_list '}'
    397         | union_term union_tag   # mikan struct_tag は namespace 対応が必要
     448                : union_term union_tag '{' union_declaration_list '}'
     449                | union_term '{' union_declaration_list '}'
     450                | union_term union_tag   # mikan struct_tag は namespace 対応が必要
    398451
    399452union_term
    400         : UNION { set_no_type_name true }
     453                : UNION { set_no_type_name true }
    401454
    402455union_declaration_list
    403         : union_declaration
    404         | union_declaration_list union_declaration
     456                : union_declaration
     457                | union_declaration_list union_declaration
    405458
    406459union_tag:
     
    408461
    409462union_declaration
    410         : declaration_specifiers union_declarator_list ';'
     463                : declaration_specifiers union_declarator_list ';'
    411464                | union_specifier ';'                       # 無名
    412465                | struct_specifier ';'                      # 無名
    413466
    414467union_declarator_list
    415         : union_declarator
    416         | union_declarator_list ',' union_declarator
    417 
    418 # ビットフィールドは使えない
     468                : union_declarator
     469                | union_declarator_list ',' union_declarator
     470
    419471union_declarator
    420         : declarator
    421 
    422 
    423 
    424 # enumの種類を追加
    425 enum_specifier          # mikan
    426         : enum_type            '{' enumerator_list '}'
    427         | enum_type IDENTIFIER '{' enumerator_list '}'
    428         | enum_type IDENTIFIER
    429 
    430 enum_type
    431         : ENUM  { result = CEnumType.new( -1 ) }
    432 #        | ENUM8        { result = CEnumType.new( 8 ) }
    433 #        | ENUM16       { result = CEnumType.new( 16 ) }
    434 #        | ENUM32       { result = CEnumType.new( 32 ) }
    435 #        | ENUM64       { result = CEnumType.new( 64 ) }
    436 #        | ENUM128      { result = CEnumType.new( 128 ) }
     472                : declarator
     473                | ':' constant_expression
     474                | declarator ':' constant_expression
     475
     476enum_specifier
     477                : ENUM '{' enumerator_list '}'
     478                | ENUM IDENTIFIER '{' enumerator_list '}'
     479                | ENUM '{' enumerator_list ',' '}'
     480                | ENUM IDENTIFIER '{' enumerator_list ',' '}'
     481                | ENUM IDENTIFIER
     482                | ENUM TYPE_NAME '{' enumerator_list '}'
     483                | ENUM TYPE_NAME '{' enumerator_list ',' '}'
     484                | ENUM TYPE_NAME
    437485
    438486enumerator_list
    439         : enumerator
    440         | enumerator_list ',' enumerator
     487                : enumerator
     488                | enumerator_list ',' enumerator
    441489
    442490enumerator
    443         : IDENTIFIER
    444         | IDENTIFIER '=' constant_expression
     491                : IDENTIFIER
     492                | IDENTIFIER '=' constant_expression
    445493
    446494type_qualifier
    447         : CONST { result = :CONST }
    448         | VOLATILE      { result = :VOLATILE }
     495                : CONST
     496                { result = :CONST }
     497                | RESTRICT
     498                | VOLATILE
     499                { result = :VOLATILE }
     500
     501function_specifier
     502                : __INLINE__
     503                | INLINE
     504                | __INLINE
     505                | CINLINE
    449506
    450507declarator
    451         : pointer direct_declarator
     508                : pointer direct_declarator
    452509                {
    453510                        val[1].set_type( val[0] )
    454511                        result = val[1]
    455512                }
    456         | direct_declarator
    457         | pointer TYPE_NAME     # 関数ポインタの typedef が二重定義の場合
     513                | direct_declarator
     514                | pointer TYPE_NAME     # 関数ポインタの typedef が二重定義の場合
    458515                {
    459516                        result = Decl.new( val[1].val )
     
    462519
    463520direct_declarator               # mikan
    464         : IDENTIFIER
     521                : IDENTIFIER
    465522                { result = Decl.new( val[0].val ) }
    466         | '(' declarator ')'
     523                | '(' declarator ')'
    467524                { result = val[1] }
    468         | direct_declarator '[' constant_expression ']'
     525                | direct_declarator '[' constant_expression ']'
    469526                {
    470527                        val[0].set_type( CArrayType.new( val[2] ) )
    471528                        result = val[0]
    472529                }
    473         | direct_declarator '[' ']'
     530                | direct_declarator '[' ']'
    474531                {
    475532                        val[0].set_type( CArrayType.new )
    476533                        result = val[0]
    477534                }
    478         | direct_declarator '(' parameter_type_list ')'
     535                | direct_declarator '(' parameter_type_list ')'
    479536                {
    480537                #       Generator.warning( "W6001 need 'void' for no parameter"  )
     
    482539                        result = val[0]
    483540                }
    484 
    485 #        | direct_declarator '(' identifier_list ')'  # これは何のために必要? 060211
    486         | direct_declarator '(' ')'
     541                | direct_declarator '(' identifier_list ')'  # これは何のために必要? 060211
     542                | direct_declarator '(' ')'
    487543                {
    488544                #       Generator.warning( "W6002 need 'void' for no parameter"  )
     
    492548
    493549pointer
    494         : '*'
     550                : '*'
    495551                { result = CPtrType.new }
    496         | '*' type_qualifier
     552                | '*' type_qualifier_list
    497553                {
    498554                        result = CPtrType.new
    499555                        result.set_qualifier( val[1] )
    500556                }
    501         | '*' pointer
     557                | '*' pointer
    502558                {
    503559                        val[1].set_type(CPtrType.new)
    504560                        result = val[1]
    505561                }
    506         | '*' type_qualifier pointer
     562                | '*' type_qualifier_list pointer
    507563                {
    508564                        ptrtype = CPtrType.new
     
    512568                }
    513569
     570type_qualifier_list
     571                : type_qualifier
     572                | type_qualifier_list type_qualifier
    514573
    515574parameter_type_list
    516         : parameter_list
    517         | parameter_list ',' '.' '.' '.'
     575                : parameter_list
     576                | parameter_list ',' '.' '.' '.'
    518577                # mikan 可変長パラメータ,  ... の間のスペースが許される(手抜き)
    519578
    520579parameter_list
    521         : parameter_declaration
     580                : parameter_declaration
    522581#               { result = ParamList.new( val[0] ) }
    523         | parameter_list ',' parameter_declaration
     582                | parameter_list ',' parameter_declaration
    524583#               {
    525584#                       val[0].add_param( val[2] )
     
    530589# パラメータ修飾子を追加
    531590parameter_declaration
    532         : declaration_specifiers declarator
     591                : declaration_specifiers declarator
    533592#               {
    534593#                       decl = ParamDecl.new( val[1], val[0], [] )
     
    545604#                       result = nil
    546605#               }
    547         | declaration_specifiers abstract_declarator    # 仮引数なし
    548         | declaration_specifiers                                                # 仮引数なし
    549 
    550 
    551 #identifier_list       # 060211  不用になった
    552 #        : IDENTIFIER
    553 #        | identifier_list ',' IDENTIFIER
     606                | declaration_specifiers abstract_declarator    # 仮引数なし
     607                | declaration_specifiers                                                # 仮引数なし
     608
     609
     610identifier_list       # 060211  不用になった
     611        : IDENTIFIER
     612        | identifier_list ',' IDENTIFIER
    554613
    555614type_name
    556         : type_specifier_qualifier_list
    557         | type_specifier_qualifier_list abstract_declarator
     615                : specifier_qualifier_list
     616                | specifier_qualifier_list abstract_declarator
    558617
    559618abstract_declarator             # mikan
    560         : pointer
    561         | direct_abstract_declarator
    562         | pointer direct_abstract_declarator
     619                : pointer
     620                | direct_abstract_declarator
     621                | pointer direct_abstract_declarator
    563622
    564623direct_abstract_declarator
    565         : '(' abstract_declarator ')'
    566         | '[' ']'
    567         | '[' constant_expression ']'
    568         | direct_abstract_declarator '[' ']'
    569         | direct_abstract_declarator '[' constant_expression ']'
    570         | '(' ')'
     624                : '(' abstract_declarator ')'
     625                | '[' ']'
     626                | '[' assignment_expression ']'
     627                | direct_abstract_declarator '[' ']'
     628                | direct_abstract_declarator '[' assignment_expression ']'
     629                | '(' ')'
    571630                {
    572631                        Generator.warning( "W6003 need 'void' for no parameter"  )
    573632                }
    574         | '(' parameter_type_list ')'
    575         | direct_abstract_declarator '(' ')'
     633                | '(' parameter_type_list ')'
     634                | direct_abstract_declarator '(' ')'
    576635                {
    577636                        Generator.warning( "W6004 need 'void' for no parameter"  )
    578637                }
    579         | direct_abstract_declarator '(' parameter_type_list ')'
     638                | direct_abstract_declarator '(' parameter_type_list ')'
    580639
    581640# assignment_expressionをconstant_expressionに変更
    582641initializer                     # mikan
    583         : constant_expression
     642                : assignment_expression
    584643                { result = val[0] }
    585         | '{' initializer_list '}'
     644                | '{' initializer_list '}'
    586645                { result = val[1] }
    587         | '{' initializer_list ',' '}'
     646                | '{' initializer_list ',' '}'
    588647                { result = val[1] }
    589         | C_EXP '(' STRING_LITERAL ')'
     648                | C_EXP '(' STRING_LITERAL ')'
    590649                { result = C_EXP.new( val[2] ) }
    591650
    592651initializer_list
    593         : initializer
     652                : initializer
    594653                {
    595654                        result = [ val[0] ]
    596655                }
    597         | initializer_list ',' initializer
     656                | initializer_list ',' initializer
    598657                {
    599658                        val[0] << val[2]
     
    606665#トップレベルの構文規則
    607666C_parser
    608         :
    609         | C_parser extension_statement
     667                :
     668                | C_parser extension_statement
    610669
    611670extension_statement
    612         : statement
    613         | EXTENSION statement
    614 
    615 statement
    616         : typedef
    617         | func_def
    618         | enum_specifier ';'
    619         | struct_specifier ';'
    620         | declaration
    621         | ';'
    622         | error   # エラー回復ポイント
     671                : cdl_statement
     672                | EXTENSION cdl_statement
     673
     674cdl_statement
     675                : typedef
     676                | func_def
     677                | enum_specifier ';'
     678                | struct_specifier ';'
     679                | declaration
     680                | ';'
     681                | error   # エラー回復ポイント
    623682
    624683typedef
    625         : TYPEDEF type_specifier_qualifier_list declarator_list ';'
     684        : TYPEDEF specifier_qualifier_list declarator_list ';'
    626685                {
    627686                        val[2].each{ |i|
     
    633692
    634693declarator_list
    635         : declarator
     694                : declarator
    636695                { result = [ val[0] ] }
    637         | declarator_list ',' declarator
     696                | declarator_list ',' declarator
    638697                { result << val[2] }
    639698
    640699func_def
    641         : declaration_specifiers declarator compoundstatement
    642 
    643 infunc_statement_list
    644         :
    645         | infunc_statement_list infunc_statement
    646 
    647 infunc_statement
    648         : declaration
    649         | ifstatement
    650         | whilestatement
    651         | dowhilestatement
    652         | forstatement
    653         | switchstatement
    654         | labelstatement
    655         | compoundstatement
    656         | gotostatement
    657         | expressionstatement
    658         | ';'
     700                : declaration_specifiers declarator compound_statement
     701
     702statement
     703                : labeled_statement
     704                | compound_statement
     705                | expression_statement
     706                | ifstatement
     707                | whilestatement
     708                | dowhilestatement
     709                | forstatement
     710                | switchstatement
     711                | jump_statement
     712                | asm_statement
     713
     714labeled_statement
     715                : IDENTIFIER ':' statement
     716                | CASE constant_expression ':' statement
     717                | DEFAULT ':' statement
     718
     719compound_statement
     720                : '{' '}'
     721                | '{' block_item_list '}'
     722
     723block_item_list
     724                : block_item
     725                | block_item_list block_item
     726
     727block_item
     728                : declaration
     729                | statement
     730
     731expression_statement
     732                : ';'
     733                | expression ';'
    659734
    660735ifstatement
    661         : IF '(' expression ')' infunc_statement
    662         | IF '(' expression ')' infunc_statement ELSE infunc_statement
     736                : IF '(' expression ')' statement
     737                | IF '(' expression ')' statement ELSE statement
     738
     739switchstatement
     740                : SWITCH '(' expression ')' compound_statement
    663741
    664742whilestatement
    665         : WHILE '(' expression ')' infunc_statement
     743                : WHILE '(' expression ')' statement
    666744
    667745dowhilestatement
    668         : DO infunc_statement WHILE '(' expression ')' ';'
     746                : DO statement WHILE '(' expression ')' ';'
    669747
    670748forstatement
    671         : FOR '(' expression ';' expression ';' expression ')' infunc_statement
    672 
    673 switchstatement
    674         : SWITCH '(' expression ')'  infunc_statment
    675 
    676 labelstatement
    677         : IDENTIFIER ':' infunc_statement
    678         | CASE constant_expression ':' infunc_statement
    679         | DEFAULT ':' infunc_statement
    680 
    681 compoundstatement
    682         : '{' infunc_statement_list '}'
    683 
    684 gotostatement
    685         : GOTO IDENTIFIER ';'
    686         | CONTINUE ';'
    687         | BREAK ';'
    688         | RETURN expression ';'
    689         | RETURN ';'
    690 
    691 expressionstatement
    692         : expression ';'
    693         | unary_expression assignment_operator expression ';'
    694 
    695 assignment_operator
    696         : '='
    697         | '+='
    698         | '-='
    699         | '*='
    700         | '/='
    701         | '%='
    702         | '<<='
    703         | '>>='
    704         | '&='
    705         | '|='
    706         | '^='
    707 
    708 storage_class
    709         : __INLINE__
    710         | INLINE
    711         | __INLINE
    712         | CINLINE
    713         | EXTERN
    714         | STATIC
    715         | AUTO
    716         | REGISTER
     749                : FOR '(' expression_statement expression_statement ')' statement
     750                | FOR '(' expression_statement expression_statement expression ')' statement
     751                | FOR '(' declaration expression_statement ')' statement
     752                | FOR '(' declaration expression_statement expression ')' statement
     753
     754jump_statement
     755                : GOTO IDENTIFIER ';'
     756                | CONTINUE ';'
     757                | BREAK ';'
     758                | RETURN ';'
     759                | RETURN expression ';'
    717760
    718761namespace_identifier
    719         : IDENTIFIER            { result = NamespacePath.new( val[0].val, false ) }
    720         | '::' IDENTIFIER       { result = NamespacePath.new( val[1].val, true ) }
    721         | namespace_identifier '::' IDENTIFIER
     762                : IDENTIFIER            { result = NamespacePath.new( val[0].val, false ) }
     763                | '::' IDENTIFIER       { result = NamespacePath.new( val[1].val, true ) }
     764                | namespace_identifier '::' IDENTIFIER
    722765                { result = val[0].append!( val[2].val ) }
    723766
     767asm_statement
     768                : _ASM {
     769                while true
     770                        # ';' が表れるまで、トークンを読み飛ばす。
     771                        # gcc の構文拡張に対応すべきだが、単純な実装として、';' まで読み飛ばす。
     772                        # トークン単位で読み飛ばしているので、文字列やコメント内の ';' は対象にならない。
     773                        token = next_token
     774                        if token[1].val == ";"
     775                                break
     776                        end
     777                        # p "skip: #{token[1].val}"
     778                end
     779                }
     780
    724781end
    725782
    726783---- inner
    727784
    728   RESERVED = {
    729     # keyword
    730     'typedef' => :TYPEDEF,
    731     'struct' => :STRUCT,
    732     'union' => :UNION,
    733     'sizeof' => :SIZEOF,
    734     'throw' => :THROW,
    735 
    736     # specifier
    737     # types
    738     'void'    => :VOID,
    739     'char'    => :CHAR,
    740     'short'   => :SHORT,
    741 
    742     'volatile'=> :VOLATILE,
    743     'const'   => :CONST,
    744     'extern'   => :EXTERN,
    745 
    746     'long'    => :LONG,
    747     'float'   => :FLOAT,
    748     'double'  => :DOUBLE,
    749     'signed'  => :SIGNED,
    750     'unsigned'=> :UNSIGNED,
    751 
    752     'int'     => :INT,
    753     'enum'    => :ENUM,
    754 
    755     'if'      => :IF,
    756     'else'    => :ELSE,
    757     'while'   => :WHILE,
    758     'do'      => :DO,
    759     'for'     => :FOR,
    760     'case'    => :CASE,
    761     'default' => :DEFAULT,
    762     'goto'    => :GOTO,
    763     'continue' => :CONTINUE,
    764     'break'   => :BREAK,
    765     'return'  => :RETURN,
    766     '__inline__'  => :__INLINE__,
    767     'inline'  => :INLINE,
    768     '__inline'  => :__INLINE,
    769     'Inline'  => :CINLINE,        # inline starting with Capital letter
    770     'static'  => :STATIC,
    771     'register' => :REGISTER,
    772     'auto'    => :AUTO,
    773     '__extension__'    => :EXTENSION,
    774 
    775   }
    776 
    777   @@generator_nest = -1
    778   @@generator_stack = []
    779   @@current_locale = []
    780 
    781   def finalize
    782 
    783     # mikan Namespace.pop
    784     Celltype.pop
    785     Cell.pop
    786     CompositeCelltype.pop
    787     Region.pop
    788 
    789   end
    790 
    791   def set_plugin( plugin )
    792     @plugin = plugin
    793   end
    794 
    795   def self.get_plugin
    796     @@generator_stack[@@generator_nest].get_plugin
    797   end
    798 
    799   def get_plugin
    800     @plugin
    801   end
    802 
    803   def parse(files)
    804 
    805     # mikan Namespace.push
    806     Celltype.push
    807     Cell.push
    808     CompositeCelltype.push
    809     Region.push
    810 
    811     @@generator_nest += 1
    812     @@generator_stack[@@generator_nest] = self
    813     @b_no_type_name = false
    814 
    815    begin
    816 
    817     @q = []
    818     comment = false
    819 
    820     # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策
    821     TECS_LANG::set_kcode_binary
    822 
    823     # 800U, 0xffLL など (整数リテラルに共通の修飾子)
    824     integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
    825 
    826     files.each {|file|
    827       lineno = 1
    828      begin
    829 #2.0       IO.foreach(file) {|line|
    830        TECSIO.foreach(file) {|line|
    831         col = 1
    832         line.rstrip!
    833 
    834         until line.empty?
    835 
    836           if comment
    837             case line
    838             # コメント終了
    839             when /\A\*\//
    840               comment = false
    841             when /\A./
    842               ;
    843             end
    844           else
    845             case line
    846             # 空白、プリプロセスディレクティブ
    847             when /\A\s+/
    848               ;
    849             # 識別子
    850             when /\A[a-zA-Z_]\w*/
    851               word = $&
    852               @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
    853             # 16 進数定数
    854             when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
    855               @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
    856             # 8 進数定数
    857             when /\A0[0-7]+#{integer_qualifier}/
    858               @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
    859             # 浮動小数定数
    860             when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
    861               @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
    862             # 整数定数
    863             when /\A\d+#{integer_qualifier}/
    864             # when /\A\d+/
    865               @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
    866             # 文字
    867             when /\A'(?:[^'\\]|\\.)'/
    868               @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
    869             # 文字列
    870 #              "#include  #include #include \"../systask/logtask.cfg\"       最後の " 忘れ)で無限ループ
    871 #            when /\A"(?:[^"\\]+|\\.)*"/
    872             when /\A"(?:[^"\\]|\\.)*"/   # これはうまく行くようだ
    873               @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
    874             # 行コメント
    875             when /\A\/\/.*$/
    876               # 読み飛ばすだけ
    877             # コメント開始
    878             when /\A\/\*/
    879               comment = true
    880             when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
    881               @q << [$&, Token.new($&, file, lineno, col)]
    882             when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
    883               @q << [$&, Token.new($&, file, lineno, col)]
    884             when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
    885               @q << [$&, Token.new($&, file, lineno, col)]
    886             when /\A./
    887               @q << [$&, Token.new($&, file, lineno, col)]
    888             else
    889               raise
    890             end
    891           end
    892 
    893           line = $'
    894           col += $&.length
    895         end
    896 
    897         lineno += 1
    898       }
    899 
    900      rescue => evar
    901        Generator.error( "B1002 while open or reading \'$1\'" , file )
    902        print_exception( evar )
    903      end
    904     }
    905 
    906     # 終了の印
    907     @q << nil
    908 
    909     @yydebug = true
    910     do_parse
    911 
    912    ensure
    913     @@generator_nest -= 1
    914     TECS_LANG::reset_kcode
    915    end
    916 
    917   end
    918 
    919 
    920   def next_token
    921     token = @q.shift
    922 
    923     if token then
    924       @@current_locale[@@generator_nest] = token[1].locale
    925 
    926       case token[1].val
    927       when ";", ":", ",", "(", ")", "{", "}"
    928         set_no_type_name false
    929       when ".", "->"
    930         set_no_type_name true
    931       end
    932 
    933       # TYPE_NAME トークンへ置き換え
    934       if @b_no_type_name == false
    935         if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
    936           token[0] = :TYPE_NAME
    937           locale = @@current_locale[@@generator_nest]
     785        RESERVED = {
     786                # keyword
     787                'typedef' => :TYPEDEF,
     788                'struct' => :STRUCT,
     789                'union' => :UNION,
     790                'sizeof' => :SIZEOF,
     791                'throw' => :THROW,
     792
     793                # specifier
     794                # types
     795                'void'    => :VOID,
     796                'char'    => :CHAR,
     797                'short'   => :SHORT,
     798
     799                'volatile'=> :VOLATILE,
     800                'restrict'=> :RESTRICT,
     801                'const'   => :CONST,
     802                'extern'   => :EXTERN,
     803
     804                'long'    => :LONG,
     805                'float'   => :FLOAT,
     806                'double'  => :DOUBLE,
     807                'signed'  => :SIGNED,
     808                'unsigned'=> :UNSIGNED,
     809
     810                'int'     => :INT,
     811                'enum'    => :ENUM,
     812
     813                'if'      => :IF,
     814                'else'    => :ELSE,
     815                'while'   => :WHILE,
     816                'do'      => :DO,
     817                'for'     => :FOR,
     818                'switch'  => :SWITCH,
     819                'case'    => :CASE,
     820                'default' => :DEFAULT,
     821                'goto'    => :GOTO,
     822                'continue' => :CONTINUE,
     823                'break'   => :BREAK,
     824                'return'  => :RETURN,
     825                '__inline__'  => :__INLINE__,
     826                'inline'  => :INLINE,
     827                '__inline'  => :__INLINE,
     828                'Inline'  => :CINLINE,        # inline starting with Capital letter
     829                'static'  => :STATIC,
     830                'register' => :REGISTER,
     831                'auto'    => :AUTO,
     832                '__extension__'    => :EXTENSION,
     833                '__asm__' => :_ASM,
     834                'asm' =>     :_ASM
     835
     836        }
     837
     838        @@generator_nest = -1
     839        @@generator_stack = []
     840        @@current_locale = []
     841
     842        def finalize
     843
     844                # mikan Namespace.pop
     845                Celltype.pop
     846                Cell.pop
     847                CompositeCelltype.pop
     848                Region.pop
     849
     850        end
     851
     852        def set_plugin( plugin )
     853                @plugin = plugin
     854        end
     855
     856        def self.get_plugin
     857                @@generator_stack[@@generator_nest].get_plugin
     858        end
     859
     860        def get_plugin
     861                @plugin
     862        end
     863
     864        def parse(files)
     865
     866                # mikan Namespace.push
     867                Celltype.push
     868                Cell.push
     869                CompositeCelltype.push
     870                Region.push
     871
     872                @@generator_nest += 1
     873                @@generator_stack[@@generator_nest] = self
     874                @b_no_type_name = false
     875
     876        begin
     877
     878                @q = []
     879                comment = false
     880#               b_asm   = false
     881
     882                # euc のコメントを utf8 として扱うと、コメントの終わりを誤る問題の対策
     883                TECS_LANG::set_kcode_binary
     884
     885                # 800U, 0xffLL など (整数リテラルに共通の修飾子)
     886                integer_qualifier = "([Uu][Ll][Ll]|[Uu][Ll]|[Uu]|[Ll][Ll]|[Ll])?"
     887
     888                files.each {|file|
     889                        lineno = 1
     890                begin
     891#2.0            IO.foreach(file) {|line|
     892                        TECSIO.foreach(file) {|line|
     893                        col = 1
     894                        line.rstrip!
     895
     896                        until line.empty?
     897
     898                                if comment
     899                                        case line
     900                                        # コメント終了
     901                                        when /\A\*\//
     902                                                comment = false
     903                                        when /\A./
     904                                                ;
     905                                        end
     906                                else
     907                                        case line
     908                                        # 空白、プリプロセスディレクティブ
     909                                        when /\A\s+/
     910                                                ;
     911                                        # 識別子
     912                                        when /\A[a-zA-Z_]\w*/
     913                                                word = $&
     914                                                @q << [RESERVED[word] || :IDENTIFIER, Token.new(word.intern, file, lineno, col)]
     915                                        # 16 進数定数
     916                                        when /\A0x[0-9A-Fa-f]+#{integer_qualifier}/
     917                                                @q << [:HEX_CONSTANT, Token.new($&, file, lineno, col)]
     918                                        # 8 進数定数
     919                                        when /\A0[0-7]+#{integer_qualifier}/
     920                                                @q << [:OCTAL_CONSTANT, Token.new($&, file, lineno, col)]
     921                                        # 浮動小数定数
     922                                        when /\A[0-9]+\.([0-9]*)?([Ee][+-]?[0-9]+)?/
     923                                                @q << [:FLOATING_CONSTANT, Token.new($&, file, lineno, col)]
     924                                        # 整数定数
     925                                        when /\A\d+#{integer_qualifier}/
     926                                        # when /\A\d+/
     927                                                @q << [:INTEGER_CONSTANT, Token.new($&.to_i, file, lineno, col)]
     928                                        # 文字
     929                                        when /\A'(?:[^'\\]|\\.)'/
     930                                                @q << [:CHARACTER_LITERAL, Token.new($&, file, lineno, col)]
     931                                        # 文字列
     932#                                       "#include  #include #include \"../systask/logtask.cfg\"       最後の " 忘れ)で無限ループ
     933#                                       when /\A"(?:[^"\\]+|\\.)*"/
     934                                        when /\A"(?:[^"\\]|\\.)*"/   # これはうまく行くようだ
     935                                                @q << [:STRING_LITERAL, Token.new($&, file, lineno, col)]
     936                                        # 行コメント
     937                                        when /\A\/\/.*$/
     938                                                # 読み飛ばすだけ
     939                                        # コメント開始
     940                                        when /\A\/\*/
     941                                                comment = true
     942                                        when /\A>>=/, /\A<<=/, /\A>>/,  /\A<</
     943                                                @q << [$&, Token.new($&, file, lineno, col)]
     944                                        when /\A\+=/, /\A\-=/, /\A\*=/, /\A\/=/, /\A%=/, /\A&=/, /\A\|=/, /\A\^=/
     945                                                @q << [$&, Token.new($&, file, lineno, col)]
     946                                        when /\A::/, /\A==/, /\A!=/, /\A>=/, /\A<=/, /\A\->/, /\A\+\+/, /\A\-\-/
     947                                                @q << [$&, Token.new($&, file, lineno, col)]
     948                                        when /\A\|\|/, /\A\&\&/
     949                                                @q << [$&, Token.new($&, file, lineno, col)]
     950                                        when /\A./
     951                                                @q << [$&, Token.new($&, file, lineno, col)]
     952                                        else
     953                                                raise
     954                                        end
     955                                end
     956
     957                                line = $'
     958                                col += $&.length
     959                        end
     960
     961                        lineno += 1
     962                }
     963
     964                rescue => evar
     965                        Generator.error( "B1002 while open or reading \'$1\'" , file )
     966                        print_exception( evar )
     967                end
     968        }
     969
     970        # 終了の印
     971        @q << nil
     972
     973        @yydebug = true
     974        do_parse
     975
     976        ensure
     977                @@generator_nest -= 1
     978                TECS_LANG::reset_kcode
     979        end
     980
     981        end
     982
     983
     984        def next_token
     985                token = @q.shift
     986
     987                if token then
     988                        @@current_locale[@@generator_nest] = token[1].locale
     989
     990                        case token[1].val
     991                        when ";", ":", ",", "(", ")", "{", "}"
     992                        set_no_type_name false
     993                        when ".", "->"
     994                        set_no_type_name true
     995                        end
     996
     997                        # TYPE_NAME トークンへ置き換え
     998                        if @b_no_type_name == false
     999                                if token[0] == :IDENTIFIER && Namespace.is_typename?( token[1].val ) then
     1000                                        token[0] = :TYPE_NAME
     1001                                        locale = @@current_locale[@@generator_nest]
    9381002#print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}: type_name'\n" )
    939         end
    940       end
    941 
    942       if $debug then     # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生)
    943         locale = @@current_locale[@@generator_nest]
    944         if token then
    945           print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
    946         else
    947           print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
    948         end
    949       end
    950     end
    951 
    952     token
    953   end
    954 
    955   def on_error(t, v, vstack)
    956     if v == "$" then
    957      Generator.error( "B1003 Unexpected EOF"  )
    958     else
    959      Generator.error( "B1004 syntax error near \'$1\'" , v.val )
    960     end
    961 
    962   end
    963 
    964   def self.current_locale
    965     @@current_locale[ @@generator_nest ]
    966   end
    967 
    968   @@n_error = 0
    969   @@n_warning = 0
    970   @@n_info = 0
    971 
    972   # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切)
    973   def self.error( msg )
    974     @@n_error += 1
    975     locale = @@current_locale[ @@generator_nest ]
    976 
    977     if locale then
    978       Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
    979     else
    980       Console.puts "error: #{msg}"
    981     end
    982   end
    983 
    984   # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切)
    985   def self.warning( msg )
    986     @@n_warning += 1
    987     locale = @@current_locale[ @@generator_nest ]
    988     Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
    989   end
    990 
    991   # このメソッドは構文解析、意味解析からのみ呼出し可
    992   def self.info( msg )
    993     @@n_info += 1
    994     locale = @@current_locale[ @@generator_nest ]
    995     Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
    996   end
    997 
    998   def self.get_n_error
    999     @@n_error
    1000   end
    1001 
    1002   def self.get_n_warning
    1003     @@n_warning
    1004   end
    1005 
    1006   def self.get_nest
    1007     @@generator_nest
    1008   end
    1009 
    1010   def set_no_type_name b_no_type_name
    1011     locale = @@current_locale[ @@generator_nest ]
     1003                                end
     1004                        end
     1005
     1006                        if $debug then     # 070107 token 無効時ここを通さないようした (through 対応 -d の時に例外発生)
     1007                                locale = @@current_locale[@@generator_nest]
     1008                                if token then
     1009                                        print( "#{locale[0]}: line #{locale[1]} : #{token[0]} '#{token[1].val}'\n" )
     1010                                else
     1011                                        print( "#{locale[0]}: line #{locale[1]} : EOF\n" )
     1012                                end
     1013                        end
     1014                end
     1015
     1016                token
     1017        end
     1018
     1019        def on_error(t, v, vstack)
     1020                if v == "$" then
     1021                        Generator.error( "B1003 Unexpected EOF"  )
     1022                else
     1023                        Generator.error( "B1004 syntax error near \'$1\'" , v.val )
     1024                end
     1025
     1026        end
     1027
     1028        def self.current_locale
     1029                @@current_locale[ @@generator_nest ]
     1030        end
     1031
     1032        @@n_error = 0
     1033        @@n_warning = 0
     1034        @@n_info = 0
     1035
     1036        # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でエラー発生は不適切)
     1037        def self.error( msg )
     1038                @@n_error += 1
     1039                locale = @@current_locale[ @@generator_nest ]
     1040
     1041                if locale then
     1042                        Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
     1043                else
     1044                        Console.puts "error: #{msg}"
     1045                end
     1046        end
     1047
     1048        # このメソッドは構文解析、意味解析からのみ呼出し可(コード生成でウォーニング発生は不適切)
     1049        def self.warning( msg )
     1050                @@n_warning += 1
     1051                locale = @@current_locale[ @@generator_nest ]
     1052                Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     1053        end
     1054
     1055        # このメソッドは構文解析、意味解析からのみ呼出し可
     1056        def self.info( msg )
     1057                @@n_info += 1
     1058                locale = @@current_locale[ @@generator_nest ]
     1059                Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     1060        end
     1061
     1062        def self.get_n_error
     1063                @@n_error
     1064        end
     1065
     1066        def self.get_n_warning
     1067                @@n_warning
     1068        end
     1069
     1070        def self.get_nest
     1071                @@generator_nest
     1072        end
     1073
     1074        def set_no_type_name b_no_type_name
     1075                locale = @@current_locale[ @@generator_nest ]
    10121076#print "b_no_type_name=#{b_no_type_name} #{locale[0]}: line #{locale[1]}\n"
    1013     @b_no_type_name = b_no_type_name
    1014   end
     1077                @b_no_type_name = b_no_type_name
     1078        end
    10151079
    10161080---- footer
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.tab.rb

    r337 r374  
    284284                  string += line
    285285                  # この位置では error メソッドは使えない (token 読出し前)
    286                   puts "error: #{file} line #{lineno}: string literal has newline without escape"
     286                  puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape"
    287287                  @@n_error += 1
    288288                end
     
    325325                  b_in_string = true
    326326                  # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない
    327                   puts "error: #{file} line #{lineno}: string literal has newline without escape"
     327                  puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape"
    328328                  @@n_error += 1
    329329                # 山括弧で囲まれた文字列
    330                 when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
     330                # when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
     331                when /\A<(?:[^>\\]|\\.)*>/   # これはうまく行くようだ
    331332                  @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)]
    332333                # 行コメント
     
    458459      end
    459460      if locale then
    460         Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
     461        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: error: #{msg}"
    461462      else
    462463        Console.puts "error: #{msg}"
     
    491492      end
    492493      if locale then
    493         Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     494        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: warning: #{msg}"
    494495      else
    495496        Console.puts "warning: #{msg}"
     
    524525      end
    525526      if locale then
    526         Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     527        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: info: #{msg}"
    527528      else
    528529        Console.puts "info: #{msg}"
     
    589590
    590591clist = [
    591 '66,575,328,666,538,872,78,330,562,328,78,78,78,163,199,200,201,202,203',
    592 '204,205,207,846,208,678,700,897,135,647,212,213,214,215,216,217,218',
    593 '679,249,761,711,565,547,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
     592'66,575,328,559,538,815,78,330,869,328,78,78,78,409,199,200,201,202,203',
     593'204,205,207,846,208,678,135,897,135,647,212,213,214,215,216,217,218',
     594'249,679,177,872,870,408,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
    594595'25,26,27,28,29,30,31,32,33,34,35,38,465,189,693,333,334,42,43,44,45',
    595 '46,47,48,49,896,180,644,256,559,177,815,163,135,189,135,135,135,135',
    596 '189,66,189,189,70,68,69,135,71,72,328,73,78,74,304,305,324,860,901,189',
    597 '255,162,325,136,327,189,75,75,75,76,77,77,77,135,88,189,189,189,189',
    598 '79,87,101,80,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
    599 '29,30,31,32,33,34,35,38,78,426,569,668,899,42,43,44,45,46,47,48,49,189',
    600 '178,189,136,66,136,136,136,136,256,135,446,89,100,78,78,136,328,70,68',
    601 '69,667,71,72,135,73,571,74,304,305,324,135,135,135,478,868,325,479,327',
    602 '867,399,75,136,76,89,77,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
    603 '25,26,27,28,29,30,31,32,33,34,35,38,450,48,49,400,839,42,43,44,45,46',
    604 '47,48,49,135,135,328,838,66,304,305,306,607,307,308,310,311,406,208',
    605 '78,136,136,70,68,69,401,71,72,797,73,150,74,78,149,136,654,304,305,324',
    606 '78,796,136,136,136,325,75,327,76,407,77,5,6,7,10,13,14,15,16,17,18,19',
    607 '20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,835,163,403,661,402',
    608 '42,43,44,45,46,47,48,49,163,648,826,403,88,697,136,136,432,78,87,681',
    609 '816,574,89,208,520,720,70,68,69,660,71,72,532,73,196,74,510,636,827',
    610 '199,200,201,202,203,204,205,207,208,208,75,682,76,135,77,212,213,214',
    611 '215,216,217,218,304,305,306,889,307,308,310,311,199,200,201,202,203',
    612 '204,205,207,817,208,635,747,518,135,637,212,213,214,215,216,217,218',
    613 '529,888,415,199,200,201,202,203,204,205,207,341,208,342,528,343,135',
    614 '234,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,414',
    615 '208,270,878,235,135,719,212,213,214,215,216,217,218,525,277,589,504',
    616 '691,314,180,136,582,590,721,581,199,200,201,202,203,204,205,207,879',
    617 '208,720,587,163,135,776,212,213,214,215,216,217,218,503,690,313,136',
    618 '199,200,201,202,203,204,205,207,264,208,523,698,282,135,770,212,213',
    619 '214,215,216,217,218,347,582,136,275,581,348,349,898,180,850,199,200',
    620 '201,202,203,204,205,207,163,208,699,283,91,135,136,212,213,214,215,216',
    621 '217,218,199,200,201,202,203,204,205,207,851,208,722,833,691,135,162',
    622 '212,213,214,215,216,217,218,630,163,88,887,136,902,478,886,87,479,347',
    623 '859,89,163,409,348,349,88,631,699,832,794,903,87,904,234,592,89,629',
    624 '170,136,199,200,201,202,203,204,205,207,858,208,564,408,90,135,235,212',
    625 '213,214,215,216,217,218,522,199,200,201,202,203,204,205,207,136,208',
    626 '521,150,906,135,149,212,213,214,215,216,217,218,199,200,201,202,203',
    627 '204,205,207,136,208,394,395,396,135,360,212,213,214,215,216,217,218',
    628 '199,200,201,202,203,204,205,207,361,208,394,395,396,135,362,212,213',
    629 '214,215,216,217,218,145,146,363,199,200,201,202,203,204,205,207,437',
    630 '208,287,288,454,135,136,212,213,214,215,216,217,218,234,354,355,356',
    631 '357,591,436,438,439,440,441,456,457,458,455,136,347,350,351,515,235',
    632 '348,349,199,200,201,202,203,204,205,207,907,208,352,353,514,135,136',
    633 '212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,513,208',
    634 '358,359,512,135,136,212,213,214,215,216,217,218,364,365,511,199,200',
    635 '201,202,203,204,205,207,208,208,404,336,482,135,136,212,213,214,215',
    636 '216,217,218,199,200,201,202,203,204,205,207,481,208,517,518,474,135',
    637 '473,212,213,214,215,216,217,218,472,199,200,201,202,203,204,205,207',
    638 '470,208,350,351,463,135,136,212,213,214,215,216,217,218,350,351,234',
    639 '354,355,356,357,607,454,737,738,740,741,437,136,88,352,353,196,739,785',
    640 '87,235,608,234,89,610,743,742,456,457,458,455,436,438,439,440,441,611',
    641 '136,354,355,356,357,235,352,353,199,200,201,202,203,204,205,207,336',
    642 '208,352,353,612,135,136,212,213,214,215,216,217,218,614,199,200,201',
    643 '202,203,204,205,207,472,208,352,353,615,135,136,212,213,214,215,216',
    644 '217,218,199,200,201,202,203,204,205,207,616,208,358,359,617,135,618',
    645 '212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,208,208',
    646 '594,336,908,135,621,212,213,214,215,216,217,218,620,288,163,199,200',
    647 '201,202,203,204,205,207,462,208,787,788,459,135,136,212,213,214,215',
    648 '216,217,218,625,199,200,201,202,203,204,205,207,448,208,789,790,445',
     596'46,47,48,49,896,88,644,406,666,761,711,87,135,871,135,135,135,135,189',
     597'66,189,189,70,68,69,135,71,72,328,73,78,74,304,305,324,860,901,189,407',
     598'136,325,136,327,189,75,75,75,76,77,77,77,135,874,178,189,189,189,79',
     599'875,101,80,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
     600'29,30,31,32,33,34,35,38,78,364,365,256,899,42,43,44,45,46,47,48,49,189',
     601'189,189,136,66,136,136,136,136,878,135,135,89,100,78,78,136,328,70,68',
     602'69,399,71,72,135,73,877,74,304,305,324,135,446,135,478,868,325,479,327',
     603'867,879,75,136,76,89,77,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
     604'25,26,27,28,29,30,31,32,33,34,35,38,450,48,49,314,838,42,43,44,45,46',
     605'47,48,49,135,135,839,135,66,304,305,306,135,307,308,310,311,691,838',
     606'78,136,136,70,68,69,313,71,72,275,73,880,74,78,180,136,816,304,305,324',
     607'78,881,136,136,136,325,75,327,76,690,77,5,6,7,10,13,14,15,16,17,18,19',
     608'20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,835,426,403,282,697',
     609'42,43,44,45,46,47,48,49,163,817,163,620,288,277,136,136,432,136,180',
     610'504,78,150,136,654,149,720,70,68,69,283,71,72,403,73,402,74,520,636',
     611'162,199,200,201,202,203,204,205,207,328,208,75,503,76,135,77,212,213',
     612'214,215,216,217,218,304,305,306,859,307,308,310,311,199,200,201,202',
     613'203,204,205,207,889,208,635,648,883,135,637,212,213,214,215,216,217',
     614'218,884,858,681,199,200,201,202,203,204,205,207,341,208,342,888,343',
     615'135,234,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207',
     616'682,208,885,668,235,135,661,212,213,214,215,216,217,218,88,789,790,691',
     617'256,400,87,136,150,890,89,149,199,200,201,202,203,204,205,207,667,208',
     618'891,660,163,135,776,212,213,214,215,216,217,218,794,255,401,136,199',
     619'200,201,202,203,204,205,207,892,208,719,415,850,135,162,212,213,214',
     620'215,216,217,218,887,898,136,902,886,582,721,903,581,833,199,200,201',
     621'202,203,204,205,207,720,208,414,851,904,135,136,212,213,214,215,216',
     622'217,218,199,200,201,202,203,204,205,207,832,208,722,698,826,135,906',
     623'212,213,214,215,216,217,218,163,163,88,478,136,907,479,582,87,908,581',
     624'607,89,163,3,163,88,910,827,699,699,81,87,352,353,234,89,797,170,770',
     625'136,199,200,201,202,203,204,205,207,796,208,547,587,564,135,235,212',
     626'213,214,215,216,217,218,90,199,200,201,202,203,204,205,207,136,208,394',
     627'395,396,135,91,212,213,214,215,216,217,218,199,200,201,202,203,204,205',
     628'207,136,208,394,395,396,135,92,212,213,214,215,216,217,218,199,200,201',
     629'202,203,204,205,207,163,208,350,351,96,135,124,212,213,214,215,216,217',
     630'218,594,336,125,199,200,201,202,203,204,205,207,126,208,130,510,132',
     631'135,136,212,213,214,215,216,217,218,134,199,200,201,202,203,204,205',
     632'207,140,208,352,353,142,135,136,212,213,214,215,216,217,218,199,200',
     633'201,202,203,204,205,207,143,208,404,336,144,135,136,212,213,214,215',
     634'216,217,218,199,200,201,202,203,204,205,207,147,208,358,359,155,135',
     635'136,212,213,214,215,216,217,218,350,351,156,199,200,201,202,203,204',
     636'205,207,159,208,350,351,160,135,136,212,213,214,215,216,217,218,164',
     637'199,200,201,202,203,204,205,207,165,208,358,359,166,135,136,212,213',
     638'214,215,216,217,218,199,200,201,202,203,204,205,207,167,208,630,437',
     639'168,135,136,212,213,214,215,216,217,218,352,353,234,747,518,171,631',
     640'287,288,436,438,439,440,441,136,347,629,172,347,173,348,349,235,348',
     641'349,199,200,201,202,203,204,205,207,174,208,352,353,175,135,136,212',
     642'213,214,215,216,217,218,176,199,200,201,202,203,204,205,207,180,208',
     643'184,772,185,135,136,212,213,214,215,216,217,218,199,200,201,202,203',
     644'204,205,207,454,208,145,146,186,135,136,212,213,214,215,216,217,218',
     645'347,187,234,517,518,348,349,456,457,458,455,199,200,201,202,203,204',
     646'205,207,454,208,188,235,189,135,191,212,213,214,215,216,217,218,354',
     647'355,356,357,787,788,136,456,457,458,455,354,355,356,357,199,200,201',
     648'202,203,204,205,207,437,208,382,383,384,135,136,212,213,214,215,216',
     649'217,218,377,378,379,380,381,385,436,438,439,440,441,304,305,306,136',
     650'307,308,310,311,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
     651'28,29,30,31,32,33,34,35,38,136,354,355,356,357,42,43,44,45,46,47,48',
     652'49,199,200,201,202,203,204,205,207,192,208,352,353,193,135,196,212,213',
     653'214,215,216,217,218,247,89,136,199,200,201,202,203,204,205,207,257,208',
     654'159,264,208,135,270,212,213,214,215,216,217,218,199,200,201,202,203',
     655'204,205,207,180,208,272,279,280,135,281,212,213,214,215,216,217,218',
     656'234,284,285,286,289,290,199,200,201,202,203,204,205,207,312,208,335',
     657'189,336,135,235,212,213,214,215,216,217,218,360,199,200,201,202,203',
     658'204,205,207,136,208,361,670,362,135,363,212,213,214,215,216,217,218',
     659'199,200,201,202,203,204,205,207,368,208,369,136,371,135,372,212,213',
     660'214,215,216,217,218,159,199,200,201,202,203,204,205,207,405,208,136',
     661'587,410,135,142,212,213,214,215,216,217,218,412,413,199,200,201,202',
     662'203,204,205,207,416,208,417,418,419,135,136,212,213,214,215,216,217',
     663'218,420,199,200,201,202,203,204,205,207,421,208,444,445,448,135,136',
     664'212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,459,208',
     665'462,772,463,135,136,212,213,214,215,216,217,218,470,88,234,88,382,383',
     666'384,87,472,87,473,89,474,89,481,136,377,378,379,380,381,385,235,482',
     667'208,199,200,201,202,203,204,205,207,511,208,512,513,514,135,136,212',
     668'213,214,215,216,217,218,515,199,200,201,202,203,204,205,207,521,208',
     669'522,523,264,135,136,212,213,214,215,216,217,218,199,200,201,202,203',
     670'204,205,207,525,208,270,528,529,135,136,212,213,214,215,216,217,218',
     671'199,200,201,202,203,204,205,207,208,208,532,208,208,135,180,212,213',
     672'214,215,216,217,218,536,537,540,199,200,201,202,203,204,205,207,541',
     673'208,542,544,545,135,136,212,213,214,215,216,217,218,737,738,740,741',
     674'548,189,270,558,562,196,739,737,738,740,741,136,565,189,743,742,196',
     675'739,234,592,569,88,88,571,88,743,742,87,87,88,87,89,89,136,89,87,328',
     676'574,235,89,196,199,200,201,202,203,204,205,207,589,208,590,700,360,135',
     677'136,212,213,214,215,216,217,218,361,362,472,199,200,201,202,203,204',
     678'205,207,363,208,472,591,607,135,136,212,213,214,215,216,217,218,199',
     679'200,201,202,203,204,205,207,608,208,611,336,612,135,614,212,213,214',
     680'215,216,217,218,199,200,201,202,203,204,205,207,615,208,616,617,618',
     681'135,208,212,213,214,215,216,217,218,621,737,738,740,741,163,625,88,88',
     682'641,196,739,785,87,87,136,643,89,89,743,742,625,662,663,669,674,199',
     683'200,201,202,203,204,205,207,675,208,676,680,683,135,136,212,213,214',
     684'215,216,217,218,199,200,201,202,203,204,205,207,685,208,686,687,688',
     685'135,136,212,213,214,215,216,217,218,472,104,105,106,107,108,109,110',
     686'111,112,113,114,689,189,136,692,208,695,704,5,6,7,10,13,14,15,16,17',
     687'18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,163,706,707',
     688'708,163,42,43,44,45,46,47,48,49,710,712,136,117,118,119,120,121,122',
     689'123,199,200,201,202,203,204,205,207,713,208,714,715,718,135,136,212',
     690'213,214,215,216,217,218,199,200,201,202,203,204,205,207,723,208,726',
     691'571,75,135,729,212,213,214,215,216,217,218,199,200,201,202,203,204,205',
     692'207,730,208,196,744,745,135,748,212,213,214,215,216,217,218,199,200',
     693'201,202,203,204,205,207,749,208,752,753,754,135,756,212,213,214,215',
     694'216,217,218,625,759,760,764,199,200,201,202,203,204,205,207,767,208',
     695'771,779,780,135,136,212,213,214,215,216,217,218,199,200,201,202,203',
     696'204,205,207,782,208,783,791,793,135,136,212,213,214,215,216,217,218',
     697'199,200,201,202,203,204,205,207,189,208,795,798,799,135,136,212,213',
     698'214,215,216,217,218,199,200,201,202,203,204,205,207,800,208,803,804',
     699'805,135,136,212,213,214,215,216,217,218,806,654,718,180,199,200,201',
     700'202,203,204,205,207,811,208,812,813,814,135,136,212,213,214,215,216',
     701'217,218,199,200,201,202,203,204,205,207,726,208,823,828,831,135,136',
     702'212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,836,208',
     703'840,841,-386,135,136,212,213,214,215,216,217,218,199,200,201,202,203',
     704'204,205,207,842,208,843,237,844,135,136,212,213,214,215,216,217,218',
     705'848,803,208,854,199,200,201,202,203,204,205,207,857,208,862,863,865',
    649706'135,136,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207',
    650 '444,208,421,772,641,135,136,212,213,214,215,216,217,218,88,88,234,382',
    651 '383,384,87,87,420,643,89,89,419,418,136,377,378,379,380,381,385,417',
    652 '235,416,625,199,200,201,202,203,204,205,207,413,208,412,662,663,135',
    653 '136,212,213,214,215,216,217,218,142,199,200,201,202,203,204,205,207',
    654 '410,208,405,159,669,135,136,212,213,214,215,216,217,218,199,200,201',
    655 '202,203,204,205,207,372,208,371,369,674,135,136,212,213,214,215,216',
    656 '217,218,199,200,201,202,203,204,205,207,368,208,675,237,676,135,363',
    657 '212,213,214,215,216,217,218,304,305,306,234,307,308,310,311,362,199',
    658 '200,201,202,203,204,205,207,136,208,361,680,360,135,235,212,213,214',
    659 '215,216,217,218,683,199,200,201,202,203,204,205,207,136,208,336,685',
    660 '686,135,687,212,213,214,215,216,217,218,199,200,201,202,203,204,205',
    661 '207,136,208,688,689,189,135,692,212,213,214,215,216,217,218,199,200',
    662 '201,202,203,204,205,207,136,208,335,208,695,135,312,212,213,214,215',
    663 '216,217,218,290,289,286,199,200,201,202,203,204,205,207,285,208,704',
    664 '163,706,135,136,212,213,214,215,216,217,218,737,738,740,741,707,708',
    665 '88,88,163,196,739,710,87,87,284,136,89,89,743,742,712,713,714,199,200',
    666 '201,202,203,204,205,207,715,208,718,281,280,135,136,212,213,214,215',
    667 '216,217,218,199,200,201,202,203,204,205,207,723,208,726,571,75,135,136',
    668 '212,213,214,215,216,217,218,729,730,472,20,21,22,23,24,25,26,27,28,29',
    669 '30,31,32,33,136,196,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25',
    670 '26,27,28,29,30,31,32,33,34,35,38,279,744,745,272,3,42,43,44,45,46,47',
    671 '48,49,748,749,136,117,118,119,120,121,122,123,199,200,201,202,203,204',
    672 '205,207,750,208,610,752,753,135,136,212,213,214,215,216,217,218,199',
    673 '200,201,202,203,204,205,207,754,208,180,756,625,135,759,212,213,214',
    674 '215,216,217,218,199,200,201,202,203,204,205,207,760,208,270,208,264',
    675 '135,764,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207',
    676 '159,208,257,767,89,135,247,212,213,214,215,216,217,218,771,196,193,192',
    677 '199,200,201,202,203,204,205,207,779,208,780,191,782,135,136,212,213',
    678 '214,215,216,217,218,199,200,201,202,203,204,205,207,783,208,189,81,910',
    679 '135,136,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207',
    680 '791,208,188,793,187,135,136,212,213,214,215,216,217,218,199,200,201',
    681 '202,203,204,205,207,795,208,186,670,798,135,136,212,213,214,215,216',
    682 '217,218,799,800,803,804,199,200,201,202,203,204,205,207,805,208,806',
    683 '654,718,135,136,212,213,214,215,216,217,218,737,738,740,741,180,88,88',
    684 '88,811,196,739,87,87,87,136,89,89,89,743,742,812,813,199,200,201,202',
    685 '203,204,205,207,814,208,185,184,726,135,136,212,213,214,215,216,217',
    686 '218,199,200,201,202,203,204,205,207,823,208,180,176,175,135,136,212',
    687 '213,214,215,216,217,218,382,383,384,472,117,118,119,120,121,122,123',
    688 '828,377,378,379,380,381,385,136,5,6,7,10,13,14,15,16,17,18,19,20,21',
    689 '22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,174,173,831,172,171,42',
    690 '43,44,45,46,47,48,49,168,836,136,167,166,840,841,-386,842,843,199,200',
    691 '201,202,203,204,205,207,844,208,165,164,160,135,136,212,213,214,215',
    692 '216,217,218,199,200,201,202,203,204,205,345,848,208,803,159,156,135',
    693 '208,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,854',
    694 '208,155,147,857,135,144,212,213,214,215,216,217,218,199,200,201,202',
    695 '203,204,205,207,143,208,862,863,142,135,865,212,213,214,215,216,217',
    696 '218,140,869,870,871,199,200,201,202,203,204,205,207,134,208,132,874',
    697 '875,135,136,212,213,214,215,216,217,218,199,200,201,202,203,204,205',
    698 '207,130,208,877,126,838,135,136,212,213,214,215,216,217,218,199,200',
    699 '201,202,203,204,205,207,880,208,881,587,328,135,136,212,213,214,215',
    700 '216,217,218,199,200,201,202,203,204,205,207,883,208,884,885,125,135',
    701 '136,212,213,214,215,216,217,218,124,890,891,234,104,105,106,107,108',
    702 '109,110,111,112,113,114,88,892,96,136,92,544,87,545,235,542,89,199,200',
    703 '201,202,203,204,205,207,548,208,189,270,541,135,136,212,213,214,215',
    704 '216,217,218,199,200,201,202,203,204,205,207,540,208,558,537,536,135',
    705 '136,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207,,208',
    706 ',,,135,136,212,213,214,215,216,217,218,199,200,201,202,203,204,205,207',
    707 ',208,,,,135,,212,213,214,215,216,217,218,,,,,199,200,201,202,203,204',
    708 '205,207,,208,,772,,135,136,212,213,214,215,216,217,218,199,200,201,202',
    709 '203,204,205,207,,208,,,,135,136,212,213,214,215,216,217,218,199,200',
    710 '201,202,203,204,205,207,,208,,,,135,136,212,213,214,215,216,217,218',
    711 '199,200,201,202,203,204,205,207,,208,,,,135,136,212,213,214,215,216',
    712 '217,218,,,,,199,200,201,202,203,204,205,207,,208,,,,135,136,212,213',
    713 '214,215,216,217,218,199,200,201,202,203,204,205,207,,208,,,,135,136',
    714 '212,213,214,215,216,217,218,737,738,740,741,,88,,,,196,739,87,,,136',
    715 '89,,,743,742,,,,,,,,,,,,,,,,,136,104,105,106,107,108,109,110,111,112',
    716 '113,114,,,,478,585,,584,,,,,,,89,136,,,,,,,472,,,,,,117,118,119,120',
    717 '121,122,123,,,136,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
    718 '27,28,29,30,31,32,33,34,35,38,241,,78,,,42,43,44,45,46,47,48,49,,,,',
    719 ',,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
    720 '28,29,30,31,32,33,34,35,38,672,,78,,,42,43,44,45,46,47,48,49,,,,,,,',
    721 ',,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
     707',208,,,,135,136,212,213,214,215,216,217,218,199,200,201,202,203,204',
     708'205,207,,208,,,,135,136,212,213,214,215,216,217,218,199,200,201,202',
     709'203,204,205,207,,208,,,,135,136,212,213,214,215,216,217,218,88,,,,,',
     710'87,,,88,89,737,738,740,741,87,,,136,89,196,739,,,,234,,,,743,742,117',
     711'118,119,120,121,122,123,,,136,,,,,235,,,199,200,201,202,203,204,205',
     712'207,,208,,,,135,136,212,213,214,215,216,217,218,199,200,201,202,203',
     713'204,205,207,,208,472,,,135,136,212,213,214,215,216,217,218,199,200,201',
     714'202,203,204,205,345,,208,,,,135,,212,213,214,215,216,217,218,199,200',
     715'201,202,203,204,205,207,,208,,,,135,,212,213,214,215,216,217,218,,,',
     716'104,105,106,107,108,109,110,111,112,113,114,,,,,136,,,,,,,104,105,106',
     717'107,108,109,110,111,112,113,114,,,,,136,117,118,119,120,121,122,123',
     718',,,478,585,,584,,,,,,,89,136,117,118,119,120,121,122,123,20,21,22,23',
     719'24,25,26,27,28,29,30,31,32,33,136,5,6,7,10,13,14,15,16,17,18,19,20,21',
     720'22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,672,,78,,,42,43,44,45,46',
     721'47,48,49,,,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22',
     722'23,24,25,26,27,28,29,30,31,32,33,34,35,38,241,,78,,,42,43,44,45,46,47',
     723'48,49,,,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23',
     724'24,25,26,27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49',
     725',,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
     726'27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,506,,,',
     727',,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
     728'28,29,30,31,32,33,34,35,38,78,428,,,,42,43,44,45,46,47,48,49,,,,,,,',
     729',,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
    722730'29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,',
    723731',,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30',
    724 '31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,506,,,,,,,,,,,,,,,',
    725 ',,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
    726 '32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6',
    727 '7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33',
    728 '34,35,38,78,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13',
    729 '14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38',
    730 '78,428,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15',
    731 '16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,,',
    732 ',,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17',
    733 '18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,387,,,,42',
     732'31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5',
     733'6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33',
     734'34,35,38,78,632,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10',
     735'13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35',
     736'38,78,638,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14',
     737'15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,128',
     738'658,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16',
     739'17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,,,,,42',
    734740'43,44,45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19',
    735 '20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45',
    736 '46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22',
    737 '23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48',
    738 '49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25',
    739 '26,27,28,29,30,31,32,33,34,35,38,128,516,,,,42,43,44,45,46,47,48,49',
     741'20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,516,,,,42,43,44',
     742'45,46,47,48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21',
     743'22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47',
     744'48,49,,,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
     745'25,26,27,28,29,30,31,32,33,34,35,38,78,387,,,,42,43,44,45,46,47,48,49',
    740746',,,,,,,,,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26',
    741747'27,28,29,30,31,32,33,34,35,38,78,,,,,42,43,44,45,46,47,48,49,,,,,,,',
    742748',,,,,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
    743 '29,30,31,32,33,34,35,38,78,632,,,,42,43,44,45,46,47,48,49,,,,,,,,,,',
    744 ',,,,,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29',
    745 '30,31,32,33,34,35,38,78,638,,,,42,43,44,45,46,47,48,49,,,,,,,,,,,,,',
    746 ',,,,,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30',
    747 '31,32,33,34,35,38,,658,,,,42,43,44,45,46,47,48,49,104,105,106,107,108',
    748 '109,110,111,112,113,114,,,,,,,,,,,,,,,,,,,,,,,,,,,,117,118,119,120,121',
    749 '122,123,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29',
    750 '30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15',
    751 '16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,',
    752 '42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24',
    753 '25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6',
    754 '7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33',
    755 '34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19',
    756 '20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45',
    757 '46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28',
    758749'29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14',
    759750'15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,',
    760751',,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23',
    761 '24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47' ]
    762         racc_action_table = arr = ::Array.new(3623, nil)
     752'24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49',
     753'5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32',
     754'33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18',
     755'19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44',
     756'45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27',
     757'28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48,49,5,6,7,10,13',
     758'14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,38',
     759',,,,,42,43,44,45,46,47,48,49,5,6,7,10,13,14,15,16,17,18,19,20,21,22',
     760'23,24,25,26,27,28,29,30,31,32,33,34,35,38,,,,,,42,43,44,45,46,47,48',
     761'49,5,6,7,10,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31',
     762'32,33,34,35,38,,,,,,42,43,44,45,46,47' ]
     763        racc_action_table = arr = ::Array.new(3593, nil)
    763764        idx = 0
    764765        clist.each do |str|
     
    770771
    771772clist = [
    772 '2,469,843,576,422,856,192,194,450,192,329,2,613,434,630,630,630,630',
    773 '630,630,630,630,824,630,596,630,893,630,560,630,630,630,630,630,630',
    774 '630,597,154,703,642,454,434,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2',
    775 '2,2,2,2,2,2,2,2,329,422,613,194,194,2,2,2,2,2,2,2,2,893,414,560,157',
    776 '447,125,777,573,721,460,558,631,303,470,576,291,856,469,2,2,2,839,2',
    777 '2,563,2,291,2,192,192,192,843,895,824,157,573,192,630,192,596,329,2',
    778 '613,2,329,2,613,782,85,703,642,597,154,2,85,41,2,291,291,291,291,291',
     773'2,469,843,447,422,777,192,194,852,192,329,2,613,269,515,515,515,515',
     774'515,515,515,515,824,515,596,325,893,515,560,515,515,515,515,515,515',
     775'515,154,597,125,856,853,269,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2',
     776'2,2,2,2,2,2,2,2,329,422,613,194,194,2,2,2,2,2,2,2,2,893,85,560,267,576',
     777'703,642,85,721,855,631,558,528,511,447,161,777,469,2,2,2,92,2,2,563',
     778'2,161,2,192,192,192,843,895,824,267,325,192,515,192,596,329,2,613,2',
     779'329,2,613,75,860,125,856,154,597,2,861,41,2,161,161,161,161,161,161',
     780'161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161',
     781'161,161,161,161,161,187,230,230,258,895,161,161,161,161,161,161,161',
     782'161,576,703,642,721,185,631,558,528,511,866,691,303,89,41,315,185,92',
     783'315,161,161,161,258,161,161,333,161,863,161,563,563,563,286,308,782',
     784'340,851,563,340,563,851,866,161,75,161,340,161,185,185,185,185,185,185',
     785'185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185',
     786'185,185,185,185,185,315,89,89,190,869,185,185,185,185,185,185,185,185',
     787'839,470,812,692,291,187,187,187,512,187,187,187,187,609,812,291,691',
     788'303,185,185,185,190,185,185,171,185,872,185,778,171,333,778,315,315',
     789'315,294,873,286,308,782,315,185,315,185,609,185,291,291,291,291,291',
    779790'291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,291,291',
    780 '291,291,291,291,291,291,187,291,461,577,895,291,291,291,291,291,291',
    781 '291,291,447,125,777,721,185,558,631,303,470,258,286,308,89,41,315,185',
    782 '839,315,291,291,291,577,291,291,92,291,462,291,563,563,563,512,75,325',
    783 '340,851,563,340,563,851,258,291,782,291,340,291,185,185,185,185,185',
    784 '185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185',
    785 '185,185,185,185,185,185,315,89,89,262,812,185,185,185,185,185,185,185',
    786 '185,511,333,463,812,161,187,187,187,756,187,187,187,187,267,413,161',
    787 '286,308,185,185,185,262,185,185,756,185,148,185,561,148,92,561,315,315',
    788 '315,294,756,512,75,325,315,185,315,185,267,185,161,161,161,161,161,161',
    789 '161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161',
    790 '161,161,161,161,161,808,392,264,568,264,161,161,161,161,161,161,161',
    791 '161,375,561,784,625,127,625,511,333,294,778,127,599,778,465,127,412',
    792 '392,808,161,161,161,568,161,161,411,161,472,161,375,553,784,720,720',
    793 '720,720,720,720,720,720,410,720,161,599,161,720,161,720,720,720,720',
    794 '720,720,720,294,294,294,880,294,294,294,294,257,257,257,257,257,257',
    795 '257,257,778,257,553,684,684,257,553,257,257,257,257,257,257,257,409',
    796 '880,278,474,474,474,474,474,474,474,474,210,474,210,408,210,474,720',
    797 '474,474,474,474,474,474,474,403,403,403,403,403,403,403,403,278,403',
    798 '407,866,720,403,653,403,403,403,403,403,403,403,402,172,480,366,609',
    799 '190,172,720,580,483,653,580,479,479,479,479,479,479,479,479,866,479',
    800 '653,479,716,479,720,479,479,479,479,479,479,479,366,609,190,257,889',
    801 '889,889,889,889,889,889,889,401,889,396,626,176,889,716,889,889,889',
    802 '889,889,889,889,488,477,474,171,477,488,488,894,171,834,504,504,504',
    803 '504,504,504,504,504,102,504,626,176,9,504,403,504,504,504,504,504,504',
    804 '504,862,862,862,862,862,862,862,862,834,862,657,801,751,862,102,862',
    805 '862,862,862,862,862,862,549,115,253,879,479,897,476,879,253,476,221',
    806 '841,253,452,269,221,221,88,549,657,801,751,898,88,901,504,504,88,549',
    807 '115,889,859,859,859,859,859,859,859,859,841,859,452,269,8,859,504,859',
    808 '859,859,859,859,859,859,395,513,513,513,513,513,513,513,513,504,513',
    809 '394,86,904,513,86,513,513,513,513,513,513,513,848,848,848,848,848,848',
    810 '848,848,862,848,254,254,254,848,498,848,848,848,848,848,848,848,359',
    811 '359,359,359,359,359,359,359,499,359,520,520,520,359,500,359,359,359',
    812 '359,359,359,359,82,82,501,358,358,358,358,358,358,358,358,547,358,181',
    813 '181,564,358,859,358,358,358,358,358,358,358,848,496,496,496,496,502',
    814 '547,547,547,547,547,564,564,564,564,513,487,222,222,384,848,487,487',
    815 '806,806,806,806,806,806,806,806,905,806,223,223,383,806,848,806,806',
    816 '806,806,806,806,806,357,357,357,357,357,357,357,357,382,357,225,225',
    817 '381,357,359,357,357,357,357,357,357,357,230,230,380,797,797,797,797',
    818 '797,797,797,797,368,797,265,265,343,797,358,797,797,797,797,797,797',
    819 '797,796,796,796,796,796,796,796,796,342,796,389,389,338,796,337,796',
    820 '796,796,796,796,796,796,335,356,356,356,356,356,356,356,356,334,356',
    821 '489,489,327,356,806,356,356,356,356,356,356,356,490,490,797,495,495',
    822 '495,495,525,318,739,739,739,739,297,357,696,491,491,739,739,739,696',
    823 '797,526,796,696,528,739,739,318,318,318,318,297,297,297,297,297,529',
    824 '797,224,224,224,224,796,492,492,355,355,355,355,355,355,355,355,530',
    825 '355,493,493,531,355,796,355,355,355,355,355,355,355,533,354,354,354',
    826 '354,354,354,354,354,739,354,494,494,534,354,356,354,354,354,354,354',
    827 '354,354,353,353,353,353,353,353,353,353,535,353,497,497,536,353,537',
    828 '353,353,353,353,353,353,353,352,352,352,352,352,352,352,352,538,352',
    829 '505,505,906,352,543,352,352,352,352,352,352,352,539,539,544,748,748',
    830 '748,748,748,748,748,748,326,748,742,742,324,748,355,748,748,748,748',
    831 '748,748,748,548,729,729,729,729,729,729,729,729,309,729,743,743,307',
    832 '729,354,729,729,729,729,729,729,729,719,719,719,719,719,719,719,719',
    833 '306,719,285,719,557,719,353,719,719,719,719,719,719,719,430,602,748',
    834 '246,246,246,430,602,284,559,430,602,283,282,352,246,246,246,246,246',
    835 '246,281,748,280,565,351,351,351,351,351,351,351,351,276,351,274,570',
    836 '572,351,748,351,351,351,351,351,351,351,272,147,147,147,147,147,147',
    837 '147,147,271,147,266,256,578,147,729,147,147,147,147,147,147,147,350',
    838 '350,350,350,350,350,350,350,242,350,240,236,583,350,719,350,350,350',
    839 '350,350,350,350,149,149,149,149,149,149,149,149,235,149,586,149,588',
    840 '149,229,149,149,149,149,149,149,149,546,546,546,147,546,546,546,546',
    841 '228,349,349,349,349,349,349,349,349,351,349,227,598,226,349,147,349',
    842 '349,349,349,349,349,349,600,714,714,714,714,714,714,714,714,147,714',
    843 '206,604,605,714,606,714,714,714,714,714,714,714,348,348,348,348,348',
    844 '348,348,348,350,348,607,608,198,348,611,348,348,348,348,348,348,348',
    845 '710,710,710,710,710,710,710,710,149,710,195,616,619,710,189,710,710',
    846 '710,710,710,710,710,184,183,179,347,347,347,347,347,347,347,347,178',
    847 '347,632,634,636,347,349,347,347,347,347,347,347,347,827,827,827,827',
    848 '637,638,373,288,640,827,827,641,373,288,177,714,373,288,827,827,643',
    849 '644,646,706,706,706,706,706,706,706,706,648,706,651,175,174,706,348',
    850 '706,706,706,706,706,706,706,345,345,345,345,345,345,345,345,658,345',
    851 '662,663,664,345,710,345,345,345,345,345,345,345,665,666,827,36,36,36',
    852 '36,36,36,36,36,36,36,36,36,36,36,347,668,345,345,345,345,345,345,345',
    853 '345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,345',
    854 '345,345,345,345,173,671,673,169,1,345,345,345,345,345,345,345,345,688',
    855 '689,706,260,260,260,260,260,260,260,515,515,515,515,515,515,515,515',
    856 '691,515,692,693,694,515,345,515,515,515,515,515,515,515,166,166,166',
    857 '166,166,166,166,166,695,166,168,697,699,166,700,166,166,166,166,166',
    858 '166,166,341,341,341,341,341,341,341,341,701,341,167,165,164,341,707',
    859 '341,341,341,341,341,341,341,682,682,682,682,682,682,682,682,160,682',
    860 '159,711,152,682,151,682,682,682,682,682,682,682,718,144,141,139,521',
    861 '521,521,521,521,521,521,521,725,521,727,138,730,521,515,521,521,521',
    862 '521,521,521,521,522,522,522,522,522,522,522,522,731,522,137,3,909,522',
    863 '166,522,522,522,522,522,522,522,523,523,523,523,523,523,523,523,746',
    864 '523,136,749,133,523,341,523,523,523,523,523,523,523,581,581,581,581',
    865 '581,581,581,581,755,581,131,581,760,581,682,581,581,581,581,581,581',
    866 '581,761,763,764,766,908,908,908,908,908,908,908,908,767,908,768,769',
    867 '770,908,521,908,908,908,908,908,908,908,783,783,783,783,771,146,518',
    868 '245,772,783,783,146,518,245,522,146,518,245,783,783,773,775,290,290',
    869 '290,290,290,290,290,290,776,290,129,128,780,290,523,290,290,290,290',
    870 '290,290,290,207,207,207,207,207,207,207,207,781,207,126,124,123,207',
    871 '581,207,207,207,207,207,207,207,510,510,510,783,170,170,170,170,170',
    872 '170,170,793,510,510,510,510,510,510,908,207,207,207,207,207,207,207',
     791'291,291,291,291,291,291,808,291,625,176,625,291,291,291,291,291,291',
     792'291,291,392,778,573,539,539,172,839,470,294,692,172,366,561,86,512,561',
     793'86,808,291,291,291,176,291,291,264,291,264,291,392,553,573,720,720,720',
     794'720,720,720,720,720,874,720,291,366,291,720,291,720,720,720,720,720',
     795'720,720,294,294,294,841,294,294,294,294,902,902,902,902,902,902,902',
     796'902,880,902,553,561,876,902,553,902,902,902,902,902,902,902,877,841',
     797'599,889,889,889,889,889,889,889,889,210,889,210,880,210,889,720,889',
     798'889,889,889,889,889,889,521,521,521,521,521,521,521,521,599,521,878',
     799'577,720,521,568,521,521,521,521,521,521,521,430,743,743,751,157,262',
     800'430,720,148,881,430,148,522,522,522,522,522,522,522,522,577,522,882',
     801'568,102,522,720,522,522,522,522,522,522,522,751,157,262,902,523,523',
     802'523,523,523,523,523,523,883,523,653,278,834,523,102,523,523,523,523',
     803'523,523,523,879,894,889,897,879,580,653,898,580,801,234,234,234,234',
     804'234,234,234,234,653,234,278,834,901,234,521,234,234,234,234,234,234',
     805'234,166,166,166,166,166,166,166,166,801,166,657,626,784,166,904,166',
     806'166,166,166,166,166,166,115,716,518,476,522,905,476,477,518,906,477',
     807'756,518,434,1,452,127,909,784,657,626,3,127,494,494,234,127,756,115',
     808'716,523,479,479,479,479,479,479,479,479,756,479,434,479,452,479,234',
     809'479,479,479,479,479,479,479,8,358,358,358,358,358,358,358,358,234,358',
     810'520,520,520,358,9,358,358,358,358,358,358,358,363,363,363,363,363,363',
     811'363,363,166,363,254,254,254,363,16,363,363,363,363,363,363,363,360,360',
     812'360,360,360,360,360,360,375,360,222,222,38,360,68,360,360,360,360,360',
     813'360,360,505,505,69,361,361,361,361,361,361,361,361,70,361,72,375,73',
     814'361,479,361,361,361,361,361,361,361,74,682,682,682,682,682,682,682,682',
     815'76,682,223,223,77,682,358,682,682,682,682,682,682,682,862,862,862,862',
     816'862,862,862,862,79,862,265,265,80,862,363,862,862,862,862,862,862,862',
     817'362,362,362,362,362,362,362,362,84,362,225,225,94,362,360,362,362,362',
     818'362,362,362,362,489,489,95,797,797,797,797,797,797,797,797,100,797,490',
     819'490,101,797,361,797,797,797,797,797,797,797,104,811,811,811,811,811',
     820'811,811,811,106,811,497,497,108,811,682,811,811,811,811,811,811,811',
     821'838,838,838,838,838,838,838,838,110,838,549,297,114,838,862,838,838',
     822'838,838,838,838,838,491,491,797,684,684,117,549,181,181,297,297,297',
     823'297,297,362,487,549,118,221,119,487,487,797,221,221,796,796,796,796',
     824'796,796,796,796,122,796,492,492,123,796,797,796,796,796,796,796,796',
     825'796,124,835,835,835,835,835,835,835,835,126,835,128,835,129,835,811',
     826'835,835,835,835,835,835,835,514,514,514,514,514,514,514,514,318,514',
     827'82,82,131,514,838,514,514,514,514,514,514,514,488,133,796,389,389,488',
     828'488,318,318,318,318,823,823,823,823,823,823,823,823,564,823,136,796',
     829'137,823,138,823,823,823,823,823,823,823,495,495,495,495,742,742,796',
     830'564,564,564,564,224,224,224,224,207,207,207,207,207,207,207,207,547',
     831'207,510,510,510,207,835,207,207,207,207,207,207,207,510,510,510,510',
     832'510,510,547,547,547,547,547,546,546,546,514,546,546,546,546,207,207',
    873833'207,207,207,207,207,207,207,207,207,207,207,207,207,207,207,207,207',
    874 '207,207,207,207,122,119,799,118,117,207,207,207,207,207,207,207,207',
    875 '114,810,290,110,108,814,815,816,817,821,211,211,211,211,211,211,211',
    876 '211,822,211,106,104,101,211,207,211,211,211,211,211,211,211,212,212',
    877 '212,212,212,212,212,212,828,212,833,100,95,212,836,212,212,212,212,212',
    878 '212,212,902,902,902,902,902,902,902,902,837,902,94,84,840,902,80,902',
    879 '902,902,902,902,902,902,591,591,591,591,591,591,591,591,79,591,845,846',
    880 '77,591,850,591,591,591,591,591,591,591,76,852,853,855,575,575,575,575',
    881 '575,575,575,575,74,575,73,860,861,575,211,575,575,575,575,575,575,575',
    882 '234,234,234,234,234,234,234,234,72,234,863,70,869,234,212,234,234,234',
    883 '234,234,234,234,584,584,584,584,584,584,584,584,872,584,873,584,874',
    884 '584,902,584,584,584,584,584,584,584,514,514,514,514,514,514,514,514',
    885 '876,514,877,878,69,514,591,514,514,514,514,514,514,514,68,881,882,234',
    886 '162,162,162,162,162,162,162,162,162,162,162,4,883,38,575,16,431,4,432',
    887 '234,428,4,365,365,365,365,365,365,365,365,437,365,442,443,426,365,234',
    888 '365,365,365,365,365,365,365,364,364,364,364,364,364,364,364,425,364',
    889 '446,419,416,364,584,364,364,364,364,364,364,364,363,363,363,363,363',
    890 '363,363,363,,363,,,,363,514,363,363,363,363,363,363,363,838,838,838',
    891 '838,838,838,838,838,,838,,,,838,,838,838,838,838,838,838,838,,,,,835',
    892 '835,835,835,835,835,835,835,,835,,835,,835,365,835,835,835,835,835,835',
    893 '835,362,362,362,362,362,362,362,362,,362,,,,362,364,362,362,362,362',
    894 '362,362,362,361,361,361,361,361,361,361,361,,361,,,,361,363,361,361',
    895 '361,361,361,361,361,823,823,823,823,823,823,823,823,,823,,,,823,838',
    896 '823,823,823,823,823,823,823,,,,,360,360,360,360,360,360,360,360,,360',
    897 ',,,360,835,360,360,360,360,360,360,360,811,811,811,811,811,811,811,811',
    898 ',811,,,,811,362,811,811,811,811,811,811,811,669,669,669,669,,424,,,',
    899 '669,669,424,,,361,424,,,669,669,,,,,,,,,,,,,,,,,823,54,54,54,54,54,54',
    900 '54,54,54,54,54,,,,478,478,,478,,,,,,,478,360,,,,,,,669,,,,,,54,54,54',
    901 '54,54,54,54,,,811,478,478,478,478,478,478,478,478,478,478,478,478,478',
    902 '478,478,478,478,478,478,478,478,478,478,478,478,478,478,478,150,,150',
    903 ',,478,478,478,478,478,478,478,478,,,,,,,,,,,,,,,,,,,,,150,150,150,150',
     834'207,207,207,207,207,207,207,207,207,823,496,496,496,496,207,207,207',
     835'207,207,207,207,207,748,748,748,748,748,748,748,748,139,748,493,493',
     836'141,748,144,748,748,748,748,748,748,748,151,152,207,859,859,859,859',
     837'859,859,859,859,159,859,160,164,165,859,167,859,859,859,859,859,859',
     838'859,575,575,575,575,575,575,575,575,168,575,169,173,174,575,175,575',
     839'575,575,575,575,575,575,748,177,178,179,183,184,257,257,257,257,257',
     840'257,257,257,189,257,195,198,206,257,748,257,257,257,257,257,257,257',
     841'226,581,581,581,581,581,581,581,581,748,581,227,581,228,581,229,581',
     842'581,581,581,581,581,581,729,729,729,729,729,729,729,729,235,729,236',
     843'859,240,729,242,729,729,729,729,729,729,729,256,584,584,584,584,584',
     844'584,584,584,266,584,575,584,271,584,272,584,584,584,584,584,584,584',
     845'274,276,147,147,147,147,147,147,147,147,280,147,281,282,283,147,257',
     846'147,147,147,147,147,147,147,284,591,591,591,591,591,591,591,591,285',
     847'591,306,307,309,591,581,591,591,591,591,591,591,591,719,719,719,719',
     848'719,719,719,719,324,719,326,719,327,719,729,719,719,719,719,719,719',
     849'719,334,288,147,602,246,246,246,288,335,602,337,288,338,602,342,584',
     850'246,246,246,246,246,246,147,343,368,714,714,714,714,714,714,714,714',
     851'380,714,381,382,383,714,147,714,714,714,714,714,714,714,384,710,710',
     852'710,710,710,710,710,710,394,710,395,396,401,710,591,710,710,710,710',
     853'710,710,710,706,706,706,706,706,706,706,706,402,706,407,408,409,706',
     854'719,706,706,706,706,706,706,706,504,504,504,504,504,504,504,504,410',
     855'504,411,412,413,504,414,504,504,504,504,504,504,504,416,419,425,365',
     856'365,365,365,365,365,365,365,426,365,428,431,432,365,714,365,365,365',
     857'365,365,365,365,827,827,827,827,437,442,443,446,450,827,827,783,783',
     858'783,783,710,454,460,827,827,783,783,504,504,461,4,696,462,373,783,783',
     859'4,696,146,373,4,696,706,373,146,463,465,504,146,472,630,630,630,630',
     860'630,630,630,630,480,630,483,630,498,630,504,630,630,630,630,630,630',
     861'630,499,500,827,364,364,364,364,364,364,364,364,501,364,783,502,525',
     862'364,365,364,364,364,364,364,364,364,908,908,908,908,908,908,908,908',
     863'526,908,529,530,531,908,533,908,908,908,908,908,908,908,341,341,341',
     864'341,341,341,341,341,534,341,535,536,537,341,538,341,341,341,341,341',
     865'341,341,543,739,739,739,739,544,548,88,424,557,739,739,739,88,424,630',
     866'559,88,424,739,739,565,570,572,578,583,347,347,347,347,347,347,347,347',
     867'586,347,588,598,600,347,364,347,347,347,347,347,347,347,345,345,345',
     868'345,345,345,345,345,604,345,605,606,607,345,908,345,345,345,345,345',
     869'345,345,739,162,162,162,162,162,162,162,162,162,162,162,608,610,341',
     870'611,616,619,632,345,345,345,345,345,345,345,345,345,345,345,345,345',
     871'345,345,345,345,345,345,345,345,345,345,345,345,345,345,345,634,636',
     872'637,638,640,345,345,345,345,345,345,345,345,641,643,347,260,260,260',
     873'260,260,260,260,348,348,348,348,348,348,348,348,644,348,646,648,651',
     874'348,345,348,348,348,348,348,348,348,349,349,349,349,349,349,349,349',
     875'658,349,662,663,664,349,665,349,349,349,349,349,349,349,350,350,350',
     876'350,350,350,350,350,666,350,668,671,673,350,688,350,350,350,350,350',
     877'350,350,351,351,351,351,351,351,351,351,689,351,693,694,695,351,697',
     878'351,351,351,351,351,351,351,699,700,701,707,352,352,352,352,352,352',
     879'352,352,711,352,718,725,727,352,348,352,352,352,352,352,352,352,353',
     880'353,353,353,353,353,353,353,730,353,731,746,749,353,349,353,353,353',
     881'353,353,353,353,354,354,354,354,354,354,354,354,750,354,755,760,761',
     882'354,350,354,354,354,354,354,354,354,355,355,355,355,355,355,355,355',
     883'763,355,764,766,767,355,351,355,355,355,355,355,355,355,768,769,770',
     884'771,356,356,356,356,356,356,356,356,772,356,773,775,776,356,352,356',
     885'356,356,356,356,356,356,357,357,357,357,357,357,357,357,780,357,781',
     886'793,799,357,353,357,357,357,357,357,357,357,359,359,359,359,359,359',
     887'359,359,810,359,814,815,816,359,354,359,359,359,359,359,359,359,149',
     888'149,149,149,149,149,149,149,817,149,821,149,822,149,355,149,149,149',
     889'149,149,149,149,828,833,836,837,474,474,474,474,474,474,474,474,840',
     890'474,845,846,850,474,356,474,474,474,474,474,474,474,290,290,290,290',
     891'290,290,290,290,,290,,,,290,357,290,290,290,290,290,290,290,848,848',
     892'848,848,848,848,848,848,,848,,,,848,359,848,848,848,848,848,848,848',
     893'806,806,806,806,806,806,806,806,,806,,,,806,149,806,806,806,806,806',
     894'806,806,245,,,,,,245,,,253,245,669,669,669,669,253,,,474,253,669,669',
     895',,,848,,,,669,669,170,170,170,170,170,170,170,,,290,,,,,848,,,403,403',
     896'403,403,403,403,403,403,,403,,,,403,848,403,403,403,403,403,403,403',
     897'513,513,513,513,513,513,513,513,,513,669,,,513,806,513,513,513,513,513',
     898'513,513,212,212,212,212,212,212,212,212,,212,,,,212,,212,212,212,212',
     899'212,212,212,211,211,211,211,211,211,211,211,,211,,,,211,,211,211,211',
     900'211,211,211,211,,,,464,464,464,464,464,464,464,464,464,464,464,,,,,403',
     901',,,,,,54,54,54,54,54,54,54,54,54,54,54,,,,,513,464,464,464,464,464,464',
     902'464,,,,478,478,,478,,,,,,,478,212,54,54,54,54,54,54,54,36,36,36,36,36',
     903'36,36,36,36,36,36,36,36,36,211,478,478,478,478,478,478,478,478,478,478',
     904'478,478,478,478,478,478,478,478,478,478,478,478,478,478,478,478,478',
     905'478,582,,582,,,478,478,478,478,478,478,478,478,,,,,,,,,,,,,,,,,,,,,582',
     906'582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,582',
     907'582,582,582,582,582,582,582,582,582,582,150,,150,,,582,582,582,582,582',
     908'582,582,582,,,,,,,,,,,,,,,,,,,,,150,150,150,150,150,150,150,150,150',
    904909'150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150,150',
    905 '150,150,150,150,150,150,150,582,,582,,,150,150,150,150,150,150,150,150',
    906 ',,,,,,,,,,,,,,,,,,,,582,582,582,582,582,582,582,582,582,582,582,582',
    907 '582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,582,372',
    908 ',,,,582,582,582,582,582,582,582,582,,,,,,,,,,,,,,,,,,,372,372,372,372',
     910'150,150,372,,,,,150,150,150,150,150,150,150,150,,,,,,,,,,,,,,,,,,,372',
    909911'372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372,372',
    910 '372,372,372,372,372,372,372,459,,,,,372,372,372,372,372,372,372,372',
    911 '372,,,,,,,,,,,,,,,,,,459,459,459,459,459,459,459,459,459,459,459,459',
    912 '459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,250',
    913 ',,,,459,459,459,459,459,459,459,459,,,,,,,,,,,,,,,,,,,250,250,250,250',
     912'372,372,372,372,372,372,372,372,372,372,293,,,,,372,372,372,372,372',
     913'372,372,372,372,,,,,,,,,,,,,,,,,,293,293,293,293,293,293,293,293,293',
     914'293,293,293,293,293,293,293,293,293,293,293,293,293,293,293,293,293',
     915'293,293,444,293,,,,293,293,293,293,293,293,293,293,,,,,,,,,,,,,,,,,',
     916',444,444,444,444,444,444,444,444,444,444,444,444,444,444,444,444,444',
     917'444,444,444,444,444,444,444,444,444,444,444,445,,,,,444,444,444,444',
     918'444,444,444,444,,,,,,,,,,,,,,,,,,,445,445,445,445,445,445,445,445,445',
     919'445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445',
     920'445,445,550,,,,,445,445,445,445,445,445,445,445,,,,,,,,,,,,,,,,,,,550',
     921'550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550,550',
     922'550,550,550,550,550,550,550,550,550,550,554,550,,,,550,550,550,550,550',
     923'550,550,550,,,,,,,,,,,,,,,,,,,554,554,554,554,554,554,554,554,554,554',
     924'554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554',
     925'554,566,554,,,,554,554,554,554,554,554,554,554,,,,,,,,,,,,,,,,,,,566',
     926'566,566,566,566,566,566,566,566,566,566,566,566,566,566,566,566,566',
     927'566,566,566,566,566,566,566,566,566,566,71,566,,,,566,566,566,566,566',
     928'566,566,566,,,,,,,,,,,,,,,,,,,71,71,71,71,71,71,71,71,71,71,71,71,71',
     929'71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,386,,,,,71,71,71,71,71',
     930'71,71,71,,,,,,,,,,,,,,,,,,,386,386,386,386,386,386,386,386,386,386,386',
     931'386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386',
     932'459,386,,,,386,386,386,386,386,386,386,386,,,,,,,,,,,,,,,,,,,459,459',
     933'459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,459,459',
     934'459,459,459,459,459,459,459,459,459,251,,,,,459,459,459,459,459,459',
     935'459,459,,,,,,,,,,,,,,,,,,,251,251,251,251,251,251,251,251,251,251,251',
     936'251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251',
     937'250,251,,,,251,251,251,251,251,251,251,251,,,,,,,,,,,,,,,,,,,250,250',
    914938'250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250',
    915 '250,250,250,250,250,250,250,293,,,,,250,250,250,250,250,250,250,250',
    916 ',,,,,,,,,,,,,,,,,,293,293,293,293,293,293,293,293,293,293,293,293,293',
    917 '293,293,293,293,293,293,293,293,293,293,293,293,293,293,293,445,293',
    918 ',,,293,293,293,293,293,293,293,293,,,,,,,,,,,,,,,,,,,445,445,445,445',
    919 '445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445,445',
    920 '445,445,445,445,445,445,445,251,,,,,445,445,445,445,445,445,445,445',
    921 ',,,,,,,,,,,,,,,,,,251,251,251,251,251,251,251,251,251,251,251,251,251',
    922 '251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,444,251',
    923 ',,,251,251,251,251,251,251,251,251,,,,,,,,,,,,,,,,,,,444,444,444,444',
    924 '444,444,444,444,444,444,444,444,444,444,444,444,444,444,444,444,444',
    925 '444,444,444,444,444,444,444,156,,,,,444,444,444,444,444,444,444,444',
    926 ',,,,,,,,,,,,,,,,,,156,156,156,156,156,156,156,156,156,156,156,156,156',
    927 '156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,386,,,,',
    928 '156,156,156,156,156,156,156,156,,,,,,,,,,,,,,,,,,,386,386,386,386,386',
    929 '386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386,386',
    930 '386,386,386,386,386,386,71,386,,,,386,386,386,386,386,386,386,386,,',
    931 ',,,,,,,,,,,,,,,,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71',
    932 '71,71,71,71,71,71,71,71,71,71,550,,,,,71,71,71,71,71,71,71,71,,,,,,',
    933 ',,,,,,,,,,,,550,550,550,550,550,550,550,550,550,550,550,550,550,550',
    934 '550,550,550,550,550,550,550,550,550,550,550,550,550,550,554,550,,,,550',
    935 '550,550,550,550,550,550,550,,,,,,,,,,,,,,,,,,,554,554,554,554,554,554',
    936 '554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554,554',
    937 '554,554,554,554,554,566,554,,,,554,554,554,554,554,554,554,554,,,,,',
    938 ',,,,,,,,,,,,,566,566,566,566,566,566,566,566,566,566,566,566,566,566',
    939 '566,566,566,566,566,566,566,566,566,566,566,566,566,566,,566,,,,566',
    940 '566,566,566,566,566,566,566,464,464,464,464,464,464,464,464,464,464',
    941 '464,,,,,,,,,,,,,,,,,,,,,,,,,,,,464,464,464,464,464,464,464,244,244,244',
     939'250,250,250,250,250,250,250,250,250,156,,,,,250,250,250,250,250,250',
     940'250,250,,,,,,,,,,,,,,,,,,,156,156,156,156,156,156,156,156,156,156,156',
     941'156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156,156',
     942',,,,,156,156,156,156,156,156,156,156,622,622,622,622,622,622,622,622',
     943'622,622,622,622,622,622,622,622,622,622,622,622,622,622,622,622,622',
     944'622,622,622,,,,,,622,622,622,622,622,622,622,622,40,40,40,40,40,40,40',
     945'40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,,,,,',
     946'40,40,40,40,40,40,40,40,705,705,705,705,705,705,705,705,705,705,705',
     947'705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705',
     948',,,,,705,705,705,705,705,705,705,705,244,244,244,244,244,244,244,244',
    942949'244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244,244',
    943 '244,244,244,244,244,244,244,244,,,,,,244,244,244,244,244,244,244,244',
    944 '40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40,40',
    945 '40,40,40,40,40,,,,,,40,40,40,40,40,40,40,40,289,289,289,289,289,289',
    946 '289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289',
    947 '289,289,289,289,289,,,,,,289,289,289,289,289,289,289,289,709,709,709',
     950'244,244,244,,,,,,244,244,244,244,244,244,244,244,519,519,519,519,519',
     951'519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519',
     952'519,519,519,519,519,519,,,,,,519,519,519,519,519,519,519,519,709,709',
    948953'709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709,709',
    949 '709,709,709,709,709,709,709,709,,,,,,709,709,709,709,709,709,709,709',
    950 '519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519,519',
    951 '519,519,519,519,519,519,519,519,519,519,519,,,,,,519,519,519,519,519',
    952 '519,519,519,622,622,622,622,622,622,622,622,622,622,622,622,622,622',
    953 '622,622,622,622,622,622,622,622,622,622,622,622,622,622,,,,,,622,622',
    954 '622,622,622,622,622,622,705,705,705,705,705,705,705,705,705,705,705',
    955 '705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705,705',
    956 ',,,,,705,705,705,705,705,705,705,705,239,239,239,239,239,239,239,239',
    957 '239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,239',
    958 '239,239,239,,,,,,239,239,239,239,239,239' ]
    959         racc_action_check = arr = ::Array.new(3623, nil)
     954'709,709,709,709,709,709,709,709,709,,,,,,709,709,709,709,709,709,709',
     955'709,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289,289',
     956'289,289,289,289,289,289,289,289,289,289,289,289,,,,,,289,289,289,289',
     957'289,289,289,289,239,239,239,239,239,239,239,239,239,239,239,239,239',
     958'239,239,239,239,239,239,239,239,239,239,239,239,239,239,239,,,,,,239',
     959'239,239,239,239,239' ]
     960        racc_action_check = arr = ::Array.new(3593, nil)
    960961        idx = 0
    961962        clist.each do |str|
     
    967968
    968969racc_action_pointer = [
    969    nil,  1442,    -1,  1586,  1989,   nil,   nil,   nil,   602,   527,
    970    nil,   nil,   nil,   nil,   nil,   nil,  1993,   nil,   nil,   nil,
     970   nil,   613,    -1,   620,  1492,   nil,   nil,   nil,   612,   627,
     971   nil,   nil,   nil,   nil,   nil,   nil,   680,   nil,   nil,   nil,
    971972   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    972    nil,   nil,   nil,   nil,   nil,   nil,  1340,   nil,  1985,   nil,
    973   3295,   123,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    974    nil,   nil,   nil,   nil,  2182,   nil,   nil,   nil,   nil,   nil,
    975    nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,  1974,  1964,
    976   1919,  2991,  1910,  1890,  1888,   198,  1876,  1866,   nil,  1806,
    977   1852,   nil,   679,   nil,  1816,   122,   655,   nil,   607,   174,
    978    nil,   nil,   190,   nil,  1786,  1766,   nil,   nil,   nil,   nil,
    979   1821,  1744,   550,   nil,  1805,   nil,  1804,   nil,  1788,   nil,
    980   1787,   nil,   nil,   nil,  1784,   587,   nil,  1775,  1774,  1772,
    981    nil,   nil,  1771,  1714,  1711,    77,  1706,   350,  1627,  1628,
    982    nil,  1558,   nil,  1538,   nil,   nil,  1592,  1477,  1549,  1481,
    983    nil,  1480,   nil,   nil,  1539,   nil,  1663,  1133,   285,  1177,
    984   2340,  1531,  1520,   nil,    27,   nil,  2873,    45,   nil,  1495,
    985   1520,   271,  1895,   nil,  1502,  1505,  1481,  1500,  1478,  1312,
    986   1607,   538,   476,  1423,  1344,  1343,   525,  1328,  1300,  1260,
    987    nil,   692,   nil,  1287,  1290,   184,   nil,   156,   nil,  1276,
    988    450,   nil,    -6,   nil,   -65,  1277,   nil,   nil,  1159,   nil,
    989    nil,   nil,   nil,   nil,   nil,   nil,  1232,  1709,   nil,   nil,
    990    437,  1801,  1823,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    991    nil,   590,   741,   751,   893,   767,  1204,  1186,  1174,  1157,
    992    774,   nil,   nil,   nil,  1915,  1178,  1155,   nil,   nil,  3541,
    993   1157,   nil,  1124,   nil,  3254,  1665,  1017,   nil,   nil,   nil,
    994   2578,  2755,   nil,   592,   612,   nil,  1131,   414,   149,   nil,
    995   1324,   nil,   248,   nil,   332,   814,  1135,   271,   nil,   599,
    996    nil,  1102,  1119,   nil,  1081,   nil,  1079,   nil,   430,   nil,
    997   1069,  1098,  1060,  1088,  1055,  1035,   176,   nil,  1322,  3336,
    998   1687,    97,   nil,  2637,   291,   nil,   nil,   802,   nil,   nil,
    999    nil,   nil,   nil,    80,   nil,   nil,  1002,   984,   177,   980,
    1000    nil,   nil,   nil,   nil,   nil,   183,   nil,   nil,   797,   nil,
    1001    nil,   nil,   nil,   nil,   961,   199,   900,   857,   nil,    -2,
    1002    nil,   nil,   nil,   254,   858,   787,   nil,   840,   838,   nil,
    1003    206,  1503,   829,   811,   nil,  1367,   nil,  1300,  1253,  1208,
    1004   1155,  1110,   993,   971,   949,   926,   857,   787,   720,   695,
    1005   2191,  2143,  2121,  2051,  2029,  2007,   447,   nil,   811,   nil,
    1006    nil,   nil,  2460,  1321,   nil,   342,   nil,   nil,   nil,   nil,
    1007    804,   792,   788,   770,   754,   nil,  2932,   nil,   nil,   806,
    1008    nil,   nil,   330,   nil,   654,   643,   524,   nil,   nil,   nil,
    1009    nil,   516,   470,   461,   nil,   nil,   nil,   458,   381,   423,
    1010    383,   308,   359,   271,    69,   nil,  2032,   nil,   nil,  2032,
    1011    nil,   nil,   -37,   nil,  2233,  2029,  1981,   nil,  1967,   nil,
    1012   1078,  1893,  1965,   nil,     0,   nil,   nil,  2008,   nil,   nil,
    1013    nil,   nil,  1911,  2005,  2814,  2696,  1999,    73,   nil,   nil,
    1014    -32,   nil,   599,   nil,    31,   nil,   nil,   nil,   nil,  2519,
    1015    -16,   155,   192,   255,  3160,   328,   nil,   nil,   nil,    -8,
    1016     81,   nil,   370,   nil,   439,   nil,   596,   537,  2279,   495,
    1017    474,   nil,   nil,   484,   nil,   nil,   nil,   741,   526,   849,
    1018    861,   871,   900,   912,   935,   856,   717,   951,   671,   671,
    1019    676,   685,   710,   nil,   553,   995,   nil,   nil,   nil,   nil,
    1020   1660,   253,   197,   651,  1959,  1459,   nil,   nil,  1664,  3418,
    1021    634,  1551,  1573,  1595,   nil,   874,   891,   nil,   892,   877,
    1022    925,   930,   nil,   940,   953,   940,   975,   947,   992,   977,
    1023    nil,   nil,   nil,   969,  1006,   nil,  1084,   638,  1027,   587,
    1024   3050,   nil,   nil,   310,  3109,   nil,   nil,  1003,    78,  1081,
    1025     13,   284,   nil,    92,   642,  1096,  3168,   nil,   305,   nil,
    1026   1109,   nil,   996,    77,   nil,  1893,   -11,   130,  1108,   nil,
    1027    484,  1617,  2401,  1159,  1937,   nil,  1179,   nil,  1178,   nil,
    1028    nil,  1867,   nil,   nil,   nil,   nil,    14,    26,  1211,   356,
    1029   1222,   nil,  1079,   nil,  1234,  1235,  1237,  1250,  1252,   448,
    1030    nil,  1198,   nil,     0,   nil,   nil,  1277,   nil,   nil,  1279,
    1031    nil,   nil,  3459,   nil,   nil,   346,   524,   nil,   nil,   nil,
    1032     12,    79,  1272,   nil,  1300,   nil,  1305,  1286,  1289,   nil,
    1033   1319,  1326,    25,  1304,  1305,   nil,  1337,   nil,  1315,   nil,
    1034    nil,  1231,   nil,   465,   nil,   nil,   nil,   577,  1337,   nil,
    1035    nil,   nil,  1364,  1365,  1256,  1350,  1377,   nil,  1398,  2235,
    1036    nil,  1426,   nil,  1430,   nil,   nil,   nil,   nil,   nil,   nil,
    1037    nil,   nil,  1525,   nil,   387,   nil,   nil,   nil,  1409,  1437,
    1038    nil,  1454,  1456,  1432,  1463,  1451,   887,  1479,   nil,  1480,
    1039   1457,  1500,   nil,    24,   nil,  3500,  1345,  1448,   nil,  3377,
    1040   1275,  1523,   nil,   nil,  1231,   nil,   496,   nil,  1540,  1063,
    1041    384,    76,   nil,   nil,   nil,  1521,   nil,  1549,   nil,  1041,
    1042   1437,  1544,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   888,
    1043    nil,   nil,  1026,  1049,   nil,   nil,  1595,   nil,  1018,  1594,
    1044    nil,   548,   nil,   nil,   nil,  1587,   262,   nil,   nil,   nil,
    1045   1591,  1626,   nil,  1632,  1632,   nil,  1634,  1613,  1614,  1641,
    1046   1531,  1656,  1633,  1674,   nil,  1648,  1683,    75,   352,   nil,
    1047   1686,  1678,   115,  1665,   344,   nil,   nil,   nil,   nil,   nil,
    1048    nil,   nil,   nil,  1729,   nil,   nil,   834,   812,   nil,  1742,
    1049    nil,   547,   nil,   nil,   nil,   nil,   765,   nil,   330,   nil,
    1050   1753,  2213,   229,   nil,  1783,  1784,  1672,  1761,   nil,   nil,
    1051    nil,  1674,  1771,  2165,     8,   nil,   nil,  1322,  1791,   nil,
    1052    nil,   nil,   nil,  1824,   544,  2099,  1828,  1815,  2073,    89,
    1053   1819,   598,   nil,   -13,   nil,  1838,  1865,   nil,   673,   nil,
    1054   1843,   205,  1879,  1883,   nil,  1854,    -9,   nil,   nil,   628,
    1055   1892,  1867,   575,  1917,   nil,   nil,   464,   nil,   nil,  1887,
    1056    nil,   nil,  1932,  1936,  1936,   nil,  1959,  1900,  1932,   591,
    1057    399,  1944,  1945,  1928,   nil,   nil,   nil,   nil,   nil,   521,
    1058    nil,   nil,   nil,    11,   539,   100,   nil,   595,   581,   nil,
    1059    nil,   614,  1845,   nil,   650,   765,   966,   nil,  1643,  1577,
     973   nil,   nil,   nil,   nil,   nil,   nil,  2268,   nil,   694,   nil,
     974  3265,   123,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     975   nil,   nil,   nil,   nil,  2185,   nil,   nil,   nil,   nil,   nil,
     976   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   702,   712,
     977   721,  2888,   717,   719,   729,   115,   738,   742,   nil,   704,
     978   770,   nil,   921,   nil,   755,    75,   359,   nil,  1610,   174,
     979   nil,   nil,    89,   nil,   730,   742,   nil,   nil,   nil,   nil,
     980   807,   755,   496,   nil,   827,   nil,   836,   nil,   840,   nil,
     981   858,   nil,   nil,   nil,   862,   586,   nil,   877,   889,   891,
     982   nil,   nil,   905,   909,   917,    27,   922,   606,   866,   870,
     983   nil,   892,   nil,   903,   nil,   nil,   979,   888,   983,  1040,
     984   nil,  1044,   nil,   nil,  1106,   nil,  1500,  1268,   484,  2000,
     985  2416,  1115,  1107,   nil,    26,   nil,  3183,   448,   nil,  1094,
     986  1123,    97,  1591,   nil,  1124,  1129,   575,  1127,  1143,  1031,
     987  2017,   282,   350,  1146,  1147,  1149,   335,  1163,  1164,  1134,
     988   nil,   848,   nil,  1163,  1168,   184,   nil,   156,   nil,  1171,
     989   218,   nil,    -6,   nil,   -65,  1178,   nil,   nil,  1081,   nil,
     990   nil,   nil,   nil,   nil,   nil,   nil,  1179,  1019,   nil,   nil,
     991   437,  2228,  2206,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     992   nil,   880,   687,   729,   989,   767,  1182,  1177,  1178,  1179,
     993   132,   nil,   nil,   nil,   553,  1222,  1220,   nil,   nil,  3511,
     994  1225,   nil,  1196,   nil,  3347,  2107,  1268,   nil,   nil,   nil,
     995  3124,  3065,   nil,  2116,   612,   nil,  1230,  1176,   130,   nil,
     996  1615,   nil,   480,   nil,   367,   767,  1244,    76,   nil,    -1,
     997   nil,  1217,  1245,   nil,  1227,   nil,  1228,   nil,   524,   nil,
     998  1237,  1270,  1241,  1271,  1252,  1261,   197,   nil,  1329,  3470,
     999  2048,   271,   nil,  2534,   291,   nil,   nil,   778,   nil,   nil,
     1000   nil,   nil,   nil,   177,   nil,   nil,  1232,  1233,   198,  1234,
     1001   nil,   nil,   nil,   nil,   nil,   183,   nil,   nil,   867,   nil,
     1002   nil,   nil,   nil,   nil,  1252,    10,  1197,  1313,   nil,    -2,
     1003   nil,   nil,   nil,   190,  1328,  1274,   nil,  1337,  1339,   nil,
     1004   206,  1588,  1336,  1345,   nil,  1658,   nil,  1636,  1750,  1772,
     1005  1794,  1816,  1842,  1864,  1886,  1908,  1934,  1956,   651,  1978,
     1006   695,   720,   787,   673,  1544,  1452,   325,   nil,  1350,   nil,
     1007   nil,   nil,  2475,  1495,   nil,   692,   nil,   nil,   nil,   nil,
     1008  1361,  1363,  1364,  1365,  1375,   nil,  2947,   nil,   nil,   936,
     1009   nil,   nil,   342,   nil,  1384,  1386,  1387,   nil,   nil,   nil,
     1010   nil,  1382,  1400,  2162,   nil,   nil,   nil,  1402,  1347,  1404,
     1011  1426,  1368,  1429,  1430,  1428,   nil,  1440,   nil,   nil,  1442,
     1012   nil,   nil,   -37,   nil,  1611,  1443,  1422,   nil,  1424,   nil,
     1013   476,  1355,  1426,   nil,   599,   nil,   nil,  1471,   nil,   nil,
     1014   nil,   nil,  1373,  1467,  2593,  2652,  1441,   -11,   nil,   nil,
     1015  1444,   nil,   601,   nil,  1483,   nil,   nil,   nil,   nil,  3006,
     1016  1385,  1485,  1488,  1501,  2163,  1477,   nil,   nil,   nil,    -8,
     1017   254,   nil,  1509,   nil,  2026,   nil,   593,   597,  2294,   628,
     1018  1516,   nil,   nil,  1521,   nil,   nil,   nil,   877,   954,   791,
     1019   804,   855,   890,  1087,   596,   978,  1063,   815,  1515,  1509,
     1020  1509,  1518,  1518,   nil,  1427,   709,   nil,   nil,   nil,   nil,
     1021   958,    81,   261,  2184,   949,    12,   nil,   nil,   592,  3388,
     1022   590,   461,   495,   521,   nil,  1544,  1563,   nil,    80,  1536,
     1023  1568,  1570,   nil,  1572,  1588,  1559,  1591,  1562,  1593,   318,
     1024   nil,   nil,   nil,  1572,  1604,   nil,   937,   937,  1603,   857,
     1025  2711,   nil,   nil,   310,  2770,   nil,   nil,  1547,    79,  1613,
     1026    13,   355,   nil,    92,   900,  1618,  2829,   nil,   437,   nil,
     1027  1620,   nil,  1507,   344,   nil,  1148,    73,   433,  1597,   nil,
     1028   541,  1199,  2355,  1627,  1244,   nil,  1636,   nil,  1635,   nil,
     1029   nil,  1291,   nil,   nil,   nil,   nil,    14,    27,  1639,   430,
     1030  1640,   nil,  1331,   nil,  1658,  1660,  1661,  1657,  1680,   240,
     1031  1587,  1626,   nil,     0,   nil,   nil,  1687,   nil,   nil,  1689,
     1032   nil,   nil,  3224,   nil,   nil,   332,   578,   nil,   nil,   nil,
     1033  1519,    78,  1660,   nil,  1716,   nil,  1721,  1689,  1692,   nil,
     1034  1720,  1733,    75,  1703,  1720,   nil,  1753,   nil,  1723,   nil,
     1035   nil,  1638,   nil,   521,   nil,   nil,   nil,   577,  1742,   nil,
     1036   nil,   nil,  1769,  1770,  1661,  1747,  1789,   nil,  1795,  2125,
     1037   nil,  1794,   nil,  1798,   nil,   nil,   nil,   nil,   nil,   nil,
     1038   nil,   nil,   743,   nil,   844,   nil,   nil,   nil,  1768,  1811,
     1039   nil,   176,   256,  1788,  1819,  1790,  1493,  1817,   nil,  1825,
     1040  1801,  1829,   nil,    74,   nil,  3306,  1405,  1772,   nil,  3429,
     1041  1383,  1837,   nil,   nil,  1360,   nil,   587,   nil,  1845,  1313,
     1042   384,    76,   nil,   nil,   nil,  1815,   nil,  1842,   nil,  1221,
     1043  1746,  1837,   nil,   nil,   nil,   nil,   nil,   nil,   nil,  1611,
     1044   nil,   nil,  1006,   482,   nil,   nil,  1867,   nil,  1101,  1864,
     1045  1788,   447,   nil,   nil,   nil,  1858,   596,   nil,   nil,   nil,
     1046  1859,  1885,   nil,  1908,  1909,   nil,  1911,  1882,  1891,  1918,
     1047  1808,  1920,  1902,  1933,   nil,  1907,  1934,    -9,   284,   nil,
     1048  1951,  1927,   199,  1485,   576,   nil,   nil,   nil,   nil,   nil,
     1049   nil,   nil,   nil,  1954,   nil,   nil,   904,   812,   nil,  1930,
     1050   nil,   513,   nil,   nil,   nil,   nil,  2092,   nil,   330,   nil,
     1051  1947,   835,   240,   nil,  1975,  1976,  1864,  1970,   nil,   nil,
     1052   nil,  1884,  1974,   982,     8,   nil,   nil,  1474,  1982,   nil,
     1053   nil,   nil,   nil,  2014,   525,   927,  2015,  1987,   857,   253,
     1054  1996,   399,   nil,   -13,   nil,  1997,  2024,   nil,  2070,   nil,
     1055  2000,   205,    -5,    30,   nil,    52,    25,   nil,   nil,  1126,
     1056   117,    97,   765,   197,   nil,   nil,   180,   nil,   nil,   217,
     1057   nil,   nil,   279,   291,   379,   nil,   418,   367,   433,   534,
     1058   412,   454,   467,   460,   nil,   nil,   nil,   nil,   nil,   439,
     1059   nil,   nil,   nil,    11,   533,   100,   nil,   539,   512,   nil,
     1060   nil,   558,   414,   nil,   576,   594,   567,   nil,  1566,   606,
    10601061   nil ]
    10611062
     
    12001201   665,   nil,   nil,   nil,   nil,   nil,   671,   596,   597,   588,
    12011202   nil,   nil,   553,   557,   673,   nil,   238,   nil,   763,   622,
    1202    853,   nil,   766,   nil,   nil,   nil,   530,   553,   nil,   nil,
     1203   853,   nil,   766,   nil,   610,   nil,   530,   553,   nil,   nil,
    12031204   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    12041205   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   664,   nil,
     
    12161217   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   696,
    12171218   nil,   873,   nil,   792,   nil,   nil,   nil,   nil,   nil,   nil,
    1218    nil,   464,   nil,   nil,   339,   nil,   nil,   nil,   nil,   nil,
     1219   nil,   464,   nil,   nil,   339,   nil,   nil,   750,   610,   nil,
    12191220   nil,   769,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    12201221   nil,   894,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     
    12801281    23,   nil,   nil,   nil,   nil,   nil,    23,     4,     4,    23,
    12811282   nil,   nil,    45,    45,    55,   nil,    28,   nil,     6,    47,
    1282     84,   nil,     6,   nil,   nil,   nil,     5,    45,   nil,   nil,
     1283    84,   nil,     6,   nil,     4,   nil,     5,    45,   nil,   nil,
    12831284   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    12841285   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    47,   nil,
     
    12961297   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,    25,
    12971298   nil,     6,   nil,    32,   nil,   nil,   nil,   nil,   nil,   nil,
    1298    nil,    45,   nil,   nil,    22,   nil,   nil,   nil,   nil,   nil,
     1299   nil,    45,   nil,   nil,    22,   nil,   nil,     4,     4,   nil,
    12991300   nil,    47,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
    13001301   nil,     6,   nil,   nil,   nil,   nil,   nil,   nil,   nil,   nil,
     
    29432944  def _reduce_104(val, _values, result)
    29442945                        # tag が無い場合、内部名を与える
    2945                         result = StructType.new( :"$TAG_#{@@no_struct_tag_num}" )
     2946                        result = StructType.new( :"TAG__#{@@no_struct_tag_num}__" )
    29462947                        @@no_struct_tag_num += 1
    29472948                        StructType.set_define( true )
     
    37493750module_eval(<<'.,.,', 'bnf.y.rb', 802)
    37503751  def _reduce_233(val, _values, result)
    3751         result = [val[0].val]           
     3752        result = [val[0]]               
    37523753    result
    37533754  end
     
    37563757module_eval(<<'.,.,', 'bnf.y.rb', 804)
    37573758  def _reduce_234(val, _values, result)
    3758         result << val[2].val           
     3759        result << val[2]               
    37593760    result
    37603761  end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/bnf.y.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2016 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    379379                {
    380380                        # tag が無い場合、内部名を与える
    381                         result = StructType.new( :"$TAG_#{@@no_struct_tag_num}" )
     381                        result = StructType.new( :"TAG__#{@@no_struct_tag_num}__" )
    382382                        @@no_struct_tag_num += 1
    383383                        StructType.set_define( true )
     
    800800
    801801region_name_list
    802         : IDENTIFIER
    803                 {       result = [val[0].val]           }
    804         | region_name_list ',' IDENTIFIER
    805                 {       result << val[2].val            }
     802        : namespace_identifier
     803                {       result = [val[0]]               }
     804        | region_name_list ',' namespace_identifier
     805                {       result << val[2]                }
    806806
    807807const_statement
     
    18071807                  string += line
    18081808                  # この位置では error メソッドは使えない (token 読出し前)
    1809                   puts "error: #{file} line #{lineno}: string literal has newline without escape"
     1809                  puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape"
    18101810                  @@n_error += 1
    18111811                end
     
    18481848                  b_in_string = true
    18491849                  # この位置では error メソッドは使えない (token 読出し前) # mikan cdl_error ではない
    1850                   puts "error: #{file} line #{lineno}: string literal has newline without escape"
     1850                  puts "#{file}:#{lineno}:#{col}: error: string literal has newline without escape"
    18511851                  @@n_error += 1
    18521852                # 山括弧で囲まれた文字列
    1853                 when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
     1853                # when /\A<[0-9A-Za-z_\. \/]+>/   # AB: angle bracke
     1854                when /\A<(?:[^>\\]|\\.)*>/   # これはうまく行くようだ
    18541855                  @q << [:AB_STRING_LITERAL, Token.new($&, file, lineno, col)]
    18551856                # 行コメント
     
    19811982      end
    19821983      if locale then
    1983         Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
     1984        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: error: #{msg}"
    19841985      else
    19851986        Console.puts "error: #{msg}"
     
    20142015      end
    20152016      if locale then
    2016         Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     2017        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: warning: #{msg}"
    20172018      else
    20182019        Console.puts "warning: #{msg}"
     
    20472048      end
    20482049      if locale then
    2049         Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     2050        Console.puts "#{locale[0]}:#{locale[1]}:#{locale[2]}: info: #{msg}"
    20502051      else
    20512052        Console.puts "info: #{msg}"
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/componentobj.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2017 by TOPPERS Project
     6#   Copyright (C) 2008-2019 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    149149    end
    150150
    151     set_descriptor_list
     151    # set_descriptor_list ##
    152152
    153153    if @generate then
     
    364364  end
    365365
     366  @@set_descriptor_list = {}
     367  def self.set_descriptor_list
     368    Namespace.get_root.travers_all_signature{ |sig|
     369      if @@set_descriptor_list[ sig ] == nil then
     370        @@set_descriptor_list[ sig ] = true
     371        sig.set_descriptor_list
     372      end
     373    }
     374  end
     375
    366376  #== Signature# 引数で参照されている Descriptor 型のリストを作成する
    367377  def set_descriptor_list
     
    538548# @ct_factory_list::    Factory[] :    celltype factory
    539549# @cell_list:: Cell[] : 定義のみ (V1.0.0.2 以降)
     550# @ordered_cell_list:: Cell[] : ID 順に順序付けされたセルリスト、最適化以降有効 (リンク単位ごとに生成されなおす)
    540551# @singleton:: bool
    541552# @idx_is_id:: bool
    542553# @idx_is_id_act:: bool: actual value
     554# @b_need_ptab:: bool: true if having cells in multi-domain
    543555# @active:: bool
    544556# @b_reuse:: bool :  reuse 指定されて import された(template 不要)
     
    654666    if $idx_is_id then
    655667      @idx_is_id = true
     668      @idx_is_id_act = true
     669      @b_need_ptab = true
    656670    else
    657671      @idx_is_id = false
    658     end
    659     @idx_is_id_act = @idx_is_id
     672      @idx_is_id_act = false
     673      @b_need_ptab = false
     674    end
    660675
    661676    Namespace.new_celltype( self )
     
    700715    end
    701716
    702     check_dynamic_join
     717    # check_dynamic_join ##
    703718
    704719    @@current_object = nil
     
    886901        @idx_is_id = true
    887902        @idx_is_id_act = true
     903        @b_need_ptab = true
    888904      when :ACTIVE
    889905        @active = true
     
    899915    if @singleton then
    900916      @idx_is_id_act = false
     917      @b_need_ptab = false
    901918    end
    902919  end
     
    9991016  end
    10001017
     1018  @@dynamic_join_checked_list = {}
     1019  def self.check_dynamic_join
     1020    Namespace.get_root.travers_all_celltype{ |ct|
     1021      if @@dynamic_join_checked_list[ ct ] == nil then
     1022        @@dynamic_join_checked_list[ ct ] = true
     1023        ct.check_dynamic_join
     1024      end
     1025    }
     1026  end
     1027
    10011028  #=== Celltype#dynamic の適合性チェック
    10021029  def check_dynamic_join
     1030    return if ! $verbose
    10031031    @port.each{ |port|
    10041032      signature = port.get_signature
     
    10381066              end
    10391067            end
    1040             cdl_warning( 'W9999 "$1" cannot handle Descriptor "$2" infromation for port "$3"', @name, param.get_name, port.get_name )
     1068            cdl_warning( 'W9999 "$1" cannot handle Descriptor "$2" information for port "$3"', @name, param.get_name, port.get_name )
    10411069          }
    10421070        end
     
    11431171  #     呼び口(ただし、最適化で不要となるものは除く)
    11441172  def has_INIB?
    1145 #    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"
    1146     return $rom &&
    1147       (@n_attribute_ro > 0 ||
    1148        @n_var_size_is > 0 ||
    1149        ( @n_call_port - @n_call_port_omitted_in_CB - (@n_call_port_dynamic-@n_call_port_array_dynamic) ) > 0 ||
    1150        $ram_initializer && @n_call_port_dynamic ||
    1151        @n_entry_port_array_ns > 0)
    1152 #    return $rom && (@n_attribute_ro > 0 || ( @n_call_port - @n_call_port_omitted_in_CB ) > 0)
     1173
     1174    result = $rom &&
     1175             (@n_attribute_ro > 0 ||
     1176              @n_var_size_is > 0 ||
     1177              ( @n_call_port - @n_call_port_omitted_in_CB - (@n_call_port_dynamic-@n_call_port_array_dynamic) ) > 0 ||
     1178              $ram_initializer && @n_call_port_dynamic > 0 ||
     1179              @n_entry_port_array_ns > 0)
     1180    # 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_call_port_dynamic=#{@n_call_port_dynamic} n_call_port_array_dynamic=#{@n_call_port_array_dynamic} n_entry_port_array_ns=#{@n_entry_port_array_ns} has_INIB?=#{result}\n"
     1181
     1182    return result
    11531183  end
    11541184
     
    12311261  def idx_is_id_act?
    12321262    @idx_is_id_act
     1263  end
     1264
     1265  def multi_domain?
     1266    @b_need_ptab
    12331267  end
    12341268
     
    13531387#                                               逆require ポートに対して複数の結合がないかチェックする
    13541388# @generate:: [ Symbol, String, Plugin ]  = [ PluginName, option, Plugin ] Plugin は生成後に追加される
     1389# @b_post_code_generated:: Bool: true if generated in tmp_plugin_post_code.cdl
    13551390#
    13561391# composite のためインスタンス変数
     
    13751410# @id:: Integer : コード生成直前に設定  (プロトタイプ宣言の場合は -1 のまま放置)
    13761411# @id_specified::Integer : 指定された id
    1377 # @restrict_list::{ entry_name => { func_name, [ region_name, ... ] } }
     1412# @restrict_list::{ entry_name => { func_name, [ region_path_str, ... ] } }
     1413# @restrict_list2::{ entry_name => { func_name, [ domain_root_region, ... ] } }
     1414# @b_restrict_referenced::Bool: restrict_list が参照れた
    13781415
    13791416=begin
     
    14591496    @referenced_port_list = {}
    14601497    @restrict_list = {}
     1498    @restrict_list2 = {}
     1499    @b_restrict_referenced = false
     1500    @b_post_code_generated = false
    14611501
    14621502    @cell_list = {}
     
    18031843      set_specifier_list( Generator.get_statement_specifier )
    18041844    end
     1845    if TECSGEN.post_coded?
     1846      @b_post_code_generated = true
     1847    end
    18051848    set_f_def f_def
    18061849
     
    18201863    if ! @in_composite then
    18211864      # if @celltype.instance_of? Celltype then
     1865      if @celltype then  # composite でも呼びだす, エラー時 nil
    18221866        @celltype.new_cell self
    1823       # end
     1867      end
    18241868      @@cell_list << self
    18251869    end
     
    21322176  end
    21332177
     2178  #=== Cell# composite のセルか?
     2179  def is_of_composite?
     2180    if @celltype.kind_of? CompositeCelltype
     2181      return true
     2182    else
     2183      return false
     2184    end
     2185  end
     2186
     2187  #=== Cell# tmp_plugin_post_code.cdl で生成されたセルか?
     2188  def post_code_generated?
     2189    @b_post_code_generated
     2190  end
     2191
    21342192  # composite cell の port に対応する内部の cell の port の名前(リンク時に必要な名前)
    21352193  def get_real_global_name port_name
     
    22192277
    22202278      # セルタイプ内で port_name の CompositeCelltypeJoin を探す(コード生成段階では必ず見つかる)
     2279      # print "get_real_cell: cell=#{@name} port=#{port_name}\n"
     2280      # pp @cell_list
    22212281      cj = @celltype.find_export( port_name )
    22222282
     
    22302290  end
    22312291
     2292  #=== Cell#get_real_celltype
     2293  #
     2294  def get_real_celltype( port_name )
     2295    if @celltype.instance_of?( CompositeCelltype ) then
     2296      return @celltype.get_real_celltype port_name
     2297    else
     2298      return @celltype
     2299    end
     2300  end
    22322301
    22332302  #=== Cell# 受け口のport の参照カウントをアップする
     
    22702339      return "#{@global_name}_#{port_name}"
    22712340    end
     2341  end
     2342
     2343  #Cell#属性の初期値を得る
     2344  #attr_name::Symbol  必ず初期化されていないと Ruby 例外となる
     2345  def get_attr_initializer attr_name
     2346    val = @join_list.get_item( attr_name )
     2347    if val == nil then
     2348      val = (@celltype.find  attr_name).get_initializer
     2349    else
     2350      val = val.get_rhs
     2351    end
     2352    return val
    22722353  end
    22732354
     
    25202601        else
    25212602          cell = j.get_rhs_cell2
    2522           next if cell == nil     # 右辺が見つからなかった.既にエラー
     2603          next if cell == nil || cell.get_celltype == nil     # 右辺が見つからなかった.既にエラー
    25232604          port = cell.get_celltype.find( j.get_rhs_port2 )
     2605          if port == nil then
     2606            dbgPrint "set_port_ref: #{@name}.#{j.get_name} = #{cell.get_name}.#{j.get_rhs_port2}\n"
     2607            # through プラグインで生成されたセルの受け口が見つからないケース (のハズ)
     2608            cdl_error( "entry '$1' not found in '$2' refered from $3.$4", j.get_rhs_port2, cell.get_name, @name, j.get_name )
     2609            next
     2610          end
    25242611          dbgPrint( "set_port_reference_count: #{@name}.#{j.get_name} => #{cell.get_name}.#{port.get_name}\n")
    25252612          cell.port_referenced port
     
    29663053  #=== Cell#restrict を追加
    29673054  def add_restrict( entry_name, func_name, region_name_list )
    2968     if @restrict_list[ entry_name ] then
    2969       if @restrict_list[ entry_name ][ func_name ] then
    2970         @restrict_list[ entry_name ][ func_name ].each{ |rn|
    2971           if region_name_list.include? rn then
    2972             # p func_name
    2973             name = func_name ? entry_name : entry_name+"."+func_name
    2974             cdl_warning( "W9999 $1 restrict region duplicate $2", name, rn )
     3055    if @restrict_list[ entry_name ] == nil then
     3056      @restrict_list[ entry_name ] = {}
     3057      @restrict_list2[ entry_name ] = {}
     3058    end
     3059    if @restrict_list[ entry_name ][ func_name ] == nil then
     3060      @restrict_list[ entry_name ][ func_name ] = []
     3061      @restrict_list2[ entry_name ][ func_name ] = []
     3062    end
     3063    region_name_list.each { |rp|
     3064      @restrict_list[ entry_name ][ func_name ] << rp
     3065      # p "Class: " + rp.to_s
     3066      obj = Namespace.find rp
     3067      if ( obj.kind_of? Region ) then
     3068        @restrict_list2[ entry_name ][ func_name ] << obj.get_domain_root
     3069      else
     3070        cdl_error( "S9999 $1 not found or not region", rp.to_s )
     3071      end
     3072    }
     3073  end
     3074
     3075  #=== Cell#check_restrict_list
     3076  def check_restrict_list
     3077    # p "check_restrict_list"
     3078    @restrict_list.each{ |entry_name, func_hash|
     3079      func_hash.each{ |func_name, region_list|
     3080        region_list.each{ |rp|
     3081          obj = Namespace.find rp
     3082          if ( obj.kind_of? Region ) then
     3083            if obj.get_domain_root != @region.get_domain_root then
     3084            else
     3085              cdl_info( "I9999 $1: restrict calling domain to $2, which is same domain as the cell locates", @name, rp.to_s )
     3086              # restrict を同じドメインを指定してもよいこととする (HRP3)
     3087              # KernelDoamin 内のセルに対し、KernelDomain に restrict している場合、
     3088              # 無所属経由で結合されているが、KernelDomain から呼出すことを想定した許可
     3089            end
     3090          else
     3091            cdl_error( "S9999 $1 not region", rp.to_s )
     3092          end
     3093        }
     3094      }
     3095    }
     3096  end
     3097
     3098  #=== Cell#callable?
     3099  def callable?( callee_cell, entry_name, func_name )
     3100    # p "callable? #{@name}"
     3101    res = callee_cell.callable_from?( entry_name, func_name, self )
     3102    dbgPrint "callable? #{callee_cell.get_namespace_path}.#{entry_name}.#{func_name} from #{@NamespacePath} is #{res}\n"
     3103    return res
     3104  end
     3105
     3106  #=== Cell#callable_from? (private)
     3107  def callable_from?( entry_name, func_name, caller_cell )
     3108    @b_restrict_referenced = true
     3109    if @restrict_list.length == 0 then
     3110      return true
     3111    end
     3112
     3113    dr = caller_cell.get_region.get_domain_root
     3114    if @restrict_list[entry_name] then
     3115      if @restrict_list[entry_name][func_name] then
     3116        @restrict_list2[entry_name][func_name].each{ |region|
     3117          if dr == region then
     3118            return true
     3119          end
     3120        }
     3121      elsif @restrict_list[entry_name][nil] then
     3122        @restrict_list2[entry_name][nil].each{ |region|
     3123          if dr == region then
     3124            return true
    29753125          end
    29763126        }
    29773127      else
    2978         @restrict_list[ entry_name ][ func_name ] = region_name_list
    2979       end
    2980     else
    2981       func_list = { }
    2982       func_list[ func_name ] = region_name_list
    2983       @restrict_list[ entry_name ] = func_list
    2984     end
    2985     # pp @restrict_list
    2986   end
    2987 
    2988   #=== Cell#check_restrict_list
    2989   def check_restrict_list
    2990     @restrict_list.each{ |entry_name, func_hash|
    2991       func_hash.each{ |func_name, region_list|
    2992         region_list.each{ |rn|
    2993           obj = Namespace.find [ rn ]
    2994           if ( obj.kind_of? Region ) then
    2995             if obj.get_domain_root != @region.get_domain_root then
    2996             else
    2997               cdl_warning( "W9999 $1 in same domain", rn )
    2998             end
    2999           else
    3000             cdl_error( "S9999 $1 not region", region )
    3001           end
    3002         }
    3003       }
    3004     }
    3005   end
    3006 
    3007   #=== Cell#callable?
    3008   def callable?( callee_cell, entry_name, func_name )
    3009     res = callee_cell.callable_from?( entry_name, func_name, self )
    3010     dbgPrint "callable? #{callee_cell.get_namespace_path}.#{entry_name}.#{func_name} from #{@NamespacePath} is #{res}\n"
    3011     return res
    3012   end
    3013 
    3014   #=== Cell#callable_from? (private)
    3015   def callable_from?( entry_name, func_name, caller_cell )
    3016     if @restrict_list.length == 0 then
     3128        return false
     3129      end
     3130    else
     3131      return false
     3132    end
     3133  end
     3134
     3135  #=== Cell#get_callable_regions( entry_name, func_name )
     3136  # func_name=nil の場合、entry_name の可否をチェック数る
     3137  # nil が返る場合、制限されていないことを意味する
     3138  def get_restricted_regions( entry_name, func_name )
     3139    # p "get_restricted_regions #{@name}"
     3140    @b_restrict_referenced = true
     3141    if @restrict_list[entry_name] then
     3142      if @restrict_list[entry_name][func_name] then
     3143        return @restrict_list2[entry_name][func_name]
     3144      else
     3145        return @restrict_list2[entry_name][nil]
     3146      end
     3147    end
     3148    return nil
     3149  end
     3150
     3151  #=== Cell#has_ineffective_restrict_specifier
     3152  # restrict 指定子が指定されていて、参照されていない場合 true
     3153  # 参照は、HRPSVCPlugin のみ
     3154  def has_ineffective_restrict_specifier
     3155    if @restrict_list.length != 0 && @b_restrict_referenced == false then
    30173156      return true
    3018     end
    3019 
    3020     if @restrict_list[entry_name] then
    3021       if @restrict_list[entry_name][nil] &&
    3022          @restrict_list[entry_name][nil].include?( caller_cell.get_region.get_domain_root.get_name )then
    3023         return true
    3024       end
    3025       if @restrict_list[entry_name][func_name] &&
    3026          @restrict_list[entry_name][func_name].include?( caller_cell.get_region.get_domain_root.get_name )then
    3027         return true
    3028       else
    3029         return false
    3030       end
    3031     else
    3032       return true
    3033     end
    3034   end
    3035  
     3157    else
     3158      return false
     3159    end
     3160  end
     3161
    30363162  def show_tree( indent )
    30373163    indent.times { print "  " }
     
    37093835  end
    37103836
     3837  def get_global_name
     3838    @global_name
     3839  end
     3840
    37113841  def get_port_list
    37123842    @port_list
     
    37233853  def get_internal_allocator_list
    37243854    @internal_allocator_list
     3855  end
     3856
     3857  #== CompositeCelltype#get_real_celltype
     3858  # port_name に接続されている内部のセルタイプを得る
     3859  def get_real_celltype( port_name )
     3860    cj = find_export port_name
     3861    inner_celltype = cj.get_cell.get_celltype
     3862    if inner_celltype.instance_of? CompositeCelltype then
     3863      return inner_celltype.get_real_celltype
     3864    else
     3865      return inner_celltype
     3866    end
    37253867  end
    37263868
     
    39364078    else
    39374079      # entry port optimize
    3938       if $unopt then
     4080      if $unopt || $unopt_entry then
    39394081        # 最適化なし
    39404082        @b_VMT_useless = false                     # VMT 不要 (true の時 VMT を介することなく呼出す)
     
    42604402
    42614403  def is_VMT_useless?                     # VMT 関数テーブルを使用しない
    4262    @b_VMT_useless
     4404    if @port_type == :ENTRY && $unopt_entry == true then
     4405      # プラグインから $unopt_entry を設定するケースのため
     4406      # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる)
     4407      return false
     4408    else
     4409      return @b_VMT_useless
     4410    end
    42634411  end
    42644412
    42654413  def is_skelton_useless?                 # スケルトン関数不要   (true の時、受け口関数を呼出す)
    4266     @b_skelton_useless
     4414    if @port_type == :ENTRY && $unopt_entry == true then
     4415      # プラグインから $unopt_entry を設定するケースのため
     4416      # ここで読み出すときに、false を返す (reset_optimize での設定変更は速すぎる)
     4417      return false
     4418    else
     4419      return @b_skelton_useless
     4420    end
    42674421  end
    42684422
     
    48014955      if ! c.get_f_def then   # Namespace の @cell_list にはプロトタイプが含まれるケースあり
    48024956        if c.get_f_ref then
    4803           cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str )
     4957          c.cdl_error( "S1093 $1 : undefined cell" , c.get_namespace_path.get_path_str )
    48044958        elsif $verbose then
    4805           cdl_warning( "W1006 $1 : only prototype, unused and undefined cell" , c.get_namespace_path.get_path_str )
     4959          c.cdl_warning( "W1006 $1 : only prototype, unused and undefined cell" , c.get_namespace_path.get_path_str )
    48064960        end
    48074961      else
     
    48104964        # if c.get_f_ref == false && c.is_generate? && ct && ct.is_inactive? then
    48114965        if c.get_f_ref == false && ct && ct.is_inactive? then
    4812           cdl_warning( "W1007 $1 : non-active cell has no entry join and no factory" , c.get_namespace_path.get_path_str )
     4966          c.cdl_warning( "W1007 $1 : non-active cell has no entry join and no factory" , c.get_namespace_path.get_path_str )
     4967        end
     4968        if c.has_ineffective_restrict_specifier then
     4969          c.cdl_warning( "W9999: $1 has ineffective restrict specifier", c.get_namespace_path.get_path_str )
    48134970        end
    48144971      end
     
    50055162  end
    50065163
     5164  #== Namespace (Region) に属するセルのリスト
     5165  def get_cell_list
     5166    @cell_list
     5167  end
     5168
     5169  #== Namespace (Region)# 子リージョンのリスト
     5170  #
     5171  # リージョンは Namespace クラスで namespace として記憶されている
     5172  def get_region_list
     5173    @namespace_list
     5174  end
     5175 
    50075176  def show_tree( indent )
    50085177    indent.times { print "  " }
     
    56015770          next_cell_nsp       = @through_generated_list[ i + 1 ].get_cell_namespace_path
    56025771          next_port_name      = @through_generated_list[ i + 1 ].get_through_entry_port_name
     5772          next_port_subscript = @through_generated_list[ i + 1 ].get_through_entry_port_subscript
    56035773        rescue Exception => evar
    56045774          cdl_error( "S1124 $1: plugin function failed: \'get_through_entry_port_name\'" , plugin_name )
     
    56195789        next_cell      = @cell
    56205790        next_port_name = @port_name
     5791        next_port_subscript = @rhs_subscript
    56215792
    56225793        if next_cell == nil then
     
    56305801        # region から @cell_name.@port_name への through がないか探す
    56315802        # rp = @through_list[i][3].find_cell_port_through_plugin( @cell_name, @port_name ) #762
    5632         rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name )
     5803        rp = @through_list[i][3].find_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript )
    56335804           # @through_list[i] と @region_through_list[i-cp_len] は同じ
    56345805        # 共用しないようにするには、見つからなかったことにすればよい
     
    56435814        plClass = load_plugin( plugin_name, ThroughPlugin )
    56445815        if( plClass ) then
    5645           gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, plClass )
     5816          gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, next_port_subscript, plClass )
    56465817        end
    56475818      else
     
    56565827          # 生成したものを region(@through_list[i][3]) のリストに追加
    56575828          # @through_list[i][3].add_cell_port_through_plugin( @cell_name, @port_name, @through_generated_list[i] ) #762
    5658           @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @through_generated_list[i] )
     5829          @through_list[i][3].add_cell_port_through_plugin( @cell.get_global_name, @port_name, @rhs_subscript, @through_generated_list[i] )
    56595830        end
    56605831      end
     
    56905861
    56915862  #=== Join# through プラグインを呼び出して CDL 生成させるとともに、import する
    5692   def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, plClass )
     5863  def gen_through_cell_code_and_parse( plugin_name, i, next_cell, next_port_name, next_port_subscript, plClass )
    56935864
    56945865    through = @through_list[ i ]
     
    57175888
    57185889    begin
    5719       plugin_object = plClass.new( "#{generating_cell_name}".to_sym, plugin_arg.to_s, next_cell, "#{next_port_name}".to_sym, @definition.get_signature, @celltype, caller_cell )
     5890      plugin_object = plClass.new( generating_cell_name.to_sym, plugin_arg.to_s,
     5891                                   next_cell, next_port_name.to_sym, next_port_subscript,
     5892                                   @definition.get_signature, @celltype, caller_cell )
    57205893      plugin_object.set_locale @locale
    57215894    rescue Exception => evar
     
    59126085  end
    59136086
    5914   def get_rhs_subscript
     6087  # 末尾数字1 : CDL で指定された、右辺のセルを返す
     6088  def get_rhs_cell1   # get_cell と同じ
     6089    @cell
     6090  end
     6091  def get_rhs_port1   # get_port_name 同じ
     6092    @port_name
     6093  end
     6094  def get_rhs_subscript1
    59156095    @rhs_subscript
    59166096  end
     
    59226102    # through 指定あり?
    59236103    if @through_list[0] then
    5924       # mikan through で生成したものが root namespace 限定
    59256104      # through で生成されたセルを探す
    5926 #      cell = Namespace.find( [ "::", @through_generated_list[0].get_cell_name.to_sym ] )    #1
    59276105      cell = Namespace.find( @through_generated_list[0].get_cell_namespace_path )    #1
    59286106      # cell のプラグインで生成されたポート名のポートを探す (composite なら内部の繋がるポート)
     
    59316109      # ポートを返す(composite なら内部の繋がるポートを返す)
    59326110      return @cell.get_real_port( @port_name )
     6111    end
     6112  end
     6113
     6114  #=== Join# 右辺の配列添数を得る
     6115  #    右辺が through の場合は挿入されたセルの添数
     6116  #    右辺が composite の場合は、内部の繋がるセルのポートの添数 (composite では変わらない)
     6117  #    このメソッドは get_rhs_cell,  と対になっている
     6118  def get_rhs_subscript
     6119    if @through_list[0] then
     6120      return @through_generated_list[0].get_through_entry_port_subscript
     6121    else
     6122      return @rhs_subscript
    59336123    end
    59346124  end
     
    65686758end
    65696759
    6570 #== Domain
     6760#== DomainType
    65716761#
    65726762# region の domain を記憶するクラス
     
    66076797      return if pluginClass == nil
    66086798      @plugin = pluginClass.new( @region, @name, @option )
     6799      @plugin.set_locale @locale
    66096800    end
    66106801  end
     
    66246815  end
    66256816
    6626   #== Domain リージョンの Hash を得る
     6817  #== DomainType リージョンの Hash を得る
    66276818  # @@domain_regions の説明参照
    66286819  def self.get_domain_regions
     
    66366827  def get_option
    66376828    @option
     6829  end
     6830
     6831  #== DomainType#ドメイン種別を得る
     6832  #return::Symbol :kernel, :user, :OutOfDomain
     6833  def get_kind
     6834    @plugin.get_kind
    66386835  end
    66396836
     
    66976894
    66986895    if @@domain_name then
     6896      dbgPrint "Region=#{name} domain_type=#{@@domain_name} option=#{@@domain_option}\n"
    66996897      domain_option = CDLString.remove_dquote @@domain_option.to_s
    67006898      @domain_type = DomainType.new( self, @@domain_name, domain_option )
     
    69457143  end
    69467144
     7145  #== Region# ルートリージョン
     7146  # ルートリージョンは、namespace のルートと同じインスタンス
     7147  def selfget_root
     7148    Namespace.get_root
     7149  end
     7150
    69477151  def next_in_through_count
    69487152    @in_through_count += 1
     
    69787182  #=== Region# through プラグインで、この region から cell_name.port_name へのプラグインオブジェクトを登録
    69797183  # mikan namesppace 対応 (cell_name)
    6980   def add_cell_port_through_plugin( cell_name, port_name, through_plugin_object )
    6981     @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ] = through_plugin_object
    6982   end
    6983 
    6984   def find_cell_port_through_plugin( cell_name, port_name )
    6985     return @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}" ]
     7184  def add_cell_port_through_plugin( cell_name, port_name, subscript, through_plugin_object )
     7185    if subscript then
     7186      subscript = '[' + subscript.to_s + ']'
     7187    end
     7188    @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}#{subscript}" ] = through_plugin_object
     7189  end
     7190
     7191  def find_cell_port_through_plugin( cell_name, port_name, subscript )
     7192    if subscript then
     7193      subscript = '[' + subscript.to_s + ']'
     7194    end
     7195    return @cell_port_throug_plugin_list[ "#{cell_name}.#{port_name}#{subscript}" ]
    69867196  end
    69877197
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/ctypes.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    122122      #   TECS には long double を表現する手段がない (double80_t を定義すればよいか?)
    123123#      cdl_warning( "C1003 $1 & $2 incompatible (\'long double\' is not supported.). Treated as $3." , self.class, another.class, self.class )
    124       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 )
     124#      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 )
     125      self.to_long     
    125126      return self
    126127    else
     
    185186  end
    186187
     188  def to_long
     189    if @bit_size != -64 then
     190      cdl_warning( "W9999 long specified for $1" , get_type_str )
     191    else
     192      @bit_size = -128  # @bit_size = -128 : long double
     193    end
     194  end
    187195end
    188196
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/expression.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/generate.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2017 by TOPPERS Project
     6#   Copyright (C) 2008-2019 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    122122
    123123class Namespace
     124  @@domain_gen_factory_list = nil
    124125  def generate
    125126
     
    135136          return
    136137        end
     138        if instance_of? Region then
     139          @@domain_gen_factory_list = {}   # create hash
     140        end
    137141      end
    138142
     
    141145      gen_global_header
    142146
     147      if ( instance_of? Region ) && get_domain_type != nil then
     148        # p "*******************  domain_type: #{get_domain_type.get_name}  ****************"
     149        domain_type = get_domain_type
     150        if @@domain_gen_factory_list[ domain_type ] == nil then
     151          @@domain_gen_factory_list[ domain_type ] = self
     152          domain_type.gen_factory
     153        end
     154      end
     155     
    143156      # signature のコードを生成
    144157      @signature_list.each { |s|
     
    455468      }
    456469    end
    457         f.print "       rm -f $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(TARGET) #{timestamp}\n"
     470          f.print "     rm -f $(CELLTYPE_COBJS) $(TECSGEN_COBJS) $(PLUGIN_COBJS) $(OTHER_OBJS) $(TARGET) #{timestamp}\n"
    458471    if $generating_region == @@root_namespace then
    459472      f.print " rm -rf $(GEN_DIR)\n"
     
    465478      f.print "tecs : $(PRE_TECSGEN_TARGET) $(TIMESTAMP) $(POST_TECSGEN_TARGET)\n\n"
    466479      f.print "$(TIMESTAMP) : $(TECS_IMPORTS)\n"
    467       f.print " $(TECSGEN) #{TECSGEN.subst_tecspath( $arguments, true )}\n"
     480      f.print " $(TECSGEN) #{TECSGEN.subst_tecspath( $arguments, true )}\n\n"
    468481      # f.print "       touch $(TIMESTAMP)\n\n"
    469 
    470482    else
    471483      f.print "tecs:\n"
     
    473485    end
    474486
     487    # tecsflow:, tcflow ターゲット
     488    if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then
     489      f.print "#####  TECSFlow targets  #####\n"
     490    end
     491
     492    if Region.get_link_roots.length > 1 && $generating_region == @@root_namespace then
     493      tecsflow_target = "tecsflow_sub"
     494      if $generating_region.get_n_cells > 0 then
     495        f.print "tecsflow: tecs tecsflow_sub\n"
     496      else
     497        f.print "tecsflow:\n"
     498      end
     499      Region.get_link_roots.each {|region|
     500        if region.get_n_cells > 0 then
     501          f.print "\tcd #{region.get_global_name}; make tecsflow\n"
     502        end
     503      }
     504      f.print "\n"
     505    else
     506      tecsflow_target = "tecsflow"
     507    end
     508
     509    if $generating_region.get_n_cells != 0 then
     510      f.print "#{tecsflow_target} : $(GEN_DIR)/tecsgen.rbdmp tcflow\n"
     511      f.print "\ttecsflow -g $(GEN_DIR)\n\n"
     512      f.print "tecsflow_u : $(GEN_DIR)/tecsgen.rbdmp tcflow\n"
     513      f.print "\ttecsflow -g $(GEN_DIR) -U\n\n"
     514      f.print "$(GEN_DIR)/tecsgen.rbdmp : tecs\n\n"
     515      f.print "tcflow : tecs\n"
     516      f.print "\tmake tcflow_exec\n\n"
     517      f.print "tcflow_exec : $(GEN_DIR)/tcflow.rbdmp\n"
     518      f.print "$(GEN_DIR)/tcflow.rbdmp : $(CELLTYPE_SRCS) $(PLUGIN_CELLTYPE_SRCS)\n"
     519      f.print "\ttcflow -g $(GEN_DIR) -c '$(CC) -E -DTECSFLOW -DTECSGEN $(CFLAGS) -I ./' $^\n"
     520    end
     521
     522    if $generating_region.get_n_cells != 0 || $generating_region == @@root_namespace then
     523      f.print "#####  end TECSFlow targets  #####\n\n"
     524    end
     525
     526    # generic %.o : %.c
    475527    f.print "# generic target for objs\n"
    476528    f.print "$(_TECS_OBJ_DIR)%.o : %.#{$c_suffix}\n"
     
    492544    ### Makefile.tecsgen の生成
    493545    f = AppFile.open( "#{$gen}/Makefile.tecsgen" )
     546
     547    f.print <<EOT
     548# generated automatically by tecsgen.
     549# This file is not intended to modify.
     550#
     551# Makefile variables below are defined.
     552#  TECS_IMPORT_CDLS          .cdl files improted by import statement
     553#  SIGNATURE_HEADERS         .h files of signature
     554#  CELLTYPE_TECSGEN_HEADERS  .h files of celltype
     555#  CELLTYPE_FACTORY_HEADERS  .h files of celltype's factory
     556#  TECS_HEADERS              summary of .h files above
     557#  TECS_INLINE_HEADERS       .h files of celltype inline header
     558#  PLUGIN_INLINE_HEADERS     .h files of plugin generated inline header
     559#
     560#  TECS_COBJS                .o files of TECS
     561#                            = $(TECSGEN_COBJS)+$(PLUGIN_COBJS)+$(CELLTYPE_COBJS)
     562#                            = $(TECS_KERNEL_COBJS)+$(TECS_KERNEL_COBJS)+$(TECS_OUTOFDOMAIN_COBJS)
     563#                            = $(TECSGEN_domain_COBJS)+$(PLUGIN_domain_COBJS)+$(CELLTYPE_domain_COBJS) for each domain
     564#
     565#  TECSGEN_COBJS             .o files of celltype_tecsgen.c
     566#  CELLTYPE_COBJS            .o files of celltype.c (celltype code)
     567#  PLUGIN_COBJS              .o files of plugin generated .c files
     568#
     569#  TECSGEN_SRCS              .c files of celltype_tecsgen.c
     570#  CELLTYPE_SRCS             .c files of celltype.c (celltype code)
     571#  PLUGIN_SRCS               .c files of plugin generated
     572#  PLUGIN_CELLTYPE_SRCS      .c files of plugin generated celltype.c (celltype code)
     573#  PLUGIN_TECSGEN_SRCS       .c files of plugin generated celltype_tecsgen.c
     574#
     575# Variables for domain
     576#  TECS_DOMAINS             domain names
     577#  TECS_KERNEL_COBJS        .o files of kernel domain (tecsgen, celltype, plugin)
     578#  TECS_USER_COBJS          .o files of user domain (tecsgen, celltype, plugin)
     579#  TECS_OUTOFDOMAIN_COBJS   .o files of OutOfDomain (tecsgen, celltype, plugin)
     580#  TECSGEN_domain_COBJS     .o files of celltype_tecsgen.c files for each domain
     581#  PLUGIN_domain_COBJS      .o files of plugin generated .c files for each domain
     582#  CELLTYPE_domain_COBJS    .o files of celltype.c files for each domain
     583#  TECSGEN_domain_SRCS      .c files of celltype_domain_tecsgen.c
     584#  PLUGIN_domain_SRCS       .c files of plugin generated .c files for each domain
     585#  CELLTYPE_domain_SRCS     .c files of celltype.c files for each domain
     586
     587EOT
    494588
    495589    f.print( "TECS_IMPORT_CDLS =" )
     
    546640    DomainType.get_domain_regions.each{ |dt, regions|
    547641      # domain_type は一つのノードには、一つしかないので、このループは、必ず一回しか回らない
     642        ###   mikan 複数のノードがあり、異なる domain_type が指定される可能性はある
    548643      domain_regions = regions
    549644      domain_type = dt
     
    588683      f.print( "\n\n" )
    589684
    590       f.print( "# TECS_COBJS: objects from sources which are automatically generated by tecsgen\n" )
     685      f.print( "# TECS_KERNEL_COBJS: objects belong to kernel domain\n" )
     686      f.print( "TECS_KERNEL_COBJS = \\\n" )
     687      domain_regions.each{ |r|
     688        if r.get_domain_type.get_kind == :kernel then
     689          f.print( "    $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     690          f.print( "    $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     691          f.print( "    $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" )
     692        end
     693      }
     694      f.print( "# TECS_KERNEL_COBJS terminator\n\n" )
     695
     696      f.print( "# TECS_USER_COBJS: objects belong to user domain\n" )
     697      f.print( "TECS_USER_COBJS = \\\n" )
     698      domain_regions.each{ |r|
     699        if r.get_domain_type.get_kind == :user then
     700          f.print( "    $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     701          f.print( "    $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     702          f.print( "    $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" )
     703        end
     704      }
     705      f.print( "# TECS_USER_COBJS terminator\n\n" )
     706
     707      f.print( "# TECS_OUTOFDOMAIN_COBJS: objects belong to OutOfDomain\n" )
     708      f.print( "TECS_OUTOFDOMAIN_COBJS = \\\n" )
     709      domain_regions.each{ |r|
     710        if r.get_domain_type.get_kind == :OutOfDomain then
     711          f.print( "    $(TECSGEN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     712          f.print( "    $(PLUGIN#{decideDomainNameProc.call r}_COBJS) \\\n" )
     713          f.print( "    $(CELLTYPE#{decideDomainNameProc.call r}_COBJS) \\\n" )
     714        end
     715      }
     716      f.print( "# TECS_OUTOFDOMAIN_COBJS terminator\n\n" )
     717     
     718      f.print( "# TECSGEN_COBJS: objects from sources which are automatically generated by tecsgen\n" )
    591719      f.print( "TECSGEN_COBJS = \\\n" )
    592720      domain_regions.each{ |r|
     
    622750
    623751    ###
    624     f.print( "# TECS_COBJS: objects from sources which are automatically generated by tecsgen\n" )
     752    f.print( "# TECSGEN_COBJS: objects from sources which are automatically generated by tecsgen\n" )
    625753    domain_regions.each{ |r|
    626754      nsp = decideDomainNameProc.call( r )
     
    656784
    657785    f.print( "# PLUGIN_SRCS: sources automatically generated by plugin\n" )
     786    f.print( "PLUGIN_CELLTYPE_SRCS = \\\n" )
    658787    domain_regions.each{ |r|
    659788      nsp = decideDomainNameProc.call( r )
    660       f.print( "PLUGIN#{nsp}_SRCS = \\\n" )
    661       gen_celltype_names_domain( f, "   $(GEN_DIR)/", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, true )
    662       gen_celltype_names_domain2( f, "  $(GEN_DIR)/", ".#{$c_suffix} \\\n", domain_type, r, true, false )
    663       f.print( "# PLUGIN#{nsp}_SRCS terminator\n\n" )
    664     }
    665 
     789      f.print( "  $(PLUGIN#{nsp}_CELLTYPE_SRCS)\\\n" )
     790    }
     791    f.print( "# PLUGIN_CELLTYPE_SRCS terminator\n\n" )
     792    f.print( "PLUGIN_TECSGEN_SRCS = \\\n" )
     793    domain_regions.each{ |r|
     794      nsp = decideDomainNameProc.call( r )
     795      f.print( "  $(PLUGIN#{nsp}_TECSGEN_SRCS)\\\n" )
     796    }
     797    f.print( "# PLUGIN_TECSGEN_SRCS terminator\n\n" )
     798    domain_regions.each{ |r|
     799      nsp = decideDomainNameProc.call( r )
     800      f.print( "PLUGIN#{nsp}_SRCS = $(PLUGIN#{nsp}_CELLTYPE_SRCS) $(PLUGIN#{nsp}_TECSGEN_SRCS)\n\n" )
     801      f.print( "PLUGIN#{nsp}_CELLTYPE_SRCS = \\\n" )
     802      gen_celltype_names_domain2( f, "", ".#{$c_suffix} \\\n", domain_type, r, true, false )
     803      f.print( "# PLUGIN#{nsp}_CELLTYPE_SRCS terminator\n\n" )
     804      nsp = decideDomainNameProc.call( r )
     805      f.print( "PLUGIN#{nsp}_TECSGEN_SRCS = \\\n" )
     806      gen_celltype_names_domain( f, "", "_tecsgen.#{$c_suffix} \\\n", domain_type, r, true )
     807      f.print( "# PLUGIN#{nsp}_TECSGEN_SRCS terminator\n\n" )
     808    }
     809
     810    f.print( "# CELLTYPE_SRCS: sources of celltype code written by user\n" )
     811     f.print( "CELLTYPE_SRCS = \\\n" )
     812     gen_celltype_names( f, "   ", ".#{$c_suffix} \\\n", false, false )
     813      f.print( "# CELLTYPE_SRCS terminator\n\n" )
    666814    f.close
    667815
     
    779927    @namespace_list.each{ |ns|
    780928      ns.travers_all_signature_proc proc
     929    }
     930  end
     931
     932  #=== Namespace#すべてのセルタイプをたどる
     933  def travers_all_celltype # ブロック引数 { |celltype|  }
     934    proc = Proc.new    # このメソッドのブロック引数
     935    @celltype_list.each{ |ct|
     936      proc.call ct
     937    }
     938    @namespace_list.each{ |ns|
     939      ns.travers_all_celltype_proc proc
     940    }
     941  end
     942  def travers_all_celltype_proc proc
     943    @celltype_list.each{ |ct|
     944      proc.call ct
     945    }
     946    @namespace_list.each{ |ns|
     947      ns.travers_all_celltype_proc proc
    781948    }
    782949  end
     
    10231190    gen_ph_get_cellcb f
    10241191    gen_ph_attr_access f          if @n_attribute_rw > 0 || @n_attribute_ro > 0 || @n_var > 0
    1025     gen_ph_cp_fun_macro f         if @n_call_port > 0
     1192    f.print "#ifndef TECSFLOW\n"
     1193    gen_ph_cp_fun_macro f, false  if @n_call_port > 0
     1194    f.print "#else  /* TECSFLOW */\n"
     1195    gen_ph_cp_fun_macro f, true   if @n_call_port > 0
     1196    f.print "#endif /* TECSFLOW */\n"
    10261197#    gen_ph_abstract_ep_des_type f
    10271198
     
    12471418  def gen_ph_info f
    12481419
     1420    yn_multi_domain = "no"
     1421    yn_multi_domain = "yes" if multi_domain?
    12491422    yn_idx_is_id = "no"
    12501423    yn_idx_is_id = "yes"  if @idx_is_id
     
    12551428    yn_rom       = "no"
    12561429    yn_rom       = "yes"  if $rom
     1430    yn_has_CB    = "no"
     1431    yn_has_CB    = "yes"  if has_CB?
     1432    yn_has_INIB  = "no"
     1433    yn_has_INIB  = "yes"  if has_INIB?
    12571434    yn_cb_init   = "no"
    12581435    yn_cb_init   = "yes"  if need_CB_initializer?
     
    12631440 * celltype          :  #{@name}
    12641441 * global name       :  #{@global_name}
     1442 * multi-domain      :  #{yn_multi_domain}
    12651443 * idx_is_id(actual) :  #{yn_idx_is_id}(#{yn_idx_is_id_act})
    12661444 * singleton         :  #{yn_singleton}
    1267  * has_CB            :  #{has_CB?}
    1268  * has_INIB          :  #{has_INIB?}
     1445 * has_CB            :  #{yn_has_CB}
     1446 * has_INIB          :  #{yn_has_INIB}
    12691447 * rom               :  #{yn_rom}
    12701448 * CB initializer    :  #{yn_cb_init}
     
    15951773      f.print( "#define #{@global_name}_GET_CELLCB(idx) ((void *)0)\n" )
    15961774    elsif @idx_is_id_act then   # mikan 単一のセルの場合の最適化, idx_is_id でない場合
    1597       f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_tab[(idx) - #{@global_name}_ID_BASE])\n" )
     1775      f.print( "#define #{@global_name}_GET_CELLCB(idx) (#{@global_name}_CB_ptab[(idx) - #{@global_name}_ID_BASE])\n" )
    15981776    else
    15991777      f.print( "#define #{@global_name}_GET_CELLCB(idx) (idx)\n" )
     
    17991977  end
    18001978
    1801   def gen_ph_cp_fun_macro f
    1802     if @n_call_port >0 then
     1979  def gen_ph_cp_fun_macro f, b_flow
     1980    if @n_call_port >0 && b_flow == false then
    18031981      f.printf( TECSMsg.get( :CPM_comment ) , "#_CPM_#" )
    18041982    end
     
    18562034
    18572035        # 関数名の出力(標準:受け口ディスクリプタから VMT の関数名、最適化:受け口関数 or 受け口ディスクリプタ)
    1858         if ! p.is_VMT_useless? then
     2036        if b_flow then
     2037          f.print( "\t  (p_that)->#{p.get_name}#{subsc}.#{fun.get_name}__T( \\\n" )
     2038        elsif ! p.is_VMT_useless? then
    18592039          # 標準コード
    18602040          if @singleton then
     
    18912071
    18922072        # 受け口情報の出力(標準:受け口ディスクリプタ、最適化:IDX など)
    1893         if ! p.is_skelton_useless? && ! p.is_cell_unique? then
     2073        if b_flow then
     2074        elsif ! p.is_skelton_useless? && ! p.is_cell_unique? then
    18942075          # 標準コード
    18952076          if @singleton then
     
    19692150        p_cellcb = "    #{@global_name}_CB *p_cellcb = p_that;\n"
    19702151        delim = ", "
    1971         cb = "p_that#{inib}->"
     2152        cb = "p_cellcb#{inib}->"
    19722153      end
    19732154
     
    26162797        f.print "extern  #{@global_name}_INIB  #{@global_name}_SINGLE_CELL_INIB;\n"
    26172798      end
    2618 
    2619 #     @ordered_cell_list.each{ |c|
    2620 #        f.print "extern  #{@global_name}_CB  #{@global_name}_#{c.get_name}_CB;\n"
    2621 #      }
    2622 
    26232799      f.print "\n"
    2624     elsif @idx_is_id_act then
    2625       f.print "extern #{@global_name}_CB  *#{@global_name}_CB_tab[];\n"
     2800    elsif @b_need_ptab then
     2801      f.printf( TECSMsg.get( :SCP_comment ),  "#_MCPP_#" )
     2802      if has_CB? then
     2803        f.print "extern #{@global_name}_CB  *const #{@global_name}_CB_ptab[];\n"
     2804        @ordered_cell_list.each{ |c|
     2805          if c.is_generate? then                           # 生成対象か?
     2806            name_array = get_name_array c
     2807            f.print "extern #{@global_name}_CB  #{name_array[4]};\n"
     2808          end
     2809        }
     2810      elsif has_INIB?
     2811        f.print "extern #{@global_name}_INIB  *const #{@global_name}_INIB_ptab[];\n"
     2812        @ordered_cell_list.each{ |c|
     2813          if c.is_generate? then                           # 生成対象か?
     2814            name_array = get_name_array c
     2815            f.print "extern #{@global_name}_INIB  #{name_array[11]};\n"
     2816          end
     2817        }
     2818      end
    26262819    else
    2627       f.print "extern #{@global_name}_CB  #{@global_name}_CB_tab[];\n"
     2820      f.printf( TECSMsg.get( :SCP_comment ),  "#_MCPB_#" )
     2821      if has_CB? then
     2822        f.print "extern #{@global_name}_CB  #{@global_name}_CB_tab[];\n"
     2823      elsif has_INIB?
     2824        f.print "extern #{@global_name}_INIB  #{@global_name}_INIB_tab[];\n"
     2825      end
    26282826    end
    26292827  end
    26302828
    26312829  def gen_ph_INIB_as_CB f
    2632 
     2830    # ここは、手抜きである。本来なら INIB を出力すべき
    26332831    if ! has_CB? && has_INIB? then
    26342832      f.printf( TECSMsg.get( :DCI_comment ),  "#_DCI_#" )
    2635       f.print "#define #{@global_name}_CB_tab           #{@global_name}_INIB_tab\n"
    2636       f.print "#define #{@global_name}_SINGLE_CELL_CB   #{@global_name}_SINGLE_CELL_INIB\n"
     2833      if @singleton then
     2834        f.print "#define #{@global_name}_SINGLE_CELL_CB   #{@global_name}_SINGLE_CELL_INIB\n"
     2835      elsif @b_need_ptab then
     2836        f.print "#define #{@global_name}_CB_ptab           #{@global_name}_INIB_ptab\n"
     2837      else
     2838        f.print "#define #{@global_name}_CB_tab           #{@global_name}_INIB_tab\n"
     2839      end
    26372840      f.print "#define #{@global_name}_CB               #{@global_name}_INIB\n"
    26382841      f.print "#define tag_#{@global_name}_CB           tag_#{@global_name}_INIB\n"
     
    26582861      f.printf( TECSMsg.get( :FEC_comment ), "#_FEC_#" )
    26592862
    2660       if @idx_is_id_act then
     2863      if @b_need_ptab then
    26612864        amp = ''
     2865        tab = 'ptab'
    26622866      else
    26632867        amp = '&'
     2868        tab = 'tab'
    26642869      end
    26652870      f.print <<EOT
    26662871#define FOREACH_CELL(i,p_cb)   \\
    26672872    for( (i) = 0; (i) < #{@global_name}_N_CELL; (i)++ ){ \\
    2668        #{necessity}(p_cb) = #{amp}#{@global_name}_CB_tab[i];
     2873       #{necessity}(p_cb) = #{amp}#{@global_name}_CB_#{tab}[i];
    26692874
    26702875#define END_FOREACH_CELL   }
     
    27993004        if @singleton then
    28003005          f.print "\t#{that}_inib = &#{@global_name}_SINGLE_CELL_INIB;\n\n"
    2801         elsif @idx_is_id_act
    2802           f.print "\t#{that}_inib = #{@global_name}_INIB_tab[(i)];\n\n"
     3006        elsif @b_need_ptab then
     3007          f.print "\t#{that}_inib = #{@global_name}_INIB_ptab[(i)];\n\n"
    28033008        else
    28043009          f.print "\t#{that}_inib = &#{@global_name}_INIB_tab[(i)];\n\n"
     
    33973602        fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_SINGLE_CELL_INIB = \n" }
    33983603        indent = 0
    3399       elsif ! @idx_is_id_act then
     3604      elsif ! @b_need_ptab then
    34003605        fs.each{ |r, f| f.print "#{@global_name}_INIB #{@global_name}_INIB_tab[] = {\n" }
    34013606        indent = 1
     
    34183623
    34193624        print_indent( f, indent )
    3420         if @idx_is_id_act then
     3625        if @b_need_ptab then
    34213626          f.print "const #{@global_name}_INIB #{name_array[5]} = "
    34223627        end
     
    34283633        unless @singleton then
    34293634          # 1 つの cell INIB の終わり
    3430           if @idx_is_id_act then
     3635          if @b_need_ptab then
    34313636            f.print( "};\n\n" )
    34323637          else
     
    34353640        end
    34363641      }
    3437       if ! @idx_is_id_act then
     3642      if ! @b_need_ptab then
    34383643        fs.each{ |r, f| f.print( "};\n\n" ) }
    34393644      end
     
    34503655          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB = \n" }
    34513656          indent = 0
    3452         elsif ! @idx_is_id_act then
     3657        elsif ! @b_need_ptab then
    34533658          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_CB_tab[] = {\n" }
    34543659          indent = 1
     
    34713676
    34723677          print_indent( f, indent )
    3473           if @idx_is_id_act then
     3678          if @b_need_ptab then
    34743679            f.print "#{@global_name}_CB #{name_array[2]} = "
    34753680          end
     
    34933698          unless @singleton then
    34943699            # 1 つの cell CB の終わり
    3495             if @idx_is_id_act then
     3700            if @b_need_ptab then
    34963701              f.print( "};\n\n" )
    34973702            else
     
    35003705          end
    35013706        }
    3502         if ! @idx_is_id_act then
     3707        if ! @b_need_ptab then
    35033708          fs.each{ |r, f| f.print( "};\n\n" ) }
    35043709        end
     
    35073712          fs.each{ |r, f| f.print "struct tag_#{@global_name}_CB #{@global_name}_SINGLE_CELL_CB;\n" }
    35083713          indent = 0
    3509         elsif @idx_is_id_act then
     3714        elsif @b_need_ptab then
    35103715          @ordered_cell_list.each{ |c|
    35113716            next if ! c.is_generate?
     
    35263731  def gen_cell_cb_tab f
    35273732    indent = 0
    3528     if @idx_is_id_act then
     3733    if @b_need_ptab then
    35293734      if has_INIB? && ( $ram_initializer || ! has_CB? ) then
    35303735        f.print "/* ID to INIB table #_INTAB_# */\n"
     
    35373742        }
    35383743
    3539         f.print "#{@global_name}_INIB *#{@global_name}_INIB_tab[] ={\n"
     3744        f.print "#{@global_name}_INIB *const #{@global_name}_INIB_ptab[] ={\n"
    35403745        @ordered_cell_list.each{ |c|
    35413746          if c.is_generate? then                           # 生成対象か?
     
    35573762        }
    35583763
    3559         f.print "#{@global_name}_CB *#{@global_name}_CB_tab[] ={\n"
     3764        f.print "#{@global_name}_CB *const #{@global_name}_CB_ptab[] ={\n"
    35603765        @ordered_cell_list.each{ |c|
    35613766          if c.is_generate? then                           # 生成対象か?
     
    35863791  #   name_array[9] = @global_name    # celltype global name
    35873792  #   name_array[10] = cell.get_global_name # cell global name
     3793  #   name_array[11] = cell_INIB_proto #INIB name for proto type
    35883794 
    35893795  def get_name_array( cell )
     
    35943800      cell_CB_proto = "#{@global_name}_SINGLE_CELL_CB"
    35953801      cell_INIB_name = "#{@global_name}_SINGLE_CELL_INIB"
     3802      cell_INIB_proto = cell_INIB_name
    35963803      cell_ID = 0
    35973804    else
    3598       if ! @idx_is_id_act then
     3805      if ! @b_need_ptab then
    35993806        index = cell.get_id - cell.get_celltype.get_id_base
    36003807        cell_CB_name = "#{@global_name}_CB_tab[#{index}]"
     
    36023809        cell_CB_proto = "#{@global_name}_CB_tab[]"
    36033810        cell_INIB_name = "#{@global_name}_INIB_tab[#{index}]"
     3811        cell_INIB_proto = "#{@global_name}_INIB_tab[]"
    36043812      else
    36053813        cell_CB_name = "#{cell.get_global_name}_CB"
     
    36073815        cell_CB_proto = cell_CB_name
    36083816        cell_INIB_name = "#{cell.get_global_name}_INIB"
     3817        cell_INIB_proto = cell_INIB_name
    36093818      end
    36103819      cell_ID = cell.get_id
    3611     end
    3612     if @idx_is_id_act then
    3613       cell_IDX = cell_ID
    3614     else
    3615       cell_IDX = "&#{cell_CB_name}"
    36163820    end
    36173821
     
    36223826    else
    36233827      cell_CBP = "NULL"    # CB も INIB もなければ NULL に置換
     3828    end
     3829
     3830    if @idx_is_id_act then
     3831      cell_IDX = cell_ID
     3832    else
     3833      cell_IDX = cell_CBP
    36243834    end
    36253835
     
    36363846    name_array[9] = @global_name    # celltype global name
    36373847    name_array[10] = cell.get_global_name # cell global name
     3848    name_array[11] = cell_INIB_proto # INIB name for prototype
    36383849
    36393850    return name_array
     
    38204031              c = j.get_rhs_cell                    # 呼び先セル
    38214032              ct = c.get_celltype                   # 呼び先セルタイプ
     4033              name_array = ct.get_name_array( c )   # 呼び先セルタイプで name_array を得る
    38224034              if ct.has_INIB? || ct.has_CB? then
    3823                 name_array = ct.get_name_array( c )   # 呼び先セルタイプで name_array を得る
    38244035                f.printf( "%-40s /* %s #_CCP2_# */\n", "#{name_array[7]},", p.get_name )
    38254036              else
     
    41074318      f = fs[ c.get_region.get_domain_root ]
    41084319
    4109       ct = c.get_celltype
     4320      ct = c.get_celltype     # ct = self でも同じ
    41104321      jl = c.get_join_list
     4322      name_array = get_name_array( c )
    41114323
    41124324      port = ct.get_port_list
     
    41434355              else
    41444356                if has_CB? then
    4145                   if @singleton then
    4146                     f.print "    &#{@global_name}_SINGLE_CELL_CB,        /* CB */\n"
    4147                   else
    4148                     # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
    4149                     f.print "    &#{@global_name}_CB_tab[#{index}],      /* CB */\n"
    4150                   end
     4357                  # if @singleton then
     4358                  #   f.print "    &#{@global_name}_SINGLE_CELL_CB,        /* CB 1 */\n"
     4359                  # else
     4360                  #   # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
     4361                  #   f.print "    &#{@global_name}_CB_tab[#{index}],      /* CB 2 */\n"
     4362                  # end
     4363                  f.print "    #{name_array[8]},      /* CB 1 */\n"
    41514364                elsif has_INIB? then
    4152                   if @singleton then
    4153                     f.print "    &#{@global_name}_SINGLE_CELL_INIB,      /* INIB */\n"
    4154                   else
    4155                     f.print "    &#{@global_name}_INIB_tab[#{index}],    /* INIB */\n"
    4156                   end
     4365                  # if @singleton then
     4366                  #   f.print "    &#{@global_name}_SINGLE_CELL_INIB,      /* INIB 1 */\n"
     4367                  # else
     4368                  #   f.print "    &#{@global_name}_INIB_tab[#{index}],    /* INIB 2 */\n"
     4369                  # end
     4370                  f.print "    &#{name_array[5]},      /* INIB 1 */\n"
    41574371                else
    41584372                  f.print "    0,\n"
     
    41784392            else
    41794393              if has_CB? then
    4180                 if @singleton then
    4181                   f.print "    &#{@global_name}_SINGLE_CELL_CB,       /* CB */\n"
    4182                 else
    4183                   f.print "    &#{@global_name}_CB_tab[#{index}],     /* CB */\n"
    4184                   # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
    4185                 end
     4394                # if @singleton then
     4395                #   f.print "    &#{@global_name}_SINGLE_CELL_CB,       /* CB 3 */\n"
     4396                # else
     4397                #   f.print "    &#{@global_name}_CB_tab[#{index}],     /* CB 4 */\n"
     4398                #   # f.print "    &#{@global_name}_#{c.get_name}_CB,\n"
     4399                # end
     4400                f.print "    #{name_array[8]},      /* CB 3 */\n"
    41864401              elsif has_INIB? then
    4187                 if @singleton then
    4188                   f.print "    &#{@global_name}_SINGLE_CELL_INIB,     /* INIB */\n"
    4189                 else
    4190                   f.print "    &#{@global_name}_INIB_tab[#{index}],   /* INIB */\n"
    4191                 end
     4402                # if @singleton then
     4403                #   f.print "    &#{@global_name}_SINGLE_CELL_INIB,     /* INIB 3 */\n"
     4404                # else
     4405                #   # f.print "    &#{@global_name}_INIB_tab[#{index}],   /* INIB 4 */\n"
     4406                # end
     4407                f.print "    &#{name_array[5]},      /* INIB 3 */\n"
    41924408              else
    41934409                f.print "    0,\n"
     
    45504766  def generate_inline_template_code
    45514767    return if @n_entry_port_inline == 0
     4768    return if @b_reuse && ! $generate_all_template
    45524769    if ! ( @plugin && @plugin.gen_ep_func? ) then
    45534770      return if @b_reuse && ! $generate_all_template
     
    49275144  #  str に以下の置換を行う
    49285145  #-   $ct$ ⇒ セルタイプ名(ct)
    4929   #-   $cell$ ⇒ セル名(cell)   cell が nil ならば3つの置換は行われない
     5146  #-   $cell$ ⇒ セル名(cell)   cell が nil ならば以下の置換は行われない
    49305147  #-   $cb$ ⇒ CB の C 言語名(cb)
    49315148  #-   $cbp$ ⇒ CB へのポインタ(cbp)
    49325149  #-   $cb_proto$ ⇒ CB の C 言語名プロトタイプ宣言用(cb_proto)
    4933   #-   $id$ ⇒ ct_cell
     5150  #-   $id$ ⇒ $ct$_$cell_global$    # ct_cell  before or same V1.5.2
    49345151  #-   $idx$ ⇒ idx
    49355152  #-   $ID$ ⇒ id (整数の番号)
    49365153  #-   $ct_global$ ⇒ セルタイプ名(ct)
    4937   #-   $cell_global$ ⇒ セル名(cell)   cell が nil ならば3つの置換は行われない
     5154  #-   $cell_global$ ⇒ セル名(cell)
    49385155  #-   $$   ⇒ $
    49395156  def subst_name( str, name_array )
     
    49505167
    49515168    str = str.gsub( /(^|[^\$])\$ct\$/, "\\1#{ct}" )
     5169    str = str.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{ct_global}" )
    49525170    if cell then
    49535171      str = str.gsub( /(^|[^\$])\$cell\$/, "\\1#{cell}" )
    49545172      str = str.gsub( /(^|[^\$])\$cb\$/, "\\1#{cb}" )
    4955       str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell}" )
     5173      # str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell}" )
     5174      str = str.gsub( /(^|[^\$])\$id\$/, "\\1#{ct}_#{cell_global}" )
    49565175      str = str.gsub( /(^|[^\$])\$cb_proto\$/, "\\1#{cb_proto}" )
    49575176      str = str.gsub( /(^|[^\$])\$ID\$/, "\\1#{id}" )
    49585177      str = str.gsub( /(^|[^\$])\$idx\$/, "\\1#{idx}" )
    49595178      str = str.gsub( /(^|[^\$])\$cbp\$/, "\\1#{cbp}" )
    4960       str = str.gsub( /(^|[^\$])\$ct_global\$/, "\\1#{ct_global}" )
    49615179      str = str.gsub( /(^|[^\$])\$cell_global\$/, "\\1#{cell_global}" )
    49625180    end
     
    50785296  end
    50795297end
     5298
     5299class DomainType < Node
     5300  def gen_factory
     5301    # p "DomainType: gen_factory"
     5302    @plugin.gen_factory
     5303  end
     5304end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/location.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/messages.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/optimize.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    178178
    179179  def set_domain
     180    domain_cells = {}
    180181    @cell_list.each{ |c|
    181182      if c.is_generate? then
     
    191192          @domain_roots[ dn ] = [ dr ]
    192193        end
     194        if domain_cells[ dr ]  then
     195          domain_cells[ dr ] << c
     196        else
     197          domain_cells[ dr ] = [ c ]
     198        end
    193199      end
    194200    }
     
    196202    @domain_roots.each{ |dn, drs|
    197203      drs.uniq!
    198       if ! $debug then
    199         dbgPrint "domains celltype:#{@name} domain=#{dn} "
     204      if $verbose && dn then
     205        print "[domain] celltype=#{@name} domainType=#{dn} domainRootRegions={"
     206        delim = ""
    200207        drs.each{ |r|
    201           dbgPrint " region=#{r.get_name}"
     208          print delim, r.get_name
     209          delim = ", "
    202210        }
    203         dbgPrint "\n"
     211        print "}\n"
     212        drs.each{ |r|
     213          print "[domain] celltype=#{@name} domainRootRegion=#{r.get_name} domainType=#{dn} domainKind=#{r.get_domain_root.get_domain_type.get_kind} domainCells={"
     214          delim = ""
     215          domain_cells[r].each{ |c|
     216            print delim, c.get_name
     217            delim = ", "
     218          }
     219          print "}\n"
     220        }
    204221      end
    205222    }
     
    212229      # domain_type は一つのノードに一つしかないので、一つの要素を無条件で取り出す
    213230      if regions.length > 1 then
    214         cdl_info( "I9999 celltype:#{@name} has cells in multi domain.\n" )
    215         if @idx_is_id == false then
    216           cdl_info( "I9999 celltype:#{@name} forcely set idx_is_id\n" )
    217         end
    218         @idx_is_id_act = true
     231        if $verbose then
     232          cdl_info( "I9999 celltype '$1' has cells in multi-domain.\n", @name )
     233        end
     234        # if @idx_is_id == false then
     235        #   cdl_info( "I9999 celltype '$1' forcely set idx_is_id\n", @name )
     236        # end
     237        @b_need_ptab = true
     238        # @idx_is_id_act = true
    219239      end
    220240    }
     
    228248    end
    229249
     250    optimize_call
     251    if $unopt_entry == false then
     252      optimize_entry
     253    end
     254  end
     255
     256  #=== Celltype#呼び口最適化
     257  def optimize_call
    230258    @port.each{ |port|
    231259      next if port.get_port_type != :CALL
     
    361389      dbgPrint "#{port.get_name} : # of cells : #{port_cells.length}  # of ports : #{port_ports.length}\n"
    362390    }
    363 
     391  end
     392
     393  #=== Celltype#受け口最適化
     394  # optimize_entry は、呼び口最適化の結果を使用している
     395  def optimize_entry
    364396    # 受け口最適化の設定
    365397    @port.each{ |port|
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/plugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    160160      #  識別子取得
    161161      if arg =~ /\A[a-zA-Z_]\w*/ then
    162         ident = $~
     162        ident = $~.to_s    #
    163163        arg = $'
    164164      else
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/pluginModule.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/syntaxobj.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2016 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    685685  end
    686686
     687  #=== Decl# print_flowinfo
     688  def print_flowinfo file
     689    if @kind == :VAR then
     690      file.write "#{@identifier} "
     691    end
     692  end
     693
    687694  def show_tree( indent )
    688695    indent.times { print "  " }
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/tecsgen.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    250250    Cell.create_reverse_join
    251251
     252    DescriptorType.check_signature
     253    Signature.set_descriptor_list
     254    Celltype.check_dynamic_join
     255
    252256    #0 set_definition_join は2回呼び出される(1回目)
    253257    dbgPrint( "## Checking all join\n")
     
    450454  end # finalize
    451455
     456  def dump_tecsgen_rbdmp
     457    dbgPrint "dump_tecsgen_rbdmp 0:\n"
     458    #### unjoin_plugin 後に行う必要があるため、コード生成後にダンプを行う
     459    #### Region link root ごとにオプティマイズしてダンプ ####
     460    Namespace.get_root.unjoin_plugin
     461    Namespace.get_root.find_plugin 0, []
     462
     463    Region.get_link_roots.each { |region|
     464      dbgPrint "dump_tecsgen_rbdmp 1: Region.path_str: #{region.get_namespace_path.get_path_str}\n"
     465
     466      n_cells = region.get_n_cells
     467
     468      if $region_list.length > 0 then
     469        if $region_list[ region.get_namespace_path.get_path_str ] == false then
     470          $region_list[ region.get_namespace_path.get_path_str ] = true
     471        else
     472          next
     473        end
     474      end
     475
     476      dbgPrint "dump_tecsgen_rbdmp 2: Region.path_str: #{region.get_namespace_path.get_path_str}\n"
     477      # セルが一つもなければ生成しない
     478      # セルの生成がない場合
     479      if region.get_n_cells == 0 then
     480        # if $region_list.length > 0 then
     481        #   Generator.warning( "W9999 $1: specified to generate but has no cell", region.get_name )
     482        # end
     483        if region != @root_namespace then
     484          next
     485        end
     486      end
     487
     488      dbgPrint "dump_tecsgen_rbdmp 3: Region.path_str: #{region.get_namespace_path.get_path_str}\n"
     489      $generating_region = region
     490      if Region.get_link_roots.length > 1 then
     491        if region.get_name == "::" then
     492          $gen = $gen_base
     493        else
     494          $gen = $gen_base + "/" + region.get_global_name.to_s
     495        end
     496      else
     497        $gen = $gen_base
     498      end
     499
     500      dbgPrint "dump_tecsgen_rbdmp 4: Region.path_str: #{region.get_namespace_path.get_path_str}\n"
     501      dbgPrint( "## Unset optimize variables\n")
     502      @root_namespace.reset_optimize   # 最適化をリセットする
     503
     504      #  if Generator.get_n_error == 0 then
     505      #   # エラーが発生していたら、ここへは来ない
     506         dbgPrint( "## Set cell id\n")
     507        @root_namespace.set_cell_id_and_domain      # セルの ID とドメイン情報を設定(linkunit 毎に0からつける)
     508
     509        # エラーが発生していたら、最適化は実施しない
     510        if ! $unopt then
     511          dbgPrint( "## Optimizing: Link Region=#{@root_namespace.get_name}\n")
     512          @root_namespace.optimize
     513        end
     514      # end
     515      dbgPrint "dump_tecsgen_rbdmp final: Region.path_str: #{region.get_namespace_path.get_path_str}\n"
     516      File.write( "#{$gen}/tecsgen.rbdmp", Marshal.dump(Namespace.get_root) )
     517    }
     518  end
     519 
    452520  def self.post_coded?
    453521    @@b_post_coded
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/tecsinfo.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2017 by TOPPERS Project
     6#   Copyright (C) 2017-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4949#{indent0}region rTECSInfo {
    5050EOT
    51     # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力する.
     51    Type.reset_print_info
     52
     53    # mikan 全部生成するのではなく、region 下のセルのセルタイプと、そこから参照されるシグニチャ、セルタイプに限定して出力すべき
    5254    # しかし、意味解析後に出力するため、これは容易ではない.最適化とコード生成は、リンクルートごとに行われる.
    5355    Namespace.print_info f, indent
     
    149151                 "#{tag.get_ID_str}_#{decl.get_name}",
    150152                 "(uint32_t)(intptr_t)&(((#{tag.get_type_str}#{tag.get_type_str_post}*)0)->#{decl.get_name})"
     153        f.printf "#define PLACE_OF_%-30s  (%s)\n",
     154                 "#{tag.get_ID_str}_#{decl.get_name}",
     155                 "VARDECL_PLACE_STRUCT"
    151156      }
    152157    }
     
    191196    }
    192197  end
     198
     199  def print_entry_define f
     200    @celltype_list.each { |ct|
     201      if ct.get_cell_list.length > 0 then
     202        ct.print_entry_define f
     203      end
     204    }
     205    @namespace_list.each { |ns|
     206      if ns.instance_of? Namespace then   # region を含めない
     207        ns.print_entry_define f
     208      end
     209    }
     210  end
    193211end
    194212
     
    200218      name = @global_name
    201219    end
     220    # p "region:#{get_name}"
    202221    f.print "\n#{indent}/*** #{get_namespace_path} region information cell ***/\n"
    203222    f.print <<EOT
    204223#{indent}cell nTECSInfo::tRegionInfo #{name}RegionInfo{
    205224#{indent}    name = "#{@name}";
    206 #{indent}};
    207 EOT
     225EOT
     226    @cell_list.each{ |cell|
     227        # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 1\n"
     228      if ! cell.exclude_info? then
     229        # print "cell class="+cell.get_celltype.class.name+", " + cell.get_celltype.get_name.to_s + " 2\n"
     230        f.print "#{indent}    cCellInfo[] = #{cell.get_global_name}CellInfo.eCellInfo;\n"
     231      end
     232    }
     233    @namespace_list.each { |region|
     234      if region.instance_of? Region then
     235        f.print "#{indent}    cRegionInfo[] = #{region.get_global_name}RegionInfo.eRegionInfo;\n"
     236       end
     237    }
     238    f.print "#{indent}};\n"
     239    @cell_list.each{ |cell|
     240      if ! cell.exclude_info? then
     241        cell.print_info f, indent
     242      end
     243    }
    208244  end
    209245
     
    221257    self.print_info_region f, indent
    222258  end
     259
     260  def self.print_cell_define f
     261    region.get_link_root.print_cell_define f
     262    region.get_link_root.get_region{ |region|
     263      if region.instance_of? Region then
     264        region.print_cell_define_offset f
     265      end
     266
     267    }
     268  end
     269
     270  def print_cell_define f
     271    ct_list = {}
     272    @cell_list.each{ |cell|
     273      next if cell.exclude_info_factory?
     274      ct_list[ cell.get_celltype ] = true
     275    }
     276    f.print "#define TOPPERS_CB_TYPE_ONLY\n"
     277    ct_list.each{ |ct, val|
     278      f.print "#include \"#{ct.get_global_name}_tecsgen.h\"\n"
     279    }
     280    f.print "\n"
     281    @cell_list.each{ |cell|
     282      next if cell.exclude_info_factory?
     283      name_array = cell.get_celltype.get_name_array cell
     284      if cell.get_celltype.has_CB?
     285        cb = "(void*)#{name_array[8]}"
     286        cb_proto = "extern #{cell.get_celltype.get_global_name}_CB #{name_array[4]};\n"
     287      else
     288        cb = "0"
     289        cb_proto = ""
     290      end
     291      if cell.get_celltype.has_INIB?
     292        inib = "(void*)&#{name_array[5]}"
     293        inib_proto = "extern #{cell.get_celltype.get_global_name}_INIB #{name_array[11]};\n"
     294      else
     295        inib = "0"
     296        inib_proto = ""
     297      end
     298      if ! cell.exclude_info_factory? then
     299        f.print <<EOT
     300#{cb_proto}#define  #{cell.get_global_name}__CBP   #{cb}
     301#{inib_proto}#define  #{cell.get_global_name}__INIBP #{inib}
     302EOT
     303      end
     304    }
     305    @namespace_list.each { |region|
     306      if region.instance_of? Region then
     307        region.print_cell_define f
     308      end
     309    }
     310  end
     311
     312  def print_entry_descriptor_define f
     313    @cell_list.each{ |cell|
     314      next if cell.exclude_info_factory?
     315
     316      signatures = {}
     317      cell.get_celltype.get_port_list.each{ |port|
     318        next if port.get_port_type != :ENTRY
     319
     320        if signatures[ port.get_signature ] == nil then
     321          f.print "#include \"#{port.get_signature.get_global_name}_tecsgen.h\"\n"
     322        end
     323        if cell.get_celltype.get_global_name == :nTECSInfo_tRawEntryDescriptorInfo then
     324          f.print "const struct tag_#{cell.get_celltype.get_global_name}_#{port.get_name}_DES "
     325          f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
     326        else
     327          f.print "extern struct tag_#{port.get_signature.get_global_name}_VDES "
     328          f.print "#{cell.get_global_name}_#{port.get_name}_des;\n"
     329        end
     330      }
     331    }
     332    @namespace_list.each { |region|
     333      if region.instance_of? Region then
     334        region.print_entry_descriptor_define f
     335      end
     336    }
     337  end
    223338end
    224339
     
    227342    f.print <<EOT
    228343#{indent}cell nTECSInfo::tCelltypeInfo #{@global_name}CelltypeInfo {
    229 #{indent}    name            = "#{@name}";
    230 #{indent}    b_singleton     = #{@singleton};
    231 #{indent}    b_IDX_is_ID_act = C_EXP( "#{@global_name}__IDX_is_ID_act" );
    232 #{indent}    b_hasCB         = C_EXP( "#{@global_name}__hasCB" );
    233 #{indent}    b_hasINIB       = C_EXP( "#{@global_name}__hasINIB" );
    234 #{indent}    n_cellInLinUnit = C_EXP( "#{@global_name}__NCELLINLINKUNIT" );
    235 #{indent}    n_cellInSystem  = #{@cell_list.length};
     344#{indent}    name             = "#{@name}";
     345#{indent}    b_singleton      = #{@singleton};
     346#{indent}    b_IDX_is_ID_act  = C_EXP( "#{@global_name}__IDX_is_ID_act" );
     347#{indent}    sizeOfCB         = C_EXP( "#{@global_name}__sizeOfCB" );
     348#{indent}    sizeOfINIB       = C_EXP( "#{@global_name}__sizeOfINIB" );
     349#{indent}    n_cellInLinkUnit = C_EXP( "#{@global_name}__NCELLINLINKUNIT" );
     350#{indent}    n_cellInSystem   = #{@cell_list.length};
    236351EOT
    237352    @port.each{ |port|
     
    273388    }
    274389    @attribute.each{ |decl|
    275       decl.print_info f, @global_name, indent
     390      decl.print_info f, @global_name, indent, :DECLTYPE_ATTR
    276391    }
    277392    @var.each{ |decl|
    278       decl.print_info f, @global_name, indent
     393      decl.print_info f, @global_name, indent, :DECLTYPE_VAR
    279394    }
    280395  end
     
    295410        if ! decl.is_omit? then
    296411          offset = "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
     412          place = inib_cb
    297413        else
    298414          offset = "0xffffffff"
     415          place = "NON"
    299416        end
    300417        f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", offset
     418        f.printf "#define PLACE_OF_%-30s  VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
    301419      }
    302420      @var.each{ |decl|
    303         if decl.get_size_is then
     421        if decl.get_size_is && has_INIB? then
    304422          inib_cb = "INIB"
    305423        else
    306424          inib_cb = "CB"
    307425        end
    308           f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
     426        place = inib_cb
     427        f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "(uint32_t)(intptr_t)&(((#{@global_name}_#{inib_cb}*)0)->#{decl.get_name})"
     428        f.printf "#define PLACE_OF_%-30s  VARDECL_PLACE_%s\n", "#{@global_name}_#{decl.get_name}", place
    309429      }
    310430    else
     
    316436      @attribute.each{ |decl|
    317437        f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
     438        f.printf "#define PLACE_OF_%-30s   VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
    318439      }
    319440      @var.each{ |decl|
    320441        f.printf "#define OFFSET_OF_%-30s  (%s)\n", "#{@global_name}_#{decl.get_name}", "0xffffffff"
     442        f.printf "#define PLACE_OF_%-30s   VARDECL_PLACE_NON\n", "#{@global_name}_#{decl.get_name}"
    321443      }
    322444    end
     
    324446
    325447  def print_celltype_define f
    326     f.printf "#define %-50s (#{@idx_is_id_act})\n",     "#{@global_name}__IDX_is_ID_act"
    327     f.printf "#define %-50s (#{has_CB?})\n",            "#{@global_name}__hasCB"
    328     f.printf "#define %-50s (#{has_INIB?})\n",          "#{@global_name}__hasINIB"
    329     f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
     448    if has_INIB? then
     449      size_INIB = "(sizeof(#{@global_name}_INIB))"
     450    else
     451      size_INIB = "(0)"
     452    end
     453    if has_CB? then
     454      size_CB = "(sizeof(#{@global_name}_CB))"
     455    else
     456      size_CB   = "(0)"
     457    end
     458
     459    if @n_cell_gen > 0 then
     460      f.printf "\n#include \"#{@global_name}_tecsgen.h\"\n"
     461      f.printf "#define %-50s (#{@idx_is_id_act})\n",     "#{@global_name}__IDX_is_ID_act"
     462      f.printf "#define %-50s (#{size_CB})\n",            "#{@global_name}__sizeOfCB"
     463      f.printf "#define %-50s (#{size_INIB})\n",          "#{@global_name}__sizeOfINIB"
     464      f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
     465    else
     466      f.printf "#define %-50s (false)\n",                 "#{@global_name}__IDX_is_ID_act"
     467      f.printf "#define %-50s (0)\n",                     "#{@global_name}__sizeOfCB"
     468      f.printf "#define %-50s (0)\n",                     "#{@global_name}__sizeOfINIB"
     469      f.printf "#define %-30s (%d)\n", "#{@global_name}__NCELLINLINKUNIT", @n_cell_gen
     470    end
    330471  end
    331472
     
    365506        end
    366507      end
    367       if ( port.is_VMT_useless? && port.is_cell_unique? ) || @n_cell_gen == 0 then
     508      if ( port.is_VMT_useless? && port.is_cell_unique? ) || port.is_omit? || @n_cell_gen == 0 then
    368509        offset = "0xffffffff"
    369510      else
     
    375516        offset = "(uint32_t)(intptr_t)&((#{@global_name}_#{cb_inib}*)0)->#{port.get_name}"
    376517      end
     518      array_size = port.get_array_size
     519      if array_size == "[]" then
     520        array_size = "0xffffffff"
     521      elsif array_size == nil then
     522        array_size = "0"
     523      end
     524
    377525      f.printf "#define %-50s (#{offset})\n",                   "#{@global_name}_#{port.get_name}__offset"
     526      f.printf "#define %-50s (#{array_size})\n",               "#{@global_name}_#{port.get_name}__array_size"
    378527      f.printf "#define %-50s (#{place})\n",                    "#{@global_name}_#{port.get_name}__place"
    379528      f.printf "#define %-50s (#{port.is_VMT_useless?})\n",     "#{@global_name}_#{port.get_name}__b_VMT_useless"
     
    382531    }
    383532  end
     533
     534  def print_entry_define f
     535    @port.each{ |port|
     536      next if port.get_port_type == :CALL
     537      array_size = port.get_array_size
     538      if array_size == "[]" then
     539        array_size = "0xffffffff"
     540      elsif array_size == nil then
     541        array_size = "0"
     542      end
     543
     544      f.printf "#define %-50s (#{array_size})\n",               "#{@global_name}_#{port.get_name}__array_size"
     545    }
     546  end
    384547end
    385548
     
    393556#{indent}    cSignatureInfo  = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
    394557#{indent}    b_inline        = #{@b_inline};
     558#{indent}    array_size      = C_EXP( "#{ct_global}_#{@name}__array_size" );
    395559#{indent}};
    396560EOT
     
    401565#{indent}    cSignatureInfo  = #{@signature.get_global_name}SignatureInfo.eSignatureInfo;
    402566#{indent}    offset            = C_EXP( "#{ct_global}_#{@name}__offset" );
     567#{indent}    array_size        = C_EXP( "#{ct_global}_#{@name}__array_size" );
    403568#{indent}    b_optional        = #{@b_optional};
    404569#{indent}    b_omit            = #{@b_omit};
     
    418583end
    419584
     585class Cell
     586  def print_info f, indent
     587    if exclude_info? then
     588      return
     589    end
     590    f.print <<EOT
     591
     592#{indent}/*** #{@global_name} cell information ****/
     593#{indent}cell nTECSInfo::tCellInfo #{@global_name}CellInfo {
     594#{indent}    name            = "#{@name}";
     595#{indent}    cbp             = C_EXP( \"#{@global_name}__CBP\" );
     596#{indent}    inibp           = C_EXP( \"#{@global_name}__INIBP\" );
     597#{indent}    cCelltypeInfo   = #{@celltype.get_global_name}CelltypeInfo.eCelltypeInfo;
     598EOT
     599    @celltype.get_port_list.each{ |port|
     600      next if port.get_port_type != :ENTRY
     601
     602      f.print <<EOT
     603#{indent}    cRawEntryDescriptor[] = #{@global_name}_#{port.get_name}RawEntryDescriptorInfo.eRawEntryDescriptor;
     604EOT
     605    }
     606    f.print "#{indent}};\n"
     607
     608    # RawEntryDescriptorInfo cells
     609    @celltype.get_port_list.each{ |port|
     610      next if port.get_port_type != :ENTRY
     611
     612      size = port.get_array_size
     613      if size == nil then
     614        size = 1
     615      elsif size == "[]" then
     616        size = @entry_array_max_subscript[ port ]
     617      end
     618      if ! port.is_omit? then
     619        red = "C_EXP( \"&#{@global_name}_#{port.get_name}_des\" )"
     620      else
     621        red = "(void *)0"
     622      end
     623      # mikan 受け口配列
     624      f.print <<EOT
     625#{indent}cell nTECSInfo::tRawEntryDescriptorInfo #{@global_name}_#{port.get_name}RawEntryDescriptorInfo {
     626#{indent}   size = #{size};
     627#{indent}   rawEntryDescriptor = { #{red} };
     628EOT
     629#  #{indent}   cEntryInfo = #{@celltype.get_global_name}_#{port.get_name}EntryInfo.eEntryInfo;
     630      f.print "#{indent}};\n"
     631    }
     632  end
     633
     634  def exclude_info?
     635    # print "exclude_info?: name=" + get_name.to_s
     636    if @celltype == nil ||
     637       is_of_composite? ||
     638       @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
     639       post_code_generated? ||
     640       @b_defined == false then
     641      # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
     642      return true
     643    else
     644      # print ": false\n"
     645      return false
     646    end
     647  end
     648
     649  def exclude_info_factory?
     650    # print "exclude_info_factory?: name=" + get_name.to_s
     651    if @celltype == nil ||
     652       is_of_composite? ||
     653       @celltype.get_global_name == :nTECSInfo_tTECSInfoSub ||
     654       ! @celltype.need_generate? then
     655      # print ": true celltype_is_of_composite=#{is_of_composite?} celltype_name=#{@celltype.get_global_name} celltype.need_generate=#{@celltype.need_generate?}\n"
     656      return true
     657    else
     658      # print ": false\n"
     659      return false
     660    end
     661  end
     662end
     663
    420664class Signature
    421665  def print_info f, indent
     
    446690    f.print <<EOT
    447691#{indent}cell nTECSInfo::tFunctionInfo #{sig_name}_#{func_name}FunctionInfo {
    448 #{indent}    name            = "#{@owner.get_global_name}_#{@name}";
     692#{indent}    name            = "#{get_name}";
    449693#{indent}    bOneway         = #{is_oneway?};
    450694EOT
     
    502746
    503747class Decl
    504   def print_info f, parent_ID_str, indent
     748  def print_info f, parent_ID_str, indent, decl_type
    505749    if @size_is then
    506750      size = "\"mikan\"";
     
    512756#{indent}    name            = "#{get_name}";
    513757#{indent}    sizeIsExpr      = #{size};
    514 #{indent}    declType        = DECLTYPE_STMEMBER;
     758#{indent}    declType        = #{decl_type};
    515759#{indent}    offset          = C_EXP( "OFFSET_OF_#{parent_ID_str}_#{get_name}" );
     760#{indent}    place           = C_EXP( "PLACE_OF_#{parent_ID_str}_#{get_name}" );
    516761#{indent}    cTypeInfo       = #{get_type.get_ID_str}TypeInfo.eTypeInfo;
    517762#{indent}};
     
    523768class Type
    524769  @@typeinfo_printed = {}
     770
     771  def self.reset_print_info
     772    @@typeinfo_printed = {}
     773  end
     774
    525775  def print_info f, indent
    526776    # Type の info は、最後にまとめて出力するので、ここでは記録するだけ
     
    538788    elsif self.kind_of? StructType then
    539789      get_members_decl.get_items.each{ |decl|
    540         decl.get_type.print_info f, indent
     790        decl.print_info f, get_ID_str, indent, :DECLTYPE_STMEMBER
    541791      }
    542792    end
     
    550800
    551801  def print_info_post f, indent
    552     bit_size = get_bit_size
    553     if bit_size == 0 then
    554       bit_size = "C_EXP( \"sizeof(#{get_type_str}#{get_type_str_post})\" )"
    555     end
    556802    if self.class.superclass == Type then     # 親クラスが Type の場合 types.rb のクラス
    557803      type_name = self.class.name
     
    566812#{indent}    name           = "#{get_type_str}#{get_type_str_post}";
    567813#{indent}    typeKind       = TECSTypeKind_#{type_name};
    568 #{indent}    bitSize        = #{bit_size};
     814#{indent}    size           = C_EXP( "sizeof(#{get_type_str}#{get_type_str_post})" );
    569815#{indent}    b_const        = #{is_const?};
    570816#{indent}    b_volatile     = #{is_volatile?};
    571817EOT
    572818    if self.kind_of? PtrType then
    573       f.print "#{indent}    cTypeInfo      = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
     819      f.print "#{indent}    cTypeInfo        = #{get_referto.get_ID_str}TypeInfo.eTypeInfo;\n"
    574820    elsif self.kind_of? ArrayType then
    575       f.print "#{indent}    cTypeInfo      = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
     821      f.print "#{indent}    cTypeInfo        = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
    576822    elsif self.kind_of? DefinedType then
    577       f.print "#{indent}    cTypeInfo      = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
     823      f.print "#{indent}    cTypeInfo        = #{get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
    578824    elsif self.kind_of? StructType then
    579825      get_members_decl.get_items.each{ |decl|
    580         f.print "#{indent}    cTypeInfo[]    = #{decl.get_type.get_ID_str}TypeInfo.eTypeInfo;\n"
     826        f.print "#{indent}    cVarDeclInfo[] = #{get_ID_str}_#{decl.get_name}VarDeclInfo.eVarDeclInfo;\n"
    581827      }
    582828    elsif self.kind_of? DescriptorType then
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/tool_info.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/types.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55#
    6 #   Copyright (C) 2008-2015 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#-- 
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    629629
    630630class FloatType < Type
    631 #  @bit_size::         32, 64, (80), -32, -64
     631#  @bit_size::         32, 64, (80), -32, -64, -128
    632632
    633633  def initialize( bit_size )
     
    684684    when -64
    685685      str = "#{str}double"
     686    when -128
     687      str = "#{str}long double"
    686688    end
    687689    return str
     
    15581560# 動的結合で渡すデスクリプタ型
    15591561class DescriptorType < Type
    1560 # @sinagure_nsp::NamespacePath
     1562  # @sinagure_nsp::NamespacePath
     1563
     1564  @@descriptors = {}
    15611565
    15621566  def initialize( signature_nsp )
    1563     # p "Desc #{signature_nsp.to_s}"
    1564     obj = Namespace.find signature_nsp
    1565     if ! obj.kind_of? Signature then
    1566       cdl_error( "T9999 '$1': not signature or not found", signature_nsp.to_s )
    1567       @signature_nsp = signature_nsp
    1568     else
    1569       if obj.has_descriptor? then
    1570        # cdl_error( "T9999 '$1': has Descriptor in function parameter", signature_nsp.to_s )
    1571       end
    1572       @signature_nsp = obj.get_namespace_path
    1573     end
     1567    @signature_nsp = signature_nsp
     1568    # check_signature ##
     1569    @@descriptors[ self ] = false
    15741570  end
    15751571
     
    15951591    else
    15961592      cdl_error2( locale, "T9999 Descriptor cannot be used for $1", kind)
     1593    end
     1594  end
     1595
     1596  def self.check_signature
     1597    @@descriptors.each{ |desc, val|
     1598      if val != true then
     1599        desc.check_signature
     1600        @@descriptors[ desc ] = true
     1601      end
     1602    }
     1603  end
     1604 
     1605  def check_signature
     1606    # p "Desc #{@signature_nsp.to_s}"
     1607    obj = Namespace.find @signature_nsp
     1608    if ! obj.kind_of? Signature then
     1609      cdl_error( "T9999 '$1': not signature or not found", @signature_nsp.to_s )
     1610    else
     1611      if obj.has_descriptor? then
     1612       # cdl_error( "T9999 '$1': has Descriptor in function parameter", @signature_nsp.to_s )
     1613      end
     1614      # @signature_nsp = obj.get_namespace_path
    15971615    end
    15981616  end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/messages/messages_console_en_US.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/messages/messages_console_ja_JP.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/messages/messages_file_en_US.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    7676#  * このファイルを編集して使用することが意図されていますが
    7777#  * tecsgen の再実行により上書きされてしまうため、通常
    78 #  *   gen/%s_template.c => src/%s.c
     78#  *   gen/%s_templ.c => src/%s.c
    7979#  * のように名前, フォルダを変更してから修正します
    8080#  */
     
    8383 * This file was automatically generated by tecsgen.
    8484 * Move and rename like below before editing,
    85  *   gen/%s_template.c => src/%s.c
     85 *   gen/%s_templ.c => src/%s.c
    8686 * to avoid to be overwritten by tecsgen.
    8787 */
     
    335335@@comment[ :TEFB_comment ] = "\t/* Put statements here %s */\n"
    336336
     337# @@comment[ :MCPP_comment ] = "/* セル CB プロトタイプ宣言 %s */\n"
     338@@comment[ :MCPP_comment ] = "/* cell CB prototype declaration %s */\n"
     339
     340# @@comment[ :MCPB_comment ] = "/* セル CB プロトタイプ宣言 %s */\n"
     341@@comment[ :MCPB_comment ] = "/* cell CB prototype declaration %s */\n"
    337342end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/messages/messages_file_ja_JP.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    6565 * このファイルを編集して使用することが意図されていますが
    6666 * tecsgen の再実行により上書きされてしまうため、通常
    67  *   gen/%s_template.c => src/%s.c
     67 *   gen/%s_templ.c => src/%s.c
    6868 * のように名前, フォルダを変更してから修正します
    6969 */
     
    163163@@comment[ :TEPF_comment ] = "/* 受け口関数 %s */\n"
    164164@@comment[ :TEFB_comment ] = "\t/* ここに処理本体を記述します %s */\n"
     165@@comment[ :MCPP_comment ] = "/* CB プロトタイプ宣言 %s */\n"
     166@@comment[ :MCPB_comment ] = "/* CB プロトタイプ宣言 %s */\n"
    165167
    166168end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1AlarmPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1DelayTaskPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ISRPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1KernelPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1ResourcePlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ATK1TaskPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
    37 #   $Id
     37#   $Id$
    3838#++
    3939
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/DomainPlugin.rb

    r337 r374  
    4646  #option::String : domain 指定子の第二引数
    4747  def initialize( region, domain_type_name, option )
     48    super()
    4849  end
    4950
     
    7778    return false
    7879  end
     80
     81  #== ドメイン種別を返す
     82  #return::Symbol :kernel, :user, :OutOfDomain
     83  def get_kind
     84    :kernel
     85  end
     86
     87  #== factory 生成
     88  # DomainPlugin の factory は特定のファイルへの出力が想定されていない
     89  def gen_factory
     90  end
    7991end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Cache.rb

    r337 r374  
    11# -*- coding: utf-8 -*-
    22
     3#   $Id$
    34
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2CyclicHandlerPlugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2DataqueuePlugin.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2EventflagPlugin.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2FixedSizeMemoryPoolPlugin.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2HandlerPlugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    7777        elsif @plugin_arg_str == "ISR"
    7878            file.print <<EOT
    79 #{tab}ATT_ISR({ #{val[:attribute]}, &#{cell_CB_name}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} });
     79#{tab}ATT_ISR({ #{val[:attribute]}, #{cell_CBP}, #{val[:interruptNumber]}, tISR_start, #{val[:priority]} });
    8080EOT
    8181        elsif @plugin_arg_str == "INIT_ROUTINE"
    8282            file.print <<EOT
    83 #{tab}ATT_INI({ #{val[:attribute]}, &#{cell_CB_name}, tInitializeRoutine_start });
     83#{tab}ATT_INI({ #{val[:attribute]}, #{cell_CBP}, tInitializeRoutine_start });
    8484EOT
    8585        elsif @plugin_arg_str == "TERM_ROUTINE"
    8686            file.print <<EOT
    87 #{tab}ATT_TER({ #{val[:attribute]}, &#{cell_CB_name}, tTerminateRoutine_start });
     87#{tab}ATT_TER({ #{val[:attribute]}, #{cell_CBP}, tTerminateRoutine_start });
    8888EOT
    8989        else
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2KernelObjectPlugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2012 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    186186                val = {}
    187187                @celltype.get_attribute_list.each{ |a|
    188                     p a.get_name
     188                    # p a.get_name
    189189                    if a.get_type.kind_of?( ArrayType )
    190190                        val[a.get_name] = []
     
    218218                if val[:id].nil? != true
    219219                    puts val[:id]
    220                     val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
     220                    #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
     221                    val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) )
    221222                end
    222223                # $cbp$の代わり
     
    244245                        file2.puts "}\n"
    245246                    else
    246                         print "~~~~~ #{cell.get_region.get_name.to_s} is included in"
    247                         p @@region_list
     247                        dbgPrint "~~~~~ #{cell.get_region.get_name.to_s} is included in"
     248                        # p @@region_list
    248249                    end
    249250                    file3 = AppFile.open( "#{$gen}/tecsgen_#{cell_domain_root.get_name.to_s}.cfg" )
     
    260261                if !val[:accessPattern].nil?
    261262                    puts "===== begin check regions #{cell.get_name} ====="
    262                     p val[:accessPattern]
    263                     p val[:accessPattern].class
     263                    # p val[:accessPattern]
     264                    # p val[:accessPattern].class
    264265
    265266                    #ep = [ :eTaskActivate, :eTaskControl, :eTaskManage, :eTaskRefer ]
     
    273274                        if acptnx != "OMIT"
    274275                            acv << acptnx
    275                             p acv[i]
     276                            # p acv[i]
    276277                        elsif cell_domain_type.get_option.to_s == "trusted"
    277278                            acv << "TACP_KERNEL"
    278                             p acv[i]
     279                            # p acv[i]
    279280                        elsif cell_domain_type.get_option.to_s != "OutOfDomain"
    280281                            acv << "TACP(#{cell_domain_root.get_name.to_s})"
     
    286287                    }
    287288
    288                     print "acv = "
     289                    dbgPrint "acv = "
    289290                    p acv
    290291
     
    322323
    323324    def self.check_referenced_cells()
    324         puts "===== begin check registered celltype ====="
     325        dbgPrint "===== begin check registered celltype =====\n"
    325326        self.get_celltype_list.each { |ct|
    326             p ct.get_name.to_s
     327            dbgPrint( ct.get_name.to_s + "\n" )
    327328        }
    328         puts "===== end check registered celltype ====="
     329        dbgPrint "===== end check registered celltype =====\n"
    329330
    330331=begin
     
    334335                j = cell.get_join_list.get_item(p.get_name)
    335336                printf "===== check call port : "
    336                 p p.get_name.to_s
     337                # p p.get_name.to_s
    337338                next if j.nil? # 未結合の場合
    338339                if @@celltype_list.include?(j.get_celltype)
     
    341342                    j.get_cell.set_referenced_cell(cell, j.get_port_name)
    342343                    printf "===== check joined rhs cell : "
    343                     p j.get_cell.get_name.to_s
     344                    # p j.get_cell.get_name.to_s
    344345                    printf "===== check joined rhs port_name : "
    345                     p j.get_port_name
     346                    # p j.get_port_name
    346347                end
    347348            }
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2ObjectPlugin.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2Plugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2014 by TOPPERS Project
     6#   Copyright (C) 2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4444
    4545  def initialize( region, name, option )
     46    super
    4647    print "HRP2Plugin: initialize: region=#{region.get_name}, domainName=#{name}, option=#{option}\n"
     48    @region = region
     49    @name   = name
     50
     51    case option
     52    when "trusted", "nontrusted", "OutOfDomain"
     53      # OK
     54      @option = option
     55    else
     56      cdl_error( "HRPPlugin: '$1' is unacceptable domain kind, specify 'trusted' or 'nontrusted'", option )
     57      @option = "trusted"   # とりあえず trusted を設定しておく
     58    end
    4759  end
    4860
     
    108120  end
    109121
     122  #== ドメイン種別を返す
     123  #return::Symbol :kernel, :user, :OutOfDomain
     124  def get_kind
     125    case @option
     126    when "trusted"
     127      return :kernel
     128    when "nontrusted"
     129      return :user
     130    when "OutOfDomain"
     131      return :OutOfDomain
     132    end
     133  end
     134
    110135  def joinable?(current_region, next_region, through_type )
    111136    print "HRP2Plugin: joinable? from #{current_region.get_name} to #{next_region.get_name} (#{through_type})\n"
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PostHook.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2012 by TOPPERS Project
     6#   Copyright (C) 2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2PriorityDataqueuePlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2RPCPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    7071  #=== RPCPlugin の initialize
    7172  #  説明は ThroughPlugin (plugin.rb) を参照
    72   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     73  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    7374    super
    7475    @b_noClientSemaphore = false
     
    234235    if cell.get_allocator_list.length > 0 then
    235236
    236       dbgPrint "make allocator"
     237      dbgPrint "make allocator\n"
    237238      file.print "#{indent_str}[allocator("
    238239
     
    269270    nest = @end_region.gen_region_str_pre file
    270271    indent_str = "  " * nest
     272    nest_str = "  " * nest
     273    if @next_cell_port_subscript then
     274      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     275    else
     276      subscript = ""
     277    end
    271278
    272279    file.print <<EOT
    273280#{indent_str}cell #{@rpc_channel_celltype_name}Server #{@cell_name}Body {
    274 #{indent_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     281#{indent_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    275282//#{indent_str}    #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
    276283#{indent_str}  //cTDR         = #{@channelCellName}.eTDR;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SVCPlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
     
    8384  @@generated_celltype_header = {}
    8485
    85   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     86  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    8687    super
    8788    @ct_name_body = "#{@ct_name}SVCBody_#{@next_cell.get_name}_#{@next_cell_port_name}".to_sym
     
    217218    nest = @end_region.gen_region_str_pre file
    218219    nest_str = "  " * nest
     220    if @next_cell_port_subscript then
     221      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     222    else
     223      subscript = ""
     224    end
    219225
    220226    # サーバー側チャンネルの生成
     
    224230#{nest_str}  //  Server Side Channel
    225231#{nest_str}  cell #{@ct_name_body} #{@cell_name_body}{
    226 #{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     232#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    227233#{nest_str}  };
    228234EOT
     
    241247    nest = @start_region.gen_region_str_pre file
    242248    nest_str = "  " * nest
     249    if @next_cell_port_subscript then
     250      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     251    else
     252      subscript = ""
     253    end
    243254
    244255    # クライアント側チャンネルの生成
     
    247258#{nest_str}  //  Client Side Channel
    248259#{nest_str}  cell #{@ct_name} #{@cell_name}{
    249 #{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     260#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    250261#{nest_str}  };
    251262
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2SemaphorePlugin.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/HRP2TaskPlugin.rb

    r359 r374  
    5353    # tab  :
    5454    def print_cfg_cre(file, cell, val, tab)
    55         val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_name.to_s}" )
     55        #val[:id] = val[:id].gsub( /(^|[^\$])\$id\$/, "\\1#{@celltype.get_name.to_s}_#{cell.get_global_name.to_s}" )
     56        #val[:id] = @celltype.subst_name( val[:id], @celltype.get_name_array( cell ) )
    5657        # $cbp$の代わり
    5758        index = cell.get_id - @celltype.get_id_base
     
    5960        cell_CB_name = "#{index}"
    6061        # CRE_XXX/DEF_XXXの生成
    61         print "assign task plugin\n"
     62        dbgPrint "assign task plugin\n"
    6263        domainOption = cell.get_region.get_domain_root.get_domain_type.get_option
    6364        # if cell.get_region.get_region_type == :DOMAIN
     65# cell.show_tree 1
    6466        if domainOption != "OutOfDomain"
    6567            # 保護ドメインに属する場合
     
    6971                    raise "system task cannot have user stack."
    7072                end
     73p "CRE_TSK 0 user=#{val[:userStackSize]} system=#{val[:systemStackSize]}"
    7174                file.print <<EOT
    7275#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:systemStackSize]}, NULL });
     
    7780                    raise "user task must have user stack."
    7881                end
     82p "CRE_TSK 1"
    7983                if val[:systemStackSize] == "OMIT"
    8084                    file.print <<EOT
     
    8286EOT
    8387                else
     88p "CRE_TSK 2"
    8489                    file.print <<EOT
    8590#{tab}CRE_TSK(#{val[:id]}, { #{val[:taskAttribute]}, #{cell_CB_name}, tTask_start_task, #{val[:priority]}, #{val[:userStackSize]}, NULL, #{val[:systemStackSize]}, NULL });
     
    138143                    regions = ct.get_domain_roots
    139144                    regions_hrp2 = regions[ :HRP2 ]
    140                     print "HRP2 domain in #{ct.get_name}: "
     145                    dbgPrint "HRP2 domain in #{ct.get_name}: "
    141146                    regions_hrp2.each { |reg|
    142                         print reg.get_name
     147                        dbgPrint reg.get_name
    143148                    }
    144149                    puts ""
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/MrubyBridgePlugin.rb

    r359 r374  
    33#  mruby => TECS bridge
    44
    5 #   Copyright (C) 2008-2015 by TOPPERS Project
     5#   Copyright (C) 2008-2017 by TOPPERS Project
    66#
    77#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/MultiPlugin.rb

    r359 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2017 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/NotifierPlugin.rb

    r359 r374  
    11# -*- coding: utf-8 -*-
     2#
     3#  TECS Generator
     4#      Generator for TOPPERS Embedded Component System
    25#
    36#  Copyright (C) 2015 by Ushio Laboratory
     
    58#  Copyright (C) 2015-2016 by Embedded and Real-Time Systems Laboratory
    69#              Graduate School of Information Science, Nagoya Univ., JAPAN
     10#  Copyright (C) 2015-2018 by TOPPERS Project
    711#
     12#--
     13#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     14#   ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     15#   変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
     16#   (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
     17#       権表示,この利用条件および下記の無保証規定が,そのままの形でソー
     18#       スコード中に含まれていること.
     19#   (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
     20#       用できる形で再配布する場合には,再配布に伴うドキュメント(利用
     21#       者マニュアルなど)に,上記の著作権表示,この利用条件および下記
     22#       の無保証規定を掲載すること.
     23#   (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
     24#       用できない形で再配布する場合には,次のいずれかの条件を満たすこ
     25#       と.
     26#     (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
     27#         作権表示,この利用条件および下記の無保証規定を掲載すること.
     28#     (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
     29#         報告すること.
     30#   (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
     31#       害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
     32#       また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
     33#       由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
     34#       免責すること.
     35
     36#   本ソフトウェアは,無保証で提供されているものである.上記著作権者お
     37#   よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     38#   に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
     39#   アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
     40#   の責任を負わない.
     41
     42#  $Id$
     43#++
    844
    945NotifierPluginArgProc = {
     
    128164                        # @param [Cell, Symbol] cell セル.セルについて一般化する場合は `:generic`
    129165                        # @param [Integer, Symbol, nil] subscript 添字.添字について一般化する場合は `:generic`
     166                        # @param [Celltype] 呼び先のセルタイプ、cell==:generic の場合のみ有効
    130167                        # @private
    131                         def generate_inner(context, fn_name, cell, subscript)
     168                        def generate_inner(context, fn_name, cell, subscript, callee_ct=nil)
    132169                                source_file = context.source_file
    133170                                header_file = context.header_file
     
    141178                                unless ct.is_singleton?
    142179                                        if cell == :generic
    143                                                 params << "(CELLIDX)extinf"
     180                                                params << "(#{callee_ct.get_global_name}_IDX)extinf"
     181                                                # params << "(CELLIDX)extinf"
    144182                                        else
    145183                                                # セルのCELLIDXを得る
     
    233271
    234272                                                generate_inner context, fn_name,
    235                                                         :generic, subscript
     273                                                        :generic, subscript, ct
    236274
    237275                                                props.each { |prop|
     
    445483            # join:: Join : 結合 (declarationがPortであるもの)
    446484                def validate_join(handler, cell, join)
    447                 return !generate_attr_map(handler, cell).nil?
     485        return !generate_attr_map(handler, cell).nil?
    448486                end
    449487
     
    872910        parse_plugin_arg
    873911        unless @factory
    874                 cdl_error("ASP1003 celltype $1: option factory is not specified",
     912                cdl_error("NTF1003 celltype $1: option factory is not specified",
    875913                        celltype.get_name)
    876914        end
    877915        unless @output_file
    878                 cdl_error("ASP1003 celltype $1: option output_file is not specified",
     916                cdl_error("NTF1003 celltype $1: option output_file is not specified",
    879917                        celltype.get_name)
    880918        end
     
    883921    def set_factory(template_string)
    884922        unless @factory.nil?
    885                 cdl_error("ASP1003 celltype $1: option factory was specified more than once",
     923                cdl_error("NTF1003 celltype $1: option factory was specified more than once",
    886924                        celltype.get_name)
    887925        end
     
    891929    def set_factory_output_file(output_file)
    892930        unless @output_file.nil?
    893                 cdl_error("ASP1003 celltype $1: option output_file was specified more than once",
     931                cdl_error("NTF1003 celltype $1: option output_file was specified more than once",
    894932                        celltype.get_name)
    895933        end
     
    898936
    899937    def gen_factory file
    900         puts "===== begin #{@celltype.get_name.to_s} plugin ====="
     938        # puts "===== begin #{@celltype.get_name.to_s} plugin ====="
    901939
    902940        kernelCfg = AppFile.open( "#{$gen}/#{@output_file}" )
     
    922960                        subst_attr = @celltype.find(name)
    923961                        unless subst_attr
    924                         cdl_error( "ASP1007 celltype $1: additional_param: attribute $2 does not exist.",
     962                        cdl_error( "NTF1007 celltype $1: additional_param: attribute $2 does not exist.",
    925963                                @celltype.get_name, name)
    926964                        end
     
    935973
    936974        kernelCfg.close
    937         puts "===== end #{@celltype.get_name.to_s} plugin ====="
     975        # puts "===== end #{@celltype.get_name.to_s} plugin ====="
    938976    end
    939977
    940978    def gen_factory_for_cell(kernelCfg, cell)
     979      # print "########## gen_factory_for_cell cell=#{cell.get_name}\n"
    941980        handler_flags = []
    942981        handler_args = []
     
    959998                        when 'false' then ignoreErrors = false
    960999                        else
    961                                 cdl_warning( "ASP1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
     1000                                cdl_warning2( cell.get_locale, "NTF1005 cell $1: unrecognized value '$2' specified for ignoreErrors",
    9621001                                        cell.get_name, ignoreErrors )
    9631002                                ignoreErrors = false
    9641003                end
    9651004
     1005    # ドメイン指定用文字列
     1006    pre_text  = ""
     1007    post_text = "\n"
     1008    indent    = ""
     1009 
    9661010        [EVENT_HANDLER, ERROR_HANDLER].each { |handler|
    9671011                # 呼び口の結合を取得
    9681012                call_join = cell.get_join_list.get_item(handler.call_port_name.to_sym)
     1013        domain_root = cell.get_region.get_domain_root
     1014        if cell.get_region.get_domain_root.get_domain_type then
     1015          # print "cell=#{cell.get_name} domain_root=#{domain_root.get_name} domain_type=#{domain_root.get_domain_type.get_name} domain_option=#{domain_root.get_domain_type.get_option}\n"
     1016        else
     1017          # print "cell=#{cell.get_name} domain_root=#{cell.get_region.get_domain_root.get_name}\n"
     1018        end
     1019        if call_join
     1020          # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name} join=#{call_join.get_name} rhs_cell=#{call_join.get_cell}\n"
     1021        else
     1022          # print "validate_join: hanlder=#{handler.class.name} cell=#{cell.get_name}\n"
     1023        end
    9691024
    9701025                # ハンドラタイプを判別する
     
    9741029
    9751030                if matches.length == 0
    976                         cdl_error( "ASP1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
     1031                        cdl_error2( cell.get_locale, "NTF1001 cell $1: no matching handler type found for $2", cell.get_name, handler.call_port_name )
    9771032                        next
    978                 end
     1033        end
    9791034
    9801035                        # 最初に見つかった有効なハンドラタイプを使用
    9811036                ht = matches[0]
     1037
     1038      # ドメインプラグインが指定されている場合、所属ドメインのチェック
     1039      domain_root = cell.get_region.get_domain_root
     1040      if domain_root.get_domain_type then
     1041        if domain_root.get_domain_type.get_name == :HRP then
     1042          option = domain_root.get_domain_type.get_option
     1043          matches.each{ |match|
     1044            # p "match:#{match}"
     1045            case match
     1046            when ActivateTaskHandlerType,       WakeUpTaskHandlerType,
     1047                 SetVariableHandlerType,        SetVariableToErrorCodeHandlerType,
     1048                             IncrementVariableHandlerType,  SignalSemaphoreHandlerType,
     1049                             SetEventflagHandlerType,       SendToDataqueueHandlerType,
     1050                             SendErrorCodeToDataqueueHandlerType
     1051              if option == "OutOfDomain" then
     1052                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 cannot be placed out of domain", cell.get_name )
     1053              elsif call_join.get_cell.get_region.get_domain_root == nil ||
     1054                    call_join.get_cell.get_region.get_domain_root != domain_root then
     1055                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name )
     1056              end
     1057              dbgPrint "#{self.class.name}: match pattern 1.\n"
     1058            when UserHandlerType
     1059              if option != "kernel" then
     1060                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 can be placed in kernel domain only, because notify target is handler", cell.get_name )
     1061              elsif call_join.get_cell.get_region.get_domain_root == nil ||
     1062                    call_join.get_cell.get_region.get_domain_root != domain_root then
     1063                cdl_error2( cell.get_locale, "NTF9999: NotifierPlugin: $1 and $2 must be placed in same domain", cell.get_name, call_join.get_cell.get_name )
     1064              end
     1065              dbgPrint "#{self.class.name}: match pattern 2.\n"
     1066                        when NullHandlerType.new  # エラー通知を指定していない
     1067              dbgPrint "#{self.class.name}: match pattern 3.\n"
     1068            end
     1069          }
     1070
     1071          # if cell.get_region.get_param == :KERNEL_DOMAIN
     1072          if option == "kernel"
     1073            pre_text  = "KERNEL_DOMAIN{\n"
     1074            post_text = "}\n"
     1075            indent    =  "\t"
     1076          elsif option != "OutOfDomain" then
     1077            pre_text  = "DOMAIN(#{domain_root.get_name.to_s}){\n"
     1078            post_text = "}\n"
     1079            indent    =  "\t"
     1080          end
     1081        else
     1082          cdl_error( "NTF9999: NotifierPlugin: unknown domain type $1", domain_root.get_domain_type.get_name )
     1083        end
     1084
     1085      end
    9821086
    9831087                        # 通知ハンドラで「エラーが発生するはずがない」のに「エラーハンドラが指定されている」
     
    9861090                        #  なため、検出は行わない。)
    9871091                if handler == ERROR_HANDLER && !ht.is_a?(NullHandlerType) && !event_handler_might_fail
    988                         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.",
     1092                        cdl_error2( cell.get_locale, "NTF1004 cell $1: handler type $2 which never raises an error was inferred for the normal notification handler, but an error notification handler was specified.",
    9891093                                cell.get_name, handler_flag)
    9901094                end
    9911095                if handler == ERROR_HANDLER && ht.is_a?(NullHandlerType) && event_handler_might_fail && !ignoreErrors
    992                         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.",
     1096                        cdl_warning2( cell.get_locale, "NTF1006 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.",
    9931097                                cell.get_name, handler_flag)
    9941098                end
     
    10571161                        # $id$等の置換
    10581162                        cell.get_celltype.subst_name(subst, name_array)
    1059         }
    1060 
    1061         # 出力
    1062         kernelCfg.puts text
    1063 
    1064     end
    1065     private :gen_factory_for_cell
     1163      }
     1164
     1165     # 出力 (CRE_xxx)
     1166     kernelCfg.print pre_text
     1167     kernelCfg.print indent, text, "\n"
     1168     gen_sac kernelCfg, cell, indent
     1169     kernelCfg.print post_text
     1170   end
     1171
     1172   def gen_sac file, cell, indent
     1173     domain_root = cell.get_region.get_domain_root
     1174     if domain_root.get_domain_type then
     1175       id = (cell.get_attr_initializer :id).to_s
     1176                 name_array = cell.get_celltype.get_name_array(cell)
     1177       case cell.get_celltype.get_name
     1178       when :tCyclicNotifier
     1179         obj_type = "CYC"
     1180       when :tAlarmNotifier
     1181         obj_type = "ALM"
     1182       else
     1183         raise "NotifierPlugin: unknown celltype #{cell.get_celltype.get_name}"
     1184       end
     1185       id = cell.get_celltype.subst_name(id, name_array)
     1186       # p obj_type
     1187       # p HRPPlugin.get_sac_str cell
     1188       file.print indent, "SAC_#{obj_type}( #{id}, #{HRPPlugin.get_sac_str cell} );\n"
     1189     end
     1190   end
     1191   private :gen_factory_for_cell
    10661192
    10671193end
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/OpaqueRPCPlugin.rb

    r337 r374  
    5656  #=== RPCPlugin の initialize
    5757  #  説明は ThroughPlugin (plugin.rb) を参照
    58   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     58  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    5959    super
    6060    @b_noClientSemaphore = false
     
    254254    nest = @end_region.gen_region_str_pre file
    255255    nest_str = "  " * nest
     256    if @next_cell_port_subscript then
     257      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     258    else
     259      subscript = ""
     260    end
    256261
    257262    if @serverErrorHandler then
     
    282287#{nest_str}  cell #{@rpc_server_channel_celltype_name} #{@serverChannelCell}_Unmarshaler {
    283288#{nest_str}    cChannel = #{@serverChannelCell}.eC1;
    284 #{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     289#{nest_str}    #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    285290#{serverErrorHandler_str}#{nest_str}  };
    286291EOT
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/RPCPlugin.rb

    r337 r374  
    6565  #=== RPCPlugin の initialize
    6666  #  説明は ThroughPlugin (plugin.rb) を参照
    67   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     67  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    6868    super
    6969    @b_noClientSemaphore = false
     
    197197    nest = @region.gen_region_str_pre file
    198198    indent_str = "  " * nest
     199    if @next_cell_port_subscript then
     200      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     201    else
     202      subscript = ""
     203    end
    199204
    200205    file.print <<EOT
     
    233238    file.print <<EOT
    234239#{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
    235 #{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
     240#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript};
    236241#{indent_str}  cTDR         = #{@channelCellName}.eTDR;
    237242#{indent_str}  cEventflag   = #{@channelCellName}.eEventflag;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedOpaqueRPCPlugin.rb

    r337 r374  
    6868  #=== RPCPlugin の initialize
    6969  #  説明は ThroughPlugin (plugin.rb) を参照
    70   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     70  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    7171    super
    7272    initialize_opaque_marshaler
     
    221221    nest = @start_region.gen_region_str_pre file
    222222    indent_str = "  " * nest
     223    nest_str = "  " * nest
     224    if @next_cell_port_subscript then
     225      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     226    else
     227      subscript = ""
     228    end
    223229
    224230    # セルを探す
     
    303309#{indent_str}cell #{@unmarshaler_celltype_name} #{@cell_name}_Server {
    304310#{indent_str}  cTDR         = #{@shared_channel_cell}_Server.eTDR;
    305 #{indent_str}  cServerCall  = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     311#{indent_str}  cServerCall  = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    306312#{ppallocator_join}#{indent_str}};
    307313EOT
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/SharedRPCPlugin.rb

    r337 r374  
    6262  #=== RPCPlugin の initialize
    6363  #  説明は ThroughPlugin (plugin.rb) を参照
    64   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     64  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    6565
    6666    # mikan プラグインオプション指定の不一致のチェック task_priority,
     
    236236    nest = @region.gen_region_str_pre file
    237237    indent_str = "  " * nest
     238    if @next_cell_port_subscript then
     239      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     240    else
     241      subscript = ""
     242    end
    238243
    239244    # セルを探す
     
    291296    file.print <<EOT
    292297#{indent_str}cell #{@rpc_channel_celltype_name} #{@cell_name} {
    293 #{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name};
     298#{indent_str}  #{@call_port_name} = #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript};
    294299#{indent_str}  cTDR         = #{@shared_channel_cell}.eTDR;
    295300#{indent_str}  cEventflag   = #{@shared_channel_cell}.eEventflag;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/ThroughPlugin.rb

    r337 r374  
    4747#@next_cell:: Cell                    呼び口を結合するセル
    4848#@next_cell_port_name:: Symbol       呼び口を結合する受口の名前
     49#@next_cell_port_subscript::Nil|Integer   呼び口を結合する受口の配列添数.受け口配列でない場合 nil
    4950#@signature::      Signature          シグニチャ
    5051#@celltype::       Celltype           呼び先のセルのセルタイプ. through が連接する場合、最終的な呼び先のセルのセルタイプ
     
    7475  #next_cell::      Cell               呼び口を接続するセル
    7576  #next_cell_port_name:: Symbol        呼び口を接続する受口の名前
     77  #next_cell_port_subscript:: Nil|Integer  呼び口を接続する受口配列添数
    7678  #signature::      Signature          シグニチャ
    7779  #celltype::       Celltype           セルタイプ (呼び先のセルのセルタイプ)
    7880  #caller_cell::    Cell               呼び元のセル.@caller_cell の項を参照
    79   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     81  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    8082    super()
    8183    @cell_name = cell_name                      # 生成すべきセル名(受け口側のセル名)
     
    8385    @next_cell = next_cell                      # 呼び先のセル
    8486    @next_cell_port_name = next_cell_port_name
     87    @next_cell_port_subscript = next_cell_port_subscript
    8588    @signature = signature
    8689    @entry_port_name = :"eThroughEntry"
     
    136139  def get_through_entry_port_name
    137140    @entry_port_name
     141  end
     142
     143  #===  生成されたセルの受け口配列添数を得る
     144  def get_through_entry_port_subscript
     145    @entry_port_subscript
    138146  end
    139147
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/TracePlugin.rb

    r337 r374  
    4444  #=== TracePlugin の initialize
    4545  #  説明は ThroughPlugin (plugin.rb) を参照
    46   def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, signature, celltype, caller_cell )
     46  def initialize( cell_name, plugin_arg, next_cell, next_cell_port_name, next_cell_port_subscript, signature, celltype, caller_cell )
    4747
    4848    @maxArrayDisplay = 16
     
    141141      nest = @region.gen_region_str_pre file
    142142      indent_str =  "  " * nest
     143      if @next_cell_port_subscript then
     144        subscript = '[' + @next_cell_port_subscript.to_s + ']'
     145      else
     146        subscript = ""
     147      end
    143148
    144149      if @probeName then
     
    155160      file.print <<EOT
    156161#{indent_str}cell #{@ct_name} #{@cell_name} {
    157 #{indent_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name};
     162#{indent_str}  #{@call_port_name} = #{@next_cell.get_namespace_path.get_path_str}.#{@next_cell_port_name}#{subscript};
    158163#{probeName_str}#{caller_cell_str}#{indent_str}};
    159164EOT
     
    210215    }
    211216    file.print( " );\n" )
     217    if @next_cell_port_subscript then
     218      subscript = '[' + @next_cell_port_subscript.to_s + ']'
     219    else
     220      subscript = ""
     221    end
    212222
    213223    file.print <<EOT
    214224\tgetMicroTime( &utime );
    215 \tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}.#{func_name}\", ATTR_probeName_str, utime );
     225\tsyslog( LOG_INFO, \"Leave: %sTime=%d: #{@next_cell.get_name}.#{@next_cell_port_name}#{subscript}.#{func_name}\", ATTR_probeName_str, utime );
    216226EOT
    217227
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenHRP2Marshaler.rb

    r337 r374  
    3535#   の責任を負わない.
    3636
     37#   $Id$
    3738#++
    3839
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenOpaqueMarshaler.rb

    r337 r374  
    44#      Generator for TOPPERS Embedded Component System
    55
    6 #   Copyright (C) 2008-2014 by TOPPERS Project
     6#   Copyright (C) 2008-2018 by TOPPERS Project
    77#--
    88#   上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    464464        /* Channel Lock */
    465465        SET_RPC_STATE( state_, RPCSTATE_CLIENT_GET_SEM );
    466         if( is_cLockChannel_joined() )
    467                 cLockChannel_wait();
     466        if( is_cLockChannel_joined() ){
     467                if( (ercd_=cLockChannel_wait()) != E_OK )
     468                        goto error_reset;
     469        }
    468470EOT
    469471
     
    554556        /* Channel Unlock */
    555557        SET_RPC_STATE( state_, RPCSTATE_CLIENT_RELEASE_SEM );
    556         if( is_cLockChannel_joined() )
    557                 cLockChannel_signal();
     558        if( is_cLockChannel_joined() ){
     559                if( (ercd_=cLockChannel_signal()) != E_OK )
     560                        goto error_reset;
     561        }
     562EOT
     563
     564    file.print <<EOT
     565        /* state_ is not used in normal case */
     566  /* below is to avoid 'set but not used' warnning */
     567        (void)state_;
    558568EOT
    559569
     
    630640        file.print <<EOT
    631641        }else{
    632                 return;
     642                return E_ID;
    633643        }
    634644EOT
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/plugin/lib/GenTransparentMarshaler.rb

    r337 r374  
    388388    };
    389389#{ppallocator_dealloc_str}
    390     return;
     390    return E_OK;
    391391
    392392error_reset:
     
    394394        (void)cTDR_reset();
    395395#{ppallocator_dealloc_str}
     396    return E_OK;
    396397EOT
    397398
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/version.rb

    r337 r374  
    11$package = "tecsgen"
    2 $version = "1.5.0"
     2$version = "1.6.4"
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netdev/if_btusb/Makefile.tinet

    r337 r374  
    4242INCLUDES        := $(INCLUDES) -I$(TINET_ROOT)/netdev/$(NET_DEV)
    4343TINET_DIRS      := $(TINET_DIRS):$(TINET_ROOT)/netdev/$(NET_DEV)
    44 TINET_COBJS     := $(TINET_COBJS) nap_main.o panu_main.o if_btusb.o
     44TINET_COBJS     := $(TINET_COBJS) bt_main.o if_btusb.o
    4545TINET_KERNEL_CFG := $(TINET_KERNEL_CFG) $(TINET_ROOT)/netdev/$(NET_DEV)/if_btusb.cfg
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netdev/if_btusb/bt_main.c

    r373 r374  
    5858#include "sdp.h"
    5959#include "pan.h"
    60 #include "panu_main.h"
     60#include "bt_main.h"
     61#include "usb_hbth.h"
    6162
    6263//#define PACKET_DUMP
     
    6667
    6768#define RFCOMM_SERVER_CHANNEL 1
    68 /*static*/ uint16_t  rfcomm_channel_id = FAILED_RFCOMM_ID_NOT_SET;
     69static uint16_t  rfcomm_channel_id = FAILED_RFCOMM_ID_NOT_SET;
    6970
    7071static int record_id = -1;
     
    9091
    9192volatile int bt_bnep_mode = 0;
    92 bool_t bt_enabled = false;
     93
     94enum bt_state_t {
     95        BT_STATE_DORMANT,
     96        BT_STATE_POWER_ON,
     97        BT_STATE_BNEP_QUERY,
     98        BT_STATE_BNEP_WAIT,
     99        BT_STATE_BNEP_QUERY_WAIT,
     100        BT_STATE_CONNECTING,
     101        BT_STATE_CONNECTED,
     102};
     103
     104enum bt_state_t bt_state = BT_STATE_DORMANT;
     105int bt_timer;
    93106
    94107// outgoing network packet
     
    108121                break;
    109122        case DE_SIZE_VAR_16:
    110                 len = READ_NET_16(element, 1);
     123                len = big_endian_read_16(element, 1);
    111124                break;
    112125        default:
     
    129142
    130143        // accept first entry or if we foudn a NAP and only have a PANU yet
    131         if ((bnep_remote_uuid == 0) || (sdp_bnep_remote_uuid == BNEP_UUID_NAP && bnep_remote_uuid == BNEP_UUID_PANU)) {
     144        if ((bnep_remote_uuid == 0) || (sdp_bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_NAP && bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_PANU)) {
    132145                bnep_l2cap_psm = sdp_bnep_l2cap_psm;
    133146                bnep_remote_uuid = sdp_bnep_remote_uuid;
     
    146159
    147160        switch (event->type) {
    148         case SDP_QUERY_ATTRIBUTE_VALUE:
     161        case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
    149162                value_event = (sdp_query_attribute_value_event_t*)event;
    150163
     
    165178
    166179                                switch (value_event->attribute_id) {
    167                                 case SDP_ServiceClassIDList:
     180                                case BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST:
    168181                                        if (de_get_element_type(attribute_value) != DE_DES) break;
    169182                                        for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) {
     
    172185                                                uint32_t uuid = de_get_uuid32(element);
    173186                                                switch (uuid) {
    174                                                 case BNEP_UUID_PANU:
    175                                                 case BNEP_UUID_NAP:
    176                                                 case BNEP_UUID_GN:
     187                                                case BLUETOOTH_SERVICE_CLASS_PANU:
     188                                                case BLUETOOTH_SERVICE_CLASS_NAP:
     189                                                case BLUETOOTH_SERVICE_CLASS_GN:
    177190                                                        log_info("SDP Attribute 0x%04x: BNEP PAN protocol UUID: %04x", value_event->attribute_id, uuid);
    178191                                                        sdp_bnep_remote_uuid = uuid;
     
    192205                                        free(str);
    193206                                        break;
    194                                 case SDP_ProtocolDescriptorList: {
     207                                case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: {
    195208                                        log_info("SDP Attribute: 0x%04x", value_event->attribute_id);
    196209
     
    210223                                                uuid = de_get_uuid32(element);
    211224                                                switch (uuid) {
    212                                                 case SDP_L2CAPProtocol:
     225                                                case BLUETOOTH_PROTOCOL_L2CAP:
    213226                                                        if (!des_iterator_has_more(&prot_it)) continue;
    214227                                                        des_iterator_next(&prot_it);
    215228                                                        de_element_get_uint16(des_iterator_get_element(&prot_it), &sdp_bnep_l2cap_psm);
    216229                                                        break;
    217                                                 case SDP_BNEPProtocol:
     230                                                case BLUETOOTH_PROTOCOL_BNEP:
    218231                                                        if (!des_iterator_has_more(&prot_it)) continue;
    219232                                                        des_iterator_next(&prot_it);
     
    238251                break;
    239252
    240         case SDP_QUERY_COMPLETE:
     253        case SDP_EVENT_QUERY_COMPLETE:
    241254                handle_sdp_client_record_complete();
    242255                complete_event = (sdp_query_complete_event_t*)event;
     
    246259                }
    247260                else {
     261                        bnep_do_connect = false;
    248262                        log_error("No BNEP service found");
     263                }
     264                if (!bnep_do_connect) {
     265                        // 20秒後 BNEP Query 開始
     266                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     267                        bt_timer = 20 * 1000;
    249268                }
    250269                break;
     
    269288                        if (packet[2] == HCI_STATE_WORKING) {
    270289                                hci_send_cmd(&hci_write_local_name, bt_localname);
    271                                 /* Send a general query for BNEP Protocol ID */
    272                                 log_info("Start SDP BNEP query.");
    273                                 sdp_general_query_for_uuid(remote_addr, SDP_BNEPProtocol);
     290                                if (bt_bnep_mode == 0) {
     291                                        // 即時 BNEP Query 開始
     292                                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     293                                        bt_timer = 0;
     294                                }
     295                                else {
     296                                        bt_state = BT_STATE_BNEP_WAIT;
     297                                        bt_timer = -1;
     298                                }
    274299                        }
    275300                        break;
     
    284309
    285310                case HCI_EVENT_COMMAND_COMPLETE:
    286                         if (COMMAND_COMPLETE_EVENT(packet, hci_read_bd_addr)) {
    287                                 bt_flip_addr(event_addr, &packet[6]);
     311                        if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_bd_addr)) {
     312                                reverse_bd_addr(&packet[6], event_addr);
    288313                                log_info("BD-ADDR: %s", bd_addr_to_str(event_addr));
    289314
     
    292317                                break;
    293318                        }
    294                         if (COMMAND_COMPLETE_EVENT(packet, hci_write_local_name)) {
    295                                 hci_discoverable_control(1);
     319                        if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_local_name)) {
     320                                gap_discoverable_control(1);
    296321                                break;
    297322                        }
     
    301326                        // deny link key request
    302327                        log_info("Link key request");
    303                         bt_flip_addr(event_addr, &packet[2]);
     328                        reverse_bd_addr(&packet[2], event_addr);
    304329                        hci_send_cmd(&hci_link_key_request_negative_reply, &event_addr);
    305330                        break;
     
    308333                        // inform about pin code request
    309334                        log_info("Pin code request - using '0000'");
    310                         bt_flip_addr(event_addr, &packet[2]);
     335                        reverse_bd_addr(&packet[2], event_addr);
    311336                        hci_send_cmd(&hci_pin_code_request_reply, &event_addr, 4, "0000");
    312337                        break;
     
    314339                case HCI_EVENT_USER_CONFIRMATION_REQUEST:
    315340                        // inform about user confirmation request
    316                         log_info("HCI User Confirmation Request with numeric value '%06u'", READ_BT_32(packet, 8));
     341                        log_info("HCI User Confirmation Request with numeric value '%06u'", little_endian_read_32(packet, 8));
    317342                        log_info("HCI User Confirmation Auto accept");
    318343                        break;
     
    320345                case RFCOMM_EVENT_INCOMING_CONNECTION:
    321346                        // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
    322                         bt_flip_addr(event_addr, &packet[2]);
     347                        reverse_bd_addr(&packet[2], event_addr);
    323348                        rfcomm_channel_nr = packet[8];
    324                         rfcomm_channel_id = READ_BT_16(packet, 9);
     349                        rfcomm_channel_id = little_endian_read_16(packet, 9);
    325350                        log_info("RFCOMM channel %u requested for %s", rfcomm_channel_nr, bd_addr_to_str(event_addr));
    326351                        rfcomm_accept_connection_internal(rfcomm_channel_id);
     
    333358                        }
    334359                        else {
    335                                 rfcomm_channel_id = READ_BT_16(packet, 12);
    336                                 mtu = READ_BT_16(packet, 14);
     360                                rfcomm_channel_id = little_endian_read_16(packet, 12);
     361                                mtu = little_endian_read_16(packet, 14);
    337362                                log_info("RFCOMM channel open succeeded. New RFCOMM Channel ID %u, max frame size %u", rfcomm_channel_id, mtu);
    338363                        }
     
    347372                        if (packet[2]) {
    348373                                log_info("BNEP channel open failed, status %02x", packet[2]);
     374
     375                                // 30秒後 BNEP Query 開始
     376                                bt_state = BT_STATE_BNEP_QUERY_WAIT;
     377                                bt_timer = 30 * 1000;
    349378                        }
    350379                        else {
    351380                                // data: event(8), len(8), status (8), bnep source uuid (16), bnep destination uuid (16), remote_address (48)
    352                                 bnep_cid = READ_BT_16(packet, 3);
    353                                 uuid_source = READ_BT_16(packet, 5);
    354                                 uuid_dest = READ_BT_16(packet, 7);
    355                                 mtu = READ_BT_16(packet, 9);
    356                                 //bt_flip_addr(remote_addr, &packet[11]);
     381                                bnep_cid = little_endian_read_16(packet, 3);
     382                                uuid_source = little_endian_read_16(packet, 5);
     383                                uuid_dest = little_endian_read_16(packet, 7);
     384                                mtu = little_endian_read_16(packet, 9);
     385                                //reverse_bd_addr(&packet[11], remote_addr);
    357386                                memcpy(&remote_addr, &packet[11], sizeof(bd_addr_t));
    358387                                log_info("BNEP connection open succeeded to %s source UUID 0x%04x dest UUID: 0x%04x, max frame size %u", bd_addr_to_str(event_addr), uuid_source, uuid_dest, mtu);
     
    360389                                btstack_network_up(bnep_cid, (uint8_t *)hci_local_bd_addr(), (uint8_t *)remote_addr);
    361390                                log_info("Network Interface %s activated", btstack_network_get_name(bnep_cid));
     391
     392                                bt_state = BT_STATE_CONNECTED;
     393                                bt_timer = -1;
    362394                        }
    363395                        break;
     
    368400
    369401                case BNEP_EVENT_CHANNEL_CLOSED:
    370                         bnep_cid = READ_BT_16(packet, 2);
     402                        bnep_cid = little_endian_read_16(packet, 2);
    371403                        bt_channel_closed(bnep_cid);
     404
     405                        // 30秒後 BNEP Query 開始
     406                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     407                        bt_timer = 30 * 1000;
    372408                        break;
    373409
    374410                case BNEP_EVENT_READY_TO_SEND:
    375                         bnep_cid = READ_BT_16(packet, 2);
     411                        bnep_cid = little_endian_read_16(packet, 2);
    376412                        bt_send_packet(bnep_cid);
    377413                        break;
     
    428464}
    429465
    430 void panu_init(void)
     466void bt_init(void)
    431467{
    432468        const hci_transport_t *transport;
     
    437473        service_record_item_t *bnep_service_record_item;
    438474
     475        btstack_network_init(&network_send_packet_callback);
     476
    439477        //hci_dump_open("", HCI_DUMP_PACKETLOGGER);
    440 
    441         log_info("bt初期化...");
    442478
    443479        // start with BTstack init - especially configure HCI Transport
     
    446482
    447483        /* Initialize HCI */
    448         log_info("HCI初期化...");
    449484        transport = hci_transport_usb_instance();
    450485        control = NULL;
     
    455490
    456491        /* Initialize L2CAP */
    457         log_info("L2CAP初期化...");
    458492        l2cap_init();
    459493        l2cap_register_packet_handler(packet_handler);
    460494
    461495        /* Initialise SDP, create record for SPP and register with SDP */
    462         log_info("SDP初期化...");
    463496        sdp_init();
    464497
    465498        /* Initialize RFCOMM */
    466         log_info("RFCOMM初期化...");
    467499        rfcomm_init();
    468500        rfcomm_register_packet_handler(packet_handler);
     
    470502
    471503        /* Initialise BNEP */
    472         log_info("BNEP初期化...");
    473504        bnep_init();
    474505        bnep_register_packet_handler(packet_handler);
    475         bnep_register_service(NULL, BNEP_UUID_PANU, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     506        if (bt_bnep_mode == 0) {
     507                bnep_register_service(NULL, BLUETOOTH_SERVICE_CLASS_PANU, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     508        }
     509        else {
     510                bnep_register_service(NULL, BLUETOOTH_SERVICE_CLASS_NAP, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     511        }
    476512
    477513        memset(spp_service_buffer, 0, sizeof(spp_service_buffer));
     
    482518        bnep_service_record_item = (service_record_item_t *)bnep_service_buffer;
    483519
    484         log_info("SPPサービス登録...");
    485520        sdp_create_spp_service((uint8_t*)&spp_service_record_item->service_record, 1, "RX SPP");
    486521        de_dump_data_element((uint8_t*)spp_service_record_item->service_record);
     
    488523        sdp_register_service_internal(NULL, spp_service_record_item);
    489524
    490         log_info("BNEPサービス登録...");
    491         pan_create_panu_service((uint8_t*)&bnep_service_record_item->service_record, "RX PANU", "RX PANU", BNEP_SECURITY_NONE);
    492         de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
    493         log_info("PANU SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     525        if (bt_bnep_mode == 0) {
     526                pan_create_panu_service((uint8_t*)&bnep_service_record_item->service_record, "RX PANU", "RX PANU", BNEP_SECURITY_NONE);
     527                de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
     528                log_info("PANU SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     529        }
     530        else {
     531                pan_create_nap_service((uint8_t*)&bnep_service_record_item->service_record, "RX NAP", "RX NAP", BNEP_SECURITY_NONE,
     532                        PAN_NET_ACCESS_TYPE_100MB_ETHERNET, 0x0001312D0/*10Mb/sec*/, NULL, NULL);
     533                de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
     534                log_info("NAP SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     535        }
    494536        sdp_register_service_internal(NULL, bnep_service_record_item);
    495537
     
    500542
    501543        /* Turn on the device */
    502         log_info("HCI電源ON...");
    503544        hci_power_control(HCI_POWER_ON);
    504545
     
    506547        sdp_parser_init();
    507548        sdp_parser_register_callback(handle_sdp_client_query_result);
    508 }
    509 
    510 void nap_init(void);
    511 
    512 void bt_init(void)
    513 {
    514         btstack_network_init(&network_send_packet_callback);
    515 
    516         if (bt_bnep_mode == 0) {
    517                 panu_init();
    518         }
    519         else {
    520                 nap_init();
    521         }
    522 
    523         bt_enabled = true;
    524 }
    525 
    526 void bt_task(void)
    527 {
    528         extern void hal_tick_handler();
    529 
    530         if (bt_enabled) {
    531                 hal_tick_handler();
     549
     550        bt_state = BT_STATE_POWER_ON;
     551        bt_timer = -1;
     552}
     553
     554void bt_process(void)
     555{
     556        if (bt_state != BT_STATE_DORMANT) {
    532557                run_loop_execute();
    533558                bt_send_packet(0xffff);
     559        }
     560
     561        if (bt_timer != 0)
     562                return;
     563
     564        switch (bt_state) {
     565        case BT_STATE_BNEP_QUERY_WAIT:
     566                /* Send a general query for BNEP Protocol ID */
     567                log_info("Start SDP BNEP query.");
     568                sdp_general_query_for_uuid(remote_addr, BLUETOOTH_PROTOCOL_BNEP);
     569
     570                bt_state = BT_STATE_BNEP_QUERY;
     571                bt_timer = -1;
     572                break;
     573        default:
     574                bt_timer = -1;
     575                break;
    534576        }
    535577}
     
    592634        hci_close();
    593635
    594         bt_enabled = false;
    595 }
     636        bt_state = BT_STATE_DORMANT;
     637        bt_timer = -1;
     638}
     639
     640void bt_task_on_start(struct task_if_t *task, ID tskid)
     641{
     642}
     643
     644void bt_task_on_end(struct task_if_t *task)
     645{
     646}
     647
     648int bt_task_get_timer(struct task_if_t *task)
     649{
     650        return bt_timer;
     651}
     652
     653void bt_task_progress(struct task_if_t *task, int elapse)
     654{
     655        if (bt_timer == -1)
     656                return;
     657
     658        bt_timer -= elapse;
     659        if (bt_timer < 0)
     660                bt_timer = 0;
     661}
     662
     663void bt_task_process(struct task_if_t *task, enum task_event_t event)
     664{
     665        extern void hal_tick_handler();
     666
     667        switch (event & ~TASK_EVENT_TICK) {
     668        case TASK_EVENT_START:
     669                bt_init();
     670                break;
     671        case TASK_EVENT_TERMINATE:
     672                bt_terminate();
     673                break;
     674        case TASK_EVENT_WAKEUP:
     675        case TASK_EVENT_TIMEOUT:
     676                if (event & TASK_EVENT_TICK)
     677                        hal_tick_handler();
     678                bt_process();
     679                break;
     680        }
     681}
     682
     683struct task_if_t bt_task = {
     684        bt_task_on_start,
     685        bt_task_on_end,
     686        bt_task_get_timer,
     687        bt_task_progress,
     688        bt_task_process,
     689};
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netdev/if_btusb/bt_main.h

    r373 r374  
    11/*
    2  * panu_main.h
     2 * bt_main.h
    33 *
    44 */
     
    1616
    1717void bt_init(void);
    18 void bt_task(void);
    1918int bt_can_send_packet(void);
    2019void bt_send_packet(uint16_t bnep_cid);
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netdev/if_btusb/if_btusb.c

    r364 r374  
    7979#include "kernel/kernel_impl.h"
    8080#include "btstack/utils.h"
    81 #include "panu_main.h"
     81#include "bt_main.h"
    8282#include "usb_hbth.h"
    8383//#include "hal_cpu.h"
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/Debug/Makefile

    r365 r374  
    155155
    156156#
     157#  mbedサービスの定義
     158#
     159
     160include $(SRCDIR)/mbed/Makefile.mbed
     161
     162#
    157163#  共通コンパイルオプションの定義
    158164#
     
    180186
    181187APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    182 APPL_COBJS := $(APPL_COBJS) ntshell_main.o mbed_api.o fdtable.o io_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
     188APPL_COBJS := $(APPL_COBJS) ntshell_main.o fdtable.o io_stub.o ffarch.o diskio.o ff.o mmc_rspi.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o
    183189
    184190#
     
    194200ifdef USE_CXX
    195201        APPL_CXXOBJS := main.o
    196         APPL_COBJS := $(APPL_COBJS) ether_phy.o if_btusb.o if_rx62n.o nap_main.o panu_main.o
    197 else
    198         APPL_COBJS := $(APPL_COBJS) main.o ether_phy.o if_btusb.o if_rx62n.o nap_main.o panu_main.o
     202        APPL_COBJS := $(APPL_COBJS) ether_phy.o if_btusb.o if_rx62n.o bt_main.o
     203else
     204        APPL_COBJS := $(APPL_COBJS) main.o ether_phy.o if_btusb.o if_rx62n.o bt_main.o
    199205endif
    200206APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/bt_main.c

    r373 r374  
    5858#include "sdp.h"
    5959#include "pan.h"
    60 #include "panu_main.h"
     60#include "bt_main.h"
     61#include "usb_hbth.h"
    6162
    6263//#define PACKET_DUMP
     
    6667
    6768#define RFCOMM_SERVER_CHANNEL 1
    68 /*static*/ uint16_t  rfcomm_channel_id = FAILED_RFCOMM_ID_NOT_SET;
     69static uint16_t  rfcomm_channel_id = FAILED_RFCOMM_ID_NOT_SET;
    6970
    7071static int record_id = -1;
     
    9091
    9192volatile int bt_bnep_mode = 0;
    92 bool_t bt_enabled = false;
     93
     94enum bt_state_t {
     95        BT_STATE_DORMANT,
     96        BT_STATE_POWER_ON,
     97        BT_STATE_BNEP_QUERY,
     98        BT_STATE_BNEP_WAIT,
     99        BT_STATE_BNEP_QUERY_WAIT,
     100        BT_STATE_CONNECTING,
     101        BT_STATE_CONNECTED,
     102};
     103
     104enum bt_state_t bt_state = BT_STATE_DORMANT;
     105int bt_timer;
    93106
    94107// outgoing network packet
     
    108121                break;
    109122        case DE_SIZE_VAR_16:
    110                 len = READ_NET_16(element, 1);
     123                len = big_endian_read_16(element, 1);
    111124                break;
    112125        default:
     
    129142
    130143        // accept first entry or if we foudn a NAP and only have a PANU yet
    131         if ((bnep_remote_uuid == 0) || (sdp_bnep_remote_uuid == BNEP_UUID_NAP && bnep_remote_uuid == BNEP_UUID_PANU)) {
     144        if ((bnep_remote_uuid == 0) || (sdp_bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_NAP && bnep_remote_uuid == BLUETOOTH_SERVICE_CLASS_PANU)) {
    132145                bnep_l2cap_psm = sdp_bnep_l2cap_psm;
    133146                bnep_remote_uuid = sdp_bnep_remote_uuid;
     
    146159
    147160        switch (event->type) {
    148         case SDP_QUERY_ATTRIBUTE_VALUE:
     161        case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
    149162                value_event = (sdp_query_attribute_value_event_t*)event;
    150163
     
    165178
    166179                                switch (value_event->attribute_id) {
    167                                 case SDP_ServiceClassIDList:
     180                                case BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST:
    168181                                        if (de_get_element_type(attribute_value) != DE_DES) break;
    169182                                        for (des_iterator_init(&des_list_it, attribute_value); des_iterator_has_more(&des_list_it); des_iterator_next(&des_list_it)) {
     
    172185                                                uint32_t uuid = de_get_uuid32(element);
    173186                                                switch (uuid) {
    174                                                 case BNEP_UUID_PANU:
    175                                                 case BNEP_UUID_NAP:
    176                                                 case BNEP_UUID_GN:
     187                                                case BLUETOOTH_SERVICE_CLASS_PANU:
     188                                                case BLUETOOTH_SERVICE_CLASS_NAP:
     189                                                case BLUETOOTH_SERVICE_CLASS_GN:
    177190                                                        log_info("SDP Attribute 0x%04x: BNEP PAN protocol UUID: %04x", value_event->attribute_id, uuid);
    178191                                                        sdp_bnep_remote_uuid = uuid;
     
    192205                                        free(str);
    193206                                        break;
    194                                 case SDP_ProtocolDescriptorList: {
     207                                case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: {
    195208                                        log_info("SDP Attribute: 0x%04x", value_event->attribute_id);
    196209
     
    210223                                                uuid = de_get_uuid32(element);
    211224                                                switch (uuid) {
    212                                                 case SDP_L2CAPProtocol:
     225                                                case BLUETOOTH_PROTOCOL_L2CAP:
    213226                                                        if (!des_iterator_has_more(&prot_it)) continue;
    214227                                                        des_iterator_next(&prot_it);
    215228                                                        de_element_get_uint16(des_iterator_get_element(&prot_it), &sdp_bnep_l2cap_psm);
    216229                                                        break;
    217                                                 case SDP_BNEPProtocol:
     230                                                case BLUETOOTH_PROTOCOL_BNEP:
    218231                                                        if (!des_iterator_has_more(&prot_it)) continue;
    219232                                                        des_iterator_next(&prot_it);
     
    238251                break;
    239252
    240         case SDP_QUERY_COMPLETE:
     253        case SDP_EVENT_QUERY_COMPLETE:
    241254                handle_sdp_client_record_complete();
    242255                complete_event = (sdp_query_complete_event_t*)event;
     
    246259                }
    247260                else {
     261                        bnep_do_connect = false;
    248262                        log_error("No BNEP service found");
     263                }
     264                if (!bnep_do_connect) {
     265                        // 20秒後 BNEP Query 開始
     266                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     267                        bt_timer = 20 * 1000;
    249268                }
    250269                break;
     
    269288                        if (packet[2] == HCI_STATE_WORKING) {
    270289                                hci_send_cmd(&hci_write_local_name, bt_localname);
    271                                 /* Send a general query for BNEP Protocol ID */
    272                                 log_info("Start SDP BNEP query.");
    273                                 sdp_general_query_for_uuid(remote_addr, SDP_BNEPProtocol);
     290                                if (bt_bnep_mode == 0) {
     291                                        // 即時 BNEP Query 開始
     292                                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     293                                        bt_timer = 0;
     294                                }
     295                                else {
     296                                        bt_state = BT_STATE_BNEP_WAIT;
     297                                        bt_timer = -1;
     298                                }
    274299                        }
    275300                        break;
     
    284309
    285310                case HCI_EVENT_COMMAND_COMPLETE:
    286                         if (COMMAND_COMPLETE_EVENT(packet, hci_read_bd_addr)) {
    287                                 bt_flip_addr(event_addr, &packet[6]);
     311                        if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_bd_addr)) {
     312                                reverse_bd_addr(&packet[6], event_addr);
    288313                                log_info("BD-ADDR: %s", bd_addr_to_str(event_addr));
    289314
     
    292317                                break;
    293318                        }
    294                         if (COMMAND_COMPLETE_EVENT(packet, hci_write_local_name)) {
    295                                 hci_discoverable_control(1);
     319                        if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_local_name)) {
     320                                gap_discoverable_control(1);
    296321                                break;
    297322                        }
     
    301326                        // deny link key request
    302327                        log_info("Link key request");
    303                         bt_flip_addr(event_addr, &packet[2]);
     328                        reverse_bd_addr(&packet[2], event_addr);
    304329                        hci_send_cmd(&hci_link_key_request_negative_reply, &event_addr);
    305330                        break;
     
    308333                        // inform about pin code request
    309334                        log_info("Pin code request - using '0000'");
    310                         bt_flip_addr(event_addr, &packet[2]);
     335                        reverse_bd_addr(&packet[2], event_addr);
    311336                        hci_send_cmd(&hci_pin_code_request_reply, &event_addr, 4, "0000");
    312337                        break;
     
    314339                case HCI_EVENT_USER_CONFIRMATION_REQUEST:
    315340                        // inform about user confirmation request
    316                         log_info("HCI User Confirmation Request with numeric value '%06u'", READ_BT_32(packet, 8));
     341                        log_info("HCI User Confirmation Request with numeric value '%06u'", little_endian_read_32(packet, 8));
    317342                        log_info("HCI User Confirmation Auto accept");
    318343                        break;
     
    320345                case RFCOMM_EVENT_INCOMING_CONNECTION:
    321346                        // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16)
    322                         bt_flip_addr(event_addr, &packet[2]);
     347                        reverse_bd_addr(&packet[2], event_addr);
    323348                        rfcomm_channel_nr = packet[8];
    324                         rfcomm_channel_id = READ_BT_16(packet, 9);
     349                        rfcomm_channel_id = little_endian_read_16(packet, 9);
    325350                        log_info("RFCOMM channel %u requested for %s", rfcomm_channel_nr, bd_addr_to_str(event_addr));
    326351                        rfcomm_accept_connection_internal(rfcomm_channel_id);
     
    333358                        }
    334359                        else {
    335                                 rfcomm_channel_id = READ_BT_16(packet, 12);
    336                                 mtu = READ_BT_16(packet, 14);
     360                                rfcomm_channel_id = little_endian_read_16(packet, 12);
     361                                mtu = little_endian_read_16(packet, 14);
    337362                                log_info("RFCOMM channel open succeeded. New RFCOMM Channel ID %u, max frame size %u", rfcomm_channel_id, mtu);
    338363                        }
     
    347372                        if (packet[2]) {
    348373                                log_info("BNEP channel open failed, status %02x", packet[2]);
     374
     375                                // 30秒後 BNEP Query 開始
     376                                bt_state = BT_STATE_BNEP_QUERY_WAIT;
     377                                bt_timer = 30 * 1000;
    349378                        }
    350379                        else {
    351380                                // data: event(8), len(8), status (8), bnep source uuid (16), bnep destination uuid (16), remote_address (48)
    352                                 bnep_cid = READ_BT_16(packet, 3);
    353                                 uuid_source = READ_BT_16(packet, 5);
    354                                 uuid_dest = READ_BT_16(packet, 7);
    355                                 mtu = READ_BT_16(packet, 9);
    356                                 //bt_flip_addr(remote_addr, &packet[11]);
     381                                bnep_cid = little_endian_read_16(packet, 3);
     382                                uuid_source = little_endian_read_16(packet, 5);
     383                                uuid_dest = little_endian_read_16(packet, 7);
     384                                mtu = little_endian_read_16(packet, 9);
     385                                //reverse_bd_addr(&packet[11], remote_addr);
    357386                                memcpy(&remote_addr, &packet[11], sizeof(bd_addr_t));
    358387                                log_info("BNEP connection open succeeded to %s source UUID 0x%04x dest UUID: 0x%04x, max frame size %u", bd_addr_to_str(event_addr), uuid_source, uuid_dest, mtu);
     
    360389                                btstack_network_up(bnep_cid, (uint8_t *)hci_local_bd_addr(), (uint8_t *)remote_addr);
    361390                                log_info("Network Interface %s activated", btstack_network_get_name(bnep_cid));
     391
     392                                bt_state = BT_STATE_CONNECTED;
     393                                bt_timer = -1;
    362394                        }
    363395                        break;
     
    368400
    369401                case BNEP_EVENT_CHANNEL_CLOSED:
    370                         bnep_cid = READ_BT_16(packet, 2);
     402                        bnep_cid = little_endian_read_16(packet, 2);
    371403                        bt_channel_closed(bnep_cid);
     404
     405                        // 30秒後 BNEP Query 開始
     406                        bt_state = BT_STATE_BNEP_QUERY_WAIT;
     407                        bt_timer = 30 * 1000;
    372408                        break;
    373409
    374410                case BNEP_EVENT_READY_TO_SEND:
    375                         bnep_cid = READ_BT_16(packet, 2);
     411                        bnep_cid = little_endian_read_16(packet, 2);
    376412                        bt_send_packet(bnep_cid);
    377413                        break;
     
    428464}
    429465
    430 void panu_init(void)
     466void bt_init(void)
    431467{
    432468        const hci_transport_t *transport;
     
    437473        service_record_item_t *bnep_service_record_item;
    438474
     475        btstack_network_init(&network_send_packet_callback);
     476
    439477        //hci_dump_open("", HCI_DUMP_PACKETLOGGER);
    440 
    441         log_info("bt初期化...");
    442478
    443479        // start with BTstack init - especially configure HCI Transport
     
    446482
    447483        /* Initialize HCI */
    448         log_info("HCI初期化...");
    449484        transport = hci_transport_usb_instance();
    450485        control = NULL;
     
    455490
    456491        /* Initialize L2CAP */
    457         log_info("L2CAP初期化...");
    458492        l2cap_init();
    459493        l2cap_register_packet_handler(packet_handler);
    460494
    461495        /* Initialise SDP, create record for SPP and register with SDP */
    462         log_info("SDP初期化...");
    463496        sdp_init();
    464497
    465498        /* Initialize RFCOMM */
    466         log_info("RFCOMM初期化...");
    467499        rfcomm_init();
    468500        rfcomm_register_packet_handler(packet_handler);
     
    470502
    471503        /* Initialise BNEP */
    472         log_info("BNEP初期化...");
    473504        bnep_init();
    474505        bnep_register_packet_handler(packet_handler);
    475         bnep_register_service(NULL, BNEP_UUID_PANU, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     506        if (bt_bnep_mode == 0) {
     507                bnep_register_service(NULL, BLUETOOTH_SERVICE_CLASS_PANU, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     508        }
     509        else {
     510                bnep_register_service(NULL, BLUETOOTH_SERVICE_CLASS_NAP, BNEP_MTU_MIN);  /* Minimum L2CAP MTU for bnep is 1691 bytes */
     511        }
    476512
    477513        memset(spp_service_buffer, 0, sizeof(spp_service_buffer));
     
    482518        bnep_service_record_item = (service_record_item_t *)bnep_service_buffer;
    483519
    484         log_info("SPPサービス登録...");
    485520        sdp_create_spp_service((uint8_t*)&spp_service_record_item->service_record, 1, "RX SPP");
    486521        de_dump_data_element((uint8_t*)spp_service_record_item->service_record);
     
    488523        sdp_register_service_internal(NULL, spp_service_record_item);
    489524
    490         log_info("BNEPサービス登録...");
    491         pan_create_panu_service((uint8_t*)&bnep_service_record_item->service_record, "RX PANU", "RX PANU", BNEP_SECURITY_NONE);
    492         de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
    493         log_info("PANU SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     525        if (bt_bnep_mode == 0) {
     526                pan_create_panu_service((uint8_t*)&bnep_service_record_item->service_record, "RX PANU", "RX PANU", BNEP_SECURITY_NONE);
     527                de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
     528                log_info("PANU SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     529        }
     530        else {
     531                pan_create_nap_service((uint8_t*)&bnep_service_record_item->service_record, "RX NAP", "RX NAP", BNEP_SECURITY_NONE,
     532                        PAN_NET_ACCESS_TYPE_100MB_ETHERNET, 0x0001312D0/*10Mb/sec*/, NULL, NULL);
     533                de_dump_data_element((uint8_t*)bnep_service_record_item->service_record);
     534                log_info("NAP SDP service buffer size: %u", (uint16_t)(sizeof(service_record_item_t) + de_get_len((uint8_t*)bnep_service_record_item->service_record)));
     535        }
    494536        sdp_register_service_internal(NULL, bnep_service_record_item);
    495537
     
    500542
    501543        /* Turn on the device */
    502         log_info("HCI電源ON...");
    503544        hci_power_control(HCI_POWER_ON);
    504545
     
    506547        sdp_parser_init();
    507548        sdp_parser_register_callback(handle_sdp_client_query_result);
    508 }
    509 
    510 void nap_init(void);
    511 
    512 void bt_init(void)
    513 {
    514         btstack_network_init(&network_send_packet_callback);
    515 
    516         if (bt_bnep_mode == 0) {
    517                 panu_init();
    518         }
    519         else {
    520                 nap_init();
    521         }
    522 
    523         bt_enabled = true;
    524 }
    525 
    526 void bt_task(void)
    527 {
    528         extern void hal_tick_handler();
    529 
    530         if (bt_enabled) {
    531                 hal_tick_handler();
     549
     550        bt_state = BT_STATE_POWER_ON;
     551        bt_timer = -1;
     552}
     553
     554void bt_process(void)
     555{
     556        if (bt_state != BT_STATE_DORMANT) {
    532557                run_loop_execute();
    533558                bt_send_packet(0xffff);
     559        }
     560
     561        if (bt_timer != 0)
     562                return;
     563
     564        switch (bt_state) {
     565        case BT_STATE_BNEP_QUERY_WAIT:
     566                /* Send a general query for BNEP Protocol ID */
     567                log_info("Start SDP BNEP query.");
     568                sdp_general_query_for_uuid(remote_addr, BLUETOOTH_PROTOCOL_BNEP);
     569
     570                bt_state = BT_STATE_BNEP_QUERY;
     571                bt_timer = -1;
     572                break;
     573        default:
     574                bt_timer = -1;
     575                break;
    534576        }
    535577}
     
    592634        hci_close();
    593635
    594         bt_enabled = false;
    595 }
     636        bt_state = BT_STATE_DORMANT;
     637        bt_timer = -1;
     638}
     639
     640void bt_task_on_start(struct task_if_t *task, ID tskid)
     641{
     642}
     643
     644void bt_task_on_end(struct task_if_t *task)
     645{
     646}
     647
     648int bt_task_get_timer(struct task_if_t *task)
     649{
     650        return bt_timer;
     651}
     652
     653void bt_task_progress(struct task_if_t *task, int elapse)
     654{
     655        if (bt_timer == -1)
     656                return;
     657
     658        bt_timer -= elapse;
     659        if (bt_timer < 0)
     660                bt_timer = 0;
     661}
     662
     663void bt_task_process(struct task_if_t *task, enum task_event_t event)
     664{
     665        extern void hal_tick_handler();
     666
     667        switch (event & ~TASK_EVENT_TICK) {
     668        case TASK_EVENT_START:
     669                bt_init();
     670                break;
     671        case TASK_EVENT_TERMINATE:
     672                bt_terminate();
     673                break;
     674        case TASK_EVENT_WAKEUP:
     675        case TASK_EVENT_TIMEOUT:
     676                if (event & TASK_EVENT_TICK)
     677                        hal_tick_handler();
     678                bt_process();
     679                break;
     680        }
     681}
     682
     683struct task_if_t bt_task = {
     684        bt_task_on_start,
     685        bt_task_on_end,
     686        bt_task_get_timer,
     687        bt_task_progress,
     688        bt_task_process,
     689};
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/bt_main.h

    r373 r374  
    11/*
    2  * panu_main.h
     2 * bt_main.h
    33 *
    44 */
     
    1616
    1717void bt_init(void);
    18 void bt_task(void);
    1918int bt_can_send_packet(void);
    2019void bt_send_packet(uint16_t bnep_cid);
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/if_btusb.c

    r337 r374  
    7777#include "kernel/kernel_impl.h"
    7878#include "btstack/utils.h"
    79 #include "panu_main.h"
     79#include "bt_main.h"
    8080#include "usb_hbth.h"
    8181//#include "hal_cpu.h"
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/main.c

    r364 r374  
    5656#include "core/ntshell.h"
    5757#include "core/ntlibc.h"
    58 #include "util/ntstdio.h"
     58#include <stdio.h>
    5959#include "usrcmd.h"
    6060#include "util/ntopt.h"
    61 #include "mbed_api.h"
     61#include "gpio_api.h"
    6262#include "usb_hbth.h"
    6363#include "ntshell_main.h"
     
    6969extern int bt_bnep_mode;
    7070/* PANU向けリモートアドレス */
    71 // BUFFALLO
    72 //bd_addr_t remote_addr = { 0x00,0x1B,0xDC,0x04,0x5C,0x2D };
    73 // Raspberry Pi 3
    74 //bd_addr_t remote_addr = {0xB8,0x27,0xEB,0x10,0x6D,0x60};
    75 // PRINCETON
    76 //bd_addr_t remote_addr = {0x00,0x1B,0xDC,0x06,0x6E,0x98};
    77 // ELECOM
    7871bd_addr_t remote_addr = {0x00,0x1B,0xDC,0x09,0x27,0x26};
    7972
     
    185178{
    186179        FILINFO fno;
    187 #if _USE_LFN
    188         char lfn[_MAX_LFN + 1];
     180#if FF_USE_LFN
     181        char lfn[FF_MAX_LFN + 1];
    189182        fno.lfname = lfn;
    190         fno.lfsize = _MAX_LFN + 1;
     183        fno.lfsize = FF_MAX_LFN + 1;
    191184#endif
    192185        ER ret;
    193186
    194 #ifdef TOPPERS_OMIT_TECS
    195         serial_opn_por(SIO_PORTID);
    196 #endif
    197         serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
    198 
    199         ntshell_task_init(uart_read, uart_write, &main_obj);
     187        ntshell_task_init(SIO_PORTID);
    200188
    201189        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/hci_cmds.h

    r337 r374  
    404404 * @param status
    405405 */
    406 #define SDP_QUERY_COMPLETE                                 0x91
     406#define SDP_EVENT_QUERY_COMPLETE                           0x91
    407407
    408408// data: event(8), len(8), rfcomm channel(8), name(var)
     
    422422 * @param attribute_value
    423423 */
    424 #define SDP_QUERY_ATTRIBUTE_VALUE                          0x93
     424#define SDP_EVENT_QUERY_ATTRIBUTE_VALUE                    0x93
    425425
    426426// not provided by daemon, only used for internal testing
  • asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/sdp_util.h

    r337 r374  
    6868// UNIVERSAL ATTRIBUTE DEFINITIONS
    6969#define SDP_ServiceRecordHandle     0x0000
    70 #define SDP_ServiceClassIDList      0x0001
     70#define BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST      0x0001
    7171#define SDP_ServiceRecordState      0x0002
    7272#define SDP_ServiceID               0x0003
    73 #define SDP_ProtocolDescriptorList  0x0004
     73#define BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST  0x0004
    7474#define SDP_BrowseGroupList                 0x0005
    7575#define SDP_LanguageBaseAttributeIDList 0x0006
     
    9393#define SDP_RFCOMMProtocol    0x0003
    9494#define SDP_OBEXProtocol      0x0008
    95 #define SDP_L2CAPProtocol     0x0100
    96 #define SDP_BNEPProtocol      0x000f
     95#define BLUETOOTH_PROTOCOL_L2CAP     0x0100
     96#define BLUETOOTH_PROTOCOL_BNEP      0x000f
    9797
    9898// OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList
  • asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/utils.h

    r337 r374  
    9090
    9191// helper for BT little endian format
    92 #define READ_BT_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8))
    93 #define READ_BT_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16))
    94 #define READ_BT_32( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16) | (((uint32_t) buffer[pos+3])) << 24)
     92#define little_endian_read_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8))
     93#define little_endian_read_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16))
     94#define little_endian_read_32( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16) | (((uint32_t) buffer[pos+3])) << 24)
    9595
    9696// helper for SDP big endian format
    97 #define READ_NET_16( buffer, pos) ( ((uint16_t) buffer[pos+1]) | (((uint16_t)buffer[pos  ]) << 8))
    98 #define READ_NET_32( buffer, pos) ( ((uint32_t) buffer[pos+3]) | (((uint32_t)buffer[pos+2]) << 8) | (((uint32_t)buffer[pos+1]) << 16) | (((uint32_t) buffer[pos])) << 24)
     97#define big_endian_read_16( buffer, pos) ( ((uint16_t) buffer[pos+1]) | (((uint16_t)buffer[pos  ]) << 8))
     98#define big_endian_read_32( buffer, pos) ( ((uint32_t) buffer[pos+3]) | (((uint32_t)buffer[pos+2]) << 8) | (((uint32_t)buffer[pos+1]) << 16) | (((uint32_t) buffer[pos])) << 24)
    9999
    100100// HCI CMD OGF/OCF
     
    103103
    104104// check if command complete event for given command
    105 #define COMMAND_COMPLETE_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_COMPLETE && READ_BT_16(event,3) == cmd.opcode)
    106 #define COMMAND_STATUS_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_STATUS && READ_BT_16(event,4) == cmd.opcode)
     105#define HCI_EVENT_IS_COMMAND_COMPLETE(event,cmd) ( event[0] == HCI_EVENT_COMMAND_COMPLETE && little_endian_read_16(event,3) == cmd.opcode)
     106#define COMMAND_STATUS_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_STATUS && little_endian_read_16(event,4) == cmd.opcode)
    107107
    108108// Code+Len=2, Pkts+Opcode=3; total=5
     
    110110
    111111// ACL Packet
    112 #define READ_ACL_CONNECTION_HANDLE( buffer ) ( READ_BT_16(buffer,0) & 0x0fff)
     112#define READ_ACL_CONNECTION_HANDLE( buffer ) ( little_endian_read_16(buffer,0) & 0x0fff)
    113113#define READ_ACL_FLAGS( buffer )      ( buffer[1] >> 4 )
    114 #define READ_ACL_LENGTH( buffer )     (READ_BT_16(buffer, 2))
     114#define READ_ACL_LENGTH( buffer )     (little_endian_read_16(buffer, 2))
    115115
    116116// L2CAP Packet
    117 #define READ_L2CAP_LENGTH(buffer)     ( READ_BT_16(buffer, 4))
    118 #define READ_L2CAP_CHANNEL_ID(buffer) ( READ_BT_16(buffer, 6))
     117#define READ_L2CAP_LENGTH(buffer)     ( little_endian_read_16(buffer, 4))
     118#define READ_L2CAP_CHANNEL_ID(buffer) ( little_endian_read_16(buffer, 6))
    119119
    120 void bt_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
    121 void bt_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);
    122 void bt_flip_addr(bd_addr_t dest, bd_addr_t src);
     120void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
     121void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);
     122void reverse_bd_addr(bd_addr_t src, bd_addr_t dest);
    123123
    124124void net_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);
  • asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c

    r337 r374  
    8484    event[1] = sizeof(event) - 2;
    8585    event[2] = status;
    86     bt_store_16(event, 3, channel->l2cap_cid);
    87     bt_store_16(event, 5, channel->uuid_source);
    88     bt_store_16(event, 7, channel->uuid_dest);
    89     bt_store_16(event, 9, channel->max_frame_size);
     86    little_endian_store_16(event, 3, channel->l2cap_cid);
     87    little_endian_store_16(event, 5, channel->uuid_source);
     88    little_endian_store_16(event, 7, channel->uuid_dest);
     89    little_endian_store_16(event, 9, channel->max_frame_size);
    9090    BD_ADDR_COPY(&event[11], channel->remote_addr);
    9191    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    101101    event[0] = BNEP_EVENT_CHANNEL_TIMEOUT;
    102102    event[1] = sizeof(event) - 2;
    103     bt_store_16(event, 2, channel->l2cap_cid);
    104     bt_store_16(event, 4, channel->uuid_source);
    105     bt_store_16(event, 6, channel->uuid_dest);
     103    little_endian_store_16(event, 2, channel->l2cap_cid);
     104    little_endian_store_16(event, 4, channel->uuid_source);
     105    little_endian_store_16(event, 6, channel->uuid_dest);
    106106    BD_ADDR_COPY(&event[8], channel->remote_addr);
    107107    event[14] = channel->state;
     
    118118    event[0] = BNEP_EVENT_CHANNEL_CLOSED;
    119119    event[1] = sizeof(event) - 2;
    120     bt_store_16(event, 2, channel->l2cap_cid);
    121     bt_store_16(event, 4, channel->uuid_source);
    122     bt_store_16(event, 6, channel->uuid_dest);
     120    little_endian_store_16(event, 2, channel->l2cap_cid);
     121    little_endian_store_16(event, 4, channel->uuid_source);
     122    little_endian_store_16(event, 6, channel->uuid_dest);
    123123    BD_ADDR_COPY(&event[8], channel->remote_addr);
    124124    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    133133    event[0] = BNEP_EVENT_READY_TO_SEND;
    134134    event[1] = sizeof(event) - 2;
    135     bt_store_16(event, 2, channel->l2cap_cid);
     135    little_endian_store_16(event, 2, channel->l2cap_cid);
    136136    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    137137        (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
     
    464464    BD_ADDR_COPY(addr_source, &packet[pos]);
    465465    pos += sizeof(bd_addr_t);
    466     network_protocol_type = READ_NET_16(packet, pos);
     466    network_protocol_type = big_endian_read_16(packet, pos);
    467467    pos += sizeof(uint16_t);
    468468
     
    475475        }
    476476        /* The "real" network protocol type is 4 bytes ahead in a VLAN packet */
    477                 network_protocol_type = READ_NET_16(packet, pos + 2);
     477                network_protocol_type = big_endian_read_16(packet, pos + 2);
    478478        }
    479479
     
    808808    /* Check source and destination UUIDs for valid combinations */
    809809    if (response_code == BNEP_RESP_SETUP_SUCCESS) {
    810         channel->uuid_dest = READ_NET_16(packet, 2 + uuid_offset);
    811         channel->uuid_source = READ_NET_16(packet, 2 + uuid_offset + uuid_size);
    812 
    813         if ((channel->uuid_dest != BNEP_UUID_PANU) &&
    814             (channel->uuid_dest != BNEP_UUID_NAP) &&
    815             (channel->uuid_dest != BNEP_UUID_GN)) {
     810        channel->uuid_dest = big_endian_read_16(packet, 2 + uuid_offset);
     811        channel->uuid_source = big_endian_read_16(packet, 2 + uuid_offset + uuid_size);
     812
     813        if ((channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU) &&
     814            (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_NAP) &&
     815            (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_GN)) {
    816816            log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest);
    817817            channel->uuid_dest = 0;
    818818        }
    819         if ((channel->uuid_source != BNEP_UUID_PANU) &&
    820             (channel->uuid_source != BNEP_UUID_NAP) &&
    821             (channel->uuid_source != BNEP_UUID_GN)) {
     819        if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) &&
     820            (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_NAP) &&
     821            (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_GN)) {
    822822            log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source);
    823823            channel->uuid_source = 0;
     
    829829            response_code = BNEP_RESP_SETUP_INVALID_DEST_UUID;
    830830        } else
    831         if ((channel->uuid_source != BNEP_UUID_PANU) && (channel->uuid_dest != BNEP_UUID_PANU)) {
     831        if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU)) {
    832832            response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID;
    833833        }
     
    857857    }
    858858
    859     response_code = READ_NET_16(packet, 1);
     859    response_code = big_endian_read_16(packet, 1);
    860860
    861861    if (response_code == BNEP_RESP_SETUP_SUCCESS) {
     
    882882    }
    883883
    884     list_length = READ_NET_16(packet, 1);
     884    list_length = big_endian_read_16(packet, 1);
    885885    /* Sanity check packet size again with known package size */
    886886    if (size < 3 + list_length) {
     
    903903        /* There is still enough space, copy the filters to our filter list */
    904904        for (i = 0; i < list_length / (2 * 2); i ++) {
    905             channel->net_filter[channel->net_filter_count].range_start = READ_NET_16(packet, 1 + 2 + i * 4);
    906             channel->net_filter[channel->net_filter_count].range_end = READ_NET_16(packet, 1 + 2 + i * 4 + 2);
     905            channel->net_filter[channel->net_filter_count].range_start = big_endian_read_16(packet, 1 + 2 + i * 4);
     906            channel->net_filter[channel->net_filter_count].range_end = big_endian_read_16(packet, 1 + 2 + i * 4 + 2);
    907907            if (channel->net_filter[channel->net_filter_count].range_start > channel->net_filter[channel->net_filter_count].range_end) {
    908908                /* Invalid filter range, ignore this filter rule */
     
    945945    }
    946946
    947     response_code = READ_NET_16(packet, 1);
     947    response_code = big_endian_read_16(packet, 1);
    948948
    949949    if (response_code == BNEP_RESP_FILTER_SUCCESS) {
     
    966966    }
    967967
    968     list_length = READ_NET_16(packet, 1);
     968    list_length = big_endian_read_16(packet, 1);
    969969    /* Sanity check packet size again with known package size */
    970970    if (size < 3 + list_length) {
     
    10321032    }
    10331033
    1034     response_code = READ_NET_16(packet, 1);
     1034    response_code = big_endian_read_16(packet, 1);
    10351035
    10361036    if (response_code == BNEP_RESP_FILTER_SUCCESS) {
     
    11691169        case L2CAP_EVENT_INCOMING_CONNECTION:
    11701170            /* L2CAP event data: event(8), len(8), address(48), handle (16),  psm (16), source cid(16) dest cid(16) */
    1171             bt_flip_addr(event_addr, &packet[2]);
    1172             con_handle = READ_BT_16(packet,  8);
    1173             psm        = READ_BT_16(packet, 10);
    1174             l2cap_cid  = READ_BT_16(packet, 12);
     1171            reverse_bd_addr(&packet[2], event_addr);
     1172            con_handle = little_endian_read_16(packet,  8);
     1173            psm        = little_endian_read_16(packet, 10);
     1174            l2cap_cid  = little_endian_read_16(packet, 12);
    11751175
    11761176            if (psm != PSM_BNEP) break;
     
    12111211        case L2CAP_EVENT_CHANNEL_OPENED:
    12121212            /* Check if the l2cap channel has been opened for PSM_BNEP */
    1213             if (READ_BT_16(packet, 11) != PSM_BNEP) {
     1213            if (little_endian_read_16(packet, 11) != PSM_BNEP) {
    12141214                break;
    12151215            }
     
    12191219
    12201220            /* Get the bnep channel fpr remote address */
    1221             con_handle = READ_BT_16(packet, 9);
    1222             l2cap_cid  = READ_BT_16(packet, 13);
    1223             bt_flip_addr(event_addr, &packet[3]);
     1221            con_handle = little_endian_read_16(packet, 9);
     1222            l2cap_cid  = little_endian_read_16(packet, 13);
     1223            reverse_bd_addr(&packet[3], event_addr);
    12241224            channel = bnep_channel_for_addr(&event_addr);
    12251225            if (!channel) {
     
    12521252                    channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE;
    12531253                    bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST);
    1254                     channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
     1254                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17));
    12551255                    bnep_run();
    12561256                    break;
    12571257                case BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_REQUEST:
    12581258                    /* New information: channel mtu */
    1259                     channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
     1259                    channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17));
    12601260                    break;
    12611261                default:
     
    12721272        case L2CAP_EVENT_CHANNEL_CLOSED:
    12731273            // data: event (8), len(8), channel (16)
    1274             l2cap_cid   = READ_BT_16(packet, 2);
     1274            l2cap_cid   = little_endian_read_16(packet, 2);
    12751275            channel = bnep_channel_for_l2cap_cid(l2cap_cid);
    12761276            log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, channel %p", l2cap_cid, channel);
     
    13311331            BD_ADDR_COPY(addr_source, &packet[pos]);
    13321332            pos += sizeof(bd_addr_t);
    1333             network_protocol_type = READ_NET_16(packet, pos);
     1333            network_protocol_type = big_endian_read_16(packet, pos);
    13341334            pos += 2;
    13351335            break;
     
    13371337            BD_ADDR_COPY(addr_dest, channel->local_addr);
    13381338            BD_ADDR_COPY(addr_source, channel->remote_addr);
    1339             network_protocol_type = READ_NET_16(packet, pos);
     1339            network_protocol_type = big_endian_read_16(packet, pos);
    13401340            pos += 2;
    13411341            break;
     
    13441344            BD_ADDR_COPY(addr_source, &packet[pos]);
    13451345            pos += sizeof(bd_addr_t);
    1346             network_protocol_type = READ_NET_16(packet, pos);
     1346            network_protocol_type = big_endian_read_16(packet, pos);
    13471347            pos += 2;
    13481348            break;
     
    13511351            pos += sizeof(bd_addr_t);
    13521352            BD_ADDR_COPY(addr_source, channel->remote_addr);
    1353             network_protocol_type = READ_NET_16(packet, pos);
     1353            network_protocol_type = big_endian_read_16(packet, pos);
    13541354            pos += 2;
    13551355            break;
     
    15631563    }
    15641564
    1565     channel->uuid_source = BNEP_UUID_PANU;
     1565    channel->uuid_source = BLUETOOTH_SERVICE_CLASS_PANU;
    15661566    channel->uuid_dest   = uuid_dest;
    15671567
     
    15971597
    15981598    /* Only alow one the three service types: PANU, NAP, GN */
    1599     if ((service_uuid != BNEP_UUID_PANU) &&
    1600         (service_uuid != BNEP_UUID_NAP) &&
    1601         (service_uuid != BNEP_UUID_GN)) {
     1599    if ((service_uuid != BLUETOOTH_SERVICE_CLASS_PANU) &&
     1600        (service_uuid != BLUETOOTH_SERVICE_CLASS_NAP) &&
     1601        (service_uuid != BLUETOOTH_SERVICE_CLASS_GN)) {
    16021602        log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid);
    16031603        return BNEP_CHANNEL_NOT_CONNECTED;
  • asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.h

    r337 r374  
    7272
    7373/* BNEP UUIDs */
    74 #define BNEP_UUID_PANU                                  0x1115
    75 #define BNEP_UUID_NAP                                   0x1116
    76 #define BNEP_UUID_GN                                    0x1117
     74#define BLUETOOTH_SERVICE_CLASS_PANU                    0x1115
     75#define BLUETOOTH_SERVICE_CLASS_NAP                     0x1116
     76#define BLUETOOTH_SERVICE_CLASS_GN                      0x1117
    7777   
    7878/* BNEP packet types */   
  • asp3_tinet_ecnl_rx/trunk/btstack/src/hci.c

    r337 r374  
    233233    bd_addr_t addr;
    234234    hci_connection_t * conn;
    235     bt_flip_addr(addr, *(bd_addr_t *) bd_addr);
     235    reverse_bd_addr(*(bd_addr_t *) bd_addr, addr);
    236236    conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC);
    237237    if (conn) {
     
    469469        // copy handle_and_flags if not first fragment and update packet boundary flags to be 01 (continuing fragmnent)
    470470        if (acl_header_pos > 0){
    471             uint16_t handle_and_flags = READ_BT_16(hci_stack->hci_packet_buffer, 0);
     471            uint16_t handle_and_flags = little_endian_read_16(hci_stack->hci_packet_buffer, 0);
    472472            handle_and_flags = (handle_and_flags & 0xcfff) | (1 << 12);
    473             bt_store_16(hci_stack->hci_packet_buffer, acl_header_pos, handle_and_flags);
     473            little_endian_store_16(hci_stack->hci_packet_buffer, acl_header_pos, handle_and_flags);
    474474        }
    475475
    476476        // update header len
    477         bt_store_16(hci_stack->hci_packet_buffer, acl_header_pos + 2, current_acl_data_packet_length);
     477        little_endian_store_16(hci_stack->hci_packet_buffer, acl_header_pos + 2, current_acl_data_packet_length);
    478478
    479479        // count packet
     
    640640                conn->acl_recombination_pos    = acl_length + 4;
    641641                conn->acl_recombination_length = l2cap_length;
    642                 bt_store_16(conn->acl_recombination_buffer, HCI_INCOMING_PRE_BUFFER_SIZE + 2, l2cap_length +4);
     642                little_endian_store_16(conn->acl_recombination_buffer, HCI_INCOMING_PRE_BUFFER_SIZE + 2, l2cap_length +4);
    643643            }
    644644            break;
     
    793793    // odd: waiting for event
    794794    if (packet[0] == HCI_EVENT_COMMAND_COMPLETE){
    795         uint16_t opcode = READ_BT_16(packet,3);
     795        uint16_t opcode = little_endian_read_16(packet,3);
    796796        if (opcode == hci_stack->last_cmd_opcode){
    797797            command_completed = 1;
     
    803803    if (packet[0] == HCI_EVENT_COMMAND_STATUS){
    804804        uint8_t  status = packet[2];
    805         uint16_t opcode = READ_BT_16(packet,4);
     805        uint16_t opcode = little_endian_read_16(packet,4);
    806806        if (opcode == hci_stack->last_cmd_opcode){
    807807            if (status){
     
    843843        case 1: // SEND BAUD CHANGE
    844844            hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer);
    845             hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
     845            hci_stack->last_cmd_opcode = little_endian_read_16(hci_stack->hci_packet_buffer, 0);
    846846            hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
    847847            hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]);
     
    860860                if (valid_cmd){
    861861                    int size = 3 + hci_stack->hci_packet_buffer[2];
    862                     hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);
     862                    hci_stack->last_cmd_opcode = little_endian_read_16(hci_stack->hci_packet_buffer, 0);
    863863                    hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, size);
    864864                    hci_stack->hci_transport->send_packet(HCI_COMMAND_DATA_PACKET, hci_stack->hci_packet_buffer, size);
     
    992992            hci_stack->num_cmd_packets = packet[2];
    993993
    994             if (COMMAND_COMPLETE_EVENT(packet, hci_read_buffer_size)){
     994            if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_buffer_size)){
    995995                // from offset 5
    996996                // status
    997997                // "The HC_ACL_Data_Packet_Length return parameter will be used to determine the size of the L2CAP segments contained in ACL Data Packets"
    998                 hci_stack->acl_data_packet_length = READ_BT_16(packet, 6);
     998                hci_stack->acl_data_packet_length = little_endian_read_16(packet, 6);
    999999                // ignore: SCO data packet len (8)
    10001000                hci_stack->acl_packets_total_num  = packet[9];
     
    10101010            }
    10111011#ifdef HAVE_BLE
    1012             if (COMMAND_COMPLETE_EVENT(packet, hci_le_read_buffer_size)){
    1013                 hci_stack->le_data_packets_length = READ_BT_16(packet, 6);
     1012            if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_le_read_buffer_size)){
     1013                hci_stack->le_data_packets_length = little_endian_read_16(packet, 6);
    10141014                hci_stack->le_acl_packets_total_num  = packet[8];
    10151015                    // determine usable ACL payload size
     
    10211021#endif
    10221022            // Dump local address
    1023             if (COMMAND_COMPLETE_EVENT(packet, hci_read_bd_addr)) {
    1024                 bt_flip_addr(hci_stack->local_bd_addr, &packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1]);
     1023            if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_bd_addr)) {
     1024                reverse_bd_addr(&packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1], hci_stack->local_bd_addr);
    10251025                log_info("Local Address, Status: 0x%02x: Addr: %s",
    10261026                    packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE], bd_addr_to_str(hci_stack->local_bd_addr));
    10271027            }
    1028             if (COMMAND_COMPLETE_EVENT(packet, hci_write_scan_enable)){
     1028            if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_scan_enable)){
    10291029                hci_emit_discoverable_enabled(hci_stack->discoverable);
    10301030            }
    10311031            // Note: HCI init checks
    1032             if (COMMAND_COMPLETE_EVENT(packet, hci_read_local_supported_features)){
     1032            if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_features)){
    10331033                memcpy(hci_stack->local_supported_features, &packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1], 8);
    10341034                log_info("Local Supported Features: 0x%02x%02x%02x%02x%02x%02x%02x%02x",
     
    10571057            for (i=0; i<packet[2];i++){
    10581058                uint16_t num_packets;
    1059                 handle = READ_BT_16(packet, offset);
     1059                handle = little_endian_read_16(packet, offset);
    10601060                offset += 2;
    1061                 num_packets = READ_BT_16(packet, offset);
     1061                num_packets = little_endian_read_16(packet, offset);
    10621062                offset += 2;
    10631063
     
    10791079        }
    10801080        case HCI_EVENT_CONNECTION_REQUEST:
    1081             bt_flip_addr(addr, &packet[2]);
     1081            reverse_bd_addr(&packet[2], addr);
    10821082            // TODO: eval COD 8-10
    10831083            link_type = packet[11];
     
    11061106        case HCI_EVENT_CONNECTION_COMPLETE:
    11071107            // Connection management
    1108             bt_flip_addr(addr, &packet[5]);
     1108            reverse_bd_addr(&packet[5], addr);
    11091109            log_info("Connection_complete (status=%u) %s", packet[2], bd_addr_to_str(addr));
    11101110            addr_type = BD_ADDR_TYPE_CLASSIC;
     
    11131113                if (!packet[2]){
    11141114                    conn->state = OPEN;
    1115                     conn->con_handle = READ_BT_16(packet, 3);
     1115                    conn->con_handle = little_endian_read_16(packet, 3);
    11161116                    conn->bonding_flags |= BONDING_REQUEST_REMOTE_FEATURES;
    11171117
     
    11481148
    11491149        case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE:
    1150             handle = READ_BT_16(packet, 3);
     1150            handle = little_endian_read_16(packet, 3);
    11511151            conn = hci_connection_for_handle(handle);
    11521152            if (!conn) break;
     
    11761176        case HCI_EVENT_LINK_KEY_NOTIFICATION: {
    11771177            link_key_type_t link_key_type;
    1178             bt_flip_addr(addr, &packet[2]);
     1178            reverse_bd_addr(&packet[2], addr);
    11791179            conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC);
    11801180            if (!conn) break;
     
    12011201            // PIN CODE REQUEST means the link key request didn't succee -> delete stored link key
    12021202            if (!hci_stack->remote_device_db) break;
    1203             bt_flip_addr(addr, &packet[2]);
     1203            reverse_bd_addr(&packet[2], addr);
    12041204            hci_stack->remote_device_db->delete_link_key(&addr);
    12051205            break;
     
    12231223
    12241224        case HCI_EVENT_ENCRYPTION_CHANGE:
    1225             handle = READ_BT_16(packet, 3);
     1225            handle = little_endian_read_16(packet, 3);
    12261226            conn = hci_connection_for_handle(handle);
    12271227            if (!conn) break;
     
    12371237
    12381238        case HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT:
    1239             handle = READ_BT_16(packet, 3);
     1239            handle = little_endian_read_16(packet, 3);
    12401240            conn = hci_connection_for_handle(handle);
    12411241            if (!conn) break;
     
    12621262            if (!hci_stack->remote_device_db) break;
    12631263            if (packet[2]) break; // status not ok
    1264             bt_flip_addr(addr, &packet[3]);
     1264            reverse_bd_addr(&packet[3], addr);
    12651265            // fix for invalid remote names - terminate on 0xff
    12661266            for (i=0; i<248;i++){
     
    12831283            int offset = 3;
    12841284            for (i=0; i<packet[2];i++){
    1285                 bt_flip_addr(addr, &packet[offset]);
     1285                reverse_bd_addr(&packet[offset], addr);
    12861286                offset += 14; // 6 + 1 + 1 + 1 + 3 + 2;
    12871287                if (hci_stack->remote_device_db->get_name(&addr, &device_name)){
     
    13081308        case HCI_EVENT_ROLE_CHANGE:
    13091309            if (packet[2]) break;   // status != 0
    1310             handle = READ_BT_16(packet, 3);
     1310            handle = little_endian_read_16(packet, 3);
    13111311            conn = hci_connection_for_handle(handle);
    13121312            if (!conn) break;       // no conn
     
    13311331                case HCI_SUBEVENT_LE_CONNECTION_COMPLETE:
    13321332                    // Connection management
    1333                     bt_flip_addr(addr, &packet[8]);
     1333                    reverse_bd_addr(&packet[8], addr);
    13341334                    addr_type = (bd_addr_type_t)packet[7];
    13351335                    log_info("LE Connection_complete (status=%u) type %u, %s", packet[3], addr_type, bd_addr_to_str(addr));
     
    13571357
    13581358                    conn->state = OPEN;
    1359                     conn->con_handle = READ_BT_16(packet, 4);
     1359                    conn->con_handle = little_endian_read_16(packet, 4);
    13601360
    13611361                    // TODO: store - role, peer address type, conn_interval, conn_latency, supervision timeout, master clock
     
    13701370                    break;
    13711371
    1372             // log_info("LE buffer size: %u, count %u", READ_BT_16(packet,6), packet[8]);
     1372            // log_info("LE buffer size: %u, count %u", little_endian_read_16(packet,6), packet[8]);
    13731373
    13741374                default:
     
    13891389    if (hci_stack->state == HCI_STATE_FALLING_ASLEEP
    13901390        && hci_stack->substate == 1
    1391         && COMMAND_COMPLETE_EVENT(packet, hci_write_scan_enable)){
     1391        && HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_scan_enable)){
    13921392        hci_stack->substate++;
    13931393    }
     
    14001400        if (!packet[2]){
    14011401            hci_connection_t * conn;
    1402             handle = READ_BT_16(packet, 3);
     1402            handle = little_endian_read_16(packet, 3);
    14031403            conn = hci_connection_for_handle(handle);
    14041404            if (conn) {
     
    17931793}
    17941794
    1795 void hci_discoverable_control(uint8_t enable){
     1795void gap_discoverable_control(uint8_t enable){
    17961796    if (enable) enable = 1; // normalize argument
    17971797
     
    21402140    // create_connection?
    21412141    if (IS_COMMAND(packet, hci_create_connection)){
    2142         bt_flip_addr(addr, &packet[3]);
     2142        reverse_bd_addr(&packet[3], addr);
    21432143        log_info("Create_connection to %s", bd_addr_to_str(addr));
    21442144
     
    21792179    if (IS_COMMAND(packet, hci_delete_stored_link_key)){
    21802180        if (hci_stack->remote_device_db){
    2181             bt_flip_addr(addr, &packet[3]);
     2181            reverse_bd_addr(&packet[3], addr);
    21822182            hci_stack->remote_device_db->delete_link_key(&addr);
    21832183        }
     
    21862186    if (IS_COMMAND(packet, hci_pin_code_request_negative_reply)
    21872187    ||  IS_COMMAND(packet, hci_pin_code_request_reply)){
    2188         bt_flip_addr(addr, &packet[3]);
     2188        reverse_bd_addr(&packet[3], addr);
    21892189        conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC);
    21902190        if (conn){
     
    21972197    ||  IS_COMMAND(packet, hci_user_passkey_request_negative_reply)
    21982198    ||  IS_COMMAND(packet, hci_user_passkey_request_reply)) {
    2199         bt_flip_addr(addr, &packet[3]);
     2199        reverse_bd_addr(&packet[3], addr);
    22002200        conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC);
    22012201        if (conn){
     
    22092209    }
    22102210    if (IS_COMMAND(packet, hci_le_set_random_address)){
    2211         bt_flip_addr(hci_stack->adv_address, &packet[3]);
     2211        reverse_bd_addr(&packet[3], hci_stack->adv_address);
    22122212    }
    22132213#endif
     
    23032303    event[1] = sizeof(event) - 2;
    23042304    event[2] = status;
    2305     bt_store_16(event, 3, conn->con_handle);
    2306     bt_flip_addr(&event[5], conn->address);
     2305    little_endian_store_16(event, 3, conn->con_handle);
     2306    reverse_bd_addr(conn->address, &event[5]);
    23072307    event[11] = 1; // ACL connection
    23082308    event[12] = 0; // encryption disabled
     
    23172317    event[2] = HCI_SUBEVENT_LE_CONNECTION_COMPLETE;
    23182318    event[3] = status;
    2319     bt_store_16(event, 4, conn_handle);
     2319    little_endian_store_16(event, 4, conn_handle);
    23202320    event[6] = 0; // TODO: role
    23212321    event[7] = address_type;
    2322     bt_flip_addr(&event[8], *address);
    2323     bt_store_16(event, 14, 0); // interval
    2324     bt_store_16(event, 16, 0); // latency
    2325     bt_store_16(event, 18, 0); // supervision timeout
     2322    reverse_bd_addr(*address, &event[8]);
     2323    little_endian_store_16(event, 14, 0); // interval
     2324    little_endian_store_16(event, 16, 0); // latency
     2325    little_endian_store_16(event, 18, 0); // supervision timeout
    23262326    event[20] = 0; // master clock accuracy
    23272327    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    23342334    event[1] = sizeof(event) - 2;
    23352335    event[2] = 0; // status = OK
    2336     bt_store_16(event, 3, handle);
     2336    little_endian_store_16(event, 3, handle);
    23372337    event[5] = reason;
    23382338    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    23462346    event[0] = L2CAP_EVENT_TIMEOUT_CHECK;
    23472347    event[1] = sizeof(event) - 2;
    2348     bt_store_16(event, 2, conn->con_handle);
     2348    little_endian_store_16(event, 2, conn->con_handle);
    23492349    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    23502350    hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
     
    23782378    event[2] = BTSTACK_MAJOR;
    23792379    event[3] = BTSTACK_MINOR;
    2380     bt_store_16(event, 4, BTSTACK_REVISION);
     2380    little_endian_store_16(event, 4, BTSTACK_REVISION);
    23812381    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    23822382    hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
     
    23992399    event[1] = sizeof(event) - 2 - 1;
    24002400    event[2] = 0;   // just to be compatible with HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE
    2401     bt_flip_addr(&event[3], *addr);
     2401    reverse_bd_addr(*addr, &event[3]);
    24022402    memcpy(&event[9], name, 248);
    24032403
     
    24262426    event[pos++] = GAP_SECURITY_LEVEL;
    24272427    event[pos++] = sizeof(event) - 2;
    2428     bt_store_16(event, 2, con_handle);
     2428    little_endian_store_16(event, 2, con_handle);
    24292429    pos += 2;
    24302430    event[pos++] = level;
     
    24412441    event[pos++] = sizeof(event) - 2;
    24422442    event[pos++] = status;
    2443     bt_flip_addr( * (bd_addr_t *) &event[pos], address);
     2443    reverse_bd_addr(address,  * (bd_addr_t *) &event[pos]);
    24442444    pos += 6;
    24452445    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
  • asp3_tinet_ecnl_rx/trunk/btstack/src/hci.h

    r337 r374  
    234234
    235235//
    236 #define IS_COMMAND(packet, command) (READ_BT_16(packet,0) == command.opcode)
     236#define IS_COMMAND(packet, command) (little_endian_read_16(packet,0) == command.opcode)
    237237
    238238// data: event(8)
     
    595595
    596596// Allows to control if device is discoverable. OFF by default.
    597 void hci_discoverable_control(uint8_t enable);
     597void gap_discoverable_control(uint8_t enable);
    598598
    599599// Creates and sends HCI command packets based on a template and
  • asp3_tinet_ecnl_rx/trunk/btstack/src/hci_dump.c

    r337 r374  
    194194
    195195        case HCI_DUMP_BLUEZ:
    196             bt_store_16( (uint8_t *) &header_bluez.len, 0, 1 + len);
     196            little_endian_store_16( (uint8_t *) &header_bluez.len, 0, 1 + len);
    197197            header_bluez.in  = in;
    198198            header_bluez.pad = 0;
    199             bt_store_32( (uint8_t *) &header_bluez.ts_sec,  0, curr_time.tv_sec);
    200             bt_store_32( (uint8_t *) &header_bluez.ts_usec, 0, curr_time.tv_usec);
     199            little_endian_store_32( (uint8_t *) &header_bluez.ts_sec,  0, curr_time.tv_sec);
     200            little_endian_store_32( (uint8_t *) &header_bluez.ts_usec, 0, curr_time.tv_usec);
    201201            header_bluez.packet_type = packet_type;
    202202            write (dump_file, &header_bluez, sizeof(hcidump_hdr) );
  • asp3_tinet_ecnl_rx/trunk/btstack/src/l2cap.c

    r337 r374  
    135135    event[1] = sizeof(event) - 2;
    136136    event[2] = status;
    137     bt_flip_addr(&event[3], channel->address);
    138     bt_store_16(event,  9, channel->handle);
    139     bt_store_16(event, 11, channel->psm);
    140     bt_store_16(event, 13, channel->local_cid);
    141     bt_store_16(event, 15, channel->remote_cid);
    142     bt_store_16(event, 17, channel->local_mtu);
    143     bt_store_16(event, 19, channel->remote_mtu);
    144     bt_store_16(event, 21, channel->flush_timeout);
     137    reverse_bd_addr(channel->address, &event[3]);
     138    little_endian_store_16(event,  9, channel->handle);
     139    little_endian_store_16(event, 11, channel->psm);
     140    little_endian_store_16(event, 13, channel->local_cid);
     141    little_endian_store_16(event, 15, channel->remote_cid);
     142    little_endian_store_16(event, 17, channel->local_mtu);
     143    little_endian_store_16(event, 19, channel->remote_mtu);
     144    little_endian_store_16(event, 21, channel->flush_timeout);
    145145    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    146146    l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event));
     
    152152    event[0] = L2CAP_EVENT_CHANNEL_CLOSED;
    153153    event[1] = sizeof(event) - 2;
    154     bt_store_16(event, 2, channel->local_cid);
     154    little_endian_store_16(event, 2, channel->local_cid);
    155155    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    156156    l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event));
     
    163163    event[0] = L2CAP_EVENT_INCOMING_CONNECTION;
    164164    event[1] = sizeof(event) - 2;
    165     bt_flip_addr(&event[2], channel->address);
    166     bt_store_16(event,  8, channel->handle);
    167     bt_store_16(event, 10, channel->psm);
    168     bt_store_16(event, 12, channel->local_cid);
    169     bt_store_16(event, 14, channel->remote_cid);
     165    reverse_bd_addr(channel->address, &event[2]);
     166    little_endian_store_16(event,  8, channel->handle);
     167    little_endian_store_16(event, 10, channel->psm);
     168    little_endian_store_16(event, 12, channel->local_cid);
     169    little_endian_store_16(event, 14, channel->remote_cid);
    170170    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    171171    l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event));
     
    176176    event[0] = L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_RESPONSE;
    177177    event[1] = 4;
    178     bt_store_16(event, 2, handle);
    179     bt_store_16(event, 4, result);
     178    little_endian_store_16(event, 2, handle);
     179    little_endian_store_16(event, 4, result);
    180180    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    181181    (*packet_handler)(NULL, HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    188188    event[1] = sizeof(event) - 2;
    189189    event[2] = status;
    190     bt_store_16(event, 3, psm);
     190    little_endian_store_16(event, 3, psm);
    191191    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
    192192    (*packet_handler)(connection, HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    201201    event[0] = L2CAP_EVENT_CREDITS;
    202202    event[1] = sizeof(event) - 2;
    203     bt_store_16(event, 2, channel->local_cid);
     203    little_endian_store_16(event, 2, channel->local_cid);
    204204    event[4] = credits;
    205205    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    412412
    413413    // 0 - Connection handle : PB=pb : BC=00
    414     bt_store_16(acl_buffer, 0, channel->handle | (pb << 12) | (0 << 14));
     414    little_endian_store_16(acl_buffer, 0, channel->handle | (pb << 12) | (0 << 14));
    415415    // 2 - ACL length
    416     bt_store_16(acl_buffer, 2,  len + 4);
     416    little_endian_store_16(acl_buffer, 2,  len + 4);
    417417    // 4 - L2CAP packet length
    418     bt_store_16(acl_buffer, 4,  len + 0);
     418    little_endian_store_16(acl_buffer, 4,  len + 0);
    419419    // 6 - L2CAP channel DEST
    420     bt_store_16(acl_buffer, 6, channel->remote_cid);
     420    little_endian_store_16(acl_buffer, 6, channel->remote_cid);
    421421    // send
    422422    err = hci_send_acl_packet_buffer(len+8);
     
    449449
    450450    // 0 - Connection handle : PB=pb : BC=00
    451     bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
     451    little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
    452452    // 2 - ACL length
    453     bt_store_16(acl_buffer, 2,  len + 4);
     453    little_endian_store_16(acl_buffer, 2,  len + 4);
    454454    // 4 - L2CAP packet length
    455     bt_store_16(acl_buffer, 4,  len + 0);
     455    little_endian_store_16(acl_buffer, 4,  len + 0);
    456456    // 6 - L2CAP channel DEST
    457     bt_store_16(acl_buffer, 6, cid);
     457    little_endian_store_16(acl_buffer, 6, cid);
    458458    // send
    459459    err = hci_send_acl_packet_buffer(len+8);
     
    665665                        config_options[0] = 1; // MTU
    666666                        config_options[1] = 2; // len param
    667                         bt_store_16( (uint8_t*)&config_options, 2, channel->remote_mtu);
     667                        little_endian_store_16( (uint8_t*)&config_options, 2, channel->remote_mtu);
    668668                        l2cap_send_signaling_packet(channel->handle, CONFIGURE_RESPONSE, channel->remote_sig_id, channel->remote_cid, flags, 0, 4, &config_options);
    669669                        channelStateVarClearFlag(channel,L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU);
     
    679679                    config_options[0] = 1; // MTU
    680680                    config_options[1] = 2; // len param
    681                     bt_store_16( (uint8_t*)&config_options, 2, channel->local_mtu);
     681                    little_endian_store_16( (uint8_t*)&config_options, 2, channel->local_mtu);
    682682                    l2cap_send_signaling_packet(channel->handle, CONFIGURE_REQUEST, channel->local_sig_id, channel->remote_cid, 0, 4, &config_options);
    683683                    l2cap_start_rtx(channel);
     
    893893        // handle connection complete events
    894894        case HCI_EVENT_CONNECTION_COMPLETE:
    895             bt_flip_addr(address, &packet[5]);
     895            reverse_bd_addr(&packet[5], address);
    896896            if (packet[2] == 0){
    897                 handle = READ_BT_16(packet, 3);
     897                handle = little_endian_read_16(packet, 3);
    898898                l2cap_handle_connection_success_for_addr(address, handle);
    899899            } else {
     
    904904        // handle successful create connection cancel command
    905905        case HCI_EVENT_COMMAND_COMPLETE:
    906             if ( COMMAND_COMPLETE_EVENT(packet, hci_create_connection_cancel) ) {
     906            if ( HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_create_connection_cancel) ) {
    907907                if (packet[5] == 0){
    908                     bt_flip_addr(address, &packet[6]);
     908                    reverse_bd_addr(&packet[6], address);
    909909                    // CONNECTION TERMINATED BY LOCAL HOST (0X16)
    910910                    l2cap_handle_connection_failed_for_addr(address, 0x16);
     
    921921        case HCI_EVENT_DISCONNECTION_COMPLETE:
    922922            // send l2cap disconnect events for all channels on this handle and free them
    923             handle = READ_BT_16(packet, 3);
     923            handle = little_endian_read_16(packet, 3);
    924924            linked_list_iterator_init(&it, &l2cap_channels);
    925925            while (linked_list_iterator_has_next(&it)){
     
    940940        // HCI Connection Timeouts
    941941        case L2CAP_EVENT_TIMEOUT_CHECK:
    942             handle = READ_BT_16(packet, 2);
     942            handle = little_endian_read_16(packet, 2);
    943943            if (hci_authentication_active_for_handle(handle)) break;
    944944            hci_con_used = 0;
     
    971971
    972972        case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE:
    973             handle = READ_BT_16(packet, 3);
     973            handle = little_endian_read_16(packet, 3);
    974974            linked_list_iterator_init(&it, &l2cap_channels);
    975975            while (linked_list_iterator_has_next(&it)){
     
    982982
    983983        case GAP_SECURITY_LEVEL:
    984             handle = READ_BT_16(packet, 2);
     984            handle = little_endian_read_16(packet, 2);
    985985            log_info("l2cap - security level update");
    986986            linked_list_iterator_init(&it, &l2cap_channels);
     
    11631163    channel->remote_sig_id = command[L2CAP_SIGNALING_COMMAND_SIGID_OFFSET];
    11641164
    1165     flags = READ_BT_16(command, 6);
     1165    flags = little_endian_read_16(command, 6);
    11661166    if (flags & 1) {
    11671167        channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_CONT);
     
    11691169
    11701170    // accept the other's configuration options
    1171     end_pos = 4 + READ_BT_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);
     1171    end_pos = 4 + little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);
    11721172    pos     = 8;
    11731173    while (pos < end_pos){
     
    11801180        // MTU { type(8): 1, len(8):2, MTU(16) }
    11811181        if (option_type == 1 && length == 2){
    1182             channel->remote_mtu = READ_BT_16(command, pos);
     1182            channel->remote_mtu = little_endian_read_16(command, pos);
    11831183            // log_info("l2cap cid 0x%02x, remote mtu %u", channel->local_cid, channel->remote_mtu);
    11841184            channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU);
     
    11861186        // Flush timeout { type(8):2, len(8): 2, Flush Timeout(16)}
    11871187        if (option_type == 2 && length == 2){
    1188             channel->flush_timeout = READ_BT_16(command, pos);
     1188            channel->flush_timeout = little_endian_read_16(command, pos);
    11891189        }
    11901190        // check for unknown options
     
    12371237                case CONNECTION_RESPONSE:
    12381238                    l2cap_stop_rtx(channel);
    1239                     result = READ_BT_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);
     1239                    result = little_endian_read_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);
    12401240                    switch (result) {
    12411241                        case 0:
    12421242                            // successful connection
    1243                             channel->remote_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
     1243                            channel->remote_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
    12441244                            channel->state = L2CAP_STATE_CONFIG;
    12451245                            channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_REQ);
     
    12741274
    12751275        case L2CAP_STATE_CONFIG:
    1276             result = READ_BT_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);
     1276            result = little_endian_read_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);
    12771277            switch (code) {
    12781278                case CONFIGURE_REQUEST:
     
    13531353
    13541354        case CONNECTION_REQUEST: {
    1355             uint16_t psm =        READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
    1356             uint16_t source_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+2);
     1355            uint16_t psm =        little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
     1356            uint16_t source_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+2);
    13571357            l2cap_handle_connection_request(handle, sig_id, psm, source_cid);
    13581358            return;
     
    13641364
    13651365        case INFORMATION_REQUEST: {
    1366             uint16_t infoType = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
     1366            uint16_t infoType = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
    13671367            l2cap_register_signaling_response(handle, code, sig_id, infoType);
    13681368            return;
     
    13751375   
    13761376    // Get potential destination CID
    1377     dest_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
     1377    dest_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);
    13781378
    13791379    // Find channel for this sig_id and connection handle
     
    14151415
    14161416                // increment command_offset
    1417                 command_offset += L2CAP_SIGNALING_COMMAND_DATA_OFFSET + READ_BT_16(packet, command_offset + L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);
     1417                command_offset += L2CAP_SIGNALING_COMMAND_DATA_OFFSET + little_endian_read_16(packet, command_offset + L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);
    14181418            }
    14191419            break;
     
    14351435            switch (packet[8]){
    14361436                case CONNECTION_PARAMETER_UPDATE_RESPONSE: {
    1437                     uint16_t result = READ_BT_16(packet, 12);
     1437                    uint16_t result = little_endian_read_16(packet, 12);
    14381438                    l2cap_emit_connection_parameter_update_response(handle, result);
    14391439                    break;
     
    14501450                        int update_parameter = 1;
    14511451                        le_connection_parameter_range_t existing_range = gap_le_get_connection_parameter_range();
    1452                         uint16_t le_conn_interval_min = READ_BT_16(packet,12);
    1453                         uint16_t le_conn_interval_max = READ_BT_16(packet,14);
    1454                         uint16_t le_conn_latency = READ_BT_16(packet,16);
    1455                         uint16_t le_supervision_timeout = READ_BT_16(packet,18);
     1452                        uint16_t le_conn_interval_min = little_endian_read_16(packet,12);
     1453                        uint16_t le_conn_interval_max = little_endian_read_16(packet,14);
     1454                        uint16_t le_conn_latency = little_endian_read_16(packet,16);
     1455                        uint16_t le_supervision_timeout = little_endian_read_16(packet,18);
    14561456
    14571457                        if (le_conn_interval_min < existing_range.le_conn_interval_min) update_parameter = 0;
  • asp3_tinet_ecnl_rx/trunk/btstack/src/l2cap_signaling.c

    r337 r374  
    9191
    9292    // 0 - Connection handle : PB=pb : BC=00
    93     bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
     93    little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
    9494    // 6 - L2CAP channel = 1
    95     bt_store_16(acl_buffer, 6, cid);
     95    little_endian_store_16(acl_buffer, 6, cid);
    9696    // 8 - Code
    9797    acl_buffer[8] = cmd;
     
    134134
    135135    // 2 - ACL length
    136     bt_store_16(acl_buffer, 2,  pos - 4);
     136    little_endian_store_16(acl_buffer, 2,  pos - 4);
    137137    // 4 - L2CAP packet length
    138     bt_store_16(acl_buffer, 4,  pos - 6 - 2);
     138    little_endian_store_16(acl_buffer, 4,  pos - 6 - 2);
    139139    // 10 - L2CAP signaling parameter length
    140     bt_store_16(acl_buffer, 10, pos - 12);
     140    little_endian_store_16(acl_buffer, 10, pos - 12);
    141141
    142142    return pos;
     
    158158
    159159    // 0 - Connection handle : PB=pb : BC=00
    160     bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
     160    little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
    161161    // 6 - L2CAP LE Signaling channel = 5
    162     bt_store_16(acl_buffer, 6, 5);
     162    little_endian_store_16(acl_buffer, 6, 5);
    163163    // 8 - Code
    164164    acl_buffer[8] = CONNECTION_PARAMETER_UPDATE_REQUEST;
     
    166166    acl_buffer[9] = 1;
    167167    uint16_t pos = 12;
    168     bt_store_16(acl_buffer, pos, interval_min);
    169     pos += 2;
    170     bt_store_16(acl_buffer, pos, interval_max);
    171     pos += 2;
    172     bt_store_16(acl_buffer, pos, slave_latency);
    173     pos += 2;
    174     bt_store_16(acl_buffer, pos, timeout_multiplier);
     168    little_endian_store_16(acl_buffer, pos, interval_min);
     169    pos += 2;
     170    little_endian_store_16(acl_buffer, pos, interval_max);
     171    pos += 2;
     172    little_endian_store_16(acl_buffer, pos, slave_latency);
     173    pos += 2;
     174    little_endian_store_16(acl_buffer, pos, timeout_multiplier);
    175175    pos += 2;
    176176    // 2 - ACL length
    177     bt_store_16(acl_buffer, 2,  pos - 4);
     177    little_endian_store_16(acl_buffer, 2,  pos - 4);
    178178    // 4 - L2CAP packet length
    179     bt_store_16(acl_buffer, 4,  pos - 6 - 2);
     179    little_endian_store_16(acl_buffer, 4,  pos - 6 - 2);
    180180    // 10 - L2CAP signaling parameter length
    181     bt_store_16(acl_buffer, 10, pos - 12);
     181    little_endian_store_16(acl_buffer, 10, pos - 12);
    182182    return pos;
    183183}
     
    188188
    189189    // 0 - Connection handle : PB=pb : BC=00
    190     bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
     190    little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));
    191191    // 6 - L2CAP LE Signaling channel = 5
    192     bt_store_16(acl_buffer, 6, 5);
     192    little_endian_store_16(acl_buffer, 6, 5);
    193193    // 8 - Code
    194194    acl_buffer[8] = CONNECTION_PARAMETER_UPDATE_REQUEST;
     
    196196    acl_buffer[9] = 1;
    197197    uint16_t pos = 12;
    198     bt_store_16(acl_buffer, pos, response);
     198    little_endian_store_16(acl_buffer, pos, response);
    199199    pos += 2;
    200200    // 2 - ACL length
    201     bt_store_16(acl_buffer, 2,  pos - 4);
     201    little_endian_store_16(acl_buffer, 2,  pos - 4);
    202202    // 4 - L2CAP packet length
    203     bt_store_16(acl_buffer, 4,  pos - 6 - 2);
     203    little_endian_store_16(acl_buffer, 4,  pos - 6 - 2);
    204204    // 10 - L2CAP signaling parameter length
    205     bt_store_16(acl_buffer, 10, pos - 12);
     205    little_endian_store_16(acl_buffer, 10, pos - 12);
    206206    return pos;
    207207}
  • asp3_tinet_ecnl_rx/trunk/btstack/src/pan.c

    r337 r374  
    8080
    8181        // 0x0001 "Service Class ID List"
    82         de_add_number(service,  DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
     82        de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
    8383        attribute = de_push_sequence(service);
    8484        {
     
    8989
    9090        // 0x0004 "Protocol Descriptor List"
    91         de_add_number(service,  DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
     91        de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
    9292        attribute = de_push_sequence(service);
    9393        {
     
    9595                {
    9696                        de_add_number(l2cpProtocol,  DE_UUID, DE_SIZE_16, 0x0100);
    97                         de_add_number(l2cpProtocol,  DE_UINT, DE_SIZE_16, SDP_BNEPProtocol);  // l2cap psm
     97                        de_add_number(l2cpProtocol,  DE_UINT, DE_SIZE_16, BLUETOOTH_PROTOCOL_BNEP);  // l2cap psm
    9898                }
    9999                de_pop_sequence(attribute, l2cpProtocol);
  • asp3_tinet_ecnl_rx/trunk/btstack/src/rfcomm.c

    r337 r374  
    136136    event[0] = RFCOMM_EVENT_INCOMING_CONNECTION;
    137137    event[1] = sizeof(event) - 2;
    138     bt_flip_addr(&event[2], channel->multiplexer->remote_addr);
     138    reverse_bd_addr(channel->multiplexer->remote_addr, &event[2]);
    139139    event[8] = channel->dlci >> 1;
    140     bt_store_16(event, 9, channel->rfcomm_cid);
     140    little_endian_store_16(event, 9, channel->rfcomm_cid);
    141141    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    142142        (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
     
    157157    event[pos++] = sizeof(event) - 2;
    158158    event[pos++] = status;
    159     bt_flip_addr(&event[pos], channel->multiplexer->remote_addr); pos += 6;
    160     bt_store_16(event,  pos, channel->multiplexer->con_handle);   pos += 2;
     159    reverse_bd_addr(channel->multiplexer->remote_addr, &event[pos]); pos += 6;
     160    little_endian_store_16(event,  pos, channel->multiplexer->con_handle);   pos += 2;
    161161        event[pos++] = channel->dlci >> 1;
    162         bt_store_16(event, pos, channel->rfcomm_cid); pos += 2;       // channel ID
    163         bt_store_16(event, pos, channel->max_frame_size); pos += 2;   // max frame size
     162        little_endian_store_16(event, pos, channel->rfcomm_cid); pos += 2;       // channel ID
     163        little_endian_store_16(event, pos, channel->max_frame_size); pos += 2;   // max frame size
    164164    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    165165        (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, pos);
     
    175175    event[pos++] = sizeof(event) - 2;
    176176    event[pos++] = BTSTACK_MEMORY_ALLOC_FAILED;
    177     bt_flip_addr(&event[pos], *addr); pos += 6;
    178     bt_store_16(event,  pos, 0);   pos += 2;
     177    reverse_bd_addr(*addr, &event[pos]); pos += 6;
     178    little_endian_store_16(event,  pos, 0);   pos += 2;
    179179        event[pos++] = server_channel;
    180         bt_store_16(event, pos, 0); pos += 2;   // channel ID
    181         bt_store_16(event, pos, 0); pos += 2;   // max frame size
     180        little_endian_store_16(event, pos, 0); pos += 2;   // channel ID
     181        little_endian_store_16(event, pos, 0); pos += 2;   // max frame size
    182182    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    183183        (*app_packet_handler)(connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, pos);
     
    204204    event[0] = RFCOMM_EVENT_CHANNEL_CLOSED;
    205205    event[1] = sizeof(event) - 2;
    206     bt_store_16(event, 2, channel->rfcomm_cid);
     206    little_endian_store_16(event, 2, channel->rfcomm_cid);
    207207    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    208208        (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
     
    214214    event[0] = RFCOMM_EVENT_CREDITS;
    215215    event[1] = sizeof(event) - 2;
    216     bt_store_16(event, 2, channel->rfcomm_cid);
     216    little_endian_store_16(event, 2, channel->rfcomm_cid);
    217217    event[4] = credits;
    218218    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    237237    event[0] = RFCOMM_EVENT_REMOTE_LINE_STATUS;
    238238    event[1] = sizeof(event) - 2;
    239     bt_store_16(event, 2, channel->rfcomm_cid);
     239    little_endian_store_16(event, 2, channel->rfcomm_cid);
    240240    event[4] = line_status;
    241241    hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
     
    905905        case L2CAP_EVENT_INCOMING_CONNECTION:
    906906            // data: event(8), len(8), address(48), handle (16),  psm (16), source cid(16) dest cid(16)
    907             bt_flip_addr(event_addr, &packet[2]);
    908             con_handle = READ_BT_16(packet,  8);
    909             psm        = READ_BT_16(packet, 10);
    910             l2cap_cid  = READ_BT_16(packet, 12);
     907            reverse_bd_addr(&packet[2], event_addr);
     908            con_handle = little_endian_read_16(packet,  8);
     909            psm        = little_endian_read_16(packet, 10);
     910            l2cap_cid  = little_endian_read_16(packet, 12);
    911911
    912912            if (psm != PSM_RFCOMM) break;
     
    939939        case L2CAP_EVENT_CHANNEL_OPENED:
    940940
    941             if (READ_BT_16(packet, 11) != PSM_RFCOMM) break;
     941            if (little_endian_read_16(packet, 11) != PSM_RFCOMM) break;
    942942
    943943            status = packet[2];
     
    945945
    946946            // get multiplexer for remote addr
    947             con_handle = READ_BT_16(packet, 9);
    948             l2cap_cid = READ_BT_16(packet, 13);
    949             bt_flip_addr(event_addr, &packet[3]);
     947            con_handle = little_endian_read_16(packet, 9);
     948            l2cap_cid = little_endian_read_16(packet, 13);
     949            reverse_bd_addr(&packet[3], event_addr);
    950950            multiplexer = rfcomm_multiplexer_for_addr(&event_addr);
    951951            if (!multiplexer) {
     
    990990
    991991                // set max frame size based on l2cap MTU
    992                 multiplexer->max_frame_size = rfcomm_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
     992                multiplexer->max_frame_size = rfcomm_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17));
    993993            }
    994994            return 1;
     
    998998        case L2CAP_EVENT_CREDITS:
    999999            // data: event(8), len(8), local_cid(16), credits(8)
    1000             l2cap_cid = READ_BT_16(packet, 2);
     1000            l2cap_cid = little_endian_read_16(packet, 2);
    10011001            multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid);
    10021002            if (!multiplexer) break;
     
    10191019        case L2CAP_EVENT_CHANNEL_CLOSED:
    10201020            // data: event (8), len(8), channel (16)
    1021             l2cap_cid = READ_BT_16(packet, 2);
     1021            l2cap_cid = little_endian_read_16(packet, 2);
    10221022            multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid);
    10231023            log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, mult %p", l2cap_cid, multiplexer);
     
    14781478                    event_pn.super.type = CH_EVT_RCVD_PN;
    14791479                    event_pn.priority = packet[payload_offset+4];
    1480                     event_pn.max_frame_size = READ_BT_16(packet, payload_offset+6);
     1480                    event_pn.max_frame_size = little_endian_read_16(packet, payload_offset+6);
    14811481                    event_pn.credits_outgoing = packet[payload_offset+9];
    14821482                    log_info("Received UIH Parameter Negotiation Command for #%u, credits %u",
     
    14891489                    event_pn.super.type = CH_EVT_RCVD_PN_RSP;
    14901490                    event_pn.priority = packet[payload_offset+4];
    1491                     event_pn.max_frame_size = READ_BT_16(packet, payload_offset+6);
     1491                    event_pn.max_frame_size = little_endian_read_16(packet, payload_offset+6);
    14921492                    event_pn.credits_outgoing = packet[payload_offset+9];
    14931493                    log_info("Received UIH Parameter Negotiation Response max frame %u, credits %u",
  • asp3_tinet_ecnl_rx/trunk/btstack/src/sdp.c

    r337 r374  
    9090    if (de_get_element_type(serviceRecordHandleAttribute) != DE_UINT) return 0;
    9191    if (de_get_size_type(serviceRecordHandleAttribute) != DE_SIZE_32) return 0;
    92     return READ_NET_32(serviceRecordHandleAttribute, 1);
     92    return big_endian_read_32(serviceRecordHandleAttribute, 1);
    9393}
    9494
     
    100100    event[1] = sizeof(event) - 2;
    101101    event[2] = status;
    102     bt_store_32(event, 3, handle);
     102    little_endian_store_32(event, 3, handle);
    103103    hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event));
    104104    (*app_packet_handler)(connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
     
    275275
    276276    // get request details
    277     uint16_t  transaction_id = READ_NET_16(packet, 1);
    278     // not used yet - uint16_t  param_len = READ_NET_16(packet, 3);
     277    uint16_t  transaction_id = big_endian_read_16(packet, 1);
     278    // not used yet - uint16_t  param_len = big_endian_read_16(packet, 3);
    279279    uint8_t * serviceSearchPattern = &packet[5];
    280280    uint16_t  serviceSearchPatternLen = de_get_len(serviceSearchPattern);
    281     uint16_t  maximumServiceRecordCount = READ_NET_16(packet, 5 + serviceSearchPatternLen);
     281    uint16_t  maximumServiceRecordCount = big_endian_read_16(packet, 5 + serviceSearchPatternLen);
    282282    uint8_t * continuationState = &packet[5+serviceSearchPatternLen+2];
    283283
     
    297297    continuation_index = 0;
    298298    if (continuationState[0] == 2){
    299         continuation_index = READ_NET_16(continuationState, 1);
     299        continuation_index = big_endian_read_16(continuationState, 1);
    300300    }
    301301
     
    359359
    360360    // get request details
    361     uint16_t  transaction_id = READ_NET_16(packet, 1);
    362     // not used yet - uint16_t  param_len = READ_NET_16(packet, 3);
    363     uint32_t  serviceRecordHandle = READ_NET_32(packet, 5);
    364     uint16_t  maximumAttributeByteCount = READ_NET_16(packet, 9);
     361    uint16_t  transaction_id = big_endian_read_16(packet, 1);
     362    // not used yet - uint16_t  param_len = big_endian_read_16(packet, 3);
     363    uint32_t  serviceRecordHandle = big_endian_read_32(packet, 5);
     364    uint16_t  maximumAttributeByteCount = big_endian_read_16(packet, 9);
    365365    uint8_t * attributeIDList = &packet[11];
    366366    uint16_t  attributeIDListLen = de_get_len(attributeIDList);
     
    383383    continuation_offset = 0;
    384384    if (continuationState[0] == 2){
    385         continuation_offset = READ_NET_16(continuationState, 1);
     385        continuation_offset = big_endian_read_16(continuationState, 1);
    386386    }
    387387
     
    452452
    453453    // get request details
    454     uint16_t  transaction_id = READ_NET_16(packet, 1);
    455     // not used yet - uint16_t  param_len = READ_NET_16(packet, 3);
     454    uint16_t  transaction_id = big_endian_read_16(packet, 1);
     455    // not used yet - uint16_t  param_len = big_endian_read_16(packet, 3);
    456456    uint8_t * serviceSearchPattern = &packet[5];
    457457    uint16_t  serviceSearchPatternLen = de_get_len(serviceSearchPattern);
    458     uint16_t  maximumAttributeByteCount = READ_NET_16(packet, 5 + serviceSearchPatternLen);
     458    uint16_t  maximumAttributeByteCount = big_endian_read_16(packet, 5 + serviceSearchPatternLen);
    459459    uint8_t * attributeIDList = &packet[5+serviceSearchPatternLen+2];
    460460    uint16_t  attributeIDListLen = de_get_len(attributeIDList);
     
    481481    continuation_offset = 0;
    482482    if (continuationState[0] == 4){
    483         continuation_service_index = READ_NET_16(continuationState, 1);
    484         continuation_offset = READ_NET_16(continuationState, 3);
     483        continuation_service_index = big_endian_read_16(continuationState, 1);
     484        continuation_offset = big_endian_read_16(continuationState, 3);
    485485    }
    486486
     
    593593        case L2CAP_DATA_PACKET:
    594594            pdu_id = (SDP_PDU_ID_t) packet[0];
    595             transaction_id = READ_NET_16(packet, 1);
    596             // param_len = READ_NET_16(packet, 3);
     595            transaction_id = big_endian_read_16(packet, 1);
     596            // param_len = big_endian_read_16(packet, 3);
    597597            remote_mtu = l2cap_get_remote_mtu_for_local_cid(channel);
    598598            // account for our buffer
  • asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_client.c

    r337 r374  
    151151static void parse_service_search_attribute_response(uint8_t* packet){
    152152    uint16_t offset = 3;
    153     uint16_t parameterLength = READ_NET_16(packet,offset);
     153    uint16_t parameterLength = big_endian_read_16(packet,offset);
    154154    uint16_t attributeListByteCount;
    155155    offset+=2;
    156156    // AttributeListByteCount <= mtu
    157     attributeListByteCount = READ_NET_16(packet,offset);
     157    attributeListByteCount = big_endian_read_16(packet,offset);
    158158    offset+=2;
    159159
     
    185185    // uint16_t handle;
    186186    if (packet_type == L2CAP_DATA_PACKET){
    187         uint16_t responseTransactionID = READ_NET_16(packet,1);
     187        uint16_t responseTransactionID = big_endian_read_16(packet,1);
    188188        if ( responseTransactionID != transactionID){
    189189            log_error("Missmatching transaction ID, expected %u, found %u.", transactionID, responseTransactionID);
     
    247247            }
    248248            sdp_cid = channel;
    249             mtu = READ_BT_16(packet, 17);
    250             // handle = READ_BT_16(packet, 9);
     249            mtu = little_endian_read_16(packet, 17);
     250            // handle = little_endian_read_16(packet, 9);
    251251            log_info("SDP Client Connected, cid %x, mtu %u.", sdp_cid, mtu);
    252252
     
    261261        case L2CAP_EVENT_CHANNEL_CLOSED: {
    262262            uint8_t status;
    263             if (sdp_cid != READ_BT_16(packet, 2)) {
    264                 // log_info("Received L2CAP_EVENT_CHANNEL_CLOSED for cid %x, current cid %x\n",  READ_BT_16(packet, 2),sdp_cid);
     263            if (sdp_cid != little_endian_read_16(packet, 2)) {
     264                // log_info("Received L2CAP_EVENT_CHANNEL_CLOSED for cid %x, current cid %x\n",  little_endian_read_16(packet, 2),sdp_cid);
    265265                break;
    266266            }
     
    402402static void parse_service_search_response(uint8_t* packet){
    403403    uint16_t offset = 3;
    404     uint16_t parameterLength = READ_NET_16(packet,offset);
     404    uint16_t parameterLength = big_endian_read_16(packet,offset);
    405405    uint16_t totalServiceRecordCount;
    406406    uint16_t currentServiceRecordCount;
    407407    offset+=2;
    408408
    409     totalServiceRecordCount = READ_NET_16(packet,offset);
    410     offset+=2;
    411 
    412     currentServiceRecordCount = READ_NET_16(packet,offset);
     409    totalServiceRecordCount = big_endian_read_16(packet,offset);
     410    offset+=2;
     411
     412    currentServiceRecordCount = big_endian_read_16(packet,offset);
    413413    offset+=2;
    414414    if (currentServiceRecordCount > totalServiceRecordCount){
     
    436436static void parse_service_attribute_response(uint8_t* packet){
    437437    uint16_t offset = 3;
    438     uint16_t parameterLength = READ_NET_16(packet,offset);
     438    uint16_t parameterLength = big_endian_read_16(packet,offset);
    439439        uint16_t attributeListByteCount;
    440440    offset+=2;
    441441
    442442    // AttributeListByteCount <= mtu
    443     attributeListByteCount = READ_NET_16(packet,offset);
     443    attributeListByteCount = big_endian_read_16(packet,offset);
    444444    offset+=2;
    445445
  • asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_parser.c

    r337 r374  
    166166            {
    167167            sdp_query_attribute_value_event_t attribute_value_event = {
    168                 SDP_QUERY_ATTRIBUTE_VALUE,
     168                SDP_EVENT_QUERY_ATTRIBUTE_VALUE,
    169169                record_counter,
    170170                attribute_id,
     
    186186            {
    187187            sdp_query_attribute_value_event_t attribute_value_event = {
    188                 SDP_QUERY_ATTRIBUTE_VALUE,
     188                SDP_EVENT_QUERY_ATTRIBUTE_VALUE,
    189189                record_counter,
    190190                attribute_id,
     
    258258    int i;
    259259    for (i=0;i<record_handle_count;i++){
    260         record_handle = READ_NET_32(data, i*4);
     260        record_handle = big_endian_read_32(data, i*4);
    261261        record_counter++;
    262262                {
     
    275275void sdp_parser_handle_done(uint8_t status){
    276276    sdp_query_complete_event_t complete_event = {
    277         SDP_QUERY_COMPLETE,
     277        SDP_EVENT_QUERY_COMPLETE,
    278278        status
    279279    };
  • asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_query_rfcomm.c

    r337 r374  
    248248    sdp_query_attribute_value_event_t * ve;
    249249    switch (event->type){
    250         case SDP_QUERY_ATTRIBUTE_VALUE:
     250        case SDP_EVENT_QUERY_ATTRIBUTE_VALUE:
    251251            ve = (sdp_query_attribute_value_event_t*) event;
    252252           // log_info("handle_sdp_parser_event [ AID, ALen, DOff, Data] : [%x, %u, %u] BYTE %02x",
     
    254254
    255255            switch (ve->attribute_id){
    256                 case SDP_ProtocolDescriptorList:
     256                case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST:
    257257                    // find rfcomm channel
    258258                    handleProtocolDescriptorListData(ve->attribute_length, ve->data_offset, ve->data);
     
    267267            }
    268268            break;
    269         case SDP_QUERY_COMPLETE:
     269        case SDP_EVENT_QUERY_COMPLETE:
    270270            (*sdp_app_callback)(event, sdp_app_context);
    271271            break;
  • asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_util.c

    r337 r374  
    9898            break;
    9999        case DE_SIZE_VAR_16:
    100             result = READ_NET_16(header,1);
     100            result = big_endian_read_16(header,1);
    101101            break;
    102102        case DE_SIZE_VAR_32:
    103             result = READ_NET_32(header,1);
     103            result = big_endian_read_32(header,1);
    104104            break;
    105105        default:
     
    122122int de_element_get_uint16(uint8_t * element, uint16_t * value){
    123123    if (de_get_size_type(element) != DE_SIZE_16) return 0;
    124     *value = READ_NET_16(element, de_get_header_size(element));
     124    *value = big_endian_read_16(element, de_get_header_size(element));
    125125    return 1;
    126126}
     
    134134    switch (uuidSize){
    135135        case DE_SIZE_16:
    136             shortUUID = READ_NET_16(element, 1);
     136            shortUUID = big_endian_read_16(element, 1);
    137137            break;
    138138        case DE_SIZE_32:
    139             shortUUID = READ_NET_32(element, 1);
     139            shortUUID = big_endian_read_32(element, 1);
    140140            break;
    141141        case DE_SIZE_128:
     
    157157    hasBlueoothBaseUuid = sdp_has_blueooth_base_uuid(uuid128);
    158158    if (!hasBlueoothBaseUuid) return 0;
    159     return READ_NET_32(uuid128, 0);
     159    return big_endian_read_32(uuid128, 0);
    160160}
    161161
     
    199199void de_pop_sequence(uint8_t * parent, uint8_t * child){
    200200    int child_len = de_get_len(child);
    201     int data_size_parent = READ_NET_16(parent,1);
     201    int data_size_parent = big_endian_read_16(parent,1);
    202202    net_store_16(parent, 1, data_size_parent + child_len);
    203203}
     
    205205/* adds a single number value and 16+32 bit UUID to the sequence */
    206206void de_add_number(uint8_t *seq, de_type_t type, de_size_t size, uint32_t value){
    207     int data_size   = READ_NET_16(seq,1);
     207    int data_size   = big_endian_read_16(seq,1);
    208208    int element_size = 1;   // e.g. for DE_TYPE_NIL
    209209    de_store_descriptor(seq+3+data_size, type, size);
     
    231231/* add a single block of data, e.g. as DE_STRING, DE_URL */
    232232void de_add_data( uint8_t *seq, de_type_t type, uint16_t size, uint8_t *data){
    233     int data_size   = READ_NET_16(seq,1);
     233    int data_size   = big_endian_read_16(seq,1);
    234234    if (size > 0xff) {
    235235        // use 16-bit lengh information (3 byte header)
     
    247247
    248248void de_add_uuid128(uint8_t * seq, uint8_t * uuid){
    249     int data_size   = READ_NET_16(seq,1);
     249    int data_size   = big_endian_read_16(seq,1);
    250250    de_store_descriptor(seq+3+data_size, DE_UUID, DE_SIZE_128);
    251251    memcpy( seq + 4 + data_size, uuid, 16);
     
    326326        uint8_t done;
    327327        if (idType != DE_UINT || idSize != DE_SIZE_16) break; // wrong type
    328         attribute_id = READ_NET_16(element, pos + 1);
     328        attribute_id = big_endian_read_16(element, pos + 1);
    329329        pos += 3;
    330330        if (pos >= end_pos) break; // array out of bounds
     
    349349    switch (size) {
    350350        case DE_SIZE_16:
    351             if (READ_NET_16(element, 1) == context->attributeID) {
     351            if (big_endian_read_16(element, 1) == context->attributeID) {
    352352                context->result = 1;
    353353                return 1;
     
    355355            break;
    356356        case DE_SIZE_32:
    357             if (READ_NET_16(element, 1) <= context->attributeID
    358             &&  context->attributeID <= READ_NET_16(element, 3)) {
     357            if (big_endian_read_16(element, 1) <= context->attributeID
     358            &&  context->attributeID <= big_endian_read_16(element, 3)) {
    359359                context->result = 1;
    360360                return 1;
     
    388388    if (sdp_attribute_list_constains_id(context->attributeIDList, attributeID)) {
    389389        // DES_HEADER(3) + DES_DATA + (UINT16(3) + attribute)
    390         uint16_t data_size = READ_NET_16(context->buffer, 1);
     390        uint16_t data_size = big_endian_read_16(context->buffer, 1);
    391391        int attribute_len = de_get_len(attributeValue);
    392392        if (3 + data_size + (3 + attribute_len) <= context->maxBytes) {
     
    662662                break;
    663663            case DE_SIZE_VAR_16:
    664                 len = READ_NET_16(element, 1);
     664                len = big_endian_read_16(element, 1);
    665665                break;
    666666            default:
     
    678678                break;
    679679            case DE_SIZE_16:
    680                                 value = READ_NET_16(element,pos);
     680                                value = big_endian_read_16(element,pos);
    681681                break;
    682682            case DE_SIZE_32:
    683                                 value = READ_NET_32(element,pos);
     683                                value = big_endian_read_32(element,pos);
    684684                break;
    685685            default:
     
    712712
    713713        // 0x0001 "Service Class ID List"
    714         de_add_number(service,  DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);
     714        de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST);
    715715        attribute = de_push_sequence(service);
    716716        {
     
    720720
    721721        // 0x0004 "Protocol Descriptor List"
    722         de_add_number(service,  DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);
     722        de_add_number(service,  DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST);
    723723        attribute = de_push_sequence(service);
    724724        {
  • asp3_tinet_ecnl_rx/trunk/btstack/src/utils.c

    r337 r374  
    4949#include "debug.h"
    5050
    51 void bt_store_16(uint8_t *buffer, uint16_t pos, uint16_t value){
     51void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value){
    5252    buffer[pos++] = value;
    5353    buffer[pos++] = value >> 8;
    5454}
    5555
    56 void bt_store_32(uint8_t *buffer, uint16_t pos, uint32_t value){
     56void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value){
    5757    buffer[pos++] = value;
    5858    buffer[pos++] = value >> 8;
     
    7373}
    7474
    75 void bt_flip_addr(bd_addr_t dest, bd_addr_t src){
     75void reverse_bd_addr(bd_addr_t src, bd_addr_t dest){
    7676    dest[0] = src[5];
    7777    dest[1] = src[4];
  • asp3_tinet_ecnl_rx/trunk/curl-7.57.0/lib/security.c

    r337 r374  
    88 * below.
    99 *
    10  * Copyright (c) 1998, 1999, 2017 Kungliga Tekniska Hgskolan
     10 * Copyright (c) 1998, 1999, 2017 Kungliga Tekniska Hogskolan
    1111 * (Royal Institute of Technology, Stockholm, Sweden).
    1212 *
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/include/bits/alltypes.h

    r364 r374  
    2323#define open musl_open
    2424#define perror musl_perror
     25#define printf musl_printf
    2526#define read musl_read
    2627#define realloc musl_realloc
     
    3132#define tzset musl_tzset
    3233#define unlink musl_unlink
     34#define strncmp musl_strncmp
     35#define strtol musl_strtol
     36#define strchr musl_strchr
    3337#endif
    3438#ifdef _MSC_VER
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/process/vfork.c

    r337 r374  
    1515}
    1616
     17#ifndef __c2__
    1718weak_alias(__vfork, vfork);
     19#else
     20pid_t vfork(void)
     21{
     22        return __vfork();
     23}
     24#endif
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/signal/sigaction.c

    r337 r374  
    6161}
    6262
     63#ifndef __c2__
    6364weak_alias(__sigaction, sigaction);
     65#else
     66int sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
     67{
     68        return __sigaction(sig, sa, old);
     69}
     70#endif
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdlib/strtol.c

    r364 r374  
    5757}
    5858
    59 weak_alias(strtol, __strtol_internal);
    6059#if defined(_MSC_VER) || defined(__c2__)
     60weak_alias(musl_strtol, __strtol_internal);
    6161weak_alias(musl_strtoul, __strtoul_internal);
    6262#else
     63weak_alias(strtol, __strtol_internal);
    6364weak_alias(strtoul, __strtoul_internal);
    6465#endif
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/memrchr.c

    r337 r374  
    1010}
    1111
     12#ifndef __c2__
    1213weak_alias(__memrchr, memrchr);
     14#else
     15void *memrchr(const void *m, int c, size_t n)
     16{
     17        return __memrchr(m, c, n);
     18}
     19#endif
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/strchrnul.c

    r337 r374  
    2424}
    2525
     26#ifndef __c2__
    2627weak_alias(__strchrnul, strchrnul);
     28#else
     29char *strchrnul(const char *s, int c)
     30{
     31        return __strchrnul(s, c);
     32}
     33#endif
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ccsbcs.c

    r337 r374  
    2525
    2626
    27 #if _CODE_PAGE == 437
     27#if FF_CODE_PAGE == 437
    2828#define _TBLDEF 1
    2929static
     
    3939};
    4040
    41 #elif _CODE_PAGE == 720
     41#elif FF_CODE_PAGE == 720
    4242#define _TBLDEF 1
    4343static
     
    5353};
    5454
    55 #elif _CODE_PAGE == 737
     55#elif FF_CODE_PAGE == 737
    5656#define _TBLDEF 1
    5757static
     
    6767};
    6868
    69 #elif _CODE_PAGE == 771
     69#elif FF_CODE_PAGE == 771
    7070#define _TBLDEF 1
    7171static
     
    8181};
    8282
    83 #elif _CODE_PAGE == 775
     83#elif FF_CODE_PAGE == 775
    8484#define _TBLDEF 1
    8585static
     
    9595};
    9696
    97 #elif _CODE_PAGE == 850
     97#elif FF_CODE_PAGE == 850
    9898#define _TBLDEF 1
    9999static
     
    109109};
    110110
    111 #elif _CODE_PAGE == 852
     111#elif FF_CODE_PAGE == 852
    112112#define _TBLDEF 1
    113113static
     
    123123};
    124124
    125 #elif _CODE_PAGE == 855
     125#elif FF_CODE_PAGE == 855
    126126#define _TBLDEF 1
    127127static
     
    137137};
    138138
    139 #elif _CODE_PAGE == 857
     139#elif FF_CODE_PAGE == 857
    140140#define _TBLDEF 1
    141141static
     
    151151};
    152152
    153 #elif _CODE_PAGE == 860
     153#elif FF_CODE_PAGE == 860
    154154#define _TBLDEF 1
    155155static
     
    165165};
    166166
    167 #elif _CODE_PAGE == 861
     167#elif FF_CODE_PAGE == 861
    168168#define _TBLDEF 1
    169169static
     
    179179};
    180180
    181 #elif _CODE_PAGE == 862
     181#elif FF_CODE_PAGE == 862
    182182#define _TBLDEF 1
    183183static
     
    193193};
    194194
    195 #elif _CODE_PAGE == 863
     195#elif FF_CODE_PAGE == 863
    196196#define _TBLDEF 1
    197197static
     
    207207};
    208208
    209 #elif _CODE_PAGE == 864
     209#elif FF_CODE_PAGE == 864
    210210#define _TBLDEF 1
    211211static
     
    221221};
    222222
    223 #elif _CODE_PAGE == 865
     223#elif FF_CODE_PAGE == 865
    224224#define _TBLDEF 1
    225225static
     
    235235};
    236236
    237 #elif _CODE_PAGE == 866
     237#elif FF_CODE_PAGE == 866
    238238#define _TBLDEF 1
    239239static
     
    249249};
    250250
    251 #elif _CODE_PAGE == 869
     251#elif FF_CODE_PAGE == 869
    252252#define _TBLDEF 1
    253253static
     
    266266
    267267
    268 #if _CODE_PAGE != 65001 && (!_TBLDEF || !_USE_LFN)
     268#if FF_CODE_PAGE != 65001 && (!_TBLDEF || !FF_USE_LFN)
    269269#error This file is not needed at current configuration. Remove from the project.
    270270#endif
     
    272272
    273273
    274 #if _CODE_PAGE != 65001
     274#if FF_CODE_PAGE != 65001
    275275WCHAR ff_convert (      /* Converted character, Returns zero on error */
    276276        WCHAR   chr,    /* Character code to be converted */
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/diskio.c

    r337 r374  
    3434int get_status(volatile RD_STAT *stat) {
    3535        stat->sz_sector = SS_RAMDISK;
    36         if(stat->sz_sector < _MIN_SS || stat->sz_sector > _MAX_SS) return 0;
     36        if(stat->sz_sector < FF_MIN_SS || stat->sz_sector > FF_MAX_SS) return 0;
    3737        stat->n_sectors = SZ_RAMDISK * 1024 / SS_RAMDISK;
    3838        stat->status = 0;
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/diskio.h

    r337 r374  
    6060
    6161/* Generic command (Used by FatFs) */
    62 #define CTRL_SYNC                       0       /* Complete pending write process (needed at _FS_READONLY == 0) */
    63 #define GET_SECTOR_COUNT        1       /* Get media size (needed at _USE_MKFS == 1) */
    64 #define GET_SECTOR_SIZE         2       /* Get sector size (needed at _MAX_SS != _MIN_SS) */
    65 #define GET_BLOCK_SIZE          3       /* Get erase block size (needed at _USE_MKFS == 1) */
    66 #define CTRL_TRIM                       4       /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
     62#define CTRL_SYNC                       0       /* Complete pending write process (needed at FF_FS_READONLY == 0) */
     63#define GET_SECTOR_COUNT        1       /* Get media size (needed at FF_USE_MKFS == 1) */
     64#define GET_SECTOR_SIZE         2       /* Get sector size (needed at FF_MAX_SS != FF_MIN_SS) */
     65#define GET_BLOCK_SIZE          3       /* Get erase block size (needed at FF_USE_MKFS == 1) */
     66#define CTRL_TRIM                       4       /* Inform device that the data on the block of sectors is no longer used (needed at FF_USE_TRIM == 1) */
    6767
    6868/* Generic command (Not used by FatFs) */
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ff.c

    r369 r374  
    2020#include "ff.h"                 /* Declarations of FatFs API */
    2121#include "diskio.h"             /* Declarations of disk I/O functions */
    22 #include "util/ntstdio.h"
     22#include <stdio.h>
    2323
    2424/*--------------------------------------------------------------------------
     
    3434
    3535/* Reentrancy related */
    36 #if _FS_REENTRANT
    37 #if _USE_LFN == 1
     36#if FF_FS_REENTRANT
     37#if FF_USE_LFN == 1
    3838#error Static LFN work area cannot be used at thread-safe configuration
    3939#endif
     
    4949
    5050/* Definitions of sector size */
    51 #if (_MAX_SS < _MIN_SS) || (_MAX_SS != 512 && _MAX_SS != 1024 && _MAX_SS != 2048 && _MAX_SS != 4096) || (_MIN_SS != 512 && _MIN_SS != 1024 && _MIN_SS != 2048 && _MIN_SS != 4096)
     51#if (FF_MAX_SS < FF_MIN_SS) || (FF_MAX_SS != 512 && FF_MAX_SS != 1024 && FF_MAX_SS != 2048 && FF_MAX_SS != 4096) || (FF_MIN_SS != 512 && FF_MIN_SS != 1024 && FF_MIN_SS != 2048 && FF_MIN_SS != 4096)
    5252#error Wrong sector size configuration
    5353#endif
    54 #if _MAX_SS == _MIN_SS
    55 #define SS(fs)  ((UINT)_MAX_SS) /* Fixed sector size */
     54#if FF_MAX_SS == FF_MIN_SS
     55#define SS(fs)  ((UINT)FF_MAX_SS)       /* Fixed sector size */
    5656#else
    5757#define SS(fs)  ((fs)->ssize)   /* Variable sector size */
     
    6060
    6161/* Timestamp feature */
    62 #if _FS_NORTC == 1
    63 #if _NORTC_YEAR < 1980 || _NORTC_YEAR > 2107 || _NORTC_MON < 1 || _NORTC_MON > 12 || _NORTC_MDAY < 1 || _NORTC_MDAY > 31
    64 #error Invalid _FS_NORTC settings
    65 #endif
    66 #define GET_FATTIME()   ((DWORD)(_NORTC_YEAR - 1980) << 25 | (DWORD)_NORTC_MON << 21 | (DWORD)_NORTC_MDAY << 16)
     62#if FF_FS_NORTC == 1
     63#if FF_NORTC_YEAR < 1980 || FF_NORTC_YEAR > 2107 || FF_NORTC_MON < 1 || FF_NORTC_MON > 12 || FF_NORTC_MDAY < 1 || FF_NORTC_MDAY > 31
     64#error Invalid FF_FS_NORTC settings
     65#endif
     66#define GET_FATTIME()   ((DWORD)(FF_NORTC_YEAR - 1980) << 25 | (DWORD)FF_NORTC_MON << 21 | (DWORD)FF_NORTC_MDAY << 16)
    6767#else
    6868#define GET_FATTIME()   get_fattime()
     
    7171
    7272/* File access control feature */
    73 #if _FS_LOCK
    74 #if _FS_READONLY
    75 #error _FS_LOCK must be 0 at read-only configuration
     73#if FF_FS_LOCK != 0
     74#if FF_FS_READONLY
     75#error FF_FS_LOCK must be 0 at read-only configuration
    7676#endif
    7777typedef struct {
     
    8787/* DBCS code ranges and SBCS upper conversion tables */
    8888
    89 #if _CODE_PAGE == 932   /* Japanese Shift-JIS */
     89#if FF_CODE_PAGE == 932 /* Japanese Shift-JIS */
    9090#define _DF1S   0x81    /* DBC 1st byte range 1 start */
    9191#define _DF1E   0x9F    /* DBC 1st byte range 1 end */
     
    9797#define _DS2E   0xFC    /* DBC 2nd byte range 2 end */
    9898
    99 #elif _CODE_PAGE == 936 /* Simplified Chinese GBK */
     99#elif FF_CODE_PAGE == 936       /* Simplified Chinese GBK */
    100100#define _DF1S   0x81
    101101#define _DF1E   0xFE
     
    105105#define _DS2E   0xFE
    106106
    107 #elif _CODE_PAGE == 949 /* Korean */
     107#elif FF_CODE_PAGE == 949       /* Korean */
    108108#define _DF1S   0x81
    109109#define _DF1E   0xFE
     
    115115#define _DS3E   0xFE
    116116
    117 #elif _CODE_PAGE == 950 /* Traditional Chinese Big5 */
     117#elif FF_CODE_PAGE == 950       /* Traditional Chinese Big5 */
    118118#define _DF1S   0x81
    119119#define _DF1E   0xFE
     
    123123#define _DS2E   0xFE
    124124
    125 #elif _CODE_PAGE == 437 /* U.S. */
     125#elif FF_CODE_PAGE == 437       /* U.S. */
    126126#define _DF1S   0
    127127#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
     
    134134                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    135135
    136 #elif _CODE_PAGE == 720 /* Arabic */
     136#elif FF_CODE_PAGE == 720       /* Arabic */
    137137#define _DF1S   0
    138138#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    145145                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    146146
    147 #elif _CODE_PAGE == 737 /* Greek */
     147#elif FF_CODE_PAGE == 737       /* Greek */
    148148#define _DF1S   0
    149149#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    156156                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    157157
    158 #elif _CODE_PAGE == 771 /* KBL */
     158#elif FF_CODE_PAGE == 771       /* KBL */
    159159#define _DF1S   0
    160160#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    167167                                0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFE,0xFF}
    168168
    169 #elif _CODE_PAGE == 775 /* Baltic */
     169#elif FF_CODE_PAGE == 775       /* Baltic */
    170170#define _DF1S   0
    171171#define _EXCVT {0x80,0x9A,0x91,0xA0,0x8E,0x95,0x8F,0x80,0xAD,0xED,0x8A,0x8A,0xA1,0x8D,0x8E,0x8F, \
     
    178178                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    179179
    180 #elif _CODE_PAGE == 850 /* Latin 1 */
     180#elif FF_CODE_PAGE == 850       /* Latin 1 */
    181181#define _DF1S   0
    182182#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x41,0x43,0x45,0x45,0x45,0x49,0x49,0x49,0x41,0x41, \
     
    189189                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    190190
    191 #elif _CODE_PAGE == 852 /* Latin 2 */
     191#elif FF_CODE_PAGE == 852       /* Latin 2 */
    192192#define _DF1S   0
    193193#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xDE,0x8F,0x80,0x9D,0xD3,0x8A,0x8A,0xD7,0x8D,0x8E,0x8F, \
     
    200200                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xEB,0xFC,0xFC,0xFE,0xFF}
    201201
    202 #elif _CODE_PAGE == 855 /* Cyrillic */
     202#elif FF_CODE_PAGE == 855       /* Cyrillic */
    203203#define _DF1S   0
    204204#define _EXCVT {0x81,0x81,0x83,0x83,0x85,0x85,0x87,0x87,0x89,0x89,0x8B,0x8B,0x8D,0x8D,0x8F,0x8F, \
     
    211211                                0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF8,0xFA,0xFA,0xFC,0xFC,0xFD,0xFE,0xFF}
    212212
    213 #elif _CODE_PAGE == 857 /* Turkish */
     213#elif FF_CODE_PAGE == 857       /* Turkish */
    214214#define _DF1S   0
    215215#define _EXCVT {0x80,0x9A,0x90,0xB6,0x8E,0xB7,0x8F,0x80,0xD2,0xD3,0xD4,0xD8,0xD7,0x49,0x8E,0x8F, \
     
    222222                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    223223
    224 #elif _CODE_PAGE == 860 /* Portuguese */
     224#elif FF_CODE_PAGE == 860       /* Portuguese */
    225225#define _DF1S   0
    226226#define _EXCVT {0x80,0x9A,0x90,0x8F,0x8E,0x91,0x86,0x80,0x89,0x89,0x92,0x8B,0x8C,0x98,0x8E,0x8F, \
     
    233233                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    234234
    235 #elif _CODE_PAGE == 861 /* Icelandic */
     235#elif FF_CODE_PAGE == 861       /* Icelandic */
    236236#define _DF1S   0
    237237#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x8B,0x8B,0x8D,0x8E,0x8F, \
     
    244244                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    245245
    246 #elif _CODE_PAGE == 862 /* Hebrew */
     246#elif FF_CODE_PAGE == 862       /* Hebrew */
    247247#define _DF1S   0
    248248#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    255255                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    256256
    257 #elif _CODE_PAGE == 863 /* Canadian-French */
     257#elif FF_CODE_PAGE == 863       /* Canadian-French */
    258258#define _DF1S   0
    259259#define _EXCVT {0x43,0x55,0x45,0x41,0x41,0x41,0x86,0x43,0x45,0x45,0x45,0x49,0x49,0x8D,0x41,0x8F, \
     
    266266                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    267267
    268 #elif _CODE_PAGE == 864 /* Arabic */
     268#elif FF_CODE_PAGE == 864       /* Arabic */
    269269#define _DF1S   0
    270270#define _EXCVT {0x80,0x9A,0x45,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
     
    277277                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    278278
    279 #elif _CODE_PAGE == 865 /* Nordic */
     279#elif FF_CODE_PAGE == 865       /* Nordic */
    280280#define _DF1S   0
    281281#define _EXCVT {0x80,0x9A,0x90,0x41,0x8E,0x41,0x8F,0x80,0x45,0x45,0x45,0x49,0x49,0x49,0x8E,0x8F, \
     
    288288                                0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    289289
    290 #elif _CODE_PAGE == 866 /* Russian */
     290#elif FF_CODE_PAGE == 866       /* Russian */
    291291#define _DF1S   0
    292292#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    299299                                0xF0,0xF0,0xF2,0xF2,0xF4,0xF4,0xF6,0xF6,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF}
    300300
    301 #elif _CODE_PAGE == 869 /* Greek 2 */
     301#elif FF_CODE_PAGE == 869       /* Greek 2 */
    302302#define _DF1S   0
    303303#define _EXCVT {0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, \
     
    310310                                0xF0,0xF1,0xD1,0xD2,0xD3,0xF5,0xD4,0xF7,0xF8,0xF9,0xD5,0x96,0x95,0x98,0xFE,0xFF}
    311311
    312 #elif _CODE_PAGE == 1   /* ASCII (for only non-LFN cfg) */
    313 #if _USE_LFN
     312#elif FF_CODE_PAGE == 1 /* ASCII (for only non-LFN cfg) */
     313#if FF_USE_LFN
    314314#error Cannot use LFN feature without valid code page.
    315315#endif
    316316#define _DF1S   0
    317317
    318 #elif _CODE_PAGE == 65001 /* UTF-8 */
    319 #if _LFN_UNICODE
     318#elif FF_CODE_PAGE == 65001 /* UTF-8 */
     319#if FF_LFN_UNICODE
    320320#error Cannot use LFN_UNICODE feature without valid code page.
    321321#endif
     
    532532*/
    533533
    534 #if _VOLUMES < 1 || _VOLUMES > 9
    535 #error Wrong _VOLUMES setting
    536 #endif
    537 static FATFS *FatFs[_VOLUMES];  /* Pointer to the file system objects (logical drives) */
     534#if FF_VOLUMES < 1 || FF_VOLUMES > 9
     535#error Wrong FF_VOLUMES setting
     536#endif
     537static FATFS *FatFs[FF_VOLUMES];        /* Pointer to the file system objects (logical drives) */
    538538static WORD Fsid;                               /* File system mount ID */
    539539
    540 #if _FS_RPATH && _VOLUMES >= 2
     540#if FF_FS_RPATH && FF_VOLUMES >= 2
    541541static BYTE CurrVol;                    /* Current drive */
    542542#endif
    543543
    544 #if _FS_LOCK
    545 static FILESEM Files[_FS_LOCK]; /* Open object lock semaphores */
    546 #endif
    547 
    548 #if _USE_LFN == 0                       /* Non LFN feature */
     544#if FF_FS_LOCK != 0
     545static FILESEM Files[FF_FS_LOCK];       /* Open object lock semaphores */
     546#endif
     547
     548#if FF_USE_LFN == 0                     /* Non LFN feature */
    549549#define DEFINE_NAMEBUF          BYTE sfn[12]
    550550#define INIT_BUF(dobj)          (dobj).fn = sfn
    551551#define FREE_BUF()
    552552#else
    553 #if _MAX_LFN < 12 || _MAX_LFN > 255
    554 #error Wrong _MAX_LFN setting
    555 #endif
    556 #if _USE_LFN == 1                       /* LFN feature with static working buffer */
    557 static WCHAR LfnBuf[_MAX_LFN + 1];
     553#if FF_MAX_LFN < 12 || FF_MAX_LFN > 255
     554#error Wrong FF_MAX_LFN setting
     555#endif
     556#if FF_USE_LFN == 1                     /* LFN feature with static working buffer */
     557static WCHAR LfnBuf[FF_MAX_LFN + 1];
    558558#define DEFINE_NAMEBUF          BYTE sfn[12]
    559559#define INIT_BUF(dobj)          { (dobj).fn = sfn; (dobj).lfn = LfnBuf; }
    560560#define FREE_BUF()
    561 #elif _USE_LFN == 2             /* LFN feature with dynamic working buffer on the stack */
    562 #define DEFINE_NAMEBUF          BYTE sfn[12]; WCHAR lbuf[_MAX_LFN + 1]
     561#elif FF_USE_LFN == 2           /* LFN feature with dynamic working buffer on the stack */
     562#define DEFINE_NAMEBUF          BYTE sfn[12]; WCHAR lbuf[FF_MAX_LFN + 1]
    563563#define INIT_BUF(dobj)          { (dobj).fn = sfn; (dobj).lfn = lbuf; }
    564564#define FREE_BUF()
    565 #elif _USE_LFN == 3             /* LFN feature with dynamic working buffer on the heap */
     565#elif FF_USE_LFN == 3           /* LFN feature with dynamic working buffer on the heap */
    566566#define DEFINE_NAMEBUF          BYTE sfn[12]; WCHAR *lfn
    567 #define INIT_BUF(dobj)          { lfn = ff_memalloc((_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; }
     567#define INIT_BUF(dobj)          { lfn = ff_memalloc((FF_MAX_LFN + 1) * 2); if (!lfn) LEAVE_FF((dobj).fs, FR_NOT_ENOUGH_CORE); (dobj).lfn = lfn; (dobj).fn = sfn; }
    568568#define FREE_BUF()                      ff_memfree(lfn)
    569569#else
    570 #error Wrong _USE_LFN setting
     570#error Wrong FF_USE_LFN setting
    571571#endif
    572572#endif
     
    598598        const BYTE *s = (const BYTE*)src;
    599599
    600 #if _WORD_ACCESS == 1
     600#if FF_WORD_ACCESS == 1
    601601        while (cnt >= sizeof (int)) {
    602602                *(int*)d = *(int*)s;
     
    641641/* Request/Release grant to access the volume                            */
    642642/*-----------------------------------------------------------------------*/
    643 #if _FS_REENTRANT
     643#if FF_FS_REENTRANT
    644644static
    645645int lock_fs (
     
    673673/* File lock control functions                                           */
    674674/*-----------------------------------------------------------------------*/
    675 #if _FS_LOCK
     675#if FF_FS_LOCK != 0
    676676
    677677static
    678678FRESULT chk_lock (      /* Check if the file can be accessed */
    679         DIR* dp,                /* Directory object pointing the file to be checked */
     679        FATFS_DIR* dp,          /* Directory object pointing the file to be checked */
    680680        int acc                 /* Desired access type (0:Read, 1:Write, 2:Delete/Rename) */
    681681)
     
    684684
    685685        /* Search file semaphore table */
    686         for (i = be = 0; i < _FS_LOCK; i++) {
     686        for (i = be = 0; i < FF_FS_LOCK; i++) {
    687687                if (Files[i].fs) {      /* Existing entry */
    688688                        if (Files[i].fs == dp->fs &&            /* Check if the object matched with an open object */
     
    693693                }
    694694        }
    695         if (i == _FS_LOCK)      /* The object is not opened */
     695        if (i == FF_FS_LOCK)    /* The object is not opened */
    696696                return (be || acc == 2) ? FR_OK : FR_TOO_MANY_OPEN_FILES;       /* Is there a blank entry for new object? */
    697697
     
    706706        UINT i;
    707707
    708         for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
    709         return (i == _FS_LOCK) ? 0 : 1;
     708        for (i = 0; i < FF_FS_LOCK && Files[i].fs; i++) ;
     709        return (i == FF_FS_LOCK) ? 0 : 1;
    710710}
    711711
     
    713713static
    714714UINT inc_lock ( /* Increment object open counter and returns its index (0:Internal error) */
    715         DIR* dp,        /* Directory object pointing the file to register or increment */
     715        FATFS_DIR* dp,  /* Directory object pointing the file to register or increment */
    716716        int acc         /* Desired access (0:Read, 1:Write, 2:Delete/Rename) */
    717717)
     
    720720
    721721
    722         for (i = 0; i < _FS_LOCK; i++) {        /* Find the object */
     722        for (i = 0; i < FF_FS_LOCK; i++) {      /* Find the object */
    723723                if (Files[i].fs == dp->fs &&
    724724                        Files[i].clu == dp->sclust &&
     
    726726        }
    727727
    728         if (i == _FS_LOCK) {                            /* Not opened. Register it as new. */
    729                 for (i = 0; i < _FS_LOCK && Files[i].fs; i++) ;
    730                 if (i == _FS_LOCK) return 0;    /* No free entry to register (int err) */
     728        if (i == FF_FS_LOCK) {                          /* Not opened. Register it as new. */
     729                for (i = 0; i < FF_FS_LOCK && Files[i].fs; i++) ;
     730                if (i == FF_FS_LOCK) return 0;  /* No free entry to register (int err) */
    731731                Files[i].fs = dp->fs;
    732732                Files[i].clu = dp->sclust;
     
    752752
    753753
    754         if (--i < _FS_LOCK) {   /* Shift index number origin from 0 */
     754        if (--i < FF_FS_LOCK) { /* Shift index number origin from 0 */
    755755                n = Files[i].ctr;
    756756                if (n == 0x100) n = 0;          /* If write mode open, delete the entry */
     
    773773        UINT i;
    774774
    775         for (i = 0; i < _FS_LOCK; i++) {
     775        for (i = 0; i < FF_FS_LOCK; i++) {
    776776                if (Files[i].fs == fs) Files[i].fs = 0;
    777777        }
     
    785785/* Move/Flush disk access window in the file system object               */
    786786/*-----------------------------------------------------------------------*/
    787 #if !_FS_READONLY
     787#if !FF_FS_READONLY
    788788static
    789789FRESULT sync_window (   /* FR_OK:succeeded, !=0:error */
     
    825825
    826826        if (sector != fs->winsect) {    /* Window offset changed? */
    827 #if !_FS_READONLY
     827#if !FF_FS_READONLY
    828828                res = sync_window(fs);          /* Write-back changes */
    829829#endif
     
    845845/* Synchronize file system and strage device                             */
    846846/*-----------------------------------------------------------------------*/
    847 #if !_FS_READONLY
     847#if !FF_FS_READONLY
    848848static
    849849FRESULT sync_fs (       /* FR_OK:succeeded, !=0:error */
     
    959959/* Hidden API for hacks and disk tools */
    960960
    961 #if !_FS_READONLY
     961#if !FF_FS_READONLY
    962962FRESULT put_fat (       /* FR_OK(0):succeeded, !=0:error */
    963963        FATFS* fs,              /* File system object */
     
    10141014        return res;
    10151015}
    1016 #endif /* !_FS_READONLY */
     1016#endif /* !FF_FS_READONLY */
    10171017
    10181018
     
    10221022/* FAT handling - Remove a cluster chain                                 */
    10231023/*-----------------------------------------------------------------------*/
    1024 #if !_FS_READONLY
     1024#if !FF_FS_READONLY
    10251025static
    10261026FRESULT remove_chain (  /* FR_OK(0):succeeded, !=0:error */
     
    10311031        FRESULT res;
    10321032        DWORD nxt;
    1033 #if _USE_TRIM
     1033#if FF_USE_TRIM
    10341034        DWORD scl = clst, ecl = clst, rt[2];
    10351035#endif
     
    10511051                                fs->fsi_flag |= 1;
    10521052                        }
    1053 #if _USE_TRIM
     1053#if FF_USE_TRIM
    10541054                        if (ecl + 1 == nxt) {   /* Is next cluster contiguous? */
    10551055                                ecl = nxt;
     
    10751075/* FAT handling - Stretch or Create a cluster chain                      */
    10761076/*-----------------------------------------------------------------------*/
    1077 #if !_FS_READONLY
     1077#if !FF_FS_READONLY
    10781078static
    10791079DWORD create_chain (    /* 0:No free cluster, 1:Internal error, 0xFFFFFFFF:Disk error, >=2:New cluster# */
     
    11281128        return ncl;             /* Return new cluster number or error code */
    11291129}
    1130 #endif /* !_FS_READONLY */
     1130#endif /* !FF_FS_READONLY */
    11311131
    11321132
     
    11371137/*-----------------------------------------------------------------------*/
    11381138
    1139 #if _USE_FASTSEEK
     1139#if FF_USE_FASTSEEK
    11401140static
    11411141DWORD clmt_clust (      /* <2:Error, >=2:Cluster number */
     
    11571157        return cl + *tbl;       /* Return the cluster number */
    11581158}
    1159 #endif  /* _USE_FASTSEEK */
     1159#endif  /* FF_USE_FASTSEEK */
    11601160
    11611161
     
    11681168static
    11691169FRESULT dir_sdi (       /* FR_OK(0):succeeded, !=0:error */
    1170         DIR* dp,                /* Pointer to directory object */
     1170        FATFS_DIR* dp,          /* Pointer to directory object */
    11711171        UINT idx                /* Index of directory table */
    11721172)
     
    12161216static
    12171217FRESULT dir_next (      /* FR_OK(0):succeeded, FR_NO_FILE:End of table, FR_DENIED:Could not stretch */
    1218         DIR* dp,                /* Pointer to the directory object */
     1218        FATFS_DIR* dp,          /* Pointer to the directory object */
    12191219        int stretch             /* 0: Do not stretch table, 1: Stretch table if needed */
    12201220)
     
    12221222        DWORD clst;
    12231223        UINT i;
    1224 #if !_FS_READONLY
     1224#if !FF_FS_READONLY
    12251225        UINT c;
    12261226#endif
     
    12441244                                if (clst == 0xFFFFFFFF) return FR_DISK_ERR;
    12451245                                if (clst >= dp->fs->n_fatent) {                                 /* If it reached end of dynamic table, */
    1246 #if !_FS_READONLY
     1246#if !FF_FS_READONLY
    12471247                                        if (!stretch) return FR_NO_FILE;                        /* If do not stretch, report EOT */
    12481248                                        clst = create_chain(dp->fs, dp->clust);         /* Stretch cluster chain */
     
    12841284/*-----------------------------------------------------------------------*/
    12851285
    1286 #if !_FS_READONLY
     1286#if !FF_FS_READONLY
    12871287static
    12881288FRESULT dir_alloc (     /* FR_OK(0):succeeded, !=0:error */
    1289         DIR* dp,                /* Pointer to the directory object */
     1289        FATFS_DIR* dp,          /* Pointer to the directory object */
    12901290        UINT nent               /* Number of contiguous entries to allocate (1-21) */
    12911291)
     
    13371337
    13381338
    1339 #if !_FS_READONLY
     1339#if !FF_FS_READONLY
    13401340static
    13411341void st_clust (
     
    13551355/* LFN handling - Test/Pick/Fit an LFN segment from/to directory entry   */
    13561356/*-----------------------------------------------------------------------*/
    1357 #if _USE_LFN
     1357#if FF_USE_LFN
    13581358static
    13591359const BYTE LfnOfs[] = {1,3,5,7,9,14,16,18,20,22,24,28,30};      /* Offset of LFN characters in the directory entry */
     
    13771377                uc = LD_WORD(dir + LfnOfs[s]);          /* Pick an LFN character */
    13781378                if (wc) {
    1379                         if (i >= _MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++]))       /* Compare it */
     1379                        if (i >= FF_MAX_LFN || ff_wtoupper(uc) != ff_wtoupper(lfnbuf[i++]))     /* Compare it */
    13801380                                return 0;                                       /* Not matched */
    13811381                        wc = uc;
     
    14101410                uc = LD_WORD(dir + LfnOfs[s]);          /* Pick an LFN character */
    14111411                if (wc) {
    1412                         if (i >= _MAX_LFN) return 0;    /* Buffer overflow? */
     1412                        if (i >= FF_MAX_LFN) return 0;  /* Buffer overflow? */
    14131413                        lfnbuf[i++] = wc = uc;                  /* Store it */
    14141414                } else {
     
    14181418
    14191419        if (dir[LDIR_Ord] & LLEF) {                             /* Put terminator if it is the last LFN part */
    1420                 if (i >= _MAX_LFN) return 0;            /* Buffer overflow? */
     1420                if (i >= FF_MAX_LFN) return 0;          /* Buffer overflow? */
    14211421                lfnbuf[i] = 0;
    14221422        }
     
    14261426
    14271427
    1428 #if !_FS_READONLY
     1428#if !FF_FS_READONLY
    14291429static
    14301430void fit_lfn (
     
    14641464/* Create numbered name                                                  */
    14651465/*-----------------------------------------------------------------------*/
    1466 #if _USE_LFN
     1466#if FF_USE_LFN
    14671467static
    14681468void gen_numname (
     
    15231523/* Calculate checksum of an SFN entry                                    */
    15241524/*-----------------------------------------------------------------------*/
    1525 #if _USE_LFN
     1525#if FF_USE_LFN
    15261526static
    15271527BYTE sum_sfn (
     
    15461546static
    15471547FRESULT dir_find (      /* FR_OK(0):succeeded, !=0:error */
    1548         DIR* dp                 /* Pointer to the directory object linked to the file name */
     1548        FATFS_DIR* dp                   /* Pointer to the directory object linked to the file name */
    15491549)
    15501550{
    15511551        FRESULT res;
    15521552        BYTE c, *dir;
    1553 #if _USE_LFN
     1553#if FF_USE_LFN
    15541554        BYTE a, ord, sum;
    15551555#endif
     
    15581558        if (res != FR_OK) return res;
    15591559
    1560 #if _USE_LFN
     1560#if FF_USE_LFN
    15611561        ord = sum = 0xFF; dp->lfn_idx = 0xFFFF; /* Reset LFN sequence */
    15621562#endif
     
    15671567                c = dir[DIR_Name];
    15681568                if (c == 0) { res = FR_NO_FILE; break; }        /* Reached to end of table */
    1569 #if _USE_LFN    /* LFN configuration */
     1569#if FF_USE_LFN  /* LFN configuration */
    15701570                a = dir[DIR_Attr] & AM_MASK;
    15711571                if (c == DDEM || ((a & AM_VOL) && a != AM_LFN)) {       /* An entry without valid data */
     
    16041604/* Read an object from the directory                                     */
    16051605/*-----------------------------------------------------------------------*/
    1606 #if _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2
     1606#if FF_FS_MINIMIZE <= 1 || FF_USE_LABEL || FF_FS_RPATH >= 2
    16071607static
    16081608FRESULT dir_read (
    1609         DIR* dp,                /* Pointer to the directory object */
     1609        FATFS_DIR* dp,          /* Pointer to the directory object */
    16101610        int vol                 /* Filtered by 0:file/directory or 1:volume label */
    16111611)
     
    16131613        FRESULT res;
    16141614        BYTE a, c, *dir;
    1615 #if _USE_LFN
     1615#if FF_USE_LFN
    16161616        BYTE ord = 0xFF, sum = 0xFF;
    16171617#endif
     
    16251625                if (c == 0) { res = FR_NO_FILE; break; }        /* Reached to end of table */
    16261626                a = dir[DIR_Attr] & AM_MASK;
    1627 #if _USE_LFN    /* LFN configuration */
    1628                 if (c == DDEM || (!_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) {   /* An entry without valid data */
     1627#if FF_USE_LFN  /* LFN configuration */
     1628                if (c == DDEM || (!FF_FS_RPATH && c == '.') || (int)((a & ~AM_ARC) == AM_VOL) != vol) { /* An entry without valid data */
    16291629                        ord = 0xFF;
    16301630                } else {
     
    16441644                }
    16451645#else           /* Non LFN configuration */
    1646                 if (c != DDEM && (_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol)       /* Is it a valid entry? */
     1646                if (c != DDEM && (FF_FS_RPATH || c != '.') && a != AM_LFN && (int)((a & ~AM_ARC) == AM_VOL) == vol)     /* Is it a valid entry? */
    16471647                        break;
    16481648#endif
     
    16551655        return res;
    16561656}
    1657 #endif  /* _FS_MINIMIZE <= 1 || _USE_LABEL || _FS_RPATH >= 2 */
     1657#endif  /* FF_FS_MINIMIZE <= 1 || FF_USE_LABEL || FF_FS_RPATH >= 2 */
    16581658
    16591659
     
    16631663/* Register an object to the directory                                   */
    16641664/*-----------------------------------------------------------------------*/
    1665 #if !_FS_READONLY
     1665#if !FF_FS_READONLY
    16661666static
    16671667FRESULT dir_register (  /* FR_OK:succeeded, FR_DENIED:no free entry or too many SFN collision, FR_DISK_ERR:disk error */
    1668         DIR* dp                         /* Target directory with object name to be created */
     1668        FATFS_DIR* dp                           /* Target directory with object name to be created */
    16691669)
    16701670{
    16711671        FRESULT res;
    1672 #if _USE_LFN    /* LFN configuration */
     1672#if FF_USE_LFN  /* LFN configuration */
    16731673        UINT n, nent;
    16741674        BYTE sn[12], *fn, sum;
     
    16791679        mem_cpy(sn, fn, 12);
    16801680
    1681         if (_FS_RPATH && (sn[NSFLAG] & NS_DOT))         /* Cannot create dot entry */
     1681        if (FF_FS_RPATH && (sn[NSFLAG] & NS_DOT))               /* Cannot create dot entry */
    16821682                return FR_INVALID_NAME;
    16831683
     
    17241724                        mem_set(dp->dir, 0, SZ_DIRE);   /* Clean the entry */
    17251725                        mem_cpy(dp->dir, dp->fn, 11);   /* Put SFN */
    1726 #if _USE_LFN
     1726#if FF_USE_LFN
    17271727                        dp->dir[DIR_NTres] = dp->fn[NSFLAG] & (NS_BODY | NS_EXT);       /* Put NT flag */
    17281728#endif
     
    17331733        return res;
    17341734}
    1735 #endif /* !_FS_READONLY */
     1735#endif /* !FF_FS_READONLY */
    17361736
    17371737
     
    17411741/* Remove an object from the directory                                   */
    17421742/*-----------------------------------------------------------------------*/
    1743 #if !_FS_READONLY && !_FS_MINIMIZE
     1743#if !FF_FS_READONLY && !FF_FS_MINIMIZE
    17441744static
    17451745FRESULT dir_remove (    /* FR_OK:Succeeded, FR_DISK_ERR:A disk error */
    1746         DIR* dp                         /* Directory object pointing the entry to be removed */
     1746        FATFS_DIR* dp                           /* Directory object pointing the entry to be removed */
    17471747)
    17481748{
    17491749        FRESULT res;
    1750 #if _USE_LFN    /* LFN configuration */
     1750#if FF_USE_LFN  /* LFN configuration */
    17511751        UINT i;
    17521752
     
    17801780        return res;
    17811781}
    1782 #endif /* !_FS_READONLY */
     1782#endif /* !FF_FS_READONLY */
    17831783
    17841784
     
    17881788/* Get file information from directory entry                             */
    17891789/*-----------------------------------------------------------------------*/
    1790 #if _FS_MINIMIZE <= 1 || _FS_RPATH >= 2
     1790#if FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2
    17911791static
    17921792void get_fileinfo (             /* No return code */
    1793         DIR* dp,                        /* Pointer to the directory object */
     1793        FATFS_DIR* dp,                  /* Pointer to the directory object */
    17941794        FILINFO* fno            /* Pointer to the file information to be filled */
    17951795)
     
    17981798        TCHAR *p, c;
    17991799        BYTE *dir;
    1800 #if _USE_LFN
     1800#if FF_USE_LFN
    18011801        WCHAR w, *lfn;
    18021802#endif
    1803 #if _CODE_PAGE == 65001
     1803#if FF_CODE_PAGE == 65001
    18041804        unsigned char utf8_code[6];
    18051805        int code_size;
     
    18151815                        if (c == RDDEM) c = (TCHAR)DDEM;        /* Restore replaced DDEM character */
    18161816                        if (i == 9) *p++ = '.';                         /* Insert a . if extension is exist */
    1817 #if _USE_LFN
     1817#if FF_USE_LFN
    18181818                        if (IsUpper(c) && (dir[DIR_NTres] & (i >= 9 ? NS_EXT : NS_BODY)))
    18191819                                c += 0x20;                      /* To lower */
    1820 #if _LFN_UNICODE
     1820#if FF_LFN_UNICODE
    18211821                        if (IsDBCS1(c) && i != 8 && i != 11 && IsDBCS2(dir[i]))
    18221822                                c = c << 8 | dir[i++];
     
    18341834        *p = 0;         /* Terminate SFN string by a \0 */
    18351835
    1836 #if _USE_LFN
     1836#if FF_USE_LFN
    18371837        if (fno->lfname) {
    18381838                i = 0; p = fno->lfname;
     
    18401840                        lfn = dp->lfn;
    18411841                        while ((w = *lfn++) != 0) {             /* Get an LFN character */
    1842 #if !_LFN_UNICODE
    1843 #if _CODE_PAGE == 65001
     1842#if !FF_LFN_UNICODE
     1843#if FF_CODE_PAGE == 65001
    18441844                                Utf16_to_Utf8(utf8_code, &code_size, w);
    18451845                                for (int j = 0; j < code_size - 1; j++) {
     
    18621862#endif
    18631863}
    1864 #endif /* _FS_MINIMIZE <= 1 || _FS_RPATH >= 2 */
     1864#endif /* FF_FS_MINIMIZE <= 1 || FF_FS_RPATH >= 2 */
    18651865
    18661866
     
    18701870/* Pattern matching                                                      */
    18711871/*-----------------------------------------------------------------------*/
    1872 #if _USE_FIND && _FS_MINIMIZE <= 1
     1872#if FF_USE_FIND && FF_FS_MINIMIZE <= 1
    18731873static
    18741874WCHAR get_achar (               /* Get a character and advances ptr 1 or 2 */
     
    18781878        WCHAR chr;
    18791879
    1880 #if !_LFN_UNICODE
    1881 #if _CODE_PAGE == 65001
     1880#if !FF_LFN_UNICODE
     1881#if FF_CODE_PAGE == 65001
    18821882        int code_size;
    18831883        chr = Utf8_to_Utf16(*ptr, &code_size);
     
    19381938        return 0;
    19391939}
    1940 #endif /* _USE_FIND && _FS_MINIMIZE <= 1 */
     1940#endif /* FF_USE_FIND && FF_FS_MINIMIZE <= 1 */
    19411941
    19421942
     
    19491949static
    19501950FRESULT create_name (   /* FR_OK: successful, FR_INVALID_NAME: could not create */
    1951         DIR* dp,                        /* Pointer to the directory object */
     1951        FATFS_DIR* dp,                  /* Pointer to the directory object */
    19521952        const TCHAR** path      /* Pointer to pointer to the segment in the path string */
    19531953)
    19541954{
    1955 #if _USE_LFN    /* LFN configuration */
     1955#if FF_USE_LFN  /* LFN configuration */
    19561956        BYTE b, cf;
    19571957        WCHAR w, *lfn;
    19581958        UINT i, ni, si, di;
    19591959        const TCHAR *p;
    1960 #if _CODE_PAGE == 65001
     1960#if FF_CODE_PAGE == 65001
    19611961        unsigned char utf8_code[6];
    19621962        int code_size;
     
    19691969                w = p[si++];                                    /* Get a character */
    19701970                if (w < ' ' || w == '/' || w == '\\') break;    /* Break on end of segment */
    1971                 if (di >= _MAX_LFN)                             /* Reject too long name */
     1971                if (di >= FF_MAX_LFN)                           /* Reject too long name */
    19721972                        return FR_INVALID_NAME;
    1973 #if !_LFN_UNICODE
    1974 #if _CODE_PAGE == 65001
     1973#if !FF_LFN_UNICODE
     1974#if FF_CODE_PAGE == 65001
    19751975                w = Utf8_to_Utf16(&p[si - 1], &code_size);
    19761976                si += code_size - 1;
     
    19931993        *path = &p[si];                                         /* Return pointer to the next segment */
    19941994        cf = (w < ' ') ? NS_LAST : 0;           /* Set last segment flag if end of path */
    1995 #if _FS_RPATH
     1995#if FF_FS_RPATH
    19961996        if ((di == 1 && lfn[di - 1] == '.') ||
    19971997                (di == 2 && lfn[di - 1] == '.' && lfn[di - 2] == '.')) {        /* Is this segment a dot entry? */
     
    20402040                        if (w) w = ExCvt[w - 0x80];     /* Convert extended character to upper (SBCS) */
    20412041#else
    2042 #if _CODE_PAGE == 65001
     2042#if FF_CODE_PAGE == 65001
    20432043                        Utf16_to_Utf8(utf8_code, &code_size, ff_wtoupper(w));
    20442044#else
     
    20482048                        cf |= NS_LFN;                           /* Force create LFN entry */
    20492049                }
    2050 #if _CODE_PAGE == 65001
     2050#if FF_CODE_PAGE == 65001
    20512051                else
    20522052                        code_size = 1;
    20532053#endif
    20542054
    2055 #if _CODE_PAGE == 65001
     2055#if FF_CODE_PAGE == 65001
    20562056                if (code_size > 1) {            /* Is this DBC? (always false at SBCS cfg) */
    20572057                        if (i >= ni - 1) {
     
    21262126        mem_set(sfn, ' ', 11);
    21272127        si = i = b = 0; ni = 8;
    2128 #if _FS_RPATH
     2128#if FF_FS_RPATH
    21292129        if (p[si] == '.') { /* Is this a dot entry? */
    21302130                for (;;) {
     
    22012201static
    22022202FRESULT follow_path (   /* FR_OK(0): successful, !=0: error code */
    2203         DIR* dp,                        /* Directory object to return last directory and found object */
     2203        FATFS_DIR* dp,                  /* Directory object to return last directory and found object */
    22042204        const TCHAR* path       /* Full-path string to find a file or directory */
    22052205)
     
    22092209
    22102210
    2211 #if _FS_RPATH
     2211#if FF_FS_RPATH
    22122212        if (*path == '/' || *path == '\\') {    /* There is a heading separator */
    22132213                path++; dp->sclust = 0;                         /* Strip it and start from the root directory */
     
    22322232                        if (res != FR_OK) {                             /* Failed to find the object */
    22332233                                if (res == FR_NO_FILE) {        /* Object is not found */
    2234                                         if (_FS_RPATH && (ns & NS_DOT)) {       /* If dot entry is not exist, */
     2234                                        if (FF_FS_RPATH && (ns & NS_DOT)) {     /* If dot entry is not exist, */
    22352235                                                dp->sclust = 0; dp->dir = 0;    /* it is the root directory and stay there */
    22362236                                                if (!(ns & NS_LAST)) continue;  /* Continue to follow if not last segment */
     
    22692269        UINT i;
    22702270        int vol = -1;
    2271 #if _STR_VOLUME_ID              /* Find string drive id */
    2272         static const char* const str[] = {_VOLUME_STRS};
     2271#if FF_STR_VOLUME_ID            /* Find string drive id */
     2272        static const char* const str[] = {FF_VOLUME_STRS};
    22732273        const char *sp;
    22742274        char c;
     
    22782278
    22792279        if (*path) {    /* If the pointer is not a null */
    2280                 for (tt = *path; (UINT)*tt >= (_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ;     /* Find ':' in the path */
     2280                for (tt = *path; (UINT)*tt >= (FF_USE_LFN ? ' ' : '!') && *tt != ':'; tt++) ;   /* Find ':' in the path */
    22812281                if (*tt == ':') {       /* If a ':' is exist in the path name */
    22822282                        tp = *path;
    22832283                        i = *tp++ - '0';
    22842284                        if (i < 10 && tp == tt) {       /* Is there a numeric drive id? */
    2285                                 if (i < _VOLUMES) {     /* If a drive id is found, get the value and strip it */
     2285                                if (i < FF_VOLUMES) {   /* If a drive id is found, get the value and strip it */
    22862286                                        vol = (int)i;
    22872287                                        *path = ++tt;
    22882288                                }
    22892289                        }
    2290 #if _STR_VOLUME_ID
     2290#if FF_STR_VOLUME_ID
    22912291                         else { /* No numeric drive number, find string drive id */
    22922292                                i = 0; tt++;
     
    22972297                                                if (IsLower(tc)) tc -= 0x20;
    22982298                                        } while (c && (TCHAR)c == tc);
    2299                                 } while ((c || tp != tt) && ++i < _VOLUMES);    /* Repeat for each id until pattern match */
    2300                                 if (i < _VOLUMES) {     /* If a drive id is found, get the value and strip it */
     2299                                } while ((c || tp != tt) && ++i < FF_VOLUMES);  /* Repeat for each id until pattern match */
     2300                                if (i < FF_VOLUMES) {   /* If a drive id is found, get the value and strip it */
    23012301                                        vol = (int)i;
    23022302                                        *path = tt;
     
    23062306                        return vol;
    23072307                }
    2308 #if _FS_RPATH && _VOLUMES >= 2
     2308#if FF_FS_RPATH && FF_VOLUMES >= 2
    23092309                vol = CurrVol;  /* Current drive */
    23102310#else
     
    23812381                stat = disk_status(fs->drv);
    23822382                if (!(stat & STA_NOINIT)) {             /* and the physical drive is kept initialized */
    2383                         if (!_FS_READONLY && wmode && (stat & STA_PROTECT))     /* Check write protection if needed */
     2383                        if (!FF_FS_READONLY && wmode && (stat & STA_PROTECT))   /* Check write protection if needed */
    23842384                                return FR_WRITE_PROTECTED;
    23852385                        return FR_OK;                           /* The file system object is valid */
     
    23952395        if (stat & STA_NOINIT)                          /* Check if the initialization succeeded */
    23962396                return FR_NOT_READY;                    /* Failed to initialize due to no medium or hard error */
    2397         if (!_FS_READONLY && wmode && (stat & STA_PROTECT))     /* Check disk write protection if needed */
     2397        if (!FF_FS_READONLY && wmode && (stat & STA_PROTECT))   /* Check disk write protection if needed */
    23982398                return FR_WRITE_PROTECTED;
    2399 #if _MAX_SS != _MIN_SS                                          /* Get sector size (multiple sector size cfg only) */
     2399#if FF_MAX_SS != FF_MIN_SS                                              /* Get sector size (multiple sector size cfg only) */
    24002400        if (disk_ioctl(fs->drv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK
    2401                 || SS(fs) < _MIN_SS || SS(fs) > _MAX_SS) return FR_DISK_ERR;
     2401                || SS(fs) < FF_MIN_SS || SS(fs) > FF_MAX_SS) return FR_DISK_ERR;
    24022402#endif
    24032403        /* Find an FAT partition on the drive. Supports only generic partitioning, FDISK and SFD. */
     
    24482448
    24492449        /* Determine the FAT sub type */
    2450         sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE);    /* RSV + FAT + DIR */
     2450        sysect = nrsv + fasize + fs->n_rootdir / (SS(fs) / SZ_DIRE);    /* RSV + FAT + FATFS_DIR */
    24512451        if (tsect < sysect) return FR_NO_FILESYSTEM;            /* (Invalid volume size) */
    24522452        nclst = (tsect - sysect) / fs->csize;                           /* Number of clusters */
     
    24742474                return FR_NO_FILESYSTEM;
    24752475
    2476 #if !_FS_READONLY
     2476#if !FF_FS_READONLY
    24772477        /* Initialize cluster allocation information */
    24782478        fs->last_clust = fs->free_clust = 0xFFFFFFFF;
     
    24802480        /* Get fsinfo if available */
    24812481        fs->fsi_flag = 0x80;
    2482 #if (_FS_NOFSINFO & 3) != 3
     2482#if (FF_FS_NOFSINFO & 3) != 3
    24832483        if (fmt == FS_FAT32                             /* Enable FSINFO only if FAT32 and BPB_FSInfo == 1 */
    24842484                && LD_WORD(fs->win + BPB_FSInfo) == 1
     
    24902490                        && LD_DWORD(fs->win + FSI_StrucSig) == 0x61417272)
    24912491                {
    2492 #if (_FS_NOFSINFO & 1) == 0
     2492#if (FF_FS_NOFSINFO & 1) == 0
    24932493                        fs->free_clust = LD_DWORD(fs->win + FSI_Free_Count);
    24942494#endif
    2495 #if (_FS_NOFSINFO & 2) == 0
     2495#if (FF_FS_NOFSINFO & 2) == 0
    24962496                        fs->last_clust = LD_DWORD(fs->win + FSI_Nxt_Free);
    24972497#endif
     
    25022502        fs->fs_type = fmt;      /* FAT sub-type */
    25032503        fs->id = ++Fsid;        /* File system mount ID */
    2504 #if _FS_RPATH
     2504#if FF_FS_RPATH
    25052505        fs->cdir = 0;           /* Set current directory to root */
    25062506#endif
    2507 #if _FS_LOCK                    /* Clear file lock semaphores */
     2507#if FF_FS_LOCK != 0                     /* Clear file lock semaphores */
    25082508        clear_lock(fs);
    25092509#endif
     
    25212521static
    25222522FRESULT validate (      /* FR_OK(0): The object is valid, !=0: Invalid */
    2523         void* obj               /* Pointer to the object FIL/DIR to check validity */
    2524 )
    2525 {
    2526         FIL *fil = (FIL*)obj;   /* Assuming offset of .fs and .id in the FIL/DIR structure is identical */
     2523        void* obj               /* Pointer to the object FIL/FATFS_DIR to check validity */
     2524)
     2525{
     2526        FIL *fil = (FIL*)obj;   /* Assuming offset of .fs and .id in the FIL/FATFS_DIR structure is identical */
    25272527
    25282528
     
    25672567
    25682568        if (cfs) {
    2569 #if _FS_LOCK
     2569#if FF_FS_LOCK != 0
    25702570                clear_lock(cfs);
    25712571#endif
    2572 #if _FS_REENTRANT                                               /* Discard sync object of the current volume */
     2572#if FF_FS_REENTRANT                                             /* Discard sync object of the current volume */
    25732573                if (!ff_del_syncobj(cfs->sobj)) return FR_INT_ERR;
    25742574#endif
     
    25782578        if (fs) {
    25792579                fs->fs_type = 0;                                /* Clear new fs object */
    2580 #if _FS_REENTRANT                                               /* Create sync object for the new volume */
     2580#if FF_FS_REENTRANT                                             /* Create sync object for the new volume */
    25812581                if (!ff_cre_syncobj((BYTE)vol, &fs->sobj)) return FR_INT_ERR;
    25822582#endif
     
    26042604{
    26052605        FRESULT res;
    2606         DIR dj;
     2606        FATFS_DIR dj;
    26072607        BYTE *dir;
    26082608        DEFINE_NAMEBUF;
    2609 #if !_FS_READONLY
     2609#if !FF_FS_READONLY
    26102610        DWORD dw, cl;
    26112611#endif
     
    26162616
    26172617        /* Get logical drive number */
    2618 #if !_FS_READONLY
    2619         mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW;
     2618#if !FF_FS_READONLY
     2619        mode &= FA_READ | FA_WRITE | FA_CREATE_ALWAYS | FA_OPEN_ALWAYS | FA_CREATE_NEW | FA_OPEN_APPEND;
    26202620        res = find_volume(&dj.fs, &path, (BYTE)(mode & ~FA_READ));
    26212621#else
     
    26272627                res = follow_path(&dj, path);   /* Follow the file path */
    26282628                dir = dj.dir;
    2629 #if !_FS_READONLY       /* R/W configuration */
     2629#if !FF_FS_READONLY     /* R/W configuration */
    26302630                if (res == FR_OK) {
    26312631                        if (!dir)       /* Default directory itself */
    26322632                                res = FR_INVALID_NAME;
    2633 #if _FS_LOCK
     2633#if FF_FS_LOCK != 0
    26342634                        else
    26352635                                res = chk_lock(&dj, (mode & ~FA_READ) ? 1 : 0);
     
    26402640                        if (res != FR_OK) {                                     /* No file, create new */
    26412641                                if (res == FR_NO_FILE)                  /* There is no file to open, create a new entry */
    2642 #if _FS_LOCK
     2642#if FF_FS_LOCK != 0
    26432643                                        res = enq_lock() ? dir_register(&dj) : FR_TOO_MANY_OPEN_FILES;
    26442644#else
     
    26492649                        }
    26502650                        else {                                                          /* Any object is already existing */
    2651                                 if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) {        /* Cannot overwrite it (R/O or DIR) */
     2651                                if (dir[DIR_Attr] & (AM_RDO | AM_DIR)) {        /* Cannot overwrite it (R/O or FATFS_DIR) */
    26522652                                        res = FR_DENIED;
    26532653                                } else {
     
    26872687                if (res == FR_OK) {
    26882688                        if (mode & FA_CREATE_ALWAYS)            /* Set file change flag if created or overwritten */
    2689                                 mode |= FA__WRITTEN;
     2689                                mode |= FA_MODIFIED;
    26902690                        fp->dir_sect = dj.fs->winsect;          /* Pointer to the directory entry */
    26912691                        fp->dir_ptr = dir;
    2692 #if _FS_LOCK
     2692#if FF_FS_LOCK != 0
    26932693                        fp->lockid = inc_lock(&dj, (mode & ~FA_READ) ? 1 : 0);
    26942694                        if (!fp->lockid) res = FR_INT_ERR;
     
    27162716                        fp->fptr = 0;                                           /* File pointer */
    27172717                        fp->dsect = 0;
    2718 #if _USE_FASTSEEK
     2718#if FF_USE_FASTSEEK
    27192719                        fp->cltbl = 0;                                          /* Normal seek mode */
    27202720#endif
     
    27662766                                        clst = fp->sclust;                      /* Follow from the origin */
    27672767                                } else {                                                /* Middle or end of the file */
    2768 #if _USE_FASTSEEK
     2768#if FF_USE_FASTSEEK
    27692769                                        if (fp->cltbl)
    27702770                                                clst = clmt_clust(fp, fp->fptr);        /* Get cluster# from the CLMT */
     
    27862786                                if (disk_read(fp->fs->drv, rbuff, sect, cc) != RES_OK)
    27872787                                        ABORT(fp->fs, FR_DISK_ERR);
    2788 #if !_FS_READONLY && _FS_MINIMIZE <= 2                  /* Replace one of the read sectors with cached data if it contains a dirty sector */
    2789 #if _FS_TINY
     2788#if !FF_FS_READONLY && FF_FS_MINIMIZE <= 2                      /* Replace one of the read sectors with cached data if it contains a dirty sector */
     2789#if FF_FS_TINY
    27902790                                if (fp->fs->wflag && fp->fs->winsect - sect < cc)
    27912791                                        mem_cpy(rbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), fp->fs->win, SS(fp->fs));
    27922792#else
    2793                                 if ((fp->flag & FA__DIRTY) && fp->dsect - sect < cc)
     2793                                if ((fp->flag & FA_DIRTY) && fp->dsect - sect < cc)
    27942794                                        mem_cpy(rbuff + ((fp->dsect - sect) * SS(fp->fs)), fp->buf, SS(fp->fs));
    27952795#endif
     
    27982798                                continue;
    27992799                        }
    2800 #if !_FS_TINY
     2800#if !FF_FS_TINY
    28012801                        if (fp->dsect != sect) {                        /* Load data sector if not in cache */
    2802 #if !_FS_READONLY
    2803                                 if (fp->flag & FA__DIRTY) {             /* Write-back dirty sector cache */
     2802#if !FF_FS_READONLY
     2803                                if (fp->flag & FA_DIRTY) {              /* Write-back dirty sector cache */
    28042804                                        if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    28052805                                                ABORT(fp->fs, FR_DISK_ERR);
    2806                                         fp->flag &= ~FA__DIRTY;
     2806                                        fp->flag &= ~FA_DIRTY;
    28072807                                }
    28082808#endif
     
    28152815                rcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));      /* Get partial sector data from sector buffer */
    28162816                if (rcnt > btr) rcnt = btr;
    2817 #if _FS_TINY
     2817#if FF_FS_TINY
    28182818                if (move_window(fp->fs, fp->dsect) != FR_OK)            /* Move sector window */
    28192819                        ABORT(fp->fs, FR_DISK_ERR);
     
    28302830
    28312831
    2832 #if !_FS_READONLY
     2832#if !FF_FS_READONLY
    28332833/*-----------------------------------------------------------------------*/
    28342834/* Write File                                                            */
     
    28692869                                                clst = create_chain(fp->fs, 0); /* Create a new cluster chain */
    28702870                                } else {                                        /* Middle or end of the file */
    2871 #if _USE_FASTSEEK
     2871#if FF_USE_FASTSEEK
    28722872                                        if (fp->cltbl)
    28732873                                                clst = clmt_clust(fp, fp->fptr);        /* Get cluster# from the CLMT */
     
    28822882                                if (fp->sclust == 0) fp->sclust = clst; /* Set start cluster if the first write */
    28832883                        }
    2884 #if _FS_TINY
     2884#if FF_FS_TINY
    28852885                        if (fp->fs->winsect == fp->dsect && sync_window(fp->fs))        /* Write-back sector cache */
    28862886                                ABORT(fp->fs, FR_DISK_ERR);
    28872887#else
    2888                         if (fp->flag & FA__DIRTY) {             /* Write-back sector cache */
     2888                        if (fp->flag & FA_DIRTY) {              /* Write-back sector cache */
    28892889                                if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    28902890                                        ABORT(fp->fs, FR_DISK_ERR);
    2891                                 fp->flag &= ~FA__DIRTY;
     2891                                fp->flag &= ~FA_DIRTY;
    28922892                        }
    28932893#endif
     
    29012901                                if (disk_write(fp->fs->drv, wbuff, sect, cc) != RES_OK)
    29022902                                        ABORT(fp->fs, FR_DISK_ERR);
    2903 #if _FS_MINIMIZE <= 2
    2904 #if _FS_TINY
     2903#if FF_FS_MINIMIZE <= 2
     2904#if FF_FS_TINY
    29052905                                if (fp->fs->winsect - sect < cc) {      /* Refill sector cache if it gets invalidated by the direct write */
    29062906                                        mem_cpy(fp->fs->win, wbuff + ((fp->fs->winsect - sect) * SS(fp->fs)), SS(fp->fs));
     
    29102910                                if (fp->dsect - sect < cc) { /* Refill sector cache if it gets invalidated by the direct write */
    29112911                                        mem_cpy(fp->buf, wbuff + ((fp->dsect - sect) * SS(fp->fs)), SS(fp->fs));
    2912                                         fp->flag &= ~FA__DIRTY;
     2912                                        fp->flag &= ~FA_DIRTY;
    29132913                                }
    29142914#endif
     
    29172917                                continue;
    29182918                        }
    2919 #if _FS_TINY
     2919#if FF_FS_TINY
    29202920                        if (fp->fptr >= fp->fsize) {    /* Avoid silly cache filling at growing edge */
    29212921                                if (sync_window(fp->fs)) ABORT(fp->fs, FR_DISK_ERR);
     
    29332933                wcnt = SS(fp->fs) - ((UINT)fp->fptr % SS(fp->fs));/* Put partial sector into file I/O buffer */
    29342934                if (wcnt > btw) wcnt = btw;
    2935 #if _FS_TINY
     2935#if FF_FS_TINY
    29362936                if (move_window(fp->fs, fp->dsect) != FR_OK)    /* Move sector window */
    29372937                        ABORT(fp->fs, FR_DISK_ERR);
     
    29402940#else
    29412941                mem_cpy(&fp->buf[fp->fptr % SS(fp->fs)], wbuff, wcnt);  /* Fit partial sector */
    2942                 fp->flag |= FA__DIRTY;
     2942                fp->flag |= FA_DIRTY;
    29432943#endif
    29442944        }
    29452945
    29462946        if (fp->fptr > fp->fsize) fp->fsize = fp->fptr; /* Update file size if needed */
    2947         fp->flag |= FA__WRITTEN;                                                /* Set file change flag */
     2947        fp->flag |= FA_MODIFIED;                                                /* Set file change flag */
    29482948
    29492949        LEAVE_FF(fp->fs, FR_OK);
     
    29682968        res = validate(fp);                                     /* Check validity of the object */
    29692969        if (res == FR_OK) {
    2970                 if (fp->flag & FA__WRITTEN) {   /* Is there any change to the file? */
    2971 #if !_FS_TINY
    2972                         if (fp->flag & FA__DIRTY) {     /* Write-back cached data if needed */
     2970                if (fp->flag & FA_MODIFIED) {   /* Is there any change to the file? */
     2971#if !FF_FS_TINY
     2972                        if (fp->flag & FA_DIRTY) {      /* Write-back cached data if needed */
    29732973                                if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    29742974                                        LEAVE_FF(fp->fs, FR_DISK_ERR);
    2975                                 fp->flag &= ~FA__DIRTY;
     2975                                fp->flag &= ~FA_DIRTY;
    29762976                        }
    29772977#endif
     
    29862986                                ST_DWORD(dir + DIR_WrtTime, tm);
    29872987                                ST_WORD(dir + DIR_LstAccDate, 0);
    2988                                 fp->flag &= ~FA__WRITTEN;
     2988                                fp->flag &= ~FA_MODIFIED;
    29892989                                fp->fs->wflag = 1;
    29902990                                res = sync_fs(fp->fs);
     
    29962996}
    29972997
    2998 #endif /* !_FS_READONLY */
     2998#endif /* !FF_FS_READONLY */
    29992999
    30003000
     
    30123012
    30133013
    3014 #if !_FS_READONLY
     3014#if !FF_FS_READONLY
    30153015        res = f_sync(fp);                                       /* Flush cached data */
    30163016        if (res == FR_OK)
     
    30193019                res = validate(fp);                             /* Lock volume */
    30203020                if (res == FR_OK) {
    3021 #if _FS_REENTRANT
     3021#if FF_FS_REENTRANT
    30223022                        FATFS *fs = fp->fs;
    30233023#endif
    3024 #if _FS_LOCK
     3024#if FF_FS_LOCK != 0
    30253025                        res = dec_lock(fp->lockid);     /* Decrement file open counter */
    30263026                        if (res == FR_OK)
    30273027#endif
    30283028                                fp->fs = 0;                             /* Invalidate file object */
    3029 #if _FS_REENTRANT
     3029#if FF_FS_REENTRANT
    30303030                        unlock_fs(fs, FR_OK);           /* Unlock volume */
    30313031#endif
     
    30423042/*-----------------------------------------------------------------------*/
    30433043
    3044 #if _FS_RPATH >= 1
    3045 #if _VOLUMES >= 2
     3044#if FF_FS_RPATH >= 1
     3045#if FF_VOLUMES >= 2
    30463046FRESULT f_chdrive (
    30473047        const TCHAR* path               /* Drive number */
     
    30663066{
    30673067        FRESULT res;
    3068         DIR dj;
     3068        FATFS_DIR dj;
    30693069        DEFINE_NAMEBUF;
    30703070
     
    30933093
    30943094
    3095 #if _FS_RPATH >= 2
     3095#if FF_FS_RPATH >= 2
    30963096FRESULT f_getcwd (
    30973097        TCHAR* buff,    /* Pointer to the directory path */
     
    31003100{
    31013101        FRESULT res;
    3102         DIR dj;
     3102        FATFS_DIR dj;
    31033103        UINT i, n;
    31043104        DWORD ccl;
     
    31313131                        if (res == FR_NO_FILE) res = FR_INT_ERR;/* It cannot be 'not found'. */
    31323132                        if (res != FR_OK) break;
    3133 #if _USE_LFN
     3133#if FF_USE_LFN
    31343134                        fno.lfname = buff;
    31353135                        fno.lfsize = i;
     
    31373137                        get_fileinfo(&dj, &fno);                /* Get the directory name and push it to the buffer */
    31383138                        tp = fno.fname;
    3139 #if _USE_LFN
     3139#if FF_USE_LFN
    31403140                        if (*buff) tp = buff;
    31413141#endif
     
    31493149                tp = buff;
    31503150                if (res == FR_OK) {
    3151 #if _VOLUMES >= 2
     3151#if FF_VOLUMES >= 2
    31523152                        *tp++ = '0' + CurrVol;                  /* Put drive number */
    31533153                        *tp++ = ':';
     
    31673167        LEAVE_FF(dj.fs, res);
    31683168}
    3169 #endif /* _FS_RPATH >= 2 */
    3170 #endif /* _FS_RPATH >= 1 */
    3171 
    3172 
    3173 
    3174 #if _FS_MINIMIZE <= 2
     3169#endif /* FF_FS_RPATH >= 2 */
     3170#endif /* FF_FS_RPATH >= 1 */
     3171
     3172
     3173
     3174#if FF_FS_MINIMIZE <= 2
    31753175/*-----------------------------------------------------------------------*/
    31763176/* Seek File R/W Pointer                                                 */
     
    31843184        FRESULT res;
    31853185        DWORD clst, bcs, nsect, ifptr;
    3186 #if _USE_FASTSEEK
     3186#if FF_USE_FASTSEEK
    31873187        DWORD cl, pcl, ncl, tcl, dsc, tlen, ulen, *tbl;
    31883188#endif
     
    31943194                LEAVE_FF(fp->fs, (FRESULT)fp->err);
    31953195
    3196 #if _USE_FASTSEEK
     3196#if FF_USE_FASTSEEK
    31973197        if (fp->cltbl) {        /* Fast seek */
    31983198                if (ofs == CREATE_LINKMAP) {    /* Create CLMT */
     
    32313231                                dsc += (ofs - 1) / SS(fp->fs) & (fp->fs->csize - 1);
    32323232                                if (fp->fptr % SS(fp->fs) && dsc != fp->dsect) {        /* Refill sector cache if needed */
    3233 #if !_FS_TINY
    3234 #if !_FS_READONLY
    3235                                         if (fp->flag & FA__DIRTY) {             /* Write-back dirty sector cache */
     3233#if !FF_FS_TINY
     3234#if !FF_FS_READONLY
     3235                                        if (fp->flag & FA_DIRTY) {              /* Write-back dirty sector cache */
    32363236                                                if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    32373237                                                        ABORT(fp->fs, FR_DISK_ERR);
    3238                                                 fp->flag &= ~FA__DIRTY;
     3238                                                fp->flag &= ~FA_DIRTY;
    32393239                                        }
    32403240#endif
     
    32523252        {
    32533253                if (ofs > fp->fsize                                     /* In read-only mode, clip offset with the file size */
    3254 #if !_FS_READONLY
     3254#if !FF_FS_READONLY
    32553255                         && !(fp->flag & FA_WRITE)
    32563256#endif
     
    32683268                        } else {                                                                        /* When seek to back cluster, */
    32693269                                clst = fp->sclust;                                              /* start from the first cluster */
    3270 #if !_FS_READONLY
     3270#if !FF_FS_READONLY
    32713271                                if (clst == 0) {                                                /* If no cluster chain, create a new chain */
    32723272                                        clst = create_chain(fp->fs, 0);
     
    32803280                        if (clst != 0) {
    32813281                                while (ofs > bcs) {                                             /* Cluster following loop */
    3282 #if !_FS_READONLY
     3282#if !FF_FS_READONLY
    32833283                                        if (fp->flag & FA_WRITE) {                      /* Check if in write mode or not */
    32843284                                                clst = create_chain(fp->fs, clst);      /* Force stretch if in write mode */
     
    33043304                }
    33053305                if (fp->fptr % SS(fp->fs) && nsect != fp->dsect) {      /* Fill sector cache if needed */
    3306 #if !_FS_TINY
    3307 #if !_FS_READONLY
    3308                         if (fp->flag & FA__DIRTY) {                     /* Write-back dirty sector cache */
     3306#if !FF_FS_TINY
     3307#if !FF_FS_READONLY
     3308                        if (fp->flag & FA_DIRTY) {                      /* Write-back dirty sector cache */
    33093309                                if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    33103310                                        ABORT(fp->fs, FR_DISK_ERR);
    3311                                 fp->flag &= ~FA__DIRTY;
     3311                                fp->flag &= ~FA_DIRTY;
    33123312                        }
    33133313#endif
     
    33173317                        fp->dsect = nsect;
    33183318                }
    3319 #if !_FS_READONLY
     3319#if !FF_FS_READONLY
    33203320                if (fp->fptr > fp->fsize) {                     /* Set file change flag if the file size is extended */
    33213321                        fp->fsize = fp->fptr;
    3322                         fp->flag |= FA__WRITTEN;
     3322                        fp->flag |= FA_MODIFIED;
    33233323                }
    33243324#endif
     
    33423342}
    33433343
    3344 #if _FS_MINIMIZE <= 1
     3344#if FF_FS_MINIMIZE <= 1
    33453345/*-----------------------------------------------------------------------*/
    33463346/* Create a Directory Object                                             */
     
    33483348
    33493349FRESULT f_opendir (
    3350         DIR* dp,                        /* Pointer to directory object to create */
     3350        FATFS_DIR* dp,                  /* Pointer to directory object to create */
    33513351        const TCHAR* path       /* Pointer to the directory path */
    33523352)
     
    33763376                                dp->id = fs->id;
    33773377                                res = dir_sdi(dp, 0);                   /* Rewind directory */
    3378 #if _FS_LOCK
     3378#if FF_FS_LOCK != 0
    33793379                                if (res == FR_OK) {
    33803380                                        if (dp->sclust) {
     
    34043404
    34053405FRESULT f_closedir (
    3406         DIR *dp         /* Pointer to the directory object to be closed */
     3406        FATFS_DIR *dp           /* Pointer to the directory object to be closed */
    34073407)
    34083408{
     
    34123412        res = validate(dp);
    34133413        if (res == FR_OK) {
    3414 #if _FS_REENTRANT
     3414#if FF_FS_REENTRANT
    34153415                FATFS *fs = dp->fs;
    34163416#endif
    3417 #if _FS_LOCK
     3417#if FF_FS_LOCK != 0
    34183418                if (dp->lockid)                         /* Decrement sub-directory open counter */
    34193419                        res = dec_lock(dp->lockid);
     
    34213421#endif
    34223422                        dp->fs = 0;                             /* Invalidate directory object */
    3423 #if _FS_REENTRANT
     3423#if FF_FS_REENTRANT
    34243424                unlock_fs(fs, FR_OK);           /* Unlock volume */
    34253425#endif
     
    34363436
    34373437FRESULT f_readdir (
    3438         DIR* dp,                        /* Pointer to the open directory object */
     3438        FATFS_DIR* dp,                  /* Pointer to the open directory object */
    34393439        FILINFO* fno            /* Pointer to file information to return */
    34403440)
     
    34723472
    34733473
    3474 #if _USE_FIND
     3474#if FF_USE_FIND
    34753475/*-----------------------------------------------------------------------*/
    34763476/* Find next file                                                        */
     
    34783478
    34793479FRESULT f_findnext (
    3480         DIR* dp,                /* Pointer to the open directory object */
     3480        FATFS_DIR* dp,          /* Pointer to the open directory object */
    34813481        FILINFO* fno    /* Pointer to the file information structure */
    34823482)
     
    34883488                res = f_readdir(dp, fno);               /* Get a directory item */
    34893489                if (res != FR_OK || !fno || !fno->fname[0]) break;      /* Terminate if any error or end of directory */
    3490 #if _USE_LFN
     3490#if FF_USE_LFN
    34913491                if (fno->lfname && pattern_matching(dp->pat, fno->lfname, 0, 0)) break; /* Test for LFN if exist */
    34923492#endif
     
    35043504
    35053505FRESULT f_findfirst (
    3506         DIR* dp,                                /* Pointer to the blank directory object */
     3506        FATFS_DIR* dp,                          /* Pointer to the blank directory object */
    35073507        FILINFO* fno,                   /* Pointer to the file information structure */
    35083508        const TCHAR* path,              /* Pointer to the directory to open */
     
    35203520}
    35213521
    3522 #endif  /* _USE_FIND */
    3523 
    3524 
    3525 
    3526 #if _FS_MINIMIZE == 0
     3522#endif  /* FF_USE_FIND */
     3523
     3524
     3525
     3526#if FF_FS_MINIMIZE == 0
    35273527/*-----------------------------------------------------------------------*/
    35283528/* Get File Status                                                       */
     
    35353535{
    35363536        FRESULT res;
    3537         DIR dj;
     3537        FATFS_DIR dj;
    35383538        DEFINE_NAMEBUF;
    35393539
     
    35593559
    35603560
    3561 #if !_FS_READONLY
     3561#if !FF_FS_READONLY
    35623562/*-----------------------------------------------------------------------*/
    35633563/* Get Number of Free Clusters                                           */
     
    36503650                if (fp->fsize > fp->fptr) {
    36513651                        fp->fsize = fp->fptr;   /* Set file size to current R/W point */
    3652                         fp->flag |= FA__WRITTEN;
     3652                        fp->flag |= FA_MODIFIED;
    36533653                        if (fp->fptr == 0) {    /* When set file size to zero, remove entire cluster chain */
    36543654                                res = remove_chain(fp->fs, fp->sclust);
     
    36643664                                }
    36653665                        }
    3666 #if !_FS_TINY
    3667                         if (res == FR_OK && (fp->flag & FA__DIRTY)) {
     3666#if !FF_FS_TINY
     3667                        if (res == FR_OK && (fp->flag & FA_DIRTY)) {
    36683668                                if (disk_write(fp->fs->drv, fp->buf, fp->dsect, 1) != RES_OK)
    36693669                                        res = FR_DISK_ERR;
    36703670                                else
    3671                                         fp->flag &= ~FA__DIRTY;
     3671                                        fp->flag &= ~FA_DIRTY;
    36723672                        }
    36733673#endif
     
    36913691{
    36923692        FRESULT res;
    3693         DIR dj, sdj;
     3693        FATFS_DIR dj, sdj;
    36943694        BYTE *dir;
    36953695        DWORD dclst = 0;
     
    37023702                INIT_BUF(dj);
    37033703                res = follow_path(&dj, path);           /* Follow the file path */
    3704                 if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
     3704                if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
    37053705                        res = FR_INVALID_NAME;                  /* Cannot remove dot entry */
    3706 #if _FS_LOCK
     3706#if FF_FS_LOCK != 0
    37073707                if (res == FR_OK) res = chk_lock(&dj, 2);       /* Cannot remove open object */
    37083708#endif
     
    37183718                                dclst = ld_clust(dj.fs, dir);
    37193719                                if (dclst && (dir[DIR_Attr] & AM_DIR)) {        /* Is it a sub-directory ? */
    3720 #if _FS_RPATH
     3720#if FF_FS_RPATH
    37213721                                        if (dclst == dj.fs->cdir) {                             /* Is it the current directory? */
    37223722                                                res = FR_DENIED;
     
    37243724#endif
    37253725                                        {
    3726                                                 mem_cpy(&sdj, &dj, sizeof (DIR));       /* Open the sub-directory */
     3726                                                mem_cpy(&sdj, &dj, sizeof (FATFS_DIR)); /* Open the sub-directory */
    37273727                                                sdj.sclust = dclst;
    37283728                                                res = dir_sdi(&sdj, 2);
     
    37603760{
    37613761        FRESULT res;
    3762         DIR dj;
     3762        FATFS_DIR dj;
    37633763        BYTE *dir, n;
    37643764        DWORD dsc, dcl, pcl, tm = GET_FATTIME();
     
    37723772                res = follow_path(&dj, path);                   /* Follow the file path */
    37733773                if (res == FR_OK) res = FR_EXIST;               /* Any object with same name is already existing */
    3774                 if (_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT))
     3774                if (FF_FS_RPATH && res == FR_NO_FILE && (dj.fn[NSFLAG] & NS_DOT))
    37753775                        res = FR_INVALID_NAME;
    37763776                if (res == FR_NO_FILE) {                                /* Can create a new directory */
     
    38363836{
    38373837        FRESULT res;
    3838         DIR dj;
     3838        FATFS_DIR dj;
    38393839        BYTE *dir;
    38403840        DEFINE_NAMEBUF;
     
    38463846                res = follow_path(&dj, path);           /* Follow the file path */
    38473847                FREE_BUF();
    3848                 if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
     3848                if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
    38493849                        res = FR_INVALID_NAME;
    38503850                if (res == FR_OK) {
     
    38773877{
    38783878        FRESULT res;
    3879         DIR djo, djn;
     3879        FATFS_DIR djo, djn;
    38803880        BYTE buf[21], *dir;
    38813881        DWORD dw;
     
    38903890                INIT_BUF(djo);
    38913891                res = follow_path(&djo, path_old);              /* Check old object */
    3892                 if (_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT))
     3892                if (FF_FS_RPATH && res == FR_OK && (djo.fn[NSFLAG] & NS_DOT))
    38933893                        res = FR_INVALID_NAME;
    3894 #if _FS_LOCK
     3894#if FF_FS_LOCK != 0
    38953895                if (res == FR_OK) res = chk_lock(&djo, 2);
    38963896#endif
     
    39003900                        } else {
    39013901                                mem_cpy(buf, djo.dir + DIR_Attr, 21);   /* Save information about object except name */
    3902                                 mem_cpy(&djn, &djo, sizeof (DIR));              /* Duplicate the directory object */
     3902                                mem_cpy(&djn, &djo, sizeof (FATFS_DIR));                /* Duplicate the directory object */
    39033903                                if (get_ldnumber(&path_new) >= 0)               /* Snip drive number off and ignore it */
    39043904                                        res = follow_path(&djn, path_new);      /* and make sure if new object name is not conflicting */
     
    39093909                                        dir = djn.dir;
    39103910                                        if (dir[DIR_Attr] & AM_DIR) {   /* The new object is a directory */
    3911                                                 temp_new_path = (TCHAR *)ff_memalloc((_MAX_LFN + 1) * sizeof(WCHAR));
    3912                                                 ntstdio_snprintf(temp_new_path, _MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
     3911                                                temp_new_path = (TCHAR *)ff_memalloc((FF_MAX_LFN + 1) * sizeof(WCHAR));
     3912                                                snprintf(temp_new_path, FF_MAX_LFN, "%s/%s", path_new, basename((char *)path_old));
    39133913                                                res = follow_path(&djn, temp_new_path);
    39143914                                        }
     
    39663966{
    39673967        FRESULT res;
    3968         DIR dj;
     3968        FATFS_DIR dj;
    39693969        BYTE *dir;
    39703970        DEFINE_NAMEBUF;
     
    39773977                res = follow_path(&dj, path);   /* Follow the file path */
    39783978                FREE_BUF();
    3979                 if (_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
     3979                if (FF_FS_RPATH && res == FR_OK && (dj.fn[NSFLAG] & NS_DOT))
    39803980                        res = FR_INVALID_NAME;
    39813981                if (res == FR_OK) {
     
    39953995}
    39963996
    3997 #endif /* !_FS_READONLY */
    3998 #endif /* _FS_MINIMIZE == 0 */
    3999 #endif /* _FS_MINIMIZE <= 1 */
    4000 #endif /* _FS_MINIMIZE <= 2 */
    4001 
    4002 
    4003 
    4004 
    4005 #if _USE_LABEL
     3997#endif /* !FF_FS_READONLY */
     3998#endif /* FF_FS_MINIMIZE == 0 */
     3999#endif /* FF_FS_MINIMIZE <= 1 */
     4000#endif /* FF_FS_MINIMIZE <= 2 */
     4001
     4002
     4003
     4004
     4005#if FF_USE_LABEL
    40064006/*-----------------------------------------------------------------------*/
    40074007/* Get volume label                                                      */
     
    40154015{
    40164016        FRESULT res;
    4017         DIR dj;
     4017        FATFS_DIR dj;
    40184018        UINT i, j;
    4019 #if _USE_LFN && _LFN_UNICODE
     4019#if FF_USE_LFN && FF_LFN_UNICODE
    40204020        WCHAR w;
    40214021#endif
     
    40324032                        res = dir_read(&dj, 1);         /* Get an entry with AM_VOL */
    40334033                        if (res == FR_OK) {                     /* A volume label is exist */
    4034 #if _USE_LFN && _LFN_UNICODE
     4034#if FF_USE_LFN && FF_LFN_UNICODE
    40354035                                i = j = 0;
    40364036                                do {
     
    40704070
    40714071
    4072 #if !_FS_READONLY
     4072#if !FF_FS_READONLY
    40734073/*-----------------------------------------------------------------------*/
    40744074/* Set volume label                                                      */
     
    40804080{
    40814081        FRESULT res;
    4082         DIR dj;
     4082        FATFS_DIR dj;
    40834083        BYTE vn[11];
    40844084        UINT i, j, sl;
    40854085        WCHAR w;
    40864086        DWORD tm;
    4087 #if _CODE_PAGE == 65001
     4087#if FF_CODE_PAGE == 65001
    40884088        int code_size;
    40894089        unsigned char utf8_code[6];
     
    41014101                i = j = 0;
    41024102                do {
    4103 #if _CODE_PAGE == 65001
     4103#if FF_CODE_PAGE == 65001
    41044104                        w = ff_wtoupper(Utf8_to_Utf16(&label[i], &code_size));
    41054105                        i += code_size;
     
    41104110                                vn[j++] = utf8_code[k];
    41114111#else
    4112 #if _USE_LFN && _LFN_UNICODE
     4112#if FF_USE_LFN && FF_LFN_UNICODE
    41134113                        w = ff_convert(ff_wtoupper(label[i++]), 0);
    41144114#else
     
    41164116                        if (IsDBCS1(w))
    41174117                                w = (j < 10 && i < sl && IsDBCS2(label[i])) ? w << 8 | (BYTE)label[i++] : 0;
    4118 #if _USE_LFN
     4118#if FF_USE_LFN
    41194119                        w = ff_convert(ff_wtoupper(ff_convert(w, 1)), 0);
    41204120#else
     
    41744174}
    41754175
    4176 #endif /* !_FS_READONLY */
    4177 #endif /* _USE_LABEL */
     4176#endif /* !FF_FS_READONLY */
     4177#endif /* FF_USE_LABEL */
    41784178
    41794179
     
    41824182/* Forward data to the stream directly (available on only tiny cfg)      */
    41834183/*-----------------------------------------------------------------------*/
    4184 #if _USE_FORWARD && _FS_TINY
     4184#if FF_USE_FORWARD && FF_FS_TINY
    41854185
    41864186FRESULT f_forward (
     
    42354235        LEAVE_FF(fp->fs, FR_OK);
    42364236}
    4237 #endif /* _USE_FORWARD */
    4238 
    4239 
    4240 
    4241 #if _USE_MKFS && !_FS_READONLY
     4237#endif /* FF_USE_FORWARD */
     4238
     4239
     4240
     4241#if FF_USE_MKFS && !FF_FS_READONLY
    42424242/*-----------------------------------------------------------------------*/
    42434243/* Create file system on the logical drive                               */
     
    42634263        FATFS *fs;
    42644264        DSTATUS stat;
    4265 #if _USE_TRIM
     4265#if FF_USE_TRIM
    42664266        DWORD eb[2];
    42674267#endif
     
    42824282        if (stat & STA_NOINIT) return FR_NOT_READY;
    42834283        if (stat & STA_PROTECT) return FR_WRITE_PROTECTED;
    4284 #if _MAX_SS != _MIN_SS          /* Get disk sector size */
    4285         if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > _MAX_SS || SS(fs) < _MIN_SS)
     4284#if FF_MAX_SS != FF_MIN_SS              /* Get disk sector size */
     4285        if (disk_ioctl(pdrv, GET_SECTOR_SIZE, &SS(fs)) != RES_OK || SS(fs) > FF_MAX_SS || SS(fs) < FF_MIN_SS)
    42864286                return FR_DISK_ERR;
    42874287#endif
    4288         if (_MULTI_PARTITION && part) {
     4288        if (FF_MULTI_PARTITION && part) {
    42894289                /* Get partition information from partition table in the MBR */
    42904290                if (disk_read(pdrv, fs->win, 0, 1) != RES_OK) return FR_DISK_ERR;
     
    43084308                au = cst[i];
    43094309        }
    4310         if (au >= _MIN_SS) au /= SS(fs);        /* Number of sectors per cluster */
     4310        if (au >= FF_MIN_SS) au /= SS(fs);      /* Number of sectors per cluster */
    43114311        if (!au) au = 1;
    43124312        if (au > 128) au = 128;
     
    43624362        }
    43634363
    4364         if (_MULTI_PARTITION && part) {
     4364        if (FF_MULTI_PARTITION && part) {
    43654365                /* Update system ID in the partition table */
    43664366                tbl = &fs->win[MBR_Table + (part - 1) * SZ_PTE];
     
    44654465        } while (--i);
    44664466
    4467 #if _USE_TRIM   /* Erase data area if needed */
     4467#if FF_USE_TRIM /* Erase data area if needed */
    44684468        {
    44694469                eb[0] = wsect; eb[1] = wsect + (n_clst - ((fmt == FS_FAT32) ? 1 : 0)) * au - 1;
     
    44884488
    44894489
    4490 #if _MULTI_PARTITION
     4490#if FF_MULTI_PARTITION
    44914491/*-----------------------------------------------------------------------*/
    44924492/* Create partition table on the physical drive                          */
     
    45184518
    45194519        /* Create partition table */
    4520         mem_set(buf, 0, _MAX_SS);
     4520        mem_set(buf, 0, FF_MAX_SS);
    45214521        p = buf + MBR_Table; b_cyl = 0;
    45224522        for (i = 0; i < 4; i++, p += SZ_PTE) {
     
    45554555
    45564556
    4557 #endif /* _MULTI_PARTITION */
    4558 #endif /* _USE_MKFS && !_FS_READONLY */
    4559 
    4560 
    4561 
    4562 
    4563 #if _USE_STRFUNC
     4557#endif /* FF_MULTI_PARTITION */
     4558#endif /* FF_USE_MKFS && !FF_FS_READONLY */
     4559
     4560
     4561
     4562
     4563#if FF_USE_STRFUNC
    45644564/*-----------------------------------------------------------------------*/
    45654565/* Get a string from the file                                            */
     
    45794579
    45804580        while (n < len - 1) {   /* Read characters until buffer gets filled */
    4581 #if _USE_LFN && _LFN_UNICODE
    4582 #if _STRF_ENCODE == 3           /* Read a character in UTF-8 */
     4581#if FF_USE_LFN && FF_LFN_UNICODE
     4582#if FF_STRF_ENCODE == 3         /* Read a character in UTF-8 */
    45834583                f_read(fp, s, 1, &rc);
    45844584                if (rc != 1) break;
     
    46024602                        }
    46034603                }
    4604 #elif _STRF_ENCODE == 2         /* Read a character in UTF-16BE */
     4604#elif FF_STRF_ENCODE == 2               /* Read a character in UTF-16BE */
    46054605                f_read(fp, s, 2, &rc);
    46064606                if (rc != 2) break;
    46074607                c = s[1] + (s[0] << 8);
    4608 #elif _STRF_ENCODE == 1         /* Read a character in UTF-16LE */
     4608#elif FF_STRF_ENCODE == 1               /* Read a character in UTF-16LE */
    46094609                f_read(fp, s, 2, &rc);
    46104610                if (rc != 2) break;
     
    46274627                c = s[0];
    46284628#endif
    4629                 if (_USE_STRFUNC == 2 && c == '\r') continue;   /* Strip '\r' */
     4629                if (FF_USE_STRFUNC == 2 && c == '\r') continue; /* Strip '\r' */
    46304630                *p++ = c;
    46314631                n++;
     
    46394639
    46404640
    4641 #if !_FS_READONLY
     4641#if !FF_FS_READONLY
    46424642/*-----------------------------------------------------------------------*/
    46434643/* Put a character to the file                                           */
     
    46614661
    46624662
    4663         if (_USE_STRFUNC == 2 && c == '\n')      /* LF -> CRLF conversion */
     4663        if (FF_USE_STRFUNC == 2 && c == '\n')    /* LF -> CRLF conversion */
    46644664                putc_bfd(pb, '\r');
    46654665
     
    46674667        if (i < 0) return;
    46684668
    4669 #if _USE_LFN && _LFN_UNICODE
    4670 #if _STRF_ENCODE == 3                   /* Write a character in UTF-8 */
     4669#if FF_USE_LFN && FF_LFN_UNICODE
     4670#if FF_STRF_ENCODE == 3                 /* Write a character in UTF-8 */
    46714671        if (c < 0x80) {                         /* 7-bit */
    46724672                pb->buf[i++] = (BYTE)c;
     
    46804680                pb->buf[i++] = (BYTE)(0x80 | (c & 0x3F));
    46814681        }
    4682 #elif _STRF_ENCODE == 2                 /* Write a character in UTF-16BE */
     4682#elif FF_STRF_ENCODE == 2                       /* Write a character in UTF-16BE */
    46834683        pb->buf[i++] = (BYTE)(c >> 8);
    46844684        pb->buf[i++] = (BYTE)c;
    4685 #elif _STRF_ENCODE == 1                 /* Write a character in UTF-16LE */
     4685#elif FF_STRF_ENCODE == 1                       /* Write a character in UTF-16LE */
    46864686        pb->buf[i++] = (BYTE)c;
    46874687        pb->buf[i++] = (BYTE)(c >> 8);
     
    48664866        ret = f_vprintf(fp, fmt, arp);
    48674867        va_end(arp);
    4868 
     4868       
    48694869        return ret;
    48704870}
    48714871
    4872 #endif /* !_FS_READONLY */
    4873 #endif /* _USE_STRFUNC */
     4872#endif /* !FF_FS_READONLY */
     4873#endif /* FF_USE_STRFUNC */
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ff.h

    r337 r374  
    2828#include "ffconf.h"             /* FatFs configuration options */
    2929#include "diskio.h"
    30 #if _FATFS != _FFCONF
     30#if _FATFS != FFCONF_DEF
    3131#error Wrong configuration file (ffconf.h).
    3232#endif
     
    3636/* Definitions of volume management */
    3737
    38 #if _MULTI_PARTITION            /* Multiple partition configuration */
     38#if FF_MULTI_PARTITION          /* Multiple partition configuration */
    3939typedef struct {
    4040        BYTE pd;        /* Physical drive number */
     
    5555/* Type of path name strings on FatFs API */
    5656
    57 #if _LFN_UNICODE                        /* Unicode string */
    58 #if !_USE_LFN
    59 #error _LFN_UNICODE must be 0 at non-LFN cfg.
     57#if FF_LFN_UNICODE                      /* Unicode string */
     58#if !FF_USE_LFN
     59#error FF_LFN_UNICODE must be 0 at non-LFN cfg.
    6060#endif
    6161#ifndef _INC_TCHAR
     
    8787        WORD    id;                             /* File system mount ID */
    8888        WORD    n_rootdir;              /* Number of root directory entries (FAT12/16) */
    89 #if _MAX_SS != _MIN_SS
     89#if FF_MAX_SS != FF_MIN_SS
    9090        WORD    ssize;                  /* Bytes per sector (512, 1024, 2048 or 4096) */
    9191#endif
    92 #if _FS_REENTRANT
    93         _SYNC_t sobj;                   /* Identifier of sync object */
    94 #endif
    95 #if !_FS_READONLY
     92#if FF_FS_REENTRANT
     93        FF_SYNC_t       sobj;                   /* Identifier of sync object */
     94#endif
     95#if !FF_FS_READONLY
    9696        DWORD   last_clust;             /* Last allocated cluster */
    9797        DWORD   free_clust;             /* Number of free clusters */
    9898#endif
    99 #if _FS_RPATH
     99#if FF_FS_RPATH
    100100        DWORD   cdir;                   /* Current directory start cluster (0:root) */
    101101#endif
     
    107107        DWORD   database;               /* Data start sector */
    108108        DWORD   winsect;                /* Current sector appearing in the win[] */
    109         BYTE    win[_MAX_SS];   /* Disk access window for Directory, FAT (and file data at tiny cfg) */
     109        BYTE    win[FF_MAX_SS]; /* Disk access window for Directory, FAT (and file data at tiny cfg) */
    110110} FATFS;
    111111
     
    124124        DWORD   clust;                  /* Current cluster of fpter (not valid when fprt is 0) */
    125125        DWORD   dsect;                  /* Sector number appearing in buf[] (0:invalid) */
    126 #if !_FS_READONLY
     126#if !FF_FS_READONLY
    127127        DWORD   dir_sect;               /* Sector number containing the directory entry */
    128128        BYTE*   dir_ptr;                /* Pointer to the directory entry in the win[] */
    129129#endif
    130 #if _USE_FASTSEEK
     130#if FF_USE_FASTSEEK
    131131        DWORD*  cltbl;                  /* Pointer to the cluster link map table (Nulled on file open) */
    132132#endif
    133 #if _FS_LOCK
     133#if FF_FS_LOCK != 0
    134134        UINT    lockid;                 /* File lock ID origin from 1 (index of file semaphore table Files[]) */
    135135#endif
    136 #if !_FS_TINY
    137         BYTE    buf[_MAX_SS];   /* File private data read/write window */
     136#if !FF_FS_TINY
     137        BYTE    buf[FF_MAX_SS]; /* File private data read/write window */
    138138#endif
    139139} FIL;
     
    141141
    142142
    143 /* Directory object structure (DIR) */
     143/* Directory object structure (FATFS_DIR) */
    144144
    145145typedef struct __dirstream {
     
    152152        BYTE*   dir;                    /* Pointer to the current SFN entry in the win[] */
    153153        BYTE*   fn;                             /* Pointer to the SFN (in/out) {file[8],ext[3],status[1]} */
    154 #if _FS_LOCK
     154#if FF_FS_LOCK != 0
    155155        UINT    lockid;                 /* File lock ID (index of file semaphore table Files[]) */
    156156#endif
    157 #if _USE_LFN
     157#if FF_USE_LFN
    158158        WCHAR*  lfn;                    /* Pointer to the LFN working buffer */
    159159        WORD    lfn_idx;                /* Last matched LFN index number (0xFFFF:No LFN) */
    160160#endif
    161 #if _USE_FIND
     161#if FF_USE_FIND
    162162        const TCHAR*    pat;    /* Pointer to the name matching pattern */
    163163#endif
    164 } DIR;
     164} FATFS_DIR;
    165165
    166166
     
    174174        BYTE    fattrib;                /* Attribute */
    175175        TCHAR   fname[13];              /* Short file name (8.3 format) */
    176 #if _USE_LFN
     176#if FF_USE_LFN
    177177        TCHAR*  lfname;                 /* Pointer to the LFN buffer */
    178178        UINT    lfsize;                 /* Size of LFN buffer in TCHAR */
     
    203203        FR_LOCKED,                              /* (16) The operation is rejected according to the file sharing policy */
    204204        FR_NOT_ENOUGH_CORE,             /* (17) LFN working buffer could not be allocated */
    205         FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > _FS_LOCK */
     205        FR_TOO_MANY_OPEN_FILES, /* (18) Number of open files > FF_FS_LOCK */
    206206        FR_INVALID_PARAMETER    /* (19) Given parameter is invalid */
    207207} FRESULT;
     
    220220FRESULT f_truncate (FIL* fp);                                                                           /* Truncate file */
    221221FRESULT f_sync (FIL* fp);                                                                                       /* Flush cached data of a writing file */
    222 FRESULT f_opendir (DIR* dp, const TCHAR* path);                                         /* Open a directory */
    223 FRESULT f_closedir (DIR* dp);                                                                           /* Close an open directory */
    224 FRESULT f_readdir (DIR* dp, FILINFO* fno);                                                      /* Read a directory item */
    225 FRESULT f_findfirst (DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);   /* Find first file */
    226 FRESULT f_findnext (DIR* dp, FILINFO* fno);                                                     /* Find next file */
     222FRESULT f_opendir (FATFS_DIR* dp, const TCHAR* path);                                           /* Open a directory */
     223FRESULT f_closedir (FATFS_DIR* dp);                                                                             /* Close an open directory */
     224FRESULT f_readdir (FATFS_DIR* dp, FILINFO* fno);                                                        /* Read a directory item */
     225FRESULT f_findfirst (FATFS_DIR* dp, FILINFO* fno, const TCHAR* path, const TCHAR* pattern);     /* Find first file */
     226FRESULT f_findnext (FATFS_DIR* dp, FILINFO* fno);                                                       /* Find next file */
    227227FRESULT f_mkdir (const TCHAR* path);                                                            /* Create a sub directory */
    228228FRESULT f_unlink (const TCHAR* path);                                                           /* Delete an existing file or directory */
     
    270270
    271271/* RTC function */
    272 #if !_FS_READONLY && !_FS_NORTC
     272#if !FF_FS_READONLY && !FF_FS_NORTC
    273273DWORD get_fattime (void);
    274274#endif
    275275
    276276/* Unicode support functions */
    277 #if _USE_LFN                                                    /* Unicode - OEM code conversion */
     277#if FF_USE_LFN                                                  /* Unicode - OEM code conversion */
    278278WCHAR ff_convert (WCHAR chr, UINT dir); /* OEM-Unicode bidirectional conversion */
    279279WCHAR ff_wtoupper (WCHAR chr);                  /* Unicode upper-case conversion */
    280 #if _USE_LFN == 3                                               /* Memory functions */
     280#if FF_USE_LFN == 3                                             /* Memory functions */
    281281void* ff_memalloc (UINT msize);                 /* Allocate memory block */
    282282void ff_memfree (void* mblock);                 /* Free memory block */
     
    285285
    286286/* Sync functions */
    287 #if _FS_REENTRANT
    288 int ff_cre_syncobj (BYTE vol, _SYNC_t* sobj);   /* Create a sync object */
    289 int ff_req_grant (_SYNC_t sobj);                                /* Lock sync object */
    290 void ff_rel_grant (_SYNC_t sobj);                               /* Unlock sync object */
    291 int ff_del_syncobj (_SYNC_t sobj);                              /* Delete a sync object */
     287#if FF_FS_REENTRANT
     288int ff_cre_syncobj (BYTE vol, FF_SYNC_t* sobj); /* Create a sync object */
     289int ff_req_grant (FF_SYNC_t sobj);                              /* Lock sync object */
     290void ff_rel_grant (FF_SYNC_t sobj);                             /* Unlock sync object */
     291int ff_del_syncobj (FF_SYNC_t sobj);                            /* Delete a sync object */
    292292#endif
    293293
     
    304304#define FA_OPEN_EXISTING        0x00
    305305
    306 #if !_FS_READONLY
     306#if !FF_FS_READONLY
    307307#define FA_WRITE                        0x02
    308308#define FA_CREATE_NEW           0x04
    309309#define FA_CREATE_ALWAYS        0x08
    310310#define FA_OPEN_ALWAYS          0x10
    311 #define FA__WRITTEN                     0x20
    312 #define FA__DIRTY                       0x40
     311#define FA_OPEN_APPEND          0x30
     312#define FA_MODIFIED                     0x20
     313#define FA_DIRTY                        0x40
    313314#endif
    314315
     
    341342/* Multi-byte word access macros  */
    342343
    343 #if _WORD_ACCESS == 1   /* Enable word access to the FAT structure */
     344#if FF_WORD_ACCESS == 1 /* Enable word access to the FAT structure */
    344345#define LD_WORD(ptr)            (WORD)(*(WORD*)(BYTE*)(ptr))
    345346#define LD_DWORD(ptr)           (DWORD)(*(DWORD*)(BYTE*)(ptr))
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ffarch.c

    r364 r374  
    5454#include "ff.h"
    5555#include "ffarch.h"
    56 #include "util/ntstdio.h"
    57 #include "mbed_api.h"
    58 
    59 extern ntstdio_t ntstdio;
     56#include <stdio.h>
     57#include "gpio_api.h"
     58#include "rtc_api.h"
    6059
    6160enum ffarch_state_t {
     
    8584        ret2 = get_tim(&now);
    8685        if (ret2 != E_OK){
    87                 ntstdio_printf(&ntstdio, "[ffarch] get_tim error: %s",
     86                printf("[ffarch] get_tim error: %s",
    8887                        itron_strerror(ret2));
    8988                return;
     
    9998                ret = tslp_tsk(timer);
    10099                if ((ret != E_OK) && (ret != E_TMOUT)) {
    101                         ntstdio_printf(&ntstdio, "[ffarch] tslp_tsk error: %s %d",
     100                        printf("[ffarch] tslp_tsk error: %s %d",
    102101                                itron_strerror(ret), timer);
    103102                        break;
     
    106105                ret2 = get_tim(&now);
    107106                if (ret2 != E_OK) {
    108                         ntstdio_printf(&ntstdio, "[ffarch] get_tim error: %s",
     107                        printf("[ffarch] get_tim error: %s",
    109108                                itron_strerror(ret2));
    110109                        break;
     
    151150#endif
    152151        if (romdisk_init()) {
    153                 ntstdio_printf(&ntstdio, "ROM disk (0:) OK!\n");
     152                printf("ROM disk (0:) OK!\n");
    154153        }
    155154        else {
    156                 ntstdio_printf(&ntstdio, "ROM disk (0:) NG!\n");
     155                printf("ROM disk (0:) NG!\n");
    157156        }
    158157}
     
    304303        case FFS_RETRY_WAIT:
    305304                if (ffarch_retry_count == 0) {
    306                         ntstdio_printf(&ntstdio, "SD card (1:) initialize tired...\n");
     305                        printf("SD card (1:) initialize tired...\n");
    307306
    308307                        ffarch_state = FFS_IDLE;
     
    316315                /* SDカードが入れられた場合 */
    317316                if (((mmc_rspi_prev_status & STA_NODISK) != 0) && ((mmc_rspi_status() & STA_NODISK) == 0)) {
    318                         ntstdio_printf(&ntstdio, "SD card initializing ...\n");
     317                        printf("SD card initializing ...\n");
    319318
    320319                        Sd.FatFs.fs_type = 0;
    321320                        if (SD_begin()) {
    322                                 ntstdio_printf(&ntstdio, "SD card (1:) OK!\n");
     321                                printf("SD card (1:) OK!\n");
    323322
    324323                                /* uploadディレクトリを作成しておく */
     
    330329                        }
    331330                        else {
    332                                 ntstdio_printf(&ntstdio, "SD card (1:) NG!\n");
     331                                printf("SD card (1:) NG!\n");
    333332                                ffarch_state = FFS_RETRY_WAIT;
    334333                                ffarch_timer = 1000 * 1000;
     
    337336                /* SDカードが抜かれた場合 */
    338337                else if (((mmc_rspi_prev_status & STA_NODISK) == 0) && ((mmc_rspi_status() & STA_NODISK) != 0)) {
    339                         ntstdio_printf(&ntstdio, "SD card unmount\n");
     338                        printf("SD card unmount\n");
    340339
    341340                        f_mount(&Sd.FatFs, "1:", 0);
     
    349348}
    350349
    351 int ff_cre_syncobj(BYTE vol, _SYNC_t* sobj)
     350int ff_cre_syncobj(BYTE vol, FF_SYNC_t* sobj)
    352351{
    353352        return 1;
    354353}
    355354
    356 int ff_req_grant(_SYNC_t sobj)
     355int ff_req_grant(FF_SYNC_t sobj)
    357356{
    358357        ER ret;
     
    361360}
    362361
    363 void ff_rel_grant(_SYNC_t sobj)
     362void ff_rel_grant(FF_SYNC_t sobj)
    364363{
    365364        sig_sem(SEM_FILESYSTEM);
    366365}
    367366
    368 int ff_del_syncobj(_SYNC_t sobj)
     367int ff_del_syncobj(FF_SYNC_t sobj)
    369368{
    370369        return 1;
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/ffconf.h

    r337 r374  
    33/---------------------------------------------------------------------------*/
    44
    5 #define _FFCONF 64180   /* Revision ID */
     5#define FFCONF_DEF 64180        /* Revision ID */
     6
     7#define FFS_DBG                 0
    68
    79/*---------------------------------------------------------------------------/
     
    911/---------------------------------------------------------------------------*/
    1012
    11 #define _FS_READONLY    0
     13#define FF_FS_READONLY  0
    1214/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
    1315/  Read-only configuration removes writing API functions, f_write(), f_sync(),
     
    1618
    1719
    18 #define _FS_MINIMIZE    0
     20#define FF_FS_MINIMIZE  0
    1921/* This option defines minimization level to remove some basic API functions.
    2022/
     
    2628
    2729
    28 #define _USE_STRFUNC    1
     30#define FF_USE_STRFUNC  1
    2931/* This option switches string functions, f_gets(), f_putc(), f_puts() and
    3032/  f_printf().
     
    3537
    3638
    37 #define _USE_FIND               1
     39#define FF_USE_FIND             1
    3840/* This option switches filtered directory read feature and related functions,
    3941/  f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
    4042
    4143
    42 #define _USE_MKFS               1
     44#define FF_USE_MKFS             1
    4345/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
    4446
    4547
    46 #define _USE_FASTSEEK   0
     48#define FF_USE_FASTSEEK 0
    4749/* This option switches fast seek feature. (0:Disable or 1:Enable) */
    4850
    4951
    50 #define _USE_LABEL              1
     52#define FF_USE_LABEL            1
    5153/* This option switches volume label functions, f_getlabel() and f_setlabel().
    5254/  (0:Disable or 1:Enable) */
    5355
    5456
    55 #define _USE_FORWARD    1
     57#define FF_USE_FORWARD  1
    5658/* This option switches f_forward() function. (0:Disable or 1:Enable)
    57 /  To enable it, also _FS_TINY need to be set to 1. */
     59/  To enable it, also FF_FS_TINY need to be set to 1. */
    5860
    5961
     
    6264/---------------------------------------------------------------------------*/
    6365
    64 #define _CODE_PAGE 65001
     66#define FF_CODE_PAGE 65001
    6567/* This option specifies the OEM code page to be used on the target system.
    6668/  Incorrect setting of the code page can cause a file open failure.
     
    9193
    9294
    93 #define _USE_LFN        3
    94 #define _MAX_LFN        255
    95 /* The _USE_LFN option switches the LFN feature.
    96 /
    97 /   0: Disable LFN feature. _MAX_LFN has no effect.
     95#define FF_USE_LFN      3
     96#define FF_MAX_LFN      255
     97/* The FF_USE_LFN option switches the LFN feature.
     98/
     99/   0: Disable LFN feature. FF_MAX_LFN has no effect.
    98100/   1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
    99101/   2: Enable LFN with dynamic working buffer on the STACK.
     
    101103/
    102104/  When enable the LFN feature, Unicode handling functions (option/unicode.c) must
    103 /  be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
     105/  be added to the project. The LFN working buffer occupies (FF_MAX_LFN + 1) * 2 bytes.
    104106/  When use stack for the working buffer, take care on stack overflow. When use heap
    105107/  memory for the working buffer, memory management functions, ff_memalloc() and
     
    107109
    108110
    109 #define _LFN_UNICODE    0
     111#define FF_LFN_UNICODE  0
    110112/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
    111 /  To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
     113/  To use Unicode string for the path name, enable LFN feature and set FF_LFN_UNICODE
    112114/  to 1. This option also affects behavior of string I/O functions. */
    113115
    114116
    115 #define _STRF_ENCODE    3
    116 /* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
     117#define FF_STRF_ENCODE  3
     118/* When FF_LFN_UNICODE is 1, this option selects the character encoding on the file to
    117119/  be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
    118120/
     
    122124/  3: UTF-8
    123125/
    124 /  When _LFN_UNICODE is 0, this option has no effect. */
    125 
    126 
    127 #define _FS_RPATH       2
     126/  When FF_LFN_UNICODE is 0, this option has no effect. */
     127
     128
     129#define FF_LFN_BUF              255
     130#define FF_SFN_BUF              12
     131/* This set of options defines size of file name members in the FILINFO structure
     132/  which is used to read out directory items. These values should be suffcient for
     133/  the file names to read. The maximum possible length of the read file name depends
     134/  on character encoding. When LFN is not enabled, these options have no effect. */
     135
     136
     137#define FF_FS_RPATH     2
    128138/* This option configures relative path feature.
    129139/
     
    139149/---------------------------------------------------------------------------*/
    140150
    141 #define _VOLUMES        2
     151#define FF_VOLUMES      4
    142152/* Number of volumes (logical drives) to be used. */
    143153
    144154
    145 #define _STR_VOLUME_ID  0
    146 #define _VOLUME_STRS    "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
    147 /* _STR_VOLUME_ID option switches string volume ID feature.
    148 /  When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
    149 /  number in the path name. _VOLUME_STRS defines the drive ID strings for each
    150 /  logical drives. Number of items must be equal to _VOLUMES. Valid characters for
     155#define FF_STR_VOLUME_ID        0
     156#define FF_VOLUME_STRS  "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
     157/* FF_STR_VOLUME_ID option switches string volume ID feature.
     158/  When FF_STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
     159/  number in the path name. FF_VOLUME_STRS defines the drive ID strings for each
     160/  logical drives. Number of items must be equal to FF_VOLUMES. Valid characters for
    151161/  the drive ID strings are: A-Z and 0-9. */
    152162
    153163
    154 #define _MULTI_PARTITION        0
     164#define FF_MULTI_PARTITION      0
    155165/* This option switches multi-partition feature. By default (0), each logical drive
    156166/  number is bound to the same physical drive number and only an FAT volume found on
     
    160170
    161171
    162 #define _MIN_SS         512
    163 #define _MAX_SS         512
     172#define FF_MIN_SS               512
     173#define FF_MAX_SS               512
    164174/* These options configure the range of sector size to be supported. (512, 1024,
    165175/  2048 or 4096) Always set both 512 for most systems, all type of memory cards and
    166176/  harddisk. But a larger value may be required for on-board flash memory and some
    167 /  type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
     177/  type of optical media. When FF_MAX_SS is larger than FF_MIN_SS, FatFs is configured
    168178/  to variable sector size and GET_SECTOR_SIZE command must be implemented to the
    169179/  disk_ioctl() function. */
    170180
    171181
    172 #define _USE_TRIM       0
     182#define FF_USE_TRIM     0
    173183/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
    174184/  To enable Trim feature, also CTRL_TRIM command should be implemented to the
     
    176186
    177187
    178 #define _FS_NOFSINFO    0
     188#define FF_FS_NOFSINFO  0
    179189/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
    180190/  option, and f_getfree() function at first time after volume mount will force
     
    193203/---------------------------------------------------------------------------*/
    194204
    195 #define _FS_TINY        1
     205#define FF_FS_TINY      1
    196206/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
    197 /  At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
     207/  At the tiny configuration, size of the file object (FIL) is reduced FF_MAX_SS
    198208/  bytes. Instead of private sector buffer eliminated from the file object,
    199209/  common sector buffer in the file system object (FATFS) is used for the file
     
    201211
    202212
    203 #define _FS_NORTC       0
    204 #define _NORTC_MON      1
    205 #define _NORTC_MDAY     1
    206 #define _NORTC_YEAR     2015
    207 /* The _FS_NORTC option switches timestamp feature. If the system does not have
    208 /  an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
     213#define FF_FS_NORTC     0
     214#define FF_NORTC_MON    1
     215#define FF_NORTC_MDAY   1
     216#define FF_NORTC_YEAR   2015
     217/* The FF_FS_NORTC option switches timestamp feature. If the system does not have
     218/  an RTC function or valid timestamp is not needed, set FF_FS_NORTC to 1 to disable
    209219/  the timestamp feature. All objects modified by FatFs will have a fixed timestamp
    210 /  defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
    211 /  When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
    212 /  to be added to the project to read current time form RTC. _NORTC_MON,
    213 _NORTC_MDAY and _NORTC_YEAR have no effect.
    214 /  These options have no effect at read-only configuration (_FS_READONLY == 1). */
    215 
    216 
    217 #define _FS_LOCK        0
    218 /* The _FS_LOCK option switches file lock feature to control duplicated file open
    219 /  and illegal operation to open objects. This option must be 0 when _FS_READONLY
     220/  defined by FF_NORTC_MON, FF_NORTC_MDAY and FF_NORTC_YEAR.
     221/  When timestamp feature is enabled (FF_FS_NORTC == 0), get_fattime() function need
     222/  to be added to the project to read current time form RTC. FF_NORTC_MON,
     223FF_NORTC_MDAY and FF_NORTC_YEAR have no effect.
     224/  These options have no effect at read-only configuration (FF_FS_READONLY == 1). */
     225
     226
     227#define FF_FS_LOCK      0
     228/* The FF_FS_LOCK option switches file lock feature to control duplicated file open
     229/  and illegal operation to open objects. This option must be 0 when FF_FS_READONLY
    220230/  is 1.
    221231/
     
    227237
    228238
    229 #define _FS_REENTRANT   1
    230 #define _FS_TIMEOUT             1000
    231 #define _SYNC_t                 unsigned int
    232 /* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
     239#define FF_FS_REENTRANT 1
     240#define FF_FS_TIMEOUT           1000
     241#define FF_SYNC_t                       unsigned int
     242/* The FF_FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
    233243/  module itself. Note that regardless of this option, file access to different
    234244/  volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
     
    236246/  to the same volume is under control of this feature.
    237247/
    238 /   0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
     248/   0: Disable re-entrancy. FF_FS_TIMEOUT and FF_SYNC_t have no effect.
    239249/   1: Enable re-entrancy. Also user provided synchronization handlers,
    240250/      ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
     
    242252/      option/syscall.c.
    243253/
    244 /  The _FS_TIMEOUT defines timeout period in unit of time tick.
    245 /  The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
     254/  The FF_FS_TIMEOUT defines timeout period in unit of time tick.
     255/  The FF_SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
    246256/  SemaphoreHandle_t and etc.. A header file for O/S definitions needs to be
    247257/  included somewhere in the scope of ff.c. */
    248258
    249259
    250 #define _WORD_ACCESS    1
    251 /* The _WORD_ACCESS option is an only platform dependent option. It defines
     260#define FF_WORD_ACCESS  1
     261/* The FF_WORD_ACCESS option is an only platform dependent option. It defines
    252262/  which access method is used to the word data on the FAT volume.
    253263/
     
    258268/  * Byte order on the memory is little-endian.
    259269/
    260 /  If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
     270/  If it is the case, FF_WORD_ACCESS can also be set to 1 to reduce code size.
    261271/  Following table shows allowable settings of some type of processors.
    262272/
  • asp3_tinet_ecnl_rx/trunk/ntshell/fatfs/mmc_rspi.c

    r359 r374  
    663663                break;
    664664
    665         case CTRL_TRIM: /* Erase a block of sectors (used when _USE_TRIM == 1) */
     665        case CTRL_TRIM: /* Erase a block of sectors (used when FF_USE_TRIM == 1) */
    666666                if (!(CardType & CT_SDC)) break;                                /* Check if the card is SDC */
    667667                if (mmc_rspi_ioctl(MMC_GET_CSD, csd)) break;    /* Get CSD */
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.c

    r340 r374  
    4747#include "core/ntshell.h"
    4848#include "core/ntlibc.h"
    49 #include "util/ntstdio.h"
    50 
    51 extern ntstdio_t ntstdio;
     49#include <stdio.h>
     50#include <getopt.h>
     51
    5252extern int ntshell_exit;
    53 
    54 extern int mbtowc(wchar_t *__restrict wc, const char *__restrict src, size_t n);
    55 
    56 /* musl_getopt from msul */
    57 char *optarg;
    58 int optind=1, opterr=1, optopt, optpos, optreset=0;
    59 extern int optind, opterr;
    60 
    61 static void ntstdio_write(ntstdio_t *handle, const char *str, int l)
    62 {
    63         for (; *str && l >= 0; l--) {
    64                 ntstdio_putc(handle, *str++);
    65         }
    66 }
    67 
    68 static void __getopt_msg(const char *a, const char *b, const char *c, size_t l)
    69 {
    70         ntstdio_puts(&ntstdio, a);
    71         ntstdio_write(&ntstdio, b, strlen(b));
    72         ntstdio_write(&ntstdio, c, l);
    73         ntstdio_putc(&ntstdio, '\n');
    74 }
    75 
    76 static int musl_getopt(int argc, char * const argv[], const char *optstring)
    77 {
    78         int i;
    79         wchar_t c, d;
    80         int k, l;
    81         char *optchar;
    82 
    83         if (!optind || optreset) {
    84                 optreset = 0;
    85                 optpos = 0;
    86                 optind = 1;
    87         }
    88 
    89         if (optind >= argc || !argv[optind])
    90                 return -1;
    91 
    92         if (argv[optind][0] != '-') {
    93                 if (optstring[0] == '-') {
    94                         optarg = argv[optind++];
    95                         return 1;
    96                 }
    97                 return -1;
    98         }
    99 
    100         if (!argv[optind][1])
    101                 return -1;
    102 
    103         if (argv[optind][1] == '-' && !argv[optind][2])
    104                 return optind++, -1;
    105 
    106         if (!optpos) optpos++;
    107         if ((k = mbtowc(&c, argv[optind]+optpos, MB_LEN_MAX)) < 0) {
    108                 k = 1;
    109                 c = 0xfffd; /* replacement char */
    110         }
    111         optchar = argv[optind]+optpos;
    112         optopt = c;
    113         optpos += k;
    114 
    115         if (!argv[optind][optpos]) {
    116                 optind++;
    117                 optpos = 0;
    118         }
    119 
    120         if (optstring[0] == '-' || optstring[0] == '+')
    121                 optstring++;
    122 
    123         i = 0;
    124         d = 0;
    125         do {
    126                 l = mbtowc(&d, optstring+i, MB_LEN_MAX);
    127                 if (l>0) i+=l; else i++;
    128         } while (l && d != c);
    129 
    130         if (d != c) {
    131                 if (optstring[0] != ':' && opterr)
    132                         __getopt_msg(argv[0], ": unrecognized option: ", optchar, k);
    133                 return '?';
    134         }
    135         if (optstring[i] == ':') {
    136                 if (optstring[i+1] == ':') optarg = 0;
    137                 else if (optind >= argc) {
    138                         if (optstring[0] == ':') return ':';
    139                         if (opterr) __getopt_msg(argv[0],
    140                                 ": option requires an argument: ",
    141                                 optchar, k);
    142                         return '?';
    143                 }
    144                 if (optstring[i+1] != ':' || optpos) {
    145                         optarg = argv[optind++] + optpos;
    146                         optpos = 0;
    147                 }
    148         }
    149         return c;
    150 }
    151 
    152 int shell_kill(int pid, int sig)
    153 {
    154         DebugBreak();
    155         return -1;
    156 }
    157 
    158 int shell_gettimeofday(struct timeval *tv, void *tzvp)
    159 {
    160         SYSTIM time;
    161         if (!tv) return 0;
    162         get_tim(&time);
    163         tv->tv_sec = time / 1000000;
    164         tv->tv_usec = time - (tv->tv_sec * 1000000);
    165         return 0;
    166 }
    16753
    16854void put_rc(const char *func, FRESULT rc)
     
    17864                while (*p++);
    17965        }
    180         ntstdio_printf(&ntstdio, "%s() =>%u FR_%s\n", func, (UINT)rc, p);
     66        printf("%s() =>%u FR_%s\n", func, (UINT)rc, p);
    18167}
    18268
     
    19076                while (*p++);
    19177        }
    192         ntstdio_printf(&ntstdio, "%s() =>%u %s\n", func, (UINT)rc, p);
     78        printf("%s() =>%u %s\n", func, (UINT)rc, p);
    19379}
    19480
     
    240126
    241127        ntlibc_strlcat(path, "\n", sizeof(path));
    242         ntstdio_printf(&ntstdio, path);
     128        printf(path);
    243129
    244130        return 0;
     
    252138        char *fn;
    253139
    254 #if _USE_LFN
     140#if FF_USE_LFN
    255141        fn = *fno->lfname ? fno->lfname : fno->fname;
    256142#else
     
    263149
    264150        if (list_option & LS_LONG) {
    265                 ntstdio_printf(&ntstdio, "%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
     151                printf("%c%c%c%c%c %04d/%02d/%02d %02d:%02d:%02d ",
    266152                        (fno->fattrib & AM_DIR) ? 'd' : '-',
    267153                        (fno->fattrib & AM_RDO) ? 'r' : '-',
     
    277163
    278164                if (fno->fattrib & AM_DIR) {                    /* It is a directory */
    279                         ntstdio_printf(&ntstdio, "%10S ", " ");
     165                        printf("%10s ", " ");
    280166                }
    281167                else {
    282                         ntstdio_printf(&ntstdio, "%10d ", fno->fsize);
     168                        printf("%10lu ", fno->fsize);
    283169                }
    284170        }
    285171
    286172        if (fno->fattrib & AM_DIR) {                    /* It is a directory */
    287                 ntstdio_printf(&ntstdio, "\x1B[32m%s\x1B[0m\n", fn);
     173                printf("\x1B[32m%s\x1B[0m\n", fn);
    288174        }
    289175        else {
    290                 ntstdio_printf(&ntstdio, "%s\n", fn);
    291         }
    292 }
    293 
    294 #define LFN_BUF_SIZE (_MAX_LFN + 1)
     176                printf("%s\n", fn);
     177        }
     178}
     179
     180#define LFN_BUF_SIZE (FF_MAX_LFN + 1)
    295181/* lsコマンド dir内 表示 */
    296182void print_ls(char *path_p, char *pattern_p, BYTE list_option)
     
    298184        FRESULT res;
    299185        FILINFO fno;
    300         DIR dir;
     186        FATFS_DIR dir;
    301187        char *fn;   /* This function assumes non-Unicode configuration */
    302188
     
    307193        path_backup = ff_memalloc(LFN_BUF_SIZE);
    308194        if (path_backup == NULL) {
    309                 ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
     195                printf("ff_memalloc err.\n");
    310196                return;
    311197        }
    312198
    313 #if _USE_LFN
     199#if FF_USE_LFN
    314200        char *lfn = NULL;
    315201        lfn = ff_memalloc(LFN_BUF_SIZE);
    316202        if (lfn == NULL) {
    317                 ntstdio_printf(&ntstdio, "ff_memalloc err.\n");
     203                printf("ff_memalloc err.\n");
    318204                ff_memfree(path_backup);
    319205                return;
     
    333219
    334220        while ((res == FR_OK) && (fno.fname[0] != 0)) {
    335                 if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* DIR とパターンマッチしている場合は DIR 内部を ls する */
    336 #if _USE_LFN
     221                if (pattern_p != NULL && (fno.fattrib & AM_DIR) && ((fno.fname[0] == '.') ? (pattern_p[0] == '.') : 1)) {/* FATFS_DIR とパターンマッチしている場合は FATFS_DIR 内部を ls する */
     222#if FF_USE_LFN
    337223                        fn = *fno.lfname ? fno.lfname : fno.fname;
    338224#else
     
    351237                        }
    352238
    353                         ntstdio_printf(&ntstdio, "\n%s/%s:\n", path_p, fn);
     239                        printf("\n%s/%s:\n", path_p, fn);
    354240
    355241                        print_ls(fn, NULL, list_option);
    356242
    357                         ntstdio_printf(&ntstdio, "\n");
     243                        printf("\n");
    358244
    359245                        if ((res = f_chdrive(path_backup)) != FR_OK) {
     
    384270{
    385271        char *pattern_p = NULL, *basename_p = NULL, *dirname_p = NULL;
    386         char default_pattern[_MAX_LFN] = "";
     272        char default_pattern[FF_MAX_LFN] = "";
    387273        int c;
    388274        BYTE list_option = 0;
    389275
    390         while ((c = musl_getopt(argc, argv, "al")) != -1) {
     276        while ((c = getopt(argc, argv, "al")) != -1) {
    391277                switch (c) {
    392278                case 'a':
     
    446332                return 0;
    447333
    448 #if _USE_LFN
     334#if FF_USE_LFN
    449335        /* LFN buffer alloc */
    450336        lfn = ff_memalloc(LFN_BUF_SIZE);
    451337        if (lfn == NULL) {
    452                 ntstdio_printf(&ntstdio, "alloc err.\n");
     338                printf("alloc err.\n");
    453339                goto cp_end;
    454340        }
     
    460346        local_buff = ff_memalloc(64);
    461347        if (local_buff == NULL) {
    462                 ntstdio_printf(&ntstdio, "alloc err.\n");
     348                printf("alloc err.\n");
    463349                goto cp_end;
    464350        }
     
    470356        if (res != FR_OK) {
    471357                if (res == FR_NO_FILE)
    472                         ntstdio_printf(&ntstdio, "src no file.\n", res);
     358                        printf("src no file.\n");
    473359                else
    474                         ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
     360                        printf("src stat err(%d).\n", res);
    475361                goto cp_end;
    476362        }
     
    481367                res = f_open(&src_fp, src_str_p, (FA_OPEN_EXISTING | FA_READ));
    482368                if (res != FR_OK) {
    483                         ntstdio_printf(&ntstdio, "src open err(%d).\n", res);
     369                        printf("src open err(%d).\n", res);
    484370                        goto cp_end;
    485371                }
     
    496382                                dst_mod_str_p = ff_memalloc(LFN_BUF_SIZE);
    497383                                if (dst_mod_str_p == NULL) {
    498                                         ntstdio_printf(&ntstdio, "alloc err.\n");
     384                                        printf("alloc err.\n");
    499385                                        goto cp_end;
    500386                                }
    501                                 ntstdio_snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
     387                                snprintf(dst_mod_str_p, LFN_BUF_SIZE, "%s/%s\0", dst_str_p, src_basename_p);
    502388                                dst_str_p = dst_mod_str_p;
    503389                        }
    504390                        else {
    505                                 ntstdio_printf(&ntstdio, "dst file exists.\n");
     391                                printf("dst file exists.\n");
    506392                                goto cp_end_1;
    507393                        }
    508394                }
    509395                else {
    510                         ntstdio_printf(&ntstdio, "src stat err(%d).\n", res);
     396                        printf("src stat err(%d).\n", res);
    511397                        goto cp_end_1;
    512398                }
     
    514400        res = f_open(&dst_fp, dst_str_p, (FA_CREATE_NEW | FA_WRITE));
    515401        if (res != FR_OK) {
    516                 ntstdio_printf(&ntstdio, "dst open err(%d).\n", res);
     402                printf("dst open err(%d).\n", res);
    517403                goto cp_end_1;
    518404        }
     
    525411                res = f_read(&src_fp, local_buff, sizeof(local_buff), &read_size);
    526412                if (res != FR_OK) {
    527                         ntstdio_printf(&ntstdio, "src read err(%d).\n", res);
     413                        printf("src read err(%d).\n", res);
    528414                        goto cp_end_2;
    529415                }
     
    532418                res = f_write(&dst_fp, local_buff, read_size, &write_size);
    533419                if (res != FR_OK) {
    534                         ntstdio_printf(&ntstdio, "dst write err(%d).\n", res);
     420                        printf("dst write err(%d).\n", res);
    535421                        goto cp_end_2;
    536422                }
    537423                if (read_size != write_size) {
    538                         ntstdio_printf(&ntstdio, "dst write err(disk full).\n", res);
     424                        printf("dst write err(disk full).\n");
    539425                        goto cp_end_2;
    540426                }
     
    622508        unsigned int op_offset = 0, op_size = 0, op_end = 0;
    623509
    624         while ((op = musl_getopt(argc, argv, "hduos0123456789xX")) != -1) {
     510        while ((op = getopt(argc, argv, "hduos0123456789xX")) != -1) {
    625511                switch (op) {
    626512                case 'h': /* help */
    627                         ntstdio_printf(&ntstdio, " hexdump [OPTION] file\n");
    628                         ntstdio_printf(&ntstdio, "  -h : help\n");
    629                         ntstdio_printf(&ntstdio, "  -d : print all byte with convert and color [in character area] (default)\n");
    630                         ntstdio_printf(&ntstdio, "  -u : try print UTF-8 code [in character area]\n");
    631                         ntstdio_printf(&ntstdio, "  -oOFFSET : print start offset address from top\n");
    632                         ntstdio_printf(&ntstdio, "  -sSIZE   : print size\n");
     513                        printf(" hexdump [OPTION] file\n");
     514                        printf("  -h : help\n");
     515                        printf("  -d : print all byte with convert and color [in character area] (default)\n");
     516                        printf("  -u : try print UTF-8 code [in character area]\n");
     517                        printf("  -oOFFSET : print start offset address from top\n");
     518                        printf("  -sSIZE   : print size\n");
    633519                        break;
    634520                case 'd': /* print one byte character [in character area] (default) */
     
    661547        /* position adjusting */
    662548        if (op_offset >= fsrc.fsize) {
    663                 ntstdio_printf(&ntstdio, "error : input offset is bigger than file size(0x%X).\n", fsrc.fsize);
     549                printf("error : input offset is bigger than file size(0x%lX).\n", fsrc.fsize);
    664550                return 0;
    665551        }
     
    674560                char *pos = line;
    675561                int rst = sizeof(line);
    676                 int len = ntstdio_snprintf(pos, rst, "%08X: ", i);
     562                int len = snprintf(pos, rst, "%08X: ", i);
    677563                pos += len;
    678564                rst -= len;
     
    693579                        char c = data[j];
    694580                        if (j != 7)
    695                                 len = ntstdio_snprintf(pos, rst, "%02X ", c);
     581                                len = snprintf(pos, rst, "%02X ", c);
    696582                        else
    697                                 len = ntstdio_snprintf(pos, rst, "%02X-", c);
     583                                len = snprintf(pos, rst, "%02X-", c);
    698584                        pos += len;
    699585                        rst -= len;
     
    723609                                                                break;
    724610                                                        if (j + k != 7)
    725                                                                 len = ntstdio_snprintf(pos, rst, "%02X ", data[j + k]);
     611                                                                len = snprintf(pos, rst, "%02X ", data[j + k]);
    726612                                                        else
    727                                                                 len = ntstdio_snprintf(pos, rst, "%02X-", data[j + k]);
     613                                                                len = snprintf(pos, rst, "%02X-", data[j + k]);
    728614                                                        pos += len;
    729615                                                        rst -= len;
     
    743629                                apos += len;
    744630                                arst -= len;
    745                                 len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
     631                                len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", CCOLOR_RESET, ' ');
    746632                                utf8_odd_bytes--;
    747633                        }
     
    763649                                        c = '?';
    764650                                }
    765                                 len = ntstdio_snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
     651                                len = snprintf(apos, arst, "\x1B[%dm%c\x1B[0m", ccolor, c);
    766652                        }
    767653
     
    772658                for (int j = br; j < 16; j++) {
    773659                        if (j != 7)
    774                                 len = ntstdio_snprintf(pos, rst, "   ");
     660                                len = snprintf(pos, rst, "   ");
    775661                        else
    776                                 len = ntstdio_snprintf(pos, rst, "  -");
     662                                len = snprintf(pos, rst, "  -");
    777663                        pos += len;
    778664                        rst -= len;
    779665                }
    780666
    781                 len = ntstdio_snprintf(pos, rst, ": %s\n", ascii);
     667                len = snprintf(pos, rst, ": %s\n", ascii);
    782668                pos += len;
    783669                rst -= len;
    784670
    785                 ntstdio_puts(&ntstdio, line);
     671                puts(line);
    786672        }
    787673
     
    796682        char buf[30];
    797683
    798         ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
     684        ret = clock_gettime(CLOCK_REALTIME, &tp);
    799685        if (ret != 0) {
    800                 ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
     686                printf("clock_gettime error %d", ret);
    801687                return 0;
    802688        }
     
    804690        memset(buf, 0, sizeof(buf));
    805691        if (ctime_r(&tp.tv_sec, buf) == NULL) {
    806                 ntstdio_printf(&ntstdio, "ctime_r error");
     692                printf("ctime_r error");
    807693                return 0;
    808694        }
     
    812698        buf[ret - 1] = '\0';
    813699
    814         ntstdio_printf(&ntstdio, "%s .%09u\n", buf, tp.tv_nsec);
     700        printf("%s .%09ld\n", buf, tp.tv_nsec);
    815701        return 0;
    816702}
     
    819705{
    820706        if (argc != 2) {
    821                 ntstdio_printf(&ntstdio, "info sys\n");
    822                 ntstdio_printf(&ntstdio, "info ver\n");
     707                printf("info sys\n");
     708                printf("info ver\n");
    823709                return 0;
    824710        }
    825711        if (strcmp(argv[1], "sys") == 0) {
    826                 ntstdio_printf(&ntstdio, TARGET_NAME" Monitor\n");
     712                printf(TARGET_NAME" Monitor\n");
    827713                return 0;
    828714        }
     
    830716                int mj, mn, bd;
    831717                ntshell_version(&mj, &mn, &bd);
    832                 ntstdio_printf(&ntstdio, "Version %d.%d.%d\n", mj, mn, bd);
    833                 return 0;
    834         }
    835         ntstdio_printf(&ntstdio, "Unknown sub command found\n");
     718                printf("Version %d.%d.%d\n", mj, mn, bd);
     719                return 0;
     720        }
     721        printf("Unknown sub command found\n");
    836722        return -1;
    837723}
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/usrcmd.h

    r340 r374  
    5656int usrcmd_exit(int argc, char **argv);
    5757
    58 void shell_abort();
    59 void shell_exit(int exitcd);
    60 int shell_kill(int pid, int sig);
    61 
    6258#endif
    6359
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.h

    r337 r374  
    7878        int pos;
    7979        unsigned int option;
     80        void *exinf;
    8081} ntstdio_t;
    8182
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/fdtable.c

    r364 r374  
    6868#include "kernel_cfg.h"
    6969#include <string.h>
    70 
    71 #define IO_TYPE_FREE    0
    72 #define IO_TYPE_SIO             1
    73 #define IO_TYPE_FILE    2
    74 #define IO_TYPE_DIR             3
    75 #define IO_TYPE_TCP             4
    76 #define IO_TYPE_UDP     5
    77 
    78 static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = {
    79         { 0, IO_TYPE_SIO, 0, stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl },
    80         { 1, IO_TYPE_SIO, 0, stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl },
    81         { 2, IO_TYPE_SIO, 0, stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl },
     70#include "util/ntstdio.h"
     71#include "hal/serial_api.h"
     72
     73static int stdio_close(struct SHELL_FILE *fp);
     74static size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     75static size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     76static size_t stdin_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     77static size_t stdout_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     78static size_t stderr_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     79static void stdio_delete(struct SHELL_FILE *fp);
     80
     81static int sio_close(struct SHELL_FILE *fp);
     82static size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     83static size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     84static off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org);
     85static int sio_ioctl(struct SHELL_FILE *fp, int req, void *arg);
     86static bool_t sio_readable(struct SHELL_FILE *fp);
     87static void sio_delete(struct SHELL_FILE *fp);
     88
     89IO_TYPE IO_TYPE_STDIN = { stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
     90IO_TYPE IO_TYPE_STDOUT = { stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
     91IO_TYPE IO_TYPE_STDERR = { stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
     92IO_TYPE IO_TYPE_SIO = { sio_close, sio_read, sio_write, sio_seek, sio_ioctl, sio_readable, sio_delete };
     93ntstdio_t ntstdio;
     94
     95static struct SHELL_FILE fd_table[8 * sizeof(FLGPTN)] = {
     96        { 0, &IO_TYPE_STDIN, 0, .exinf = &ntstdio },
     97        { 1, &IO_TYPE_STDOUT, 0, .exinf = &ntstdio },
     98        { 2, &IO_TYPE_STDERR, 0,.exinf = &ntstdio },
    8299};
    83100#define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0]))
    84101
    85 static int new_fd(int type, int id)
    86 {
     102extern ntstdio_t ntstdio;
     103serial_t stdio_uart;
     104
     105unsigned char ntstdio_xi(struct ntstdio_t *handle)
     106{
     107        return serial_getc((serial_t *)handle->exinf);
     108}
     109
     110void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
     111{
     112        serial_putc((serial_t *)handle->exinf, c);
     113}
     114
     115void sys_init(intptr_t exinf)
     116{
     117        sys_tlsf_init();
     118
     119        serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
     120        serial_baud(&stdio_uart, UART_BAUDRATE);
     121        serial_format(&stdio_uart, 8, ParityNone, 1);
     122
     123        ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo);
     124        ntstdio.exinf = (void *)&stdio_uart;
     125}
     126
     127int stdio_close(struct SHELL_FILE *fp)
     128{
     129        return -EPERM;
     130}
     131
     132size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
     133{
     134        return -EPERM;
     135}
     136
     137size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
     138{
     139        return -EPERM;
     140}
     141
     142size_t stdin_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
     143{
     144        int i = 0;
     145        while (i < len) {
     146                int c = ntstdio_getc((struct ntstdio_t *)fp->exinf);
     147                data[i++] = c;
     148                if ((c == EOF) || (c == '\n'))
     149                        break;
     150        }
     151        return i;
     152}
     153
     154size_t stdout_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
     155{
     156        for (int i = 0; i < len; i++) {
     157                ntstdio_putc((struct ntstdio_t *)fp->exinf, data[i]);
     158        }
     159        return len;
     160}
     161
     162size_t stderr_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
     163{
     164        for (int i = 0; i < len; i++) {
     165                ntstdio_putc((struct ntstdio_t *)fp->exinf, data[i]);
     166        }
     167        return len;
     168}
     169
     170void stdio_delete(struct SHELL_FILE *fp)
     171{
     172}
     173
     174int sio_close(struct SHELL_FILE *fp)
     175{
     176        return -EPERM;
     177}
     178
     179size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
     180{
     181        return -EPERM;
     182}
     183
     184size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
     185{
     186        return -EPERM;
     187}
     188
     189off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org)
     190{
     191        return -EPERM;
     192}
     193
     194int sio_ioctl(struct SHELL_FILE *fp, int request, void *arg)
     195{
     196        switch (request) {
     197        case TIOCGWINSZ:
     198                return 0;
     199        case TCGETS:
     200                return sio_tcgetattr(fp->fd, (struct termios *)arg);
     201        case TCSETS + TCSANOW:
     202        case TCSETS + TCSADRAIN:
     203        case TCSETS + TCSAFLUSH:
     204                return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg);
     205        }
     206
     207        return -EINVAL;
     208}
     209
     210bool_t sio_readable(struct SHELL_FILE *fp)
     211{
     212        return fp->readevt_w != fp->readevt_r;
     213}
     214
     215void sio_delete(struct SHELL_FILE *fp)
     216{
     217        free((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf);
     218        ((struct ntstdio_t *)fp->exinf)->exinf = NULL;
     219        free((struct ntstdio_t *)fp->exinf);
     220        fp->exinf = NULL;
     221}
     222
     223struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable)
     224{
     225        struct SHELL_FILE *fp = NULL;
     226        ER ret;
     227
     228        ret = wai_sem(SEM_FILEDESC);
     229        if (ret < 0) {
     230                syslog(LOG_ERROR, "wai_sem => %d", ret);
     231        }
     232
    87233        for (int fd = 3; fd < fd_table_count; fd++) {
    88                 struct _IO_FILE *fp = &fd_table[fd];
    89                 if (fp->type != IO_TYPE_FREE)
     234                fp = &fd_table[fd];
     235                if (fp->type != NULL)
    90236                        continue;
    91237
    92                 memset(fp, 0, sizeof(struct _IO_FILE));
     238                memset(fp, 0, sizeof(struct SHELL_FILE));
    93239                fp->fd = fd;
    94240                fp->type = type;
    95241                fp->handle = id;
    96                 return fd;
    97         }
    98 
    99         return -ENOMEM;
    100 }
    101 
    102 static struct _IO_FILE *id_to_fd(int type, int id)
    103 {
     242                fp->writable = writable;
     243                break;
     244        }
     245
     246        ret = sig_sem(SEM_FILEDESC);
     247        if (ret < 0) {
     248                syslog(LOG_ERROR, "sig_sem => %d", ret);
     249        }
     250
     251        return fp;
     252}
     253
     254struct SHELL_FILE *id_to_fd(IO_TYPE *type, int id)
     255{
     256        struct SHELL_FILE *fp = NULL;
     257        ER ret;
     258
     259        ret = wai_sem(SEM_FILEDESC);
     260        if (ret < 0) {
     261                syslog(LOG_ERROR, "wai_sem => %d", ret);
     262        }
     263
    104264        for (int fd = 3; fd < fd_table_count; fd++) {
    105                 struct _IO_FILE *fp = &fd_table[fd];
     265                fp = &fd_table[fd];
    106266                if ((fp->type == type) && (fp->handle == id))
    107                         return fp;
    108         }
    109 
    110         return NULL;
    111 }
    112 
    113 static int delete_fd(int type, int id)
    114 {
    115         struct _IO_FILE *fp = id_to_fd(type, id);
     267                        break;
     268        }
     269
     270        ret = sig_sem(SEM_FILEDESC);
     271        if (ret < 0) {
     272                syslog(LOG_ERROR, "sig_sem => %d", ret);
     273        }
     274
     275        return fp;
     276}
     277
     278int delete_fd_by_id(IO_TYPE *type, int id)
     279{
     280        struct SHELL_FILE *fp = id_to_fd(type, id);
    116281        if (fp == NULL)
    117282                return -EBADF;
     
    120285}
    121286
    122 int delete_fp(struct _IO_FILE *fp)
    123 {
    124         free(fp->pfile);
    125         fp->pfile = NULL;
    126         free(fp->pdir);
    127         fp->pdir = NULL;
    128         free(fp->psock);
    129         fp->psock = NULL;
    130         memset(fp, 0, sizeof(struct _IO_FILE));
     287int delete_fp(struct SHELL_FILE *fp)
     288{
     289        ER ret;
     290
     291        fp->type->delete(fp);
     292
     293        ret = wai_sem(SEM_FILEDESC);
     294        if (ret < 0) {
     295                syslog(LOG_ERROR, "wai_sem => %d", ret);
     296        }
     297
     298        memset(fp, 0, sizeof(struct SHELL_FILE));
     299
     300        ret = sig_sem(SEM_FILEDESC);
     301        if (ret < 0) {
     302                syslog(LOG_ERROR, "sig_sem => %d", ret);
     303        }
    131304
    132305        return 0;
    133306}
    134307
    135 struct _IO_FILE *fd_to_fp(int fd)
     308struct SHELL_FILE *fd_to_fp(int fd)
    136309{
    137310        if ((fd < 0) || (fd >= fd_table_count))
     
    140313}
    141314
    142 struct _IO_FILE *new_sio_fd(int sioid)
    143 {
    144         int fd = new_fd(IO_TYPE_SIO, sioid);
    145         if ((fd < 0) || (fd >= fd_table_count))
    146                 return NULL;
    147 
    148         struct _IO_FILE *fp = &fd_table[fd];
    149         fp->close = sio_close;
    150         fp->read = sio_read;
    151         fp->write = sio_write;
    152         fp->seek = sio_seek;
    153         fp->ioctl = sio_ioctl;
    154         fp->writable = 1;
    155 
    156         return fp;
    157 }
    158 
    159 int delete_sio_fd(int sioid)
    160 {
    161         return delete_fd(IO_TYPE_SIO, sioid);
    162 }
    163 
    164 struct _IO_FILE *sioid_to_fd(int sioid)
    165 {
    166         return id_to_fd(IO_TYPE_SIO, sioid);
    167 }
    168 
    169 struct _IO_FILE *new_file_fd(int fileid)
    170 {
    171         int fd = new_fd(IO_TYPE_FILE, fileid);
    172         if ((fd < 0) || (fd >= fd_table_count))
    173                 return NULL;
    174 
    175         struct _IO_FILE *fp = &fd_table[fd];
    176         fp->close = file_close;
    177         fp->read = file_read;
    178         fp->write = file_write;
    179         fp->seek = file_seek;
    180         fp->ioctl = file_ioctl;
    181         fp->writable = 1;
    182         fp->pfile = malloc(sizeof(FIL));
    183         memset(fp->pfile, 0, sizeof(FIL));
    184 
    185         return fp;
    186 }
    187 
    188 int delete_file_fd(int fileid)
    189 {
    190         return delete_fd(IO_TYPE_FILE, fileid);
    191 }
    192 
    193 struct _IO_FILE *fileid_to_fd(int fileid)
    194 {
    195         return id_to_fd(IO_TYPE_FILE, fileid);
    196 }
    197 
    198 struct _IO_FILE *new_dir_fd(int fileid)
    199 {
    200         int fd = new_fd(IO_TYPE_DIR, fileid);
    201         if ((fd < 0) || (fd >= fd_table_count))
    202                 return NULL;
    203 
    204         struct _IO_FILE *fp = &fd_table[fd];
    205         fp->close = dir_close;
    206         fp->read = dir_read;
    207         fp->write = dir_write;
    208         fp->seek = dir_seek;
    209         fp->ioctl = dir_ioctl;
    210         fp->writable = 0;
    211         fp->pdir = malloc(sizeof(struct _IO_DIR));
    212         memset(fp->pdir, 0, sizeof(struct _IO_DIR));
    213 
    214         return fp;
    215 }
    216 
    217 int delete_dir_fd(int dirid)
    218 {
    219         return delete_fd(IO_TYPE_DIR, dirid);
    220 }
    221 
    222 struct _IO_FILE *dirid_to_fd(int dirid)
    223 {
    224         return id_to_fd(IO_TYPE_DIR, dirid);
    225 }
    226 
    227 #ifndef NTSHELL_NO_SOCKET
    228 struct _IO_FILE *new_tcp_fd(int tcpid)
    229 {
    230         int fd = new_fd(IO_TYPE_TCP, tcpid);
    231         if ((fd < 0) || (fd >= fd_table_count))
    232                 return NULL;
    233 
    234         struct _IO_FILE *fp = &fd_table[fd];
    235         fp->close = tcp_fd_close;
    236         fp->read = tcp_fd_read;
    237         fp->write = tcp_fd_write;
    238         fp->seek = tcp_fd_seek;
    239         fp->ioctl = tcp_fd_ioctl;
    240         fp->writable = 0;
    241         fp->psock = malloc(sizeof(socket_t));
    242         memset(fp->psock, 0, sizeof(socket_t));
    243 
    244         return fp;
    245 }
    246 
    247 int delete_tcp_fd(int tcpid)
    248 {
    249         return delete_fd(IO_TYPE_TCP, tcpid);
    250 }
    251 
    252 struct _IO_FILE *tcpid_to_fd(int tcpid)
    253 {
    254         return id_to_fd(IO_TYPE_TCP, tcpid);
    255 }
    256 
    257 struct _IO_FILE *new_udp_fd(int udpid)
    258 {
    259         int fd = new_fd(IO_TYPE_UDP, udpid);
    260         if ((fd < 0) || (fd >= fd_table_count))
    261                 return NULL;
    262 
    263         struct _IO_FILE *fp = &fd_table[fd];
    264         fp->close = udp_fd_close;
    265         fp->read = udp_fd_read;
    266         fp->write = udp_fd_write;
    267         fp->seek = udp_fd_seek;
    268         fp->ioctl = udp_fd_ioctl;
    269         fp->writable = 1;
    270         fp->psock = malloc(sizeof(socket_t));
    271         memset(fp->psock, 0, sizeof(socket_t));
    272 
    273         return fp;
    274 }
    275 
    276 int delete_udp_fd(int udpid)
    277 {
    278         return delete_fd(IO_TYPE_UDP, udpid);
    279 }
    280 
    281 struct _IO_FILE *udpid_to_fd(int udpid)
    282 {
    283         return id_to_fd(IO_TYPE_UDP, udpid);
    284 }
    285 
    286 #endif
    287 
    288 void memor(void *dst, void *src, size_t len)
     315void memand(void *dst, void *src, size_t len)
    289316{
    290317        uint8_t *d = (uint8_t *)dst;
     
    293320
    294321        while (s < e) {
    295                 *d++ |= *s++;
     322                *d++ &= *s++;
    296323        }
    297324}
     
    336363
    337364        ret = shell_get_evts(&evts, tmout);
    338         if (rfds != NULL)
    339                 memset(rfds, 0, sizeof(fd_set));
    340         if (wfds != NULL)
    341                 memset(wfds, 0, sizeof(fd_set));
    342         if (efds != NULL)
    343                 memset(efds, 0, sizeof(fd_set));
    344365        if (ret == E_OK) {
    345366                if (rfds != NULL)
    346                         memor(rfds, &evts.readfds, sizeof(fd_set));
     367                        memand(rfds, &evts.readfds, sizeof(fd_set));
    347368                if (wfds != NULL)
    348                         memor(wfds, &evts.writefds, sizeof(fd_set));
     369                        memand(wfds, &evts.writefds, sizeof(fd_set));
    349370                if (efds != NULL)
    350                         memor(efds, &evts.errorfds, sizeof(fd_set));
     371                        memand(efds, &evts.errorfds, sizeof(fd_set));
    351372                return evts.count;
    352373        }
    353374        if (ret == E_TMOUT) {
     375                if (rfds != NULL)
     376                        memset(rfds, 0, sizeof(fd_set));
     377                if (wfds != NULL)
     378                        memset(wfds, 0, sizeof(fd_set));
     379                if (efds != NULL)
     380                        memset(efds, 0, sizeof(fd_set));
    354381                return 0;
    355382        }
     
    419446{
    420447        int fd = STDIN_FILENO;
    421         struct _IO_FILE *fp = &fd_table[fd];
    422         T_SERIAL_RPOR rpor;
     448        struct SHELL_FILE *fp = &fd_table[fd];
    423449        FLGPTN flgptn = 0;
    424450
    425         ER ret = serial_ref_por(SIO_PORTID, &rpor);
    426         if (ret != E_OK)
    427                 return;
    428 
    429         if (rpor.reacnt != 0) {
     451        if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    430452                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    431453
    432454                FD_SET(fd, (fd_set *)&flgptn);
    433455        }
    434         if (rpor.wricnt != 0) {
     456        if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    435457                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    436458
     
    447469{
    448470        int fd = STDIN_FILENO;
    449         struct _IO_FILE *fp = &fd_table[fd];
    450         T_SERIAL_RPOR rpor;
     471        struct SHELL_FILE *fp = &fd_table[fd];
    451472        *flgptn = 0;
    452473
    453         ER ret = serial_ref_por(SIO_PORTID, &rpor);
    454         if (ret != E_OK)
    455                 return;
    456 
    457         if (rpor.reacnt != 0) {
     474        if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    458475                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    459476
    460477                FD_SET(fd, (fd_set *)flgptn);
    461478        }
    462         if (rpor.wricnt != 0) {
     479        if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    463480                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    464481
     
    466483        }
    467484}
    468 
    469 #ifndef NTSHELL_NO_SOCKET
    470 
    471 ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk)
    472 {
    473         struct _IO_FILE *fp = tcpid_to_fd(cepid);
    474         FLGPTN flgptn = 0;
    475         ER ret;
    476         int len;
    477 
    478         if (fp == NULL)
    479                 return E_PAR;
    480 
    481         int fd = fp->fd;
    482         FD_SET(fd, (fd_set *)&flgptn);
    483 
    484         switch (fncd) {
    485         case TFN_TCP_RCV_BUF:
    486                 len = *(int *)p_parblk;
    487                 if (len <= 0)
    488                         return E_OK;
    489 
    490                 ret = wai_sem(SEM_FILEDESC);
    491                 if (ret < 0) {
    492                         syslog(LOG_ERROR, "wai_sem => %d", ret);
    493                 }
    494                 fp->psock->len += len;
    495                 ret = sig_sem(SEM_FILEDESC);
    496                 if (ret < 0) {
    497                         syslog(LOG_ERROR, "sig_sem => %d", ret);
    498                 }
    499 
    500                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    501 
    502                 set_flg(FLG_SELECT_WAIT, flgptn);
    503                 return E_OK;
    504 
    505         case TFN_TCP_RCV_DAT:
    506                 len = *(int *)p_parblk;
    507                 if (len <= 0)
    508                         return E_OK;
    509 
    510                 ret = wai_sem(SEM_FILEDESC);
    511                 if (ret < 0) {
    512                         syslog(LOG_ERROR, "wai_sem => %d", ret);
    513                 }
    514                 fp->psock->len += len;
    515                 ret = sig_sem(SEM_FILEDESC);
    516                 if (ret < 0) {
    517                         syslog(LOG_ERROR, "sig_sem => %d", ret);
    518                 }
    519 
    520                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    521 
    522                 set_flg(FLG_SELECT_WAIT, flgptn);
    523                 return E_OK;
    524 
    525         case TFN_TCP_SND_DAT:
    526                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    527 
    528                 set_flg(FLG_SELECT_WAIT, flgptn);
    529                 return E_OK;
    530 
    531         case TFN_TCP_CAN_CEP:
    532                 if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
    533 
    534                 set_flg(FLG_SELECT_WAIT, flgptn);
    535                 return E_OK;
    536 
    537         case TFN_TCP_DEL_REP:
    538                 delete_tcp_rep(cepid);
    539                 return E_OK;
    540 
    541         case TFN_TCP_DEL_CEP:
    542                 delete_tcp_fd(cepid);
    543                 return E_OK;
    544 
    545         default:
    546                 return E_OK;
    547         }
    548 }
    549 
    550 ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk)
    551 {
    552         struct _IO_FILE *fp = udpid_to_fd(cepid);
    553         FLGPTN flgptn = 0;
    554         int len;
    555 
    556         if (fp == NULL)
    557                 return E_PAR;
    558 
    559         int fd = fp->fd;
    560         FD_SET(fd, (fd_set *)&flgptn);
    561 
    562         switch (fncd) {
    563         case TEV_UDP_RCV_DAT:
    564         {
    565                 T_UDP_RCV_DAT_PARA *udppara = (T_UDP_RCV_DAT_PARA *)p_parblk;
    566                 len = udppara->len;
    567                 if (len <= 0)
    568                         return E_OK;
    569 
    570                 ER ret = wai_sem(SEM_FILEDESC);
    571                 if (ret < 0) {
    572                         syslog(LOG_ERROR, "wai_sem => %d", ret);
    573                 }
    574                 fp->psock->len = len;
    575                 if (fp->psock->input != NULL) {
    576                         ret = rel_net_buf(fp->psock->input);
    577                         if (ret < 0) {
    578                                 syslog(LOG_ERROR, "rel_net_buf => %d", ret);
    579                         }
    580                 }
    581                 fp->psock->input = udppara->input;
    582                 fp->psock->buf = GET_UDP_SDU(udppara->input, udppara->off);
    583                 memset(&fp->psock->raddr4, 0, sizeof(fp->psock->raddr4));
    584                 fp->psock->raddr4.sin_family = AF_INET;
    585                 fp->psock->raddr4.sin_port = htons(udppara->rep4.portno);
    586                 fp->psock->raddr4.sin_addr.s_addr = htonl(udppara->rep4.ipaddr);
    587                 udppara->input->flags |= NB_FLG_NOREL_IFOUT;
    588                 ret = sig_sem(SEM_FILEDESC);
    589                 if (ret < 0) {
    590                         syslog(LOG_ERROR, "sig_sem => %d", ret);
    591                 }
    592 
    593                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    594 
    595                 set_flg(FLG_SELECT_WAIT, flgptn);
    596                 return E_OK;
    597         }
    598         case TFN_UDP_CRE_CEP:
    599                 return E_OK;
    600 
    601         case TFN_UDP_RCV_DAT:
    602                 len = *(int *)p_parblk;
    603                 if (len <= 0)
    604                         return E_OK;
    605 
    606                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    607 
    608                 set_flg(FLG_SELECT_WAIT, flgptn);
    609                 return E_OK;
    610 
    611         case TFN_UDP_SND_DAT:
    612                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    613 
    614                 set_flg(FLG_SELECT_WAIT, flgptn);
    615                 return E_OK;
    616 
    617         case TFN_UDP_CAN_CEP:
    618                 if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
    619 
    620                 set_flg(FLG_SELECT_WAIT, flgptn);
    621                 return E_OK;
    622 
    623         case TFN_UDP_DEL_CEP:
    624                 delete_udp_fd(cepid);
    625                 return E_OK;
    626 
    627         default:
    628                 return E_OK;
    629         }
    630 }
    631 
    632 #endif
    633485
    634486ER shell_get_evts(struct fd_events *evts, TMO tmout)
     
    642494                ER ret;
    643495                FLGPTN waitptn, flgptn, readfds = 0, writefds = 0;
    644                 struct _IO_FILE *fp = NULL;
     496                struct SHELL_FILE *fp = NULL;
    645497
    646498                stdio_update_evts();
     
    656508#ifndef NTSHELL_NO_SOCKET
    657509                        if (FD_ISSET(fd, &evts->readfds)) {
    658                                 if ((fp->type == IO_TYPE_TCP) && (fp->psock->cepid != 0)) {
    659                                         if (fp->psock->len == 0) {
    660                                                 ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_NBLK);
    661                                                 if ((ret != E_WBLK) && (ret != E_OBJ) && (ret < 0)) {
    662                                                         syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
    663                                                         //return ret;
    664                                                 }
    665                                                 if (ret > 0) {
    666                                                         ret = wai_sem(SEM_FILEDESC);
    667                                                         if (ret < 0) {
    668                                                                 syslog(LOG_ERROR, "wai_sem => %d", ret);
    669                                                         }
    670                                                         fp->psock->len += ret;
    671                                                         ret = sig_sem(SEM_FILEDESC);
    672                                                         if (ret < 0) {
    673                                                                 syslog(LOG_ERROR, "sig_sem => %d", ret);
    674                                                         }
    675                                                 }
    676                                         }
    677                                         else ret = 1;
    678                                         if (ret > 0) {
    679                                                 FD_SET(fd, (fd_set *)&readfds);
    680                                                 count++;
    681                                                 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
    682                                         }
    683                                 }
    684                                 else if ((fp->type == IO_TYPE_UDP) && (fp->psock->cepid != 0)) {
    685                                         if (fp->psock->input != NULL) {
    686                                                 FD_SET(fd, (fd_set *)&readfds);
    687                                                 count++;
    688                                                 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
    689                                         }
     510                                if (fp->type->readable(fp)) {
     511                                        FD_SET(fd, (fd_set *)&readfds);
     512                                        count++;
     513                                        if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
    690514                                }
    691515                                else {
     
    786610void clean_fd()
    787611{
    788         struct _IO_FILE *fp = NULL;
     612        struct SHELL_FILE *fp = NULL;
    789613        for (int fd = 3; fd < fd_table_count; fd++) {
    790614                fp = &fd_table[fd];
     
    792616                        continue;
    793617
    794                 fp->close(fp);
     618                fp->type->close(fp);
    795619
    796620                delete_fp(fp);
     
    800624int shell_ioctl(int fd, int request, void *arg)
    801625{
    802         struct _IO_FILE *fp = fd_to_fp(fd);
     626        struct SHELL_FILE *fp = fd_to_fp(fd);
    803627        if (fp == NULL)
    804628                return -EBADF;
    805629
    806         return fp->ioctl(fp, request, arg);
     630        return fp->type->ioctl(fp, request, arg);
    807631}
    808632
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/io_stub.c

    r337 r374  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2017 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
     
    4343#include <sil.h>
    4444#include <string.h>
     45#include "syssvc/serial.h"
    4546#include "syssvc/syslog.h"
    4647#include "socket_stub.h"
     
    4950#include "core/ntlibc.h"
    5051#include "kernel_cfg.h"
     52#include "target_syssvc.h"
    5153
    5254int fresult2errno(FRESULT res)
     
    7779}
    7880
    79 int shell_open(const char * path, int flags, void *arg)
    80 {
    81         FRESULT res;
    82         struct _IO_FILE *fp;
     81static int file_close(struct SHELL_FILE *fp);
     82static size_t file_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     83static size_t file_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     84static off_t file_seek(struct SHELL_FILE *fp, off_t ofs, int org);
     85static int file_ioctl(struct SHELL_FILE *fp, int req, void *arg);
     86static bool_t file_readable(struct SHELL_FILE *fp);
     87static void file_delete(struct SHELL_FILE *fp);
     88
     89static int dir_close(struct SHELL_FILE *fp);
     90static size_t dir_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     91static size_t dir_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     92static off_t dir_seek(struct SHELL_FILE *fp, off_t ofs, int org);
     93static int dir_ioctl(struct SHELL_FILE *fp, int req, void *arg);
     94static bool_t dir_readable(struct SHELL_FILE *fp);
     95static void dir_delete(struct SHELL_FILE *fp);
     96
     97IO_TYPE IO_TYPE_FILE = { file_close, file_read, file_write, file_seek, file_ioctl, file_readable, file_delete };
     98IO_TYPE IO_TYPE_DIR = { dir_close, dir_read, dir_write, dir_seek, dir_ioctl, dir_readable, dir_delete };
     99
     100int shell_open(const char *path, int flags, void *arg)
     101{
     102        FRESULT res;
     103        struct SHELL_FILE *fp;
    83104
    84105        if (flags & O_DIRECTORY) {
    85                 fp = new_dir_fd(0);
     106                fp = new_fp(&IO_TYPE_DIR, 0, 0);
    86107                if (fp == NULL)
    87108                        return -ENOMEM;
    88109
    89                 DIR *dir = &fp->pdir->dir;
     110                fp->exinf = malloc(sizeof(struct SHELL_DIR));
     111                memset(fp->exinf, 0, sizeof(struct SHELL_DIR));
     112
     113                FATFS_DIR *dir = &((struct SHELL_DIR *)fp->exinf)->dir;
    90114                FRESULT res;
    91115                if ((res = f_opendir(dir, path)) != FR_OK) {
     
    95119        }
    96120
    97         fp = new_file_fd(0);
     121        fp = new_fp(&IO_TYPE_FILE, 0, 1);
    98122        if (fp == NULL)
    99123                return -ENOMEM;
     124
     125        fp->exinf = malloc(sizeof(FIL));
     126        memset(fp->exinf, 0, sizeof(FIL));
    100127
    101128        BYTE fmd = 0;
     
    133160        }
    134161
    135         if ((res = f_open(fp->pfile, path, fmd)) == FR_OK) {
     162        if ((res = f_open((FIL *)fp->exinf, path, fmd)) == FR_OK) {
    136163                fp->handle = fp->fd;
    137164                return fp->fd;
     
    141168}
    142169
    143 int file_close(struct _IO_FILE *fp)
    144 {
    145         FRESULT res;
    146 
    147         if ((res = f_close(fp->pfile)) == FR_OK) {
     170int file_close(struct SHELL_FILE *fp)
     171{
     172        FRESULT res;
     173
     174        if ((res = f_close((FIL *)fp->exinf)) == FR_OK) {
    148175                return 0;
    149176        }
     
    152179}
    153180
    154 size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
     181size_t file_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    155182{
    156183        unsigned int ret = 0;
    157184        FRESULT res;
    158185
    159         if ((res = f_read(fp->pfile, data, len, &ret)) != FR_OK)
     186        if ((res = f_read((FIL *)fp->exinf, data, len, &ret)) != FR_OK)
    160187                return -EIO;
    161188
     
    163190}
    164191
    165 size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
     192size_t file_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    166193{
    167194        unsigned int ret = 0;
    168195        FRESULT res;
    169196
    170         if ((res = f_write(fp->pfile, data, len, &ret)) != FR_OK)
     197        if ((res = f_write((FIL *)fp->exinf, data, len, &ret)) != FR_OK)
    171198                return -EIO;
    172199
     
    174201}
    175202
    176 off_t file_seek(struct _IO_FILE *fp, off_t ptr, int dir)
     203off_t file_seek(struct SHELL_FILE *fp, off_t ptr, int dir)
    177204{
    178205        switch (dir) {
     
    191218
    192219        FRESULT res;
    193         if ((res = f_seek(fp->pfile, ptr, dir)) != FR_OK)
     220        if ((res = f_seek((FIL *)fp->exinf, ptr, dir)) != FR_OK)
    194221                return -EIO;
    195222
    196         return fp->pfile->fptr;
    197 }
    198 
    199 int file_ioctl(struct _IO_FILE *fp, int req, void *arg)
     223        return ((FIL *)fp->exinf)->fptr;
     224}
     225
     226int file_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    200227{
    201228        DRESULT res;
    202229
    203         if ((res = disk_ioctl(fp->pfile->fs->drv, req, arg) != RES_OK))
     230        if ((res = disk_ioctl(((FIL *)fp->exinf)->fs->drv, req, arg) != RES_OK))
    204231                return -EINVAL;
    205232
     
    207234}
    208235
     236bool_t file_readable(struct SHELL_FILE *fp)
     237{
     238        return fp->readevt_w != fp->readevt_r;
     239}
     240
     241void file_delete(struct SHELL_FILE *fp)
     242{
     243        free((FIL *)fp->exinf);
     244        fp->exinf = NULL;
     245}
     246
    209247int shell_close(int fd)
    210248{
    211         struct _IO_FILE *fp = fd_to_fp(fd);
    212         if (fp == NULL)
    213                 return -EBADF;
    214 
    215         int ret = fp->close(fp);
     249        struct SHELL_FILE *fp = fd_to_fp(fd);
     250        if (fp == NULL)
     251                return -EBADF;
     252
     253        int ret = fp->type->close(fp);
    216254
    217255        delete_fp(fp);
     
    222260ssize_t shell_read(int fd, void *data, size_t len)
    223261{
    224         struct _IO_FILE *fp = fd_to_fp(fd);
    225         if (fp == NULL)
    226                 return -EBADF;
    227 
    228         return fp->read(fp, (unsigned char *)data, len);
     262        struct SHELL_FILE *fp = fd_to_fp(fd);
     263        if (fp == NULL)
     264                return -EBADF;
     265
     266        return fp->type->read(fp, (unsigned char *)data, len);
    229267}
    230268
     
    232270{
    233271        int result = 0;
    234         struct _IO_FILE *fp = fd_to_fp(fd);
     272        struct SHELL_FILE *fp = fd_to_fp(fd);
    235273        if (fp == NULL)
    236274                return -EBADF;
     
    238276        const struct iovec *end = &iov[iovcnt];
    239277        for (; iov < end; iov++) {
    240                 result += fp->read(fp, (unsigned char *)iov->iov_base, iov->iov_len);
     278                result += fp->type->read(fp, (unsigned char *)iov->iov_base, iov->iov_len);
    241279        }
    242280
     
    246284ssize_t shell_write(int fd, const void *data, size_t len)
    247285{
    248         struct _IO_FILE *fp = fd_to_fp(fd);
    249         if (fp == NULL)
    250                 return -EBADF;
    251 
    252         return fp->write(fp, (unsigned char *)data, len);
     286        struct SHELL_FILE *fp = fd_to_fp(fd);
     287        if (fp == NULL)
     288                return -EBADF;
     289
     290        return fp->type->write(fp, (unsigned char *)data, len);
    253291}
    254292
     
    256294{
    257295        int result = 0;
    258         struct _IO_FILE *fp = fd_to_fp(fd);
     296        struct SHELL_FILE *fp = fd_to_fp(fd);
    259297        if (fp == NULL)
    260298                return -EBADF;
     
    262300        const struct iovec *end = &iov[iovcnt];
    263301        for (; iov < end; iov++) {
    264                 result += fp->write(fp, (unsigned char *)iov->iov_base, iov->iov_len);
     302                result += fp->type->write(fp, (unsigned char *)iov->iov_base, iov->iov_len);
    265303        }
    266304
     
    270308int shell_llseek(int fd, off_t ptr, off_t *result, int dir)
    271309{
    272         struct _IO_FILE *fp = fd_to_fp(fd);
    273         if (fp == NULL)
    274                 return -EBADF;
    275 
    276         off_t ret = fp->seek(fp, ptr, dir);
     310        struct SHELL_FILE *fp = fd_to_fp(fd);
     311        if (fp == NULL)
     312                return -EBADF;
     313
     314        off_t ret = fp->type->seek(fp, ptr, dir);
    277315        if (ret < 0)
    278316                return ret;
     
    284322int shell_fstat(int fd, struct stat * st)
    285323{
    286         struct _IO_FILE *fp = fd_to_fp(fd);
     324        struct SHELL_FILE *fp = fd_to_fp(fd);
    287325        if (fp == NULL)
    288326                return -EBADF;
     
    296334int shell_fsync(int fd)
    297335{
    298         struct _IO_FILE *fp = fd_to_fp(fd);
     336        struct SHELL_FILE *fp = fd_to_fp(fd);
    299337        if (fp == NULL)
    300338                return -EBADF;
     
    304342int shell_ftruncate(int fd, off_t length)
    305343{
    306         struct _IO_FILE *fp = fd_to_fp(fd);
    307         if (fp == NULL)
    308                 return -EBADF;
    309 
    310         FRESULT res;
    311         if ((res = f_truncate(fp->pfile)) != FR_OK)
     344        struct SHELL_FILE *fp = fd_to_fp(fd);
     345        if (fp == NULL)
     346                return -EBADF;
     347
     348        FRESULT res;
     349        if ((res = f_truncate((FIL *)fp->exinf)) != FR_OK)
    312350                return fresult2errno(res);
    313351
     
    320358}
    321359
     360extern IO_TYPE IO_TYPE_SIO;
     361
    322362int sio_tcgetattr(int fd, struct termios *termios)
    323363{
    324         extern ntstdio_t ntstdio;
    325 
    326         if (fd == STDIN_FILENO) {
    327                 memset(termios, 0, sizeof(*termios));
    328 
    329                 if (ntstdio.option & NTSTDIO_OPTION_LINE_ECHO) {
    330                         termios->c_lflag |= ECHO;
     364        struct SHELL_FILE *fp = fd_to_fp(fd);
     365        if ((fp == NULL) || (fp->type != &IO_TYPE_SIO))
     366                return -EBADF;
     367
     368        ntstdio_t *ntstdio = (ntstdio_t *)fp->exinf;
     369
     370        memset(termios, 0, sizeof(*termios));
     371
     372        if (ntstdio->option & NTSTDIO_OPTION_LINE_ECHO) {
     373                termios->c_lflag |= ECHO;
     374        }
     375        else {
     376                termios->c_lflag &= ~ECHO;
     377        }
     378        if (ntstdio->option & NTSTDIO_OPTION_CANON) {
     379                termios->c_lflag |= ICANON;
     380        }
     381        else {
     382                termios->c_lflag &= ~ICANON;
     383        }
     384        if (ntstdio->option & NTSTDIO_OPTION_LF_CR) {
     385                termios->c_iflag |= INLCR;
     386        }
     387        else {
     388                termios->c_iflag &= ~INLCR;
     389        }
     390        if (ntstdio->option & NTSTDIO_OPTION_LF_CRLF) {
     391                termios->c_oflag |= ONLCR;
     392        }
     393        else {
     394                termios->c_oflag &= ~ONLCR;
     395        }
     396
     397        return 0;
     398}
     399
     400int sio_tcsetattr(int fd, int optional_actions, const struct termios *termios)
     401{
     402        struct SHELL_FILE *fp = fd_to_fp(fd);
     403        if ((fp == NULL) || (fp->type != &IO_TYPE_SIO))
     404                return -EBADF;
     405
     406        ntstdio_t *ntstdio = (ntstdio_t *)fp->exinf;
     407
     408        if (optional_actions == TCSANOW) {
     409                if (termios->c_lflag & ECHO) {
     410                        ntstdio->option |= NTSTDIO_OPTION_LINE_ECHO;
    331411                }
    332412                else {
    333                         termios->c_lflag &= ~ECHO;
    334                 }
    335                 if (ntstdio.option & NTSTDIO_OPTION_CANON) {
    336                         termios->c_lflag |= ICANON;
     413                        ntstdio->option &= ~NTSTDIO_OPTION_LINE_ECHO;
     414                }
     415                if (termios->c_lflag & ICANON) {
     416                        ntstdio->option |= NTSTDIO_OPTION_CANON;
    337417                }
    338418                else {
    339                         termios->c_lflag &= ~ICANON;
    340                 }
    341                 if (ntstdio.option & NTSTDIO_OPTION_LF_CR) {
    342                         termios->c_iflag |= INLCR;
     419                        ntstdio->option &= ~NTSTDIO_OPTION_CANON;
     420                }
     421                if (termios->c_iflag & INLCR) {
     422                        ntstdio->option |= NTSTDIO_OPTION_LF_CR;
    343423                }
    344424                else {
    345                         termios->c_iflag &= ~INLCR;
    346                 }
    347                 if (ntstdio.option & NTSTDIO_OPTION_LF_CRLF) {
    348                         termios->c_oflag |= ONLCR;
     425                        ntstdio->option &= ~NTSTDIO_OPTION_LF_CR;
     426                }
     427                if (termios->c_oflag & ONLCR) {
     428                        ntstdio->option |= NTSTDIO_OPTION_LF_CRLF;
    349429                }
    350430                else {
    351                         termios->c_oflag &= ~ONLCR;
     431                        ntstdio->option &= ~NTSTDIO_OPTION_LF_CRLF;
    352432                }
    353433                return 0;
    354434        }
    355         shell_abort();
    356         return 0;
    357 }
    358 
    359 int sio_tcsetattr(int fd, int optional_actions, const struct termios *termios)
    360 {
    361         extern ntstdio_t ntstdio;
    362 
    363         if ((fd == STDIN_FILENO) && (optional_actions == TCSANOW)) {
    364                 if (termios->c_lflag & ECHO) {
    365                         ntstdio.option |= NTSTDIO_OPTION_LINE_ECHO;
    366                 }
    367                 else {
    368                         ntstdio.option &= ~NTSTDIO_OPTION_LINE_ECHO;
    369                 }
    370                 if (termios->c_lflag & ICANON) {
    371                         ntstdio.option |= NTSTDIO_OPTION_CANON;
    372                 }
    373                 else {
    374                         ntstdio.option &= ~NTSTDIO_OPTION_CANON;
    375                 }
    376                 if (termios->c_iflag & INLCR) {
    377                         ntstdio.option |= NTSTDIO_OPTION_LF_CR;
    378                 }
    379                 else{
    380                         ntstdio.option &= ~NTSTDIO_OPTION_LF_CR;
    381                 }
    382                 if (termios->c_oflag & ONLCR) {
    383                         ntstdio.option |= NTSTDIO_OPTION_LF_CRLF;
    384                 }
    385                 else {
    386                         ntstdio.option &= ~NTSTDIO_OPTION_LF_CRLF;
    387                 }
    388                 return 0;
    389         }
     435
    390436        shell_abort();
    391437        return 0;
     
    396442        FILINFO fi;
    397443        FRESULT ret;
    398 #if _USE_LFN
    399         static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
     444#if FF_USE_LFN
     445        static char lfn[FF_MAX_LFN + 1];   /* Buffer to store the LFN */
    400446        fi.lfname = lfn;
    401447        fi.lfsize = sizeof lfn;
    402448#endif
    403449        if (strcmp(path, ".") == 0) {
    404                 char cwd[_MAX_LFN];
     450                char cwd[FF_MAX_LFN];
    405451                if ((ret = f_getcwd(cwd, sizeof(cwd))) != FR_OK) {
    406452                        return fresult2errno(ret);
     
    426472        st->st_mtim.tv_nsec = 0;
    427473        st->st_mtim.tv_sec = fi.fdate + fi.ftime;
    428         st->st_mode  = (S_IRUSR | S_IRGRP | S_IROTH);
     474        st->st_mode = (S_IRUSR | S_IRGRP | S_IROTH);
    429475        st->st_mode |= (fi.fattrib & AM_RDO) ? 0 : (S_IWUSR | S_IWGRP | S_IWOTH);
    430476        st->st_mode |= (fi.fattrib & (AM_DIR | AM_VOL)) ? S_IFDIR : S_IFREG;
     
    485531        BYTE mask = AM_RDO | AM_SYS; // AM_ARC, AM_HID
    486532
    487         if(mode & S_IREAD) {
    488                 if((mode & S_IWRITE) == 0) {
     533        if (mode & S_IREAD) {
     534                if ((mode & S_IWRITE) == 0) {
    489535                        attr |= AM_RDO;
    490536                }
     
    494540        }
    495541
    496         if((res = f_chmod(path, attr, mask)) != FR_OK) {
     542        if ((res = f_chmod(path, attr, mask)) != FR_OK) {
    497543                return fresult2errno(res);
    498544        }
     
    507553        BYTE mask = AM_RDO | AM_SYS; // AM_ARC, AM_HID
    508554
    509         if(mode & S_IREAD) {
    510                 if((mode & S_IWRITE) == 0) {
     555        if (mode & S_IREAD) {
     556                if ((mode & S_IWRITE) == 0) {
    511557                        attr |= AM_RDO;
    512558                }
     
    516562        }
    517563
    518         if((res = f_chmod(path, attr, mask)) != FR_OK) {
     564        if ((res = f_chmod(path, attr, mask)) != FR_OK) {
    519565                return fresult2errno(res);
    520566        }
     
    526572{
    527573        FRESULT ret;
    528         if((ret = f_getcwd(buf, size)) != FR_OK) {
     574        if ((ret = f_getcwd(buf, size)) != FR_OK) {
    529575                return NULL;
    530576        }
     
    549595}
    550596
    551 int dir_close(struct _IO_FILE *fp)
    552 {
    553         FRESULT res;
    554         if ((res = f_closedir(&fp->pdir->dir)) != FR_OK) {
     597int dir_close(struct SHELL_FILE *fp)
     598{
     599        FRESULT res;
     600        if ((res = f_closedir(&((struct SHELL_DIR *)fp->exinf)->dir)) != FR_OK) {
    555601                return fresult2errno(res);
    556602        }
     
    564610                return -EINVAL;
    565611
    566         struct _IO_FILE *fp = fd_to_fp(fd);
     612        struct SHELL_FILE *fp = fd_to_fp(fd);
    567613        if (fp == NULL)
    568614                return -EBADF;
    569615
    570616        FILINFO fno;
    571 #if _USE_LFN
    572         static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
     617#if FF_USE_LFN
     618        static char lfn[FF_MAX_LFN + 1];   /* Buffer to store the LFN */
    573619        fno.lfname = lfn;
    574620        fno.lfsize = sizeof lfn;
    575621#endif
    576622        FRESULT res;
    577         if ((res = f_readdir(&fp->pdir->dir, &fno)) != FR_OK || fno.fname[0] == '\0') {
     623        if ((res = f_readdir(&((struct SHELL_DIR *)fp->exinf)->dir, &fno)) != FR_OK || fno.fname[0] == '\0') {
    578624                return fresult2errno(res);
    579625        }
    580626
    581627        memset(de, 0, sizeof(*de));
    582 #if _USE_LFN
     628#if FF_USE_LFN
    583629        ntlibc_strlcpy(de->d_name, *fno.lfname ? fno.lfname : fno.fname, sizeof(de->d_name));
    584630#else
     
    589635}
    590636
    591 size_t dir_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
     637size_t dir_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    592638{
    593639        return -EPERM;
    594640}
    595641
    596 size_t dir_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
     642size_t dir_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    597643{
    598644        return -EPERM;
    599645}
    600646
    601 off_t dir_seek(struct _IO_FILE *fp, off_t ptr, int dir)
     647off_t dir_seek(struct SHELL_FILE *fp, off_t ptr, int dir)
    602648{
    603649        FRESULT res;
     
    607653
    608654        if (ptr == 0) {
    609                 if ((res = f_rewinddir(&fp->pdir->dir)) != FR_OK) {
     655                if ((res = f_rewinddir(&((struct SHELL_DIR *)fp->exinf)->dir)) != FR_OK) {
    610656                        return fresult2errno(res);
    611657                }
     
    613659        else {
    614660                FILINFO fno;
    615 #if _USE_LFN
    616                 static char lfn[_MAX_LFN + 1];   /* Buffer to store the LFN */
     661#if FF_USE_LFN
     662                static char lfn[FF_MAX_LFN + 1];   /* Buffer to store the LFN */
    617663                fno.lfname = lfn;
    618664                fno.lfsize = sizeof lfn;
    619665#endif
    620                 if ((res = f_rewinddir(&fp->pdir->dir)) != FR_OK) {
     666                if ((res = f_rewinddir(&((struct SHELL_DIR *)fp->exinf)->dir)) != FR_OK) {
    621667                        return fresult2errno(res);
    622668                }
    623669
    624670                for (int i = 0; i < ptr; i++) {
    625                         if ((res = f_readdir(&fp->pdir->dir, &fno)) != FR_OK || fno.fname[0] == '\0') {
     671                        if ((res = f_readdir(&((struct SHELL_DIR *)fp->exinf)->dir, &fno)) != FR_OK || fno.fname[0] == '\0') {
    626672                                return fresult2errno(res);
    627673                        }
     
    632678}
    633679
    634 int dir_ioctl(struct _IO_FILE *fp, int req, void *arg)
     680int dir_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    635681{
    636682        return -EINVAL;
     683}
     684
     685bool_t dir_readable(struct SHELL_FILE *fp)
     686{
     687        return fp->readevt_w != fp->readevt_r;
     688}
     689
     690void dir_delete(struct SHELL_FILE *fp)
     691{
     692        free((struct SHELL_DIR *)fp->exinf);
     693        fp->exinf = NULL;
    637694}
    638695
     
    687744{
    688745        //if ((addr >= (void *)&_HeapBase) && (addr + len < (void *)&_HeapLimit)) {
    689                 return 0;
    690         //}
    691         //return -1;
     746        return 0;
     747//}
     748//return -1;
    692749}
    693750
     
    697754static pool_t sys_pool;
    698755
    699 void sys_init(void)
     756void sys_tlsf_init(void)
    700757{
    701758        sys_tlsf = tlsf_create(&_HeapBase);
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/net_misc.c

    r359 r374  
    6060#include "kernel_cfg.h"
    6161#include "tinet_cfg.h"
    62 #include "util/ntstdio.h"
    63 
    64 extern ntstdio_t ntstdio;
     62#include <stdio.h>
    6563
    6664T_DHCP4_CLI_CONTEXT *dhcp4_cli_initialize(ID tskid, ID cepid);
     
    9795
    9896        get_tid(&nc->tskid);
    99         ntstdio_printf(&ntstdio, "[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
     97        printf("[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
    10098
    10199        /* 初期化 */
     
    105103        ret = get_tim(&time);
    106104        if (ret != E_OK) {
    107                 ntstdio_printf(&ntstdio, "[NET MISC,%d] get_tim error: %7lu,%s",
     105                printf("[NET MISC,%d] get_tim error: %7lu,%s",
    108106                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    109107                return;
     
    119117                error = tslp_tsk(timer);
    120118                if ((error != E_OK) && (error != E_TMOUT)) {
    121                         ntstdio_printf(&ntstdio, "[NET MISC,%d] tslp_tsk error: %s %d",
     119                        printf("[NET MISC,%d] tslp_tsk error: %s %d",
    122120                                nc->cepid, itron_strerror(error), timer);
    123121                        break;
     
    126124                ret = get_tim(&time);
    127125                if (ret != E_OK) {
    128                         ntstdio_printf(&ntstdio, "[NET MISC,%d] get_tim error: %s",
     126                        printf("[NET MISC,%d] get_tim error: %s",
    129127                                nc->cepid, itron_strerror(ret));
    130128                        break;
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/netcmd.c

    r364 r374  
    5959#include <netapp/resolver.h>
    6060#include "core/ntlibc.h"
    61 #include "util/ntstdio.h"
     61#include <stdio.h>
    6262#include "ntp_cli.h"
    6363#include "kernel_cfg.h"
    64 
    65 extern ntstdio_t ntstdio;
    6664
    6765#if defined(SUPPORT_INET6)
     
    280278
    281279        if ((line = lookup_ipaddr(&addr, line, apip)) == NULL) {
    282                 ntstdio_printf(&ntstdio, "[PING] unknown host.\n");
     280                printf("[PING] unknown host.\n");
    283281                return 0;
    284282        }
     
    299297#if defined(SUPPORT_INET4)
    300298        if (apip == API_PROTO_IPV6) {
    301                 ntstdio_printf(&ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     299                printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    302300                ping6(&addr, (uint_t)tmo, (uint_t)size);
    303301        }
    304302        else {
    305303                addr4 = ntohl(addr.s6_addr32[3]);
    306                 ntstdio_printf(&ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
     304                printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr4));
    307305                ping4(&addr4, (uint_t)tmo, (uint_t)size);
    308306        }
    309307#else /* of #if defined(SUPPORT_INET4) */
    310         ntstdio_printf(&ntstdio, "[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
     308        printf("[PING6] size: %d, tmo: %d, host: %s\n", size, tmo, ipv62str(NULL, &addr));
    311309        ping6(&addr, (uint_t)tmo, (uint_t)size);
    312310#endif  /* of #if defined(SUPPORT_INET4) */
    313311#else   /* of #if defined(SUPPORT_INET6) */
    314         ntstdio_printf(&ntstdio, "[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
     312        printf("[PING4] size: %d, tmo: %d, host: %s\n", size, tmo, ip2str(NULL, &addr));
    315313        ping4(&addr, (uint_t)tmo, (uint_t)size);
    316314#endif  /* of #if defined(SUPPORT_INET6) */
     
    331329                pos = str_ipv4addr(temp, sizeof(temp), &svaddr, 0);
    332330                temp[pos] = '\0';
    333                 ntstdio_printf(&ntstdio, "DHCPv4 server: %s,\n", temp);
    334                 ntstdio_printf(&ntstdio, "  Renew:       %u:%02u:%02u,\n",
     331                printf("DHCPv4 server: %s,\n", temp);
     332                printf("  Renew:       %u:%02u:%02u,\n",
    335333                        renew / 3600, (renew / 60) % 60, renew % 60);
    336                 ntstdio_printf(&ntstdio, "  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
     334                printf("  Rebind:      %u:%02u:%02u, Expire:   %u:%02u:%02u.\n",
    337335                        rebind / 3600, (rebind / 60) % 60, rebind % 60,
    338336                        expire / 3600, (expire / 60) % 60, expire % 60);
    339337        }
    340338        else if (ret == E_OBJ)
    341                 ntstdio_printf(&ntstdio, "DHCPv4 server: not available.\n");
     339                printf("DHCPv4 server: not available.\n");
    342340}
    343341
     
    351349        if (ntlibc_strcmp(argv[1], "rel") == 0) {
    352350                ret = dhcp4c_rel_info();
    353                 ntstdio_printf(&ntstdio, "dhcp4c_rel_info %d\n", ret);
     351                printf("dhcp4c_rel_info %d\n", ret);
    354352        }
    355353        else if (ntlibc_strcmp(argv[1], "renew") == 0) {
    356354                ret = dhcp4c_renew_info();
    357                 ntstdio_printf(&ntstdio, "dhcp4c_renew_info %d\n", ret);
     355                printf("dhcp4c_renew_info %d\n", ret);
    358356        }
    359357        else {
     
    383381                else {
    384382                        for (c = 1; c <= *ptr; c++)
    385                                 ntstdio_printf(&ntstdio, "%c", *(ptr + c));
     383                                printf("%c", *(ptr + c));
    386384                        ptr += *ptr + 1;
    387385                        if (*ptr)
    388                                 ntstdio_printf(&ntstdio, ".");
     386                                printf(".");
    389387                }
    390388        }
     
    406404                return error;
    407405
    408         ntstdio_printf(&ntstdio, "    mname:   ");
     406        printf("    mname:   ");
    409407        rn_offset = s_show_dns_domain_name(msg, offset);
    410         ntstdio_putc(&ntstdio, '\n');
    411         ntstdio_printf(&ntstdio, "    rname:   ");
     408        putchar('\n');
     409        printf("    rname:   ");
    412410        s_show_dns_domain_name(msg, rn_offset);
    413         ntstdio_putc(&ntstdio, '\n');
    414 
    415         ntstdio_printf(&ntstdio, "    serial:  %d\n", soa.serial);
    416         ntstdio_printf(&ntstdio, "    refresh: %d\n", soa.refresh);
    417         ntstdio_printf(&ntstdio, "    retry:   %d\n", soa.retry);
    418         ntstdio_printf(&ntstdio, "    expirel: %d\n", soa.expire);
    419         ntstdio_printf(&ntstdio, "    minimum: %d\n", soa.minimum);
     411        putchar('\n');
     412
     413        printf("    serial:  %d\n", soa.serial);
     414        printf("    refresh: %d\n", soa.refresh);
     415        printf("    retry:   %d\n", soa.retry);
     416        printf("    expirel: %d\n", soa.expire);
     417        printf("    minimum: %d\n", soa.minimum);
    420418
    421419        return E_OK;
     
    433431        int             scount;
    434432
    435         ntstdio_printf(&ntstdio, "question   section: %d\n", rslv->dns_hdr.qdcount);
     433        printf("question   section: %d\n", rslv->dns_hdr.qdcount);
    436434        offset = rslv->qd_offset;
    437435        for (scount = 1; scount <= rslv->dns_hdr.qdcount; scount++) {
     
    439437                        return error;
    440438
    441                 ntstdio_printf(&ntstdio, "%2d: ", scount);
     439                printf("%2d: ", scount);
    442440                s_show_dns_domain_name(msg, offset);
    443                 ntstdio_printf(&ntstdio, "\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
     441                printf("\n    type: %-4s, class: %2s\n", dns_strtype(qd.type), dns_strclass(qd.class));
    444442                offset = error;
    445443        }
     
    463461        int pos;
    464462
    465         ntstdio_printf(&ntstdio, "%10s section: %d\n", title, scount);
     463        printf("%10s section: %d\n", title, scount);
    466464        for (count = 1; count <= scount; count++) {
    467465                if ((error = dns_analyze_rr(&rr, offset, msg, length)) < 0)
    468466                        return error;
    469467
    470                 ntstdio_printf(&ntstdio, "%2d: ", count);
     468                printf("%2d: ", count);
    471469                s_show_dns_domain_name(msg, offset);
    472                 ntstdio_printf(&ntstdio, "\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
     470                printf("\n    type: %-4s, class: %2s, TTL: %2d, len: %3d, offset: 0x%02x\n",
    473471                        dns_strtype(rr.type), dns_strclass(rr.class), rr.ttl, rr.rdlength, rr.rdata_offset);
    474472
     
    479477                        pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    480478                        temp[pos] = '\0';
    481                         ntstdio_printf(&ntstdio, "    IPv4 addr: %s\n", temp);
     479                        printf("    IPv4 addr: %s\n", temp);
    482480                        break;
    483481                case DNS_TYPE_NS:
    484                         ntstdio_printf(&ntstdio, "    host: ");
     482                        printf("    host: ");
    485483                        s_show_dns_domain_name(msg, rr.rdata_offset);
    486                         ntstdio_putc(&ntstdio, '\n');
     484                        putchar('\n');
    487485                        break;
    488486                case DNS_TYPE_CNAME:
    489                         ntstdio_printf(&ntstdio, "    host: ");
     487                        printf("    host: ");
    490488                        s_show_dns_domain_name(msg, rr.rdata_offset);
    491                         ntstdio_putc(&ntstdio, '\n');
     489                        putchar('\n');
    492490                        break;
    493491                case DNS_TYPE_SOA:
     
    495493                        break;
    496494                case DNS_TYPE_PTR:
    497                         ntstdio_printf(&ntstdio, "     PTR: ");
     495                        printf("     PTR: ");
    498496                        s_show_dns_domain_name(msg, rr.rdata_offset);
    499                         ntstdio_putc(&ntstdio, '\n');
     497                        putchar('\n');
    500498                        break;
    501499                case DNS_TYPE_AAAA:
     
    503501                        pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    504502                        temp[pos] = '\0';
    505                         ntstdio_printf(&ntstdio, "    IPv6 addr: %s\n", temp);
     503                        printf("    IPv6 addr: %s\n", temp);
    506504                        break;
    507505                default:
    508                         ntstdio_printf(&ntstdio, "    data: ");
     506                        printf("    data: ");
    509507                        col = 32;
    510508                        for (dcount = 0; dcount < rr.rdlength; dcount++) {
    511                                 ntstdio_printf(&ntstdio, "%02x", *(msg + rr.rdata_offset + dcount));
     509                                printf("%02x", *(msg + rr.rdata_offset + dcount));
    512510                                if (--col == 0) {
    513                                         ntstdio_printf(&ntstdio, "\n          ");
     511                                        printf("\n          ");
    514512                                        col = 32;
    515513                                }
    516514                        }
    517                         ntstdio_putc(&ntstdio, '\n');
     515                        putchar('\n');
    518516                        break;
    519517                }
     
    539537#if defined(SUPPORT_INET6)
    540538
    541         ntstdio_printf(&ntstdio, "domain name:     %s\n", dns_in6_get_dname());
     539        printf("domain name:     %s\n", dns_in6_get_dname());
    542540
    543541#else   /* of #if defined(SUPPORT_INET6) */
    544542
    545         ntstdio_printf(&ntstdio, "domain name:     %s\n", dns_in4_get_dname());
     543        printf("domain name:     %s\n", dns_in4_get_dname());
    546544
    547545#endif  /* of #if defined(SUPPORT_INET6) */
     
    549547#if defined(SUPPORT_INET6)
    550548        dns_in6_get_addr(&in6_addr);
    551         ntstdio_printf(&ntstdio, "IPv6 DNS server: ");
     549        printf("IPv6 DNS server: ");
    552550        if (IN6_IS_ADDR_UNSPECIFIED(&in6_addr))
    553                 ntstdio_printf(&ntstdio, "not available.\n");
     551                printf("not available.\n");
    554552        else {
    555553                pos = str_ipv6addr(temp, sizeof(temp), &in6_addr, 0);
    556554                temp[pos] = '\0';
    557                 ntstdio_printf(&ntstdio, "%s.\n", temp);
     555                printf("%s.\n", temp);
    558556        }
    559557#endif  /* of #if defined(SUPPORT_INET6) */
     
    561559#if defined(SUPPORT_INET4)
    562560        dns_in4_get_addr(&in4_addr);
    563         ntstdio_printf(&ntstdio, "IPv4 DNS server: ");
     561        printf("IPv4 DNS server: ");
    564562        if (in4_addr == IPV4_ADDRANY)
    565                 ntstdio_printf(&ntstdio, "not available.\n");
     563                printf("not available.\n");
    566564        else {
    567565                pos = str_ipv4addr(temp, sizeof(temp), &in4_addr, 0);
    568566                temp[pos] = '\0';
    569                 ntstdio_printf(&ntstdio, "%s.\n", temp);
     567                printf("%s.\n", temp);
    570568        }
    571569#endif  /* of #if defined(SUPPORT_INET4) */
     
    604602        line = skip_blanks(resolv_options(&flags, line, DEFAULT_API_PROTO));
    605603        if ((flags & (DNS_LUP_FLAGS_PROTO_IPV6 | DNS_LUP_FLAGS_PROTO_IPV4)) == 0) {
    606                 ntstdio_printf(&ntstdio, "DNS server not available.\n");
     604                printf("DNS server not available.\n");
    607605                return 0;
    608606        }
     
    620618
    621619        if ((error = tget_mpf(MPF_RSLV_SRBUF, (void*)&msg, TMO_FEVR)) != E_OK) {
    622                 ntstdio_printf(&ntstdio, "get buffer error: %s.\n", itron_strerror(error));
     620                printf("get buffer error: %s.\n", itron_strerror(error));
    623621                return 0;
    624622        }
    625623
    626624        if ((length = dns_lookup_host(flags | DNS_LUP_FLAGS_MSG, line, msg, DNS_UDP_MSG_LENGTH, &rslv)) < 0) {
    627                 //ntstdio_printf(&ntstdio, "error: %s.\n", itron_strerror(length));
     625                //printf("error: %s.\n", itron_strerror(length));
    628626                goto err_ret;
    629627        }
    630628
    631629        dly_tsk(1 * 1000);
    632         ntstdio_printf(&ntstdio, "DNS header: flags: ");
     630        printf("DNS header: flags: ");
    633631        if (rslv.dns_hdr.code & (DNS_QR_RESPONSE | DNS_AUTHORITATIVE |
    634632                DNS_TRUN_CATION | DNS_RECURSION_DESIRED | DNS_RECURSION_AVAILABLE)) {
    635                 ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
    636                 ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
    637                 ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
    638                 ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
    639                 ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
    640                 ntstdio_printf(&ntstdio, " ");
    641         }
    642         ntstdio_printf(&ntstdio, "opcode: ");
    643         ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
    644         ntstdio_printf(&ntstdio, (rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
    645         ntstdio_printf(&ntstdio, ", rcode: %s.\n",
     633                printf((rslv.dns_hdr.code & DNS_QR_RESPONSE) ? "QR," : "");
     634                printf((rslv.dns_hdr.code & DNS_AUTHORITATIVE) ? "AA," : "");
     635                printf((rslv.dns_hdr.code & DNS_TRUN_CATION) ? "TC," : "");
     636                printf((rslv.dns_hdr.code & DNS_RECURSION_DESIRED) ? "RD," : "");
     637                printf((rslv.dns_hdr.code & DNS_RECURSION_AVAILABLE) ? "RA," : "");
     638                printf(" ");
     639        }
     640        printf("opcode: ");
     641        printf((rslv.dns_hdr.code & DNS_OPCODE_REVERSE) ? "RV" : "FW");
     642        printf((rslv.dns_hdr.code & DNS_OPCODE_STATUS) ? ",ST" : "");
     643        printf(", rcode: %s.\n",
    646644                (rslv.dns_hdr.code & DNS_RCODE_MASK) > DNS_RCODE_REFUSED
    647645                ? "6" : rcode_str[rslv.dns_hdr.code & DNS_RCODE_MASK]);
    648646
    649647        if ((offset = show_dns_qdsection(msg, length, &rslv)) < 0) {
    650                 ntstdio_printf(&ntstdio, "msg error: %s.\n", itron_strerror(offset));
     648                printf("msg error: %s.\n", itron_strerror(offset));
    651649        }
    652650        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.ancount, rslv.an_offset, "answer")) < 0) {
    653                 ntstdio_printf(&ntstdio, "msg error: %s.\n", itron_strerror(offset));
     651                printf("msg error: %s.\n", itron_strerror(offset));
    654652        }
    655653        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.nscount, rslv.ns_offset, "authority")) < 0) {
    656                 ntstdio_printf(&ntstdio, "msg error: %s.\n", itron_strerror(offset));
     654                printf("msg error: %s.\n", itron_strerror(offset));
    657655        }
    658656        if ((offset = show_dns_section(msg, length, rslv.dns_hdr.arcount, rslv.ar_offset, "additional")) < 0) {
    659                 ntstdio_printf(&ntstdio, "msg error: %s.\n", itron_strerror(offset));
     657                printf("msg error: %s.\n", itron_strerror(offset));
    660658        }
    661659
    662660err_ret:
    663661        if ((error = rel_mpf(MPF_RSLV_SRBUF, msg)) != E_OK)
    664                 ntstdio_printf(&ntstdio, "release buffer error: %s.\n", itron_strerror(error));
     662                printf("release buffer error: %s.\n", itron_strerror(error));
    665663        return 0;
    666664}
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntp_cli.c

    r364 r374  
    5050#include <t_syslog.h>
    5151#include "kernel_cfg.h"
    52 #include "util/ntstdio.h"
    53 
    54 extern ntstdio_t ntstdio;
     52#include <stdio.h>
    5553
    5654#endif  /* of #if defined(TARGET_KERNEL_ASP) */
     
    279277        }
    280278
    281         ntstdio_printf(&ntstdio, "[NTP CLI,%d] recv time: %s .%09u\n",
     279        printf("[NTP CLI,%d] recv time: %s .%09u\n",
    282280                nc->cepid, nc->buf, tp.tv_nsec);
    283281}
     
    311309                line = lookup_ipaddr(&nc->ipaddr6, NTP_SRV_URL, API_PROTO_IPV4);
    312310                if (line == NULL || !in6_is_addr_ipv4mapped(&nc->ipaddr6)) {
    313                         ntstdio_printf(&ntstdio, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     311                        printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    314312                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    315313                        nc->timer = SLP_ITV;
     
    319317#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
    320318                if ((line = lookup_ipaddr(&nc->snd_rmt.ipaddr, NTP_SRV_URL, DEFAULT_API_PROTO)) == NULL) {
    321                         ntstdio_printf(&ntstdio, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     319                        printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    322320                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    323321                        nc->timer = SLP_ITV;
     
    423421
    424422        if ((error = udp_snd_dat(nc->cepid, &nc->snd_rmt, ntp, len, TMO_NBLK)) != E_WBLK) {
    425                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] udp_snd_dat error: %s",
     423                printf("[NTP CLI,%d] udp_snd_dat error: %s",
    426424                        nc->cepid, itron_strerror(error));
    427425                return error;
     
    441439        ret = get_tim(&time);
    442440        if (ret != E_OK) {
    443                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %s",
     441                printf("[NTP CLI,%d] get_tim error: %s",
    444442                        nc->cepid, itron_strerror(ret));
    445443                tp->tv_sec = 0;
     
    461459        ret = set_tim(time);
    462460        if (ret != E_OK) {
    463                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] set_tim error: %s",
     461                printf("[NTP CLI,%d] set_tim error: %s",
    464462                        nc->cepid, itron_strerror(ret));
    465463        }
     
    479477        if (len < 0 && len != E_RLWAI) {
    480478                /* E_RLWAI 以外で、0 以下の場合は、エラーを意味している。*/
    481                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
     479                printf("[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
    482480                        itron_strerror(len), in_strtfn(fncd));
    483481        }
     
    486484                        if ((len = udp_rcv_dat(nc->cepid, &nc->rcv_rmt, &nc->ntp_msg, len, TMO_POL)) < 0)
    487485                        {
    488                                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
     486                                printf("[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
    489487                                        itron_strerror(len));
    490488                        }
     
    518516
    519517        get_tid(&nc->tskid);
    520         ntstdio_printf(&ntstdio, "[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
     518        printf("[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
    521519
    522520        /* 初期化 */
     
    525523        ret = get_tim(&time);
    526524        if (ret != E_OK) {
    527                 ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %7lu,%s",
     525                printf("[NTP CLI,%d] get_tim error: %7lu,%s",
    528526                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    529527                return;
     
    539537                error = tslp_tsk(timer);
    540538                if ((error != E_OK) && (error != E_TMOUT)) {
    541                         ntstdio_printf(&ntstdio, "[NTP CLI,%d] tslp_tsk error: %s %d",
     539                        printf("[NTP CLI,%d] tslp_tsk error: %s %d",
    542540                                nc->cepid, itron_strerror(error), timer);
    543541                        break;
     
    546544                ret = get_tim(&time);
    547545                if (ret != E_OK) {
    548                         ntstdio_printf(&ntstdio, "[NTP CLI,%d] get_tim error: %s",
     546                        printf("[NTP CLI,%d] get_tim error: %s",
    549547                                nc->cepid, itron_strerror(ret));
    550548                        break;
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntshell_main.c

    r364 r374  
    5959#include "ntshell_main.h"
    6060#include "socket_stub.h"
    61 #include "usb_hbth.h"
    62 #include "mbed_api.h"
    63 
    64 extern int bt_bnep_mode;
    6561
    6662char command[NTOPT_TEXT_MAXLEN];
    67 ntstdio_t ntstdio;
    6863
    6964extern uint8_t mac_addr[6];
     
    8883volatile int ntshell_state;
    8984jmp_buf process_exit;
    90 void sys_init(void);
    91 NTSHELL_SERIAL_READ ntshell_serial_read = 0;
    92 NTSHELL_SERIAL_WRITE ntshell_serial_write = 0;
    93 void *ntshell_serial_extobj;
    94 
    95 unsigned char ntstdio_xi(struct ntstdio_t *handle)
    96 {
    97         unsigned char buf[1];
    98         ntshell_serial_read((char *)buf, 1, ntshell_serial_extobj);
    99         return buf[0];
    100 }
    101 
    102 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
    103 {
    104         char buf[1];
    105         buf[0] = c;
    106         ntshell_serial_write(buf, 1, ntshell_serial_extobj);
    107 }
    108 
    109 void ntshell_task_init(NTSHELL_SERIAL_READ func_read,
    110         NTSHELL_SERIAL_WRITE func_write, void *extobj)
    111 {
    112         ntshell_serial_read = func_read;
    113         ntshell_serial_write = func_write;
    114         ntshell_serial_extobj = extobj;
    115 
    116         sys_init();
    117 
    118         ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo);
     85
     86void ntshell_task_init(ID portid)
     87{
     88        serial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);
    11989}
    12090
     
    178148        const cmd_table_t *p = cmd_table_info.table;
    179149        for (int i = 0; i < cmd_table_info.count; i++) {
    180                 ntstdio_puts(&ntstdio, p->cmd);
    181                 ntstdio_puts(&ntstdio, "\t:");
    182                 ntstdio_puts(&ntstdio, p->desc);
    183                 ntstdio_puts(&ntstdio, "\n");
     150                fwrite(p->cmd, strlen(p->cmd), 1, stdout);
     151                fwrite("\t:", strlen("\t:"), 1, stdout);
     152                puts(p->desc);
    184153                p++;
    185154        }
     
    207176int execute_command(int wait)
    208177{
     178        T_RTSK rtsk;
    209179        ER ret;
    210180
     
    229199        do {
    230200                tslp_tsk(100000);
     201
     202                ret = ref_tsk(NTSHELL_TASK, &rtsk);
     203                if ((ret != E_OK) || (rtsk.tskstat == TTS_DMT))
     204                        ntshell_state = 3;
    231205        } while(ntshell_state == 1);
    232206
     
    238212        ntlibc_strlcpy(command, text, sizeof(command));
    239213        return execute_command(1);
    240 }
    241 
    242 int stdio_close(struct _IO_FILE *fp)
    243 {
    244         return -EPERM;
    245 }
    246 
    247 size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
    248 {
    249         return -EPERM;
    250 }
    251 
    252 size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
    253 {
    254         return -EPERM;
    255 }
    256 
    257 size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
    258 {
    259         int i = 0;
    260         while (i < len) {
    261                 int c = ntstdio_getc(&ntstdio);
    262                 data[i++] = c;
    263                 if ((c == EOF) || (c == '\n'))
    264                         break;
    265         }
    266         return i;
    267 }
    268 
    269 size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
    270 {
    271         for (int i = 0; i < len; i++) {
    272                 ntstdio_putc(&ntstdio, data[i]);
    273         }
    274         return len;
    275 }
    276 
    277 size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
    278 {
    279         for (int i = 0; i < len; i++) {
    280                 ntstdio_putc(&ntstdio, data[i]);
    281         }
    282         return len;
    283 }
    284 
    285 int sio_close(struct _IO_FILE *fp)
    286 {
    287         return -EPERM;
    288 }
    289 
    290 size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len)
    291 {
    292         return -EPERM;
    293 }
    294 
    295 size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len)
    296 {
    297         return -EPERM;
    298 }
    299 
    300 off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org)
    301 {
    302         return -EPERM;
    303 }
    304 
    305 int sio_ioctl(struct _IO_FILE *fp, int request, void *arg)
    306 {
    307         switch (request) {
    308         case TIOCGWINSZ:
    309                 return 0;
    310         case TCGETS:
    311                 return sio_tcgetattr(fp->fd, (struct termios *)arg);
    312         case TCSETS + TCSANOW:
    313         case TCSETS + TCSADRAIN:
    314         case TCSETS + TCSAFLUSH:
    315                 return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg);
    316         }
    317 
    318         return -EINVAL;
    319214}
    320215
     
    457352}
    458353
     354int shell_kill(int pid, int sig)
     355{
     356        DebugBreak();
     357        return -1;
     358}
     359
     360int shell_gettimeofday(struct timeval *tv, void *tzvp)
     361{
     362        SYSTIM time;
     363        if (!tv) return 0;
     364        get_tim(&time);
     365        tv->tv_sec = time / 1000000;
     366        tv->tv_usec = time - (tv->tv_sec * 1000000);
     367        return 0;
     368}
     369
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntshell_main.cfg

    r364 r374  
    4141#include "ntshell_main.h"
    4242
     43ATT_INI({ TA_NULL, 0, sys_init });
     44
    4345CRE_TSK(NTSHELL_TASK, { TA_NULL, 0, ntshell_task, NTSHELL_PRIORITY, NTSHELL_STACK_SIZE, NULL });
    4446CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 });
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntshell_main.h

    r367 r374  
    7676extern PRI main_task_priority;
    7777
     78/* ntshellの初期化 */
     79void sys_init(intptr_t exinf);
     80
    7881/* ntshellタスク初期化 */
    79 void ntshell_task_init(NTSHELL_SERIAL_READ func_read,
    80         NTSHELL_SERIAL_WRITE func_write, void *extobj);
     82void ntshell_task_init(ID portid);
    8183
    8284/* ntshellタスク */
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/shellif.h

    r364 r374  
    134134
    135135// dirent.h
    136 typedef struct __dirstream DIR;
     136typedef struct __dirstream FATFS_DIR;
    137137
    138138int shell_getdents(int, struct dirent *, size_t);
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/socket_stub.c

    r364 r374  
    5757#include <netinet/udp_var.h>
    5858#include <net/net_buf.h>
    59 //#include <netinet/tcp_var.h>
     59#include <netinet/udp.h>
     60#include <netinet/udp_var.h>
     61#include <netinet/tcp.h>
     62#include <netinet/tcp_var.h>
    6063#include <netapp/resolver.h>
    6164extern const ID tmax_tcp_cepid;
     
    6568
    6669#define SOCKET_TIMEOUT 2000000
     70
     71#define tcp6_cre_cep tcp_cre_cep
     72#define tcp6_del_cep tcp_del_cep
     73#define tcp6_del_rep tcp_del_rep
     74#define tcp6_sht_cep tcp_sht_cep
     75#define tcp6_cls_cep tcp_cls_cep
     76#define tcp6_snd_oob tcp_snd_oob
     77#define tcp6_snd_dat tcp_snd_dat
     78#define tcp6_rcv_oob tcp_rcv_oob
     79#define tcp6_rcv_buf tcp_rcv_buf
     80#define tcp6_rel_buf tcp_rel_buf
     81#define tcp6_get_opt tcp_get_opt
     82#define tcp6_set_opt tcp_set_opt
     83
     84#define udp6_del_cep udp_del_cep
     85#define udp6_get_opt udp_get_opt
     86#define udp6_set_opt udp_set_opt
     87
     88#ifndef SUPPORT_INET6
     89
     90ER      tcp6_cre_rep (ID repid, T_TCP6_CREP *pk_crep) { return E_SYS; }
     91ER      tcp6_acp_cep (ID cepid, ID repid, T_IPV6EP *p_dstaddr, TMO tmout) { return E_SYS; }
     92ER      tcp6_con_cep (ID cepid, T_IPV6EP *p_myaddr, T_IPV6EP *p_dstaddr, TMO tmout) { return E_SYS; }
     93
     94ER      udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep) { return E_SYS; }
     95ER_UINT udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
     96ER_UINT udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
     97
     98const T_IN6_ADDR *in6_get_ifaddr (int_t index) { return NULL; }
     99
     100#endif
     101
     102ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk);
     103ER socket_tcp6_callback(ID cepid, FN fncd, void *p_parblk);
     104ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk);
     105ER socket_udp6_callback(ID cepid, FN fncd, void *p_parblk);
     106
     107static int tcp_fd_close(struct SHELL_FILE *fp);
     108static size_t tcp_fd_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     109static size_t tcp_fd_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     110static off_t tcp_fd_seek(struct SHELL_FILE *fp, off_t ofs, int org);
     111static int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
     112static bool_t tcp_fd_readable(struct SHELL_FILE *fp);
     113static void tcp_fd_delete(struct SHELL_FILE *fp);
     114
     115static int udp_fd_close(struct SHELL_FILE *fp);
     116static size_t udp_fd_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
     117static size_t udp_fd_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
     118static off_t udp_fd_seek(struct SHELL_FILE *fp, off_t ofs, int org);
     119static int udp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
     120static bool_t udp_fd_readable(struct SHELL_FILE *fp);
     121static void udp_fd_delete(struct SHELL_FILE *fp);
     122
     123IO_TYPE IO_TYPE_TCP = { tcp_fd_close, tcp_fd_read, tcp_fd_write, tcp_fd_seek, tcp_fd_ioctl, tcp_fd_readable, tcp_fd_delete };
     124IO_TYPE IO_TYPE_UDP = { udp_fd_close, udp_fd_read, udp_fd_write, udp_fd_seek, udp_fd_ioctl, udp_fd_readable, udp_fd_delete };
    67125
    68126typedef struct id_table_t {
     
    84142#define tcp_cepid_table_count (sizeof(tcp_cepid_table) / sizeof(tcp_cepid_table[0]))
    85143
     144#ifdef SUPPORT_INET6
     145
     146id_table_t tcp6_repid_table[] = {
     147        {0, USR_TCP6_REP1}, {0, USR_TCP6_REP2}, {0, USR_TCP6_REP3}, {0, USR_TCP6_REP4}
     148};
     149#define tcp6_repid_table_count (sizeof(tcp6_repid_table) / sizeof(tcp6_repid_table[0]))
     150
     151id_table_t tcp6_cepid_table[] = {
     152        {0, USR_TCP6_CEP1}, {0, USR_TCP6_CEP2}, {0, USR_TCP6_CEP3}, {0, USR_TCP6_CEP4},
     153#ifndef TOPPERS_GRSAKURA
     154        {0, USR_TCP6_CEP5}, {0, USR_TCP6_CEP6}, {0, USR_TCP6_CEP7}, {0, USR_TCP6_CEP8}
     155#endif
     156};
     157#define tcp6_cepid_table_count (sizeof(tcp6_cepid_table) / sizeof(tcp6_cepid_table[0]))
     158
     159#else
     160
     161#define tcp6_repid_table NULL
     162#define tcp6_repid_table_count 0
     163
     164#define tcp6_cepid_table NULL
     165#define tcp6_cepid_table_count 0
     166
     167#endif
     168
    86169id_table_t udp_cepid_table[] = {
    87170        {0, USR_UDP_CEP1}, {0, USR_UDP_CEP2}, {0, USR_UDP_CEP3}, {0, USR_UDP_CEP4}
     
    89172#define udp_cepid_table_count (sizeof(udp_cepid_table) / sizeof(udp_cepid_table[0]))
    90173
     174#ifdef SUPPORT_INET6
     175
     176id_table_t udp6_cepid_table[] = {
     177        {0, USR_UDP6_CEP1}, {0, USR_UDP6_CEP2}, {0, USR_UDP6_CEP3}, {0, USR_UDP6_CEP4}
     178};
     179#define udp6_cepid_table_count (sizeof(udp6_cepid_table) / sizeof(udp6_cepid_table[0]))
     180
     181#else
     182
     183#define udp6_cepid_table NULL
     184#define udp6_cepid_table_count 0
     185
     186#endif
     187
    91188ID new_id(id_table_t *table, int count)
    92189{
     
    116213}
    117214
    118 int delete_tcp_rep(int repid)
    119 {
    120         return delete_tcp_fd(tmax_tcp_cepid + repid);
    121 }
    122 
    123 typedef struct _IO_FILE SOCKET;
     215typedef struct SHELL_FILE SOCKET;
    124216
    125217int shell_socket(int family, int type, int protocol)
     
    141233        switch (type) {
    142234        case SOCK_STREAM:
    143                 fp = new_tcp_fd(0);
     235                fp = new_fp(&IO_TYPE_TCP, 0, 0);
     236                if (fp == NULL)
     237                        return -ENOMEM;
     238
     239                fp->exinf = malloc(sizeof(socket_t));
     240                memset(fp->exinf, 0, sizeof(socket_t));
    144241                break;
    145242        case SOCK_DGRAM:
    146                 fp = new_udp_fd(0);
     243                fp = new_fp(&IO_TYPE_UDP, 0, 1);
     244                if (fp == NULL)
     245                        return -ENOMEM;
     246
     247                fp->exinf = malloc(sizeof(socket_t));
     248                memset(fp->exinf, 0, sizeof(socket_t));
    147249                break;
    148250        default:
     
    150252        }
    151253
    152         if (fp == NULL) {
    153                 return -ENOMEM;
    154         }
    155 
    156         fp->psock->family = family;
    157         fp->psock->type = type;
    158         fp->psock->protocol = protocol;
    159         fp->psock->flags = flags;
     254        socket_t *socket = (socket_t *)fp->exinf;
     255        socket->family = family;
     256        socket->type = type;
     257        socket->protocol = protocol;
     258        socket->flags = flags;
    160259
    161260        return fp->fd;
     
    167266        if (fp == NULL)
    168267                return -EBADF;
    169         if (fp->psock->family != addr->sa_family)
     268        socket_t *socket = (socket_t *)fp->exinf;
     269        if (socket->family != addr->sa_family)
    170270                return -EINVAL;
    171271
     
    177277                }
    178278                struct sockaddr_in *addr_in = (struct sockaddr_in *)addr;
    179                 memcpy(&fp->psock->laddr4, addr, len);
    180                 switch (fp->psock->type) {
     279                memcpy(&socket->laddr4, addr, len);
     280                switch (socket->type) {
    181281                case SOCK_STREAM: {
    182282                        ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
     
    184284                                return -ENOMEM;
    185285
    186                         fp->psock->buf_size = 512 + 512;
    187                         fp->psock->buf = malloc(fp->psock->buf_size);
     286                        socket->buf_size = 512 + 512;
     287                        socket->buf = malloc(socket->buf_size);
    188288#ifdef _DEBUG
    189                         memset(fp->psock->buf, 0, fp->psock->buf_size);
     289                        memset(socket->buf, 0, socket->buf_size);
    190290#endif
    191                         T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
     291                        T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
    192292                        ret = tcp_cre_cep(cepid, &ccep);
    193293                        if (ret != E_OK) {
     
    196296                        }
    197297                        fp->handle = cepid;
    198                         fp->psock->cepid = cepid;
     298                        socket->cepid = cepid;
    199299                        break;
    200300                }
     
    211311                        }
    212312                        fp->handle = cepid;
    213                         fp->psock->cepid = cepid;
     313                        socket->cepid = cepid;
    214314                        break;
    215315                }
     
    223323                        return -EINVAL;
    224324                }
    225                 memcpy(&fp->psock->laddr4, addr, len);
    226                 break;
    227         }
     325                struct sockaddr_in6 *addr_in6 = (struct sockaddr_in6 *)addr;
     326                memcpy(&socket->laddr6, addr, len);
     327                switch (socket->type) {
     328                case SOCK_STREAM: {
     329                        ID cepid = new_id(tcp6_cepid_table, tcp6_cepid_table_count);
     330                        if (cepid < 0)
     331                                return -ENOMEM;
     332
     333                        socket->buf_size = 512 + 512;
     334                        socket->buf = malloc(socket->buf_size);
     335#ifdef _DEBUG
     336                        memset(socket->buf, 0, socket->buf_size);
     337#endif
     338                        T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
     339                        ret = tcp6_cre_cep(cepid, &ccep);
     340                        if (ret != E_OK) {
     341                                delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
     342                                return -ENOMEM;
     343                        }
     344                        fp->handle = cepid;
     345                        socket->cepid = cepid;
     346                        break;
     347                }
     348                case SOCK_DGRAM: {
     349                        ID cepid = new_id(udp_cepid_table, udp_cepid_table_count);
     350                        if (cepid < 0)
     351                                return -ENOMEM;
     352
     353                        T_UDP6_CCEP ccep = { 0, {ntohl(addr_in6->sin6_addr.__in6_union.__s6_addr), ntohs(addr_in6->sin6_port)}, (FP)socket_udp6_callback };
     354                        ret = udp6_cre_cep(cepid, &ccep);
     355                        if (ret != E_OK) {
     356                                delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
     357                                return -ENOMEM;
     358                        }
     359                        fp->handle = cepid;
     360                        socket->cepid = cepid;
     361                        break;
     362                }
     363                default:
     364                        return -ENOPROTOOPT;
     365                }
     366                break;
     367        }
     368        default:
     369                return -ENOPROTOOPT;
    228370        }
    229371
     
    236378        if (fp == NULL)
    237379                return -EBADF;
    238         if (fp->psock->type != SOCK_STREAM)
     380        socket_t *socket = (socket_t *)fp->exinf;
     381        if (socket->type != SOCK_STREAM)
    239382                return -EINVAL;
    240383
    241         fp->psock->backlog = backlog;
     384        socket->backlog = backlog;
    242385
    243386        ER ret;
    244         switch (fp->psock->family) {
     387        switch (socket->family) {
    245388        case AF_INET: {
    246389                ID repid = new_id(tcp_repid_table, tcp_repid_table_count);
     
    248391                        return -ENOMEM;
    249392
    250                 struct sockaddr_in *laddr = &fp->psock->laddr4;
     393                struct sockaddr_in *laddr = &socket->laddr4;
    251394                T_TCP_CREP crep = { 0, {ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port)} };
    252395                ret = tcp_cre_rep(repid, &crep);
     
    255398                        return -ENOMEM;
    256399                }
    257                 fp->psock->repid = repid;
     400                socket->repid = repid;
    258401                break;
    259402        }
    260403        case AF_INET6: {
    261                 break;
    262         }
     404                ID repid = new_id(tcp6_repid_table, tcp6_repid_table_count);
     405                if (repid < 0)
     406                        return -ENOMEM;
     407
     408                struct sockaddr_in6 *laddr = &socket->laddr6;
     409                T_TCP6_CREP crep = { 0, {ntohl(laddr->sin6_addr.__in6_union.__s6_addr), ntohs(laddr->sin6_port)} };
     410                ret = tcp6_cre_rep(repid, &crep);
     411                if (ret != E_OK) {
     412                        delete_id(tcp6_repid_table, tcp6_repid_table_count, repid);
     413                        return -ENOMEM;
     414                }
     415                socket->repid = repid;
     416                break;
     417        }
     418        default:
     419                return -ENOPROTOOPT;
    263420        }
    264421
     
    271428        if (fp == NULL)
    272429                return -EBADF;
    273         if (fp->psock->type != SOCK_STREAM)
     430        socket_t *socket = (socket_t *)fp->exinf;
     431        if (socket->type != SOCK_STREAM)
    274432                return -EINVAL;
    275433
    276434        ER ret;
    277         switch (fp->psock->family) {
     435        switch (socket->family) {
    278436        case AF_INET: {
    279437                if (len < 8) {
    280438                        return -EINVAL;
    281439                }
    282                 if (fp->psock->cepid == 0) {
     440                if (socket->cepid == 0) {
    283441                        ID cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
    284442                        if (cepid < 0)
    285443                                return -ENOMEM;
    286444
    287                         fp->psock->buf_size = 512 + 512;
    288                         fp->psock->buf = malloc(fp->psock->buf_size);
     445                        socket->buf_size = 512 + 512;
     446                        socket->buf = malloc(socket->buf_size);
    289447#ifdef _DEBUG
    290                         memset(fp->psock->buf, 0, fp->psock->buf_size);
     448                        memset(socket->buf, 0, socket->buf_size);
    291449#endif
    292                         T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
     450                        T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
    293451                        ret = tcp_cre_cep(cepid, &ccep);
    294452                        if (ret != E_OK) {
     
    297455                        }
    298456                        fp->handle = cepid;
    299                         fp->psock->cepid = cepid;
    300                 }
    301                 struct sockaddr_in *laddr = &fp->psock->laddr4;
    302                 struct sockaddr_in *raddr = &fp->psock->raddr4;
     457                        socket->cepid = cepid;
     458                }
     459                struct sockaddr_in *laddr = &socket->laddr4;
     460                struct sockaddr_in *raddr = &socket->raddr4;
    303461                memset(raddr, 0, sizeof(*raddr));
    304462                memcpy(raddr, addr, len);
    305463                T_IPV4EP lep = { ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port) };
    306464                T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    307                 ret = tcp_con_cep(fp->psock->cepid, &lep, &rep, SOCKET_TIMEOUT);
     465                ret = tcp_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
    308466                if (ret < 0) {
    309467                        return -EHOSTUNREACH;
     
    312470        }
    313471        case AF_INET6: {
    314                 break;
    315         }
     472                if (len < 20) {
     473                        return -EINVAL;
     474                }
     475                if (socket->cepid == 0) {
     476                        ID cepid = new_id(tcp6_cepid_table, tcp6_cepid_table_count);
     477                        if (cepid < 0)
     478                                return -ENOMEM;
     479
     480                        socket->buf_size = 512 + 512;
     481                        socket->buf = malloc(socket->buf_size);
     482#ifdef _DEBUG
     483                        memset(socket->buf, 0, socket->buf_size);
     484#endif
     485                        T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
     486                        ret = tcp6_cre_cep(cepid, &ccep);
     487                        if (ret != E_OK) {
     488                                delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
     489                                return -ENOMEM;
     490                        }
     491                        fp->handle = cepid;
     492                        socket->cepid = cepid;
     493                }
     494                struct sockaddr_in6 *laddr = &socket->laddr6;
     495                struct sockaddr_in6 *raddr = &socket->raddr6;
     496                memset(raddr, 0, sizeof(*raddr));
     497                memcpy(raddr, addr, len);
     498                T_IPV6EP lep = { ntohl(laddr->sin6_addr.__in6_union.__s6_addr), ntohs(laddr->sin6_port) };
     499                T_IPV6EP rep = { ntohl(raddr->sin6_addr.__in6_union.__s6_addr), ntohs(raddr->sin6_port) };
     500                ret = tcp6_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
     501                if (ret < 0) {
     502                        return -EHOSTUNREACH;
     503                }
     504                break;
     505        }
     506        default:
     507                return -ENOPROTOOPT;
    316508        }
    317509
     
    324516        if (lfp == NULL)
    325517                return -EBADF;
    326         if (lfp->psock->type != SOCK_STREAM)
     518        if (((socket_t *)lfp->exinf)->type != SOCK_STREAM)
    327519                return -EINVAL;
    328520
    329         SOCKET *fp = new_tcp_fd(0);
    330         if (fp == NULL) {
     521        SOCKET *fp = new_fp(&IO_TYPE_TCP, 0, 0);
     522        if (fp == NULL)
    331523                return -ENOMEM;
    332         }
    333 
    334         memcpy(fp->psock, lfp->psock, offsetof(socket_t, buf_size));
     524
     525        fp->exinf = malloc(sizeof(socket_t));
     526        memset(fp->exinf, 0, sizeof(socket_t));
     527
     528        memcpy(fp->exinf, lfp->exinf, offsetof(socket_t, buf_size));
    335529
    336530        ER ret;
    337         switch (fp->psock->family) {
     531        socket_t *socket = (socket_t *)fp->exinf;
     532        switch (socket->family) {
    338533        case AF_INET: {
    339534                ID cepid;
    340                 if (fp->psock->cepid == 0) {
     535                if (socket->cepid == 0) {
    341536                        cepid = new_id(tcp_cepid_table, tcp_cepid_table_count);
    342537                        if (cepid < 0)
    343538                                return -ENOMEM;
    344539
    345                         fp->psock->buf_size = 512 + 512;
    346                         fp->psock->buf = malloc(fp->psock->buf_size);
     540                        socket->buf_size = 512 + 512;
     541                        socket->buf = malloc(socket->buf_size);
    347542#ifdef _DEBUG
    348                         memset(fp->psock->buf, 0, fp->psock->buf_size);
     543                        memset(socket->buf, 0, socket->buf_size);
    349544#endif
    350                         T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
     545                        T_TCP_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp_callback };
    351546                        ret = tcp_cre_cep(cepid, &ccep);
    352547                        if (ret != E_OK) {
     
    355550                        }
    356551                        fp->handle = cepid;
    357                         fp->psock->cepid = cepid;
     552                        socket->cepid = cepid;
    358553                }
    359554                else {
    360                         cepid = lfp->psock->cepid;
     555                        cepid = ((socket_t *)lfp->exinf)->cepid;
    361556                        fp->handle = cepid;
    362                         lfp->handle = tmax_tcp_cepid + lfp->psock->repid;
    363                         lfp->psock->cepid = 0;
    364                         lfp->psock->buf_size = 0;
    365                         lfp->psock->buf = 0;
     557                        lfp->handle = tmax_tcp_cepid + ((socket_t *)lfp->exinf)->repid;
     558                        ((socket_t *)lfp->exinf)->cepid = 0;
     559                        ((socket_t *)lfp->exinf)->buf_size = 0;
     560                        ((socket_t *)lfp->exinf)->buf = 0;
    366561                }
    367562                T_IPV4EP rep = { 0, 0 };
    368                 ret = tcp_acp_cep(fp->psock->cepid, fp->psock->repid, &rep, TMO_FEVR);
     563                ret = tcp_acp_cep(socket->cepid, socket->repid, &rep, TMO_FEVR);
    369564                if (ret < 0) {
    370565                        return -ENOMEM;
    371566                }
    372                 struct sockaddr_in *raddr = &fp->psock->raddr4;
     567                struct sockaddr_in *raddr = &socket->raddr4;
    373568                memset(raddr, 0, sizeof(*raddr));
    374569                raddr->sin_family = AF_INET;
    375570                raddr->sin_port = htons(rep.portno);
    376571                raddr->sin_addr.s_addr = htonl(rep.ipaddr);
     572
     573                if (addr != NULL && len != NULL) {
     574                        int sz = *len;
     575                        if (sz < 8) {
     576                                return -EINVAL;
     577                        }
     578                        struct sockaddr_in *raddr = &socket->raddr4;
     579                        if (sz > sizeof(*raddr))
     580                                sz = sizeof(*raddr);
     581                        memcpy(addr, raddr, sz);
     582                        *len = sizeof(*raddr);
     583                }
    377584                break;
    378585        }
    379586        case AF_INET6: {
    380                 return -EAFNOSUPPORT;
    381         }
    382         }
    383 
    384         if (addr != NULL && len != NULL) {
    385                 int sz = *len;
    386                 if (sz < 8) {
    387                         return -EINVAL;
    388                 }
    389                 struct sockaddr_in *raddr = &fp->psock->raddr4;
    390                 if (sz > sizeof(*raddr))
    391                         sz = sizeof(*raddr);
    392                 memcpy(addr, raddr, sz);
    393                 *len = sizeof(*raddr);
     587                ID cepid;
     588                if (socket->cepid == 0) {
     589                        cepid = new_id(tcp6_cepid_table, tcp6_cepid_table_count);
     590                        if (cepid < 0)
     591                                return -ENOMEM;
     592
     593                        socket->buf_size = 512 + 512;
     594                        socket->buf = malloc(socket->buf_size);
     595#ifdef _DEBUG
     596                        memset(socket->buf, 0, socket->buf_size);
     597#endif
     598                        T_TCP6_CCEP ccep = { 0, socket->buf, 512, &socket->buf[512], 512, (FP)socket_tcp6_callback };
     599                        ret = tcp6_cre_cep(cepid, &ccep);
     600                        if (ret != E_OK) {
     601                                delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
     602                                return -ENOMEM;
     603                        }
     604                        fp->handle = cepid;
     605                        socket->cepid = cepid;
     606                }
     607                else {
     608                        cepid = ((socket_t *)lfp->exinf)->cepid;
     609                        fp->handle = cepid;
     610                        lfp->handle = tmax_tcp6_cepid + ((socket_t *)lfp->exinf)->repid;
     611                        ((socket_t *)lfp->exinf)->cepid = 0;
     612                        ((socket_t *)lfp->exinf)->buf_size = 0;
     613                        ((socket_t *)lfp->exinf)->buf = 0;
     614                }
     615                T_IPV6EP rep = { 0, 0 };
     616                ret = tcp6_acp_cep(socket->cepid, socket->repid, &rep, TMO_FEVR);
     617                if (ret < 0) {
     618                        return -ENOMEM;
     619                }
     620                struct sockaddr_in6 *raddr = &socket->raddr6;
     621                memset(raddr, 0, sizeof(*raddr));
     622                raddr->sin6_family = AF_INET;
     623                raddr->sin6_port = htons(rep.portno);
     624#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     625                memcpy(raddr->sin6_addr.__in6_union.__s6_addr, rep.ipaddr.__u6_addr.__u6_addr8, 16);
     626#else
     627                for (int i = 0; i < 16; i++)
     628                        raddr->sin6_addr.__in6_union.__s6_addr[i] = rep.ipaddr.__u6_addr.__u6_addr8[i];
     629#endif
     630
     631                if (addr != NULL && len != NULL) {
     632                        int sz = *len;
     633                        if (sz < 8) {
     634                                return -EINVAL;
     635                        }
     636                        struct sockaddr_in6 *raddr = &socket->raddr6;
     637                        if (sz > sizeof(*raddr))
     638                                sz = sizeof(*raddr);
     639                        memcpy(addr, raddr, sz);
     640                        *len = sizeof(*raddr);
     641                }
     642                break;
     643        }
     644        default:
     645                return -ENOPROTOOPT;
    394646        }
    395647
     
    405657
    406658        int ret = 0;
    407         switch (fp->psock->family) {
     659        socket_t *socket = (socket_t *)fp->exinf;
     660        switch (socket->family) {
    408661        case AF_INET: {
    409                 switch (fp->psock->type) {
     662                switch (socket->type) {
    410663                case SOCK_STREAM: {
    411664                        if ((addr != NULL) || (alen != 0)) {
     
    414667
    415668                        if (flags & MSG_OOB) {
    416                                 ret = tcp_snd_oob(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     669                                ret = tcp_snd_oob(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    417670                                if (ret < 0) {
    418671                                        return -ECOMM;
     
    421674                        else {
    422675                                for (;;) {
    423                                         ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     676                                        ret = tcp_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    424677                                        if (ret < 0) {
    425678                                                if (ret == E_TMOUT)
     
    440693                                return -EINVAL;
    441694                        }
    442                         struct sockaddr_in *raddr = &fp->psock->raddr4;
     695                        struct sockaddr_in *raddr = &socket->raddr4;
    443696                        memset(raddr, 0, sizeof(*raddr));
    444697                        memcpy(raddr, addr, sz);
    445698                        T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    446                         ret = udp_snd_dat(fp->psock->cepid, &rep, (void *)buf, len,
    447                                 (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     699                        ret = udp_snd_dat(socket->cepid, &rep, (void *)buf, len,
     700                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    448701                        if (ret < 0) {
    449702                                return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     
    455708        }
    456709        case AF_INET6: {
    457                 return -EAFNOSUPPORT;
    458         }
     710                switch (socket->type) {
     711                case SOCK_STREAM: {
     712                        if ((addr != NULL) || (alen != 0)) {
     713                                return -EISCONN;
     714                        }
     715
     716                        if (flags & MSG_OOB) {
     717                                ret = tcp6_snd_oob(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     718                                if (ret < 0) {
     719                                        return -ECOMM;
     720                                }
     721                        }
     722                        else {
     723                                for (;;) {
     724                                        ret = tcp6_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     725                                        if (ret < 0) {
     726                                                if (ret == E_TMOUT)
     727                                                        return -ETIME;
     728                                                return -ECOMM;
     729                                        }
     730                                        len -= ret;
     731                                        if (len <= 0)
     732                                                break;
     733                                        buf = (const void *)&((uint8_t *)buf)[ret];
     734                                }
     735                        }
     736                        break;
     737                }
     738                case SOCK_DGRAM: {
     739                        int sz = alen;
     740                        if ((addr == NULL) || (sz < 8)) {
     741                                return -EINVAL;
     742                        }
     743                        struct sockaddr_in6 *raddr = &socket->raddr6;
     744                        memset(raddr, 0, sizeof(*raddr));
     745                        memcpy(raddr, addr, sz);
     746                        T_IPV6EP rep = { ntohl(raddr->sin6_addr.__in6_union.__s6_addr), ntohs(raddr->sin6_port) };
     747                        ret = udp6_snd_dat(socket->cepid, &rep, (void *)buf, len,
     748                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     749                        if (ret < 0) {
     750                                return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     751                        }
     752                        break;
     753                }
     754                }
     755                break;
     756        }
     757        default:
     758                return -ENOPROTOOPT;
    459759        }
    460760
     
    476776
    477777        int ret = 0;
    478         switch (fp->psock->family) {
     778        socket_t *socket = (socket_t *)fp->exinf;
     779        switch (socket->family) {
    479780        case AF_INET: {
    480                 switch (fp->psock->type) {
     781                switch (socket->type) {
    481782                case SOCK_STREAM: {
    482783                        if (flags & MSG_OOB) {
    483                                 ret = tcp_rcv_oob(fp->psock->cepid, buf, len);
     784                                ret = tcp_rcv_oob(socket->cepid, buf, len);
    484785                                if (ret < 0) {
    485786                                        syslog(LOG_ERROR, "tcp_rcv_oob => %d", ret);
     
    489790                        else {
    490791                                int rsz, tmp;
    491                                 if (fp->psock->input == NULL) {
     792                                if (socket->input == NULL) {
    492793                                        ret = wai_sem(SEM_FILEDESC);
    493794                                        if (ret < 0) {
    494795                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
    495796                                        }
    496                                         fp->psock->len = 0;
     797                                        socket->len = 0;
    497798                                        ret = sig_sem(SEM_FILEDESC);
    498799                                        if (ret < 0) {
    499800                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
    500801                                        }
    501                                         ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_FEVR);
     802                                        ret = tcp_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
    502803                                        if (ret < 0) {
    503804                                                syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     
    507808                                }
    508809                                else
    509                                         rsz = fp->psock->len;
     810                                        rsz = socket->len;
    510811                                tmp = rsz;
    511812                                if (rsz > len)
    512813                                        rsz = len;
    513814                                if (rsz >= 0) {
    514                                         memcpy(buf, fp->psock->input, rsz);
     815                                        memcpy(buf, socket->input, rsz);
    515816                                        ret = wai_sem(SEM_FILEDESC);
    516817                                        if (ret < 0) {
    517818                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
    518819                                        }
    519                                         fp->psock->len = tmp - rsz;
     820                                        socket->len = tmp - rsz;
    520821                                        ret = sig_sem(SEM_FILEDESC);
    521822                                        if (ret < 0) {
     
    523824                                        }
    524825                                        if (tmp - rsz == 0) {
    525                                                 fp->psock->input = NULL;
     826                                                socket->input = NULL;
    526827                                        }
    527828                                        else
    528                                                 fp->psock->input = (void *)&((uint8_t *)fp->psock->input)[rsz];
    529                                         ret = tcp_rel_buf(fp->psock->cepid, rsz);
     829                                                socket->input = (void *)&((uint8_t *)socket->input)[rsz];
     830                                        ret = tcp_rel_buf(socket->cepid, rsz);
    530831                                        if ((ret != E_OBJ) && (ret < 0)) {
    531832                                                syslog(LOG_ERROR, "tcp_rel_buf => %d", ret);
     
    538839                }
    539840                case SOCK_DGRAM: {
    540                         struct sockaddr_in *raddr = &fp->psock->raddr4;
     841                        struct sockaddr_in *raddr = &socket->raddr4;
    541842                        int rsz;
    542843                        ret = wai_sem(SEM_FILEDESC);
     
    544845                                syslog(LOG_ERROR, "wai_sem => %d", ret);
    545846                        }
    546                         T_NET_BUF *input = fp->psock->input;
     847                        T_NET_BUF *input = socket->input;
    547848                        if (input == NULL) {
    548849                                ret = sig_sem(SEM_FILEDESC);
     
    552853
    553854                                T_IPV4EP rep = { 0, 0 };
    554                                 ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len,
    555                                         (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     855                                ret = udp_rcv_dat(socket->cepid, &rep, buf, len,
     856                                        (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    556857                                if (ret < 0) {
    557                                         syslog(LOG_ERROR, "udp_rcv_buf => %d", ret);
     858                                        if ((socket->flags & O_NONBLOCK) == 0)
     859                                                syslog(LOG_ERROR, "udp_rcv_buf => %d", ret);
    558860                                        return (ret == E_TMOUT) ? -ETIME : -ECOMM;
    559861                                }
     
    565867                                        }
    566868                                        int sz = *alen;
    567                                         memset(raddr, 0, sizeof(fp->psock->raddr4));
     869                                        memset(raddr, 0, sizeof(socket->raddr4));
    568870                                        raddr->sin_family = AF_INET;
    569871                                        raddr->sin_port = htons(rep.portno);
    570872                                        raddr->sin_addr.s_addr = htonl(rep.ipaddr);
    571                                         if (sz > sizeof(fp->psock->raddr4))
    572                                                 sz = sizeof(fp->psock->raddr4);
     873                                        if (sz > sizeof(socket->raddr4))
     874                                                sz = sizeof(socket->raddr4);
    573875                                        memcpy(addr, raddr, sz);
    574876                                        *alen = sz;
     
    580882                        }
    581883                        else {
    582                                 rsz = fp->psock->len;
    583                                 void *pbuf = fp->psock->buf;
    584                                 fp->psock->input = NULL;
    585                                 fp->psock->len = 0;
    586                                 fp->psock->buf = NULL;
     884                                rsz = socket->len;
     885                                void *pbuf = socket->buf;
     886                                socket->input = NULL;
     887                                socket->len = 0;
     888                                socket->buf = NULL;
    587889                                if ((addr != NULL) && (alen != NULL)) {
    588890                                        int sz = *alen;
    589                                         if (sz > sizeof(fp->psock->raddr4))
    590                                                 sz = sizeof(fp->psock->raddr4);
     891                                        if (sz > sizeof(socket->raddr4))
     892                                                sz = sizeof(socket->raddr4);
    591893                                        memcpy(addr, raddr, sz);
    592894                                        *alen = sz;
     
    611913        }
    612914        case AF_INET6: {
    613                 return -EAFNOSUPPORT;
    614         }
     915                switch (socket->type) {
     916                case SOCK_STREAM: {
     917                        if (flags & MSG_OOB) {
     918                                ret = tcp6_rcv_oob(socket->cepid, buf, len);
     919                                if (ret < 0) {
     920                                        syslog(LOG_ERROR, "tcp6_rcv_oob => %d", ret);
     921                                        return -ECOMM;
     922                                }
     923                        }
     924                        else {
     925                                int rsz, tmp;
     926                                if (socket->input == NULL) {
     927                                        ret = wai_sem(SEM_FILEDESC);
     928                                        if (ret < 0) {
     929                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     930                                        }
     931                                        socket->len = 0;
     932                                        ret = sig_sem(SEM_FILEDESC);
     933                                        if (ret < 0) {
     934                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     935                                        }
     936                                        ret = tcp6_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
     937                                        if (ret < 0) {
     938                                                syslog(LOG_ERROR, "tcp6_rcv_buf => %d", ret);
     939                                                return -ECOMM;
     940                                        }
     941                                        rsz = ret;
     942                                }
     943                                else
     944                                        rsz = socket->len;
     945                                tmp = rsz;
     946                                if (rsz > len)
     947                                        rsz = len;
     948                                if (rsz >= 0) {
     949                                        memcpy(buf, socket->input, rsz);
     950                                        ret = wai_sem(SEM_FILEDESC);
     951                                        if (ret < 0) {
     952                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     953                                        }
     954                                        socket->len = tmp - rsz;
     955                                        ret = sig_sem(SEM_FILEDESC);
     956                                        if (ret < 0) {
     957                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     958                                        }
     959                                        if (tmp - rsz == 0) {
     960                                                socket->input = NULL;
     961                                        }
     962                                        else
     963                                                socket->input = (void *)&((uint8_t *)socket->input)[rsz];
     964                                        ret = tcp6_rel_buf(socket->cepid, rsz);
     965                                        if ((ret != E_OBJ) && (ret < 0)) {
     966                                                syslog(LOG_ERROR, "tcp6_rel_buf => %d", ret);
     967                                                //return -ECOMM;
     968                                        }
     969                                }
     970                                ret = rsz;
     971                        }
     972                        break;
     973                }
     974                case SOCK_DGRAM: {
     975                        struct sockaddr_in6 *raddr = &socket->raddr6;
     976                        int rsz;
     977                        ret = wai_sem(SEM_FILEDESC);
     978                        if (ret < 0) {
     979                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     980                        }
     981                        T_NET_BUF *input = socket->input;
     982                        if (input == NULL) {
     983                                ret = sig_sem(SEM_FILEDESC);
     984                                if (ret < 0) {
     985                                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     986                                }
     987
     988                                T_IPV6EP rep = { 0, 0 };
     989                                ret = udp6_rcv_dat(socket->cepid, &rep, buf, len,
     990                                        (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     991                                if (ret < 0) {
     992                                        if ((socket->flags & O_NONBLOCK) == 0)
     993                                                syslog(LOG_ERROR, "udp6_rcv_buf => %d", ret);
     994                                        return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     995                                }
     996                                rsz = ret;
     997                                if ((addr != NULL) && (alen != NULL)) {
     998                                        ret = wai_sem(SEM_FILEDESC);
     999                                        if (ret < 0) {
     1000                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     1001                                        }
     1002                                        int sz = *alen;
     1003                                        memset(raddr, 0, sizeof(socket->raddr6));
     1004                                        raddr->sin6_family = AF_INET;
     1005                                        raddr->sin6_port = htons(rep.portno);
     1006#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     1007                                        memcpy(raddr->sin6_addr.__in6_union.__s6_addr, rep.ipaddr.__u6_addr.__u6_addr8, 16);
     1008#else
     1009                                        for (int i = 0; i < 16; i++)
     1010                                                raddr->sin6_addr.__in6_union.__s6_addr[i] = rep.ipaddr.__u6_addr.__u6_addr8[i];
     1011#endif
     1012                                        if (sz > sizeof(socket->raddr6))
     1013                                                sz = sizeof(socket->raddr6);
     1014                                        memcpy(addr, raddr, sz);
     1015                                        *alen = sz;
     1016                                        ret = sig_sem(SEM_FILEDESC);
     1017                                        if (ret < 0) {
     1018                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     1019                                        }
     1020                                }
     1021                        }
     1022                        else {
     1023                                rsz = socket->len;
     1024                                void *pbuf = socket->buf;
     1025                                socket->input = NULL;
     1026                                socket->len = 0;
     1027                                socket->buf = NULL;
     1028                                if ((addr != NULL) && (alen != NULL)) {
     1029                                        int sz = *alen;
     1030                                        if (sz > sizeof(socket->raddr6))
     1031                                                sz = sizeof(socket->raddr6);
     1032                                        memcpy(addr, raddr, sz);
     1033                                        *alen = sz;
     1034                                }
     1035                                ret = sig_sem(SEM_FILEDESC);
     1036                                if (ret < 0) {
     1037                                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1038                                }
     1039                                if (rsz > len)
     1040                                        rsz = len;
     1041                                memcpy(buf, pbuf, rsz);
     1042                                ret = rel_net_buf(input);
     1043                                if (ret < 0) {
     1044                                        syslog(LOG_ERROR, "rel_net_buf => %d", ret);
     1045                                        //return -ECOMM;
     1046                                }
     1047                        }
     1048                        ret = rsz;
     1049                }
     1050                }
     1051                break;
     1052        }
     1053        default:
     1054                return -ENOPROTOOPT;
    6151055        }
    6161056
     
    6321072
    6331073        ER ret;
    634         switch (fp->psock->family) {
     1074        socket_t *socket = (socket_t *)fp->exinf;
     1075        switch (socket->family) {
    6351076        case AF_INET: {
    636                 switch (fp->psock->type) {
     1077                switch (socket->type) {
    6371078                case SOCK_STREAM: {
    638                         ret = tcp_sht_cep(fp->psock->cepid);
     1079                        ret = tcp_sht_cep(socket->cepid);
    6391080                        if (ret < 0) {
    6401081                                return -ECOMM;
     
    6461087        }
    6471088        case AF_INET6: {
    648                 return -EAFNOSUPPORT;
    649         }
     1089                switch (socket->type) {
     1090                case SOCK_STREAM: {
     1091                        ret = tcp6_sht_cep(socket->cepid);
     1092                        if (ret < 0) {
     1093                                return -ECOMM;
     1094                        }
     1095                        break;
     1096                }
     1097                }
     1098                break;
     1099        }
     1100        default:
     1101                return -ENOPROTOOPT;
    6501102        }
    6511103
     
    6611113
    6621114        ER ret;
    663         switch (fp->psock->family) {
     1115        socket_t *socket = (socket_t *)fp->exinf;
     1116        switch (socket->family) {
    6641117        case AF_INET: {
    665                 switch (fp->psock->type) {
     1118                switch (socket->type) {
    6661119                case SOCK_STREAM: {
    6671120                        switch (level) {
     
    6691122                                switch (optname) {
    6701123                                case SO_REUSEADDR:
    671                                         if (fp->psock->flags & SO_REUSEADDR) {
     1124                                        if (socket->flags & SO_REUSEADDR) {
    6721125                                                *(bool *)optval = true;
    6731126                                        }
     
    6771130                                        break;
    6781131                                case SO_KEEPALIVE:
    679                                         if (fp->psock->flags & SO_KEEPALIVE) {
     1132                                        if (socket->flags & SO_KEEPALIVE) {
    6801133                                                *(bool *)optval = true;
    6811134                                        }
     
    6921145                                break;
    6931146                        case IPPROTO_TCP:
    694                                 ret = tcp_get_opt(fp->psock->cepid, optname, (void *)optval, *optlen);
     1147                                ret = tcp_get_opt(socket->cepid, optname, (void *)optval, *optlen);
    6951148                                if (ret < 0) {
    6961149                                        return -EINVAL;
     
    7061159                        switch (level) {
    7071160                        case IPPROTO_UDP:
    708                                 ret = udp_get_opt(fp->psock->cepid, optname, (void *)optval, *optlen);
     1161                                ret = udp_get_opt(socket->cepid, optname, (void *)optval, *optlen);
    7091162                                if (ret < 0) {
    7101163                                        return -EINVAL;
     
    7211174        }
    7221175        case AF_INET6: {
    723                 return -EAFNOSUPPORT;
    724         }
     1176                switch (socket->type) {
     1177                case SOCK_STREAM: {
     1178                        switch (level) {
     1179                        case SOL_SOCKET:
     1180                                switch (optname) {
     1181                                case SO_REUSEADDR:
     1182                                        if (socket->flags & SO_REUSEADDR) {
     1183                                                *(bool *)optval = true;
     1184                                        }
     1185                                        else {
     1186                                                *(bool *)optval = false;
     1187                                        }
     1188                                        break;
     1189                                case SO_KEEPALIVE:
     1190                                        if (socket->flags & SO_KEEPALIVE) {
     1191                                                *(bool *)optval = true;
     1192                                        }
     1193                                        else {
     1194                                                *(bool *)optval = false;
     1195                                        }
     1196                                        break;
     1197                                case SO_ERROR:
     1198                                        *(int *)optval = 0;
     1199                                        break;
     1200                                default:
     1201                                        return -EINVAL;
     1202                                }
     1203                                break;
     1204                        case IPPROTO_TCP:
     1205                                ret = tcp6_get_opt(socket->cepid, optname, (void *)optval, *optlen);
     1206                                if (ret < 0) {
     1207                                        return -EINVAL;
     1208                                }
     1209                                *optlen = ret;
     1210                                break;
     1211                        default:
     1212                                return -EINVAL;
     1213                        }
     1214                        break;
     1215                }
     1216                case SOCK_DGRAM: {
     1217                        switch (level) {
     1218                        case IPPROTO_UDP:
     1219                                ret = udp6_get_opt(socket->cepid, optname, (void *)optval, *optlen);
     1220                                if (ret < 0) {
     1221                                        return -EINVAL;
     1222                                }
     1223                                *optlen = ret;
     1224                                break;
     1225                        default:
     1226                                return -EINVAL;
     1227                        }
     1228                        break;
     1229                }
     1230                }
     1231                break;
     1232        }
     1233        default:
     1234                return -ENOPROTOOPT;
    7251235        }
    7261236
     
    7361246
    7371247        ER ret;
    738         switch (fp->psock->family) {
     1248        socket_t *socket = (socket_t *)fp->exinf;
     1249        switch (socket->family) {
    7391250        case AF_INET: {
    740                 switch (fp->psock->type) {
     1251                switch (socket->type) {
    7411252                case SOCK_STREAM: {
    7421253                        switch (level){
     
    7451256                                case SO_REUSEADDR:
    7461257                                        if (*(bool *)optval) {
    747                                                 fp->psock->flags |= SO_REUSEADDR;
     1258                                                socket->flags |= SO_REUSEADDR;
    7481259                                        }
    7491260                                        else {
    750                                                 fp->psock->flags &= ~SO_REUSEADDR;
     1261                                                socket->flags &= ~SO_REUSEADDR;
    7511262                                        }
    7521263                                        break;
    7531264                                case SO_KEEPALIVE:
    7541265                                        if (*(bool *)optval) {
    755                                                 fp->psock->flags |= SO_KEEPALIVE;
     1266                                                socket->flags |= SO_KEEPALIVE;
    7561267                                        }
    7571268                                        else {
    758                                                 fp->psock->flags &= ~SO_KEEPALIVE;
     1269                                                socket->flags &= ~SO_KEEPALIVE;
    7591270                                        }
    7601271                                        break;
     
    7641275                                break;
    7651276                        case IPPROTO_TCP:
    766                                 ret = tcp_set_opt(fp->psock->cepid, optname, (void *)optval, optlen);
     1277                                ret = tcp_set_opt(socket->cepid, optname, (void *)optval, optlen);
    7671278                                if (ret < 0) {
    7681279                                        return -EINVAL;
     
    7771288                        switch (level){
    7781289                        case IPPROTO_UDP:
    779                                 ret = udp_set_opt(fp->psock->cepid, optname, (void *)optval, optlen);
     1290                                ret = udp_set_opt(socket->cepid, optname, (void *)optval, optlen);
    7801291                                if (ret < 0) {
    7811292                                        return -EINVAL;
     
    7911302        }
    7921303        case AF_INET6: {
    793                 return -EAFNOSUPPORT;
    794         }
     1304                switch (socket->type) {
     1305                case SOCK_STREAM: {
     1306                        switch (level){
     1307                        case SOL_SOCKET:
     1308                                switch (optname) {
     1309                                case SO_REUSEADDR:
     1310                                        if (*(bool *)optval) {
     1311                                                socket->flags |= SO_REUSEADDR;
     1312                                        }
     1313                                        else {
     1314                                                socket->flags &= ~SO_REUSEADDR;
     1315                                        }
     1316                                        break;
     1317                                case SO_KEEPALIVE:
     1318                                        if (*(bool *)optval) {
     1319                                                socket->flags |= SO_KEEPALIVE;
     1320                                        }
     1321                                        else {
     1322                                                socket->flags &= ~SO_KEEPALIVE;
     1323                                        }
     1324                                        break;
     1325                                default:
     1326                                        return -EINVAL;
     1327                                }
     1328                                break;
     1329                        case IPPROTO_TCP:
     1330                                ret = tcp6_set_opt(socket->cepid, optname, (void *)optval, optlen);
     1331                                if (ret < 0) {
     1332                                        return -EINVAL;
     1333                                }
     1334                                break;
     1335                        default:
     1336                                return -EINVAL;
     1337                        }
     1338                        break;
     1339                }
     1340                case SOCK_DGRAM: {
     1341                        switch (level){
     1342                        case IPPROTO_UDP:
     1343                                ret = udp6_set_opt(socket->cepid, optname, (void *)optval, optlen);
     1344                                if (ret < 0) {
     1345                                        return -EINVAL;
     1346                                }
     1347                                break;
     1348                        default:
     1349                                return -EINVAL;
     1350                        }
     1351                        break;
     1352                }
     1353                }
     1354                break;
     1355        }
     1356        default:
     1357                return -ENOPROTOOPT;
    7951358        }
    7961359
     
    8091372
    8101373        socklen_t size = *len;
    811         switch (fp->psock->family) {
     1374        socket_t *socket = (socket_t *)fp->exinf;
     1375        switch (socket->family) {
    8121376        case AF_INET: {
    813                 struct sockaddr_in *raddr = &fp->psock->raddr4;
     1377                struct sockaddr_in *raddr = &socket->raddr4;
    8141378                *len = sizeof(struct sockaddr_in);
    8151379                if (size > sizeof(struct sockaddr_in))
     
    8191383        }
    8201384        case AF_INET6: {
    821                 return -EAFNOSUPPORT;
    822         }
     1385                struct sockaddr_in6 *raddr = &socket->raddr6;
     1386                *len = sizeof(struct sockaddr_in6);
     1387                if (size > sizeof(struct sockaddr_in6))
     1388                        size = sizeof(struct sockaddr_in6);
     1389                memcpy(addr, raddr, size);
     1390                break;
     1391        }
     1392        default:
     1393                return -ENOPROTOOPT;
    8231394        }
    8241395
     
    8371408
    8381409        socklen_t size = *len;
    839         switch (fp->psock->family) {
     1410        socket_t *socket = (socket_t *)fp->exinf;
     1411        switch (socket->family) {
    8401412        case AF_INET: {
    8411413                const T_IN4_ADDR *laddr4 = in4_get_ifaddr(0);
     
    8431415                laddr.sin_family = AF_INET;
    8441416                laddr.sin_addr.s_addr = htonl(*laddr4);
    845                 laddr.sin_port = fp->psock->laddr4.sin_port;
     1417                laddr.sin_port = socket->laddr4.sin_port;
    8461418                memset(&laddr.sin_zero, 0, sizeof(laddr.sin_zero));
    8471419                *len = sizeof(struct sockaddr_in);
     
    8521424        }
    8531425        case AF_INET6: {
    854                 return -EAFNOSUPPORT;
    855         }
     1426                const T_IN6_ADDR *laddr6 = in6_get_ifaddr(0);
     1427                struct sockaddr_in6 laddr;
     1428                laddr.sin6_family = AF_INET;
     1429#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     1430                memcpy(laddr.sin6_addr.__in6_union.__s6_addr, laddr6->__u6_addr.__u6_addr8, 16);
     1431#else
     1432                for (int i = 0; i < 16; i++)
     1433                        laddr.sin6_addr.__in6_union.__s6_addr[i] = laddr6->__u6_addr.__u6_addr8[i];
     1434#endif
     1435                laddr.sin6_port = socket->laddr6.sin6_port;
     1436                *len = sizeof(struct sockaddr_in6);
     1437                if (size > sizeof(struct sockaddr_in6))
     1438                        size = sizeof(struct sockaddr_in6);
     1439                memcpy(addr, &laddr, size);
     1440                break;
     1441        }
     1442        default:
     1443                return -ENOPROTOOPT;
    8561444        }
    8571445
     
    8591447}
    8601448
    861 int tcp_fd_close(struct _IO_FILE *fp)
     1449int tcp_fd_close(struct SHELL_FILE *fp)
    8621450{
    8631451        ER ret, ret2;
    8641452
    865         switch (fp->psock->family) {
     1453        socket_t *socket = (socket_t *)fp->exinf;
     1454        switch (socket->family) {
    8661455        case AF_INET: {
    867                 if (fp->psock->cepid != 0) {
    868                         ID cepid = fp->psock->cepid;
     1456                if (socket->cepid != 0) {
     1457                        ID cepid = socket->cepid;
    8691458                        ret = tcp_sht_cep(cepid);
    8701459                        if (ret < 0) {
    8711460                                //return -1;
    8721461                        }
    873                         ret = tcp_cls_cep(cepid, (fp->psock->repid != 0) ? 0 : SOCKET_TIMEOUT);
     1462                        ret = tcp_cls_cep(cepid, (socket->repid != 0) ? 0 : SOCKET_TIMEOUT);
    8741463                        ret2 = tcp_del_cep(cepid);
    875                         free(fp->psock->buf);
    876                         fp->psock->buf = NULL;
    877                         delete_tcp_fd(cepid);
     1464                        //delete_fd_by_id(&IO_TYPE_TCP, cepid);
    8781465                        delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
    8791466                        if ((ret < 0) || (ret2 < 0)) {
     
    8811468                        }
    8821469                }
    883                 else if (fp->psock->repid != 0) {
    884                         ID repid = fp->psock->repid;
     1470                else if (socket->repid != 0) {
     1471                        ID repid = socket->repid;
    8851472                        ret = tcp_del_rep(repid);
    886                         free(fp->psock->buf);
    887                         fp->psock->buf = NULL;
    888                         delete_tcp_fd(tmax_tcp_cepid + repid);
     1473                        //delete_fd_by_id(&IO_TYPE_TCP, tmax_tcp_cepid + repid);
    8891474                        delete_id(tcp_repid_table, tcp_repid_table_count, repid);
    8901475                        if (ret < 0) {
     
    8931478                }
    8941479                else {
    895                         free(fp->psock->buf);
    896                         fp->psock->buf = NULL;
    8971480                        return -EINVAL;
    8981481                }
     
    9001483        }
    9011484        case AF_INET6: {
    902                 return -EAFNOSUPPORT;
    903         }
     1485                if (socket->cepid != 0) {
     1486                        ID cepid = socket->cepid;
     1487                        ret = tcp6_sht_cep(cepid);
     1488                        if (ret < 0) {
     1489                                //return -1;
     1490                        }
     1491                        ret = tcp6_cls_cep(cepid, (socket->repid != 0) ? 0 : SOCKET_TIMEOUT);
     1492                        ret2 = tcp6_del_cep(cepid);
     1493                        //delete_fd_by_id(&IO_TYPE_TCP, cepid);
     1494                        delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
     1495                        if ((ret < 0) || (ret2 < 0)) {
     1496                                return (ret == E_TMOUT) ? -ETIME : -EINVAL;
     1497                        }
     1498                }
     1499                else if (socket->repid != 0) {
     1500                        ID repid = socket->repid;
     1501                        ret = tcp6_del_rep(repid);
     1502                        //delete_fd_by_id(&IO_TYPE_TCP, tmax_tcp6_cepid + repid);
     1503                        delete_id(tcp6_repid_table, tcp6_repid_table_count, repid);
     1504                        if (ret < 0) {
     1505                                return -EINVAL;
     1506                        }
     1507                }
     1508                else {
     1509                        return -EINVAL;
     1510                }
     1511                break;
     1512        }
     1513        default:
     1514                return -ENOPROTOOPT;
    9041515        }
    9051516
     
    9071518}
    9081519
    909 size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
     1520size_t tcp_fd_read(struct SHELL_FILE *fp, unsigned char *dst, size_t dstsz)
    9101521{
    9111522        return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL);
    9121523}
    9131524
    914 size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
     1525size_t tcp_fd_write(struct SHELL_FILE *fp, const unsigned char *src, size_t srcsz)
    9151526{
    9161527        return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0);
    9171528}
    9181529
    919 off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org)
     1530off_t tcp_fd_seek(struct SHELL_FILE *fp, off_t ofs, int org)
    9201531{
    9211532        return -EPERM;
    9221533}
    9231534
    924 int tcp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg)
     1535int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    9251536{
    9261537        return -EINVAL;
    9271538}
    9281539
    929 int udp_fd_close(struct _IO_FILE *fp)
     1540bool_t tcp_fd_readable(struct SHELL_FILE *fp)
     1541{
     1542        ER ret;
     1543
     1544        socket_t *socket = (socket_t *)fp->exinf;
     1545        if (socket->cepid != 0) {
     1546                if (socket->len == 0) {
     1547                        ret = tcp_rcv_buf(socket->cepid, &socket->input, TMO_NBLK);
     1548                        if ((ret != E_WBLK) && (ret != E_OBJ) && (ret < 0)) {
     1549                                syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     1550                                //return ret;
     1551                        }
     1552                        if (ret > 0) {
     1553                                ret = wai_sem(SEM_FILEDESC);
     1554                                if (ret < 0) {
     1555                                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1556                                }
     1557                                socket->len += ret;
     1558                                ret = sig_sem(SEM_FILEDESC);
     1559                                if (ret < 0) {
     1560                                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1561                                }
     1562                        }
     1563                }
     1564                else ret = 1;
     1565                if (ret > 0) {
     1566                        return true;
     1567                }
     1568        }
     1569
     1570        return false;
     1571}
     1572
     1573void tcp_fd_delete(struct SHELL_FILE *fp)
     1574{
     1575        socket_t *socket = (socket_t *)fp->exinf;
     1576        free(socket->buf);
     1577        socket->buf = NULL;
     1578        free(fp->exinf);
     1579        fp->exinf = NULL;
     1580}
     1581
     1582ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk)
     1583{
     1584        struct SHELL_FILE *fp = id_to_fd(&IO_TYPE_TCP, cepid);
     1585        FLGPTN flgptn = 0;
     1586        ER ret;
     1587        int len;
     1588
     1589        if (fp == NULL)
     1590                return E_PAR;
     1591
     1592        int fd = fp->fd;
     1593        FD_SET(fd, (fd_set *)&flgptn);
     1594
     1595        switch (fncd) {
     1596        case TFN_TCP_RCV_BUF:
     1597                len = *(int *)p_parblk;
     1598                if ((len <= 0) || (fp->exinf == NULL))
     1599                        return E_OK;
     1600
     1601                ret = wai_sem(SEM_FILEDESC);
     1602                if (ret < 0) {
     1603                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1604                }
     1605                socket_t *socket = (socket_t *)fp->exinf;
     1606                socket->len += len;
     1607                ret = sig_sem(SEM_FILEDESC);
     1608                if (ret < 0) {
     1609                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1610                }
     1611
     1612                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1613
     1614                set_flg(FLG_SELECT_WAIT, flgptn);
     1615                return E_OK;
     1616
     1617        case TFN_TCP_RCV_DAT:
     1618                len = *(int *)p_parblk;
     1619                if ((len <= 0) || (fp->exinf == NULL))
     1620                        return E_OK;
     1621
     1622                ret = wai_sem(SEM_FILEDESC);
     1623                if (ret < 0) {
     1624                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1625                }
     1626                socket->len += len;
     1627                ret = sig_sem(SEM_FILEDESC);
     1628                if (ret < 0) {
     1629                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1630                }
     1631
     1632                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1633
     1634                set_flg(FLG_SELECT_WAIT, flgptn);
     1635                return E_OK;
     1636
     1637        case TFN_TCP_SND_DAT:
     1638                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
     1639
     1640                set_flg(FLG_SELECT_WAIT, flgptn);
     1641                return E_OK;
     1642
     1643        case TFN_TCP_CAN_CEP:
     1644                if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
     1645
     1646                set_flg(FLG_SELECT_WAIT, flgptn);
     1647                return E_OK;
     1648
     1649        case TFN_TCP_DEL_REP:
     1650                delete_fd_by_id(&IO_TYPE_TCP, tmax_tcp_cepid + cepid);
     1651                return E_OK;
     1652
     1653        case TFN_TCP_DEL_CEP:
     1654                delete_fd_by_id(&IO_TYPE_TCP, cepid);
     1655                return E_OK;
     1656
     1657        default:
     1658                return E_OK;
     1659        }
     1660}
     1661
     1662ER socket_tcp6_callback(ID cepid, FN fncd, void *p_parblk)
     1663{
     1664        struct SHELL_FILE *fp = id_to_fd(&IO_TYPE_TCP, cepid);
     1665        FLGPTN flgptn = 0;
     1666        ER ret;
     1667        int len;
     1668
     1669        if (fp == NULL)
     1670                return E_PAR;
     1671
     1672        int fd = fp->fd;
     1673        FD_SET(fd, (fd_set *)&flgptn);
     1674
     1675        switch (fncd) {
     1676        case TFN_TCP_RCV_BUF:
     1677                len = *(int *)p_parblk;
     1678                if ((len <= 0) || (fp->exinf == NULL))
     1679                        return E_OK;
     1680
     1681                ret = wai_sem(SEM_FILEDESC);
     1682                if (ret < 0) {
     1683                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1684                }
     1685                socket_t *socket = (socket_t *)fp->exinf;
     1686                socket->len += len;
     1687                ret = sig_sem(SEM_FILEDESC);
     1688                if (ret < 0) {
     1689                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1690                }
     1691
     1692                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1693
     1694                set_flg(FLG_SELECT_WAIT, flgptn);
     1695                return E_OK;
     1696
     1697        case TFN_TCP_RCV_DAT:
     1698                len = *(int *)p_parblk;
     1699                if ((len <= 0) || (fp->exinf == NULL))
     1700                        return E_OK;
     1701
     1702                ret = wai_sem(SEM_FILEDESC);
     1703                if (ret < 0) {
     1704                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1705                }
     1706                socket->len += len;
     1707                ret = sig_sem(SEM_FILEDESC);
     1708                if (ret < 0) {
     1709                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1710                }
     1711
     1712                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1713
     1714                set_flg(FLG_SELECT_WAIT, flgptn);
     1715                return E_OK;
     1716
     1717        case TFN_TCP_SND_DAT:
     1718                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
     1719
     1720                set_flg(FLG_SELECT_WAIT, flgptn);
     1721                return E_OK;
     1722
     1723        case TFN_TCP_CAN_CEP:
     1724                if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
     1725
     1726                set_flg(FLG_SELECT_WAIT, flgptn);
     1727                return E_OK;
     1728
     1729        case TFN_TCP_DEL_REP:
     1730                delete_fd_by_id(&IO_TYPE_TCP, tmax_tcp_cepid + cepid);
     1731                return E_OK;
     1732
     1733        case TFN_TCP_DEL_CEP:
     1734                delete_fd_by_id(&IO_TYPE_TCP, cepid);
     1735                return E_OK;
     1736
     1737        default:
     1738                return E_OK;
     1739        }
     1740}
     1741
     1742int udp_fd_close(struct SHELL_FILE *fp)
    9301743{
    9311744        ER ret;
    9321745        ID cepid;
    9331746
    934         switch (fp->psock->family) {
     1747        socket_t *socket = (socket_t *)fp->exinf;
     1748        switch (socket->family) {
    9351749        case AF_INET: {
    936                 cepid = fp->psock->cepid;
     1750                cepid = socket->cepid;
    9371751                ret = udp_del_cep(cepid);
    938                 //free(fp->psock->buf);
    939                 //fp->psock->buf = NULL;
    940                 delete_udp_fd(cepid);
     1752                //delete_fd_by_id(&IO_TYPE_UDP, cepid);
    9411753                delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
    9421754                if (ret < 0) {
     
    9461758        }
    9471759        case AF_INET6: {
    948                 return -EAFNOSUPPORT;
    949         }
     1760                cepid = socket->cepid;
     1761                ret = udp6_del_cep(cepid);
     1762                //delete_fd_by_id(&IO_TYPE_UDP, cepid);
     1763                delete_id(udp6_cepid_table, udp6_cepid_table_count, cepid);
     1764                if (ret < 0) {
     1765                        return -EINVAL;
     1766                }
     1767                break;
     1768        }
     1769        default:
     1770                return -ENOPROTOOPT;
    9501771        }
    9511772
     
    9531774}
    9541775
    955 size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
     1776size_t udp_fd_read(struct SHELL_FILE *fp, unsigned char *dst, size_t dstsz)
    9561777{
    9571778        return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL);
    9581779}
    9591780
    960 size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
     1781size_t udp_fd_write(struct SHELL_FILE *fp, const unsigned char *src, size_t srcsz)
    9611782{
    9621783        return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0);
    9631784}
    9641785
    965 off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org)
     1786off_t udp_fd_seek(struct SHELL_FILE *fp, off_t ofs, int org)
    9661787{
    9671788        return -EPERM;
    9681789}
    9691790
    970 int udp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg)
     1791int udp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    9711792{
    9721793        return -EINVAL;
     1794}
     1795
     1796bool_t udp_fd_readable(struct SHELL_FILE *fp)
     1797{
     1798        socket_t *socket = (socket_t *)fp->exinf;
     1799        if (socket->cepid != 0) {
     1800                if (socket->input != NULL) {
     1801                        return true;
     1802                }
     1803        }
     1804
     1805        return false;
     1806}
     1807
     1808void udp_fd_delete(struct SHELL_FILE *fp)
     1809{
     1810        //socket_t *socket = (socket_t *)fp->exinf;
     1811        //free(socket->buf);
     1812        //socket->buf = NULL;
     1813        free(fp->exinf);
     1814        fp->exinf = NULL;
     1815}
     1816
     1817ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk)
     1818{
     1819        struct SHELL_FILE *fp = id_to_fd(&IO_TYPE_UDP, cepid);
     1820        FLGPTN flgptn = 0;
     1821        int len;
     1822
     1823        if (fp == NULL)
     1824                return E_PAR;
     1825
     1826        int fd = fp->fd;
     1827        FD_SET(fd, (fd_set *)&flgptn);
     1828
     1829        switch (fncd) {
     1830        case TEV_UDP_RCV_DAT:
     1831        {
     1832                T_UDP_RCV_DAT_PARA *udppara = (T_UDP_RCV_DAT_PARA *)p_parblk;
     1833                len = udppara->len;
     1834                if ((len <= 0) || (fp->exinf == NULL))
     1835                        return E_OK;
     1836
     1837                ER ret = wai_sem(SEM_FILEDESC);
     1838                if (ret < 0) {
     1839                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1840                }
     1841                socket_t *socket = (socket_t *)fp->exinf;
     1842                socket->len = len;
     1843                if (socket->input != NULL) {
     1844                        ret = rel_net_buf(socket->input);
     1845                        if (ret < 0) {
     1846                                syslog(LOG_ERROR, "rel_net_buf => %d", ret);
     1847                        }
     1848                }
     1849                socket->input = udppara->input;
     1850                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
     1851                memset(&socket->raddr4, 0, sizeof(socket->raddr4));
     1852                socket->raddr4.sin_family = AF_INET;
     1853                socket->raddr4.sin_port = htons(udppara->rep4.portno);
     1854                socket->raddr4.sin_addr.s_addr = htonl(udppara->rep4.ipaddr);
     1855                udppara->input->flags |= NB_FLG_NOREL_IFOUT;
     1856                ret = sig_sem(SEM_FILEDESC);
     1857                if (ret < 0) {
     1858                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1859                }
     1860
     1861                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1862
     1863                set_flg(FLG_SELECT_WAIT, flgptn);
     1864                return E_OK;
     1865        }
     1866        case TFN_UDP_CRE_CEP:
     1867                return E_OK;
     1868
     1869        case TFN_UDP_RCV_DAT:
     1870                len = *(int *)p_parblk;
     1871                if ((len <= 0) || (fp->exinf == NULL))
     1872                        return E_OK;
     1873
     1874                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1875
     1876                set_flg(FLG_SELECT_WAIT, flgptn);
     1877                return E_OK;
     1878
     1879        case TFN_UDP_SND_DAT:
     1880                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
     1881
     1882                set_flg(FLG_SELECT_WAIT, flgptn);
     1883                return E_OK;
     1884
     1885        case TFN_UDP_CAN_CEP:
     1886                if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
     1887
     1888                set_flg(FLG_SELECT_WAIT, flgptn);
     1889                return E_OK;
     1890
     1891        case TFN_UDP_DEL_CEP:
     1892                delete_fd_by_id(&IO_TYPE_UDP, cepid);
     1893                return E_OK;
     1894
     1895        default:
     1896                return E_OK;
     1897        }
     1898}
     1899
     1900ER socket_udp6_callback(ID cepid, FN fncd, void *p_parblk)
     1901{
     1902        struct SHELL_FILE *fp = id_to_fd(&IO_TYPE_UDP, cepid);
     1903        FLGPTN flgptn = 0;
     1904        int len;
     1905
     1906        if (fp == NULL)
     1907                return E_PAR;
     1908
     1909        int fd = fp->fd;
     1910        FD_SET(fd, (fd_set *)&flgptn);
     1911
     1912        switch (fncd) {
     1913        case TEV_UDP_RCV_DAT:
     1914        {
     1915                T_UDP_RCV_DAT_PARA *udppara = (T_UDP_RCV_DAT_PARA *)p_parblk;
     1916                len = udppara->len;
     1917                if ((len <= 0) || (fp->exinf == NULL))
     1918                        return E_OK;
     1919
     1920                ER ret = wai_sem(SEM_FILEDESC);
     1921                if (ret < 0) {
     1922                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     1923                }
     1924                socket_t *socket = (socket_t *)fp->exinf;
     1925                socket->len = len;
     1926                if (socket->input != NULL) {
     1927                        ret = rel_net_buf(socket->input);
     1928                        if (ret < 0) {
     1929                                syslog(LOG_ERROR, "rel_net_buf => %d", ret);
     1930                        }
     1931                }
     1932                socket->input = udppara->input;
     1933                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
     1934                memset(&socket->raddr6, 0, sizeof(socket->raddr6));
     1935                socket->raddr6.sin6_family = AF_INET;
     1936                socket->raddr6.sin6_port = htons(udppara->rep6.portno);
     1937#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     1938                memcpy(socket->raddr6.sin6_addr.__in6_union.__s6_addr, udppara->rep6.ipaddr.__u6_addr.__u6_addr8, 16);
     1939#else
     1940                for (int i = 0; i < 16; i++)
     1941                        socket->raddr6.sin6_addr.__in6_union.__s6_addr[i] = udppara->rep6.ipaddr.__u6_addr.__u6_addr8[i];
     1942#endif
     1943                udppara->input->flags |= NB_FLG_NOREL_IFOUT;
     1944                ret = sig_sem(SEM_FILEDESC);
     1945                if (ret < 0) {
     1946                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     1947                }
     1948
     1949                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1950
     1951                set_flg(FLG_SELECT_WAIT, flgptn);
     1952                return E_OK;
     1953        }
     1954        case TFN_UDP_CRE_CEP:
     1955                return E_OK;
     1956
     1957        case TFN_UDP_RCV_DAT:
     1958                len = *(int *)p_parblk;
     1959                if ((len <= 0) || (fp->exinf == NULL))
     1960                        return E_OK;
     1961
     1962                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     1963
     1964                set_flg(FLG_SELECT_WAIT, flgptn);
     1965                return E_OK;
     1966
     1967        case TFN_UDP_SND_DAT:
     1968                if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
     1969
     1970                set_flg(FLG_SELECT_WAIT, flgptn);
     1971                return E_OK;
     1972
     1973        case TFN_UDP_CAN_CEP:
     1974                if (fp->errorevt_w == fp->errorevt_r) fp->errorevt_w++;
     1975
     1976                set_flg(FLG_SELECT_WAIT, flgptn);
     1977                return E_OK;
     1978
     1979        case TFN_UDP_DEL_CEP:
     1980                delete_fd_by_id(&IO_TYPE_UDP, cepid);
     1981                return E_OK;
     1982
     1983        default:
     1984                return E_OK;
     1985        }
    9731986}
    9741987
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/socket_stub.h

    r364 r374  
    103103} socket_t;
    104104
    105 struct _IO_DIR {
    106         DIR dir;
     105struct SHELL_DIR {
     106        FATFS_DIR dir;
    107107        struct dirent dirent;
    108108};
    109109
    110 struct _IO_FILE {
     110typedef const struct io_type_s IO_TYPE;
     111
     112struct SHELL_FILE {
    111113        int fd;
    112         int type;
     114        IO_TYPE *type;
    113115        int handle;
    114         int (*close)(struct _IO_FILE *);
    115         size_t (*read)(struct _IO_FILE *, unsigned char *, size_t);
    116         size_t (*write)(struct _IO_FILE *, const unsigned char *, size_t);
    117         off_t (*seek)(struct _IO_FILE *, off_t, int);
    118         int (*ioctl)(struct _IO_FILE *, int, void *);
    119116        int readevt_r;
    120117        int readevt_w;
     
    124121        int errorevt_r;
    125122        int errorevt_w;
    126         union {
    127                 FIL *pfile;
    128                 struct _IO_DIR *pdir;
    129                 socket_t *psock;
    130         };
     123        void *exinf;
     124};
     125
     126struct io_type_s {
     127        int (*close)(struct SHELL_FILE *);
     128        size_t (*read)(struct SHELL_FILE *, unsigned char *, size_t);
     129        size_t (*write)(struct SHELL_FILE *, const unsigned char *, size_t);
     130        off_t (*seek)(struct SHELL_FILE *, off_t, int);
     131        int (*ioctl)(struct SHELL_FILE *, int, void *);
     132        bool_t (*readable)(struct SHELL_FILE *);
     133        void (*delete)(struct SHELL_FILE *);
    131134};
    132135
     
    141144#endif
    142145
    143 extern int stdio_close(struct _IO_FILE *fp);
    144 extern size_t stdio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    145 extern size_t stdio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    146 extern size_t stdin_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    147 extern size_t stdout_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    148 extern size_t stderr_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
     146struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable);
     147int delete_fd_by_id(IO_TYPE *type, int id);
     148struct SHELL_FILE *fd_to_fp(int fd);
     149struct SHELL_FILE *id_to_fd(IO_TYPE *type, int id);
    149150
    150 extern int sio_close(struct _IO_FILE *fp);
    151 extern size_t sio_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    152 extern size_t sio_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    153 extern off_t sio_seek(struct _IO_FILE *fp, off_t ofs, int org);
    154 extern int sio_ioctl(struct _IO_FILE *fp, int req, void *arg);
    155 
    156 extern int file_close(struct _IO_FILE *fp);
    157 extern size_t file_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    158 extern size_t file_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    159 extern off_t file_seek(struct _IO_FILE *fp, off_t ofs, int org);
    160 extern int file_ioctl(struct _IO_FILE *fp, int req, void *arg);
    161 
    162 extern int dir_close(struct _IO_FILE *fp);
    163 extern size_t dir_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    164 extern size_t dir_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    165 extern off_t dir_seek(struct _IO_FILE *fp, off_t ofs, int org);
    166 extern int dir_ioctl(struct _IO_FILE *fp, int req, void *arg);
    167 
    168 extern int tcp_fd_close(struct _IO_FILE *fp);
    169 extern size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    170 extern size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    171 extern off_t tcp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org);
    172 extern int tcp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg);
    173 
    174 extern int udp_fd_close(struct _IO_FILE *fp);
    175 extern size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *data, size_t len);
    176 extern size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *data, size_t len);
    177 extern off_t udp_fd_seek(struct _IO_FILE *fp, off_t ofs, int org);
    178 extern int udp_fd_ioctl(struct _IO_FILE *fp, int req, void *arg);
    179 
    180 struct _IO_FILE *fd_to_fp(int fd);
    181 
    182 struct _IO_FILE *new_sio_fd(int sioid);
    183 int delete_sio_fd(int sioid);
    184 struct _IO_FILE *sioid_to_fd(int sioid);
    185 
    186 struct _IO_FILE *new_file_fd(int fileid);
    187 int delete_file_fd(int fileid);
    188 struct _IO_FILE *fileid_to_fd(int fileid);
    189 
    190 struct _IO_FILE *new_dir_fd(int dirid);
    191 int delete_dir_fd(int dirid);
    192 struct _IO_FILE *dirid_to_fd(int dirid);
    193 
    194 struct _IO_FILE *new_tcp_fd(int tcpid);
    195 int delete_tcp_fd(int tcpid);
    196 struct _IO_FILE *tcpid_to_fd(int tcpid);
    197 
    198 struct _IO_FILE *new_udp_fd(int udpid);
    199 int delete_udp_fd(int udpid);
    200 struct _IO_FILE *udpid_to_fd(int udpid);
    201 
    202 int delete_fp(struct _IO_FILE *fp);
    203 int delete_tcp_rep(int repid);
     151int delete_fp(struct SHELL_FILE *fp);
    204152void clean_fd();
    205153
    206 ER socket_tcp_callback(ID cepid, FN fncd, void *p_parblk);
    207 ER socket_udp_callback(ID cepid, FN fncd, void *p_parblk);
     154void sys_tlsf_init(void);
    208155
    209156#endif // !SOCKET_STUB_H
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/syscall.c

    r364 r374  
    442442        return no_implement("flock\n");
    443443}
     444
     445long SYS_fchdir()
     446{
     447        return no_implement("fchdir\n");
     448}
     449
     450long SYS_getegid32()
     451{
     452        return no_implement("getegid32\n");
     453}
     454
     455long SYS_geteuid32()
     456{
     457        return no_implement("geteuid32\n");
     458}
     459
     460long SYS_getgid32()
     461{
     462        return no_implement("getgid32\n");
     463}
     464
     465long SYS_pipe2()
     466{
     467        return no_implement("pipe2\n");
     468}
     469
     470long SYS_setgid32()
     471{
     472        return no_implement("setgid32\n");
     473}
     474
     475long SYS_setpgid()
     476{
     477        return no_implement("setpgid\n");
     478}
     479
     480long SYS_setsid()
     481{
     482        return no_implement("setsid\n");
     483}
     484
     485long SYS_setuid32()
     486{
     487        return no_implement("setuid32\n");
     488}
     489
     490long SYS_tgkill()
     491{
     492        return no_implement("tgkill\n");
     493}
  • asp3_tinet_ecnl_rx/trunk/ntshell/tlsf/tlsf.c

    r337 r374  
    55#include <stdlib.h>
    66#include <string.h>
    7 #include "util/ntstdio.h"
     7#include <stdio.h>
    88
    99#include "tlsf.h"
     
    1616#define tlsf_decl static
    1717#endif
    18 
    19 extern ntstdio_t ntstdio;
    2018
    2119/*
     
    889887{
    890888        (void)user;
    891         ntstdio_printf(&ntstdio, "\t%p %s size: %x (%p)\n", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr));
     889        printf("\t%p %s size: %x (%p)\n", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr));
    892890}
    893891
     
    978976        if (((ptrdiff_t)mem % ALIGN_SIZE) != 0)
    979977        {
    980                 ntstdio_printf(&ntstdio, "tlsf_add_pool: Memory must be aligned by %u bytes.\n",
     978                printf("tlsf_add_pool: Memory must be aligned by %u bytes.\n",
    981979                        (unsigned int)ALIGN_SIZE);
    982980                return 0;
     
    986984        {
    987985#if defined (TLSF_64BIT)
    988                 ntstdio_printf(&ntstdio, "tlsf_add_pool: Memory size must be between 0x%x and 0x%x00 bytes.\n",
     986                printf("tlsf_add_pool: Memory size must be between 0x%x and 0x%x00 bytes.\n",
    989987                        (unsigned int)(pool_overhead + block_size_min),
    990988                        (unsigned int)((pool_overhead + block_size_max) / 256));
    991989#else
    992                 ntstdio_printf(&ntstdio, "tlsf_add_pool: Memory size must be between %u and %u bytes.\n",
     990                printf("tlsf_add_pool: Memory size must be between %u and %u bytes.\n",
    993991                        (unsigned int)(pool_overhead + block_size_min),
    994992                        (unsigned int)(pool_overhead + block_size_max));
     
    10581056        if (rv)
    10591057        {
    1060                 ntstdio_printf(&ntstdio, "test_ffs_fls: %x ffs/fls tests failed.\n", rv);
     1058                printf("test_ffs_fls: %x ffs/fls tests failed.\n", rv);
    10611059        }
    10621060        return rv;
     
    10751073        if (((tlsfptr_t)mem % ALIGN_SIZE) != 0)
    10761074        {
    1077                 ntstdio_printf(&ntstdio, "tlsf_create: Memory must be aligned to %u bytes.\n",
     1075                printf("tlsf_create: Memory must be aligned to %u bytes.\n",
    10781076                        (unsigned int)ALIGN_SIZE);
    10791077                return 0;
  • asp3_tinet_ecnl_rx/trunk/usbhost/src/usb_hbth.h

    r337 r374  
    1111#define USBHOST_STACK_SIZE                      2048
    1212
    13 extern void usbhost_init(ID tskid);
    14 extern void usbhost_main(intptr_t exinf);
     13enum task_event_t {
     14        TASK_EVENT_START,
     15        TASK_EVENT_TERMINATE,
     16        TASK_EVENT_WAKEUP,
     17        TASK_EVENT_TIMEOUT,
     18        TASK_EVENT_TICK = 0x80,
     19};
     20
     21struct task_if_t {
     22        void (*on_start)(struct task_if_t *task, ID tskid);
     23        void (*on_end)(struct task_if_t *task);
     24        int (*get_timer)(struct task_if_t *task);
     25        void (*progress)(struct task_if_t *task, int elapse);
     26        void (*process)(struct task_if_t *task, enum task_event_t event);
     27};
     28
     29extern struct task_if_t bt_task;
     30
     31void usbhost_init(ID tskid);
     32void usbhost_main(intptr_t exinf);
    1533
    1634/*
Note: See TracChangeset for help on using the changeset viewer.