-
Notifications
You must be signed in to change notification settings - Fork 39
/
amec_amester.c
executable file
·1543 lines (1359 loc) · 58.1 KB
/
amec_amester.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/occ/amec/amec_amester.c $ */
/* */
/* OpenPOWER OnChipController Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2015 */
/* [+] International Business Machines Corp. */
/* */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); */
/* you may not use this file except in compliance with the License. */
/* You may obtain a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
/* implied. See the License for the specific language governing */
/* permissions and limitations under the License. */
/* */
/* IBM_PROLOG_END_TAG */
//*************************************************************************/
// Includes
//*************************************************************************/
#include <occ_common.h>
#include <ssx.h>
#include <errl.h> // Error logging
#include <rtls.h>
#include <occ_service_codes.h> // for SSX_GENERIC_FAILURE
#include <sensor.h>
#include <amec_smh.h>
#include <amec_master_smh.h>
#include <amec_amester.h>
#include <amec_sys.h>
#include <trac.h> // For traces
#include <sensor_query_list.h>
#include <proc_data.h>
#include <amec_parm.h>
#include <string.h>
#include <occ_sys_config.h>
#include <dcom.h>
//*************************************************************************/
// Externs
//*************************************************************************/
extern uint32_t G_present_hw_cores;
//*************************************************************************/
// Macros
//*************************************************************************/
//*************************************************************************/
// Defines/Enums
//*************************************************************************/
///Maximum size of trace buffer
#define AMEC_TB_2MS_SIZE_BYTES 8192
#define AMEC_TB_250US_SIZE_BYTES 8192
#define AMEC_TB_SIZE_BYTES (AMEC_TB_250US_SIZE_BYTES + AMEC_TB_2MS_SIZE_BYTES)
///Maximum number of trace buffers we will support
#define AMEC_MAX_NUM_TB 2
///Maximum size of config info for 1 trace buffer
#define AMEC_TB_CONFIG_SIZE (MAX_SENSOR_NAME_SZ + 4)
#define MAX_NUM_CHIPS MAX_NUM_OCC
//*************************************************************************/
// Structures
//*************************************************************************/
//*************************************************************************/
// Globals
//*************************************************************************/
// Each trace buffer should be aligned to 128 bytes in main memory because the
// block copy engine only copies multiples of 128 byte units.
// Make this a power of 2 (bytes) in size and aligned to 4 bytes.
DMA_BUFFER(UINT8 g_amec_tb_bytes[AMEC_TB_SIZE_BYTES]);
// Array that maintains a list of all trace buffers built.
// NOTE: Must be in same order as AMEC_TB_ENUM
DMA_BUFFER(amec_tb_t g_amec_tb_list[AMEC_MAX_NUM_TB]) = {
//trace 2ms
[AMEC_TB_2MS] = {
"trace2ms", // name
AMEFP(500,0), // freq
(UINT8*)(UINT32)g_amec_tb_bytes, // bytes
AMEC_TB_2MS_SIZE_BYTES, // size
0, // entry_size
0, // entry_n
0, // write
0, // read
0, // sensors_n
0, // parm_n
{0}, // sensors_field[]
{0}, // sensors_num[]
{0} // parms_num[]
},
// trace 250us
[AMEC_TB_250US] = {
"trace250us", // name
AMEFP(4000,0), // freq
(UINT8*)(UINT32)g_amec_tb_bytes+AMEC_TB_2MS_SIZE_BYTES, // bytes
AMEC_TB_250US_SIZE_BYTES, //size
0, // entry_size
0, // entry_n
0, // write
0, // read
0, // sensors_n
0, // parm_n
{0}, // sensors_field[]
{0}, // sensors_num[]
{0} // parms_num[]
}
};
//Throw a compiler error when the enum and array are not both updated
STATIC_ASSERT((AMEC_TB_NUMBER_OF_TRACES != (sizeof(g_amec_tb_list)/sizeof(amec_tb_t))));
///=1 signals a trace is being taken
UINT8 g_amec_tb_record=0;
///=1 signals continuous tracing
UINT8 g_amec_tb_continuous=0; //CL273
//*************************************************************************/
// Function Prototypes
//*************************************************************************/
//*************************************************************************/
// Functions
//*************************************************************************/
// Function Specification
//
// Name: amester_get_sensor_info
//
// Description: Returns name, units, update frequency, and scalefactor for a sensor
//
// Task Flags:
//
// End Function Specification
static uint8_t amester_get_sensor_info( uint8_t* o_resp, uint16_t* io_resp_length, const uint8_t i_type, const uint16_t i_sensor)
{
uint8_t l_rc = COMPCODE_NORMAL; // assume no error
sensor_t * l_sensor_ptr = NULL;
uint16_t l_numOfSensors = 1;
sensor_info_t l_sensorInfo;
errlHndl_t l_err = NULL;
uint16_t l_resp_length = 0;
do
{
// Check o_resp and io_resp_length pointers
if( (o_resp == NULL) ||
(io_resp_length == NULL) )
{
l_rc = COMPCODE_UNSPECIFIED;
break;
}
l_resp_length = *io_resp_length;
*io_resp_length = 0;
if (i_sensor >= MAX_AMEC_SENSORS )
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
l_sensor_ptr = getSensorByGsid(i_sensor);
if(l_sensor_ptr == NULL)
{
// Didn't find it
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
querySensorListArg_t l_qsl_arg = {
i_sensor, // i_startGsid
0, // i_present
SENSOR_TYPE_ALL, // i_type
SENSOR_LOC_ALL, // i_loc
&l_numOfSensors, // io_numOfSensors
NULL, // o_sensors
&l_sensorInfo // o_sensorInfoPtr
};
// Get sensor list
l_err = querySensorList(&l_qsl_arg);
if( NULL != l_err)
{
// Query failure, it should not happens
TRAC_ERR("amester_get_sensor_info: Failed to get sensor list. Error status is : 0x%x", l_err->iv_reasonCode);
// commit error log
commitErrl( &l_err );
l_rc = COMPCODE_UNSPECIFIED;
break;
}
switch (i_type)
{
case AME_INFO_NAME:
{
char *src = l_sensorInfo.name;
char *dest = (char*)o_resp;
uint16_t l_length = strlen(src)+1; // add string terminator
// Check length
if(l_resp_length < l_length)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
// Copy string
strcpy( dest, src );
*io_resp_length = l_length;
break;
}
case AME_INFO_UNITS:
{
char *src = l_sensorInfo.sensor.units;
char *dest = (char*)o_resp;
uint16_t l_length = strlen(src)+1; // add string terminator
// Check length
if(l_resp_length < l_length)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
// Copy string
strcpy( dest, src );
*io_resp_length = l_length;
break;
}
case AME_INFO_FREQ:
{
uint16_t l_length = sizeof( uint32_t);
// Check length
if(l_resp_length < l_length)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
*((uint32_t *)o_resp) = l_sensorInfo.sensor.freq;
*io_resp_length = l_length;
break;
}
case AME_INFO_SCALE:
{
uint16_t l_length = sizeof( uint32_t);
// Check length
if(l_resp_length < l_length)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
*((uint32_t *)o_resp) = l_sensorInfo.sensor.scalefactor;
*io_resp_length = l_length;
break;
}
case AME_INFO_ALL: //Added for AME API 2.16
{
char *src = NULL;
char *dest = (char*)o_resp;
uint16_t l_length = strlen(l_sensorInfo.name) + 1 +\
strlen(l_sensorInfo.sensor.units) + 1 + \
sizeof(uint32_t) + sizeof(uint32_t);
// Check length
if(l_resp_length < l_length)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
src = l_sensorInfo.name;
// Copy string
strcpy( dest, src );
dest += strlen(src)+1; // add string terminator
src = l_sensorInfo.sensor.units;
// Copy string
strcpy( dest, src );
dest += strlen(src)+1; // add string terminator
*((uint32_t *)dest) = l_sensorInfo.sensor.freq;
dest+= 4;
*((uint32_t *)dest) = l_sensorInfo.sensor.scalefactor;
dest+= 4;
*io_resp_length = (uint8_t) ((uint32_t)dest - (uint32_t)o_resp);
break;
}
default:
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
} // End of switch case
} while (0);
return l_rc;
}
// Function Specification
//
// Name: amester_api
//
// Description: amester entry point for ipmicommand 0x3C
//
// Task Flags:
//
// End Function Specification
uint8_t amester_api( const IPMIMsg_t * i_msg,
uint16_t * io_resp_length,
uint8_t * o_resp )
{
uint8_t l_rc = COMPCODE_NORMAL;
uint8_t l_temp_buffer[ sizeof(sensor_info_t) ];
sensor_t *l_sensor_ptr = NULL;
uint16_t l_sensor_id = 0; // sensor id
uint16_t l_sensor_count = 0; // sensor count
uint8_t l_sensor_type = 0; // sensor type
uint16_t l_maxlen = 0, l_retlen = 0; // for echo command and 0xff command
uint16_t l_resp_length = *io_resp_length;
sensorrec_t SensorInfo;
switch( i_msg->au8CmdData_ptr[0] )
{
// commands 0x01 ~ 0x1B are DEPRECATED except 0x07, 0x0A
case 0x07: // Get Multiple Sensor Data
{
uint16_t l_in; // input pointer
uint16_t l_out=0; // output pointer
char *t;
int k;
l_rc = COMPCODE_NORMAL;; // assume no error
// Process each sensor in turn
for (l_in = 1; l_in + 1 < i_msg->u8CmdDataLen; l_in=l_in+2)
{
// exit when a return message is filled. -1 is for IPMI return code
if (l_out + AME_SDRS > IPMI_MAX_MSG_SIZE - 1) break;
// Get the next sensor
l_sensor_id = CONVERT_UINT8_ARRAY_UINT16(i_msg->au8CmdData_ptr[l_in],
i_msg->au8CmdData_ptr[l_in+1]);
l_sensor_ptr = getSensorByGsid(l_sensor_id);
if(l_sensor_ptr == NULL)
{
// Mark which sensor number does not exist
o_resp[0] = (uint8_t)(l_in >> 8);
o_resp[1] = (uint8_t)(l_in);
*io_resp_length = 2;
l_rc = COMPCODE_DEST_UNAVAILABLE;
break;
}
/* Get a snap-shot of this sensors registers */
/* This copy is required so the bytes in each field are self-consistent
since the AME interrupt can modify them at any time. Note that it is
possible that the fields are not consistent with each other, but this
is how Amester has always been. Use traces to get a consistent view.*/
SensorInfo.timestamp=G_current_tick;
SensorInfo.updates=l_sensor_ptr->update_tag;
SensorInfo.accumulated_value=l_sensor_ptr->accumulator;
SensorInfo.value=l_sensor_ptr->sample;
SensorInfo.value_min=l_sensor_ptr->sample_min;
SensorInfo.value_max=l_sensor_ptr->sample_max;
memcpy(&SensorInfo.status,&l_sensor_ptr->status,sizeof(uint16_t));
// Copy to output buffer.
t=(char *)&SensorInfo;
for (k=0;k<AME_SDRS;k++) o_resp[l_out++]=*t++;
*io_resp_length = l_out;
} // for each sensor
break;
};
case 0x0a: // Get API version
o_resp[0] = AME_API_MAJ;
o_resp[1] = AME_API_MIN;
*io_resp_length = 2;
l_rc = COMPCODE_NORMAL;
break;
//----------------------------------------------------------------------
// AME 2.16 commands
//----------------------------------------------------------------------
case 0x1c: // AME component level constants
// Goal is to allow 1 IPMI to get a bunch of important data at startup.
// Dramatically speedup Amester initialization
// Check length
if(l_resp_length < AME_COMPONENT_LEVEL_RSPCMD_LEN)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
o_resp[0] = AME_API_MAJ;
o_resp[1] = AME_API_MIN;
o_resp[2] = AME_VERSION_MAJ;
o_resp[3] = AME_VERSION_MIN;
o_resp[4] = CONVERT_UINT16_UINT8_HIGH(AME_YEAR);
o_resp[5] = CONVERT_UINT16_UINT8_LOW(AME_YEAR);
o_resp[6] = AME_MONTH;
o_resp[7] = AME_DAY;
o_resp[8] = CONVERT_UINT16_UINT8_HIGH(G_amec_sensor_count);
o_resp[9] = CONVERT_UINT16_UINT8_LOW(G_amec_sensor_count);
o_resp[10] = AMEC_TB_NUMBER_OF_TRACES;
*io_resp_length = AME_COMPONENT_LEVEL_RSPCMD_LEN;
l_rc = COMPCODE_NORMAL;
break;
case 0x1d:
// Check length
if(l_resp_length < 2)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
o_resp[0] = 0;
o_resp[1] = 0;
*io_resp_length = 2;
l_rc = COMPCODE_NORMAL;
break;
//Clear min/max fields in all sensors.
case 0x21:
l_sensor_ptr = NULL;
l_sensor_count = G_amec_sensor_count;
// clear min/max
uint16_t i = 0;
for( i = 0;i < l_sensor_count; i++)
{
l_sensor_ptr = getSensorByGsid(i);
sensor_clear_minmax(l_sensor_ptr);
}
*io_resp_length = 0;
l_rc = COMPCODE_NORMAL;
break;
case 0x25: // Get sensors info
l_rc = COMPCODE_NORMAL;
l_sensor_type = i_msg->au8CmdData_ptr[3];
l_sensor_count = G_amec_sensor_count;
l_sensor_id = CONVERT_UINT8_ARRAY_UINT16( i_msg->au8CmdData_ptr[1],
i_msg->au8CmdData_ptr[2] );
uint16_t j = 0;
uint16_t l_final_length = 0;
for( j = l_sensor_id; j < l_sensor_count; j++)
{
*io_resp_length = sizeof(sensor_info_t);
l_rc = amester_get_sensor_info(l_temp_buffer,io_resp_length,l_sensor_type,j);
if(l_rc != COMPCODE_NORMAL)
{
l_final_length = 0;
break;
}
// max response length is IPMI_MAX_MSG_SIZE
if( ((l_final_length+(*io_resp_length)) < IPMI_MAX_MSG_SIZE) &&
((l_final_length+(*io_resp_length)) < l_resp_length ) )
{
memcpy( o_resp, l_temp_buffer, *io_resp_length); // Copy to final output buffer
o_resp += (*io_resp_length);
l_final_length = l_final_length+(*io_resp_length);
}
else
{
break;
}
}
*io_resp_length = l_final_length;
break;
// Trace buffer commands
// Get trace buffer configuration
case 0x30:
amec_tb_cmd_info(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Configure TB
case 0x31:
amec_tb_cmd_set_config(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Read TB
// Input is an index into the buffer.
// Output is a full-sized response, possibly wrapping around at end of buffer.
case 0x32:
amec_tb_cmd_read(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Start recording TB
case 0x33:
amec_tb_cmd_start_recording(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Stop recording TB
case 0x34:
amec_tb_cmd_stop_recording(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Get sensor table, not support
case 0x35: //No support
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
// Get SCOM table, not support
case 0x36: //No support
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
// Return all configurable parameters for a trace
case 0x3f:
amec_tb_cmd_get_config(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Get number of parameters
case 0x40:
amec_parm_get_number(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Return configuration of parameters starting with a given guid
case 0x41:
amec_parm_get_config(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Read parameter
case 0x42:
amec_parm_read(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Write parameter
case 0x43:
amec_parm_write(i_msg,o_resp,io_resp_length,&l_rc);
break;
// Partition management
case 0x50: //No support
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
// Note: Amester uses the echo command to figure out how much data it is
// allowed to send in 1 message to OCC.
case 0xfe: //echo
l_maxlen = IPMI_MAX_MSG_SIZE - 1; // -1 for completion code
l_retlen = l_maxlen;
// Pick the smaller of the input length and max output length.
if (i_msg->u8CmdDataLen < l_maxlen)
{
l_retlen = i_msg->u8CmdDataLen;
}
// Check length
if(l_resp_length < l_retlen)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
l_rc = COMPCODE_NORMAL; /* assume no error */
// Copy back as much of the input message as possible.
memcpy( o_resp, i_msg->au8CmdData_ptr, l_retlen);
*io_resp_length = l_retlen;
break;
// Note: Amester uses this command to find out the maximum length output
// message OCC supports.
case 0xff:
l_maxlen = IPMI_MAX_MSG_SIZE - 1; // -1 for completion code
if (i_msg->u8CmdDataLen == 3)
{
l_maxlen = CONVERT_UINT8_ARRAY_UINT16( i_msg->au8CmdData_ptr[1],
i_msg->au8CmdData_ptr[2]);
}
if (l_maxlen > IPMI_MAX_MSG_SIZE -1)
{
l_maxlen = IPMI_MAX_MSG_SIZE -1;
}
// Check length
if(l_resp_length < l_maxlen)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
l_rc = COMPCODE_NORMAL; /* assume no error */
for (i = 0; i<l_maxlen; i++)
{
o_resp[i] = i;
}
*io_resp_length = l_maxlen;
break;
default:
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
}
return l_rc;
}
// Function Specification
//
// Name: amester_manual_throttle
//
// Description: Amester interface entry point for ipmicommand 0x3B
//
// Task Flags:
//
// End Function Specification
uint8_t amester_manual_throttle( const IPMIMsg_t * i_msg,
uint16_t * io_resp_length,
uint8_t * o_resp )
{
/*------------------------------------------------------------------------*/
/* Local variables */
/*------------------------------------------------------------------------*/
uint8_t l_rc,temp1,temp2;
uint16_t l_resp_length = *io_resp_length;
uint16_t i,j,cc,idx,temp16;
uint16_t k;
uint32_t temp32a;
uint32_t *temp32;
/*------------------------------------------------------------------------*/
/* Code */
/*------------------------------------------------------------------------*/
switch (i_msg->au8CmdData_ptr[0])
{
case 0x03: // CPU(s) Present Bit Mask
// The CPU Present Bit Mask is now being generated by the
// PROC component of OCC.
// Check length
if(l_resp_length < 2)
{
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
o_resp[0] = CONVERT_UINT32_UINT8_UPPER_HIGH( G_present_hw_cores);
o_resp[1] = CONVERT_UINT32_UINT8_UPPER_LOW( G_present_hw_cores);
*io_resp_length = 2;
l_rc = COMPCODE_NORMAL;
break;
case 0x04: // Get last throttle value sent to CPU 0. DEPRECATED.
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
case 0x05: // Get AME enable/disable flag (old style interface...do not use), no support
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
case 0x06: // Get new PTVR (Power Threshold Vector Request), no support
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
case 0x07: // Write individual AME parameters
switch (i_msg->au8CmdData_ptr[1])
{
case 20: // parameter 20: Set Probe Parameters
{
if (i_msg->au8CmdData_ptr[2]> (NUM_AMEC_FW_PROBES-1))
{
o_resp[0]=i_msg->au8CmdData_ptr[2];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
if (i_msg->au8CmdData_ptr[3] < 1)
{
o_resp[0]=i_msg->au8CmdData_ptr[2];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
temp32a=((uint32_t)i_msg->au8CmdData_ptr[4]<<24)+((uint32_t)i_msg->au8CmdData_ptr[5]<<16);
temp32a=temp32a+((uint32_t)i_msg->au8CmdData_ptr[6]<<8)+((uint32_t)i_msg->au8CmdData_ptr[7]);
temp32=(uint32_t*)temp32a;
g_amec->ptr_probe250us[i_msg->au8CmdData_ptr[2]]=temp32;
g_amec->size_probe250us[i_msg->au8CmdData_ptr[2]]=i_msg->au8CmdData_ptr[3];
g_amec->index_probe250us[i_msg->au8CmdData_ptr[2]]=0; // Reset index
o_resp[0]=i_msg->au8CmdData_ptr[2]; // Return probe #
*io_resp_length=1;
l_rc = COMPCODE_NORMAL;
break;
};
case 22: // parameter 22: Analytics parameters
{
g_amec->analytics_group=i_msg->au8CmdData_ptr[2]; // Set group
g_amec->analytics_chip=i_msg->au8CmdData_ptr[3]; // Select which chip to analyze
g_amec->analytics_option=i_msg->au8CmdData_ptr[4]; // Select which option
g_amec->analytics_total_chips=i_msg->au8CmdData_ptr[5]; // Select total number of chips
g_amec->analytics_slot=i_msg->au8CmdData_ptr[6]; // Select time slot to read data
o_resp[0]=i_msg->au8CmdData_ptr[2];
o_resp[1]=i_msg->au8CmdData_ptr[3];
o_resp[2]=i_msg->au8CmdData_ptr[4];
o_resp[3]=i_msg->au8CmdData_ptr[5];
o_resp[4]=i_msg->au8CmdData_ptr[6];
*io_resp_length=5;
l_rc = COMPCODE_NORMAL;
break;
}
case 23: // parameter 23: CPM calibration parameters
{
// g_amec->cpms_enabled=i_msg->au8CmdData_ptr[2]; // Enable CPMs
o_resp[0]=i_msg->au8CmdData_ptr[2];
*io_resp_length=1;
l_rc = COMPCODE_NORMAL;
break;
}
case 29: // parameter 29: Control vector recording modes and stream rates.
{
g_amec->stream_vector_rate=255; // First step is to set an invalid rate so no recording done at all
g_amec->stream_vector_mode=0; // Also is to assure NO recording during parameter changes
g_amec->stream_vector_group=i_msg->au8CmdData_ptr[4]; // Choose group #
g_amec->write_stream_index=(uint32_t)CONVERT_UINT8_ARRAY_UINT16(i_msg->au8CmdData_ptr[5],i_msg->au8CmdData_ptr[6]);
g_amec->stream_vector_delay=(uint32_t)CONVERT_UINT8_ARRAY_UINT16(i_msg->au8CmdData_ptr[7],i_msg->au8CmdData_ptr[8]);
g_amec->stream_vector_mode=i_msg->au8CmdData_ptr[2]; // Choose mode
switch (g_amec->stream_vector_group)
{
case 45: //group 45 decimal (amec_analytics support)
g_amec->stream_vector_map[0]=0; // Leave space for 250usec time stamp
k = 1;
for (i=0; i<=(STREAM_VECTOR_SIZE_EX-2); i++)
{
g_amec->stream_vector_map[k++] = &g_amec->analytics_array[i];
}
//gpEMP->stream_vector_map[64]=(void *) 0xffffffff; // Termination of partial vector
g_amec->analytics_group=45;
g_amec->analytics_bad_output_count=2; // drop first 2 frames of output
break;
default:
break;
}
// Final step is to set a valid rate to begin recording at
g_amec->stream_vector_rate=i_msg->au8CmdData_ptr[3]; // Choose stream rate
g_amec->recordflag=1; // Recording is now valid
*io_resp_length = 1;
l_rc = COMPCODE_NORMAL;
break;
}
case 64: // support for THREADMODE group 44 recording
g_amec->analytics_threadmode=i_msg->au8CmdData_ptr[2];
g_amec->analytics_threadcountmax=i_msg->au8CmdData_ptr[3];
o_resp[0]=i_msg->au8CmdData_ptr[2];
o_resp[1]=i_msg->au8CmdData_ptr[3];
*io_resp_length=2;
l_rc = COMPCODE_NORMAL;
break;
default:
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
break;
case 0x08: // Read individual AME parameters
switch (i_msg->au8CmdData_ptr[1])
{
case 0x08: // parameter 8: Set histogram copy interval in msec (4 bytes)
o_resp[0] = (uint8_t)(AME_HISTOGRAM_COPY_INTERVAL>>24);
o_resp[1] = (uint8_t)(AME_HISTOGRAM_COPY_INTERVAL>>16);
o_resp[2] = (uint8_t)(AME_HISTOGRAM_COPY_INTERVAL>>8);
o_resp[3] = (uint8_t)(AME_HISTOGRAM_COPY_INTERVAL);
*io_resp_length = 4;
l_rc = COMPCODE_NORMAL;
break;
case 20: // parameter 20: Read Probe Parameters
{
if (i_msg->au8CmdData_ptr[2]> (NUM_AMEC_FW_PROBES-1))
{
o_resp[0]=i_msg->au8CmdData_ptr[2];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
o_resp[1]=g_amec->size_probe250us[i_msg->au8CmdData_ptr[2]]; // Return size of object read by probe in bytes
temp32=g_amec->ptr_probe250us[i_msg->au8CmdData_ptr[2]]; // Get copy of 32 bit probe ptr
temp32a=(uint32_t)temp32;
o_resp[5]=(uint8_t)temp32a;
o_resp[4]=(uint8_t)((uint32_t)temp32a>>8);
o_resp[3]=(uint8_t)((uint32_t)temp32a>>16);
o_resp[2]=(uint8_t)((uint32_t)temp32a>>24);
o_resp[0]=i_msg->au8CmdData_ptr[2]; // Return probe #
*io_resp_length=6;
l_rc=COMPCODE_NORMAL;
break;
};
case 22: // parameter 22: Analytics parameters
o_resp[0]=g_amec->analytics_group;
o_resp[1]=g_amec->analytics_chip;
o_resp[2]=g_amec->analytics_option;
o_resp[3]=g_amec->analytics_total_chips;
o_resp[4]=g_amec->analytics_slot;
*io_resp_length=5;
l_rc = COMPCODE_NORMAL;
break;
case 23: // parameter 23: CPM parameters
// o_resp[0]=g_amec->cpms_enabled;
// o_resp[1]=g_amec->cpm_active_core;
// o_resp[2]=g_amec->cpm_cal_state;
// o_resp[3]=g_amec->cpm_core_state;
// o_resp[4]=g_amec->cpm_measure_state;
// o_resp[5]=g_amec->cpm_cal_count;
*io_resp_length=6;
l_rc = COMPCODE_NORMAL;
break;
case 29: // parameter 29: Stream recording control parameters
o_resp[0]=(uint8_t)(g_amec->stream_vector_mode);
o_resp[1]=(uint8_t)(g_amec->stream_vector_rate);
o_resp[2]=(uint8_t)(g_amec->write_stream_index>>8);
o_resp[3]=(uint8_t)(g_amec->write_stream_index & 0xff);
o_resp[4]=(uint8_t)(g_amec->stream_vector_delay>>8);
o_resp[5]=(uint8_t)(g_amec->stream_vector_delay & 0xff);
*io_resp_length=6;
l_rc=COMPCODE_NORMAL;
break;
case 37: // parameter 37: Read out (IPMI_MAX_MSG_SIZE-2*STREAM_VECTOR_SIZE) byte vector from
// streaming buffer
g_amec->read_stream_index=(uint32_t)((i_msg->au8CmdData_ptr[2]<<8)+i_msg->au8CmdData_ptr[3]);
temp1=i_msg->au8CmdData_ptr[4];
temp2=i_msg->au8CmdData_ptr[5];
if (g_amec->read_stream_index > (STREAM_BUFFER_SIZE-1*STREAM_VECTOR_SIZE_EX))
{
o_resp[0]=i_msg->au8CmdData_ptr[2];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
if (temp1 > 1) // No averaging is allowed when using large read sizes
{
o_resp[0]=i_msg->au8CmdData_ptr[4];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
if (temp2 > 0)
{
o_resp[0]=i_msg->au8CmdData_ptr[5];
*io_resp_length=1;
l_rc=COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
if (g_amec->write_stream_index >= g_amec->read_stream_index)
{
temp32a=g_amec->write_stream_index-g_amec->read_stream_index;
}
else
{
temp32a=STREAM_BUFFER_SIZE+g_amec->write_stream_index-g_amec->read_stream_index;
}
if (temp32a < 1*STREAM_VECTOR_SIZE_EX)
{
o_resp[0]=1; // Indicate insufficient data, but return a zero return code
*io_resp_length=STREAM_VECTOR_SIZE_EX+3; // # of bytes (STREAM_VECTOR_SIZE is in 16 bit words)
l_rc=COMPCODE_NORMAL;
break;
}
o_resp[0]=0; // Indicate sufficient data
i=0;
j=1*STREAM_VECTOR_SIZE_EX; // used to be 10*STREAM_VECTOR_SIZE_EX
cc=3; // Begin just past return code and time stamp
for(idx = i; idx < j; idx++) // Skip first 1 entry: either write_index and time stamp
{
temp16 = (uint16_t)g_amec->ptr_stream_buffer[g_amec->read_stream_index + idx];
o_resp[cc] = (temp16 >> 8);
o_resp[cc + 1] = (temp16 & 0xff);
cc = cc + 2; // output index
}
if(i_msg->au8CmdData_ptr[7] == 0)
{
temp16 = g_amec->ptr_stream_buffer[g_amec->read_stream_index]; // Send back time stamp
} else
{
temp16 = g_amec->write_stream_index; // Send back write stream index
}
o_resp[1] = (uint8_t)(temp16 >> 8);
o_resp[2] = (uint8_t)(temp16 & 0xff);
*io_resp_length = 3 + 2 * (1 * STREAM_VECTOR_SIZE_EX); // # of bytes (STREAM_VECTOR_SIZE_EX is in 16 bit words)
l_rc = COMPCODE_NORMAL;
break;
case 64: // support for THREADMODE group 45 recording
o_resp[0]=(uint8_t)(g_amec->analytics_threadmode);
o_resp[1]=(uint8_t)(g_amec->analytics_threadcountmax);
*io_resp_length=2;
l_rc=COMPCODE_NORMAL;
break;
default:
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
}
break;
default:
*io_resp_length = 0;
l_rc = COMPCODE_PARAM_OUT_OF_RANGE;
break;
} // end of switch
return l_rc;
}
// Function Specification
//
// Name: AMEC_entry_point
//
// Description: Amester interface entry point
//
// Task Flags:
//
// End Function Specification
uint8_t amester_entry_point( const IPMIMsg_t * i_msg,
uint16_t * io_resp_length,
uint8_t * o_resp)
{
uint8_t l_rc = COMPCODE_NORMAL;
do
{
if( (i_msg == NULL) ||
(io_resp_length == NULL) ||
(o_resp == NULL) )
{
l_rc = COMPCODE_UNSPECIFIED;
break;
}
switch (i_msg->u8Cmd)
{
case 0x3C:
l_rc = amester_api( i_msg, io_resp_length, o_resp);
break;
case 0x3B:
l_rc = amester_manual_throttle( i_msg, io_resp_length, o_resp);
break;
default: