Tidy u gfxSem, gfxMutex and various Macros by converting to new types gSem, gMutex etc
This commit is contained in:
parent
7c5a6c928f
commit
8a9ed5195b
@ -18,8 +18,8 @@ CHANGE: Added types gI8, gU8 .. gI32, gU32 to replace V2.x int8_t etc
|
|||||||
CHANGE: Added type gBool to replace V2.x bool_t, and values gTrue/gFalse to replace TRUE/FALSE
|
CHANGE: Added type gBool to replace V2.x bool_t, and values gTrue/gFalse to replace TRUE/FALSE
|
||||||
CHANGE: Added type gDelay to replace V2.x delaytime_t and values gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE
|
CHANGE: Added type gDelay to replace V2.x delaytime_t and values gDelayNone/gDelayForever to replace TIME_IMMEDIATE/TIME_INFINITE
|
||||||
CHANGE: Added type gTicks to replace V2.x systemticks_t
|
CHANGE: Added type gTicks to replace V2.x systemticks_t
|
||||||
CHANGE: Added type gThread to replace V2.x gfxThreadHandle
|
CHANGE: Added type gThread to replace V2.x gfxThreadHandle and macros GFX_THREAD_FUNCTION/STACK to replace DECLARE_THREAD_FUNCTION & DECLARE_THREAD_STACK
|
||||||
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t
|
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t and pseudo function gfxThreadReturn() to replace THREAD_RETURN()
|
||||||
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t and values gThreadpriorityLow/Normal/High to replace LOW_/NORMAL_/HIGH_PRIORITY
|
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t and values gThreadpriorityLow/Normal/High to replace LOW_/NORMAL_/HIGH_PRIORITY
|
||||||
CHANGE: Added type gPoint to replace V2.x point and point_t
|
CHANGE: Added type gPoint to replace V2.x point and point_t
|
||||||
CHANGE: Added type gCoord to replace V2.x coord_t
|
CHANGE: Added type gCoord to replace V2.x coord_t
|
||||||
@ -31,7 +31,9 @@ CHANGE: Added type gPowermode to replace V2.x powermode_t, and values gP
|
|||||||
CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
|
CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
|
||||||
CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX
|
CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX
|
||||||
CHANGE: Added type gOrientation to replace V2.x orientation_t, and values gOrientationX replace GDISP_ROTATE_X
|
CHANGE: Added type gOrientation to replace V2.x orientation_t, and values gOrientationX replace GDISP_ROTATE_X
|
||||||
CHANGE: Added macros JUSTIFYMASK_HORIZONTAL, JUSTIFYMASK_VERTICAL to replace macros JUSTIFYMASK_LEFTRIGHT, JUSTIFYMASK_TOPBOTTOM
|
CHANGE: Added type gSem to replace V2.x gfxSem, and values gSemMaxCount replace MAX_SEMAPHORE_COUNT
|
||||||
|
CHANGE: Added type gMutex to replace V2.x gfxMutex
|
||||||
|
CHANGE: Added macros JUSTIFYMASK_HORIZONTAL, JUSTIFYMASK_VERTICAL to replace V2.x macros JUSTIFYMASK_LEFTRIGHT, JUSTIFYMASK_TOPBOTTOM
|
||||||
FEATURE: Added types gPtr, gPtrDiff and gAny
|
FEATURE: Added types gPtr, gPtrDiff and gAny
|
||||||
FEATURE: Added type gMemSize and config macro GFX_MEM_LT64K
|
FEATURE: Added type gMemSize and config macro GFX_MEM_LT64K
|
||||||
FEATURE: Added type gFileSize
|
FEATURE: Added type gFileSize
|
||||||
|
8
demos/3rdparty/notepad-2/notepadApp.c
vendored
8
demos/3rdparty/notepad-2/notepadApp.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* File: notepadApp.c
|
* File: notepadApp.c
|
||||||
*
|
*
|
||||||
* This file is a part of the Notepad demo application for ChibiOS/GFX
|
* This file is a part of the Notepad demo application for ChibiOS/GFX
|
||||||
* Copyright © 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
|
* Copyright 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -70,7 +70,7 @@ static int selColorIndex = 0, selPenWidth = 1, tbMode = 1;
|
|||||||
|
|
||||||
static NColorScheme nCurColorScheme;
|
static NColorScheme nCurColorScheme;
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(notepadThread, param);
|
static GFX_THREAD_FUNCTION(notepadThread, param);
|
||||||
|
|
||||||
// Custom drawing functions for the buttons
|
// Custom drawing functions for the buttons
|
||||||
static void nbtnColorBarDraw(GHandle gh, gBool enabled, gBool isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
static void nbtnColorBarDraw(GHandle gh, gBool enabled, gBool isdown, const char *txt, const GButtonDrawStyle *pstyle, void *param) {
|
||||||
@ -311,8 +311,8 @@ static void drawVButtons(void) {
|
|||||||
gwinButtonDraw(H(btnFill));
|
gwinButtonDraw(H(btnFill));
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
|
static GFX_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
|
||||||
static DECLARE_THREAD_FUNCTION(notepadThread, param) {
|
static GFX_THREAD_FUNCTION(notepadThread, param) {
|
||||||
|
|
||||||
GEventMouse *pem;
|
GEventMouse *pem;
|
||||||
GEventGWinButton *peb;
|
GEventGWinButton *peb;
|
||||||
|
6
demos/3rdparty/notepad-2/notepadCore.c
vendored
6
demos/3rdparty/notepad-2/notepadCore.c
vendored
@ -2,7 +2,7 @@
|
|||||||
* File: notepadCore.c
|
* File: notepadCore.c
|
||||||
*
|
*
|
||||||
* This file is a part of the Notepad demo application for ChibiOS/GFX
|
* This file is a part of the Notepad demo application for ChibiOS/GFX
|
||||||
* Copyright © 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
|
* Copyright 2013, Kumar Abhishek [abhishek.kakkar@edaboard.com].
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -43,7 +43,7 @@
|
|||||||
(ev.y >= ncoreDrawingArea->y) && (ev.y <= (ncoreDrawingArea->y + ncoreDrawingArea->height)))
|
(ev.y >= ncoreDrawingArea->y) && (ev.y <= (ncoreDrawingArea->y + ncoreDrawingArea->height)))
|
||||||
|
|
||||||
/* This is the drawing core */
|
/* This is the drawing core */
|
||||||
static DECLARE_THREAD_STACK(waDrawThread, NCORE_THD_STACK_SIZE);
|
static GFX_THREAD_STACK(waDrawThread, NCORE_THD_STACK_SIZE);
|
||||||
|
|
||||||
static gU8 nPenWidth = 1;
|
static gU8 nPenWidth = 1;
|
||||||
static gU8 nMode = NCORE_MODE_DRAW;
|
static gU8 nMode = NCORE_MODE_DRAW;
|
||||||
@ -127,7 +127,7 @@ static void draw_line(gCoord x0, gCoord y0, gCoord x1, gCoord y1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Core thread */
|
/* Core thread */
|
||||||
static DECLARE_THREAD_FUNCTION(ncoreDrawThread, msg) {
|
static GFX_THREAD_FUNCTION(ncoreDrawThread, msg) {
|
||||||
|
|
||||||
GEventMouse ev, evPrev;
|
GEventMouse ev, evPrev;
|
||||||
gCoord dx, dy;
|
gCoord dx, dy;
|
||||||
|
@ -62,7 +62,7 @@ static gThread thread;
|
|||||||
#define FLOORCOLOR HTML2COLOR(0x606060)
|
#define FLOORCOLOR HTML2COLOR(0x606060)
|
||||||
#define SHADOWALPHA (255-255*0.2)
|
#define SHADOWALPHA (255-255*0.2)
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(task, param) {
|
static GFX_THREAD_FUNCTION(task, param) {
|
||||||
gCoord width, height, x, y, radius, ballx, bally, dx, floor;
|
gCoord width, height, x, y, radius, ballx, bally, dx, floor;
|
||||||
gCoord minx, miny, maxx, maxy, winx, winy;
|
gCoord minx, miny, maxx, maxy, winx, winy;
|
||||||
gCoord ballcx, ballcy;
|
gCoord ballcx, ballcy;
|
||||||
|
@ -66,7 +66,7 @@ static void mandelbrot(float x1, float y1, float x2, float y2) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(task, param) {
|
static GFX_THREAD_FUNCTION(task, param) {
|
||||||
float cx, cy;
|
float cx, cy;
|
||||||
float zoom = 1.0f;
|
float zoom = 1.0f;
|
||||||
(void) param;
|
(void) param;
|
||||||
|
@ -223,7 +223,7 @@ static void printCongrats(void) {
|
|||||||
gdispDrawString(JG10_TOTAL_FIELD_WIDTH+((gdispGetWidth()-JG10_TOTAL_FIELD_WIDTH)/2)-(gdispGetStringWidth(pps_str, font)/2), (gdispGetHeight()/2)+20, pps_str, font, GFX_RED);
|
gdispDrawString(JG10_TOTAL_FIELD_WIDTH+((gdispGetWidth()-JG10_TOTAL_FIELD_WIDTH)/2)-(gdispGetStringWidth(pps_str, font)/2), (gdispGetHeight()/2)+20, pps_str, font, GFX_RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
|
static GFX_THREAD_FUNCTION(thdJg10, msg) {
|
||||||
(void)msg;
|
(void)msg;
|
||||||
gU16 x,y;
|
gU16 x,y;
|
||||||
while (!jg10GameOver) {
|
while (!jg10GameOver) {
|
||||||
@ -273,7 +273,7 @@ static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
THREAD_RETURN(0);
|
gfxThreadReturn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initField(void) {
|
static void initField(void) {
|
||||||
|
@ -192,7 +192,7 @@ static void openEmptyNodes(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(thdMines, msg)
|
static GFX_THREAD_FUNCTION(thdMines, msg)
|
||||||
{
|
{
|
||||||
(void)msg;
|
(void)msg;
|
||||||
gU16 x,y, delay;
|
gU16 x,y, delay;
|
||||||
@ -245,7 +245,7 @@ static DECLARE_THREAD_FUNCTION(thdMines, msg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
THREAD_RETURN(0);
|
gfxThreadReturn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printGameOver(void)
|
static void printGameOver(void)
|
||||||
|
@ -427,7 +427,7 @@ static void goLeft(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(thdTetris, arg) {
|
static GFX_THREAD_FUNCTION(thdTetris, arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
gU8 i;
|
gU8 i;
|
||||||
while (!tetrisGameOver) {
|
while (!tetrisGameOver) {
|
||||||
|
@ -182,8 +182,8 @@ static gBool sendpkt(gU16 *pkt, int len) {
|
|||||||
* We do the send in a single transaction to prevent it getting interspersed with
|
* We do the send in a single transaction to prevent it getting interspersed with
|
||||||
* any reply we need to send on the main thread.
|
* any reply we need to send on the main thread.
|
||||||
*/
|
*/
|
||||||
static DECLARE_THREAD_STACK(waNetThread, 512);
|
static GFX_THREAD_STACK(waNetThread, 512);
|
||||||
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
static GFX_THREAD_FUNCTION(NetThread, param) {
|
||||||
GEventMouse *pem;
|
GEventMouse *pem;
|
||||||
gU16 cmd[2];
|
gU16 cmd[2];
|
||||||
gU16 lbuttons;
|
gU16 lbuttons;
|
||||||
|
@ -270,8 +270,8 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* this is the X11 thread which keeps track of all events */
|
/* this is the X11 thread which keeps track of all events */
|
||||||
static DECLARE_THREAD_STACK(waXThread, 1024);
|
static GFX_THREAD_STACK(waXThread, 1024);
|
||||||
static DECLARE_THREAD_FUNCTION(ThreadX, arg) {
|
static GFX_THREAD_FUNCTION(ThreadX, arg) {
|
||||||
GDisplay *g;
|
GDisplay *g;
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ typedef struct netPriv {
|
|||||||
static gThread hThread;
|
static gThread hThread;
|
||||||
|
|
||||||
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
||||||
static gfxMutex uGFXnetMutex;
|
static gMutex uGFXnetMutex;
|
||||||
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
||||||
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
||||||
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
||||||
@ -318,8 +318,8 @@ static gBool rxdata(SOCKET_TYPE fd) {
|
|||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLARE_THREAD_STACK(waNetThread, 512);
|
static GFX_THREAD_STACK(waNetThread, 512);
|
||||||
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
static GFX_THREAD_FUNCTION(NetThread, param) {
|
||||||
SOCKET_TYPE listenfd, fdmax, i, clientfd;
|
SOCKET_TYPE listenfd, fdmax, i, clientfd;
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
fd_set master, read_fds;
|
fd_set master, read_fds;
|
||||||
|
@ -126,7 +126,7 @@ typedef struct netPriv {
|
|||||||
} netPriv;
|
} netPriv;
|
||||||
|
|
||||||
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
||||||
static gfxMutex uGFXnetMutex;
|
static gMutex uGFXnetMutex;
|
||||||
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
||||||
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
||||||
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
||||||
|
2
ffconf.h
2
ffconf.h
@ -244,7 +244,7 @@
|
|||||||
|
|
||||||
#define FF_FS_REENTRANT 0
|
#define FF_FS_REENTRANT 0
|
||||||
#define FF_FS_TIMEOUT 1000
|
#define FF_FS_TIMEOUT 1000
|
||||||
#define FF_SYNC_t gfxSem
|
#define FF_SYNC_t gSem
|
||||||
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
/* The option FF_FS_REENTRANT switches the re-entrancy (thread safe) of the FatFs
|
||||||
/ module itself. Note that regardless of this option, file access to different
|
/ module itself. Note that regardless of this option, file access to different
|
||||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||||
|
@ -25,7 +25,7 @@ typedef struct NonTimerData_t {
|
|||||||
GADCCallbackFunction callback;
|
GADCCallbackFunction callback;
|
||||||
union {
|
union {
|
||||||
void *param;
|
void *param;
|
||||||
gfxSem sigdone;
|
gSem sigdone;
|
||||||
};
|
};
|
||||||
GadcNonTimerJob job;
|
GadcNonTimerJob job;
|
||||||
} NonTimerData;
|
} NonTimerData;
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
#include "gaudio_driver_play.h"
|
#include "gaudio_driver_play.h"
|
||||||
|
|
||||||
static gfxQueueASync playList;
|
static gfxQueueASync playList;
|
||||||
static gfxSem playComplete;
|
static gSem playComplete;
|
||||||
static gU16 playFlags;
|
static gU16 playFlags;
|
||||||
#define PLAYFLG_USEEVENTS 0x0001
|
#define PLAYFLG_USEEVENTS 0x0001
|
||||||
#define PLAYFLG_PLAYING 0x0002
|
#define PLAYFLG_PLAYING 0x0002
|
||||||
|
@ -338,7 +338,7 @@ struct GDisplay {
|
|||||||
|
|
||||||
// Multithread Mutex
|
// Multithread Mutex
|
||||||
#if GDISP_NEED_MULTITHREAD
|
#if GDISP_NEED_MULTITHREAD
|
||||||
gfxMutex mutex;
|
gMutex mutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Software clipping
|
// Software clipping
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define GLISTENER_WITHSOURCE 0x0002 // The source is currently using the buffer
|
#define GLISTENER_WITHSOURCE 0x0002 // The source is currently using the buffer
|
||||||
|
|
||||||
/* This mutex protects access to our tables */
|
/* This mutex protects access to our tables */
|
||||||
static gfxMutex geventMutex;
|
static gMutex geventMutex;
|
||||||
|
|
||||||
/* Our table of listener/source pairs */
|
/* Our table of listener/source pairs */
|
||||||
static GSourceListener Assignments[GEVENT_MAX_SOURCE_LISTENERS];
|
static GSourceListener Assignments[GEVENT_MAX_SOURCE_LISTENERS];
|
||||||
@ -62,7 +62,7 @@ void _geventDeinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void geventListenerInit(GListener *pl) {
|
void geventListenerInit(GListener *pl) {
|
||||||
gfxSemInit(&pl->waitqueue, 0, MAX_SEMAPHORE_COUNT); // Next wait'er will block
|
gfxSemInit(&pl->waitqueue, 0, gSemMaxCount); // Next wait'er will block
|
||||||
pl->callback = 0; // No callback active
|
pl->callback = 0; // No callback active
|
||||||
pl->event.type = GEVENT_NULL; // Always safety
|
pl->event.type = GEVENT_NULL; // Always safety
|
||||||
pl->flags = 0;
|
pl->flags = 0;
|
||||||
|
@ -55,7 +55,7 @@ typedef void (*GEventCallbackFn)(void *param, GEvent *pe);
|
|||||||
|
|
||||||
// The Listener Object
|
// The Listener Object
|
||||||
typedef struct GListener {
|
typedef struct GListener {
|
||||||
gfxSem waitqueue; // Private: Semaphore for the listener to wait on.
|
gSem waitqueue; // Private: Semaphore for the listener to wait on.
|
||||||
gU16 flags; // Private: Flags for operation
|
gU16 flags; // Private: Flags for operation
|
||||||
GEventCallbackFn callback; // Private: Call back Function
|
GEventCallbackFn callback; // Private: Call back Function
|
||||||
void *param; // Private: Parameter for the callback function.
|
void *param; // Private: Parameter for the callback function.
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Static array of Synchronization Objects */
|
/* Static array of Synchronization Objects */
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
static gfxSem ff_sem[_VOLUMES];
|
static gSem ff_sem[_VOLUMES];
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
/* Create a Synchronization Object */
|
/* Create a Synchronization Object */
|
||||||
@ -28,7 +28,7 @@
|
|||||||
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
|
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
|
||||||
{
|
{
|
||||||
*sobj = ff_sem[vol];
|
*sobj = ff_sem[vol];
|
||||||
gfxSemInit(sobj, 1, MAX_SEMAPHORE_COUNT);
|
gfxSemInit(sobj, 1, gSemMaxCount);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
int ff_del_syncobj(_SYNC_t sobj)
|
int ff_del_syncobj(_SYNC_t sobj)
|
||||||
{
|
{
|
||||||
gfxSemDestroy( (gfxSem*)&sobj );
|
gfxSemDestroy( (gSem*)&sobj );
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -48,7 +48,7 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
int ff_req_grant(_SYNC_t sobj)
|
int ff_req_grant(_SYNC_t sobj)
|
||||||
{
|
{
|
||||||
if (gfxSemWait( (gfxSem*)&sobj, (gDelay)_FS_TIMEOUT) )
|
if (gfxSemWait( (gSem*)&sobj, (gDelay)_FS_TIMEOUT) )
|
||||||
return gTrue;
|
return gTrue;
|
||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
void ff_rel_grant(_SYNC_t sobj)
|
void ff_rel_grant(_SYNC_t sobj)
|
||||||
{
|
{
|
||||||
gfxSemSignal( (gfxSem*)&sobj );
|
gfxSemSignal( (gSem*)&sobj );
|
||||||
}
|
}
|
||||||
#endif /* _FS_REENTRANT */
|
#endif /* _FS_REENTRANT */
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
* @param[in] fnName The name of the function
|
* @param[in] fnName The name of the function
|
||||||
* @param[in] param A custom parameter that is passed to the function
|
* @param[in] param A custom parameter that is passed to the function
|
||||||
*/
|
*/
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Declare a thread stack
|
* @brief Declare a thread stack
|
||||||
@ -82,17 +82,7 @@
|
|||||||
* Many platforms will round the size to ensure correct stack alignment.
|
* Many platforms will round the size to ensure correct stack alignment.
|
||||||
* Other platforms may entirely ignore the suggested size.
|
* Other platforms may entirely ignore the suggested size.
|
||||||
*/
|
*/
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[sz];
|
#define GFX_THREAD_STACK(name, sz) gU8 name[sz];
|
||||||
|
|
||||||
/*
|
|
||||||
* @brief Return from a thread
|
|
||||||
*
|
|
||||||
* @details Some underlying operating systems allow to return a value from a thread while others don't.
|
|
||||||
* For systems that don't allow to return a value from a thread function this call is simply ignored.
|
|
||||||
*
|
|
||||||
* @param[in] reval The value which should be returned
|
|
||||||
*/
|
|
||||||
#define THREAD_RETURN(retval) return retval
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name Various platform (and operating system) constants
|
* @name Various platform (and operating system) constants
|
||||||
@ -101,7 +91,7 @@
|
|||||||
*/
|
*/
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever ((gDelay)-1)
|
#define gDelayForever ((gDelay)-1)
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow 0
|
#define gThreadpriorityLow 0
|
||||||
#define gThreadpriorityNormal 1
|
#define gThreadpriorityNormal 1
|
||||||
#define gThreadpriorityHigh 2
|
#define gThreadpriorityHigh 2
|
||||||
@ -111,13 +101,13 @@
|
|||||||
* @brief A semaphore
|
* @brief A semaphore
|
||||||
* @note Your operating system will have a proper definition for this structure
|
* @note Your operating system will have a proper definition for this structure
|
||||||
*/
|
*/
|
||||||
typedef struct {} gfxSem;
|
typedef struct {} gSem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A mutex
|
* @brief A mutex
|
||||||
* @note Your operating system will have a proper definition for this structure
|
* @note Your operating system will have a proper definition for this structure
|
||||||
*/
|
*/
|
||||||
typedef struct {} gfxMutex;
|
typedef struct {} gMutex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A thread handle
|
* @brief A thread handle
|
||||||
@ -297,7 +287,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxMutexInit(gfxMutex *pmutex);
|
void gfxMutexInit(gMutex *pmutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy a Mutex.
|
* @brief Destroy a Mutex.
|
||||||
@ -306,7 +296,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxMutexDestroy(gfxMutex *pmutex);
|
void gfxMutexDestroy(gMutex *pmutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enter the critical code region protected by the mutex.
|
* @brief Enter the critical code region protected by the mutex.
|
||||||
@ -316,7 +306,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxMutexEnter(gfxMutex *pmutex);
|
void gfxMutexEnter(gMutex *pmutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Exit the critical code region protected by the mutex.
|
* @brief Exit the critical code region protected by the mutex.
|
||||||
@ -326,7 +316,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxMutexExit(gfxMutex *pmutex);
|
void gfxMutexExit(gMutex *pmutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initialise a Counted Semaphore
|
* @brief Initialise a Counted Semaphore
|
||||||
@ -344,7 +334,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy a Counted Semaphore
|
* @brief Destroy a Counted Semaphore
|
||||||
@ -355,7 +345,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait on a semaphore
|
* @brief Wait on a semaphore
|
||||||
@ -368,7 +358,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Test if a wait on a semaphore can be satisfied immediately
|
* @brief Test if a wait on a semaphore can be satisfied immediately
|
||||||
@ -380,7 +370,7 @@
|
|||||||
* @iclass
|
* @iclass
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
gBool gfxSemWaitI(gfxSem *psem);
|
gBool gfxSemWaitI(gSem *psem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Signal a semaphore
|
* @brief Signal a semaphore
|
||||||
@ -392,7 +382,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Signal a semaphore
|
* @brief Signal a semaphore
|
||||||
@ -405,7 +395,7 @@
|
|||||||
* @iclass
|
* @iclass
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gSem *psem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Start a new thread.
|
* @brief Start a new thread.
|
||||||
@ -420,7 +410,7 @@
|
|||||||
*
|
*
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Wait for a thread to finish.
|
* @brief Wait for a thread to finish.
|
||||||
@ -453,6 +443,17 @@
|
|||||||
*/
|
*/
|
||||||
void gfxThreadClose(gThread thread);
|
void gfxThreadClose(gThread thread);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @brief Return from a thread
|
||||||
|
*
|
||||||
|
* @details Some underlying operating systems allow to return a value from a thread while others don't.
|
||||||
|
* For systems that don't allow to return a value from a thread function this call is simply ignored.
|
||||||
|
* @pre This pseudo function can only be called within the main body of the thread function (not a sub-function)
|
||||||
|
*
|
||||||
|
* @param[in] reval The value which should be returned
|
||||||
|
*/
|
||||||
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All the above was just for the doxygen documentation. All the implementation of the above
|
* All the above was just for the doxygen documentation. All the implementation of the above
|
||||||
* (without any of the documentation overheads) is in the files below.
|
* (without any of the documentation overheads) is in the files below.
|
||||||
@ -502,11 +503,17 @@
|
|||||||
#endif
|
#endif
|
||||||
typedef gTicks systemticks_t;
|
typedef gTicks systemticks_t;
|
||||||
typedef gThread gfxThreadHandle;
|
typedef gThread gfxThreadHandle;
|
||||||
|
#define DECLARE_THREAD_FUNCTION GFX_THREAD_FUNCTION
|
||||||
|
#define DECLARE_THREAD_STACK GFX_THREAD_STACK
|
||||||
typedef gThreadreturn threadreturn_t;
|
typedef gThreadreturn threadreturn_t;
|
||||||
|
#define THREAD_RETURN gfxThreadReturn
|
||||||
typedef gThreadpriority threadpriority_t;
|
typedef gThreadpriority threadpriority_t;
|
||||||
#define LOW_PRIORITY gThreadpriorityLow
|
#define LOW_PRIORITY gThreadpriorityLow
|
||||||
#define NORMAL_PRIORITY gThreadpriorityNormal
|
#define NORMAL_PRIORITY gThreadpriorityNormal
|
||||||
#define HIGH_PRIORITY gThreadpriorityHigh
|
#define HIGH_PRIORITY gThreadpriorityHigh
|
||||||
|
typedef gSem gfxSem;
|
||||||
|
#define MAX_SEMAPHORE_COUNT gSemMaxCount
|
||||||
|
typedef gMutex gfxMutex;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _GOS_H */
|
#endif /* _GOS_H */
|
||||||
|
@ -99,7 +99,7 @@ void gfxSleepMicroseconds(gDelay ms)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
if (val > limit)
|
if (val > limit)
|
||||||
val = limit;
|
val = limit;
|
||||||
@ -113,12 +113,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemDestroy(gfxSem *psem)
|
void gfxSemDestroy(gSem *psem)
|
||||||
{
|
{
|
||||||
chSemReset(&psem->sem, 1);
|
chSemReset(&psem->sem, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
gBool gfxSemWait(gSem *psem, gDelay ms)
|
||||||
{
|
{
|
||||||
#if CH_KERNEL_MAJOR <= 2
|
#if CH_KERNEL_MAJOR <= 2
|
||||||
switch(ms) {
|
switch(ms) {
|
||||||
@ -135,7 +135,7 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem *psem)
|
gBool gfxSemWaitI(gSem *psem)
|
||||||
{
|
{
|
||||||
#if CH_KERNEL_MAJOR <= 3
|
#if CH_KERNEL_MAJOR <= 3
|
||||||
if (psem->sem.s_cnt <= 0)
|
if (psem->sem.s_cnt <= 0)
|
||||||
@ -148,7 +148,7 @@ gBool gfxSemWaitI(gfxSem *psem)
|
|||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem *psem)
|
void gfxSemSignal(gSem *psem)
|
||||||
{
|
{
|
||||||
chSysLock();
|
chSysLock();
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ void gfxSemSignal(gfxSem *psem)
|
|||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem *psem)
|
void gfxSemSignalI(gSem *psem)
|
||||||
{
|
{
|
||||||
#if CH_KERNEL_MAJOR <= 3
|
#if CH_KERNEL_MAJOR <= 3
|
||||||
if (psem->sem.s_cnt < psem->limit)
|
if (psem->sem.s_cnt < psem->limit)
|
||||||
@ -175,7 +175,7 @@ void gfxSemSignalI(gfxSem *psem)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
||||||
{
|
{
|
||||||
if (!stackarea) {
|
if (!stackarea) {
|
||||||
if (!stacksz) stacksz = 256;
|
if (!stacksz) stacksz = 256;
|
||||||
|
@ -38,33 +38,33 @@ typedef cnt_t gSemcount;
|
|||||||
typedef msg_t gThreadreturn;
|
typedef msg_t gThreadreturn;
|
||||||
typedef tprio_t gThreadpriority;
|
typedef tprio_t gThreadpriority;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow LOWPRIO
|
#define gThreadpriorityLow LOWPRIO
|
||||||
#define gThreadpriorityNormal NORMALPRIO
|
#define gThreadpriorityNormal NORMALPRIO
|
||||||
#define gThreadpriorityHigh HIGHPRIO
|
#define gThreadpriorityHigh HIGHPRIO
|
||||||
|
|
||||||
#define DECLARE_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
|
#define GFX_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#if CH_KERNEL_MAJOR <= 2
|
#if CH_KERNEL_MAJOR <= 2
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Semaphore sem;
|
Semaphore sem;
|
||||||
gSemcount limit;
|
gSemcount limit;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
typedef Mutex gfxMutex;
|
typedef Mutex gMutex;
|
||||||
typedef Thread* gThread;
|
typedef Thread* gThread;
|
||||||
#else
|
#else
|
||||||
#undef DECLARE_THREAD_STACK
|
#undef GFX_THREAD_STACK
|
||||||
#define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
#define GFX_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
semaphore_t sem;
|
semaphore_t sem;
|
||||||
gSemcount limit;
|
gSemcount limit;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
typedef mutex_t gfxMutex;
|
typedef mutex_t gMutex;
|
||||||
typedef thread_t* gThread;
|
typedef thread_t* gThread;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -104,13 +104,13 @@ typedef tprio_t gThreadpriority;
|
|||||||
void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
|
void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
|
||||||
void gfxSleepMilliseconds(gDelay ms);
|
void gfxSleepMilliseconds(gDelay ms);
|
||||||
void gfxSleepMicroseconds(gDelay ms);
|
void gfxSleepMicroseconds(gDelay ms);
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem *psem);
|
gBool gfxSemWaitI(gSem *psem);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gSem *psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
#define gfxThreadWait(thread) chThdWait(thread)
|
#define gfxThreadWait(thread) chThdWait(thread)
|
||||||
#define gfxThreadMe() chThdSelf()
|
#define gfxThreadMe() chThdSelf()
|
||||||
#define gfxThreadClose(thread) (void)thread
|
#define gfxThreadClose(thread) (void)thread
|
||||||
|
@ -38,7 +38,7 @@ void _gosDeinit(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex* pmutex)
|
void gfxMutexInit(gMutex* pmutex)
|
||||||
{
|
{
|
||||||
osMutexDef_t def;
|
osMutexDef_t def;
|
||||||
def.mutex = pmutex->mutex;
|
def.mutex = pmutex->mutex;
|
||||||
@ -46,7 +46,7 @@ void gfxMutexInit(gfxMutex* pmutex)
|
|||||||
pmutex->id = osMutexCreate(&def);
|
pmutex->id = osMutexCreate(&def);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
osSemaphoreDef_t def;
|
osSemaphoreDef_t def;
|
||||||
def.semaphore = psem->semaphore;
|
def.semaphore = psem->semaphore;
|
||||||
@ -56,12 +56,12 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
|||||||
psem->id = osSemaphoreCreate(&def, val);
|
psem->id = osSemaphoreCreate(&def, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemDestroy(gfxSem* psem)
|
void gfxSemDestroy(gSem* psem)
|
||||||
{
|
{
|
||||||
osSemaphoreDelete(psem->id);
|
osSemaphoreDelete(psem->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||||
{
|
{
|
||||||
if (osSemaphoreWait(psem->id, ms) > 0) {
|
if (osSemaphoreWait(psem->id, ms) > 0) {
|
||||||
psem->available++;
|
psem->available++;
|
||||||
@ -70,17 +70,17 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
|||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem* psem)
|
gBool gfxSemWaitI(gSem* psem)
|
||||||
{
|
{
|
||||||
return gfxSemWait(psem, 0);
|
return gfxSemWait(psem, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem* psem)
|
void gfxSemSignal(gSem* psem)
|
||||||
{
|
{
|
||||||
gfxSemSignalI(psem);
|
gfxSemSignalI(psem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem* psem)
|
void gfxSemSignalI(gSem* psem)
|
||||||
{
|
{
|
||||||
if (psem->available) {
|
if (psem->available) {
|
||||||
psem->available--;
|
psem->available--;
|
||||||
@ -88,7 +88,7 @@ void gfxSemSignalI(gfxSem* psem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param)
|
||||||
{
|
{
|
||||||
osThreadDef_t def;
|
osThreadDef_t def;
|
||||||
|
|
||||||
|
@ -33,27 +33,27 @@ typedef gU16 gSemcount;
|
|||||||
typedef void gThreadreturn;
|
typedef void gThreadreturn;
|
||||||
typedef osPriority gThreadpriority;
|
typedef osPriority gThreadpriority;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
|
#define gSemMaxCount osFeature_Semaphore
|
||||||
#define gThreadpriorityLow osPriorityLow
|
#define gThreadpriorityLow osPriorityLow
|
||||||
#define gThreadpriorityNormal osPriorityNormal
|
#define gThreadpriorityNormal osPriorityNormal
|
||||||
#define gThreadpriorityHigh osPriorityHigh
|
#define gThreadpriorityHigh osPriorityHigh
|
||||||
|
|
||||||
typedef struct gfxSem {
|
typedef struct gSem {
|
||||||
gU32 semaphore[2];
|
gU32 semaphore[2];
|
||||||
osSemaphoreId id;
|
osSemaphoreId id;
|
||||||
gSemcount available;
|
gSemcount available;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
typedef struct gfxMutex {
|
typedef struct gMutex {
|
||||||
gU32 mutex[4];
|
gU32 mutex[4];
|
||||||
osMutexId id;
|
osMutexId id;
|
||||||
} gfxMutex;
|
} gMutex;
|
||||||
|
|
||||||
typedef osThreadId gThread;
|
typedef osThreadId gThread;
|
||||||
|
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
#define GFX_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||||
#define THREAD_RETURN(retval)
|
#define gfxThreadReturn(retval) return
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Function declarations. */
|
/* Function declarations. */
|
||||||
@ -67,19 +67,19 @@ typedef osThreadId gThread;
|
|||||||
#define gfxSystemUnlock() osKernelStart()
|
#define gfxSystemUnlock() osKernelStart()
|
||||||
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex* pmutex);
|
void gfxMutexInit(gMutex* pmutex);
|
||||||
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
|
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
|
||||||
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, gDelayForever)
|
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, gDelayForever)
|
||||||
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
|
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem* psem);
|
void gfxSemDestroy(gSem* psem);
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem* psem);
|
gBool gfxSemWaitI(gSem* psem);
|
||||||
void gfxSemSignal(gfxSem* psem);
|
void gfxSemSignal(gSem* psem);
|
||||||
void gfxSemSignalI(gfxSem* psem);
|
void gfxSemSignalI(gSem* psem);
|
||||||
|
|
||||||
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param);
|
||||||
#define gfxYield() osThreadYield()
|
#define gfxYield() osThreadYield()
|
||||||
#define gfxThreadMe() osThreadGetId()
|
#define gfxThreadMe() osThreadGetId()
|
||||||
#define gfxThreadClose(thread) {}
|
#define gfxThreadClose(thread) {}
|
||||||
|
@ -31,7 +31,7 @@ void _gosInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
|
#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
|
||||||
static DECLARE_THREAD_FUNCTION(startUGFX_CMSIS2, p) {
|
static GFX_THREAD_FUNCTION(startUGFX_CMSIS2, p) {
|
||||||
(void) p;
|
(void) p;
|
||||||
uGFXMain();
|
uGFXMain();
|
||||||
}
|
}
|
||||||
@ -59,24 +59,24 @@ void _gosDeinit(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex* pmutex)
|
void gfxMutexInit(gMutex* pmutex)
|
||||||
{
|
{
|
||||||
*pmutex = osMutexNew(NULL);
|
*pmutex = osMutexNew(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
*psem = osSemaphoreNew(limit, val, NULL);
|
*psem = osSemaphoreNew(limit, val, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||||
{
|
{
|
||||||
if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK)
|
if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK)
|
||||||
return gTrue;
|
return gTrue;
|
||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param)
|
||||||
{
|
{
|
||||||
osThreadAttr_t def;
|
osThreadAttr_t def;
|
||||||
|
|
||||||
|
@ -33,20 +33,20 @@ typedef gU16 gSemcount;
|
|||||||
typedef void gThreadreturn;
|
typedef void gThreadreturn;
|
||||||
typedef osPriority_t gThreadpriority;
|
typedef osPriority_t gThreadpriority;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT 65535UL
|
#define gSemMaxCount 65535UL
|
||||||
#define gThreadpriorityLow osPriorityLow
|
#define gThreadpriorityLow osPriorityLow
|
||||||
#define gThreadpriorityNormal osPriorityNormal
|
#define gThreadpriorityNormal osPriorityNormal
|
||||||
#define gThreadpriorityHigh osPriorityHigh
|
#define gThreadpriorityHigh osPriorityHigh
|
||||||
|
|
||||||
typedef osSemaphoreId_t gfxSem;
|
typedef osSemaphoreId_t gSem;
|
||||||
|
|
||||||
typedef osMutexId_t gfxMutex;
|
typedef osMutexId_t gMutex;
|
||||||
|
|
||||||
typedef osThreadId_t gThread;
|
typedef osThreadId_t gThread;
|
||||||
|
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
#define GFX_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||||
#define THREAD_RETURN(retval)
|
#define gfxThreadReturn(retval) return
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Function declarations. */
|
/* Function declarations. */
|
||||||
@ -60,19 +60,19 @@ typedef osThreadId_t gThread;
|
|||||||
#define gfxSystemUnlock() osKernelUnlock()
|
#define gfxSystemUnlock() osKernelUnlock()
|
||||||
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex* pmutex);
|
void gfxMutexInit(gMutex* pmutex);
|
||||||
#define gfxMutexDestroy(pmutex) osMutexDelete(*(pmutex))
|
#define gfxMutexDestroy(pmutex) osMutexDelete(*(pmutex))
|
||||||
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), gDelayForever)
|
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), gDelayForever)
|
||||||
#define gfxMutexExit(pmutex) osMutexRelease(*(pmutex))
|
#define gfxMutexExit(pmutex) osMutexRelease(*(pmutex))
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
|
||||||
#define gfxSemDestroy(psem) osSemaphoreDelete(*(psem))
|
#define gfxSemDestroy(psem) osSemaphoreDelete(*(psem))
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||||
#define gfxSemWaitI(psem) gfxSemWait((psem), 0)
|
#define gfxSemWaitI(psem) gfxSemWait((psem), 0)
|
||||||
#define gfxSemSignal(psem) osSemaphoreRelease(*(psem))
|
#define gfxSemSignal(psem) osSemaphoreRelease(*(psem))
|
||||||
#define gfxSemSignalI(psem) osSemaphoreRelease(*(psem))
|
#define gfxSemSignalI(psem) osSemaphoreRelease(*(psem))
|
||||||
|
|
||||||
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
gThread gfxThreadCreate(void* stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void* param);
|
||||||
#define gfxYield() osThreadYield()
|
#define gfxYield() osThreadYield()
|
||||||
#define gfxThreadMe() osThreadGetId()
|
#define gfxThreadMe() osThreadGetId()
|
||||||
#define gfxThreadClose(thread) {}
|
#define gfxThreadClose(thread) {}
|
||||||
|
@ -50,7 +50,7 @@ void gfxSleepMicroseconds(gDelay ms)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
if (val > limit)
|
if (val > limit)
|
||||||
val = limit;
|
val = limit;
|
||||||
@ -59,12 +59,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
|||||||
cyg_semaphore_init(&psem->sem, val);
|
cyg_semaphore_init(&psem->sem, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemDestroy(gfxSem *psem)
|
void gfxSemDestroy(gSem *psem)
|
||||||
{
|
{
|
||||||
cyg_semaphore_destroy(&psem->sem);
|
cyg_semaphore_destroy(&psem->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
gBool gfxSemWait(gSem *psem, gDelay ms)
|
||||||
{
|
{
|
||||||
switch(ms) {
|
switch(ms) {
|
||||||
case gDelayNone: return cyg_semaphore_trywait(&psem->sem);
|
case gDelayNone: return cyg_semaphore_trywait(&psem->sem);
|
||||||
@ -73,14 +73,14 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem *psem)
|
gBool gfxSemWaitI(gSem *psem)
|
||||||
{
|
{
|
||||||
return cyg_semaphore_trywait(&psem->sem);
|
return cyg_semaphore_trywait(&psem->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem *psem)
|
void gfxSemSignal(gSem *psem)
|
||||||
{
|
{
|
||||||
if (psem->limit == MAX_SEMAPHORE_COUNT)
|
if (psem->limit == gSemMaxCount)
|
||||||
cyg_semaphore_post(&psem->sem);
|
cyg_semaphore_post(&psem->sem);
|
||||||
else {
|
else {
|
||||||
cyg_scheduler_lock();
|
cyg_scheduler_lock();
|
||||||
@ -90,13 +90,13 @@ void gfxSemSignal(gfxSem *psem)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem *psem)
|
void gfxSemSignalI(gSem *psem)
|
||||||
{
|
{
|
||||||
if (psem->limit == MAX_SEMAPHORE_COUNT || cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
|
if (psem->limit == gSemMaxCount || cyg_semaphore_peek(&psem->sem, &cnt) < psem->limit)
|
||||||
cyg_semaphore_post(&psem->sem);
|
cyg_semaphore_post(&psem->sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
||||||
{
|
{
|
||||||
gThread th;
|
gThread th;
|
||||||
|
|
||||||
|
@ -28,21 +28,21 @@ typedef void gThreadreturn;
|
|||||||
typedef cyg_addrword_t gThreadpriority;
|
typedef cyg_addrword_t gThreadpriority;
|
||||||
typedef cyg_handle_t gThread;
|
typedef cyg_handle_t gThread;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF
|
#define gSemMaxCount 0x7FFFFFFF
|
||||||
#define gThreadpriorityLow (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
|
#define gThreadpriorityLow (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
|
||||||
#define gThreadpriorityNormal (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
|
#define gThreadpriorityNormal (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
|
||||||
#define gThreadpriorityHigh 0
|
#define gThreadpriorityHigh 0
|
||||||
|
|
||||||
#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
|
#define GFX_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(cyg_addrword_t param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(cyg_addrword_t param)
|
||||||
#define THREAD_RETURN(retval)
|
#define gfxThreadReturn(retval) return
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
cyg_sem_t sem;
|
cyg_sem_t sem;
|
||||||
gSemcount limit;
|
gSemcount limit;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
typedef cyg_mutex_t gfxMutex;
|
typedef cyg_mutex_t gMutex;
|
||||||
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
@ -70,14 +70,14 @@ void gfxSleepMicroseconds(gDelay ms);
|
|||||||
#define gfxMutexDestroy(pmutex) cyg_mutex_destroy(pmutex)
|
#define gfxMutexDestroy(pmutex) cyg_mutex_destroy(pmutex)
|
||||||
#define gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex)
|
#define gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex)
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem *psem);
|
gBool gfxSemWaitI(gSem *psem);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gSem *psem);
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
#define gfxThreadWait(thread) NOTIMPLEMENTED_YET
|
#define gfxThreadWait(thread) NOTIMPLEMENTED_YET
|
||||||
#define gfxThreadMe() cyg_thread_self()
|
#define gfxThreadMe() cyg_thread_self()
|
||||||
#define gfxThreadClose(thread) (void)thread
|
#define gfxThreadClose(thread) (void)thread
|
||||||
|
@ -42,7 +42,7 @@ void _gosInit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
|
#if !GFX_OS_NO_INIT && GFX_OS_CALL_UGFXMAIN
|
||||||
static DECLARE_THREAD_FUNCTION(startUGFX_FreeRTOS, p) {
|
static GFX_THREAD_FUNCTION(startUGFX_FreeRTOS, p) {
|
||||||
(void) p;
|
(void) p;
|
||||||
uGFXMain();
|
uGFXMain();
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ void gfxSleepMicroseconds(gDelay ms)
|
|||||||
// vUsDelay(ms%1000);
|
// vUsDelay(ms%1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex *pmutex)
|
void gfxMutexInit(gMutex *pmutex)
|
||||||
{
|
{
|
||||||
*pmutex = xSemaphoreCreateMutex();
|
*pmutex = xSemaphoreCreateMutex();
|
||||||
#if GFX_FREERTOS_USE_TRACE
|
#if GFX_FREERTOS_USE_TRACE
|
||||||
@ -106,7 +106,7 @@ void gfxMutexInit(gfxMutex *pmutex)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
if (val > limit)
|
if (val > limit)
|
||||||
val = limit;
|
val = limit;
|
||||||
@ -117,14 +117,14 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||||
{
|
{
|
||||||
if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS)
|
if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS)
|
||||||
return gTrue;
|
return gTrue;
|
||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem* psem)
|
gBool gfxSemWaitI(gSem* psem)
|
||||||
{
|
{
|
||||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
@ -133,20 +133,20 @@ gBool gfxSemWaitI(gfxSem* psem)
|
|||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem* psem)
|
void gfxSemSignal(gSem* psem)
|
||||||
{
|
{
|
||||||
xSemaphoreGive(*psem);
|
xSemaphoreGive(*psem);
|
||||||
taskYIELD();
|
taskYIELD();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem* psem)
|
void gfxSemSignalI(gSem* psem)
|
||||||
{
|
{
|
||||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||||
|
|
||||||
xSemaphoreGiveFromISR(*psem,&xHigherPriorityTaskWoken);
|
xSemaphoreGiveFromISR(*psem,&xHigherPriorityTaskWoken);
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
||||||
{
|
{
|
||||||
gThread task;
|
gThread task;
|
||||||
(void) stackarea;
|
(void) stackarea;
|
||||||
|
@ -32,18 +32,18 @@ typedef gI32 gSemcount;
|
|||||||
typedef void gThreadreturn;
|
typedef void gThreadreturn;
|
||||||
typedef portBASE_TYPE gThreadpriority;
|
typedef portBASE_TYPE gThreadpriority;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow 0
|
#define gThreadpriorityLow 0
|
||||||
#define gThreadpriorityNormal configMAX_PRIORITIES/2
|
#define gThreadpriorityNormal configMAX_PRIORITIES/2
|
||||||
#define gThreadpriorityHigh configMAX_PRIORITIES-1
|
#define gThreadpriorityHigh configMAX_PRIORITIES-1
|
||||||
|
|
||||||
/* FreeRTOS will allocate the stack when creating the thread */
|
/* FreeRTOS will allocate the stack when creating the thread */
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1]
|
#define GFX_THREAD_STACK(name, sz) gU8 name[1]
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define THREAD_RETURN(retval)
|
#define gfxThreadReturn(retval) return
|
||||||
|
|
||||||
typedef xSemaphoreHandle gfxSem;
|
typedef xSemaphoreHandle gSem;
|
||||||
typedef xSemaphoreHandle gfxMutex;
|
typedef xSemaphoreHandle gMutex;
|
||||||
typedef xTaskHandle gThread;
|
typedef xTaskHandle gThread;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
@ -60,7 +60,7 @@ typedef xTaskHandle gThread;
|
|||||||
#define gfxSystemLock() taskENTER_CRITICAL()
|
#define gfxSystemLock() taskENTER_CRITICAL()
|
||||||
#define gfxSystemUnlock() taskEXIT_CRITICAL()
|
#define gfxSystemUnlock() taskEXIT_CRITICAL()
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex* s);
|
void gfxMutexInit(gMutex* s);
|
||||||
#define gfxMutexDestroy(pmutex) vSemaphoreDelete(*(pmutex))
|
#define gfxMutexDestroy(pmutex) vSemaphoreDelete(*(pmutex))
|
||||||
#define gfxMutexEnter(pmutex) xSemaphoreTake(*(pmutex),portMAX_DELAY)
|
#define gfxMutexEnter(pmutex) xSemaphoreTake(*(pmutex),portMAX_DELAY)
|
||||||
#define gfxMutexExit(pmutex) xSemaphoreGive(*(pmutex))
|
#define gfxMutexExit(pmutex) xSemaphoreGive(*(pmutex))
|
||||||
@ -69,13 +69,13 @@ void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
|
|||||||
void gfxSleepMilliseconds(gDelay ms);
|
void gfxSleepMilliseconds(gDelay ms);
|
||||||
void gfxSleepMicroseconds(gDelay ms);
|
void gfxSleepMicroseconds(gDelay ms);
|
||||||
|
|
||||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
|
||||||
#define gfxSemDestroy(psem) vSemaphoreDelete(*(psem))
|
#define gfxSemDestroy(psem) vSemaphoreDelete(*(psem))
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem* psem);
|
gBool gfxSemWaitI(gSem* psem);
|
||||||
void gfxSemSignal(gfxSem* psem);
|
void gfxSemSignal(gSem* psem);
|
||||||
void gfxSemSignalI(gfxSem* psem);
|
void gfxSemSignalI(gSem* psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
|
|
||||||
#define gfxThreadMe() xTaskGetCurrentTaskHandle()
|
#define gfxThreadMe() xTaskGetCurrentTaskHandle()
|
||||||
#if INCLUDE_eTaskGetState == 1
|
#if INCLUDE_eTaskGetState == 1
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#define linuxyield() pthread_yield()
|
#define linuxyield() pthread_yield()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gfxMutex SystemMutex;
|
static gMutex SystemMutex;
|
||||||
|
|
||||||
void _gosInit(void)
|
void _gosInit(void)
|
||||||
{
|
{
|
||||||
@ -109,7 +109,7 @@ gTicks gfxSystemTicks(void) {
|
|||||||
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
|
||||||
gThread th;
|
gThread th;
|
||||||
(void) stackarea;
|
(void) stackarea;
|
||||||
(void) stacksz;
|
(void) stacksz;
|
||||||
@ -138,14 +138,14 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if GFX_USE_POSIX_SEMAPHORES
|
#if GFX_USE_POSIX_SEMAPHORES
|
||||||
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
|
||||||
pSem->max = limit;
|
pSem->max = limit;
|
||||||
sem_init(&pSem->sem, 0, val);
|
sem_init(&pSem->sem, 0, val);
|
||||||
}
|
}
|
||||||
void gfxSemDestroy(gfxSem *pSem) {
|
void gfxSemDestroy(gSem *pSem) {
|
||||||
sem_destroy(&pSem->sem);
|
sem_destroy(&pSem->sem);
|
||||||
}
|
}
|
||||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||||
switch (ms) {
|
switch (ms) {
|
||||||
case gDelayForever:
|
case gDelayForever:
|
||||||
return sem_wait(&pSem->sem) ? gFalse : gTrue;
|
return sem_wait(&pSem->sem) ? gFalse : gTrue;
|
||||||
@ -164,7 +164,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void gfxSemSignal(gfxSem *pSem) {
|
void gfxSemSignal(gSem *pSem) {
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = 0;
|
res = 0;
|
||||||
@ -173,7 +173,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
sem_post(&pSem->sem);
|
sem_post(&pSem->sem);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
|
||||||
pthread_mutex_init(&pSem->mtx, 0);
|
pthread_mutex_init(&pSem->mtx, 0);
|
||||||
pthread_cond_init(&pSem->cond, 0);
|
pthread_cond_init(&pSem->cond, 0);
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
@ -181,11 +181,11 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
pSem->max = limit;
|
pSem->max = limit;
|
||||||
pthread_mutex_unlock(&pSem->mtx);
|
pthread_mutex_unlock(&pSem->mtx);
|
||||||
}
|
}
|
||||||
void gfxSemDestroy(gfxSem *pSem) {
|
void gfxSemDestroy(gSem *pSem) {
|
||||||
pthread_mutex_destroy(&pSem->mtx);
|
pthread_mutex_destroy(&pSem->mtx);
|
||||||
pthread_cond_destroy(&pSem->cond);
|
pthread_cond_destroy(&pSem->cond);
|
||||||
}
|
}
|
||||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
|
|
||||||
switch (ms) {
|
switch (ms) {
|
||||||
@ -226,7 +226,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
pthread_mutex_unlock(&pSem->mtx);
|
pthread_mutex_unlock(&pSem->mtx);
|
||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
void gfxSemSignal(gfxSem *pSem) {
|
void gfxSemSignal(gSem *pSem) {
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
|
|
||||||
if (pSem->cnt < pSem->max) {
|
if (pSem->cnt < pSem->max) {
|
||||||
|
@ -29,11 +29,11 @@ typedef unsigned long gDelay;
|
|||||||
typedef pthread_t gThread;
|
typedef pthread_t gThread;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
typedef gU32 gSemcount;
|
typedef gU32 gSemcount;
|
||||||
typedef pthread_mutex_t gfxMutex;
|
typedef pthread_mutex_t gMutex;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0];
|
#define GFX_THREAD_STACK(name, sz) gU8 name[0];
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gfxExit() exit(0)
|
#define gfxExit() exit(0)
|
||||||
#define gfxAlloc(sz) malloc(sz)
|
#define gfxAlloc(sz) malloc(sz)
|
||||||
@ -51,23 +51,23 @@ typedef pthread_mutex_t gfxMutex;
|
|||||||
|
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever ((gDelay)-1)
|
#define gDelayForever ((gDelay)-1)
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
|
#define gSemMaxCount ((gSemcount)-1)
|
||||||
#define gThreadpriorityLow 10
|
#define gThreadpriorityLow 10
|
||||||
#define gThreadpriorityNormal 0
|
#define gThreadpriorityNormal 0
|
||||||
#define gThreadpriorityHigh -10
|
#define gThreadpriorityHigh -10
|
||||||
|
|
||||||
#if GFX_USE_POSIX_SEMAPHORES
|
#if GFX_USE_POSIX_SEMAPHORES
|
||||||
typedef struct gfxSem {
|
typedef struct gSem {
|
||||||
sem_t sem;
|
sem_t sem;
|
||||||
gSemcount max;
|
gSemcount max;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
#else
|
#else
|
||||||
typedef struct gfxSem {
|
typedef struct gSem {
|
||||||
pthread_mutex_t mtx;
|
pthread_mutex_t mtx;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
gSemcount cnt;
|
gSemcount cnt;
|
||||||
gSemcount max;
|
gSemcount max;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
@ -81,11 +81,11 @@ void gfxSleepMicroseconds(gDelay ms);
|
|||||||
gTicks gfxSystemTicks(void);
|
gTicks gfxSystemTicks(void);
|
||||||
void gfxSystemLock(void);
|
void gfxSystemLock(void);
|
||||||
void gfxSystemUnlock(void);
|
void gfxSystemUnlock(void);
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
gThreadreturn gfxThreadWait(gThread thread);
|
gThreadreturn gfxThreadWait(gThread thread);
|
||||||
|
|
||||||
#endif /* GFX_USE_OS_LINUX */
|
#endif /* GFX_USE_OS_LINUX */
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <mach/clock.h>
|
#include <mach/clock.h>
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
|
|
||||||
static gfxMutex SystemMutex;
|
static gMutex SystemMutex;
|
||||||
|
|
||||||
void _gosInit(void)
|
void _gosInit(void)
|
||||||
{
|
{
|
||||||
@ -92,7 +92,7 @@ gTicks gfxSystemTicks(void) {
|
|||||||
return ts.tv_sec * 1000UL + ts.tv_nsec / 1000000;
|
return ts.tv_sec * 1000UL + ts.tv_nsec / 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
|
||||||
gThread th;
|
gThread th;
|
||||||
(void) stackarea;
|
(void) stackarea;
|
||||||
(void) stacksz;
|
(void) stacksz;
|
||||||
@ -118,7 +118,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
|
||||||
pthread_mutex_init(&pSem->mtx, 0);
|
pthread_mutex_init(&pSem->mtx, 0);
|
||||||
pthread_cond_init(&pSem->cond, 0);
|
pthread_cond_init(&pSem->cond, 0);
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
@ -127,12 +127,12 @@ void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
|||||||
pthread_mutex_unlock(&pSem->mtx);
|
pthread_mutex_unlock(&pSem->mtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemDestroy(gfxSem *pSem) {
|
void gfxSemDestroy(gSem *pSem) {
|
||||||
pthread_mutex_destroy(&pSem->mtx);
|
pthread_mutex_destroy(&pSem->mtx);
|
||||||
pthread_cond_destroy(&pSem->cond);
|
pthread_cond_destroy(&pSem->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
switch (ms) {
|
switch (ms) {
|
||||||
case gDelayForever:
|
case gDelayForever:
|
||||||
@ -171,7 +171,7 @@ gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
|||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem *pSem) {
|
void gfxSemSignal(gSem *pSem) {
|
||||||
pthread_mutex_lock(&pSem->mtx);
|
pthread_mutex_lock(&pSem->mtx);
|
||||||
if (pSem->cnt < pSem->max) {
|
if (pSem->cnt < pSem->max) {
|
||||||
pSem->cnt++;
|
pSem->cnt++;
|
||||||
|
@ -20,11 +20,11 @@ typedef unsigned long gDelay;
|
|||||||
typedef pthread_t gThread;
|
typedef pthread_t gThread;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
typedef gU32 gSemcount;
|
typedef gU32 gSemcount;
|
||||||
typedef pthread_mutex_t gfxMutex;
|
typedef pthread_mutex_t gMutex;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0];
|
#define GFX_THREAD_STACK(name, sz) gU8 name[0];
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gfxExit() exit(0)
|
#define gfxExit() exit(0)
|
||||||
#define gfxAlloc(sz) malloc(sz)
|
#define gfxAlloc(sz) malloc(sz)
|
||||||
@ -43,17 +43,17 @@ typedef pthread_mutex_t gfxMutex;
|
|||||||
|
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever ((gDelay)-1)
|
#define gDelayForever ((gDelay)-1)
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
|
#define gSemMaxCount ((gSemcount)-1)
|
||||||
#define gThreadpriorityLow 10
|
#define gThreadpriorityLow 10
|
||||||
#define gThreadpriorityNormal 0
|
#define gThreadpriorityNormal 0
|
||||||
#define gThreadpriorityHigh -10
|
#define gThreadpriorityHigh -10
|
||||||
|
|
||||||
typedef struct gfxSem {
|
typedef struct gSem {
|
||||||
pthread_mutex_t mtx;
|
pthread_mutex_t mtx;
|
||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
gSemcount cnt;
|
gSemcount cnt;
|
||||||
gSemcount max;
|
gSemcount max;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Function declarations. */
|
/* Function declarations. */
|
||||||
@ -65,11 +65,11 @@ void gfxSleepMicroseconds(gDelay ms);
|
|||||||
gTicks gfxSystemTicks(void);
|
gTicks gfxSystemTicks(void);
|
||||||
void gfxSystemLock(void);
|
void gfxSystemLock(void);
|
||||||
void gfxSystemUnlock(void);
|
void gfxSystemUnlock(void);
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
gThreadreturn gfxThreadWait(gThread thread);
|
gThreadreturn gfxThreadWait(gThread thread);
|
||||||
|
|
||||||
#endif /* GFX_USE_OS_OSX */
|
#endif /* GFX_USE_OS_OSX */
|
||||||
|
@ -133,59 +133,59 @@ void gfxSystemUnlock(void)
|
|||||||
_systemMutex.unlock();
|
_systemMutex.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex *pmutex)
|
void gfxMutexInit(gMutex *pmutex)
|
||||||
{
|
{
|
||||||
*pmutex = new QMutex;
|
*pmutex = new QMutex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexDestroy(gfxMutex *pmutex)
|
void gfxMutexDestroy(gMutex *pmutex)
|
||||||
{
|
{
|
||||||
delete static_cast<QMutex*>(*pmutex);
|
delete static_cast<QMutex*>(*pmutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexEnter(gfxMutex *pmutex)
|
void gfxMutexEnter(gMutex *pmutex)
|
||||||
{
|
{
|
||||||
static_cast<QMutex*>(*pmutex)->lock();
|
static_cast<QMutex*>(*pmutex)->lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexExit(gfxMutex *pmutex)
|
void gfxMutexExit(gMutex *pmutex)
|
||||||
{
|
{
|
||||||
static_cast<QMutex*>(*pmutex)->unlock();
|
static_cast<QMutex*>(*pmutex)->unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit)
|
||||||
{
|
{
|
||||||
*psem = new QSemaphore(limit);
|
*psem = new QSemaphore(limit);
|
||||||
|
|
||||||
static_cast<QSemaphore*>(*psem)->release(val);
|
static_cast<QSemaphore*>(*psem)->release(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemDestroy(gfxSem *psem)
|
void gfxSemDestroy(gSem *psem)
|
||||||
{
|
{
|
||||||
delete static_cast<QSemaphore*>(*psem);
|
delete static_cast<QSemaphore*>(*psem);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
gBool gfxSemWait(gSem *psem, gDelay ms)
|
||||||
{
|
{
|
||||||
return static_cast<QSemaphore*>(*psem)->tryAcquire(1, ms);
|
return static_cast<QSemaphore*>(*psem)->tryAcquire(1, ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem *psem)
|
gBool gfxSemWaitI(gSem *psem)
|
||||||
{
|
{
|
||||||
return static_cast<QSemaphore*>(*psem)->tryAcquire(1);
|
return static_cast<QSemaphore*>(*psem)->tryAcquire(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem *psem)
|
void gfxSemSignal(gSem *psem)
|
||||||
{
|
{
|
||||||
static_cast<QSemaphore*>(*psem)->release(1);
|
static_cast<QSemaphore*>(*psem)->release(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem *psem)
|
void gfxSemSignalI(gSem *psem)
|
||||||
{
|
{
|
||||||
static_cast<QSemaphore*>(*psem)->release(1);
|
static_cast<QSemaphore*>(*psem)->release(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
||||||
{
|
{
|
||||||
Q_UNUSED(stackarea)
|
Q_UNUSED(stackarea)
|
||||||
|
|
||||||
|
@ -10,21 +10,21 @@
|
|||||||
|
|
||||||
#if GFX_USE_OS_QT
|
#if GFX_USE_OS_QT
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0]
|
#define GFX_THREAD_STACK(name, sz) gU8 name[0]
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever ((gDelay)-1)
|
#define gDelayForever ((gDelay)-1)
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow 2
|
#define gThreadpriorityLow 2
|
||||||
#define gThreadpriorityNormal 3
|
#define gThreadpriorityNormal 3
|
||||||
#define gThreadpriorityHigh 4
|
#define gThreadpriorityHigh 4
|
||||||
|
|
||||||
typedef int gTicks;
|
typedef int gTicks;
|
||||||
typedef int gDelay;
|
typedef int gDelay;
|
||||||
typedef void* gfxMutex;
|
typedef void* gMutex;
|
||||||
typedef void* gfxSem;
|
typedef void* gSem;
|
||||||
typedef int gSemcount;
|
typedef int gSemcount;
|
||||||
typedef int gThreadreturn;
|
typedef int gThreadreturn;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
@ -45,17 +45,17 @@ gTicks gfxSystemTicks(void);
|
|||||||
gTicks gfxMillisecondsToTicks(gDelay ms);
|
gTicks gfxMillisecondsToTicks(gDelay ms);
|
||||||
void gfxSystemLock(void);
|
void gfxSystemLock(void);
|
||||||
void gfxSystemUnlock(void);
|
void gfxSystemUnlock(void);
|
||||||
void gfxMutexInit(gfxMutex *pmutex);
|
void gfxMutexInit(gMutex *pmutex);
|
||||||
void gfxMutexDestroy(gfxMutex *pmutex);
|
void gfxMutexDestroy(gMutex *pmutex);
|
||||||
void gfxMutexEnter(gfxMutex *pmutex);
|
void gfxMutexEnter(gMutex *pmutex);
|
||||||
void gfxMutexExit(gfxMutex *pmutex);
|
void gfxMutexExit(gMutex *pmutex);
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
void gfxSemDestroy(gfxSem *psem);
|
void gfxSemDestroy(gSem *psem);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem *psem);
|
gBool gfxSemWaitI(gSem *psem);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gSem *psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
gThreadreturn gfxThreadWait(gThread thread);
|
gThreadreturn gfxThreadWait(gThread thread);
|
||||||
gThread gfxThreadMe(void);
|
gThread gfxThreadMe(void);
|
||||||
void gfxThreadClose(gThread thread);
|
void gfxThreadClose(gThread thread);
|
||||||
|
@ -59,7 +59,7 @@ void gfxSleepMicroseconds(gDelay us)
|
|||||||
raw_sleep(ticks);
|
raw_sleep(ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||||
{
|
{
|
||||||
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
|
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
|
||||||
if(!ticks)ticks=1;
|
if(!ticks)ticks=1;
|
||||||
@ -68,14 +68,14 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
|||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem* psem)
|
gBool gfxSemWaitI(gSem* psem)
|
||||||
{
|
{
|
||||||
if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
|
if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
|
||||||
return gTrue;
|
return gTrue;
|
||||||
return gFalse;
|
return gFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
||||||
{
|
{
|
||||||
RAW_U16 ret;
|
RAW_U16 ret;
|
||||||
gThread taskobj;
|
gThread taskobj;
|
||||||
|
@ -13,18 +13,18 @@ typedef gI32 gSemcount;
|
|||||||
typedef gU32 gThreadreturn;
|
typedef gU32 gThreadreturn;
|
||||||
typedef RAW_U8 gThreadpriority;
|
typedef RAW_U8 gThreadpriority;
|
||||||
|
|
||||||
#define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
|
#define gSemMaxCount RAW_SEMAPHORE_COUNT
|
||||||
#define gThreadpriorityLow (CONFIG_RAW_PRIO_MAX-2)
|
#define gThreadpriorityLow (CONFIG_RAW_PRIO_MAX-2)
|
||||||
#define gThreadpriorityNormal (CONFIG_RAW_PRIO_MAX/2)
|
#define gThreadpriorityNormal (CONFIG_RAW_PRIO_MAX/2)
|
||||||
#define gThreadpriorityHigh 1
|
#define gThreadpriorityHigh 1
|
||||||
|
|
||||||
typedef RAW_SEMAPHORE gfxSem;
|
typedef RAW_SEMAPHORE gSem;
|
||||||
typedef RAW_MUTEX gfxMutex;
|
typedef RAW_MUTEX gMutex;
|
||||||
typedef RAW_TASK_OBJ* gThread;
|
typedef RAW_TASK_OBJ* gThread;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
|
#define GFX_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gfxHalt(msg) for(;;)
|
#define gfxHalt(msg) for(;;)
|
||||||
#define gfxExit() for(;;)
|
#define gfxExit() for(;;)
|
||||||
@ -65,9 +65,9 @@ extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
|
|||||||
|
|
||||||
void gfxSleepMilliseconds(gDelay ms);
|
void gfxSleepMilliseconds(gDelay ms);
|
||||||
void gfxSleepMicroseconds(gDelay us);
|
void gfxSleepMicroseconds(gDelay us);
|
||||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem* psem);
|
gBool gfxSemWaitI(gSem* psem);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void gfxSystemUnlock(void) {
|
|||||||
ReleaseMutex(SystemMutex);
|
ReleaseMutex(SystemMutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
gBool gfxSemWait(gSem *psem, gDelay ms) {
|
||||||
return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
|
return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ typedef LONG (__stdcall *_NtQuerySemaphore)(
|
|||||||
);
|
);
|
||||||
|
|
||||||
/* - Left here simply because of its undocumented cleverness...
|
/* - Left here simply because of its undocumented cleverness...
|
||||||
gSemcount gfxSemCounter(gfxSem *pSem) {
|
gSemcount gfxSemCounter(gSem *pSem) {
|
||||||
static _NtQuerySemaphore NtQuerySemaphore;
|
static _NtQuerySemaphore NtQuerySemaphore;
|
||||||
struct _SEMAPHORE_BASIC_INFORMATION {
|
struct _SEMAPHORE_BASIC_INFORMATION {
|
||||||
ULONG CurrentCount;
|
ULONG CurrentCount;
|
||||||
@ -103,7 +103,7 @@ gSemcount gfxSemCounter(gfxSem *pSem) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param) {
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION(*fn,p), void *param) {
|
||||||
(void) stackarea;
|
(void) stackarea;
|
||||||
HANDLE thd;
|
HANDLE thd;
|
||||||
|
|
||||||
|
@ -31,19 +31,19 @@ typedef LONG gSemcount;
|
|||||||
typedef DWORD gThreadreturn;
|
typedef DWORD gThreadreturn;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1];
|
#define GFX_THREAD_STACK(name, sz) gU8 name[1];
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever INFINITE
|
#define gDelayForever INFINITE
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
|
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
|
||||||
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
|
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
|
||||||
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
|
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
|
||||||
|
|
||||||
typedef HANDLE gfxSem;
|
typedef HANDLE gSem;
|
||||||
typedef HANDLE gfxMutex;
|
typedef HANDLE gMutex;
|
||||||
typedef HANDLE gThread;
|
typedef HANDLE gThread;
|
||||||
|
|
||||||
#define gfxExit() ExitProcess(0)
|
#define gfxExit() ExitProcess(0)
|
||||||
@ -72,10 +72,10 @@ typedef HANDLE gThread;
|
|||||||
|
|
||||||
void gfxHalt(const char *msg);
|
void gfxHalt(const char *msg);
|
||||||
void gfxSleepMicroseconds(gDelay ms);
|
void gfxSleepMicroseconds(gDelay ms);
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
void gfxSystemLock(void);
|
void gfxSystemLock(void);
|
||||||
void gfxSystemUnlock(void);
|
void gfxSystemUnlock(void);
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION(*fn,p), void *param);
|
||||||
gThreadreturn gfxThreadWait(gThread thread);
|
gThreadreturn gfxThreadWait(gThread thread);
|
||||||
|
|
||||||
#endif /* GFX_USE_OS_WIN32 */
|
#endif /* GFX_USE_OS_WIN32 */
|
||||||
|
@ -26,11 +26,11 @@ void gfxSystemUnlock(void) {
|
|||||||
INTERRUPTS_ON();
|
INTERRUPTS_ON();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexInit(gfxMutex *pmutex) {
|
void gfxMutexInit(gMutex *pmutex) {
|
||||||
pmutex[0] = 0;
|
pmutex[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexEnter(gfxMutex *pmutex) {
|
void gfxMutexEnter(gMutex *pmutex) {
|
||||||
INTERRUPTS_OFF();
|
INTERRUPTS_OFF();
|
||||||
while (pmutex[0]) {
|
while (pmutex[0]) {
|
||||||
INTERRUPTS_ON();
|
INTERRUPTS_ON();
|
||||||
@ -41,16 +41,16 @@ void gfxMutexEnter(gfxMutex *pmutex) {
|
|||||||
INTERRUPTS_ON();
|
INTERRUPTS_ON();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxMutexExit(gfxMutex *pmutex) {
|
void gfxMutexExit(gMutex *pmutex) {
|
||||||
pmutex[0] = 0;
|
pmutex[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit) {
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit) {
|
||||||
psem->cnt = val;
|
psem->cnt = val;
|
||||||
psem->limit = limit;
|
psem->limit = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
gBool gfxSemWait(gSem *psem, gDelay ms) {
|
||||||
gTicks starttm, delay;
|
gTicks starttm, delay;
|
||||||
|
|
||||||
// Convert our delay to ticks
|
// Convert our delay to ticks
|
||||||
@ -90,20 +90,20 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
|||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
gBool gfxSemWaitI(gfxSem *psem) {
|
gBool gfxSemWaitI(gSem *psem) {
|
||||||
if (psem->cnt <= 0)
|
if (psem->cnt <= 0)
|
||||||
return gFalse;
|
return gFalse;
|
||||||
psem->cnt--;
|
psem->cnt--;
|
||||||
return gTrue;
|
return gTrue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignal(gfxSem *psem) {
|
void gfxSemSignal(gSem *psem) {
|
||||||
INTERRUPTS_OFF();
|
INTERRUPTS_OFF();
|
||||||
gfxSemSignalI(psem);
|
gfxSemSignalI(psem);
|
||||||
INTERRUPTS_ON();
|
INTERRUPTS_ON();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxSemSignalI(gfxSem *psem) {
|
void gfxSemSignalI(gSem *psem) {
|
||||||
if (psem->cnt < psem->limit)
|
if (psem->cnt < psem->limit)
|
||||||
psem->cnt++;
|
psem->cnt++;
|
||||||
}
|
}
|
||||||
@ -508,7 +508,7 @@ void gfxThreadExit(gThreadreturn ret) {
|
|||||||
// We never get back here as we didn't re-queue ourselves
|
// We never get back here as we didn't re-queue ourselves
|
||||||
}
|
}
|
||||||
|
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param) {
|
||||||
thread * t;
|
thread * t;
|
||||||
thread * me;
|
thread * me;
|
||||||
(void) prio;
|
(void) prio;
|
||||||
|
@ -30,13 +30,13 @@ typedef short gSemcount;
|
|||||||
typedef int gThreadreturn;
|
typedef int gThreadreturn;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[(sz) & ~3];
|
#define GFX_THREAD_STACK(name, sz) gU8 name[(sz) & ~3];
|
||||||
#define THREAD_RETURN(retval) return retval
|
#define gfxThreadReturn(retval) return retval
|
||||||
|
|
||||||
#define gDelayNone 0
|
#define gDelayNone 0
|
||||||
#define gDelayForever ((gDelay)-1)
|
#define gDelayForever ((gDelay)-1)
|
||||||
#define MAX_SEMAPHORE_COUNT 0x7FFF
|
#define gSemMaxCount 0x7FFF
|
||||||
#define gThreadpriorityLow 0
|
#define gThreadpriorityLow 0
|
||||||
#define gThreadpriorityNormal 1
|
#define gThreadpriorityNormal 1
|
||||||
#define gThreadpriorityHigh 2
|
#define gThreadpriorityHigh 2
|
||||||
@ -44,9 +44,9 @@ typedef int gThreadpriority;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
gSemcount cnt;
|
gSemcount cnt;
|
||||||
gSemcount limit;
|
gSemcount limit;
|
||||||
} gfxSem;
|
} gSem;
|
||||||
|
|
||||||
typedef gU32 gfxMutex;
|
typedef gU32 gMutex;
|
||||||
typedef void * gThread;
|
typedef void * gThread;
|
||||||
|
|
||||||
// Required timing functions - supplied by the user or the operating system
|
// Required timing functions - supplied by the user or the operating system
|
||||||
@ -63,21 +63,21 @@ void gfxSystemLock(void);
|
|||||||
void gfxSystemUnlock(void);
|
void gfxSystemUnlock(void);
|
||||||
|
|
||||||
// Mutexes
|
// Mutexes
|
||||||
void gfxMutexInit(gfxMutex *pmutex);
|
void gfxMutexInit(gMutex *pmutex);
|
||||||
#define gfxMutexDestroy(pmutex)
|
#define gfxMutexDestroy(pmutex)
|
||||||
void gfxMutexEnter(gfxMutex *pmutex);
|
void gfxMutexEnter(gMutex *pmutex);
|
||||||
void gfxMutexExit(gfxMutex *pmutex);
|
void gfxMutexExit(gMutex *pmutex);
|
||||||
|
|
||||||
// Semaphores
|
// Semaphores
|
||||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||||
#define gfxSemDestroy(psem)
|
#define gfxSemDestroy(psem)
|
||||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||||
gBool gfxSemWaitI(gfxSem *psem);
|
gBool gfxSemWaitI(gSem *psem);
|
||||||
void gfxSemSignal(gfxSem *psem);
|
void gfxSemSignal(gSem *psem);
|
||||||
void gfxSemSignalI(gfxSem *psem);
|
void gfxSemSignalI(gSem *psem);
|
||||||
|
|
||||||
// Threads
|
// Threads
|
||||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||||
#define gfxThreadClose(thread)
|
#define gfxThreadClose(thread)
|
||||||
gThreadreturn gfxThreadWait(gThread thread);
|
gThreadreturn gfxThreadWait(gThread thread);
|
||||||
gThread gfxThreadMe(void);
|
gThread gfxThreadMe(void);
|
||||||
|
@ -22,24 +22,22 @@ typedef u32_t gSemcount;
|
|||||||
typedef void gThreadreturn;
|
typedef void gThreadreturn;
|
||||||
typedef int gThreadpriority;
|
typedef int gThreadpriority;
|
||||||
|
|
||||||
#define DECLARE_THREAD_FUNCTION(fnName, param)\
|
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param, void* p2, void* p3)
|
||||||
gThreadreturn fnName(void* param, void* p2, void* p3)
|
|
||||||
|
|
||||||
#define DECLARE_THREAD_STACK(name, sz)\
|
#define GFX_THREAD_STACK(name, sz) K_THREAD_STACK_DEFINE(name, sz)
|
||||||
K_THREAD_STACK_DEFINE(name, sz)
|
|
||||||
|
|
||||||
#define THREAD_RETURN(retval) return
|
#define gfxThreadReturn(retval) return
|
||||||
|
|
||||||
#define gDelayNone K_NO_WAIT
|
#define gDelayNone K_NO_WAIT
|
||||||
#define gDelayForever K_FOREVER
|
#define gDelayForever K_FOREVER
|
||||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||||
#define gThreadpriorityLow CONFIG_NUM_PREEMPT_PRIORITIES-1
|
#define gThreadpriorityLow CONFIG_NUM_PREEMPT_PRIORITIES-1
|
||||||
#define gThreadpriorityNormal 1
|
#define gThreadpriorityNormal 1
|
||||||
#define gThreadpriorityHigh 0
|
#define gThreadpriorityHigh 0
|
||||||
|
|
||||||
typedef struct k_sem gfxSem;
|
typedef struct k_sem gSem;
|
||||||
|
|
||||||
typedef struct k_mutex gfxMutex;
|
typedef struct k_mutex gMutex;
|
||||||
|
|
||||||
typedef k_tid_t gThread;
|
typedef k_tid_t gThread;
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void _gqueueDeinit(void)
|
|||||||
#if GQUEUE_NEED_GSYNC
|
#if GQUEUE_NEED_GSYNC
|
||||||
void gfxQueueGSyncInit(gfxQueueGSync *pqueue) {
|
void gfxQueueGSyncInit(gfxQueueGSync *pqueue) {
|
||||||
pqueue->head = pqueue->tail = 0;
|
pqueue->head = pqueue->tail = 0;
|
||||||
gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
|
gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
|
||||||
}
|
}
|
||||||
void gfxQueueGSyncDeinit(gfxQueueGSync *pqueue) {
|
void gfxQueueGSyncDeinit(gfxQueueGSync *pqueue) {
|
||||||
pqueue->head = pqueue->tail = 0;
|
pqueue->head = pqueue->tail = 0;
|
||||||
@ -294,7 +294,7 @@ void _gqueueDeinit(void)
|
|||||||
#if GQUEUE_NEED_FSYNC
|
#if GQUEUE_NEED_FSYNC
|
||||||
void gfxQueueFSyncInit(gfxQueueFSync *pqueue) {
|
void gfxQueueFSyncInit(gfxQueueFSync *pqueue) {
|
||||||
pqueue->head = pqueue->tail = 0;
|
pqueue->head = pqueue->tail = 0;
|
||||||
gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
|
gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
|
||||||
}
|
}
|
||||||
void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue) {
|
void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue) {
|
||||||
while(gfxQueueFSyncGet(pqueue, gDelayNone));
|
while(gfxQueueFSyncGet(pqueue, gDelayNone));
|
||||||
|
@ -43,7 +43,7 @@ typedef struct gfxQueueASyncItem {
|
|||||||
|
|
||||||
typedef struct gfxQueueFSyncItem {
|
typedef struct gfxQueueFSyncItem {
|
||||||
struct gfxQueueFSyncItem *next;
|
struct gfxQueueFSyncItem *next;
|
||||||
gfxSem sem;
|
gSem sem;
|
||||||
} gfxQueueFSyncItem;
|
} gfxQueueFSyncItem;
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
@ -59,13 +59,13 @@ typedef struct gfxQueueASync {
|
|||||||
typedef struct gfxQueueGSync {
|
typedef struct gfxQueueGSync {
|
||||||
gfxQueueGSyncItem *head;
|
gfxQueueGSyncItem *head;
|
||||||
gfxQueueGSyncItem *tail;
|
gfxQueueGSyncItem *tail;
|
||||||
gfxSem sem;
|
gSem sem;
|
||||||
} gfxQueueGSync;
|
} gfxQueueGSync;
|
||||||
|
|
||||||
typedef struct gfxQueueFSync {
|
typedef struct gfxQueueFSync {
|
||||||
gfxQueueFSyncItem *head;
|
gfxQueueFSyncItem *head;
|
||||||
gfxQueueFSyncItem *tail;
|
gfxQueueFSyncItem *tail;
|
||||||
gfxSem sem;
|
gSem sem;
|
||||||
} gfxQueueFSync;
|
} gfxQueueFSync;
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
@ -18,18 +18,18 @@
|
|||||||
#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
|
#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
|
||||||
|
|
||||||
/* This mutex protects access to our tables */
|
/* This mutex protects access to our tables */
|
||||||
static gfxMutex mutex;
|
static gMutex mutex;
|
||||||
static gThread hThread = 0;
|
static gThread hThread = 0;
|
||||||
static GTimer *pTimerHead = 0;
|
static GTimer *pTimerHead = 0;
|
||||||
static gfxSem waitsem;
|
static gSem waitsem;
|
||||||
static gTicks ticks2ms;
|
static gTicks ticks2ms;
|
||||||
static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
|
static GFX_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
static GFX_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
||||||
GTimer *pt;
|
GTimer *pt;
|
||||||
gTicks tm;
|
gTicks tm;
|
||||||
gTicks nxtTimeout;
|
gTicks nxtTimeout;
|
||||||
@ -109,7 +109,7 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
|||||||
lastTime = tm;
|
lastTime = tm;
|
||||||
gfxMutexExit(&mutex);
|
gfxMutexExit(&mutex);
|
||||||
}
|
}
|
||||||
THREAD_RETURN(0);
|
gfxThreadReturn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _gtimerInit(void)
|
void _gtimerInit(void)
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#define MIN_WIN_WIDTH 1
|
#define MIN_WIN_WIDTH 1
|
||||||
#define MIN_WIN_HEIGHT 1
|
#define MIN_WIN_HEIGHT 1
|
||||||
|
|
||||||
static gfxMutex gmutex;
|
static gMutex gmutex;
|
||||||
|
|
||||||
void _gwmInit(void) {
|
void _gwmInit(void) {
|
||||||
gfxMutexInit(&gmutex);
|
gfxMutexInit(&gmutex);
|
||||||
@ -162,7 +162,7 @@
|
|||||||
extern const GWindowManager GNullWindowManager;
|
extern const GWindowManager GNullWindowManager;
|
||||||
GWindowManager * _GWINwm;
|
GWindowManager * _GWINwm;
|
||||||
gBool _gwinFlashState;
|
gBool _gwinFlashState;
|
||||||
static gfxSem gwinsem;
|
static gSem gwinsem;
|
||||||
static gfxQueueASync _GWINList;
|
static gfxQueueASync _GWINList;
|
||||||
#if GWIN_NEED_FLASHING
|
#if GWIN_NEED_FLASHING
|
||||||
static GTimer FlashTimer;
|
static GTimer FlashTimer;
|
||||||
|
Loading…
Reference in New Issue
Block a user