From 9826378b9608362c4ad6efa3271e6f6de1e2b30e Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 29 Jul 2014 12:00:47 +1000 Subject: [PATCH] Operating System initialisation can now be turned off in gfxconf.h --- docs/releases.txt | 1 + gfxconf.example.h | 3 +++ src/gos/chibios.c | 27 +++++++++++++++------------ src/gos/ecos.c | 7 +++++-- src/gos/freertos.c | 8 ++++++-- src/gos/linux.c | 1 + src/gos/osx.c | 1 + src/gos/raw32.c | 6 ++++++ src/gos/rawrtos.c | 6 +++++- src/gos/sys_options.h | 14 ++++++++++++++ src/gos/win32.c | 2 +- 11 files changed, 58 insertions(+), 18 deletions(-) diff --git a/docs/releases.txt b/docs/releases.txt index 46a58ab4..d658deee 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -19,6 +19,7 @@ FEATURE: Added R61505U gdisp driver FIX: Fix threading issues in GEvent for callbacks FEATURE: Added geventEventComplete() FEATURE: Added support for the rawrtos real time operating system +FEATURE: Operating System initialisation is now optional *** Release 2.1 *** FIX: Significant improvements to the way the MCU touch driver works. diff --git a/gfxconf.example.h b/gfxconf.example.h index 8754ba32..8163b6f5 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -38,6 +38,9 @@ // #define INTERRUPTS_OFF() optional_code // #define INTERRUPTS_ON() optional_code +// Options that (should where relevant) apply to all operating systems +// #define GFX_NO_OS_INIT FALSE + /////////////////////////////////////////////////////////////////////////// // GDISP // diff --git a/src/gos/chibios.c b/src/gos/chibios.c index 468c012c..9d1a86da 100644 --- a/src/gos/chibios.c +++ b/src/gos/chibios.c @@ -33,18 +33,21 @@ void _gosInit(void) { - /* Don't initialise if the user already has */ - - #if CH_KERNEL_MAJOR == 2 - if (!chThdSelf()) { - halInit(); - chSysInit(); - } - #elif CH_KERNEL_MAJOR == 3 - if (!chThdGetSelfX()) { - halInit(); - chSysInit(); - } + #if !GFX_NO_OS_INIT + /* Don't Initialize if the user already has */ + #if CH_KERNEL_MAJOR == 2 + if (!chThdSelf()) { + halInit(); + chSysInit(); + } + #elif CH_KERNEL_MAJOR == 3 + if (!chThdGetSelfX()) { + halInit(); + chSysInit(); + } + #endif + #else + #warning "GOS: Operating System initialization has been turned off. Make sure you call halInit() and chSysInit() before gfxInit() in your application!" #endif } diff --git a/src/gos/ecos.c b/src/gos/ecos.c index 5b94497a..16ce821b 100644 --- a/src/gos/ecos.c +++ b/src/gos/ecos.c @@ -11,8 +11,11 @@ void _gosInit(void) { - /* Don't initialise if the user already has */ - //cyg_scheduler_start(); + #if !GFX_NO_OS_INIT + #error "GOS: Operating System initialization for eCos is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h" + #else + #warning "GOS: Operating System initialization has been turned off. Make sure you call cyg_scheduler_start() before gfxInit() in your application!" + #endif } void _gosDeinit(void) diff --git a/src/gos/freertos.c b/src/gos/freertos.c index f2c03eec..dbdfd22e 100644 --- a/src/gos/freertos.c +++ b/src/gos/freertos.c @@ -18,13 +18,17 @@ #error "GOS: configUSE_MUTEXES must be defined in FreeRTOSConfig.h" #endif -#if configUSE_COUNTING_SEMAPHORES != 1 +#if configUSE_COUNTING_SEMAPHORES != 1 #error "GOS: configUSE_COUNTING_SEMAPHORES must be defined in FreeRTOSConfig.h" #endif void _gosInit(void) { - // The user must call vTaskStartScheduler() himself before he calls gfxInit(). + #if !GFX_NO_OS_INIT + #error "GOS: Operating System initialization for FreeRTOS is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h" + #else + #warning "GOS: Operating System initialization has been turned off. Make sure you call vTaskStartScheduler() before gfxInit() in your application!" + #endif } void _gosDeinit(void) diff --git a/src/gos/linux.c b/src/gos/linux.c index d127fbe1..59b7f9c8 100644 --- a/src/gos/linux.c +++ b/src/gos/linux.c @@ -18,6 +18,7 @@ static gfxMutex SystemMutex; void _gosInit(void) { + /* No initialization of the operating system itself is needed */ gfxMutexInit(&SystemMutex); } diff --git a/src/gos/osx.c b/src/gos/osx.c index dccd49c9..50b06530 100644 --- a/src/gos/osx.c +++ b/src/gos/osx.c @@ -35,6 +35,7 @@ void get_ticks(mach_timespec_t *mts){ void _gosInit(void) { + /* No initialization of the operating system itself is needed */ gfxMutexInit(&SystemMutex); } diff --git a/src/gos/raw32.c b/src/gos/raw32.c index c75342d4..22c753aa 100644 --- a/src/gos/raw32.c +++ b/src/gos/raw32.c @@ -24,6 +24,12 @@ static void _gosThreadsInit(void); void _gosInit(void) { + /* No initialization of the operating system itself is needed as there isn't one. + * On the other hand the C runtime should still already be initialized before + * getting here! + */ + #warning "GOS: Raw32 - Make sure you initialize your hardware and the C runtime before calling gfxInit() in your application!" + // Set up the heap allocator _gosHeapInit(); diff --git a/src/gos/rawrtos.c b/src/gos/rawrtos.c index 688828c9..cd684208 100644 --- a/src/gos/rawrtos.c +++ b/src/gos/rawrtos.c @@ -17,7 +17,11 @@ void _gosInit(void) { - // The user must call raw_os_start() himself before he calls gfxInit(). + #if !GFX_NO_OS_INIT + #error "GOS: Operating System initialization for RawRTOS is not yet implemented in uGFX. Please set GFX_NO_OS_INIT to TRUE in your gfxconf.h" + #else + #warning "GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!" + #endif } void _gosDeinit(void) diff --git a/src/gos/sys_options.h b/src/gos/sys_options.h index 7937e082..ead1f3f7 100644 --- a/src/gos/sys_options.h +++ b/src/gos/sys_options.h @@ -75,6 +75,20 @@ * @name GOS Optional Parameters * @{ */ + /** + * @brief Should uGFX avoid initializing the operating system + * @details Defaults to FALSE + * @note This is not relevant to all operating systems eg Win32 never initializes the + * operating system as uGFX runs as an application outside the boot process. + * @note Operating system initialization is not necessarily implemented for all + * operating systems yet even when it is relevant. These operating systems + * will display a compile warning reminding you to initialize the operating + * system in your application code. Note that on these operating systems the + * demo applications will not work without modification. + */ + #ifndef GFX_NO_OS_INIT + #define GFX_NO_OS_INIT FALSE + #endif /** * @brief Should uGFX stuff be added to the FreeRTOS+Tracer * @details Defaults to FALSE diff --git a/src/gos/win32.c b/src/gos/win32.c index 3a3f2517..ffa7fac5 100644 --- a/src/gos/win32.c +++ b/src/gos/win32.c @@ -19,7 +19,7 @@ static HANDLE SystemMutex; void _gosInit(void) { - + /* No initialization of the operating system itself is needed */ } void _gosDeinit(void)