FreeCalypso > hg > freecalypso-sw
changeset 362:03d034db09fa
OSL: os_SendToQueue() reconstructed
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Wed, 28 May 2014 19:54:10 +0000 |
parents | 62f850da5d49 |
children | 28a2965df6aa |
files | gsm-fw/gpf/osl/Makefile gsm-fw/gpf/osl/os_com_ir.c |
diffstat | 2 files changed, 28 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/gsm-fw/gpf/osl/Makefile Thu May 15 11:44:36 2014 +0000 +++ b/gsm-fw/gpf/osl/Makefile Wed May 28 19:54:10 2014 +0000 @@ -3,7 +3,7 @@ IOPTS= -DRUN_INT_RAM XOPTS= -DRUN_FLASH -mthumb -IOBJS= os_pro_ir.o +IOBJS= os_com_ir.o os_pro_ir.o XOBJS= os_com_fl.o os_isr.o os_pro_fl.o all: ${IOBJS} ${XOBJS}
--- a/gsm-fw/gpf/osl/os_com_ir.c Thu May 15 11:44:36 2014 +0000 +++ b/gsm-fw/gpf/osl/os_com_ir.c Wed May 28 19:54:10 2014 +0000 @@ -8,13 +8,13 @@ #include <string.h> #include "gpfconf.h" /* FreeCalypso addition */ #include "../../nucleus/nucleus.h" +#include "../../nucleus/tc_extr.h" /* not seen in original, but needed */ #include "typedefs.h" #include "os.h" #include "gdi.h" #include "os_types.h" #include "os_glob.h" -extern TC_PROTECT TCD_System_Protect; extern T_OS_COM_TABLE_ENTRY ComTable[]; extern unsigned os_tick_to_time_multiplier; @@ -27,9 +27,33 @@ ULONG Suspend, OS_QDATA *Msg) { T_OS_COM_TABLE_ENTRY *pTable; - T_QDATA_ELEMENT *pFreeElement, *pRet; + T_QDATA_ELEMENT *elem; + T_QUEUE *queue; int ret; NU_SEMAPHORE *CBPtr; - + USHORT watmark; + if (ComHandle <= 0 || ComHandle > MaxCommunications) + return(OS_INVALID_QUEUE); + pTable = ComTable + ComHandle; + if (!pTable->Name[0]) + return(OS_INVALID_QUEUE); + CBPtr = &pTable->FreeSemCB; + ret = ObtainSemaphoreCB(CBPtr, Suspend, 1); + if (ret == OS_ERROR || ret == OS_TIMEOUT) + return(ret); + TCT_System_Protect(); + elem = pTable->pFreeElement; + pTable->pFreeElement = elem->pNext; + bcopy(Msg, &elem->Data, sizeof(OS_QDATA)); + queue = &pTable->Queue[Priority - OS_MIN_PRIORITY]; + *queue->pWrite++ = &elem->Data; + if (queue->pWrite - queue->pStart >= pTable->Entries + 1) + queue->pWrite = queue->pStart; + watmark = pTable->Entries - CBPtr->sm_semaphore_count; + if (pTable->MaxUsed < watmark) + pTable->MaxUsed = watmark; + TCT_System_Unprotect(); + ReleaseSemaphoreCB(&pTable->UsedSemCB); + return(ret); }