This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathsyscall.c
843 lines (653 loc) · 15.6 KB
/
syscall.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
/*
* Copyright (c) 2010, Stefan Lankes, RWTH Aachen University
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <hermit/stddef.h>
#include <hermit/stdio.h>
#include <hermit/tasks.h>
#include <hermit/errno.h>
#include <hermit/syscall.h>
#include <hermit/spinlock.h>
#include <hermit/semaphore.h>
#include <hermit/time.h>
#include <hermit/rcce.h>
#include <hermit/memory.h>
#include <hermit/signal.h>
#include <hermit/logging.h>
#include <asm/uhyve.h>
#include <asm/io.h>
#include <sys/poll.h>
#include <lwip/sockets.h>
#include <lwip/err.h>
#include <lwip/stats.h>
/*
* Note that linker symbols are not variables, they have no memory allocated for
* maintaining a value, rather their address is their value.
*/
extern const void kernel_start;
//TODO: don't use one big kernel lock to comminicate with all proxies
static spinlock_irqsave_t lwip_lock = SPINLOCK_IRQSAVE_INIT;
extern spinlock_irqsave_t stdio_lock;
extern int32_t isle;
extern int32_t possible_isles;
extern volatile int libc_sd;
static inline int socket_send(int fd, const void* buf, size_t len)
{
int ret, sz = 0;
do {
ret = lwip_write(fd, (char*)buf + sz, len-sz);
if (ret >= 0)
sz += ret;
else
return ret;
} while(sz < len);
return len;
}
static inline int socket_recv(int fd, void* buf, size_t len)
{
int ret, sz = 0;
do {
ret = lwip_read(fd, (char*)buf + sz, len-sz);
if (ret >= 0)
sz += ret;
else
return ret;
} while(sz < len);
return len;
}
tid_t sys_getpid(void)
{
task_t* task = per_core(current_task);
return task->id;
}
int sys_getprio(tid_t* id)
{
task_t* task = per_core(current_task);
if (!id || (task->id == *id))
return task->prio;
return -EINVAL;
}
int sys_setprio(tid_t* id, int prio)
{
return -ENOSYS;
}
void NORETURN do_exit(int arg);
typedef struct {
int sysnr;
int arg;
} __attribute__((packed)) sys_exit_t;
/** @brief To be called by the systemcall to exit tasks */
void NORETURN sys_exit(int arg)
{
if (is_uhyve()) {
uhyve_send(UHYVE_PORT_EXIT, (unsigned) virt_to_phys((size_t) &arg));
} else {
sys_exit_t sysargs = {__NR_exit, arg};
spinlock_irqsave_lock(&lwip_lock);
if (libc_sd >= 0)
{
int s = libc_sd;
socket_send(s, &sysargs, sizeof(sysargs));
libc_sd = -1;
spinlock_irqsave_unlock(&lwip_lock);
// switch to LwIP thread
reschedule();
lwip_close(s);
} else {
spinlock_irqsave_unlock(&lwip_lock);
}
}
do_exit(arg);
}
typedef struct {
int sysnr;
int fd;
size_t len;
} __attribute__((packed)) sys_read_t;
typedef struct {
int fd;
char* buf;
size_t len;
ssize_t ret;
} __attribute__((packed)) uhyve_read_t;
ssize_t sys_read(int fd, char* buf, size_t len)
{
sys_read_t sysargs = {__NR_read, fd, len};
ssize_t j, ret;
// do we have an LwIP file descriptor?
if (fd & LWIP_FD_BIT) {
spinlock_irqsave_lock(&lwip_lock);
ret = lwip_read(fd & ~LWIP_FD_BIT, buf, len);
spinlock_irqsave_unlock(&lwip_lock);
if (ret < 0)
return -errno;
return ret;
}
if (is_uhyve()) {
uhyve_read_t uhyve_args = {fd, (char*) buf, len, -1};
uhyve_send(UHYVE_PORT_READ, (unsigned)virt_to_phys((size_t)&uhyve_args));
return uhyve_args.ret;
}
if (libc_sd < 0)
return -ENOSYS;
spinlock_irqsave_lock(&lwip_lock);
int s = libc_sd;
socket_send(s, &sysargs, sizeof(sysargs));
socket_recv(s, &j, sizeof(j));
ssize_t i=0;
while(i < j)
{
ret = lwip_read(s, (char*)buf+i, j-i);
if (ret < 0) {
spinlock_irqsave_unlock(&lwip_lock);
return ret;
}
i += ret;
}
spinlock_irqsave_unlock(&lwip_lock);
return j;
}
ssize_t readv(int d, const struct iovec *iov, int iovcnt)
{
return -ENOSYS;
}
typedef struct {
int sysnr;
int fd;
size_t len;
} __attribute__((packed)) sys_write_t;
typedef struct {
int fd;
const char* buf;
size_t len;
} __attribute__((packed)) uhyve_write_t;
ssize_t sys_write(int fd, const char* buf, size_t len)
{
if (BUILTIN_EXPECT(!buf, 0))
return -EINVAL;
ssize_t i, ret;
sys_write_t sysargs = {__NR_write, fd, len};
// do we have an LwIP file descriptor?
if (fd & LWIP_FD_BIT) {
spinlock_irqsave_lock(&lwip_lock);
ret = lwip_write(fd & ~LWIP_FD_BIT, buf, len);
spinlock_irqsave_unlock(&lwip_lock);
if (ret < 0)
return -errno;
return ret;
}
if (is_uhyve()) {
uhyve_write_t uhyve_args = {fd, (const char*) buf, len};
uhyve_send(UHYVE_PORT_WRITE, (unsigned)virt_to_phys((size_t)&uhyve_args));
return uhyve_args.len;
}
if (libc_sd < 0)
{
spinlock_irqsave_lock(&stdio_lock);
for(i=0; i<len; i++)
kputchar(buf[i]);
spinlock_irqsave_unlock(&stdio_lock);
return len;
}
spinlock_irqsave_lock(&lwip_lock);
int s = libc_sd;
socket_send(s, &sysargs, sizeof(sysargs));
i=0;
while(i < len)
{
ret = lwip_write(s, (char*)buf+i, len-i);
if (ret < 0) {
spinlock_irqsave_unlock(&lwip_lock);
return ret;
}
i += ret;
}
if (fd > 2)
{
int temp = socket_recv(s, &i, sizeof(i));
if (temp < 0)
{
return (ssize_t) temp;
}
}
spinlock_irqsave_unlock(&lwip_lock);
return i;
}
ssize_t writev(int fildes, const struct iovec *iov, int iovcnt)
{
return -ENOSYS;
}
ssize_t sys_sbrk(ssize_t incr)
{
ssize_t ret;
vma_t* heap = per_core(current_task)->heap;
static spinlock_t heap_lock = SPINLOCK_INIT;
if (BUILTIN_EXPECT(!heap, 0)) {
LOG_ERROR("sys_sbrk: missing heap!\n");
do_abort();
}
spinlock_lock(&heap_lock);
ret = heap->end;
// check heapp boundaries
if ((heap->end >= HEAP_START) && (heap->end+incr < HEAP_START + HEAP_SIZE)) {
heap->end += incr;
// reserve VMA regions
if (PAGE_FLOOR(heap->end) > PAGE_FLOOR(ret)) {
// region is already reserved for the heap, we have to change the
// property
vma_free(PAGE_FLOOR(ret), PAGE_CEIL(heap->end));
vma_add(PAGE_FLOOR(ret), PAGE_CEIL(heap->end), VMA_HEAP|VMA_USER);
}
} else ret = -ENOMEM;
// allocation and mapping of new pages for the heap
// is catched by the pagefault handler
spinlock_unlock(&heap_lock);
return ret;
}
typedef struct {
const char* name;
int flags;
int mode;
int ret;
} __attribute__((packed)) uhyve_open_t;
int sys_open(const char* name, int flags, int mode)
{
if (is_uhyve()) {
uhyve_open_t uhyve_open = {(const char*)virt_to_phys((size_t)name), flags, mode, -1};
uhyve_send(UHYVE_PORT_OPEN, (unsigned)virt_to_phys((size_t) &uhyve_open));
return uhyve_open.ret;
}
int s, i, ret, sysnr = __NR_open;
size_t len;
spinlock_irqsave_lock(&lwip_lock);
if (libc_sd < 0) {
ret = -EINVAL;
goto out;
}
s = libc_sd;
len = strlen(name)+1;
//i = 0;
//lwip_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i));
ret = socket_send(s, &sysnr, sizeof(sysnr));
if (ret < 0)
goto out;
ret = socket_send(s, &len, sizeof(len));
if (ret < 0)
goto out;
i=0;
while(i<len)
{
ret = socket_send(s, name+i, len-i);
if (ret < 0)
goto out;
i += ret;
}
ret = socket_send(s, &flags, sizeof(flags));
if (ret < 0)
goto out;
ret = socket_send(s, &mode, sizeof(mode));
if (ret < 0)
goto out;
//i = 1;
//lwip_setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &i, sizeof(i));
socket_recv(s, &ret, sizeof(ret));
out:
spinlock_irqsave_unlock(&lwip_lock);
return ret;
}
typedef struct {
int sysnr;
int fd;
} __attribute__((packed)) sys_close_t;
typedef struct {
int fd;
int ret;
} __attribute__((packed)) uhyve_close_t;
int sys_close(int fd)
{
int ret, s;
sys_close_t sysargs = {__NR_close, fd};
// do we have an LwIP file descriptor?
if (fd & LWIP_FD_BIT) {
ret = lwip_close(fd & ~LWIP_FD_BIT);
if (ret < 0)
return -errno;
return 0;
}
if (is_uhyve()) {
uhyve_close_t uhyve_close = {fd, -1};
uhyve_send(UHYVE_PORT_CLOSE, (unsigned)virt_to_phys((size_t) &uhyve_close));
return uhyve_close.ret;
}
spinlock_irqsave_lock(&lwip_lock);
if (libc_sd < 0) {
ret = 0;
goto out;
}
s = libc_sd;
ret = socket_send(s, &sysargs, sizeof(sysargs));
if (ret != sizeof(sysargs))
goto out;
socket_recv(s, &ret, sizeof(ret));
out:
spinlock_irqsave_unlock(&lwip_lock);
return ret;
}
int sys_spinlock_init(spinlock_t** lock)
{
int ret;
if (BUILTIN_EXPECT(!lock, 0))
return -EINVAL;
*lock = (spinlock_t*) kmalloc(sizeof(spinlock_t));
if (BUILTIN_EXPECT(!(*lock), 0))
return -ENOMEM;
ret = spinlock_init(*lock);
if (ret) {
kfree(*lock);
*lock = NULL;
}
return ret;
}
int sys_spinlock_destroy(spinlock_t* lock)
{
int ret;
if (BUILTIN_EXPECT(!lock, 0))
return -EINVAL;
ret = spinlock_destroy(lock);
if (!ret)
kfree(lock);
return ret;
}
int sys_spinlock_lock(spinlock_t* lock)
{
if (BUILTIN_EXPECT(!lock, 0))
return -EINVAL;
return spinlock_lock(lock);
}
int sys_spinlock_unlock(spinlock_t* lock)
{
if (BUILTIN_EXPECT(!lock, 0))
return -EINVAL;
return spinlock_unlock(lock);
}
void sys_msleep(unsigned int ms)
{
if (ms * TIMER_FREQ / 1000 > 0)
timer_wait(ms * TIMER_FREQ / 1000);
else if (ms > 0)
udelay(ms * 1000);
}
int sys_sem_init(sem_t** sem, unsigned int value)
{
int ret;
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
*sem = (sem_t*) kmalloc(sizeof(sem_t));
if (BUILTIN_EXPECT(!(*sem), 0))
return -ENOMEM;
ret = sem_init(*sem, value);
if (ret) {
kfree(*sem);
*sem = NULL;
}
return ret;
}
int sys_sem_destroy(sem_t* sem)
{
int ret;
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
ret = sem_destroy(sem);
if (!ret)
kfree(sem);
return ret;
}
int sys_sem_wait(sem_t* sem)
{
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
return sem_wait(sem, 0);
}
int sys_sem_post(sem_t* sem)
{
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
return sem_post(sem);
}
int sys_sem_timedwait(sem_t *sem, unsigned int ms)
{
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
return sem_wait(sem, ms);
}
int sys_sem_cancelablewait(sem_t* sem, unsigned int ms)
{
if (BUILTIN_EXPECT(!sem, 0))
return -EINVAL;
return sem_wait(sem, ms);
}
int sys_clone(tid_t* id, void* ep, void* argv)
{
return clone_task(id, ep, argv, per_core(current_task)->prio);
}
typedef struct {
int sysnr;
int fd;
off_t offset;
int whence;
} __attribute__((packed)) sys_lseek_t;
typedef struct {
int fd;
off_t offset;
int whence;
} __attribute__((packed)) uhyve_lseek_t;
off_t sys_lseek(int fd, off_t offset, int whence)
{
if (is_uhyve()) {
uhyve_lseek_t uhyve_lseek = { fd, offset, whence };
outportl(UHYVE_PORT_LSEEK, (unsigned)virt_to_phys((size_t) &uhyve_lseek));
return uhyve_lseek.offset;
}
off_t off;
sys_lseek_t sysargs = {__NR_lseek, fd, offset, whence};
int s;
spinlock_irqsave_lock(&lwip_lock);
if (libc_sd < 0) {
spinlock_irqsave_unlock(&lwip_lock);
return -ENOSYS;
}
s = libc_sd;
socket_send(s, &sysargs, sizeof(sysargs));
socket_recv(s, &off, sizeof(off));
spinlock_irqsave_unlock(&lwip_lock);
return off;
}
int sys_rcce_init(int session_id)
{
int i, err = 0;
size_t paddr = 0;
if (is_single_kernel())
return -ENOSYS;
if (session_id <= 0)
return -EINVAL;
islelock_lock(rcce_lock);
for(i=0; i<MAX_RCCE_SESSIONS; i++)
{
if (rcce_mpb[i].id == session_id)
break;
}
// create new session
if (i >=MAX_RCCE_SESSIONS)
{
for(i=0; i<MAX_RCCE_SESSIONS; i++)
{
if (rcce_mpb[i].id == 0) {
rcce_mpb[i].id = session_id;
break;
}
}
}
if (i >= MAX_RCCE_SESSIONS)
{
err = -EINVAL;
goto out;
}
if (is_hbmem_available())
paddr = hbmem_get_pages(RCCE_MPB_SIZE / PAGE_SIZE);
else
paddr = get_pages(RCCE_MPB_SIZE / PAGE_SIZE);
if (BUILTIN_EXPECT(!paddr, 0))
{
err = -ENOMEM;
goto out;
}
rcce_mpb[i].mpb[isle] = paddr;
out:
islelock_unlock(rcce_lock);
LOG_INFO("Create MPB for session %d at 0x%zx, using of slot %d\n", session_id, paddr, i);
return err;
}
size_t sys_rcce_malloc(int session_id, int ue)
{
size_t vaddr = 0;
int i, counter = 0;
if (is_single_kernel())
return -ENOSYS;
if (session_id <= 0)
return -EINVAL;
// after 120 retries (= 120*300 ms) we give up
do {
for(i=0; i<MAX_RCCE_SESSIONS; i++)
{
if ((rcce_mpb[i].id == session_id) && rcce_mpb[i].mpb[ue])
break;
}
if (i >= MAX_RCCE_SESSIONS) {
counter++;
timer_wait((300*TIMER_FREQ)/1000);
}
} while((i >= MAX_RCCE_SESSIONS) && (counter < 120));
LOG_DEBUG("i = %d, counter = %d, max %d\n", i, counter, MAX_RCCE_SESSIONS);
// create new session
if (i >= MAX_RCCE_SESSIONS)
goto out;
vaddr = vma_alloc(RCCE_MPB_SIZE, VMA_READ|VMA_WRITE|VMA_USER|VMA_CACHEABLE);
if (BUILTIN_EXPECT(!vaddr, 0))
goto out;
if (page_map(vaddr, rcce_mpb[i].mpb[ue], RCCE_MPB_SIZE / PAGE_SIZE, PG_RW|PG_USER|PG_PRESENT)) {
vma_free(vaddr, vaddr + 2*PAGE_SIZE);
goto out;
}
LOG_INFO("Map MPB of session %d at 0x%zx, using of slot %d, isle %d\n", session_id, vaddr, i, ue);
if (isle == ue)
memset((void*)vaddr, 0x0, RCCE_MPB_SIZE);
return vaddr;
out:
LOG_ERROR("Didn't find a valid MPB for session %d, isle %d\n", session_id, ue);
return 0;
}
int sys_rcce_fini(int session_id)
{
int i, j;
int ret = 0;
// we have to free the MPB
if (is_single_kernel())
return -ENOSYS;
if (session_id <= 0)
return -EINVAL;
islelock_lock(rcce_lock);
for(i=0; i<MAX_RCCE_SESSIONS; i++)
{
if (rcce_mpb[i].id == session_id)
break;
}
if (i >= MAX_RCCE_SESSIONS) {
ret = -EINVAL;
goto out;
}
if (rcce_mpb[i].mpb[isle]) {
if (is_hbmem_available())
hbmem_put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE);
else
put_pages(rcce_mpb[i].mpb[isle], RCCE_MPB_SIZE / PAGE_SIZE);
}
rcce_mpb[i].mpb[isle] = 0;
for(j=0; (j<MAX_ISLE) && !rcce_mpb[i].mpb[j]; j++) {
PAUSE;
}
// rest full session
if (j >= MAX_ISLE)
rcce_mpb[i].id = 0;
out:
islelock_unlock(rcce_lock);
return ret;
}
size_t sys_get_ticks(void)
{
return get_clock_tick();
}
int sys_stat(const char* file, /*struct stat *st*/ void* st)
{
return -ENOSYS;
}
void sys_yield(void)
{
#if 0
check_workqueues();
#else
if (BUILTIN_EXPECT(go_down, 0))
shutdown_system();
check_scheduling();
#endif
}
int sys_kill(tid_t dest, int signum)
{
if(signum < 0) {
return -EINVAL;
}
return hermit_kill(dest, signum);
}
int sys_signal(signal_handler_t handler)
{
return hermit_signal(handler);
}
static spinlock_irqsave_t malloc_lock = SPINLOCK_IRQSAVE_INIT;
void __sys_malloc_lock(void)
{
spinlock_irqsave_lock(&malloc_lock);
}
void __sys_malloc_unlock(void)
{
spinlock_irqsave_unlock(&malloc_lock);
}
static spinlock_irqsave_t env_lock = SPINLOCK_IRQSAVE_INIT;
void __sys_env_lock(void)
{
spinlock_irqsave_lock(&env_lock);
}
void __sys_env_unlock(void)
{
spinlock_irqsave_unlock(&env_lock);
}