Fixed simulator. Needs testing.

This commit is contained in:
Fabien Poussin 2017-03-24 01:59:14 +01:00
parent f5d2eab8b5
commit 63e4a3dea1
10 changed files with 369 additions and 401 deletions

3
.gitignore vendored
View File

@ -1,7 +1,8 @@
.svn* .svn*
.dep* .dep*
*.o.d *.o.d
*.o
build/ build/
Debug_EMS/ Debug_EMS/
Release_EMS/ Release_EMS/
Debug/ Debug/

View File

@ -121,8 +121,8 @@ static void sayHello(void) {
*/ */
static void cmd_threads(void) { static void cmd_threads(void) {
#if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__) #if CH_DBG_THREADS_PROFILING || defined(__DOXYGEN__)
static const char *states[] = { THD_STATE_NAMES }; static const char *states[] = { CH_STATE_NAMES };
Thread *tp; thread_t *tp;
scheduleMsg(&logger, " addr stack prio refs state time"); scheduleMsg(&logger, " addr stack prio refs state time");
tp = chRegFirstThread(); tp = chRegFirstThread();

View File

@ -15,14 +15,17 @@
#include "histogram.h" #include "histogram.h"
/**
* Unfortunately ChibiOS has two versions of methods for different
* contexts.
*/
#ifndef SIMULATOR
#define isLocked() (ch.dbg.lock_cnt > 0) #define isLocked() (ch.dbg.lock_cnt > 0)
/**
* Unfortunately ChibiOS has two versions of methods for different
* contexts.
*/
#define isIsrContext() (ch.dbg.isr_cnt > 0) #define isIsrContext() (ch.dbg.isr_cnt > 0)
#else
#define isLocked() (0)
#define isIsrContext() (0)
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"

View File

@ -3,60 +3,47 @@
# NOTE: Can be overridden externally. # NOTE: Can be overridden externally.
# #
PROJECT_DIR = ../firmware
#CHIBIOS = $(PROJECT_DIR)/chibios
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
# this config if debugging is needed, but the binary is about 50M # 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 # 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 # 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 USE_OPT = -Os
endif
ifeq ($(OS),Windows_NT)
else
USE_OPT += -m32
endif
ifeq ($(OS),Windows_NT)
else
USE_OPT += -m32
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),) ifeq ($(USE_COPT),)
USE_COPT = -std=gnu99 -fgnu89-inline 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
ifeq ($(OS),Windows_NT)
else
USE_COPT += -Wno-error=attributes -Wno-error=implicit-function-declaration -include stdio.h
endif endif
# C++ specific options here (added to USE_OPT). # C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),) ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -std=c++11 -fno-rtti -fpermissive -fno-exceptions -fno-use-cxa-atexit 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
endif 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 # Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),) ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes USE_LINK_GC = yes
endif 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. # Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),) ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no USE_VERBOSE_COMPILE = yes
endif endif
# #
@ -78,18 +65,24 @@ DDEFS =
############################################################################## ##############################################################################
# Project, sources and paths # Project, sources and paths
# #
# Define project name here
# Define project name here
PROJECT = rusefi_simulator 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 # 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)/util/util.mk
include $(PROJECT_DIR)/config/engines/engines.mk include $(PROJECT_DIR)/config/engines/engines.mk
include $(PROJECT_DIR)/controllers/algo/algo.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)/console/binary/tunerstudio.mk
include $(PROJECT_DIR)/development/development.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 # Define linker script file here
#LDSCRIPT= config/system/STM32F407xG.ld #LDSCRIPT= config/system/STM32F407xG.ld
#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld #LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld
# C sources that can be compiled in ARM or THUMB mode depending on the global # C sources that can be compiled in ARM or THUMB mode depending on the global
# setting. # setting.
CSRC = ${PORTSRC} \ CSRC = ${PORTSRC} \
${KERNSRC} \ ${KERNSRC} \
${TESTSRC} \ ${HALSRC} \
${HALSRC} \ ${PLATFORMSRC} \
${PLATFORMSRC} \ $(SYSTEMSRC) \
$(SYSTEMSRC) \ $(CONSOLESRC) \
$(CONSOLESRC) \ $(CONTROLLERS_ALGO_SRC) \
$(CONTROLLERS_ALGO_SRC) \ $(CONTROLLERS_CORE_SRC) \
$(CONTROLLERS_CORE_SRC) \ $(CONTROLLERS_SENSORS_SRC) \
$(CONTROLLERS_SENSORS_SRC) \ $(ENGINES_SRC) \
$(ENGINES_SRC) \ $(BOARDSRC) \
$(BOARDSRC) \ $(CHIBIOS)/os/hal/lib/streams/memstreams.c \
${CHIBIOS}/os/various/chprintf.c \ $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
${CHIBIOS}/os/various/memstreams.c \ $(CHIBIOS)/os/various/shell.c \
$(UTILSRC) \ $(UTILSRC) \
main.c main.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting. # setting.
CPPSRC = $(UTILSRC_CPP) \ CPPSRC = $(UTILSRC_CPP) \
$(CONTROLLERS_ALGO_SRC_CPP) \ $(CONTROLLERS_ALGO_SRC_CPP) \
$(PROJECT_DIR)/controllers/settings.cpp \ $(PROJECT_DIR)/controllers/settings.cpp \
$(PROJECT_DIR)/controllers/engine_controller.cpp \ $(PROJECT_DIR)/controllers/engine_controller.cpp \
$(PROJECT_DIR)/controllers/error_handling.cpp \ $(PROJECT_DIR)/controllers/error_handling.cpp \
$(PROJECT_DIR)/development/sensor_chart.cpp \ $(PROJECT_DIR)/development/sensor_chart.cpp \
$(TRIGGER_SRC_CPP) \ $(TRIGGER_SRC_CPP) \
$(TRIGGER_DECODERS_SRC_CPP) \ $(TRIGGER_DECODERS_SRC_CPP) \
@ -155,57 +136,43 @@ CPPSRC = $(UTILSRC_CPP) \
$(CONTROLLERS_MATH_SRC_CPP) \ $(CONTROLLERS_MATH_SRC_CPP) \
$(DEV_SIMULATOR_SRC_CPP) \ $(DEV_SIMULATOR_SRC_CPP) \
$(ENGINES_SRC_CPP) \ $(ENGINES_SRC_CPP) \
$(PROJECT_DIR)/simulator/rusEfiFunctionalTest.cpp \ simulator/rusEfiFunctionalTest.cpp \
$(PROJECT_DIR)/simulator/framework.cpp \ simulator/framework.cpp \
simulator/boards.cpp \
$(PROJECT_DIR)/controllers/map_averaging.cpp \ $(PROJECT_DIR)/controllers/map_averaging.cpp \
$(PROJECT_DIR)/development/trigger_emulator.cpp \ $(PROJECT_DIR)/development/trigger_emulator.cpp \
simulator/boards.cpp \
$(TEST_SRC_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 # List ASM source files here
ASMSRC = $(PORTASM) ASMSRC = $(PORTASM)
INCDIR = . \ INCDIR = . \
$(PORTINC) $(KERNINC) $(TESTINC) \ $(PORTINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) \ $(KERNINC) \
$(PROJECT_DIR)/util \ $(OSALINC) \
$(PROJECT_DIR)/console \ $(HALINC) \
$(PROJECT_DIR)/console/binary \ $(PLATFORMINC) \
$(PROJECT_DIR)/console/fl_binary \ $(BOARDINC) \
$(PROJECT_DIR)/config/engines \ $(PROJECT_DIR)/util \
$(PROJECT_DIR)/ext_algo \ $(PROJECT_DIR)/console \
$(PROJECT_DIR)/controllers \ $(PROJECT_DIR)/console/binary \
$(PROJECT_DIR)/hw_layer/algo \ $(PROJECT_DIR)/console/fl_binary \
$(PROJECT_DIR)/development \ $(PROJECT_DIR)/config/engines \
$(PROJECT_DIR)/controllers/algo \ $(PROJECT_DIR)/ext_algo \
$(PROJECT_DIR)/controllers/core \ $(PROJECT_DIR)/controllers \
$(PROJECT_DIR)/controllers/math \ $(PROJECT_DIR)/hw_layer/algo \
$(PROJECT_DIR)/controllers/sensors \ $(PROJECT_DIR)/development \
$(PROJECT_DIR)/controllers/system \ $(PROJECT_DIR)/controllers/algo \
$(PROJECT_DIR)/controllers/trigger \ $(PROJECT_DIR)/controllers/core \
$(PROJECT_DIR)/controllers/trigger/decoders \ $(PROJECT_DIR)/controllers/math \
${CHIBIOS}/os/various \ $(PROJECT_DIR)/controllers/sensors \
simulator $(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 # Project, sources and paths
@ -221,6 +188,7 @@ $(PORTINC) $(KERNINC) $(TESTINC) \
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
#Cygwin64 is used with mingw64 32-bit version #Cygwin64 is used with mingw64 32-bit version
#TRGT = i686-w64-mingw32-
TRGT = i686-w64-mingw32- TRGT = i686-w64-mingw32-
else else
TRGT = TRGT =
@ -239,12 +207,6 @@ OD = $(TRGT)objdump
HEX = $(CP) -O ihex HEX = $(CP) -O ihex
BIN = $(CP) -O binary BIN = $(CP) -O binary
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
# Define C warning options here # Define C warning options here
CWARN = -Wall -Wextra -Wstrict-prototypes CWARN = -Wall -Wextra -Wstrict-prototypes
@ -285,7 +247,7 @@ endif
# #
# List all user C define here, like -D_DEBUG=1 # List all user C define here, like -D_DEBUG=1
UDEFS = UDEFS = -DSIMULATOR
# Define ASM defines here # Define ASM defines here
UADEFS = UADEFS =

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -28,11 +28,37 @@
#ifndef _CHCONF_H_ #ifndef _CHCONF_H_
#define _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. * @brief Round robin interval.
* @details This constant is the number of system ticks allowed for the * @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 * disables the preemption for threads with equal priority and the
* round robin becomes cooperative. Note that higher priority * round robin becomes cooperative. Note that higher priority
* threads can still preempt, the kernel is always preemptive. * threads can still preempt, the kernel is always preemptive.
*
* @note Disabling the round robin preemption makes the kernel more compact * @note Disabling the round robin preemption makes the kernel more compact
* and generally faster. * 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_CFG_TIME_QUANTUM 20
#define CH_TIME_QUANTUM 20
#endif
/** /**
* @brief Managed RAM size. * @brief Managed RAM size.
@ -74,28 +90,18 @@
* *
* @note In order to let the OS manage the whole RAM the linker script must * @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. * 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_CFG_MEMCORE_SIZE 0x20000
#define CH_MEMCORE_SIZE 0x20000
#endif
/** /**
* @brief Idle thread automatic spawn suppression. * @brief Idle thread automatic spawn suppression.
* @details When this option is activated the function @p chSysInit() * @details When this option is activated the function @p chSysInit()
* does not spawn the idle thread automatically. The application has * does not spawn the idle thread. The application @p main()
* then the responsibility to do one of the following: * function becomes the idle thread and must implement an
* - Spawn a custom idle thread at priority @p IDLEPRIO. * infinite loop.
* - 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.
*/ */
#if !defined(CH_NO_IDLE_THREAD) || defined(__DOXYGEN__) #define CH_CFG_NO_IDLE_THREAD FALSE
#define CH_NO_IDLE_THREAD FALSE
#endif
/** @} */ /** @} */
@ -114,9 +120,7 @@
* @note This is not related to the compiler optimization options. * @note This is not related to the compiler optimization options.
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__) #define CH_CFG_OPTIMIZE_SPEED TRUE
#define CH_OPTIMIZE_SPEED TRUE
#endif
/** @} */ /** @} */
@ -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. * @brief Threads registry APIs.
* @details If enabled then the registry APIs are included in the kernel. * @details If enabled then the registry APIs are included in the kernel.
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__) #define CH_CFG_USE_REGISTRY TRUE
#define CH_USE_REGISTRY TRUE
#endif
/** /**
* @brief Threads synchronization APIs. * @brief Threads synchronization APIs.
@ -144,9 +155,7 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__) #define CH_CFG_USE_WAITEXIT TRUE
#define CH_USE_WAITEXIT TRUE
#endif
/** /**
* @brief Semaphores APIs. * @brief Semaphores APIs.
@ -154,33 +163,18 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__) #define CH_CFG_USE_SEMAPHORES TRUE
#define CH_USE_SEMAPHORES TRUE
#endif
/** /**
* @brief Semaphores queuing mode. * @brief Semaphores queuing mode.
* @details If enabled then the threads are enqueued on semaphores by * @details If enabled then the threads are enqueued on semaphores by
* priority rather than in FIFO order. * priority rather than in FIFO order.
* *
* @note The default is @p FALSE. Enable this if you have special requirements. * @note The default is @p FALSE. Enable this if you have special
* @note Requires @p CH_USE_SEMAPHORES. * requirements.
* @note Requires @p CH_CFG_USE_SEMAPHORES.
*/ */
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__) #define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE
#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
/** /**
* @brief Mutexes APIs. * @brief Mutexes APIs.
@ -188,9 +182,17 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__) #define CH_CFG_USE_MUTEXES TRUE
#define CH_USE_MUTEXES TRUE
#endif /**
* @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. * @brief Conditional Variables APIs.
@ -198,11 +200,9 @@
* in the kernel. * in the kernel.
* *
* @note The default is @p TRUE. * @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_CFG_USE_CONDVARS TRUE
#define CH_USE_CONDVARS TRUE
#endif
/** /**
* @brief Conditional Variables APIs with timeout. * @brief Conditional Variables APIs with timeout.
@ -210,11 +210,9 @@
* specification are included in the kernel. * specification are included in the kernel.
* *
* @note The default is @p TRUE. * @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_CFG_USE_CONDVARS_TIMEOUT TRUE
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/** /**
* @brief Events Flags APIs. * @brief Events Flags APIs.
@ -222,9 +220,7 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__) #define CH_CFG_USE_EVENTS TRUE
#define CH_USE_EVENTS TRUE
#endif
/** /**
* @brief Events Flags APIs with timeout. * @brief Events Flags APIs with timeout.
@ -232,11 +228,9 @@
* are included in the kernel. * are included in the kernel.
* *
* @note The default is @p TRUE. * @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_CFG_USE_EVENTS_TIMEOUT TRUE
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/** /**
* @brief Synchronous Messages APIs. * @brief Synchronous Messages APIs.
@ -245,21 +239,18 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__) #define CH_CFG_USE_MESSAGES TRUE
#define CH_USE_MESSAGES TRUE
#endif
/** /**
* @brief Synchronous Messages queuing mode. * @brief Synchronous Messages queuing mode.
* @details If enabled then messages are served by priority rather than in * @details If enabled then messages are served by priority rather than in
* FIFO order. * FIFO order.
* *
* @note The default is @p FALSE. Enable this if you have special requirements. * @note The default is @p FALSE. Enable this if you have special
* @note Requires @p CH_USE_MESSAGES. * requirements.
* @note Requires @p CH_CFG_USE_MESSAGES.
*/ */
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__) #define CH_CFG_USE_MESSAGES_PRIORITY FALSE
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/** /**
* @brief Mailboxes APIs. * @brief Mailboxes APIs.
@ -267,11 +258,9 @@
* included in the kernel. * included in the kernel.
* *
* @note The default is @p TRUE. * @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_CFG_USE_MAILBOXES TRUE
#define CH_USE_MAILBOXES TRUE
#endif
/** /**
* @brief I/O Queues APIs. * @brief I/O Queues APIs.
@ -279,9 +268,7 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__) #define CH_CFG_USE_QUEUES TRUE
#define CH_USE_QUEUES TRUE
#endif
/** /**
* @brief Core Memory Manager APIs. * @brief Core Memory Manager APIs.
@ -290,9 +277,7 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__) #define CH_CFG_USE_MEMCORE TRUE
#define CH_USE_MEMCORE TRUE
#endif
/** /**
* @brief Heap Allocator APIs. * @brief Heap Allocator APIs.
@ -300,27 +285,11 @@
* in the kernel. * in the kernel.
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
* @note Requires @p CH_USE_MEMCORE and either @p CH_USE_MUTEXES or * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or
* @p CH_USE_SEMAPHORES. * @p CH_CFG_USE_SEMAPHORES.
* @note Mutexes are recommended. * @note Mutexes are recommended.
*/ */
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__) #define CH_CFG_USE_HEAP TRUE
#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
/** /**
* @brief Memory Pools Allocator APIs. * @brief Memory Pools Allocator APIs.
@ -329,9 +298,7 @@
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
*/ */
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__) #define CH_CFG_USE_MEMPOOLS TRUE
#define CH_USE_MEMPOOLS TRUE
#endif
/** /**
* @brief Dynamic Threads APIs. * @brief Dynamic Threads APIs.
@ -339,12 +306,10 @@
* in the kernel. * in the kernel.
* *
* @note The default is @p TRUE. * @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT. * @note Requires @p CH_CFG_USE_WAITEXIT.
* @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS. * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS.
*/ */
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__) #define CH_CFG_USE_DYNAMIC TRUE
#define CH_USE_DYNAMIC TRUE
#endif
/** @} */ /** @} */
@ -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. * @brief Debug option, system state check.
* @details If enabled the correct call protocol for system APIs is checked * @details If enabled the correct call protocol for system APIs is checked
@ -362,9 +334,7 @@
* *
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__) #define CH_DBG_SYSTEM_STATE_CHECK FALSE
#define CH_DBG_SYSTEM_STATE_CHECK TRUE
#endif
/** /**
* @brief Debug option, parameters checks. * @brief Debug option, parameters checks.
@ -373,9 +343,7 @@
* *
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__) #define CH_DBG_ENABLE_CHECKS FALSE
#define CH_DBG_ENABLE_CHECKS TRUE
#endif
/** /**
* @brief Debug option, consistency checks. * @brief Debug option, consistency checks.
@ -385,9 +353,7 @@
* *
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__) #define CH_DBG_ENABLE_ASSERTS FALSE
#define CH_DBG_ENABLE_ASSERTS TRUE
#endif
/** /**
* @brief Debug option, trace buffer. * @brief Debug option, trace buffer.
@ -396,9 +362,7 @@
* *
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__) #define CH_DBG_ENABLE_TRACE FALSE
#define CH_DBG_ENABLE_TRACE FALSE
#endif
/** /**
* @brief Debug option, stack checks. * @brief Debug option, stack checks.
@ -410,9 +374,7 @@
* @note The default failure mode is to halt the system with the global * @note The default failure mode is to halt the system with the global
* @p panic_msg variable set to @p NULL. * @p panic_msg variable set to @p NULL.
*/ */
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__) #define CH_DBG_ENABLE_STACK_CHECK FALSE
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/** /**
* @brief Debug option, stacks initialization. * @brief Debug option, stacks initialization.
@ -422,22 +384,18 @@
* *
* @note The default is @p FALSE. * @note The default is @p FALSE.
*/ */
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__) #define CH_DBG_FILL_THREADS FALSE
#define CH_DBG_FILL_THREADS FALSE
#endif
/** /**
* @brief Debug option, threads profiling. * @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. * counts the system ticks occurred while executing the thread.
* *
* @note The default is @p TRUE. * @note The default is @p FALSE.
* @note This debug option is defaulted to TRUE because it is required by * @note This debug option is not currently compatible with the
* some test cases into the test suite. * tickless mode.
*/ */
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__) #define CH_DBG_THREADS_PROFILING TRUE
#define CH_DBG_THREADS_PROFILING TRUE
#endif
/** @} */ /** @} */
@ -450,12 +408,10 @@
/** /**
* @brief Threads descriptor structure extension. * @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 CH_CFG_THREAD_EXTRA_FIELDS \
#define THREAD_EXT_FIELDS \
/* Add threads custom fields here.*/ /* Add threads custom fields here.*/
#endif
/** /**
* @brief Threads initialization hook. * @brief Threads initialization hook.
@ -464,11 +420,9 @@
* @note It is invoked from within @p chThdInit() and implicitly from all * @note It is invoked from within @p chThdInit() and implicitly from all
* the threads creation APIs. * the threads creation APIs.
*/ */
#if !defined(THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__) #define CH_CFG_THREAD_INIT_HOOK(tp) { \
#define THREAD_EXT_INIT_HOOK(tp) { \
/* Add threads initialization code here.*/ \ /* Add threads initialization code here.*/ \
} }
#endif
/** /**
* @brief Threads finalization hook. * @brief Threads finalization hook.
@ -478,54 +432,61 @@
* @note It is also invoked when the threads simply return in order to * @note It is also invoked when the threads simply return in order to
* terminate. * terminate.
*/ */
#if !defined(THREAD_EXT_EXIT_HOOK) || defined(__DOXYGEN__) #define CH_CFG_THREAD_EXIT_HOOK(tp) { \
#define THREAD_EXT_EXIT_HOOK(tp) { \
/* Add threads finalization code here.*/ \ /* Add threads finalization code here.*/ \
} }
#endif
/** /**
* @brief Context switch hook. * @brief Context switch hook.
* @details This hook is invoked just before switching between threads. * @details This hook is invoked just before switching between threads.
*/ */
#if !defined(THREAD_CONTEXT_SWITCH_HOOK) || defined(__DOXYGEN__) #define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \
#define THREAD_CONTEXT_SWITCH_HOOK(ntp, otp) { \ /* Context switch code here.*/ \
/* System halt 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. * @brief Idle Loop hook.
* @details This hook is continuously invoked by the idle thread loop. * @details This hook is continuously invoked by the idle thread loop.
*/ */
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__) #define CH_CFG_IDLE_LOOP_HOOK() { \
#define IDLE_LOOP_HOOK() { \
/* Idle loop code here.*/ \ /* Idle loop code here.*/ \
} }
#endif
/** /**
* @brief System tick event hook. * @brief System tick event hook.
* @details This hook is invoked in the system tick handler immediately * @details This hook is invoked in the system tick handler immediately
* after processing the virtual timers queue. * after processing the virtual timers queue.
*/ */
#if !defined(SYSTEM_TICK_EVENT_HOOK) || defined(__DOXYGEN__) #define CH_CFG_SYSTEM_TICK_HOOK() { \
#define SYSTEM_TICK_EVENT_HOOK() { \
/* System tick event code here.*/ \ /* System tick event code here.*/ \
} }
#endif
/** /**
* @brief System halt hook. * @brief System halt hook.
* @details This hook is invoked in case to a system halting error before * @details This hook is invoked in case to a system halting error before
* the system is halted. * the system is halted.
*/ */
#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) #define CH_CFG_SYSTEM_HALT_HOOK(reason) { \
#define SYSTEM_HALT_HOOK() { \
/* System halt code here.*/ \ /* System halt code here.*/ \
} }
#endif
/** @} */ /** @} */

View File

@ -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"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -58,6 +58,13 @@
#define HAL_USE_CAN FALSE #define HAL_USE_CAN FALSE
#endif #endif
/**
* @brief Enables the DAC subsystem.
*/
#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__)
#define HAL_USE_DAC FALSE
#endif
/** /**
* @brief Enables the EXT subsystem. * @brief Enables the EXT subsystem.
*/ */
@ -79,6 +86,13 @@
#define HAL_USE_I2C FALSE #define HAL_USE_I2C FALSE
#endif #endif
/**
* @brief Enables the I2S subsystem.
*/
#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__)
#define HAL_USE_I2S FALSE
#endif
/** /**
* @brief Enables the ICU subsystem. * @brief Enables the ICU subsystem.
*/ */
@ -156,6 +170,13 @@
#define HAL_USE_USB FALSE #define HAL_USE_USB FALSE
#endif #endif
/**
* @brief Enables the WDG subsystem.
*/
#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__)
#define HAL_USE_WDG FALSE
#endif
/*===========================================================================*/ /*===========================================================================*/
/* ADC driver related settings. */ /* ADC driver related settings. */
/*===========================================================================*/ /*===========================================================================*/
@ -280,7 +301,7 @@
* @brief Serial buffers size. * @brief Serial buffers size.
* @details Configuration parameter, you can change the depth of the queue * @details Configuration parameter, you can change the depth of the queue
* buffers depending on the requirements of your application. * 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. * buffers.
*/ */
#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) #if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__)
@ -307,6 +328,38 @@
#define SPI_USE_MUTUAL_EXCLUSION TRUE #define SPI_USE_MUTUAL_EXCLUSION TRUE
#endif #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_ */ #endif /* _HALCONF_H_ */
/** @} */ /** @} */

View File

@ -19,13 +19,13 @@
#include "rusEfiFunctionalTest.h" #include "rusEfiFunctionalTest.h"
#include "framework.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; bool main_loop_started = false;
static thread_t *cdtp; static thread_t *cdtp;
//static Thread *shelltp1; //static thread_t *shelltp1;
//static Thread *shelltp2; //static thread_t *shelltp2;
#define cputs(msg) chMsgSend(cdtp, (msg_t)msg) #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. * to the C printf() thread safe and the print operation atomic among threads.
* In this example the message is the zero terminated string itself. * 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; (void) arg;
while (!chThdShouldTerminate()) { while (!chThdShouldTerminateX()) {
thread_t *tp = chMsgWait(); thread_t *tp = chMsgWait();
puts((char *) chMsgGet(tp)); puts((char *) chMsgGet(tp));
fflush(stdout); fflush(stdout);
chMsgRelease(tp, MSG_OK); chMsgRelease(tp, MSG_OK);
} }
return 0;
} }
extern int isSerialOverTcpReady; extern int isSerialOverTcpReady;
@ -172,7 +171,7 @@ int main(void) {
/* /*
* Events servicing loop. * Events servicing loop.
*/ */
while (!chThdShouldTerminate()) { while (!chThdShouldTerminateX()) {
chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS)); chEvtDispatch(fhandlers, chEvtWaitOne(ALL_EVENTS));
printPendingMessages(); printPendingMessages();
chThdSleepMilliseconds(100); chThdSleepMilliseconds(100);

View File

@ -1,72 +1,84 @@
# ARM Cortex-Mx common makefile scripts and rules. # ARM Cortex-Mx common makefile scripts and rules.
# Output directory and files ##############################################################################
ifeq ($(BUILDDIR),) # Processing options coming from the upper Makefile.
BUILDDIR = build #
endif
ifeq ($(BUILDDIR),.)
BUILDDIR = build
endif
OUTFILES = $(BUILDDIR)/$(PROJECT)
# Automatic compiler options # Compiler options
OPT = $(USE_OPT) OPT := $(USE_OPT)
COPT = $(USE_COPT) COPT := $(USE_COPT)
CPPOPT = $(USE_CPPOPT) CPPOPT := $(USE_CPPOPT)
# Garbage collection
ifeq ($(USE_LINK_GC),yes) 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 endif
# Source files groups and paths # Linker extra options
ifeq ($(USE_THUMB),yes) ifneq ($(USE_LDOPT),)
TCSRC += $(CSRC) LDOPT := $(LDOPT),$(USE_LDOPT)
TCPPSRC += $(CPPSRC)
else
ACSRC += $(CSRC)
ACPPSRC += $(CPPSRC)
endif endif
ASRC = $(ACSRC)$(ACPPSRC)
TSRC = $(TCSRC)$(TCPPSRC) # Link time optimizations
SRCPATHS = $(sort $(dir $(ASMXSRC)) $(dir $(ASMSRC)) $(dir $(ASRC)) $(dir $(TSRC))) 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 # Various directories
OBJDIR = $(BUILDDIR)/obj OBJDIR := $(BUILDDIR)/obj
LSTDIR = $(BUILDDIR)/lst LSTDIR := $(BUILDDIR)/lst
# Object files groups # Object files groups
ACOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACSRC:.c=.o))) COBJS := $(addprefix $(OBJDIR)/, $(notdir $(CSRC:.c=.o)))
ACPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ACPPSRC:.cpp=.o))) CPPOBJS := $(addprefix $(OBJDIR)/, $(notdir $(CPPSRC:.cpp=.o)))
TCOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCSRC:.c=.o))) ASMOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o)))
TCPPOBJS = $(addprefix $(OBJDIR)/, $(notdir $(TCPPSRC:.cpp=.o))) ASMXOBJS := $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
ASMOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMSRC:.s=.o))) OBJS := $(ASMXOBJS) $(ASMOBJS) $(COBJS) $(CPPOBJS)
ASMXOBJS = $(addprefix $(OBJDIR)/, $(notdir $(ASMXSRC:.S=.o)))
OBJS = $(ASMXOBJS) $(ASMOBJS) $(ACOBJS) $(TCOBJS) $(ACPPOBJS) $(TCPPOBJS)
# Paths # Paths
IINCDIR = $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR)) IINCDIR := $(patsubst %,-I%,$(INCDIR) $(DINCDIR) $(UINCDIR))
LLIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) LLIBDIR := $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
# Macros # Macros
DEFS = $(DDEFS) $(UDEFS) DEFS := $(DDEFS) $(UDEFS)
ADEFS = $(DADEFS) $(UADEFS) ADEFS := $(DADEFS) $(UADEFS)
# Libs # Libs
LIBS = $(DLIBS) $(ULIBS) LIBS := $(DLIBS) $(ULIBS)
# Various settings # Various settings
#MCFLAGS = -mcpu=$(MCU) MCFLAGS =
ODFLAGS = -x --syms ODFLAGS = -x --syms
ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS) ASFLAGS = $(MCFLAGS) -Wa,-amhls=$(LSTDIR)/$(notdir $(<:.s=.lst)) $(ADEFS)
ASXFLAGS = $(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) CFLAGS = $(MCFLAGS) $(OPT) $(COPT) $(CWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.c=.lst)) $(DEFS)
CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS) CPPFLAGS = $(MCFLAGS) $(OPT) $(CPPOPT) $(CPPWARN) -Wa,-alms=$(LSTDIR)/$(notdir $(<:.cpp=.lst)) $(DEFS)
ifeq ($(USE_LINK_GC),yes) LDFLAGS = $(MCFLAGS) $(OPT) $(LLIBDIR) -Wl,-Map=$(BUILDDIR)/$(PROJECT).map,--cref,--no-warn-mismatch,--library-path=$(RULESPATH),$(LDOPT)
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
# Generate dependency information # Generate dependency information
ASFLAGS += -MD -MP -MF .dep/$(@F).d
ASXFLAGS += -MD -MP -MF .dep/$(@F).d
CFLAGS += -MD -MP -MF .dep/$(@F).d CFLAGS += -MD -MP -MF .dep/$(@F).d
CPPFLAGS += -MD -MP -MF .dep/$(@F).d CPPFLAGS += -MD -MP -MF .dep/$(@F).d
@ -77,55 +89,40 @@ VPATH = $(SRCPATHS)
# Makefile rules # Makefile rules
# #
all: $(OBJS) $(OUTFILES) MAKE_ALL_RULE_HOOK all: $(OBJS) $(OUTFILES)
MAKE_ALL_RULE_HOOK: $(OBJS): $(BUILDDIR) $(OBJDIR) $(LSTDIR)
$(OBJS): | $(BUILDDIR) $(BUILDDIR):
$(BUILDDIR) $(OBJDIR) $(LSTDIR):
ifneq ($(USE_VERBOSE_COMPILE),yes) ifneq ($(USE_VERBOSE_COMPILE),yes)
@echo Compiler Options @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 @echo
endif endif
mkdir -p $(OBJDIR) @mkdir -p $(BUILDDIR)
mkdir -p $(LSTDIR)
$(ACPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile $(OBJDIR):
@mkdir -p $(OBJDIR)
$(LSTDIR):
@mkdir -p $(LSTDIR)
$(CPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes) ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo @echo
$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@ $(CPPC) -c $(CPPFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
else else
@echo Compiling $(<F) @echo Compiling $(<F)
@$(CPPC) -c $(CPPFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@ @$(CPPC) -c $(CPPFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
endif endif
$(TCPPOBJS) : $(OBJDIR)/%.o : %.cpp Makefile $(COBJS) : $(OBJDIR)/%.o : %.c Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes) ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo @echo
$(CPPC) -c $(CPPFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@ $(CC) -c $(CFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
else else
@echo Compiling $(<F) @echo Compiling $(<F)
@$(CPPC) -c $(CPPFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@ @$(CC) -c $(CFLAGS) $(OPT) -I. $(IINCDIR) $< -o $@
endif
$(ACOBJS) : $(OBJDIR)/%.o : %.c Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
$(CC) -c $(CFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
else
@echo Compiling $(<F)
@$(CC) -c $(CFLAGS) $(AOPT) -I. $(IINCDIR) $< -o $@
endif
$(TCOBJS) : $(OBJDIR)/%.o : %.c Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo
$(CC) -c $(CFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
else
@echo Compiling $(<F)
@$(CC) -c $(CFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif endif
$(ASMOBJS) : $(OBJDIR)/%.o : %.s Makefile $(ASMOBJS) : $(OBJDIR)/%.o : %.s Makefile
@ -139,14 +136,14 @@ endif
$(ASMXOBJS) : $(OBJDIR)/%.o : %.S Makefile $(ASMXOBJS) : $(OBJDIR)/%.o : %.S Makefile
ifeq ($(USE_VERBOSE_COMPILE),yes) ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo @echo
$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@ $(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
else else
@echo Compiling $(<F) @echo Compiling $(<F)
@$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@ @$(CC) -c $(ASXFLAGS) $(TOPT) -I. $(IINCDIR) $< -o $@
endif endif
$(BUILDDIR)/$(PROJECT): $(OBJS) $(BUILDDIR)/$(PROJECT).exe: $(OBJS) $(LDSCRIPT)
ifeq ($(USE_VERBOSE_COMPILE),yes) ifeq ($(USE_VERBOSE_COMPILE),yes)
@echo @echo
$(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ $(LD) $(OBJS) $(LDFLAGS) $(LIBS) -o $@
@ -158,6 +155,7 @@ endif
clean: clean:
@echo Cleaning @echo Cleaning
-rm -fR .dep $(BUILDDIR) -rm -fR .dep $(BUILDDIR)
@echo
@echo Done @echo Done
# #

View File

@ -13,17 +13,17 @@ efitick_t getTimeNowNt(void) {
} }
efitimeus_t getTimeNowUs(void) { efitimeus_t getTimeNowUs(void) {
return chTimeNow() * (1000000 / CH_FREQUENCY); return chVTGetSystemTimeX() * (1000000 / CH_CFG_ST_FREQUENCY);
} }
// todo; reduce code duplication with prod code? // todo; reduce code duplication with prod code?
efitimems_t currentTimeMillis(void) { efitimems_t currentTimeMillis(void) {
return getTimeNowUs() / 1000; return chVTGetSystemTimeX() / 1000;
} }
// todo; reduce code duplication with prod code? // todo; reduce code duplication with prod code?
efitimesec_t getTimeNowSeconds(void) { efitimesec_t getTimeNowSeconds(void) {
return chTimeNow() / CH_FREQUENCY; return currentTimeMillis() / CH_CFG_ST_FREQUENCY;
} }
int getRusEfiVersion(void) { int getRusEfiVersion(void) {

View File

@ -16,22 +16,13 @@
#include "efilib.h" #include "efilib.h"
#include "efitime.h" #include "efitime.h"
// this stuff is about ChibiOS 2.6 > Migration #define EFI_UNIT_TEST FALSE
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 hasFatalError() (FALSE)
#define US_TO_NT_MULTIPLIER 100 #define US_TO_NT_MULTIPLIER 100
#define ALWAYS_INLINE INLINE #define ALWAYS_INLINE
#define US2NT(x) (US_TO_NT_MULTIPLIER * (x)) #define US2NT(x) (US_TO_NT_MULTIPLIER * (x))