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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.