@@ -615,6 +615,7 @@ InitService& InitService::getTheInstance( )
615
615
616
616
InitService ::InitService ( ) :
617
617
iv_shutdownInProgress (false),
618
+ iv_worst_status (false),
618
619
iv_iStep ( 0 ),
619
620
iv_iSubStep ( 0 )
620
621
{
@@ -661,6 +662,49 @@ void InitService::registerBlock(void* i_vaddr, uint64_t i_size,
661
662
mutex_unlock (& iv_registryMutex );
662
663
}
663
664
665
+ bool InitService ::_setShutdownStatus (
666
+ const uint64_t i_status ,
667
+ const uint32_t i_error_info )
668
+ {
669
+ TRACFCOMP (g_trac_initsvc , "_setShutdownStatus(i_status=0x%016llX)" ,
670
+ i_status );
671
+
672
+ // Hostboot PLIDs always start with 0x9 (32-bit)
673
+ static const uint64_t PLID_MASK = 0x0000000090000000 ;
674
+ bool first = false;
675
+
676
+ // Ensure no one is manpulating the registry lists
677
+ mutex_lock (& iv_registryMutex );
678
+
679
+ // This already takes care of accepting only the first TI code, so
680
+ // just always call this
681
+ termWriteSRC (TI_SHUTDOWN ,
682
+ i_status ,
683
+ reinterpret_cast < uint64_t > (linkRegister ()),
684
+ i_error_info );
685
+
686
+ if (iv_shutdownInProgress )
687
+ {
688
+ // switch the failing status if an RC comes in after
689
+ // a plid fail because we'd rather have the RC
690
+ if ( ((iv_worst_status & 0x00000000F0000000 ) == PLID_MASK )
691
+ && ((i_status & 0x00000000F0000000 ) != PLID_MASK )
692
+ && (i_status > SHUTDOWN_STATUS_GOOD ) )
693
+ {
694
+ iv_worst_status = i_status ;
695
+ }
696
+ }
697
+ else
698
+ {
699
+ first = true;
700
+ iv_worst_status = i_status ;
701
+ iv_shutdownInProgress = true;
702
+ }
703
+
704
+ mutex_unlock (& iv_registryMutex );
705
+
706
+ return first ;
707
+ }
664
708
665
709
void doShutdown (uint64_t i_status ,
666
710
bool i_inBackground ,
@@ -670,11 +714,27 @@ void doShutdown(uint64_t i_status,
670
714
uint64_t i_masterHBInstance ,
671
715
uint32_t i_error_info )
672
716
{
673
- termWriteSRC (TI_SHUTDOWN ,
674
- i_status ,
675
- reinterpret_cast < uint64_t > (linkRegister ()),
676
- i_error_info );
717
+ (void )InitService ::doShutdown (
718
+ i_status ,
719
+ i_inBackground ,
720
+ i_payload_base ,
721
+ i_payload_entry ,
722
+ i_payload_data ,
723
+ i_masterHBInstance ,
724
+ i_error_info );
725
+ }
677
726
727
+ void InitService ::doShutdown (
728
+ uint64_t i_status ,
729
+ bool i_inBackground ,
730
+ uint64_t i_payload_base ,
731
+ uint64_t i_payload_entry ,
732
+ uint64_t i_payload_data ,
733
+ uint64_t i_masterHBInstance ,
734
+ uint32_t i_error_info )
735
+ {
736
+ bool first = Singleton < InitService > ::instance ()._setShutdownStatus (
737
+ i_status ,i_error_info );
678
738
class ShutdownExecute
679
739
{
680
740
public :
@@ -694,7 +754,7 @@ void doShutdown(uint64_t i_status,
694
754
695
755
void execute ()
696
756
{
697
- Singleton < InitService > ::instance ().doShutdown (status ,
757
+ Singleton < InitService > ::instance ()._doShutdown (status ,
698
758
payload_base ,
699
759
payload_entry ,
700
760
payload_data ,
@@ -730,15 +790,30 @@ void doShutdown(uint64_t i_status,
730
790
ShutdownExecute * s = new ShutdownExecute (i_status , i_payload_base ,
731
791
i_payload_entry , i_payload_data ,
732
792
i_masterHBInstance , i_error_info );
733
-
734
- if (i_inBackground )
793
+ if (first )
735
794
{
736
- s -> startThread ();
795
+ if (i_inBackground )
796
+ {
797
+ s -> startThread ();
798
+ }
799
+ else
800
+ {
801
+ s -> execute ();
802
+ while (1 )
803
+ {
804
+ nanosleep (1 ,0 );
805
+ }
806
+ }
737
807
}
738
808
else
739
809
{
740
- s -> execute ();
741
- while (1 ) nanosleep (1 ,0 );
810
+ if (!i_inBackground )
811
+ {
812
+ while (1 )
813
+ {
814
+ nanosleep (1 ,0 );
815
+ }
816
+ }
742
817
}
743
818
}
744
819
@@ -760,18 +835,17 @@ class isPriority
760
835
uint32_t iv_priority ;
761
836
};
762
837
763
- void InitService ::doShutdown (uint64_t i_status ,
764
- uint64_t i_payload_base ,
765
- uint64_t i_payload_entry ,
766
- uint64_t i_payload_data ,
767
- uint64_t i_masterHBInstance ,
768
- uint32_t i_error_info )
838
+ void InitService ::_doShutdown (uint64_t i_status ,
839
+ uint64_t i_payload_base ,
840
+ uint64_t i_payload_entry ,
841
+ uint64_t i_payload_data ,
842
+ uint64_t i_masterHBInstance ,
843
+ uint32_t i_error_info )
769
844
{
770
845
int l_rc = 0 ;
771
846
errlHndl_t l_err = NULL ;
772
- static volatile uint64_t worst_status = 0 ;
773
847
774
- TRACFCOMP (g_trac_initsvc , "doShutdown (i_status=%.16X)" ,i_status );
848
+ TRACFCOMP (g_trac_initsvc , "_doShutdown (i_status=%.16X)" ,i_status );
775
849
#ifdef CONFIG_CONSOLE
776
850
// check if console msg not needed or already displayed by caller
777
851
if ((SHUTDOWN_STATUS_GOOD != i_status ) &&
@@ -788,31 +862,7 @@ void InitService::doShutdown(uint64_t i_status,
788
862
}
789
863
#endif
790
864
791
- // Hostboot PLIDs always start with 0x9 (32-bit)
792
- static const uint64_t PLID_MASK = 0x0000000090000000 ;
793
-
794
- // Ensure no one is manpulating the registry lists and that only one
795
- // thread actually executes the shutdown path.
796
- mutex_lock (& iv_registryMutex );
797
-
798
- if (iv_shutdownInProgress )
799
- {
800
- // switch the failing status if an RC comes in after
801
- // a plid fail because we'd rather have the RC
802
- if ( ((worst_status & 0x00000000F0000000 ) == PLID_MASK )
803
- && ((i_status & 0x00000000F0000000 ) != PLID_MASK )
804
- && (i_status > SHUTDOWN_STATUS_GOOD ) )
805
- {
806
- worst_status = i_status ;
807
- }
808
- mutex_unlock (& iv_registryMutex );
809
- return ;
810
- }
811
- worst_status = i_status ; //first thread in is the default
812
- iv_shutdownInProgress = true;
813
- mutex_unlock (& iv_registryMutex );
814
-
815
- TRACFCOMP (g_trac_initsvc , "doShutdown> status=%.16X" ,worst_status );
865
+ TRACFCOMP (g_trac_initsvc , "_doShutdown> status=%.16X" ,iv_worst_status );
816
866
817
867
// sort the queue by priority before sending..
818
868
std ::sort ( iv_regMsgQ .begin (), iv_regMsgQ .end ());
@@ -828,7 +878,7 @@ void InitService::doShutdown(uint64_t i_status,
828
878
{
829
879
TRACFCOMP (g_trac_initsvc ,"notify priority=0x%x, queue=0x%x" , i -> msgPriority , i -> msgQ );
830
880
l_msg -> type = i -> msgType ;
831
- l_msg -> data [0 ] = worst_status ;
881
+ l_msg -> data [0 ] = iv_worst_status ;
832
882
(void )msg_sendrecv (i -> msgQ ,l_msg );
833
883
}
834
884
@@ -878,7 +928,7 @@ void InitService::doShutdown(uint64_t i_status,
878
928
{
879
929
TRACDCOMP (g_trac_initsvc ,"notify priority=0x%x, queue=0x%x" , i -> msgPriority , i -> msgQ );
880
930
l_msg -> type = i -> msgType ;
881
- l_msg -> data [0 ] = worst_status ;
931
+ l_msg -> data [0 ] = iv_worst_status ;
882
932
(void )msg_sendrecv (i -> msgQ ,l_msg );
883
933
}
884
934
msg_free (l_msg );
@@ -891,17 +941,17 @@ void InitService::doShutdown(uint64_t i_status,
891
941
task_yield ();
892
942
nanosleep (0 ,TEN_CTX_SWITCHES_NS );
893
943
894
- TRACFCOMP (g_trac_initsvc , "doShutdown > Final status=%.16X" ,worst_status );
944
+ TRACFCOMP (g_trac_initsvc , "_doShutdown > Final status=%.16X" ,iv_worst_status );
895
945
MAGIC_INST_PRINT_ISTEP (21 ,4 );
896
946
897
947
// Update the HB TI area with the worst status.
898
948
termWriteSRC (TI_SHUTDOWN ,
899
- worst_status ,
949
+ iv_worst_status ,
900
950
reinterpret_cast < uint64_t > (linkRegister ()),
901
951
i_error_info ,
902
952
true); // Force write
903
953
904
- shutdown (worst_status ,
954
+ shutdown (iv_worst_status ,
905
955
i_payload_base ,
906
956
i_payload_entry ,
907
957
i_payload_data ,
0 commit comments