1 /* IBM_PROLOG_BEGIN_TAG                                                   */
2 /* This is an automatically generated prolog.                             */
3 /*                                                                        */
4 /* $Source: src/import/chips/p9/procedures/utils/stopreg/p9_stop_api.H $  */
5 /*                                                                        */
6 /* OpenPOWER HostBoot Project                                             */
7 /*                                                                        */
8 /* Contributors Listed Below - COPYRIGHT 2015,2017                        */
9 /* [+] International Business Machines Corp.                              */
10 /*                                                                        */
11 /*                                                                        */
12 /* Licensed under the Apache License, Version 2.0 (the "License");        */
13 /* you may not use this file except in compliance with the License.       */
14 /* You may obtain a copy of the License at                                */
15 /*                                                                        */
16 /*     http://www.apache.org/licenses/LICENSE-2.0                         */
17 /*                                                                        */
18 /* Unless required by applicable law or agreed to in writing, software    */
19 /* distributed under the License is distributed on an "AS IS" BASIS,      */
20 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
21 /* implied. See the License for the specific language governing           */
22 /* permissions and limitations under the License.                         */
23 /*                                                                        */
24 /* IBM_PROLOG_END_TAG                                                     */
25 #ifndef __P9_STOP_IMAGE_API_
26 #define __P9_STOP_IMAGE_API_
27 
28 #include <stdint.h>
29 
30 #ifdef __SKIBOOT__
31     #include <skiboot.h>
32 #endif
33 
34 ///
35 /// @file   p9_stop_api.H
36 /// @brief  describes STOP API which  create/manipulate STOP image.
37 ///
38 // *HWP HW Owner    :  Greg Still <stillgs@us.ibm.com>
39 // *HWP FW Owner    :  Prem Shanker Jha <premjha2@in.ibm.com>
40 // *HWP Team        :  PM
41 // *HWP Level       :  2
42 // *HWP Consumed by :  HB:HYP
43 
44 #ifdef __cplusplus
45 namespace stopImageSection
46 {
47 #endif
48 
49 /**
50  * @brief   all SPRs and MSR for which register restore is to be supported.
51  * @note    STOP API design has built in support to accomodate 8 register of
52  *          scope core and thread each.
53  */
54 typedef enum
55 {
56     P9_STOP_SPR_DAWR    =    180,   // thread register
57     P9_STOP_SPR_HSPRG0  =    304,   // thread register
58     P9_STOP_SPR_HRMOR   =    313,   // core register
59     P9_STOP_SPR_LPCR    =    318,   // thread register
60     P9_STOP_SPR_HMEER   =    337,   // core register
61     P9_STOP_SPR_LDBAR   =    850,   // thread register
62     P9_STOP_SPR_PSSCR   =    855,   // thread register
63     P9_STOP_SPR_PMCR    =    884,   // core register
64     P9_STOP_SPR_HID     =   1008,   // core register
65     P9_STOP_SPR_MSR     =   2000,   // thread register
66 } CpuReg_t;
67 
68 /**
69  * @brief lists all the bad error codes.
70  */
71 typedef enum
72 {
73     STOP_SAVE_SUCCESS                    = 0,
74     STOP_SAVE_ARG_INVALID_IMG            = 1,
75     STOP_SAVE_ARG_INVALID_REG            = 2,
76     STOP_SAVE_ARG_INVALID_THREAD         = 3,
77     STOP_SAVE_ARG_INVALID_MODE           = 4,
78     STOP_SAVE_ARG_INVALID_CORE           = 5,
79     STOP_SAVE_SPR_ENTRY_NOT_FOUND        = 6,
80     STOP_SAVE_SPR_ENTRY_UPDATE_FAILED    = 7,
81     STOP_SAVE_SCOM_INVALID_OPERATION     = 8,
82     STOP_SAVE_SCOM_INVALID_SECTION       = 9,
83     STOP_SAVE_SCOM_INVALID_ADDRESS       = 10,
84     STOP_SAVE_SCOM_INVALID_CHIPLET       = 11,
85     STOP_SAVE_SCOM_ENTRY_UPDATE_FAILED   = 12,
86     STOP_SAVE_INVALID_FUSED_CORE_STATUS  = 13,
87     STOP_SAVE_FAIL                       = 14,  // for internal failure within firmware.
88 } StopReturnCode_t;
89 
90 /**
91  * @brief summarizes all operations supported on scom entries of STOP image.
92  */
93 typedef enum
94 {
95     P9_STOP_SCOM_OP_MIN     = 0,
96     P9_STOP_SCOM_APPEND     = 1,
97     P9_STOP_SCOM_REPLACE    = 2,
98     P9_STOP_SCOM_OR         = 3,
99     P9_STOP_SCOM_AND        = 4,
100     P9_STOP_SCOM_NOOP       = 5,
101     P9_STOP_SCOM_RESET      = 6,
102     P9_STOP_SCOM_OR_APPEND  = 7,
103     P9_STOP_SCOM_AND_APPEND = 8,
104     P9_STOP_SCOM_OP_MAX     = 9
105 } ScomOperation_t;
106 
107 /**
108  * @brief All subsections that contain scom entries in a STOP image.
109  */
110 typedef enum
111 {
112     P9_STOP_SECTION_MIN         = 0,
113     P9_STOP_SECTION_CORE_SCOM   = 1,
114     P9_STOP_SECTION_EQ_SCOM     = 2,
115     P9_STOP_SECTION_L2          = 3,
116     P9_STOP_SECTION_L3          = 4,
117     P9_STOP_SECTION_MAX         = 5
118 } ScomSection_t;
119 
120 #ifdef __cplusplus
121 extern "C" {
122 #endif
123 /**
124  * @brief   Updates STOP image entry associated with CPU register.
125  * @param[in]   i_pImage    start address of homer image associated with processor.
126  * @param[in]   i_regId     id of SPR for which STOP image needs to be updated.
127  * @param[in]   i_regData   data to be restored in SPR register.
128  * @param[in]   i_pir       value of processor identification register (PIR)
129  * @return      STOP_SAVE_SUCCESS SUCCESS if image is updated successfully, error
130  *              code otherwise.
131  */
132 
133 StopReturnCode_t p9_stop_save_cpureg(  void* const i_pImage,
134                                        const CpuReg_t  i_regId,
135                                        const uint64_t  i_regData,
136                                        const uint64_t  i_pir );
137 
138 /**
139  * @brief   Updates scom image entry associated with given core or cache in
140  *          STOP section of homer image.
141  * @param[in]   i_pImage        start address of homer image of P9 chip.
142  * @param[in]   i_scomAddress   fully qualified address of SCOM register.
143  * @param[in]   i_scomData      data associated with SCOM register.
144  * @param[in]   i_operation     operation to be done on SCOM image entry.
145  * @param[in]   i_section       area to which given SCOM entry belongs.
146  * @return      STOP_SAVE_SUCCESS if image is updated successfully, error code
147  *              otherwise.
148  * @note        API is intended to update SCOM image entry associated with given
149  *              core or given part of a cache section. API doesn't validate if
150  *              a given SCOM address really belongs to given section.
151  */
152 StopReturnCode_t p9_stop_save_scom( void* const   i_pImage,
153                                     const uint32_t i_scomAddress,
154                                     const uint64_t i_scomData,
155                                     const ScomOperation_t i_operation,
156                                     const ScomSection_t i_section );
157 
158 #ifdef __cplusplus
159 } // extern "C"
160 };  // namespace stopImageSection ends
161 #endif //__cplusplus
162 
163 #endif //__P9_STOP_IMAGE_API_
164