diff --git a/kernel/host.c b/kernel/host.c index 3c0c82cb..a43f3f01 100644 --- a/kernel/host.c +++ b/kernel/host.c @@ -33,6 +33,7 @@ static void process_msg_prepare_process(unsigned long rphys) char **argv; int argc, envc, args_envs_npages; char **env; + int range_npages; sz = sizeof(struct program_load_desc) + sizeof(struct program_image_section) * 16; @@ -59,9 +60,65 @@ static void process_msg_prepare_process(unsigned long rphys) s = (pn->sections[i].vaddr) & PAGE_MASK; e = (pn->sections[i].vaddr + pn->sections[i].len + PAGE_SIZE - 1) & PAGE_MASK; - up = virt_to_phys(aal_mc_alloc_pages((e - s) >> PAGE_SHIFT, 0)); + range_npages = (e - s) >> PAGE_SHIFT; + +#if 0 + if (range_npages <= 256) { +#endif + up = virt_to_phys(aal_mc_alloc_pages(range_npages, 0)); + add_process_memory_range(proc, s, e, up, 0); + + { + void *_virt = (void *)s; + unsigned long _phys; + aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table, + _virt, &_phys); + for (_virt = (void *)s + PAGE_SIZE; + (unsigned long)_virt < e; _virt += PAGE_SIZE) { + unsigned long __phys; + aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table, + _virt, &__phys); + if (__phys != _phys + PAGE_SIZE) { + kprintf("0x%lX + PAGE_SIZE is not physically contigous, from 0x%lX to 0x%lX\n", _virt - PAGE_SIZE, _phys, __phys); + panic("mondai"); + } + + _phys = __phys; + } + kprintf("0x%lX -> 0x%lX is physically contigous\n", s, e); + } +#if 0 + } + else { + up = 0; + if (add_process_large_range(proc, s, e, 0, &up)) { + kprintf("ERROR: not enough memory\n"); + while (1) cpu_halt(); + } + + + { + void *_virt = (void *)s; + unsigned long _phys; + aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table, + _virt, &_phys); + for (_virt = (void *)s + PAGE_SIZE; + (unsigned long)_virt < e; _virt += PAGE_SIZE) { + unsigned long __phys; + aal_mc_pt_virt_to_phys(cpu_local_var(current)->vm->page_table, + _virt, &__phys); + if (__phys != _phys + PAGE_SIZE) { + kprintf("0x%lX + PAGE_SIZE is not physically contigous, from 0x%lX to 0x%lX\n", _virt - PAGE_SIZE, _phys, __phys); + panic("mondai"); + } + + _phys = __phys; + } + kprintf("0x%lX -> 0x%lX is physically contigous\n", s, e); + } + } +#endif - add_process_memory_range(proc, s, e, up, 0); p->sections[i].remote_pa = up; /* TODO: Maybe we need flag */ @@ -181,7 +238,7 @@ static void process_msg_prepare_process(unsigned long rphys) dkprintf("env OK\n"); - aal_mc_unmap_virtual(args_envs, ARGENV_PAGE_COUNT); + aal_mc_unmap_virtual(args_envs, ARGENV_PAGE_COUNT, 0); p->rprocess = (unsigned long)proc; init_process_stack(proc, argc, argv, envc, env); @@ -191,7 +248,7 @@ static void process_msg_prepare_process(unsigned long rphys) aal_mc_free(pn); - aal_mc_unmap_virtual(p, npages); + aal_mc_unmap_virtual(p, npages, 1); aal_mc_unmap_memory(NULL, phys, sz); } diff --git a/kernel/listeners.c b/kernel/listeners.c index 56e149d4..e9c4bb44 100644 --- a/kernel/listeners.c +++ b/kernel/listeners.c @@ -53,7 +53,7 @@ static int test_packet_handler(struct aal_ikc_channel_desc *c, testmem(v, 4 * 1024 * 1024); - aal_mc_unmap_virtual(v, 4 * 1024); + aal_mc_unmap_virtual(v, 4 * 1024, 1); aal_mc_unmap_memory(NULL, pp, 4 * 1024 * 1024); } else if (packet->msg == 0x11110012) { p.msg = 0x11110013;