MsgHndlr.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. /****************************************************************
  2. ****************************************************************
  3. ** **
  4. ** (C)Copyright 2005-2006, American Megatrends Inc. **
  5. ** **
  6. ** All Rights Reserved. **
  7. ** **
  8. ** 6145-F, Northbelt Parkway, Norcross, **
  9. ** **
  10. ** Georgia - 30071, USA. Phone-(770)-246-8600. **
  11. ** **
  12. ****************************************************************
  13. ****************************************************************/
  14. /*****************************************************************
  15. *
  16. * MsgHndlr.h
  17. * Message Handler.
  18. *
  19. * Author: Govind Kothandapani <govindk@ami.com>
  20. * : Rama Bisa <ramab@ami.com>
  21. * : Basavaraj Astekar <basavaraja@ami.com>
  22. * : Bakka Ravinder Reddy <bakkar@ami.com>
  23. *
  24. *****************************************************************/
  25. #ifndef MSG_HNDLR_H
  26. #define MSG_HNDLR_H
  27. #include "com_Message.h"
  28. #include "com_IPMIDefs.h"
  29. #pragma pack( 1 )
  30. #define BMC_LUN_00 0
  31. #define BMC_LUN_01 1
  32. #define BMC_LUN_10 2
  33. #define BMC_LUN_11 3
  34. #define LOOP_BACK_REQ 0x10
  35. #define LAN_IFC_SUP 0x0001
  36. #define SOL_IFC_SUP 0x0002
  37. #define SERIAL_IFC_SUP 0x0004
  38. #define AMI_DEVICE_SUP 0x0008
  39. #define USER_LOCKED 1
  40. #define USER_UNLOCKED 0
  41. #define MAX_NETFN 64
  42. // /*FLASH TYPE*/
  43. // #define YAFU_FLASH 1
  44. // #define TFTP_FLASH 2
  45. // #define HPM_FLASH 3
  46. /*Get the current cmd channel for OBSM*/
  47. //#define GetCurCmdChannel(BMCInst) g_BMCInfo[BMCInst].Msghndlr.CurChannel
  48. /*-----------------------
  49. * Command Handler Type
  50. *----------------------*/
  51. typedef int (*pCmdHndlr_T) ( uint8_t* pReq, uint8_t ReqLen, uint8_t* pRes);
  52. /*----------------------
  53. * Command Handler map
  54. *----------------------*/
  55. typedef struct
  56. {
  57. uint8_t Cmd;
  58. uint8_t Privilege;
  59. pCmdHndlr_T CmdHndlr;
  60. uint8_t ReqLen; /* 0xFF - Any Length */
  61. uint16_t FFConfig;
  62. uint16_t IfcSupport;
  63. } CmdHndlrMap_T;
  64. /*-------------------------------
  65. * Extended Command Handler Type
  66. *-------------------------------*/
  67. typedef int (*pExCmdHndlr_T) ( uint8_t* pReq, uint32_t ReqLen, uint8_t* pRes);
  68. /*------------------------------
  69. * Extended Command Handler map
  70. *------------------------------*/
  71. typedef struct
  72. {
  73. uint8_t Cmd;
  74. uint8_t Privilege;
  75. pExCmdHndlr_T CmdHndlr;
  76. uint8_t ReqLen; /* 0xFF - Any Length */
  77. uint16_t FFConfig;
  78. uint16_t IfcSupport;
  79. } ExCmdHndlrMap_T;
  80. /*-------------------------
  81. * Message Handler Table
  82. *-------------------------*/
  83. typedef struct
  84. {
  85. uint8_t NetFn;
  86. const CmdHndlrMap_T* CmdHndlrMap;
  87. } MsgHndlrTbl_T;
  88. typedef struct
  89. {
  90. uint8_t NetFn;
  91. uint8_t GroupExtnCode;
  92. const CmdHndlrMap_T* CmdHndlrMap;
  93. } GroupExtnMsgHndlrTbl_T;
  94. /*-------------------------------------------------------------
  95. * Pending Bridged Response Tbl Size
  96. *
  97. * Do not increase beyond 60 as maximum sequence number is 64
  98. *------------------------------------------------------------*/
  99. #define MAX_PENDING_BRIDGE_RES 64
  100. #define MAX_PENDING_BRIDGE_TBL 2
  101. #define PRIMARY_PB_TBL 0
  102. #define SECONDARY_PB_TBL 1
  103. typedef union
  104. {
  105. IPMIMsgHdr_T IPMIMsgHdr;
  106. IPMIUDSMsg_T UDSMsgHdr;
  107. } ResMsgHdr_T;
  108. typedef struct
  109. {
  110. uint8_t Used;
  111. uint8_t TimeOut;
  112. uint8_t SeqNum;
  113. uint8_t ChannelNum;
  114. uint8_t DstSessionHandle;
  115. uint8_t SrcSessionHandle;
  116. uint32_t SrcSessionID;
  117. uint8_t DestQ[PIPE_NAME_LEN];
  118. uint8_t OriginSrc;
  119. IPMIMsgHdr_T ReqMsgHdr;
  120. ResMsgHdr_T ResMsgHdr;
  121. } PendingBridgedResTbl_T;
  122. /*------------------------------
  123. * Pending Sequence Number
  124. *-----------------------------*/
  125. //#define NO_IPMB_PROTOCOL_CHANNEL 3
  126. #define MAX_PENDING_SEQ_NO 50
  127. #define SEQ_NO_EXPIRATION_TIME 5
  128. typedef struct
  129. {
  130. uint8_t Used;
  131. uint8_t TimeOut;
  132. uint8_t SeqNum;
  133. uint8_t NetFn;
  134. uint8_t Cmd;
  135. } PendingSeqNoTbl_T;
  136. #define MAX_IPMI_CMD_BLOCKS 3
  137. // typedef struct
  138. // {
  139. // uint8_t Channel; /**< Originator's channel number */
  140. // HQueue_T hSrcQ; /**< Originator Queue */
  141. // uint8_t Param; /**< Parameter */
  142. // uint8_t Cmd; /**< Command that needs to be processed */
  143. // uint8_t NetFnLUN; /**< Net function and LUN of command */
  144. // uint8_t Privilege; /**< Current privilege level */
  145. // uint32_t SessionID; /**< Session ID if any */
  146. // uint8_t RequestSize; /**< Size of the Request */
  147. // uint8_t Request [MSG_PAYLOAD_SIZE]; /**< Request Data buffer */
  148. // uint8_t ResponseSize; /**< Size of the response */
  149. // uint8_t Response [MSG_PAYLOAD_SIZE]; /**< Response Data buffer */
  150. // uint8_t* pRequest; /**< Pointer to Request data */
  151. // uint8_t* pResponse; /**< Pointer to Response data */
  152. // } IPMICmdMsg_T;
  153. typedef struct
  154. {
  155. uint8_t NetFnLUN;
  156. uint32_t SessionID;
  157. uint8_t SrcQ [PIPE_NAME_LEN];
  158. } KCSBridgeResInfo_T;
  159. #pragma pack( )
  160. // /*------------------ Timer Task Table --------------------------*/
  161. // typedef void (*pTimerFn_T) ();
  162. // typedef struct
  163. // {
  164. // uint8_t NumSecs;
  165. // pTimerFn_T TimerFn;
  166. // } TimerTaskTbl_T;
  167. /*-----------------------------------------------------------
  168. * Bridge Status
  169. *---------------------------------------------------------*/
  170. #define STATUS_OK 0x0
  171. #define STATUS_FAIL 0x1
  172. /* Extern declaration */
  173. extern int GetCmdHndlr(MsgPkt_T* pReq,MsgPkt_T* pRes,CmdHndlrMap_T* pCmdHndlrMap,
  174. uint32_t HdrOffset,uint8_t CmdOverride,CmdHndlrMap_T** CmdHndrl );
  175. extern int GetMsgHndlrMap (uint8_t NetFn, CmdHndlrMap_T ** pCmdHndlrMap);
  176. /**
  177. *@fn GroupExtnGetMsgHndlrMap
  178. *@brief Gets the exact command Handler by comparing NetFn
  179. *@param Netfn -NetFunction of the Cmd to execute
  180. *@GroupExtnCode - Group Extension code
  181. *@param pCmdHndlrMap Pointer to the Command Handler
  182. */
  183. extern int GroupExtnGetMsgHndlrMap (uint8_t NetFn, uint8_t GroupExtnCode, CmdHndlrMap_T ** pCmdHndlrMap);
  184. //extern PendingBridgedResTbl_T m_PendingBridgedResTbl[MAX_PENDING_BRIDGE_TBL][MAX_PENDING_BRIDGE_RES];
  185. extern uint8_t CalculateCheckSum2 ( uint8_t* Pkt, uint32_t Len);
  186. extern void SwapIPMIMsgHdr ( IPMIMsgHdr_T* pIPMIMsgReq, IPMIMsgHdr_T* pIPMIMsgRes);
  187. extern void SwapUDSIPMIMsg ( MsgPkt_T* pIPMIMsgReq, MsgPkt_T* pIPMIMsgRes);
  188. /**
  189. * @fn GetIfcSupport
  190. * @brief This function checks the support of Interface before
  191. * Interface specific commands are executed
  192. * @param IfcSupt - Interface support variable to be verified
  193. * @param IfcSupport - Gives the Interface presence support
  194. */
  195. //extern int GetIfcSupport(uint16_t IfcSupt,uint8_t *IfcSupport);
  196. /*------------------------
  197. * Privilege Levels
  198. *------------------------*/
  199. #define PRIV_NONE 0x00
  200. #define PRIV_CALLBACK 0x01
  201. #define PRIV_USER 0x02
  202. #define PRIV_OPERATOR 0x03
  203. #define PRIV_ADMIN 0x04
  204. #define PRIV_OEM 0x05
  205. #define PRIV_LOCAL 0x81
  206. #define PRIV_SYS_IFC 0x82
  207. /*------------------------------
  208. * Channel type used for BadPassword
  209. *------------------------------*/
  210. #define LAN_CHANNEL_BADP 0x1
  211. #define SERIAL_CHANNEL_BADP 0x2
  212. /*----------------------------
  213. * Command Handler Example (app.c)
  214. *----------------------------*/
  215. /*
  216. #ifdef APP_DEVICE
  217. .... Code ....
  218. const CmdHndlrMap_T g_APP_CmdHndlr [] =
  219. {
  220. { CMD_GET_DEV_ID, PRIV_USER, GET_DEV_ID, 0x00 },
  221. { CMD_BROADCAST_GET_DEV_ID, PRIV_LOCAL, BROADCAST_GET_DEV_ID, 0x00 },
  222. ...
  223. ...
  224. { 0x00, 0x00, 0x00, 0x00 }
  225. };
  226. #else
  227. const CmdHndlrMap_T g_APP_CmdHndlr [] = { 0x00, 0x00, 0x00, 0x00 };
  228. #endif // APP_DEVICE
  229. */
  230. /*---------------------------
  231. * app.h
  232. *---------------------------*/
  233. /*
  234. #ifndef APP_H
  235. #define APP_H
  236. #include "MsgHndlr.h"
  237. extern const CmdHndlrMap_T g_APP_CmdHndlr [];
  238. #endif
  239. */
  240. /*---------------------------------------------------
  241. * Parameters passed by through the message handler Q.
  242. *---------------------------------------------------*/
  243. // #define PARAM_IFC 0x01
  244. // #define PARAM_TIMER 0x02
  245. // #define PARAM_EXECUTE_SP 0x03
  246. // #define PARAM_SENSOR_MONITOR 0x04
  247. // #define PARAM_SENSOR_MONITOR_DONE 0x05
  248. // #define PARAM_IFC_READY 0x06
  249. #define RCVMSGQ_LENGTH 100
  250. #define NO_RESPONSE 0x10
  251. #define NORMAL_RESPONSE 0x11
  252. //#define BRIDGING_REQUEST 0x12
  253. /*----------------------------------------------------
  254. * Receive Message Queue Names
  255. *----------------------------------------------------*/
  256. extern char g_RcvMsgQ [3][RCVMSGQ_LENGTH];
  257. /*------------------------------------------------------------------
  258. *@fn RespondSendMessage
  259. *@brief Frames the Response packet when a IPMB destination is
  260. * unavialable
  261. *
  262. *@param pReq: Request Message Packet address
  263. *@param Status Status of SendIPMBPkt method
  264. *@param BMCInst: BMC Instance Number
  265. *
  266. *@return none
  267. *-----------------------------------------------------------------*/
  268. extern void RespondSendMessage ( MsgPkt_T* pReq, uint8_t Status);
  269. /**
  270. *@fn ValidateMsgHdr
  271. *@brief Validates the Message header and keeps track of the messages that has been bridged
  272. *@param pReq Request packet of the command to be executed
  273. *@return Returns -1 in case of the response to the bridged message
  274. * Returns 0 otherwise
  275. */
  276. extern int ValidateMsgHdr ( MsgPkt_T* pReq);
  277. #endif /* MSG_HNDLR_H */