blob: e2d052fec201f2421c568f800f034a2785b8ebad [file] [log] [blame]
Bill Hoffac83ea272017-05-25 10:43:19 -05001From 826657215c64a6fba1f8141769af5a93994b4a5d Mon Sep 17 00:00:00 2001
2From: Dan Crowell <dcrowell@us.ibm.com>
3Date: Fri, 12 May 2017 15:40:46 -0500
4Subject: [PATCH] Updates to HBRT runtime interfaces
5
6Reconciling P9 function table with P8 table to make opal-prd
7work.
8
9Added new entries for:
10- firmware_request
11- get_ipoll_events
12- firmware_notify
13
14Added in entries for P8 functions:
15- get_interface_capabilities
16
17Added deprecated placeholders for P8 functions:
18- occ_load
19- occ_start
20- occ_stop
21
22Moved entries for:
23- load_pm_complex
24- start_pm_complex
25- reset_pm_complex
26
27Change-Id: I1892b4465a6e5901aa9eaa6a49e139a4bc4c5b56
28---
29 src/include/runtime/interface.h | 230 +++++++++++++++++++++++++++-------------
30 src/runtime/rt_main.C | 26 ++++-
31 2 files changed, 182 insertions(+), 74 deletions(-)
32
33diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h
34index aafbbf9..363e50c 100644
35--- a/src/include/runtime/interface.h
36+++ b/src/include/runtime/interface.h
37@@ -37,9 +37,9 @@
38 */
39
40 /** Current interface version.
41- * 0x9001: 9=P9, 001=Version 1
42+ * 0x9001: 9=P9, 002=Version 2
43 */
44-#define HOSTBOOT_RUNTIME_INTERFACE_VERSION 0x9001
45+#define HOSTBOOT_RUNTIME_INTERFACE_VERSION 0x9002
46
47 #ifndef __HOSTBOOT_RUNTIME_INTERFACE_VERSION_ONLY
48
49@@ -53,7 +53,7 @@ enum MemoryError_t
50 * continues to report errors on subsequent reads. A second CE on that
51 * cache line will result in memory UE. Therefore, it is advised to
52 * migrate off of the address range as soon as possible. */
53- MEMORY_ERROR_CE,
54+ MEMORY_ERROR_CE = 0,
55
56 /** Hardware has reported an uncorrectable error in memory (memory UE,
57 * channel failure, etc). The hypervisor should migrate any partitions
58@@ -63,13 +63,13 @@ enum MemoryError_t
59 * partition failures to handle the hardware attentions so that the
60 * hypervisor will know all areas of memory that are impacted by the
61 * failure. */
62- MEMORY_ERROR_UE,
63+ MEMORY_ERROR_UE = 1,
64
65 /** Firmware has predictively requested service on a part in the memory
66 * subsystem. The partitions may not have been affected, but it is
67 * advised to migrate off of the address range as soon as possible to
68 * avoid potential partition outages. */
69- MEMORY_ERROR_PREDICTIVE,
70+ MEMORY_ERROR_PREDICTIVE = 2,
71 };
72
73 /**
74@@ -130,6 +130,21 @@ enum MemoryError_t
75 #define HBRT_RSVD_MEM__SBE_FFDC "ibm,sbe-ffdc"
76
77
78+/**
79+ * Specifiers for get_interface_capabilities
80+ */
81+
82+/* Common Features */
83+#define HBRT_CAPS_SET0_COMMON 0
84+
85+/* OPAL fixes */
86+#define HBRT_CAPS_SET1_OPAL 1
87+#define HBRT_CAPS_OPAL_HAS_XSCOM_RC (1ul << 0)
88+
89+/* PHYP fixes */
90+#define HBRT_CAPS_SET2_PHYP 2
91+
92+
93 /** @typedef hostInterfaces_t
94 * @brief Interfaces provided by the underlying environment (ex. Sapphire).
95 *
96@@ -412,6 +427,40 @@ typedef struct hostInterfaces
97 enum MemoryError_t i_errorType );
98
99 /**
100+ * @brief Query the HBRT host for a list of fixes/features
101+ *
102+ * There are times when workarounds need to be put into place to handle
103+ * issues with the hosting layer (e.g. opal-prd) while fixes are not yet
104+ * released. This is especially true because of the disconnected release
105+ * streams for the firmware and the hosting environment.
106+ *
107+ * @param i_set Indicates which set of fixes/features we're checking
108+ * see HBRT_CAPS_SET...
109+ *
110+ * @return a bitmask containing the relevant flags for the current
111+ * implementation, see HBRT_CAPS_FLAGS_...
112+ */
113+ uint64_t (*get_interface_capabilities)( uint64_t i_set );
114+
115+ /**
116+ * @brief Map a physical address space into usable memory
117+ * @note Repeated calls to map the same memory should not return an error
118+ * @param[in] i_physMem Physical address
119+ * @param[in] i_bytes Number of bytes to map in
120+ * @return NULL on error, else pointer to usable memory
121+ * @platform FSP, OpenPOWER
122+ */
123+ void* (*map_phys_mem)(uint64_t i_physMem, size_t i_bytes);
124+
125+ /**
126+ * @brief Unmap a physical address space from usable memory
127+ * @param[in] i_ptr Previously mapped pointer
128+ * @return 0 on success, else RC
129+ * @platform FSP, OpenPOWER
130+ */
131+ int (*unmap_phys_mem)(void* i_ptr);
132+
133+ /**
134 * @brief Modify the SCOM restore section of the HCODE image with the
135 * given register data
136 *
137@@ -441,22 +490,27 @@ typedef struct hostInterfaces
138 uint64_t i_scomData );
139
140 /**
141- * @brief Map a physical address space into usable memory
142- * @note Repeated calls to map the same memory should not return an error
143- * @param[in] i_physMem Physical address
144- * @param[in] i_bytes Number of bytes to map in
145- * @return NULL on error, else pointer to usable memory
146- * @platform FSP, OpenPOWER
147- */
148- void* (*map_phys_mem)(uint64_t i_physMem, size_t i_bytes);
149-
150- /**
151- * @brief Unmap a physical address space from usable memory
152- * @param[in] i_ptr Previously mapped pointer
153- * @return 0 on success, else RC
154- * @platform FSP, OpenPOWER
155+ * @brief Send a request to firmware, and receive a response
156+ * @details
157+ * req_len bytes are sent to runtime firmware, and resp_len
158+ * bytes received in response.
159+ *
160+ * Both req and resp are allocated by the caller. If resp_len
161+ * is not large enough to contain the full response, an error
162+ * is returned.
163+ *
164+ * @param[in] i_reqLen length of request data
165+ * @param[in] i_req request data
166+ * @param[inout] o_respLen in: size of request data buffer
167+ * out: length of request data
168+ * @param[in] o_resp response data
169+ * @return 0 on success, else RC
170+ * @platform FSP, OpenPOWER
171 */
172- int (*unmap_phys_mem)(void* i_ptr);
173+ int (*firmware_request)( uint64_t i_reqLen,
174+ void *i_req,
175+ uint64_t* o_respLen,
176+ void *o_resp );
177
178 // Reserve some space for future growth.
179 // do NOT ever change this number, even if you add functions.
180@@ -475,7 +529,7 @@ typedef struct hostInterfaces
181 // allocated with sufficient space and populated with NULL function
182 // pointers. 32 is big enough that we should not likely add that many
183 // functions from either direction in between any two levels of support.
184- void (*reserved[32])(void);
185+ void (*reserved[27])(void);
186
187 } hostInterfaces_t;
188
189@@ -502,44 +556,11 @@ typedef struct runtimeInterfaces
190 const uint32_t * (*get_lid_list)(size_t * o_num);
191
192 /**
193- * @brief Load OCC/HCODE images into mainstore
194- *
195- * @param[in] i_chip the HW chip id (XSCOM chip ID)
196- * @param[in] i_homer_addr the physical mainstore address of the
197- * start of the HOMER image,
198- * @param[in] i_occ_common_addr the physical mainstore address of the
199- * OCC common area, 8MB, used for
200- * OCC-OCC communication (1 per node)
201- * @param[in] i_mode selects initial load vs concurrent reloads
202- * HBRT_PM_LOAD:
203- * load all lids/sections from scratch,
204- * preserve nothing
205- * HBRT_PM_RELOAD:
206- * reload all lids/sections,
207- * but preserve runtime updates
208- * @return 0 on success else return code
209- * @platform FSP, OpenPOWER
210- */
211- int (*load_pm_complex)( uint64_t i_chip,
212- uint64_t i_homer_addr,
213- uint64_t i_occ_common_addr,
214- uint32_t i_mode );
215-
216- /**
217- * @brief Start OCC/HCODE on the specified chip
218- * @param[in] i_chip the HW chip id
219- * @return 0 on success else return code
220- * @platform FSP, OpenPOWER
221- */
222- int (*start_pm_complex)( uint64_t i_chip );
223-
224- /**
225- * @brief Reset OCC/HCODE on the specified chip
226- * @param[in] i_chip the HW chip id
227- * @return 0 on success else return code
228- * @platform FSP, OpenPOWER
229+ * Space allocated for deprecated P8 interfaces
230 */
231- int (*reset_pm_complex)( uint64_t i_chip );
232+ const uint32_t * (*occ_load__deprecated)(size_t * o_num);
233+ const uint32_t * (*occ_start__deprecated)(size_t * o_num);
234+ const uint32_t * (*occ_stop__deprecated)(size_t * o_num);
235
236 /**
237 * @brief Notify HTMGT that an OCC has an error to report
238@@ -629,20 +650,20 @@ typedef struct runtimeInterfaces
239 /**
240 * @brief Send a pass-through command to HTMGT
241 *
242- * @details  This is a blocking call that will send a command
243- *           to HTMGT.
244- * @note     If o_rspLength is returned with a non-zero value,
245- *           the data at the o_rspData should be dumped to
246- *           stdout in a hex dump format.
247- * @note The maximum response data returned will be 4096 bytes
248+ * @details This is a blocking call that will send a command
249+ * to HTMGT.
250+ * @note If o_rspLength is returned with a non-zero value,
251+ * the data at the o_rspData should be dumped to
252+ * stdout in a hex dump format.
253+ * @note The maximum response data returned will be 4096 bytes
254 *
255 * @param[in] i_cmdLength number of bytes in pass-thru command data
256- * @param[in]     *i_cmdData   pointer to pass-thru command data
257+ * @param[in] *i_cmdData pointer to pass-thru command data
258 * @param[out] *o_rspLength pointer to number of bytes returned
259 * in o_rspData
260- * @param[out] *o_rspData   pointer to a 4096 byte buffer that will
261+ * @param[out] *o_rspData pointer to a 4096 byte buffer that will
262 * contain the response data from the command
263- * @returns  0 on success, or return code if the command failed
264+ * @returns 0 on success, or return code if the command failed
265 * @platform OpenPOWER
266 */
267 int (*mfg_htmgt_pass_thru)( uint16_t i_cmdLength,
268@@ -691,20 +712,83 @@ typedef struct runtimeInterfaces
269 size_t i_hwKeyHashSize);
270
271 /**
272- * @brief SBE message passing
273+ * @brief SBE message passing notification
274 *
275- * @details  This is a blocking call that will pass an SBE message
276- *           with a pass-through command through HBRT to code that
277- * will process the command and provide a response.
278+ * @details
279+ * This is a blocking call that is used to notify HBRT there is
280+ * a SBE message available. This should be called when the Host
281+ * detects the appropriate PSU interrupt from the SBE.
282 *
283 * @param[in] i_procChipId Chip ID of the processor whose SBE is passing
284 * the message and sent the interrupt
285 *
286- * @returns  0 on success, or return code if the command failed
287+ * @return 0 on success, or return code if the command failed
288 * @platform FSP, OpenPOWER
289 */
290 int (*sbe_message_passing)(uint32_t i_procChipId);
291
292+ /**
293+ * @brief Load OCC/HCODE images into mainstore
294+ *
295+ * @param[in] i_chip the HW chip id (XSCOM chip ID)
296+ * @param[in] i_homer_addr the physical mainstore address of the
297+ * start of the HOMER image,
298+ * @param[in] i_occ_common_addr the physical mainstore address of the
299+ * OCC common area, 8MB, used for
300+ * OCC-OCC communication (1 per node)
301+ * @param[in] i_mode selects initial load vs concurrent reloads
302+ * HBRT_PM_LOAD:
303+ * load all lids/sections from scratch,
304+ * preserve nothing
305+ * HBRT_PM_RELOAD:
306+ * reload all lids/sections,
307+ * but preserve runtime updates
308+ * @return 0 on success else return code
309+ * @platform FSP, OpenPOWER
310+ */
311+ int (*load_pm_complex)( uint64_t i_chip,
312+ uint64_t i_homer_addr,
313+ uint64_t i_occ_common_addr,
314+ uint32_t i_mode );
315+
316+ /**
317+ * @brief Start OCC/HCODE on the specified chip
318+ * @param[in] i_chip the HW chip id
319+ * @return 0 on success else return code
320+ * @platform FSP, OpenPOWER
321+ */
322+ int (*start_pm_complex)( uint64_t i_chip );
323+
324+ /**
325+ * @brief Reset OCC/HCODE on the specified chip
326+ * @param[in] i_chip the HW chip id
327+ * @return 0 on success else return code
328+ * @platform FSP, OpenPOWER
329+ */
330+ int (*reset_pm_complex)( uint64_t i_chip );
331+
332+ /**
333+ * @brief Query the IPOLL event mask supported by HBRT
334+ *
335+ * @details This call allows the wrapper application to query
336+ * the ipoll event mask to set when the HBRT instance is running. Bits
337+ * that are *set* in this bitmask represent events that will be
338+ * forwarded to the handle_attn() callback.
339+ *
340+ * @return The IPOLL event bits to enable during HBRT execution
341+ * @platform FSP, OpenPOWER
342+ */
343+ uint64_t (*get_ipoll_events)( void );
344+
345+ /**
346+ * @brief Receive an async notification from firmware
347+ * @param[in] i_len length of notification data
348+ * @param[in] i_data notification data
349+ * @platform FSP, OpenPOWER
350+ */
351+ void (*firmware_notify)( uint64_t len,
352+ void *data );
353+
354 // Reserve some space for future growth.
355 // do NOT ever change this number, even if you add functions.
356 //
357@@ -722,7 +806,7 @@ typedef struct runtimeInterfaces
358 // allocated with sufficient space and populated with NULL function
359 // pointers. 32 is big enough that we should not likely add that many
360 // functions from either direction in between any two levels of support.
361- void (*reserved[32])(void);
362+ void (*reserved[22])(void);
363
364 } runtimeInterfaces_t;
365
366diff --git a/src/runtime/rt_main.C b/src/runtime/rt_main.C
367index d9a21c9..d539018 100644
368--- a/src/runtime/rt_main.C
369+++ b/src/runtime/rt_main.C
370@@ -5,7 +5,7 @@
371 /* */
372 /* OpenPOWER HostBoot Project */
373 /* */
374-/* Contributors Listed Below - COPYRIGHT 2013,2016 */
375+/* Contributors Listed Below - COPYRIGHT 2013,2017 */
376 /* [+] International Business Machines Corp. */
377 /* */
378 /* */
379@@ -70,6 +70,27 @@ extern "C"
380 */
381 runtimeInterfaces_t* rt_start(hostInterfaces_t*) NEVER_INLINE;
382
383+
384+/** @fn rt_version_fixup
385+ *
386+ * @brief Make any adjustments needed to handle old versions
387+ */
388+void rt_version_fixup( void )
389+{
390+ uint64_t hostver = g_hostInterfaces->interfaceVersion;
391+ if( HOSTBOOT_RUNTIME_INTERFACE_VERSION == hostver )
392+ {
393+ return; //nothing to do, we match
394+ }
395+
396+ char verstring[100];
397+ sprintf( verstring,
398+ "HRBT Ver=%X, HostVer=%X\n",
399+ HOSTBOOT_RUNTIME_INTERFACE_VERSION,
400+ hostver );
401+ (g_hostInterfaces->puts)(verstring);
402+}
403+
404 /** Call C++ constructors present in this image. */
405 void rt_cppBootstrap();
406
407@@ -111,6 +132,9 @@ runtimeInterfaces_t* rt_start(hostInterfaces_t* intf)
408 postInitCalls_t* rtPost = getPostInitCalls();
409 rtPost->callApplyTempOverrides();
410
411+ // do any version mismatch fixups
412+ rt_version_fixup();
413+
414 // Return our interface pointer structure.
415 return rtInterfaces;
416 }
417--
4181.8.2.2
419