1 | /*
|
---|
2 | * TOPPERS ECHONET Lite Communication Middleware
|
---|
3 | *
|
---|
4 | * Copyright (C) 2018 Cores Co., Ltd. Japan
|
---|
5 | *
|
---|
6 | * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
|
---|
7 | * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
|
---|
8 | * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
|
---|
9 | * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
|
---|
10 | * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
|
---|
11 | * スコード中に含まれていること.
|
---|
12 | * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
|
---|
13 | * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
|
---|
14 | * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
|
---|
15 | * の無保証規定を掲載すること.
|
---|
16 | * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
|
---|
17 | * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
|
---|
18 | * と.
|
---|
19 | * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
|
---|
20 | * 作権表示,この利用条件および下記の無保証規定を掲載すること.
|
---|
21 | * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
|
---|
22 | * 報告すること.
|
---|
23 | * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
|
---|
24 | * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
|
---|
25 | * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
|
---|
26 | * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
|
---|
27 | * 免責すること.
|
---|
28 | *
|
---|
29 | * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
|
---|
30 | * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
|
---|
31 | * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
|
---|
32 | * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
|
---|
33 | * の責任を負わない.
|
---|
34 | *
|
---|
35 | * @(#) $Id$
|
---|
36 | */
|
---|
37 | #include "bits/syscall.h"
|
---|
38 | #include "shellif.h"
|
---|
39 | #include <t_syslog.h>
|
---|
40 | #include "MBRZA1H.h"
|
---|
41 |
|
---|
42 | void *thread_area;
|
---|
43 | void *tid_address;
|
---|
44 |
|
---|
45 | // https://os.mbed.com/users/dkato/code/FlashAccess/#652a093cf264
|
---|
46 | void flash_access_cache_control(void) {
|
---|
47 | unsigned int assoc;
|
---|
48 |
|
---|
49 | /* ==== Cleaning and invalidation of the L1 data cache ==== */
|
---|
50 | __v7_all_cache(2);
|
---|
51 | __DSB();
|
---|
52 |
|
---|
53 | /* ==== Cleaning and invalidation of the L2 cache ==== */
|
---|
54 | if (PL310->AUX_CNT & (1 << 16)) {
|
---|
55 | assoc = 16;
|
---|
56 | }
|
---|
57 | else {
|
---|
58 | assoc = 8;
|
---|
59 | }
|
---|
60 | PL310->INV_WAY = (1 << assoc) - 1;
|
---|
61 | while (PL310->INV_WAY & ((1 << assoc) - 1)); // poll invalidate
|
---|
62 | PL310->CACHE_SYNC = 0x0;
|
---|
63 |
|
---|
64 | /* ==== Invalidate all TLB entries ==== */
|
---|
65 | __ca9u_inv_tlb_all();
|
---|
66 |
|
---|
67 | /* ==== Invalidate the L1 instruction cache ==== */
|
---|
68 | __v7_inv_icache_all();
|
---|
69 | __DSB();
|
---|
70 | __ISB();
|
---|
71 | }
|
---|
72 |
|
---|
73 | long no_implement(const char *text)
|
---|
74 | {
|
---|
75 | syslog(LOG_ERROR, text);
|
---|
76 | DebugBreak();
|
---|
77 | return -ENOSYS;
|
---|
78 | }
|
---|
79 |
|
---|
80 | long __syscall_nr(long n, ...)
|
---|
81 | {
|
---|
82 | long ret = -ENOSYS;
|
---|
83 | va_list ap;
|
---|
84 |
|
---|
85 | va_start(ap, n);
|
---|
86 |
|
---|
87 | switch (n) {
|
---|
88 | case __NR_setresgid:
|
---|
89 | no_implement("setresgid");
|
---|
90 | break;
|
---|
91 | case __NR_setresuid:
|
---|
92 | no_implement("setresuid");
|
---|
93 | break;
|
---|
94 | case __NR_setgid:
|
---|
95 | no_implement("setgid");
|
---|
96 | break;
|
---|
97 | case __NR_setregid:
|
---|
98 | no_implement("setregid");
|
---|
99 | break;
|
---|
100 | case __NR_setreuid:
|
---|
101 | no_implement("setreuid");
|
---|
102 | break;
|
---|
103 | case __NR_setuid:
|
---|
104 | no_implement("setuid");
|
---|
105 | break;
|
---|
106 | default:
|
---|
107 | no_implement("syscall");
|
---|
108 | break;
|
---|
109 | }
|
---|
110 |
|
---|
111 | va_end(ap);
|
---|
112 |
|
---|
113 | return ret;
|
---|
114 | }
|
---|
115 |
|
---|
116 | long SYS__llseek(long a, long b, long c, long d, long e) {
|
---|
117 | return shell_llseek((int)a, ((off_t)b << 32) | (off_t)c, (off_t *)d, (int)e);
|
---|
118 | }
|
---|
119 |
|
---|
120 | long SYS__newselect(long a, long b, long c, long d, long e) {
|
---|
121 | return shell_select((int)a, (fd_set *)b, (fd_set *)c, (fd_set *)d, (struct timeval *)e);
|
---|
122 | }
|
---|
123 |
|
---|
124 | long SYS_accept(long a, long b, long c) {
|
---|
125 | return shell_accept((int)a, (struct sockaddr *)b, (socklen_t *)c);
|
---|
126 | }
|
---|
127 |
|
---|
128 | long SYS_access(long a, long b) {
|
---|
129 | return shell_access((const char *)a, (int)b);
|
---|
130 | }
|
---|
131 |
|
---|
132 | long SYS_bind(long a, long b, long c) {
|
---|
133 | return shell_bind((int)a, (const struct sockaddr *)b, (socklen_t)c);
|
---|
134 | }
|
---|
135 |
|
---|
136 | long SYS_brk(long a) {
|
---|
137 | return (long)shell_brk((void *)a);
|
---|
138 | }
|
---|
139 |
|
---|
140 | long SYS_chdir(long a) {
|
---|
141 | return shell_chdir((const char *)a);
|
---|
142 | }
|
---|
143 |
|
---|
144 | long SYS_chmod(long a, long b) {
|
---|
145 | return shell_chmod((const char *)a, (mode_t)b);
|
---|
146 | }
|
---|
147 |
|
---|
148 | long SYS_chroot(long a) {
|
---|
149 | return shell_chroot((const char *)a);
|
---|
150 | }
|
---|
151 |
|
---|
152 | long SYS_clock_getres(long a, long b) {
|
---|
153 | return shell_clock_getres((clockid_t)a, (struct timespec *)b);
|
---|
154 | }
|
---|
155 |
|
---|
156 | long SYS_clock_gettime(long a, long b) {
|
---|
157 | return shell_clock_gettime((clockid_t)a, (struct timespec *)b);
|
---|
158 | }
|
---|
159 |
|
---|
160 | long SYS_clock_settime(long a, long b) {
|
---|
161 | return shell_clock_settime((clockid_t)a, (const struct timespec *)b);
|
---|
162 | }
|
---|
163 |
|
---|
164 | long SYS_close(long a) {
|
---|
165 | return shell_close((int)a);
|
---|
166 | }
|
---|
167 |
|
---|
168 | long SYS_connect(long a, long b, long c) {
|
---|
169 | return shell_connect((int)a, (const struct sockaddr *)b, (socklen_t)c);
|
---|
170 | }
|
---|
171 |
|
---|
172 | long SYS_exit(long a) {
|
---|
173 | shell_exit((int)a);
|
---|
174 | return 0;
|
---|
175 | }
|
---|
176 |
|
---|
177 | long SYS_exit_group(long a) {
|
---|
178 | shell_exit_group((int)a);
|
---|
179 | return 0;
|
---|
180 | }
|
---|
181 |
|
---|
182 | long SYS_fcntl64(long a, long b, long c) {
|
---|
183 | return shell_fcntl((int)a, (int)b, (void *)c);
|
---|
184 | }
|
---|
185 |
|
---|
186 | long SYS_fdatasync() {
|
---|
187 | return no_implement("fdatasync\n");
|
---|
188 | }
|
---|
189 |
|
---|
190 | long SYS_fstat64(long a, long b) {
|
---|
191 | return shell_fstat((int)a, (struct stat *)b);
|
---|
192 | }
|
---|
193 |
|
---|
194 | long SYS_fsync(long a) {
|
---|
195 | return shell_fsync((int)a);
|
---|
196 | }
|
---|
197 |
|
---|
198 | long SYS_ftruncate64(long a, long b, long c) {
|
---|
199 | return shell_ftruncate((int)a, ((off_t)b << 32) | (off_t)c);
|
---|
200 | }
|
---|
201 |
|
---|
202 | long SYS_futex() {
|
---|
203 | int futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3);
|
---|
204 | return no_implement("futex\n");
|
---|
205 | }
|
---|
206 |
|
---|
207 | long SYS_futimesat() {
|
---|
208 | return no_implement("futimesat\n");
|
---|
209 | }
|
---|
210 |
|
---|
211 | long SYS_getcwd(long a, long b) {
|
---|
212 | return (long)shell_getcwd((char *)a, (size_t)b);
|
---|
213 | }
|
---|
214 |
|
---|
215 | long SYS_getdents64(long a, long b, long c) {
|
---|
216 | return shell_getdents((int)a, (struct dirent *)b, (size_t)c);
|
---|
217 | }
|
---|
218 |
|
---|
219 | long SYS_getpeername(long a, long b, long c) {
|
---|
220 | return shell_getpeername((int)a, (struct sockaddr *)b, (socklen_t *)c);
|
---|
221 | }
|
---|
222 |
|
---|
223 | long SYS_getsockname(long a, long b, long c) {
|
---|
224 | return shell_getsockname((int)a, (struct sockaddr *)b, (socklen_t *)c);
|
---|
225 | }
|
---|
226 |
|
---|
227 | long SYS_getpid() {
|
---|
228 | return shell_getpid();
|
---|
229 | }
|
---|
230 |
|
---|
231 | long SYS_getsockopt(long a, long b, long c, long d, long e) {
|
---|
232 | return shell_getsockopt((int)a, (int)b, (int)c, (void *)d, (socklen_t *)e);
|
---|
233 | }
|
---|
234 |
|
---|
235 | long SYS_gettid() {
|
---|
236 | return shell_gettid();
|
---|
237 | }
|
---|
238 |
|
---|
239 | long SYS_gettimeofday(long a, long b) {
|
---|
240 | return shell_gettimeofday((struct timeval *)a, (void *)b);
|
---|
241 | }
|
---|
242 |
|
---|
243 | long SYS_getuid32() {
|
---|
244 | return no_implement("getuid\n");
|
---|
245 | }
|
---|
246 |
|
---|
247 | long SYS_ioctl(long a, long b, long c) {
|
---|
248 | return shell_ioctl((int)a, (int)b, (void *)c);
|
---|
249 | }
|
---|
250 |
|
---|
251 | long SYS_kill(long a, long b) {
|
---|
252 | return shell_kill((int)a, (int)b);
|
---|
253 | }
|
---|
254 |
|
---|
255 | long SYS_link(long a, long b) {
|
---|
256 | return shell_link((const char *)a, (const char *)b);
|
---|
257 | }
|
---|
258 |
|
---|
259 | long SYS_listen(long a, long b) {
|
---|
260 | return shell_listen((int)a, (int)b);
|
---|
261 | }
|
---|
262 |
|
---|
263 | long SYS_lstat64(long a, long b) {
|
---|
264 | return shell_lstat((const char *__restrict)a, (struct stat *__restrict)b);
|
---|
265 | }
|
---|
266 |
|
---|
267 | long SYS_madvise(long a, long b, long c) {
|
---|
268 | return shell_madvise((void *)a, (size_t)b, (int)c);
|
---|
269 | }
|
---|
270 |
|
---|
271 | long SYS_mkdir(long a, long b) {
|
---|
272 | return shell_mkdir((const char *)a, (mode_t)b);
|
---|
273 | }
|
---|
274 |
|
---|
275 | long SYS_mmap2(long a, long b, long c, long d, long e, long f, long g) {
|
---|
276 | return (int)shell_mmap2((void *)a, (size_t)b, (int)c, (int)d, (int)e, ((off_t)f << 32) | (off_t)g);
|
---|
277 | }
|
---|
278 |
|
---|
279 | long SYS_mprotect(long a, long b, long c) {
|
---|
280 | return shell_mprotect((void *)a, (size_t)b, (int)c);
|
---|
281 | }
|
---|
282 |
|
---|
283 | long SYS_munmap() {
|
---|
284 | return no_implement("munmap\n");
|
---|
285 | }
|
---|
286 |
|
---|
287 | long SYS_open(long a, long b, long c) {
|
---|
288 | return shell_open((const char *)a, (int)b, (void *)c);
|
---|
289 | }
|
---|
290 |
|
---|
291 | long SYS_poll(long a, long b, long c) {
|
---|
292 | return shell_poll((struct pollfd *)a, (nfds_t)b, (int)c);
|
---|
293 | }
|
---|
294 |
|
---|
295 | long SYS_pread64() {
|
---|
296 | return no_implement("pread64\n");
|
---|
297 | }
|
---|
298 |
|
---|
299 | long SYS_pwrite64() {
|
---|
300 | return no_implement("pwrite64\n");
|
---|
301 | }
|
---|
302 |
|
---|
303 | long SYS_read(long a, long b, long c) {
|
---|
304 | return shell_read((int)a, (void *)b, (size_t)c);
|
---|
305 | }
|
---|
306 |
|
---|
307 | long SYS_readv(long a, long b, long c) {
|
---|
308 | return shell_readv((int)a, (const struct iovec *)b, (int)c);
|
---|
309 | }
|
---|
310 |
|
---|
311 | long SYS_recv(long a, long b, long c, long d) {
|
---|
312 | return shell_recvfrom((int)a, (void *)b, (size_t)c, (int)d, NULL, NULL);
|
---|
313 | }
|
---|
314 |
|
---|
315 | long SYS_recvfrom(long a, long b, long c, long d, long e, long f) {
|
---|
316 | return shell_recvfrom(a, (void *)b, (size_t)c, (int)d, (struct sockaddr *)e, (socklen_t *)f);
|
---|
317 | }
|
---|
318 |
|
---|
319 | long SYS_recvmsg(long a, long b, long c) {
|
---|
320 | return shell_recvmsg((int)a, (struct msghdr *)b, (size_t)c);
|
---|
321 | }
|
---|
322 |
|
---|
323 | long SYS_rename(long a, long b) {
|
---|
324 | return shell_rename((const char *)a, (const char *)b);
|
---|
325 | }
|
---|
326 |
|
---|
327 | long SYS_rmdir(long a) {
|
---|
328 | return shell_rmdir((const char *)a);
|
---|
329 | }
|
---|
330 |
|
---|
331 | long SYS_rt_sigaction(long a, long b, long c) {
|
---|
332 | return shell_sigaction((int)a, (const struct sigaction *)b, (struct sigaction *)c);
|
---|
333 | }
|
---|
334 |
|
---|
335 | long SYS_rt_sigprocmask(long a, long b, long c) {
|
---|
336 | return shell_sigprocmask((int)a, (const sigset_t *)b, (sigset_t *)c);
|
---|
337 | }
|
---|
338 |
|
---|
339 | long SYS_rt_sigqueueinfo() {
|
---|
340 | return no_implement("rt_sigqueueinfo\n");
|
---|
341 | }
|
---|
342 |
|
---|
343 | long SYS_send(long a, long b, long c, long d) {
|
---|
344 | return shell_sendto((int)a, (const void *)b, (size_t)c, (int)d, NULL, 0);
|
---|
345 | }
|
---|
346 |
|
---|
347 | long SYS_sendmsg(long a, long b, long c) {
|
---|
348 | return shell_sendmsg((int)a, (const struct msghdr *)b, (size_t)c);
|
---|
349 | }
|
---|
350 |
|
---|
351 | long SYS_sendto(long a, long b, long c, long d, long e, long f) {
|
---|
352 | return shell_sendto(a, (const void *)b, (size_t)c, (int)d, (const struct sockaddr *)e, (socklen_t)f);
|
---|
353 | }
|
---|
354 |
|
---|
355 | long SYS_setsockopt(long a, long b, long c, long d, long e) {
|
---|
356 | return shell_setsockopt((int)a, (int)b, (int)c, (const void *)d, (socklen_t)e);
|
---|
357 | }
|
---|
358 |
|
---|
359 | long SYS_shutdown(long a, long b) {
|
---|
360 | return shell_shutdown((int)a, (int)b);
|
---|
361 | }
|
---|
362 |
|
---|
363 | long SYS_sched_setscheduler() {
|
---|
364 | return no_implement("sched_setscheduler\n");
|
---|
365 | }
|
---|
366 |
|
---|
367 | long SYS_set_robust_list() {
|
---|
368 | return no_implement("set_robust_list\n");
|
---|
369 | }
|
---|
370 |
|
---|
371 | #ifdef SYS_set_thread_area
|
---|
372 | long SYS_set_thread_area(long a) {
|
---|
373 | thread_area = (void *)a;
|
---|
374 | return 0;
|
---|
375 | }
|
---|
376 | #endif
|
---|
377 |
|
---|
378 | long SYS_set_tid_address(long a) {
|
---|
379 | tid_address = (void *)a;
|
---|
380 | return 0;
|
---|
381 | }
|
---|
382 |
|
---|
383 | long SYS_socket(long a, long b, long c) {
|
---|
384 | return shell_socket((int)a, (int)b, (int)c);
|
---|
385 | }
|
---|
386 |
|
---|
387 | long SYS_stat64(long a, long b) {
|
---|
388 | return shell_stat((const char *)a, (struct stat *)b);
|
---|
389 | }
|
---|
390 |
|
---|
391 | long SYS_tkill(long a, long b) {
|
---|
392 | return shell_tkill((int)a, (int)b);
|
---|
393 | }
|
---|
394 |
|
---|
395 | long SYS_uname(long a) {
|
---|
396 | return shell_uname((struct utsname *)a);
|
---|
397 | }
|
---|
398 |
|
---|
399 | long SYS_unlink(long a) {
|
---|
400 | return shell_unlink((const char *)a);
|
---|
401 | }
|
---|
402 |
|
---|
403 | long SYS_utimensat() {
|
---|
404 | return no_implement("utimensat\n");
|
---|
405 | }
|
---|
406 |
|
---|
407 | long SYS_utimes() {
|
---|
408 | return no_implement("utimes\n");
|
---|
409 | }
|
---|
410 |
|
---|
411 | long SYS_write(long a, long b, long c) {
|
---|
412 | return shell_write((int)a, (const void *)b, (size_t)c);
|
---|
413 | }
|
---|
414 |
|
---|
415 | long SYS_writev(long a, long b, long c) {
|
---|
416 | return shell_writev((int)a, (const struct iovec *)b, (size_t)c);
|
---|
417 | }
|
---|
418 |
|
---|
419 | long SYS_dup()
|
---|
420 | {
|
---|
421 | return no_implement("dup\n");
|
---|
422 | }
|
---|
423 |
|
---|
424 | long SYS_dup2()
|
---|
425 | {
|
---|
426 | return no_implement("dup2\n");
|
---|
427 | }
|
---|
428 |
|
---|
429 | long SYS_pipe()
|
---|
430 | {
|
---|
431 | return no_implement("pipe\n");
|
---|
432 | }
|
---|
433 |
|
---|
434 | long SYS_readlink()
|
---|
435 | {
|
---|
436 | return no_implement("readlink\n");
|
---|
437 | }
|
---|
438 |
|
---|
439 | long SYS_symlink()
|
---|
440 | {
|
---|
441 | return no_implement("symlink\n");
|
---|
442 | }
|
---|
443 |
|
---|
444 | long SYS_umask()
|
---|
445 | {
|
---|
446 | return no_implement("umask\n");
|
---|
447 | }
|
---|
448 |
|
---|
449 | long SYS_execve()
|
---|
450 | {
|
---|
451 | return no_implement("execve\n");
|
---|
452 | }
|
---|
453 |
|
---|
454 | long SYS_fork()
|
---|
455 | {
|
---|
456 | return no_implement("fork\n");
|
---|
457 | }
|
---|
458 |
|
---|
459 | long SYS_wait4()
|
---|
460 | {
|
---|
461 | return no_implement("wait4\n");
|
---|
462 | }
|
---|
463 |
|
---|
464 | long SYS_socketpair()
|
---|
465 | {
|
---|
466 | return no_implement("socketpair\n");
|
---|
467 | }
|
---|
468 |
|
---|
469 | long SYS_flock()
|
---|
470 | {
|
---|
471 | return no_implement("flock\n");
|
---|
472 | }
|
---|
473 |
|
---|
474 | long ARM_SYS_cacheflush() {
|
---|
475 | flash_access_cache_control();
|
---|
476 | return 0;
|
---|
477 | }
|
---|
478 |
|
---|
479 | long ARM_SYS_set_tls(long a) {
|
---|
480 | thread_area = (void *)a;
|
---|
481 | __asm__ __volatile__("mcr p15,0,%0,c13,c0,3" :: "r"(thread_area));
|
---|
482 | return 0;
|
---|
483 | }
|
---|