2013-05-24 15:26:52 +00:00
|
|
|
/*
|
2013-06-15 11:09:02 +00:00
|
|
|
* 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://chibios-gfx.com/license.html
|
|
|
|
*/
|
2013-05-24 15:26:52 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @file include/gos/win32.h
|
|
|
|
* @brief GOS - Operating System Support header file for WIN32.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GOS_WIN32_H
|
|
|
|
#define _GOS_WIN32_H
|
|
|
|
|
|
|
|
#if GFX_USE_OS_WIN32
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
//#define WIN32_LEAN_AND_MEAN
|
|
|
|
#include <windows.h>
|
|
|
|
|
2013-06-02 08:57:22 +00:00
|
|
|
/* Stop cygwin from defining these types */
|
|
|
|
#define __int8_t_defined
|
|
|
|
|
2013-05-25 16:06:55 +00:00
|
|
|
/**
|
|
|
|
* size_t
|
|
|
|
* TRUE, FALSE
|
|
|
|
* are already defined by Win32
|
|
|
|
*/
|
|
|
|
typedef __int8 bool_t;
|
|
|
|
typedef __int8 int8_t;
|
|
|
|
typedef unsigned __int8 uint8_t;
|
|
|
|
typedef __int16 int16_t;
|
|
|
|
typedef unsigned __int16 uint16_t;
|
|
|
|
typedef __int32 int32_t;
|
|
|
|
typedef unsigned __int32 uint32_t;
|
|
|
|
typedef DWORD delaytime_t;
|
|
|
|
typedef DWORD systemticks_t;
|
|
|
|
typedef LONG semcount_t;
|
2013-06-02 08:57:22 +00:00
|
|
|
typedef DWORD threadreturn_t;
|
2013-05-25 16:06:55 +00:00
|
|
|
typedef int threadpriority_t;
|
|
|
|
|
2013-06-02 08:57:22 +00:00
|
|
|
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t WINAPI fnName(void *param)
|
|
|
|
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0];
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
#define TIME_IMMEDIATE 0
|
|
|
|
#define TIME_INFINITE INFINITE
|
|
|
|
#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
|
|
|
|
#define LOW_PRIORITY THREAD_PRIORITY_BELOW_NORMAL
|
|
|
|
#define NORMAL_PRIORITY THREAD_PRIORITY_NORMAL
|
|
|
|
#define HIGH_PRIORITY THREAD_PRIORITY_ABOVE_NORMAL
|
|
|
|
|
|
|
|
typedef HANDLE gfxSem;
|
|
|
|
typedef HANDLE gfxMutex;
|
2013-06-02 08:57:22 +00:00
|
|
|
typedef HANDLE gfxThreadHandle;
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
#define gfxExit() ExitProcess(0)
|
|
|
|
#define gfxAlloc(sz) malloc(sz)
|
|
|
|
#define gfxFree(ptr) free(ptr)
|
|
|
|
#define gfxSleepMilliseconds(ms) Sleep(ms)
|
|
|
|
#define gfxYield() Sleep(0)
|
|
|
|
#define gfxSystemTicks() GetTickCount()
|
|
|
|
#define gfxMillisecondsToTicks(ms) (ms)
|
|
|
|
#define gfxMutexInit(pmutex) *(pmutex) = CreateMutex(NULL, FALSE, NULL)
|
|
|
|
#define gfxMutexDestory(pmutex) CloseHandle(*(pmutex))
|
|
|
|
#define gfxMutexEnter(pmutex) WaitForSingleObject(*(pmutex), INFINITE)
|
|
|
|
#define gfxMutexExit(pmutex) ReleaseMutex(*(pmutex))
|
|
|
|
#define gfxSemInit(psem, val, limit) *(psem) = CreateSemaphore(NULL, val, limit, NULL)
|
|
|
|
#define gfxSemDestory(psem) CloseHandle(*(psem))
|
|
|
|
#define gfxSemSignal(psem) ReleaseSemaphore(*(psem), 1, NULL)
|
|
|
|
#define gfxSemSignalI(psem) ReleaseSemaphore(*(psem), 1, NULL)
|
|
|
|
#define gfxSemCounterI(psem) gfxSemCounter(psem)
|
2013-06-02 08:57:22 +00:00
|
|
|
#define gfxThreadMe() GetCurrentThread()
|
|
|
|
#define gfxThreadClose(thread) CloseHandle(thread)
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Function declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void gfxHalt(const char *msg);
|
|
|
|
void gfxSleepMicroseconds(delaytime_t ms);
|
|
|
|
bool_t gfxSemWait(gfxSem *psem, delaytime_t ms);
|
|
|
|
semcount_t gfxSemCounter(gfxSem *pSem);
|
|
|
|
void gfxSystemLock(void);
|
|
|
|
void gfxSystemUnlock(void);
|
2013-06-02 08:57:22 +00:00
|
|
|
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
|
|
|
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
|
2013-05-25 16:06:55 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-05-24 15:26:52 +00:00
|
|
|
#endif /* GFX_USE_OS_WIN32 */
|
|
|
|
|
|
|
|
#endif /* _GOS_WIN32_H */
|