SerialModem.c 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314
  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. // * SerialModem.c
  15. // * Serial/Modem configuration , Callback & MUX
  16. // *
  17. // * Author: Govindarajan <govindarajann@amiindia.co.in>
  18. // * Vinoth Kumar <vinothkumars@amiindia.co.in>
  19. // ****************************************************************/
  20. // #define ENABLE_DEBUG_MACROS 0
  21. // #include "Types.h"
  22. // #include "Debug.h"
  23. // #include "IPMI_Main.h"
  24. // #include "MsgHndlr.h"
  25. // #include "Support.h"
  26. // #include "IPMIDefs.h"
  27. // #include "IPMI_SerialModem.h"
  28. // #include "SerialModem.h"
  29. // #include "SharedMem.h"
  30. // #include "AppDevice.h"
  31. // #include "Message.h"
  32. // #include "PMConfig.h"
  33. // #include "Util.h"
  34. // #include "SerialIfc.h"
  35. // #include "NVRAccess.h"
  36. // #include "IPMIConf.h"
  37. // #include "PDKDefs.h"
  38. // #include "PDKAccess.h"
  39. // /* Reserved bit macro definitions */
  40. // #define RESERVED_BITS_SETSERIALMODEMCONFIG_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  41. // #define RESERVED_BITS_SETSERIALMODEMCONFIG_SERINPRO 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  42. // #define RESERVED_BITS_GETSERIALMODEMCONFIG_REVCH 0X70 //(BIT6 | BIT5 | BIT4)
  43. // #define RESERVED_BITS_CALLBACK_CH 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  44. // #define RESERVED_BITS_CALLBACK_DESTSEL 0xF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  45. // #define RESERVED_BITS_SETUSERCALLBACKOPT_USRID 0XC0 //(BIT7 | BIT6)
  46. // #define RESERVED_BITS_SETUSERCALLBACKOPT_CH 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  47. // #define RESERVED_BITS_SETUSERCALLBACKOPT_USRCALLBAKCAP 0xFC //(BIT7 | BIT6 | BIT5 | BIT4 | BIT3 | BIT2)
  48. // #define RESERVED_BITS_SETUSERCALLBACKOPT_CBCNEGOPT 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  49. // #define RESERVED_BITS_GETUSERCALLBACKOPTIONS_USRID 0XC0 //(BIT7 | BIT6)
  50. // #define RESERVED_BITS_SETSERIALMODEMMUX_CH 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  51. // #define RESERVED_BITS_SETSERIALMODEMMUX_MUXSETREQ 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  52. // #define RESERVED_BITS_SERIALMODEMCONNECTACTIVE 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  53. // #define RESERVED_BITS_GETTAPRESPONSECODES_CH 0XF0 //(BIT7 | BIT6 | BIT5 | BIT4)
  54. // /*** Local Typedefs ***/
  55. // /**
  56. // * @struct SMConfigTable_T
  57. // * @brief Serial Modem Configuration Table.
  58. // **/
  59. // #pragma pack( )
  60. // typedef struct
  61. // {
  62. // INT8U ParamFlags;
  63. // INT8U MaxSetSelector;
  64. // INT8U MaxBlockSelector;
  65. // unsigned long Offset;
  66. // INT8U Size;
  67. // } PACKED SMConfigTable_T;
  68. // #pragma pack( )
  69. // /**
  70. // * @struct RsvdBitsTable_T
  71. // * @brief Reserved Bits Table.
  72. // **/
  73. // #pragma pack (1)
  74. // typedef struct
  75. // {
  76. // INT8U Param;
  77. // INT8U Length;
  78. // } PACKED RsvdBitsTable_T;
  79. // #pragma pack( )
  80. // /*** Local Definitions ***/
  81. // #define PARAM_VOLATILE 0x01
  82. // #define PARAM_NON_VOLATILE 0x02
  83. // #define PARAM_VOLATILE_NON_VOLATILE 0x04
  84. // #define PARAM_READ_ONLY 0x08
  85. // #define PARAM_WRITE_ONLY 0x10
  86. // #define CHECK_RSVD_BITS 0x20
  87. // #define BLOCK_SELECTOR_REQ 0x80
  88. // #define GET_PARAM_REV_ONLY 0x80
  89. // #define PARAM_REVISION 0x11
  90. // #define SET_IN_PROGRESS 1
  91. // #define SET_COMPLETE 0
  92. // #define SET_BAUD_RATE 7
  93. // #define SET_BAD_PWD_THRESHOLD 54
  94. // #define INIT_STR_PARAM 10
  95. // /* Set Serial Port Mux */
  96. // #define REQ_CUR_MUX_SETTING 0
  97. // #define REQ_MUX_TO_SYS 1
  98. // #define REQ_MUX_TO_BMC 2
  99. // #define REQ_MUX_FORCE_TO_SYS 3
  100. // #define REQ_MUX_FORCE_TO_BMC 4
  101. // #define REQ_BLOCK_MUX_TO_SYS 5
  102. // #define REQ_ALLOW_MUX_TO_SYS 6
  103. // #define REQ_BLOCK_MUX_TO_BMC 7
  104. // #define REQ_ALLOW_MUX_TO_BMC 8
  105. // #define REQ_MUX_TO_SYS_MASK 0x80
  106. // #define REQ_MUX_TO_BMC_MASK 0x40
  107. // #define SET_MUX_TO_SYS_MASK 0xFE
  108. // #define SET_MUX_TO_BMC_MASK 0x1
  109. // #define ALLOW_MUX_TO_SYS_MASK 0x7F
  110. // #define BLOCK_MUX_TO_SYS_MASK 0x80
  111. // #define ALLOW_MUX_TO_BMC_MASK 0xBF
  112. // #define BLOCK_MUX_TO_BMC_MASK 0x40
  113. // #define MUX_REQ_ACCEPTED_MASK 0x02
  114. // #define MUX_REQ_REJECTED_MASK 0xFD
  115. // #define MUX_SESSION_ACTIVE_MASK 0x04
  116. // #define MUX_SESSION_ALERT_INACTIVE_MASK 0xF3
  117. // #define MUX_ALERT_IN_PROGRESS_MASK 0x08
  118. // #define SERIAL_PORT_SHARING_ENABLED 0x08
  119. // #define IPMI_CALLBACK_MASK 1
  120. // #define CBCP_CALLBACK_MASK 2
  121. // #define SESSION_STATE_ACTIVE 1
  122. // #define SESSION_STATE_INACTIVE 0
  123. // #define DIRECT_PING_ENABLE_MASK 2
  124. // #define MUX_SWITCHED_TO_SYS 2
  125. // #define PING_MSG_ACTIVE_BIT 0x01
  126. // #define BAUD_RATE_9600 6
  127. // #define BAUD_RATE_19200 7
  128. // #define BAUD_RATE_38400 8
  129. // #define BAUD_RATE_57600 9
  130. // #define BAUD_RATE_115200 10
  131. // #define NO_FLOWCONTROL 0
  132. // #define HARDWARE_FLOWCONTROL 1
  133. // #define XON_XOFF_FLOWCONTRO 2
  134. // #define SERIAL_BAUD_RATE 0x0F
  135. // #define SM_OFFSET(MEMBER) (unsigned long)&(((SMConfig_T*) 0)->MEMBER)
  136. // /**
  137. // * @brief SerialModem Validation Info Table
  138. // **/
  139. // const SMConfigTable_T SMConfigTable [] =
  140. // {
  141. // { PARAM_VOLATILE, 0, 0, SM_OFFSET (SetInProgress), 1 }, // Set In Progress
  142. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (AuthTypeSupport), 1 }, // Authentication Type Support
  143. // { PARAM_NON_VOLATILE | \
  144. // CHECK_RSVD_BITS, 0, 0, SM_OFFSET (AuthTypeEnable), sizeof (AuthTypeEnable_T) }, // Authetication Type enable
  145. // { PARAM_NON_VOLATILE | \
  146. // CHECK_RSVD_BITS, 0, 0, SM_OFFSET (ConnectionMode), 1, }, // Connection Mode
  147. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (SessionInactivity),1 },
  148. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (ChannelCallBackCtrl), sizeof (ChannelCallbackCtrl_T) },
  149. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (SessionTermination), 1 },
  150. // { PARAM_NON_VOLATILE | \
  151. // CHECK_RSVD_BITS, 0, 0, SM_OFFSET (IpmiMsgCommSet), sizeof (IpmiMsgCommSettings_T) },
  152. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (MUXSwitchCtrl), sizeof (MuxSwitchCtrl_T) },
  153. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (RingTime), sizeof (ModemRingTime_T) },
  154. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_INIT_STR_BLOCKS, 0, SM_OFFSET (ModemInitString [0] [0]),MAX_MODEM_INIT_STR_BLOCK_SIZE + 0x80 },
  155. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (ModemEscapeSeq [0]), MAX_MODEM_ESC_SEQ_SIZE },
  156. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (ModemHangup [0]), MAX_MODEM_HANG_UP_SEQ_SIZE },
  157. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (ModemDialCmd [0]), MAX_MODEM_DIAL_CMD_SIZE },
  158. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PageBlockOut), 1 },
  159. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (CommunityString [0]), MAX_COMM_STRING_SIZE },
  160. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (TotalAlertDest), 1 },
  161. // { PARAM_VOLATILE_NON_VOLATILE, MAX_SERIAL_ALERT_DESTINATIONS,0, SM_OFFSET (DestinationInfo [0]), sizeof (DestInfo_T) },
  162. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (CallRetryInterval), 1 },
  163. // { PARAM_VOLATILE_NON_VOLATILE, MAX_SERIAL_ALERT_DESTINATIONS,0, SM_OFFSET (DestComSet [0]), sizeof (ModemDestCommSettings_T) },
  164. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (TotalDialStr), 1 },
  165. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_DIAL_STRS + 0x80, MAX_MODEM_DIAL_STR_BLOCKS, SM_OFFSET (DestDialStrings [0] [0] [0]),MAX_MODEM_DIAL_STR_BLOCK_SIZE + 0x80},
  166. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (TotalDestIP), 1 },
  167. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_ALERT_DEST_IP_ADDRS,0, SM_OFFSET (DestAddr [0]), sizeof (DestIPAddr_T) },
  168. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (TotalTAPAcc), 1 },
  169. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_TAP_ACCOUNTS, 0, SM_OFFSET (TAPAccountSelector[0]), 1 },
  170. // { PARAM_VOLATILE_NON_VOLATILE | \
  171. // PARAM_WRITE_ONLY, MAX_MODEM_TAP_ACCOUNTS, 0, SM_OFFSET (TAPPasswd [0] [0]), TAP_PASSWORD_SIZE },
  172. // { PARAM_NON_VOLATILE, MAX_MODEM_TAP_ACCOUNTS, 0, SM_OFFSET (TAPPagerIDStrings [0] [0]),TAP_PAGER_ID_STRING_SIZE },
  173. // { PARAM_NON_VOLATILE, MAX_MODEM_TAP_ACCOUNTS, 0, SM_OFFSET (TAPServiceSettings [0]), sizeof (TAPServiceSettings_T)},
  174. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (Termconfig), sizeof (TermConfig_T) },
  175. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPProtocolOptions), sizeof (PPPProtocolOptions_T)},
  176. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPPrimaryRMCPPort), sizeof (INT16U) },
  177. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPSecondaryRMCPPort), sizeof (INT16U) },
  178. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPLinkAuth), 1 },
  179. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (CHAPName [0]), MAX_MODEM_CHAP_NAME_SIZE + 0x80},
  180. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPACCM), sizeof (PPPAccm_T) },
  181. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPSnoopACCM), sizeof (PPPSnoopAccm_T) },
  182. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (TotalPPPAcc), 1 },
  183. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccDialStrSel [0]), 1 },
  184. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccIPAddress [0] [0]),IP_ADDR_LEN },
  185. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccUserNames [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80 },
  186. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccUserDomain [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80},
  187. // { PARAM_VOLATILE_NON_VOLATILE | \
  188. // PARAM_WRITE_ONLY, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccUserPasswd [0] [0]),PPP_ACC_USER_NAME_DOMAIN_PASSWD_SIZE + 0x80},
  189. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccAuthSettings [0]), 1 },
  190. // { PARAM_VOLATILE_NON_VOLATILE, MAX_MODEM_PPP_ACCOUNTS, 0, SM_OFFSET (PPPAccConnHoldTimes [0]),1 },
  191. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (PPPUDPProxyIPHeadData),sizeof (PPPUDPProxyIPHeaderData_T) },
  192. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (PPPUDPProxyTransmitBuffSize),2 },
  193. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (PPPUDPProxyReceiveBuffSize),2 },
  194. // { PARAM_READ_ONLY, 0, 0, SM_OFFSET (PPPRemoteConsoleIPAdd [0]),IP_ADDR_LEN },
  195. // {0, 0, 0, 0, 0},
  196. // {0, 0, 0, 0, 0},
  197. // {0, 0, 0, 0, 0},
  198. // {0, 0, 0, 0, 0},
  199. // {0, 0, 0, 0, 0},
  200. // { PARAM_NON_VOLATILE, 0, 0, SM_OFFSET (BadPasswd),sizeof(BadPassword_T) },
  201. // };
  202. // /**
  203. // * @brief SerialModem Reserved Bits Validation Info Table
  204. // **/
  205. // const INT8U ReservedBitsTable [] =
  206. // {
  207. // /*Param, Length, ReservedBits Masks*/
  208. // 2, 5, 0xc8,0xc8,0xc8,0xc8,0xc8,
  209. // 3, 1, 0x78,
  210. // 7, 2, 0x0f,0xf0,
  211. // };
  212. // /*** Prototype Declarations ***/
  213. // static _FAR_ INT8U* getSMConfigAddr (_FAR_ const SMConfigTable_T* SMEntry,
  214. // INT8U SetSelector,
  215. // INT8U BlockSelector,
  216. // int BMCInst);
  217. // static _FAR_ ChannelUserInfo_T* GetCBChUserInfo (INT8U UserID, INT8U Channel );
  218. // static int SetSerialPort (int BMCInst);
  219. // /*---------------------------------------
  220. // * SetSerialModemConfig
  221. // *---------------------------------------*/
  222. // int
  223. // SetSerialModemConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  224. // {
  225. // _NEAR_ SetSerialModemConfigReq_T* SetReq =
  226. // (_NEAR_ SetSerialModemConfigReq_T*) pReq;
  227. // const SMConfigTable_T* SMEntry;
  228. // _NEAR_ RsvdBitsTable_T* RsvdEntry;
  229. // INT8U SetSelector;
  230. // INT8U BlockSelector;
  231. // INT8U ReqStartOffset,i,tempdata;
  232. // _FAR_ INT8U* SetStart;
  233. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  234. // INT8U m_Serial_SetInProgress; /**< Contains setting Serial configuration status */
  235. // IPMI_DBG_PRINT ("Set SerialModem Configuration Cmd\n");
  236. // if(SetReq->ChannelNo & RESERVED_BITS_SETSERIALMODEMCONFIG_CH)
  237. // {
  238. // *pRes = CC_INV_DATA_FIELD;
  239. // return sizeof(*pRes);
  240. // }
  241. // /* Verify if the Channel number & param selector is valid */
  242. // if (SetReq->ChannelNo != pBMCInfo->SERIALch)
  243. // {
  244. // *pRes = CC_INV_DATA_FIELD;
  245. // return sizeof (*pRes);
  246. // }
  247. // if (SetReq->ParamSel >= sizeof (SMConfigTable) / sizeof (SMConfigTable [0]))
  248. // {
  249. // *pRes = CC_PARAM_NOT_SUPPORTED;
  250. // return sizeof (*pRes);
  251. // }
  252. // SMEntry = &(SMConfigTable [SetReq->ParamSel]);
  253. // /*Adjust length if Set Selector Needed */
  254. // if (0 != (SMEntry->MaxSetSelector & 0x7f))
  255. // {
  256. // ReqLen--;
  257. // }
  258. // /*Adjust length if Block Selector Needed */
  259. // if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
  260. // {
  261. // ReqLen--;
  262. // }
  263. // /* Verify length */
  264. // if (0 == (SMEntry->Size & 0x80))
  265. // {
  266. // if ((ReqLen - sizeof (SetSerialModemConfigReq_T)) != SMEntry->Size)
  267. // {
  268. // *pRes = CC_REQ_INV_LEN;
  269. // return sizeof (*pRes);
  270. // }
  271. // }
  272. // else
  273. // {
  274. // IPMI_DBG_PRINT_1 ("ReqLen = %d\n",ReqLen);
  275. // if ((ReqLen - sizeof (SetSerialModemConfigReq_T)) > (SMEntry->Size & 0x7f))
  276. // {
  277. // *pRes = CC_REQ_INV_LEN;
  278. // return sizeof (*pRes);
  279. // }
  280. // }
  281. // LOCK_BMC_SHARED_MEM(BMCInst);
  282. // m_Serial_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress;
  283. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  284. // /*Process Set In Progress parameter */
  285. // if (SetReq->ParamSel == SET_IN_PROGRESS_PARAM)
  286. // {
  287. // if((pReq[2] & RESERVED_BITS_SETSERIALMODEMCONFIG_SERINPRO))
  288. // {
  289. // *pRes = CC_INV_DATA_FIELD;
  290. // return sizeof(*pRes);
  291. // }
  292. // /* Commit Write is optional and supported
  293. // * only if rollback is supported */
  294. // if ((SET_COMPLETE != pReq [2]) && (SET_IN_PROGRESS != pReq [2]))
  295. // {
  296. // *pRes = CC_PARAM_NOT_SUPPORTED;
  297. // return sizeof (*pRes);
  298. // }
  299. // else if ((SET_IN_PROGRESS == m_Serial_SetInProgress) &&
  300. // (SET_IN_PROGRESS == pReq [2]))
  301. // {
  302. // /*Set In Progress already Set */
  303. // *pRes = CC_SET_IN_PROGRESS;
  304. // return sizeof (*pRes);
  305. // }
  306. // LOCK_BMC_SHARED_MEM(BMCInst);
  307. // BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress = pReq [2];
  308. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  309. // *pRes = CC_NORMAL;
  310. // return sizeof (*pRes);
  311. // }
  312. // /* Get the param selector & Block Selector */
  313. // if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
  314. // {
  315. // SetSelector = pReq [2];
  316. // BlockSelector = pReq [3];
  317. // ReqStartOffset = sizeof (SetSerialModemConfigReq_T) +
  318. // sizeof (SetSelector) + sizeof (BlockSelector);
  319. // }
  320. // else if (0 == (SMEntry->MaxSetSelector & 0x7f))
  321. // {
  322. // SetSelector = 0;
  323. // BlockSelector = 0;
  324. // ReqStartOffset = sizeof (SetSerialModemConfigReq_T);
  325. // }
  326. // else
  327. // {
  328. // SetSelector = pReq [2];
  329. // BlockSelector = 0;
  330. // ReqStartOffset = sizeof (SetSerialModemConfigReq_T) +
  331. // sizeof (SetSelector);
  332. // }
  333. // /*Check Reserved Bits */
  334. // i = 0;
  335. // while ((0 != (SMEntry->ParamFlags & CHECK_RSVD_BITS)) &&
  336. // (i < sizeof (ReservedBitsTable)))
  337. // {
  338. // RsvdEntry = (_NEAR_ RsvdBitsTable_T*)&ReservedBitsTable [i];
  339. // i = i + sizeof (RsvdBitsTable_T);
  340. // if (RsvdEntry->Param == SetReq->ParamSel)
  341. // {
  342. // INT8U j;
  343. // for (j=0; j < RsvdEntry->Length; j++)
  344. // {
  345. // if (0 != (pReq [ReqStartOffset + j] & ReservedBitsTable [i + j]))
  346. // {
  347. // *pRes = CC_INV_DATA_FIELD;
  348. // return sizeof (*pRes);
  349. // }
  350. // }
  351. // break;
  352. // }
  353. // i = i + RsvdEntry->Length;
  354. // }
  355. // /* Verify the set selector & block selector */
  356. // if ((0 != (SMEntry->MaxSetSelector & 0x7f)) &&
  357. // ((SMEntry->MaxSetSelector & 0x7f) < SetSelector))
  358. // {
  359. // *pRes = CC_PARAM_OUT_OF_RANGE;
  360. // return sizeof (*pRes);
  361. // }
  362. // if ((0 != SMEntry->MaxBlockSelector) &&
  363. // (SMEntry->MaxBlockSelector <= BlockSelector))
  364. // {
  365. // *pRes = CC_PARAM_OUT_OF_RANGE;
  366. // return sizeof (*pRes);
  367. // }
  368. // /* Check read only access */
  369. // if (0 != (SMEntry->ParamFlags & PARAM_READ_ONLY))
  370. // {
  371. // *pRes = CC_ATTEMPT_TO_SET_RO_PARAM;
  372. // return sizeof (*pRes);
  373. // }
  374. // /* Get the address where we want to set */
  375. // SetStart = getSMConfigAddr (SMEntry , SetSelector, BlockSelector,BMCInst);
  376. // switch(SetReq->ParamSel)
  377. // {
  378. // case SET_BAUD_RATE:
  379. // /*Check for Valid Baud Rate*/
  380. // tempdata = GetBits (pReq[3], SERIAL_BAUD_RATE);
  381. // if((tempdata > BAUD_RATE_115200)||(tempdata < BAUD_RATE_9600))
  382. // {
  383. // *pRes = CC_PARAM_OUT_OF_RANGE;
  384. // return sizeof(*pRes);
  385. // }
  386. // LOCK_BMC_SHARED_MEM(BMCInst);
  387. // _fmemcpy (SetStart, (_FAR_ INT8U*) (pReq + ReqStartOffset), (SMEntry->Size & 0x7f));
  388. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  389. // /* if Set serial port setting, initlize the serial port */
  390. // SetSerialPort (BMCInst);
  391. // break;
  392. // case SET_BAD_PWD_THRESHOLD:
  393. // LOCK_BMC_SHARED_MEM(BMCInst);
  394. // _fmemcpy (SetStart, (_FAR_ INT8U*) (pReq + ReqStartOffset), (SMEntry->Size & 0x7f));
  395. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  396. // break;
  397. // default:
  398. // *pRes=CC_PARAM_NOT_SUPPORTED;
  399. // return sizeof(INT8U);
  400. // }
  401. // FlushIPMI((INT8U*)&pBMCInfo->SMConfig,(INT8U*)&pBMCInfo->SMConfig,pBMCInfo->IPMIConfLoc.SMConfigAddr,
  402. // sizeof(SMConfig_T),BMCInst);
  403. // *pRes = CC_NORMAL;
  404. // return sizeof (*pRes);
  405. // }
  406. // /*---------------------------------------
  407. // * GetSerialModemConfig
  408. // *---------------------------------------*/
  409. // int
  410. // GetSerialModemConfig (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  411. // {
  412. // _NEAR_ GetSerialModemConfigReq_T* GetReq =
  413. // (_NEAR_ GetSerialModemConfigReq_T*) pReq;
  414. // _NEAR_ GetSerialModemConfigRes_T* GetRes =
  415. // (_NEAR_ GetSerialModemConfigRes_T*) pRes;
  416. // const SMConfigTable_T* SMEntry;
  417. // _FAR_ INT8U* SetStart;
  418. // INT8U ResStartOffset;
  419. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  420. // INT8U m_Serial_SetInProgress; /**< Contains setting Serial configuration status */
  421. // if(GetReq->ParamRevChannelNo & RESERVED_BITS_GETSERIALMODEMCONFIG_REVCH)
  422. // {
  423. // *pRes = CC_INV_DATA_FIELD;
  424. // return sizeof(*pRes);
  425. // }
  426. // /* Verify if the Channel number & param selector is valid */
  427. // if ((GetReq->ParamRevChannelNo & 0x7f) != pBMCInfo->SERIALch)
  428. // {
  429. // *pRes = CC_INV_DATA_FIELD;
  430. // return sizeof (*pRes);
  431. // }
  432. // if (GetReq->ParamSel >= sizeof (SMConfigTable) / sizeof (SMConfigTable [0]))
  433. // {
  434. // *pRes = CC_PARAM_NOT_SUPPORTED;
  435. // return sizeof (*pRes);
  436. // }
  437. // SMEntry = &(SMConfigTable [GetReq->ParamSel]);
  438. // /* Verify length */
  439. // if (ReqLen != sizeof (GetSerialModemConfigReq_T))
  440. // {
  441. // *pRes = CC_REQ_INV_LEN;
  442. // return (*pRes);
  443. // }
  444. // GetRes->CompCode = CC_NORMAL;
  445. // GetRes->ParamRev = PARAM_REVISION;
  446. // /* Check if only parameter revision is required */
  447. // if (0 != (GetReq->ParamRevChannelNo & GET_PARAM_REV_ONLY))
  448. // {
  449. // return sizeof (GetSerialModemConfigRes_T);
  450. // }
  451. // /* Get the param selector & Block Selector */
  452. // if (0 != (SMEntry->MaxSetSelector & BLOCK_SELECTOR_REQ))
  453. // {
  454. // IPMI_DBG_PRINT ("Param With Set & BLock Selector \n");
  455. // *(pRes + 2) = GetReq->SetSel;
  456. // *(pRes + 3) = GetReq->BlockSel;
  457. // ResStartOffset = sizeof (GetSerialModemConfigRes_T) +
  458. // sizeof (GetReq->SetSel) + sizeof (GetReq->BlockSel);
  459. // }
  460. // else if (0 == (SMEntry->MaxSetSelector & 0x7F))
  461. // {
  462. // IPMI_DBG_PRINT ("Param With No Set Selector \n");
  463. // ResStartOffset = sizeof (GetSerialModemConfigRes_T);
  464. // }
  465. // else
  466. // {
  467. // IPMI_DBG_PRINT ("Param With Set Selector \n");
  468. // *(pRes + 2) = GetReq->SetSel;
  469. // ResStartOffset = sizeof (GetSerialModemConfigRes_T) +
  470. // sizeof (GetReq->SetSel);
  471. // }
  472. // /* Verify the set selector & block selector */
  473. // *pRes = CC_PARAM_OUT_OF_RANGE;
  474. // if (GetReq->ParamSel == INIT_STR_PARAM)
  475. // {
  476. // if (0 != GetReq->SetSel)
  477. // {
  478. // return sizeof (*pRes);
  479. // }
  480. // GetReq->SetSel = GetReq->BlockSel;
  481. // GetReq->BlockSel = 0;
  482. // *(pRes + 2) = GetReq->SetSel;
  483. // ResStartOffset = sizeof (GetSerialModemConfigRes_T) +
  484. // sizeof (GetReq->SetSel);
  485. // }
  486. // if ((0 != (SMEntry->MaxSetSelector & 0x7f)) &&
  487. // ((SMEntry->MaxSetSelector & 0x7f) < GetReq->SetSel))
  488. // {
  489. // return sizeof (*pRes);
  490. // }
  491. // if ((0 != SMEntry->MaxBlockSelector) &&
  492. // ((SMEntry->MaxBlockSelector <= GetReq->BlockSel) ||
  493. // (0 == GetReq->BlockSel)))
  494. // {
  495. // return sizeof (*pRes);
  496. // }
  497. // if ((0 == (SMEntry->MaxSetSelector & 0x7f)) &&
  498. // (0 != GetReq->SetSel))
  499. // {
  500. // return sizeof (*pRes);
  501. // }
  502. // if ((0 == SMEntry->MaxBlockSelector) &&
  503. // (0 != GetReq->BlockSel))
  504. // {
  505. // return sizeof (*pRes);
  506. // }
  507. // if ((0 == GetReq->SetSel) && (GetReq->ParamSel == INIT_STR_PARAM))
  508. // {
  509. // return sizeof (*pRes);
  510. // }
  511. // /* Load Response */
  512. // GetRes->CompCode = CC_NORMAL;
  513. // /* Process Set In Progress parameter */
  514. // if (GetReq->ParamSel == SET_IN_PROGRESS_PARAM)
  515. // {
  516. // LOCK_BMC_SHARED_MEM(BMCInst);
  517. // m_Serial_SetInProgress = BMC_GET_SHARED_MEM(BMCInst)->m_Serial_SetInProgress;
  518. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  519. // *(pRes + 2) = m_Serial_SetInProgress;
  520. // return (sizeof (GetSerialModemConfigRes_T) + sizeof (m_Serial_SetInProgress));
  521. // }
  522. // /* Check Write only access */
  523. // if (0 != (SMEntry->ParamFlags & PARAM_WRITE_ONLY))
  524. // {
  525. // *pRes = CC_WRITE_ONLY_PARAM;
  526. // return sizeof (*pRes);
  527. // }
  528. // /* Get the address where we want to set */
  529. // SetStart = getSMConfigAddr (SMEntry, GetReq->SetSel, GetReq->BlockSel, BMCInst);
  530. // LOCK_BMC_SHARED_MEM(BMCInst);
  531. // _fmemcpy ( (pRes + ResStartOffset), SetStart, (SMEntry->Size & 0x7f));
  532. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  533. // return ( (SMEntry->Size & 0x7f) + ResStartOffset);
  534. // }
  535. // /*---------------------------------------
  536. // * getSMConfigAddr
  537. // *--------------------------------------*/
  538. // static _FAR_ INT8U*
  539. // getSMConfigAddr (_FAR_ const SMConfigTable_T* SMEntry,
  540. // INT8U SetSelector,
  541. // INT8U BlockSelector,
  542. // int BMCInst)
  543. // {
  544. // _FAR_ INT8U* SetStart;
  545. // INT8U Size;
  546. // INT8U MaxBlockSel;
  547. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  548. // /* Get the NVRAM PM config address */
  549. // SetStart = (_FAR_ INT8U*) &pBMCInfo->SMConfig;
  550. // Size = SMEntry->Size & 0x7f;
  551. // if (0 == SMEntry->MaxBlockSelector)
  552. // {
  553. // MaxBlockSel = 1;
  554. // }
  555. // else
  556. // {
  557. // MaxBlockSel = SMEntry->MaxBlockSelector;
  558. // }
  559. // if (0 != (SMEntry->ParamFlags & PARAM_VOLATILE_NON_VOLATILE))
  560. // {
  561. // if (0 == SetSelector)
  562. // {
  563. // /*Get Shared Memory Info */
  564. // SetStart = (_FAR_ INT8U*)&BMC_GET_SHARED_MEM (BMCInst)->SMConfig;
  565. // SetStart = SetStart + SMEntry->Offset +
  566. // (Size * ((SetSelector * MaxBlockSel) + BlockSelector));
  567. // return SetStart;
  568. // }
  569. // else
  570. // {
  571. // SetSelector--;
  572. // if (0 != BlockSelector)
  573. // {
  574. // BlockSelector--;
  575. // }
  576. // }
  577. // }
  578. // SetStart = SetStart + SMEntry->Offset +
  579. // (Size * ((SetSelector * MaxBlockSel) + BlockSelector));
  580. // return SetStart;
  581. // }
  582. // /*---------------------------------------
  583. // * CallBack
  584. // *---------------------------------------*/
  585. // int
  586. // CallBack (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  587. // {
  588. // _NEAR_ CallbackReq_T* CallBackReq = (_NEAR_ CallbackReq_T*) pReq;
  589. // _FAR_ SMConfig_T* pVSMConfig =
  590. // &(((_FAR_ BMCSharedMem_T*) BMC_GET_SHARED_MEM (BMCInst))->SMConfig);
  591. // _FAR_ ChannelInfo_T* pChannelInfo;
  592. // _FAR_ DestInfo_T* pDestInfo;
  593. // INT8U DestType,*curchannel;
  594. // MsgPkt_T MsgPkt;
  595. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  596. // _FAR_ SMConfig_T* pNVSMConfig = &pBMCInfo->SMConfig;
  597. // INT32U *CurSesID;
  598. // if(CallBackReq->ChannelNum & RESERVED_BITS_CALLBACK_CH)
  599. // {
  600. // *pRes = CC_INV_DATA_FIELD;
  601. // return sizeof(*pRes);
  602. // }
  603. // if(CallBackReq->DestSel & RESERVED_BITS_CALLBACK_DESTSEL)
  604. // {
  605. // *pRes = CC_INV_DATA_FIELD;
  606. // return sizeof(*pRes);
  607. // }
  608. // OS_THREAD_TLS_GET(g_tls.CurChannel,curchannel);
  609. // /* Check if Session Already exist */
  610. // if ((pBMCInfo->SERIALch!= (*curchannel & 0xF)) &&
  611. // (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive))
  612. // {
  613. // *pRes = CC_CALLBACK_REJ_SESSION_ACTIVE;
  614. // return sizeof (*pRes);
  615. // }
  616. // CallBackReq->DestSel &= 0x0f;
  617. // /* Check the validity of Destination Selector */
  618. // if (CallBackReq->DestSel > pNVSMConfig->TotalAlertDest)
  619. // {
  620. // *pRes = CC_DEST_UNAVAILABLE;
  621. // return sizeof (*pRes);
  622. // }
  623. // if (0 == CallBackReq->DestSel)
  624. // {
  625. // /* Destination Info is volatile */
  626. // pDestInfo = (_FAR_ DestInfo_T*) &pVSMConfig->DestinationInfo [0];
  627. // }
  628. // else
  629. // {
  630. // /* Destination Info is non-volatile */
  631. // pDestInfo = (_FAR_ DestInfo_T*) &pNVSMConfig->DestinationInfo [CallBackReq->DestSel - 1];
  632. // }
  633. // /*Check if Destination if Configured & Enabled for CALLBACK */
  634. // *pRes = CC_INV_DATA_FIELD;
  635. // DestType = pDestInfo->DesType & MODEM_CFG_DEST_INFO_DEST_TYPE_MASK;
  636. // if ((BASIC_MODE_CALLBACK != DestType) && (PPP_MODE_CALLBACK != DestType))
  637. // {
  638. // return sizeof (*pRes);
  639. // }
  640. // if (0 == (pNVSMConfig->ChannelCallBackCtrl.CallBackEnable & IPMI_CALLBACK_MASK))
  641. // {
  642. // return sizeof (*pRes);
  643. // }
  644. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  645. // /* If Current Channel is Session Based, Check is User is allowed for CallBack */
  646. // pChannelInfo = getChannelInfo (*curchannel & 0xF, BMCInst);
  647. // if(NULL == pChannelInfo)
  648. // {
  649. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  650. // *pRes = CC_INV_DATA_FIELD;
  651. // return sizeof (*pRes);
  652. // }
  653. // /* Disable Ping during CallBack */
  654. // pNVSMConfig->MUXSwitchCtrl.Data2 &= ~DIRECT_PING_ENABLE_MASK;
  655. // if (pChannelInfo->SessionSupport != SESSIONLESS_CHANNEL)
  656. // {
  657. // _FAR_ SessionInfo_T* pSessionInfo;
  658. // _FAR_ SessionTblInfo_T* pSessionTblInfo =
  659. // &pBMCInfo->SessionTblInfo;
  660. // _FAR_ ChannelUserInfo_T* pChUserInfo;
  661. // INT8U Index;
  662. // IPMI_DBG_PRINT_1 ("Session Less ch - %d\n",*curchannel & 0xF);
  663. // OS_THREAD_TLS_GET(g_tls.CurSessionID,CurSesID);
  664. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->SessionTblMutex,WAIT_INFINITE);
  665. // pSessionInfo = getSessionInfo (SESSION_ID_INFO,CurSesID, BMCInst);
  666. // if(pSessionInfo == NULL)
  667. // {
  668. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  669. // return sizeof (*pRes);
  670. // }
  671. // pChUserInfo = getChUserIdInfo (pSessionInfo->UserId,&Index,
  672. // pChannelInfo->ChannelUserInfo, BMCInst);
  673. // if(pChUserInfo == NULL)
  674. // {
  675. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  676. // return sizeof (*pRes);
  677. // }
  678. // if (0 == (pChUserInfo->UserCallbackCapabilities & 0x01))
  679. // {
  680. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  681. // return sizeof (*pRes);
  682. // }
  683. // /* For Serial Channel Existing Session should be deleted */
  684. // if ((pBMCInfo->SERIALch!= (*curchannel & 0xF)) &&
  685. // (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive))
  686. // {
  687. // for (Index=0; Index < pBMCInfo->IpmiConfig.MaxSession; Index++)
  688. // {
  689. // if (pBMCInfo->SERIALch == pSessionTblInfo->SessionTbl [Index].Channel)
  690. // {
  691. // pSessionTblInfo->SessionTbl [Index].TimeOutValue = 0;
  692. // }
  693. // }
  694. // }
  695. // }
  696. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  697. // /* Request to Initiate CallBack */
  698. // MsgPkt.Channel = pBMCInfo->SERIALch;
  699. // MsgPkt.Param = SERIAL_INIT_CALLBACK_REQUEST;
  700. // MsgPkt.Size = sizeof (CallBackReq->DestSel);
  701. // MsgPkt.Data [0] = CallBackReq->DestSel;
  702. // IPMI_DBG_PRINT ("Posting CallBack Request\n");
  703. // if( 0 != PostMsg (&MsgPkt,SERIAL_IFC_Q,BMCInst ))
  704. // {
  705. // IPMI_WARNING ("SerialModem.c: Unable to post messages to hSerialIfc_Q\n");
  706. // }
  707. // *pRes = CC_NORMAL;
  708. // return sizeof (*pRes);
  709. // }
  710. // /*---------------------------------------
  711. // * SetUserCallBackOptions
  712. // *---------------------------------------*/
  713. // int
  714. // SetUserCallBackOptions (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  715. // {
  716. // _NEAR_ SetUserCallbackReq_T *Req = (_NEAR_ SetUserCallbackReq_T*) pReq;
  717. // _FAR_ ChannelUserInfo_T *pChUserInfo;
  718. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  719. // if(Req->UserID & RESERVED_BITS_SETUSERCALLBACKOPT_USRID)
  720. // {
  721. // *pRes = CC_INV_DATA_FIELD;
  722. // return sizeof(*pRes);
  723. // }
  724. // if(Req->ChannelNum & RESERVED_BITS_SETUSERCALLBACKOPT_CH)
  725. // {
  726. // *pRes = CC_INV_DATA_FIELD;
  727. // return sizeof(*pRes);
  728. // }
  729. // if(Req->UserCallbackCapabilities & RESERVED_BITS_SETUSERCALLBACKOPT_USRCALLBAKCAP)
  730. // {
  731. // *pRes = CC_INV_DATA_FIELD;
  732. // return sizeof(*pRes);
  733. // }
  734. // if(Req->CBCPNegOptions & RESERVED_BITS_SETUSERCALLBACKOPT_CBCNEGOPT)
  735. // {
  736. // *pRes = CC_INV_DATA_FIELD;
  737. // return sizeof(*pRes);
  738. // }
  739. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  740. // pChUserInfo = GetCBChUserInfo (Req->UserID, Req->ChannelNum, BMCInst);
  741. // *pRes = CC_INV_DATA_FIELD;
  742. // /*Check if the user info exits */
  743. // if (NULL == pChUserInfo)
  744. // {
  745. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  746. // return sizeof (*pRes);
  747. // }
  748. // /*Set CallBack Options */
  749. // pChUserInfo->UserAccessCallback = (Req->UserCallbackCapabilities &
  750. // IPMI_CALLBACK_MASK);
  751. // pChUserInfo->UserAccessCBCPCallback = (Req->UserCallbackCapabilities &
  752. // CBCP_CALLBACK_MASK);
  753. // pChUserInfo->UserCallbackCapabilities = Req->UserCallbackCapabilities;
  754. // pChUserInfo->CBCPNegOptions = Req->CBCPNegOptions;
  755. // pChUserInfo->CallBack1 = Req->CallBack1;
  756. // pChUserInfo->CallBack2 = Req->CallBack2;
  757. // pChUserInfo->CallBack3 = Req->CallBack3;
  758. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  759. // *pRes = CC_NORMAL;
  760. // return sizeof (*pRes);
  761. // }
  762. // /*---------------------------------------
  763. // * SetUserCallBackOptions
  764. // *---------------------------------------*/
  765. // int
  766. // GetUserCallBackOptions (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  767. // {
  768. // _NEAR_ GetUserCallbackReq_T* Req = ( _NEAR_ GetUserCallbackReq_T*) pReq;
  769. // _NEAR_ GetUserCallbackRes_T* Res = ( _NEAR_ GetUserCallbackRes_T*) pRes;
  770. // _FAR_ ChannelUserInfo_T* pChUserInfo;
  771. // BMCInfo_t *pBMCInfo = &g_BMCInfo[BMCInst];
  772. // if(Req->UserID & RESERVED_BITS_GETUSERCALLBACKOPTIONS_USRID)
  773. // {
  774. // *pRes = CC_INV_DATA_FIELD;
  775. // return sizeof(*pRes);
  776. // }
  777. // OS_THREAD_MUTEX_ACQUIRE(&pBMCInfo->ChUserMutex,WAIT_INFINITE);
  778. // pChUserInfo = GetCBChUserInfo (Req->UserID , Req->ChannelNum, BMCInst);
  779. // *pRes = CC_INV_DATA_FIELD;
  780. // /*Check if the user info exits */
  781. // if (NULL == pChUserInfo )
  782. // {
  783. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  784. // return sizeof (*pRes);
  785. // }
  786. // /*Set CallBack Options */
  787. // Res->CompletionCode = CC_NORMAL;
  788. // Res->UserCallbackCapabilities = pChUserInfo->UserCallbackCapabilities ;
  789. // Res->CBCPNegOptions = pChUserInfo->CBCPNegOptions;
  790. // Res->CallBack1 = pChUserInfo->CallBack1;
  791. // Res->CallBack2 = pChUserInfo->CallBack2;
  792. // Res->CallBack3 = pChUserInfo->CallBack3;
  793. // OS_THREAD_MUTEX_RELEASE(&pBMCInfo->ChUserMutex);
  794. // return sizeof (GetUserCallbackRes_T);
  795. // }
  796. // /*---------------------------------------
  797. // * GetCBChUserInfo
  798. // *---------------------------------------*/
  799. // static _FAR_ ChannelUserInfo_T*
  800. // GetCBChUserInfo (INT8U UserID, INT8U Channel )
  801. // {
  802. // _FAR_ ChannelInfo_T* pChannelInfo;
  803. // INT8U Index;
  804. // /*Get Channel Info */
  805. // pChannelInfo = getChannelInfo (Channel, BMCInst);
  806. // if (NULL == pChannelInfo )
  807. // {
  808. // return NULL;
  809. // }
  810. // /*Get the particular user entitled for callback */
  811. // return getChUserIdInfo (UserID,&Index,pChannelInfo->ChannelUserInfo, BMCInst);
  812. // }
  813. // /*---------------------------------------
  814. // * SetSerialModemMUX
  815. // *---------------------------------------*/
  816. // int
  817. // SetSerialModemMUX (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  818. // {
  819. // _NEAR_ SetMuxReq_T* Req = (_NEAR_ SetMuxReq_T*) pReq;
  820. // _NEAR_ SetMuxRes_T* Res = (_NEAR_ SetMuxRes_T*) pRes;
  821. // INT8U TSettings;
  822. // ChannelInfo_T* pChannelInfo;
  823. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  824. // _FAR_ SMConfig_T* pNVSMConfig = &(pBMCInfo->SMConfig);
  825. // Res->CompCode = CC_INV_DATA_FIELD;
  826. // if(Req->ChannelNo & RESERVED_BITS_SETSERIALMODEMMUX_CH) return sizeof(*pRes);
  827. // if(Req->MuxSettingReq & RESERVED_BITS_SETSERIALMODEMMUX_MUXSETREQ) return sizeof(*pRes);
  828. // if (Req->ChannelNo != pBMCInfo->SERIALch)
  829. // {
  830. // return sizeof(*pRes);
  831. // }
  832. // TSettings = BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting;
  833. // /* No Session or Alert In progress */
  834. // TSettings = TSettings & MUX_SESSION_ALERT_INACTIVE_MASK;
  835. // if (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive)
  836. // {
  837. // TSettings |= MUX_SESSION_ACTIVE_MASK;
  838. // }
  839. // /* Accept Request */
  840. // TSettings = TSettings | MUX_REQ_ACCEPTED_MASK;
  841. // Res->CompCode = CC_NORMAL;
  842. // pChannelInfo = getChannelInfo(pBMCInfo->SERIALch, BMCInst);
  843. // if(NULL == pChannelInfo)
  844. // {
  845. // Res->CompCode = CC_INV_DATA_FIELD;
  846. // return sizeof (*pRes);
  847. // }
  848. // /*Check if Serial Port Sharing Enabled */
  849. // if ((0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & SERIAL_PORT_SHARING_ENABLED)) ||
  850. // (CHANNEL_ALWAYS_AVAILABLE == pChannelInfo->AccessMode))
  851. // {
  852. // if(Req->MuxSettingReq==0x0)
  853. // {
  854. // Res->MuxSetting = TSettings& MUX_REQ_REJECTED_MASK;
  855. // return sizeof (SetMuxRes_T);
  856. // }
  857. // else
  858. // {
  859. // Res->CompCode = CC_COULD_NOT_PROVIDE_RESP;
  860. // return sizeof(*pRes);
  861. // }
  862. // }
  863. // switch (Req->MuxSettingReq)
  864. // {
  865. // case REQ_CUR_MUX_SETTING:
  866. // break;
  867. // case REQ_MUX_TO_SYS:
  868. // if (0 == (REQ_MUX_TO_SYS_MASK & TSettings))
  869. // {
  870. // IPMI_DBG_PRINT ("SYS HOLDS EMP\n");
  871. // if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
  872. // {
  873. // ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_SYS,BMCInst);
  874. // }
  875. // TSettings = (TSettings & SET_MUX_TO_SYS_MASK);
  876. // }
  877. // else
  878. // {
  879. // TSettings &= MUX_REQ_REJECTED_MASK;
  880. // }
  881. // break;
  882. // case REQ_MUX_TO_BMC:
  883. // if (0 == (REQ_MUX_TO_BMC_MASK & TSettings))
  884. // {
  885. // IPMI_DBG_PRINT ("BMC HOLDS EMP\n");
  886. // if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
  887. // {
  888. // ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_BMC,BMCInst);
  889. // }
  890. // TSettings = (TSettings | SET_MUX_TO_BMC_MASK);
  891. // }
  892. // else
  893. // {
  894. // TSettings &= MUX_REQ_REJECTED_MASK;
  895. // }
  896. // break;
  897. // case REQ_MUX_FORCE_TO_SYS:
  898. // IPMI_DBG_PRINT ("SYS HOLDS EMP\n");
  899. // if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
  900. // {
  901. // ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_SYS,BMCInst);
  902. // }
  903. // TSettings = (TSettings & SET_MUX_TO_SYS_MASK);
  904. // break;
  905. // case REQ_MUX_FORCE_TO_BMC:
  906. // IPMI_DBG_PRINT ("BMC HOLDS EMP\n");
  907. // if(g_PDKHandle[PDK_SWITCHEMPMUX] != NULL)
  908. // {
  909. // ((void(*)(INT8U,int))g_PDKHandle[PDK_SWITCHEMPMUX]) (MUX_2_BMC,BMCInst);
  910. // }
  911. // TSettings = (TSettings | SET_MUX_TO_BMC_MASK);
  912. // break;
  913. // case REQ_BLOCK_MUX_TO_SYS:
  914. // TSettings = (TSettings | BLOCK_MUX_TO_SYS_MASK);
  915. // break;
  916. // case REQ_ALLOW_MUX_TO_SYS:
  917. // TSettings = (TSettings & ALLOW_MUX_TO_SYS_MASK);
  918. // break;
  919. // case REQ_BLOCK_MUX_TO_BMC:
  920. // TSettings = (TSettings | BLOCK_MUX_TO_BMC_MASK);
  921. // break;
  922. // case REQ_ALLOW_MUX_TO_BMC:
  923. // TSettings = (TSettings & ALLOW_MUX_TO_BMC_MASK);
  924. // break;
  925. // default:
  926. // return sizeof (*pRes);
  927. // }
  928. // Res->MuxSetting = TSettings;
  929. // BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting = TSettings;
  930. // IPMI_DBG_PRINT_1 ("SerialMUXSetting = %X\n",TSettings);
  931. // return sizeof (SetMuxRes_T);
  932. // }
  933. // /*---------------------------------------
  934. // * SerialModemConnectActive
  935. // *---------------------------------------*/
  936. // int
  937. // SerialModemConnectActive (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  938. // {
  939. // _NEAR_ SerialModemActivePingReq_T* Req = (_NEAR_ SerialModemActivePingReq_T*) pReq;
  940. // if(Req->SessionState & RESERVED_BITS_SERIALMODEMCONNECTACTIVE)
  941. // {
  942. // *pRes = CC_INV_DATA_FIELD;
  943. // return sizeof(*pRes);
  944. // }
  945. // *pRes = CC_NORMAL;
  946. // if ((Req->SessionState != 0) && /* No Session State */
  947. // (Req->SessionState != 1) && /* Session State Active */
  948. // (Req->SessionState != 2) && /* MUX Switch to SYS */
  949. // (Req->IPMIVersion != 0x51)) /* IPMIVersion 1.5 */
  950. // {
  951. // *pRes = CC_INV_DATA_FIELD;
  952. // }
  953. // return sizeof (*pRes);
  954. // }
  955. // /*---------------------------------------
  956. // * SerialModemPingTask
  957. // *---------------------------------------*/
  958. // void
  959. // SerialModemPingTask ( int BMCInst )
  960. // {
  961. // MsgPkt_T MsgPkt;
  962. // _FAR_ static INT8U MuxSwitchToSys;
  963. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  964. // _FAR_ SMConfig_T* pNVSMConfig = &pBMCInfo->SMConfig;
  965. // /* Check if Serial Port Sharing Enabled & Mux is switched to BMC */
  966. // if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & SERIAL_PORT_SHARING_ENABLED))
  967. // {
  968. // return;
  969. // }
  970. // /* Check if Serial Ping Message Enabled */
  971. // if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & DIRECT_PING_ENABLE_MASK))
  972. // {
  973. // return;
  974. // }
  975. // /* Update Session State */
  976. // if (0 == (BMC_GET_SHARED_MEM (BMCInst)->SerialMuxSetting & SET_MUX_TO_BMC_MASK))
  977. // {
  978. // /* Ping should be generated Only once before Mux switch to System */
  979. // if (1 == MuxSwitchToSys )
  980. // {
  981. // return;
  982. // }
  983. // MsgPkt.Data [0] = MUX_SWITCHED_TO_SYS;
  984. // MuxSwitchToSys = 1;
  985. // }
  986. // else
  987. // {
  988. // /* Check for periodical ping message active flag */
  989. // if (0 == (pNVSMConfig->MUXSwitchCtrl.Data2 & PING_MSG_ACTIVE_BIT))
  990. // {
  991. // return;
  992. // }
  993. // MsgPkt.Data [0] = SESSION_STATE_INACTIVE;
  994. // MuxSwitchToSys = 0;
  995. // if (TRUE == BMC_GET_SHARED_MEM (BMCInst)->SerialSessionActive)
  996. // {
  997. // MsgPkt.Data [0] = SESSION_STATE_ACTIVE;
  998. // }
  999. // }
  1000. // /* Request to give Ping Message */
  1001. // MsgPkt.Channel = pBMCInfo->SERIALch;
  1002. // MsgPkt.Param = SERIAL_PING_REQUEST;
  1003. // MsgPkt.Size = 1;
  1004. // /* Post Ping Request */
  1005. // if( 0 != PostMsg (&MsgPkt,SERIAL_IFC_Q ,BMCInst))
  1006. // {
  1007. // IPMI_WARNING ("SerialModem.c: Unable to post messages to hSerialIfc_Q\n");
  1008. // }
  1009. // }
  1010. // /*---------------------------------------
  1011. // * GetTAPResponseCodes
  1012. // *---------------------------------------*/
  1013. // int
  1014. // GetTAPResponseCodes (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  1015. // {
  1016. // _NEAR_ GetTAPResCodeReq_T* Req = (_NEAR_ GetTAPResCodeReq_T*) pReq;
  1017. // _NEAR_ GetTAPResCodeRes_T* Res = (_NEAR_ GetTAPResCodeRes_T*) pRes;
  1018. // _FAR_ TAPResCode_T* TAPCodes = &(((_FAR_ BMCSharedMem_T*) BMC_GET_SHARED_MEM (BMCInst))->TAPRes);
  1019. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1020. // IPMI_DBG_PRINT ("Get TAP Respone Code CMD\n");
  1021. // if(Req->ChannelNo & RESERVED_BITS_GETTAPRESPONSECODES_CH)
  1022. // {
  1023. // *pRes = CC_INV_DATA_FIELD;
  1024. // return sizeof(*pRes);
  1025. // }
  1026. // /* Check Channel No */
  1027. // if (Req->ChannelNo != pBMCInfo->SERIALch)
  1028. // {
  1029. // Res->CompCode = CC_INV_DATA_FIELD;
  1030. // return sizeof (*pRes);
  1031. // }
  1032. // /*Load Response Codes*/
  1033. // Res->CompCode = CC_NORMAL;
  1034. // LOCK_BMC_SHARED_MEM(BMCInst);
  1035. // _fmemcpy (&pRes [1],TAPCodes,sizeof (TAPResCode_T));
  1036. // UNLOCK_BMC_SHARED_MEM(BMCInst);
  1037. // return sizeof (GetTAPResCodeRes_T);
  1038. // }
  1039. // /**
  1040. // * SetSerialPort
  1041. // * @brief Initilize the Serial port
  1042. // **/
  1043. // int
  1044. // SetSerialPort (int BMCInst)
  1045. // {
  1046. // INT8U BaudRate;
  1047. // //INT8U FlowCtrl;
  1048. // //int status;
  1049. // int fd;
  1050. // struct termios tty_struct;
  1051. // _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo[BMCInst];
  1052. // if ((fd = open(pBMCInfo->IpmiConfig.pSerialPort, O_RDONLY)) < 0)
  1053. // {
  1054. // IPMI_WARNING ("Can't open serial port..%s\n",strerror(errno));
  1055. // return -1;
  1056. // }
  1057. // /* Get the default Baudrate & FlowControl from Serial Modem configureation */
  1058. // BaudRate = pBMCInfo->SMConfig.IpmiMsgCommSet.BitRate;
  1059. // //FlowCtrl = pBMCInfo->SMConfig.IpmiMsgCommSet.FlowCtrl;
  1060. // tcgetattr(fd,&tty_struct); /* get termios structure */
  1061. // switch (BaudRate)
  1062. // {
  1063. // case BAUD_RATE_9600:
  1064. // cfsetospeed(&tty_struct, B9600);
  1065. // cfsetispeed(&tty_struct, B9600);
  1066. // break;
  1067. // case BAUD_RATE_19200:
  1068. // cfsetospeed(&tty_struct, B19200);
  1069. // cfsetispeed(&tty_struct, B19200);
  1070. // break;
  1071. // case BAUD_RATE_38400:
  1072. // cfsetospeed(&tty_struct, B38400);
  1073. // cfsetispeed(&tty_struct, B38400);
  1074. // break;
  1075. // case BAUD_RATE_57600:
  1076. // cfsetospeed(&tty_struct, B57600);
  1077. // cfsetispeed(&tty_struct, B57600);
  1078. // break;
  1079. // case BAUD_RATE_115200:
  1080. // cfsetospeed(&tty_struct, B115200);
  1081. // cfsetispeed(&tty_struct, B115200);
  1082. // break;
  1083. // default:
  1084. // IPMI_ERROR ("SerialIfc.c : Invalid baud rate\n");
  1085. // }
  1086. // tty_struct.c_cflag |= CS8; /* Set 8bits/charecter */
  1087. // tty_struct.c_cflag &= ~CSTOPB; /* set framing to 1 stop bits */
  1088. // tty_struct.c_cflag &= ~(PARENB); /* set parity to NONE */
  1089. // tty_struct.c_iflag &= ~(INPCK);
  1090. // /* set the new attributes in the tty driver */
  1091. // tcsetattr(fd, TCSANOW, &tty_struct);
  1092. // close (fd);
  1093. // return 0;
  1094. // }