diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gfx_rules.h | 4 | ||||
-rw-r--r-- | include/gos/gos.h | 2 | ||||
-rw-r--r-- | include/gos/options.h | 7 | ||||
-rw-r--r-- | include/gos/raw32.h | 124 |
4 files changed, 135 insertions, 2 deletions
diff --git a/include/gfx_rules.h b/include/gfx_rules.h index 534c2cc9..54fe3a1a 100644 --- a/include/gfx_rules.h +++ b/include/gfx_rules.h @@ -26,14 +26,14 @@ #define GFX_DISPLAY_RULE_WARNINGS FALSE #endif -#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX +#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 #if GFX_DISPLAY_RULE_WARNINGS #warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you." #endif #undef GFX_USE_OS_CHIBIOS #define GFX_USE_OS_CHIBIOS TRUE #endif -#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX != 1 * TRUE +#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 != 1 * TRUE #error "GOS: More than one operation system has been defined as TRUE." #endif diff --git a/include/gos/gos.h b/include/gos/gos.h index 8e7840e3..37335fbb 100644 --- a/include/gos/gos.h +++ b/include/gos/gos.h @@ -435,6 +435,8 @@ #include "gos/linux.h" #elif GFX_USE_OS_OSX #include "gos/osx.h" +#elif GFX_USE_OS_RAW32 + #include "gos/raw32.h" #else #error "Your operating system is not supported yet" #endif diff --git a/include/gos/options.h b/include/gos/options.h index f1762134..4edb35d8 100644 --- a/include/gos/options.h +++ b/include/gos/options.h @@ -48,6 +48,13 @@ #ifndef GFX_USE_OS_OSX #define GFX_USE_OS_OSX FALSE #endif + /** + * @brief Use a Raw 32 bit CPU based system + * @details Defaults to FALSE + */ + #ifndef GFX_USE_OS_RAW32 + #define GFX_USE_OS_RAW32 FALSE + #endif /** * @} * diff --git a/include/gos/raw32.h b/include/gos/raw32.h new file mode 100644 index 00000000..165bc606 --- /dev/null +++ b/include/gos/raw32.h @@ -0,0 +1,124 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +/** + * @file include/gos/raw32.h + * @brief GOS - Operating System Support header file for any 32 bit processor in bare-metal mode + */ + +/** + * The raw32 GOS implementation supports any 32 bit processor with or without an + * underlying operating system. It uses cooperative multi-tasking. Be careful + * when writing device drivers not to disturb the assumptions this creates by performing + * call-backs to uGFX code unless you define the INTERRUPTS_OFF() and INTERRUPTS_ON() macros. + * It still requires some C runtime library support... + * enough startup to initialise the stack, interrupts, static data etc and call main(). + * setjmp() and longjmp() - for threading + * memcpy() - for heap and threading + * malloc(), realloc and free() - if GOS_RAW_HEAP_SIZE == 0 + * + * You must also define the following routines in your own code so that timing functions will work... + * systemticks_t gfxSystemTicks(void); + * systemticks_t gfxMillisecondsToTicks(delaytime_t ms); + */ +#ifndef _GOS_RAW32_H +#define _GOS_RAW32_H + +#if GFX_USE_OS_RAW32 + +/*===========================================================================*/ +/* Special Macros just for a Raw implementation */ +/*===========================================================================*/ + +/** + * @brief Set the maximum size of the heap. + * @note If set to 0 then the C runtime library malloc() and free() are used. + */ +#ifndef GOS_RAW_HEAP_SIZE + #define GOS_RAW_HEAP_SIZE 0 +#endif + +/*===========================================================================*/ +/* Type definitions */ +/*===========================================================================*/ + +typedef unsigned char bool_t; +typedef char int8_t; +typedef unsigned char uint8_t; +typedef short int16_t; +typedef unsigned short uint16_t; +typedef int int32_t; +typedef unsigned int uint32_t; + +typedef uint32_t size_t; +typedef uint32_t delaytime_t; +typedef uint32_t systemticks_t; +typedef short semcount_t; +typedef int threadreturn_t; +typedef int threadpriority_t; + +#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param) +#define DECLARE_THREAD_STACK(name, sz) uint8_t name[sz]; + +#define TIME_IMMEDIATE 0 +#define TIME_INFINITE ((delaytime_t)-1) +#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1)) +#define LOW_PRIORITY 0 +#define NORMAL_PRIORITY 1 +#define HIGH_PRIORITY 2 + +typedef struct { + semcount_t cnt; + semcount_t limit; + } gfxSem; + +typedef uint32_t gfxMutex; +typedef void * gfxThreadHandle; + +#define gfxThreadClose(thread) +#define gfxMutexDestroy(pmutex) +#define gfxSemDestroy(psem) +#define gfxSemCounter(psem) ((psem)->cnt) +#define gfxSemCounterI(psem) ((psem)->cnt) + +#ifdef __cplusplus +extern "C" { +#endif + + #if GOS_RAW_HEAP_SIZE != 0 + void gfxAddHeapBlock(void *ptr, size_t sz); + #endif + + void gfxHalt(const char *msg); + void gfxExit(void); + void *gfxAlloc(size_t sz); + void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz); + void gfxFree(void *ptr); + void gfxYield(void); + void gfxSleepMilliseconds(delaytime_t ms); + void gfxSleepMicroseconds(delaytime_t ms); + systemticks_t gfxSystemTicks(void); + systemticks_t gfxMillisecondsToTicks(delaytime_t ms); + void gfxSystemLock(void); + void gfxSystemUnlock(void); + void gfxMutexInit(gfxMutex *pmutex); + void gfxMutexEnter(gfxMutex *pmutex); + void gfxMutexExit(gfxMutex *pmutex); + void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit); + bool_t gfxSemWait(gfxSem *psem, delaytime_t ms); + void gfxSemSignal(gfxSem *psem); + void gfxSemSignalI(gfxSem *psem); + gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param); + threadreturn_t gfxThreadWait(gfxThreadHandle thread); + gfxThreadHandle gfxThreadMe(void); + +#ifdef __cplusplus +} +#endif + +#endif /* GFX_USE_OS_RAW32 */ +#endif /* _GOS_RAW32_H */ |