diff --git a/.gitignore b/.gitignore index e16d067fd0..5c807052b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ .svn* .dep* *.o.d +*.o build/ Debug_EMS/ Release_EMS/ -Debug/ \ No newline at end of file +Debug/ diff --git a/firmware/console/eficonsole.cpp b/firmware/console/eficonsole.cpp index a7bf1a4c0b..17922b9324 100644 --- a/firmware/console/eficonsole.cpp +++ b/firmware/console/eficonsole.cpp @@ -121,8 +121,8 @@ static void sayHello(void) { */ static void cmd_threads(void) { #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) - static const char *states[] = { THD_STATE_NAMES }; - Thread *tp; + static const char *states[] = { CH_STATE_NAMES }; + thread_t *tp; scheduleMsg(&logger, " addr stack prio refs state time"); tp = chRegFirstThread(); diff --git a/firmware/util/rfiutil.h b/firmware/util/rfiutil.h index f9770f792d..b0a79076c9 100644 --- a/firmware/util/rfiutil.h +++ b/firmware/util/rfiutil.h @@ -15,14 +15,17 @@ #include "histogram.h" +/** + * Unfortunately ChibiOS has two versions of methods for different + * contexts. + */ +#ifndef SIMULATOR #define isLocked() (ch.dbg.lock_cnt > 0) - - /** - * Unfortunately ChibiOS has two versions of methods for different - * contexts. - */ - #define isIsrContext() (ch.dbg.isr_cnt > 0) +#else +#define isLocked() (0) +#define isIsrContext() (0) +#endif #ifdef __cplusplus extern "C" diff --git a/win32_functional_tests/Makefile b/win32_functional_tests/Makefile index a7e566fed0..7786105a2d 100644 --- a/win32_functional_tests/Makefile +++ b/win32_functional_tests/Makefile @@ -3,60 +3,47 @@ # NOTE: Can be overridden externally. # -PROJECT_DIR = ../firmware -#CHIBIOS = $(PROJECT_DIR)/chibios - # Compiler options here. ifeq ($(USE_OPT),) # this config if debugging is needed, but the binary is about 50M # USE_OPT = -c -Wall -O0 -ggdb -g3 -Werror-implicit-function-declaration -Werror -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings # this config producec a smaller binary file - USE_OPT = -c -Wall -O2 -Werror-implicit-function-declaration -Wno-error=pointer-sign -Wno-error=unused-function -Wno-error=unused-variable -Wno-error=sign-compare -Wno-error=unused-parameter -Wno-error=missing-field-initializers -Wno-error=write-strings -Wno-error=strict-aliasing - - ifeq ($(OS),Windows_NT) - else - USE_OPT += -m32 - endif +USE_OPT = -Os +endif +ifeq ($(OS),Windows_NT) +else +USE_OPT += -m32 endif # C specific options here (added to USE_OPT). ifeq ($(USE_COPT),) - USE_COPT = -std=gnu99 -fgnu89-inline - - ifeq ($(OS),Windows_NT) - else - USE_COPT += -Wno-error=attributes -Wno-error=implicit-function-declaration -include stdio.h - endif +USE_COPT = -std=gnu99 -fgnu89-inline +endif +ifeq ($(OS),Windows_NT) +else +USE_COPT += -Wno-error=attributes -Wno-error=implicit-function-declaration -include stdio.h endif # C++ specific options here (added to USE_OPT). ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -std=c++11 -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit - - - ifeq ($(OS),Windows_NT) - else - USE_CPPOPT += -include cstring -include cstdio -include cstdlib - endif - +USE_CPPOPT = -std=c++11 -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit endif +ifeq ($(OS),Windows_NT) +else +USE_CPPOPT += -include cstring -include cstdio -include cstdlib +endif # Enable this if you want the linker to remove unused code and data ifeq ($(USE_LINK_GC),) USE_LINK_GC = yes endif -# If enabled, this option allows to compile the application in THUMB mode. -ifeq ($(USE_THUMB),) - USE_THUMB = no -endif - # Enable this if you want to see the full log while compiling. ifeq ($(USE_VERBOSE_COMPILE),) - USE_VERBOSE_COMPILE = no + USE_VERBOSE_COMPILE = yes endif # @@ -78,18 +65,24 @@ DDEFS = ############################################################################## # Project, sources and paths # - - # Define project name here +# Define project name here PROJECT = rusefi_simulator +PROJECT_DIR = ../firmware +CHIBIOS = ../firmware/ChibiOS -#PROJECT_BOARD = OLIMEX_STM32_E407 -#ifneq ($(PROJECT_BOARD),OLIMEX_STM32_E407) -# PROJECT_BOARD = ST_STM32F4_DISCOVERY -#endif -#DDEFS += -D$(PROJECT_BOARD) - -CHIBIOS = ../firmware/chibios # Imported source files and paths +include $(CHIBIOS)/os/hal/boards/simulator/board.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/hal/osal/rt/osal.mk +include $(CHIBIOS)/os/rt/ports/SIMIA32/compilers/GCC/port.mk +include $(CHIBIOS)/os/rt/rt.mk + +ifeq ($(OS),Windows_NT) + include ${CHIBIOS}/os/hal/ports/simulator/win32/platform.mk +else + include ${CHIBIOS}/os/hal/ports/simulator/Posix/platform.mk +endif + include $(PROJECT_DIR)/util/util.mk include $(PROJECT_DIR)/config/engines/engines.mk include $(PROJECT_DIR)/controllers/algo/algo.mk @@ -102,48 +95,36 @@ include $(PROJECT_DIR)/console/console.mk include $(PROJECT_DIR)/console/binary/tunerstudio.mk include $(PROJECT_DIR)/development/development.mk -include $(CHIBIOS)/boards/simulator/board.mk -include ${CHIBIOS}/os/hal/hal.mk - -ifeq ($(OS),Windows_NT) - include ${CHIBIOS}/os/hal/platforms/Win32/platform.mk -else - include ${CHIBIOS}/os/hal/platforms/Posix/platform.mk -endif - -include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk -include ${CHIBIOS}/os/kernel/kernel.mk - # Define linker script file here #LDSCRIPT= config/system/STM32F407xG.ld #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld # C sources that can be compiled in ARM or THUMB mode depending on the global # setting. -CSRC = ${PORTSRC} \ - ${KERNSRC} \ - ${TESTSRC} \ - ${HALSRC} \ - ${PLATFORMSRC} \ - $(SYSTEMSRC) \ - $(CONSOLESRC) \ - $(CONTROLLERS_ALGO_SRC) \ - $(CONTROLLERS_CORE_SRC) \ - $(CONTROLLERS_SENSORS_SRC) \ - $(ENGINES_SRC) \ - $(BOARDSRC) \ - ${CHIBIOS}/os/various/chprintf.c \ - ${CHIBIOS}/os/various/memstreams.c \ - $(UTILSRC) \ - main.c +CSRC = ${PORTSRC} \ + ${KERNSRC} \ + ${HALSRC} \ + ${PLATFORMSRC} \ + $(SYSTEMSRC) \ + $(CONSOLESRC) \ + $(CONTROLLERS_ALGO_SRC) \ + $(CONTROLLERS_CORE_SRC) \ + $(CONTROLLERS_SENSORS_SRC) \ + $(ENGINES_SRC) \ + $(BOARDSRC) \ + $(CHIBIOS)/os/hal/lib/streams/memstreams.c \ + $(CHIBIOS)/os/hal/lib/streams/chprintf.c \ + $(CHIBIOS)/os/various/shell.c \ + $(UTILSRC) \ + main.c # C++ sources that can be compiled in ARM or THUMB mode depending on the global # setting. CPPSRC = $(UTILSRC_CPP) \ $(CONTROLLERS_ALGO_SRC_CPP) \ $(PROJECT_DIR)/controllers/settings.cpp \ - $(PROJECT_DIR)/controllers/engine_controller.cpp \ - $(PROJECT_DIR)/controllers/error_handling.cpp \ + $(PROJECT_DIR)/controllers/engine_controller.cpp \ + $(PROJECT_DIR)/controllers/error_handling.cpp \ $(PROJECT_DIR)/development/sensor_chart.cpp \ $(TRIGGER_SRC_CPP) \ $(TRIGGER_DECODERS_SRC_CPP) \ @@ -155,57 +136,43 @@ CPPSRC = $(UTILSRC_CPP) \ $(CONTROLLERS_MATH_SRC_CPP) \ $(DEV_SIMULATOR_SRC_CPP) \ $(ENGINES_SRC_CPP) \ - $(PROJECT_DIR)/simulator/rusEfiFunctionalTest.cpp \ - $(PROJECT_DIR)/simulator/framework.cpp \ + simulator/rusEfiFunctionalTest.cpp \ + simulator/framework.cpp \ + simulator/boards.cpp \ $(PROJECT_DIR)/controllers/map_averaging.cpp \ $(PROJECT_DIR)/development/trigger_emulator.cpp \ - simulator/boards.cpp \ $(TEST_SRC_CPP) -# C sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACSRC = -# C++ sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACPPSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCPPSRC = # List ASM source files here ASMSRC = $(PORTASM) INCDIR = . \ -$(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ - $(PROJECT_DIR)/util \ - $(PROJECT_DIR)/console \ - $(PROJECT_DIR)/console/binary \ - $(PROJECT_DIR)/console/fl_binary \ - $(PROJECT_DIR)/config/engines \ - $(PROJECT_DIR)/ext_algo \ - $(PROJECT_DIR)/controllers \ - $(PROJECT_DIR)/hw_layer/algo \ - $(PROJECT_DIR)/development \ - $(PROJECT_DIR)/controllers/algo \ - $(PROJECT_DIR)/controllers/core \ - $(PROJECT_DIR)/controllers/math \ - $(PROJECT_DIR)/controllers/sensors \ - $(PROJECT_DIR)/controllers/system \ - $(PROJECT_DIR)/controllers/trigger \ - $(PROJECT_DIR)/controllers/trigger/decoders \ - ${CHIBIOS}/os/various \ - simulator - + $(PORTINC) \ + $(KERNINC) \ + $(OSALINC) \ + $(HALINC) \ + $(PLATFORMINC) \ + $(BOARDINC) \ + $(PROJECT_DIR)/util \ + $(PROJECT_DIR)/console \ + $(PROJECT_DIR)/console/binary \ + $(PROJECT_DIR)/console/fl_binary \ + $(PROJECT_DIR)/config/engines \ + $(PROJECT_DIR)/ext_algo \ + $(PROJECT_DIR)/controllers \ + $(PROJECT_DIR)/hw_layer/algo \ + $(PROJECT_DIR)/development \ + $(PROJECT_DIR)/controllers/algo \ + $(PROJECT_DIR)/controllers/core \ + $(PROJECT_DIR)/controllers/math \ + $(PROJECT_DIR)/controllers/sensors \ + $(PROJECT_DIR)/controllers/system \ + $(PROJECT_DIR)/controllers/trigger \ + $(PROJECT_DIR)/controllers/trigger/decoders \ + ${CHIBIOS}/os/various \ + $(CHIBIOS)/os/hal/lib/streams \ + simulator # # Project, sources and paths @@ -221,6 +188,7 @@ $(PORTINC) $(KERNINC) $(TESTINC) \ ifeq ($(OS),Windows_NT) #Cygwin64 is used with mingw64 32-bit version + #TRGT = i686-w64-mingw32- TRGT = i686-w64-mingw32- else TRGT = @@ -239,12 +207,6 @@ OD = $(TRGT)objdump HEX = $(CP) -O ihex BIN = $(CP) -O binary -# ARM-specific options here -AOPT = - -# THUMB-specific options here -TOPT = -mthumb -DTHUMB - # Define C warning options here CWARN = -Wall -Wextra -Wstrict-prototypes @@ -285,7 +247,7 @@ endif # # List all user C define here, like -D_DEBUG=1 -UDEFS = +UDEFS = -DSIMULATOR # Define ASM defines here UADEFS = diff --git a/win32_functional_tests/chconf.h b/win32_functional_tests/chconf.h index be1cee9d80..2f29bf9e75 100644 --- a/win32_functional_tests/chconf.h +++ b/win32_functional_tests/chconf.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -28,11 +28,37 @@ #ifndef _CHCONF_H_ #define _CHCONF_H_ -#define CHPRINTF_USE_FLOAT TRUE +/*===========================================================================*/ +/** + * @name System timers settings + * @{ + */ +/*===========================================================================*/ - #define ON_LOCK_HOOK - #define ON_UNLOCK_HOOK +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#define CH_CFG_ST_RESOLUTION 32 +/** + * @brief System tick frequency. + * @details Frequency of the system timer that drives the system ticks. This + * setting also defines the system tick time unit. + */ +#define CH_CFG_ST_FREQUENCY 100000 + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#define CH_CFG_ST_TIMEDELTA 0 + +/** @} */ /*===========================================================================*/ /** @@ -41,15 +67,6 @@ */ /*===========================================================================*/ -/** - * @brief System tick frequency. - * @details Frequency of the system timer that drives the system ticks. This - * setting also defines the system tick time unit. - */ -#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__) -#define CH_FREQUENCY 100000 -#endif - /** * @brief Round robin interval. * @details This constant is the number of system ticks allowed for the @@ -57,13 +74,12 @@ * disables the preemption for threads with equal priority and the * round robin becomes cooperative. Note that higher priority * threads can still preempt, the kernel is always preemptive. - * * @note Disabling the round robin preemption makes the kernel more compact * and generally faster. + * @note The round robin preemption is not supported in tickless mode and + * must be set to zero in that case. */ -#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__) -#define CH_TIME_QUANTUM 20 -#endif +#define CH_CFG_TIME_QUANTUM 20 /** * @brief Managed RAM size. @@ -74,28 +90,18 @@ * * @note In order to let the OS manage the whole RAM the linker script must * provide the @p __heap_base__ and @p __heap_end__ symbols. - * @note Requires @p CH_USE_MEMCORE. + * @note Requires @p CH_CFG_USE_MEMCORE. */ -#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__) -#define CH_MEMCORE_SIZE 0x20000 -#endif +#define CH_CFG_MEMCORE_SIZE 0x20000 /** * @brief Idle thread automatic spawn suppression. * @details When this option is activated the function @p chSysInit() - * does not spawn the idle thread automatically. The application has - * then the responsibility to do one of the following: - * - Spawn a custom idle thread at priority @p IDLEPRIO. - * - Change the main() thread priority to @p IDLEPRIO then enter - * an endless loop. In this scenario the @p main() thread acts as - * the idle thread. - * . - * @note Unless an idle thread is spawned the @p main() thread must not - * enter a sleep state. + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. */ -#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__) -#define CH_NO_IDLE_THREAD FALSE -#endif +#define CH_CFG_NO_IDLE_THREAD FALSE /** @} */ @@ -114,9 +120,7 @@ * @note This is not related to the compiler optimization options. * @note The default is @p TRUE. */ -#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) -#define CH_OPTIMIZE_SPEED TRUE -#endif +#define CH_CFG_OPTIMIZE_SPEED TRUE /** @} */ @@ -127,15 +131,22 @@ */ /*===========================================================================*/ +/** + * @brief Time Measurement APIs. + * @details If enabled then the time measurement APIs are included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#define CH_CFG_USE_TM FALSE + /** * @brief Threads registry APIs. * @details If enabled then the registry APIs are included in the kernel. * * @note The default is @p TRUE. */ -#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) -#define CH_USE_REGISTRY TRUE -#endif +#define CH_CFG_USE_REGISTRY TRUE /** * @brief Threads synchronization APIs. @@ -144,9 +155,7 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) -#define CH_USE_WAITEXIT TRUE -#endif +#define CH_CFG_USE_WAITEXIT TRUE /** * @brief Semaphores APIs. @@ -154,33 +163,18 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) -#define CH_USE_SEMAPHORES TRUE -#endif +#define CH_CFG_USE_SEMAPHORES TRUE /** * @brief Semaphores queuing mode. * @details If enabled then the threads are enqueued on semaphores by * priority rather than in FIFO order. * - * @note The default is @p FALSE. Enable this if you have special requirements. - * @note Requires @p CH_USE_SEMAPHORES. + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_SEMAPHORES. */ -#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) -#define CH_USE_SEMAPHORES_PRIORITY FALSE -#endif - -/** - * @brief Atomic semaphore API. - * @details If enabled then the semaphores the @p chSemSignalWait() API - * is included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_USE_SEMAPHORES. - */ -#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__) -#define CH_USE_SEMSW TRUE -#endif +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE /** * @brief Mutexes APIs. @@ -188,9 +182,17 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) -#define CH_USE_MUTEXES TRUE -#endif +#define CH_CFG_USE_MUTEXES TRUE + +/** + * @brief Enables recursive behavior on mutexes. + * @note Recursive mutexes are heavier and have an increased + * memory footprint. + * + * @note The default is @p FALSE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE /** * @brief Conditional Variables APIs. @@ -198,11 +200,9 @@ * in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_MUTEXES. + * @note Requires @p CH_CFG_USE_MUTEXES. */ -#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__) -#define CH_USE_CONDVARS TRUE -#endif +#define CH_CFG_USE_CONDVARS TRUE /** * @brief Conditional Variables APIs with timeout. @@ -210,11 +210,9 @@ * specification are included in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_CONDVARS. + * @note Requires @p CH_CFG_USE_CONDVARS. */ -#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__) -#define CH_USE_CONDVARS_TIMEOUT TRUE -#endif +#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE /** * @brief Events Flags APIs. @@ -222,9 +220,7 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) -#define CH_USE_EVENTS TRUE -#endif +#define CH_CFG_USE_EVENTS TRUE /** * @brief Events Flags APIs with timeout. @@ -232,11 +228,9 @@ * are included in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_EVENTS. + * @note Requires @p CH_CFG_USE_EVENTS. */ -#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__) -#define CH_USE_EVENTS_TIMEOUT TRUE -#endif +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE /** * @brief Synchronous Messages APIs. @@ -245,21 +239,18 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) -#define CH_USE_MESSAGES TRUE -#endif +#define CH_CFG_USE_MESSAGES TRUE /** * @brief Synchronous Messages queuing mode. * @details If enabled then messages are served by priority rather than in * FIFO order. * - * @note The default is @p FALSE. Enable this if you have special requirements. - * @note Requires @p CH_USE_MESSAGES. + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_MESSAGES. */ -#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) -#define CH_USE_MESSAGES_PRIORITY FALSE -#endif +#define CH_CFG_USE_MESSAGES_PRIORITY FALSE /** * @brief Mailboxes APIs. @@ -267,11 +258,9 @@ * included in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_SEMAPHORES. + * @note Requires @p CH_CFG_USE_SEMAPHORES. */ -#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__) -#define CH_USE_MAILBOXES TRUE -#endif +#define CH_CFG_USE_MAILBOXES TRUE /** * @brief I/O Queues APIs. @@ -279,9 +268,7 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) -#define CH_USE_QUEUES TRUE -#endif +#define CH_CFG_USE_QUEUES TRUE /** * @brief Core Memory Manager APIs. @@ -290,9 +277,7 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) -#define CH_USE_MEMCORE TRUE -#endif +#define CH_CFG_USE_MEMCORE TRUE /** * @brief Heap Allocator APIs. @@ -300,27 +285,11 @@ * in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or - * @p CH_USE_SEMAPHORES. + * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or + * @p CH_CFG_USE_SEMAPHORES. * @note Mutexes are recommended. */ -#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) -#define CH_USE_HEAP TRUE -#endif - -/** - * @brief C-runtime allocator. - * @details If enabled the the heap allocator APIs just wrap the C-runtime - * @p malloc() and @p free() functions. - * - * @note The default is @p FALSE. - * @note Requires @p CH_USE_HEAP. - * @note The C-runtime may or may not require @p CH_USE_MEMCORE, see the - * appropriate documentation. - */ -#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__) -#define CH_USE_MALLOC_HEAP FALSE -#endif +#define CH_CFG_USE_HEAP TRUE /** * @brief Memory Pools Allocator APIs. @@ -329,9 +298,7 @@ * * @note The default is @p TRUE. */ -#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) -#define CH_USE_MEMPOOLS TRUE -#endif +#define CH_CFG_USE_MEMPOOLS TRUE /** * @brief Dynamic Threads APIs. @@ -339,12 +306,10 @@ * in the kernel. * * @note The default is @p TRUE. - * @note Requires @p CH_USE_WAITEXIT. - * @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. + * @note Requires @p CH_CFG_USE_WAITEXIT. + * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. */ -#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) -#define CH_USE_DYNAMIC TRUE -#endif +#define CH_CFG_USE_DYNAMIC TRUE /** @} */ @@ -355,6 +320,13 @@ */ /*===========================================================================*/ +/** + * @brief Debug option, kernel statistics. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_STATISTICS FALSE + /** * @brief Debug option, system state check. * @details If enabled the correct call protocol for system APIs is checked @@ -362,9 +334,7 @@ * * @note The default is @p FALSE. */ -#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) -#define CH_DBG_SYSTEM_STATE_CHECK TRUE -#endif +#define CH_DBG_SYSTEM_STATE_CHECK FALSE /** * @brief Debug option, parameters checks. @@ -373,9 +343,7 @@ * * @note The default is @p FALSE. */ -#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_CHECKS TRUE -#endif +#define CH_DBG_ENABLE_CHECKS FALSE /** * @brief Debug option, consistency checks. @@ -385,9 +353,7 @@ * * @note The default is @p FALSE. */ -#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_ASSERTS TRUE -#endif +#define CH_DBG_ENABLE_ASSERTS FALSE /** * @brief Debug option, trace buffer. @@ -396,9 +362,7 @@ * * @note The default is @p FALSE. */ -#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_TRACE FALSE -#endif +#define CH_DBG_ENABLE_TRACE FALSE /** * @brief Debug option, stack checks. @@ -410,9 +374,7 @@ * @note The default failure mode is to halt the system with the global * @p panic_msg variable set to @p NULL. */ -#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) -#define CH_DBG_ENABLE_STACK_CHECK FALSE -#endif +#define CH_DBG_ENABLE_STACK_CHECK FALSE /** * @brief Debug option, stacks initialization. @@ -422,22 +384,18 @@ * * @note The default is @p FALSE. */ -#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) -#define CH_DBG_FILL_THREADS FALSE -#endif +#define CH_DBG_FILL_THREADS FALSE /** * @brief Debug option, threads profiling. - * @details If enabled then a field is added to the @p Thread structure that + * @details If enabled then a field is added to the @p thread_t structure that * counts the system ticks occurred while executing the thread. * - * @note The default is @p TRUE. - * @note This debug option is defaulted to TRUE because it is required by - * some test cases into the test suite. + * @note The default is @p FALSE. + * @note This debug option is not currently compatible with the + * tickless mode. */ -#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) -#define CH_DBG_THREADS_PROFILING TRUE -#endif +#define CH_DBG_THREADS_PROFILING TRUE /** @} */ @@ -450,12 +408,10 @@ /** * @brief Threads descriptor structure extension. - * @details User fields added to the end of the @p Thread structure. + * @details User fields added to the end of the @p thread_t structure. */ -#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__) -#define THREAD_EXT_FIELDS \ +#define CH_CFG_THREAD_EXTRA_FIELDS \ /* Add threads custom fields here.*/ -#endif /** * @brief Threads initialization hook. @@ -464,11 +420,9 @@ * @note It is invoked from within @p chThdInit() and implicitly from all * the threads creation APIs. */ -#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__) -#define THREAD_EXT_INIT_HOOK(tp) { \ +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ /* Add threads initialization code here.*/ \ } -#endif /** * @brief Threads finalization hook. @@ -478,54 +432,61 @@ * @note It is also invoked when the threads simply return in order to * terminate. */ -#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__) -#define THREAD_EXT_EXIT_HOOK(tp) { \ +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ /* Add threads finalization code here.*/ \ } -#endif /** * @brief Context switch hook. * @details This hook is invoked just before switching between threads. */ -#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__) -#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \ - /* System halt code here.*/ \ +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define CH_CFG_IDLE_ENTER_HOOK() { \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define CH_CFG_IDLE_LEAVE_HOOK() { \ } -#endif /** * @brief Idle Loop hook. * @details This hook is continuously invoked by the idle thread loop. */ -#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) -#define IDLE_LOOP_HOOK() { \ +#define CH_CFG_IDLE_LOOP_HOOK() { \ /* Idle loop code here.*/ \ } -#endif /** * @brief System tick event hook. * @details This hook is invoked in the system tick handler immediately * after processing the virtual timers queue. */ -#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__) -#define SYSTEM_TICK_EVENT_HOOK() { \ +#define CH_CFG_SYSTEM_TICK_HOOK() { \ /* System tick event code here.*/ \ } -#endif - /** * @brief System halt hook. * @details This hook is invoked in case to a system halting error before * the system is halted. */ -#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) -#define SYSTEM_HALT_HOOK() { \ +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ /* System halt code here.*/ \ } -#endif /** @} */ diff --git a/win32_functional_tests/halconf.h b/win32_functional_tests/halconf.h index 37c0489640..07718cf692 100644 --- a/win32_functional_tests/halconf.h +++ b/win32_functional_tests/halconf.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -58,6 +58,13 @@ #define HAL_USE_CAN FALSE #endif +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + /** * @brief Enables the EXT subsystem. */ @@ -79,6 +86,13 @@ #define HAL_USE_I2C FALSE #endif +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + /** * @brief Enables the ICU subsystem. */ @@ -156,6 +170,13 @@ #define HAL_USE_USB FALSE #endif +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + /*===========================================================================*/ /* ADC driver related settings. */ /*===========================================================================*/ @@ -280,7 +301,7 @@ * @brief Serial buffers size. * @details Configuration parameter, you can change the depth of the queue * buffers depending on the requirements of your application. - * @note The default is 64 bytes for both the transmission and receive + * @note The default is 16 bytes for both the transmission and receive * buffers. */ #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) @@ -307,6 +328,38 @@ #define SPI_USE_MUTUAL_EXCLUSION TRUE #endif +/*===========================================================================*/ +/* UART driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_WAIT) || defined(__DOXYGEN__) +#define UART_USE_WAIT FALSE +#endif + +/** + * @brief Enables the @p uartAcquireBus() and @p uartReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(UART_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define UART_USE_MUTUAL_EXCLUSION FALSE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT FALSE +#endif + #endif /* _HALCONF_H_ */ /** @} */ diff --git a/win32_functional_tests/main.c b/win32_functional_tests/main.c index 3b790a5fd3..61de2528c0 100644 --- a/win32_functional_tests/main.c +++ b/win32_functional_tests/main.c @@ -19,13 +19,13 @@ #include "rusEfiFunctionalTest.h" #include "framework.h" -#define CONSOLE_WA_SIZE THD_WA_SIZE(4096) +#define CONSOLE_WA_SIZE THD_WORKING_AREA_SIZE(4096) bool main_loop_started = false; static thread_t *cdtp; -//static Thread *shelltp1; -//static Thread *shelltp2; +//static thread_t *shelltp1; +//static thread_t *shelltp2; #define cputs(msg) chMsgSend(cdtp, (msg_t)msg) @@ -40,16 +40,15 @@ TestStream testStream; * to the C printf() thread safe and the print operation atomic among threads. * In this example the message is the zero terminated string itself. */ -static msg_t console_thread(void *arg) { +THD_FUNCTION(console_thread, arg) { (void) arg; - while (!chThdShouldTerminate()) { + while (!chThdShouldTerminateX()) { thread_t *tp = chMsgWait(); puts((char *) chMsgGet(tp)); fflush(stdout); chMsgRelease(tp, MSG_OK); } - return 0; } extern int isSerialOverTcpReady; @@ -172,7 +171,7 @@ int main(void) { /* * Events servicing loop. */ - while (!chThdShouldTerminate()) { + while (!chThdShouldTerminateX()) { chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS)); printPendingMessages(); chThdSleepMilliseconds(100); diff --git a/win32_functional_tests/rules.mk b/win32_functional_tests/rules.mk index 5e93b3e311..b23473b182 100644 --- a/win32_functional_tests/rules.mk +++ b/win32_functional_tests/rules.mk @@ -1,72 +1,84 @@ # ARM Cortex-Mx common makefile scripts and rules. -# Output directory and files -ifeq ($(BUILDDIR),) - BUILDDIR = build -endif -ifeq ($(BUILDDIR),.) - BUILDDIR = build -endif -OUTFILES = $(BUILDDIR)/$(PROJECT) +############################################################################## +# Processing options coming from the upper Makefile. +# -# Automatic compiler options -OPT = $(USE_OPT) -COPT = $(USE_COPT) -CPPOPT = $(USE_CPPOPT) +# Compiler options +OPT := $(USE_OPT) +COPT := $(USE_COPT) +CPPOPT := $(USE_CPPOPT) + +# Garbage collection ifeq ($(USE_LINK_GC),yes) - OPT += -ffunction-sections -fdata-sections -fno-common + OPT += -ffunction-sections -fdata-sections -fno-common + LDOPT := ,--gc-sections +else + LDOPT := endif -# Source files groups and paths -ifeq ($(USE_THUMB),yes) - TCSRC += $(CSRC) - TCPPSRC += $(CPPSRC) -else - ACSRC += $(CSRC) - ACPPSRC += $(CPPSRC) +# Linker extra options +ifneq ($(USE_LDOPT),) + LDOPT := $(LDOPT),$(USE_LDOPT) endif -ASRC = $(ACSRC)$(ACPPSRC) -TSRC = $(TCSRC)$(TCPPSRC) -SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC))) + +# Link time optimizations +ifeq ($(USE_LTO),yes) + OPT += -flto +endif + +# Process stack size +ifeq ($(USE_PROCESS_STACKSIZE),) + LDOPT := $(LDOPT),--defsym=__process_stack_size__=0x400 +else + LDOPT := $(LDOPT),--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE) +endif + +# Exceptions stack size +ifeq ($(USE_EXCEPTIONS_STACKSIZE),) + LDOPT := $(LDOPT),--defsym=__main_stack_size__=0x400 +else + LDOPT := $(LDOPT),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE) +endif + +BUILDDIR = build +OUTFILES := $(BUILDDIR)/$(PROJECT).exe +SRCPATHS := $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(CSRC)) $(dir $(CPPSRC))) # Various directories -OBJDIR = $(BUILDDIR)/obj -LSTDIR = $(BUILDDIR)/lst +OBJDIR := $(BUILDDIR)/obj +LSTDIR := $(BUILDDIR)/lst # Object files groups -ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o))) -ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o))) -TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o))) -TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o))) -ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) -ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o))) -OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS) +COBJS := $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o))) +CPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o))) +ASMOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) +ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o))) +OBJS := $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS) # Paths -IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) -LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) +IINCDIR := $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) +LLIBDIR := $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) # Macros -DEFS = $(DDEFS) $(UDEFS) -ADEFS = $(DADEFS) $(UADEFS) +DEFS := $(DDEFS) $(UDEFS) +ADEFS := $(DADEFS) $(UADEFS) # Libs -LIBS = $(DLIBS) $(ULIBS) +LIBS := $(DLIBS) $(ULIBS) # Various settings -#MCFLAGS = -mcpu=$(MCU) +MCFLAGS = ODFLAGS = -x --syms ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS) ASXFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.S=.lst)) $(ADEFS) CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS) CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS) -ifeq ($(USE_LINK_GC),yes) - LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--gc-sections $(LLIBDIR) -else - LDFLAGS = $(MCFLAGS) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch $(LLIBDIR) -endif +LDFLAGS = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH),$(LDOPT) # Generate dependency information +ASFLAGS += -MD -MP -MF .dep/$(@F).d +ASXFLAGS += -MD -MP -MF .dep/$(@F).d CFLAGS += -MD -MP -MF .dep/$(@F).d CPPFLAGS += -MD -MP -MF .dep/$(@F).d @@ -77,55 +89,40 @@ VPATH = $(SRCPATHS) # Makefile rules # -all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK +all: $(OBJS) $(OUTFILES) -MAKE_ALL_RULE_HOOK: +$(OBJS): $(BUILDDIR) $(OBJDIR) $(LSTDIR) -$(OBJS): | $(BUILDDIR) - -$(BUILDDIR) $(OBJDIR) $(LSTDIR): +$(BUILDDIR): ifneq ($(USE_VERBOSE_COMPILE),yes) @echo Compiler Options - @echo $(CPPC) -c $(CPPFLAGS) -I. $(IINCDIR) main.cpp -o main.o + @echo $(CC) -c $(CFLAGS) -I. $(IINCDIR) main.c -o main.o @echo endif - mkdir -p $(OBJDIR) - mkdir -p $(LSTDIR) + @mkdir -p $(BUILDDIR) -$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile +$(OBJDIR): + @mkdir -p $(OBJDIR) + +$(LSTDIR): + @mkdir -p $(LSTDIR) + +$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile ifeq ($(USE_VERBOSE_COMPILE),yes) @echo - $(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@ + $(CPPC) -c $(CPPFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@ else @echo Compiling $( Migration -typedef VirtualTimer virtual_timer_t; -typedef EventListener event_listener_t; -typedef Thread thread_t; -#define THD_WORKING_AREA WORKING_AREA -#define THD_FUNCTION(tname, arg) void tname(void *arg) -#define MSG_OK RDY_OK -#define eventflags_t flagsmask_t -#define chSysLockFromISR chSysLockFromIsr -#define chSysUnlockFromISR chSysUnlockFromIsr -#define chThdGetSelfX chThdSelf +#define EFI_UNIT_TEST FALSE +#define hasFatalError() (FALSE) #define US_TO_NT_MULTIPLIER 100 -#define ALWAYS_INLINE INLINE +#define ALWAYS_INLINE #define US2NT(x) (US_TO_NT_MULTIPLIER * (x))