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 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 gThread to replace V2.x gfxThreadHandle
|
||||
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t
|
||||
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 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 gPoint to replace V2.x point and point_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 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 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 type gMemSize and config macro GFX_MEM_LT64K
|
||||
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
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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 DECLARE_THREAD_FUNCTION(notepadThread, param);
|
||||
static GFX_THREAD_FUNCTION(notepadThread, param);
|
||||
|
||||
// Custom drawing functions for the buttons
|
||||
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));
|
||||
}
|
||||
|
||||
static DECLARE_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
|
||||
static DECLARE_THREAD_FUNCTION(notepadThread, param) {
|
||||
static GFX_THREAD_STACK(waNotepadThread, NPAD_THD_WA_SIZE);
|
||||
static GFX_THREAD_FUNCTION(notepadThread, param) {
|
||||
|
||||
GEventMouse *pem;
|
||||
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
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* 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)))
|
||||
|
||||
/* 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 nMode = NCORE_MODE_DRAW;
|
||||
@ -127,7 +127,7 @@ static void draw_line(gCoord x0, gCoord y0, gCoord x1, gCoord y1) {
|
||||
}
|
||||
|
||||
/* Core thread */
|
||||
static DECLARE_THREAD_FUNCTION(ncoreDrawThread, msg) {
|
||||
static GFX_THREAD_FUNCTION(ncoreDrawThread, msg) {
|
||||
|
||||
GEventMouse ev, evPrev;
|
||||
gCoord dx, dy;
|
||||
|
@ -62,7 +62,7 @@ static gThread thread;
|
||||
#define FLOORCOLOR HTML2COLOR(0x606060)
|
||||
#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 minx, miny, maxx, maxy, winx, winy;
|
||||
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 zoom = 1.0f;
|
||||
(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);
|
||||
}
|
||||
|
||||
static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
|
||||
static GFX_THREAD_FUNCTION(thdJg10, msg) {
|
||||
(void)msg;
|
||||
gU16 x,y;
|
||||
while (!jg10GameOver) {
|
||||
@ -273,7 +273,7 @@ static DECLARE_THREAD_FUNCTION(thdJg10, msg) {
|
||||
}
|
||||
}
|
||||
}
|
||||
THREAD_RETURN(0);
|
||||
gfxThreadReturn(0);
|
||||
}
|
||||
|
||||
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;
|
||||
gU16 x,y, delay;
|
||||
@ -245,7 +245,7 @@ static DECLARE_THREAD_FUNCTION(thdMines, msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
THREAD_RETURN(0);
|
||||
gfxThreadReturn(0);
|
||||
}
|
||||
|
||||
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;
|
||||
gU8 i;
|
||||
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
|
||||
* any reply we need to send on the main thread.
|
||||
*/
|
||||
static DECLARE_THREAD_STACK(waNetThread, 512);
|
||||
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
||||
static GFX_THREAD_STACK(waNetThread, 512);
|
||||
static GFX_THREAD_FUNCTION(NetThread, param) {
|
||||
GEventMouse *pem;
|
||||
gU16 cmd[2];
|
||||
gU16 lbuttons;
|
||||
|
@ -270,8 +270,8 @@ static void ProcessEvent(GDisplay *g, xPriv *priv) {
|
||||
}
|
||||
|
||||
/* this is the X11 thread which keeps track of all events */
|
||||
static DECLARE_THREAD_STACK(waXThread, 1024);
|
||||
static DECLARE_THREAD_FUNCTION(ThreadX, arg) {
|
||||
static GFX_THREAD_STACK(waXThread, 1024);
|
||||
static GFX_THREAD_FUNCTION(ThreadX, arg) {
|
||||
GDisplay *g;
|
||||
(void)arg;
|
||||
|
||||
|
@ -168,7 +168,7 @@ typedef struct netPriv {
|
||||
static gThread hThread;
|
||||
|
||||
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
||||
static gfxMutex uGFXnetMutex;
|
||||
static gMutex uGFXnetMutex;
|
||||
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
||||
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
||||
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
||||
@ -318,8 +318,8 @@ static gBool rxdata(SOCKET_TYPE fd) {
|
||||
return gTrue;
|
||||
}
|
||||
|
||||
static DECLARE_THREAD_STACK(waNetThread, 512);
|
||||
static DECLARE_THREAD_FUNCTION(NetThread, param) {
|
||||
static GFX_THREAD_STACK(waNetThread, 512);
|
||||
static GFX_THREAD_FUNCTION(NetThread, param) {
|
||||
SOCKET_TYPE listenfd, fdmax, i, clientfd;
|
||||
socklen_t len;
|
||||
fd_set master, read_fds;
|
||||
|
@ -126,7 +126,7 @@ typedef struct netPriv {
|
||||
} netPriv;
|
||||
|
||||
#if GDISP_GFXNET_UNSAFE_SOCKETS
|
||||
static gfxMutex uGFXnetMutex;
|
||||
static gMutex uGFXnetMutex;
|
||||
#define MUTEX_INIT gfxMutexInit(&uGFXnetMutex)
|
||||
#define MUTEX_ENTER gfxMutexEnter(&uGFXnetMutex)
|
||||
#define MUTEX_EXIT gfxMutexExit(&uGFXnetMutex)
|
||||
|
2
ffconf.h
2
ffconf.h
@ -244,7 +244,7 @@
|
||||
|
||||
#define FF_FS_REENTRANT 0
|
||||
#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
|
||||
/ 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()
|
||||
|
@ -25,7 +25,7 @@ typedef struct NonTimerData_t {
|
||||
GADCCallbackFunction callback;
|
||||
union {
|
||||
void *param;
|
||||
gfxSem sigdone;
|
||||
gSem sigdone;
|
||||
};
|
||||
GadcNonTimerJob job;
|
||||
} NonTimerData;
|
||||
|
@ -13,8 +13,8 @@
|
||||
#include "gaudio_driver_play.h"
|
||||
|
||||
static gfxQueueASync playList;
|
||||
static gfxSem playComplete;
|
||||
static gU16 playFlags;
|
||||
static gSem playComplete;
|
||||
static gU16 playFlags;
|
||||
#define PLAYFLG_USEEVENTS 0x0001
|
||||
#define PLAYFLG_PLAYING 0x0002
|
||||
#define PLAYFLG_ISINIT 0x0004
|
||||
|
@ -338,7 +338,7 @@ struct GDisplay {
|
||||
|
||||
// Multithread Mutex
|
||||
#if GDISP_NEED_MULTITHREAD
|
||||
gfxMutex mutex;
|
||||
gMutex mutex;
|
||||
#endif
|
||||
|
||||
// Software clipping
|
||||
|
@ -20,7 +20,7 @@
|
||||
#define GLISTENER_WITHSOURCE 0x0002 // The source is currently using the buffer
|
||||
|
||||
/* This mutex protects access to our tables */
|
||||
static gfxMutex geventMutex;
|
||||
static gMutex geventMutex;
|
||||
|
||||
/* Our table of listener/source pairs */
|
||||
static GSourceListener Assignments[GEVENT_MAX_SOURCE_LISTENERS];
|
||||
@ -62,9 +62,9 @@ void _geventDeinit(void)
|
||||
}
|
||||
|
||||
void geventListenerInit(GListener *pl) {
|
||||
gfxSemInit(&pl->waitqueue, 0, MAX_SEMAPHORE_COUNT); // Next wait'er will block
|
||||
pl->callback = 0; // No callback active
|
||||
pl->event.type = GEVENT_NULL; // Always safety
|
||||
gfxSemInit(&pl->waitqueue, 0, gSemMaxCount); // Next wait'er will block
|
||||
pl->callback = 0; // No callback active
|
||||
pl->event.type = GEVENT_NULL; // Always safety
|
||||
pl->flags = 0;
|
||||
}
|
||||
|
||||
|
@ -55,8 +55,8 @@ typedef void (*GEventCallbackFn)(void *param, GEvent *pe);
|
||||
|
||||
// The Listener Object
|
||||
typedef struct GListener {
|
||||
gfxSem waitqueue; // Private: Semaphore for the listener to wait on.
|
||||
gU16 flags; // Private: Flags for operation
|
||||
gSem waitqueue; // Private: Semaphore for the listener to wait on.
|
||||
gU16 flags; // Private: Flags for operation
|
||||
GEventCallbackFn callback; // Private: Call back Function
|
||||
void *param; // Private: Parameter for the callback function.
|
||||
GEvent event; // Public: The event object into which the event information is stored.
|
||||
|
@ -20,7 +20,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Static array of Synchronization Objects */
|
||||
/*------------------------------------------------------------------------*/
|
||||
static gfxSem ff_sem[_VOLUMES];
|
||||
static gSem ff_sem[_VOLUMES];
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
/* Create a Synchronization Object */
|
||||
@ -28,7 +28,7 @@
|
||||
int ff_cre_syncobj(BYTE vol, _SYNC_t *sobj)
|
||||
{
|
||||
*sobj = ff_sem[vol];
|
||||
gfxSemInit(sobj, 1, MAX_SEMAPHORE_COUNT);
|
||||
gfxSemInit(sobj, 1, gSemMaxCount);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -38,7 +38,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
int ff_del_syncobj(_SYNC_t sobj)
|
||||
{
|
||||
gfxSemDestroy( (gfxSem*)&sobj );
|
||||
gfxSemDestroy( (gSem*)&sobj );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -48,7 +48,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
int ff_req_grant(_SYNC_t sobj)
|
||||
{
|
||||
if (gfxSemWait( (gfxSem*)&sobj, (gDelay)_FS_TIMEOUT) )
|
||||
if (gfxSemWait( (gSem*)&sobj, (gDelay)_FS_TIMEOUT) )
|
||||
return gTrue;
|
||||
return gFalse;
|
||||
}
|
||||
@ -58,7 +58,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
void ff_rel_grant(_SYNC_t sobj)
|
||||
{
|
||||
gfxSemSignal( (gfxSem*)&sobj );
|
||||
gfxSemSignal( (gSem*)&sobj );
|
||||
}
|
||||
#endif /* _FS_REENTRANT */
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
* @note GFX_TYPE_64 is set to GFXON or GFXOFF by the compiler detector. It is not a user configuration macro.
|
||||
* @{
|
||||
*/
|
||||
typedef long long gI64;
|
||||
typedef long long gI64;
|
||||
typedef unsigned long long gU64;
|
||||
/** @} */
|
||||
|
||||
@ -70,7 +70,7 @@
|
||||
* @param[in] fnName The name of 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
|
||||
@ -82,17 +82,7 @@
|
||||
* Many platforms will round the size to ensure correct stack alignment.
|
||||
* Other platforms may entirely ignore the suggested size.
|
||||
*/
|
||||
#define DECLARE_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
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[sz];
|
||||
|
||||
/**
|
||||
* @name Various platform (and operating system) constants
|
||||
@ -101,7 +91,7 @@
|
||||
*/
|
||||
#define gDelayNone 0
|
||||
#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 gThreadpriorityNormal 1
|
||||
#define gThreadpriorityHigh 2
|
||||
@ -111,13 +101,13 @@
|
||||
* @brief A semaphore
|
||||
* @note Your operating system will have a proper definition for this structure
|
||||
*/
|
||||
typedef struct {} gfxSem;
|
||||
typedef struct {} gSem;
|
||||
|
||||
/**
|
||||
* @brief A mutex
|
||||
* @note Your operating system will have a proper definition for this structure
|
||||
*/
|
||||
typedef struct {} gfxMutex;
|
||||
typedef struct {} gMutex;
|
||||
|
||||
/**
|
||||
* @brief A thread handle
|
||||
@ -297,7 +287,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxMutexInit(gfxMutex *pmutex);
|
||||
void gfxMutexInit(gMutex *pmutex);
|
||||
|
||||
/**
|
||||
* @brief Destroy a Mutex.
|
||||
@ -306,7 +296,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxMutexDestroy(gfxMutex *pmutex);
|
||||
void gfxMutexDestroy(gMutex *pmutex);
|
||||
|
||||
/**
|
||||
* @brief Enter the critical code region protected by the mutex.
|
||||
@ -316,7 +306,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxMutexEnter(gfxMutex *pmutex);
|
||||
void gfxMutexEnter(gMutex *pmutex);
|
||||
|
||||
/**
|
||||
* @brief Exit the critical code region protected by the mutex.
|
||||
@ -326,7 +316,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxMutexExit(gfxMutex *pmutex);
|
||||
void gfxMutexExit(gMutex *pmutex);
|
||||
|
||||
/**
|
||||
* @brief Initialise a Counted Semaphore
|
||||
@ -344,7 +334,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
|
||||
/**
|
||||
* @brief Destroy a Counted Semaphore
|
||||
@ -355,7 +345,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
|
||||
/**
|
||||
* @brief Wait on a semaphore
|
||||
@ -368,7 +358,7 @@
|
||||
*
|
||||
* @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
|
||||
@ -380,7 +370,7 @@
|
||||
* @iclass
|
||||
* @api
|
||||
*/
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
gBool gfxSemWaitI(gSem *psem);
|
||||
|
||||
/**
|
||||
* @brief Signal a semaphore
|
||||
@ -392,7 +382,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
|
||||
/**
|
||||
* @brief Signal a semaphore
|
||||
@ -405,7 +395,7 @@
|
||||
* @iclass
|
||||
* @api
|
||||
*/
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
void gfxSemSignalI(gSem *psem);
|
||||
|
||||
/**
|
||||
* @brief Start a new thread.
|
||||
@ -420,7 +410,7 @@
|
||||
*
|
||||
* @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.
|
||||
@ -453,6 +443,17 @@
|
||||
*/
|
||||
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
|
||||
* (without any of the documentation overheads) is in the files below.
|
||||
@ -502,11 +503,17 @@
|
||||
#endif
|
||||
typedef gTicks systemticks_t;
|
||||
typedef gThread gfxThreadHandle;
|
||||
#define DECLARE_THREAD_FUNCTION GFX_THREAD_FUNCTION
|
||||
#define DECLARE_THREAD_STACK GFX_THREAD_STACK
|
||||
typedef gThreadreturn threadreturn_t;
|
||||
#define THREAD_RETURN gfxThreadReturn
|
||||
typedef gThreadpriority threadpriority_t;
|
||||
#define LOW_PRIORITY gThreadpriorityLow
|
||||
#define NORMAL_PRIORITY gThreadpriorityNormal
|
||||
#define HIGH_PRIORITY gThreadpriorityHigh
|
||||
typedef gSem gfxSem;
|
||||
#define MAX_SEMAPHORE_COUNT gSemMaxCount
|
||||
typedef gMutex gfxMutex;
|
||||
#endif
|
||||
|
||||
#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)
|
||||
val = limit;
|
||||
@ -113,12 +113,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem *psem)
|
||||
void gfxSemDestroy(gSem *psem)
|
||||
{
|
||||
chSemReset(&psem->sem, 1);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms)
|
||||
{
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
switch(ms) {
|
||||
@ -135,7 +135,7 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
||||
#endif
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem *psem)
|
||||
gBool gfxSemWaitI(gSem *psem)
|
||||
{
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
if (psem->sem.s_cnt <= 0)
|
||||
@ -148,7 +148,7 @@ gBool gfxSemWaitI(gfxSem *psem)
|
||||
return gTrue;
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *psem)
|
||||
void gfxSemSignal(gSem *psem)
|
||||
{
|
||||
chSysLock();
|
||||
|
||||
@ -164,7 +164,7 @@ void gfxSemSignal(gfxSem *psem)
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem *psem)
|
||||
void gfxSemSignalI(gSem *psem)
|
||||
{
|
||||
#if CH_KERNEL_MAJOR <= 3
|
||||
if (psem->sem.s_cnt < psem->limit)
|
||||
@ -175,7 +175,7 @@ void gfxSemSignalI(gfxSem *psem)
|
||||
#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 (!stacksz) stacksz = 256;
|
||||
|
@ -38,33 +38,33 @@ typedef cnt_t gSemcount;
|
||||
typedef msg_t gThreadreturn;
|
||||
typedef tprio_t gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow LOWPRIO
|
||||
#define gThreadpriorityNormal NORMALPRIO
|
||||
#define gThreadpriorityHigh HIGHPRIO
|
||||
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow LOWPRIO
|
||||
#define gThreadpriorityNormal NORMALPRIO
|
||||
#define gThreadpriorityHigh HIGHPRIO
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
typedef struct {
|
||||
Semaphore sem;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
|
||||
typedef Mutex gfxMutex;
|
||||
typedef Mutex gMutex;
|
||||
typedef Thread* gThread;
|
||||
#else
|
||||
#undef DECLARE_THREAD_STACK
|
||||
#define DECLARE_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
||||
#undef GFX_THREAD_STACK
|
||||
#define GFX_THREAD_STACK(a, b) THD_WORKING_AREA(a, b)
|
||||
|
||||
typedef struct {
|
||||
semaphore_t sem;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
|
||||
typedef mutex_t gfxMutex;
|
||||
typedef mutex_t gMutex;
|
||||
typedef thread_t* gThread;
|
||||
#endif
|
||||
|
||||
@ -104,13 +104,13 @@ typedef tprio_t gThreadpriority;
|
||||
void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
void gfxSleepMicroseconds(gDelay ms);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem *psem);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
void gfxSemSignalI(gSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
#define gfxThreadWait(thread) chThdWait(thread)
|
||||
#define gfxThreadMe() chThdSelf()
|
||||
#define gfxThreadClose(thread) (void)thread
|
||||
|
@ -38,7 +38,7 @@ void _gosDeinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void gfxMutexInit(gfxMutex* pmutex)
|
||||
void gfxMutexInit(gMutex* pmutex)
|
||||
{
|
||||
osMutexDef_t def;
|
||||
def.mutex = pmutex->mutex;
|
||||
@ -46,7 +46,7 @@ void gfxMutexInit(gfxMutex* pmutex)
|
||||
pmutex->id = osMutexCreate(&def);
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
osSemaphoreDef_t def;
|
||||
def.semaphore = psem->semaphore;
|
||||
@ -56,12 +56,12 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
psem->id = osSemaphoreCreate(&def, val);
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem* psem)
|
||||
void gfxSemDestroy(gSem* psem)
|
||||
{
|
||||
osSemaphoreDelete(psem->id);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||
{
|
||||
if (osSemaphoreWait(psem->id, ms) > 0) {
|
||||
psem->available++;
|
||||
@ -70,17 +70,17 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
return gFalse;
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem* psem)
|
||||
gBool gfxSemWaitI(gSem* psem)
|
||||
{
|
||||
return gfxSemWait(psem, 0);
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem* psem)
|
||||
void gfxSemSignal(gSem* psem)
|
||||
{
|
||||
gfxSemSignalI(psem);
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem* psem)
|
||||
void gfxSemSignalI(gSem* psem)
|
||||
{
|
||||
if (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;
|
||||
|
||||
|
@ -27,33 +27,33 @@
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever osWaitForever
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gTicks;
|
||||
typedef gU16 gSemcount;
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gTicks;
|
||||
typedef gU16 gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef osPriority gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
|
||||
#define gSemMaxCount osFeature_Semaphore
|
||||
#define gThreadpriorityLow osPriorityLow
|
||||
#define gThreadpriorityNormal osPriorityNormal
|
||||
#define gThreadpriorityNormal osPriorityNormal
|
||||
#define gThreadpriorityHigh osPriorityHigh
|
||||
|
||||
typedef struct gfxSem {
|
||||
typedef struct gSem {
|
||||
gU32 semaphore[2];
|
||||
osSemaphoreId id;
|
||||
gSemcount available;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
|
||||
typedef struct gfxMutex {
|
||||
typedef struct gMutex {
|
||||
gU32 mutex[4];
|
||||
osMutexId id;
|
||||
} gfxMutex;
|
||||
} gMutex;
|
||||
|
||||
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 DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define THREAD_RETURN(retval)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define gfxThreadReturn(retval) return
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Function declarations. */
|
||||
@ -67,19 +67,19 @@ typedef osThreadId gThread;
|
||||
#define gfxSystemUnlock() osKernelStart()
|
||||
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
||||
|
||||
void gfxMutexInit(gfxMutex* pmutex);
|
||||
void gfxMutexInit(gMutex* pmutex);
|
||||
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
|
||||
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, gDelayForever)
|
||||
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
|
||||
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem* psem);
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem* psem);
|
||||
void gfxSemSignal(gfxSem* psem);
|
||||
void gfxSemSignalI(gfxSem* psem);
|
||||
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem* psem);
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem* psem);
|
||||
void gfxSemSignal(gSem* 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 gfxThreadMe() osThreadGetId()
|
||||
#define gfxThreadClose(thread) {}
|
||||
|
@ -31,7 +31,7 @@ void _gosInit(void)
|
||||
}
|
||||
|
||||
#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;
|
||||
uGFXMain();
|
||||
}
|
||||
@ -59,24 +59,24 @@ void _gosDeinit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void gfxMutexInit(gfxMutex* pmutex)
|
||||
void gfxMutexInit(gMutex* pmutex)
|
||||
{
|
||||
*pmutex = osMutexNew(NULL);
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
*psem = osSemaphoreNew(limit, val, NULL);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||
{
|
||||
if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK)
|
||||
return gTrue;
|
||||
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;
|
||||
|
||||
|
@ -27,26 +27,26 @@
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever osWaitForever
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gTicks;
|
||||
typedef gU16 gSemcount;
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gTicks;
|
||||
typedef gU16 gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef osPriority_t gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT 65535UL
|
||||
#define gSemMaxCount 65535UL
|
||||
#define gThreadpriorityLow osPriorityLow
|
||||
#define gThreadpriorityNormal osPriorityNormal
|
||||
#define gThreadpriorityNormal osPriorityNormal
|
||||
#define gThreadpriorityHigh osPriorityHigh
|
||||
|
||||
typedef osSemaphoreId_t gfxSem;
|
||||
typedef osSemaphoreId_t gSem;
|
||||
|
||||
typedef osMutexId_t gfxMutex;
|
||||
typedef osMutexId_t gMutex;
|
||||
|
||||
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 DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define THREAD_RETURN(retval)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define gfxThreadReturn(retval) return
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Function declarations. */
|
||||
@ -60,19 +60,19 @@ typedef osThreadId_t gThread;
|
||||
#define gfxSystemUnlock() osKernelUnlock()
|
||||
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
||||
|
||||
void gfxMutexInit(gfxMutex* pmutex);
|
||||
void gfxMutexInit(gMutex* pmutex);
|
||||
#define gfxMutexDestroy(pmutex) osMutexDelete(*(pmutex))
|
||||
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), gDelayForever)
|
||||
#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))
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||
#define gfxSemWaitI(psem) gfxSemWait((psem), 0)
|
||||
#define gfxSemSignal(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 gfxThreadMe() osThreadGetId()
|
||||
#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)
|
||||
val = limit;
|
||||
@ -59,12 +59,12 @@ void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
||||
cyg_semaphore_init(&psem->sem, val);
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem *psem)
|
||||
void gfxSemDestroy(gSem *psem)
|
||||
{
|
||||
cyg_semaphore_destroy(&psem->sem);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
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);
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *psem)
|
||||
void gfxSemSignal(gSem *psem)
|
||||
{
|
||||
if (psem->limit == MAX_SEMAPHORE_COUNT)
|
||||
if (psem->limit == gSemMaxCount)
|
||||
cyg_semaphore_post(&psem->sem);
|
||||
else {
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
|
@ -28,21 +28,21 @@ typedef void gThreadreturn;
|
||||
typedef cyg_addrword_t gThreadpriority;
|
||||
typedef cyg_handle_t gThread;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF
|
||||
#define gThreadpriorityLow (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
|
||||
#define gThreadpriorityNormal (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
|
||||
#define gThreadpriorityHigh 0
|
||||
#define gSemMaxCount 0x7FFFFFFF
|
||||
#define gThreadpriorityLow (CYGNUM_KERNEL_SCHED_PRIORITIES-2)
|
||||
#define gThreadpriorityNormal (CYGNUM_KERNEL_SCHED_PRIORITIES/2)
|
||||
#define gThreadpriorityHigh 0
|
||||
|
||||
#define DECLARE_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 THREAD_RETURN(retval)
|
||||
#define GFX_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(cyg_addrword_t param)
|
||||
#define gfxThreadReturn(retval) return
|
||||
|
||||
typedef struct {
|
||||
cyg_sem_t sem;
|
||||
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 gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex)
|
||||
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem *psem);
|
||||
void gfxSemSignal(gSem *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 gfxThreadMe() cyg_thread_self()
|
||||
#define gfxThreadClose(thread) (void)thread
|
||||
|
@ -42,7 +42,7 @@ void _gosInit(void)
|
||||
}
|
||||
|
||||
#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;
|
||||
uGFXMain();
|
||||
}
|
||||
@ -98,7 +98,7 @@ void gfxSleepMicroseconds(gDelay ms)
|
||||
// vUsDelay(ms%1000);
|
||||
}
|
||||
|
||||
void gfxMutexInit(gfxMutex *pmutex)
|
||||
void gfxMutexInit(gMutex *pmutex)
|
||||
{
|
||||
*pmutex = xSemaphoreCreateMutex();
|
||||
#if GFX_FREERTOS_USE_TRACE
|
||||
@ -106,7 +106,7 @@ void gfxMutexInit(gfxMutex *pmutex)
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
void gfxSemInit(gSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
if (val > limit)
|
||||
val = limit;
|
||||
@ -117,14 +117,14 @@ void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
#endif
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||
{
|
||||
if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS)
|
||||
return gTrue;
|
||||
return gFalse;
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem* psem)
|
||||
gBool gfxSemWaitI(gSem* psem)
|
||||
{
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
@ -133,20 +133,20 @@ gBool gfxSemWaitI(gfxSem* psem)
|
||||
return gFalse;
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem* psem)
|
||||
void gfxSemSignal(gSem* psem)
|
||||
{
|
||||
xSemaphoreGive(*psem);
|
||||
taskYIELD();
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem* psem)
|
||||
void gfxSemSignalI(gSem* psem)
|
||||
{
|
||||
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
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;
|
||||
(void) stackarea;
|
||||
|
@ -26,24 +26,24 @@
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gDelay;
|
||||
typedef portTickType gTicks;
|
||||
typedef gI32 gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
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 gThreadpriorityNormal configMAX_PRIORITIES/2
|
||||
#define gThreadpriorityNormal configMAX_PRIORITIES/2
|
||||
#define gThreadpriorityHigh configMAX_PRIORITIES-1
|
||||
|
||||
/* FreeRTOS will allocate the stack when creating the thread */
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1]
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define THREAD_RETURN(retval)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[1]
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define gfxThreadReturn(retval) return
|
||||
|
||||
typedef xSemaphoreHandle gfxSem;
|
||||
typedef xSemaphoreHandle gfxMutex;
|
||||
typedef xSemaphoreHandle gSem;
|
||||
typedef xSemaphoreHandle gMutex;
|
||||
typedef xTaskHandle gThread;
|
||||
|
||||
/*===========================================================================*/
|
||||
@ -60,7 +60,7 @@ typedef xTaskHandle gThread;
|
||||
#define gfxSystemLock() taskENTER_CRITICAL()
|
||||
#define gfxSystemUnlock() taskEXIT_CRITICAL()
|
||||
|
||||
void gfxMutexInit(gfxMutex* s);
|
||||
void gfxMutexInit(gMutex* s);
|
||||
#define gfxMutexDestroy(pmutex) vSemaphoreDelete(*(pmutex))
|
||||
#define gfxMutexEnter(pmutex) xSemaphoreTake(*(pmutex),portMAX_DELAY)
|
||||
#define gfxMutexExit(pmutex) xSemaphoreGive(*(pmutex))
|
||||
@ -69,13 +69,13 @@ void *gfxRealloc(void *ptr, gMemSize oldsz, gMemSize newsz);
|
||||
void gfxSleepMilliseconds(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))
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem* psem);
|
||||
void gfxSemSignal(gfxSem* psem);
|
||||
void gfxSemSignalI(gfxSem* psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem* psem);
|
||||
void gfxSemSignal(gSem* psem);
|
||||
void gfxSemSignalI(gSem* psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
|
||||
#define gfxThreadMe() xTaskGetCurrentTaskHandle()
|
||||
#if INCLUDE_eTaskGetState == 1
|
||||
|
@ -25,7 +25,7 @@
|
||||
#define linuxyield() pthread_yield()
|
||||
#endif
|
||||
|
||||
static gfxMutex SystemMutex;
|
||||
static gMutex SystemMutex;
|
||||
|
||||
void _gosInit(void)
|
||||
{
|
||||
@ -109,7 +109,7 @@ gTicks gfxSystemTicks(void) {
|
||||
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;
|
||||
(void) stackarea;
|
||||
(void) stacksz;
|
||||
@ -138,14 +138,14 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
||||
}
|
||||
|
||||
#if GFX_USE_POSIX_SEMAPHORES
|
||||
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
||||
void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
|
||||
pSem->max = limit;
|
||||
sem_init(&pSem->sem, 0, val);
|
||||
}
|
||||
void gfxSemDestroy(gfxSem *pSem) {
|
||||
void gfxSemDestroy(gSem *pSem) {
|
||||
sem_destroy(&pSem->sem);
|
||||
}
|
||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
||||
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||
switch (ms) {
|
||||
case gDelayForever:
|
||||
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;
|
||||
|
||||
res = 0;
|
||||
@ -173,7 +173,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
||||
sem_post(&pSem->sem);
|
||||
}
|
||||
#else
|
||||
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
||||
void gfxSemInit(gSem *pSem, gSemcount val, gSemcount limit) {
|
||||
pthread_mutex_init(&pSem->mtx, 0);
|
||||
pthread_cond_init(&pSem->cond, 0);
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
@ -181,11 +181,11 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
||||
pSem->max = limit;
|
||||
pthread_mutex_unlock(&pSem->mtx);
|
||||
}
|
||||
void gfxSemDestroy(gfxSem *pSem) {
|
||||
void gfxSemDestroy(gSem *pSem) {
|
||||
pthread_mutex_destroy(&pSem->mtx);
|
||||
pthread_cond_destroy(&pSem->cond);
|
||||
}
|
||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
||||
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
|
||||
switch (ms) {
|
||||
@ -226,7 +226,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
||||
pthread_mutex_unlock(&pSem->mtx);
|
||||
return gTrue;
|
||||
}
|
||||
void gfxSemSignal(gfxSem *pSem) {
|
||||
void gfxSemSignal(gSem *pSem) {
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
|
||||
if (pSem->cnt < pSem->max) {
|
||||
|
@ -28,12 +28,12 @@ typedef void * gThreadreturn;
|
||||
typedef unsigned long gDelay;
|
||||
typedef pthread_t gThread;
|
||||
typedef int gThreadpriority;
|
||||
typedef gU32 gSemcount;
|
||||
typedef pthread_mutex_t gfxMutex;
|
||||
typedef gU32 gSemcount;
|
||||
typedef pthread_mutex_t gMutex;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0];
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[0];
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gfxExit() exit(0)
|
||||
#define gfxAlloc(sz) malloc(sz)
|
||||
@ -49,25 +49,25 @@ typedef pthread_mutex_t gfxMutex;
|
||||
#define gfxSemWaitI(psem) gfxSemWait(psem, gDelayNone)
|
||||
#define gfxSemSignalI(psem) gfxSemSignal(psem)
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
|
||||
#define gThreadpriorityLow 10
|
||||
#define gThreadpriorityNormal 0
|
||||
#define gThreadpriorityHigh -10
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define gSemMaxCount ((gSemcount)-1)
|
||||
#define gThreadpriorityLow 10
|
||||
#define gThreadpriorityNormal 0
|
||||
#define gThreadpriorityHigh -10
|
||||
|
||||
#if GFX_USE_POSIX_SEMAPHORES
|
||||
typedef struct gfxSem {
|
||||
typedef struct gSem {
|
||||
sem_t sem;
|
||||
gSemcount max;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
#else
|
||||
typedef struct gfxSem {
|
||||
typedef struct gSem {
|
||||
pthread_mutex_t mtx;
|
||||
pthread_cond_t cond;
|
||||
gSemcount cnt;
|
||||
gSemcount max;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
@ -81,11 +81,11 @@ void gfxSleepMicroseconds(gDelay ms);
|
||||
gTicks gfxSystemTicks(void);
|
||||
void gfxSystemLock(void);
|
||||
void gfxSystemUnlock(void);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gThreadreturn gfxThreadWait(gThread thread);
|
||||
|
||||
#endif /* GFX_USE_OS_LINUX */
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <mach/clock.h>
|
||||
#include <mach/mach.h>
|
||||
|
||||
static gfxMutex SystemMutex;
|
||||
static gMutex SystemMutex;
|
||||
|
||||
void _gosInit(void)
|
||||
{
|
||||
@ -92,7 +92,7 @@ gTicks gfxSystemTicks(void) {
|
||||
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;
|
||||
(void) stackarea;
|
||||
(void) stacksz;
|
||||
@ -118,7 +118,7 @@ gThreadreturn gfxThreadWait(gThread thread) {
|
||||
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_cond_init(&pSem->cond, 0);
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
@ -127,12 +127,12 @@ void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
|
||||
pthread_mutex_unlock(&pSem->mtx);
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem *pSem) {
|
||||
void gfxSemDestroy(gSem *pSem) {
|
||||
pthread_mutex_destroy(&pSem->mtx);
|
||||
pthread_cond_destroy(&pSem->cond);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
||||
gBool gfxSemWait(gSem *pSem, gDelay ms) {
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
switch (ms) {
|
||||
case gDelayForever:
|
||||
@ -171,7 +171,7 @@ gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
|
||||
return gTrue;
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *pSem) {
|
||||
void gfxSemSignal(gSem *pSem) {
|
||||
pthread_mutex_lock(&pSem->mtx);
|
||||
if (pSem->cnt < pSem->max) {
|
||||
pSem->cnt++;
|
||||
|
@ -19,12 +19,12 @@ typedef void * gThreadreturn;
|
||||
typedef unsigned long gDelay;
|
||||
typedef pthread_t gThread;
|
||||
typedef int gThreadpriority;
|
||||
typedef gU32 gSemcount;
|
||||
typedef pthread_mutex_t gfxMutex;
|
||||
typedef gU32 gSemcount;
|
||||
typedef pthread_mutex_t gMutex;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0];
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[0];
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gfxExit() exit(0)
|
||||
#define gfxAlloc(sz) malloc(sz)
|
||||
@ -43,17 +43,17 @@ typedef pthread_mutex_t gfxMutex;
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
|
||||
#define gThreadpriorityLow 10
|
||||
#define gThreadpriorityNormal 0
|
||||
#define gThreadpriorityHigh -10
|
||||
#define gSemMaxCount ((gSemcount)-1)
|
||||
#define gThreadpriorityLow 10
|
||||
#define gThreadpriorityNormal 0
|
||||
#define gThreadpriorityHigh -10
|
||||
|
||||
typedef struct gfxSem {
|
||||
typedef struct gSem {
|
||||
pthread_mutex_t mtx;
|
||||
pthread_cond_t cond;
|
||||
gSemcount cnt;
|
||||
gSemcount max;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Function declarations. */
|
||||
@ -65,11 +65,11 @@ void gfxSleepMicroseconds(gDelay ms);
|
||||
gTicks gfxSystemTicks(void);
|
||||
void gfxSystemLock(void);
|
||||
void gfxSystemUnlock(void);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gThreadreturn gfxThreadWait(gThread thread);
|
||||
|
||||
#endif /* GFX_USE_OS_OSX */
|
||||
|
@ -133,59 +133,59 @@ void gfxSystemUnlock(void)
|
||||
_systemMutex.unlock();
|
||||
}
|
||||
|
||||
void gfxMutexInit(gfxMutex *pmutex)
|
||||
void gfxMutexInit(gMutex *pmutex)
|
||||
{
|
||||
*pmutex = new QMutex;
|
||||
}
|
||||
|
||||
void gfxMutexDestroy(gfxMutex *pmutex)
|
||||
void gfxMutexDestroy(gMutex *pmutex)
|
||||
{
|
||||
delete static_cast<QMutex*>(*pmutex);
|
||||
}
|
||||
|
||||
void gfxMutexEnter(gfxMutex *pmutex)
|
||||
void gfxMutexEnter(gMutex *pmutex)
|
||||
{
|
||||
static_cast<QMutex*>(*pmutex)->lock();
|
||||
}
|
||||
|
||||
void gfxMutexExit(gfxMutex *pmutex)
|
||||
void gfxMutexExit(gMutex *pmutex)
|
||||
{
|
||||
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);
|
||||
|
||||
static_cast<QSemaphore*>(*psem)->release(val);
|
||||
}
|
||||
|
||||
void gfxSemDestroy(gfxSem *psem)
|
||||
void gfxSemDestroy(gSem *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);
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem *psem)
|
||||
gBool gfxSemWaitI(gSem *psem)
|
||||
{
|
||||
return static_cast<QSemaphore*>(*psem)->tryAcquire(1);
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *psem)
|
||||
void gfxSemSignal(gSem *psem)
|
||||
{
|
||||
static_cast<QSemaphore*>(*psem)->release(1);
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem *psem)
|
||||
void gfxSemSignalI(gSem *psem)
|
||||
{
|
||||
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)
|
||||
|
||||
|
@ -10,21 +10,21 @@
|
||||
|
||||
#if GFX_USE_OS_QT
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[0]
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[0]
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow 2
|
||||
#define gThreadpriorityNormal 3
|
||||
#define gThreadpriorityHigh 4
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow 2
|
||||
#define gThreadpriorityNormal 3
|
||||
#define gThreadpriorityHigh 4
|
||||
|
||||
typedef int gTicks;
|
||||
typedef int gDelay;
|
||||
typedef void* gfxMutex;
|
||||
typedef void* gfxSem;
|
||||
typedef void* gMutex;
|
||||
typedef void* gSem;
|
||||
typedef int gSemcount;
|
||||
typedef int gThreadreturn;
|
||||
typedef int gThreadpriority;
|
||||
@ -45,17 +45,17 @@ gTicks gfxSystemTicks(void);
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms);
|
||||
void gfxSystemLock(void);
|
||||
void gfxSystemUnlock(void);
|
||||
void gfxMutexInit(gfxMutex *pmutex);
|
||||
void gfxMutexDestroy(gfxMutex *pmutex);
|
||||
void gfxMutexEnter(gfxMutex *pmutex);
|
||||
void gfxMutexExit(gfxMutex *pmutex);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
void gfxMutexInit(gMutex *pmutex);
|
||||
void gfxMutexDestroy(gMutex *pmutex);
|
||||
void gfxMutexEnter(gMutex *pmutex);
|
||||
void gfxMutexExit(gMutex *pmutex);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem *psem);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
void gfxSemSignalI(gSem *psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gThreadreturn gfxThreadWait(gThread thread);
|
||||
gThread gfxThreadMe(void);
|
||||
void gfxThreadClose(gThread thread);
|
||||
|
@ -59,7 +59,7 @@ void gfxSleepMicroseconds(gDelay us)
|
||||
raw_sleep(ticks);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms)
|
||||
{
|
||||
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
|
||||
if(!ticks)ticks=1;
|
||||
@ -68,14 +68,14 @@ gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
return gFalse;
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem* psem)
|
||||
gBool gfxSemWaitI(gSem* psem)
|
||||
{
|
||||
if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
|
||||
return gTrue;
|
||||
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;
|
||||
gThread taskobj;
|
||||
|
@ -7,24 +7,24 @@
|
||||
|
||||
#define gDelayNone (RAW_NO_WAIT)
|
||||
#define gDelayForever (RAW_WAIT_FOREVER)
|
||||
typedef gU32 gDelay;
|
||||
typedef gU32 gDelay;
|
||||
typedef RAW_TICK_TYPE gTicks;
|
||||
typedef gI32 gSemcount;
|
||||
typedef gU32 gThreadreturn;
|
||||
typedef gU32 gThreadreturn;
|
||||
typedef RAW_U8 gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
|
||||
#define gSemMaxCount RAW_SEMAPHORE_COUNT
|
||||
#define gThreadpriorityLow (CONFIG_RAW_PRIO_MAX-2)
|
||||
#define gThreadpriorityNormal (CONFIG_RAW_PRIO_MAX/2)
|
||||
#define gThreadpriorityNormal (CONFIG_RAW_PRIO_MAX/2)
|
||||
#define gThreadpriorityHigh 1
|
||||
|
||||
typedef RAW_SEMAPHORE gfxSem;
|
||||
typedef RAW_MUTEX gfxMutex;
|
||||
typedef RAW_SEMAPHORE gSem;
|
||||
typedef RAW_MUTEX gMutex;
|
||||
typedef RAW_TASK_OBJ* gThread;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gfxHalt(msg) for(;;)
|
||||
#define gfxExit() for(;;)
|
||||
@ -65,9 +65,9 @@ extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
|
||||
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
void gfxSleepMicroseconds(gDelay us);
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem* psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gBool gfxSemWait(gSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem* psem);
|
||||
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -74,7 +74,7 @@ void gfxSystemUnlock(void) {
|
||||
ReleaseMutex(SystemMutex);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms) {
|
||||
return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ typedef LONG (__stdcall *_NtQuerySemaphore)(
|
||||
);
|
||||
|
||||
/* - Left here simply because of its undocumented cleverness...
|
||||
gSemcount gfxSemCounter(gfxSem *pSem) {
|
||||
gSemcount gfxSemCounter(gSem *pSem) {
|
||||
static _NtQuerySemaphore NtQuerySemaphore;
|
||||
struct _SEMAPHORE_BASIC_INFORMATION {
|
||||
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;
|
||||
HANDLE thd;
|
||||
|
||||
|
@ -31,19 +31,19 @@ typedef LONG gSemcount;
|
||||
typedef DWORD gThreadreturn;
|
||||
typedef int gThreadpriority;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[1];
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[1];
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever INFINITE
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
|
||||
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
|
||||
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
|
||||
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow THREAD_PRIORITY_BELOW_NORMAL
|
||||
#define gThreadpriorityNormal THREAD_PRIORITY_NORMAL
|
||||
#define gThreadpriorityHigh THREAD_PRIORITY_ABOVE_NORMAL
|
||||
|
||||
typedef HANDLE gfxSem;
|
||||
typedef HANDLE gfxMutex;
|
||||
typedef HANDLE gSem;
|
||||
typedef HANDLE gMutex;
|
||||
typedef HANDLE gThread;
|
||||
|
||||
#define gfxExit() ExitProcess(0)
|
||||
@ -72,10 +72,10 @@ typedef HANDLE gThread;
|
||||
|
||||
void gfxHalt(const char *msg);
|
||||
void gfxSleepMicroseconds(gDelay ms);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
void gfxSystemLock(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);
|
||||
|
||||
#endif /* GFX_USE_OS_WIN32 */
|
||||
|
@ -26,11 +26,11 @@ void gfxSystemUnlock(void) {
|
||||
INTERRUPTS_ON();
|
||||
}
|
||||
|
||||
void gfxMutexInit(gfxMutex *pmutex) {
|
||||
void gfxMutexInit(gMutex *pmutex) {
|
||||
pmutex[0] = 0;
|
||||
}
|
||||
|
||||
void gfxMutexEnter(gfxMutex *pmutex) {
|
||||
void gfxMutexEnter(gMutex *pmutex) {
|
||||
INTERRUPTS_OFF();
|
||||
while (pmutex[0]) {
|
||||
INTERRUPTS_ON();
|
||||
@ -41,16 +41,16 @@ void gfxMutexEnter(gfxMutex *pmutex) {
|
||||
INTERRUPTS_ON();
|
||||
}
|
||||
|
||||
void gfxMutexExit(gfxMutex *pmutex) {
|
||||
void gfxMutexExit(gMutex *pmutex) {
|
||||
pmutex[0] = 0;
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit) {
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit) {
|
||||
psem->cnt = val;
|
||||
psem->limit = limit;
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms) {
|
||||
gTicks starttm, delay;
|
||||
|
||||
// Convert our delay to ticks
|
||||
@ -90,20 +90,20 @@ gBool gfxSemWait(gfxSem *psem, gDelay ms) {
|
||||
return gTrue;
|
||||
}
|
||||
|
||||
gBool gfxSemWaitI(gfxSem *psem) {
|
||||
gBool gfxSemWaitI(gSem *psem) {
|
||||
if (psem->cnt <= 0)
|
||||
return gFalse;
|
||||
psem->cnt--;
|
||||
return gTrue;
|
||||
}
|
||||
|
||||
void gfxSemSignal(gfxSem *psem) {
|
||||
void gfxSemSignal(gSem *psem) {
|
||||
INTERRUPTS_OFF();
|
||||
gfxSemSignalI(psem);
|
||||
INTERRUPTS_ON();
|
||||
}
|
||||
|
||||
void gfxSemSignalI(gfxSem *psem) {
|
||||
void gfxSemSignalI(gSem *psem) {
|
||||
if (psem->cnt < psem->limit)
|
||||
psem->cnt++;
|
||||
}
|
||||
@ -508,7 +508,7 @@ void gfxThreadExit(gThreadreturn ret) {
|
||||
// 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 * me;
|
||||
(void) prio;
|
||||
|
@ -30,23 +30,23 @@ typedef short gSemcount;
|
||||
typedef int gThreadreturn;
|
||||
typedef int gThreadpriority;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define DECLARE_THREAD_STACK(name, sz) gU8 name[(sz) & ~3];
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define GFX_THREAD_STACK(name, sz) gU8 name[(sz) & ~3];
|
||||
#define gfxThreadReturn(retval) return retval
|
||||
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define MAX_SEMAPHORE_COUNT 0x7FFF
|
||||
#define gThreadpriorityLow 0
|
||||
#define gThreadpriorityNormal 1
|
||||
#define gThreadpriorityHigh 2
|
||||
#define gDelayNone 0
|
||||
#define gDelayForever ((gDelay)-1)
|
||||
#define gSemMaxCount 0x7FFF
|
||||
#define gThreadpriorityLow 0
|
||||
#define gThreadpriorityNormal 1
|
||||
#define gThreadpriorityHigh 2
|
||||
|
||||
typedef struct {
|
||||
gSemcount cnt;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
} gSem;
|
||||
|
||||
typedef gU32 gfxMutex;
|
||||
typedef gU32 gMutex;
|
||||
typedef void * gThread;
|
||||
|
||||
// Required timing functions - supplied by the user or the operating system
|
||||
@ -63,21 +63,21 @@ void gfxSystemLock(void);
|
||||
void gfxSystemUnlock(void);
|
||||
|
||||
// Mutexes
|
||||
void gfxMutexInit(gfxMutex *pmutex);
|
||||
void gfxMutexInit(gMutex *pmutex);
|
||||
#define gfxMutexDestroy(pmutex)
|
||||
void gfxMutexEnter(gfxMutex *pmutex);
|
||||
void gfxMutexExit(gfxMutex *pmutex);
|
||||
void gfxMutexEnter(gMutex *pmutex);
|
||||
void gfxMutexExit(gMutex *pmutex);
|
||||
|
||||
// Semaphores
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemInit(gSem *psem, gSemcount val, gSemcount limit);
|
||||
#define gfxSemDestroy(psem)
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
gBool gfxSemWait(gSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gSem *psem);
|
||||
void gfxSemSignal(gSem *psem);
|
||||
void gfxSemSignalI(gSem *psem);
|
||||
|
||||
// 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)
|
||||
gThreadreturn gfxThreadWait(gThread thread);
|
||||
gThread gfxThreadMe(void);
|
||||
|
@ -22,24 +22,22 @@ typedef u32_t gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef int gThreadpriority;
|
||||
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param)\
|
||||
gThreadreturn fnName(void* param, void* p2, void* p3)
|
||||
#define GFX_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param, void* p2, void* p3)
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz)\
|
||||
K_THREAD_STACK_DEFINE(name, sz)
|
||||
#define GFX_THREAD_STACK(name, sz) K_THREAD_STACK_DEFINE(name, sz)
|
||||
|
||||
#define THREAD_RETURN(retval) return
|
||||
#define gfxThreadReturn(retval) return
|
||||
|
||||
#define gDelayNone K_NO_WAIT
|
||||
#define gDelayForever K_FOREVER
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow CONFIG_NUM_PREEMPT_PRIORITIES-1
|
||||
#define gThreadpriorityNormal 1
|
||||
#define gThreadpriorityHigh 0
|
||||
#define gSemMaxCount ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define gThreadpriorityLow CONFIG_NUM_PREEMPT_PRIORITIES-1
|
||||
#define gThreadpriorityNormal 1
|
||||
#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;
|
||||
|
||||
|
@ -156,7 +156,7 @@ void _gqueueDeinit(void)
|
||||
#if GQUEUE_NEED_GSYNC
|
||||
void gfxQueueGSyncInit(gfxQueueGSync *pqueue) {
|
||||
pqueue->head = pqueue->tail = 0;
|
||||
gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
|
||||
gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
|
||||
}
|
||||
void gfxQueueGSyncDeinit(gfxQueueGSync *pqueue) {
|
||||
pqueue->head = pqueue->tail = 0;
|
||||
@ -294,7 +294,7 @@ void _gqueueDeinit(void)
|
||||
#if GQUEUE_NEED_FSYNC
|
||||
void gfxQueueFSyncInit(gfxQueueFSync *pqueue) {
|
||||
pqueue->head = pqueue->tail = 0;
|
||||
gfxSemInit(&pqueue->sem, 0, MAX_SEMAPHORE_COUNT);
|
||||
gfxSemInit(&pqueue->sem, 0, gSemMaxCount);
|
||||
}
|
||||
void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue) {
|
||||
while(gfxQueueFSyncGet(pqueue, gDelayNone));
|
||||
|
@ -43,7 +43,7 @@ typedef struct gfxQueueASyncItem {
|
||||
|
||||
typedef struct gfxQueueFSyncItem {
|
||||
struct gfxQueueFSyncItem *next;
|
||||
gfxSem sem;
|
||||
gSem sem;
|
||||
} gfxQueueFSyncItem;
|
||||
/** @} */
|
||||
|
||||
@ -59,13 +59,13 @@ typedef struct gfxQueueASync {
|
||||
typedef struct gfxQueueGSync {
|
||||
gfxQueueGSyncItem *head;
|
||||
gfxQueueGSyncItem *tail;
|
||||
gfxSem sem;
|
||||
gSem sem;
|
||||
} gfxQueueGSync;
|
||||
|
||||
typedef struct gfxQueueFSync {
|
||||
gfxQueueFSyncItem *head;
|
||||
gfxQueueFSyncItem *tail;
|
||||
gfxSem sem;
|
||||
gSem sem;
|
||||
} gfxQueueFSync;
|
||||
/** @} */
|
||||
|
||||
|
@ -18,18 +18,18 @@
|
||||
#define TimeIsWithin(x, start, end) ((end >= start && x >= start && x <= end) || (end < start && (x >= start || x <= end)))
|
||||
|
||||
/* This mutex protects access to our tables */
|
||||
static gfxMutex mutex;
|
||||
static gMutex mutex;
|
||||
static gThread hThread = 0;
|
||||
static GTimer *pTimerHead = 0;
|
||||
static gfxSem waitsem;
|
||||
static GTimer *pTimerHead = 0;
|
||||
static gSem waitsem;
|
||||
static gTicks ticks2ms;
|
||||
static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
|
||||
static GFX_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Driver local functions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
||||
static GFX_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
||||
GTimer *pt;
|
||||
gTicks tm;
|
||||
gTicks nxtTimeout;
|
||||
@ -109,7 +109,7 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
|
||||
lastTime = tm;
|
||||
gfxMutexExit(&mutex);
|
||||
}
|
||||
THREAD_RETURN(0);
|
||||
gfxThreadReturn(0);
|
||||
}
|
||||
|
||||
void _gtimerInit(void)
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define MIN_WIN_WIDTH 1
|
||||
#define MIN_WIN_HEIGHT 1
|
||||
|
||||
static gfxMutex gmutex;
|
||||
static gMutex gmutex;
|
||||
|
||||
void _gwmInit(void) {
|
||||
gfxMutexInit(&gmutex);
|
||||
@ -162,7 +162,7 @@
|
||||
extern const GWindowManager GNullWindowManager;
|
||||
GWindowManager * _GWINwm;
|
||||
gBool _gwinFlashState;
|
||||
static gfxSem gwinsem;
|
||||
static gSem gwinsem;
|
||||
static gfxQueueASync _GWINList;
|
||||
#if GWIN_NEED_FLASHING
|
||||
static GTimer FlashTimer;
|
||||
|
Loading…
Reference in New Issue
Block a user