[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
|
---|
| 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
|
---|
| 80 | #define __NEED_sigset_t
|
---|
| 81 |
|
---|
| 82 | #include "../musl-1.1.18/include/bits/alltypes.h"
|
---|
| 83 |
|
---|
| 84 | typedef unsigned char cc_t;
|
---|
| 85 | typedef unsigned int speed_t;
|
---|
| 86 | typedef unsigned int tcflag_t;
|
---|
| 87 |
|
---|
| 88 | #define NCCS 32
|
---|
| 89 |
|
---|
| 90 | #include "../musl-1.1.18/include/bits/fcntl.h"
|
---|
| 91 | #include "../musl-1.1.18/include/bits/termios.h"
|
---|
[441] | 92 | #include "../musl-1.1.18/include/bits/stat.h"
|
---|
| 93 | #include "../musl-1.1.18/include/sys/select.h"
|
---|
| 94 | #include "../musl-1.1.18/include/time.h"
|
---|
| 95 | #include "../musl-1.1.18/include/signal.h"
|
---|
| 96 | #include "../musl-1.1.18/include/stdio.h"
|
---|
| 97 | #include "../musl-1.1.18/include/sys/utsname.h"
|
---|
[331] | 98 | #include "../musl-1.1.18/include/dirent.h"
|
---|
| 99 | #include "../musl-1.1.18/include/bits/ioctl.h"
|
---|
[441] | 100 | #include "../musl-1.1.18/include/fcntl.h"
|
---|
[331] | 101 | #include "../musl-1.1.18/include/bits/errno.h"
|
---|
| 102 | #include "../musl-1.1.18/include/sys/socket.h"
|
---|
[434] | 103 |
|
---|
[331] | 104 | #include <stddef.h>
|
---|
| 105 | #include <stdarg.h>
|
---|
| 106 |
|
---|
| 107 | #define DebugBreak() asm("bkpt #0")
|
---|
| 108 |
|
---|
| 109 | #ifdef __cplusplus
|
---|
| 110 | extern "C" {
|
---|
| 111 | #endif
|
---|
| 112 |
|
---|
| 113 | // time.h
|
---|
| 114 | #define CLOCK_REALTIME 0
|
---|
| 115 | int shell_nanosleep(const struct timespec *req, struct timespec *rem);
|
---|
| 116 |
|
---|
| 117 | // dirent.h
|
---|
| 118 | typedef struct __dirstream FATFS_DIR;
|
---|
| 119 |
|
---|
| 120 | int shell_getdents(int, struct dirent *, size_t);
|
---|
| 121 | // pool.h
|
---|
| 122 | typedef unsigned long nfds_t;
|
---|
| 123 |
|
---|
| 124 | struct pollfd {
|
---|
| 125 | int fd;
|
---|
| 126 | short events;
|
---|
| 127 | short revents;
|
---|
| 128 | };
|
---|
| 129 |
|
---|
| 130 | int shell_poll(struct pollfd *, nfds_t, int);
|
---|
| 131 |
|
---|
| 132 | #define POLLIN 0x001
|
---|
| 133 | #define POLLOUT 0x004
|
---|
| 134 | #define POLLERR 0x008
|
---|
| 135 |
|
---|
| 136 | // stropts.h
|
---|
| 137 | int shell_ioctl(int, int, void *);
|
---|
| 138 | // unistd.h
|
---|
| 139 | #define STDIN_FILENO 0
|
---|
| 140 | #define STDOUT_FILENO 1
|
---|
| 141 | #define STDERR_FILENO 2
|
---|
| 142 |
|
---|
| 143 | int shell_rmdir(const char *);
|
---|
| 144 | int shell_ftruncate(int, off_t);
|
---|
| 145 | int shell_chdir(const char *);
|
---|
[441] | 146 | char *shell_getcwd(char *, size_t);
|
---|
| 147 | int shell_chroot(const char *);
|
---|
| 148 | int shell_close(int);
|
---|
[331] | 149 | int shell_llseek(int, off_t, off_t *, int);
|
---|
| 150 | int shell_fsync(int);
|
---|
| 151 | ssize_t shell_read(int, void *, size_t);
|
---|
| 152 | int shell_readv(int fd, const struct iovec *iov, int iovcnt);
|
---|
| 153 | ssize_t shell_write(int, const void *, size_t);
|
---|
| 154 | int shell_writev(int fd, const struct iovec *iov, int iovcnt);
|
---|
| 155 | int shell_link(const char *, const char *);
|
---|
[441] | 156 | int shell_unlink(const char *);
|
---|
| 157 | pid_t shell_getpid(void);
|
---|
[331] | 158 | int shell_access(const char *path, int mode);
|
---|
[441] | 159 | // signal.h
|
---|
[331] | 160 | int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old);
|
---|
| 161 | struct k_sigaction;
|
---|
[441] | 162 | int shell_sigaction(int sig, const struct k_sigaction *restrict sa,
|
---|
| 163 | struct k_sigaction *restrict old, size_t size);
|
---|
[331] | 164 | // socket.h
|
---|
[441] | 165 | int shell_socket(int, int, int);
|
---|
[331] | 166 | int shell_connect(int, const struct sockaddr *, socklen_t);
|
---|
| 167 | ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
|
---|
| 168 | ssize_t shell_sendmsg(int, const struct msghdr *, int);
|
---|
[441] | 169 | int shell_bind(int, const struct sockaddr *, socklen_t);
|
---|
| 170 | int shell_listen(int, int);
|
---|
[331] | 171 | int shell_accept(int, struct sockaddr *restrict, socklen_t *restrict);
|
---|
| 172 | ssize_t shell_recvfrom(int, void *restrict, size_t, int, struct sockaddr *restrict, socklen_t *restrict);
|
---|
| 173 | ssize_t shell_recvmsg(int, struct msghdr *, int);
|
---|
| 174 | int shell_getsockopt(int, int, int, void *restrict, socklen_t *restrict);
|
---|
| 175 | int shell_setsockopt(int, int, int, const void *, socklen_t);
|
---|
| 176 | int shell_shutdown(int, int);
|
---|
| 177 | int shell_getpeername(int fd, struct sockaddr *restrict addr, socklen_t *restrict len);
|
---|
| 178 | int shell_getsockname(int fd, struct sockaddr *restrict addr, socklen_t *restrict len);
|
---|
| 179 | // select.h
|
---|
| 180 | int shell_select(int, fd_set *restrict, fd_set *restrict, fd_set *restrict, struct timeval *restrict);
|
---|
| 181 | // syslog.h
|
---|
| 182 | void vsyslog (int, const char *, va_list);
|
---|
| 183 | // termios.h
|
---|
| 184 | int tcgetattr (int, struct termios *);
|
---|
| 185 | int tcsetattr(int, int, const struct termios *);
|
---|
| 186 | // fcntl.h
|
---|
| 187 | int shell_open(const char *, int, void *arg);
|
---|
| 188 | int shell_fcntl(int fd, int cmd, void *arg);
|
---|
| 189 | // stdio.h
|
---|
[441] | 190 | int shell_rename(const char *, const char *);
|
---|
[331] | 191 | // stat.h
|
---|
[441] | 192 | #define S_IFDIR 0040000
|
---|
[331] | 193 | #define S_IFCHR 0020000
|
---|
| 194 | #define S_IFREG 0100000
|
---|
| 195 |
|
---|
| 196 | #define S_IRUSR 0400
|
---|
| 197 | #define S_IWUSR 0200
|
---|
| 198 | #define S_IRGRP 0040
|
---|
| 199 | #define S_IWGRP 0020
|
---|
| 200 | #define S_IROTH 0004
|
---|
| 201 | #define S_IWOTH 0002
|
---|
| 202 |
|
---|
| 203 | int shell_chmod(const char *, mode_t);
|
---|
| 204 | int shell_mkdir(const char *, mode_t);
|
---|
| 205 | int shell_stat(const char *restrict, struct stat *restrict);
|
---|
| 206 | int shell_fstat(int, struct stat *);
|
---|
| 207 | int shell_lstat(const char *restrict, struct stat *restrict);
|
---|
| 208 |
|
---|
[441] | 209 | int shell_clock_getres(clockid_t clk_id, struct timespec *res);
|
---|
| 210 | int shell_clock_gettime(clockid_t clk_id, struct timespec *tp);
|
---|
| 211 | int shell_clock_settime(clockid_t clk_id, const struct timespec *tp);
|
---|
| 212 | int shell_gettimeofday(struct timeval *tp, void * tzvp);
|
---|
| 213 |
|
---|
| 214 | void shell_abort();
|
---|
| 215 | void shell_exit(int exitcd);
|
---|
| 216 | void shell_exit_group(int exitcd);
|
---|
| 217 | int shell_kill(int pid, int sig);
|
---|
| 218 |
|
---|
| 219 | void *shell_brk(void *addr);
|
---|
| 220 | void *shell_mmap2(void *start, size_t length, int prot, int flags, int fd, off_t pgoffset);
|
---|
| 221 | // sys/mman.h
|
---|
| 222 | int shell_mprotect(void *addr, size_t len, int prot);
|
---|
[331] | 223 | // TODO
|
---|
[441] | 224 | int shell_clone(int, int);
|
---|
| 225 | int shell_dup2(int, int);
|
---|
| 226 | int shell_execve(const char *, char *const [], char *const []);
|
---|
| 227 | int shell_faccessat(int, const char *, int, int);
|
---|
| 228 | int shell_fchmodat(int, const char *, mode_t, int);
|
---|
| 229 | int shell_flock(int, int);
|
---|
| 230 | int shell_fork();
|
---|
| 231 | int shell_futex(volatile int *, int, int, void *);
|
---|
| 232 | int shell_futimesat(int, const char *, struct timeval *);
|
---|
| 233 | int shell_getegid();
|
---|
| 234 | int shell_geteuid();
|
---|
| 235 | int shell_getgid();
|
---|
[331] | 236 | int shell_gettid();
|
---|
[441] | 237 | int shell_getuid();
|
---|
| 238 | int shell_madvise(void *, size_t, int);
|
---|
| 239 | int shell_mremap(void *, size_t, size_t, int, void *);
|
---|
| 240 | int shell_munmap(void *, size_t);
|
---|
| 241 | int shell_pipe(int [2]);
|
---|
| 242 | int shell_pipe2(int [2], int);
|
---|
[331] | 243 | int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
|
---|
| 244 | int shell_pselect6(int, fd_set *restrict, fd_set *restrict,
|
---|
| 245 | fd_set *restrict, const struct timespec *restrict, const sigset_t *restrict);
|
---|
| 246 | int shell_setpgid(pid_t, pid_t);
|
---|
| 247 | int shell_setsid();
|
---|
| 248 | int shell_symlink(const char *, const char *);
|
---|
| 249 | int shell_tkill(int, int);
|
---|
| 250 | int shell_umask(mode_t);
|
---|
| 251 | int shell_uname(struct utsname *);
|
---|
| 252 | int shell_utimensat(int, const char *, const struct timespec [2], int);
|
---|
| 253 | int shell_utimes(const char *, struct timeval *);
|
---|
| 254 | // sys/resource.h
|
---|
| 255 | struct rusage;
|
---|
| 256 | int shell_wait4(pid_t, int *, int, struct rusage *);
|
---|
| 257 | ssize_t shell_getrandom(void *buf, size_t buflen, unsigned int flags);
|
---|
| 258 | // âââmusl
|
---|
| 259 |
|
---|
| 260 | // arduino.h
|
---|
| 261 | int SD_begin();
|
---|
| 262 |
|
---|
| 263 | char *basename(char *);
|
---|
| 264 | void shellif_into();
|
---|
[441] | 265 | void shellif_outof();
|
---|
| 266 |
|
---|
| 267 | struct regs_t {
|
---|
| 268 | long a;
|
---|
[331] | 269 | long b;
|
---|
| 270 | long c;
|
---|
| 271 | long d;
|
---|
[441] | 272 | long e;
|
---|
[331] | 273 | long f;
|
---|
| 274 | long n;
|
---|
| 275 | };
|
---|
| 276 |
|
---|
[441] | 277 | void no_implement(const char *text);
|
---|
| 278 | void __mbedcall_cp_asm();
|
---|
| 279 |
|
---|
| 280 | #include "ff.h"
|
---|
| 281 | WCHAR Utf8_to_Utf16(const char *, int *); /* in ff.c */
|
---|
| 282 | void Utf16_to_Utf8(unsigned char *, int *, UINT); /* in ff.c */
|
---|
| 283 |
|
---|
| 284 | #ifdef __cplusplus
|
---|
| 285 | extern "C" {
|
---|
| 286 | #endif
|
---|
| 287 | int Kernel_StartExternal(int argc, char **argv);
|
---|
| 288 | #ifdef __cplusplus
|
---|
| 289 | }
|
---|
| 290 | #endif
|
---|
| 291 |
|
---|
| 292 | void *malloc(size_t size);
|
---|
| 293 | void *calloc(size_t size, size_t count);
|
---|
| 294 | void *realloc(void *ptr, size_t size);
|
---|
| 295 | void free(void *ptr);
|
---|
| 296 |
|
---|
| 297 | #ifdef __cplusplus
|
---|
| 298 | }
|
---|
| 299 | #endif
|
---|
| 300 |
|
---|
| 301 | #endif /* _SHELLIF_H_ */
|
---|