writev and some fixes
This commit is contained in:
@ -1,4 +1,5 @@
|
|||||||
BUILD_TARGET = mee knf
|
#BUILD_TARGET = mee knf
|
||||||
|
BUILD_TARGET = knf
|
||||||
SRC = $(CURDIR)
|
SRC = $(CURDIR)
|
||||||
|
|
||||||
AALBASE ?= $(SRC)/../../aal/manycore
|
AALBASE ?= $(SRC)/../../aal/manycore
|
||||||
|
|||||||
27
kernel/include/uio.h
Normal file
27
kernel/include/uio.h
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#ifndef __UIO_H
|
||||||
|
#define __UIO_H
|
||||||
|
|
||||||
|
struct iovec
|
||||||
|
{
|
||||||
|
void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */
|
||||||
|
size_t iov_len; /* Must be size_t (1003.1g) */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Total number of bytes covered by an iovec.
|
||||||
|
*
|
||||||
|
* NOTE that it is not safe to use this function until all the iovec's
|
||||||
|
* segment lengths have been validated. Because the individual lengths can
|
||||||
|
* overflow a size_t when added together.
|
||||||
|
*/
|
||||||
|
static inline size_t iov_length(const struct iovec *iov, unsigned long nr_segs)
|
||||||
|
{
|
||||||
|
unsigned long seg;
|
||||||
|
size_t ret = 0;
|
||||||
|
|
||||||
|
for (seg = 0; seg < nr_segs; seg++)
|
||||||
|
ret += iov[seg].iov_len;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -9,6 +9,17 @@
|
|||||||
#include <syscall.h>
|
#include <syscall.h>
|
||||||
#include <page.h>
|
#include <page.h>
|
||||||
#include <amemcpy.h>
|
#include <amemcpy.h>
|
||||||
|
#include <uio.h>
|
||||||
|
|
||||||
|
#define SYSCALL_BY_IKC
|
||||||
|
|
||||||
|
#define DEBUG_PRINT_SC
|
||||||
|
|
||||||
|
#ifdef DEBUG_PRINT_SC
|
||||||
|
#define dkprintf kprintf
|
||||||
|
#else
|
||||||
|
#define dkprintf(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
int memcpy_async(unsigned long dest, unsigned long src,
|
int memcpy_async(unsigned long dest, unsigned long src,
|
||||||
unsigned long len, int wait, unsigned long *notify);
|
unsigned long len, int wait, unsigned long *notify);
|
||||||
@ -45,15 +56,23 @@ static void send_syscall(struct syscall_request *req)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_syscall(struct syscall_request *req)
|
static int do_syscall(struct syscall_request *req, aal_mc_user_context_t *ctx)
|
||||||
{
|
{
|
||||||
struct syscall_response *res = cpu_local_var(scp).response_va;
|
struct syscall_response *res = cpu_local_var(scp).response_va;
|
||||||
|
|
||||||
send_syscall(req);
|
send_syscall(req);
|
||||||
|
|
||||||
|
dkprintf("SC(%d)[%3d] waiting for host.. \n",
|
||||||
|
aal_mc_get_processor_id(),
|
||||||
|
req->number);
|
||||||
|
|
||||||
while (!res->status) {
|
while (!res->status) {
|
||||||
cpu_pause();
|
cpu_pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dkprintf("SC(%d)[%3d] got host reply: %d \n",
|
||||||
|
aal_mc_get_processor_id(),
|
||||||
|
req->number, res->ret);
|
||||||
|
|
||||||
return res->ret;
|
return res->ret;
|
||||||
}
|
}
|
||||||
@ -105,7 +124,7 @@ long sys_brk(int n, aal_mc_user_context_t *ctx)
|
|||||||
SYSCALL_ARG_##a0(0); SYSCALL_ARG_##a1(1); \
|
SYSCALL_ARG_##a0(0); SYSCALL_ARG_##a1(1); \
|
||||||
SYSCALL_ARG_##a2(2); SYSCALL_ARG_##a3(3)
|
SYSCALL_ARG_##a2(2); SYSCALL_ARG_##a3(3)
|
||||||
|
|
||||||
#define SYSCALL_FOOTER return do_syscall(&request)
|
#define SYSCALL_FOOTER return do_syscall(&request, ctx)
|
||||||
|
|
||||||
SYSCALL_DECLARE(fstat)
|
SYSCALL_DECLARE(fstat)
|
||||||
{
|
{
|
||||||
@ -187,7 +206,7 @@ SYSCALL_DECLARE(lseek)
|
|||||||
SYSCALL_DECLARE(exit_group)
|
SYSCALL_DECLARE(exit_group)
|
||||||
{
|
{
|
||||||
SYSCALL_HEADER;
|
SYSCALL_HEADER;
|
||||||
do_syscall(&request);
|
do_syscall(&request, ctx);
|
||||||
|
|
||||||
free_process_memory(cpu_local_var(current));
|
free_process_memory(cpu_local_var(current));
|
||||||
cpu_local_var(next) = &cpu_local_var(idle);
|
cpu_local_var(next) = &cpu_local_var(idle);
|
||||||
@ -218,7 +237,7 @@ SYSCALL_DECLARE(mmap)
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kprintf("Non-anonymous mmap: fd = %lx, %lx\n",
|
dkprintf("Non-anonymous mmap: fd = %lx, %lx\n",
|
||||||
aal_mc_syscall_arg4(ctx), aal_mc_syscall_arg5(ctx));
|
aal_mc_syscall_arg4(ctx), aal_mc_syscall_arg5(ctx));
|
||||||
while(1);
|
while(1);
|
||||||
}
|
}
|
||||||
@ -243,6 +262,7 @@ SYSCALL_DECLARE(uname)
|
|||||||
{
|
{
|
||||||
SYSCALL_HEADER;
|
SYSCALL_HEADER;
|
||||||
unsigned long phys;
|
unsigned long phys;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table,
|
if (aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table,
|
||||||
(void *)aal_mc_syscall_arg0(ctx), &phys)) {
|
(void *)aal_mc_syscall_arg0(ctx), &phys)) {
|
||||||
@ -252,7 +272,9 @@ SYSCALL_DECLARE(uname)
|
|||||||
request.number = n;
|
request.number = n;
|
||||||
request.args[0] = phys;
|
request.args[0] = phys;
|
||||||
|
|
||||||
return do_syscall(&request);
|
ret = do_syscall(&request, ctx);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
long sys_getxid(int n, aal_mc_user_context_t *ctx)
|
long sys_getxid(int n, aal_mc_user_context_t *ctx)
|
||||||
@ -261,7 +283,7 @@ long sys_getxid(int n, aal_mc_user_context_t *ctx)
|
|||||||
|
|
||||||
request.number = n;
|
request.number = n;
|
||||||
|
|
||||||
return do_syscall(&request);
|
return do_syscall(&request, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
long sys_arch_prctl(int n, aal_mc_user_context_t *ctx)
|
long sys_arch_prctl(int n, aal_mc_user_context_t *ctx)
|
||||||
@ -293,7 +315,7 @@ SYSCALL_DECLARE(clone)
|
|||||||
aal_mc_syscall_arg1(ctx));
|
aal_mc_syscall_arg1(ctx));
|
||||||
/* XXX Assign new pid! */
|
/* XXX Assign new pid! */
|
||||||
new->pid = cpu_local_var(current)->pid;
|
new->pid = cpu_local_var(current)->pid;
|
||||||
kprintf("Cloned: %p \n", new);
|
dkprintf("Cloned: %p \n", new);
|
||||||
|
|
||||||
aal_mc_syscall_ret(new->uctx) = 0;
|
aal_mc_syscall_ret(new->uctx) = 0;
|
||||||
|
|
||||||
@ -301,11 +323,50 @@ SYSCALL_DECLARE(clone)
|
|||||||
request.number = n;
|
request.number = n;
|
||||||
request.args[0] = (unsigned long)new;
|
request.args[0] = (unsigned long)new;
|
||||||
/* Sync */
|
/* Sync */
|
||||||
do_syscall(&request);
|
do_syscall(&request, ctx);
|
||||||
kprintf("Clone ret.\n");
|
dkprintf("Clone ret.\n");
|
||||||
return new->pid;
|
return new->pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SYSCALL_DECLARE(writev)
|
||||||
|
{
|
||||||
|
/* Adhoc implementation of writev calling write sequentially */
|
||||||
|
struct syscall_request request AAL_DMA_ALIGN;
|
||||||
|
unsigned long seg;
|
||||||
|
size_t seg_ret, ret = 0;
|
||||||
|
|
||||||
|
int fd = aal_mc_syscall_arg0(ctx);
|
||||||
|
struct iovec *iov = (struct iovec*)aal_mc_syscall_arg1(ctx);
|
||||||
|
unsigned long nr_segs = aal_mc_syscall_arg2(ctx);
|
||||||
|
|
||||||
|
for (seg = 0; seg < nr_segs; ++seg) {
|
||||||
|
unsigned long __phys;
|
||||||
|
|
||||||
|
if (aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table,
|
||||||
|
(void *)iov[seg].iov_base, &__phys)) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.number = 1; /* write */
|
||||||
|
request.args[0] = fd;
|
||||||
|
request.args[1] = __phys;
|
||||||
|
request.args[2] = iov[seg].iov_len;
|
||||||
|
|
||||||
|
seg_ret = do_syscall(&request, ctx);
|
||||||
|
|
||||||
|
if (seg_ret < 0) {
|
||||||
|
ret = -EFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret += seg_ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static long (*syscall_table[])(int, aal_mc_user_context_t *) = {
|
static long (*syscall_table[])(int, aal_mc_user_context_t *) = {
|
||||||
[0] = sys_read,
|
[0] = sys_read,
|
||||||
[1] = sys_write,
|
[1] = sys_write,
|
||||||
@ -319,6 +380,7 @@ static long (*syscall_table[])(int, aal_mc_user_context_t *) = {
|
|||||||
[16] = sys_ioctl,
|
[16] = sys_ioctl,
|
||||||
[17] = sys_pread,
|
[17] = sys_pread,
|
||||||
[18] = sys_pwrite,
|
[18] = sys_pwrite,
|
||||||
|
[20] = sys_writev,
|
||||||
[39] = sys_getpid,
|
[39] = sys_getpid,
|
||||||
[56] = sys_clone,
|
[56] = sys_clone,
|
||||||
[63] = sys_uname,
|
[63] = sys_uname,
|
||||||
@ -338,27 +400,23 @@ long syscall(int num, aal_mc_user_context_t *ctx)
|
|||||||
|
|
||||||
cpu_enable_interrupt();
|
cpu_enable_interrupt();
|
||||||
|
|
||||||
#ifdef DEBUG_PRINT_SC
|
dkprintf("SC(%d)[%3d](%lx, %lx) @ %lx | %lx = ",
|
||||||
kprintf("SC(%d)[%3d](%lx, %lx) @ %lx | %lx = ",
|
|
||||||
aal_mc_get_processor_id(),
|
aal_mc_get_processor_id(),
|
||||||
num,
|
num,
|
||||||
aal_mc_syscall_arg0(ctx), aal_mc_syscall_arg1(ctx),
|
aal_mc_syscall_arg0(ctx), aal_mc_syscall_arg1(ctx),
|
||||||
aal_mc_syscall_pc(ctx), aal_mc_syscall_sp(ctx));
|
aal_mc_syscall_pc(ctx), aal_mc_syscall_sp(ctx));
|
||||||
#endif
|
|
||||||
|
|
||||||
if (syscall_table[num]) {
|
if (syscall_table[num]) {
|
||||||
l = syscall_table[num](num, ctx);
|
l = syscall_table[num](num, ctx);
|
||||||
#ifdef DEBUG_PRINT_SC
|
dkprintf(" %lx\n", l);
|
||||||
kprintf(" %lx\n", l);
|
|
||||||
#endif
|
|
||||||
return l;
|
return l;
|
||||||
} else {
|
} else {
|
||||||
kprintf("USC[%3d](%lx, %lx, %lx, %lx, %lx) @ %lx | %lx\n", num,
|
dkprintf("USC[%3d](%lx, %lx, %lx, %lx, %lx) @ %lx | %lx\n", num,
|
||||||
aal_mc_syscall_arg0(ctx), aal_mc_syscall_arg1(ctx),
|
aal_mc_syscall_arg0(ctx), aal_mc_syscall_arg1(ctx),
|
||||||
aal_mc_syscall_arg2(ctx), aal_mc_syscall_arg3(ctx),
|
aal_mc_syscall_arg2(ctx), aal_mc_syscall_arg3(ctx),
|
||||||
aal_mc_syscall_arg4(ctx), aal_mc_syscall_pc(ctx),
|
aal_mc_syscall_arg4(ctx), aal_mc_syscall_pc(ctx),
|
||||||
aal_mc_syscall_sp(ctx));
|
aal_mc_syscall_sp(ctx));
|
||||||
while(1);
|
//while(1);
|
||||||
return -ENOSYS;
|
return -ENOSYS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
CFLAGS = -O3
|
CFLAGS = -O3 -Wall -g
|
||||||
|
|
||||||
all: mcexec
|
all: mcexec
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,8 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
|
|
||||||
|
#define DEBUG
|
||||||
|
|
||||||
#ifndef DEBUG
|
#ifndef DEBUG
|
||||||
#define __dprint(msg, ...)
|
#define __dprint(msg, ...)
|
||||||
#define __dprintf(arg, ...)
|
#define __dprintf(arg, ...)
|
||||||
@ -220,9 +222,9 @@ int main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Error: Failed to open /dev/mcctrl.\n");
|
fprintf(stderr, "Error: Failed to open /dev/mcctrl.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
fdm = open("/dev/mem", O_RDWR);
|
fdm = open("/dev/fmem", O_RDWR);
|
||||||
if (fdm < 0) {
|
if (fdm < 0) {
|
||||||
fprintf(stderr, "Error: Failed to open /dev/mem.\n");
|
fprintf(stderr, "Error: Failed to open /dev/fmem.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,14 +301,20 @@ int main_loop(int fd, int cpu)
|
|||||||
w.cpu = cpu;
|
w.cpu = cpu;
|
||||||
|
|
||||||
while (ioctl(fd, MCEXEC_UP_WAIT_SYSCALL, (unsigned long)&w) == 0) {
|
while (ioctl(fd, MCEXEC_UP_WAIT_SYSCALL, (unsigned long)&w) == 0) {
|
||||||
|
|
||||||
|
__dprintf("got syscall: %d\n", w.sr.number);
|
||||||
|
|
||||||
switch (w.sr.number) {
|
switch (w.sr.number) {
|
||||||
case __NR_open:
|
case __NR_open:
|
||||||
dma_buf[256] = 0;
|
dma_buf[256] = 0;
|
||||||
do_syscall_load(fd, cpu, dma_buf_pa, w.sr.args[0], 256);
|
|
||||||
|
do_syscall_load(fd, cpu, dma_buf, w.sr.args[0], 256);
|
||||||
|
/*
|
||||||
while (!dma_buf[256]) {
|
while (!dma_buf[256]) {
|
||||||
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ret = open(dma_buf, w.sr.args[1], w.sr.args[2]);
|
ret = open(dma_buf, w.sr.args[1], w.sr.args[2]);
|
||||||
SET_ERR(ret);
|
SET_ERR(ret);
|
||||||
do_syscall_return(fd, cpu, ret, 0, 0, 0, 0);
|
do_syscall_return(fd, cpu, ret, 0, 0, 0, 0);
|
||||||
@ -321,19 +329,21 @@ int main_loop(int fd, int cpu)
|
|||||||
case __NR_read:
|
case __NR_read:
|
||||||
ret = read(w.sr.args[0], dma_buf, w.sr.args[2]);
|
ret = read(w.sr.args[0], dma_buf, w.sr.args[2]);
|
||||||
SET_ERR(ret);
|
SET_ERR(ret);
|
||||||
do_syscall_return(fd, cpu, ret, 1, dma_buf_pa,
|
do_syscall_return(fd, cpu, ret, 1, dma_buf,
|
||||||
w.sr.args[1], w.sr.args[2]);
|
w.sr.args[1], w.sr.args[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case __NR_write:
|
case __NR_write:
|
||||||
dma_buf[w.sr.args[2]] = 0;
|
dma_buf[w.sr.args[2]] = 0;
|
||||||
SET_ERR(ret);
|
SET_ERR(ret);
|
||||||
do_syscall_load(fd, cpu, dma_buf_pa,
|
do_syscall_load(fd, cpu, dma_buf,
|
||||||
w.sr.args[1], w.sr.args[2]);
|
w.sr.args[1], w.sr.args[2]);
|
||||||
|
|
||||||
|
/*
|
||||||
while (!dma_buf[w.sr.args[2]]) {
|
while (!dma_buf[w.sr.args[2]]) {
|
||||||
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ret = write(w.sr.args[0], dma_buf, w.sr.args[2]);
|
ret = write(w.sr.args[0], dma_buf, w.sr.args[2]);
|
||||||
do_syscall_return(fd, cpu, ret, 0, 0, 0, 0);
|
do_syscall_return(fd, cpu, ret, 0, 0, 0, 0);
|
||||||
@ -347,18 +357,20 @@ int main_loop(int fd, int cpu)
|
|||||||
case __NR_pread64:
|
case __NR_pread64:
|
||||||
ret = pread(w.sr.args[0], dma_buf, w.sr.args[2],
|
ret = pread(w.sr.args[0], dma_buf, w.sr.args[2],
|
||||||
w.sr.args[3]);
|
w.sr.args[3]);
|
||||||
do_syscall_return(fd, cpu, ret, 1, dma_buf_pa,
|
do_syscall_return(fd, cpu, ret, 1, dma_buf,
|
||||||
w.sr.args[1], w.sr.args[2]);
|
w.sr.args[1], w.sr.args[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case __NR_pwrite64:
|
case __NR_pwrite64:
|
||||||
dma_buf[w.sr.args[2]] = 0;
|
dma_buf[w.sr.args[2]] = 0;
|
||||||
do_syscall_load(fd, cpu, dma_buf_pa,
|
do_syscall_load(fd, cpu, dma_buf,
|
||||||
w.sr.args[1], w.sr.args[2]);
|
w.sr.args[1], w.sr.args[2]);
|
||||||
|
|
||||||
|
/*
|
||||||
while (!dma_buf[w.sr.args[2]]) {
|
while (!dma_buf[w.sr.args[2]]) {
|
||||||
asm volatile ("" : : : "memory");
|
asm volatile ("" : : : "memory");
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
ret = pwrite(w.sr.args[0], dma_buf, w.sr.args[2],
|
ret = pwrite(w.sr.args[0], dma_buf, w.sr.args[2],
|
||||||
w.sr.args[3]);
|
w.sr.args[3]);
|
||||||
@ -371,7 +383,7 @@ int main_loop(int fd, int cpu)
|
|||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
do_syscall_return(fd, cpu, ret, 1, dma_buf_pa,
|
do_syscall_return(fd, cpu, ret, 1, dma_buf,
|
||||||
w.sr.args[1], sizeof(struct stat));
|
w.sr.args[1], sizeof(struct stat));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -382,7 +394,7 @@ int main_loop(int fd, int cpu)
|
|||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
do_syscall_return(fd, cpu, ret, 1, dma_buf_pa,
|
do_syscall_return(fd, cpu, ret, 1, dma_buf,
|
||||||
w.sr.args[2],
|
w.sr.args[2],
|
||||||
sizeof(struct kernel_termios)
|
sizeof(struct kernel_termios)
|
||||||
);
|
);
|
||||||
@ -413,7 +425,7 @@ int main_loop(int fd, int cpu)
|
|||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
do_syscall_return(fd,
|
do_syscall_return(fd,
|
||||||
cpu, ret, 1, dma_buf_pa, w.sr.args[0],
|
cpu, ret, 1, dma_buf, w.sr.args[0],
|
||||||
sizeof(struct utsname));
|
sizeof(struct utsname));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@ -1,8 +1,10 @@
|
|||||||
ifeq ($(K),"current")
|
|
||||||
|
#ifeq ($(K),"current")
|
||||||
KDIR=/lib/modules/`uname -r `/build
|
KDIR=/lib/modules/`uname -r `/build
|
||||||
else
|
#else
|
||||||
KDIR=../target
|
#KDIR=../target
|
||||||
endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
obj-m += mcctrl.o
|
obj-m += mcctrl.o
|
||||||
|
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/delay.h>
|
#include <asm/delay.h>
|
||||||
#include <asm/msr.h>
|
#include <asm/msr.h>
|
||||||
|
#include <asm/io.h>
|
||||||
#include "mcctrl.h"
|
#include "mcctrl.h"
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
@ -145,9 +146,10 @@ int mcexec_syscall(struct mcctrl_channel *c, unsigned long arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef DO_USER_MODE
|
||||||
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
||||||
struct syscall_request *sc);
|
struct syscall_request *sc);
|
||||||
|
#endif
|
||||||
|
|
||||||
static int remaining_job, base_cpu, job_pos;
|
static int remaining_job, base_cpu, job_pos;
|
||||||
extern int num_channels;
|
extern int num_channels;
|
||||||
@ -251,29 +253,52 @@ long mcexec_pin_region(aal_os_t os, unsigned long *__user uaddress)
|
|||||||
long mcexec_load_syscall(aal_os_t os, struct syscall_load_desc *__user arg)
|
long mcexec_load_syscall(aal_os_t os, struct syscall_load_desc *__user arg)
|
||||||
{
|
{
|
||||||
struct syscall_load_desc desc;
|
struct syscall_load_desc desc;
|
||||||
|
unsigned long phys;
|
||||||
|
void *rpm;
|
||||||
|
|
||||||
|
if (copy_from_user(&desc, arg, sizeof(struct syscall_load_desc))) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
phys = aal_device_map_memory(aal_os_to_dev(os), desc.src, desc.size);
|
||||||
|
rpm = ioremap_wc(phys, desc.size);
|
||||||
|
|
||||||
|
printk("mcexec_load_syscall: %s (desc.size: %d)\n", rpm, desc.size);
|
||||||
|
|
||||||
|
if (copy_to_user((void *__user)desc.dest, rpm, desc.size)) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
iounmap(rpm);
|
||||||
|
aal_device_unmap_memory(aal_os_to_dev(os), phys, desc.size);
|
||||||
|
|
||||||
|
/*
|
||||||
aal_dma_channel_t channel;
|
aal_dma_channel_t channel;
|
||||||
struct aal_dma_request request;
|
struct aal_dma_request request;
|
||||||
|
unsigned long dma_status = 0;
|
||||||
|
|
||||||
channel = aal_device_get_dma_channel(aal_os_to_dev(os), 0);
|
channel = aal_device_get_dma_channel(aal_os_to_dev(os), 0);
|
||||||
if (!channel) {
|
if (!channel) {
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user(&desc, arg, sizeof(struct syscall_load_desc))) {
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(&request, 0, sizeof(request));
|
memset(&request, 0, sizeof(request));
|
||||||
request.src_os = os;
|
request.src_os = os;
|
||||||
request.src_phys = desc.src;
|
request.src_phys = desc.src;
|
||||||
request.dest_os = NULL;
|
request.dest_os = NULL;
|
||||||
request.dest_phys = desc.dest;
|
request.dest_phys = desc.dest;
|
||||||
request.size = desc.size;
|
request.size = desc.size;
|
||||||
request.notify = (void *)(desc.dest + desc.size);
|
request.notify = (void *)virt_to_phys(&dma_status);
|
||||||
request.priv = (void *)1;
|
request.priv = (void *)1;
|
||||||
|
|
||||||
aal_dma_request(channel, &request);
|
aal_dma_request(channel, &request);
|
||||||
|
|
||||||
|
while (!dma_status) {
|
||||||
|
mb();
|
||||||
|
udelay(1);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,7 +333,10 @@ long mcexec_ret_syscall(aal_os_t os, struct syscall_ret_desc *__user arg)
|
|||||||
ret.size);
|
ret.size);
|
||||||
rpm = ioremap_wc(phys, ret.size);
|
rpm = ioremap_wc(phys, ret.size);
|
||||||
|
|
||||||
memcpy(rpm, phys_to_virt(ret.src), ret.size);
|
if (copy_from_user(rpm, (void *__user)ret.src, ret.size)) {
|
||||||
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
mc->param.response_va->status = 1;
|
mc->param.response_va->status = 1;
|
||||||
|
|
||||||
iounmap(rpm);
|
iounmap(rpm);
|
||||||
|
|||||||
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
#define DMA_PIN_SHIFT 21
|
#define DMA_PIN_SHIFT 21
|
||||||
|
|
||||||
|
#define DO_USER_MODE
|
||||||
|
|
||||||
struct ikc_scd_packet {
|
struct ikc_scd_packet {
|
||||||
int msg;
|
int msg;
|
||||||
int ref;
|
int ref;
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
#include <linux/syscalls.h>
|
#include <linux/syscalls.h>
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/delay.h>
|
#include <asm/delay.h>
|
||||||
|
#include <asm/io.h>
|
||||||
#include "mcctrl.h"
|
#include "mcctrl.h"
|
||||||
|
|
||||||
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
||||||
@ -112,10 +113,14 @@ static unsigned long translate_remote_va(struct mcctrl_channel *c,
|
|||||||
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long last_thread_exec = 0;
|
unsigned long last_thread_exec = 0;
|
||||||
|
|
||||||
extern struct mcctrl_channel *channels;
|
extern struct mcctrl_channel *channels;
|
||||||
|
|
||||||
|
#ifndef DO_USER_MODE
|
||||||
|
|
||||||
|
|
||||||
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
||||||
struct syscall_request *sc)
|
struct syscall_request *sc)
|
||||||
{
|
{
|
||||||
@ -230,3 +235,4 @@ int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif /* DO_USER_MODE */
|
||||||
|
|||||||
Reference in New Issue
Block a user