diff --git a/arch/x86/scc/RCCE_admin.c b/arch/x86/scc/RCCE_admin.c index 2ad87e18..dc7db27d 100644 --- a/arch/x86/scc/RCCE_admin.c +++ b/arch/x86/scc/RCCE_admin.c @@ -26,6 +26,7 @@ // #include +#include #ifdef CONFIG_ROCKCREEK @@ -335,13 +336,13 @@ int RCCE_init( RCCE_malloc_init(RCCE_comm_buffer[RCCE_IAM],RCCE_BUFF_SIZE); #ifdef SHMADD - RCCE_shmalloc_init(RC_SHM_BUFFER_START()+RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX); + RCCE_shmalloc_init(map_region(NULL, RC_SHM_BUFFER_START()+RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX/PAGE_SIZE, MAP_KERNEL_SPACE|MAP_NO_CACHE), RCCE_SHM_SIZE_MAX); #ifdef SHMDBG kprintf("\n%d:%s:%d: RCCE_SHM_BUFFER_offset, RCCE_SHM_SIZE_MAX: %x %x\n", RCCE_IAM, __FILE__,__LINE__,RCCE_SHM_BUFFER_offset ,RCCE_SHM_SIZE_MAX); #endif #else - RCCE_shmalloc_init(RC_SHM_BUFFER_START(),RCCE_SHM_SIZE_MAX); + RCCE_shmalloc_init(map_region(NULL, RC_SHM_BUFFER_START(), RCCE_SHM_SIZE_MAX/PAGE_SIZE, MAP_KERNEL_SPACE|MAP_NO_CACHE), RCCE_SHM_SIZE_MAX); #endif // initialize the (global) flag bookkeeping data structure diff --git a/arch/x86/scc/icc.c b/arch/x86/scc/icc.c index d56a9e4a..ca2bd9b4 100644 --- a/arch/x86/scc/icc.c +++ b/arch/x86/scc/icc.c @@ -142,6 +142,17 @@ int icc_init(void) kprintf("failed! (0x%x)\n", msg); #endif +#if 0 + char* str = RCCE_shmalloc(128); + if (my_ue == 1) { + memset(str, 0x00, 128); + strcpy(str, "Hello RCCE_shmalloc\n"); + } + RCCE_barrier(&RCCE_COMM_WORLD); + kprintf("RCCE_shmalloc test: %s\n", str); + RCCE_shfree(str); +#endif + // reset INTR/LINT0 flag z = Z_PID(RC_COREID[my_ue]); tmp=ReadConfigReg(CRB_OWN + (z==0 ? GLCFG0 : GLCFG1)); diff --git a/include/metalsvm/config.h.example b/include/metalsvm/config.h.example index f5b35948..34a2717a 100644 --- a/include/metalsvm/config.h.example +++ b/include/metalsvm/config.h.example @@ -63,11 +63,6 @@ extern "C" { #define SHMADD #define SHMDBG //#define SHMADD_CACHEABLE -/* default values for 16 GB system */ -#define PRIVATE_MEM1_START 0x00000000 -#define PRIVATE_MEM1_END 0x13FFFFFF -#define PRIVATE_MEM2_START 0xFF000000 -#define PRIVATE_MEM2_END 0xFFFFFFFF #define SCC_BOOTINFO 0x80000 #define BUILTIN_EXPECT(exp, b) __builtin_expect((exp), (b)) diff --git a/mm/memory.c b/mm/memory.c index ad29aedd..11f6fdce 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -30,6 +30,9 @@ #include #endif #ifdef CONFIG_ROCKCREEK +#include +#include +#include #include #endif @@ -93,6 +96,7 @@ int mmu_init(void) size_t kernel_size; unsigned int i; size_t addr; + int ret; // at first, set default value of the bitmap memset(bitmap, 0xFF, sizeof(uint8_t)*BITMAP_SIZE); @@ -148,15 +152,8 @@ int mmu_init(void) } } #elif defined(CONFIG_ROCKCREEK) - for(addr=PRIVATE_MEM1_START; addr> PAGE_SHIFT); - if (addr > addr + PAGE_SIZE) - break; - atomic_int32_inc(&total_pages); - atomic_int32_inc(&total_available_pages); - } - - for(addr=PRIVATE_MEM2_START; addr> PAGE_SHIFT); if (addr > addr + PAGE_SIZE) break; @@ -164,6 +161,15 @@ int mmu_init(void) atomic_int32_inc(&total_available_pages); } + // Note: The last slot belongs always to the private memory. + for(addr=0xFF000000; addr<0xFFFFFFFF; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } + /* * Mark the bootinfo as used. */ @@ -200,7 +206,30 @@ int mmu_init(void) if ((size_t) &kernel_end & (PAGE_SIZE-1)) alloc_start++; - return paging_init(); + ret = paging_init(); + +#ifdef CONFIG_ROCKCREEK + /* + * Now, we are able to read the FPGA registers and to + * determine the number of slots for private memory. + */ + uint32_t slots = *((volatile uint32_t*) (FPGA_BASE + 0x8244)); + if (slots == 0) + slots = 21; + + kprintf("MetalSVM use %d slots for private memory\n", slots); + + // define the residual private slots as free + for(addr=20*0x1000000; addr<(slots-1)*0x1000000; addr+=PAGE_SIZE) { + page_clear_mark(addr >> PAGE_SHIFT); + if (addr > addr + PAGE_SIZE) + break; + atomic_int32_inc(&total_pages); + atomic_int32_inc(&total_available_pages); + } +#endif + + return ret; } /*