From 86b874250ddbca879009d9a97bc4d4be9ac8872a Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 15 Aug 2011 01:08:19 -0700 Subject: [PATCH 1/3] remove compiling errors by disabling the LwIP stack --- kernel/tasks.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/tasks.c b/kernel/tasks.c index 2dec1348..413ce994 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -243,7 +243,9 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) task_table[i].start_heap = 0; task_table[i].end_heap = 0; +#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; +#endif task_table[i].start_tick = get_clock_tick(); break; } @@ -309,7 +311,9 @@ int sys_fork(void) task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; task_table[i].end_heap = 0; +#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; +#endif ret = arch_fork(task_table+i); From c8e22fe08e19ae2618548f15d5d26223a00e5a87 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Mon, 15 Aug 2011 08:01:47 -0700 Subject: [PATCH 2/3] add faster memcpy function for the SCC --- arch/x86/include/asm/string.h | 55 +++++++++++++++++++++++++++++++++++ arch/x86/scc/scc_memcpy.h | 9 +++++- kernel/tests.c | 6 ++-- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/string.h b/arch/x86/include/asm/string.h index 51d288a5..fd6480e0 100644 --- a/arch/x86/include/asm/string.h +++ b/arch/x86/include/asm/string.h @@ -35,6 +35,59 @@ void copy_page_physical(void* dest, const void * src); #ifdef HAVE_ARCH_MEMCPY +#ifdef CONFIG_ROCKCREEK +/** @brief Fast procedure to get a byte range from RAM into on-die memory. + * + * A write access, which cache line is not present, doesn't perform (on the + * current SCC architecture) a cache line fill. Therefore, the core writes + * in this case directly to the memory. + * + * The following function copies by prefetching its destintation. Therefore, + * the function avoids the bad behavior of a "write miss". + * + * @param dest Destination address + * @param src Source address + * @param count Range size in bytes + */ +inline static void *memcpy(void *dest, const void *src, size_t count) +{ + int32_t h, i, j, k, l, m; + + asm volatile ("cld;\n\t" + "1: cmpl $0, %%eax ; je 3f\n\t" + "movl (%%esi), %%ecx\n\t" + "movl (%%edi), %%edx\n\t" + "cmpl $1, %%eax ; je 2f\n\t" + "movl 32(%%esi), %%ecx\n\t" + "movl 32(%%edi), %%edx\n\t" + "2: movl 0(%%esi), %%ecx\n\t" + "movl 4(%%esi), %%edx\n\t" + "movl %%ecx, 0(%%edi)\n\t" + "movl %%edx, 4(%%edi)\n\t" + "movl 8(%%esi), %%ecx\n\t" + "movl 12(%%esi), %%edx\n\t" + "movl %%ecx, 8(%%edi)\n\t" + "movl %%edx, 12(%%edi)\n\t" + "movl 16(%%esi), %%ecx\n\t" + "movl 20(%%esi), %%edx\n\t" + "movl %%ecx, 16(%%edi)\n\t" + "movl %%edx, 20(%%edi)\n\t" + "movl 24(%%esi), %%ecx\n\t" + "movl 28(%%esi), %%edx\n\t" + "movl %%ecx, 24(%%edi)\n\t" + "movl %%edx, 28(%%edi)\n\t" + "addl $32, %%esi\n\t" + "addl $32, %%edi\n\t" + "dec %%eax ; jmp 1b\n\t" + "3: movl %%ebx, %%ecx\n\t" + "movl (%%edi), %%edx\n\t" + "andl $31, %%ecx\n\t" + "rep ; movsb\n\t":"=&a" (h), "=&D"(i), "=&S"(j), "=&b"(k), "=&c"(l), "=&d"(m) + : "0"(count / 32), "1"(dest), "2"(src), "3"(count) : "memory"); + + return dest; +} +#else /** @brief Copy a byte range from source to dest * * @param dest Destination address @@ -60,6 +113,8 @@ inline static void *memcpy(void* dest, const void *src, size_t count) } #endif +#endif + #ifdef HAVE_ARCH_MEMSET /** @brief Repeated write of a value to a whole range of bytes diff --git a/arch/x86/scc/scc_memcpy.h b/arch/x86/scc/scc_memcpy.h index 31eb47c1..8748a496 100644 --- a/arch/x86/scc/scc_memcpy.h +++ b/arch/x86/scc/scc_memcpy.h @@ -85,7 +85,13 @@ inline static void *memcpy_get(void *dest, const void *src, size_t count) return dest; } - +#if 1 +/* + * In our kernel, we didn't want to use FPU registers. + * Therefore, we use standard memcpy routine + */ +#define memcpy_put memcpy +#else /** @brief Fast procedure to get a byte range from on-die memory into RAM. * * If the destination is located on on-die memory (MPB), classical prefetching @@ -166,6 +172,7 @@ inline static void *memcpy_put(void *dest, const void *src, size_t count) return dest; } +#endif #endif diff --git a/kernel/tests.c b/kernel/tests.c index 5b67a06d..67c3a430 100644 --- a/kernel/tests.c +++ b/kernel/tests.c @@ -274,15 +274,15 @@ int test_init(void) #endif create_kernel_task(NULL, foo, "Hello from foo1"); - create_kernel_task(NULL, join_test, NULL); + //create_kernel_task(NULL, join_test, NULL); //create_kernel_task(NULL, producer, NULL); //create_kernel_task(NULL, consumer, NULL); //create_kernel_task(NULL, mail_ping, NULL); //create_user_task(NULL, "/bin/hello", argv); - create_user_task(NULL, "/bin/tests", argv); + //create_user_task(NULL, "/bin/tests", argv); //create_user_task(NULL, "/bin/jacobi", argv); //create_user_task(NULL, "/bin/jacobi", argv); - create_user_task(NULL, "/bin/server", server_argv); + //create_user_task(NULL, "/bin/server", server_argv); //sleep(5); //create_user_task(NULL, "/bin/client", client_argv); From 5661ee64e118095d37913d6e562022434c61d76f Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Wed, 17 Aug 2011 14:55:33 +0200 Subject: [PATCH 3/3] remove compiler warnings --- include/metalsvm/tasks_types.h | 2 -- kernel/tasks.c | 4 ---- 2 files changed, 6 deletions(-) diff --git a/include/metalsvm/tasks_types.h b/include/metalsvm/tasks_types.h index 3379fccb..a3d0bd3a 100644 --- a/include/metalsvm/tasks_types.h +++ b/include/metalsvm/tasks_types.h @@ -85,10 +85,8 @@ typedef struct task { uint32_t start_heap; /// End address of the heap uint32_t end_heap; -#ifdef CONFIG_LWIP /// LwIP error code int lwip_err; -#endif /// Mail inbox mailbox_wait_msg_t inbox; /// Mail outbox array diff --git a/kernel/tasks.c b/kernel/tasks.c index 413ce994..2dec1348 100644 --- a/kernel/tasks.c +++ b/kernel/tasks.c @@ -243,9 +243,7 @@ static int create_task(tid_t* id, internal_entry_point_t ep, void* arg) task_table[i].start_heap = 0; task_table[i].end_heap = 0; -#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; -#endif task_table[i].start_tick = get_clock_tick(); break; } @@ -311,9 +309,7 @@ int sys_fork(void) task_table[i].start_tick = get_clock_tick(); task_table[i].start_heap = 0; task_table[i].end_heap = 0; -#ifdef CONFIG_LWIP task_table[i].lwip_err = 0; -#endif ret = arch_fork(task_table+i);