Changeset 387


Ignore:
Timestamp:
May 22, 2019, 4:09:18 PM (5 years ago)
Author:
coas-nagasima
Message:

ファイルディスクリプタ処理を更新

Files:
19 added
169 edited
4 moved

Legend:

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

    r374 r387  
    204204APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    205205APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    206 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     206APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     207APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEnbt/Makefile

    r374 r387  
    204204APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    205205APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    206 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     206APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     207APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEther/Makefile

    r374 r387  
    204204APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    205205APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    206 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     206APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     207APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.c

    r374 r387  
    6666#include "ffarch.h"
    6767#include "ff.h"
    68 #include "core/ntshell.h"
    69 #include "core/ntlibc.h"
    7068#include <stdio.h>
    7169#include "usrcmd.h"
    72 #include "util/ntopt.h"
    73 #include "socket_stub.h"
    7470#include "gpio_api.h"
    7571#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app2_light/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    193193
    194194#
  • asp3_tinet_ecnl_arm/trunk/app2_light/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    191191
    192192#
  • asp3_tinet_ecnl_arm/trunk/app2_light/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app2_light/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    193193
    194194#
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    191191
    192192#
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/Debug/Makefile

    r374 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/DebugEther/Makefile

    r374 r387  
    193193APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    194194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    195 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    196 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     195APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/Debug/Makefile

    r374 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/DebugEther/Makefile

    r374 r387  
    193193APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    194194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    195 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    196 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     195APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    193193
    194194#
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    191191
    192192#
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    193193
    194194#
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.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
    191191
    192192#
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/gdic/adafruit_ssd1306/Makefile.config

    r374 r387  
    3939#  @(#) $Id$
    4040#
    41  
     41
    4242#
    4343#  Makefile のプロセッサ依存 (adafruit ssd1306:OLED用)
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/mbed_stub.c

    r377 r387  
    6666#include "t_syslog.h"
    6767
     68extern void musl_start(const char *const args);
     69
    6870int main()
    6971{
     
    182184}
    183185
    184 __attribute__((weak))
    185 void *SYS_brk(void *addr)
     186void *shell_brk(void *addr)
    186187{
    187188        if (addr == 0) {
     
    194195}
    195196
    196 __attribute__((weak))
    197 void *SYS_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset)
     197void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset)
    198198{
    199199        if (fd != -1)
     
    206206}
    207207
    208 __attribute__((weak))
    209 int SYS_mprotect(void *addr, size_t len, int prot)
     208int shell_mprotect(void *addr, size_t len, int prot)
    210209{
    211210        //if ((addr >= (void *)&__HeapBase) && (addr + len < (void *)&__HeapLimit)) {
     
    216215
    217216__attribute__((weak))
     217long SYS_brk(long a) {
     218        return (long)shell_brk((void *)a);
     219}
     220
     221__attribute__((weak))
     222long SYS_mmap2(long a, long b, long c, long d, long e, long f, long g) {
     223        return (int)shell_mmap2((void *)a, (size_t)b, (int)c, (int)d, (int)e, ((off_t)f << 32) | (off_t)g);
     224}
     225
     226__attribute__((weak))
     227long SYS_mprotect(long a, long b, long c) {
     228        return shell_mprotect((void *)a, (size_t)b, (int)c);
     229}
     230
     231__attribute__((weak))
    218232long SYS_madvise()
    219233{
     
    235249int malloc_lock_sem_count[TNUM_TSKID];
    236250
     251__attribute__((weak))
    237252void __malloc_lock(struct _reent *_r)
    238253{
     
    261276}
    262277
     278__attribute__((weak))
    263279void __malloc_unlock(struct _reent *_r)
    264280{
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/tMbedSerial.c

    r374 r387  
    130130
    131131        if (serial_readable(obj)) {
    132                 if (c = serial_getc(obj)) {
    133                         return((int_t) c);
    134                 }
     132                return serial_getc(obj);
    135133        }
    136134        return(-1);
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/targets/TARGET_RENESAS/TARGET_RZA1XX/serial_api.c

    r374 r387  
    344344        }
    345345    }
    346    
     346
    347347    if (uart_data[index].irq_handler != NULL)
    348348        uart_data[index].irq_handler(uart_data[index].serial_irq_id, TxIrq);
     
    409409        }
    410410    }
    411    
     411
    412412    if (uart_data[index].irq_handler != NULL)
    413413        uart_data[index].irq_handler(uart_data[index].serial_irq_id, RxIrq);
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/target/gr_peach_gcc/gr_peach.h

    r352 r387  
    5858
    5959/*
     60 *  ボーレート設定
     61 */
     62#define UART_BAUDRATE           115200
     63
     64/*
    6065 *  LEDの点灯/消灯
    6166 */
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/target/gr_peach_gcc/target.cdl

    r352 r387  
    6060 *  ターゲット依存のセルタイプの定義
    6161 */
    62 import("tPutLogGRPeach.cdl");
     62import("syssvc/tPutLogSIOPort.cdl");
    6363import("tSIOPortGRPeach.cdl");
    6464
     
    7272 *  低レベル出力の組み上げ記述
    7373 */
    74 cell tPutLogGRPeach PutLogTarget {
     74cell tPutLogSIOPort PutLogTarget {
    7575        /* SIOドライバとの結合 */
    7676        cSIOPort = SIOPortTarget1.eSIOPort;
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/target/gr_peach_gcc/target_kernel_impl.c

    r374 r387  
    264264         */
    265265#ifndef TOPPERS_OMIT_TECS
    266         tPutLogGRPeach_initialize();
     266        tPutLogSIOPort_initialize();
    267267#endif /* TOPPERS_OMIT_TECS */
    268268}
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netapp/Makefile.netapp

    r352 r387  
    183183                NETAPP_COBJS := $(NETAPP_COBJS) udp6_echo_cli.o
    184184                NETAPP_KERNEL_CFG := $(NETAPP_KERNEL_CFG) $(NETAPP_DIRS)/udp6_echo_cli.cfg
    185        
     185
    186186                ifeq ($(SUPPORT_INET4),true)
    187187                        ifeq ($(USE_UDP4_ECHO_CLI),true)
     
    191191                        endif
    192192                endif
    193         else
     193                else
    194194                ifeq ($(SUPPORT_INET4),true)
    195195                        SUPPORT_UDP = true
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/in_itron.h

    r364 r387  
    131131extern ER_UINT  udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
    132132extern ER_UINT  udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
     133extern ER       udp6_can_cep(ID cepid, FN fncd);
    133134
    134135/* 【拡張機能】 */
     
    139140extern ER       udp_cre_cep (ID cepid, T_UDP_CCEP *pk_ccep);
    140141
     142extern ER       udp6_del_cep(ID cepid);
     143extern ER       udp6_set_opt(ID cepid, int_t optname, void *optval, int_t optlen);
     144extern ER       udp6_get_opt(ID cepid, int_t optname, void *optval, int_t optlen);
    141145extern ER       udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep);
    142146
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/tcp_input.c

    r364 r387  
    521521
    522522                                /* 相手のアドレスをコピーする。*/
     523
     524#if defined(_IP6_CFG) && defined(_IP4_CFG)
     525
     526                                if (cep->flags & TCP_CEP_FLG_IPV4) {
     527                                        (*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     528                                        (*cep->p_dstaddr4).portno = cep->dstaddr.portno;
     529                                        }
     530                                else
     531                                        *cep->p_dstaddr = cep->dstaddr;
     532
     533#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     534
    523535                                *cep->p_dstaddr = cep->dstaddr;
     536
     537#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
    524538
    525539                                if (IS_PTR_DEFINED(cep->callback)) {
     
    847861
    848862                                /* 相手のアドレスをコピーする。*/
     863
     864#if defined(_IP6_CFG) && defined(_IP4_CFG)
     865
     866                                if (cep->flags & TCP_CEP_FLG_IPV4) {
     867                                        (*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     868                                        (*cep->p_dstaddr4).portno = cep->dstaddr.portno;
     869                                        }
     870                                else
     871                                        *cep->p_dstaddr = cep->dstaddr;
     872
     873#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     874
    849875                                *cep->p_dstaddr = cep->dstaddr;
     876
     877#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
    850878
    851879                                if (IS_PTR_DEFINED(cep->callback)) {
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c

    r352 r387  
    671671                cep->p_myaddr4    = p_myaddr;
    672672                cep->p_dstaddr    = NULL;
    673                 cep->p_myaddr     = NULL;
     673                cep->p_myaddr     = NADR;
    674674
    675675#else   /* of #if API_PROTO == API_PROTO_IPV4 */
    676676
    677677                cep->p_dstaddr4   = NULL;
    678                 cep->p_myaddr4    = NULL;
     678                cep->p_myaddr4    = NADR;
    679679                cep->p_dstaddr    = p_dstaddr;
    680680                cep->p_myaddr     = p_myaddr;
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udp_output.c

    r352 r387  
    182182#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
    183183
    184                 for (ix = tmax_udp6_cepid; ix -- > 0; ) {
     184                for (ix = TNUM_UDP6_CEPID - 1; ix -- > 0; ) {
    185185
    186186                        if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
     
    194194#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
    195195
    196                 for (ix = tmax_udp4_cepid; ix -- > 0; ) {
     196                for (ix = TNUM_UDP4_CEPID - 1; ix -- > 0; ) {
    197197
    198198                        if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udp_subr.c

    r352 r387  
    146146#define UDP_FIND_CEP            udp6_find_cep
    147147#define UDP_NOTIFY              udp6_notify
    148 #define TMAX_UDP_CEPID          tmax_udp6_cepid
     148#define TMAX_UDP_CEPID          (TNUM_UDP6_CEPID - 1)
    149149#define UDP_CEP                 udp6_cep
    150150#define T_UDP_CEP               T_UDP6_CEP
     
    183183#define UDP_FIND_CEP            udp4_find_cep
    184184#define UDP_NOTIFY              udp4_notify
    185 #define TMAX_UDP_CEPID          tmax_udp4_cepid
     185#define TMAX_UDP_CEPID          (TNUM_UDP4_CEPID - 1)
    186186#define T_UDP_CEP               T_UDP4_CEP
    187187#define UDP_CEP                 udp4_cep
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c

    r364 r387  
    308308                else
    309309                        error = UDP_ALLOC_PORT(cep, pk_ccep->myaddr.portno);
    310                
    311                 if (error == E_OK) {
    312 
    313                         /* UDP 通信端点生成情報をコピーする。*/
    314                         cep->cepatr        = pk_ccep->cepatr;                   /* 通信端点属性               */
    315                         cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;            /* 自分のアドレス      */
    316                         cep->callback      = (void*)pk_ccep->callback;          /* コールバック               */
    317 
    318                         /* UDP 通信端点を生成済みにする。*/
    319                         cep->flags |= UDP_CEP_FLG_VALID;
    320                         }
    321                 }
     310
     311                        if (error == E_OK) {
     312                                /* UDP 通信端点生成情報をコピーする。*/
     313                                cep->cepatr        = pk_ccep->cepatr;                   /* 通信端点属性               */
     314                                cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;            /* 自分のアドレス      */
     315                                cep->callback      = (void*)pk_ccep->callback;          /* コールバック               */
     316
     317                                /* UDP 通信端点を生成済みにする。*/
     318                                cep->flags |= UDP_CEP_FLG_VALID;
     319                                }
     320                        }
    322321
    323322        /* 通信端点のロックを解除する。*/
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet6/nd6_rtr.c

    r352 r387  
    999999                return;
    10001000
    1001         /* ルータ要請ヘッダを設定する。*/
    1002         rsh = GET_ROUTER_SOLICIT_HDR(output, IF_IP6_ROUTER_SOLICIT_HDR_OFFSET);
    1003         rsh->hdr.type       = ND_ROUTER_SOLICIT;
    1004         rsh->hdr.code       = 0;
    1005         rsh->nd_rs_reserved = 0;
     1001        /* ルータ要請ヘッダを設定する。*/
     1002        rsh = GET_ROUTER_SOLICIT_HDR(output, IF_IP6_ROUTER_SOLICIT_HDR_OFFSET);
     1003        rsh->hdr.type       = ND_ROUTER_SOLICIT;
     1004        rsh->hdr.code       = 0;
     1005        rsh->nd_rs_reserved = 0;
    10061006
    10071007        /* チェックサムを計算する。*/
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/Debug/Makefile

    r374 r387  
    5858        LIBS = $(SRCDIR)/../musl-1.1.18/Debug/libmusl.a \
    5959                $(SRCDIR)/../btstack/Debug/libbtstack.a \
    60                 $(SRCDIR)/../usbhost/Debug/libusbhost.a
     60                $(SRCDIR)/../usbhost/Debug/libusbhost.a \
     61                $(SRCDIR)/../zlib-1.2.11/Debug/libzlib.a
    6162endif
    6263ifeq ($(SRCLANG),c++)
     
    189190#
    190191APPLNAME = bnep_bridge
    191 APPLDIRS = ../src ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src $(SRCDIR)/$(TINETDIR)/netapp
     192APPLDIRS = ../src ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src $(SRCDIR)/$(TINETDIR)/netapp
    192193APPL_CFG = main.cfg
    193194APPL_CDL = main.cdl
    194195
    195 APPL_COBJS := $(APPL_COBJS) ntshell_main.o fdtable.o io_stub.o ffarch.o diskio.o ff.o sdfs.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) ntshell_main.o fdtable.o stdio_stub.o io_stub.o ffarch.o diskio.o ff.o sdfs.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
    196197
    197198APPL_DIRS := $(APPLDIRS) $(SRCDIR)/library
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/src/main.c

    r374 r387  
    5454#include "ffarch.h"
    5555#include "ff.h"
    56 #include "core/ntshell.h"
    57 #include "core/ntlibc.h"
    5856#include <stdio.h>
    5957#include "usrcmd.h"
    60 #include "util/ntopt.h"
    6158#include "gpio_api.h"
    6259#include "usb_hbth.h"
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/src/main.cdl

    r352 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_arm/trunk/btstack/include/btstack/hci_cmds.h

    r374 r387  
    422422 * @param attribute_value
    423423 */
    424 #define SDP_EVENT_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_arm/trunk/btstack/src/bnep.h

    r374 r387  
    7272
    7373/* BNEP UUIDs */
    74 #define BLUETOOTH_SERVICE_CLASS_PANU                                  0x1115
    75 #define BLUETOOTH_SERVICE_CLASS_NAP                                   0x1116
    76 #define BLUETOOTH_SERVICE_CLASS_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_arm/trunk/curl-7.57.0/lib/easy.c

    r352 r387  
    166166#endif
    167167
    168 #ifdef __c2__
    169 #define malloc musl_malloc
    170 #define free musl_free
    171 #define realloc musl_realloc
    172 #define calloc musl_calloc
    173 #endif
    174 
    175168#ifndef __SYMBIAN32__
    176169/*
  • asp3_tinet_ecnl_arm/trunk/curl-7.57.0/lib/security.c

    r352 r387  
    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_arm/trunk/musl-1.1.18/include/bits/alltypes.h

    r352 r387  
    1 #if defined(_MSC_VER) || defined(__c2__)
    2 #define close musl_close
    3 #define execvp musl_execvp
    4 #define fclose musl_fclose
    5 #define fdopen musl_fdopen
    6 #define fflush musl_fflush
    7 #define fopen musl_fopen
    8 #define free musl_free
    9 #define fwrite musl_fwrite
    10 #define getcwd musl_getcwd
    11 #define localtime musl_localtime
    12 #define lseek musl_lseek
    13 #define open musl_open
    14 #define read musl_read
    15 #define malloc musl_malloc
    16 #define calloc musl_calloc
    17 #define realloc musl_realloc
    18 #define time musl_time
    19 #define unlink musl_unlink
    20 #define perror musl_perror
    21 #define strnlen musl_strnlen
    22 #define strftime musl_strftime
    23 #define asctime musl_asctime
    24 #define tzset musl_tzset
    25 #define clock musl_clock
    26 #endif
    27 #ifdef _MSC_VER
    28 #define __builtin_va_list char *
    29 #define __NEED_va_list
    30 #define restrict __restrict
    31 #endif
    32 
    331#define _Addr int
    342#define _Int64 long long
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/include/stddef.h

    r352 r387  
    1111#define __NEED_size_t
    1212#define __NEED_wchar_t
    13 #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
     13#if __STDC_VERSION__ >= 201112L || (defined(__cplusplus) && __cplusplus >= 201103L)
    1414#define __NEED_max_align_t
    1515#endif
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/locale/__lctrans.c

    r352 r387  
    88}
    99
    10 #ifndef __c2__
    1110weak_alias(dummy, __lctrans_impl);
    12 #endif
    1311
    1412const char *__lctrans(const char *msg, const struct __locale_map *lm)
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/locale/__mo_lookup.c

    r352 r387  
    44static inline uint32_t swapc(uint32_t x, int c)
    55{
    6         return c ? x>>24 | x>>8&0xff00 | x<<8&0xff0000 | x<<24 : x;
     6        return c ? (x>>24) | (x>>8&0xff00) | (x<<8&0xff0000) | (x<<24) : x;
    77}
    88
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/locale/iconv.c

    r352 r387  
    136136{
    137137        e &= 3;
    138         return s[e]+0U<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
     138        return (s[e]+0U)<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
    139139}
    140140
     
    156156        unsigned x = c - 128 - map[-1];
    157157        x = legacy_chars[ map[x*5/4]>>2*x%8 |
    158                 map[x*5/4+1]<<8-2*x%8 & 1023 ];
     158                (map[x*5/4+1]<<(8-2*x%8) & 1023) ];
    159159        return x ? x : c;
    160160}
     
    348348                                c += (0xa1-0x81);
    349349                                d += 0xa1;
    350                                 if (c >= 93 || c>=0xc6-0x81 && d>0x52)
     350                                if (c >= 93 || (c>=0xc6-0x81 && d>0x52))
    351351                                        goto ilseq;
    352352                                if (d-'A'<26) d = d-'A';
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/locale/locale_map.c

    r352 r387  
    3636
    3737        if (!*val) {
    38                 (val = getenv("LC_ALL")) && *val ||
    39                 (val = getenv(envvars[cat])) && *val ||
    40                 (val = getenv("LANG")) && *val ||
     38                ((val = getenv("LC_ALL")) && *val) ||
     39                ((val = getenv(envvars[cat])) && *val) ||
     40                ((val = getenv("LANG")) && *val) ||
    4141                (val = "C.UTF-8");
    4242        }
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/malloc/memalign.c

    r352 r387  
    4646        footer = ((size_t *)end)[-2];
    4747
    48         ((size_t *)mem)[-1] = header&7 | new-mem;
    49         ((size_t *)new)[-2] = footer&7 | new-mem;
    50         ((size_t *)new)[-1] = header&7 | end-new;
    51         ((size_t *)end)[-2] = footer&7 | end-new;
     48        ((size_t *)mem)[-1] = (header&7) | new-mem;
     49        ((size_t *)new)[-2] = (footer&7) | new-mem;
     50        ((size_t *)new)[-1] = (header&7) | end-new;
     51        ((size_t *)end)[-2] = (footer&7) | end-new;
    5252
    5353        free(mem);
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/math/fma.c

    r352 r387  
    7070                if (d < 64) {
    7171                        zlo = nz.m<<d;
    72                         zhi = nz.m>>64-d;
     72                        zhi = nz.m>>(64-d);
    7373                } else {
    7474                        zlo = 0;
     
    7878                        if (d == 0) {
    7979                        } else if (d < 64) {
    80                                 rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d);
     80                                rlo = rhi<<(64-d) | rlo>>d | !!(rlo<<(64-d));
    8181                                rhi = rhi>>d;
    8282                        } else {
     
    9191                        zlo = nz.m;
    9292                } else if (d < 64) {
    93                         zlo = nz.m>>d | !!(nz.m<<64-d);
     93                        zlo = nz.m>>d | !!(nz.m<<(64-d));
    9494                } else {
    9595                        zlo = 1;
     
    123123                d = a_clz_64(rhi)-1;
    124124                /* note: d > 0 */
    125                 rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
     125                rhi = rhi<<d | rlo>>(64-d) | !!(rlo<<d);
    126126        } else if (rlo) {
    127127                d = a_clz_64(rlo)-1;
     
    174174                        /* only round once when scaled */
    175175                        d = 10;
    176                         i = ( rhi>>d | !!(rhi<<64-d) ) << d;
     176                        i = ( rhi>>d | !!(rhi<<(64-d)) ) << d;
    177177                        if (sign)
    178178                                i = -i;
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/network/lookup_name.c

    r352 r387  
    1111#include <pthread.h>
    1212#include <errno.h>
     13#include <resolv.h>
    1314#include "lookup.h"
    1415#include "stdio_impl.h"
     
    185186        if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
    186187
     188        /* Strip final dot for canon, fail if multiple trailing dots. */
     189        if (name[l-1]=='.') l--;
     190        if (!l || name[l-1]=='.') return EAI_NONAME;
     191
    187192        /* This can never happen; the caller already checked length. */
    188193        if (l >= 256) return EAI_NONAME;
     
    311316        if (!cnt && !(flags & AI_NUMERICHOST)) {
    312317                cnt = name_from_hosts(buf, canon, name, family);
    313                 if (!cnt) cnt = name_from_dns_search(buf, canon, name, family);
     318                if (cnt<=0) cnt = name_from_dns_search(buf, canon, name, family);
    314319        }
    315320        if (cnt<=0) return cnt ? cnt : EAI_NONAME;
     
    352357         * So far the label/precedence table cannot be customized. */
    353358        for (i=0; i<cnt; i++) {
     359                int family = buf[i].family;
    354360                int key = 0;
    355                 struct sockaddr_in6 sa, da = {
     361                struct sockaddr_in6 sa6 = { 0 }, da6 = {
    356362                        .sin6_family = AF_INET6,
    357363                        .sin6_scope_id = buf[i].scopeid,
    358364                        .sin6_port = 65535
    359365                };
    360                 if (buf[i].family == AF_INET6) {
    361                         memcpy(da.sin6_addr.s6_addr, buf[i].addr, 16);
     366                struct sockaddr_in sa4 = { 0 }, da4 = {
     367                        .sin_family = AF_INET,
     368                        .sin_port = 65535
     369                };
     370                void *sa, *da;
     371                socklen_t salen, dalen;
     372                if (family == AF_INET6) {
     373                        memcpy(da6.sin6_addr.s6_addr, buf[i].addr, 16);
     374                        da = &da6; dalen = sizeof da6;
     375                        sa = &sa6; salen = sizeof sa6;
    362376                } else {
    363                         memcpy(da.sin6_addr.s6_addr,
     377                        memcpy(sa6.sin6_addr.s6_addr,
    364378                                "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
    365                         memcpy(da.sin6_addr.s6_addr+12, buf[i].addr, 4);
    366                 }
    367                 const struct policy *dpolicy = policyof(&da.sin6_addr);
    368                 int dscope = scopeof(&da.sin6_addr);
     379                        memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
     380                        memcpy(da6.sin6_addr.s6_addr,
     381                                "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
     382                        memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
     383                        memcpy(&da4.sin_addr, buf[i].addr, 4);
     384                        da = &da4; dalen = sizeof da4;
     385                        sa = &sa4; salen = sizeof sa4;
     386                }
     387                const struct policy *dpolicy = policyof(&da6.sin6_addr);
     388                int dscope = scopeof(&da6.sin6_addr);
    369389                int dlabel = dpolicy->label;
    370390                int dprec = dpolicy->prec;
    371391                int prefixlen = 0;
    372                 int fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
     392                int fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
    373393                if (fd >= 0) {
    374                         if (!connect(fd, (void *)&da, sizeof da)) {
     394                        if (!connect(fd, da, dalen)) {
    375395                                key |= DAS_USABLE;
    376                                 if (!getsockname(fd, (void *)&sa,
    377                                     &(socklen_t){sizeof sa})) {
    378                                         if (dscope == scopeof(&sa.sin6_addr))
     396                                if (!getsockname(fd, sa, &salen)) {
     397                                        if (family == AF_INET) memcpy(
     398                                                sa6.sin6_addr.s6_addr+12,
     399                                                &sa4.sin_addr, 4);
     400                                        if (dscope == scopeof(&sa6.sin6_addr))
    379401                                                key |= DAS_MATCHINGSCOPE;
    380                                         if (dlabel == labelof(&sa.sin6_addr))
     402                                        if (dlabel == labelof(&sa6.sin6_addr))
    381403                                                key |= DAS_MATCHINGLABEL;
    382                                         prefixlen = prefixmatch(&sa.sin6_addr,
    383                                                 &da.sin6_addr);
     404                                        prefixlen = prefixmatch(&sa6.sin6_addr,
     405                                                &da6.sin6_addr);
    384406                                }
    385407                        }
  • asp3_tinet_ecnl_arm/trunk/ntshell/fatfs/ffarch.c

    r374 r387  
    8080        ret2 = get_tim(&now);
    8181        if (ret2 != E_OK){
    82                 printf("[ffarch] get_tim error: %s",
     82                syslog(LOG_NOTICE, "[ffarch] get_tim error: %s",
    8383                        itron_strerror(ret2));
    8484                return;
     
    9494                ret = tslp_tsk(timer);
    9595                if ((ret != E_OK) && (ret != E_TMOUT)) {
    96                         printf("[ffarch] tslp_tsk error: %s %d",
     96                        syslog(LOG_NOTICE, "[ffarch] tslp_tsk error: %s %d",
    9797                                itron_strerror(ret), timer);
    9898                        break;
     
    101101                ret2 = get_tim(&now);
    102102                if (ret2 != E_OK) {
    103                         printf("[ffarch] get_tim error: %s",
     103                        syslog(LOG_NOTICE, "[ffarch] get_tim error: %s",
    104104                                itron_strerror(ret2));
    105105                        break;
     
    131131bool_t SD_begin();
    132132
    133 void ffarch_init()
     133void ffarch_init(void)
    134134{
    135135        /* SD_CD */
     
    150150
    151151        if (romdisk_init()) {
    152                 printf("ROM disk (0:) OK!\n");
     152                syslog(LOG_NOTICE, "ROM disk (0:) OK!");
    153153        }
    154154        else {
    155                 printf("ROM disk (0:) NG!\n");
     155                syslog(LOG_NOTICE, "ROM disk (0:) NG!");
    156156        }
    157157}
     
    352352}
    353353
    354 int ffarch_get_timer()
     354int ffarch_get_timer(void)
    355355{
    356356        return ffarch_timer;
     
    367367}
    368368
    369 void ffarch_timeout()
     369void ffarch_timeout(void)
    370370{
    371371        if (ffarch_timer != 0)
     
    375375        case FFS_RETRY_WAIT:
    376376                if (ffarch_retry_count == 0) {
    377                         printf("SD card (1:) initialize tired...\n");
     377                        syslog(LOG_NOTICE, "SD card (1:) initialize tired...");
    378378
    379379                        ffarch_state = FFS_IDLE;
     
    388388                if ((sdfs._is_initialized & STA_NOINIT)
    389389                        || (((sdfs_prev_status & STA_NODISK) != 0) && ((sdfs_new_status & STA_NODISK) == 0))) {
    390                         printf("SD card initializing ...\n");
     390                        syslog(LOG_NOTICE, "SD card initializing ...");
    391391
    392392                        if (SD_begin()) {
    393                                 printf("SD card (1:) OK!\n");
     393                                syslog(LOG_NOTICE, "SD card (1:) OK!");
    394394
    395395                                /* uploadディレクトリを作成しておく */
     
    401401                        }
    402402                        else {
    403                                 printf("SD card (1:) NG!\n");
     403                                syslog(LOG_NOTICE, "SD card (1:) NG!");
    404404                                ffarch_state = FFS_RETRY_WAIT;
    405405                                ffarch_timer = 1000 * 1000;
     
    408408                /* SDカードが抜かれた場合 */
    409409                else if (((sdfs_prev_status & STA_NODISK) == 0) && ((sdfs_new_status & STA_NODISK) != 0)) {
    410                         printf("SD card unmount\n");
     410                        syslog(LOG_NOTICE, "SD card unmount");
    411411
    412412                        f_mount(&Sd.FatFs, "1:", 0);
  • asp3_tinet_ecnl_arm/trunk/ntshell/ntshell/util/ntstdio.c

    r352 r387  
    224224        handle->xi = xi;
    225225        handle->xo = xo;
    226         handle->outptr = 0;
    227         handle->len = 0;
    228226        handle->pos = 0;
    229227        handle->option = option;
     
    232230static void _putc(ntstdio_t *handle, char c)
    233231{
    234         if (handle->outptr) {
    235                 if ((handle->pos + 1) >= handle->len)
    236                         return;
    237                 handle->outptr[handle->pos] = (unsigned char)c;
    238                 handle->pos++;
    239                 return;
    240         }
    241 
    242232        if (handle->xo) {
    243233                handle->xo(handle, (unsigned char)c);
     
    291281}
    292282
     283struct put_buf_t {
     284        char *outptr;
     285        int len;
     286};
     287
     288static void put_buf(struct ntstdio_t *handle, unsigned char c)
     289{
     290        struct put_buf_t *put_buf = (struct put_buf_t *)handle->exinf;
     291        if ((handle->pos + 1) >= put_buf->len)
     292                return;
     293        put_buf->outptr[handle->pos] = (char)c;
     294        handle->pos++;
     295}
     296
    293297int ntstdio_snprintf(char *buf, int len, const char *fmt, ...)
    294298{
    295299        int result;
    296300        ntstdio_t handle;
     301        struct put_buf_t exinf;
    297302        va_list arp;
    298303        /* Switch destination for memory */
     304        handle.xo = put_buf;
    299305        handle.option = 0;
    300         handle.outptr = buf;
    301         handle.len = len;
    302306        handle.pos = 0;
     307        handle.exinf = &exinf;
     308        exinf.outptr = buf;
     309        exinf.len = len;
     310
    303311        va_start(arp, fmt);
    304312        result = xvprintf(&handle, fmt, arp);
     
    306314
    307315        /* Terminate output string with a \0 */
    308         handle.outptr[handle.pos] = '\0';
     316        buf[handle.pos] = '\0';
    309317        return result;
    310318}
  • asp3_tinet_ecnl_arm/trunk/ntshell/ntshell/util/ntstdio.h

    r374 r387  
    7474        NTSTDIO_XI xi;
    7575        NTSTDIO_XO xo;
    76         char *outptr;
    77         int len;
    7876        int pos;
    7977        unsigned int option;
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/fdtable.c

    r374 r387  
    4444#include "syssvc/syslog.h"
    4545#include "target_syssvc.h"
    46 #ifndef NTSHELL_NO_SOCKET
    47 #include <tinet_defs.h>
    48 #include <tinet_config.h>
    49 #include <net/net.h>
    50 #include <net/net_endian.h>
    51 #include <netinet/in.h>
    52 #include <netinet/in_itron.h>
    53 #include <tinet_nic_defs.h>
    54 #include <tinet_cfg.h>
    55 #include <netinet/in_var.h>
    56 #include <net/ethernet.h>
    57 #include <net/if6_var.h>
    58 #include <net/net.h>
    59 #include <net/if_var.h>
    60 #include <netinet/udp.h>
    61 #include <netinet/udp_var.h>
    62 #include <netinet/tcp.h>
    63 #include <netinet/tcp_var.h>
    64 #include <net/net_buf.h>
    65 #endif
    66 #include "ff.h"
    67 #include "socket_stub.h"
     46#include "fdtable.h"
    6847#include "kernel_cfg.h"
    6948#include <string.h>
     
    7554#endif
    7655
    77 static int stdio_close(struct SHELL_FILE *fp);
    78 static size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    79 static size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    80 static size_t stdin_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    81 static size_t stdout_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    82 static size_t stderr_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    83 static void stdio_delete(struct SHELL_FILE *fp);
    84 
    85 static int sio_close(struct SHELL_FILE *fp);
    86 static size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    87 static size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    88 static off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org);
    89 static int sio_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    90 static bool_t sio_readable(struct SHELL_FILE *fp);
    91 static void sio_delete(struct SHELL_FILE *fp);
    92 
    93 IO_TYPE IO_TYPE_STDIN = { stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    94 IO_TYPE IO_TYPE_STDOUT = { stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    95 IO_TYPE IO_TYPE_STDERR = { stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    96 IO_TYPE IO_TYPE_SIO = { sio_close, sio_read, sio_write, sio_seek, sio_ioctl, sio_readable, sio_delete };
    97 ntstdio_t ntstdio;
     56extern IO_TYPE IO_TYPE_STDIN;
     57extern IO_TYPE IO_TYPE_STDOUT;
     58extern IO_TYPE IO_TYPE_STDERR;
    9859
    9960static struct SHELL_FILE fd_table[8 * sizeof(FLGPTN)] = {
    100         { 0, &IO_TYPE_STDIN, 0, .exinf = &ntstdio },
    101         { 1, &IO_TYPE_STDOUT, 0, .exinf = &ntstdio },
    102         { 2, &IO_TYPE_STDERR, 0,.exinf = &ntstdio },
     61        { STDIN_FILENO, &IO_TYPE_STDIN, 0 },
     62        { STDOUT_FILENO, &IO_TYPE_STDOUT, 0 },
     63        { STDERR_FILENO, &IO_TYPE_STDERR, 0 },
    10364};
    10465#define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0]))
    105 
    106 extern ntstdio_t ntstdio;
    107 extern serial_t stdio_uart;
    108 
    109 unsigned char ntstdio_xi(struct ntstdio_t *handle)
    110 {
    111         return serial_getc((serial_t *)handle->exinf);
    112 }
    113 
    114 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
    115 {
    116         serial_putc((serial_t *)handle->exinf, c);
    117 }
    118 
    119 void sys_init(intptr_t exinf)
    120 {
    121         ntstdio_init(&ntstdio, NTSTDIO_OPTION_LINE_ECHO | NTSTDIO_OPTION_CANON | NTSTDIO_OPTION_LF_CRLF | NTSTDIO_OPTION_LF_CR, ntstdio_xi, ntstdio_xo);
    122         ntstdio.exinf = (void *)&stdio_uart;
    123 }
    124 
    125 int stdio_close(struct SHELL_FILE *fp)
    126 {
    127         return -EPERM;
    128 }
    129 
    130 size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    131 {
    132         return -EPERM;
    133 }
    134 
    135 size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    136 {
    137         return -EPERM;
    138 }
    139 
    140 size_t stdin_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    141 {
    142         int i = 0;
    143         while (i < len) {
    144                 int c = ntstdio_getc((struct ntstdio_t *)fp->exinf);
    145                 data[i++] = c;
    146                 if ((c == EOF) || (c == '\n'))
    147                         break;
    148         }
    149         return i;
    150 }
    151 
    152 size_t stdout_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    153 {
    154         for (int i = 0; i < len; i++) {
    155                 ntstdio_putc((struct ntstdio_t *)fp->exinf, data[i]);
    156         }
    157         return len;
    158 }
    159 
    160 size_t stderr_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    161 {
    162         for (int i = 0; i < len; i++) {
    163                 ntstdio_putc((struct ntstdio_t *)fp->exinf, data[i]);
    164         }
    165         return len;
    166 }
    167 
    168 void stdio_delete(struct SHELL_FILE *fp)
    169 {
    170 }
    171 
    172 int sio_close(struct SHELL_FILE *fp)
    173 {
    174         return -EPERM;
    175 }
    176 
    177 size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    178 {
    179         return -EPERM;
    180 }
    181 
    182 size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    183 {
    184         return -EPERM;
    185 }
    186 
    187 off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org)
    188 {
    189         return -EPERM;
    190 }
    191 
    192 int sio_ioctl(struct SHELL_FILE *fp, int request, void *arg)
    193 {
    194         switch (request) {
    195         case TIOCGWINSZ:
    196                 return 0;
    197         case TCGETS:
    198                 return sio_tcgetattr(fp->fd, (struct termios *)arg);
    199         case TCSETS + TCSANOW:
    200         case TCSETS + TCSADRAIN:
    201         case TCSETS + TCSAFLUSH:
    202                 return sio_tcsetattr(fp->fd, request - TCSETS, (const struct termios *)arg);
    203         }
    204 
    205         return -EINVAL;
    206 }
    207 
    208 bool_t sio_readable(struct SHELL_FILE *fp)
    209 {
    210         return fp->readevt_w != fp->readevt_r;
    211 }
    212 
    213 void sio_delete(struct SHELL_FILE *fp)
    214 {
    215         free((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf);
    216         ((struct ntstdio_t *)fp->exinf)->exinf = NULL;
    217         free((struct ntstdio_t *)fp->exinf);
    218         fp->exinf = NULL;
    219 }
    22066
    22167struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable)
     
    24591        if (ret < 0) {
    24692                syslog(LOG_ERROR, "sig_sem => %d", ret);
     93        }
     94
     95        if (fp != NULL) {
     96                FLGPTN flgptn = 0;
     97
     98                FD_SET(fp->fd, (fd_set *)&flgptn);
     99
     100                ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
     101                if (ret != E_OK) {
     102                        syslog(LOG_ERROR, "clr_flg => %d", ret);
     103                }
    247104        }
    248105
     
    440297}
    441298
    442 /* TODO:コールバック化したい */
    443 void stdio_update_evts()
    444 {
    445         int fd = STDIN_FILENO;
    446         struct SHELL_FILE *fp = &fd_table[fd];
    447         FLGPTN flgptn = 0;
    448 
    449         if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    450                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    451 
    452                 FD_SET(fd, (fd_set *)&flgptn);
    453         }
    454         if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    455                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    456 
    457                 FD_SET(fd, (fd_set *)&flgptn);
    458         }
    459 
    460         if (flgptn != 0) {
    461                 set_flg(FLG_SELECT_WAIT, flgptn);
    462         }
    463 }
    464 
    465 /* TODO:コールバック化したい */
    466 void stdio_flgptn(FLGPTN *flgptn)
    467 {
    468         int fd = STDIN_FILENO;
    469         struct SHELL_FILE *fp = &fd_table[fd];
    470         *flgptn = 0;
    471 
    472         if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    473                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    474 
    475                 FD_SET(fd, (fd_set *)flgptn);
    476         }
    477         if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    478                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    479 
    480                 FD_SET(fd, (fd_set *)flgptn);
    481         }
    482 }
    483 
    484299ER shell_get_evts(struct fd_events *evts, TMO tmout)
    485300{
    486301        int count = 0;
    487302        SYSTIM prev, now;
     303        FLGPTN flgptn;
    488304
    489305        get_tim(&prev);
     
    491307        for (;;) {
    492308                ER ret;
    493                 FLGPTN waitptn, flgptn, readfds = 0, writefds = 0;
     309                FLGPTN waitptn, readfds = 0, writefds = 0;
    494310                struct SHELL_FILE *fp = NULL;
    495 
    496                 stdio_update_evts();
    497311
    498312#ifndef NTSHELL_NO_SOCKET
     
    504318                        fp = &fd_table[fd];
    505319
    506 #ifndef NTSHELL_NO_SOCKET
    507320                        if (FD_ISSET(fd, &evts->readfds)) {
    508321                                if (fp->type->readable(fp)) {
     
    515328                                }
    516329                        }
    517 #endif
     330
    518331                        if (FD_ISSET(fd, &evts->writefds)) {
    519                                 if (fp->writeevt_w == fp->writeevt_r) {
     332                                if (fp->type->writable(fp)) {
    520333                                        FD_SET(fd, (fd_set *)&writefds);
    521334                                        count++;
     
    547360                                return ret;
    548361                        }
    549 
    550                         stdio_flgptn(&flgptn);
    551 
    552                         if (flgptn == 0)
    553                                 return E_TMOUT;
    554                 }
    555                 flgptn &= waitptn;
    556 
    557                 /* 受け取ったフラグのみクリア */
    558                 ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
    559                 if (ret != E_OK) {
    560                         syslog(LOG_ERROR, "clr_flg => %d", ret);
     362                }
     363
     364                if (flgptn != 0) {
     365                        flgptn &= waitptn;
     366
     367                        /* 受け取ったフラグのみクリア */
     368                        ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
     369                        if (ret != E_OK) {
     370                                syslog(LOG_ERROR, "clr_flg => %d", ret);
     371                        }
    561372                }
    562373
    563374                count = 0;
    564375                for (int fd = 0; fd < fd_table_count; fd++) {
    565                         if (!FD_ISSET(fd, (fd_set *)&waitptn))
    566                                 continue;
    567 
    568376                        fp = &fd_table[fd];
    569377
    570378                        if (fp->readevt_w != fp->readevt_r) {
    571379                                fp->readevt_r++;
    572                                 FD_SET(fd, &evts->readfds);
     380                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     381                                        FD_SET(fd, &evts->readfds);
    573382                                count++;
    574383                        }
    575384                        if (fp->writeevt_w != fp->writeevt_r) {
    576385                                fp->writeevt_r++;
    577                                 fp->writable = 1;
    578                         }
    579                         if (fp->writable) {
    580                                 FD_SET(fd, &evts->writefds);
     386                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     387                                        FD_SET(fd, &evts->writefds);
    581388                                count++;
    582389                        }
    583390                        if (fp->errorevt_w != fp->errorevt_r) {
    584391                                fp->errorevt_r++;
    585                                 FD_SET(fd, &evts->errorfds);
     392                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     393                                        FD_SET(fd, &evts->errorfds);
    586394                                count++;
    587395                        }
    588396                }
    589397
    590                 if (count > 0)
     398                if ((flgptn == 0) || (count > 0))
    591399                        break;
    592400
     
    594402
    595403                SYSTIM elapse = now - prev;
    596                 if (elapse > tmout)
    597                         return E_TMOUT;
     404                if (elapse > tmout) {
     405                        flgptn = 0;
     406                        break;
     407                }
    598408
    599409                prev = now;
     
    603413        evts->count = count;
    604414
    605         return E_OK;
     415        return (flgptn == 0) ? E_TMOUT : E_OK;
    606416}
    607417
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/fdtable.h

    r386 r387  
    3838#define SOCKET_STUB_H
    3939
    40 struct addrinfo {
    41         int ai_flags;
    42         int ai_family;
    43         int ai_socktype;
    44         int ai_protocol;
    45         socklen_t ai_addrlen;
    46         struct sockaddr *ai_addr;
    47         char *ai_canonname;
    48         struct addrinfo *ai_next;
    49 };
    50 
    51 typedef uint16_t in_port_t;
    52 typedef uint32_t in_addr_t;
    53 struct in_addr { in_addr_t s_addr; };
    54 
    55 struct sockaddr_in {
    56         sa_family_t sin_family;
    57         in_port_t sin_port;
    58         struct in_addr sin_addr;
    59         uint8_t sin_zero[8];
    60 };
    61 
    62 struct in6_addr
    63 {
    64         union {
    65                 uint8_t __s6_addr[16];
    66                 uint16_t __s6_addr16[8];
    67                 uint32_t __s6_addr32[4];
    68         } __in6_union;
    69 };
    70 //#define s6_addr __in6_union.__s6_addr
    71 //#define s6_addr16 __in6_union.__s6_addr16
    72 //#define s6_addr32 __in6_union.__s6_addr32
    73 
    74 struct sockaddr_in6
    75 {
    76         sa_family_t     sin6_family;
    77         in_port_t       sin6_port;
    78         uint32_t        sin6_flowinfo;
    79         struct in6_addr sin6_addr;
    80         uint32_t        sin6_scope_id;
    81 };
    82 
    83 typedef struct socket_t {
    84         int family;
    85         int type;
    86         int protocol;
    87         int cepid;
    88         int repid;
    89         int backlog;
    90         unsigned int flags;
    91         union {
    92                 struct sockaddr_in laddr4;
    93                 struct sockaddr_in6 laddr6;
    94         };
    95         union {
    96                 struct sockaddr_in raddr4;
    97                 struct sockaddr_in6 raddr6;
    98         };
    99         int buf_size;
    100         unsigned char *buf;
    101         void *input;
    102         int len;
    103 } socket_t;
    104 
    105 struct SHELL_DIR {
    106         FATFS_DIR dir;
    107         struct dirent dirent;
    108 };
    109 
    11040typedef const struct io_type_s IO_TYPE;
    11141
     
    13161        int (*ioctl)(struct SHELL_FILE *, int, void *);
    13262        bool_t (*readable)(struct SHELL_FILE *);
     63        bool_t (*writable)(struct SHELL_FILE *);
    13364        void (*delete)(struct SHELL_FILE *);
    13465};
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/io_stub.c

    r374 r387  
    4545#include "syssvc/serial.h"
    4646#include "syssvc/syslog.h"
    47 #include "socket_stub.h"
     47#include "fdtable.h"
    4848#include "util/ntstdio.h"
    4949#include "usrcmd.h"
     
    5151#include "kernel_cfg.h"
    5252#include "target_syssvc.h"
     53
     54struct SHELL_DIR {
     55        FATFS_DIR dir;
     56        struct dirent dirent;
     57};
    5358
    5459int fresult2errno(FRESULT res)
     
    8590static int file_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    8691static bool_t file_readable(struct SHELL_FILE *fp);
     92static bool_t file_writable(struct SHELL_FILE *fp);
    8793static void file_delete(struct SHELL_FILE *fp);
    8894
     
    9399static int dir_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    94100static bool_t dir_readable(struct SHELL_FILE *fp);
     101static bool_t dir_writable(struct SHELL_FILE *fp);
    95102static void dir_delete(struct SHELL_FILE *fp);
    96103
    97 IO_TYPE IO_TYPE_FILE = { file_close, file_read, file_write, file_seek, file_ioctl, file_readable, file_delete };
    98 IO_TYPE IO_TYPE_DIR = { dir_close, dir_read, dir_write, dir_seek, dir_ioctl, dir_readable, dir_delete };
     104IO_TYPE IO_TYPE_FILE = { file_close, file_read, file_write, file_seek, file_ioctl, file_readable, file_writable, file_delete };
     105IO_TYPE IO_TYPE_DIR = { dir_close, dir_read, dir_write, dir_seek, dir_ioctl, dir_readable, dir_writable, dir_delete };
    99106
    100107int shell_open(const char *path, int flags, void *arg)
     
    114121                FRESULT res;
    115122                if ((res = f_opendir(dir, path)) != FR_OK) {
     123                        delete_fp(fp);
    116124                        return fresult2errno(res);
    117125                }
     
    165173        }
    166174
     175        delete_fp(fp);
    167176        return fresult2errno(res);
    168177}
     
    239248}
    240249
     250bool_t file_writable(struct SHELL_FILE *fp)
     251{
     252        return fp->writable && (fp->writeevt_w == fp->writeevt_r);
     253}
     254
    241255void file_delete(struct SHELL_FILE *fp)
    242256{
     
    356370{
    357371        return shell_ioctl(fd, cmd, arg);
    358 }
    359 
    360 extern IO_TYPE IO_TYPE_SIO;
    361 
    362 int sio_tcgetattr(int fd, struct termios *termios)
    363 {
    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 
    400 int 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;
    411                 }
    412                 else {
    413                         ntstdio->option &= ~NTSTDIO_OPTION_LINE_ECHO;
    414                 }
    415                 if (termios->c_lflag & ICANON) {
    416                         ntstdio->option |= NTSTDIO_OPTION_CANON;
    417                 }
    418                 else {
    419                         ntstdio->option &= ~NTSTDIO_OPTION_CANON;
    420                 }
    421                 if (termios->c_iflag & INLCR) {
    422                         ntstdio->option |= NTSTDIO_OPTION_LF_CR;
    423                 }
    424                 else {
    425                         ntstdio->option &= ~NTSTDIO_OPTION_LF_CR;
    426                 }
    427                 if (termios->c_oflag & ONLCR) {
    428                         ntstdio->option |= NTSTDIO_OPTION_LF_CRLF;
    429                 }
    430                 else {
    431                         ntstdio->option &= ~NTSTDIO_OPTION_LF_CRLF;
    432                 }
    433                 return 0;
    434         }
    435 
    436         shell_abort();
    437         return 0;
    438372}
    439373
     
    688622}
    689623
     624bool_t dir_writable(struct SHELL_FILE *fp)
     625{
     626        return false;
     627}
     628
    690629void dir_delete(struct SHELL_FILE *fp)
    691630{
     
    710649        return 0;
    711650}
    712 
    713 #ifndef _MSC_VER
    714 extern uint32_t __HeapBase;
    715 extern uint32_t __HeapLimit;
    716 #else
    717 uint8_t __HeapBase[14 * 4096];
    718 #define __HeapLimit __HeapBase[sizeof(__HeapBase)]
    719 #endif
    720 
    721 void *shell_brk(void *addr)
    722 {
    723         if (addr == 0) {
    724                 return (void *)(&__HeapBase);
    725         }
    726         if ((addr >= (void *)&__HeapBase) && (addr < (void *)&__HeapLimit)) {
    727                 return addr;
    728         }
    729         return (void *)-1;
    730 }
    731 
    732 void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset)
    733 {
    734         if (fd != -1)
    735                 return (void *)-EINVAL;
    736 
    737         if ((length >= 0) && (length <= sizeof(&__HeapBase))) {
    738                 return &__HeapBase;
    739         }
    740         return (void *)-1;
    741 }
    742 
    743 int shell_mprotect(void *addr, size_t len, int prot)
    744 {
    745         //if ((addr >= (void *)&__HeapBase) && (addr + len < (void *)&__HeapLimit)) {
    746         return 0;
    747 //}
    748 //return -1;
    749 }
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/net_misc.c

    r374 r387  
    9595
    9696        get_tid(&nc->tskid);
    97         printf("[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
     97        syslog(LOG_NOTICE, "[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
    9898
    9999        /* 初期化 */
     
    103103        ret = get_tim(&time);
    104104        if (ret != E_OK) {
    105                 printf("[NET MISC,%d] get_tim error: %7lu,%s",
     105                syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %7lu,%s",
    106106                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    107107                return;
     
    117117                error = tslp_tsk(timer);
    118118                if ((error != E_OK) && (error != E_TMOUT)) {
    119                         printf("[NET MISC,%d] tslp_tsk error: %s %d",
     119                        syslog(LOG_NOTICE, "[NET MISC,%d] tslp_tsk error: %s %d",
    120120                                nc->cepid, itron_strerror(error), timer);
    121121                        break;
     
    124124                ret = get_tim(&time);
    125125                if (ret != E_OK) {
    126                         printf("[NET MISC,%d] get_tim error: %s",
     126                        syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %s",
    127127                                nc->cepid, itron_strerror(ret));
    128128                        break;
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntp_cli.c

    r374 r387  
    277277        }
    278278
    279         printf("[NTP CLI,%d] recv time: %s .%09u\n",
     279        syslog(LOG_NOTICE, "[NTP CLI,%d] recv time: %s .%09u",
    280280                nc->cepid, nc->buf, tp.tv_nsec);
    281281}
     
    309309                line = lookup_ipaddr(&nc->ipaddr6, NTP_SRV_URL, API_PROTO_IPV4);
    310310                if (line == NULL || !in6_is_addr_ipv4mapped(&nc->ipaddr6)) {
    311                         printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     311                        syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    312312                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    313313                        nc->timer = SLP_ITV;
     
    317317#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
    318318                if ((line = lookup_ipaddr(&nc->snd_rmt.ipaddr, NTP_SRV_URL, DEFAULT_API_PROTO)) == NULL) {
    319                         printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     319                        syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    320320                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    321321                        nc->timer = SLP_ITV;
     
    421421
    422422        if ((error = udp_snd_dat(nc->cepid, &nc->snd_rmt, ntp, len, TMO_NBLK)) != E_WBLK) {
    423                 printf("[NTP CLI,%d] udp_snd_dat error: %s",
     423                syslog(LOG_NOTICE, "[NTP CLI,%d] udp_snd_dat error: %s",
    424424                        nc->cepid, itron_strerror(error));
    425425                return error;
    426426        }
    427427        else
    428                 syslog(LOG_DEBUG, "[NTP CLI,%d] udp_snd_dat: to: %s.%d\n",
     428                syslog(LOG_DEBUG, "[NTP CLI,%d] udp_snd_dat: to: %s.%d",
    429429                        nc->cepid, ip2str(NULL, &nc->snd_rmt.ipaddr), nc->snd_rmt.portno);
    430430
     
    439439        ret = get_tim(&time);
    440440        if (ret != E_OK) {
    441                 printf("[NTP CLI,%d] get_tim error: %s",
     441                syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",
    442442                        nc->cepid, itron_strerror(ret));
    443443                tp->tv_sec = 0;
     
    459459        ret = set_tim(time);
    460460        if (ret != E_OK) {
    461                 printf("[NTP CLI,%d] set_tim error: %s",
     461                syslog(LOG_NOTICE, "[NTP CLI,%d] set_tim error: %s",
    462462                        nc->cepid, itron_strerror(ret));
    463463        }
     
    477477        if (len < 0 && len != E_RLWAI) {
    478478                /* E_RLWAI 以外で、0 以下の場合は、エラーを意味している。*/
    479                 printf("[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
     479                syslog(LOG_NOTICE, "[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
    480480                        itron_strerror(len), in_strtfn(fncd));
    481481        }
     
    484484                        if ((len = udp_rcv_dat(nc->cepid, &nc->rcv_rmt, &nc->ntp_msg, len, TMO_POL)) < 0)
    485485                        {
    486                                 printf("[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
     486                                syslog(LOG_NOTICE, "[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
    487487                                        itron_strerror(len));
    488488                        }
     
    516516
    517517        get_tid(&nc->tskid);
    518         printf("[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
     518        syslog(LOG_NOTICE, "[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
    519519
    520520        /* 初期化 */
     
    523523        ret = get_tim(&time);
    524524        if (ret != E_OK) {
    525                 printf("[NTP CLI,%d] get_tim error: %7lu,%s",
     525                syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %7lu,%s",
    526526                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    527527                return;
     
    537537                error = tslp_tsk(timer);
    538538                if ((error != E_OK) && (error != E_TMOUT)) {
    539                         printf("[NTP CLI,%d] tslp_tsk error: %s %d",
     539                        syslog(LOG_NOTICE, "[NTP CLI,%d] tslp_tsk error: %s %d",
    540540                                nc->cepid, itron_strerror(error), timer);
    541541                        break;
     
    544544                ret = get_tim(&time);
    545545                if (ret != E_OK) {
    546                         printf("[NTP CLI,%d] get_tim error: %s",
     546                        syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",
    547547                                nc->cepid, itron_strerror(ret));
    548548                        break;
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c

    r374 r387  
    5858#include "util/ntopt.h"
    5959#include "ntshell_main.h"
    60 #include "socket_stub.h"
     60#include "fdtable.h"
    6161
    6262char command[NTOPT_TEXT_MAXLEN];
     
    7878}
    7979
     80void stdio_open(ID portid);
    8081static int usrcmd_ntopt_callback(long *args, void *extobj);
    8182
     
    8687void ntshell_task_init(ID portid)
    8788{
    88         serial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);
     89        stdio_open(portid);
    8990}
    9091
     
    9596{
    9697        ntshell_state = 1;
    97         ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
     98
     99        if (setjmp(process_exit) == 0) {
     100                ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
     101        }
     102
     103        fflush(stdout);
     104        clean_fd();
     105
    98106        ntshell_state = 2;
    99107}
     
    139147                printf("Unknown command found.\n");
    140148
    141         clean_fd();
    142 
    143149        return result;
    144150}
     
    285291}
    286292
    287 struct sigaction sigtable[7];
    288 
    289 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
    290 {
    291         struct sigaction *sat;
     293// musl-1.1.18\src\internal\ksigaction.h
     294struct k_sigaction {
     295        void(*handler)(int);
     296        unsigned long flags;
     297        void(*restorer)(void);
     298        unsigned mask[2];
     299};
     300
     301struct k_sigaction sigtable[7];
     302
     303int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
     304        struct k_sigaction *__restrict old, size_t size)
     305{
     306        struct k_sigaction *sat;
    292307
    293308        switch(sig){
     
    318333
    319334        if (old != NULL)
    320                 memcpy(old, sat, sizeof(struct sigaction));
    321 
    322         memcpy(sat, sa, sizeof(struct sigaction));
     335                memcpy(old, sat, offsetof(struct k_sigaction, mask) + size);
     336
     337        memcpy(sat, sa, offsetof(struct k_sigaction, mask) + size);
    323338
    324339        return 0;
     
    368383}
    369384
     385int shell_nanosleep(const struct timespec *req, struct timespec *rem)
     386{
     387        ER ret;
     388        TMO tmo;
     389        SYSTIM prev, now, diff;
     390
     391        if ((req == NULL) || (req->tv_nsec < 0) || (req->tv_nsec >= 1000000000))
     392                return -EINVAL;
     393
     394        get_tim(&prev);
     395
     396        tmo = req->tv_sec * 1000000 + req->tv_nsec / 1000;
     397        ret = tslp_tsk(tmo);
     398        if (ret == E_OK) {
     399                if (rem != NULL) {
     400                        get_tim(&now);
     401                        diff = now - prev;
     402                        rem->tv_sec = diff / 1000000ll;
     403                        rem->tv_nsec = (diff - (rem->tv_sec * 1000000ll)) * 1000ll;
     404                }
     405                return 0;
     406        }
     407        else if (ret == E_TMOUT) {
     408                if (rem != NULL) {
     409                        rem->tv_sec = 0;
     410                        rem->tv_nsec = 0;
     411                }
     412                return 0;
     413        }
     414
     415        return -EFAULT;
     416}
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/shellif.h

    r374 r387  
    7474#define NCCS 32
    7575
    76 #include <bits/fcntl.h>
    77 #include <bits/termios.h>
    78 #include <bits/stat.h>
     76#include <fcntl.h>
     77#include <termios.h>
     78#include <sys/stat.h>
    7979#include <sys/select.h>
    8080#include <time.h>
     
    8585#include <sys/utsname.h>
    8686#include <dirent.h>
    87 #include <bits/ioctl.h>
    88 #include <bits/errno.h>
     87#include <sys/ioctl.h>
     88#include <errno.h>
    8989#include <sys/socket.h>
    9090#else
     
    132132// time.h
    133133#define CLOCK_REALTIME 0
     134int shell_nanosleep(const struct timespec *req, struct timespec *rem);
    134135
    135136// dirent.h
     
    177178// signal.h
    178179int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
    179 int shell_sigaction(int sig, const struct sigaction *__restrict sa, struct sigaction *__restrict old);
     180struct k_sigaction;
     181int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
     182        struct k_sigaction *__restrict old, size_t size);
    180183// socket.h
    181184int shell_socket(int, int, int);
     
    197200// syslog.h
    198201void vsyslog (int, const char *, va_list);
    199 // termios.h
    200 int sio_tcgetattr (int, struct termios *);
    201 int sio_tcsetattr(int, int, const struct termios *);
    202202// fcntl.h
    203203int shell_open(const char *, int, void *arg);
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/socket_stub.c

    r375 r387  
    6262#include <netinet/tcp_var.h>
    6363#include <netapp/resolver.h>
    64 extern const ID tmax_tcp_cepid;
    65 #include "ff.h"
    66 #include "socket_stub.h"
     64#include "fdtable.h"
    6765#include "kernel_cfg.h"
    6866
     67#ifdef _DEBUG
     68static const char THIS_FILE[] = __FILE__;
     69#endif
     70
    6971#define SOCKET_TIMEOUT 2000000
     72
     73struct addrinfo {
     74        int ai_flags;
     75        int ai_family;
     76        int ai_socktype;
     77        int ai_protocol;
     78        socklen_t ai_addrlen;
     79        struct sockaddr *ai_addr;
     80        char *ai_canonname;
     81        struct addrinfo *ai_next;
     82};
     83
     84typedef uint16_t in_port_t;
     85typedef uint32_t in_addr_t;
     86struct in_addr { in_addr_t s_addr; };
     87
     88struct sockaddr_in {
     89        sa_family_t sin_family;
     90        in_port_t sin_port;
     91        struct in_addr sin_addr;
     92        uint8_t sin_zero[8];
     93};
     94
     95struct in6_addr
     96{
     97        union {
     98                uint8_t __s6_addr[16];
     99                uint16_t __s6_addr16[8];
     100                uint32_t __s6_addr32[4];
     101        } __in6_union;
     102};
     103//#define s6_addr __in6_union.__s6_addr
     104//#define s6_addr16 __in6_union.__s6_addr16
     105//#define s6_addr32 __in6_union.__s6_addr32
     106
     107struct sockaddr_in6
     108{
     109        sa_family_t     sin6_family;
     110        in_port_t       sin6_port;
     111        uint32_t        sin6_flowinfo;
     112        struct in6_addr sin6_addr;
     113        uint32_t        sin6_scope_id;
     114};
     115
     116typedef struct socket_t {
     117        int family;
     118        int type;
     119        int protocol;
     120        int cepid;
     121        int repid;
     122        int backlog;
     123        unsigned int flags;
     124        union {
     125                struct sockaddr_in laddr4;
     126                struct sockaddr_in6 laddr6;
     127        };
     128        union {
     129                struct sockaddr_in raddr4;
     130                struct sockaddr_in6 raddr6;
     131        };
     132        int buf_size;
     133        unsigned char *buf;
     134        void *input;
     135        int len;
     136} socket_t;
    70137
    71138#define tcp6_cre_cep tcp_cre_cep
     
    82149#define tcp6_set_opt tcp_set_opt
    83150
    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 
    88151#ifndef SUPPORT_INET6
    89152
     
    93156
    94157ER      udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep) { return E_SYS; }
     158ER      udp6_del_cep (ID cepid) { return E_SYS; }
    95159ER_UINT udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
    96160ER_UINT udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
     161ER      udp6_set_opt (ID cepid, int_t optname, void *optval, int_t optlen) { return E_SYS; }
     162ER      udp6_get_opt (ID cepid, int_t optname, void *optval, int_t optlen) { return E_SYS; }
    97163
    98164const T_IN6_ADDR *in6_get_ifaddr (int_t index) { return NULL; }
     
    111177static int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    112178static bool_t tcp_fd_readable(struct SHELL_FILE *fp);
     179static bool_t tcp_fd_writable(struct SHELL_FILE *fp);
    113180static void tcp_fd_delete(struct SHELL_FILE *fp);
    114181
     
    119186static int udp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    120187static bool_t udp_fd_readable(struct SHELL_FILE *fp);
     188static bool_t udp_fd_writable(struct SHELL_FILE *fp);
    121189static void udp_fd_delete(struct SHELL_FILE *fp);
    122190
    123 IO_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 };
    124 IO_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 };
     191IO_TYPE IO_TYPE_TCP = { tcp_fd_close, tcp_fd_read, tcp_fd_write, tcp_fd_seek, tcp_fd_ioctl, tcp_fd_readable, tcp_fd_writable, tcp_fd_delete };
     192IO_TYPE IO_TYPE_UDP = { udp_fd_close, udp_fd_read, udp_fd_write, udp_fd_seek, udp_fd_ioctl, udp_fd_readable, udp_fd_writable, udp_fd_delete };
    125193
    126194typedef struct id_table_t {
     
    185253
    186254#endif
     255
     256void addrcpy(void *_dst, const void *_src, int len)
     257{
     258#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     259        memcpy(_dst, _src, len);
     260#else
     261        uint8_t *dst = (uint8_t *)_dst, *src = &((uint8_t *)_src)[len];
     262        while (src != _src)
     263                *dst++ = *--src;
     264#endif
     265}
    187266
    188267ID new_id(id_table_t *table, int count)
     
    347426                }
    348427                case SOCK_DGRAM: {
    349                         ID cepid = new_id(udp_cepid_table, udp_cepid_table_count);
     428                        ID cepid = new_id(udp6_cepid_table, udp6_cepid_table_count);
    350429                        if (cepid < 0)
    351430                                return -ENOMEM;
    352431
    353                         T_UDP6_CCEP ccep = { 0, {ntohl(addr_in6->sin6_addr.__in6_union.__s6_addr), ntohs(addr_in6->sin6_port)}, (FP)socket_udp6_callback };
     432                        T_UDP6_CCEP ccep = { 0, { { ntohl(addr_in6->sin6_addr.__in6_union.__s6_addr) }, ntohs(addr_in6->sin6_port)}, (FP)socket_udp6_callback };
    354433                        ret = udp6_cre_cep(cepid, &ccep);
    355434                        if (ret != E_OK) {
    356                                 delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
     435                                delete_id(udp6_cepid_table, udp6_cepid_table_count, cepid);
    357436                                return -ENOMEM;
    358437                        }
     
    407486
    408487                struct sockaddr_in6 *laddr = &socket->laddr6;
    409                 T_TCP6_CREP crep = { 0, {ntohl(laddr->sin6_addr.__in6_union.__s6_addr), ntohs(laddr->sin6_port)} };
     488                T_TCP6_CREP crep = { 0, { { ntohl(laddr->sin6_addr.__in6_union.__s6_addr) }, ntohs(laddr->sin6_port)} };
    410489                ret = tcp6_cre_rep(repid, &crep);
    411490                if (ret != E_OK) {
     
    423502}
    424503
    425 int shell_connect(int fd, const struct sockaddr *addr, socklen_t len)
     504int shell_connect(int fd, const struct sockaddr *addr, socklen_t alen)
    426505{
    427506        SOCKET *fp = fd_to_fp(fd);
     
    435514        switch (socket->family) {
    436515        case AF_INET: {
    437                 if (len < 8) {
     516                if (alen < sizeof(struct sockaddr_in)) {
    438517                        return -EINVAL;
    439518                }
     
    455534                        }
    456535                        fp->handle = cepid;
     536                        fp->writable = 1;
    457537                        socket->cepid = cepid;
    458538                }
    459539                struct sockaddr_in *laddr = &socket->laddr4;
    460540                struct sockaddr_in *raddr = &socket->raddr4;
    461                 memset(raddr, 0, sizeof(*raddr));
    462                 memcpy(raddr, addr, len);
     541                memcpy(raddr, addr, sizeof(struct sockaddr_in));
    463542                T_IPV4EP lep = { ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port) };
    464543                T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    465544                ret = tcp_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
    466                 if (ret < 0) {
     545                if (ret == E_TMOUT) {
     546                        return -ETIMEDOUT;
     547                }
     548                else if (ret < 0) {
    467549                        return -EHOSTUNREACH;
    468550                }
     
    470552        }
    471553        case AF_INET6: {
    472                 if (len < 20) {
     554                if (alen < sizeof(struct sockaddr_in6)) {
    473555                        return -EINVAL;
    474556                }
     
    490572                        }
    491573                        fp->handle = cepid;
     574                        fp->writable = 1;
    492575                        socket->cepid = cepid;
    493576                }
    494577                struct sockaddr_in6 *laddr = &socket->laddr6;
    495578                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) };
     579                memcpy(raddr, addr, sizeof(struct sockaddr_in6));
     580                T_IPV6EP lep;
     581                addrcpy(&lep.ipaddr, &laddr->sin6_addr, 16);
     582                lep.portno = ntohs(laddr->sin6_port);
     583                T_IPV6EP rep;
     584                addrcpy(&rep.ipaddr, &raddr->sin6_addr, 16);
     585                rep.portno = ntohs(raddr->sin6_port);
    500586                ret = tcp6_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
    501                 if (ret < 0) {
     587                if (ret == E_TMOUT) {
     588                        return -ETIMEDOUT;
     589                }
     590                else if (ret < 0) {
    502591                        return -EHOSTUNREACH;
    503592                }
     
    508597        }
    509598
     599        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
     600
    510601        return 0;
    511602}
    512603
    513 int shell_accept(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len)
     604int shell_accept(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
    514605{
    515606        SOCKET *lfp = fd_to_fp(fd);
     
    550641                        }
    551642                        fp->handle = cepid;
     643                        fp->writable = 1;
    552644                        socket->cepid = cepid;
    553645                }
     
    555647                        cepid = ((socket_t *)lfp->exinf)->cepid;
    556648                        fp->handle = cepid;
     649                        fp->writable = 1;
    557650                        lfp->handle = tmax_tcp_cepid + ((socket_t *)lfp->exinf)->repid;
    558651                        ((socket_t *)lfp->exinf)->cepid = 0;
     
    566659                }
    567660                struct sockaddr_in *raddr = &socket->raddr4;
    568                 memset(raddr, 0, sizeof(*raddr));
     661                memset(raddr, 0, sizeof(struct sockaddr_in));
    569662                raddr->sin_family = AF_INET;
    570663                raddr->sin_port = htons(rep.portno);
    571664                raddr->sin_addr.s_addr = htonl(rep.ipaddr);
    572665
    573                 if (addr != NULL && len != NULL) {
    574                         int sz = *len;
    575                         if (sz < 8) {
     666                if (addr != NULL && alen != NULL) {
     667                        int sz = *alen;
     668                        if (sz < sizeof(struct sockaddr_in)) {
    576669                                return -EINVAL;
    577670                        }
    578671                        struct sockaddr_in *raddr = &socket->raddr4;
    579                         if (sz > sizeof(*raddr))
    580                                 sz = sizeof(*raddr);
     672                        if (sz > sizeof(struct sockaddr_in))
     673                                sz = sizeof(struct sockaddr_in);
    581674                        memcpy(addr, raddr, sz);
    582                         *len = sizeof(*raddr);
     675                        *alen = sz;
    583676                }
    584677                break;
     
    603696                        }
    604697                        fp->handle = cepid;
     698                        fp->writable = 1;
    605699                        socket->cepid = cepid;
    606700                }
     
    608702                        cepid = ((socket_t *)lfp->exinf)->cepid;
    609703                        fp->handle = cepid;
     704                        fp->writable = 1;
    610705                        lfp->handle = tmax_tcp6_cepid + ((socket_t *)lfp->exinf)->repid;
    611706                        ((socket_t *)lfp->exinf)->cepid = 0;
     
    613708                        ((socket_t *)lfp->exinf)->buf = 0;
    614709                }
    615                 T_IPV6EP rep = { 0, 0 };
     710                T_IPV6EP rep = { { 0 }, 0 };
    616711                ret = tcp6_acp_cep(socket->cepid, socket->repid, &rep, TMO_FEVR);
    617712                if (ret < 0) {
     
    619714                }
    620715                struct sockaddr_in6 *raddr = &socket->raddr6;
    621                 memset(raddr, 0, sizeof(*raddr));
     716                memset(raddr, 0, sizeof(struct sockaddr_in6));
    622717                raddr->sin6_family = AF_INET;
    623718                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) {
     719                addrcpy(&raddr->sin6_addr, &rep.ipaddr, 16);
     720
     721                if (addr != NULL && alen != NULL) {
     722                        int sz = *alen;
     723                        if (sz < sizeof(struct sockaddr_in6)) {
    634724                                return -EINVAL;
    635725                        }
    636726                        struct sockaddr_in6 *raddr = &socket->raddr6;
    637                         if (sz > sizeof(*raddr))
    638                                 sz = sizeof(*raddr);
     727                        if (sz > sizeof(struct sockaddr_in6))
     728                                sz = sizeof(struct sockaddr_in6);
    639729                        memcpy(addr, raddr, sz);
    640                         *len = sizeof(*raddr);
     730                        *alen = sz;
    641731                }
    642732                break;
     
    645735                return -ENOPROTOOPT;
    646736        }
     737
     738        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
    647739
    648740        return fp->fd;
     
    673765                        }
    674766                        else {
     767                                int temp = len;
    675768                                for (;;) {
    676769                                        ret = tcp_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    677770                                        if (ret < 0) {
    678                                                 if (ret == E_TMOUT)
    679                                                         return -ETIME;
    680                                                 return -ECOMM;
     771                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    681772                                        }
    682773                                        len -= ret;
     
    685776                                        buf = (const void *)&((uint8_t *)buf)[ret];
    686777                                }
     778                                ret = temp;
    687779                        }
    688780                        break;
    689781                }
    690782                case SOCK_DGRAM: {
    691                         int sz = alen;
    692                         if ((addr == NULL) || (sz < 8)) {
     783                        if ((addr == NULL) || (alen < sizeof(struct sockaddr_in))) {
    693784                                return -EINVAL;
    694785                        }
    695786                        struct sockaddr_in *raddr = &socket->raddr4;
    696                         memset(raddr, 0, sizeof(*raddr));
    697                         memcpy(raddr, addr, sz);
     787                        memcpy(raddr, addr, sizeof(struct sockaddr_in));
    698788                        T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    699789                        ret = udp_snd_dat(socket->cepid, &rep, (void *)buf, len,
    700790                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    701791                        if (ret < 0) {
    702                                 return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     792                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    703793                        }
    704794                        break;
     
    721811                        }
    722812                        else {
     813                                int temp = len;
    723814                                for (;;) {
    724815                                        ret = tcp6_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    725816                                        if (ret < 0) {
    726                                                 if (ret == E_TMOUT)
    727                                                         return -ETIME;
    728                                                 return -ECOMM;
     817                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    729818                                        }
    730819                                        len -= ret;
     
    732821                                                break;
    733822                                        buf = (const void *)&((uint8_t *)buf)[ret];
    734                                 }
     823                                }
     824                                ret = temp;
    735825                        }
    736826                        break;
    737827                }
    738828                case SOCK_DGRAM: {
    739                         int sz = alen;
    740                         if ((addr == NULL) || (sz < 8)) {
     829                        if ((addr == NULL) || (alen < sizeof(struct sockaddr_in6))) {
    741830                                return -EINVAL;
    742831                        }
    743832                        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) };
     833                        memcpy(raddr, addr, sizeof(struct sockaddr_in6));
     834                        T_IPV6EP rep;
     835                        addrcpy(&rep.ipaddr, &raddr->sin6_addr, 16);
     836                        rep.portno = ntohs(raddr->sin6_port);
    747837                        ret = udp6_snd_dat(socket->cepid, &rep, (void *)buf, len,
    748838                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    749839                        if (ret < 0) {
    750                                 return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     840                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    751841                        }
    752842                        break;
     
    758848                return -ENOPROTOOPT;
    759849        }
     850
     851        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
    760852
    761853        return ret;
     
    800892                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
    801893                                        }
    802                                         ret = tcp_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
     894                                        ret = tcp_rcv_buf(socket->cepid, &socket->input,
     895                                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    803896                                        if (ret < 0) {
    804                                                 syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
    805                                                 return -ECOMM;
     897                                                if ((socket->flags & O_NONBLOCK) == 0)
     898                                                        syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     899                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    806900                                        }
    807901                                        rsz = ret;
     
    858952                                        if ((socket->flags & O_NONBLOCK) == 0)
    859953                                                syslog(LOG_ERROR, "udp_rcv_buf => %d", ret);
    860                                         return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     954                                        return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    861955                                }
    862956                                rsz = ret;
     
    867961                                        }
    868962                                        int sz = *alen;
    869                                         memset(raddr, 0, sizeof(socket->raddr4));
     963                                        memset(raddr, 0, sizeof(struct sockaddr_in));
    870964                                        raddr->sin_family = AF_INET;
    871965                                        raddr->sin_port = htons(rep.portno);
    872966                                        raddr->sin_addr.s_addr = htonl(rep.ipaddr);
    873                                         if (sz > sizeof(socket->raddr4))
    874                                                 sz = sizeof(socket->raddr4);
     967                                        if (sz > sizeof(struct sockaddr_in))
     968                                                sz = sizeof(struct sockaddr_in);
    875969                                        memcpy(addr, raddr, sz);
    876970                                        *alen = sz;
     
    889983                                if ((addr != NULL) && (alen != NULL)) {
    890984                                        int sz = *alen;
    891                                         if (sz > sizeof(socket->raddr4))
    892                                                 sz = sizeof(socket->raddr4);
     985                                        if (sz > sizeof(struct sockaddr_in))
     986                                                sz = sizeof(struct sockaddr_in);
    893987                                        memcpy(addr, raddr, sz);
    894988                                        *alen = sz;
     
    9341028                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
    9351029                                        }
    936                                         ret = tcp6_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
     1030                                        ret = tcp6_rcv_buf(socket->cepid, &socket->input,
     1031                                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    9371032                                        if (ret < 0) {
    938                                                 syslog(LOG_ERROR, "tcp6_rcv_buf => %d", ret);
    939                                                 return -ECOMM;
     1033                                                if ((socket->flags & O_NONBLOCK) == 0)
     1034                                                        syslog(LOG_ERROR, "tcp6_rcv_buf => %d", ret);
     1035                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    9401036                                        }
    9411037                                        rsz = ret;
     
    9861082                                }
    9871083
    988                                 T_IPV6EP rep = { 0, 0 };
     1084                                T_IPV6EP rep = { { 0 }, 0 };
    9891085                                ret = udp6_rcv_dat(socket->cepid, &rep, buf, len,
    9901086                                        (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     
    9921088                                        if ((socket->flags & O_NONBLOCK) == 0)
    9931089                                                syslog(LOG_ERROR, "udp6_rcv_buf => %d", ret);
    994                                         return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     1090                                        return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    9951091                                }
    9961092                                rsz = ret;
     
    10011097                                        }
    10021098                                        int sz = *alen;
    1003                                         memset(raddr, 0, sizeof(socket->raddr6));
     1099                                        memset(raddr, 0, sizeof(struct sockaddr_in6));
    10041100                                        raddr->sin6_family = AF_INET;
    10051101                                        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);
     1102                                        addrcpy(&raddr->sin6_addr, &rep.ipaddr, 16);
     1103                                        if (sz > sizeof(struct sockaddr_in6))
     1104                                                sz = sizeof(struct sockaddr_in6);
    10141105                                        memcpy(addr, raddr, sz);
    10151106                                        *alen = sz;
     
    10281119                                if ((addr != NULL) && (alen != NULL)) {
    10291120                                        int sz = *alen;
    1030                                         if (sz > sizeof(socket->raddr6))
    1031                                                 sz = sizeof(socket->raddr6);
     1121                                        if (sz > sizeof(struct sockaddr_in6))
     1122                                                sz = sizeof(struct sockaddr_in6);
    10321123                                        memcpy(addr, raddr, sz);
    10331124                                        *alen = sz;
     
    10541145                return -ENOPROTOOPT;
    10551146        }
     1147
     1148        if (fp->readevt_w != fp->readevt_r) fp->readevt_r++;
    10561149
    10571150        return ret;
     
    14271520                struct sockaddr_in6 laddr;
    14281521                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
     1522                addrcpy(&laddr.sin6_addr, laddr6, 16);
    14351523                laddr.sin6_port = socket->laddr6.sin6_port;
    14361524                *len = sizeof(struct sockaddr_in6);
     
    14651553                        delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
    14661554                        if ((ret < 0) || (ret2 < 0)) {
    1467                                 return (ret == E_TMOUT) ? -ETIME : -EINVAL;
     1555                                return (ret == E_TMOUT) ? -ETIMEDOUT : -EIO;
    14681556                        }
    14691557                }
     
    14941582                        delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
    14951583                        if ((ret < 0) || (ret2 < 0)) {
    1496                                 return (ret == E_TMOUT) ? -ETIME : -EINVAL;
     1584                                return (ret == E_TMOUT) ? -ETIMEDOUT : -EIO;
    14971585                        }
    14981586                }
     
    15351623int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    15361624{
     1625        socket_t *socket = (socket_t *)fp->exinf;
     1626
     1627        switch (req) {
     1628        case F_GETFL:
     1629                return socket->flags;
     1630        case F_SETFL:
     1631                socket->flags = (unsigned int)arg;
     1632                return 0;
     1633        }
     1634
    15371635        return -EINVAL;
    15381636}
     
    15711669}
    15721670
     1671bool_t tcp_fd_writable(struct SHELL_FILE *fp)
     1672{
     1673        //socket_t *socket = (socket_t *)fp->exinf;
     1674
     1675        return /*fp->writable &&*/ (fp->writeevt_w == fp->writeevt_r);
     1676}
     1677
    15731678void tcp_fd_delete(struct SHELL_FILE *fp)
    15741679{
     
    15901695                return E_PAR;
    15911696
     1697        socket_t *socket = (socket_t *)fp->exinf;
    15921698        int fd = fp->fd;
    15931699        FD_SET(fd, (fd_set *)&flgptn);
     
    16031709                        syslog(LOG_ERROR, "wai_sem => %d", ret);
    16041710                }
    1605                 socket_t *socket = (socket_t *)fp->exinf;
    16061711                socket->len += len;
    16071712                ret = sig_sem(SEM_FILEDESC);
     
    16701775                return E_PAR;
    16711776
     1777        socket_t *socket = (socket_t *)fp->exinf;
    16721778        int fd = fp->fd;
    16731779        FD_SET(fd, (fd_set *)&flgptn);
     
    16831789                        syslog(LOG_ERROR, "wai_sem => %d", ret);
    16841790                }
    1685                 socket_t *socket = (socket_t *)fp->exinf;
    16861791                socket->len += len;
    16871792                ret = sig_sem(SEM_FILEDESC);
     
    18061911}
    18071912
     1913bool_t udp_fd_writable(struct SHELL_FILE *fp)
     1914{
     1915        //socket_t *socket = (socket_t *)fp->exinf;
     1916
     1917        return fp->writable && (fp->writeevt_w == fp->writeevt_r);
     1918}
     1919
    18081920void udp_fd_delete(struct SHELL_FILE *fp)
    18091921{
     
    18491961                socket->input = udppara->input;
    18501962                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
    1851                 memset(&socket->raddr4, 0, sizeof(socket->raddr4));
     1963                memset(&socket->raddr4, 0, sizeof(struct sockaddr_in));
    18521964                socket->raddr4.sin_family = AF_INET;
    18531965                socket->raddr4.sin_port = htons(udppara->rep4.portno);
     
    19322044                socket->input = udppara->input;
    19332045                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
    1934                 memset(&socket->raddr6, 0, sizeof(socket->raddr6));
     2046                memset(&socket->raddr6, 0, sizeof(struct sockaddr_in6));
    19352047                socket->raddr6.sin6_family = AF_INET;
    19362048                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
     2049                addrcpy(&socket->raddr6.sin6_addr, &udppara->rep6.ipaddr, 16);
    19432050                udppara->input->flags |= NB_FLG_NOREL_IFOUT;
    19442051                ret = sig_sem(SEM_FILEDESC);
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/syscall.c

    r374 r387  
    336336}
    337337
    338 long SYS_rt_sigaction(long a, long b, long c) {
    339         return shell_sigaction((int)a, (const struct sigaction *)b, (struct sigaction *)c);
     338long SYS_rt_sigaction(long a, long b, long c, long d) {
     339        return shell_sigaction((int)a, (const struct k_sigaction *)b, (struct k_sigaction *)c, (size_t)d);
    340340}
    341341
     
    429429}
    430430
     431long SYS_nanosleep(long a, long b)
     432{
     433        return shell_nanosleep((const struct timespec *)a, (struct timespec *)b);
     434}
     435
    431436long SYS_dup(long a) {
    432437        //int dup(int fd)
     
    532537{
    533538        return no_implement("tgkill\n");
    534 }
    535 
    536 long SYS_nanosleep(long a, long b) {
    537         //int nanosleep(const struct timespec *req, struct timespec *rem)
    538         return no_implement("nanosleep\n");
    539539}
    540540
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/Debug/Makefile

    r374 r387  
    198198APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    199199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    200 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    201 APPL_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
     200APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    202202
    203203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/DebugCitrus/Makefile

    r374 r387  
    198198APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    199199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    200 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    201 APPL_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
     200APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    202202
    203203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/DebugEther/Makefile

    r374 r387  
    198198APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    199199APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    200 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    201 APPL_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
     200APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     201APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    202202
    203203#
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/src/main.c

    r374 r387  
    6666#include "ffarch.h"
    6767#include "ff.h"
    68 #include "core/ntshell.h"
    69 #include "core/ntlibc.h"
    7068#include <stdio.h>
    7169#include "usrcmd.h"
    72 #include "util/ntopt.h"
    73 #include "socket_stub.h"
    7470#include "gpio_api.h"
    7571#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app1_usb_watt_meter/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app2_light/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app2_light/DebugCitrus/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app2_light/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    191191
    192192#
  • asp3_tinet_ecnl_rx/trunk/app2_light/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app2_light/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/DebugCitrus/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    191191
    192192#
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app3_human_detec/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/Debug/Makefile

    r376 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/DebugCitrus/Makefile

    r376 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/DebugEther/Makefile

    r376 r387  
    193193APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    194194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    195 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    196 APPL_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
     195APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app4_aircon/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/Debug/Makefile

    r374 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/DebugCitrus/Makefile

    r374 r387  
    195195APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    196196APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    197 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    198 APPL_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
     197APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     198APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/DebugEther/Makefile

    r374 r387  
    193193APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    194194APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    195 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    196 APPL_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
     195APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     196APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app5_temp_sensor/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/DebugCitrus/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    191191
    192192#
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app6_hot_water_pot/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/Debug/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/DebugCitrus/Makefile

    r374 r387  
    189189APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    190190APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    191 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    192 APPL_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
     191APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     192APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    193193
    194194#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/DebugEther/Makefile

    r374 r387  
    187187APPLDIRS := $(APPLDIRS) $(SRCDIR)/$(TINETDIR)/netapp
    188188APPL_COBJS := $(APPL_COBJS) ping.o ping6.o resolver.o dhcp4_cli.o netapp_subr.o ntp_cli.o net_misc.o
    189 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    190 APPL_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
     189APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     190APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o stdio_stub.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
    191191
    192192#
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/src/main.c

    r374 r387  
    6565#include "ffarch.h"
    6666#include "ff.h"
    67 #include "core/ntshell.h"
    68 #include "core/ntlibc.h"
    6967#include <stdio.h>
    7068#include "usrcmd.h"
    71 #include "util/ntopt.h"
    72 #include "socket_stub.h"
    7369#include "gpio_api.h"
    7470#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/app7_buzzer/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/arch/rx630_gcc/prc_kernel_impl.c

    r378 r387  
    236236}
    237237#endif /* OMIT_DEFAULT_EXC_HANDLER */
    238 
    239 void _start_c(char * const*args);
    240 
    241 void
    242 _sta_ker()
    243 {
    244         static const char *const args[] = {
    245                 (char *)1,
    246                 "asp3",
    247                 0,
    248                 // envp
    249                 "TZ=JST-9",
    250                 0,
    251                 // auxv
    252                 0
    253         };
    254         _start_c(args);
    255 }
    256 
    257 //#include <errno.h>
    258 #define ENOSYS          38
    259 
    260 __attribute__((weak))
    261 long SYS_poll()
    262 {
    263         return -ENOSYS;
    264 }
    265 
    266 __attribute__((weak))
    267 long SYS_open()
    268 {
    269         return -ENOSYS;
    270 }
    271 
    272 __attribute__((weak))
    273 long SYS_set_tid_address()
    274 {
    275         return 0;//-ENOSYS;
    276 }
    277 
    278 __attribute__((weak))
    279 long SYS_gettid()
    280 {
    281         return 0;//-ENOSYS;
    282 }
    283 
    284 __attribute__((weak))
    285 long SYS_rt_sigprocmask()
    286 {
    287         return 0;//-ENOSYS;
    288 }
    289 
    290 __attribute__((weak))
    291 long SYS_mmap2()
    292 {
    293         return 0;//-ENOSYS;
    294 }
    295 
    296 __attribute__((weak))
    297 long SYS_tkill()
    298 {
    299         return 0;//-ENOSYS;
    300 }
    301 
    302 __attribute__((weak))
    303 void SYS_exit_group()
    304 {
    305         ext_ker();
    306 }
    307 
    308 __attribute__((weak))
    309 void SYS_exit()
    310 {
    311         ext_ker();
    312 }
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/mbed/hal/spi_api.h

    r374 r387  
    3434
    3535#define SPI_FILL_WORD         (0xFFFF)
     36#define SPI_FILL_CHAR         (0xFF)
    3637
    3738#if DEVICE_SPI_ASYNCH
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/mbed/target/mbed_api.c

    r374 r387  
    13491349{
    13501350        //return probe_int(obj->rxi_intno);
    1351         return (sil_reb_mem(SCI_SSR(obj->base_address)) & RIE) != 0U;
     1351        return true;
    13521352}
    13531353
     
    13551355{
    13561356        //return probe_int(obj->tei_intno);
    1357         return (sil_reb_mem(SCI_SSR(obj->base_address)) & TEIE) != 0U;
     1357        return (sil_reb_mem(SCI_SSR(obj->base_address)) & TEND) != 0U;
    13581358}
    13591359
     
    13941394{
    13951395        int no = SCI_NUM(obj->base_address);
     1396        bool_t lock = sense_lock();
     1397
     1398        if (!lock)
     1399                loc_cpu();
    13961400
    13971401        sci_irq_info[no].handler = handler;
    13981402        sci_irq_info[no].id = id;
     1403
     1404        if (!lock)
     1405                unl_cpu();
    13991406}
    14001407
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/syssvc/tlsf/tlsf.c

    r374 r387  
    66#include <string.h>
    77#include <stdio.h>
     8#include <t_syslog.h>
    89
    910#include "tlsf.h"
     
    887888{
    888889        (void)user;
    889         printf("\t%p %s size: %x (%p)\n", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr));
     890        syslog(LOG_NOTICE, "\t%p %s size: %x (%p)", ptr, used ? "used" : "free", (unsigned int)size, block_from_ptr(ptr));
    890891}
    891892
     
    976977        if (((ptrdiff_t)mem % ALIGN_SIZE) != 0)
    977978        {
    978                 printf("tlsf_add_pool: Memory must be aligned by %u bytes.\n",
     979                syslog(LOG_NOTICE, "tlsf_add_pool: Memory must be aligned by %u bytes.",
    979980                        (unsigned int)ALIGN_SIZE);
    980981                return 0;
     
    984985        {
    985986#if defined (TLSF_64BIT)
    986                 printf("tlsf_add_pool: Memory size must be between 0x%x and 0x%x00 bytes.\n",
     987                syslog(LOG_NOTICE, "tlsf_add_pool: Memory size must be between 0x%x and 0x%x00 bytes.",
    987988                        (unsigned int)(pool_overhead + block_size_min),
    988989                        (unsigned int)((pool_overhead + block_size_max) / 256));
    989990#else
    990                 printf("tlsf_add_pool: Memory size must be between %u and %u bytes.\n",
     991                syslog(LOG_NOTICE, "tlsf_add_pool: Memory size must be between %u and %u bytes.",
    991992                        (unsigned int)(pool_overhead + block_size_min),
    992993                        (unsigned int)(pool_overhead + block_size_max));
     
    10561057        if (rv)
    10571058        {
    1058                 printf("test_ffs_fls: %x ffs/fls tests failed.\n", rv);
     1059                syslog(LOG_NOTICE, "test_ffs_fls: %x ffs/fls tests failed.", rv);
    10591060        }
    10601061        return rv;
     
    10731074        if (((tlsfptr_t)mem % ALIGN_SIZE) != 0)
    10741075        {
    1075                 printf("tlsf_create: Memory must be aligned to %u bytes.\n",
     1076                syslog(LOG_NOTICE, "tlsf_create: Memory must be aligned to %u bytes.",
    10761077                        (unsigned int)ALIGN_SIZE);
    10771078                return 0;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/Makefile.target

    r374 r387  
    2525#  システムサービスに関する定義
    2626#
    27 SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed
    28 SYSSVC_COBJS := $(SYSSVC_COBJS)
     27SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed $(SRCDIR)/syssvc/tlsf
     28SYSSVC_COBJS := $(SYSSVC_COBJS) musl_adapter.o tlsf.o
    2929
    3030#
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target.cdl

    r337 r387  
    6060 *  ターゲット依存のセルタイプの定義
    6161 */
    62 import("tPutLogGRCitrus.cdl");
     62import("syssvc/tPutLogSIOPort.cdl");
    6363import("tSIOPortGRCitrus.cdl");
    6464
     
    7272 *  低レベル出力の組み上げ記述
    7373 */
    74 cell tPutLogGRCitrus PutLogTarget {
     74cell tPutLogSIOPort PutLogTarget {
    7575        /* SIOドライバとの結合 */
    7676        cSIOPort = SIOPortTarget1.eSIOPort;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_kernel.cfg

    r337 r387  
    55 */
    66INCLUDE("target_timer.cfg")
     7INCLUDE("syssvc/musl_adapter.cfg")
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_kernel_impl.c

    r374 r387  
    5454#ifdef TOPPERS_OMIT_TECS
    5555#include "serial_api.h"
     56#include "target_syssvc.h"
    5657#endif
    5758
     
    8384         *  シリアルポートの設定
    8485         */
    85         serial_init(&log_serial, P20, P21);
     86        serial_init(&log_serial, STDIO_UART_TX, STDIO_UART_RX);
    8687        serial_baud(&log_serial, UART_BAUDRATE);
    8788        serial_format(&log_serial, 8, ParityNone, 1);
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_serial.c

    r374 r387  
    33 *      Toyohashi Open Platform for Embedded Real-Time Systems/
    44 *      Advanced Standard Profile Kernel
    5  *
    6  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    7  *                              Toyohashi Univ. of Technology, JAPAN
    8  *  Copyright (C) 2003-2004 by Naoki Saito
    9  *             Nagoya Municipal Industrial Research Institute, JAPAN
    10  *  Copyright (C) 2003-2004 by Platform Development Center
    11  *                                          RICOH COMPANY,LTD. JAPAN
    12  *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    13  *  Copyright (C) 2013      by Mitsuhiro Matsuura
    14  *
     5 *
     6 *  Copyright (C) 2006-2018 by Embedded and Real-Time Systems Laboratory
     7 *              Graduate School of Information Science, Nagoya Univ., JAPAN
     8 *
    159 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    1610 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    3529 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    3630 *      免責すること.
    37  *
     31 * 
    3832 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3933 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    4135 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    4236 *  の責任を負わない.
    43  *
     37 * 
    4438 *  @(#) $Id$
    4539 */
    4640
    4741/*
    48  *      RX630 UART用シリアルI/Oモジュール
    49  */
    50 #include "kernel_impl.h"
    51 #include <sil.h>
     42 *              シリアルインタフェースドライバのターゲット依存部(GR-CITRUS用)
     43 */
     44
     45#include "gr_citrus.h"
     46#include <t_stddef.h>
     47#include <t_syslog.h>
     48#include <errno.h>
     49#include <unistd.h>
     50#include <fcntl.h>
     51#include <termios.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ポート初期化ブロックの定義
     53#include "syssvc/siofd.h"
     54
     55/*
     56 *  SIOポート初期化ブロックの定義
    5957 */
    6058typedef struct sio_port_initialization_block {
    61         PinName tx;
    62         PinName rx;
     59        char            *path;                  /* ファイルのパス名 */
    6360} SIOPINIB;
    6461
    6562/*
    66  *  シリアルI/Oポート管理ブロックの定義
     63 *  SIOポート管理ブロックの定義
    6764 */
    6865struct sio_port_control_block {
    69         const SIOPINIB *p_siopinib;
    70         intptr_t exinf;
    71         bool_t openflag;
    72         serial_t serial;
     66        const SIOPINIB *p_siopinib;     /* SIOポート初期化ブロック */
     67        intptr_t        exinf;                  /* 拡張情報 */
     68        bool_t          opened;         /* オープン済みフラグ */
     69        struct termios saved_term;      /* 元の端末制御情報 */
     70
     71        int_t           read_fd;                /* 読出し用ファイルディスクリプタ */
     72        bool_t          rcv_flag;               /* 受信文字バッファ有効フラグ */
     73        char            rcv_buf;                /* 受信文字バッファ */
     74        bool_t          rcv_rdy;                /* 受信通知コールバック許可フラグ */
     75
     76        int_t           write_fd;               /* 書込み用ファイルディスクリプタ */
     77        bool_t          snd_flag;               /* 送信文字バッファ有効フラグ */
     78        char            snd_buf;                /* 送信文字バッファ */
     79        bool_t          snd_rdy;                /* 送信通知コールバック許可フラグ */
    7380};
    7481
    7582/*
    76  *  シリアルI/Oポート管理ブロックのエリア
    77  */
    78 SIOPCB siopcb_table[TNUM_PORT];
    79 
    80 static 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
     83 *  SIOポート初期化ブロック
     84 */
     85const SIOPINIB siopinib_table[TNUM_SIOP] = {
     86        { NULL }
    10187};
    10288
    10389/*
    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 
    110 static void mbed_serial_irq_handler(uint32_t id, SerialIrq event);
     90 *  SIOポート管理ブロックのエリア
     91 */
     92SIOPCB  siopcb_table[TNUM_SIOP];
     93
     94/*
     95 *  SIOポートIDから管理ブロックを取り出すためのマクロ
     96 */
     97#define INDEX_SIOP(siopid)      ((uint_t)((siopid) - 1))
     98#define get_siopcb(siopid)      (&(siopcb_table[INDEX_SIOP(siopid)]))
    11199
    112100/*
     
    120108
    121109        /*
    122          *  シリアルI/Oポート管理ブロックの初期化
     110         *  SIOポート管理ブロックの初期化
    123111         */
    124         for (p_siopcb = siopcb_table, i = 0; i < TNUM_SIOP; p_siopcb++, i++) {
     112        for (i = 0; i < TNUM_SIOP; i++) {
     113                p_siopcb = &(siopcb_table[i]);
    125114                p_siopcb->p_siopinib = &(siopinib_table[i]);
    126                 p_siopcb->openflag = false;
    127         }
    128 }
    129 
    130 /*
    131  *  シリアルI/Oポートのオープン
     115                p_siopcb->opened = false;
     116        }
     117}
     118
     119/*
     120 *  SIOドライバの終了処理
     121 */
     122void
     123sio_terminate(intptr_t exinf)
     124{
     125        uint_t  i;
     126
     127        /*
     128         *  オープンされているSIOポートのクローズ
     129         */
     130        for (i = 0; i < TNUM_SIOP; i++) {
     131                sio_cls_por(&(siopcb_table[i]));
     132        }
     133}
     134
     135/*
     136 *  SIOポートのオープン
    132137 */
    133138SIOPCB *
    134139sio_opn_por(ID siopid, intptr_t exinf)
    135140{
    136         SIOPCB  *p_siopcb = NULL;
    137         ER      ercd;
    138         serial_t *serial;
    139 
    140         if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
    141                 return NULL;
     141        SIOPCB                  *p_siopcb;
     142        const SIOPINIB  *p_siopinib;
     143        int_t                   fd;
     144        struct termios  term;
     145
    142146        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;
    157 }
    158 
    159 /*
    160  *  シリアルI/Oポートのクローズ
     147        p_siopinib = p_siopcb->p_siopinib;
     148
     149        if (!(p_siopcb->opened)) {
     150                if (p_siopinib->path != NULL) {
     151                        fd = siofd_open(p_siopinib->path, O_RDWR, 0777);
     152                        assert(fd >= 0);
     153                        p_siopcb->read_fd = fd;
     154                        p_siopcb->write_fd = fd;
     155                }
     156                else {
     157                        fd = STDIN_FILENO;                                      /* 標準入出力を使う */
     158                        p_siopcb->read_fd = STDIN_FILENO;
     159                        p_siopcb->write_fd = STDOUT_FILENO;
     160                }
     161                siofd_fcntl(fd, F_SETOWN, getpid());
     162                siofd_fcntl(fd, F_SETFL, (O_NONBLOCK | O_ASYNC));
     163
     164                siofd_tcgetattr(fd, &(p_siopcb->saved_term));
     165                term = p_siopcb->saved_term;
     166                term.c_lflag &= ~(ECHO | ICANON);
     167                siofd_tcsetattr(fd, TCSAFLUSH, &term);
     168
     169                p_siopcb->exinf = exinf;
     170                p_siopcb->rcv_flag = false;
     171                p_siopcb->rcv_rdy = false;
     172                p_siopcb->snd_flag = false;
     173                p_siopcb->snd_rdy = false;
     174                p_siopcb->opened = true;
     175        }
     176        return(p_siopcb);
     177}
     178
     179/*
     180 *  SIOポートのクローズ
    161181 */
    162182void
    163183sio_cls_por(SIOPCB *p_siopcb)
    164184{
    165         ER        ercd;
    166         serial_t *serial = &p_siopcb->serial;
    167 
    168         /*
    169          *  デバイス依存のクローズ処理.
    170          */
    171         serial_free(serial);
    172         p_siopcb->openflag = false;
    173 }
    174 
    175 /*
    176  *  シリアルI/Oポートへの文字送信
     185        int_t   fd;
     186
     187        if (p_siopcb->opened) {
     188                fd = p_siopcb->read_fd;
     189                siofd_tcsetattr(fd, TCSAFLUSH, &(p_siopcb->saved_term));
     190                siofd_fcntl(fd, F_SETFL, 0);
     191
     192                if (p_siopcb->p_siopinib->path != NULL) {
     193                        siofd_close(p_siopcb->read_fd);
     194                }
     195
     196                p_siopcb->opened = false;
     197        }
     198}
     199
     200/*
     201 *  SIOの割込みサービスルーチン
     202 */
     203bool_t
     204sio_isr_snd(ID siopid)
     205{
     206        SIOPCB  *p_siopcb = get_siopcb(siopid);
     207        int_t   n;
     208
     209        if (p_siopcb->snd_flag) {
     210                if ((n = siofd_write(p_siopcb->write_fd, &(p_siopcb->snd_buf), 1)) > 0) {
     211                        p_siopcb->snd_flag = false;
     212                        if (p_siopcb->snd_rdy) {
     213                                sio_irdy_snd(p_siopcb->exinf);
     214                                return p_siopcb->snd_rdy;
     215                        }
     216                }
     217        }
     218
     219        return false;
     220}
     221
     222/*
     223 *  SIOの割込みサービスルーチン
     224 */
     225bool_t
     226sio_isr_rcv(ID siopid, char c)
     227{
     228        SIOPCB  *p_siopcb = get_siopcb(siopid);
     229
     230        if (!p_siopcb->rcv_flag) {
     231                p_siopcb->rcv_buf = c;
     232                p_siopcb->rcv_flag = true;
     233                if (p_siopcb->rcv_rdy) {
     234                        sio_irdy_rcv(p_siopcb->exinf);
     235                        return p_siopcb->rcv_rdy;
     236                }
     237        }
     238
     239        return false;
     240}
     241
     242/*
     243 *  SIOポートへの文字送信
    177244 */
    178245bool_t
    179246sio_snd_chr(SIOPCB *p_siopcb, char c)
    180247{
    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ポートからの文字受信
     248        int_t   n;
     249
     250        if (!p_siopcb->snd_flag) {
     251                if ((n = siofd_write(p_siopcb->write_fd, &c, 1)) > 0) {
     252                        return(true);
     253                }
     254                else {
     255                        assert(n < 0 && errno == EAGAIN);
     256                        p_siopcb->snd_flag = true;
     257                        p_siopcb->snd_buf = c;
     258                        return(true);
     259                }
     260        }
     261        else {
     262                return(false);
     263        }
     264}
     265
     266/*
     267 *  SIOポートからの文字受信
    190268 */
    191269int_t
    192270sio_rcv_chr(SIOPCB *p_siopcb)
    193271{
    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ポートからのコールバックの許可
     272        char    c;
     273        int_t   n;
     274
     275        if (p_siopcb->rcv_flag) {
     276                p_siopcb->rcv_flag = false;
     277                return((int_t)(uint8_t)(p_siopcb->rcv_buf));
     278        }
     279        else if ((n = siofd_read(p_siopcb->read_fd, &c, 1)) > 0) {
     280                return((int_t)(uint8_t) c);
     281        }
     282        else {
     283                assert(n < 0 && errno == EAGAIN);
     284                return(-1);
     285        }
     286}
     287
     288/*
     289 *  SIOポートからのコールバックの許可
    202290 */
    203291void
    204292sio_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
    205293{
    206         serial_t *serial = &p_siopcb->serial;
    207294        switch (cbrtn) {
    208295        case SIO_RDY_SND:
    209                 serial_irq_set(serial, TxIrq, true);
     296                p_siopcb->snd_rdy = true;
    210297                break;
    211298        case SIO_RDY_RCV:
    212                 serial_irq_set(serial, RxIrq, true);
     299                p_siopcb->rcv_rdy = true;
    213300                break;
    214301        }
     
    216303
    217304/*
    218  *  シリアルI/Oポートからのコールバックの禁止
     305 *  SIOポートからのコールバックの禁止
    219306 */
    220307void
    221308sio_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
    222309{
    223         serial_t *serial = &p_siopcb->serial;
    224310        switch (cbrtn) {
    225311        case SIO_RDY_SND:
    226                 serial_irq_set(serial, TxIrq, false);
     312                p_siopcb->snd_rdy = false;
    227313                break;
    228314        case SIO_RDY_RCV:
    229                 serial_irq_set(serial, RxIrq, false);
     315                p_siopcb->rcv_rdy = false;
    230316                break;
    231317        }
    232318}
    233 
    234 /*
    235  *  シリアルI/Oポートからの送信可能コールバック
    236  */
    237 void
    238 serial_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  */
    247 void
    248 serial_irdy_rcv(SIOPCB  *p_siopcb)
    249 {
    250         /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
    251         sio_irdy_rcv(p_siopcb->exinf);
    252 }
    253 
    254 /*
    255  *  SIOの割込みハンドラ
    256  */
    257 void
    258 mbed_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

    r374 r387  
    44
    55#include <target_serial.h>
    6 
     6//INCLUDE("unix_sigio.cfg");
    77ATT_INI({ TA_NULL, 0, sio_initialize });
    8 
     8ATT_TER({ TA_NULL, 0, sio_terminate });
     9//CRE_ISR( ISR_SIO, { TA_NULL, 0, INTNO_SIGIO, sio_isr, ISRPRI_SIO });
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_serial.h

    r374 r387  
    44 *      Advanced Standard Profile Kernel
    55 *
    6  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    7  *                              Toyohashi Univ. of Technology, JAPAN
    8  *  Copyright (C) 2003-2004 by Naoki Saito
    9  *             Nagoya Municipal Industrial Research Institute, JAPAN
    10  *  Copyright (C) 2003-2004 by Platform Development Center
    11  *                                          RICOH COMPANY,LTD. JAPAN
    12  *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    13  *  Copyright (C) 2013      by Mitsuhiro Matsuura
     6 *  Copyright (C) 2006-2018 by Embedded and Real-Time Systems Laboratory
     7 *              Graduate School of Information Science, Nagoya Univ., JAPAN
    148 *
    159 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4640
    4741/*
    48  *              シリアルI/Oデバイス(SIO)ドライバ(GR-CITRUS用)
     42 *              シリアルインタフェースドライバのターゲット依存部(GR-CITRUS用)
    4943 */
    5044
     
    5347
    5448#include "gr_citrus.h"
    55 #include "serial_api.h"
     49#include <t_stddef.h>
    5650
    57 #define SIO_RDY_SND 1
    58 #define SIO_RDY_RCV 2
     51/*
     52 *  SIOポート数の定義
     53 */
     54//#define TNUM_SIOP             1               /* サポートするSIOポートの数 */
     55
     56/*
     57 *  SIO割込みを登録するための定義
     58 */
     59#define ISRPRI_SIO              1               /* SIOの割込みサービスルーチンのISR優先度 */
    5960
    6061#ifndef TOPPERS_MACRO_ONLY
    6162
    62 typedef struct sio_port_control_block SIOPCB;
     63/*
     64 *  SIOポート管理ブロックの定義
     65 */
     66typedef struct sio_port_control_block   SIOPCB;
     67
     68/*
     69 *  コールバックルーチンの識別番号
     70 */
     71#define SIO_RDY_SND             1U              /* 送信可能コールバック */
     72#define SIO_RDY_RCV             2U              /* 受信通知コールバック */
    6373
    6474/*
     
    6878
    6979/*
    70  *  シリアルI/Oポートのオープン
     80 *  SIOドライバの終了処理
     81 */
     82extern void             sio_terminate(intptr_t exinf);
     83
     84/*
     85 *  SIOポートのオープン
    7186 */
    7287extern SIOPCB   *sio_opn_por(ID siopid, intptr_t exinf);
    7388
    7489/*
    75  *  シリアルI/Oポートのクローズ
     90 *  SIOポートのクローズ
    7691 */
    7792extern void             sio_cls_por(SIOPCB *p_siopcb);
    7893
    7994/*
    80  *  シリアルI/Oポートへの文字送信
     95 *  SIOの割込みサービスルーチン
     96 */
     97extern bool_t   sio_isr_snd(ID siopid);
     98
     99/*
     100 *  SIOの割込みサービスルーチン
     101 */
     102extern bool_t   sio_isr_rcv(ID siopid, char c);
     103
     104/*
     105 *  SIOポートへの文字送信
    81106 */
    82107extern bool_t   sio_snd_chr(SIOPCB *siopcb, char c);
    83108
    84109/*
    85  *  シリアルI/Oポートからの文字受信
     110 *  SIOポートからの文字受信
    86111 */
    87112extern int_t    sio_rcv_chr(SIOPCB *siopcb);
    88113
    89114/*
    90  *  シリアルI/Oポートからのコールバックの許可
     115 *  SIOポートからのコールバックの許可
    91116 */
    92117extern void             sio_ena_cbr(SIOPCB *siopcb, uint_t cbrtn);
    93118
    94119/*
    95  *  シリアルI/Oポートからのコールバックの禁止
     120 *  SIOポートからのコールバックの禁止
    96121 */
    97122extern void             sio_dis_cbr(SIOPCB *siopcb, uint_t cbrtn);
    98123
    99124/*
    100  *  シリアルI/Oポートからの送信可能コールバック
     125 *  SIOポートからの送信可能コールバック
    101126 */
    102127extern void             sio_irdy_snd(intptr_t exinf);
    103128
    104129/*
    105  *  シリアルI/Oポートからの受信通知コールバック
     130 *  SIOポートからの受信通知コールバック
    106131 */
    107132extern void             sio_irdy_rcv(intptr_t exinf);
    108133
    109 
    110134#endif /* TOPPERS_MACRO_ONLY */
    111135#endif /* TOPPERS_TARGET_SERIAL_H */
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_syssvc.h

    r374 r387  
    8080#define TARGET_NAME     "GR-CITRUS"
    8181
    82 
     82#ifdef TOPPERS_OMIT_TECS
    8383/*
    8484 *  システムログの低レベル出力のための文字出力
     
    8787 */
    8888extern void     target_fput_log( char c );
    89 
     89#endif
    9090
    9191/*
     
    9494 */
    9595#ifdef PRC_COPYRIGHT
    96 #define TARGET_COPYRIGHT        PRC_COPYRIGHT
     96#define TARGET_COPYRIGHT        PRC_COPYRIGHT
    9797#endif /* PRC_COPYRIGHT */
    9898
     
    101101 *  シリアルポート数の定義
    102102 */
    103 #define TNUM_PORT                       UINT_C( 2 )
     103#define TNUM_PORT                       UINT_C( 2 )
    104104
    105105/*
    106106 *  使用するシリアルポートID
    107107 */
    108 #define SIO_PORTID                      UINT_C( 1 )
     108#define SIO_PORTID                      UINT_C( 1 )
    109109
    110110#define LOGTASK_PORTID          SIO_PORTID
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_citrus_gcc/target_timer.c

    r364 r387  
    398398         */
    399399        if (probe_int(INTNO_TIMER1)) {
    400                 if (local_cnt < 0x8000)
     400                if(local_cnt < 0x8000)
    401401                        local_eut += 1;
    402402        }
    403403
    404404        time = (((HRTCNT)local_eut * CMCOR_PERIOD) + (HRTCNT)local_cnt) / USEC_CONVERT_VALUE;
    405 
     405#ifdef _MSC_VER
     406        // シミュレーションではタイマーが戻らないよう調整
     407        if (time < current_hrtcnt)
     408                time = current_hrtcnt + ((HRTCNT)local_cnt / USEC_CONVERT_VALUE);
     409#endif
    406410        return time;
    407411}
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/Makefile.target

    r374 r387  
    2525#  システムサービスに関する定義
    2626#
    27 SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed
    28 SYSSVC_COBJS := $(SYSSVC_COBJS)
     27SYSSVC_DIRS := $(SYSSVC_DIRS) $(SRCDIR)/mbed $(SRCDIR)/syssvc/tlsf
     28SYSSVC_COBJS := $(SYSSVC_COBJS) musl_adapter.o tlsf.o
    2929
    3030#
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target.cdl

    r337 r387  
    6060 *  ターゲット依存のセルタイプの定義
    6161 */
    62 import("tPutLogGRSakura.cdl");
     62import("syssvc/tPutLogSIOPort.cdl");
    6363import("tSIOPortGRSakura.cdl");
    6464
     
    7272 *  低レベル出力の組み上げ記述
    7373 */
    74 cell tPutLogGRSakura PutLogTarget {
     74cell tPutLogSIOPort PutLogTarget {
    7575        /* SIOドライバとの結合 */
    7676        cSIOPort = SIOPortTarget1.eSIOPort;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_kernel.cfg

    r337 r387  
    55 */
    66INCLUDE("target_timer.cfg")
     7INCLUDE("syssvc/musl_adapter.cfg")
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_kernel_impl.c

    r374 r387  
    5454#ifdef TOPPERS_OMIT_TECS
    5555#include "serial_api.h"
     56#include "target_syssvc.h"
    5657#endif
    5758
     
    8687         *  シリアルポートの設定
    8788         */
    88         serial_init(&log_serial, P20, P21);
     89        serial_init(&log_serial, STDIO_UART_TX, STDIO_UART_RX);
    8990        serial_baud(&log_serial, UART_BAUDRATE);
    9091        serial_format(&log_serial, 8, ParityNone, 1);
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_serial.c

    r374 r387  
    33 *      Toyohashi Open Platform for Embedded Real-Time Systems/
    44 *      Advanced Standard Profile Kernel
    5  *
    6  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    7  *                              Toyohashi Univ. of Technology, JAPAN
    8  *  Copyright (C) 2003-2004 by Naoki Saito
    9  *             Nagoya Municipal Industrial Research Institute, JAPAN
    10  *  Copyright (C) 2003-2004 by Platform Development Center
    11  *                                          RICOH COMPANY,LTD. JAPAN
    12  *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    13  *  Copyright (C) 2013      by Mitsuhiro Matsuura
    14  *
     5 *
     6 *  Copyright (C) 2006-2018 by Embedded and Real-Time Systems Laboratory
     7 *              Graduate School of Information Science, Nagoya Univ., JAPAN
     8 *
    159 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    1610 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    3529 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    3630 *      免責すること.
    37  *
     31 * 
    3832 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3933 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    4135 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    4236 *  の責任を負わない.
    43  *
     37 * 
    4438 *  @(#) $Id$
    4539 */
    4640
    4741/*
    48  *      RX630 UART用シリアルI/Oモジュール
    49  */
    50 #include "kernel_impl.h"
    51 #include <sil.h>
     42 *              シリアルインタフェースドライバのターゲット依存部(GR-SAKURA用)
     43 */
     44
     45#include "gr_sakura.h"
     46#include <t_stddef.h>
     47#include <t_syslog.h>
     48#include <errno.h>
     49#include <unistd.h>
     50#include <fcntl.h>
     51#include <termios.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ポート初期化ブロックの定義
     53#include "syssvc/siofd.h"
     54
     55/*
     56 *  SIOポート初期化ブロックの定義
    5957 */
    6058typedef struct sio_port_initialization_block {
    61         PinName tx;
    62         PinName rx;
     59        char            *path;                  /* ファイルのパス名 */
    6360} SIOPINIB;
    6461
    6562/*
    66  *  シリアルI/Oポート管理ブロックの定義
     63 *  SIOポート管理ブロックの定義
    6764 */
    6865struct sio_port_control_block {
    69         const SIOPINIB *p_siopinib;
    70         intptr_t exinf;
    71         bool_t openflag;
    72         serial_t serial;
     66        const SIOPINIB *p_siopinib;     /* SIOポート初期化ブロック */
     67        intptr_t        exinf;                  /* 拡張情報 */
     68        bool_t          opened;         /* オープン済みフラグ */
     69        struct termios saved_term;      /* 元の端末制御情報 */
     70
     71        int_t           read_fd;                /* 読出し用ファイルディスクリプタ */
     72        bool_t          rcv_flag;               /* 受信文字バッファ有効フラグ */
     73        char            rcv_buf;                /* 受信文字バッファ */
     74        bool_t          rcv_rdy;                /* 受信通知コールバック許可フラグ */
     75
     76        int_t           write_fd;               /* 書込み用ファイルディスクリプタ */
     77        bool_t          snd_flag;               /* 送信文字バッファ有効フラグ */
     78        char            snd_buf;                /* 送信文字バッファ */
     79        bool_t          snd_rdy;                /* 送信通知コールバック許可フラグ */
    7380};
    7481
    7582/*
    76  *  シリアルI/Oポート管理ブロックのエリア
    77  */
    78 SIOPCB siopcb_table[TNUM_PORT];
    79 
    80 static 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
     83 *  SIOポート初期化ブロック
     84 */
     85const SIOPINIB siopinib_table[TNUM_SIOP] = {
     86        { NULL }
    10187};
    10288
    10389/*
    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 
    110 static void mbed_serial_irq_handler(uint32_t id, SerialIrq event);
     90 *  SIOポート管理ブロックのエリア
     91 */
     92SIOPCB  siopcb_table[TNUM_SIOP];
     93
     94/*
     95 *  SIOポートIDから管理ブロックを取り出すためのマクロ
     96 */
     97#define INDEX_SIOP(siopid)      ((uint_t)((siopid) - 1))
     98#define get_siopcb(siopid)      (&(siopcb_table[INDEX_SIOP(siopid)]))
    11199
    112100/*
     
    120108
    121109        /*
    122          *  シリアルI/Oポート管理ブロックの初期化
     110         *  SIOポート管理ブロックの初期化
    123111         */
    124         for (p_siopcb = siopcb_table, i = 0; i < TNUM_SIOP; p_siopcb++, i++) {
     112        for (i = 0; i < TNUM_SIOP; i++) {
     113                p_siopcb = &(siopcb_table[i]);
    125114                p_siopcb->p_siopinib = &(siopinib_table[i]);
    126                 p_siopcb->openflag = false;
    127         }
    128 }
    129 
    130 /*
    131  *  シリアルI/Oポートのオープン
     115                p_siopcb->opened = false;
     116        }
     117}
     118
     119/*
     120 *  SIOドライバの終了処理
     121 */
     122void
     123sio_terminate(intptr_t exinf)
     124{
     125        uint_t  i;
     126
     127        /*
     128         *  オープンされているSIOポートのクローズ
     129         */
     130        for (i = 0; i < TNUM_SIOP; i++) {
     131                sio_cls_por(&(siopcb_table[i]));
     132        }
     133}
     134
     135/*
     136 *  SIOポートのオープン
    132137 */
    133138SIOPCB *
    134139sio_opn_por(ID siopid, intptr_t exinf)
    135140{
    136         SIOPCB  *p_siopcb = NULL;
    137         ER      ercd;
    138         serial_t *serial;
    139 
    140         if ((siopid <= 0) || (siopid > (sizeof(siopcb_table) / sizeof(siopcb_table[0]))))
    141                 return NULL;
     141        SIOPCB                  *p_siopcb;
     142        const SIOPINIB  *p_siopinib;
     143        int_t                   fd;
     144        struct termios  term;
     145
    142146        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;
    157 }
    158 
    159 /*
    160  *  シリアルI/Oポートのクローズ
     147        p_siopinib = p_siopcb->p_siopinib;
     148
     149        if (!(p_siopcb->opened)) {
     150                if (p_siopinib->path != NULL) {
     151                        fd = siofd_open(p_siopinib->path, O_RDWR, 0777);
     152                        assert(fd >= 0);
     153                        p_siopcb->read_fd = fd;
     154                        p_siopcb->write_fd = fd;
     155                }
     156                else {
     157                        fd = STDIN_FILENO;                                      /* 標準入出力を使う */
     158                        p_siopcb->read_fd = STDIN_FILENO;
     159                        p_siopcb->write_fd = STDOUT_FILENO;
     160                }
     161                siofd_fcntl(fd, F_SETOWN, getpid());
     162                siofd_fcntl(fd, F_SETFL, (O_NONBLOCK | O_ASYNC));
     163
     164                siofd_tcgetattr(fd, &(p_siopcb->saved_term));
     165                term = p_siopcb->saved_term;
     166                term.c_lflag &= ~(ECHO | ICANON);
     167                siofd_tcsetattr(fd, TCSAFLUSH, &term);
     168
     169                p_siopcb->exinf = exinf;
     170                p_siopcb->rcv_flag = false;
     171                p_siopcb->rcv_rdy = false;
     172                p_siopcb->snd_flag = false;
     173                p_siopcb->snd_rdy = false;
     174                p_siopcb->opened = true;
     175        }
     176        return(p_siopcb);
     177}
     178
     179/*
     180 *  SIOポートのクローズ
    161181 */
    162182void
    163183sio_cls_por(SIOPCB *p_siopcb)
    164184{
    165         ER        ercd;
    166         serial_t *serial = &p_siopcb->serial;
    167 
    168         /*
    169          *  デバイス依存のクローズ処理.
    170          */
    171         serial_free(serial);
    172         p_siopcb->openflag = false;
    173 }
    174 
    175 /*
    176  *  シリアルI/Oポートへの文字送信
     185        int_t   fd;
     186
     187        if (p_siopcb->opened) {
     188                fd = p_siopcb->read_fd;
     189                siofd_tcsetattr(fd, TCSAFLUSH, &(p_siopcb->saved_term));
     190                siofd_fcntl(fd, F_SETFL, 0);
     191
     192                if (p_siopcb->p_siopinib->path != NULL) {
     193                        siofd_close(p_siopcb->read_fd);
     194                }
     195
     196                p_siopcb->opened = false;
     197        }
     198}
     199
     200/*
     201 *  SIOの割込みサービスルーチン
     202 */
     203bool_t
     204sio_isr_snd(ID siopid)
     205{
     206        SIOPCB  *p_siopcb = get_siopcb(siopid);
     207        int_t   n;
     208
     209        if (p_siopcb->snd_flag) {
     210                if ((n = siofd_write(p_siopcb->write_fd, &(p_siopcb->snd_buf), 1)) > 0) {
     211                        p_siopcb->snd_flag = false;
     212                        if (p_siopcb->snd_rdy) {
     213                                sio_irdy_snd(p_siopcb->exinf);
     214                                return p_siopcb->snd_rdy;
     215                        }
     216                }
     217        }
     218
     219        return false;
     220}
     221
     222/*
     223 *  SIOの割込みサービスルーチン
     224 */
     225bool_t
     226sio_isr_rcv(ID siopid, char c)
     227{
     228        SIOPCB  *p_siopcb = get_siopcb(siopid);
     229
     230        if (!p_siopcb->rcv_flag) {
     231                p_siopcb->rcv_buf = c;
     232                p_siopcb->rcv_flag = true;
     233                if (p_siopcb->rcv_rdy) {
     234                        sio_irdy_rcv(p_siopcb->exinf);
     235                        return p_siopcb->rcv_rdy;
     236                }
     237        }
     238
     239        return false;
     240}
     241
     242/*
     243 *  SIOポートへの文字送信
    177244 */
    178245bool_t
    179246sio_snd_chr(SIOPCB *p_siopcb, char c)
    180247{
    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ポートからの文字受信
     248        int_t   n;
     249
     250        if (!p_siopcb->snd_flag) {
     251                if ((n = siofd_write(p_siopcb->write_fd, &c, 1)) > 0) {
     252                        return(true);
     253                }
     254                else {
     255                        assert(n < 0 && errno == EAGAIN);
     256                        p_siopcb->snd_flag = true;
     257                        p_siopcb->snd_buf = c;
     258                        return(true);
     259                }
     260        }
     261        else {
     262                return(false);
     263        }
     264}
     265
     266/*
     267 *  SIOポートからの文字受信
    190268 */
    191269int_t
    192270sio_rcv_chr(SIOPCB *p_siopcb)
    193271{
    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ポートからのコールバックの許可
     272        char    c;
     273        int_t   n;
     274
     275        if (p_siopcb->rcv_flag) {
     276                p_siopcb->rcv_flag = false;
     277                return((int_t)(uint8_t)(p_siopcb->rcv_buf));
     278        }
     279        else if ((n = siofd_read(p_siopcb->read_fd, &c, 1)) > 0) {
     280                return((int_t)(uint8_t) c);
     281        }
     282        else {
     283                assert(n < 0 && errno == EAGAIN);
     284                return(-1);
     285        }
     286}
     287
     288/*
     289 *  SIOポートからのコールバックの許可
    202290 */
    203291void
    204292sio_ena_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
    205293{
    206         serial_t *serial = &p_siopcb->serial;
    207294        switch (cbrtn) {
    208295        case SIO_RDY_SND:
    209                 serial_irq_set(serial, TxIrq, true);
     296                p_siopcb->snd_rdy = true;
    210297                break;
    211298        case SIO_RDY_RCV:
    212                 serial_irq_set(serial, RxIrq, true);
     299                p_siopcb->rcv_rdy = true;
    213300                break;
    214301        }
     
    216303
    217304/*
    218  *  シリアルI/Oポートからのコールバックの禁止
     305 *  SIOポートからのコールバックの禁止
    219306 */
    220307void
    221308sio_dis_cbr(SIOPCB *p_siopcb, uint_t cbrtn)
    222309{
    223         serial_t *serial = &p_siopcb->serial;
    224310        switch (cbrtn) {
    225311        case SIO_RDY_SND:
    226                 serial_irq_set(serial, TxIrq, false);
     312                p_siopcb->snd_rdy = false;
    227313                break;
    228314        case SIO_RDY_RCV:
    229                 serial_irq_set(serial, RxIrq, false);
     315                p_siopcb->rcv_rdy = false;
    230316                break;
    231317        }
    232318}
    233 
    234 /*
    235  *  シリアルI/Oポートからの送信可能コールバック
    236  */
    237 void
    238 serial_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  */
    247 void
    248 serial_irdy_rcv(SIOPCB  *p_siopcb)
    249 {
    250         /* 共通部(syssvc\serial.c)にあるsio_irdy_rcv関数を呼び出し*/
    251         sio_irdy_rcv(p_siopcb->exinf);
    252 }
    253 
    254 /*
    255  *  SIOの割込みハンドラ
    256  */
    257 void
    258 mbed_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

    r374 r387  
    44
    55#include <target_serial.h>
    6 
     6//INCLUDE("unix_sigio.cfg");
    77ATT_INI({ TA_NULL, 0, sio_initialize });
    8 
     8ATT_TER({ TA_NULL, 0, sio_terminate });
     9//CRE_ISR( ISR_SIO, { TA_NULL, 0, INTNO_SIGIO, sio_isr, ISRPRI_SIO });
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_serial.h

    r374 r387  
    44 *      Advanced Standard Profile Kernel
    55 *
    6  *  Copyright (C) 2000-2003 by Embedded and Real-Time Systems Laboratory
    7  *                              Toyohashi Univ. of Technology, JAPAN
    8  *  Copyright (C) 2003-2004 by Naoki Saito
    9  *             Nagoya Municipal Industrial Research Institute, JAPAN
    10  *  Copyright (C) 2003-2004 by Platform Development Center
    11  *                                          RICOH COMPANY,LTD. JAPAN
    12  *  Copyright (C) 2008-2010 by Witz Corporation, JAPAN
    13  *  Copyright (C) 2013      by Mitsuhiro Matsuura
     6 *  Copyright (C) 2006-2018 by Embedded and Real-Time Systems Laboratory
     7 *              Graduate School of Information Science, Nagoya Univ., JAPAN
    148 *
    159 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
     
    4640
    4741/*
    48  *              シリアルI/Oデバイス(SIO)ドライバ(GR-SAKURA用)
     42 *              シリアルインタフェースドライバのターゲット依存部(GR-SAKURA用)
    4943 */
    5044
     
    5347
    5448#include "gr_sakura.h"
    55 #include "serial_api.h"
     49#include <t_stddef.h>
    5650
    57 #define SIO_RDY_SND 1
    58 #define SIO_RDY_RCV 2
     51/*
     52 *  SIOポート数の定義
     53 */
     54//#define TNUM_SIOP             1               /* サポートするSIOポートの数 */
     55
     56/*
     57 *  SIO割込みを登録するための定義
     58 */
     59#define ISRPRI_SIO              1               /* SIOの割込みサービスルーチンのISR優先度 */
    5960
    6061#ifndef TOPPERS_MACRO_ONLY
    6162
    62 typedef struct sio_port_control_block SIOPCB;
     63/*
     64 *  SIOポート管理ブロックの定義
     65 */
     66typedef struct sio_port_control_block   SIOPCB;
     67
     68/*
     69 *  コールバックルーチンの識別番号
     70 */
     71#define SIO_RDY_SND             1U              /* 送信可能コールバック */
     72#define SIO_RDY_RCV             2U              /* 受信通知コールバック */
    6373
    6474/*
     
    6878
    6979/*
    70  *  シリアルI/Oポートのオープン
     80 *  SIOドライバの終了処理
     81 */
     82extern void             sio_terminate(intptr_t exinf);
     83
     84/*
     85 *  SIOポートのオープン
    7186 */
    7287extern SIOPCB   *sio_opn_por(ID siopid, intptr_t exinf);
    7388
    7489/*
    75  *  シリアルI/Oポートのクローズ
     90 *  SIOポートのクローズ
    7691 */
    7792extern void             sio_cls_por(SIOPCB *p_siopcb);
    7893
    7994/*
    80  *  シリアルI/Oポートへの文字送信
     95 *  SIOの割込みサービスルーチン
     96 */
     97extern bool_t   sio_isr_snd(ID siopid);
     98
     99/*
     100 *  SIOの割込みサービスルーチン
     101 */
     102extern bool_t   sio_isr_rcv(ID siopid, char c);
     103
     104/*
     105 *  SIOポートへの文字送信
    81106 */
    82107extern bool_t   sio_snd_chr(SIOPCB *siopcb, char c);
    83108
    84109/*
    85  *  シリアルI/Oポートからの文字受信
     110 *  SIOポートからの文字受信
    86111 */
    87112extern int_t    sio_rcv_chr(SIOPCB *siopcb);
    88113
    89114/*
    90  *  シリアルI/Oポートからのコールバックの許可
     115 *  SIOポートからのコールバックの許可
    91116 */
    92117extern void             sio_ena_cbr(SIOPCB *siopcb, uint_t cbrtn);
    93118
    94119/*
    95  *  シリアルI/Oポートからのコールバックの禁止
     120 *  SIOポートからのコールバックの禁止
    96121 */
    97122extern void             sio_dis_cbr(SIOPCB *siopcb, uint_t cbrtn);
    98123
    99124/*
    100  *  シリアルI/Oポートからの送信可能コールバック
     125 *  SIOポートからの送信可能コールバック
    101126 */
    102127extern void             sio_irdy_snd(intptr_t exinf);
    103128
    104129/*
    105  *  シリアルI/Oポートからの受信通知コールバック
     130 *  SIOポートからの受信通知コールバック
    106131 */
    107132extern void             sio_irdy_rcv(intptr_t exinf);
    108133
    109 
    110134#endif /* TOPPERS_MACRO_ONLY */
    111135#endif /* TOPPERS_TARGET_SERIAL_H */
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_syssvc.h

    r374 r387  
    8080#define TARGET_NAME     "GR-SAKURA"
    8181
    82 
     82#ifdef TOPPERS_OMIT_TECS
    8383/*
    8484 *  システムログの低レベル出力のための文字出力
     
    8787 */
    8888extern void     target_fput_log( char c );
    89 
     89#endif
    9090
    9191/*
     
    9494 */
    9595#ifdef PRC_COPYRIGHT
    96 #define TARGET_COPYRIGHT        PRC_COPYRIGHT
     96#define TARGET_COPYRIGHT        PRC_COPYRIGHT
    9797#endif /* PRC_COPYRIGHT */
    9898
     
    101101 *  シリアルポート数の定義
    102102 */
    103 #define TNUM_PORT                       UINT_C( 2 )
     103#define TNUM_PORT                       UINT_C( 2 )
    104104
    105105/*
    106106 *  使用するシリアルポートID
    107107 */
    108 #define SIO_PORTID                      UINT_C( 1 )
     108#define SIO_PORTID                      UINT_C( 1 )
    109109
    110110#define LOGTASK_PORTID          SIO_PORTID
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/target/gr_sakura_gcc/target_timer.c

    r364 r387  
    403403
    404404        time = (((HRTCNT)local_eut * CMCOR_PERIOD) + (HRTCNT)local_cnt) / USEC_CONVERT_VALUE;
    405 
     405#ifdef _MSC_VER
     406        // シミュレーションではタイマーが戻らないよう調整
     407        if (time < current_hrtcnt)
     408                time = current_hrtcnt + ((HRTCNT)local_cnt / USEC_CONVERT_VALUE);
     409#endif
    406410        return time;
    407411}
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.tab.rb

    r374 r387  
    277277                @@n_warning += 1
    278278                locale = @@current_locale[ @@generator_nest ]
    279                 Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     279                Console.puts "#{locale[0]}:#{locale[1]}: warning: #{msg}"
    280280        end
    281281
     
    284284                @@n_info += 1
    285285                locale = @@current_locale[ @@generator_nest ]
    286                 Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     286                Console.puts "#{locale[0]}:#{locale[1]}: info: #{msg}"
    287287        end
    288288
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tecsgen/tecslib/core/C_parser.y.rb

    r374 r387  
    10401040
    10411041                if locale then
    1042                         Console.puts "error: #{locale[0]}: line #{locale[1]} #{msg}"
     1042                        Console.puts "#{locale[0]}:#{locale[1]}: error: #{msg}"
    10431043                else
    10441044                        Console.puts "error: #{msg}"
     
    10501050                @@n_warning += 1
    10511051                locale = @@current_locale[ @@generator_nest ]
    1052                 Console.puts "warning: #{locale[0]}: line #{locale[1]} #{msg}"
     1052                Console.puts "#{locale[0]}:#{locale[1]}: warning: #{msg}"
    10531053        end
    10541054
     
    10571057                @@n_info += 1
    10581058                locale = @@current_locale[ @@generator_nest ]
    1059                 Console.puts "info: #{locale[0]}: line #{locale[1]} #{msg}"
     1059                Console.puts "#{locale[0]}:#{locale[1]}: info: #{msg}"
    10601060        end
    10611061
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/in_itron.h

    r364 r387  
    131131extern ER_UINT  udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
    132132extern ER_UINT  udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout);
     133extern ER       udp6_can_cep(ID cepid, FN fncd);
    133134
    134135/* 【拡張機能】 */
     
    139140extern ER       udp_cre_cep (ID cepid, T_UDP_CCEP *pk_ccep);
    140141
     142extern ER       udp6_del_cep(ID cepid);
     143extern ER       udp6_set_opt(ID cepid, int_t optname, void *optval, int_t optlen);
     144extern ER       udp6_get_opt(ID cepid, int_t optname, void *optval, int_t optlen);
    141145extern ER       udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep);
    142146
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/tcp_input.c

    r364 r387  
    521521
    522522                                /* 相手のアドレスをコピーする。*/
     523
     524#if defined(_IP6_CFG) && defined(_IP4_CFG)
     525
     526                                if (cep->flags & TCP_CEP_FLG_IPV4) {
     527                                        (*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     528                                        (*cep->p_dstaddr4).portno = cep->dstaddr.portno;
     529                                        }
     530                                else
     531                                        *cep->p_dstaddr = cep->dstaddr;
     532
     533#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     534
    523535                                *cep->p_dstaddr = cep->dstaddr;
     536
     537#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
    524538
    525539                                if (IS_PTR_DEFINED(cep->callback)) {
     
    847861
    848862                                /* 相手のアドレスをコピーする。*/
     863
     864#if defined(_IP6_CFG) && defined(_IP4_CFG)
     865
     866                                if (cep->flags & TCP_CEP_FLG_IPV4) {
     867                                        (*cep->p_dstaddr4).ipaddr = ntohl(cep->dstaddr.ipaddr.s6_addr32[3]);
     868                                        (*cep->p_dstaddr4).portno = cep->dstaddr.portno;
     869                                        }
     870                                else
     871                                        *cep->p_dstaddr = cep->dstaddr;
     872
     873#else   /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
     874
    849875                                *cep->p_dstaddr = cep->dstaddr;
     876
     877#endif  /* of #if defined(_IP6_CFG) && defined(_IP4_CFG) */
    850878
    851879                                if (IS_PTR_DEFINED(cep->callback)) {
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/tcpn_usrreq.c

    r337 r387  
    671671                cep->p_myaddr4    = p_myaddr;
    672672                cep->p_dstaddr    = NULL;
    673                 cep->p_myaddr     = NULL;
     673                cep->p_myaddr     = NADR;
    674674
    675675#else   /* of #if API_PROTO == API_PROTO_IPV4 */
    676676
    677677                cep->p_dstaddr4   = NULL;
    678                 cep->p_myaddr4    = NULL;
     678                cep->p_myaddr4    = NADR;
    679679                cep->p_dstaddr    = p_dstaddr;
    680680                cep->p_myaddr     = p_myaddr;
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/udp_output.c

    r337 r387  
    182182#if defined(_IP6_CFG) && TNUM_UDP6_CEPID > 0
    183183
    184                 for (ix = tmax_udp6_cepid; ix -- > 0; ) {
     184                for (ix = TNUM_UDP6_CEPID - 1; ix -- > 0; ) {
    185185
    186186                        if (udp6_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
     
    194194#if defined(_IP4_CFG) && TNUM_UDP4_CEPID > 0
    195195
    196                 for (ix = tmax_udp4_cepid; ix -- > 0; ) {
     196                for (ix = TNUM_UDP4_CEPID - 1; ix -- > 0; ) {
    197197
    198198                        if (udp4_cep[ix].flags & UDP_CEP_FLG_POST_OUTPUT) {
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/udp_subr.c

    r337 r387  
    146146#define UDP_FIND_CEP            udp6_find_cep
    147147#define UDP_NOTIFY              udp6_notify
    148 #define TMAX_UDP_CEPID          tmax_udp6_cepid
     148#define TMAX_UDP_CEPID          (TNUM_UDP6_CEPID - 1)
    149149#define UDP_CEP                 udp6_cep
    150150#define T_UDP_CEP               T_UDP6_CEP
     
    183183#define UDP_FIND_CEP            udp4_find_cep
    184184#define UDP_NOTIFY              udp4_notify
    185 #define TMAX_UDP_CEPID          tmax_udp4_cepid
     185#define TMAX_UDP_CEPID          (TNUM_UDP4_CEPID - 1)
    186186#define T_UDP_CEP               T_UDP4_CEP
    187187#define UDP_CEP                 udp4_cep
  • asp3_tinet_ecnl_rx/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c

    r364 r387  
    308308                else
    309309                        error = UDP_ALLOC_PORT(cep, pk_ccep->myaddr.portno);
    310                
    311                 if (error == E_OK) {
    312 
    313                         /* UDP 通信端点生成情報をコピーする。*/
    314                         cep->cepatr        = pk_ccep->cepatr;                   /* 通信端点属性               */
    315                         cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;            /* 自分のアドレス      */
    316                         cep->callback      = (void*)pk_ccep->callback;          /* コールバック               */
    317 
    318                         /* UDP 通信端点を生成済みにする。*/
    319                         cep->flags |= UDP_CEP_FLG_VALID;
    320                         }
    321                 }
     310
     311                        if (error == E_OK) {
     312                                /* UDP 通信端点生成情報をコピーする。*/
     313                                cep->cepatr        = pk_ccep->cepatr;                   /* 通信端点属性               */
     314                                cep->myaddr.ipaddr = pk_ccep->myaddr.ipaddr;            /* 自分のアドレス      */
     315                                cep->callback      = (void*)pk_ccep->callback;          /* コールバック               */
     316
     317                                /* UDP 通信端点を生成済みにする。*/
     318                                cep->flags |= UDP_CEP_FLG_VALID;
     319                                }
     320                        }
    322321
    323322        /* 通信端点のロックを解除する。*/
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/Debug/Makefile

    r374 r387  
    5858        LIBS = $(SRCDIR)/../musl-1.1.18/Debug/libmusl.a \
    5959                $(SRCDIR)/../btstack/Debug/libbtstack.a \
    60                 $(SRCDIR)/../usbhost/Debug/libusbhost.a
     60                $(SRCDIR)/../usbhost/Debug/libusbhost.a \
     61                $(SRCDIR)/../zlib-1.2.11/Debug/libzlib.a
    6162endif
    6263ifeq ($(SRCLANG),c++)
     
    185186CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
    186187
    187 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    188 APPL_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
     188APPLDIRS := $(APPLDIRS) ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
     189APPL_COBJS := $(APPL_COBJS) ntshell_main.o fdtable.o stdio_stub.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
    189190
    190191#
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/main.c

    r374 r387  
    5454#include "ffarch.h"
    5555#include "ff.h"
    56 #include "core/ntshell.h"
    57 #include "core/ntlibc.h"
    5856#include <stdio.h>
    5957#include "usrcmd.h"
    60 #include "util/ntopt.h"
    6158#include "gpio_api.h"
    6259#include "usb_hbth.h"
  • asp3_tinet_ecnl_rx/trunk/bnep_bridge/src/main.cdl

    r337 r387  
    2222 *  ターゲット依存部の取り込み
    2323 */
    24 import("target.cdl");
     24import("ntshell.cdl");
    2525
    2626/*
  • asp3_tinet_ecnl_rx/trunk/curl-7.57.0/lib/curl_config.h

    r364 r387  
    44/* Location of default ca bundle */
    55/* #undef CURL_CA_BUNDLE */
     6#define CURL_CA_BUNDLE "0:/certs/ca-bundle.crt"
    67
    78/* define "1" to use built in CA store of SSL library */
  • asp3_tinet_ecnl_rx/trunk/curl-7.57.0/lib/easy.c

    r337 r387  
    166166#endif
    167167
    168 #ifdef __c2__
    169 #define malloc musl_malloc
    170 #define free musl_free
    171 #define realloc musl_realloc
    172 #define calloc musl_calloc
    173 #endif
    174 
    175168#ifndef __SYMBIAN32__
    176169/*
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/include/bits/alltypes.h

    r374 r387  
    1 #if defined(_MSC_VER) || defined(__c2__)
    2 #define asctime musl_asctime
    3 #define calloc musl_calloc
    4 #define clock musl_clock
    5 #define close musl_close
    6 #define execvp musl_execvp
    7 #define exit musl_exit
    8 #define fclose musl_fclose
    9 #define fdopen musl_fdopen
    10 #define fflush musl_fflush
    11 #define fma _musl_fma
    12 #define fgetc musl_fgetc
    13 #define fopen musl_fopen
    14 #define fprintf musl_fprintf
    15 #define fputc musl_fputc
    16 #define free musl_free
    17 #define fwrite musl_fwrite
    18 #define getcwd musl_getcwd
    19 #define localtime musl_localtime
    20 #define lseek musl_lseek
    21 #define malloc musl_malloc
    22 #define memmove musl_memmove
    23 #define open musl_open
    24 #define perror musl_perror
    25 #define printf musl_printf
    26 #define read musl_read
    27 #define realloc musl_realloc
    28 #define strftime musl_strftime
    29 #define strnlen musl_strnlen
    30 #define strtoul musl_strtoul
    31 #define time musl_time
    32 #define tzset musl_tzset
    33 #define unlink musl_unlink
    34 #define strncmp musl_strncmp
    35 #define strtol musl_strtol
    36 #define strchr musl_strchr
    37 #endif
    381#ifdef _MSC_VER
    392#define __builtin_va_list char *
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/include/math.h

    r364 r387  
    1515#define NAN       __builtin_nanf("")
    1616#define INFINITY  __builtin_inff()
    17 #elif !defined(_MSC_VER)
     17#else
    1818#define NAN       (0.0f/0.0f)
    1919#define INFINITY  1e5000f
    20 #else
    21 #define _HUGE_ENUF  1e+300
    22 #define INFINITY   ((float)(_HUGE_ENUF * _HUGE_ENUF))
    23 #define NAN        ((float)(INFINITY * 0.0F))
    2420#endif
    2521
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/include/stddef.h

    r337 r387  
    1111#define __NEED_size_t
    1212#define __NEED_wchar_t
    13 #if __STDC_VERSION__ >= 201112L || __cplusplus >= 201103L
     13#if __STDC_VERSION__ >= 201112L || (defined(__cplusplus) && __cplusplus >= 201103L)
    1414#define __NEED_max_align_t
    1515#endif
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__lctrans.c

    r337 r387  
    88}
    99
    10 #ifndef __c2__
    1110weak_alias(dummy, __lctrans_impl);
    12 #endif
    1311
    1412const char *__lctrans(const char *msg, const struct __locale_map *lm)
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/__mo_lookup.c

    r337 r387  
    44static inline uint32_t swapc(uint32_t x, int c)
    55{
    6         return c ? x>>24 | x>>8&0xff00 | x<<8&0xff0000 | x<<24 : x;
     6        return c ? (x>>24) | (x>>8&0xff00) | (x<<8&0xff0000) | (x<<24) : x;
    77}
    88
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/iconv.c

    r337 r387  
    136136{
    137137        e &= 3;
    138         return s[e]+0U<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
     138        return (s[e]+0U)<<24 | s[e^1]<<16 | s[e^2]<<8 | s[e^3];
    139139}
    140140
     
    156156        unsigned x = c - 128 - map[-1];
    157157        x = legacy_chars[ map[x*5/4]>>2*x%8 |
    158                 map[x*5/4+1]<<8-2*x%8 & 1023 ];
     158                (map[x*5/4+1]<<(8-2*x%8) & 1023) ];
    159159        return x ? x : c;
    160160}
     
    348348                                c += (0xa1-0x81);
    349349                                d += 0xa1;
    350                                 if (c >= 93 || c>=0xc6-0x81 && d>0x52)
     350                                if (c >= 93 || (c>=0xc6-0x81 && d>0x52))
    351351                                        goto ilseq;
    352352                                if (d-'A'<26) d = d-'A';
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/locale/locale_map.c

    r337 r387  
    3636
    3737        if (!*val) {
    38                 (val = getenv("LC_ALL")) && *val ||
    39                 (val = getenv(envvars[cat])) && *val ||
    40                 (val = getenv("LANG")) && *val ||
     38                ((val = getenv("LC_ALL")) && *val) ||
     39                ((val = getenv(envvars[cat])) && *val) ||
     40                ((val = getenv("LANG")) && *val) ||
    4141                (val = "C.UTF-8");
    4242        }
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/malloc/memalign.c

    r337 r387  
    4646        footer = ((size_t *)end)[-2];
    4747
    48         ((size_t *)mem)[-1] = header&7 | new-mem;
    49         ((size_t *)new)[-2] = footer&7 | new-mem;
    50         ((size_t *)new)[-1] = header&7 | end-new;
    51         ((size_t *)end)[-2] = footer&7 | end-new;
     48        ((size_t *)mem)[-1] = (header&7) | new-mem;
     49        ((size_t *)new)[-2] = (footer&7) | new-mem;
     50        ((size_t *)new)[-1] = (header&7) | end-new;
     51        ((size_t *)end)[-2] = (footer&7) | end-new;
    5252
    5353        free(mem);
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/math/fma.c

    r337 r387  
    7070                if (d < 64) {
    7171                        zlo = nz.m<<d;
    72                         zhi = nz.m>>64-d;
     72                        zhi = nz.m>>(64-d);
    7373                } else {
    7474                        zlo = 0;
     
    7878                        if (d == 0) {
    7979                        } else if (d < 64) {
    80                                 rlo = rhi<<64-d | rlo>>d | !!(rlo<<64-d);
     80                                rlo = rhi<<(64-d) | rlo>>d | !!(rlo<<(64-d));
    8181                                rhi = rhi>>d;
    8282                        } else {
     
    9191                        zlo = nz.m;
    9292                } else if (d < 64) {
    93                         zlo = nz.m>>d | !!(nz.m<<64-d);
     93                        zlo = nz.m>>d | !!(nz.m<<(64-d));
    9494                } else {
    9595                        zlo = 1;
     
    123123                d = a_clz_64(rhi)-1;
    124124                /* note: d > 0 */
    125                 rhi = rhi<<d | rlo>>64-d | !!(rlo<<d);
     125                rhi = rhi<<d | rlo>>(64-d) | !!(rlo<<d);
    126126        } else if (rlo) {
    127127                d = a_clz_64(rlo)-1;
     
    174174                        /* only round once when scaled */
    175175                        d = 10;
    176                         i = ( rhi>>d | !!(rhi<<64-d) ) << d;
     176                        i = ( rhi>>d | !!(rhi<<(64-d)) ) << d;
    177177                        if (sign)
    178178                                i = -i;
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/network/lookup_name.c

    r337 r387  
    1111#include <pthread.h>
    1212#include <errno.h>
     13#include <resolv.h>
    1314#include "lookup.h"
    1415#include "stdio_impl.h"
     
    185186        if (dots >= conf.ndots || name[l-1]=='.') *search = 0;
    186187
     188        /* Strip final dot for canon, fail if multiple trailing dots. */
     189        if (name[l-1]=='.') l--;
     190        if (!l || name[l-1]=='.') return EAI_NONAME;
     191
    187192        /* This can never happen; the caller already checked length. */
    188193        if (l >= 256) return EAI_NONAME;
     
    311316        if (!cnt && !(flags & AI_NUMERICHOST)) {
    312317                cnt = name_from_hosts(buf, canon, name, family);
    313                 if (!cnt) cnt = name_from_dns_search(buf, canon, name, family);
     318                if (cnt<=0) cnt = name_from_dns_search(buf, canon, name, family);
    314319        }
    315320        if (cnt<=0) return cnt ? cnt : EAI_NONAME;
     
    352357         * So far the label/precedence table cannot be customized. */
    353358        for (i=0; i<cnt; i++) {
     359                int family = buf[i].family;
    354360                int key = 0;
    355                 struct sockaddr_in6 sa, da = {
     361                struct sockaddr_in6 sa6 = { 0 }, da6 = {
    356362                        .sin6_family = AF_INET6,
    357363                        .sin6_scope_id = buf[i].scopeid,
    358364                        .sin6_port = 65535
    359365                };
    360                 if (buf[i].family == AF_INET6) {
    361                         memcpy(da.sin6_addr.s6_addr, buf[i].addr, 16);
     366                struct sockaddr_in sa4 = { 0 }, da4 = {
     367                        .sin_family = AF_INET,
     368                        .sin_port = 65535
     369                };
     370                void *sa, *da;
     371                socklen_t salen, dalen;
     372                if (family == AF_INET6) {
     373                        memcpy(da6.sin6_addr.s6_addr, buf[i].addr, 16);
     374                        da = &da6; dalen = sizeof da6;
     375                        sa = &sa6; salen = sizeof sa6;
    362376                } else {
    363                         memcpy(da.sin6_addr.s6_addr,
     377                        memcpy(sa6.sin6_addr.s6_addr,
    364378                                "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
    365                         memcpy(da.sin6_addr.s6_addr+12, buf[i].addr, 4);
    366                 }
    367                 const struct policy *dpolicy = policyof(&da.sin6_addr);
    368                 int dscope = scopeof(&da.sin6_addr);
     379                        memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
     380                        memcpy(da6.sin6_addr.s6_addr,
     381                                "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12);
     382                        memcpy(da6.sin6_addr.s6_addr+12, buf[i].addr, 4);
     383                        memcpy(&da4.sin_addr, buf[i].addr, 4);
     384                        da = &da4; dalen = sizeof da4;
     385                        sa = &sa4; salen = sizeof sa4;
     386                }
     387                const struct policy *dpolicy = policyof(&da6.sin6_addr);
     388                int dscope = scopeof(&da6.sin6_addr);
    369389                int dlabel = dpolicy->label;
    370390                int dprec = dpolicy->prec;
    371391                int prefixlen = 0;
    372                 int fd = socket(AF_INET6, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
     392                int fd = socket(family, SOCK_DGRAM|SOCK_CLOEXEC, IPPROTO_UDP);
    373393                if (fd >= 0) {
    374                         if (!connect(fd, (void *)&da, sizeof da)) {
     394                        if (!connect(fd, da, dalen)) {
    375395                                key |= DAS_USABLE;
    376                                 if (!getsockname(fd, (void *)&sa,
    377                                     &(socklen_t){sizeof sa})) {
    378                                         if (dscope == scopeof(&sa.sin6_addr))
     396                                if (!getsockname(fd, sa, &salen)) {
     397                                        if (family == AF_INET) memcpy(
     398                                                sa6.sin6_addr.s6_addr+12,
     399                                                &sa4.sin_addr, 4);
     400                                        if (dscope == scopeof(&sa6.sin6_addr))
    379401                                                key |= DAS_MATCHINGSCOPE;
    380                                         if (dlabel == labelof(&sa.sin6_addr))
     402                                        if (dlabel == labelof(&sa6.sin6_addr))
    381403                                                key |= DAS_MATCHINGLABEL;
    382                                         prefixlen = prefixmatch(&sa.sin6_addr,
    383                                                 &da.sin6_addr);
     404                                        prefixlen = prefixmatch(&sa6.sin6_addr,
     405                                                &da6.sin6_addr);
    384406                                }
    385407                        }
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/process/vfork.c

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

    r374 r387  
    6161}
    6262
    63 #ifndef __c2__
    6463weak_alias(__sigaction, sigaction);
    65 #else
    66 int 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/stdio/__stdio_write.c

    r337 r387  
    3232                iov[0].iov_len -= cnt;
    3333        }
     34        return -1;
    3435}
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/stdlib/strtol.c

    r374 r387  
    5757}
    5858
    59 #if defined(_MSC_VER) || defined(__c2__)
    60 weak_alias(musl_strtol, __strtol_internal);
    61 weak_alias(musl_strtoul, __strtoul_internal);
    62 #else
    6359weak_alias(strtol, __strtol_internal);
    6460weak_alias(strtoul, __strtoul_internal);
    65 #endif
    6661weak_alias(strtoll, __strtoll_internal);
    6762weak_alias(strtoull, __strtoull_internal);
  • asp3_tinet_ecnl_rx/trunk/musl-1.1.18/src/string/memrchr.c

    r374 r387  
    1010}
    1111
    12 #ifndef __c2__
    1312weak_alias(__memrchr, memrchr);
    14 #else
    15 void *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

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

    r374 r387  
    8484        ret2 = get_tim(&now);
    8585        if (ret2 != E_OK){
    86                 printf("[ffarch] get_tim error: %s",
     86                syslog(LOG_NOTICE, "[ffarch] get_tim error: %s",
    8787                        itron_strerror(ret2));
    8888                return;
     
    9898                ret = tslp_tsk(timer);
    9999                if ((ret != E_OK) && (ret != E_TMOUT)) {
    100                         printf("[ffarch] tslp_tsk error: %s %d",
     100                        syslog(LOG_NOTICE, "[ffarch] tslp_tsk error: %s %d",
    101101                                itron_strerror(ret), timer);
    102102                        break;
     
    105105                ret2 = get_tim(&now);
    106106                if (ret2 != E_OK) {
    107                         printf("[ffarch] get_tim error: %s",
     107                        syslog(LOG_NOTICE, "[ffarch] get_tim error: %s",
    108108                                itron_strerror(ret2));
    109109                        break;
     
    150150#endif
    151151        if (romdisk_init()) {
    152                 printf("ROM disk (0:) OK!\n");
     152                syslog(LOG_NOTICE, "ROM disk (0:) OK!");
    153153        }
    154154        else {
    155                 printf("ROM disk (0:) NG!\n");
     155                syslog(LOG_NOTICE, "ROM disk (0:) NG!");
    156156        }
    157157}
     
    303303        case FFS_RETRY_WAIT:
    304304                if (ffarch_retry_count == 0) {
    305                         printf("SD card (1:) initialize tired...\n");
     305                        syslog(LOG_NOTICE, "SD card (1:) initialize tired...");
    306306
    307307                        ffarch_state = FFS_IDLE;
     
    315315                /* SDカードが入れられた場合 */
    316316                if (((mmc_rspi_prev_status & STA_NODISK) != 0) && ((mmc_rspi_status() & STA_NODISK) == 0)) {
    317                         printf("SD card initializing ...\n");
     317                        syslog(LOG_NOTICE, "SD card initializing ...");
    318318
    319319                        Sd.FatFs.fs_type = 0;
    320320                        if (SD_begin()) {
    321                                 printf("SD card (1:) OK!\n");
     321                                syslog(LOG_NOTICE, "SD card (1:) OK!");
    322322
    323323                                /* uploadディレクトリを作成しておく */
     
    329329                        }
    330330                        else {
    331                                 printf("SD card (1:) NG!\n");
     331                                syslog(LOG_NOTICE, "SD card (1:) NG!");
    332332                                ffarch_state = FFS_RETRY_WAIT;
    333333                                ffarch_timer = 1000 * 1000;
     
    336336                /* SDカードが抜かれた場合 */
    337337                else if (((mmc_rspi_prev_status & STA_NODISK) == 0) && ((mmc_rspi_status() & STA_NODISK) != 0)) {
    338                         printf("SD card unmount\n");
     338                        syslog(LOG_NOTICE, "SD card unmount");
    339339
    340340                        f_mount(&Sd.FatFs, "1:", 0);
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.c

    r337 r387  
    224224        handle->xi = xi;
    225225        handle->xo = xo;
    226         handle->outptr = 0;
    227         handle->len = 0;
    228226        handle->pos = 0;
    229227        handle->option = option;
     
    232230static void _putc(ntstdio_t *handle, char c)
    233231{
    234         if (handle->outptr) {
    235                 if ((handle->pos + 1) >= handle->len)
    236                         return;
    237                 handle->outptr[handle->pos] = (unsigned char)c;
    238                 handle->pos++;
    239                 return;
    240         }
    241 
    242232        if (handle->xo) {
    243233                handle->xo(handle, (unsigned char)c);
     
    291281}
    292282
     283struct put_buf_t {
     284        char *outptr;
     285        int len;
     286};
     287
     288static void put_buf(struct ntstdio_t *handle, unsigned char c)
     289{
     290        struct put_buf_t *put_buf = (struct put_buf_t *)handle->exinf;
     291        if ((handle->pos + 1) >= put_buf->len)
     292                return;
     293        put_buf->outptr[handle->pos] = (char)c;
     294        handle->pos++;
     295}
     296
    293297int ntstdio_snprintf(char *buf, int len, const char *fmt, ...)
    294298{
    295299        int result;
    296300        ntstdio_t handle;
     301        struct put_buf_t exinf;
    297302        va_list arp;
    298303        /* Switch destination for memory */
     304        handle.xo = put_buf;
    299305        handle.option = 0;
    300         handle.outptr = buf;
    301         handle.len = len;
    302306        handle.pos = 0;
     307        handle.exinf = &exinf;
     308        exinf.outptr = buf;
     309        exinf.len = len;
     310
    303311        va_start(arp, fmt);
    304312        result = xvprintf(&handle, fmt, arp);
     
    306314
    307315        /* Terminate output string with a \0 */
    308         handle.outptr[handle.pos] = '\0';
     316        buf[handle.pos] = '\0';
    309317        return result;
    310318}
  • asp3_tinet_ecnl_rx/trunk/ntshell/ntshell/util/ntstdio.h

    r374 r387  
    7474        NTSTDIO_XI xi;
    7575        NTSTDIO_XO xo;
    76         char *outptr;
    77         int len;
    7876        int pos;
    7977        unsigned int option;
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/fdtable.c

    r374 r387  
    4444#include "syssvc/syslog.h"
    4545#include "target_syssvc.h"
    46 #ifndef NTSHELL_NO_SOCKET
    47 #include <tinet_defs.h>
    48 #include <tinet_config.h>
    49 #include <net/net.h>
    50 #include <net/net_endian.h>
    51 #include <netinet/in.h>
    52 #include <netinet/in_itron.h>
    53 #include <tinet_nic_defs.h>
    54 #include <tinet_cfg.h>
    55 #include <netinet/in_var.h>
    56 #include <net/ethernet.h>
    57 #include <net/if6_var.h>
    58 #include <net/net.h>
    59 #include <net/if_var.h>
    60 #include <netinet/udp.h>
    61 #include <netinet/udp_var.h>
    62 #include <netinet/tcp.h>
    63 #include <netinet/tcp_var.h>
    64 #include <net/net_buf.h>
    65 #endif
    66 #include "ff.h"
    67 #include "socket_stub.h"
     46#include "fdtable.h"
    6847#include "kernel_cfg.h"
    6948#include <string.h>
     
    7150#include "hal/serial_api.h"
    7251
    73 static int stdio_close(struct SHELL_FILE *fp);
    74 static size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    75 static size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    76 static size_t stdin_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    77 static size_t stdout_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    78 static size_t stderr_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    79 static void stdio_delete(struct SHELL_FILE *fp);
    80 
    81 static int sio_close(struct SHELL_FILE *fp);
    82 static size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len);
    83 static size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len);
    84 static off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org);
    85 static int sio_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    86 static bool_t sio_readable(struct SHELL_FILE *fp);
    87 static void sio_delete(struct SHELL_FILE *fp);
    88 
    89 IO_TYPE IO_TYPE_STDIN = { stdio_close, stdin_read, stdio_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    90 IO_TYPE IO_TYPE_STDOUT = { stdio_close, stdio_read, stdout_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    91 IO_TYPE IO_TYPE_STDERR = { stdio_close, stdio_read, stderr_write, sio_seek, sio_ioctl, sio_readable, stdio_delete };
    92 IO_TYPE IO_TYPE_SIO = { sio_close, sio_read, sio_write, sio_seek, sio_ioctl, sio_readable, sio_delete };
    93 ntstdio_t ntstdio;
     52#ifdef _DEBUG
     53static const char THIS_FILE[] = __FILE__;
     54#endif
     55
     56extern IO_TYPE IO_TYPE_STDIN;
     57extern IO_TYPE IO_TYPE_STDOUT;
     58extern IO_TYPE IO_TYPE_STDERR;
    9459
    9560static 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 },
     61        { STDIN_FILENO, &IO_TYPE_STDIN, 0 },
     62        { STDOUT_FILENO, &IO_TYPE_STDOUT, 0 },
     63        { STDERR_FILENO, &IO_TYPE_STDERR, 0 },
    9964};
    10065#define fd_table_count (sizeof(fd_table) / sizeof(fd_table[0]))
    101 
    102 extern ntstdio_t ntstdio;
    103 serial_t stdio_uart;
    104 
    105 unsigned char ntstdio_xi(struct ntstdio_t *handle)
    106 {
    107         return serial_getc((serial_t *)handle->exinf);
    108 }
    109 
    110 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
    111 {
    112         serial_putc((serial_t *)handle->exinf, c);
    113 }
    114 
    115 void 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 
    127 int stdio_close(struct SHELL_FILE *fp)
    128 {
    129         return -EPERM;
    130 }
    131 
    132 size_t stdio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    133 {
    134         return -EPERM;
    135 }
    136 
    137 size_t stdio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    138 {
    139         return -EPERM;
    140 }
    141 
    142 size_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 
    154 size_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 
    162 size_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 
    170 void stdio_delete(struct SHELL_FILE *fp)
    171 {
    172 }
    173 
    174 int sio_close(struct SHELL_FILE *fp)
    175 {
    176         return -EPERM;
    177 }
    178 
    179 size_t sio_read(struct SHELL_FILE *fp, unsigned char *data, size_t len)
    180 {
    181         return -EPERM;
    182 }
    183 
    184 size_t sio_write(struct SHELL_FILE *fp, const unsigned char *data, size_t len)
    185 {
    186         return -EPERM;
    187 }
    188 
    189 off_t sio_seek(struct SHELL_FILE *fp, off_t ofs, int org)
    190 {
    191         return -EPERM;
    192 }
    193 
    194 int 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 
    210 bool_t sio_readable(struct SHELL_FILE *fp)
    211 {
    212         return fp->readevt_w != fp->readevt_r;
    213 }
    214 
    215 void 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 }
    22266
    22367struct SHELL_FILE *new_fp(IO_TYPE *type, int id, int writable)
     
    24791        if (ret < 0) {
    24892                syslog(LOG_ERROR, "sig_sem => %d", ret);
     93        }
     94
     95        if (fp != NULL) {
     96                FLGPTN flgptn = 0;
     97
     98                FD_SET(fp->fd, (fd_set *)&flgptn);
     99
     100                ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
     101                if (ret != E_OK) {
     102                        syslog(LOG_ERROR, "clr_flg => %d", ret);
     103                }
    249104        }
    250105
     
    442297}
    443298
    444 /* TODO:コールバック化したい */
    445 void stdio_update_evts()
    446 {
    447         int fd = STDIN_FILENO;
    448         struct SHELL_FILE *fp = &fd_table[fd];
    449         FLGPTN flgptn = 0;
    450 
    451         if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    452                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    453 
    454                 FD_SET(fd, (fd_set *)&flgptn);
    455         }
    456         if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    457                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    458 
    459                 FD_SET(fd, (fd_set *)&flgptn);
    460         }
    461 
    462         if (flgptn != 0) {
    463                 set_flg(FLG_SELECT_WAIT, flgptn);
    464         }
    465 }
    466 
    467 /* TODO:コールバック化したい */
    468 void stdio_flgptn(FLGPTN *flgptn)
    469 {
    470         int fd = STDIN_FILENO;
    471         struct SHELL_FILE *fp = &fd_table[fd];
    472         *flgptn = 0;
    473 
    474         if (serial_readable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    475                 if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    476 
    477                 FD_SET(fd, (fd_set *)flgptn);
    478         }
    479         if (serial_writable((serial_t *)((struct ntstdio_t *)fp->exinf)->exinf)) {
    480                 if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_w++;
    481 
    482                 FD_SET(fd, (fd_set *)flgptn);
    483         }
    484 }
    485 
    486299ER shell_get_evts(struct fd_events *evts, TMO tmout)
    487300{
    488301        int count = 0;
    489302        SYSTIM prev, now;
     303        FLGPTN flgptn;
    490304
    491305        get_tim(&prev);
     
    493307        for (;;) {
    494308                ER ret;
    495                 FLGPTN waitptn, flgptn, readfds = 0, writefds = 0;
     309                FLGPTN waitptn, readfds = 0, writefds = 0;
    496310                struct SHELL_FILE *fp = NULL;
    497 
    498                 stdio_update_evts();
    499311
    500312#ifndef NTSHELL_NO_SOCKET
     
    506318                        fp = &fd_table[fd];
    507319
    508 #ifndef NTSHELL_NO_SOCKET
    509320                        if (FD_ISSET(fd, &evts->readfds)) {
    510321                                if (fp->type->readable(fp)) {
     
    517328                                }
    518329                        }
    519 #endif
     330
    520331                        if (FD_ISSET(fd, &evts->writefds)) {
    521                                 if (fp->writeevt_w == fp->writeevt_r) {
     332                                if (fp->type->writable(fp)) {
    522333                                        FD_SET(fd, (fd_set *)&writefds);
    523334                                        count++;
     
    549360                                return ret;
    550361                        }
    551 
    552                         stdio_flgptn(&flgptn);
    553 
    554                         if (flgptn == 0)
    555                                 return E_TMOUT;
    556                 }
    557                 flgptn &= waitptn;
    558 
    559                 /* 受け取ったフラグのみクリア */
    560                 ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
    561                 if (ret != E_OK) {
    562                         syslog(LOG_ERROR, "clr_flg => %d", ret);
     362                }
     363
     364                if (flgptn != 0) {
     365                        flgptn &= waitptn;
     366
     367                        /* 受け取ったフラグのみクリア */
     368                        ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
     369                        if (ret != E_OK) {
     370                                syslog(LOG_ERROR, "clr_flg => %d", ret);
     371                        }
    563372                }
    564373
    565374                count = 0;
    566375                for (int fd = 0; fd < fd_table_count; fd++) {
    567                         if (!FD_ISSET(fd, (fd_set *)&waitptn))
    568                                 continue;
    569 
    570376                        fp = &fd_table[fd];
    571377
    572378                        if (fp->readevt_w != fp->readevt_r) {
    573379                                fp->readevt_r++;
    574                                 FD_SET(fd, &evts->readfds);
     380                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     381                                        FD_SET(fd, &evts->readfds);
    575382                                count++;
    576383                        }
    577384                        if (fp->writeevt_w != fp->writeevt_r) {
    578385                                fp->writeevt_r++;
    579                                 fp->writable = 1;
    580                         }
    581                         if (fp->writable) {
    582                                 FD_SET(fd, &evts->writefds);
     386                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     387                                        FD_SET(fd, &evts->writefds);
    583388                                count++;
    584389                        }
    585390                        if (fp->errorevt_w != fp->errorevt_r) {
    586391                                fp->errorevt_r++;
    587                                 FD_SET(fd, &evts->errorfds);
     392                                if (FD_ISSET(fd, (fd_set *)&waitptn))
     393                                        FD_SET(fd, &evts->errorfds);
    588394                                count++;
    589395                        }
    590396                }
    591397
    592                 if (count > 0)
     398                if ((flgptn == 0) || (count > 0))
    593399                        break;
    594400
     
    596402
    597403                SYSTIM elapse = now - prev;
    598                 if (elapse > tmout)
    599                         return E_TMOUT;
     404                if (elapse > tmout) {
     405                        flgptn = 0;
     406                        break;
     407                }
    600408
    601409                prev = now;
     
    605413        evts->count = count;
    606414
    607         return E_OK;
     415        return (flgptn == 0) ? E_TMOUT : E_OK;
    608416}
    609417
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/fdtable.h

    r386 r387  
    3838#define SOCKET_STUB_H
    3939
    40 struct addrinfo {
    41         int ai_flags;
    42         int ai_family;
    43         int ai_socktype;
    44         int ai_protocol;
    45         socklen_t ai_addrlen;
    46         struct sockaddr *ai_addr;
    47         char *ai_canonname;
    48         struct addrinfo *ai_next;
    49 };
    50 
    51 typedef uint16_t in_port_t;
    52 typedef uint32_t in_addr_t;
    53 struct in_addr { in_addr_t s_addr; };
    54 
    55 struct sockaddr_in {
    56         sa_family_t sin_family;
    57         in_port_t sin_port;
    58         struct in_addr sin_addr;
    59         uint8_t sin_zero[8];
    60 };
    61 
    62 struct in6_addr
    63 {
    64         union {
    65                 uint8_t __s6_addr[16];
    66                 uint16_t __s6_addr16[8];
    67                 uint32_t __s6_addr32[4];
    68         } __in6_union;
    69 };
    70 //#define s6_addr __in6_union.__s6_addr
    71 //#define s6_addr16 __in6_union.__s6_addr16
    72 //#define s6_addr32 __in6_union.__s6_addr32
    73 
    74 struct sockaddr_in6
    75 {
    76         sa_family_t     sin6_family;
    77         in_port_t       sin6_port;
    78         uint32_t        sin6_flowinfo;
    79         struct in6_addr sin6_addr;
    80         uint32_t        sin6_scope_id;
    81 };
    82 
    83 typedef struct socket_t {
    84         int family;
    85         int type;
    86         int protocol;
    87         int cepid;
    88         int repid;
    89         int backlog;
    90         unsigned int flags;
    91         union {
    92                 struct sockaddr_in laddr4;
    93                 struct sockaddr_in6 laddr6;
    94         };
    95         union {
    96                 struct sockaddr_in raddr4;
    97                 struct sockaddr_in6 raddr6;
    98         };
    99         int buf_size;
    100         unsigned char *buf;
    101         void *input;
    102         int len;
    103 } socket_t;
    104 
    105 struct SHELL_DIR {
    106         FATFS_DIR dir;
    107         struct dirent dirent;
    108 };
    109 
    11040typedef const struct io_type_s IO_TYPE;
    11141
     
    13161        int (*ioctl)(struct SHELL_FILE *, int, void *);
    13262        bool_t (*readable)(struct SHELL_FILE *);
     63        bool_t (*writable)(struct SHELL_FILE *);
    13364        void (*delete)(struct SHELL_FILE *);
    13465};
     
    15283void clean_fd();
    15384
    154 void sys_tlsf_init(void);
    155 
    15685#endif // !SOCKET_STUB_H
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/io_stub.c

    r374 r387  
    4545#include "syssvc/serial.h"
    4646#include "syssvc/syslog.h"
    47 #include "socket_stub.h"
     47#include "fdtable.h"
    4848#include "util/ntstdio.h"
    4949#include "usrcmd.h"
     
    5151#include "kernel_cfg.h"
    5252#include "target_syssvc.h"
     53
     54struct SHELL_DIR {
     55        FATFS_DIR dir;
     56        struct dirent dirent;
     57};
    5358
    5459int fresult2errno(FRESULT res)
     
    8590static int file_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    8691static bool_t file_readable(struct SHELL_FILE *fp);
     92static bool_t file_writable(struct SHELL_FILE *fp);
    8793static void file_delete(struct SHELL_FILE *fp);
    8894
     
    9399static int dir_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    94100static bool_t dir_readable(struct SHELL_FILE *fp);
     101static bool_t dir_writable(struct SHELL_FILE *fp);
    95102static void dir_delete(struct SHELL_FILE *fp);
    96103
    97 IO_TYPE IO_TYPE_FILE = { file_close, file_read, file_write, file_seek, file_ioctl, file_readable, file_delete };
    98 IO_TYPE IO_TYPE_DIR = { dir_close, dir_read, dir_write, dir_seek, dir_ioctl, dir_readable, dir_delete };
     104IO_TYPE IO_TYPE_FILE = { file_close, file_read, file_write, file_seek, file_ioctl, file_readable, file_writable, file_delete };
     105IO_TYPE IO_TYPE_DIR = { dir_close, dir_read, dir_write, dir_seek, dir_ioctl, dir_readable, dir_writable, dir_delete };
    99106
    100107int shell_open(const char *path, int flags, void *arg)
     
    114121                FRESULT res;
    115122                if ((res = f_opendir(dir, path)) != FR_OK) {
     123                        delete_fp(fp);
    116124                        return fresult2errno(res);
    117125                }
     
    165173        }
    166174
     175        delete_fp(fp);
    167176        return fresult2errno(res);
    168177}
     
    239248}
    240249
     250bool_t file_writable(struct SHELL_FILE *fp)
     251{
     252        return fp->writable && (fp->writeevt_w == fp->writeevt_r);
     253}
     254
    241255void file_delete(struct SHELL_FILE *fp)
    242256{
     
    356370{
    357371        return shell_ioctl(fd, cmd, arg);
    358 }
    359 
    360 extern IO_TYPE IO_TYPE_SIO;
    361 
    362 int sio_tcgetattr(int fd, struct termios *termios)
    363 {
    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 
    400 int 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;
    411                 }
    412                 else {
    413                         ntstdio->option &= ~NTSTDIO_OPTION_LINE_ECHO;
    414                 }
    415                 if (termios->c_lflag & ICANON) {
    416                         ntstdio->option |= NTSTDIO_OPTION_CANON;
    417                 }
    418                 else {
    419                         ntstdio->option &= ~NTSTDIO_OPTION_CANON;
    420                 }
    421                 if (termios->c_iflag & INLCR) {
    422                         ntstdio->option |= NTSTDIO_OPTION_LF_CR;
    423                 }
    424                 else {
    425                         ntstdio->option &= ~NTSTDIO_OPTION_LF_CR;
    426                 }
    427                 if (termios->c_oflag & ONLCR) {
    428                         ntstdio->option |= NTSTDIO_OPTION_LF_CRLF;
    429                 }
    430                 else {
    431                         ntstdio->option &= ~NTSTDIO_OPTION_LF_CRLF;
    432                 }
    433                 return 0;
    434         }
    435 
    436         shell_abort();
    437         return 0;
    438372}
    439373
     
    688622}
    689623
     624bool_t dir_writable(struct SHELL_FILE *fp)
     625{
     626        return false;
     627}
     628
    690629void dir_delete(struct SHELL_FILE *fp)
    691630{
     
    710649        return 0;
    711650}
    712 
    713 #ifndef _MSC_VER
    714 extern uint32_t _HeapBase;
    715 extern uint32_t _HeapLimit;
    716 #else
    717 uint8_t _HeapBase[14 * 4096];
    718 #define _HeapLimit _HeapBase[sizeof(_HeapBase)]
    719 #endif
    720 
    721 void *shell_brk(void *addr)
    722 {
    723         if (addr == 0) {
    724                 return (void *)(&_HeapBase);
    725         }
    726         if ((addr >= (void *)&_HeapBase) && (addr < (void *)&_HeapLimit)) {
    727                 return addr;
    728         }
    729         return (void *)-1;
    730 }
    731 
    732 void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset)
    733 {
    734         if (fd != -1)
    735                 return (void *)-EINVAL;
    736 
    737         if ((length >= 0) && (length <= sizeof(&_HeapBase))) {
    738                 return &_HeapBase;
    739         }
    740         return (void *)-1;
    741 }
    742 
    743 int shell_mprotect(void *addr, size_t len, int prot)
    744 {
    745         //if ((addr >= (void *)&_HeapBase) && (addr + len < (void *)&_HeapLimit)) {
    746         return 0;
    747 //}
    748 //return -1;
    749 }
    750 
    751 #include "tlsf.h"
    752 
    753 static tlsf_t sys_tlsf;
    754 static pool_t sys_pool;
    755 
    756 void sys_tlsf_init(void)
    757 {
    758         sys_tlsf = tlsf_create(&_HeapBase);
    759         if (sys_tlsf == NULL)
    760                 return;
    761 
    762         sys_pool = tlsf_add_pool(sys_tlsf, ((uint8_t *)&_HeapBase) + tlsf_size(), ((intptr_t)&_HeapLimit - (intptr_t)&_HeapBase) - tlsf_size());
    763 }
    764 
    765 void sys_fini(void)
    766 {
    767         tlsf_destroy(sys_tlsf);
    768 }
    769 
    770 void *malloc(size_t size)
    771 {
    772         void *result;
    773         wai_sem(SEM_MALLOC);
    774         result = tlsf_malloc(sys_tlsf, size);
    775         sig_sem(SEM_MALLOC);
    776         if (result == NULL)
    777                 tlsf_check_pool(sys_pool);
    778         return result;
    779 }
    780 
    781 void *calloc(size_t size, size_t count)
    782 {
    783         void *result;
    784         wai_sem(SEM_MALLOC);
    785         result = tlsf_malloc(sys_tlsf, count * size);
    786         sig_sem(SEM_MALLOC);
    787         if (result != NULL)
    788                 memset(result, 0, count * size);
    789         else
    790                 tlsf_check_pool(sys_pool);
    791         return result;
    792 }
    793 
    794 void *realloc(void *ptr, size_t size)
    795 {
    796         void *result;
    797         wai_sem(SEM_MALLOC);
    798         result = tlsf_realloc(sys_tlsf, ptr, size);
    799         sig_sem(SEM_MALLOC);
    800         if (result == NULL)
    801                 tlsf_check_pool(sys_pool);
    802         return result;
    803 }
    804 
    805 void free(void *ptr)
    806 {
    807         wai_sem(SEM_MALLOC);
    808         tlsf_free(sys_tlsf, ptr);
    809         sig_sem(SEM_MALLOC);
    810 }
    811 
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/net_misc.c

    r374 r387  
    9595
    9696        get_tid(&nc->tskid);
    97         printf("[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
     97        syslog(LOG_NOTICE, "[NET MISC:%d,%d] started.", nc->tskid, (ID)exinf);
    9898
    9999        /* 初期化 */
     
    103103        ret = get_tim(&time);
    104104        if (ret != E_OK) {
    105                 printf("[NET MISC,%d] get_tim error: %7lu,%s",
     105                syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %7lu,%s",
    106106                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    107107                return;
     
    117117                error = tslp_tsk(timer);
    118118                if ((error != E_OK) && (error != E_TMOUT)) {
    119                         printf("[NET MISC,%d] tslp_tsk error: %s %d",
     119                        syslog(LOG_NOTICE, "[NET MISC,%d] tslp_tsk error: %s %d",
    120120                                nc->cepid, itron_strerror(error), timer);
    121121                        break;
     
    124124                ret = get_tim(&time);
    125125                if (ret != E_OK) {
    126                         printf("[NET MISC,%d] get_tim error: %s",
     126                        syslog(LOG_NOTICE, "[NET MISC,%d] get_tim error: %s",
    127127                                nc->cepid, itron_strerror(ret));
    128128                        break;
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntp_cli.c

    r374 r387  
    277277        }
    278278
    279         printf("[NTP CLI,%d] recv time: %s .%09u\n",
     279        syslog(LOG_NOTICE, "[NTP CLI,%d] recv time: %s .%09u",
    280280                nc->cepid, nc->buf, tp.tv_nsec);
    281281}
     
    309309                line = lookup_ipaddr(&nc->ipaddr6, NTP_SRV_URL, API_PROTO_IPV4);
    310310                if (line == NULL || !in6_is_addr_ipv4mapped(&nc->ipaddr6)) {
    311                         printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     311                        syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    312312                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    313313                        nc->timer = SLP_ITV;
     
    317317#else   /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
    318318                if ((line = lookup_ipaddr(&nc->snd_rmt.ipaddr, NTP_SRV_URL, DEFAULT_API_PROTO)) == NULL) {
    319                         printf("[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
     319                        syslog(LOG_NOTICE, "[NTP CLI,%d] sleep %d.%03u[s], unknown host.",
    320320                                nc->cepid, SLP_ITV / SYSTIM_HZ, SLP_ITV % SYSTIM_HZ);
    321321                        nc->timer = SLP_ITV;
     
    421421
    422422        if ((error = udp_snd_dat(nc->cepid, &nc->snd_rmt, ntp, len, TMO_NBLK)) != E_WBLK) {
    423                 printf("[NTP CLI,%d] udp_snd_dat error: %s",
     423                syslog(LOG_NOTICE, "[NTP CLI,%d] udp_snd_dat error: %s",
    424424                        nc->cepid, itron_strerror(error));
    425425                return error;
    426426        }
    427427        else
    428                 syslog(LOG_DEBUG, "[NTP CLI,%d] udp_snd_dat: to: %s.%d\n",
     428                syslog(LOG_DEBUG, "[NTP CLI,%d] udp_snd_dat: to: %s.%d",
    429429                        nc->cepid, ip2str(NULL, &nc->snd_rmt.ipaddr), nc->snd_rmt.portno);
    430430
     
    439439        ret = get_tim(&time);
    440440        if (ret != E_OK) {
    441                 printf("[NTP CLI,%d] get_tim error: %s",
     441                syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",
    442442                        nc->cepid, itron_strerror(ret));
    443443                tp->tv_sec = 0;
     
    459459        ret = set_tim(time);
    460460        if (ret != E_OK) {
    461                 printf("[NTP CLI,%d] set_tim error: %s",
     461                syslog(LOG_NOTICE, "[NTP CLI,%d] set_tim error: %s",
    462462                        nc->cepid, itron_strerror(ret));
    463463        }
     
    477477        if (len < 0 && len != E_RLWAI) {
    478478                /* E_RLWAI 以外で、0 以下の場合は、エラーを意味している。*/
    479                 printf("[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
     479                syslog(LOG_NOTICE, "[NTP CLI,%d] callback error: %s, fncd: %s", nc->cepid,
    480480                        itron_strerror(len), in_strtfn(fncd));
    481481        }
     
    484484                        if ((len = udp_rcv_dat(nc->cepid, &nc->rcv_rmt, &nc->ntp_msg, len, TMO_POL)) < 0)
    485485                        {
    486                                 printf("[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
     486                                syslog(LOG_NOTICE, "[NTP CLI,%d] udp_rcv_dat error: %s", nc->cepid,
    487487                                        itron_strerror(len));
    488488                        }
     
    516516
    517517        get_tid(&nc->tskid);
    518         printf("[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
     518        syslog(LOG_NOTICE, "[NTP CLI:%d,%d] started.", nc->tskid, (ID)exinf);
    519519
    520520        /* 初期化 */
     
    523523        ret = get_tim(&time);
    524524        if (ret != E_OK) {
    525                 printf("[NTP CLI,%d] get_tim error: %7lu,%s",
     525                syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %7lu,%s",
    526526                        nc->cepid, time / SYSTIM_HZ, itron_strerror(ret));
    527527                return;
     
    537537                error = tslp_tsk(timer);
    538538                if ((error != E_OK) && (error != E_TMOUT)) {
    539                         printf("[NTP CLI,%d] tslp_tsk error: %s %d",
     539                        syslog(LOG_NOTICE, "[NTP CLI,%d] tslp_tsk error: %s %d",
    540540                                nc->cepid, itron_strerror(error), timer);
    541541                        break;
     
    544544                ret = get_tim(&time);
    545545                if (ret != E_OK) {
    546                         printf("[NTP CLI,%d] get_tim error: %s",
     546                        syslog(LOG_NOTICE, "[NTP CLI,%d] get_tim error: %s",
    547547                                nc->cepid, itron_strerror(ret));
    548548                        break;
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntshell_main.c

    r374 r387  
    4949#include "syssvc/syslog.h"
    5050#include "target_syssvc.h"
     51#include "target_serial.h"
    5152#include "kernel_cfg.h"
    5253#include "ffarch.h"
     
    5859#include "util/ntopt.h"
    5960#include "ntshell_main.h"
    60 #include "socket_stub.h"
     61#include "fdtable.h"
    6162
    6263char command[NTOPT_TEXT_MAXLEN];
     
    7879}
    7980
     81void stdio_open(ID portid);
    8082static int usrcmd_ntopt_callback(long *args, void *extobj);
    8183
     
    8688void ntshell_task_init(ID portid)
    8789{
    88         serial_ctl_por(portid, IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV);
     90        stdio_open(portid);
    8991}
    9092
     
    9597{
    9698        ntshell_state = 1;
    97         ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
     99
     100        if (setjmp(process_exit) == 0) {
     101                ntshell_exit_code = ntopt_parse(command, usrcmd_ntopt_callback, NULL);
     102        }
     103
     104        fflush(stdout);
     105        clean_fd();
     106
    98107        ntshell_state = 2;
    99108}
     
    139148                printf("Unknown command found.\n");
    140149
    141         clean_fd();
    142 
    143150        return result;
    144151}
     
    285292}
    286293
    287 struct sigaction sigtable[7];
    288 
    289 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
    290 {
    291         struct sigaction *sat;
     294// musl-1.1.18\src\internal\ksigaction.h
     295struct k_sigaction {
     296        void(*handler)(int);
     297        unsigned long flags;
     298        void(*restorer)(void);
     299        unsigned mask[2];
     300};
     301
     302struct k_sigaction sigtable[7];
     303
     304int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
     305        struct k_sigaction *__restrict old, size_t size)
     306{
     307        struct k_sigaction *sat;
    292308
    293309        switch(sig){
     
    318334
    319335        if (old != NULL)
    320                 memcpy(old, sat, sizeof(struct sigaction));
    321 
    322         memcpy(sat, sa, sizeof(struct sigaction));
     336                memcpy(old, sat, offsetof(struct k_sigaction, mask) + size);
     337
     338        memcpy(sat, sa, offsetof(struct k_sigaction, mask) + size);
    323339
    324340        return 0;
     
    368384}
    369385
     386int shell_nanosleep(const struct timespec *req, struct timespec *rem)
     387{
     388        ER ret;
     389        TMO tmo;
     390        SYSTIM prev, now, diff;
     391
     392        if ((req == NULL) || (req->tv_nsec < 0) || (req->tv_nsec >= 1000000000))
     393                return -EINVAL;
     394
     395        get_tim(&prev);
     396
     397        tmo = req->tv_sec * 1000000 + req->tv_nsec / 1000;
     398        ret = tslp_tsk(tmo);
     399        if (ret == E_OK) {
     400                if (rem != NULL) {
     401                        get_tim(&now);
     402                        diff = now - prev;
     403                        rem->tv_sec = diff / 1000000ll;
     404                        rem->tv_nsec = (diff - (rem->tv_sec * 1000000ll)) * 1000ll;
     405                }
     406                return 0;
     407        }
     408        else if (ret == E_TMOUT) {
     409                if (rem != NULL) {
     410                        rem->tv_sec = 0;
     411                        rem->tv_nsec = 0;
     412                }
     413                return 0;
     414        }
     415
     416        return -EFAULT;
     417}
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/ntshell_main.cfg

    r374 r387  
    4646CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 });
    4747CRE_SEM(SEM_FILEDESC, { TA_TPRI, 1, 1 });
    48 CRE_SEM(SEM_MALLOC, { TA_TPRI, 1, 1 });
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/shellif.h

    r374 r387  
    7474#define NCCS 32
    7575
    76 #include <bits/fcntl.h>
    77 #include <bits/termios.h>
    78 #include <bits/stat.h>
     76#include <fcntl.h>
     77#include <termios.h>
     78#include <sys/stat.h>
    7979#include <sys/select.h>
    8080#include <time.h>
     
    8585#include <sys/utsname.h>
    8686#include <dirent.h>
    87 #include <bits/ioctl.h>
    88 #include <bits/errno.h>
     87#include <sys/ioctl.h>
     88#include <errno.h>
    8989#include <sys/socket.h>
    9090#else
     
    132132// time.h
    133133#define CLOCK_REALTIME 0
     134int shell_nanosleep(const struct timespec *req, struct timespec *rem);
    134135
    135136// dirent.h
     
    177178// signal.h
    178179int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
    179 int shell_sigaction(int sig, const struct sigaction *__restrict sa, struct sigaction *__restrict old);
     180struct k_sigaction;
     181int shell_sigaction(int sig, const struct k_sigaction *__restrict sa,
     182        struct k_sigaction *__restrict old, size_t size);
    180183// socket.h
    181184int shell_socket(int, int, int);
     
    197200// syslog.h
    198201void vsyslog (int, const char *, va_list);
    199 // termios.h
    200 int sio_tcgetattr (int, struct termios *);
    201 int sio_tcsetattr(int, int, const struct termios *);
    202202// fcntl.h
    203203int shell_open(const char *, int, void *arg);
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/socket_stub.c

    r374 r387  
    6262#include <netinet/tcp_var.h>
    6363#include <netapp/resolver.h>
    64 extern const ID tmax_tcp_cepid;
    65 #include "ff.h"
    66 #include "socket_stub.h"
     64#include "fdtable.h"
    6765#include "kernel_cfg.h"
    6866
     67#ifdef _DEBUG
     68static const char THIS_FILE[] = __FILE__;
     69#endif
     70
    6971#define SOCKET_TIMEOUT 2000000
     72
     73struct addrinfo {
     74        int ai_flags;
     75        int ai_family;
     76        int ai_socktype;
     77        int ai_protocol;
     78        socklen_t ai_addrlen;
     79        struct sockaddr *ai_addr;
     80        char *ai_canonname;
     81        struct addrinfo *ai_next;
     82};
     83
     84typedef uint16_t in_port_t;
     85typedef uint32_t in_addr_t;
     86struct in_addr { in_addr_t s_addr; };
     87
     88struct sockaddr_in {
     89        sa_family_t sin_family;
     90        in_port_t sin_port;
     91        struct in_addr sin_addr;
     92        uint8_t sin_zero[8];
     93};
     94
     95struct in6_addr
     96{
     97        union {
     98                uint8_t __s6_addr[16];
     99                uint16_t __s6_addr16[8];
     100                uint32_t __s6_addr32[4];
     101        } __in6_union;
     102};
     103//#define s6_addr __in6_union.__s6_addr
     104//#define s6_addr16 __in6_union.__s6_addr16
     105//#define s6_addr32 __in6_union.__s6_addr32
     106
     107struct sockaddr_in6
     108{
     109        sa_family_t     sin6_family;
     110        in_port_t       sin6_port;
     111        uint32_t        sin6_flowinfo;
     112        struct in6_addr sin6_addr;
     113        uint32_t        sin6_scope_id;
     114};
     115
     116typedef struct socket_t {
     117        int family;
     118        int type;
     119        int protocol;
     120        int cepid;
     121        int repid;
     122        int backlog;
     123        unsigned int flags;
     124        union {
     125                struct sockaddr_in laddr4;
     126                struct sockaddr_in6 laddr6;
     127        };
     128        union {
     129                struct sockaddr_in raddr4;
     130                struct sockaddr_in6 raddr6;
     131        };
     132        int buf_size;
     133        unsigned char *buf;
     134        void *input;
     135        int len;
     136} socket_t;
    70137
    71138#define tcp6_cre_cep tcp_cre_cep
     
    82149#define tcp6_set_opt tcp_set_opt
    83150
    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 
    88151#ifndef SUPPORT_INET6
    89152
     
    93156
    94157ER      udp6_cre_cep (ID cepid, T_UDP6_CCEP *pk_ccep) { return E_SYS; }
     158ER      udp6_del_cep (ID cepid) { return E_SYS; }
    95159ER_UINT udp6_snd_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
    96160ER_UINT udp6_rcv_dat (ID cepid, T_IPV6EP *p_dstaddr, void *data, int_t len, TMO tmout) { return E_SYS; }
     161ER      udp6_set_opt (ID cepid, int_t optname, void *optval, int_t optlen) { return E_SYS; }
     162ER      udp6_get_opt (ID cepid, int_t optname, void *optval, int_t optlen) { return E_SYS; }
    97163
    98164const T_IN6_ADDR *in6_get_ifaddr (int_t index) { return NULL; }
     
    111177static int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    112178static bool_t tcp_fd_readable(struct SHELL_FILE *fp);
     179static bool_t tcp_fd_writable(struct SHELL_FILE *fp);
    113180static void tcp_fd_delete(struct SHELL_FILE *fp);
    114181
     
    119186static int udp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg);
    120187static bool_t udp_fd_readable(struct SHELL_FILE *fp);
     188static bool_t udp_fd_writable(struct SHELL_FILE *fp);
    121189static void udp_fd_delete(struct SHELL_FILE *fp);
    122190
    123 IO_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 };
    124 IO_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 };
     191IO_TYPE IO_TYPE_TCP = { tcp_fd_close, tcp_fd_read, tcp_fd_write, tcp_fd_seek, tcp_fd_ioctl, tcp_fd_readable, tcp_fd_writable, tcp_fd_delete };
     192IO_TYPE IO_TYPE_UDP = { udp_fd_close, udp_fd_read, udp_fd_write, udp_fd_seek, udp_fd_ioctl, udp_fd_readable, udp_fd_writable, udp_fd_delete };
    125193
    126194typedef struct id_table_t {
     
    185253
    186254#endif
     255
     256void addrcpy(void *_dst, const void *_src, int len)
     257{
     258#if _NET_CFG_BYTE_ORDER == _NET_CFG_BIG_ENDIAN
     259        memcpy(_dst, _src, len);
     260#else
     261        uint8_t *dst = (uint8_t *)_dst, *src = &((uint8_t *)_src)[len];
     262        while (src != _src)
     263                *dst++ = *--src;
     264#endif
     265}
    187266
    188267ID new_id(id_table_t *table, int count)
     
    347426                }
    348427                case SOCK_DGRAM: {
    349                         ID cepid = new_id(udp_cepid_table, udp_cepid_table_count);
     428                        ID cepid = new_id(udp6_cepid_table, udp6_cepid_table_count);
    350429                        if (cepid < 0)
    351430                                return -ENOMEM;
    352431
    353                         T_UDP6_CCEP ccep = { 0, {ntohl(addr_in6->sin6_addr.__in6_union.__s6_addr), ntohs(addr_in6->sin6_port)}, (FP)socket_udp6_callback };
     432                        T_UDP6_CCEP ccep = { 0, { { ntohl(addr_in6->sin6_addr.__in6_union.__s6_addr) }, ntohs(addr_in6->sin6_port)}, (FP)socket_udp6_callback };
    354433                        ret = udp6_cre_cep(cepid, &ccep);
    355434                        if (ret != E_OK) {
    356                                 delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
     435                                delete_id(udp6_cepid_table, udp6_cepid_table_count, cepid);
    357436                                return -ENOMEM;
    358437                        }
     
    407486
    408487                struct sockaddr_in6 *laddr = &socket->laddr6;
    409                 T_TCP6_CREP crep = { 0, {ntohl(laddr->sin6_addr.__in6_union.__s6_addr), ntohs(laddr->sin6_port)} };
     488                T_TCP6_CREP crep = { 0, { { ntohl(laddr->sin6_addr.__in6_union.__s6_addr) }, ntohs(laddr->sin6_port)} };
    410489                ret = tcp6_cre_rep(repid, &crep);
    411490                if (ret != E_OK) {
     
    423502}
    424503
    425 int shell_connect(int fd, const struct sockaddr *addr, socklen_t len)
     504int shell_connect(int fd, const struct sockaddr *addr, socklen_t alen)
    426505{
    427506        SOCKET *fp = fd_to_fp(fd);
     
    435514        switch (socket->family) {
    436515        case AF_INET: {
    437                 if (len < 8) {
     516                if (alen < sizeof(struct sockaddr_in)) {
    438517                        return -EINVAL;
    439518                }
     
    455534                        }
    456535                        fp->handle = cepid;
     536                        fp->writable = 1;
    457537                        socket->cepid = cepid;
    458538                }
    459539                struct sockaddr_in *laddr = &socket->laddr4;
    460540                struct sockaddr_in *raddr = &socket->raddr4;
    461                 memset(raddr, 0, sizeof(*raddr));
    462                 memcpy(raddr, addr, len);
     541                memcpy(raddr, addr, sizeof(struct sockaddr_in));
    463542                T_IPV4EP lep = { ntohl(laddr->sin_addr.s_addr), ntohs(laddr->sin_port) };
    464543                T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    465544                ret = tcp_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
    466                 if (ret < 0) {
     545                if (ret == E_TMOUT) {
     546                        return -ETIMEDOUT;
     547                }
     548                else if (ret < 0) {
    467549                        return -EHOSTUNREACH;
    468550                }
     
    470552        }
    471553        case AF_INET6: {
    472                 if (len < 20) {
     554                if (alen < sizeof(struct sockaddr_in6)) {
    473555                        return -EINVAL;
    474556                }
     
    490572                        }
    491573                        fp->handle = cepid;
     574                        fp->writable = 1;
    492575                        socket->cepid = cepid;
    493576                }
    494577                struct sockaddr_in6 *laddr = &socket->laddr6;
    495578                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) };
     579                memcpy(raddr, addr, sizeof(struct sockaddr_in6));
     580                T_IPV6EP lep;
     581                addrcpy(&lep.ipaddr, &laddr->sin6_addr, 16);
     582                lep.portno = ntohs(laddr->sin6_port);
     583                T_IPV6EP rep;
     584                addrcpy(&rep.ipaddr, &raddr->sin6_addr, 16);
     585                rep.portno = ntohs(raddr->sin6_port);
    500586                ret = tcp6_con_cep(socket->cepid, &lep, &rep, SOCKET_TIMEOUT);
    501                 if (ret < 0) {
     587                if (ret == E_TMOUT) {
     588                        return -ETIMEDOUT;
     589                }
     590                else if (ret < 0) {
    502591                        return -EHOSTUNREACH;
    503592                }
     
    508597        }
    509598
     599        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
     600
    510601        return 0;
    511602}
    512603
    513 int shell_accept(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict len)
     604int shell_accept(int fd, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
    514605{
    515606        SOCKET *lfp = fd_to_fp(fd);
     
    550641                        }
    551642                        fp->handle = cepid;
     643                        fp->writable = 1;
    552644                        socket->cepid = cepid;
    553645                }
     
    555647                        cepid = ((socket_t *)lfp->exinf)->cepid;
    556648                        fp->handle = cepid;
     649                        fp->writable = 1;
    557650                        lfp->handle = tmax_tcp_cepid + ((socket_t *)lfp->exinf)->repid;
    558651                        ((socket_t *)lfp->exinf)->cepid = 0;
     
    566659                }
    567660                struct sockaddr_in *raddr = &socket->raddr4;
    568                 memset(raddr, 0, sizeof(*raddr));
     661                memset(raddr, 0, sizeof(struct sockaddr_in));
    569662                raddr->sin_family = AF_INET;
    570663                raddr->sin_port = htons(rep.portno);
    571664                raddr->sin_addr.s_addr = htonl(rep.ipaddr);
    572665
    573                 if (addr != NULL && len != NULL) {
    574                         int sz = *len;
    575                         if (sz < 8) {
     666                if (addr != NULL && alen != NULL) {
     667                        int sz = *alen;
     668                        if (sz < sizeof(struct sockaddr_in)) {
    576669                                return -EINVAL;
    577670                        }
    578671                        struct sockaddr_in *raddr = &socket->raddr4;
    579                         if (sz > sizeof(*raddr))
    580                                 sz = sizeof(*raddr);
     672                        if (sz > sizeof(struct sockaddr_in))
     673                                sz = sizeof(struct sockaddr_in);
    581674                        memcpy(addr, raddr, sz);
    582                         *len = sizeof(*raddr);
     675                        *alen = sz;
    583676                }
    584677                break;
     
    603696                        }
    604697                        fp->handle = cepid;
     698                        fp->writable = 1;
    605699                        socket->cepid = cepid;
    606700                }
     
    608702                        cepid = ((socket_t *)lfp->exinf)->cepid;
    609703                        fp->handle = cepid;
     704                        fp->writable = 1;
    610705                        lfp->handle = tmax_tcp6_cepid + ((socket_t *)lfp->exinf)->repid;
    611706                        ((socket_t *)lfp->exinf)->cepid = 0;
     
    613708                        ((socket_t *)lfp->exinf)->buf = 0;
    614709                }
    615                 T_IPV6EP rep = { 0, 0 };
     710                T_IPV6EP rep = { { 0 }, 0 };
    616711                ret = tcp6_acp_cep(socket->cepid, socket->repid, &rep, TMO_FEVR);
    617712                if (ret < 0) {
     
    619714                }
    620715                struct sockaddr_in6 *raddr = &socket->raddr6;
    621                 memset(raddr, 0, sizeof(*raddr));
     716                memset(raddr, 0, sizeof(struct sockaddr_in6));
    622717                raddr->sin6_family = AF_INET;
    623718                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) {
     719                addrcpy(&raddr->sin6_addr, &rep.ipaddr, 16);
     720
     721                if (addr != NULL && alen != NULL) {
     722                        int sz = *alen;
     723                        if (sz < sizeof(struct sockaddr_in6)) {
    634724                                return -EINVAL;
    635725                        }
    636726                        struct sockaddr_in6 *raddr = &socket->raddr6;
    637                         if (sz > sizeof(*raddr))
    638                                 sz = sizeof(*raddr);
     727                        if (sz > sizeof(struct sockaddr_in6))
     728                                sz = sizeof(struct sockaddr_in6);
    639729                        memcpy(addr, raddr, sz);
    640                         *len = sizeof(*raddr);
     730                        *alen = sz;
    641731                }
    642732                break;
     
    645735                return -ENOPROTOOPT;
    646736        }
     737
     738        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
    647739
    648740        return fp->fd;
     
    673765                        }
    674766                        else {
     767                                int temp = len;
    675768                                for (;;) {
    676769                                        ret = tcp_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    677770                                        if (ret < 0) {
    678                                                 if (ret == E_TMOUT)
    679                                                         return -ETIME;
    680                                                 return -ECOMM;
     771                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    681772                                        }
    682773                                        len -= ret;
     
    685776                                        buf = (const void *)&((uint8_t *)buf)[ret];
    686777                                }
     778                                ret = temp;
    687779                        }
    688780                        break;
    689781                }
    690782                case SOCK_DGRAM: {
    691                         int sz = alen;
    692                         if ((addr == NULL) || (sz < 8)) {
     783                        if ((addr == NULL) || (alen < sizeof(struct sockaddr_in))) {
    693784                                return -EINVAL;
    694785                        }
    695786                        struct sockaddr_in *raddr = &socket->raddr4;
    696                         memset(raddr, 0, sizeof(*raddr));
    697                         memcpy(raddr, addr, sz);
     787                        memcpy(raddr, addr, sizeof(struct sockaddr_in));
    698788                        T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    699789                        ret = udp_snd_dat(socket->cepid, &rep, (void *)buf, len,
    700790                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    701791                        if (ret < 0) {
    702                                 return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     792                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    703793                        }
    704794                        break;
     
    721811                        }
    722812                        else {
     813                                int temp = len;
    723814                                for (;;) {
    724815                                        ret = tcp6_snd_dat(socket->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    725816                                        if (ret < 0) {
    726                                                 if (ret == E_TMOUT)
    727                                                         return -ETIME;
    728                                                 return -ECOMM;
     817                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    729818                                        }
    730819                                        len -= ret;
     
    732821                                                break;
    733822                                        buf = (const void *)&((uint8_t *)buf)[ret];
    734                                 }
     823                                }
     824                                ret = temp;
    735825                        }
    736826                        break;
    737827                }
    738828                case SOCK_DGRAM: {
    739                         int sz = alen;
    740                         if ((addr == NULL) || (sz < 8)) {
     829                        if ((addr == NULL) || (alen < sizeof(struct sockaddr_in6))) {
    741830                                return -EINVAL;
    742831                        }
    743832                        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) };
     833                        memcpy(raddr, addr, sizeof(struct sockaddr_in6));
     834                        T_IPV6EP rep;
     835                        addrcpy(&rep.ipaddr, &raddr->sin6_addr, 16);
     836                        rep.portno = ntohs(raddr->sin6_port);
    747837                        ret = udp6_snd_dat(socket->cepid, &rep, (void *)buf, len,
    748838                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    749839                        if (ret < 0) {
    750                                 return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     840                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    751841                        }
    752842                        break;
     
    758848                return -ENOPROTOOPT;
    759849        }
     850
     851        if (fp->writeevt_w != fp->writeevt_r) fp->writeevt_r++;
    760852
    761853        return ret;
     
    800892                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
    801893                                        }
    802                                         ret = tcp_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
     894                                        ret = tcp_rcv_buf(socket->cepid, &socket->input,
     895                                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    803896                                        if (ret < 0) {
    804                                                 syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
    805                                                 return -ECOMM;
     897                                                if ((socket->flags & O_NONBLOCK) == 0)
     898                                                        syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     899                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    806900                                        }
    807901                                        rsz = ret;
     
    858952                                        if ((socket->flags & O_NONBLOCK) == 0)
    859953                                                syslog(LOG_ERROR, "udp_rcv_buf => %d", ret);
    860                                         return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     954                                        return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    861955                                }
    862956                                rsz = ret;
     
    867961                                        }
    868962                                        int sz = *alen;
    869                                         memset(raddr, 0, sizeof(socket->raddr4));
     963                                        memset(raddr, 0, sizeof(struct sockaddr_in));
    870964                                        raddr->sin_family = AF_INET;
    871965                                        raddr->sin_port = htons(rep.portno);
    872966                                        raddr->sin_addr.s_addr = htonl(rep.ipaddr);
    873                                         if (sz > sizeof(socket->raddr4))
    874                                                 sz = sizeof(socket->raddr4);
     967                                        if (sz > sizeof(struct sockaddr_in))
     968                                                sz = sizeof(struct sockaddr_in);
    875969                                        memcpy(addr, raddr, sz);
    876970                                        *alen = sz;
     
    889983                                if ((addr != NULL) && (alen != NULL)) {
    890984                                        int sz = *alen;
    891                                         if (sz > sizeof(socket->raddr4))
    892                                                 sz = sizeof(socket->raddr4);
     985                                        if (sz > sizeof(struct sockaddr_in))
     986                                                sz = sizeof(struct sockaddr_in);
    893987                                        memcpy(addr, raddr, sz);
    894988                                        *alen = sz;
     
    9341028                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
    9351029                                        }
    936                                         ret = tcp6_rcv_buf(socket->cepid, &socket->input, TMO_FEVR);
     1030                                        ret = tcp6_rcv_buf(socket->cepid, &socket->input,
     1031                                                (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    9371032                                        if (ret < 0) {
    938                                                 syslog(LOG_ERROR, "tcp6_rcv_buf => %d", ret);
    939                                                 return -ECOMM;
     1033                                                if ((socket->flags & O_NONBLOCK) == 0)
     1034                                                        syslog(LOG_ERROR, "tcp6_rcv_buf => %d", ret);
     1035                                                return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    9401036                                        }
    9411037                                        rsz = ret;
     
    9861082                                }
    9871083
    988                                 T_IPV6EP rep = { 0, 0 };
     1084                                T_IPV6EP rep = { { 0 }, 0 };
    9891085                                ret = udp6_rcv_dat(socket->cepid, &rep, buf, len,
    9901086                                        (socket->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
     
    9921088                                        if ((socket->flags & O_NONBLOCK) == 0)
    9931089                                                syslog(LOG_ERROR, "udp6_rcv_buf => %d", ret);
    994                                         return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     1090                                        return (ret == E_TMOUT) ? -EAGAIN : -ECOMM;
    9951091                                }
    9961092                                rsz = ret;
     
    10011097                                        }
    10021098                                        int sz = *alen;
    1003                                         memset(raddr, 0, sizeof(socket->raddr6));
     1099                                        memset(raddr, 0, sizeof(struct sockaddr_in6));
    10041100                                        raddr->sin6_family = AF_INET;
    10051101                                        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);
     1102                                        addrcpy(&raddr->sin6_addr, &rep.ipaddr, 16);
     1103                                        if (sz > sizeof(struct sockaddr_in6))
     1104                                                sz = sizeof(struct sockaddr_in6);
    10141105                                        memcpy(addr, raddr, sz);
    10151106                                        *alen = sz;
     
    10281119                                if ((addr != NULL) && (alen != NULL)) {
    10291120                                        int sz = *alen;
    1030                                         if (sz > sizeof(socket->raddr6))
    1031                                                 sz = sizeof(socket->raddr6);
     1121                                        if (sz > sizeof(struct sockaddr_in6))
     1122                                                sz = sizeof(struct sockaddr_in6);
    10321123                                        memcpy(addr, raddr, sz);
    10331124                                        *alen = sz;
     
    10541145                return -ENOPROTOOPT;
    10551146        }
     1147
     1148        if (fp->readevt_w != fp->readevt_r) fp->readevt_r++;
    10561149
    10571150        return ret;
     
    14271520                struct sockaddr_in6 laddr;
    14281521                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
     1522                addrcpy(&laddr.sin6_addr, laddr6, 16);
    14351523                laddr.sin6_port = socket->laddr6.sin6_port;
    14361524                *len = sizeof(struct sockaddr_in6);
     
    14651553                        delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
    14661554                        if ((ret < 0) || (ret2 < 0)) {
    1467                                 return (ret == E_TMOUT) ? -ETIME : -EINVAL;
     1555                                return (ret == E_TMOUT) ? -ETIMEDOUT : -EIO;
    14681556                        }
    14691557                }
     
    14941582                        delete_id(tcp6_cepid_table, tcp6_cepid_table_count, cepid);
    14951583                        if ((ret < 0) || (ret2 < 0)) {
    1496                                 return (ret == E_TMOUT) ? -ETIME : -EINVAL;
     1584                                return (ret == E_TMOUT) ? -ETIMEDOUT : -EIO;
    14971585                        }
    14981586                }
     
    15351623int tcp_fd_ioctl(struct SHELL_FILE *fp, int req, void *arg)
    15361624{
     1625        socket_t *socket = (socket_t *)fp->exinf;
     1626
     1627        switch (req) {
     1628        case F_GETFL:
     1629                return socket->flags;
     1630        case F_SETFL:
     1631                socket->flags = (unsigned int)arg;
     1632                return 0;
     1633        }
     1634
    15371635        return -EINVAL;
    15381636}
     
    15711669}
    15721670
     1671bool_t tcp_fd_writable(struct SHELL_FILE *fp)
     1672{
     1673        //socket_t *socket = (socket_t *)fp->exinf;
     1674
     1675        return /*fp->writable &&*/ (fp->writeevt_w == fp->writeevt_r);
     1676}
     1677
    15731678void tcp_fd_delete(struct SHELL_FILE *fp)
    15741679{
     
    15901695                return E_PAR;
    15911696
     1697        socket_t *socket = (socket_t *)fp->exinf;
    15921698        int fd = fp->fd;
    15931699        FD_SET(fd, (fd_set *)&flgptn);
     
    16031709                        syslog(LOG_ERROR, "wai_sem => %d", ret);
    16041710                }
    1605                 socket_t *socket = (socket_t *)fp->exinf;
    16061711                socket->len += len;
    16071712                ret = sig_sem(SEM_FILEDESC);
     
    16701775                return E_PAR;
    16711776
     1777        socket_t *socket = (socket_t *)fp->exinf;
    16721778        int fd = fp->fd;
    16731779        FD_SET(fd, (fd_set *)&flgptn);
     
    16831789                        syslog(LOG_ERROR, "wai_sem => %d", ret);
    16841790                }
    1685                 socket_t *socket = (socket_t *)fp->exinf;
    16861791                socket->len += len;
    16871792                ret = sig_sem(SEM_FILEDESC);
     
    18061911}
    18071912
     1913bool_t udp_fd_writable(struct SHELL_FILE *fp)
     1914{
     1915        //socket_t *socket = (socket_t *)fp->exinf;
     1916
     1917        return fp->writable && (fp->writeevt_w == fp->writeevt_r);
     1918}
     1919
    18081920void udp_fd_delete(struct SHELL_FILE *fp)
    18091921{
     
    18491961                socket->input = udppara->input;
    18501962                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
    1851                 memset(&socket->raddr4, 0, sizeof(socket->raddr4));
     1963                memset(&socket->raddr4, 0, sizeof(struct sockaddr_in));
    18521964                socket->raddr4.sin_family = AF_INET;
    18531965                socket->raddr4.sin_port = htons(udppara->rep4.portno);
     
    19322044                socket->input = udppara->input;
    19332045                socket->buf = GET_UDP_SDU(udppara->input, udppara->off);
    1934                 memset(&socket->raddr6, 0, sizeof(socket->raddr6));
     2046                memset(&socket->raddr6, 0, sizeof(struct sockaddr_in6));
    19352047                socket->raddr6.sin6_family = AF_INET;
    19362048                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
     2049                addrcpy(&socket->raddr6.sin6_addr, &udppara->rep6.ipaddr, 16);
    19432050                udppara->input->flags |= NB_FLG_NOREL_IFOUT;
    19442051                ret = sig_sem(SEM_FILEDESC);
  • asp3_tinet_ecnl_rx/trunk/ntshell/src/syscall.c

    r374 r387  
    300300}
    301301
    302 long SYS_rt_sigaction(long a, long b, long c) {
    303         return shell_sigaction((int)a, (const struct sigaction *)b, (struct sigaction *)c);
     302long SYS_rt_sigaction(long a, long b, long c, long d) {
     303        return shell_sigaction((int)a, (const struct k_sigaction *)b, (struct k_sigaction *)c, (size_t)d);
    304304}
    305305
     
    388388}
    389389
     390long SYS_nanosleep(long a, long b)
     391{
     392        return shell_nanosleep((const struct timespec *)a, (struct timespec *)b);
     393}
     394
    390395long SYS_dup()
    391396{
Note: See TracChangeset for help on using the changeset viewer.