Ejemplo n.º 1
0
/* Function to read a message from queue with timeout */
int IPC_popMsgTout(void *data, int tout)
{
	struct ipc_queue *qrd   = &q_ipc[CPUID_CURR];
	int raise_event = QUEUE_IS_FULL(qrd);

	if (!QUEUE_IS_VALID(qrd)) {
		return QUEUE_ERROR;
	}

	if ((tout == 0) && QUEUE_IS_EMPTY(qrd)) {
		return QUEUE_EMPTY;
	}

	while (QUEUE_IS_EMPTY(qrd)) {
		if (IPC_EventHandler(IPC_EVENT_WAIT_RX, CPUID_CURR, tout) && (tout > 0)) {
			return QUEUE_TIMEOUT;
		}
	}

	/* Pop the queue Item */
	memcpy(data, qrd->data + ((qrd->tail & (qrd->count - 1)) * qrd->size), qrd->size);
	qrd->tail++;

	if (raise_event) {
		ipc_send_signal();
	}
	return QUEUE_VALID;
}
Ejemplo n.º 2
0
/* Function to push a message into queue with timeout */
int IPC_pushMsgTout(uint16_t cpuid, const void *data, int tout)
{
	struct ipc_queue *qwr = &q_ipc[cpuid];

	/* Check if write queue is initialized */
	if (!QUEUE_IS_VALID(qwr)) {
		return QUEUE_ERROR;
	}

	if ((tout == 0) && QUEUE_IS_FULL(qwr)) {
		return QUEUE_FULL;
	}

	/* Wait for read queue to have some data */
	while (QUEUE_IS_FULL(qwr)) {
		if (IPC_EventHandler(IPC_EVENT_WAIT_TX, cpuid, tout) && (tout > 0)) {
			return QUEUE_TIMEOUT;
		}
	}

	memcpy(qwr->data + ((qwr->head & (qwr->count - 1)) * qwr->size), data, qwr->size);
	qwr->head++;
	ipc_send_signal();

	return QUEUE_INSERT;
}
Ejemplo n.º 3
0
// ---------------------------------------------------------------------------
// Push a message into queue with timeout
int IPC_pushMsgTout(const void *data, int tout)
{
    // Check if write queue is initialized
    if (!QUEUE_IS_VALID(qwr)) {
        return QUEUE_ERROR;
    }

    if (tout == 0) {
        // Check if queue is full
        if (QUEUE_IS_FULL(qwr)) {
            return QUEUE_FULL;
        }
    }
    else if (tout < 0) {
        // Wait for read queue to have some data
        //ipc_wait_event(QUEUE_IS_FULL(qwr), event_tx);
    }
    else {
        // Wait for read queue to have some data
        //ipc_wait_event_tout(QUEUE_IS_FULL(qwr), tout, event_tx);
        if (tout == 0) {
            return QUEUE_TIMEOUT;
        }
    }

    memcpy(qwr->data + ((qwr->head & (qwr->count - 1)) * qwr->size), data, qwr->size);
    qwr->head++;
    ipc_send_signal();

    return QUEUE_INSERT;
}
Ejemplo n.º 4
0
// ---------------------------------------------------------------------------
// Read a message from queue with timeout
int IPC_popMsgTout(void *data, int tout)
{
#ifdef EVENT_ON_RX
    int raise_event = QUEUE_IS_FULL(qrd);
#endif

    if (!QUEUE_IS_VALID(qrd)) {
        return QUEUE_ERROR;
    }

    if (tout == 0) {
        // Check if read queue is empty
        if (QUEUE_IS_EMPTY(qrd)) {
            return QUEUE_EMPTY;
        }
    }
    else if (tout < 0) {
        // Wait for read queue to have some data
        //ipc_wait_event(QUEUE_IS_EMPTY(qrd), event_rx);
    }
    else {
        // Wait for event or timeout
        //ipc_wait_event_tout(QUEUE_IS_EMPTY(qrd), tout, event_rx);
        if (tout == 0) {
          return QUEUE_TIMEOUT;
        }
    }

    // Pop the queue Item
    memcpy(data, qrd->data + ((qrd->tail & (qrd->count - 1)) * qrd->size), qrd->size);
    qrd->tail++;

#ifdef EVENT_ON_RX
    if (raise_event) {
        ipc_send_signal();
    }
#endif
    return QUEUE_VALID;
}
Ejemplo n.º 5
0
/* Function to send notificaton interrupt */
void IPC_msgNotify(void)
{
	ipc_send_signal();
}