Merge branch 'master' of postpeta.pccluster.org:mcos
This commit is contained in:
33
kernel/mem.c
33
kernel/mem.c
@@ -7,7 +7,8 @@
|
|||||||
#include <aal/mm.h>
|
#include <aal/mm.h>
|
||||||
#include <aal/page_alloc.h>
|
#include <aal/page_alloc.h>
|
||||||
#include <registers.h>
|
#include <registers.h>
|
||||||
|
#include <sysdeps/knf/mic/micconst.h>
|
||||||
|
#include <sysdeps/knf/mic/micsboxdefine.h>
|
||||||
#include <cls.h>
|
#include <cls.h>
|
||||||
|
|
||||||
static struct aal_page_allocator_desc *pa_allocator;
|
static struct aal_page_allocator_desc *pa_allocator;
|
||||||
@@ -184,6 +185,36 @@ void aal_mc_unmap_virtual(void *va, int npages, int free_physical)
|
|||||||
aal_pagealloc_free(vmap_allocator, virt_to_phys(va), npages);
|
aal_pagealloc_free(vmap_allocator, virt_to_phys(va), npages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* moved from aal_knc/manycore/knf/setup.c */
|
||||||
|
/*static*/ void *sbox_base = (void *)SBOX_BASE;
|
||||||
|
void sbox_write(int offset, unsigned int value)
|
||||||
|
{
|
||||||
|
*(volatile unsigned int *)(sbox_base + offset) = value;
|
||||||
|
}
|
||||||
|
unsigned int sbox_read(int offset)
|
||||||
|
{
|
||||||
|
return *(volatile unsigned int *)(sbox_base + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* insert entry into map which maps mic physical address to host physical address */
|
||||||
|
|
||||||
|
unsigned int free_bitmap_micpa = ((~(1ULL<<(NUM_SMPT_ENTRIES_IN_USE - NUM_SMPT_ENTRIES_MICPA)) - 1)&(1ULL << NUM_SMPT_ENTRIES_IN_USE - 1));
|
||||||
|
|
||||||
|
void aal_mc_map_micpa(unsigned long host_pa, unsigned long* mic_pa) {
|
||||||
|
int i;
|
||||||
|
for(i = NUM_SMPT_ENTRIES_IN_USE - 1; i >= NUM_SMPT_ENTRIES_IN_USE - NUM_SMPT_ENTRIES_MICPA; i--) {
|
||||||
|
if((free_bitmap_micpa >> i) & 1) {
|
||||||
|
free_bitmap_micpa &= ~(1ULL << i);
|
||||||
|
*mic_pa = MIC_SYSTEM_BASE + MIC_SYSTEM_PAGE_SIZE * i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
kprintf("aal_mc_map_micpa,1,i=%d,host_pa=%lx,mic_pa=%llx\n", i, host_pa, *mic_pa);
|
||||||
|
if(i == NUM_SMPT_ENTRIES_IN_USE - NUM_SMPT_ENTRIES_MICPA - 1) { return 0; }
|
||||||
|
sbox_write(SBOX_SMPT00 + ((*mic_pa - MIC_SYSTEM_BASE) >> MIC_SYSTEM_PAGE_SHIFT) * 4, BUILD_SMPT(SNOOP_ON, host_pa >> MIC_SYSTEM_PAGE_SHIFT));
|
||||||
|
*mic_pa += (host_pa & (MIC_SYSTEM_PAGE_SIZE-1));
|
||||||
|
}
|
||||||
|
|
||||||
void mem_init(void)
|
void mem_init(void)
|
||||||
{
|
{
|
||||||
page_allocator_init();
|
page_allocator_init();
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ SYSCALL_DECLARE(stat)
|
|||||||
{
|
{
|
||||||
SYSCALL_HEADER;
|
SYSCALL_HEADER;
|
||||||
dkprintf("stat(\"%s\");\n", (char*)aal_mc_syscall_arg0(ctx));
|
dkprintf("stat(\"%s\");\n", (char*)aal_mc_syscall_arg0(ctx));
|
||||||
SYSCALL_ARGS_2(D, D);
|
SYSCALL_ARGS_2(MO, MO);
|
||||||
SYSCALL_FOOTER;
|
SYSCALL_FOOTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -493,14 +493,21 @@ int main_loop(int fd, int cpu)
|
|||||||
|
|
||||||
|
|
||||||
case __NR_stat:
|
case __NR_stat:
|
||||||
ret = stat((const char*)w.sr.args[0], (void *)dma_buf);
|
{
|
||||||
|
char filename[256];
|
||||||
|
|
||||||
|
do_syscall_load(fd, cpu, (unsigned long)&filename[0],
|
||||||
|
w.sr.args[0], 256);
|
||||||
|
|
||||||
|
ret = stat(filename, (void *)dma_buf);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
do_syscall_return(fd, cpu, ret, 1, (unsigned long)dma_buf,
|
do_syscall_return(fd, cpu, ret, 1, (unsigned long)dma_buf,
|
||||||
w.sr.args[1], sizeof(struct stat));
|
w.sr.args[1], sizeof(struct stat));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case __NR_fstat:
|
case __NR_fstat:
|
||||||
ret = fstat(w.sr.args[0], (void *)dma_buf);
|
ret = fstat(w.sr.args[0], (void *)dma_buf);
|
||||||
if (ret == -1) {
|
if (ret == -1) {
|
||||||
|
|||||||
Reference in New Issue
Block a user