Commit 3b01129d authored by Michael Quigley's avatar Michael Quigley
Browse files

Added files that use fipc.

parent 6d22e139
#include <thc_ipc.h>
#include <libfipc_types.h>
#include <awe-mapper.h>
//assumes msg is a valid received message
static int recv_predicate(struct fipc_message* msg, void* data)
{
struct predicate_payload* payload_ptr = (struct predicate_payload*)data;
if( THC_MSG_TYPE(msg) == (uint32_t)msg_type_request )
{
payload_ptr->msg_type = msg_type_request;
return 1;
}
else if( THC_MSG_ID(msg) == payload_ptr->expected_msg_id )
{
payload_ptr->msg_type = msg_type_response;
return 1; //message for this awe
}
else
{
return 0; //message not for this awe
}
}
int thc_ipc_recv(struct fipc_ring_channel *chnl, unsigned long msg_id, struct fipc_message** out_msg)
{
struct predicate_payload payload = {
.expected_msg_id = msg_id
};
int ret;
while( true )
{
ret = fipc_recv_msg_if(chnl, recv_predicate, &payload, out_msg);
if( !ret ) //message for us
{
if( payload.msg_type == msg_type_response )
{
awe_mapper_remove_id(msg_id);
}
return 0;
}
else if( ret == -ENOMSG ) //message not for us
{
THCYieldToId((uint32_t)THC_MSG_ID(*out_msg), (uint32_t) msg_id);
}
else if( ret == -EWOULDBLOCK ) //no message, Yield
{
THCYieldAndSave((uint32_t) msg_id);
}
else
{
printk(KERN_ERR "error in thc_ipc_recv: %d\n", ret);
return ret;
}
}
}
#ifndef THC_IPC_H
#define THC_IPC_H
#include <libfipc.h>
#define THC_MSG_TYPE(msg) ((msg)->flags)
#define THC_MSG_ID(msg) ((msg)->regs[(FIPC_NR_REGS) - 1])
int thc_ipc_recv(struct fipc_ring_channel *chnl, unsigned long msg_id, struct fipc_message** out_msg);
typedef enum {
msg_type_unspecified,
msg_type_request,
msg_type_response,
} msg_type_t;
static struct predicate_payload
{
unsigned long expected_msg_id;
msg_type_t msg_type;
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment