Exemplo n.º 1
0
xc_result_t
query_add_import (
   query_t *queryPtr,
   import_t *importPtr
) {
   xc_result_t result;

   TRACE3 (("called with queryPtr=%p, importPtr=%p", queryPtr, importPtr));
   assert (queryPtr != NULL);
   assert (importPtr != NULL);

   /* Either link this import to the query if this is the first
    * one, otherwise to the previously created import. */
   if (queryPtr->lastImportPtr == NULL) {
      assert (queryPtr->firstImportPtr == NULL);
      TRACE4 (("adding first import to query %u", queryPtr->queryHandle));
      queryPtr->firstImportPtr = importPtr;
      queryPtr->lastImportPtr = importPtr;
   }
   else {
      /* TODO check if server component is already imported by this client
       * in which case, the import would be added to the front. */
      TRACE4 (("adding one more import to query %u", queryPtr->queryHandle));
      import_set_next (queryPtr->lastImportPtr, importPtr);
      queryPtr->lastImportPtr = importPtr;
   }

   /* Add import to client component */
   component_add_import (queryPtr->componentPtr, importPtr);
   result = XC_OK;

   TRACE3 (("exiting with result=%d", result));
   return result;
}
Exemplo n.º 2
0
component_t *
cache_open (
   bundle_t *bundlePtr,
   const char *name
) {
   XML_Parser parser;
   component_t *componentPtr = NULL;
   char *path = NULL;
   char buffer [256];
   xc_result_t result = XC_ERR_INVAL;
   int fd;

   TRACE3 (("called with bundlePtr=%p", bundlePtr));
   assert (bundlePtr != NULL);

   path = malloc (PATH_MAX);
   if (path != NULL) {
      sprintf (path, "%s/" CACHE_FOLDER "/" XC_HOST "/%s.xml", bundlePtr->path, name);
      fd = open (path, O_RDONLY);
      if (fd >= 0) {
         parser = XML_ParserCreate (NULL);
         if (parser != NULL) {
            componentPtr = component_new (bundlePtr);
            if (componentPtr != NULL) {
               sprintf (path, "%s/" CODE_FOLDER "/" XC_HOST "/%s", bundlePtr->path, name);
               componentPtr->path = path;
               path = NULL;
               XML_SetUserData (parser, componentPtr);
               XML_SetElementHandler (parser, handle_cache_start_tag, NULL);
               for (;;) {
                  int n = read (fd, buffer, sizeof (buffer));
                  if (n < 0) break;
                  if (!XML_Parse (parser, buffer, n, n==0)) break;
                  if (n==0) {
                     TRACE4 (("%s: loaded meta-data from cache!", componentPtr->name));
                     result = XC_OK;
                     break;
                  }
               }
            }
            XML_ParserFree (parser);
         }
         close (fd);
      }
      else {
         TRACE2 (("%s: failed to open", path));
      }
   }
   
   if (result != XC_OK) {
      if (componentPtr != NULL) {
         component_free (componentPtr);
         componentPtr = NULL;
      }
      free (path);
   }

   TRACE3 (("exiting with result=%p", componentPtr));
   return componentPtr;
}
Exemplo n.º 3
0
xc_result_t
query_next (
   query_t *queryPtr,
   xc_handle_t *importHandlePtr
) {
   import_t *importPtr;
   xc_result_t result;

   TRACE3 (("called with queryPtr=%p, importHandlePtr=%p", queryPtr, importHandlePtr));
   assert (queryPtr != NULL);
   pthread_mutex_lock (&lock);

   importPtr = queryPtr->importPtr;
   if (importPtr != NULL) {
      TRACE4 (("%u is the next import for query %u", importPtr->importHandle, queryPtr->queryHandle));
      if (importHandlePtr != NULL) {
         *importHandlePtr = importPtr->importHandle;
      }
      queryPtr->importPtr = import_get_next (importPtr);
      result = XC_OK;
   }
   else {
      TRACE2 (("no more imports for query %u", queryPtr->queryHandle));
      result = XC_ERR_NOENT;
   }

   pthread_mutex_unlock (&lock);
   TRACE3 (("exiting with result=%d", result));
   return result;
}
Exemplo n.º 4
0
void
query_free (
   query_t *queryPtr
) {

   TRACE3 (("called with queryPtr=%p", queryPtr));
   assert (queryPtr != NULL);

   /* Free imports that were not xCOM_Import'ed. */
   if (queryPtr->firstImportPtr != NULL) {
      TRACE4 (("freeing unused imports"));
      import_free_unused (queryPtr->firstImportPtr);
   }

   /* Free query handle. */
   if (queryPtr->queryHandle != XC_INVALID_HANDLE) {
      handle_dir_remove (queryHandles, queryPtr->queryHandle);
   }

   free (queryPtr->queriedPort);
   free (queryPtr->queriedComponent);
   free ((void *) queryPtr->queriedInterface.name);
   free (queryPtr->clientPortName);

   if (queryPtr->componentPtr != NULL) {
      component_unref (queryPtr->componentPtr);
   }

   free (queryPtr);

   TRACE3 (("exiting"));
}
Exemplo n.º 5
0
xc_result_t
query_get_candidates (
   query_t *queryPtr,
   unsigned int *matchCountPtr
) {
   struct ProvidedPortsList *listPtr;
   port_t *providerPtr;
   import_t *importPtr;
   unsigned int count = 0;
   xc_result_t result = XC_OK;

   TRACE3 (("called"));
   assert (queryPtr != NULL);

   /* Get all the providers of the queried interface. */
   listPtr = provided_ports_ref (queryPtr->queriedInterface.name);
   if (listPtr != NULL) {
      /* Check matching providers and add them as candidates. */
      providerPtr = (port_t *) XC_CLIST_HEAD (&listPtr->ports);
      while (!XC_CLIST_END (&listPtr->ports, providerPtr)) {
         if (query_match_provider (queryPtr, providerPtr)) {
            importPtr = import_new (
               queryPtr->queryHandle,
               queryPtr->componentHandle,
               queryPtr->clientPortName,
               providerPtr
            );
            if (importPtr != NULL) {
               result = query_add_import (queryPtr, importPtr);
               if (result == XC_OK) {
                  count ++;
               }
               else {
                  TRACE1 (("failed to add import to query %u (%d)", queryPtr->queryHandle, result));
                  import_free (importPtr);
                  break;
               }
            }
            else {
               result = XC_ERR_NOMEM;
               break;
            }
         }
         providerPtr = XC_CLIST_NEXT (providerPtr);
      }
      provided_ports_unref (listPtr);
   }

   if (result == XC_OK) {
      TRACE4 (("%u providers of '%s' found!", count, queryPtr->queriedInterface.name));
      queryPtr->importPtr = queryPtr->firstImportPtr;
      assert ((count == 0) || (queryPtr->importPtr != NULL));
      if (matchCountPtr != NULL) {
         *matchCountPtr = count;
      }
   }

   TRACE3 (("exiting with result=%d", result));
   return result;
}
Exemplo n.º 6
0
/****************************************************************************
 *                      cmdBld_CfgCoexActivity()
 ****************************************************************************
 * DESCRIPTION: Sets the CoexActivity table.
 *
 * OUTPUT:  None
 *
 * RETURNS: TI_OK or TI_NOK  pWlanParams->RtsThreshold
 ****************************************************************************/
TI_STATUS cmdBld_CfgCoexActivity (TI_HANDLE hCmdBld, TCoexActivity *pCoexActivity, void *fCb, TI_HANDLE hCb)
{
	TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;
	TWlanParams *pWlanParams = &DB_WLAN(hCmdBld);
	TCoexActivity *pSaveCoex = &pWlanParams->tWlanParamsCoexActivityTable.entry[0];
	int numOfElements = pWlanParams->tWlanParamsCoexActivityTable.numOfElements;
	int i;

	/* Check if to overwrite existing entry or put on last index */
	for (i=0; i<numOfElements; i++) {
		if ((pSaveCoex[i].activityId == pCoexActivity->activityId) && (pSaveCoex->coexIp == pCoexActivity->coexIp)) {
			break;
		}
	}

	TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "cmdBld_CfgCoexActivity: save Param %d in index %d, %d %d\n", 0, i, pCoexActivity->coexIp, pCoexActivity->activityId);
	/* save in WlanParams for recovery */
	pSaveCoex[i].coexIp          = pCoexActivity->coexIp;
	pSaveCoex[i].activityId      = pCoexActivity->activityId;
	pSaveCoex[i].defaultPriority = pCoexActivity->defaultPriority;
	pSaveCoex[i].raisedPriority  = pCoexActivity->raisedPriority;
	pSaveCoex[i].minService      = pCoexActivity->minService;
	pSaveCoex[i].maxService      = pCoexActivity->maxService;

	if (i == numOfElements) {
		/* no existing entry overwrite, increment number of elements */
		pWlanParams->tWlanParamsCoexActivityTable.numOfElements++;
	}

	return cmdBld_CfgIeCoexActivity (hCmdBld, pCoexActivity, fCb, hCb);
}
Exemplo n.º 7
0
/*
 * \brief	Called when a command timeout occur
 *
 * \param  hCmdQueue - Handle to CmdQueue
 * \return TI_OK
 *
 * \par Description
 *
 * \sa cmdQueue_Init, cmdMbox_TimeOut
 */
TI_STATUS cmdQueue_Error (TI_HANDLE hCmdQueue, TI_UINT32 command, TI_UINT32 status, void *param)
{
	TCmdQueue* pCmdQueue = (TCmdQueue*)hCmdQueue;

	if (status == CMD_STATUS_UNKNOWN_CMD)
	{
		TRACE1(pCmdQueue->hReport, REPORT_SEVERITY_ERROR , "cmdQueue_Error: Unknown Cmd  (%d)\n", command);
	}
	else if (status == CMD_STATUS_UNKNOWN_IE)
	{
		TRACE4( pCmdQueue->hReport, REPORT_SEVERITY_CONSOLE, "cmdQueue_Error: Unknown IE, cmdType : %d (%d) IE: %d (%d)\n",
		        command,
		        command,
		        (param) ? *((TI_UINT16 *) param) : 0,
		        (param) ? *((TI_UINT16 *) param) : 0
		      );

		WLAN_OS_REPORT(("cmdQueue_Error: Unknown IE, cmdType : %s (%d) IE: %s (%d)\n",
		                cmdQueue_GetCmdString (command),
		                command,
		                (param) ? cmdQueue_GetIEString (command, *((TI_UINT16 *) param)) : "",
		                *((TI_UINT16 *) param)));
	}
	else
	{
		TRACE1(pCmdQueue->hReport, REPORT_SEVERITY_ERROR , "cmdQueue_Error: CmdMbox status is %d\n", status);
	}

	if (status != CMD_STATUS_UNKNOWN_CMD && status != CMD_STATUS_UNKNOWN_IE)
	{
#ifdef TI_DBG

		TCmdQueueNode* pHead = &pCmdQueue->aCmdQueue[pCmdQueue->head];
		TI_UINT32 TimeStamp = os_timeStampMs(pCmdQueue->hOs);

		WLAN_OS_REPORT(("cmdQueue_Error: **ERROR**  Command Occured \n"
		                "                                        Cmd = %s %s, Len = %d \n"
		                "                                        NumOfCmd = %d\n"
		                "                                        MAC TimeStamp on timeout = %d\n",
		                cmdQueue_GetCmdString(pHead->cmdType),
		                (pHead->aParamsBuf) ? cmdQueue_GetIEString(pHead->cmdType, *(TI_UINT16 *)pHead->aParamsBuf) : "",
		                pHead->uParamsLen,
		                pCmdQueue->uNumberOfCommandInQueue,
		                TimeStamp));

		/* Print The command that was sent before the timeout occur */
		cmdQueue_PrintHistory(pCmdQueue, CMDQUEUE_HISTORY_DEPTH);

#endif /* TI_DBG */

		/* preform Recovery */
		if (pCmdQueue->fFailureCb)
		{
			pCmdQueue->fFailureCb (pCmdQueue->hFailureCb, TI_NOK);
		}
	}

	return TI_OK;
}
Exemplo n.º 8
0
/**
 * "connect" method handler
 */
STATIC XRpcElement* GWENG_MidpConnect(void* ctx, const XRpcContainer* param)
{
    /* decode parameters */
    const XRpcIntElement* sidParam =
        XRPC_GetIntElementByName(param, 
        ECMTGW_SEI_CONNECT_SID_PARAM);

    const XRpcIntElement* cidParam =
        XRPC_GetIntElementByName(param, 
        ECMTGW_SEI_CONNECT_CID_PARAM);

    const XRpcShortElement* portParam =
        XRPC_GetShortElementByName(param, 
        ECMTGW_SEI_CONNECT_PORT_PARAM);

    if (sidParam && cidParam && portParam) {
        MidpSession* midp;
        EcmtGateway* gw = ctx;
        I32u cid = XRPC_GetInt(cidParam);
        Port port = XRPC_GetShort(portParam);

        MidpSessionKey key;
        key.xrpcSid = XRPC_GetInt(sidParam);
        key.xrpcSession = XRPC_GetCurrentSession(gw->xrpc);

        TRACE4("GW: MidpConnect(%08x.%08x.%u, port %hu)\n",
            key.xrpcSession, key.xrpcSid, cid, port);

        MUTEX_Lock(&gw->mutex);
        midp = HASH_Get(&gw->midpSessionMap,&key);
        if (midp) {
            MidpConnection* conn = MEM_New(MidpConnection);
            if (conn) {
                memset(conn, 0, sizeof(*conn));
                conn->connId = cid;
                if (HASH_Put(&midp->connMap, (HashKey)cid, conn)) {
                    char pkt[ECMT_MIDP_DEBUG_CONNECT_SIZE];
                    GWENG_MidpFillHeader(pkt,midp->sid,ECMT_MIDP_DEBUG_OPCODE_CONNECT);
                    *((I32u*)(pkt+ECMT_MIDP_DEBUG_CONNECT_CID_OFFSET)) = htonl(cid);
                    *((I16u*)(pkt+ECMT_MIDP_DEBUG_CONNECT_PORT_OFFSET)) = htons(port);
                    GWENG_QueueAdd(gw->handsetQueue, KECMT_MIDP_DEBUG_PLUGIN_UID, pkt,
                        ECMT_MIDP_DEBUG_CONNECT_SIZE);
                    MUTEX_Unlock(&gw->mutex);
                    return NULL;
                }
                MEM_Free(conn);
            }
            GWENG_MidpResetConn(gw, midp, cid, False, True);
        } else {
            TRACE3("GW: unexpected MIDP connect (%08x.%08x.%u)\n",
                key.xrpcSession, key.xrpcSid, cid);
        }
        MUTEX_Unlock(&gw->mutex);
    }

    return NULL;
}
Exemplo n.º 9
0
/**
 * \\n
 * \date 23-December-2005\n
 * \brief Prints a measurement type request.\n
 *
 * Function Scope \e Public.\n
 * \param hMeasurementSRV - handle to the measurement SRV object.\n
 * \param pMsrTypeRequest - the measurement type request.\n
 */
void measurementSRVPrintTypeRequest( TI_HANDLE hMeasurementSRV, TMeasurementTypeRequest* pMsrTypeRequest )
{
#ifdef TI_DBG
	measurementSRV_t* pMeasurementSRV = (measurementSRV_t*)hMeasurementSRV;

	TRACE4( pMeasurementSRV->hReport, REPORT_SEVERITY_INFORMATION, "Measurement type request: type: %d, duration:%d, scan mode: %d, reserved: %d", pMsrTypeRequest->msrType, pMsrTypeRequest->duration, pMsrTypeRequest->scanMode, pMsrTypeRequest->reserved);

#endif /* TI_DBG */
}
Exemplo n.º 10
0
/*
*===========================================================================
* IPC_buf_free
*===========================================================================
* Description:  Free the buffer, could be called on IPC message receiving node
* 				or on sending node when need to free previously allocated buffers
*
* Parameters: 	agent 			- Pointer to Agent structure
* 				buf_first		- Pointer to first message buffer
* 				pri				- Transport priority level
*
*
* Returns: Result code
*
*/
INT32 CODE_DEFAULT IPC_buf_free(IPC_agent_t *agent, volatile char *buf_first, IPC_trns_priority_e pri)
{
	volatile IPC_next_buf_ptr_t	curBufferPtr;
	volatile IPC_next_buf_ptr_t	nxtBufferPtr;
	IPC_transport_func_t		*trns_ptr;
	IPC_trns_buf_free_t			freeFuncPtr;
	UINT8						destAgentId;
	UINT8						cpuId;
	INT32						res = IPC_SUCCESS;

	HAL_INTERRUPT_SAVE_AREA;

#ifdef IPC_DBG_CF
	OS_printf_debug("[%s]-%u buf_first=0x%p, %s\n", __FUNCTION__, __LINE__, buf_first,
				agent->agentName);
#endif

	ASSERT(agent!=NULL);

	if (buf_first == NULL)
		return IPC_SUCCESS;

	destAgentId 	= (((IPC_first_buffer_t *)buf_first)->msgHdr).destAgentId;
	curBufferPtr    = (IPC_next_buf_ptr_t) buf_first;

	cpuId = IPC_GetNode(destAgentId);
	trns_ptr = IPC_getUtilFuncVector(cpuId);
	ASSERT(trns_ptr != NULL);

	freeFuncPtr = trns_ptr->trns_buf_free_ptr;

	ASSERT(freeFuncPtr != NULL);
	// Now loop all allocated buffers and free them all
	// Last buffer is either a single buffer (type = 0)
	// or the buffer marked as the last one (type = 2)
	// all other buffers have their LSB set (type = 1 or 3)

#if defined(IPC_USE_TRACE)
	TRACE4(IPC_trace_client_id, IPC_e_MSG_FREE, (UINT32)curBufferPtr,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->destAgentId,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->srcAgentId,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->msgType);
#endif

	HAL_INTERRUPT_DISABLE;
	do {
		nxtBufferPtr   = ((volatile IPC_message_hdr_t *)
				IPC_NEXT_PTR_PART(curBufferPtr))->nextBufPtr;
		(freeFuncPtr)(IPC_NEXT_PTR_PART(curBufferPtr), destAgentId, pri);
		curBufferPtr = nxtBufferPtr;
//		OS_printf_debug("Buffer serviced: next: 0x%08X\n", nxtBufferPtr);
	} while (((UINT32)curBufferPtr & IPC_BUF_TYPE_MTC) );
	HAL_INTERRUPT_RESTORE;
//	OS_printf_debug("All buffers serviced\n");

	return res;
}
Exemplo n.º 11
0
/** 
 * \fn     sme_SelectRsnMatch
 * \brief  Checks if the configured scurity settings match those of a site
 * 
 * Checks if the configured scurity settings match those of a site
 * 
 * \param  hSme - handle to the SME object
 * \param  pCurrentSite - the site to check
 * \return TI_TRUE if site matches RSN settings, TI FALSE if it doesn't
 * \sa     sme_Select
 */ 
TI_BOOL sme_SelectRsnMatch (TI_HANDLE hSme, TSiteEntry *pCurrentSite)
{
    TSme            *pSme = (TSme*)hSme;
	TRsnData    	tRsnData;
    dot11_RSN_t     *pRsnIe;
    TI_UINT8        uRsnIECount=0;
    TI_UINT8        uCurRsnData[255];
    TI_UINT32       uLength = 0;
    TI_UINT32       uMetric;
	TRsnSiteParams  tRsnSiteParams;

	tRsnSiteParams.bssType = pCurrentSite->bssType;
	MAC_COPY(tRsnSiteParams.bssid, pCurrentSite->bssid);
	tRsnSiteParams.pHTCapabilities = &pCurrentSite->tHtCapabilities;
	tRsnSiteParams.pHTInfo = &pCurrentSite->tHtInformation;

    /* copy all RSN IE's */
    pRsnIe = pCurrentSite->pRsnIe;
    while ((uLength < pCurrentSite->rsnIeLen) && (uRsnIECount < MAX_RSN_IE))
    {
        if (uLength + 2 + pRsnIe->hdr[ 1 ] > sizeof (uCurRsnData))
        {
           TRACE4( pSme->hReport, REPORT_SEVERITY_ERROR,
                  "sme_SelectRsnMatch. uRsnIECount=%d, uLength=%d; required copy of %d bytes exceeds the buffer limit %d\n",
                   uRsnIECount, uLength, pRsnIe->hdr[ 1 ] +2, sizeof (uCurRsnData));
           handleRunProblem(PROBLEM_BUF_SIZE_VIOLATION);
           return TI_FALSE;
        }
        uCurRsnData[ 0 + uLength ] = pRsnIe->hdr[ 0 ];
        uCurRsnData[ 1 + uLength ] = pRsnIe->hdr[ 1 ];
        os_memoryCopy (pSme->hOS, &uCurRsnData[ 2 + uLength ], pRsnIe->rsnIeData, pRsnIe->hdr[ 1 ]); 
        uLength += pRsnIe->hdr[ 1 ] + 2;
        pRsnIe += 1;
        uRsnIECount++;
    }
    /* sanity check - make sure RSN IE's size is not too big */
    if (uLength < pCurrentSite->rsnIeLen) 
    {
        TRACE2(pSme->hReport, REPORT_SEVERITY_ERROR , "sme_SelectRsnMatch, RSN IE is too long: rsnIeLen=%d, MAX_RSN_IE=%d\n", pCurrentSite->rsnIeLen, MAX_RSN_IE);
    }

    /* call the RSN to evaluate the site */
    tRsnData.pIe = (pCurrentSite->rsnIeLen == 0) ? NULL : uCurRsnData;
    tRsnData.ieLen = pCurrentSite->rsnIeLen;
    tRsnData.privacy = pCurrentSite->privacy;
    if (rsn_evalSite (pSme->hRsn, &tRsnData, &tRsnSiteParams , &uMetric) != TI_OK)
    {
        /* no match */
        return TI_FALSE;
    }
    else
    {
        /* match! */
        return TI_TRUE;
    }
}
Exemplo n.º 12
0
INT32 PORT_GetPortType(void* id, INT32 portIndex) {
    PortMixer *mixer = (PortMixer *)id;
    INT32 ret = 0;

    if (portIndex < 0 || portIndex >= mixer->portCount) {
        ERROR1("PORT_GetPortType: line (portIndex = %d) not found\n", portIndex);
        return 0;
    }

    AudioObjectPropertyScope scope = mixer->ports[portIndex].scope;
    AudioStreamID streamID = mixer->ports[portIndex].streamID;
    if (streamID != 0) {
        UInt32 terminalType;

        OSStatus err = GetAudioObjectProperty(streamID, kAudioObjectPropertyScopeGlobal,
            kAudioStreamPropertyTerminalType, sizeof(terminalType), &terminalType, 1);
        if (err) {
            OS_ERROR1(err, "PORT_GetPortType(kAudioStreamPropertyTerminalType), portIndex=%d", portIndex);
            return 0;
        }

        // Note that kAudioStreamPropertyTerminalType actually returns values from
        // IOAudioTypes.h, not the defined kAudioStreamTerminalType*.
        TRACE4("PORT_GetPortType (portIndex=%d), scope=%s, termType=0x%04x (%s)\n",
            (int)portIndex, FourCC2Str(scope), (int)terminalType, FourCC2Str(terminalType));
        switch (terminalType) {
        case INPUT_MICROPHONE:
            ret = PORT_SRC_MICROPHONE;
            break;

        case OUTPUT_SPEAKER:
            ret = PORT_DST_SPEAKER;
            break;
        case OUTPUT_HEADPHONES:
            ret = PORT_DST_HEADPHONE;
            break;

        case EXTERNAL_LINE_CONNECTOR:
            ret = scope == kAudioDevicePropertyScopeInput ? PORT_SRC_LINE_IN : PORT_DST_LINE_OUT;
            break;

        default:
            TRACE1("  unknown output terminal type %#x\n", terminalType);
        }
    } else {
        TRACE0("  PORT_GetPortType: multiple streams\n");
    }

    if (ret == 0) {
        // if the type not detected, return "common type"
        ret = scope == kAudioDevicePropertyScopeInput ? PORT_SRC_UNKNOWN : PORT_DST_UNKNOWN;
    }

    TRACE2("<<PORT_GetPortType (portIndex=%d) = %d\n", portIndex, ret);
    return ret;
}
Exemplo n.º 13
0
/*
 * -----------------------------------------------------------
 * Function:	IPC_msg_handler
 * Description:	Handling single IPC message
 * Input:		ipcData - IPC message
 * Output:		None
 * -----------------------------------------------------------
 */
void CODE_DEFAULT IPC_msg_handler(VCHAR *ipcData)
{
	IPC_agent_t	*agent_p;
	UINT16		msgLen;
	UINT8		destAgentId;

	ASSERT(ipcData);
	destAgentId = ((IPC_message_hdr_t *)ipcData)->destAgentId;
	msgLen = ((IPC_message_hdr_t *)ipcData)->msgLen;
#ifdef IPC_DBG_CF
#if 1 //!defined(UNIX) && !defined(WIN32)
	OS_printf_debug("[%s]-%u destAgentId: %02X (%u) msgLen: %u\n",
			__FUNCTION__, __LINE__, destAgentId, destAgentId, msgLen);
#endif
#endif

#if defined(IPC_USE_TRACE)
	TRACE4(IPC_trace_client_id, IPC_e_MSG_PROC, (UINT32)ipcData,
			(UINT32)((IPC_message_hdr_t *)ipcData)->destAgentId,
			(UINT32)((IPC_message_hdr_t *)ipcData)->srcAgentId,
			(UINT32)((IPC_message_hdr_t *)ipcData)->msgType);
#endif

	/* check is the message belongs to current node */
	if(IPC_OwnNode == IPC_GetNode(destAgentId))
	{

		ASSERT(agent_p = IPC_agent_array[IPC_LocalId(destAgentId)]);
		ASSERT(agent_p->cb);
		/* call user registered function */
		agent_p->cb((void *)ipcData);
	}
	else /* forward if possible */
	{
		ASSERT(IPC_agent_array[0]);

		if (IPC_agent_array[0]->forward_cb)
			IPC_agent_array[0]->forward_cb((void *)ipcData, 0);


#if !defined(UNIX) && !defined(WIN32)
		IPC_chunk_send(IPC_agent_array[0], ipcData, IPC_trns_prio_e_0);
#endif
		// actually was used this destination, so revert it
#if defined(UNIX) || defined(WIN32)
// 	Not implemented
#else
		/* Restore destination ID, need for release buffer to proper pool */
		((IPC_message_hdr_t *)ipcData)->destAgentId =
					IPC_agent_array[0]->agentId;
		/* Usually the destination agent shall free the buffers */
		IPC_buf_free(IPC_agent_array[0], ipcData, IPC_trns_prio_e_0);
#endif
	} // forward
}
COGLTexture::COGLTexture(uint32 dwWidth, uint32 dwHeight, TextureUsage usage) :
    CTexture(dwWidth,dwHeight,usage),
    m_glInternalFmt(GL_RGBA)
{
    // FIXME: If usage is AS_RENDER_TARGET, we need to create pbuffer instead of regular texture

    m_dwTextureFmt = TEXTURE_FMT_A8R8G8B8;  // Always use 32bit to load texture
    glGenTextures( 1, &m_dwTextureName );
    OPENGL_CHECK_ERRORS;

    // Make the width and height be the power of 2
    uint32 w;
    for (w = 1; w < dwWidth; w <<= 1);
    m_dwCreatedTextureWidth = w;
    for (w = 1; w < dwHeight; w <<= 1);
    m_dwCreatedTextureHeight = w;
    
    if (dwWidth*dwHeight > 256*256)
        TRACE4("Large texture: (%d x %d), created as (%d x %d)", 
            dwWidth, dwHeight,m_dwCreatedTextureWidth,m_dwCreatedTextureHeight);
    
    m_fYScale = (float)m_dwCreatedTextureHeight/(float)m_dwHeight;
    m_fXScale = (float)m_dwCreatedTextureWidth/(float)m_dwWidth;

    m_pTexture = malloc(m_dwCreatedTextureWidth * m_dwCreatedTextureHeight * GetPixelSize());

    switch( options.textureQuality )
    {
    case TXT_QUALITY_DEFAULT:
        if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) 
            m_glInternalFmt = GL_RGBA4;
        break;
    case TXT_QUALITY_32BIT:
        break;
    case TXT_QUALITY_16BIT:
            m_glInternalFmt = GL_RGBA4;
        break;
    };

    #ifndef USE_GLES
    m_glFmt = GL_BGRA;
    m_glType = GL_UNSIGNED_INT_8_8_8_8_REV;
    #else
    m_glInternalFmt = m_glFmt = COGLGraphicsContext::Get()->IsSupportTextureFormatBGRA() ? GL_BGRA_EXT : GL_RGBA;
    m_glType = GL_UNSIGNED_BYTE;
    #endif

    LOG_TEXTURE(TRACE2("New texture: (%d, %d)", dwWidth, dwHeight));
    
    // We create the OGL texture here and will use glTexSubImage2D to increase performance.
    glBindTexture(GL_TEXTURE_2D, m_dwTextureName);
    OPENGL_CHECK_ERRORS;
    glTexImage2D(GL_TEXTURE_2D, 0, m_glInternalFmt, m_dwCreatedTextureWidth, m_dwCreatedTextureHeight, 0, m_glFmt, m_glType, NULL);
    OPENGL_CHECK_ERRORS;
}
Exemplo n.º 15
0
/**
 * "send" method handler
 */
STATIC XRpcElement* GWENG_MidpSend(void* ctx, const XRpcContainer* param)
{
    /* decode parameters */
    const XRpcIntElement* sidParam =
        XRPC_GetIntElementByName(param, 
        ECMTGW_SEI_SEND_SID_PARAM);

    const XRpcIntElement* cidParam =
        XRPC_GetIntElementByName(param, 
        ECMTGW_SEI_SEND_CID_PARAM);

    const XRpcBinaryElement* dataParam =
        XRPC_GetBinaryElementByName(param, 
        ECMTGW_SEI_SEND_DATA_PARAM);

    if (sidParam && cidParam && dataParam) {
        MidpSession* midp;
        EcmtGateway* gw = ctx;
        size_t size = XRPC_GetBinaryDataSize(dataParam);
        I32u cid = XRPC_GetInt(cidParam);
        const XRpcByte* data = XRPC_GetBinaryData(dataParam);

        MidpSessionKey key;
        key.xrpcSid = XRPC_GetInt(sidParam);
        key.xrpcSession = XRPC_GetCurrentSession(gw->xrpc);

        TRACE4("GW: MidpSend(%08x.%08x.%u, %d bytes)\n",
            key.xrpcSession, key.xrpcSid, cid, size);
        DEBUG_ONLY(PRINT_Dump(DEBUG_Trace,data,size,0));

        MUTEX_Lock(&gw->mutex);
        midp = HASH_Get(&gw->midpSessionMap,&key);
        if (midp) {
            MidpConnection* conn = HASH_Get(&midp->connMap,(HashKey)cid);
            if (conn) {
                char h[ECMT_MIDP_DEBUG_SEND_DATA_OFFSET];
                I32u seq = conn->outCount++;
                GWENG_MidpFillHeader(h,midp->sid,ECMT_MIDP_DEBUG_OPCODE_SEND);
                *((I32u*)(h+ECMT_MIDP_DEBUG_SEND_CID_OFFSET)) = htonl(cid);
                *((I32u*)(h+ECMT_MIDP_DEBUG_SEND_SEQ_OFFSET)) = htonl(seq);
                GWENG_QueueAdd2(gw->handsetQueue, KECMT_MIDP_DEBUG_PLUGIN_UID,
                    h, ECMT_MIDP_DEBUG_SEND_DATA_OFFSET, data, size);
            } else {
                TRACE1("GW: invalid conn id %u\n",cid);
                GWENG_MidpResetConn(gw, midp, cid, False, True);
            }
        } else {
            TRACE2("GW: unexpected MIDP send (%08x.%08x)\n",
                key.xrpcSession, key.xrpcSid);
        }
        MUTEX_Unlock(&gw->mutex);
    }

    return NULL;
}
Exemplo n.º 16
0
/* Store the error in the context so that the error sending function
  can take out a descriptive text.  Inside the assuan code, use the
  macro set_error instead of this function. */
gpg_error_t
assuan_set_error (assuan_context_t ctx, gpg_error_t err, const char *text)
{
  TRACE4 (ctx, ASSUAN_LOG_CTX, "assuan_set_error", ctx,
	  "err=%i (%s,%s),text=%s", err, gpg_strsource (err),
	  gpg_strerror (err), text);

  ctx->err_no = err;
  ctx->err_str = text;
  return err;
}
Exemplo n.º 17
0
/****************************************************************************
 *                      cmdBld_CfgRssiSnrWeights()
 ****************************************************************************
 * DESCRIPTION: Set RSSI/SNR Weights for Average calculations.
 *
 * INPUTS:
 *
 * OUTPUT:  None
 *
 * RETURNS: None
 ****************************************************************************/
TI_STATUS cmdBld_CfgRssiSnrWeights (TI_HANDLE hCmdBld, RssiSnrAverageWeights_t *pWeightsParam, void *fCb, TI_HANDLE hCb)
{
	TCmdBld *pCmdBld = (TCmdBld *)hCmdBld;

	TRACE4(pCmdBld->hReport, REPORT_SEVERITY_INFORMATION , "\n cmdBld_CfgRssiSnrWeights :\n                             uRssiBeaconAverageWeight = %d\n                             uRssiPacketAverageWeight = %d\n                             uSnrBeaconAverageWeight  = %d\n                             uSnrPacketAverageWeight = %d \n ", pWeightsParam->rssiBeaconAverageWeight, pWeightsParam->rssiPacketAverageWeight, pWeightsParam->snrBeaconAverageWeight , pWeightsParam->snrPacketAverageWeight  );

	DB_WLAN(hCmdBld).tRssiSnrWeights.rssiBeaconAverageWeight = pWeightsParam->rssiBeaconAverageWeight;
	DB_WLAN(hCmdBld).tRssiSnrWeights.rssiPacketAverageWeight = pWeightsParam->rssiPacketAverageWeight;
	DB_WLAN(hCmdBld).tRssiSnrWeights.snrBeaconAverageWeight  = pWeightsParam->snrBeaconAverageWeight ;
	DB_WLAN(hCmdBld).tRssiSnrWeights.snrPacketAverageWeight  = pWeightsParam->snrPacketAverageWeight ;

	return cmdBld_CfgIeRssiSnrWeights (hCmdBld, pWeightsParam, fCb, hCb);
}
Exemplo n.º 18
0
kern_return_t vm_copy(vm_task_t target_task, const void* source_address, vm_size_t count, void* dest_address)
{
	TRACE4(target_task, source_address, count, dest_address);
	CHECK_TASK_SELF(target_task);
	
	if (!memory_readable(source_address, count))
		return KERN_INVALID_ADDRESS;
	if (!memory_writable(dest_address, count))
		return KERN_INVALID_ADDRESS;
	
	::memcpy(dest_address, source_address, count);
	return KERN_SUCCESS;
}
Exemplo n.º 19
0
kern_return_t vm_write(vm_task_t target_task, void* address, const void* data, vm_size_t data_count)
{
	TRACE4(target_task, address, data, data_count);
	CHECK_TASK_SELF(target_task);
	
	if (!memory_writable(address, data_count))
		return KERN_INVALID_ADDRESS;
	if (!memory_readable(data, data_count))
		return KERN_INVALID_ADDRESS;
	
	::memcpy(address, data, data_count);
	return KERN_SUCCESS;
}
Exemplo n.º 20
0
/*
 =======================================================================================================================
 =======================================================================================================================
 */
void DMA_Flashram_To_RDRAM(unsigned __int32 rdramaddr, unsigned __int32 flashramaddr, unsigned __int32 len)
{
	/*
	 * DEBUG_FLASHRAM_TRACE(TRACE3("DMA FlashRAM->RDRAM: %08X, %08X, %i",
	 * flashramaddr, rdramaddr, len));
	 */

	FileIO_ReadFLASHRAM(0,0,0);

	if(FlashRAM_Mode == FLASH_STATUS)
	{
		/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
		uint8	*rdramoffset = (uint8 *) &gMS_RDRAM[0] + (rdramaddr & 0x007FFFFF);
		/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

		memcpy(rdramoffset, &FlashRAM_Status, len);
		DEBUG_FLASHRAM_TRACE(TRACE0("STATUS"));
	}
	else
	{
		/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
		uint8	*rdramoffset = (uint8 *) &gMS_RDRAM[0] + (rdramaddr & 0x007FFFFF);
		uint8	*flashramoffset = pLOAD_UBYTE_PARAM(0x88000000);
		/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/

		flashramaddr = (flashramaddr & 0x001FFFF) * 2;
		if(flashramaddr < 0x20000)
		{
			flashramoffset += flashramaddr;
			memcpy(rdramoffset, flashramoffset, len);
			DEBUG_FLASHRAM_TRACE(TRACE1("READ: %08X", flashramaddr));
		}
		else
		{
			DEBUG_FLASHRAM_TRACE(TRACE1("READ: %08X", flashramaddr));
		}
	}

	DEBUG_FLASHRAM_TRACE
	(
		TRACE4
			(
				"DMA Read flashram: %08X-%08X-08X-08X ...",
				MEM_READ_UWORD(rdramaddr),
				MEM_READ_UWORD(rdramaddr + 4),
				MEM_READ_UWORD(rdramaddr + 8),
				MEM_READ_UWORD(rdramaddr + 12)
			)
	);
}
Exemplo n.º 21
0
void TogBox(int x,int y,int st)
 {
  TRACE4("->TogBox(x %d, y %d, st %d)", x, y, st);
  char sta[2][2]={{2,4},{4,2}};
  
  grSetColor(sta[st][0]);
  grMoveTo(0+x,y+32);grLineTo(0+x,y+0);grLineTo(34+x,y+0);
  grSetColor(sta[st][1]);
  grMoveTo(x+0,y+33);grLineTo(23+x,y+33);grLineTo(23+x,y+23);
  grLineTo(x+35,y+23);grLineTo(x+35,y+0);
  
  TRACE1("<-TogBox()");
  return;
}
Exemplo n.º 22
0
PPLLIST PLListNew(ULONG cbGrow)
  {
  PPLLIST pList;
  if ( !cbGrow ) cbGrow = SLPL_DEFCBGROW;
  if ( NULL != (pList = malloc(RNDUP(sizeof(PLLIST), cbGrow))) )
    {
    pList->isNode = 1;
    pList->offLast = pList->cbTot = pList->offFirst = sizeof(PLLIST);
    pList->offParent = pList->count = 0;
    pList->cbGrow = cbGrow;
    TRACE4("addr=0x%X, size requested=%d, actual size=%d, pList->count=%d", pList, cbGrow, RNDUP(sizeof(PLLIST), cbGrow), pList->count );
    return pList;
    } /* endif */
  return NULL;
  }
Exemplo n.º 23
0
/** Read sequence name array from file
 *
 * \param keyname Name of the file to read from
 * \param tbl Pointer to the tblinfo to fill
 */
void
frm_read_tbl(char *keyname, struct tblinfo *tbl)
{
    FILE *fin;
    int lo, hi;
    int idx;
    char *p;
    size_t max_name_len = 8;
    char name[max_name_len + 1];

    if ((fin = sOpen(keyname, "rb", 0)) == NULL) {
        WARNING2("Unable to open file '%s'.", keyname);
        return;
    }

    /* get number of sequence keys */
    lo = getc(fin);
    hi = getc(fin);
    tbl->count = (hi << 8) | lo;

    /* alloc enough memory for all the sequence names */
    tbl->strings = (char **)xcalloc(tbl->count, sizeof * tbl->strings);

    idx = 0;

    while (fread(name, 1, max_name_len, fin) == max_name_len) {
        name[max_name_len] = '\0';

        for (p = name; *p; p++) {
            *p = tolower(*p);

            if (*p == '#') {
                *p = '_';
            }
        }

        TRACE4("Found name '%s' at position %d in file %s.", name, idx, keyname);
        tbl->strings[idx++] = xstrdup(name);
    }

    /* now idx is number of read strings */
    if (tbl->count != idx) {
        tbl->count = idx;
        tbl->strings = (char **)xrealloc(tbl->strings, sizeof * tbl->strings);
    }

    fclose(fin);
}
Exemplo n.º 24
0
void
av_sync(void)
{
	int num_rect = 0;
	SDL_Rect r;

#ifdef PROFILE_GRAPHICS
	float tot_area = 0;
	int i = 0;
	Uint32 ticks = SDL_GetTicks();
#endif

	SDL_Scale2x(screen_surf, screen_surf2x);
	/* copy palette and handle fading! */
	transform_palette();
	SDL_SetColors(screen_surf2x, pal_colors, 0, 256);
	SDL_BlitSurface(screen_surf2x, NULL, display, NULL);
	if (video_rect.h && video_rect.w)
	{
		av_need_update(&video_rect);
		r.h = 2 * video_rect.h;
		r.w = 2 * video_rect.w;
		r.x = 2 * video_rect.x;
		r.y = 2 * video_rect.y;
		SDL_DisplayYUVOverlay(video_overlay, &r);
	}
	if (news_rect.h && news_rect.w)
	{
		av_need_update(&news_rect);
		r.h = 2 * news_rect.h;
		r.w = 2 * news_rect.w;
		r.x = 2 * news_rect.x;
		r.y = 2 * news_rect.y;
		SDL_DisplayYUVOverlay(news_overlay, &r);
	}
	num_rect = get_dirty_rect_list();
	SDL_UpdateRects(display, num_rect, dirty_rect_list);
#ifdef PROFILE_GRAPHICS
	for (i = 0; i < num_rect; ++i)
		tot_area += dirty_rect_list[i].w * dirty_rect_list[i].h;
	tot_area = tot_area * 100 / (2 * MAX_X) / (2 * MAX_Y);
	TRACE4("%3d rects (%6.2f%%) updated in ~%3ums\n",
		num_rect, tot_area, SDL_GetTicks() - ticks);
#endif
	screen_dirty = 0;
}
Exemplo n.º 25
0
kern_return_t vm_msync(vm_task_t target_task, void* addr, vm_size_t size, vm_sync_t in_flags)
{
	TRACE4(target_task, addr, size, in_flags);
	CHECK_TASK_SELF(target_task);
	
	int flags = 0;
	if (in_flags & VM_SYNC_SYNCHRONOUS)
		flags |= MS_SYNC;
	if (in_flags & VM_SYNC_ASYNCHRONOUS)
		flags |= MS_ASYNC;
	if (in_flags & VM_SYNC_INVALIDATE)
		flags |= MS_INVALIDATE;
	
	if (::msync(addr, size, flags) == -1)
		return KERN_INVALID_ADDRESS;
	else
		return KERN_SUCCESS;
}
Exemplo n.º 26
0
void wrap_kfree(void *ptr)
{
	struct alloc_info *info;

	TRACE4("%p", ptr);
	if (!ptr)
		return;
	info = ptr - sizeof(*info);
	atomic_sub(info->size, &alloc_sizes[info->type]);
#if ALLOC_DEBUG > 1
	spin_lock_bh(&alloc_lock);
	RemoveEntryList(&info->list);
	spin_unlock_bh(&alloc_lock);
	if (!(info->type == ALLOC_TYPE_KMALLOC_ATOMIC ||
	      info->type == ALLOC_TYPE_KMALLOC_NON_ATOMIC))
		WARNING("invliad type: %d", info->type);
#endif
	kfree(info);
}
int deviceInfoIterator(UINT32 deviceID, snd_pcm_info_t* pcminfo,
                       snd_ctl_card_info_t* cardinfo, void* userData) {
    char buffer[300];
    ALSA_AudioDeviceDescription* desc = (ALSA_AudioDeviceDescription*)userData;
#ifdef ALSA_PCM_USE_PLUGHW
    int usePlugHw = 1;
#else
    int usePlugHw = 0;
#endif

    initAlsaSupport();
    if (desc->index == 0) {
        // we found the device with correct index
        *(desc->maxSimultaneousLines) = needEnumerateSubdevices(ALSA_PCM) ?
                1 : snd_pcm_info_get_subdevices_count(pcminfo);
        *desc->deviceID = deviceID;
        buffer[0]=' '; buffer[1]='[';
        // buffer[300] is enough to store the actual device string w/o overrun
        getDeviceStringFromDeviceID(&buffer[2], deviceID, usePlugHw, ALSA_PCM);
        strncat(buffer, "]", sizeof(buffer) - strlen(buffer) - 1);
        strncpy(desc->name,
                (cardinfo != NULL)
                    ? snd_ctl_card_info_get_id(cardinfo)
                    : snd_pcm_info_get_id(pcminfo),
                desc->strLen - strlen(buffer));
        strncat(desc->name, buffer, desc->strLen - strlen(desc->name));
        strncpy(desc->vendor, "ALSA (http://www.alsa-project.org)", desc->strLen);
        strncpy(desc->description,
                (cardinfo != NULL)
                    ? snd_ctl_card_info_get_name(cardinfo)
                    : snd_pcm_info_get_name(pcminfo),
                desc->strLen);
        strncat(desc->description, ", ", desc->strLen - strlen(desc->description));
        strncat(desc->description, snd_pcm_info_get_id(pcminfo), desc->strLen - strlen(desc->description));
        strncat(desc->description, ", ", desc->strLen - strlen(desc->description));
        strncat(desc->description, snd_pcm_info_get_name(pcminfo), desc->strLen - strlen(desc->description));
        getALSAVersion(desc->version, desc->strLen);
        TRACE4("Returning %s, %s, %s, %s\n", desc->name, desc->vendor, desc->description, desc->version);
        return FALSE; // do not continue iteration
    }
    desc->index--;
    return TRUE;
}
Exemplo n.º 28
0
/*
*===========================================================================
* IPC_msg_send
*===========================================================================
* Description:  Message send, first buffer of the message should be provided,
*
* Parameters: 	agent 			- Pointer to Agent structure
* 				buf_first		- Pointer to the first message buffer
* 				pri				- Transport priority level
*
*
* Returns: Result code
*
*/
INT32 CODE_DEFAULT IPC_msg_send(IPC_agent_t *agent, VCHAR *buf_first, IPC_trns_priority_e pri)
{
	volatile IPC_next_buf_ptr_t	curBufferPtr;
	IPC_transport_func_t		*trns_ptr;
	IPC_trns_buf_send_t			sendFuncPtr;
	UINT8						destAgentId;
	UINT8						cpuId;
	INT32						res = IPC_SUCCESS;
	HAL_INTERRUPT_SAVE_AREA;

	ASSERT(agent!=NULL);

	if (buf_first == NULL)
		return IPC_SUCCESS;

	destAgentId 	= (((IPC_first_buffer_t *)buf_first)->msgHdr).destAgentId;
	cpuId           = IPC_GetNode(destAgentId);
	curBufferPtr    = (IPC_next_buf_ptr_t) buf_first;

	trns_ptr = IPC_getUtilFuncVector(cpuId);
	ASSERT(trns_ptr != NULL);

	sendFuncPtr  = trns_ptr->trns_buf_send_ptr;
	ASSERT(sendFuncPtr != NULL);

#ifdef IPC_SEND_CF
	OS_printf_debug("[%s]-%d destAgentId = %d, \n",
			__FUNCTION__, __LINE__, destAgentId);
	curBufferPtr    = (IPC_next_buf_ptr_t)IPC_NEXT_PTR_PART(curBufferPtr);
#endif
	HAL_INTERRUPT_DISABLE;
	res = (sendFuncPtr)((VCHAR *)curBufferPtr, destAgentId, pri);
	HAL_INTERRUPT_RESTORE;

#if defined(IPC_USE_TRACE)
	TRACE4(IPC_trace_client_id, IPC_e_MSG_SEND, (UINT32)curBufferPtr,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->destAgentId,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->srcAgentId,
			(UINT32)((IPC_message_hdr_t *)curBufferPtr)->msgType);
#endif

	return res;
}
Exemplo n.º 29
0
kern_return_t semaphore_create(darwin_task_t task, esemaphore_t *semaphore, int policy, int value)
{
	TRACE4(task, semaphore, policy, value);
	CHECK_TASK_SELF(task);
	
	if (value < 0)
		return KERN_INVALID_ARGUMENT;

	if (!semaphore)
		return KERN_INVALID_ARGUMENT;

	*semaphore = new struct semaphore;
	if (!*semaphore)
		return KERN_RESOURCE_SHORTAGE;
	
	(*semaphore)->sem = new Darling::FutexSemaphore(value);

	return KERN_SUCCESS;
}
Exemplo n.º 30
0
COGLTexture::COGLTexture(uint32_t dwWidth, uint32_t dwHeight, TextureUsage usage) :
    CTexture(dwWidth,dwHeight,usage),
    m_glFmt(GL_RGBA)
{
    // FIXME: If usage is AS_RENDER_TARGET, we need to create pbuffer instead of regular texture

    m_dwTextureFmt = TEXTURE_FMT_A8R8G8B8;  // Always use 32bit to load texture
    glGenTextures( 1, &m_dwTextureName );
    OPENGL_CHECK_ERRORS;

    // Make the width and height be the power of 2
    uint32_t w;
    for (w = 1; w < dwWidth; w <<= 1);
    m_dwCreatedTextureWidth = w;
    for (w = 1; w < dwHeight; w <<= 1);
    m_dwCreatedTextureHeight = w;
    
    if (dwWidth*dwHeight > 256*256)
        TRACE4("Large texture: (%d x %d), created as (%d x %d)", 
            dwWidth, dwHeight,m_dwCreatedTextureWidth,m_dwCreatedTextureHeight);
    
    m_fYScale = (float)m_dwCreatedTextureHeight/(float)m_dwHeight;
    m_fXScale = (float)m_dwCreatedTextureWidth/(float)m_dwWidth;

    m_pTexture = malloc(m_dwCreatedTextureWidth * m_dwCreatedTextureHeight * GetPixelSize());

    switch( options.textureQuality )
    {
    case TXT_QUALITY_DEFAULT:
        if( options.colorQuality == TEXTURE_FMT_A4R4G4B4 ) 
            m_glFmt = GL_RGBA4;
        break;
    case TXT_QUALITY_32BIT:
        break;
    case TXT_QUALITY_16BIT:
            m_glFmt = GL_RGBA4;
        break;
    };
    LOG_TEXTURE(TRACE2("New texture: (%d, %d)", dwWidth, dwHeight));

    glBindTexture(GL_TEXTURE_2D, m_dwTextureName);
    glTexImage2D(GL_TEXTURE_2D, 0, m_glFmt, m_dwCreatedTextureWidth, m_dwCreatedTextureHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_pTexture);
}