Changeset 23 for trunk/kernel/syscalls/sys_undefined.c
- Timestamp:
- Jun 18, 2017, 10:06:41 PM (6 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/syscalls/sys_undefined.c
r15 r23 1 1 /* 2 * kern/sys_dma_memcpy.c - exported DMA access to user process2 * sys_undefined.c - function executed for an undefined syscall. 3 3 * 4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless 5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites 4 * Author Alain Greiner (2016,2017) 6 5 * 7 * This file is part of ALMOS-kernel.6 * Copyright (c) UPMC Sorbonne Universites 8 7 * 9 * ALMOS-kernel is free software; you can redistribute it and/or modify it 8 * This file is part of ALMOS-MKH. 9 * 10 * ALMOS-MKH is free software; you can redistribute it and/or modify it 10 11 * under the terms of the GNU General Public License as published by 11 12 * the Free Software Foundation; version 2.0 of the License. 12 13 * 13 * ALMOS- kernelis distributed in the hope that it will be useful, but14 * ALMOS-MKH is distributed in the hope that it will be useful, but 14 15 * WITHOUT ANY WARRANTY; without even the implied warranty of 15 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU … … 17 18 * 18 19 * You should have received a copy of the GNU General Public License 19 * along with ALMOS- kernel; if not, write to the Free Software Foundation,20 * along with ALMOS-MKH; if not, write to the Free Software Foundation, 20 21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 22 23 23 24 #include <errno.h> 24 #include <types.h>25 #include <event.h>26 #include <chdev.h>27 #include <driver.h>28 #include <kmem.h>29 #include <kdmsg.h>30 #include <dma.h>31 #include <kcm.h>32 25 #include <thread.h> 33 #include < cluster.h>34 #include < kcm.h>26 #include <process.h> 27 #include <printk.h> 35 28 29 /////////////////// 30 int sys_undefined() 31 { 32 thread_t * this = CURRENT_THREAD; 33 process_t * process = this->process; 36 34 37 KMEM_OBJATTR_INIT(dma_kmem_request_init) 38 { 39 attr->type = KMEM_DMA_REQUEST; 40 attr->name = "KCM Dev-Request"; 41 attr->size = sizeof(dev_request_t); 42 attr->aligne = 0; 43 attr->min = CONFIG_DMA_RQ_KCM_MIN; 44 attr->max = CONFIG_DMA_RQ_KCM_MAX; 45 attr->ctor = NULL; 46 attr->dtor = NULL; 47 48 return 0; 35 printk("\n[ERROR] in %s : undefined syscall calle by thread %x in process %x\n", 36 __FUNCTION__ , this->trdid , process->pid ); 37 this->errno = EINVAL; 38 return -1; 49 39 } 50 51 static EVENT_HANDLER(dma_async_request_event)52 {53 kmem_req_t req;54 error_t err;55 56 if((err=event_get_error(event)) != 0)57 printk(ERROR, "ERROR: dma_async_request_event: DMA transfare is not well completed, remaining %d\n", err);58 59 req.type = KMEM_DMA_REQUEST;60 req.ptr = event_get_argument(event);61 62 assert(req.ptr != NULL && "Corrupted argument, expected the address of request");63 64 kmem_free(&req);65 return 0;66 }67 68 static inline error_t dma_do_async_request(void *dst, void *src, size_t size)69 {70 kmem_req_t req;71 dev_request_t *rq;72 73 req.type = KMEM_DMA_REQUEST;74 req.size = sizeof(*rq);75 req.flags = AF_KERNEL;76 77 if((rq = kmem_alloc(&req)) == NULL)78 return ENOMEM;79 80 memset(rq, 0, sizeof(*rq));81 82 rq->src = src;83 rq->dst = dst;84 rq->count = size;85 rq->flags = DEV_RQ_NOBLOCK;86 87 event_set_priority(&rq->event, E_FUNC);88 event_set_handler(&rq->event, &dma_async_request_event);89 event_set_argument(&rq->event, rq);90 91 return __sys_dma->op.dev.write(__sys_dma, rq);92 }93 94 static inline error_t dma_do_sync_request(void *dst, void *src, size_t size)95 {96 dev_request_t rq;97 98 rq.src = src;99 rq.dst = dst;100 rq.count = size;101 rq.flags = 0;102 103 return __sys_dma->op.dev.write(__sys_dma, &rq);104 }105 106 107 error_t dma_memcpy(void *dst, void *src, size_t size, uint_t isAsync)108 {109 if(isAsync == DMA_ASYNC)110 return dma_do_async_request(dst, src, size);111 else112 return dma_do_sync_request(dst, src, size);113 }114 115 116 int sys_dma_memcpy(void *src, void *dst, size_t size)117 {118 return dma_do_sync_request(dst, src, size);119 }
Note: See TracChangeset
for help on using the changeset viewer.