sensor_sdr.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. /*
  2. * config sensor sdr in here.
  3. * Author:Jimbo
  4. */
  5. #include "sensor_sdr.h"
  6. #include "sensor_thread.h"
  7. #include <stdio.h>
  8. #include <stdint.h>
  9. #include "bmc_main.h"
  10. #include "bmc_type.h"
  11. /*
  12. * sensor sdr table, use sensor number as index.
  13. */
  14. static INT16U SDR_ReserveSDRRepository (void);
  15. static MgmtCtrlrDevLocator_T MgmtCtrlrDevLocator =
  16. {
  17. /* SDR Record Header */
  18. 0x01, /* Record ID */
  19. 0x51, /* SDR Version */
  20. 0x12, /* Record Type */
  21. 11 + MAX_ID_STR_LEN,//sizeof "AST2300",/* Record Length = 11+ string length*/
  22. /* Record Key Bytes*/
  23. 0x2a, /* Slave address - 0x20 Primary BMC */
  24. 0x00, /* ChannelNumber - 0x00 Primary BMC */
  25. /* Record Body Bytes */
  26. 0x0, /* power state notification */
  27. 0xff, /* Device Capablities */
  28. {0x00,0x00,0x00}, /* RESERVED */
  29. 0x0, /* Entity ID */
  30. 0x1, /* Entity Instance */
  31. 0x0, /* OEM */
  32. 0xc0 + MAX_ID_STR_LEN, /* ID String Type / Length Code */
  33. "AST2300"
  34. };
  35. static SDRRec_T sdr_tbl[]=
  36. {
  37. /*
  38. * sensor number: 0
  39. * sensor name: LM73
  40. * brief: temporary
  41. */
  42. (FullSensorRec_T){
  43. /* SDR Record Header */
  44. 0x02, //Record ID
  45. 0x51, //SDR Version
  46. 0x01, //Record Type
  47. 43+MAX_ID_STR_LEN,//MAX_ID_STR_LEN,//0x43+MAX_ID_STR_LEN, //Record Length = 43+string length
  48. /* Record Key Bytes */
  49. 0x20, //Sensor Owner ID
  50. 0x0, //Sensor Owner LUN
  51. 0x0,//0x1//sensor_tbl[0].sensor_number, //Sensor Number
  52. /* Record Body Bytes */
  53. 0x7, //Entity ID
  54. 0x1, //Entity Instance
  55. 0x7f, //Entity Initialization
  56. 0x68, //Sensor Capabilities
  57. 0x01, //Sensor Type
  58. 0x01, //Event / Reading Type
  59. 0x7a95, //Lower Threshold Reading Mask
  60. 0x7a95, //Upper Threshold Reading Mask
  61. 0x3f3f, //Settable / Readable Threshold Mask
  62. (0x2<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  63. 0x1, //Sensor Units 2 - Base Unit
  64. 0x0, //Sensor Units 3 - Modifier Unit
  65. 0x0, //Linerization
  66. 0x2, //M
  67. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  68. 0x0, //B
  69. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  70. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  71. (0x0<<4)+(0x0&0x0F), //R exponent,B exponent
  72. 0x0, //Analog Characteristics Flags
  73. 0x7f, //Nominal Reading
  74. 0x7f, //Normal Maximum
  75. 0x80, //Normal Minimum
  76. 0x7f, //Sensor Maximum Reading
  77. 0x80, //Sensor Minimum Reading
  78. 0x7f, //Upper Non-Recoverable Threshold
  79. 0x7f, //Upper Critical Threshold
  80. 0x7f, //Upper Non-Critical Threshold
  81. 0x80, //Lower Non-Recoverable Threshold
  82. 0x80, //Lower Critical Threshold
  83. 0x80, //Lower Non-Critical threshold
  84. 0x0, //Positive - threshold Hysteresis value
  85. 0x0, //Negative - threshold Hysteresis value
  86. 0x0, //Reserved
  87. 0x0, //Reserved
  88. 0x0, //OEM
  89. 0xC0+MAX_ID_STR_LEN,//MAX_ID_STR_LEN, //ID String Type / Length Code
  90. "lm73_1"
  91. },
  92. /*
  93. * sensor number: 1
  94. * sensor name: LM73
  95. * brief: temporary
  96. */
  97. (FullSensorRec_T){
  98. /* SDR Record Header */
  99. 0x03, //Record ID
  100. 0x51, //SDR Version
  101. 0x01, //Record Type
  102. 43+MAX_ID_STR_LEN,//0x43+MAX_ID_STR_LEN, //Record Length = 43+string length
  103. /* Record Key Bytes */
  104. 0x20, //Sensor Owner ID
  105. 0x0, //Sensor Owner LUN
  106. 0x1,//sensor_tbl[1].sensor_number, //Sensor Number
  107. /* Record Body Bytes */
  108. 0x8, //Entity ID
  109. 0x1, //Entity Instance
  110. 0x7f, //Entity Initialization
  111. 0x68, //Sensor Capabilities
  112. 0x02, //Sensor Type
  113. 0x01, //Event / Reading Type
  114. 0x7a95, //Lower Threshold Reading Mask
  115. 0x7a95, //Upper Threshold Reading Mask
  116. 0x3f3f, //Settable / Readable Threshold Mask
  117. (0x2<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  118. 0x4, //Sensor Units 2 - Base Unit
  119. 0x0, //Sensor Units 3 - Modifier Unit
  120. 0x0, //Linerization
  121. 0x2, //M
  122. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  123. 0x0, //B
  124. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  125. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  126. (0x0<<4)+(0x0&0x0F), //R exponent,B exponent
  127. 0x0, //Analog Characteristics Flags
  128. 0x7f, //Nominal Reading
  129. 0x7f, //Normal Maximum
  130. 0x80, //Normal Minimum
  131. 0x7f, //Sensor Maximum Reading
  132. 0x80, //Sensor Minimum Reading
  133. 0x7f, //Upper Non-Recoverable Threshold
  134. 0x7f, //Upper Critical Threshold
  135. 0x7f, //Upper Non-Critical Threshold
  136. 0x80, //Lower Non-Recoverable Threshold
  137. 0x80, //Lower Critical Threshold
  138. 0x80, //Lower Non-Critical threshold
  139. 0x0, //Positive - threshold Hysteresis value
  140. 0x0, //Negative - threshold Hysteresis value
  141. 0x0, //Reserved
  142. 0x0, //Reserved
  143. 0x0, //OEM
  144. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  145. "lm73_2"
  146. },
  147. /*
  148. * * sensor number: 1
  149. * * sensor name: LM73
  150. * * brief: temporary
  151. * */
  152. (FullSensorRec_T){
  153. /* SDR Record Header */
  154. 0x04, //Record ID_H
  155. 0x51, //SDR Version
  156. 0x01, //Record Type
  157. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  158. /* Record Key Bytes */
  159. 0x20, //Sensor Owner ID
  160. 0x0, //Sensor Owner LUN
  161. 0x2,//sensor_tbl[2].sensor_number, //Sensor Number
  162. /* Record Body Bytes */
  163. 0x8, //Entity ID
  164. 0x1, //Entity Instance
  165. 0x7f, //Entity Initialization
  166. 0x68, //Sensor Capabilities
  167. 0x02, //Sensor Type
  168. 0x01, //Event / Reading Type
  169. 0x7a95, //Lower Threshold Reading Mask
  170. 0x7a95, //Upper Threshold Reading Mask
  171. 0x3f3f, //Settable / Readable Threshold Mask
  172. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  173. 0x4, //Sensor Units 2 - Base Unit
  174. 0x0, //Sensor Units 3 - Modifier Unit
  175. 0x0, //Linerization
  176. 16, //M
  177. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  178. 0x0, //B
  179. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  180. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  181. (13<<4)+(0x0&0x0F), //R exponent,B exponent
  182. 0x0, //Analog Characteristics Flags
  183. 0x0, //Nominal Reading
  184. 0xff, //Normal Maximum
  185. 0x00, //Normal Minimum
  186. 0xff, //Sensor Maximum Reading
  187. 0x00, //Sensor Minimum Reading
  188. 0xff, //Upper Non-Recoverable Threshold
  189. 0xff, //Upper Critical Threshold
  190. 0xff, //Upper Non-Critical Threshold
  191. 0x00, //Lower Non-Recoverable Threshold
  192. 0x00, //Lower Critical Threshold
  193. 0x00, //Lower Non-Critical threshold
  194. 0x0, //Positive - threshold Hysteresis value
  195. 0x0, //Negative - threshold Hysteresis value
  196. 0x0, //Reserved
  197. 0x0, //Reserved
  198. 0x0, //OEM
  199. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  200. "3V3_Vlot"
  201. },
  202. (FullSensorRec_T){
  203. /* SDR Record Header */
  204. 0x05, //Record ID_H
  205. 0x51, //SDR Version
  206. 0x01, //Record Type
  207. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  208. /* Record Key Bytes */
  209. 0x20, //Sensor Owner ID
  210. 0x0, //Sensor Owner LUN
  211. 0x3,//sensor_tbl[2].sensor_number, //Sensor Number
  212. /* Record Body Bytes */
  213. 0x8, //Entity ID
  214. 0x1, //Entity Instance
  215. 0x7f, //Entity Initialization
  216. 0x68, //Sensor Capabilities
  217. 0x02, //Sensor Type
  218. 0x01, //Event / Reading Type
  219. 0x7a95, //Lower Threshold Reading Mask
  220. 0x7a95, //Upper Threshold Reading Mask
  221. 0x3f3f, //Settable / Readable Threshold Mask
  222. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  223. 0x4, //Sensor Units 2 - Base Unit
  224. 0x0, //Sensor Units 3 - Modifier Unit
  225. 0x0, //Linerization
  226. 32, //M
  227. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  228. 0x0, //B
  229. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  230. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  231. (13<<4)+(0x0&0x0F), //R exponent,B exponent
  232. 0x0, //Analog Characteristics Flags
  233. 0x0, //Nominal Reading
  234. 0xff, //Normal Maximum
  235. 0x00, //Normal Minimum
  236. 0xff, //Sensor Maximum Reading
  237. 0x00, //Sensor Minimum Reading
  238. 0xff, //Upper Non-Recoverable Threshold
  239. 0xff, //Upper Critical Threshold
  240. 0xff, //Upper Non-Critical Threshold
  241. 0x00, //Lower Non-Recoverable Threshold
  242. 0x00, //Lower Critical Threshold
  243. 0x00, //Lower Non-Critical threshold
  244. 0x0, //Positive - threshold Hysteresis value
  245. 0x0, //Negative - threshold Hysteresis value
  246. 0x0, //Reserved
  247. 0x0, //Reserved
  248. 0x0, //OEM
  249. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  250. "5V0_Volt"
  251. },
  252. (FullSensorRec_T){
  253. /* SDR Record Header */
  254. 0x06, //Record ID_H
  255. 0x51, //SDR Version
  256. 0x01, //Record Type
  257. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  258. /* Record Key Bytes */
  259. 0x20, //Sensor Owner ID
  260. 0x0, //Sensor Owner LUN
  261. 0x4,//sensor_tbl[2].sensor_number, //Sensor Number
  262. /* Record Body Bytes */
  263. 0x8, //Entity ID
  264. 0x1, //Entity Instance
  265. 0x7f, //Entity Initialization
  266. 0x68, //Sensor Capabilities
  267. 0x02, //Sensor Type
  268. 0x01, //Event / Reading Type
  269. 0x7a95, //Lower Threshold Reading Mask
  270. 0x7a95, //Upper Threshold Reading Mask
  271. 0x3f3f, //Settable / Readable Threshold Mask
  272. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  273. 0x4, //Sensor Units 2 - Base Unit
  274. 0x0, //Sensor Units 3 - Modifier Unit
  275. 0x0, //Linerization
  276. 64, //M
  277. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  278. 0x0, //B
  279. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  280. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  281. (13<<4)+(0x0&0x0F), //R exponent,B exponent
  282. 0x0, //Analog Characteristics Flags
  283. 0x0, //Nominal Reading
  284. 0xff, //Normal Maximum
  285. 0x00, //Normal Minimum
  286. 0xff, //Sensor Maximum Reading
  287. 0x00, //Sensor Minimum Reading
  288. 0xff, //Upper Non-Recoverable Threshold
  289. 0xff, //Upper Critical Threshold
  290. 0xff, //Upper Non-Critical Threshold
  291. 0x00, //Lower Non-Recoverable Threshold
  292. 0x00, //Lower Critical Threshold
  293. 0x00, //Lower Non-Critical threshold
  294. 0x0, //Positive - threshold Hysteresis value
  295. 0x0, //Negative - threshold Hysteresis value
  296. 0x0, //Reserved
  297. 0x0, //Reserved
  298. 0x0, //OEM
  299. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  300. "12V0_Volt"
  301. },
  302. (FullSensorRec_T){
  303. /* SDR Record Header */
  304. 0x07, //Record ID_H
  305. 0x51, //SDR Version
  306. 0x01, //Record Type
  307. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  308. /* Record Key Bytes */
  309. 0x20, //Sensor Owner ID
  310. 0x0, //Sensor Owner LUN
  311. 0x5,//sensor_tbl[2].sensor_number, //Sensor Number
  312. /* Record Body Bytes */
  313. 0x8, //Entity ID
  314. 0x1, //Entity Instance
  315. 0x7f, //Entity Initialization
  316. 0x68, //Sensor Capabilities
  317. 0x03, //Sensor Type
  318. 0x01, //Event / Reading Type
  319. 0x7a95, //Lower Threshold Reading Mask
  320. 0x7a95, //Upper Threshold Reading Mask
  321. 0x3f3f, //Settable / Readable Threshold Mask
  322. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  323. 0x5, //Sensor Units 2 - Base Unit
  324. 0x0, //Sensor Units 3 - Modifier Unit
  325. 0x0, //Linerization
  326. 2, //M
  327. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  328. 0x0, //B
  329. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  330. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  331. (14<<4)+(0x0&0x0F), //R exponent,B exponent
  332. 0x0, //Analog Characteristics Flags
  333. 0x0, //Nominal Reading
  334. 0xff, //Normal Maximum
  335. 0x00, //Normal Minimum
  336. 0xff, //Sensor Maximum Reading
  337. 0x00, //Sensor Minimum Reading
  338. 0xff, //Upper Non-Recoverable Threshold
  339. 0xff, //Upper Critical Threshold
  340. 0xff, //Upper Non-Critical Threshold
  341. 0x00, //Lower Non-Recoverable Threshold
  342. 0x00, //Lower Critical Threshold
  343. 0x00, //Lower Non-Critical threshold
  344. 0x0, //Positive - threshold Hysteresis value
  345. 0x0, //Negative - threshold Hysteresis value
  346. 0x0, //Reserved
  347. 0x0, //Reserved
  348. 0x0, //OEM
  349. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  350. "3V3_Amps"
  351. },
  352. (FullSensorRec_T){
  353. /* SDR Record Header */
  354. 0x08, //Record ID_H
  355. 0x51, //SDR Version
  356. 0x01, //Record Type
  357. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  358. /* Record Key Bytes */
  359. 0x20, //Sensor Owner ID
  360. 0x0, //Sensor Owner LUN
  361. 0x6,//sensor_tbl[2].sensor_number, //Sensor Number
  362. /* Record Body Bytes */
  363. 0x8, //Entity ID
  364. 0x1, //Entity Instance
  365. 0x7f, //Entity Initialization
  366. 0x68, //Sensor Capabilities
  367. 0x03, //Sensor Type
  368. 0x01, //Event / Reading Type
  369. 0x7a95, //Lower Threshold Reading Mask
  370. 0x7a95, //Upper Threshold Reading Mask
  371. 0x3f3f, //Settable / Readable Threshold Mask
  372. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  373. 0x5, //Sensor Units 2 - Base Unit
  374. 0x0, //Sensor Units 3 - Modifier Unit
  375. 0x0, //Linerization
  376. 2, //M
  377. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  378. 0x0, //B
  379. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  380. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  381. (14<<4)+(0x0&0x0F), //R exponent,B exponent
  382. 0x0, //Analog Characteristics Flags
  383. 0x0, //Nominal Reading
  384. 0xff, //Normal Maximum
  385. 0x00, //Normal Minimum
  386. 0xff, //Sensor Maximum Reading
  387. 0x00, //Sensor Minimum Reading
  388. 0xff, //Upper Non-Recoverable Threshold
  389. 0xff, //Upper Critical Threshold
  390. 0xff, //Upper Non-Critical Threshold
  391. 0x00, //Lower Non-Recoverable Threshold
  392. 0x00, //Lower Critical Threshold
  393. 0x00, //Lower Non-Critical threshold
  394. 0x0, //Positive - threshold Hysteresis value
  395. 0x0, //Negative - threshold Hysteresis value
  396. 0x0, //Reserved
  397. 0x0, //Reserved
  398. 0x0, //OEM
  399. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  400. "5V0_Amps"
  401. },
  402. (FullSensorRec_T){
  403. /* SDR Record Header */
  404. 0x09, //Record ID_H
  405. 0x51, //SDR Version
  406. 0x01, //Record Type
  407. 43+MAX_ID_STR_LEN, //Record Length = 43+string length
  408. /* Record Key Bytes */
  409. 0x20, //Sensor Owner ID
  410. 0x0, //Sensor Owner LUN
  411. 0x7,//sensor_tbl[2].sensor_number, //Sensor Number
  412. /* Record Body Bytes */
  413. 0x8, //Entity ID
  414. 0x1, //Entity Instance
  415. 0x7f, //Entity Initialization
  416. 0x68, //Sensor Capabilities
  417. 0x03, //Sensor Type
  418. 0x01, //Event / Reading Type
  419. 0x7a95, //Lower Threshold Reading Mask
  420. 0x7a95, //Upper Threshold Reading Mask
  421. 0x3f3f, //Settable / Readable Threshold Mask
  422. (0x00<<6)+(0x0<<3)+(0x0<<1)+0x0, //Sensor Units 1
  423. 0x5, //Sensor Units 2 - Base Unit
  424. 0x0, //Sensor Units 3 - Modifier Unit
  425. 0x0, //Linerization
  426. 2, //M
  427. ((0x2>>2)&0xC0)+(0x0&0x3F), //M,Tolerance
  428. 0x0, //B
  429. ((0x0>>2)&0xC0)+(0x0&0x3F), //B,Accuracy
  430. ((0x0>>2)&0xF0)+(0x0&0x0C)+0x0, //Accuracy,Accuracy exponent
  431. (14<<4)+(0x0&0x0F), //R exponent,B exponent
  432. 0x0, //Analog Characteristics Flags
  433. 0x0, //Nominal Reading
  434. 0xff, //Normal Maximum
  435. 0x00, //Normal Minimum
  436. 0xff, //Sensor Maximum Reading
  437. 0x00, //Sensor Minimum Reading
  438. 0xff, //Upper Non-Recoverable Threshold
  439. 0xff, //Upper Critical Threshold
  440. 0xff, //Upper Non-Critical Threshold
  441. 0x00, //Lower Non-Recoverable Threshold
  442. 0x00, //Lower Critical Threshold
  443. 0x00, //Lower Non-Critical threshold
  444. 0x0, //Positive - threshold Hysteresis value
  445. 0x0, //Negative - threshold Hysteresis value
  446. 0x0, //Reserved
  447. 0x0, //Reserved
  448. 0x0, //OEM
  449. 0xC0+MAX_ID_STR_LEN, //ID String Type / Length Code
  450. "12V0_Amps"
  451. },
  452. {0} //dummy sdr when 0 sensors
  453. };
  454. SDRRec_T *getSensorSdr(uint8_t sensorNum)
  455. {
  456. uint8_t temp = 0;
  457. temp = sizeof(sdr_tbl)/sizeof(SDRRec_T);
  458. if(temp != MAX_SENSOR_NUM+1) //there is a dummy sdr
  459. {
  460. printf("Error:Invalid sdr table!\n");
  461. return NULL;
  462. }
  463. if(sensorNum >= MAX_SENSOR_NUM)
  464. {
  465. printf("Error: Invalid sensor number!\n");
  466. return NULL;
  467. }
  468. return &sdr_tbl[sensorNum];
  469. }
  470. /*---------------------------------------
  471. * * GetSDRRepositoryInfo
  472. * *---------------------------------------*/
  473. int
  474. GetSDRRepositoryInfo (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  475. {
  476. // printf("start GetSDRRepositoryInfo\n");
  477. _NEAR_ SDRRepositoryInfo_T* pSDRRepInfoRes =(_NEAR_ SDRRepositoryInfo_T*) pRes;
  478. memset (pSDRRepInfoRes, 0, sizeof (SDRRepositoryInfo_T));
  479. pSDRRepInfoRes->CompletionCode = 0x00;
  480. pSDRRepInfoRes->Version=0x51;
  481. pSDRRepInfoRes->RecCt=MAX_SENSOR_NUM+1;
  482. pSDRRepInfoRes->FreeSpace=0x5023;
  483. pSDRRepInfoRes->AddTimeStamp=0x00;
  484. pSDRRepInfoRes->EraseTimeStamp=0x00;
  485. pSDRRepInfoRes->OpSupport=0x27;
  486. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  487. return sizeof (SDRRepositoryInfo_T);
  488. }
  489. /*---------------------------------------
  490. * * ReserveSDRRepository
  491. * *---------------------------------------*/
  492. int ReserveSDRRepository (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  493. {
  494. BMCInfo_t *pBMCInfo = &g_BMCInfo;//[BMCInst];
  495. _NEAR_ ReserveSDRRepositoryRes_T* pResSDRRepRes =
  496. (_NEAR_ ReserveSDRRepositoryRes_T*) pRes;
  497. INT16U ID;
  498. memset(pResSDRRepRes,0,sizeof(ReserveSDRRepositoryRes_T)-1);
  499. ID=SDR_ReserveSDRRepository();
  500. // printf("ID is %d\n",ID);
  501. pResSDRRepRes->ReservationID_H = ID&0x00ff;//ID>>8;
  502. pResSDRRepRes->ReservationID_L = ID>>8;
  503. pResSDRRepRes->CompletionCode = 0x00;//CC_NORMAL;
  504. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  505. return sizeof (ReserveSDRRepositoryRes_T);
  506. }
  507. /*---------------------------------------
  508. * * GetSDR
  509. * *---------------------------------------*/
  510. int
  511. GetSDR (_NEAR_ INT8U* pReq, INT8U ReqLen, _NEAR_ INT8U* pRes,_NEAR_ int BMCInst)
  512. {
  513. // printf("start GetSDR:\n");
  514. char * pFullSensorRec;
  515. int i=0;
  516. _NEAR_ GetSDRReq_T* pGetSDRReq = (_NEAR_ GetSDRReq_T*) pReq;
  517. _NEAR_ GetSDRRes_T* pGetSDRRes = (_NEAR_ GetSDRRes_T*) pRes;
  518. _FAR_ BMCInfo_t* pBMCInfo = &g_BMCInfo;//[BMCInst];
  519. char RecID = pGetSDRReq->RecID;
  520. INT16U recordoffset=pGetSDRReq->Offset;
  521. if(RecID==0)
  522. pFullSensorRec=&MgmtCtrlrDevLocator;
  523. else
  524. {
  525. if(RecID != pBMCInfo->sensorInfo[RecID-2].sensorSdr->full_sensor_rec.hdr.ID)
  526. {
  527. printf("sdr_tbl ID err\n");
  528. return 1;
  529. }
  530. pFullSensorRec=&pBMCInfo->sensorInfo[RecID-2].sensorSdr->Data;
  531. }
  532. pGetSDRRes->CompletionCode = 0x00;
  533. if(RecID==0)
  534. {
  535. pGetSDRRes->NextRecID = 0x02;
  536. }
  537. else if(RecID==MAX_SENSOR_NUM+1)
  538. {
  539. pGetSDRRes->NextRecID = 0xffff;
  540. }
  541. else
  542. {
  543. pGetSDRRes->NextRecID = RecID+1;
  544. }
  545. /*from 4 byte to 1byte change*/
  546. uint8_t *Res=pGetSDRRes;
  547. memcpy(&Res[3],&pFullSensorRec[recordoffset],pGetSDRReq->Size);
  548. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  549. return sizeof (GetSDRRes_T) + pGetSDRReq->Size;
  550. }
  551. static INT16U SDR_ReserveSDRRepository ()
  552. {
  553. BMCInfo_t *pBMCInfo = &g_BMCInfo;
  554. // printf("pBMCInfo->SDRConfig.ReservationID is %d,\n",pBMCInfo->SDRConfig.ReservationID);
  555. if (0xffff == pBMCInfo->SDRConfig.ReservationID)
  556. {
  557. pBMCInfo->SDRConfig.ReservationID = 1;
  558. }else
  559. {
  560. pBMCInfo->SDRConfig.ReservationID++;
  561. }
  562. SessionSequenceNumberCount=SessionSequenceNumberCount+1;
  563. return pBMCInfo->SDRConfig.ReservationID;
  564. }