47 #include "rt_mh_def.h"
48 #include "rt_qcom_msg.h"
49 #include "rt_mh_util.h"
82 mh_sApplReturn cancel;
86 if (cancelText == NULL)
87 memset(&cancel.ReturnText, 0,
sizeof(cancel.ReturnText));
89 strncpy(cancel.ReturnText, (
char*)cancelText,
sizeof(*cancelText));
91 cancel.TargetIdx = id;
92 cancel.ReturnType = mh_eEvent_Cancel;
94 sts = sendAndReceive(mh_eMsg_ApplReturn,
sizeof(cancel), &cancel, NULL);
134 mh_eEvent abortEventType,
135 mh_eEventPrio abortEventPrio,
139 mh_mEventFlags abortEventFlags,
161 mh_sApplConnect connect;
170 sprintf(name,
"MhAppl_%X", applObject.oix);
173 errh_Error(
"Failed connecting application to QCOM\n%m", sts);
174 return MH__QCOMCONAPPL;
177 qAttr.type = qcom_eQtype_private;
180 errh_Error(
"Failed to create QCOM que\n%m", sts);
185 lAppl.head.platform.os = myNode.
os;
186 lAppl.head.platform.hw = myNode.
hw;
196 case pwr_eClass_Appl:
197 case pwr_cClass_OpAppl:
198 case pwr_cClass_Application:
205 lAppl.head.xdr = FALSE;
206 lAppl.head.ver = mh_cVersion;
207 lAppl.head.source = mh_eSource_Application;
208 net_GetTime(&lAppl.head.birthTime);
209 lAppl.head.qid = qid;
210 lAppl.head.aid = applObject;
211 lAppl.handler.
nid = qid.
nid;
212 lAppl.handler.
qix = mh_cProcHandler;
214 connect.ApplObject = applObject;
216 connect.Flags = flags;
218 connect.AbortEventName, abortEventName,
sizeof(connect.AbortEventName));
219 connect.AbortEventType = abortEventType;
220 connect.AbortEventPrio = abortEventPrio;
221 connect.AbortEventFlags = abortEventFlags;
223 connect.AbortEventText, abortEventText,
sizeof(connect.AbortEventText));
225 sts = sendAndReceive(mh_eMsg_ApplConnect,
sizeof(connect), &connect, &reply);
229 if (activeMessages != NULL)
230 *activeMessages = reply.Connect.NoOfActMessages;
232 lAppl.state = mh_eApplState_Connected;
248 sts = sendAndReceive(mh_eMsg_ApplDisconnect, 0, NULL, NULL);
250 lAppl.state = mh_eApplState_Disconnected;
282 sts = sendAndReceive(mh_eMsg_ApplMessage,
sizeof(*message), message, &reply);
286 message->
Id = reply.Message.Idx;
288 *
id = reply.Message.Idx;
307 mh_sApplReturn applReturn;
311 if (returnText == NULL)
312 memset(&applReturn.ReturnText, 0,
sizeof(applReturn.ReturnText));
314 strncpy(applReturn.ReturnText, (
char*)returnText,
sizeof(*returnText));
316 applReturn.TargetIdx = id;
317 applReturn.ReturnType = mh_eEvent_Return;
319 sts = sendAndReceive(
320 mh_eMsg_ApplReturn,
sizeof(applReturn), &applReturn, NULL);
354 sts = sendAndReceive(mh_eMsg_ApplGetMsgInfo,
sizeof(
id), &
id, &reply);
358 memcpy(message, &reply.Info.Message,
sizeof(*message));
364 mh_eMsg type,
pwr_tUInt32 inSize,
void* ip, mh_uApplReply* reply)
374 if ((put.data =
qcom_Alloc(&sts, size)) == NULL) {
375 errh_Error(
"mh_Appl, sendAndReceive, qcom_AllocMsg failed\n%m", sts);
376 return MH__QCOMALLOCMSG;
379 memcpy(put.data, &lAppl.head,
sizeof(lAppl.head));
380 ((mh_sHead*)put.data)->type = type;
382 memcpy((
char*)put.data +
sizeof(lAppl.head), ip, inSize);
384 put.type.b = mh_cMsgClass;
394 &sts, &lAppl.handler, &put, &lAppl.head.qid, &get, 1000 * 3600, 0);
396 errh_Error(
"mhAppl, sendAndReceive, qcom_Get failed\n%m", sts);
398 return MH__QCOMRCVMSG;
401 hp = (mh_sHead*)get.data;
402 rp = (mh_uApplReply*)(hp + 1);
405 if (
ODD(sts) && reply != NULL)
406 memcpy(reply, rp,
sizeof(mh_uApplReply));
Include file for Time management.
void errh_Error(const char *msg,...)
Log an error message. The function has a variable argument list similar to sprintf.
pwr_tStatus gdh_GetObjectClass(pwr_tObjid object, pwr_tClassId *classid)
Get the class identifier of an object.
mh_mApplFlags
Flags governing how mh interacts with the application.
pwr_tStatus mh_ApplMessage(pwr_tUInt32 *id, mh_sApplMessage *message)
This routine is called by an application to create and send a message.
pwr_tStatus mh_ApplCancel(pwr_tUInt32 id, pwr_tString80 *cancelText)
Cancel a message previously created by this application.
pwr_tStatus mh_ApplConnect(pwr_tObjid applObject, mh_mApplFlags flags, const pwr_tString80 abortEventName, mh_eEvent abortEventType, mh_eEventPrio abortEventPrio, mh_mEventFlags abortEventFlags, const pwr_tString80 abortEventText, pwr_tUInt32 *activeMessages)
Connects this application to the local Handler.
pwr_tStatus mh_ApplReturn(pwr_tUInt32 id, pwr_tString80 *returnText)
Set return status on a message previously created by this application.
pwr_tStatus mh_ApplDisconnect()
Informs the local Handler to remove this Application from its list of known applications.
pwr_tStatus mh_ApplGetMsgInfo(pwr_tUInt32 id, mh_sApplMessage *message)
Fetches the properties of an earlier sent message.
pwr_tBoolean qcom_MyNode(pwr_tStatus *sts, qcom_sNode *node)
Get the local qcom node.
pwr_tBoolean qcom_CreateQ(pwr_tStatus *sts, qcom_sQid *myQ, qcom_sQattr *attr, const char *qname)
Create a queue and make an implicit connect to it.
pwr_tBoolean qcom_Free(pwr_tStatus *sts, void *buffer)
Free a previously allocated buffer.
void * qcom_Request(pwr_tStatus *sts, const qcom_sQid *receiver, qcom_sPut *put, const qcom_sQid *myQ, qcom_sGet *get, int tmo_ms, pwr_tBitMask flags)
Put a request and return the reply.
pwr_tBoolean qcom_Init(pwr_tStatus *sts, qcom_sAid *aid, const char *aname)
Connect to QCom.
void * qcom_Alloc(pwr_tStatus *sts, unsigned int size)
Allocate a buffer in the qcom pool.
#define EVEN(a)
Check if value is even.
unsigned int pwr_tUInt32
32-bit unsigned integer type.
pwr_tCid pwr_tClassId
Class identity type.
char pwr_tString80[80]
80 byte string type.
int pwr_tStatus
Status type.
#define ODD(a)
Check if value is odd.
The structure describing an application message.
co_eOS os
operating system