From 889603e5fe744616a607df8ccab33126d44c2f58 Mon Sep 17 00:00:00 2001 From: Terraneo Federico <fede.tft@hotmail.it> Date: Sat, 11 Jan 2014 00:43:01 +0000 Subject: [PATCH] End of processes branch merge. Processes support is still experimental and needs work --- Makefile | 2 +- Readme.txt | 4 ++++ .../_tools/processes/app_template}/Makefile | 0 .../_tools/processes/app_template}/crt0.s | 0 .../_tools/processes/app_template}/main.c | 0 .../_tools/processes/app_template}/miosix.ld | 0 .../_tools/processes/app_template}/prog3.h | 0 .../processes/app_template_withlibs}/Makefile | 0 .../processes/app_template_withlibs}/crt0.s | 0 .../processes/app_template_withlibs}/main.c | 0 .../app_template_withlibs}/miosix.ld | 0 .../processes/app_template_withlibs}/prog3.h | 0 .../app_template_withlibs}/syscallfuffa.c | 0 .../_tools/processes/main_processes.cpp | 0 .../common/interfaces-impl/portability.cpp | 23 +++++++++++++++++++ .../common/interfaces-impl/portability_impl.h | 4 +++- miosix/config/Makefile.inc | 12 +++++----- miosix/config/miosix_settings.h | 4 ++-- miosix/filesystem/file_access.cpp | 2 +- 19 files changed, 40 insertions(+), 11 deletions(-) rename {app_template => miosix/_tools/processes/app_template}/Makefile (100%) rename {app_template => miosix/_tools/processes/app_template}/crt0.s (100%) rename {app_template => miosix/_tools/processes/app_template}/main.c (100%) rename {app_template => miosix/_tools/processes/app_template}/miosix.ld (100%) rename {app_template => miosix/_tools/processes/app_template}/prog3.h (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/Makefile (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/crt0.s (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/main.c (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/miosix.ld (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/prog3.h (100%) rename {app_template_withlibs => miosix/_tools/processes/app_template_withlibs}/syscallfuffa.c (100%) rename main_processes.cpp => miosix/_tools/processes/main_processes.cpp (100%) diff --git a/Makefile b/Makefile index c5c788c7..1f741a86 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ SUBDIRS := miosix ## List here your source files (both .s, .c and .cpp) ## SRC := \ -main_processes.cpp +main.cpp ## ## List here additional static libraries with relative path diff --git a/Readme.txt b/Readme.txt index cfdc1412..2ac0bcaf 100644 --- a/Readme.txt +++ b/Readme.txt @@ -4,3 +4,7 @@ Welcome to the Miosix kernel You can find information on how to configure and use the kernel at the following url: http://miosix.org + +The testsuite is in miosix/_tools/testsuite + +A template for processes support in in miosix/_tools/processes diff --git a/app_template/Makefile b/miosix/_tools/processes/app_template/Makefile similarity index 100% rename from app_template/Makefile rename to miosix/_tools/processes/app_template/Makefile diff --git a/app_template/crt0.s b/miosix/_tools/processes/app_template/crt0.s similarity index 100% rename from app_template/crt0.s rename to miosix/_tools/processes/app_template/crt0.s diff --git a/app_template/main.c b/miosix/_tools/processes/app_template/main.c similarity index 100% rename from app_template/main.c rename to miosix/_tools/processes/app_template/main.c diff --git a/app_template/miosix.ld b/miosix/_tools/processes/app_template/miosix.ld similarity index 100% rename from app_template/miosix.ld rename to miosix/_tools/processes/app_template/miosix.ld diff --git a/app_template/prog3.h b/miosix/_tools/processes/app_template/prog3.h similarity index 100% rename from app_template/prog3.h rename to miosix/_tools/processes/app_template/prog3.h diff --git a/app_template_withlibs/Makefile b/miosix/_tools/processes/app_template_withlibs/Makefile similarity index 100% rename from app_template_withlibs/Makefile rename to miosix/_tools/processes/app_template_withlibs/Makefile diff --git a/app_template_withlibs/crt0.s b/miosix/_tools/processes/app_template_withlibs/crt0.s similarity index 100% rename from app_template_withlibs/crt0.s rename to miosix/_tools/processes/app_template_withlibs/crt0.s diff --git a/app_template_withlibs/main.c b/miosix/_tools/processes/app_template_withlibs/main.c similarity index 100% rename from app_template_withlibs/main.c rename to miosix/_tools/processes/app_template_withlibs/main.c diff --git a/app_template_withlibs/miosix.ld b/miosix/_tools/processes/app_template_withlibs/miosix.ld similarity index 100% rename from app_template_withlibs/miosix.ld rename to miosix/_tools/processes/app_template_withlibs/miosix.ld diff --git a/app_template_withlibs/prog3.h b/miosix/_tools/processes/app_template_withlibs/prog3.h similarity index 100% rename from app_template_withlibs/prog3.h rename to miosix/_tools/processes/app_template_withlibs/prog3.h diff --git a/app_template_withlibs/syscallfuffa.c b/miosix/_tools/processes/app_template_withlibs/syscallfuffa.c similarity index 100% rename from app_template_withlibs/syscallfuffa.c rename to miosix/_tools/processes/app_template_withlibs/syscallfuffa.c diff --git a/main_processes.cpp b/miosix/_tools/processes/main_processes.cpp similarity index 100% rename from main_processes.cpp rename to miosix/_tools/processes/main_processes.cpp diff --git a/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability.cpp b/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability.cpp index ffa9e8a7..1ba281e1 100644 --- a/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability.cpp +++ b/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability.cpp @@ -168,6 +168,29 @@ void initCtxsave(unsigned int *ctxsave, void *(*pc)(void *), unsigned int *sp, //leaving the content of r4-r11 uninitialized } +#ifdef WITH_PROCESSES + +void initCtxsave(unsigned int *ctxsave, void *(*pc)(void *), unsigned int *sp, + void *argv, unsigned int *gotBase) +{ + unsigned int *stackPtr=sp; + stackPtr--; //Stack is full descending, so decrement first + *stackPtr=0x01000000; stackPtr--; //--> xPSR + *stackPtr=reinterpret_cast<unsigned long>(pc); stackPtr--; //--> pc + *stackPtr=0xffffffff; stackPtr--; //--> lr + *stackPtr=0; stackPtr--; //--> r12 + *stackPtr=0; stackPtr--; //--> r3 + *stackPtr=0; stackPtr--; //--> r2 + *stackPtr=0; stackPtr--; //--> r1 + *stackPtr=reinterpret_cast<unsigned long >(argv); //--> r0 + + ctxsave[0]=reinterpret_cast<unsigned long>(stackPtr); //--> psp + ctxsave[6]=reinterpret_cast<unsigned long>(gotBase); //--> r9 + //leaving the content of r4-r8,r10-r11 uninitialized +} + +#endif //WITH_PROCESSES + void IRQportableStartKernel() { //Enable fault handlers diff --git a/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability_impl.h b/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability_impl.h index 5fcc019b..e40061aa 100644 --- a/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability_impl.h +++ b/miosix/arch/cortexM3_stm32l1/common/interfaces-impl/portability_impl.h @@ -102,7 +102,9 @@ namespace miosix_private { inline void doYield() { - asm volatile("svc 0"); + asm volatile("movs r3, #0\n\t" + "svc 0" + :::"r3"); } inline void doDisableInterrupts() diff --git a/miosix/config/Makefile.inc b/miosix/config/Makefile.inc index db9bd7a9..7aaca4d7 100644 --- a/miosix/config/Makefile.inc +++ b/miosix/config/Makefile.inc @@ -13,12 +13,12 @@ ## architecture ## #OPT_BOARD := lpc2138_miosix_board -#OPT_BOARD := stm32f103ze_stm3210e-eval +OPT_BOARD := stm32f103ze_stm3210e-eval #OPT_BOARD := stm32f103ve_mp3v2 #OPT_BOARD := stm32f100rb_stm32vldiscovery #OPT_BOARD := stm32f103ve_strive_mini #OPT_BOARD := stm32f103ze_redbull_v2 -OPT_BOARD := stm32f407vg_stm32f4discovery +#OPT_BOARD := stm32f407vg_stm32f4discovery #OPT_BOARD := stm32f207ig_stm3220g-eval #OPT_BOARD := stm32f207zg_ethboard_v2 #OPT_BOARD := stm32f207ze_als_camboard @@ -32,8 +32,8 @@ OPT_BOARD := stm32f407vg_stm32f4discovery ## -O2 is recomended otherwise, as it provides a good balance between code ## size and speed ## -OPT_OPTIMIZATION := -O0 -#OPT_OPTIMIZATION := -O2 +#OPT_OPTIMIZATION := -O0 +OPT_OPTIMIZATION := -O2 #OPT_OPTIMIZATION := -O3 #OPT_OPTIMIZATION := -Os @@ -137,9 +137,9 @@ ifeq ($(OPT_BOARD),stm32f407vg_stm32f4discovery) ## 3) Same as 1) but space has been reserved for a process pool, allowing ## to configure the kernel with "#define WITH_PROCESSES" LINKER_SCRIPT_PATH := arch/cortexM4_stm32f4/stm32f407vg_stm32f4discovery/ - #LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_rom.ld + LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_rom.ld #LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_ram.ld - LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_rom_processes.ld + #LINKER_SCRIPT := $(LINKER_SCRIPT_PATH)stm32_1m+192k_rom_processes.ld ## This causes the interrupt vector table to be relocated in SRAM, must be ## uncommented when using the ram linker script diff --git a/miosix/config/miosix_settings.h b/miosix/config/miosix_settings.h index 9bf45c01..475b1a73 100644 --- a/miosix/config/miosix_settings.h +++ b/miosix/config/miosix_settings.h @@ -67,7 +67,7 @@ namespace miosix { /// This enables the dynamic loader to load elf programs, the extended system /// call service and, if the hardware supports it, the MPU to provide memory /// isolation of processes -#define WITH_PROCESSES +//#define WITH_PROCESSES #if defined(WITH_PROCESSES) && defined(__NO_EXCEPTIONS) #error Processes require C++ exception support @@ -125,7 +125,7 @@ const unsigned char MAX_OPEN_FILES=8; * mode, so to use debugging it is necessary to disble sleep in the idle thread. * By default it is not defined (idle thread calls sleep). */ -#define JTAG_DISABLE_SLEEP +//#define JTAG_DISABLE_SLEEP /// Minimum stack size (MUST be divisible by 4) const unsigned int STACK_MIN=256; diff --git a/miosix/filesystem/file_access.cpp b/miosix/filesystem/file_access.cpp index 06466f98..1e8b57c7 100644 --- a/miosix/filesystem/file_access.cpp +++ b/miosix/filesystem/file_access.cpp @@ -10,7 +10,7 @@ using namespace std; -#undef WITH_PROCESSES // <----------------------- FIXME! remove this! +#undef WITH_PROCESSES // FIXME: remove this after integrating file descriptor tables and processes #ifdef WITH_FILESYSTEM -- GitLab