[331] | 1 | /*
|
---|
[439] | 2 | * TOPPERS PROJECT Home Network Working Group Software
|
---|
[331] | 3 | *
|
---|
[439] | 4 | * Copyright (C) 2017-2019 Cores Co., Ltd. Japan
|
---|
[331] | 5 | *
|
---|
| 6 | * ä¸è¨èä½æ¨©è
|
---|
| 7 | ã¯ï¼ä»¥ä¸ã®(1)ï½(4)ã®æ¡ä»¶ãæºããå ´åã«éãï¼æ¬ã½ããã¦ã§
|
---|
| 8 | * ã¢ï¼æ¬ã½ããã¦ã§ã¢ãæ¹å¤ãããã®ãå«ãï¼ä»¥ä¸åãï¼ã使ç¨ã»è¤è£½ã»æ¹
|
---|
| 9 | * å¤ã»åé
|
---|
| 10 | å¸ï¼ä»¥ä¸ï¼å©ç¨ã¨å¼ã¶ï¼ãããã¨ãç¡åã§è¨±è«¾ããï¼
|
---|
| 11 | * (1) æ¬ã½ããã¦ã§ã¢ãã½ã¼ã¹ã³ã¼ãã®å½¢ã§å©ç¨ããå ´åã«ã¯ï¼ä¸è¨ã®èä½
|
---|
| 12 | * 権表示ï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãï¼ãã®ã¾ã¾ã®å½¢ã§ã½ã¼
|
---|
| 13 | * ã¹ã³ã¼ãä¸ã«å«ã¾ãã¦ãããã¨ï¼
|
---|
| 14 | * (2) æ¬ã½ããã¦ã§ã¢ãï¼ã©ã¤ãã©ãªå½¢å¼ãªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 15 | * ç¨ã§ããå½¢ã§åé
|
---|
| 16 | å¸ããå ´åã«ã¯ï¼åé
|
---|
| 17 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨
|
---|
| 18 | * è
|
---|
| 19 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®èä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨
|
---|
| 20 | * ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 21 | * (3) æ¬ã½ããã¦ã§ã¢ãï¼æ©å¨ã«çµã¿è¾¼ããªã©ï¼ä»ã®ã½ããã¦ã§ã¢éçºã«ä½¿
|
---|
| 22 | * ç¨ã§ããªãå½¢ã§åé
|
---|
| 23 | å¸ããå ´åã«ã¯ï¼æ¬¡ã®ããããã®æ¡ä»¶ãæºããã
|
---|
| 24 | * ã¨ï¼
|
---|
| 25 | * (a) åé
|
---|
| 26 | å¸ã«ä¼´ãããã¥ã¡ã³ãï¼å©ç¨è
|
---|
| 27 | ããã¥ã¢ã«ãªã©ï¼ã«ï¼ä¸è¨ã®è
|
---|
| 28 | * ä½æ¨©è¡¨ç¤ºï¼ãã®å©ç¨æ¡ä»¶ããã³ä¸è¨ã®ç¡ä¿è¨¼è¦å®ãæ²è¼ãããã¨ï¼
|
---|
| 29 | * (b) åé
|
---|
| 30 | å¸ã®å½¢æ
|
---|
| 31 | ãï¼å¥ã«å®ããæ¹æ³ã«ãã£ã¦ï¼TOPPERSããã¸ã§ã¯ãã«
|
---|
| 32 | * å ±åãããã¨ï¼
|
---|
| 33 | * (4) æ¬ã½ããã¦ã§ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ
|
---|
| 34 | * 害ãããï¼ä¸è¨èä½æ¨©è
|
---|
| 35 | ããã³TOPPERSããã¸ã§ã¯ããå
|
---|
| 36 | 責ãããã¨ï¼
|
---|
[441] | 37 | * ã¾ãï¼æ¬ã½ããã¦ã§ã¢ã®ã¦ã¼ã¶ã¾ãã¯ã¨ã³ãã¦ã¼ã¶ããã®ãããªãç
|
---|
| 38 | * ç±ã«åºã¥ãè«æ±ãããï¼ä¸è¨èä½æ¨©è
|
---|
[331] | 39 | ããã³TOPPERSããã¸ã§ã¯ãã
|
---|
| 40 | * å
|
---|
[441] | 41 | 責ãããã¨ï¼
|
---|
[331] | 42 | *
|
---|
| 43 | * æ¬ã½ããã¦ã§ã¢ã¯ï¼ç¡ä¿è¨¼ã§æä¾ããã¦ãããã®ã§ããï¼ä¸è¨èä½æ¨©è
|
---|
| 44 | ã
|
---|
| 45 | * ãã³TOPPERSããã¸ã§ã¯ãã¯ï¼æ¬ã½ããã¦ã§ã¢ã«é¢ãã¦ï¼ç¹å®ã®ä½¿ç¨ç®ç
|
---|
| 46 | * ã«å¯¾ããé©åæ§ãå«ãã¦ï¼ãããªãä¿è¨¼ãè¡ããªãï¼ã¾ãï¼æ¬ã½ããã¦ã§
|
---|
| 47 | * ã¢ã®å©ç¨ã«ããç´æ¥çã¾ãã¯éæ¥çã«çãããããªãæ害ã«é¢ãã¦ãï¼ã
|
---|
| 48 | * ã®è²¬ä»»ãè² ããªãï¼
|
---|
| 49 | *
|
---|
| 50 | * @(#) $Id$
|
---|
| 51 | */
|
---|
| 52 | #ifndef _SHELLIF_H_
|
---|
| 53 | #define _SHELLIF_H_
|
---|
| 54 |
|
---|
| 55 | #ifdef _MSC_VER
|
---|
| 56 | #undef NULL
|
---|
| 57 | #endif
|
---|
| 58 |
|
---|
| 59 | #define __NEED_off_t
|
---|
| 60 | #define __NEED_ssize_t
|
---|
| 61 | #define __NEED_size_t
|
---|
| 62 | #define __NEED_mode_t
|
---|
| 63 | #define __NEED_dev_t
|
---|
| 64 | #define __NEED_pid_t
|
---|
| 65 | #define __NEED_gid_t
|
---|
| 66 | #define __NEED_uid_t
|
---|
| 67 | #define __NEED_socklen_t
|
---|
| 68 | #define __NEED_nlink_t
|
---|
| 69 | #define __NEED_blksize_t
|
---|
| 70 | #define __NEED_blkcnt_t
|
---|
| 71 | #define __NEED_ino_t
|
---|
| 72 | #define __NEED_time_t
|
---|
| 73 | #define __NEED_suseconds_t
|
---|
| 74 | #define __NEED_struct_timeval
|
---|
[442] | 75 | #define __NEED_struct_timespec
|
---|
| 76 | #define __NEED_struct_iovec
|
---|
| 77 | #define __NEED_clockid_t
|
---|
| 78 | #define __NEED_socklen_t
|
---|
| 79 | #define __NEED_sa_family_t
|
---|
[331] | 80 | #define __NEED_sigset_t
|
---|
| 81 |
|
---|
| 82 | #include "../musl-1.1.18/include/bits/alltypes.h"
|
---|
| 83 |
|
---|
| 84 | typedef unsigned char cc_t;
|
---|
[442] | 85 | typedef unsigned int speed_t;
|
---|
[331] | 86 | typedef unsigned int tcflag_t;
|
---|
| 87 |
|
---|
[442] | 88 | #define NCCS 32
|
---|
[331] | 89 |
|
---|
| 90 | #include "../musl-1.1.18/include/stdint.h"
|
---|
| 91 | #include "../musl-1.1.18/include/strings.h"
|
---|
| 92 | #define _STRINGS_H_ // newlibã®strings.hã®includeãææ¢
|
---|
| 93 | #include "../musl-1.1.18/include/string.h"
|
---|
| 94 | #define _STRING_H_ // newlibã®string.hã®includeãææ¢
|
---|
| 95 | #include "../musl-1.1.18/include/bits/fcntl.h"
|
---|
| 96 | #include "../musl-1.1.18/include/bits/termios.h"
|
---|
| 97 | #include "../musl-1.1.18/include/bits/stat.h"
|
---|
[442] | 98 | #include "../musl-1.1.18/include/sys/select.h"
|
---|
[331] | 99 | #include "../musl-1.1.18/include/time.h"
|
---|
[441] | 100 | #define _TIME_H_ // newlibã®time.hã®includeãææ¢
|
---|
| 101 | #include "../musl-1.1.18/include/signal.h"
|
---|
| 102 | #include "../musl-1.1.18/include/stdio.h"
|
---|
| 103 | #define _STDIO_H_ // newlibã®stdio.hã®includeãææ¢
|
---|
| 104 | #include "../musl-1.1.18/include/sys/utsname.h"
|
---|
| 105 | #include "../musl-1.1.18/include/dirent.h"
|
---|
[331] | 106 | #include "../musl-1.1.18/include/bits/ioctl.h"
|
---|
| 107 | #include "../musl-1.1.18/include/fcntl.h"
|
---|
[441] | 108 | #include "../musl-1.1.18/include/bits/errno.h"
|
---|
[331] | 109 | #include "../musl-1.1.18/include/sys/socket.h"
|
---|
| 110 |
|
---|
[434] | 111 | #include <stddef.h>
|
---|
[331] | 112 | #include <stdarg.h>
|
---|
| 113 | #include <setjmp.h>
|
---|
| 114 |
|
---|
| 115 | #define DebugBreak() asm("bkpt #0")
|
---|
| 116 |
|
---|
| 117 | #ifdef __cplusplus
|
---|
| 118 | extern "C" {
|
---|
| 119 | #endif
|
---|
| 120 |
|
---|
| 121 | // time.h
|
---|
| 122 | #define CLOCK_REALTIME 0
|
---|
| 123 | int shell_nanosleep(const struct timespec *req, struct timespec *rem);
|
---|
| 124 |
|
---|
| 125 | // dirent.h
|
---|
| 126 | typedef struct __dirstream FATFS_DIR;
|
---|
| 127 |
|
---|
| 128 | int shell_getdents(int, struct dirent *, size_t);
|
---|
| 129 | // pool.h
|
---|
| 130 | typedef unsigned long nfds_t;
|
---|
| 131 |
|
---|
| 132 | struct pollfd {
|
---|
| 133 | int fd;
|
---|
| 134 | short events;
|
---|
| 135 | short revents;
|
---|
| 136 | };
|
---|
| 137 |
|
---|
| 138 | int shell_poll(struct pollfd *, nfds_t, int);
|
---|
| 139 |
|
---|
| 140 | #define POLLIN 0x001
|
---|
| 141 | #define POLLOUT 0x004
|
---|
| 142 | #define POLLERR 0x008
|
---|
| 143 |
|
---|
| 144 | // stropts.h
|
---|
| 145 | int shell_ioctl(int, int, void *);
|
---|
| 146 | // unistd.h
|
---|
| 147 | #define STDIN_FILENO 0
|
---|
| 148 | #define STDOUT_FILENO 1
|
---|
| 149 | #define STDERR_FILENO 2
|
---|
| 150 |
|
---|
| 151 | int shell_rmdir(const char *);
|
---|
| 152 | int shell_ftruncate(int, off_t);
|
---|
| 153 | int shell_chdir(const char *);
|
---|
[441] | 154 | char *shell_getcwd(char *, size_t);
|
---|
| 155 | int shell_chroot(const char *);
|
---|
| 156 | int shell_close(int);
|
---|
[331] | 157 | int shell_llseek(int, off_t, off_t *, int);
|
---|
| 158 | int shell_fsync(int);
|
---|
| 159 | ssize_t shell_read(int, void *, size_t);
|
---|
| 160 | int shell_readv(int fd, const struct iovec *iov, int iovcnt);
|
---|
| 161 | ssize_t shell_write(int, const void *, size_t);
|
---|
| 162 | int shell_writev(int fd, const struct iovec *iov, int iovcnt);
|
---|
| 163 | int shell_link(const char *, const char *);
|
---|
[441] | 164 | int shell_unlink(const char *);
|
---|
| 165 | pid_t shell_getpid(void);
|
---|
[331] | 166 | int shell_access(const char *path, int mode);
|
---|
[441] | 167 | // signal.h
|
---|
[331] | 168 | int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old);
|
---|
| 169 | struct k_sigaction;
|
---|
[441] | 170 | int shell_sigaction(int sig, const struct k_sigaction *restrict sa,
|
---|
| 171 | struct k_sigaction *restrict old, size_t size);
|
---|
[331] | 172 | // socket.h
|
---|
[441] | 173 | int shell_socket(int, int, int);
|
---|
[331] | 174 | int shell_connect(int, const struct sockaddr *, socklen_t);
|
---|
| 175 | ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
---|
| 176 | ssize_t shell_sendmsg(int, const struct msghdr *, int);
|
---|
[441] | 177 | int shell_bind(int, const struct sockaddr *, socklen_t);
|
---|
| 178 | int shell_listen(int, int);
|
---|
[331] | 179 | int shell_accept(int, struct sockaddr *restrict, socklen_t *restrict);
|
---|
| 180 | ssize_t shell_recvfrom(int, void *restrict, size_t, int, struct sockaddr *restrict, socklen_t *restrict);
|
---|
| 181 | ssize_t shell_recvmsg(int, struct msghdr *, int);
|
---|
| 182 | int shell_getsockopt(int, int, int, void *restrict, socklen_t *restrict);
|
---|
| 183 | int shell_setsockopt(int, int, int, const void *, socklen_t);
|
---|
| 184 | int shell_shutdown(int, int);
|
---|
| 185 | int shell_getpeername(int fd, struct sockaddr *restrict addr, socklen_t *restrict len);
|
---|
| 186 | int shell_getsockname(int fd, struct sockaddr *restrict addr, socklen_t *restrict len);
|
---|
| 187 | // select.h
|
---|
| 188 | int shell_select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timeval *restrict);
|
---|
| 189 | // syslog.h
|
---|
| 190 | void vsyslog (int, const char *, va_list);
|
---|
| 191 | // termios.h
|
---|
| 192 | int tcgetattr (int, struct termios *);
|
---|
| 193 | int tcsetattr(int, int, const struct termios *);
|
---|
| 194 | // fcntl.h
|
---|
| 195 | int shell_open(const char *, int, void *arg);
|
---|
| 196 | int shell_fcntl(int fd, int cmd, void *arg);
|
---|
| 197 | // stdio.h
|
---|
[441] | 198 | int shell_rename(const char *, const char *);
|
---|
[331] | 199 | // stat.h
|
---|
[441] | 200 | #define S_IFDIR 0040000
|
---|
[331] | 201 | #define S_IFCHR 0020000
|
---|
| 202 | #define S_IFREG 0100000
|
---|
| 203 |
|
---|
| 204 | #define S_IRUSR 0400
|
---|
| 205 | #define S_IWUSR 0200
|
---|
| 206 | #define S_IRGRP 0040
|
---|
| 207 | #define S_IWGRP 0020
|
---|
| 208 | #define S_IROTH 0004
|
---|
| 209 | #define S_IWOTH 0002
|
---|
| 210 |
|
---|
| 211 | int shell_chmod(const char *, mode_t);
|
---|
| 212 | int shell_mkdir(const char *, mode_t);
|
---|
| 213 | int shell_stat(const char *restrict, struct stat *restrict);
|
---|
| 214 | int shell_fstat(int, struct stat *);
|
---|
| 215 | int shell_lstat(const char *restrict, struct stat *restrict);
|
---|
| 216 |
|
---|
[441] | 217 | int shell_clock_getres(clockid_t clk_id, struct timespec *res);
|
---|
| 218 | int shell_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
---|
| 219 | int shell_clock_settime(clockid_t clk_id, const struct timespec *tp);
|
---|
| 220 | int shell_gettimeofday(struct timeval *tp, void * tzvp);
|
---|
| 221 |
|
---|
| 222 | void shell_abort();
|
---|
| 223 | void shell_exit(int exitcd);
|
---|
| 224 | void shell_exit_group(int exitcd);
|
---|
| 225 | int shell_kill(int pid, int sig);
|
---|
| 226 |
|
---|
| 227 | void *shell_brk(void *addr);
|
---|
| 228 | void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset);
|
---|
| 229 | // sys/mman.h
|
---|
| 230 | int shell_mprotect(void *addr, size_t len, int prot);
|
---|
[331] | 231 | // TODO
|
---|
[441] | 232 | int shell_clone(int, int);
|
---|
| 233 | int shell_dup2(int, int);
|
---|
| 234 | int shell_execve(const char *, char *const [], char *const []);
|
---|
| 235 | int shell_faccessat(int, const char *, int, int);
|
---|
| 236 | int shell_fchmodat(int, const char *, mode_t, int);
|
---|
| 237 | int shell_flock(int, int);
|
---|
| 238 | int shell_fork();
|
---|
| 239 | int shell_futex(volatile int *, int, int, void *);
|
---|
| 240 | int shell_futimesat(int, const char *, struct timeval *);
|
---|
| 241 | int shell_getegid();
|
---|
| 242 | int shell_geteuid();
|
---|
| 243 | int shell_getgid();
|
---|
[331] | 244 | int shell_gettid();
|
---|
[441] | 245 | int shell_getuid();
|
---|
| 246 | int shell_madvise(void *, size_t, int);
|
---|
| 247 | int shell_mremap(void *, size_t, size_t, int, void *);
|
---|
| 248 | int shell_munmap(void *, size_t);
|
---|
| 249 | int shell_pipe(int [2]);
|
---|
| 250 | int shell_pipe2(int [2], int);
|
---|
[331] | 251 | int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
|
---|
| 252 | int shell_pselect6(int, fd_set *restrict, fd_set *restrict,
|
---|
| 253 | fd_set *restrict, const struct timespec *restrict, const sigset_t *restrict);
|
---|
| 254 | int shell_setpgid(pid_t, pid_t);
|
---|
| 255 | int shell_setsid();
|
---|
| 256 | int shell_symlink(const char *, const char *);
|
---|
| 257 | int shell_tkill(int, int);
|
---|
| 258 | int shell_umask(mode_t);
|
---|
| 259 | int shell_uname(struct utsname *);
|
---|
| 260 | int shell_utimensat(int, const char *, const struct timespec [2], int);
|
---|
| 261 | int shell_utimes(const char *, struct timeval *);
|
---|
| 262 | // sys/resource.h
|
---|
| 263 | struct rusage;
|
---|
| 264 | int shell_wait4(pid_t, int *, int, struct rusage *);
|
---|
| 265 | ssize_t shell_getrandom(void *buf, size_t buflen, unsigned int flags);
|
---|
| 266 | // âââmusl
|
---|
| 267 |
|
---|
| 268 | // arduino.h
|
---|
| 269 | int SD_begin();
|
---|
| 270 |
|
---|
| 271 | char *basename(char *);
|
---|
| 272 | void shellif_into();
|
---|
[441] | 273 | void shellif_outof();
|
---|
| 274 |
|
---|
| 275 | struct regs_t {
|
---|
| 276 | long a;
|
---|
[331] | 277 | long b;
|
---|
| 278 | long c;
|
---|
| 279 | long d;
|
---|
[441] | 280 | long e;
|
---|
[331] | 281 | long f;
|
---|
| 282 | long n;
|
---|
| 283 | };
|
---|
| 284 |
|
---|
[441] | 285 | void no_implement(const char *text);
|
---|
| 286 | void __mbedcall_cp_asm();
|
---|
| 287 |
|
---|
| 288 | #include "ff.h"
|
---|
| 289 | WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
|
---|
| 290 | void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
|
---|
| 291 |
|
---|
| 292 | #ifdef __cplusplus
|
---|
| 293 | extern "C" {
|
---|
| 294 | #endif
|
---|
| 295 | int Kernel_StartExternal(int argc, char **argv);
|
---|
| 296 | #ifdef __cplusplus
|
---|
| 297 | }
|
---|
| 298 | #endif
|
---|
| 299 |
|
---|
| 300 | void *malloc(size_t size);
|
---|
| 301 | void *calloc(size_t size, size_t count);
|
---|
| 302 | void *realloc(void *ptr, size_t size);
|
---|
| 303 | void free(void *ptr);
|
---|
| 304 |
|
---|
| 305 | #ifdef __cplusplus
|
---|
| 306 | }
|
---|
| 307 | #endif
|
---|
| 308 |
|
---|
| 309 | #endif /* _SHELLIF_H_ */
|
---|