merge KNC B0 changes and cleanup mcexec
This commit is contained in:
@ -195,7 +195,9 @@ void print_desc(struct program_load_desc *desc)
|
||||
#define PIN_SIZE (1 << PIN_SHIFT)
|
||||
#define PIN_MASK ~(unsigned long)(PIN_SIZE - 1)
|
||||
|
||||
#if 0
|
||||
unsigned long dma_buf_pa;
|
||||
#endif
|
||||
|
||||
|
||||
void print_flat(char *flat)
|
||||
@ -271,10 +273,13 @@ int flatten_strings(int nr_strings, char **strings, char **flat)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int fd, fdm;
|
||||
int fd;
|
||||
#if 0
|
||||
int fdm;
|
||||
long r;
|
||||
#endif
|
||||
FILE *fp;
|
||||
struct program_load_desc *desc;
|
||||
long r;
|
||||
char *envs;
|
||||
char *args;
|
||||
|
||||
@ -311,6 +316,8 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Error: Failed to open /dev/mcctrl.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
fdm = open("/dev/fmem", O_RDWR);
|
||||
if (fdm < 0) {
|
||||
fprintf(stderr, "Error: Failed to open /dev/fmem.\n");
|
||||
@ -327,6 +334,20 @@ int main(int argc, char **argv)
|
||||
dma_buf = mmap(NULL, PIN_SIZE, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, fdm, dma_buf_pa);
|
||||
__dprintf("DMA Buffer: %lx, %p\n", dma_buf_pa, dma_buf);
|
||||
#endif
|
||||
|
||||
dma_buf = mmap(0, PIN_SIZE, PROT_READ | PROT_WRITE,
|
||||
(MAP_ANONYMOUS | MAP_PRIVATE), -1, 0);
|
||||
if (!dma_buf) {
|
||||
printf("error: allocating DMA area\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* PIN buffer */
|
||||
if (mlock(dma_buf, (size_t)PIN_SIZE)) {
|
||||
printf("ERROR: locking dma_buf\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ioctl(fd, MCEXEC_UP_PREPARE_IMAGE, (unsigned long)desc) != 0) {
|
||||
perror("prepare");
|
||||
|
||||
@ -25,6 +25,7 @@ static long mcexec_prepare_image(aal_os_t os,
|
||||
struct program_load_desc desc, *pdesc;
|
||||
struct ikc_scd_packet isp;
|
||||
void *args, *envs;
|
||||
long ret = 0;
|
||||
|
||||
if (copy_from_user(&desc, udesc,
|
||||
sizeof(struct program_load_desc))) {
|
||||
@ -56,17 +57,15 @@ static long mcexec_prepare_image(aal_os_t os,
|
||||
|
||||
envs = kmalloc(pdesc->envs_len, GFP_KERNEL);
|
||||
if (copy_from_user(envs, pdesc->envs, pdesc->envs_len)) {
|
||||
kfree(envs);
|
||||
kfree(args);
|
||||
kfree(pdesc);
|
||||
return -EFAULT;
|
||||
ret = -EFAULT;
|
||||
goto free_out;
|
||||
}
|
||||
|
||||
pdesc->args = virt_to_phys(args);
|
||||
printk("args: 0x%lX\n", pdesc->args);
|
||||
pdesc->args = (void*)virt_to_phys(args);
|
||||
printk("args: 0x%lX\n", (unsigned long)pdesc->args);
|
||||
printk("argc: %d\n", *(int*)args);
|
||||
pdesc->envs = virt_to_phys(envs);
|
||||
printk("envs: 0x%lX\n", pdesc->envs);
|
||||
pdesc->envs = (void*)virt_to_phys(envs);
|
||||
printk("envs: 0x%lX\n", (unsigned long)pdesc->envs);
|
||||
printk("envc: %d\n", *(int*)envs);
|
||||
|
||||
isp.msg = SCD_MSG_PREPARE_PROCESS;
|
||||
@ -81,19 +80,28 @@ static long mcexec_prepare_image(aal_os_t os,
|
||||
|
||||
wait_event_interruptible(wq_prepare, pdesc->status);
|
||||
|
||||
copy_to_user(udesc, pdesc, sizeof(struct program_load_desc) +
|
||||
sizeof(struct program_image_section) * desc.num_sections);
|
||||
if (copy_to_user(udesc, pdesc, sizeof(struct program_load_desc) +
|
||||
sizeof(struct program_image_section) * desc.num_sections)) {
|
||||
ret = -EFAULT;
|
||||
goto free_out;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
free_out:
|
||||
kfree(args);
|
||||
kfree(pdesc);
|
||||
kfree(envs);
|
||||
kfree(args);
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int mcexec_load_image(aal_os_t os, struct program_transfer *__user upt)
|
||||
{
|
||||
struct program_transfer pt;
|
||||
unsigned long phys, ret = 0;
|
||||
void *rpm;
|
||||
#if 0
|
||||
unsigned long dma_status = 0;
|
||||
aal_dma_channel_t channel;
|
||||
struct aal_dma_request request;
|
||||
@ -103,10 +111,33 @@ int mcexec_load_image(aal_os_t os, struct program_transfer *__user upt)
|
||||
if (!channel) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (copy_from_user(&pt, upt, sizeof(pt))) {
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
phys = aal_device_map_memory(aal_os_to_dev(os), pt.dest, PAGE_SIZE);
|
||||
#ifdef CONFIG_KNF
|
||||
rpm = ioremap_wc(phys, PAGE_SIZE);
|
||||
#else
|
||||
rpm = aal_device_map_virtual(aal_os_to_dev(os), phys, PAGE_SIZE, NULL, 0);
|
||||
#endif
|
||||
|
||||
if (copy_from_user(rpm, pt.src, PAGE_SIZE)) {
|
||||
ret = -EFAULT;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KNF
|
||||
iounmap(rpm);
|
||||
#else
|
||||
aal_device_unmap_virtual(aal_os_to_dev(os), rpm, PAGE_SIZE);
|
||||
#endif
|
||||
aal_device_unmap_memory(aal_os_to_dev(os), phys, PAGE_SIZE);
|
||||
|
||||
return ret;
|
||||
|
||||
#if 0
|
||||
p = (void *)__get_free_page(GFP_KERNEL);
|
||||
|
||||
if (copy_from_user(p, pt.src, PAGE_SIZE)) {
|
||||
@ -132,6 +163,7 @@ int mcexec_load_image(aal_os_t os, struct program_transfer *__user upt)
|
||||
free_page((unsigned long)p);
|
||||
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
extern unsigned long last_thread_exec;
|
||||
@ -174,9 +206,9 @@ int mcexec_syscall(struct mcctrl_channel *c, unsigned long arg)
|
||||
#ifndef DO_USER_MODE
|
||||
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
||||
struct syscall_request *sc);
|
||||
static int remaining_job, base_cpu, job_pos;
|
||||
#endif
|
||||
|
||||
static int remaining_job, base_cpu, job_pos;
|
||||
extern int num_channels;
|
||||
extern int mcctrl_dma_abort;
|
||||
|
||||
@ -184,7 +216,6 @@ int mcexec_wait_syscall(aal_os_t os, struct syscall_wait_desc *__user req)
|
||||
{
|
||||
struct syscall_wait_desc swd;
|
||||
struct mcctrl_channel *c;
|
||||
unsigned long s, w, d;
|
||||
|
||||
if (copy_from_user(&swd, req, sizeof(swd.cpu))) {
|
||||
return -EFAULT;
|
||||
@ -286,7 +317,11 @@ long mcexec_load_syscall(aal_os_t os, struct syscall_load_desc *__user arg)
|
||||
}
|
||||
|
||||
phys = aal_device_map_memory(aal_os_to_dev(os), desc.src, desc.size);
|
||||
#ifdef CONFIG_KNF
|
||||
rpm = ioremap_wc(phys, desc.size);
|
||||
#else
|
||||
rpm = aal_device_map_virtual(aal_os_to_dev(os), phys, desc.size, NULL, 0);
|
||||
#endif
|
||||
|
||||
dprintk("mcexec_load_syscall: %s (desc.size: %d)\n", rpm, desc.size);
|
||||
|
||||
@ -294,8 +329,13 @@ long mcexec_load_syscall(aal_os_t os, struct syscall_load_desc *__user arg)
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_KNF
|
||||
iounmap(rpm);
|
||||
aal_device_unmap_memory(aal_os_to_dev(os), phys, desc.size);
|
||||
#else
|
||||
aal_device_unmap_virtual(aal_os_to_dev(os), rpm, desc.size);
|
||||
#endif
|
||||
|
||||
aal_device_unmap_memory(aal_os_to_dev(os), phys, desc.size);
|
||||
|
||||
/*
|
||||
aal_dma_channel_t channel;
|
||||
@ -330,14 +370,16 @@ long mcexec_load_syscall(aal_os_t os, struct syscall_load_desc *__user arg)
|
||||
long mcexec_ret_syscall(aal_os_t os, struct syscall_ret_desc *__user arg)
|
||||
{
|
||||
struct syscall_ret_desc ret;
|
||||
struct mcctrl_channel *mc;
|
||||
#if 0
|
||||
aal_dma_channel_t channel;
|
||||
struct aal_dma_request request;
|
||||
struct mcctrl_channel *mc;
|
||||
|
||||
channel = aal_device_get_dma_channel(aal_os_to_dev(os), 0);
|
||||
if (!channel) {
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (copy_from_user(&ret, arg, sizeof(struct syscall_ret_desc))) {
|
||||
return -EFAULT;
|
||||
@ -356,7 +398,12 @@ long mcexec_ret_syscall(aal_os_t os, struct syscall_ret_desc *__user arg)
|
||||
|
||||
phys = aal_device_map_memory(aal_os_to_dev(os), ret.dest,
|
||||
ret.size);
|
||||
#ifdef CONFIG_KNF
|
||||
rpm = ioremap_wc(phys, ret.size);
|
||||
#else
|
||||
rpm = aal_device_map_virtual(aal_os_to_dev(os), phys,
|
||||
ret.size, NULL, 0);
|
||||
#endif
|
||||
|
||||
if (copy_from_user(rpm, (void *__user)ret.src, ret.size)) {
|
||||
return -EFAULT;
|
||||
@ -364,7 +411,11 @@ long mcexec_ret_syscall(aal_os_t os, struct syscall_ret_desc *__user arg)
|
||||
|
||||
mc->param.response_va->status = 1;
|
||||
|
||||
#ifdef CONFIG_KNF
|
||||
iounmap(rpm);
|
||||
#else
|
||||
aal_device_unmap_virtual(aal_os_to_dev(os), rpm, ret.size);
|
||||
#endif
|
||||
aal_device_unmap_memory(aal_os_to_dev(os), phys, ret.size);
|
||||
|
||||
/*
|
||||
|
||||
@ -98,7 +98,13 @@ static void mcctrl_ikc_init(aal_os_t os, int cpu, unsigned long rphys)
|
||||
|
||||
phys = aal_device_map_memory(aal_os_to_dev(os), rphys,
|
||||
sizeof(struct ikc_scd_init_param));
|
||||
#ifdef CONFIG_KNF
|
||||
rpm = ioremap_wc(phys, sizeof(struct ikc_scd_init_param));
|
||||
#else
|
||||
rpm = aal_device_map_virtual(aal_os_to_dev(os), phys,
|
||||
sizeof(struct ikc_scd_init_param),
|
||||
NULL, 0);
|
||||
#endif
|
||||
|
||||
pmc->param.request_va =
|
||||
(void *)__get_free_pages(GFP_KERNEL,
|
||||
@ -117,8 +123,14 @@ static void mcctrl_ikc_init(aal_os_t os, int cpu, unsigned long rphys)
|
||||
= aal_device_map_memory(aal_os_to_dev(os),
|
||||
pmc->param.response_rpa,
|
||||
PAGE_SIZE);
|
||||
#ifdef CONFIG_KNF
|
||||
pmc->param.response_va = ioremap_cache(pmc->param.response_pa,
|
||||
PAGE_SIZE);
|
||||
#else
|
||||
pmc->param.response_va = aal_device_map_virtual(aal_os_to_dev(os),
|
||||
pmc->param.response_pa,
|
||||
PAGE_SIZE, NULL, 0);
|
||||
#endif
|
||||
|
||||
pmc->dma_buf = (void *)__get_free_pages(GFP_KERNEL,
|
||||
DMA_PIN_SHIFT - PAGE_SHIFT);
|
||||
@ -140,7 +152,12 @@ static void mcctrl_ikc_init(aal_os_t os, int cpu, unsigned long rphys)
|
||||
|
||||
aal_ikc_send(pmc->c, &packet, 0);
|
||||
|
||||
#ifdef CONFIG_KNF
|
||||
iounmap(rpm);
|
||||
#else
|
||||
aal_device_unmap_virtual(aal_os_to_dev(os), rpm,
|
||||
sizeof(struct ikc_scd_init_param));
|
||||
#endif
|
||||
|
||||
aal_device_unmap_memory(aal_os_to_dev(os), phys,
|
||||
sizeof(struct ikc_scd_init_param));
|
||||
@ -210,7 +227,12 @@ void __destroy_ikc_channel(aal_os_t os, struct mcctrl_channel *pmc)
|
||||
REQUEST_SHIFT - PAGE_SHIFT);
|
||||
free_page((unsigned long)pmc->param.post_va);
|
||||
|
||||
#ifdef CONFIG_KNF
|
||||
iounmap(pmc->param.response_va);
|
||||
#else
|
||||
aal_device_unmap_virtual(aal_os_to_dev(os), pmc->param.response_va,
|
||||
PAGE_SIZE);
|
||||
#endif
|
||||
aal_device_unmap_memory(aal_os_to_dev(os),
|
||||
pmc->param.response_pa, PAGE_SIZE);
|
||||
free_pages((unsigned long)pmc->dma_buf,
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
||||
|
||||
#define SC_DEBUG
|
||||
//#define SC_DEBUG
|
||||
#ifdef SC_DEBUG
|
||||
static struct aal_dma_request last_request;
|
||||
|
||||
@ -26,6 +26,9 @@ static void print_dma_lastreq(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
unsigned long last_thread_exec = 0;
|
||||
|
||||
#ifndef DO_USER_MODE
|
||||
static int do_async_copy(aal_os_t os, unsigned long dest, unsigned long src,
|
||||
unsigned long size, unsigned int inbound)
|
||||
{
|
||||
@ -80,7 +83,7 @@ static void async_wait(unsigned char *p, int size)
|
||||
}
|
||||
static void clear_wait(unsigned char *p, int size)
|
||||
{
|
||||
int asize = ALIGN_WAIT_BUF(size);
|
||||
//int asize = ALIGN_WAIT_BUF(size);
|
||||
p[size] = 0;
|
||||
}
|
||||
|
||||
@ -114,13 +117,8 @@ static unsigned long translate_remote_va(struct mcctrl_channel *c,
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
unsigned long last_thread_exec = 0;
|
||||
|
||||
extern struct mcctrl_channel *channels;
|
||||
|
||||
#ifndef DO_USER_MODE
|
||||
|
||||
|
||||
int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
||||
struct syscall_request *sc)
|
||||
{
|
||||
@ -235,4 +233,4 @@ int __do_in_kernel_syscall(aal_os_t os, struct mcctrl_channel *c,
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* DO_USER_MODE */
|
||||
#endif /* !DO_USER_MODE */
|
||||
|
||||
Reference in New Issue
Block a user