diff --git a/Makefile b/Makefile index c5c788c70861b741f3ecc9b3aad8ec354ec339ad..1f741a862888f514581152a232a250426033b9ee 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 cfdc14126978950bf41b0909cf59205b6a1bf958..2ac0bcaf53fe7868268c3b8554dcd65dcc815cd4 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 ffa9e8a77fef87504267ddc762ccd4acd4f280d6..1ba281e1f94ee801a9e022a6cdffe67cf28313cd 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 5fcc019b48c22748b3466d29368a89a918708327..e40061aa5df985f07b8f1e316cc554d79f25f1cb 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 db9bd7a9fb11a8c4873dbfd0fdb139e1b22e31bc..7aaca4d797a1c0457fc5e6a8dfe84846429d3ec2 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 9bf45c016dc17ec918d2f6206d828c086796d4ed..475b1a7342cd59e5cf9658839223f0215e3648d6 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 06466f983da24b37c99fb4ed0717eaf249110450..1e8b57c7557bc49259b6d4179a87205f52128501 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