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

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

Location:
asp3_tinet_ecnl_rx/trunk/asp3_dcre
Files:
7 added
30 edited
1 moved

Legend:

Unmodified
Added
Removed
  • 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        /* 通信端点のロックを解除する。*/
Note: See TracChangeset for help on using the changeset viewer.