@@ -13,7 +13,9 @@ enum platform_special_case_code {
13
13
NORMAL_CASE = 0x00 ,
14
14
PDR_REPLY_ERROR = 0x02 ,
15
15
PLATFORM_EVENT_ERROR = 0x03 ,
16
- VERIFY_SHUTDOWN = 0x04
16
+ VERIFY_SHUTDOWN = 0x04 ,
17
+ VERIFY_RESTART = 0x05 ,
18
+ VERIFY_POWEROFF ,
17
19
};
18
20
19
21
enum platform_special_case_code platform_special_case = NORMAL_CASE ;
@@ -325,6 +327,9 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
325
327
uint8_t format_version , tid , event_class ;
326
328
size_t event_data_offset ;
327
329
uint32_t next_record_hndl ;
330
+ uint16_t effecter_id ;
331
+ uint8_t comp_effecter_count ;
332
+ set_effecter_state_field field = {0 };
328
333
329
334
/* check pldm command received and reply with appropriate pldm response message */
330
335
switch (((struct pldm_msg * )request_msg )-> hdr .command ) {
@@ -419,6 +424,45 @@ int pldm_test_reply_request_platform(void *request_msg, size_t request_len,
419
424
420
425
return PLDM_SUCCESS ;
421
426
427
+ case PLDM_SET_STATE_EFFECTER_STATES :
428
+ payload_len = request_len - sizeof (struct pldm_msg_hdr );
429
+ rc = decode_set_state_effecter_states_req (request_msg , payload_len ,
430
+ & effecter_id ,
431
+ & comp_effecter_count ,
432
+ & field );
433
+ if (rc != PLDM_SUCCESS )
434
+ return OPAL_PARAMETER ;
435
+
436
+ /*
437
+ * Verify if the effecter state matches the expected value.
438
+ * If it does not, return OPAL_PARAMETER.
439
+ */
440
+ if (platform_special_case == VERIFY_RESTART &&
441
+ field .effecter_state !=
442
+ PLDM_SW_TERM_GRACEFUL_RESTART_REQUESTED ){
443
+ return OPAL_PARAMETER ;
444
+ }
445
+ if (platform_special_case == VERIFY_POWEROFF
446
+ && field .effecter_state !=
447
+ PLDM_STATE_SET_SYS_POWER_STATE_OFF_SOFT_GRACEFUL ){
448
+ return OPAL_PARAMETER ;
449
+ }
450
+
451
+
452
+ * response_len = sizeof (struct pldm_msg );
453
+ * response_msg = malloc (* response_len );
454
+ if (* response_msg == NULL ) {
455
+ perror ("PLDM_TEST malloc" );
456
+ return OPAL_RESOURCE ;
457
+ }
458
+
459
+ rc = encode_set_state_effecter_states_resp (
460
+ ((struct pldm_msg * )request_msg )-> hdr .instance_id ,
461
+ completion_code , * response_msg );
462
+ if (rc != PLDM_SUCCESS )
463
+ return OPAL_PARAMETER ;
464
+ return PLDM_SUCCESS ;
465
+
422
466
default :
423
467
return OPAL_PARAMETER ;
424
468
@@ -610,6 +654,40 @@ int test_pldm_platform_initiate_shutdown(void)
610
654
611
655
}
612
656
657
+ int test_pldm_platform_restart (void )
658
+ {
659
+ int rc ;
660
+
661
+ platform_special_case = VERIFY_RESTART ;
662
+ rc = pldm_platform_restart ();
663
+ if (rc != OPAL_SUCCESS ) {
664
+ printf ("PLDM_TEST: %s failed :: rc = %d exp %d\n" ,
665
+ __func__ , rc , OPAL_SUCCESS );
666
+ platform_special_case = NORMAL_CASE ;
667
+ return OPAL_PARAMETER ;
668
+ }
669
+ platform_special_case = NORMAL_CASE ;
670
+ return OPAL_SUCCESS ;
671
+
672
+ }
673
+
674
+ int test_pldm_platform_poweroff (void )
675
+ {
676
+ int rc ;
677
+
678
+ platform_special_case = VERIFY_POWEROFF ;
679
+ rc = pldm_platform_power_off ();
680
+ if (rc != OPAL_SUCCESS ) {
681
+ printf ("PLDM_TEST: %s failed :: rc = %d exp %d\n" ,
682
+ __func__ , rc , OPAL_SUCCESS );
683
+ platform_special_case = NORMAL_CASE ;
684
+ return OPAL_PARAMETER ;
685
+ }
686
+ platform_special_case = NORMAL_CASE ;
687
+ return OPAL_SUCCESS ;
688
+
689
+ }
690
+
613
691
struct test_case {
614
692
const char * name ;
615
693
int (* fn )(void );
@@ -625,6 +703,8 @@ struct test_case test_cases[] = {
625
703
TEST_CASE (test_find_pdr_existing_record ),
626
704
TEST_CASE (test_find_pdr_non_existing_record ),
627
705
TEST_CASE (test_pldm_platform_initiate_shutdown ),
706
+ TEST_CASE (test_pldm_platform_restart ),
707
+ TEST_CASE (test_pldm_platform_poweroff ),
628
708
{NULL , NULL }
629
709
};
630
710
0 commit comments