diff options
Diffstat (limited to 'src/include')
104 files changed, 3298 insertions, 494 deletions
diff --git a/src/include/arch/memorymap.H b/src/include/arch/memorymap.H index 7b75f6363..1ea479d8c 100644 --- a/src/include/arch/memorymap.H +++ b/src/include/arch/memorymap.H @@ -39,8 +39,13 @@ constexpr uint64_t MMIO_OFFSET_PER_CHIP = (4*TERABYTE); //0x40000000000 constexpr uint64_t MMIO_OFFSET_PER_GROUP = (32*TERABYTE); //0x200000000000 constexpr uint64_t MMIO_BASE = 0x6000000000000; + /** * @brief Compute MMIO value for a given chip and base value + * @param[in] i_baseAddr group0-chip0 address + * @param[in] i_group Fabric Group ID to compute address for + * @param[in] i_chip Fabric Chip ID to compute address for + * @return Fully qualified memory address */ inline uint64_t computeMemoryMapOffset( uint64_t i_baseAddr, uint8_t i_group, @@ -52,6 +57,26 @@ inline uint64_t computeMemoryMapOffset( uint64_t i_baseAddr, }; /** + * @brief Determine fabric id from a MMIO address + * @param[in] i_addr position-specific memory address + * @param[out] i_group Fabric Group ID to compute address for + * @param[out] i_chip Fabric Chip ID to compute address for + */ +inline void getFabricIdFromAddr( uint64_t i_addr, + uint8_t& o_group, + uint8_t& o_chip ) +{ + // chop off any high-order offset + uint64_t l_addr = i_addr % MMIO_BASE; + // use integer math to get the group id + o_group = l_addr / MMIO_OFFSET_PER_GROUP; + // chop off the group + l_addr = l_addr % MMIO_OFFSET_PER_GROUP; + // use integer math to get the chip id + o_chip = l_addr % MMIO_OFFSET_PER_CHIP; +}; + +/** * @brief A few default values that will need to be known * by low-level code */ diff --git a/src/include/arch/ppc.H b/src/include/arch/ppc.H index 4d1762db7..b9b8df7ee 100644 --- a/src/include/arch/ppc.H +++ b/src/include/arch/ppc.H @@ -417,6 +417,24 @@ inline void writeScratchReg(uint64_t _scratch_addr, uint64_t _data) } +#ifdef __HOSTBOOT_RUNTIME + +/** @brief getDarn - deliver a random number instruction + * Returns 64 bits of random data, requires random number generator + * configured appropriately + locked down, only available at runtime. + */ +ALWAYS_INLINE +inline uint64_t getDarn() +{ + register uint64_t rt = 0; + asm volatile(".long 0x7C0105E6 | " + "((%0 & 0x1F) << 21)" : + "=r" (rt)); + return rt; +} + +#endif + /** @brief This is a special assembler instruction that is a nop on * regular hardware, but has special meaning to Simics. Code that * executes this instruction in Simics will cause a "hap," a @@ -457,10 +475,12 @@ inline void MAGIC_INSTRUCTION(int _n) { register int n = _n; isync(); - asm volatile("rlwimi %0,%0,0,%1,%2" \ - :: "i" (((n) >> 8) & 0x1f), \ - "i" (((n) >> 4) & 0xf), \ - "i" ((((n) >> 0) & 0xf) | 16)); \ + long register r3 asm("r3"); + asm volatile("rlwimi %1,%1,0,%2,%3" \ + : "=r"(r3) : "i" (((n) >> 8) & 0x1f), \ + "i" (((n) >> 4) & 0xf), \ + "i" ((((n) >> 0) & 0xf) | 16), \ + "r"(r3)); \ } // Simics components that we can raise log levels for @@ -503,6 +523,7 @@ enum MAGIC_FAKEPAYLOAD_ENTER = 7010, // Entered the fake payload. MAGIC_SIMICS_CHECK = 7011, // Check if system is running on simics MAGIC_LOAD_PAYLOAD = 7012, // load payload from flash + MAGIC_HB_DUMP = 7014, // Create a hostboot dump MAGIC_BREAK_ON_ERROR = 7018, // Breakpoint in error cases if // env var HB_BREAK_ON_ERROR MAGIC_GET_SBE_TRACES = 7019, // Collect SBE traces @@ -512,6 +533,7 @@ enum MAGIC_TOGGLE_OUTPUT = 7023, // Enable simic log capture MAGIC_CONTINUOUS_TRACE = 7055, // extract mixed trace buffer + MAGIC_GCOV_MODULE_UNLOAD = 7056, // extract gcov info // 8000-8999 are defined by the Simics CEC team diff --git a/src/include/bootloader/bootloader_trace.H b/src/include/bootloader/bootloader_trace.H index 69c708ad0..0c82a936e 100644 --- a/src/include/bootloader/bootloader_trace.H +++ b/src/include/bootloader/bootloader_trace.H @@ -166,9 +166,9 @@ enum BootloaderTraces /** Bootloader main removeECC returned error */ BTLDR_TRC_MAIN_REMOVEECC_FAIL = 0xF1, - + /** Bootloader PNOR Access readTOC checkForNullBuffer null buffer */ - BTLDR_TRC_PA_READTOC_CHKNULLBUFFER_NULL = 0xF2, + BTLDR_TRC_PA_READTOC_CHKNULLBUFFER_NULL = 0xF2, // deprecated - do not use /** Bootloader PNOR Access readTOC performHdrChecksum checksum error */ BTLDR_TRC_PA_READTOC_HDRCHECKSUM_ERR = 0xF3, diff --git a/src/include/bootloader/hbblreasoncodes.H b/src/include/bootloader/hbblreasoncodes.H index 7ea0f189f..0f2bf568a 100644 --- a/src/include/bootloader/hbblreasoncodes.H +++ b/src/include/bootloader/hbblreasoncodes.H @@ -50,6 +50,7 @@ namespace Bootloader MOD_BOOTLOADER_VERIFY = 0x05, /**< bootloader.C : verifyContainer */ MOD_BOOTLOADER_ASSERT = 0x06, /**< bootloader.H assert */ MOD_BOOTLOADER_VERIFY_COMP_ID = 0x07, /**< bootloader.C : verifyComponentId */ + MOD_PNORACC_FINDTOC = 0x08, /**< bl_pnorAccess.C : find TOC */ }; /** @@ -66,15 +67,25 @@ namespace Bootloader RC_STD_EX_W_DSISR = HBBL_COMP_ID | 0x04, /**< Std Except w/ DSISR */ RC_STD_EX_W_SRR1 = HBBL_COMP_ID | 0x05, /**< Std Except w/ SRR1 */ RC_HYPE_EXCEPTION = HBBL_COMP_ID | 0x06, /**< Hypervisor Exception */ + //termination_rc RC_REMOVE_ECC_FAIL = HBBL_COMP_ID | 0x07, /**< Remove ECC Failed */ RC_CHK_NULL_BUFFER = HBBL_COMP_ID | 0x08, /**< Check for NULL Buffr */ + //termination_rc RC_HDR_CHECKSUM_ERR = HBBL_COMP_ID | 0x09, /**< Hdr Checksum Error */ + //termination_rc RC_CHECK_HEADER_ERR = HBBL_COMP_ID | 0x0A, /**< Check Header Error */ + //termination_rc RC_PARSE_ENTRIES_ERR = HBBL_COMP_ID | 0x0B, /**< Parse Entries Error */ + //termination_rc RC_NO_HBB_IN_TOC = HBBL_COMP_ID | 0x0C, /**< No HBB Sect in TOC */ RC_PNOR_SECID_OUT_OF_RANGE = HBBL_COMP_ID | 0x0D, /**< Requested PNOR SecId DNE in string array */ RC_PNOR_NULLPTR = HBBL_COMP_ID | 0x0E, /**< Requested address to compare is a nullptr */ + //termination_rc RC_BAD_WORK_LEN = HBBL_COMP_ID | 0x0F, /**< Working length too large */ + //termination_rc + RC_LPC_ERR = HBBL_COMP_ID | 0x10, /**< LPC Error */ + //termination_rc + RC_TOC_NOT_FOUND_ERR = HBBL_COMP_ID | 0x11, /**< TOC Not Found Error */ }; }; // end Bootloader diff --git a/src/include/iterator b/src/include/iterator index 396e1b594..dbd712b9e 100644 --- a/src/include/iterator +++ b/src/include/iterator @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ +/* [+] 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. */ @@ -62,11 +64,11 @@ struct iterator_traits<T*> * @param[in] i - The iterator to advance. * @param[in] n - The distance to advance the iterator. * - * This function is equivalent to calling (++i) n times. + * This function is equivalent to calling (++i) n times. * - * If the iterator supports random access then this function will be + * If the iterator supports random access then this function will be * implemented in linear time with respect to n. - * + * */ template <typename InputIterator, typename Distance> void advance(InputIterator& i, Distance n) @@ -90,11 +92,11 @@ void advance(InputIterator& i, Distance n) * access iterators. */ template <typename InputIterator> -typename iterator_traits<InputIterator>::difference_type +typename iterator_traits<InputIterator>::difference_type distance(InputIterator first, InputIterator last) { return Util::__Util_Iterator_Impl::distance< - InputIterator, + InputIterator, typename iterator_traits<InputIterator>::difference_type> (first, last); } @@ -129,7 +131,7 @@ class back_insert_iterator /** Dereference operator. * * This is used to make the standard pattern '*i = x' work on - * an iterator. Since we need to 'push_back' into the + * an iterator. Since we need to 'push_back' into the * container we don't actually return anything except ourself, * which allows the operator= to be called. */ @@ -168,16 +170,44 @@ class back_insert_iterator * copy(v.rbegin(), v.rend(), back_inserter(v2)); * * @param[in] s - Sequence to create an iterator for. - * + * * @return The back_insert_iterator. */ template <typename BackInsertionSequence> -back_insert_iterator<BackInsertionSequence> +back_insert_iterator<BackInsertionSequence> back_inserter(BackInsertionSequence& s) { return back_insert_iterator<BackInsertionSequence>(s); } +/** + * begin(array) + * Returns pointer to beginning of array + * + * Example: + * int c_array[] = {0, 1, 2}; + * vector<int> l_cpp_array (begin(c_array), end(c_array)); + */ +template <typename T, size_t size> +T* begin(T (&c_array)[size]) +{ + return &c_array[0]; +} + +/** + * end(array) + * Returns pointer to end of array (i.e. the element after the last element) + * + * Example: + * int c_array[] = {0, 1, 2}; + * vector<int> l_cpp_array (begin(c_array), end(c_array)); + */ +template <typename T, size_t size> +T* end(T (&c_array)[size]) +{ + return &c_array[0] + size; +} + }; // namespace std. #endif diff --git a/src/include/kernel/ptmgr.H b/src/include/kernel/ptmgr.H index d6e6be151..da0a96aed 100644 --- a/src/include/kernel/ptmgr.H +++ b/src/include/kernel/ptmgr.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2015 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -28,7 +28,6 @@ #include <stdint.h> #include <util/lockfree/stack.H> #include <kernel/vmmmgr.H> -#include <config.h> /** * @class PageTableManager diff --git a/src/include/kernel/terminate.H b/src/include/kernel/terminate.H index b80331495..ce634e5c8 100644 --- a/src/include/kernel/terminate.H +++ b/src/include/kernel/terminate.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -87,4 +87,15 @@ void termModifySRC(uint8_t i_moduleID, */ void termSetHbDump(void); +/** @fn termSetIstep + * + * @brief Set istep into progress code word of the SRC. + * + * @param[in] i_istep: Encoded istep value + * @param[out] NONE: + * + * @return Nothing + */ +void termSetIstep(uint32_t i_istep); + #endif diff --git a/src/include/runtime/README.md b/src/include/runtime/README.md new file mode 100755 index 000000000..68b7382be --- /dev/null +++ b/src/include/runtime/README.md @@ -0,0 +1,107 @@ +# interface.h::hostInterfaces::hbrt_fw_msg +How to create an HBRT to FW request message interface + 0) If passing an HBRT to FSP via MBOX or receiving a firmware notify message, + then use instruction 'generic_hbrt_fsp_message.H::GenericFspMboxMessage_t' + and/or 'How to create an HBRT Firmware Notify message' below. + 1) The biggest part will be defining the interface. Inspect the current + interfaces (req_hcode_update, error_log, etc) for inspiration. + 2) Once an interface has been designed, add it to the anonymous + hbrt_fw_msg::union, among the other interfaces. + 3) Append a new hbrt_fw_msg::io_type, that will be used to + identify the interface. + 4) How to use the new interface to pass a message + a) Make sure 'g_hostInterfaces' and 'g_hostInterfaces->firmware_request' + are not NULL. + b) Create the firmware_request request struct (hostInterfaces::hbrt_fw_msg) + to send data. + c) Populate the firmware_request request struct with data. + b) Create the firmware_request response struct (hostInterfaces::hbrt_fw_msg) + to retrieve data. 'Zero' it out. Currently, this appears to be not + used, but is needed for the firmware request call. + d) Make the firmware_request call via method 'firmware_request_helper' + Examples: + ~/src/usr/sbeio/runtime/sbeio_vital_attn.C::vital_attn_inform_opal + ~/src/usr/isteps/nvdimm/runtime/nvdimm_rt.C::notifyNvdimmProtectionChange + ~/src/usr/isteps/pm/runtime/rt_pm.C::hcode_update + ~/src/usr/errl/runtime/rt_errlmanager.C::sendMboxMsg + 5) Update /hostboot/src/usr/util/runtime/rt_fwreq_helper.C::firmware_request_helper, + to capture data from the request if an error occurs. Capture data in the + TWO switch statements 'switch (l_req_fw_msg->io_type)'. Look at others + for examples. + +# generic_hbrt_fsp_message.H::GenericFspMboxMessage_t +# How to create an HBRT Generic FSP Firmware request + Firmware request: + 1) The biggest part will be defining the interface. Inspect the current + interfaces (AttributeSetter_t, SingleScomOpHbrtFspData_t, + TargetDeconfigHbrtFspData_t, etc) for inspiration. + 2) Once an interface has been designed, add the structure to the file, + generic_hbrt_fsp_message.H, among the other interfaces. + 3) Create an MBOX message queue enum for the interface and add to: + /hostboot/src/include/usr/mbox/mbox_queues.H::queue_id_t + see current message queues for example + 4) Add a new message type for the interface to: + enum GenericFspMboxMessage_t::GENERIC_FSP_MBOX_MESSAGE_MSG_TYPE in + file generic_hbrt_fsp_message.H. + 5) How to use the new interface to pass a message + a) Make sure g_hostInterfaces and g_hostInterfaces->firmware_request + are not NULL. + b) Determine size of data. It could be as simple as the size of the + structure itself. + c) Use createGenericFspMsg to create the messages for you. + c) Populate the firmware_request request struct with data. + d) Make the firmware_request call via method + firmware_request_helper + Examples: + ~/src/usr/hwas/hwasPlatDeconfigGard.C::platPostDeconfigureTarget + ~/src/usr/fsiscom/runtime/rt_fsiscom.C::sendScomOpToFsp + ~/src/usr/fsiscom/runtime/rt_fsiscom.C::sendMultiScomReadToFsp + ~/src/usr/hwas/hwasPlatDeconfigGard.C::DeconfigGard::platPostDeconfigureTarget + +# How to create an HBRT Firmware Notify message + Firmware notify: + 1) The biggest part will be defining the interface. Inspect the current + interfaces (sbeRetryReqData_t, HbrtAttrSyncData_t, etc) for inspiration. + 2) Once an interface has been designed, add the structure to this file + with the other interfaces. + 3) Since this is a message sent from the HWSV team, you will need for + them to provide the message queue and message type, once you have + this info + a) Add the message queue to: + /hostboot/src/include/usr/mbox/mbox_queues.H::queue_id_t + b) Add the message type to: + enum generic_hbrt_fsp_message.H::GENERIC_FSP_MBOX_MESSAGE_MSG_TYPE + 4) Create a method to process the notify call in file: + ~/src/usr/util/runtime/rt_fwnotify.C. This method is where the + interface in step 1 will be used. + Examples: + ~/src/usr/util/runtime/rt_fwnotify.C::sbeAttemptRecovery + ~/src/usr/util/runtime/rt_fwnotify.C::occActiveNotification + ~/src/usr/util/runtime/rt_fwnotify.C::attrSyncRequest + 5) Update the case statement 'switch (l_hbrt_fw_msg->io_type)' found in + method ~/src/usr/util/runtime/rt_fwnotify.C::firmware_notify to + call method created in step 4. + +# Integration testing the Firmware Request/Notify Message + This is not a true integration test but a verification that the data is + being sent, via the firmware request, in the format that the caller + intended. Ensuring that the data is in the correct format and is correct + in of itself. + + Add a test case to the file: + ~/src/usr/isteps/pm/runtime/test/firmwareRequestTest.H + This is where the message will being sent via the + hostInterfaces::firmware_request(...) method. Here, is where you will + create a unique test case for your interface. Follow the examples in + this file. There are plenty of examples. + + Add stub test code to the file/method: + ~/src/usr/testcore/rtloader/loader.H::rt_firmware_request(...) + This is where the message will be received and can be tested for + correctness. Follow the examples in this file. There are plenty of + examples. + + + + + diff --git a/src/include/runtime/generic_hbrt_fsp_message.H b/src/include/runtime/generic_hbrt_fsp_message.H index 3d2f48c0a..f3d252ae2 100644 --- a/src/include/runtime/generic_hbrt_fsp_message.H +++ b/src/include/runtime/generic_hbrt_fsp_message.H @@ -30,10 +30,14 @@ /** @file generic_hbrt_fsp_message.H + * * @brief A generic structure for passing data * * This file has a generic struct to be used by the * FSP/HWSV team to send and receive data. + * + * @note See README.md file on how to create an HBRT to FW + * request/notify message interface */ // Sentinel value for bad SCOM reads @@ -54,12 +58,42 @@ private: }; +// Latest attribute setter (struct AttributeSetter_t) version +enum ATTRIBUTE_SETTER_VERSION: uint8_t +{ + ATTRIBUTE_STRUCT_VERSION_FIRST = 0x01, + ATTRIBUTE_STRUCT_VERSION_LATEST = ATTRIBUTE_STRUCT_VERSION_FIRST, +}; + +/** + * A useful struct to serialize/deserialize the Attributes data + * from GenericFspMboxMessage_t::data. + */ +struct AttributeSetter_t // a firmware_request call +{ + ATTRIBUTE_SETTER_VERSION iv_structVersion;// latest attribute setter version + uint8_t iv_reserved; + uint16_t iv_numAttributes; // number of attributes being sent + uint8_t iv_attrData[]; // points to a stream of + // AttributeTank::Attribute structures + // A method to set the local vars to a default state + void initialize() + { + iv_structVersion = ATTRIBUTE_STRUCT_VERSION_LATEST; + iv_reserved = 0; + iv_numAttributes = 0; + }; +} PACKED ; + /** * A useful struct to pack/access the HUID and HWAS state * from the GenericFspMboxMessage_t.data. * The HUID will be in the first 4 bytes followed by the HWAS state. + * + * @note message queue = MBOX::FSP_TARG_DECONFIG_MSGQ; + * message type = MSG_DECONFIG_TARGET */ -struct TargetDeconfigHbrtFspData_t +struct TargetDeconfigHbrtFspData_t // a firmware_request call { uint32_t huid; TARGETING::HwasState hwasState; @@ -70,8 +104,11 @@ struct TargetDeconfigHbrtFspData_t * This struct contains the message-specific data for * MSG_SINGLE_SCOM_OP calls to the FSP. * It shows the format of GenericFspMboxMessage_t.data. + * + * @note message queue = MBOX::FSP_SCOM_OPS_MSGQ + * message type = MSG_SINGLE_SCOM_OP */ -struct SingleScomOpHbrtFspData_t +struct SingleScomOpHbrtFspData_t // a firmware_request call { uint8_t scom_op; // DeviceFW::READ, DeviceFW::WRITE uint32_t huid; // hardware target @@ -85,8 +122,11 @@ struct SingleScomOpHbrtFspData_t * This struct contains the message-specific data for * MSG_MULTI_SCOM_OP calls to the FSP. * It shows the format of GenericFspMboxMessage_t.data. + * + * @note message queue = MBOX::FSP_SCOM_OPS_MSGQ + * message type = MSG_MULTI_SCOM_OP */ -struct MultiScomReadHbrtFspData_t +struct MultiScomReadHbrtFspData_t // a firmware_request call { uint32_t huid; // hardware target uint8_t scom_num; // number of SCOMs to read @@ -107,8 +147,11 @@ struct MultiScomReadHbrtFspData_t /** * A useful struct to access the PLID from GenericFspMboxMessage_t.data * in the case where the FSP is requesting Hostboot to restart a SBE + * + * @note message queue = MBOX::FSP_SCOM_OPS_MSGQ + * message type = MSG_SBE_ERROR */ -struct SbeRetryReqData_t +struct SbeRetryReqData_t // a firmware_notify call { uint32_t huid; uint32_t plid; @@ -122,8 +165,10 @@ struct SbeRetryReqData_t * The HUID will be the first 4 bytes followed by a 4-byte attribute ID, * then a 4-byte size of attribute data, and finally the attribute's data * + * @note message queue = MBOX::HB_ATTR_SYNC_MSGQ + * message type = MSG_ATTR_SYNC_REQUEST */ -struct HbrtAttrSyncData_t +struct HbrtAttrSyncData_t // a firmware_notify call { // HUID of target on which we want to update the attribute uint32_t huid; @@ -187,14 +232,15 @@ struct GenericFspMboxMessage_t MSG_TOD_BACKUP_RESET = 0x0001, MSG_TOD_BACKUP_RESET_INFORM_PHYP = 0x0002, MSG_TOD_TOPOLOGY_DATA = 0x0003, - MSG_DECONFIG_TARGET = 0x0004, - MSG_SINGLE_SCOM_OP = 0x0005, - MSG_MULTI_SCOM_OP = 0x0006, - MSG_ATTR_SYNC_REQUEST = 0x000000A5, + MSG_DECONFIG_TARGET = 0x0004, // for TargetDeconfigHbrtFspData_t + MSG_SINGLE_SCOM_OP = 0x0005, // for SingleScomOpHbrtFspData_t + MSG_MULTI_SCOM_OP = 0x0006, // for MultiScomReadHbrtFspData_t + MSG_ATTR_WRITE_OP = 0x0007, // for AttributeSetter_t + MSG_ATTR_SYNC_REQUEST = 0x000000A5, // for HbrtAttrSyncData_t MSG_OCC_ACTIVE = 0x000000A6, - MSG_SBE_ERROR = 0x000000D4, - MSG_SBE_RECOVERY_SUCCESS = 0x000000D5, - MSG_SBE_RECOVERY_FAILED = 0x000000D6, + MSG_SBE_ERROR = 0x000000D4, // for SbeRetryReqData_t + MSG_SBE_RECOVERY_SUCCESS = 0x000000D5, // associated with SbeRetryReqData_t + MSG_SBE_RECOVERY_FAILED = 0x000000D6, // associated with SbeRetryReqData_t }; /** diff --git a/src/include/runtime/hbrt_utilities.H b/src/include/runtime/hbrt_utilities.H index 649677422..2ee2172df 100644 --- a/src/include/runtime/hbrt_utilities.H +++ b/src/include/runtime/hbrt_utilities.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017,2018 */ +/* Contributors Listed Below - COPYRIGHT 2017,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,7 +29,16 @@ #define HBRT_TRACE_NAME "HBRT" -#include "interface.h" +extern trace_desc_t *g_trac_runtime; + +#include <vector> + +#include "interface.h" // hostInterfaces +#include "generic_hbrt_fsp_message.H" // GenericFspMboxMessage_t, AttributeSetter_t +#include "targeting/common/attributeTank.H" // TARGETING::AttributeTank::Attribute +#include <initservice/initserviceif.H> // INITSERVICE +#include "util/runtime/rt_fwreq_helper.H" // firmware_request_helper +#include "runtime/runtime_reasoncodes.H" // MOD_XXX and RC_XXX /** @file hbrt_utilities.H * @brief A file to put HBRT Interface utilities @@ -54,9 +63,9 @@ * to newly created data.) * * @post The request/response messages point to a valid struct, - * the request/response message size are equal to each other - * and contain the size of the request/response messages - * respectively upon a successful call else all the output + * the request/response messages' size are equal to each other, request + * message is initalized (data size is set) and response message is + * zeroed out, upon a successful call else all the output * parameters will either be NULL or 0 based on type. * * @note Use this function iff hbrt_fw_msg::io_type is of type @@ -65,7 +74,7 @@ * @note Caller is responsible for deleting (use delete []) the * allocated memory * - * @param[in] i_fspReqPayloadSize The size of the payload that will + * @param[in] i_fspReqPayloadSize The size of the payload that will * populate GenericFspMboxMessage_t::data * @param[out] o_fspMsgSize Return the size of the * GenericFspMboxMessage_t, adjusted to @@ -76,66 +85,23 @@ * will be equal to the request msg size * @param[out] o_responseMsg The allocated response message (not * NULL), zeroed out + * @return true if NO issue allocating memory for request/response messages, + * else false */ -void createGenericFspMsg(uint32_t i_fspReqPayloadSize, - uint32_t &o_fspMsgSize, - uint64_t &o_requestMsgSize, - hostInterfaces::hbrt_fw_msg* &o_requestMsg, - uint64_t &o_responseMsgSize, - hostInterfaces::hbrt_fw_msg* &o_responseMsg) -{ - // Do some quick initialization of the output data - o_fspMsgSize = o_requestMsgSize = o_responseMsgSize = 0; - o_requestMsg = o_responseMsg = nullptr; - - // Calculate the total size of the Generic FSP Message. - o_fspMsgSize = GENERIC_FSP_MBOX_MESSAGE_BASE_SIZE + - i_fspReqPayloadSize; - - // The total Generic FSP Message size must be at a minimum the - // size of the FSP generic message (sizeof(GenericFspMboxMessage_t)) - if (o_fspMsgSize < sizeof(GenericFspMboxMessage_t)) - { - o_fspMsgSize = sizeof(GenericFspMboxMessage_t); - } +bool createGenericFspMsg(uint32_t i_fspReqPayloadSize, + uint32_t &o_fspMsgSize, + uint64_t &o_requestMsgSize, + hostInterfaces::hbrt_fw_msg* &o_requestMsg, + uint64_t &o_responseMsgSize, + hostInterfaces::hbrt_fw_msg* &o_responseMsg); - // Calculate the total size of the hbrt_fw_msgs which - // means only adding hostInterfaces::HBRT_FW_MSG_BASE_SIZE to - // the previous calculated Generic FSP Message size. - o_requestMsgSize = o_responseMsgSize = - hostInterfaces::HBRT_FW_MSG_BASE_SIZE + o_fspMsgSize; - // Create the hbrt_fw_msgs - o_responseMsg = reinterpret_cast<hostInterfaces::hbrt_fw_msg *> - (new uint8_t[o_responseMsgSize]); - o_requestMsg = reinterpret_cast<hostInterfaces::hbrt_fw_msg *> - (new uint8_t[o_requestMsgSize]); - - // If anyone of these two message's memory can't be allocated, then - // delete both messages (in case one did allocate memory), set both - // messages to NULL pointers and set their respective sizes to zero. - if (!o_responseMsg || !o_requestMsg) - { - // OK to delete a NULL pointer if it happens - delete []o_responseMsg; - delete []o_requestMsg; - - // Return output data zeroed out - o_responseMsg = o_requestMsg = nullptr; - o_fspMsgSize = o_requestMsgSize = o_responseMsgSize = 0; - } - else - { - // Initialize/zero out hbrt_fw_msgs - o_requestMsg->generic_msg.initialize(); - memset(o_responseMsg, 0, o_responseMsgSize); +/** + * @brief Serializes a list of Attributes to be sent to FSP + */ +errlHndl_t sendAttributes(const std::vector<TARGETING::AttributeTank::Attribute>& + i_attributeList); - // We can at least set these parameters based on current usage - o_requestMsg->io_type = hostInterfaces::HBRT_FW_MSG_HBRT_FSP_REQ; - o_requestMsg->generic_msg.dataSize = o_fspMsgSize; - o_requestMsg->generic_msg.__req = GenericFspMboxMessage_t::REQUEST; - } -} // end createGenericFspMsg #endif //__HOSTBOOT_RUNTIME_INTERFACE_VERSION_ONLY #endif // __RUNTIME__UTILITIES_H diff --git a/src/include/runtime/interface.h b/src/include/runtime/interface.h index cd6d0e23a..6304ec6ba 100644 --- a/src/include/runtime/interface.h +++ b/src/include/runtime/interface.h @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2019 */ +/* Contributors Listed Below - COPYRIGHT 2013,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -193,6 +193,10 @@ enum MemoryError_t /* Defined Return Codes for wakeup() */ #define HBRT_RC_WAKEUP_INVALID_ON_CORE_XSTOP -12289 /* -0x3001 */ +/* Define a const, for hostInterfaces::nvdimm_operation_t::procId, + * that will flag when to apply the NVDIMM operation(s) to all NVDIMMs + */ +const uint64_t HBRT_NVDIMM_OPERATION_APPLY_TO_ALL_NVDIMMS = 0xFFFFFFFFFFFFFFFF; /** @typedef hostInterfaces_t * @brief Interfaces provided by the underlying environment (ex. Sapphire). @@ -541,19 +545,25 @@ typedef struct hostInterfaces /** * @brief Structure to be sent and received in the * firmware_request call + * + * @note see README.md file on how to create an HBRT to FW + * request message interface */ - enum + + enum // hbrt_fw_msg::io_type the struct associated with io_type { - HBRT_FW_MSG_TYPE_REQ_NOP = 0, - HBRT_FW_MSG_TYPE_RESP_NOP = 1, - HBRT_FW_MSG_TYPE_RESP_GENERIC = 2, - HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3, - HBRT_FW_MSG_HBRT_FSP_REQ = 4, - HBRT_FW_MSG_TYPE_ERROR_LOG = 5, - HBRT_FW_MSG_HBRT_FSP_RESP = 6, - HBRT_FW_MSG_TYPE_I2C_LOCK = 7, - HBRT_FW_MSG_TYPE_SBE_STATE = 8, - HBRT_FW_MSG_TYPE_NVDIMM_PROTECTION = 9, + HBRT_FW_MSG_TYPE_REQ_NOP = 0, + HBRT_FW_MSG_TYPE_RESP_NOP = 1, // struct resp_generic + HBRT_FW_MSG_TYPE_RESP_GENERIC = 2, // struct resp_generic + HBRT_FW_MSG_TYPE_REQ_HCODE_UPDATE = 3, // struct req_hcode_update + HBRT_FW_MSG_HBRT_FSP_REQ = 4, // struct GenericFspMboxMessage_t + HBRT_FW_MSG_TYPE_ERROR_LOG = 5, // struct error_log + HBRT_FW_MSG_HBRT_FSP_RESP = 6, // struct GenericFspMboxMessage_t + HBRT_FW_MSG_TYPE_I2C_LOCK = 7, // struct req_i2c_lock + HBRT_FW_MSG_TYPE_SBE_STATE = 8, // struct sbe_state + HBRT_FW_MSG_TYPE_NVDIMM_PROTECTION = 9, // struct nvdimm_protection_state + HBRT_FW_MSG_TYPE_NVDIMM_OPERATION = 10, // struct nvdimm_operation_t + HBRT_FW_MSG_TYPE_GARD_EVENT = 11, // struct gard_event_t }; // NVDIMM protection state enum @@ -563,6 +573,88 @@ typedef struct hostInterfaces HBRT_FW_NVDIMM_PROTECTED = 1 }; + // NVDIMM valid operations + // @note Multiple operations can be triggered at the same time using + // a single NVDIMM operation call. Having said that, operation + // combinations should be sensical. Nonsensical operations will + // error out. + enum NVDIMM_Op_t: uint16_t + { + /// The following operations pertain to arming/disarming + /// the NVDIMM + // Disarm the NV logic such that the next save attempt is a NOOP + HBRT_FW_NVDIMM_DISARM = 0x0001, + // Disable encryption on the NVDIMM and clear saved values from FW + HBRT_FW_NVDIMM_DISABLE_ENCRYPTION = 0x0002, + // Remove keys + HBRT_FW_NVDIMM_REMOVE_KEYS = 0x0004, + // Enable encryption on the NVDIMM + HBRT_FW_NVDIMM_ENABLE_ENCRYPTION = 0x0008, + // Arm the NV logic + HBRT_FW_NVDIMM_ARM = 0x0010, + + /// The following operations pertain to the Health of the NVDIMM + /// This operation can be performed with the arming/disarming + /// operation, these operation types are orthogonal to each other + // Manufacturing(MNFG) energy source(ES) health check request + HBRT_FW_MNFG_ES_HEALTH_CHECK = 0x0020, + // Manufacturing(MNFG) non-volatile memory(NVM) health check request + HBRT_FW_MNFG_NVM_HEALTH_CHECK = 0x0040, + + /// The following operations pertain to the decommission of an NVDIMM + // Factory Default returns the NVDIMM to the factory default state + HBRT_FW_NVDIMM_FACTORY_DEFAULT = 0x0080, + // Secure Erase Verify all NAND flash blocks have been erased + HBRT_FW_NVDIMM_SECURE_EV_START = 0x0100, + // Secure Erase Verify Status checks if SEV operation has completed + HBRT_FW_NVDIMM_SECURE_EV_STATUS = 0x0200, + }; + + // NVDIMM (PHYP -> HBRT) message to request NVDIMM operation(s) + struct nvdimm_operation_t + { + uint64_t procId; // Retrieve all NVDIMMs under the processor ID; all + // FFs (HBRT_NVDIMM_OPERATION_APPLY_TO_ALL_NVDIMMS) + // means operate on all NVDIMMs in the system + uint32_t rsvd1; // reserved + uint16_t rsvd2; // reserved + NVDIMM_Op_t opType; // NVDIMM operation(s) to perform, + // see @note associated with NVDIMM_Op_t above + } __attribute__ ((packed)); + + // Gard event error type + // @note This needs to stay in sync with the FSP Mailbox specification for + // command : Gard-able Error Detected - cmd 0xCE, s/c 0x63, mod 01 + enum GARD_ERROR_t: uint32_t + { + HBRT_GARD_ERROR_UNKNOWN = 0x0000, + HBRT_GARD_ERROR_COMPUTATION_TEST_FAILURE = 0x0001, + HBRT_GARD_ERROR_SLB = 0x0002, + HBRT_GARD_ERROR_CHIP_TOD_FAILURE = 0x0003, + HBRT_GARD_ERROR_TIMEFAC_FAILURE = 0x0004, + HBRT_GARD_ERROR_PROC_RECOVERY_THRESHOLD = 0x0005, + HBRT_GARD_ERROR_NX = 0x0008, + HBRT_GARD_ERROR_SLW = 0x0009, + HBRT_GARD_ERROR_CAPP_UNIT = 0x000A, + + // Mark the end of the gard error types. + // This is not valid, just a marker + HBRT_GARD_ERROR_LAST, + }; + + // Gard event (PHYP/OPAL -> HBRT) + struct gard_event_t + { + GARD_ERROR_t i_error_type; // Gard event error type enum + uint32_t i_procId; // Processor ID for + // error types 0x0001 to 0x0005 + // Chip ID for + // error types 0x0008 to 0x000A + uint32_t i_plid; // Platform log identifier + uint16_t i_sub_unit_mask; // Currently not being used + uint16_t i_recovery_level; // Currently not being used + } __attribute__ ((packed)); + struct hbrt_fw_msg // define struct hbrt_fw_msg { hbrt_fw_msg() { req_hcode_update = { 0 }; }; // ctor @@ -593,7 +685,7 @@ typedef struct hostInterfaces } req_hcode_update; // This struct is sent from HBRT with - // io_type set to HBRT_FW_MSG_TYPE_ERR_LOG + // io_type set to HBRT_FW_MSG_TYPE_ERROR_LOG // Send an error log to FSP struct { @@ -633,6 +725,14 @@ typedef struct hostInterfaces uint64_t i_state; // NVDIMM protection state enum } __attribute__ ((packed)) nvdimm_protection_state; + // This struct is sent from PHYP to HBRT with + // io_type set to HBRT_FW_MSG_TYPE_NVDIMM_OPERATION + struct nvdimm_operation_t nvdimm_operation; + + // This struct is sent from PHYP/OPAL to HBRT with + // io_type set to HBRT_FW_MSG_TYPE_GARD_EVENT + struct gard_event_t gard_event; + // This struct is sent from HBRT with // io_type set to HBRT_FW_MSG_HBRT_FSP_REQ or // HBRT_FW_MSG_HBRT_FSP_RESP @@ -1032,6 +1132,11 @@ struct postInitCalls_t */ void (*callCommitRsvdTraceBufErrl)(); + /** + * @brief Sends current NV_STATUS to host + * + */ + void (*callSendNvStatus)(); }; extern hostInterfaces_t* g_hostInterfaces; diff --git a/src/include/securerom/ROM.H b/src/include/securerom/ROM.H index f4cf76528..0d97537e0 100644 --- a/src/include/securerom/ROM.H +++ b/src/include/securerom/ROM.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016,2018 */ +/* Contributors Listed Below - COPYRIGHT 2016,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -284,7 +284,7 @@ enum HW_SB_FLAGS // SW Security Flags enum SW_SB_FLAGS { - // placeholder + HASH_PAGE_TABLE_FLAG = 0x80000000 }; // Structure to store all hw and sw flag values in a container header @@ -295,7 +295,8 @@ struct sb_flags_t hw_opal(false), hw_phyp(false), hw_lab_override(false), - hw_key_transition(false) + hw_key_transition(false), + sw_hash(false) { } @@ -305,6 +306,7 @@ struct sb_flags_t bool hw_lab_override; ///< Whether to enable lab security override; ///< Only applicable for SBE partition bool hw_key_transition; ///< Indicates this is a key transition container + bool sw_hash; ///< Indicates presence of hash page table }; /** diff --git a/src/include/usr/console/consoleif.H b/src/include/usr/console/consoleif.H index 497252ded..fc3b83d24 100644 --- a/src/include/usr/console/consoleif.H +++ b/src/include/usr/console/consoleif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2017 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -26,8 +26,8 @@ #ifndef __CONSOLE_CONSOLEIF_H #define __CONSOLE_CONSOLEIF_H -#include <config.h> #include <stdarg.h> +#include <stddef.h> namespace CONSOLE { diff --git a/src/include/usr/console/uartif.H b/src/include/usr/console/uartif.H index 768e0d45b..982400227 100644 --- a/src/include/usr/console/uartif.H +++ b/src/include/usr/console/uartif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -25,7 +25,6 @@ #ifndef __CONSOLE_UARTIF_H #define __CONSOLE_UARTIF_H -#include <config.h> #include <stdarg.h> namespace CONSOLE diff --git a/src/include/usr/cxxtest/TestSuite.H b/src/include/usr/cxxtest/TestSuite.H index 0c9e2305a..716637049 100755 --- a/src/include/usr/cxxtest/TestSuite.H +++ b/src/include/usr/cxxtest/TestSuite.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -40,6 +40,7 @@ #include <trace/interface.H> #include <sys/sync.h> #include <usr/cxxtest/cxxtest_data.H> +#include <vector> extern trace_desc_t *g_trac_test; @@ -76,6 +77,9 @@ public: class AbortTest {}; +void sortTests(std::vector<const char *> & i_list, + std::vector<const char *> & o_serial_list, + std::vector<const char *> & o_parallel_list); void doTrace( ); void doWarn( ); void doFailTest( ); diff --git a/src/include/usr/devicefw/driverif.H b/src/include/usr/devicefw/driverif.H index 048b8dc19..66c420c21 100644 --- a/src/include/usr/devicefw/driverif.H +++ b/src/include/usr/devicefw/driverif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2019 */ +/* Contributors Listed Below - COPYRIGHT 2011,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -103,6 +103,8 @@ namespace DeviceFW I2C_SMBUS_WORD = 3, ///< I2c SMBUS Read/Write Word I2C_SMBUS_BYTE = 4, ///< I2c SMBUS Read/Write Byte I2C_SMBUS_SEND_OR_RECV = 5, ///< I2c SMBUS Send/Receive Byte + I2C_SMBUS_WORD_NO_PEC = 6, ///< I2c SMBUS Read/Write Word without PEC byte + I2C_SMBUS_BLOCK_NO_BYTE_COUNT = 7, ///< I2c SMBUS Block Read/Write without first byte being a byte count }; #ifndef PARSER diff --git a/src/include/usr/devicefw/userif.H b/src/include/usr/devicefw/userif.H index d626d49c0..ec94bef32 100644 --- a/src/include/usr/devicefw/userif.H +++ b/src/include/usr/devicefw/userif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2019 */ +/* Contributors Listed Below - COPYRIGHT 2011,2020 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -68,7 +68,8 @@ namespace DeviceFW AHB_SIO, // AST Hostbridge via SIO DVPD, // Direct access memory VPD NODECOMM, // Internode communication - NVDIMM, // Non-volatile DIMM controller access + NVDIMM, // Routes message to non-volatile DIMM controller access + NVDIMM_RAW, // Non-volatile DIMM controller access FAPI_I2C, // FAPI2-triggered i2c accesses MMIO, // Memory Mapped I/O IDEC, // Read and set EC and CHIPID values @@ -379,12 +380,45 @@ namespace DeviceFW static_cast<uint64_t>(( i_mailbox_id )) /** - * Construct the device addressing parameters for the NVDIMM device ops. - * @param[i] i_address - NVDIMM address to internal register + * @brief Construct the device addressing parameters for the + * NVDIMM device ops. + * @details This call includes setting the page based off the address + * and then performing the read/write of that NVDIMM address. + * @see DEVICE_NVDIMM_RAW_ADDRESS for an NVDIMM read/write call without + * page setting. + * @param[i] i_address - NVDIMM address to an internal register */ #define DEVICE_NVDIMM_ADDRESS(i_address)\ DeviceFW::NVDIMM, static_cast<uint64_t>((i_address)) + /** + * @brief Construct the device addressing parameters for the + * NVDIMM RAW device ops + use block size specified + * @details This a raw call to read/write a NVDIMM address which means it + * will not set the page before it does the read/write call. Hence, + * for this call to work properly, the page must have been set + * properly beforehand. + * @see DEVICE_NVDIMM_ADDRESS for a NVDIMM read/write call with + * page setting. + * @param[i] i_address - NVDIMM address to an internal register + * @param[i] i_blockSize - maximum block size for operation (0 = default size, 2 and 32 valid) + */ + #define DEVICE_NVDIMM_RAW_ADDRESS_WITH_BLOCKSIZE(i_address, i_blockSize)\ + DeviceFW::NVDIMM_RAW, static_cast<uint64_t>((i_address)), static_cast<uint64_t>((i_blockSize)) + + /** + * @brief Construct the device addressing parameters for the + * NVDIMM RAW device ops. + * @details This a raw call to read/write a NVDIMM address which means it + * will not set the page before it does the read/write call. Hence, + * for this call to work properly, the page must have been set + * properly beforehand. + * @see DEVICE_NVDIMM_ADDRESS for a NVDIMM read/write call with + * page setting. + * @param[i] i_address - NVDIMM address to an internal register + */ + #define DEVICE_NVDIMM_RAW_ADDRESS(i_address)\ + DEVICE_NVDIMM_RAW_ADDRESS_WITH_BLOCKSIZE(i_address, 0) /** * Construct the device addressing parameters for the FAPI I2C operation diff --git a/src/include/usr/diag/attn/attn.H b/src/include/usr/diag/attn/attn.H index 186974224..c32212663 100644 --- a/src/include/usr/diag/attn/attn.H +++ b/src/include/usr/diag/attn/attn.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -34,7 +34,6 @@ #include <errl/errlentry.H> // Custom compile configs -#include <config.h> namespace ATTN { diff --git a/src/include/usr/diag/prdf/prdfMain_ipl.H b/src/include/usr/diag/prdf/prdfMain_ipl.H index 08b626ce2..302cd4e61 100644 --- a/src/include/usr/diag/prdf/prdfMain_ipl.H +++ b/src/include/usr/diag/prdf/prdfMain_ipl.H @@ -27,7 +27,6 @@ #define __prdfMain_ipl_H // Custom compile configs -#include <config.h> /** * @file prdfMain_ipl.H @@ -48,7 +47,7 @@ extern errlHndl_t noLock_initialize(); /** * @brief Restores hardware DRAM repairs to reflect what is stored in VPD. - * @param i_trgt An MBA or MCA target. + * @param i_trgt An MBA, MCA, or OCMB target. * @return Non-SUCCESS if conditions are such that a callout had to be made, * SUCCESS otherwise. */ @@ -57,17 +56,17 @@ extern uint32_t restoreDramRepairs( const TARGETING::TargetHandle_t i_trgt ); /** * @brief Analyzes IPL CE statistics during MNFG IPL - * @param i_mba An MBA target. + * @param i_trgt An MBA, MCBIST, or OCMB_CHIP target. * @param o_calloutMade True if callout has been made, false otherwise . * @return Non-SUCCESS if internal function fails, SUCCESS otherwise. */ -extern int32_t analyzeIplCEStats( const TARGETING::TargetHandle_t i_mba, +extern int32_t analyzeIplCEStats( const TARGETING::TargetHandle_t i_trgt, bool &o_calloutMade ); /** * @brief Starts memory background scrubbing on the given target. * @param i_trgt A target that contains the maintenance command logic (i.e. - * MCBIST or MBA). + * MCBIST or MBA or OCMB_CHIP). * @return If an error log is returned, then some internal function failed. See * the FFDC in the error log for failure details. */ diff --git a/src/include/usr/dump/dumpif.H b/src/include/usr/dump/dumpif.H index ea48a71fd..0b616be74 100644 --- a/src/include/usr/dump/dumpif.H +++ b/src/include/usr/dump/dumpif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2019 */ +/* Contributors Listed Below - COPYRIGHT 2012,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -146,10 +146,19 @@ namespace DUMP #define DUMP_ARCH_REG_TYPE_SPR 0x02 // Architected register data content entries + union reg_t + { + char name[sizeof(uint32_t)*2]; + struct + { + uint32_t type; + uint32_t num; + }PACKED; + }PACKED; + struct hostArchRegDataEntry { - uint32_t regType; - uint32_t regNum; + reg_t reg; uint64_t regVal; } PACKED; diff --git a/src/include/usr/errl/errlentry.H b/src/include/usr/errl/errlentry.H index a41cb7bcf..905203a9e 100644 --- a/src/include/usr/errl/errlentry.H +++ b/src/include/usr/errl/errlentry.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2019 */ +/* Contributors Listed Below - COPYRIGHT 2011,2020 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -860,17 +860,15 @@ private: */ void addVersionInfo(void); -#ifdef CONFIG_BMC_IPMI /** - * @brief called by addHwCallout to retrieve the serial and part number - * from the current target. If the current target does not contain - * ATTR_PART_NUMBER or ATTR_SERIAL_NUMBER, find the first parent that does - * and adds the attribute to the error log. + * @brief called by addHwCallout to retrieve various pieces of card + * and/or chip data, e.g. part number, serial number, ecid. * * @param[in] i_target The target to get the numbers for */ - void addPartAndSerialNumbersToErrLog(const TARGETING::Target * i_target); + void addPartIdInfoToErrLog(const TARGETING::Target * i_target); +#ifdef CONFIG_BMC_IPMI /** * @brief called by addHwCallout to retrieve the FRU ID and sensor ID * from the current target. If the current target does not contain @@ -1146,4 +1144,10 @@ inline bool ErrlEntry::getDoHbDump() */ #define ERRL_GETEID_SAFE(errhdl) (errhdl == NULL ? 0 : errhdl->eid()) +// These defines allow standard logging of error information in traces +#define TRACE_ERR_FMT "Error info: PLID=0x%08X, EID=0x%08X, Reason=0x%04X. " + +#define TRACE_ERR_ARGS(pError) \ + ERRL_GETPLID_SAFE(pError), ERRL_GETEID_SAFE(pError), ERRL_GETRC_SAFE(pError) + #endif //ERRLENTRY_H diff --git a/src/include/usr/errl/errlmanager.H b/src/include/usr/errl/errlmanager.H index f7407d8c4..cfd5ee21d 100644 --- a/src/include/usr/errl/errlmanager.H +++ b/src/include/usr/errl/errlmanager.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -35,7 +35,6 @@ /*****************************************************************************/ // I n c l u d e s /*****************************************************************************/ -#include <config.h> #include <util/singleton.H> #include <errl/errlentry.H> #include <errldisplay/errldisplay.H> @@ -82,6 +81,32 @@ void errlCommit(errlHndl_t& io_err, compId_t i_committerComp ); uint8_t getHiddenLogsEnable(); /** + * @brief Returns the cached VERSION partition, if any. Makes a call to + * ErrlManager::getCachedVersionPartition + * @return uint8_t* The pointer to the binary contents of the VERSION + * partition; nullptr will be returned if VERSION hasn't been + * cached yet of if there was an error during caching + */ +const uint8_t* getCachedVersionPartition(); + +/** + * @brief Returns the size of the cached VERSION partition. Makes a call + * to ErrlManager::getCachedVersionPartitionSize + * @return size_t The size of the cached VERSION partition. A 0 will be + * returned if VERSION hasn't been cached yet or if there was an + * error during caching + */ +size_t getCachedVersionPartitionSize(); + +/* + * @brief Call to ErrlManager to cache the VERSION PNOR partition into an + * internal buffer. + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ +errlHndl_t cacheVersionPartition(); + +/** * @brief Global enums used by static errlResourceReady function */ enum errlManagerNeeds @@ -209,6 +234,34 @@ public: */ static bool errlCommittedThisBoot(); + /** + * @brief Returns the cached VERSION partition, if any + * @return uint8_t* The pointer to the binary contents of the VERSION + * partition + */ + const uint8_t* getCachedVersionPartition() const; + + /** + * @brief Returns the size of the cached VERSION partition + * @return size_t The size of the cached VERSION partition + */ + size_t getCachedVersionPartitionSize() const; + + /** + * @brief Cache the VERSION PNOR partition into a member buffer. The + * buffer is dynamically allocated here to hold the contents of the + * partition. If any error occurs during the execution, the buffer + * is deleted and the error is returned. This function is not + * supposed to be called within ErrlManager message handler, since + * the function itself makes synchronous calls to various message + * handlers. Note that once the partition is cached, the cache is + * never purged to make sure all possible error logs receive the + * VERSION field. No-op on FSP systems. + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ + errlHndl_t cacheVersionPartition(); + /** * @brief Value to determine what logs are to be skipped. Mirrors @@ -424,6 +477,11 @@ private: bool iv_pnorReadyForErrorLogs; /** + * @brief Indicates if we have processed a shutdown event message + */ + bool iv_recvdShutdownEvent; + + /** * @brief * Pointer to the header that precedes the error log storage buffer * in L3 RAM. This may go away when we adopt PNOR, or else become @@ -634,6 +692,15 @@ private: bool allowCallHomeEselsToBmc(void); #endif + const uint8_t* iv_versionPartitionCache; // The bin contents of the VERSION + // partition; once cached, the + // constents are never removed + + size_t iv_versionPartitionCacheSize; // The size of the VERSION partition + + bool iv_isVersionPartitionCached; // Whether the caching of the VERSION + // partition has been attempted + }; diff --git a/src/include/usr/errl/errludattribute.H b/src/include/usr/errl/errludattribute.H new file mode 100644 index 000000000..8321785cb --- /dev/null +++ b/src/include/usr/errl/errludattribute.H @@ -0,0 +1,87 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/errl/errludattribute.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ + +#ifndef ERRL_UDATTRIBUTE_H +#define ERRL_UDATTRIBUTE_H + +/** + * Defines the classes that allow you to save attribute data to + * an error log. + */ + +#include <errl/errluserdetails.H> + +namespace TARGETING // Forward reference +{ class Target; } + +namespace ERRORLOG +{ +class ErrlUserDetailsAttribute : public ErrlUserDetails { + public: + + /** + * @brief Constructor to add a single attribute + * + * @param i_target Target from whom the attribute is being read + * @param i_attr Attribute id/hash + */ + ErrlUserDetailsAttribute(const TARGETING::Target * i_pTarget, + uint32_t i_attr); + + /** + * @brief Constructor to add no attributes (need to call addData) + * + * @param i_target Target from whom the attribute is being read + */ + ErrlUserDetailsAttribute(const TARGETING::Target * i_pTarget); + + /** + * @brief Add an additional attribute to the log + * + * @param i_attr Attribute id/hash + */ + void addData(uint32_t i_attr); + + + /** + * @brief Destructor + */ + virtual ~ErrlUserDetailsAttribute(); + + private: + + // Disabled + ErrlUserDetailsAttribute(const ErrlUserDetailsAttribute &); + ErrlUserDetailsAttribute & operator=(const ErrlUserDetailsAttribute &); + + // internal function + void dumpAll(); + + const TARGETING::Target * iv_pTarget; + uint32_t iv_dataSize; +}; +} + +#endif //ERRL_UDATTRIBUTE_H diff --git a/src/include/usr/errl/errludprintk.H b/src/include/usr/errl/errludprintk.H index 4d304ff46..629716e68 100644 --- a/src/include/usr/errl/errludprintk.H +++ b/src/include/usr/errl/errludprintk.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ +/* [+] 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. */ @@ -39,7 +41,7 @@ namespace ERRORLOG class ErrlUserDetailsPrintk : public ErrlUserDetails { public: - enum { DEFAULT_SIZE_BYTES = 256 }; + enum { DEFAULT_SIZE_BYTES = 1280 }; /** @brief Constructor * diff --git a/src/include/usr/errldisplay/errldisplay.H b/src/include/usr/errldisplay/errldisplay.H index b5856b7f1..a219a47c3 100644 --- a/src/include/usr/errldisplay/errldisplay.H +++ b/src/include/usr/errldisplay/errldisplay.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2017 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -35,7 +35,6 @@ /*****************************************************************************/ // I n c l u d e s /*****************************************************************************/ -#include <config.h> #include <errl/errlentry.H> namespace ERRORLOGDISPLAY diff --git a/src/include/usr/expscom/expscom_reasoncodes.H b/src/include/usr/expscom/expscom_reasoncodes.H index 9eb7ebc29..67608b69c 100644 --- a/src/include/usr/expscom/expscom_reasoncodes.H +++ b/src/include/usr/expscom/expscom_reasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -43,6 +43,12 @@ namespace EXPSCOM RC_INVALID_OPTYPE = EXPSCOM_COMP_ID | 0x03, RC_INVALID_ADDRESS = EXPSCOM_COMP_ID | 0x04, }; + + enum UserDetailsTypes + { + EXPSCOM_UDT_ACTIVE_LOG = 0x01, + EXPSCOM_UDT_SAVED_LOG = 0x02, + }; }; #endif diff --git a/src/include/usr/expupd/expupd.H b/src/include/usr/expupd/expupd.H new file mode 100644 index 000000000..a686d7f91 --- /dev/null +++ b/src/include/usr/expupd/expupd.H @@ -0,0 +1,45 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/expupd/expupd.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +#ifndef __EXPUPD_H +#define __EXPUPD_H + +#include <isteps/hwpisteperror.H> + +namespace expupd +{ + +/** + * @brief Check flash image SHA512 hash value of each explorer chip + * and update the flash if it does not match the SHA512 hash + * of the image in PNOR. + * + * @param[out] o_stepError Error handle for logging istep failures + * + */ +void updateAll(ISTEP_ERROR::IStepError& o_stepError); + +}//namespace expupd + +#endif diff --git a/src/include/usr/expupd/expupd_reasoncodes.H b/src/include/usr/expupd/expupd_reasoncodes.H new file mode 100644 index 000000000..d5837206a --- /dev/null +++ b/src/include/usr/expupd/expupd_reasoncodes.H @@ -0,0 +1,54 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/expupd/expupd_reasoncodes.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ + +#ifndef __EXPUPD_REASONCODES_H +#define __EXPUPD_REASONCODES_H + +#include <hbotcompid.H> + +namespace EXPUPD +{ + + enum ExpUpdModuleId + { + MOD_OCMB_FW_VALIDATE_IMAGE = 0x01, + MOD_PARSE_TAGGED_DATA_TRIPLET = 0x02, + }; + + enum ExpUpdReasonCode + { + INVALID_PARMS = EXPUPD_COMP_ID | 0x01, + INVALID_EYE_CATCHER = EXPUPD_COMP_ID | 0x02, + INVALID_HEADER_VERSION = EXPUPD_COMP_ID | 0x03, + INVALID_HEADER_SIZE = EXPUPD_COMP_ID | 0x04, + MISSING_SHA512_HASH = EXPUPD_COMP_ID | 0x05, + INVALID_DATA_TRIPLET_SIZE = EXPUPD_COMP_ID | 0x06, + INVALID_HASH_TRIPLET_SIZE = EXPUPD_COMP_ID | 0x07, + INVALID_TAG_ID = EXPUPD_COMP_ID | 0x08, + }; + +}; // namespace EXPUPD + +#endif diff --git a/src/include/usr/expupd/ocmbFwImage_const.H b/src/include/usr/expupd/ocmbFwImage_const.H new file mode 100644 index 000000000..b97b1adcf --- /dev/null +++ b/src/include/usr/expupd/ocmbFwImage_const.H @@ -0,0 +1,111 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/expupd/ocmbFwImage_const.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +#ifndef __OCMBFWIMAGE_CONST_H +#define __OCMBFWIMAGE_CONST_H + +namespace expupd +{ + +// ********************************WARNING********************************** +// +// THIS FILE MUST BE KEPT IN SYNC WITH src/build/buildpnor/pkgOcmbFw.pl +// +// ********************************WARNING********************************** + + +/** + * @brief Eyecatcher value is the ascii representation of the + * null terminated string, "OCMBHDR". + */ +constexpr uint64_t EYE_CATCHER_VALUE = 0x4F434D4248445200ULL; + +constexpr uint32_t MAX_BIN_TRACE = 256; + +/** + * @brief Miscellaneous constants related to the OCMB firmware header + */ +enum OCMBFW_HEADER_CONSTS: uint32_t +{ + HEADER_VERSION_MAJOR = 1, + HEADER_VERSION_MINOR = 0, + HEADER_MAX_SIZE = 4096, +}; + +/** + * @brief Header for the OCMB flash image content + */ +typedef struct ocmbFwHeader +{ + // See EYE_CATCHER_VALUE above + uint64_t eyeCatcher; + + // The major and minor version of this header + uint32_t majorVersion; + uint32_t minorVersion; + + // The total size of this header (must be 8 byte aligned) + uint32_t headerSize; + + // The number of "tagged data triplets" included + // in this header. (see taggedTriplet_t) + uint32_t numTriplets; + + // Variable sized, unordered tagged data triplets start here +}ocmbFwHeader_t; + +/** + * @brief Tag Id's for tagged triplets + */ +enum TRIPLET_TAG_IDS: uint32_t +{ + // Data contains 64 bytes of SHA512 hash data + TAG_SHA512 = 1, + + // Data contains a null-terminated string of comma separated + // key/value pairs with the following format: + // <key1>=<value1>,<key2>=<value2>,<key3>=<value3> + // + // Keys and values are defined by the manufacturer and must + // not contain the characters "=" or "," + TAG_KEY_VALUE_PAIRS = 2, +}; + +/** + * @brief Tagged triplet data format + */ +typedef struct taggedTriplet +{ + // Identifies the data format for this triplet + uint32_t tagId; + + // Size of the data that follows (must be 8 byte aligned) + uint32_t dataSize; + + // variable sized data starts here +}taggedTriplet_t; + +} //namespace expupd + +#endif diff --git a/src/include/usr/fapi2/attribute_service.H b/src/include/usr/fapi2/attribute_service.H index 6144524c5..58d958f73 100644 --- a/src/include/usr/fapi2/attribute_service.H +++ b/src/include/usr/fapi2/attribute_service.H @@ -115,7 +115,7 @@ ReturnCode getTargetingAttr(const Target<TARGET_TYPE_ALL, /// @param[in] o_pAttr Pointer to attribute where value is copied to /// @return boolean describing if it was successful /// -bool setTargetingAttrHelper(TARGETING::Target * l_pTargTarget, +bool setTargetingAttrHelper(TARGETING::Target * i_pTargTarget, const TARGETING::ATTRIBUTE_ID i_targAttrId, const uint32_t i_attrSize, void * o_pAttr); @@ -191,6 +191,19 @@ ReturnCode platGetTargetPos(const Target<TARGET_TYPE_ALL>& i_pFapiTarget, /// +/// @brief This function is called by the FAPI_ATTR_SET macro when accessing +/// an attribute that should never be set. This is used to handle config- +/// dependent cases where the attribute may need to be writable in general +/// but not in some specific cases. +/// +/// @param[in] i_pTargTarget Pointer to TARGETING Target +/// @param[in] i_fapiAttrId FAPI attribute id +/// @return fapi2::ReturnCode. FAPI2_RC_SUCCESS if success, else error code. +/// +ReturnCode platErrorOnSet( TARGETING::Target * i_pTargTarget, + const fapi2::AttributeId i_fapiAttrId ); + +/// /// @brief This function is called by the FAPI_ATTR_GET macro when getting /// ATTR_FUSED_CORE_MODE. It should not be called directly /// @@ -500,13 +513,23 @@ ReturnCode getPllBucket(const Target<TARGET_TYPE_ALL>& i_fapiTarget, // // @param[in] i_fapiTarget The target for the attribute operation. // @param[in] i_attr Which ATTR extracting from VPD -// @param[out] o_val The retrieved attribute value. +// @param[out] o_val The retrieved attribute value // @return ReturnCode Zero on success, else platform specified error. ReturnCode platGetMBvpdSlopeInterceptData( const Target<TARGET_TYPE_ALL>& i_fapiTarget, const uint32_t i_attr, uint32_t& o_val); +/// @brief This function is called by the FAPI_ATTR_GET functions that lookup +/// values in the MEM_PLL_FREQ_BUCKETS tree. The key's used to lookup values in that +/// tree are the ATTR_FREQ_OMI_MHZ and ATTR_OMI_PLL_VCO attributes. These are on the +/// processor target but it is expected that all of the values match. +/// @param[out] o_omiFreq OMI Frequency of the system +/// @param[out] o_omiVco OMI VCO of the system +/// @return ReturnCode Zero on success, else platform specified error. +errlHndl_t getOmiFreqAndVco(TARGETING::ATTR_FREQ_OMI_MHZ_type & o_omiFreq, + TARGETING::ATTR_OMI_PLL_VCO_type & o_omiVco); + /// @brief This function is called by the FAPI_ATTR_GET macro when getting // ATTR_FREQ_MCA_MHZ // @param[in] i_fapiTarget FAPI2 Target pointer @@ -523,6 +546,22 @@ ReturnCode platGetFreqMcaMhz(const Target<TARGET_TYPE_ALL>& i_fapiTarget, ReturnCode platSetFreqMcaMhz(const Target<TARGET_TYPE_ALL>& i_fapiTarget, uint32_t i_val); +/// @brief This function is called by the FAPI_ATTR_GET macro when getting +// ATTR_MC_PLL_BUCKET +// @param[in] i_fapiTarget FAPI2 Target pointer +// @param[in] o_val PLL bucket associated with a given OMI freq +// @return ReturnCode Zero on success, else platform specified error. +ReturnCode platGetMcPllBucket(const Target<TARGET_TYPE_ALL>& i_fapiTarget, + uint8_t& o_val); + +/// @brief This function is called by the FAPI_ATTR_SET macro when getting +// ATTR_OCMB_COUNTER +// @param[in] i_fapiTarget FAPI2 Target pointer +// @param[out] o_val The retrieved attribute value +// @return ReturnCode Zero on success, else platform specified error. +ReturnCode platIncrementOcmbCounter(const Target<TARGET_TYPE_ALL>& i_fapiTarget, + uint32_t& o_val); + // ----------------------------------------------------------------------------- // End TODO: End to be supported functions // ----------------------------------------------------------------------------- @@ -1666,11 +1705,51 @@ fapiToTargeting::ID, sizeof(VAL), &(VAL)) //---------------------------------------------------------------------------- // MACRO to route ATTR_FREQ_MCA_MHZ access to the correct HB function //---------------------------------------------------------------------------- + +#undef ATTR_FREQ_MCA_MHZ_GETMACRO #define ATTR_FREQ_MCA_MHZ_GETMACRO(ID, TARGET, VAL) \ AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ ? fapi2::ReturnCode() : \ fapi2::platAttrSvc::\ platGetFreqMcaMhz(TARGET, VAL) +#undef ATTR_FREQ_MCA_MHZ_SETMACRO +#define ATTR_FREQ_MCA_MHZ_SETMACRO(ID, TARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ + ? fapi2::ReturnCode() : \ + fapi2::platAttrSvc::platErrorOnSet(TARGET, VAL) +#ifdef CONFIG_AXONE +//---------------------------------------------------------------------------- +// MACRO to route ATTR_MC_PLL_BUCKET access to the correct HB function +//---------------------------------------------------------------------------- + +#undef ATTR_MC_PLL_BUCKET_GETMACRO +#define ATTR_MC_PLL_BUCKET_GETMACRO(ID, TARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ + ? fapi2::ReturnCode() : \ + fapi2::platAttrSvc::\ + platGetMcPllBucket(TARGET, VAL) +#undef ATTR_MC_PLL_BUCKET_SETMACRO +#define ATTR_MC_PLL_BUCKET_SETMACRO(ID, TARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ + ? fapi2::ReturnCode() : \ + fapi2::platAttrSvc::platErrorOnSet(TARGET, VAL) + +#endif //CONFIG_AXONE + +//---------------------------------------------------------------------------- +// MACRO to route ATTR_OCMB_COUNTER access to the correct HB function +//---------------------------------------------------------------------------- +#undef ATTR_OCMB_COUNTER_GETMACRO +#define ATTR_OCMB_COUNTER_GETMACRO(ID, TARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ + ? fapi2::ReturnCode() : \ + fapi2::platAttrSvc::\ + platIncrementOcmbCounter(TARGET, VAL) +#undef ATTR_OCMB_COUNTER_SETMACRO +#define ATTR_OCMB_COUNTER_SETMACRO(ID, TARGET, VAL) \ + AttrOverrideSync::getAttrOverrideFunc(ID, TARGET, &VAL)\ + ? fapi2::ReturnCode() : \ + fapi2::platAttrSvc::platErrorOnSet(TARGET, VAL) #endif // ATTRIBUTESERVICE_H_ diff --git a/src/include/usr/fapi2/dimmBadDqBitmapFuncs.H b/src/include/usr/fapi2/dimmBadDqBitmapFuncs.H index 5d51b7153..a51f5c92e 100644 --- a/src/include/usr/fapi2/dimmBadDqBitmapFuncs.H +++ b/src/include/usr/fapi2/dimmBadDqBitmapFuncs.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017 */ +/* Contributors Listed Below - COPYRIGHT 2017,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -41,7 +41,7 @@ extern "C" * dimmBadDqBitmapAccessHwp to get the DQ bitmap and returns the data * for the specified rank. * - * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT Target + * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT/OCMB_CHIP Target * @param[in] i_dimm MCA/MBA port DIMM number * @param[in] i_rank DIMM rank number * @param[out] o_data Reference to data where Bad DQ bitmap is copied to @@ -50,8 +50,8 @@ extern "C" * @return ReturnCode */ fapi2::ReturnCode p9DimmGetBadDqBitmap( const fapi2::Target - <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA|fapi2::TARGET_TYPE_MEM_PORT> - & i_fapiTrgt, + <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA| + fapi2::TARGET_TYPE_MEM_PORT|fapi2::TARGET_TYPE_OCMB_CHIP> & i_fapiTrgt, const uint8_t i_dimm, const uint8_t i_rank, uint8_t (&o_data)[mss::BAD_DQ_BYTE_COUNT], @@ -67,7 +67,7 @@ fapi2::ReturnCode p9DimmGetBadDqBitmap( const fapi2::Target * dimmBadDqBitmapAccessHwp to get the DQ bitmap, fills in the data for the * specified rank and calls dimmBadDqBitmapAccessHwp to set the DQ bitmap * - * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT Target + * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT/OCMB_CHIP Target * @param[in] i_dimm MCA/MBA port DIMM number * @param[in] i_rank DIMM rank number * @param[in] i_data Reference to data where Bad DQ bitmap is copied from @@ -76,8 +76,8 @@ fapi2::ReturnCode p9DimmGetBadDqBitmap( const fapi2::Target * @return ReturnCode */ fapi2::ReturnCode p9DimmSetBadDqBitmap( const fapi2::Target - <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA|fapi2::TARGET_TYPE_MEM_PORT> - & i_fapiTrgt, + <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA| + fapi2::TARGET_TYPE_MEM_PORT|fapi2::TARGET_TYPE_OCMB_CHIP> & i_fapiTrgt, const uint8_t i_dimm, const uint8_t i_rank, const uint8_t (&i_data)[mss::BAD_DQ_BYTE_COUNT], diff --git a/src/include/usr/fapi2/fapiPlatTrace.H b/src/include/usr/fapi2/fapiPlatTrace.H index d780832ca..94f6a20b2 100644 --- a/src/include/usr/fapi2/fapiPlatTrace.H +++ b/src/include/usr/fapi2/fapiPlatTrace.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2016 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -40,7 +40,6 @@ #include <stdio.h> #include <trace/interface.H> -#include <config.h> //****************************************************************************** // Trace buffer names diff --git a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H index f0ae90b3a..793474322 100644 --- a/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H +++ b/src/include/usr/fapi2/hwpf_fapi2_reasoncodes.H @@ -68,6 +68,13 @@ namespace fapi2 MOD_FAPI2_PLAT_GET_PROC_TEST = 0x19, MOD_FAPI2_MONITOR_FOR_FSP_MSGS = 0x1A, MOD_FAPI2_PLAT_GET_VPD_OCMB = 0x1B, + MOD_FAPI2_PLAT_ERROR_ON_SET = 0x1C, + MOD_FAPI2_PLAT_GET_MC_PLL_BUCKET = 0x1D, + MOD_FAPI2_PLAT_GET_FREQ_MCA_MHZ = 0x1E, + MOD_GET_OMI_FREQ_AND_VCO = 0x1F, + MOD_FAPI2_SPD_ACCESS = 0x20, + MOD_FAPI2_EXPLR_IB_I2C_READ = 0x21, + MOD_FAPI2_EXPLR_IB_I2C_WRITE = 0x22, }; /** @@ -128,6 +135,8 @@ namespace fapi2 RC_SET_ATTR_NOT_VALID = FAPI2_COMP_ID | 0x3F, RC_FAILED_TO_GET_RING_LIST = FAPI2_COMP_ID | 0x40, RC_ATTR_OVERRIDE_DISALLOWED = FAPI2_COMP_ID | 0x41, + RC_UNKNOWN_OCMB_CHIP_TYPE = FAPI2_COMP_ID | 0x42, + RC_INVALID_BUFFER_SIZE = FAPI2_COMP_ID | 0x43, // HWP generated errors RC_HWP_GENERATED_ERROR = HWPF_COMP_ID | 0x0f, @@ -137,6 +146,9 @@ namespace fapi2 // PLL_BUCKET generated errors RC_NO_MATCHING_FREQ = HWPF_COMP_ID | 0x31, RC_FREQ_LIST_NOT_FOUND = HWPF_COMP_ID | 0x32, + RC_PROC_FREQ_MISMATCH = HWPF_COMP_ID | 0x33, + + RC_INVALID_SPD_DRAM_GEN = FAPI2_COMP_ID | 0x34, }; /** diff --git a/src/include/usr/fapi2/rowRepairsFuncs.H b/src/include/usr/fapi2/rowRepairsFuncs.H index 373ec3319..78e00b126 100644 --- a/src/include/usr/fapi2/rowRepairsFuncs.H +++ b/src/include/usr/fapi2/rowRepairsFuncs.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -39,7 +39,7 @@ extern "C" * Row Repair Data getter procedure to get the DQ bitmap and returns the data * for the specified rank. * - * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT Target + * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT/OCMB_CHIP Target * @param[in] i_dimm MCA/MBA port DIMM number * @param[in] i_rank DIMM rank number * @param[out] o_data Reference to data where Row Repair Data is copied to @@ -48,8 +48,8 @@ extern "C" * @return ReturnCode */ fapi2::ReturnCode getRowRepair( const fapi2::Target - <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA|fapi2::TARGET_TYPE_MEM_PORT> - & i_fapiTrgt, + <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA| + fapi2::TARGET_TYPE_MEM_PORT|fapi2::TARGET_TYPE_OCMB_CHIP> & i_fapiTrgt, const uint8_t i_dimm, const uint8_t i_rank, uint8_t (&o_data)[mss::ROW_REPAIR_BYTE_COUNT], @@ -62,7 +62,7 @@ fapi2::ReturnCode getRowRepair( const fapi2::Target * Row Repair Data setter procedure to set the data * for the specified rank. * - * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT Target + * @param[in] i_fapiTrgt Reference to MCA/MBA/MEM_PORT/OCMB_CHIP Target * @param[in] i_dimm MCA/MBA port DIMM number * @param[in] i_rank DIMM rank number * @param[out] i_data Reference to data where Row Repair Data is @@ -71,8 +71,8 @@ fapi2::ReturnCode getRowRepair( const fapi2::Target * @return ReturnCode */ fapi2::ReturnCode setRowRepair( const fapi2::Target - <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA|fapi2::TARGET_TYPE_MEM_PORT> - & i_fapiTrgt, + <fapi2::TARGET_TYPE_MCA|fapi2::TARGET_TYPE_MBA| + fapi2::TARGET_TYPE_MEM_PORT|fapi2::TARGET_TYPE_OCMB_CHIP> & i_fapiTrgt, const uint8_t i_dimm, const uint8_t i_rank, uint8_t (&i_data)[mss::ROW_REPAIR_BYTE_COUNT], diff --git a/src/include/usr/fapi2/target.H b/src/include/usr/fapi2/target.H index 7b286db87..31e909a68 100644 --- a/src/include/usr/fapi2/target.H +++ b/src/include/usr/fapi2/target.H @@ -267,6 +267,9 @@ inline TARGETING::TYPE convertFapi2TypeToTargeting(fapi2::TargetType i_T) case fapi2::TARGET_TYPE_MEM_PORT: o_targetingType = TARGETING::TYPE_MEM_PORT; break; + case fapi2::TARGET_TYPE_PMIC: + o_targetingType = TARGETING::TYPE_PMIC; + break; default: FAPI_ERR("convertFapi2TypeToTargeting:: Chiplet type not supported 0x%.8X!", i_T); assert(false); @@ -382,6 +385,9 @@ inline fapi2::TargetType convertTargetingTypeToFapi2(TARGETING::TYPE i_T) case TARGETING::TYPE_MEM_PORT: o_targetingType = fapi2::TARGET_TYPE_MEM_PORT; break; + case TARGETING::TYPE_PMIC: + o_targetingType = fapi2::TARGET_TYPE_PMIC; + break; default: o_targetingType = fapi2::TARGET_TYPE_NONE; break; @@ -920,9 +926,11 @@ inline std::vector<Target<K_CHILD, M, V> > // valid children for OCMB // OCMB -> MEM_PORT // OCMB -> DIMM + // OCMB -> PMIC static_assert(!((T_SELF == fapi2::TARGET_TYPE_OCMB_CHIP) && (K_CHILD != fapi2::TARGET_TYPE_MEM_PORT) && - (K_CHILD != fapi2::TARGET_TYPE_DIMM)), + (K_CHILD != fapi2::TARGET_TYPE_DIMM) && + (K_CHILD != fapi2::TARGET_TYPE_PMIC)), "improper child of fapi2::TARGET_TYPE_OCMB_CHIP"); // valid children for MEM_PORT diff --git a/src/include/usr/fapiwrap/fapiWrapif.H b/src/include/usr/fapiwrap/fapiWrapif.H new file mode 100644 index 000000000..6a59e4c3f --- /dev/null +++ b/src/include/usr/fapiwrap/fapiWrapif.H @@ -0,0 +1,79 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/fapiwrap/fapiWrapif.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +#ifndef _FAPIWRAPIF_H +#define _FAPIWRAPIF_H + +#include <errl/errlentry.H> // Also gets us targeting/common/target.H + + +/* *** Overview *** + There has been a trend to create more HWPs that process raw data. + This allows Hostboot and Cronus (and other platforms to share more code. + The trick is that we generally want to call these HWPs inside what has + traditionally been Hostboot-only code. The fapiwrap directory will help + encapsulate all of the calls to ekb code in one place. That way if we + ever need to remove HWPs/EKB code it will be easier to stub out the calls. + We have found in the past we have contaminated a lot of Hostboot-only + code with calls to EKB code. This directory should help address that problem. +*/ + + +namespace FAPIWRAP +{ + /** + * @brief This function wraps around the FAPI2 HWP "exp_getidec" which + * takes in a OCMB target and returns the associated chipId + * and ec level. + * Chip Ids can be found in src/import/chips/common/utils/chipids.H + * @param[in] i_ocmbChip - Explorer OCMB target to lookup values on + * @param[out] o_chipId - Power Chip Id associated with this OCMB + * @param[out] o_ec - EC level of this chip + * @return errlHndl_t - nullptr if no error, otherwise contains error + */ + errlHndl_t explorer_getidec( TARGETING::Target * i_ocmbChip, + uint16_t& o_chipId, + uint8_t& o_ec); + + /** + * @brief This function wraps around the FAPI2 HWP "get_pmic_i2c_addr" which + * takes in a DDIMM's DDR4 SPD data and a PMIC's position relative to + * its parent OCMB's chip and returns the device address of that pmic + * This wrapper will actually lookup the SPD of a given ocmb target so + * the caller doesnt need to worry about it. + * @param[in] i_ocmbChip - Parent ocmb of the PMIC we wish to find the device addres of + * @param[in] i_pmic_id - PMIC's position relative to parent OCMB + * @param[out]o_pmic_devAddr - If this pmic exists on the ocmb then return the device address + found in the SPD. Otherwise return NO_PMIC_DEV_ADDR + * @return errlHndl_t - nullptr if no error, otherwise contains error + */ + errlHndl_t get_pmic_dev_addr( TARGETING::Target * i_ocmbChip, + const uint8_t i_pmic_id, + uint8_t& o_pmic_devAddr); + + constexpr uint8_t NO_PMIC_DEV_ADDR = 0xFF; + +} + +#endif
\ No newline at end of file diff --git a/src/include/usr/gcov.h b/src/include/usr/gcov.h index ede5e547b..975e755a9 100644 --- a/src/include/usr/gcov.h +++ b/src/include/usr/gcov.h @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ +/* [+] 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. */ @@ -39,6 +41,7 @@ #include <stddef.h> #include <stdint.h> #include <string.h> +#include <arch/ppc.H> /** @struct gcov_info * @brief Structure generated by gcc. Do not use. @@ -56,23 +59,111 @@ * aligned on a 64-bit boundary. The unusedN fields are to ensure proper * alignment. */ + +// Inferred settings +#define BITS_PER_UNIT 8 +#define LONG_LONG_TYPE_SIZE 64 + +#define _STRINGIFY(X) #X +#define STRINGIFY(X) _STRINGIFY(X) + +static_assert(sizeof(long long) * 8 == LONG_LONG_TYPE_SIZE, + "sizeof(long long) * 8 must be LONG_LONG_TYPE_SIZE (" + STRINGIFY(LONG_LONG_TYPE_SIZE) + ")"); + +/* The following typedefs and structures were taken from: + * https://github.com/gcc-mirror/gcc/blob/gcc-4_9-branch/libgcc/libgcov.h + */ + +#if BITS_PER_UNIT == 8 +typedef unsigned gcov_unsigned_t __attribute__ ((mode (SI))); +typedef unsigned gcov_position_t __attribute__ ((mode (SI))); +#if LONG_LONG_TYPE_SIZE > 32 +typedef signed gcov_type __attribute__ ((mode (DI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (DI))); +#else +typedef signed gcov_type __attribute__ ((mode (SI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI))); +#endif +#else +#if BITS_PER_UNIT == 16 +typedef unsigned gcov_unsigned_t __attribute__ ((mode (HI))); +typedef unsigned gcov_position_t __attribute__ ((mode (HI))); +#if LONG_LONG_TYPE_SIZE > 32 +typedef signed gcov_type __attribute__ ((mode (SI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (SI))); +#else +typedef signed gcov_type __attribute__ ((mode (HI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI))); +#endif +#else +typedef unsigned gcov_unsigned_t __attribute__ ((mode (QI))); +typedef unsigned gcov_position_t __attribute__ ((mode (QI))); +#if LONG_LONG_TYPE_SIZE > 32 +typedef signed gcov_type __attribute__ ((mode (HI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (HI))); +#else +typedef signed gcov_type __attribute__ ((mode (QI))); +typedef unsigned gcov_type_unsigned __attribute__ ((mode (QI))); +#endif +#endif +#endif + +static_assert(sizeof(gcov_type) == 8, "gcov_type isn't 64 bits for some reason"); + +#if __GNUC__ == 4 && __GNUC_MINOR__ == 9 +#define GCOV_COUNTERS 9 +#elif __GNUC__ == 8 && __GNUC_MINOR__ <= 3 +#define GCOV_COUNTERS 9 +#else +#error GCOV implementation does not support this compiler yet +#endif + +/* Structures embedded in coveraged program. The structures generated + by write_profile must match these. */ + +/* Information about counters for a single function. */ +struct gcov_ctr_info +{ + gcov_unsigned_t num; /* number of counters. */ + gcov_type *values; /* their values. */ +}; + +/* Information about a single function. This uses the trailing array + idiom. The number of counters is determined from the merge pointer + array in gcov_info. The key is used to detect which of a set of + comdat functions was selected -- it points to the gcov_info object + of the object file containing the selected comdat function. */ + +struct gcov_fn_info +{ + const struct gcov_info *key; /* comdat key */ + gcov_unsigned_t ident; /* unique ident of function */ + gcov_unsigned_t lineno_checksum; /* function lineno_checksum */ + gcov_unsigned_t cfg_checksum; /* function cfg checksum */ + struct gcov_ctr_info ctrs[0]; /* instrumented counters */ +}; + +/* Type of function used to merge counters. */ +typedef void (*gcov_merge_fn) (gcov_type *, gcov_unsigned_t); + +/* Information about a single object file. */ struct gcov_info { - uint32_t version; - uint32_t unused0; - gcov_info* next; - uint32_t timestamp; - uint32_t unused1; - char* filename; - uint32_t n_functions; - uint32_t unused2; - void* functions; - uint32_t counter_mask; - uint32_t unused3; - uint32_t n_counters; - uint32_t unused4; - uint64_t* counters; -} PACKED; + gcov_unsigned_t version;/* expected version number */ + struct gcov_info *next; /* link to next, used by libgcov */ + + gcov_unsigned_t stamp; /* uniquifying time stamp */ + const char *filename; /* output file name */ + + gcov_merge_fn merge[GCOV_COUNTERS]; /* merge functions (null for + unused) */ + + unsigned n_functions; /* number of functions */ + const struct gcov_fn_info *const *functions; /* pointer to pointers + to function information */ +}; // Preprocessor magic to create a variable name based off the module name. // GCOV_INFO_OBJ() will create a post-processed name like @@ -90,6 +181,9 @@ struct gcov_info #define __GCOV_INFO_OBJ(X,Y) X ## Y #define _GCOV_INFO_OBJ(X,Y) __GCOV_INFO_OBJ(X,Y) #define GCOV_INFO_OBJ() _GCOV_INFO_OBJ(__GCOV_PREFIX, _gcov_info_head) +#define GCOV_INFO_MAGIC() _GCOV_INFO_OBJ(__GCOV_PREFIX, _gcov_info_magic) + +uint32_t GCOV_INFO_MAGIC() = 0xbeefb055; /** Pointer to the beginning of the gcov_info chain for this module. */ gcov_info* GCOV_INFO_OBJ() = NULL; @@ -121,7 +215,7 @@ void __gcov_init(gcov_info* i_info) // #ifdef __HOSTBOOT_MODULE // Forward declaration of __gcov_module_copychain for modules. -extern "C" void __gcov_module_copychain(gcov_info* chain); +extern "C" void __gcov_module_copychain(gcov_info** chain); /** Function called by module unloading to move the module's gcov_info * instances to the global chain. @@ -129,7 +223,7 @@ extern "C" void __gcov_module_copychain(gcov_info* chain); extern "C" void __gcov_module_unload(void* unused) { - __gcov_module_copychain(GCOV_INFO_OBJ()); + __gcov_module_copychain(&GCOV_INFO_OBJ()); } // Register __gcov_module_unload with __cxa_atexit. extern void* __dso_handle; @@ -137,27 +231,93 @@ extern "C" int __cxa_atexit(void(*)(void*),void*,void*); int __unused_gcov_cxa_register = __cxa_atexit(&__gcov_module_unload, NULL, __dso_handle); #else + +// This is set to 1 for now because it reduces memory pressure, but it +// won't work on hardware. See the comment below about +// MAGIC_GCOV_MODULE_UNLOAD. +#define HOSTBOOT_GCOV_EAGER_DATA_EXTRACTION 1 + /** Function called by a module being unloaded (via __gcov_module_unload) to * copy the module's gcov_info chain into the base gcov_info chain. */ extern "C" -void __gcov_module_copychain(gcov_info* chain) +void __gcov_module_copychain(gcov_info** const chain_ptr) { + gcov_info* chain = *chain_ptr; + +#if HOSTBOOT_GCOV_EAGER_DATA_EXTRACTION + asm volatile("mr %%r3, %0" + : + : "r" (chain) + : "%r3"); + + /* This magic instruction will cause simics to read the gcov_info + * pointer in r3 and use it to immediately extract this unloading + * module's data. We do this to reduce the max simultaneous memory + * pressure, otherwise we run out of memory having to preserve and + * store all the gcov info for all unloaded modules until the end + * of the run. This only works in simics, but the alternative + * won't work on hardware until we find other ways to reduce our + * memory footprint. */ + + MAGIC_INSTRUCTION(MAGIC_GCOV_MODULE_UNLOAD); +#else while(chain != NULL) { // Copy old info. - gcov_info* new_info = new gcov_info(); - memcpy(new_info, chain, sizeof(gcov_info)); + gcov_info* const new_info = new gcov_info(); + + memcpy(new_info, chain, sizeof(*chain)); + + char* const new_filename = strdup(chain->filename); + new_info->filename = new_filename; - // Copy old counters. - uint64_t* new_counters = new uint64_t[chain->n_counters](); - memcpy(new_counters, chain->counters, - chain->n_counters*sizeof(uint64_t)); - new_info->counters = new_counters; + struct gcov_fn_info** const new_functions + = new struct gcov_fn_info*[new_info->n_functions]; + + new_info->functions = new_functions; + + unsigned int num_gcov_counters = 0; + + for (unsigned int i = 0; i < GCOV_COUNTERS; ++i) + { + if (new_info->merge[i]) { + ++num_gcov_counters; + } + } + + for (unsigned int i = 0; i < chain->n_functions; ++i) + { + // malloc(base structure size + trailing array size) + new_functions[i] = + ((struct gcov_fn_info*) + (new char[sizeof(*new_functions[i]) + + (sizeof(new_functions[i]->ctrs[0]) + * num_gcov_counters)])); + + struct gcov_fn_info* const new_info = new_functions[i]; + const struct gcov_fn_info* const old_info = chain->functions[i]; + + for (unsigned int j = 0; j < num_gcov_counters; ++j) + { + const gcov_unsigned_t num_values = old_info->ctrs[j].num; + + new_info->key = NULL; + new_info->ctrs[j].num = num_values; + new_info->ctrs[j].values = new gcov_type[num_values]; + + memcpy(new_info->ctrs[j].values, + old_info->ctrs[j].values, + sizeof(gcov_type) * num_values); + } + } // Atomically push new_info onto the core_gcov_info_head stack. do { + /* GCOV_INFO_OBJ() in this function is always + core_gcov_info_head because this function is only + defined when __HOSTBOOT_MODULE is not defined */ new_info->next = GCOV_INFO_OBJ(); } while (!__sync_bool_compare_and_swap(&GCOV_INFO_OBJ(), new_info->next, new_info)); @@ -165,10 +325,16 @@ void __gcov_module_copychain(gcov_info* chain) // Advance to next info in this modules chain. chain = chain->next; } +#endif // #if HOSTBOOT_GCOV_EAGER_DATA_EXTRACTION + + /* Then we set the module info pointer to NULL so that simics + * won't dump it twice. */ + + *chain_ptr = NULL; } #endif -/** Unneeded function but must be defined to compile. +/** Unneeded function but must be defined to link. * * This function appears to be typically used by libgcov.so when instrumented * on a real linux-based system. It can be used to merge counters across @@ -182,4 +348,13 @@ void __gcov_merge_add() while(1); } +/** Unneeded function but must be defined to link. */ + +extern "C" +void __gcov_exit() +{ + MAGIC_INSTRUCTION(MAGIC_BREAK); + while (1); +} + #endif diff --git a/src/include/usr/gpio/gpioddreasoncodes.H b/src/include/usr/gpio/gpioddreasoncodes.H index 20ad10002..d794ff470 100644 --- a/src/include/usr/gpio/gpioddreasoncodes.H +++ b/src/include/usr/gpio/gpioddreasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -40,10 +40,13 @@ namespace GPIO GPIO_READ = 0x01, GPIO_WRITE = 0x02, GPIO_READATTRIBUTES = 0x03, + + // Use 0x10-0x1F range for PCA9551 functions + GPIO_PCA9551_SET_LED = 0x10, }; /** - * @enum grioReasonCode + * @enum gpioReasonCode */ enum gpioReasonCode { @@ -51,6 +54,9 @@ namespace GPIO GPIO_ATTR_INFO_NOT_FOUND = GPIO_COMP_ID | 0x01, GPIO_I2C_TARGET_NOT_FOUND = GPIO_COMP_ID | 0x02, GPIO_INVALID_OP = GPIO_COMP_ID | 0x03, + + // Use 0x10-0x1F range for PCA9551 functions + GPIO_PCA9551_DATA_MISMATCH = GPIO_COMP_ID | 0x10, }; }; diff --git a/src/include/usr/gpio/gpioif.H b/src/include/usr/gpio/gpioif.H index 03a5a9a89..2a010039b 100644 --- a/src/include/usr/gpio/gpioif.H +++ b/src/include/usr/gpio/gpioif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -26,6 +26,8 @@ #ifndef __GPIOIF_H #define __GPIOIF_H +#include <errl/errlentry.H> + namespace GPIO { /** @@ -33,10 +35,125 @@ namespace GPIO */ enum gpioDevice_t { - PCA95X_GPIO = 0, + // Corresponds to attribute ... + PCA95X_GPIO = 0, // GPIO_INFO + PCA9551_GPIO_PHYS_PRES = 1, // GPIO_INFO_PHYS_PRES INVALID_GPIO, }; +/* The following enums and interfaces are specific to PCA9551 GPIO Devices. + * Documentation here: https://www.nxp.com/docs/en/data-sheet/PCA9551.pdf + */ + +/** + * @brief Specific to PCA9551: LED Bit Mask to match how their status is read + * back from LED "INPUT" register on PCA9551 Devices + */ +enum PCA9551_LEDS_t : uint8_t +{ + PCA9551_LED0 = 0x01, + PCA9551_LED1 = 0x02, + PCA9551_LED2 = 0x04, + PCA9551_LED3 = 0x08, + PCA9551_LED4 = 0x10, + PCA9551_LED5 = 0x20, + PCA9551_LED6 = 0x40, + PCA9551_LED7 = 0x80, +}; + +/** + * @brief Specific to PCA9551: Values used by the LED select registers + * to determine the source of the LED data. + */ +enum PCA9551_LED_Output_Settings_t : uint8_t +{ + PCA9551_OUTPUT_LOW = 0x00, // LED on + PCA9551_OUTPUT_HIGH_IMPEDANCE = 0x01, // LED off; default + PCA9551_OUTPUT_PWM0 = 0x02, // Output blinks at PWM0 rate + PCA9551_OUTPUT_PWM1 = 0x03, // Output blinks at PWM1 rate +}; + +/** + * @brief Specific to PCA9551: Control register definition: + sepcificies which register the operation will target + */ +enum PCA9551_Registers_t : uint8_t +{ + PCA9551_REGISTER_INPUT = 0x00, // INPUT (read only) input register + PCA9551_REGISTER_PCS0 = 0x01, // PSC0 (r/w) frequency prescaler 0 + PCA9551_REGISTER_PWM0 = 0x02, // PWM0 (r/w) PWM register 0 + PCA9551_REGISTER_PCS1 = 0x03, // PSC1 (r/w) frequency prescaler 1 + PCA9551_REGISTER_PWM1 = 0x04, // PWM1 (r/w) PWM register 1 + PCA9551_REGISTER_LS0 = 0x05, // LS0 (r/w) LED0 to LED3 selector + PCA9551_REGISTER_LS1 = 0x06, // LS1 (r/w) LED4 to LED7 selector +}; + +/** + * @brief Specific to PCA9551: Helper constants to work with the bits in the + * PCA9551 registers + */ +enum PCA9551_Constants_t : uint8_t +{ + // Mask shifted to apply 2-bit settings to a specific LED in the output + // settings register + PCA9551_LED_SETTINGS_MASK = 0x03, + + // Amount to shift the LED value per LED when walking through the LEDs + // in the INPUT register (related to PCA9551_LEDS_t above) + PCA9551_LED_SHIFT_AMOUNT = 0x01, + + // Amount to shift the LED Settings MASK per LED when walking through the + // LEDs in the output settings register (ie, 2 bits at a time) + PCA9551_LED_SETTINGS_MASK_SHIFT_AMOUNT = 0x02, + + // LED Divider: While the INPUT register can contain all 8 LED values + // (since each value is represented by one bit), the SETTINGS registers + // (PCA9551_REGISTER_LS0 and PCA9551_REGISTER_LS1) can only cover 4 LEDs + // each since each setting requires 2 bits. + // This divisor takes LEDs 4 to 7 and makes them look like LEDs 0 to 3 + PCA9551_LED_SETTINGS_DIVISOR = 0x80, +}; + +/** + * @brief Returns the PCA9551 Device's INPUT register which reflects the state + * of the device's LEDs (aka pins) + * + * @param[in] i_target - Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute + * to run the commands against + * + * @param[out] o_led_data - The INPUT register data from the device + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ +errlHndl_t gpioPca9551GetLeds(TARGETING::Target * i_target, + uint8_t & o_led_data); + +/** + * @brief Sets the given LED (aka pin) of a PCA9551 Device to a certain setting + * and returns the INPUT register which reflects the state of device's + * LEDs (aka pins) after the setting has been run + * + * @param[in] i_target - Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute + * to run the commands against + * + * @param[in] i_led - The specific LED Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute + * to run the commands against + * + * @param[in] i_setting - the output setting to set the LED to + * + * @param[out] o_led_data - The INPUT register data from the device after the + * 'set' procedure has been run allowing the caller to + * evaluate if the set actually went through + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ + +errlHndl_t gpioPca9551SetLed(TARGETING::Target * i_target, + const PCA9551_LEDS_t i_led, + const PCA9551_LED_Output_Settings_t i_setting, + uint8_t & o_led_data); + + }; // GPIO NAMESPACE #endif diff --git a/src/include/usr/hbotcompid.H b/src/include/usr/hbotcompid.H index e3a3ec5d7..d8d819f50 100644 --- a/src/include/usr/hbotcompid.H +++ b/src/include/usr/hbotcompid.H @@ -484,6 +484,38 @@ const compId_t UCD_COMP_ID = 0x4100; const char UCD_COMP_NAME[] = "ucd"; //@} + +// +/** @name EXPUPD + * Explorer update component + */ +//@{ +const compId_t EXPUPD_COMP_ID = 0x4200; +const char EXPUPD_COMP_NAME[] = "expupd"; + +//@} + +// +/** @name BPM + * BPM flash update component + */ +//@{ +const compId_t BPM_COMP_ID = 0x4300; +const char BPM_COMP_NAME[] = "bpm"; + +//@} + +// +/** @name FAPIWRAP + * Wrapper around fapi2 HWP for hb platform to use + */ +//@{ +const compId_t FAPIWRAP_COMP_ID = 0x4400; +const char FAPIWRAP_COMP_NAME[] = "fapiwrap"; + +//@} + +// // /** @name HDAT * HDAT component diff --git a/src/include/usr/hwas/common/hwasCallout.H b/src/include/usr/hwas/common/hwasCallout.H index a39e4a229..3cf4a2638 100644 --- a/src/include/usr/hwas/common/hwasCallout.H +++ b/src/include/usr/hwas/common/hwasCallout.H @@ -180,13 +180,17 @@ enum callOutPriority enum busTypeEnum { + NO_BUS_TYPE = 0, FSI_BUS_TYPE = 1, DMI_BUS_TYPE = 2, A_BUS_TYPE = 3, X_BUS_TYPE = 4, I2C_BUS_TYPE = 5, PSI_BUS_TYPE = 6, - O_BUS_TYPE = 7 + O_BUS_TYPE = 7, + OMI_BUS_TYPE = 8, + + LAST_BUS_TYPE, //for looping in testcases }; // Used by Hostboot code where real clock targets do not exist @@ -226,6 +230,8 @@ enum partTypeEnum BPM_CABLE_PART_TYPE = 13, //Backup Power Module Cable for NVDIMM NV_CONTROLLER_PART_TYPE = 14, //Controller for NVDIMM BPM_PART_TYPE = 15, //Backup Power Module for NVDIMM + + LAST_PART_TYPE, //for looping in testcases }; enum sensorTypeEnum @@ -234,6 +240,8 @@ enum sensorTypeEnum GPU_FUNC_SENSOR = 1, GPU_TEMPERATURE_SENSOR = 2, GPU_MEMORY_TEMP_SENSOR = 3, + + LAST_SENSOR_TYPE, //for looping in testcases }; //-- Flags diff --git a/src/include/usr/hwas/common/hwas_reasoncodes.H b/src/include/usr/hwas/common/hwas_reasoncodes.H index b60e10032..f2d4e0da0 100644 --- a/src/include/usr/hwas/common/hwas_reasoncodes.H +++ b/src/include/usr/hwas/common/hwas_reasoncodes.H @@ -42,6 +42,10 @@ namespace HWAS MOD_DISCOVER_TARGETS = 0x0B, MOD_UPDATE_PROC_COMPAT_RISK_LEVEL = 0x0C, MOD_CHECK_PG_FOR_DESC = 0x0D, + MOD_OCMB_IDEC = 0x0E, + MOD_OCMB_IDEC_PHASE_1 = 0x0F, + MOD_OCMB_IDEC_PHASE_2 = 0x10, + MOD_OCMB_TRANSLATE_SPD_IDEC = 0x11, }; enum HwasReasonCode @@ -80,6 +84,11 @@ namespace HWAS RC_FORCED_NATIVE_INVALID_MIXED_EC = HWAS_COMP_ID | 0x1C, RC_FORCED_NATIVE_OF_INCOMPATIBLE_RISK = HWAS_COMP_ID | 0x1D, RC_PARTIAL_GOOD_MISSING_TARGET = HWAS_COMP_ID | 0x1E, + RC_OCMB_SPD_REVISION_MISMATCH = HWAS_COMP_ID | 0x1F, + RC_OCMB_UNEXPECTED_IDEC = HWAS_COMP_ID | 0x20, + RC_OCMB_UNKNOWN_CHIP_TYPE = HWAS_COMP_ID | 0x21, + RC_OCMB_INTERFACE_TYPE_MISMATCH = HWAS_COMP_ID | 0x22, + RC_OCMB_CHIP_ID_MISMATCH = HWAS_COMP_ID | 0x23, }; enum HwasPlatUserDetailsTypes diff --git a/src/include/usr/hwas/common/pgLogic.H b/src/include/usr/hwas/common/pgLogic.H index 66e59f5f0..12eac2f49 100644 --- a/src/include/usr/hwas/common/pgLogic.H +++ b/src/include/usr/hwas/common/pgLogic.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -129,6 +129,7 @@ namespace PARTIAL_GOOD // MC // PG/AG Masks extern const uint16_t MC_R1_AG_MASK; + extern const uint16_t MC_R1_AG_MASK_AXONE; extern const uint16_t MC_R2_PG_MASK; extern const uint16_t MC_R3_PG_MASK; @@ -533,17 +534,27 @@ namespace PARTIAL_GOOD }, { TARGETING::TYPE_MC, { - // MC Rule 1 + // MC Rule 1 (Cumulus) new PartialGoodRule ( - {&PREDICATE_CUMULUS, &PREDICATE_AXONE}, + {&PREDICATE_CUMULUS}, ALL_ON_PG_MASK, MC_R1_AG_MASK, USE_CHIPLET_ID, APPLICABLE_TO_ALL, NO_SPECIAL_RULE ), - // MC Rule 2: Chiplet N1 must be checked for chip unit 1 + // MC Rule 1 (Axone) + new PartialGoodRule + ( + {&PREDICATE_AXONE}, + ALL_ON_PG_MASK, + MC_R1_AG_MASK_AXONE, + USE_CHIPLET_ID, + APPLICABLE_TO_ALL, + NO_SPECIAL_RULE + ), + // MC Rule 2: Chiplet N1 must be checked for chip unit 1 (Axone & Cumulus) new PartialGoodRule ( {&PREDICATE_CUMULUS, &PREDICATE_AXONE}, @@ -553,7 +564,7 @@ namespace PARTIAL_GOOD ONE_BIT_CU_MASK, NO_SPECIAL_RULE ), - // MC Rule 3: Chiplet N3 must be checked for chip unit 0 + // MC Rule 3: Chiplet N3 must be checked for chip unit 0 (Axone & Cumulus) new PartialGoodRule ( {&PREDICATE_CUMULUS, &PREDICATE_AXONE}, @@ -670,6 +681,17 @@ namespace PARTIAL_GOOD APPLICABLE_TO_ALL, NO_SPECIAL_RULE ), + // @todo-RTC:208518 - Add Axone NPU PG rules + // NPU Rule 2: This logic is for Axone only. + new PartialGoodRule + ( + {&PREDICATE_AXONE}, + NPU_R1_PG_MASK, //wrong + ALL_OFF_AG_MASK, + USE_CHIPLET_ID, + APPLICABLE_TO_ALL, + NO_SPECIAL_RULE + ), }// End of PG Rules for NPU Target }, { TARGETING::TYPE_OBUS, @@ -724,13 +746,24 @@ namespace PARTIAL_GOOD // here. new PartialGoodRule ( - PREDICATE_P9, + {&PREDICATE_NIMBUS, &PREDICATE_CUMULUS}, MASK_NA, MASK_NA, INDEX_NA, APPLICABLE_TO_ALL, ObusBrickSpecialRule ), + // Axone will have some special rules related to the NPUs + // @todo-RTC:208518 - Add Axone OBUS_BRICK PG rules + new PartialGoodRule + ( + {&PREDICATE_AXONE}, + MASK_NA, + MASK_NA, + INDEX_NA, + APPLICABLE_TO_ALL, + NO_SPECIAL_RULE + ), }// End of PG Rules for OBUS BRICK Target }, { TARGETING::TYPE_OMI, {new PartialGoodRule(),}}, diff --git a/src/include/usr/hwas/common/vpdConstants.H b/src/include/usr/hwas/common/vpdConstants.H index 498f6d622..9461550e9 100644 --- a/src/include/usr/hwas/common/vpdConstants.H +++ b/src/include/usr/hwas/common/vpdConstants.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -45,38 +45,43 @@ const uint32_t VPD_CP00_PG_DATA_ENTRIES = VPD_CP00_PG_DATA_LENGTH / 2; // '0' = region is good (NOTE: opposite of P8 where '1' represented good) // '1' = region is bad or does not exist -const uint32_t VPD_CP00_PG_FSI_INDEX = 0; +const uint32_t VPD_CP00_PG_FSI_INDEX = 0; // all good - 4:FSI0, 5:FSI1, 6:FSIa -const uint32_t VPD_CP00_PG_FSI_GOOD = 0xF1FF; +const uint32_t VPD_CP00_PG_FSI_GOOD = 0xF1FF; -const uint32_t VPD_CP00_PG_PERVASIVE_INDEX = 1; +const uint32_t VPD_CP00_PG_PERVASIVE_INDEX = 1; // all good - 3:VITAL, 4:PRV, 5:NET, 6:PIB, 7:OCC, 8:ANPERV, 14:PLLNEST -const uint32_t VPD_CP00_PG_PERVASIVE_GOOD = 0xE07D; +const uint32_t VPD_CP00_PG_PERVASIVE_GOOD = 0xE07D; +// all good - 3:VITAL, 4:PRV, 5:NET, 6:PIB, 7:OCC, 8:BE, 9:SBE 14:PLLNEST +const uint32_t VPD_CP00_PG_PERVASIVE_GOOD_AXONE = 0xE03D; -const uint32_t VPD_CP00_PG_N0_INDEX = 2; +const uint32_t VPD_CP00_PG_N0_INDEX = 2; // all good - 3:VITAL, 4:PRV, 5:NX, 6:CXA0, 7:PBIOE0, 8:PBIOE1, 9:PBIOE2 -const uint32_t VPD_CP00_PG_N0_GOOD = 0xE03F; +const uint32_t VPD_CP00_PG_N0_GOOD = 0xE03F; -const uint32_t VPD_CP00_PG_N1_INDEX = 3; +const uint32_t VPD_CP00_PG_N1_INDEX = 3; // all good - 3:VITAL, 4:PRV, 5:MCD, 6:VA, 7:PBIOO0+, 8:PBIOO1+, 9:MCS23+ -const uint32_t VPD_CP00_PG_N1_GOOD = 0xE03F; -const uint32_t VPD_CP00_PG_N1_PG_MASK = 0x01C0; -const uint32_t VPD_CP00_PG_N1_PBIOO0 = 0x0100; -const uint32_t VPD_CP00_PG_N1_PBIOO1 = 0x0080; -const uint32_t VPD_CP00_PG_N1_MCS23 = 0x0040; +const uint32_t VPD_CP00_PG_N1_GOOD = 0xE03F; +const uint32_t VPD_CP00_PG_N1_PG_MASK = 0x01C0; +const uint32_t VPD_CP00_PG_N1_PBIOO0 = 0x0100; +const uint32_t VPD_CP00_PG_N1_PBIOO1 = 0x0080; +const uint32_t VPD_CP00_PG_N1_MCS23 = 0x0040; -const uint32_t VPD_CP00_PG_N2_INDEX = 4; +const uint32_t VPD_CP00_PG_N2_INDEX = 4; // all good - 3:VITAL, 4:PRV, 5:CXA1, 6:PCIS0, 7:PCIS1, 8:PCIS2, 9:IOPSI -const uint32_t VPD_CP00_PG_N2_GOOD = 0xE03F; +const uint32_t VPD_CP00_PG_N2_GOOD = 0xE03F; +// all good - 3:VITAL, 4:PRV, 6:PCIS0, 7:PCIS1, 8:PCIS2, 9:IOPSI +const uint32_t VPD_CP00_PG_N2_GOOD_AXONE = 0xE43F; -const uint32_t VPD_CP00_PG_N3_INDEX = 5; + +const uint32_t VPD_CP00_PG_N3_INDEX = 5; // all good - 3:VITAL, 4:PRV, 5:PB, 6:BR, 7:NPU+, 8:MM, 9:INT, 10:MCS01+ -const uint32_t VPD_CP00_PG_N3_GOOD = 0xE01F; -const uint32_t VPD_CP00_PG_N3_PG_MASK = 0x0120; -const uint32_t VPD_CP00_PG_N3_NPU = 0x0100; -const uint32_t VPD_CP00_PG_N3_MCS01 = 0x0020; +const uint32_t VPD_CP00_PG_N3_GOOD = 0xE01F; +const uint32_t VPD_CP00_PG_N3_PG_MASK = 0x0120; +const uint32_t VPD_CP00_PG_N3_NPU = 0x0100; +const uint32_t VPD_CP00_PG_N3_MCS01 = 0x0020; -const uint32_t VPD_CP00_PG_XBUS_INDEX = 6; +const uint32_t VPD_CP00_PG_XBUS_INDEX = 6; // all good - 3:VITAL, 4:PRV, 5:IOX0*, 6:IOX1, 7:IOX2, 8:IOPPE // 9:PBIOX0*+, 10:PBIOX1+, 11:PBIOX2+, 14:PLLIOX // Nimbus doesn't physically have PBIOX0 and IOX0. IOX0 is @@ -92,14 +97,14 @@ const uint32_t VPD_CP00_PG_XBUS_INDEX = 6; // 0xE40D --> xbus chiplet good // and rely solely on the pbiox as the Xbus target indicator // (0x0040, 0x0020, 0x0010) for all types of chips. -const uint32_t VPD_CP00_PG_XBUS_GOOD_NIMBUS = 0xE40D; -const uint32_t VPD_CP00_PG_XBUS_GOOD_CUMULUS= 0xE00D; -const uint32_t VPD_CP00_PG_XBUS_PG_MASK = 0x00170; -const uint32_t VPD_CP00_PG_XBUS_IOX[3] = {0x0040, 0x0020, 0x0010}; - -const uint32_t VPD_CP00_PG_MC01_INDEX = 7; -const uint32_t VPD_CP00_PG_MC23_INDEX = 8; -const uint32_t VPD_CP00_PG_MCxx_INDEX[4] = {VPD_CP00_PG_MC01_INDEX, +const uint32_t VPD_CP00_PG_XBUS_GOOD_NIMBUS = 0xE40D; +const uint32_t VPD_CP00_PG_XBUS_GOOD_CUMULUS = 0xE00D; +const uint32_t VPD_CP00_PG_XBUS_PG_MASK = 0x00170; +const uint32_t VPD_CP00_PG_XBUS_IOX[3] = {0x0040, 0x0020, 0x0010}; + +const uint32_t VPD_CP00_PG_MC01_INDEX = 7; +const uint32_t VPD_CP00_PG_MC23_INDEX = 8; +const uint32_t VPD_CP00_PG_MCxx_INDEX[4] = {VPD_CP00_PG_MC01_INDEX, VPD_CP00_PG_MC01_INDEX, VPD_CP00_PG_MC23_INDEX, VPD_CP00_PG_MC23_INDEX}; // by MCS @@ -109,56 +114,60 @@ const uint32_t VPD_CP00_PG_MCxx_INDEX[4] = {VPD_CP00_PG_MC01_INDEX, // Cumulus: // all good - 3:VITAL, 4:PRV, 5:MC01, 6:IOM01, 7:IOM01PPE, 14:PLLMEM // all good - 3:VITAL, 4:PRV, 5:MC23, 6:IOM23, 7:IOM23PPE, 14:PLLMEM -const uint32_t VPD_CP00_PG_MCxx_GOOD = 0xE0FD; -const uint32_t VPD_CP00_PG_MCxx_PG_MASK = 0x0300; // Nimbus only +// Axone: +// all good - 3:VITAL, 4:PRV, 5:MC01, 6:OMI00, 7:OMI01, 8:OMI002 9:OMIPPE00 14:PLLOMI00 +// all good - 3:VITAL, 4:PRV, 5:MC23, 6:OMI10, 7:OMI11, 8:OMI012 9:OMIPPE10 14:PLLOMI10 +const uint32_t VPD_CP00_PG_MCxx_GOOD = 0xE0FD; +const uint32_t VPD_CP00_PG_MCxx_GOOD_AXONE = 0xE03D; +const uint32_t VPD_CP00_PG_MCxx_PG_MASK = 0x0300; // Nimbus only // iom0 and iom4 need to be good for zqcal to work on any // of the MCAs on that side -const uint32_t VPD_CP00_PG_MCA_MAGIC_PORT_MASK = 0x0200; -const uint32_t VPD_CP00_PG_MCxx_IOMyy[4] = {0x0200, 0x0100, 0x0200, 0x0100}; +const uint32_t VPD_CP00_PG_MCA_MAGIC_PORT_MASK = 0x0200; +const uint32_t VPD_CP00_PG_MCxx_IOMyy[4] = {0x0200, 0x0100, 0x0200, 0x0100}; -const uint32_t VPD_CP00_PG_OB0_INDEX = 9; -const uint32_t VPD_CP00_PG_OB3_INDEX = 12; +const uint32_t VPD_CP00_PG_OB0_INDEX = 9; +const uint32_t VPD_CP00_PG_OB3_INDEX = 12; // all good - 3:VITAL, 4:PRV, 5:PLIOOAx, 6:IOOx, 14:PLLIOO; x=0, 1*, 2*, 3 -const uint32_t VPD_CP00_PG_OBUS_GOOD = 0xE1FD; +const uint32_t VPD_CP00_PG_OBUS_GOOD = 0xE1FD; -const uint32_t VPD_CP00_PG_PCI0_INDEX = 13; +const uint32_t VPD_CP00_PG_PCI0_INDEX = 13; // all good - 3:VITAL, 4:PRV, 5:PCI00, 6:IOPCI0, 14:PLLPCI0 // all good - 3:VITAL, 4:PRV, 5:PCI11, 6:PCI12, 7:IOPCI1, 14:PLLPCI1 // all good - 3:VITAL, 4:PRV, 5:PCI23, 6:PCI24, 7:PCI25, 8:IOPCI2, 14:PLLPCI2 -const uint32_t VPD_CP00_PG_PCIx_GOOD[3] = {0xE1FD, 0xE0FD, 0xE07D}; +const uint32_t VPD_CP00_PG_PCIx_GOOD[3] = {0xE1FD, 0xE0FD, 0xE07D}; -const uint32_t VPD_CP00_PG_EP0_INDEX = 16; -const uint32_t VPD_CP00_PG_EP5_INDEX = 21; +const uint32_t VPD_CP00_PG_EP0_INDEX = 16; +const uint32_t VPD_CP00_PG_EP5_INDEX = 21; // all good - 3:VITAL, 4:PRV, 5:EQPB, 6:L30+, 7:L31+, // 8:L20+, 9:L21+, 10:AN, 11:PBLEQ, 12:REFR0, 13:REFR1, 14:DPLL -const uint32_t VPD_CP00_PG_EPx_GOOD = 0xE001; -const uint32_t VPD_CP00_PG_EPx_PG_MASK = 0x03CC; -const uint32_t VPD_CP00_PG_EPx_L3L2REFR[2] = {0x0288, 0x0144}; +const uint32_t VPD_CP00_PG_EPx_GOOD = 0xE001; +const uint32_t VPD_CP00_PG_EPx_PG_MASK = 0x03CC; +const uint32_t VPD_CP00_PG_EPx_L3L2REFR[2] = {0x0288, 0x0144}; -const uint32_t VPD_CP00_PG_EC00_INDEX = 32; +const uint32_t VPD_CP00_PG_EC00_INDEX = 32; // all good - 3:VITAL, 4:PRV, 5:C00, 6:C01 -const uint32_t VPD_CP00_PG_ECxx_GOOD = 0xE1FF; -const uint32_t VPD_CP00_PG_ECxx_MAX_ENTRIES = 24; +const uint32_t VPD_CP00_PG_ECxx_GOOD = 0xE1FF; +const uint32_t VPD_CP00_PG_ECxx_MAX_ENTRIES = 24; -const uint32_t VPD_CP00_PG_MAX_USED_INDEX = 55; -const uint32_t VPD_CP00_PG_xxx_VITAL = 0x1000; -const uint32_t VPD_CP00_PG_xxx_PERV = 0x0800; -const uint32_t VPD_CP00_PG_RESERVED_GOOD = 0xFFFF; +const uint32_t VPD_CP00_PG_MAX_USED_INDEX = 55; +const uint32_t VPD_CP00_PG_xxx_VITAL = 0x1000; +const uint32_t VPD_CP00_PG_xxx_PERV = 0x0800; +const uint32_t VPD_CP00_PG_RESERVED_GOOD = 0xFFFF; // constants the platReadPR will use for looking at the VPD data -const uint32_t VPD_VINI_PR_DATA_LENGTH = 8; //@deprecrated +const uint32_t VPD_VINI_PR_DATA_LENGTH = 8; //@deprecrated // constants the platReadLx will use for looking at the VPD data -const uint32_t VPD_CRP0_LX_HDR_DATA_LENGTH = 256; +const uint32_t VPD_CRP0_LX_HDR_DATA_LENGTH = 256; -const uint32_t VPD_CRP0_LX_FREQ_INDEP_INDEX = 8; -const uint32_t VPD_CRP0_LX_PORT_DISABLED = 0; +const uint32_t VPD_CRP0_LX_FREQ_INDEP_INDEX = 8; +const uint32_t VPD_CRP0_LX_PORT_DISABLED = 0; -const uint8_t VPD_CRP0_LX_MIN_X = 1; -const uint8_t VPD_CRP0_LX_MAX_X = 8; +const uint8_t VPD_CRP0_LX_MIN_X = 1; +const uint8_t VPD_CRP0_LX_MAX_X = 8; // constants for the error log parser for partial good issues -const uint8_t MODEL_PG_DATA_ENTRIES = 2; +const uint8_t MODEL_PG_DATA_ENTRIES = 2; } diff --git a/src/include/usr/hwas/hwasPlat.H b/src/include/usr/hwas/hwasPlat.H index 8ccddd588..fa07c72c8 100644 --- a/src/include/usr/hwas/hwasPlat.H +++ b/src/include/usr/hwas/hwasPlat.H @@ -25,7 +25,6 @@ #ifndef __HWAS_PLAT_H #define __HWAS_PLAT_H -#include <config.h> /** * @file hwas/hwasPlat.H diff --git a/src/include/usr/i2c/eeprom_const.H b/src/include/usr/i2c/eeprom_const.H index e9e157757..275388450 100644 --- a/src/include/usr/i2c/eeprom_const.H +++ b/src/include/usr/i2c/eeprom_const.H @@ -108,7 +108,7 @@ enum EECACHE_VERSION * * uniqueRecord is useful if you want to quickly compare the "unique" * bits of a header entry which includes the target_huid, port, engine, -* devAddr, mux_huid, and mux_select. +* devAddr, mux_huid, and mux_select, and size * */ union eepromRecordHeader @@ -124,7 +124,10 @@ union eepromRecordHeader uint32_t cache_copy_size; // Size of data saved in cache (in KB) uint32_t internal_offset; // offset from start of EECACHE section where cached // data exists - uint8_t cached_copy_valid; // if == 0 , cached data is invalid + uint8_t cached_copy_valid : 1, // This bit is set when we think the contents of the + // cache is valid. + unused : 7; + } PACKED completeRecord; struct uniqueRecord @@ -167,9 +170,9 @@ struct eecacheSectionHeader */ struct eeprom_addr_t { - uint64_t port; - uint64_t engine; - uint64_t devAddr; + uint8_t port; + uint8_t engine; + uint8_t devAddr; int64_t eepromRole; uint64_t offset; eeprom_addr_size_t addrSize; @@ -235,5 +238,30 @@ struct EepromInfo_t } }; +/** + * @brief Define a set of information that describes the + different virtual addresses associated with a given + cache entry along with a byte telling us if there has been + an update detected on the eeprom this boot + */ +struct EeepromEntryMetaData_t +{ + uint64_t header_entry_address; + uint64_t cache_entry_address; + uint8_t mark_target_changed; // This byte is set after we detect a target has changed. + // Either removed, replaced, or added we don't care. But + // we need to use this bits so future targets associated + // with this eeprom can know they need to notify HWAS that + // they have been changed. This bit should get cleared after + // all eeproms have been cached. + + EeepromEntryMetaData_t() + : header_entry_address(0), + cache_entry_address(0), + mark_target_changed(0) + { + } +}; + } #endif
\ No newline at end of file diff --git a/src/include/usr/i2c/eepromddreasoncodes.H b/src/include/usr/i2c/eepromddreasoncodes.H index a2c7b1c83..41de06dfa 100644 --- a/src/include/usr/i2c/eepromddreasoncodes.H +++ b/src/include/usr/i2c/eepromddreasoncodes.H @@ -57,6 +57,9 @@ enum eepromModuleId EEPROM_CACHE_EEPROM = 0x07, EEPROM_CLEAR_EECACHE = 0x08, EEPROM_CACHE_PERFORM_OP = 0x09, + EEPROM_INVALIDATE_CACHE = 0x0A, + EEPROM_RESOLVE_SOURCE = 0x0B, + EEPROM_CACHE_INIT_RT = 0x0C, }; /** @@ -87,6 +90,14 @@ enum eepromReasonCode EEPROM_NEW_DEVICE_DETECTED = EEPROM_COMP_ID | 0x0E, // While looking up a part, found that current EEPROM size does not // match what we have seen in previous IPLs indicating a new part has // been installed on the system. + EEPROM_CACHE_NOT_FOUND_IN_MAP = EEPROM_COMP_ID | 0x0F, // An entry we thought would be in the global map that keeps track of + // what eeproms have been cached was not found + EEPROM_CACHE_NOT_FOUND_IN_PNOR = EEPROM_COMP_ID | 0x10, // An entry we thought would be in the the EECACHE section of PNOR seems + // to be missing + EEPROM_CACHE_NO_VPD_IN_RSV_MEM = EEPROM_COMP_ID | 0x11, // When looking up the VPD section in reserved memory no entry was found. + EEPROM_DUPLICATE_CACHE_ENTRY = EEPROM_COMP_ID | 0x12 // While parsing eecache found in reserved memory we found at least two + // cache entries that had identical "unique" identifiers + // (see structs defined in eeprom_const.H) }; enum UserDetailsTypes diff --git a/src/include/usr/i2c/tpmddif.H b/src/include/usr/i2c/tpmddif.H index 0f57e4797..2a0c964c5 100644 --- a/src/include/usr/i2c/tpmddif.H +++ b/src/include/usr/i2c/tpmddif.H @@ -65,7 +65,8 @@ enum tpm_locality_t /** * @brief TPM Models that are supported * - * @note Must stay in sync with TPM_MODEL in attribute_types_hb.xml + * @note Must stay in sync with TPM_MODEL in attribute_types_hb.xml and + * the attribute usage in processMrw.pl. * @note Not using Attribute Enums since FSP does not currently support * overriding enum values */ diff --git a/src/include/usr/initservice/mboxRegs.H b/src/include/usr/initservice/mboxRegs.H index 889f2126b..ce43a4d52 100644 --- a/src/include/usr/initservice/mboxRegs.H +++ b/src/include/usr/initservice/mboxRegs.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2015,2018 */ +/* Contributors Listed Below - COPYRIGHT 2015,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -157,10 +157,12 @@ namespace SPLESS struct { uint32_t procMemToUse :7; //0:6 - uint32_t reserved1 :23; //7:22 + uint32_t reserved1 :9; //7:15 + uint32_t smfConfig :1; //16 + uint32_t reserved2 :6; //17:22 uint32_t groupPumpMode :1; //23 uint32_t isSlave :1; //24 - uint32_t reserved2 :1; //25 + uint32_t reserved3 :1; //25 uint32_t groupId :3; //26:28 uint32_t chipId :3; //29:31 } PACKED; diff --git a/src/include/usr/ipmi/ipmi_reasoncodes.H b/src/include/usr/ipmi/ipmi_reasoncodes.H index 65d8e64d3..6bb7e4b4b 100644 --- a/src/include/usr/ipmi/ipmi_reasoncodes.H +++ b/src/include/usr/ipmi/ipmi_reasoncodes.H @@ -5,9 +5,10 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2017 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ +/* [+] Maxim Polyakov */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -64,6 +65,7 @@ namespace IPMI RC_INVALID_VPD_DATA = IPMI_COMP_ID | 0x0e, RC_INVALID_SENSOR_NUMBER = IPMI_COMP_ID | 0x0f, RC_INVALID_SENSOR_SETTING = IPMI_COMP_ID | 0x10, + RC_GET_DCMI_CAP_CMD_FAILED = IPMI_COMP_ID | 0x11, }; }; diff --git a/src/include/usr/ipmi/ipmiif.H b/src/include/usr/ipmi/ipmiif.H index 0421aaef3..68adfa392 100644 --- a/src/include/usr/ipmi/ipmiif.H +++ b/src/include/usr/ipmi/ipmiif.H @@ -5,9 +5,10 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ +/* [+] Maxim Polyakov */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -304,7 +305,10 @@ namespace IPMI inline const command_t hiomap_event(void) { return std::make_pair(NETFUN_IBM, 0x0f); } - // $TODO RTC:123256 - need to add code to get dcmi capabilities + // Used to get dcmi capabilities + inline const command_t get_dcmi_capability_info(void) + { return std::make_pair(NETFUN_GRPEXT, 0x01); } + // This is a dcmi message used to request the // user defined power limit from the BMC. inline const command_t get_power_limit(void) diff --git a/src/include/usr/isteps/istep07list.H b/src/include/usr/isteps/istep07list.H index 4b1feb1b6..2fb8eb49f 100644 --- a/src/include/usr/isteps/istep07list.H +++ b/src/include/usr/isteps/istep07list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -170,7 +170,6 @@ const DepModInfo g_istep07Dependancies = { #ifndef CONFIG_FSP_BUILD DEP_LIB(libnvram.so), #endif - DEP_LIB(libsmf.so), NULL } }; diff --git a/src/include/usr/isteps/istep08list.H b/src/include/usr/isteps/istep08list.H index 6ee38287c..5820907f9 100644 --- a/src/include/usr/isteps/istep08list.H +++ b/src/include/usr/isteps/istep08list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -267,6 +267,9 @@ const DepModInfo g_istep08Dependancies = { DEP_LIB(libisteps_nest.so), DEP_LIB(libsbe.so), DEP_LIB(libimageprocs.so), +#ifdef CONFIG_AXONE + DEP_LIB(libisteps_mss.so), +#endif NULL } }; diff --git a/src/include/usr/isteps/istep09list.H b/src/include/usr/isteps/istep09list.H index 4adcc0810..d52d29d30 100644 --- a/src/include/usr/isteps/istep09list.H +++ b/src/include/usr/isteps/istep09list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -58,7 +58,6 @@ #include <initservice/initsvcreasoncodes.H> // include prototypes file -#include <config.h> namespace ISTEP_09 { diff --git a/src/include/usr/isteps/istep10list.H b/src/include/usr/isteps/istep10list.H index 642fcd0ee..e6aceef33 100644 --- a/src/include/usr/isteps/istep10list.H +++ b/src/include/usr/isteps/istep10list.H @@ -68,7 +68,6 @@ #include <initservice/initsvcreasoncodes.H> // include prototypes file -#include <config.h> namespace ISTEP_10 { diff --git a/src/include/usr/isteps/istep11list.H b/src/include/usr/isteps/istep11list.H index b00f92e60..40c31d9d3 100644 --- a/src/include/usr/isteps/istep11list.H +++ b/src/include/usr/isteps/istep11list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -74,7 +74,6 @@ #include <initservice/initsvcreasoncodes.H> // include prototypes file -#include <config.h> namespace ISTEP_11 { diff --git a/src/include/usr/isteps/istep12list.H b/src/include/usr/isteps/istep12list.H index 2fadd6fee..e002e48db 100644 --- a/src/include/usr/isteps/istep12list.H +++ b/src/include/usr/isteps/istep12list.H @@ -69,7 +69,6 @@ // include prototypes file -#include <config.h> namespace ISTEP_12 { @@ -290,6 +289,7 @@ const DepModInfo g_istep12Dependancies = { DEP_LIB(libnestmemutils.so), DEP_LIB(libisteps_io.so), DEP_LIB(libisteps_mss.so), + DEP_LIB(libexpupd.so), NULL } }; diff --git a/src/include/usr/isteps/istep13list.H b/src/include/usr/isteps/istep13list.H index 5a00e9537..89041eae0 100644 --- a/src/include/usr/isteps/istep13list.H +++ b/src/include/usr/isteps/istep13list.H @@ -69,7 +69,6 @@ #include <initservice/initsvcreasoncodes.H> // include prototypes file -#include <config.h> namespace ISTEP_13 { @@ -296,6 +295,7 @@ const DepModInfo g_istep13Dependancies = { DEP_LIB(libistep13.so), DEP_LIB(libisteps_mss.so), DEP_LIB(libcen.so), + DEP_LIB(libnestmemutils.so), NULL } }; diff --git a/src/include/usr/isteps/istep14list.H b/src/include/usr/isteps/istep14list.H index ac358f7b8..f335a35b5 100644 --- a/src/include/usr/isteps/istep14list.H +++ b/src/include/usr/isteps/istep14list.H @@ -55,7 +55,6 @@ #include <initservice/initsvcstructs.H> #include <initservice/initsvcreasoncodes.H> -#include <config.h> namespace ISTEP_14 { diff --git a/src/include/usr/isteps/istep15list.H b/src/include/usr/isteps/istep15list.H index d32145d0c..d93acf859 100644 --- a/src/include/usr/isteps/istep15list.H +++ b/src/include/usr/isteps/istep15list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -47,7 +47,6 @@ #include <initservice/initsvcstructs.H> #include <initservice/initsvcreasoncodes.H> -#include <config.h> namespace ISTEP_15 { @@ -141,7 +140,6 @@ const DepModInfo g_istep15Dependancies = { DEP_LIB(libpm.so), DEP_LIB(libimageprocs.so), DEP_LIB(libisteps_mss.so), - DEP_LIB(libsmf.so), NULL } }; diff --git a/src/include/usr/isteps/istep21list.H b/src/include/usr/isteps/istep21list.H index 18f029fad..65f62fab4 100644 --- a/src/include/usr/isteps/istep21list.H +++ b/src/include/usr/isteps/istep21list.H @@ -135,7 +135,6 @@ const DepModInfo g_istep21Dependancies = { #ifdef CONFIG_UCD_FLASH_UPDATES DEP_LIB(libucd.so), #endif - DEP_LIB(libsmf.so), NULL } }; diff --git a/src/include/usr/isteps/istep_reasoncodes.H b/src/include/usr/isteps/istep_reasoncodes.H index 5bd5fbf94..468ac5d9a 100644 --- a/src/include/usr/isteps/istep_reasoncodes.H +++ b/src/include/usr/isteps/istep_reasoncodes.H @@ -68,6 +68,7 @@ namespace ISTEP MOD_MSS_SCRUB = 0x25, MOD_CALL_UPDATE_UCD_FLASH = 0x26, MOD_LOAD_HCODE = 0x27, + MOD_DISCOVER_TARGETS = 0x28, }; /** @@ -142,6 +143,7 @@ namespace ISTEP RC_SLAVE_CORE_WAKEUP_ERROR = ISTEP_COMP_ID | 0x4E, RC_UCD_IMG_NOT_IN_CONTAINER = ISTEP_COMP_ID | 0x4F, RC_MM_UNMAP_FAILED = ISTEP_COMP_ID | 0x50, + RC_CANNOT_BOOT_WITH_MISMATCHED_BARS = ISTEP_COMP_ID | 0x51, }; }; diff --git a/src/include/usr/isteps/nvdimm/bpmreasoncodes.H b/src/include/usr/isteps/nvdimm/bpmreasoncodes.H new file mode 100644 index 000000000..2957e2e6e --- /dev/null +++ b/src/include/usr/isteps/nvdimm/bpmreasoncodes.H @@ -0,0 +1,90 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/isteps/nvdimm/bpmreasoncodes.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +/** + * @file bpmreasoncode.H + * + * @brief Reason codes and module ids for the BPM + */ +#ifndef __BPMREASONCODES_H +#define __BPMREASONCODES_H + +#include <hbotcompid.H> + +namespace BPM_RC +{ + + enum bpmModuleId + { + BPM_ISSUE_COMMAND = 0x00, + BPM_IN_UPDATE_MODE = 0x01, + BPM_UPDATE_FIRMWARE = 0x02, + BPM_ENTER_BSL_MODE = 0x03, + BPM_SETUP_PAYLOAD = 0x04, + BPM_DUMP_SEGMENT = 0x05, + BPM_DISABLE_WRITE_PROTECTION = 0x06, + BPM_WRITE_MAGIC_REG = 0x07, + BPM_GET_RESPONSE = 0x08, + BPM_RETRY_BLOCK_WRITE = 0x09, + BPM_WAIT_FOR_CMD_BIT_RESET = 0x0A, + BPM_WAIT_FOR_BUSY_BIT_RESET = 0x0B, + BPM_CHECK_FIRMWARE_CRC = 0x0C, + BPM_VERIFY_GOOD_BPM_STATE = 0x0D, + BPM_RUN_FW_UPDATES = 0x0F, + BPM_WRITE_VIA_SCAP = 0x10, + BPM_BLOCK_WRITE = 0x11, + BPM_RUN_UPDATE = 0x12, + BPM_START_UPDATE = 0xFD, + BPM_END_UPDATE = 0xFE, + BPM_DUMMY_ERROR = 0xFF, + }; + + enum bpmReasonCode + { + BPM_INVALID_PAYLOAD_SIZE = BPM_COMP_ID | 0x00, + BPM_UPDATE_MODE_VERIFICATION_FAIL = BPM_COMP_ID | 0x01, + BPM_RESET_VECTOR_NEVER_RECEIVED = BPM_COMP_ID | 0x02, + BPM_FAILED_TO_ENTER_BSL_MODE = BPM_COMP_ID | 0x03, + BPM_INVALID_PAYLOAD_DATA_SIZE = BPM_COMP_ID | 0x04, + BPM_BSL_MODE_ENABLED = BPM_COMP_ID | 0x05, + BPM_DISABLE_WRITE_PROTECTION_FAILED = BPM_COMP_ID | 0x06, + BPM_WRITE_TO_MAGIC_REG_FAILED = BPM_COMP_ID | 0x07, + BPM_RESPONSE_CRC_MISMATCH = BPM_COMP_ID | 0x08, + BPM_EXCEEDED_RETRY_LIMIT = BPM_COMP_ID | 0x09, + BPM_CMD_STATUS_ERROR_BIT_SET = BPM_COMP_ID | 0x0A, + BPM_FIRMWARE_CRC_VERIFY_FAILURE = BPM_COMP_ID | 0x0B, + BPM_VERSION_MISMATCH = BPM_COMP_ID | 0x0C, + BPM_EXCEEDED_RETRY_LIMIT_REG = BPM_COMP_ID | 0x0D, + BPM_EXCEEDED_RETRY_LIMIT_DATA = BPM_COMP_ID | 0x0E, + BPM_BAD_RESPONSE = BPM_COMP_ID | 0x0F, + BPM_UPDATE_SUCCESSFUL = BPM_COMP_ID | 0xFC, + BPM_ENTER_UPDATE_MODE = BPM_COMP_ID | 0xFD, + BPM_EXIT_UPDATE_MODE = BPM_COMP_ID | 0xFE, + BPM_DUMMY_REASONCODE = BPM_COMP_ID | 0xFF, + }; + +}; + + +#endif diff --git a/src/include/usr/isteps/nvdimm/nvdimm.H b/src/include/usr/isteps/nvdimm/nvdimm.H index 567299925..966d4fd17 100644 --- a/src/include/usr/isteps/nvdimm/nvdimm.H +++ b/src/include/usr/isteps/nvdimm/nvdimm.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -29,20 +29,24 @@ namespace NVDIMM { + enum nvdimm_err_status { - NSTD_VAL_NOPRSV = 0x08, // memory valid, contents not preserved (genesis) - NSTD_VAL_NOPRSV_MASK = 0xF7, - NSTD_VAL_PRSV = 0x04, // memory contents preserved - NSTD_VAL_PRSV_MASK = 0xFB, - NSTD_ERR_NOPRSV = 0x02, // memory failed to preserve contents - NSTD_ERR_NOPRSV_MASK = 0xFD, - NSTD_ERR_NOBKUP = 0x01, // memory unable to preserve future content - NSTD_ERR_NOBKUP_MASK = 0xFE, - NSTD_ERR = 0x03, // NSTD_ERR_NOPRSV+NSTD_ERR_NOBKUP + NSTD_VAL_ERASED = 0x08, // Image erased, SCM device contents not persisted + NSTD_VAL_ERASED_MASK = 0xF7, + NSTD_VAL_RESTORED = 0x04, // Valid image successfully restored, SCM persisted + NSTD_VAL_RESTORED_MASK = 0xFB, + NSTD_VAL_SR_FAILED = 0x02, // Save/Restore failed to persist memory contents + NSTD_VAL_SR_FAILED_MASK = 0xFD, + NSTD_VAL_DISARMED = 0x01, // memory unable to preserve future content + NSTD_VAL_DISARMED_MASK = 0xFE, + NSTD_ERR_VAL_SR = 0x40, // Partially working. Error detected but save/restore (SR) may still work + NSTD_ERR_VAL_SR_MASK = 0xBF, + NSTD_ERR = 0x03, // NSTD_ERR_NOPRSV+NSTD_ERR_NOBKUP }; #ifndef __HOSTBOOT_RUNTIME + /** * @brief Entry function to NVDIMM management * - Restore image from NVDIMM NAND flash to DRAM @@ -69,15 +73,105 @@ void nvdimm_restore(TARGETING::TargetHandleList &i_nvdimmList); **/ bool nvdimm_update(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Entry function to set NVDIMM thresholds + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + **/ +void nvdimm_thresholds(TARGETING::TargetHandleList &i_nvdimmList); + + #endif /** + * @brief Entry function to NVDIMM unlock encryption + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimm_encrypt_unlock(TARGETING::TargetHandleList &i_nvdimmList); + + +/** + * @brief Entry function to NVDIMM generate keys + * Generate encryption keys and set the FW key attribute + * + * @return true if no errors logged, else false + */ +bool nvdimm_gen_keys(void); + +/** + * @brief Entry function to NVDIMM remove keys + * Set the FW key attribute = 0 + * Tell HWSV to clear anchor key attribute + * + * @return true if no errors logged, else false + */ +bool nvdimm_remove_keys(void); + +/** + * @brief Entry function to NVDIMM enable encryption + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimm_encrypt_enable(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Entry function to NVDIMM crypto erase + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimm_crypto_erase(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Entry function to NVDIMM factory default + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimmFactoryDefault(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Entry function to NVDIMM secure erase verify + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimmSecureEraseVerifyStart(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Entry function to NVDIMM secure erase verify status + * + * @param[in] i_nvdimmList - list of nvdimm targets + * + * @return true if no errors logged, else false + */ +bool nvdimmSecureEraseVerifyStatus(TARGETING::TargetHandleList &i_nvdimmList); + +/** + * @brief Helper function to get list of nvdimm target pointers + * + * @param[out] o_nvdimmList - list of nvdimm targets + * + */ +void nvdimm_getNvdimmList(TARGETING::TargetHandleList &o_nvdimmList); + +/** * @brief This function erases image on the nvdimm target * * @param[in] i_nvdimm - nvdimm target with NV controller * - * @return errlHndl_t - Null if successful, otherwise a pointer to + * @return errlHndl_t - nullptr if successful, otherwise a pointer to * the error log. */ errlHndl_t nvdimmEraseNF(TARGETING::Target *i_nvdimm); @@ -92,17 +186,6 @@ errlHndl_t nvdimmEraseNF(TARGETING::Target *i_nvdimm); */ void nvdimmSetStatusFlag(TARGETING::Target *i_nvdimm, const uint8_t i_status_flag); -#ifdef __HOSTBOOT_RUNTIME - -/** - * @brief Check nvdimm error state - * - * @param[in] i_nvdimm - nvdimm target - * - * @return bool - true if nvdimm is in any error state, false otherwise - */ -bool nvdimmInErrorState(TARGETING::Target *i_nvdimm); - /** * @brief This function arms/disarms the trigger based on i_state * @@ -110,7 +193,7 @@ bool nvdimmInErrorState(TARGETING::Target *i_nvdimm); * * @param[in] i_state - true to arm, false to disarm * - * @return errlHndl_t - Null if successful, otherwise a pointer to + * @return errlHndl_t - nullptr if successful, otherwise a pointer to * the error log. */ errlHndl_t nvdimmChangeArmState(TARGETING::Target *i_nvdimm, bool i_state); @@ -130,39 +213,290 @@ errlHndl_t nvdimmChangeArmState(TARGETING::Target *i_nvdimm, bool i_state); bool nvdimmArm(TARGETING::TargetHandleList &i_nvdimmTargetList); /** + * @brief Disarms the trigger to enable backup in the event of a + * power loss on each NVDIMM + * + * @param[in] i_nvdimmTargetList : list of dimms that are NVDIMMs + * @return true if no errors logged, else false + */ +bool nvdimmDisarm(TARGETING::TargetHandleList &i_nvdimmTargetList); + +#ifdef __HOSTBOOT_RUNTIME + +/** + * @brief Check nvdimm error state + * + * @param[in] i_nvdimm - nvdimm target + * + * @return bool - true if nvdimm is in any error state, false otherwise + */ +bool nvdimmInErrorState(TARGETING::Target *i_nvdimm); + +/** + * @brief Check the ES (enery source)/backup power module(BPM) health status of + * the individual NVDIMMs supplied in list + * + * @details The BPM will trigger the health check when power is applied at the + * beginning of the IPL, with results ready to check about 20 mins + * later. It is the caller's responsibility to ensure enough time has + * passed to make this call. + * Excerpt from the Jedec Standard, Byte Addressable Energy Backed + * Interface of the interested flags (bits 0 .. 2). + * ES_CMD_STATUS0 + * Bit 0 : Health Check in Progress + * Bit 1 : Health Check Succeeded + * Bit 2 : Health Check Failed + * + * @param[in] i_nvdimmTargetList - list of NVDIMMs to check the ES health of + * + * @return false if one or more NVDIMMs fail ES health check, else true + */ +bool nvDimmEsCheckHealthStatus(const TARGETING::TargetHandleList + &i_nvdimmTargetList); + +/** + * @brief A wrapper around the call to nvDimmEsCheckHealthStatus + * + * @details This will aggregate all the NVDIMMs of the system and pass + * them to the call nvDimmEsCheckHealthStatus + * + * @see nvDimmEsCheckHealthStatus for more details + * + * @return false if one or more NVDIMMs fail an ES health check, else true + */ +bool nvDimmEsCheckHealthStatusOnSystem(); + + +/** + * @brief Check the NVM (non-volatile memory)/flash health status of the + * individual NVDIMMs supplied in list. + * + * @details This method will check the flash error count registers + * (FLASH_ERROR_COUNT0 to FLASH_ERROR_COUNT2) to determine if the + * number of flash error exceeds the maximum allowed. Will also check + * the flash bad block percentage register (FLASH_BAD_BLK_PCT) to + * determine if the percentage exceeds the maximum allowed. + * If any one of these or both of these fail their perspective + * maximums then a callout will be made with either or both failures. + * + * @param[in] i_nvdimmTargetList - list of NVDIMMs to check the NVM health of + * + * @return false if one or more NVDIMMs fail NVM health check, else true + */ +bool nvDimmNvmCheckHealthStatus(const TARGETING::TargetHandleList + &i_nvdimmTargetList); + +/** + * @brief A wrapper around the call to nvDimmNvmCheckHealthStatus + * + * @details This will aggregate all the NVDIMMs of the system and pass + * them to the call nvDimmNvmCheckHealthStatus + * + * @see nvDimmNvmCheckHealthStatus for more details + * + * @return false if one or more NVDIMMs fail an NVM health check, else true + */ +bool nvDimmNvmCheckHealthStatusOnSystem(); + + +/** + * @brief Send NV_STATUS to host + */ +void nvdimmSendNvStatus(); + +#endif + +/** * @brief NVDIMM protection state * - * NOT_PROTECTED - default state - * PROTECTED - switches to this when armed & OCC is in control - * UNPROTECTED_BECAUSE_ERROR - PRD detected error on NV controller - * Note: error will stay with target preventing PROTECTED status - * until power is cycled again + * NVDIMM_ARMED - set armed state + * NVDIMM_DISARMED - set disarmed state + * OCC_ACTIVE - set active state + * OCC_INACTIVE - set inactive state + * NVDIMM_FATAL_HW_ERROR - set fatal hw state + * NVDIMM_RISKY_HW_ERROR - set risky hw state + * NVDIMM_ENCRYPTION_ERROR - set encryption state + * Note: fatal error will stay with target preventing + * PROTECTED status until power is cycled again + * ENCRYPTION_ENABLED - contents of nvdimm are encrypted + * ENCRYPTION_DISABLED - contents of nvdimm are not encrypted + * ERASE_VERIFY_STARTED - set secure_erase_verify_complete to 0 + * ERASE_VERIFY_COMPLETE = set secure_erase_verify_complete to 1 */ enum nvdimm_protection_t { - NOT_PROTECTED = 0, - PROTECTED = 1, - UNPROTECTED_BECAUSE_ERROR = 2 + NVDIMM_ARMED = 0, + NVDIMM_DISARMED = 1, + OCC_ACTIVE = 2, + OCC_INACTIVE = 3, + NVDIMM_FATAL_HW_ERROR = 4, + NVDIMM_RISKY_HW_ERROR = 5, + NVDIMM_ENCRYPTION_ERROR = 6, + ENCRYPTION_ENABLED = 7, + ENCRYPTION_DISABLED = 8, + ERASE_VERIFY_STARTED = 9, + ERASE_VERIFY_COMPLETED = 10, + SEND_NV_STATUS = 11, + /* deprecated, still used by PRD */ + UNPROTECTED_BECAUSE_ERROR = 4, }; /** * @brief Notify PHYP of NVDIMM protection status * - * @param i_target Processor with NVDIMM + * @param i_target Processor with NVDIMM or NVDIMM itself + * - ARMED state updated per NVDIMM + * - ERROR states updated per NVDIMM + * - OCC state updated per PROC * @param i_state Protection state of NVDIMM + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. */ errlHndl_t notifyNvdimmProtectionChange(TARGETING::Target* i_target, const nvdimm_protection_t i_state); -#endif + +/** + * @brief Get operational unit operation timeout + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[out] o_timeout - operation timeout + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. + */ +errlHndl_t getOperOpsTimeout(TARGETING::Target* i_nvdimm, + uint16_t& o_timeout); + + +/** + * @brief Wait for operational unit operation to complete + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[in] i_cmd - operational unit ops command + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. + */ +errlHndl_t waitOperOpsComplete(TARGETING::Target* i_nvdimm, + uint8_t i_cmd); + + +/** + * @brief Get the vendor log unit + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[in] i_unitId - vendor log unit id + * + * @param[out] o_unitData - vendor log unit data + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. + */ +errlHndl_t getLogPerUnit(TARGETING::Target* i_nvdimm, + uint16_t i_unitId, + std::vector<uint8_t>& o_unitData); + +/** + * @brief Calculate host CRC + * + * @param[in] i_data - host data + * + * @param[in] i_data_size - data size + * + * @return crc + */ +uint16_t crc16(const uint8_t * i_data, int i_size); + + +/** + * @brief Get operational unit crc + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[out] o_crc - nvdimm hw crc + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. + */ +errlHndl_t getOperUnitCrc(TARGETING::Target* i_nvdimm, uint16_t& o_crc); + + +/** + * @brief Compare host and nvdimm checksum + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[in] i_unitData - data sent to the nvdimm by the host + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. + */ +errlHndl_t compareCksum(TARGETING::Target* i_nvdimm, + std::vector<uint8_t>& i_unitData); + + +/** + * @brief Function to add NVDIMM vendor log data to errorlog FFDC + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[inout] io_err - error log to add FFDC data. Must not be nullptr + * + */ +void nvdimmAddVendorLog(TARGETING::Target *i_nvdimm, errlHndl_t& io_err); + + +/** + * @brief Add NVDIMM Update regs to FFDC for errors encountered + * during NVDIMM firmware update process + * Regs specified in NVDIMM IPL Error Handling Document + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[in] io_err - error log to add FFDC data. Must not be nullptr + * + */ +void nvdimmAddUpdateRegs(TARGETING::Target *i_nvdimm, errlHndl_t& io_err); + + +/** + * @brief Function to add some NVDIMM Page 4 status regs to errorlog FFDC + * PANIC_CNT Counts FPGA firmware events + * PARITY_ERROR_COUNT Counts FPGA SRAM parity errors + * FLASH_ERROR_COUNT0 Counts FLASH read/write errors + * FLASH_ERROR_COUNT1 + * FLASH_ERROR_COUNT2 + * FLASH_BAD_BLOCK_COUNT0 Counts bad blocks within the flash array + * FLASH_BAD_BLOCK_COUNT1 + * SCAP_STATUS BackupPowerModule/SuperCap state + * STATUS_EVENT_INT_INFO1 NVDIMM error info + * STATUS_EVENT_INT_INFO2 + * + * @param[in] i_nvdimm - nvdimm target + * + * @param[inout] io_err - error log to add FFDC data. Must not be nullptr + * + */ +void nvdimmAddPage4Regs(TARGETING::Target *i_nvdimm, errlHndl_t& io_err); + + /** * @brief Entry function to NVDIMM initialization * - Checks for ready state * - Waits for the ongoing backup to complete * - Disarms the trigger for draminit * @param i_target nvdimm target + * + * @return errlHndl_t - nullptr if successful, otherwise a pointer to + * the error log. */ void nvdimm_init(TARGETING::Target *i_nvdimm); + } #endif // NVDIMM_EXT_H__ diff --git a/src/include/usr/isteps/nvdimm/nvdimmif.H b/src/include/usr/isteps/nvdimm/nvdimmif.H index 4ddfcf970..e96bb17d4 100644 --- a/src/include/usr/isteps/nvdimm/nvdimmif.H +++ b/src/include/usr/isteps/nvdimm/nvdimmif.H @@ -42,6 +42,22 @@ namespace NVDIMM */ void getNVDIMMs( std::list<EEPROM::EepromInfo_t>& o_info ); +/** + * @brief Check if given address is owned by nvdimms and return + a new address that isn't if it was + * @param[in] i_topAddr = High mainstore address (see get_top_homer_mem_addr) + * @return uint64_t - Highest address without a nvdimm + */ +uint64_t get_top_addr_with_no_nvdimms( uint64_t i_topAddr ); + +// Make a very simple inline if we don't support NVDIMMs in this compile +#ifndef CONFIG_NVDIMM +inline uint64_t get_top_addr_with_no_nvdimms( uint64_t i_topAddr ) +{ + return i_topAddr; +}; +#endif + }; // end namespace NVDIMM #endif // end __NVDIMMIF_H diff --git a/src/include/usr/isteps/nvdimm/nvdimmreasoncodes.H b/src/include/usr/isteps/nvdimm/nvdimmreasoncodes.H index 0b1680d92..134988be6 100644 --- a/src/include/usr/isteps/nvdimm/nvdimmreasoncodes.H +++ b/src/include/usr/isteps/nvdimm/nvdimmreasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2019 */ +/* Contributors Listed Below - COPYRIGHT 2019,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -85,6 +85,32 @@ enum nvdimmModuleId VALIDATE_FW_IMAGE = 0x23, WAIT_FW_OPS_BLOCK_RECEIVED = 0x24, NVDIMM_IS_UPDATE_NEEDED = 0x25, + NVDIMM_RUN_UPDATE_USING_LID = 0x26, + NVDIMM_GET_TPM = 0x27, + NVDIMM_SET_KEY_REG = 0x28, + NVDIMM_ENCRYPT_ENABLE = 0x29, + NVDIMM_CRYPTO_ERASE = 0x2A, + NVDIMM_CHECK_VALID_ATTR_DATA = 0x2B, + NVDIMM_HANDLE_CONFLICTING_KEYS = 0x2C, + NVDIMM_ENCRYPT_UNLOCK = 0x2D, + NVDIMM_GET_DARN_NUMBER = 0x2E, + NVDIMM_KEYIFY_RANDOM_NUMBER = 0x2F, + SET_ATTR_NVDIMM_ENCRYPTION_KEYS_FW = 0x30, + SEND_ATTR_NVDIMM_ARMED = 0x31, + NVDIMM_FACTORY_RESET = 0x32, + NVDIMM_ES_HEALTH_CHECK = 0x33, // Health check on the ES (energy source)/backup power module + NVDIMM_CHECK_RESETN = 0x34, + NVDIMM_CHECK_CSAVE = 0x35, + NVDIMM_MODULE_HEALTH_STATUS_CHECK = 0x36, + NVDIMM_SET_EVENT_NOTIFICATION = 0x37, + NVDIMM_NVM_HEALTH_CHECK = 0x38, // Health check on the NVM (non-volatile memory)/flash + NVDIMM_WAIT_OPER_OPS_COMPLETE = 0x39, + NVDIMM_COMPARE_CKSUM = 0x3A, + NVDIMM_CHECK_FW_SLOT = 0x3B, + NVDIMM_ARM_PRE_CHECK = 0x3C, + NVDIMM_ARM = 0x3D, + CLEAR_FW_OPS_STATUS = 0x3E, + NVDIMM_SECURE_ERASE_VERIFY_STATUS = 0x3F, }; /** @@ -95,52 +121,102 @@ enum nvdimmModuleId */ enum nvdimmReasonCode { - NVDIMM_INVALID_REASONCODE = NVDIMM_COMP_ID | 0x00, // Invalid Reasoncode - NVDIMM_INVALID_OPERATION = NVDIMM_COMP_ID | 0x01, - NVDIMM_INVALID_DEVICE_TYPE = NVDIMM_COMP_ID | 0x02, - NVDIMM_ATTR_INFO_NOT_FOUND = NVDIMM_COMP_ID | 0x03, - NVDIMM_INVALID_CHIP = NVDIMM_COMP_ID | 0x04, - NVDIMM_I2C_MASTER_PATH_ERROR = NVDIMM_COMP_ID | 0x05, - NVDIMM_TARGET_NULL = NVDIMM_COMP_ID | 0x06, - NVDIMM_INVALID_ADDR_OFFSET_SIZE = NVDIMM_COMP_ID | 0x07, - NVDIMM_OVERFLOW_ERROR = NVDIMM_COMP_ID | 0x08, - NVDIMM_I2C_WRITE_PAGE_SIZE_ZERO = NVDIMM_COMP_ID | 0x09, - NVDIMM_INVALID_OFFSET = NVDIMM_COMP_ID | 0x0A, - NVDIMM_READ_FAILURE = NVDIMM_COMP_ID | 0x0B, // NV Controller read failure - NVDIMM_WRITE_FAILURE = NVDIMM_COMP_ID | 0x0C, // NV Controller write failure - NVDIMM_BACKUP_TIMEOUT = NVDIMM_COMP_ID | 0x0D, // Backup/save timeout - NVDIMM_RESTORE_TIMEOUT = NVDIMM_COMP_ID | 0x0E, // Restore timeout - NVDIMM_ERASE_TIMEOUT = NVDIMM_COMP_ID | 0x0F, // Erase timeout - NVDIMM_CHARGE_TIMEOUT = NVDIMM_COMP_ID | 0x10, // Battery charging timeout - NVDIMM_ARM_TIMEOUT = NVDIMM_COMP_ID | 0x11, // Arming timeout - NVDIMM_SET_ES_ERROR = NVDIMM_COMP_ID | 0x12, // Failure to set the ES policy - NVDIMM_MSS_STR_ENTRY_ERROR = NVDIMM_COMP_ID | 0x13, // Failure to enter STR - NVDIMM_MSS_STR_EXIT_ERROR = NVDIMM_COMP_ID | 0x14, // Failure to exit STR - NVDIMM_MSS_POST_RSTR_ERROR = NVDIMM_COMP_ID | 0x15, // Failure to perform post restore work - NVDIMM_OPEN_PAGE_TIMEOUT = NVDIMM_COMP_ID | 0x16, // Open page timeout - NVDIMM_STATUS_TIMEOUT = NVDIMM_COMP_ID | 0x17, // Status timeout - NVDIMM_ARM_FAILED = NVDIMM_COMP_ID | 0x18, // Failure to arm reset_n - NVDIMM_ERASE_FAILED = NVDIMM_COMP_ID | 0x19, // Failure to erase - NVDIMM_RESTORE_FAILED = NVDIMM_COMP_ID | 0x1A, // Failure to restore - NVDIMM_NOT_READY = NVDIMM_COMP_ID | 0x1B, // NVDIMM not ready for host to access - NVDIMM_NULL_FIRMWARE_REQUEST_PTR = NVDIMM_COMP_ID | 0x1C, // Firmware request is NULL - NVDIMM_UNSUPPORTED_NVDIMM_TYPE = NVDIMM_COMP_ID | 0x1D, // Unsupported NVDIMM type for update - NVDIMM_OPERATION_IN_PROGRESS = NVDIMM_COMP_ID | 0x1E, // NV controller is busy - NVDIMM_CHECKSUM_ERROR = NVDIMM_COMP_ID | 0x1F, // Checksum error between host and nv calculated - NVDIMM_ZERO_TOTAL_REGIONS = NVDIMM_COMP_ID | 0x20, // Zero write regions calculated - NVDIMM_UPDATE_MODE_UNCHANGED = NVDIMM_COMP_ID | 0x21, // Unable to change update mode - NVDIMM_FW_OPS_IN_PROGRESS_TIMEOUT = NVDIMM_COMP_ID | 0x22, // Operations In Progress timeout - NVDIMM_DATA_SIZE_TOO_LARGE = NVDIMM_COMP_ID | 0x23, // Trying to write too much data - NVDIMM_DATA_SIZE_INVALID = NVDIMM_COMP_ID | 0x24, // Data size is invalid - NVDIMM_BLOCK_NOT_RECEIVED = NVDIMM_COMP_ID | 0x25, // Block data not received - NVDIMM_FW_OPS_NOT_SUCCESSFUL = NVDIMM_COMP_ID | 0x26, // Unsuccessful Firmware Operation - NVDIMM_UPDATE_NOT_SUPPORTED = NVDIMM_COMP_ID | 0x27, // NV controller cannot be updated + NVDIMM_INVALID_REASONCODE = NVDIMM_COMP_ID | 0x00, // Invalid Reasoncode + NVDIMM_INVALID_OPERATION = NVDIMM_COMP_ID | 0x01, + NVDIMM_INVALID_DEVICE_TYPE = NVDIMM_COMP_ID | 0x02, + NVDIMM_ATTR_INFO_NOT_FOUND = NVDIMM_COMP_ID | 0x03, + NVDIMM_INVALID_CHIP = NVDIMM_COMP_ID | 0x04, + NVDIMM_I2C_MASTER_PATH_ERROR = NVDIMM_COMP_ID | 0x05, + NVDIMM_TARGET_NULL = NVDIMM_COMP_ID | 0x06, + NVDIMM_INVALID_ADDR_OFFSET_SIZE = NVDIMM_COMP_ID | 0x07, + NVDIMM_OVERFLOW_ERROR = NVDIMM_COMP_ID | 0x08, + NVDIMM_I2C_WRITE_PAGE_SIZE_ZERO = NVDIMM_COMP_ID | 0x09, + NVDIMM_INVALID_OFFSET = NVDIMM_COMP_ID | 0x0A, + NVDIMM_READ_FAILURE = NVDIMM_COMP_ID | 0x0B, // NV Controller read failure + NVDIMM_WRITE_FAILURE = NVDIMM_COMP_ID | 0x0C, // NV Controller write failure + NVDIMM_BACKUP_TIMEOUT = NVDIMM_COMP_ID | 0x0D, // Backup/save timeout + NVDIMM_RESTORE_TIMEOUT = NVDIMM_COMP_ID | 0x0E, // Restore timeout + NVDIMM_ERASE_TIMEOUT = NVDIMM_COMP_ID | 0x0F, // Erase timeout + NVDIMM_CHARGE_TIMEOUT = NVDIMM_COMP_ID | 0x10, // Battery charging timeout + NVDIMM_ARM_TIMEOUT = NVDIMM_COMP_ID | 0x11, // Arming timeout + NVDIMM_SET_ES_ERROR = NVDIMM_COMP_ID | 0x12, // Failure to set the ES policy + NVDIMM_MSS_STR_ENTRY_ERROR = NVDIMM_COMP_ID | 0x13, // Failure to enter STR + NVDIMM_MSS_STR_EXIT_ERROR = NVDIMM_COMP_ID | 0x14, // Failure to exit STR + NVDIMM_MSS_POST_RSTR_ERROR = NVDIMM_COMP_ID | 0x15, // Failure to perform post restore work + NVDIMM_OPEN_PAGE_TIMEOUT = NVDIMM_COMP_ID | 0x16, // Open page timeout + NVDIMM_STATUS_TIMEOUT = NVDIMM_COMP_ID | 0x17, // Status timeout + NVDIMM_ARM_FAILED = NVDIMM_COMP_ID | 0x18, // Failure to arm reset_n + NVDIMM_ERASE_FAILED = NVDIMM_COMP_ID | 0x19, // Failure to erase + NVDIMM_RESTORE_FAILED = NVDIMM_COMP_ID | 0x1A, // Failure to restore + NVDIMM_NOT_READY = NVDIMM_COMP_ID | 0x1B, // NVDIMM not ready for host to access + NVDIMM_NULL_FIRMWARE_REQUEST_PTR = NVDIMM_COMP_ID | 0x1C, // Firmware request is NULL + NVDIMM_UNSUPPORTED_NVDIMM_TYPE = NVDIMM_COMP_ID | 0x1D, // Unsupported NVDIMM type for update + NVDIMM_OPERATION_IN_PROGRESS = NVDIMM_COMP_ID | 0x1E, // NV controller is busy + NVDIMM_CHECKSUM_ERROR = NVDIMM_COMP_ID | 0x1F, // Checksum error between host and nv calculated + NVDIMM_ZERO_TOTAL_REGIONS = NVDIMM_COMP_ID | 0x20, // Zero write regions calculated + NVDIMM_UPDATE_MODE_UNCHANGED = NVDIMM_COMP_ID | 0x21, // Unable to change update mode + NVDIMM_FW_OPS_IN_PROGRESS_TIMEOUT = NVDIMM_COMP_ID | 0x22, // Operations In Progress timeout + NVDIMM_DATA_SIZE_TOO_LARGE = NVDIMM_COMP_ID | 0x23, // Trying to write too much data + NVDIMM_DATA_SIZE_INVALID = NVDIMM_COMP_ID | 0x24, // Data size is invalid + NVDIMM_BLOCK_NOT_RECEIVED = NVDIMM_COMP_ID | 0x25, // Block data not received + NVDIMM_FW_OPS_NOT_SUCCESSFUL = NVDIMM_COMP_ID | 0x26, // Unsuccessful Firmware Operation + NVDIMM_UPDATE_NOT_SUPPORTED = NVDIMM_COMP_ID | 0x27, // NV controller cannot be updated + NVDIMM_START_UPDATE = NVDIMM_COMP_ID | 0x28, // start update + NVDIMM_UPDATE_COMPLETE = NVDIMM_COMP_ID | 0x29, // update completed + NVDIMM_TPM_NOT_FOUND = NVDIMM_COMP_ID | 0x2A, // TPM not found + NVDIMM_POWER_SAVE_FAILURE = NVDIMM_COMP_ID | 0x2B, // Save failed due to power loss + NVDIMM_CSAVE_ERROR = NVDIMM_COMP_ID | 0x2C, // CSave failed due to error + NVDIMM_VOLTAGE_REGULATOR_FAILED = NVDIMM_COMP_ID | 0x2D, + NVDIMM_VDD_LOST = NVDIMM_COMP_ID | 0x2E, + NVDIMM_VPP_LOST = NVDIMM_COMP_ID | 0x2F, + NVDIMM_VTT_LOST = NVDIMM_COMP_ID | 0x30, + NVDIMM_DRAM_NOT_SELF_REFRESH = NVDIMM_COMP_ID | 0x31, + NVDIMM_CONTROLLER_HARDWARE_ERROR = NVDIMM_COMP_ID | 0x32, + NVDIMM_NVM_CONTROLLER_ERROR = NVDIMM_COMP_ID | 0x33, + NVDIMM_NVM_LIFETIME_ERROR = NVDIMM_COMP_ID | 0x34, + NVDIMM_NOT_ENOUGH_ENERGY_FOR_CSAVE = NVDIMM_COMP_ID | 0x35, + NVDIMM_INVALID_FIRMWARE_ERROR = NVDIMM_COMP_ID | 0x36, // Module Health Status Registers + NVDIMM_CONFIG_DATA_ERROR = NVDIMM_COMP_ID | 0x37, + NVDIMM_NO_ES_PRESENT = NVDIMM_COMP_ID | 0x38, + NVDIMM_ES_POLICY_NOT_SET = NVDIMM_COMP_ID | 0x39, + NVDIMM_ES_HARDWARE_FAILURE = NVDIMM_COMP_ID | 0x3A, + NVDIMM_ES_HEALTH_ASSESSMENT_ERROR = NVDIMM_COMP_ID | 0x3B, + NVDIMM_ES_LIFETIME_ERROR = NVDIMM_COMP_ID | 0x3C, + NVDIMM_ES_TEMP_ERROR = NVDIMM_COMP_ID | 0x3D, + NVDIMM_SET_EVENT_NOTIFICATION_ERROR = NVDIMM_COMP_ID | 0x3E, + NVDIMM_VERIF_BYTE_CHECK_FAILED = NVDIMM_COMP_ID | 0x3F, // Encryption key reg verif failed + NVDIMM_ENCRYPTION_ENABLE_FAILED = NVDIMM_COMP_ID | 0x40, // Encryption enable failed + NVDIMM_ENCRYPTION_ERASE_PENDING_FAILED = NVDIMM_COMP_ID | 0x41, // Encryption crypto erase pending failed + NVDIMM_ENCRYPTION_ERASE_FAILED = NVDIMM_COMP_ID | 0x42, // Encryption crypto erase failed + NVDIMM_ENCRYPTION_UNLOCK_FAILED = NVDIMM_COMP_ID | 0x43, // Encryption unlock failed + NVDIMM_ENCRYPTION_INVALID_ATTRIBUTE = NVDIMM_COMP_ID | 0x44, // Encryption attribute key data invalid + NVDIMM_ENCRYPTION_KEY_ATTRS_INVALID = NVDIMM_COMP_ID | 0x45, // Encryption key attributes are both invalid + NVDIMM_ENCRYPTION_MAX_DARN_ERRORS = NVDIMM_COMP_ID | 0x46, // Darn random key gen reached max errors + NVDIMM_ENCRYPTION_BAD_RANDOM_DATA = NVDIMM_COMP_ID | 0x47, // Generated key data not valid + NVDIMM_CANNOT_MAKE_ATTRIBUTE = NVDIMM_COMP_ID | 0x48, // Cannot make Attribute + NVDIMM_ES_HEALTH_CHECK_IN_PROGRESS_FAILURE = NVDIMM_COMP_ID | 0x49, // !< pertains to ES_CMD_STATUS0[0]; the ES health check in progress flag + NVDIMM_ES_HEALTH_CHECK_REPORTED_FAILURE = NVDIMM_COMP_ID | 0x4A, // !< pertains to ES_CMD_STATUS0[2]; the ES health check reported a failure flag + NVDIMM_ES_LIFETIME_MIN_REQ_NOT_MET = NVDIMM_COMP_ID | 0x4B, // !< pertains to ES_LIFETIME; BPM does not meet minimum requirement for a new BPM + NVDIMM_ES_HEALTH_CHECK_NEVER_INITIATED = NVDIMM_COMP_ID | 0x4C, // !< An ES health check was never initiated at start of IPL + NVDIMM_NVM_HEALTH_CHECK_FAILED = NVDIMM_COMP_ID | 0x4D, // !< An NVM health check on the NVDIMM failed + NVDIMM_VENDOR_LOG_TIMEOUT = NVDIMM_COMP_ID | 0x4E, // Vendor log for FFDC timeout + NVDIMM_VENDOR_LOG_CKSUM_FAILED = NVDIMM_COMP_ID | 0x4F, // Vendor log for FFDC checksum fail + NVDIMM_INVALID_FW_SLOT = NVDIMM_COMP_ID | 0x50, + NVDIMM_ERASE_ERROR = NVDIMM_COMP_ID | 0x51, + NVDIMM_ARM_PRE_CHECK_FAILED = NVDIMM_COMP_ID | 0x52, + NVDIMM_ARM_ENCRYPTION_UNLOCK_FAILED = NVDIMM_COMP_ID | 0x53, + NVDIMM_ARM_RETRY = NVDIMM_COMP_ID | 0x54, + NVDIMM_CLEAR_FW_OPS_STATUS_TIMEOUT = NVDIMM_COMP_ID | 0x55, // Failed to clear FW_OPS_STATUS + NVDIMM_NOT_RUNNING_LATEST_LEVEL = NVDIMM_COMP_ID | 0x56, // Either running from slot 0 or level was not updated + NVDIMM_ERASE_VERIFY_STATUS_NONZERO = NVDIMM_COMP_ID | 0x57, + NVDIMM_ERASE_VERIFY_RESULT_NONZERO = NVDIMM_COMP_ID | 0x58, }; enum UserDetailsTypes { NVDIMM_UDT_NO_FORMAT = 0x0, NVDIMM_UDT_PARAMETERS = 0x1, + NVDIMM_OP_PARAMETERS = 0x2, }; }; // end NVDIMM diff --git a/src/include/usr/isteps/pm/occAccess.H b/src/include/usr/isteps/pm/occAccess.H index a5b46ff45..f8c3ea8c7 100644 --- a/src/include/usr/isteps/pm/occAccess.H +++ b/src/include/usr/isteps/pm/occAccess.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2017 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -25,7 +25,6 @@ #ifndef OCCACCESS_H_ #define OCCACCESS_H_ -#include <config.h> #include <errl/errlentry.H> #include <targeting/common/commontargeting.H> diff --git a/src/include/usr/isteps/pm/occCheckstop.H b/src/include/usr/isteps/pm/occCheckstop.H index 026c8db55..edb4b4ab3 100644 --- a/src/include/usr/isteps/pm/occCheckstop.H +++ b/src/include/usr/isteps/pm/occCheckstop.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2017 */ +/* Contributors Listed Below - COPYRIGHT 2014,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -47,6 +47,10 @@ namespace HBOCC NOT_FIR_MASTER = 0x00000000, IS_FIR_MASTER = 0x00000001, + // SMF Mode + SMF_MODE_DISABLED = 0x00000000, + SMF_MODE_ENABLED = 0x00000001, + // SRAM Addresses for OCC Main App and GPE0 app OCC_405_SRAM_ADDRESS = 0xFFF40000, OCC_GPE0_SRAM_ADDRESS = 0xFFF01000, diff --git a/src/include/usr/isteps/pm/pm_common_ext.H b/src/include/usr/isteps/pm/pm_common_ext.H index 307dfbc7f..5c6e3985d 100644 --- a/src/include/usr/isteps/pm/pm_common_ext.H +++ b/src/include/usr/isteps/pm/pm_common_ext.H @@ -52,6 +52,11 @@ namespace HBPM // FIR collection configuration data needed by FIR Master // OCC in the event of a checkstop uint8_t firdataConfig[3072]; + + // For informing OCC if SMF mode is enabled: + // 0x00000000 = Default (SMF disabled) + // 0x00000001 = SMF mode is enabled + uint32_t smfMode; }; /** diff --git a/src/include/usr/isteps/spless_255list.H b/src/include/usr/isteps/spless_255list.H index 074e898d5..c19aa080e 100644 --- a/src/include/usr/isteps/spless_255list.H +++ b/src/include/usr/isteps/spless_255list.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2017 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -38,7 +38,6 @@ #include <initservice/initsvcstructs.H> #include <initservice/initsvcreasoncodes.H> -#include <config.h> /** diff --git a/src/include/usr/mbox/mbox_queues.H b/src/include/usr/mbox/mbox_queues.H index aa2b9a4a8..19c5eeabc 100644 --- a/src/include/usr/mbox/mbox_queues.H +++ b/src/include/usr/mbox/mbox_queues.H @@ -82,6 +82,8 @@ namespace MBOX FSP_TARG_DECONFIG_MSGQ = 0x80000010, FSP_SCOM_OPS_MSGQ = 0x80000011, FSP_OCC_MSGQ_ID = 0x80000012, + FSP_NVDIMM_KEYS_MSGQ_ID = 0x80000013, // Attribute write request, equivalent + // to HWSV's ATTR_WRITE_OP_QUEUE_ID FSP_LID_MSGQ = FSP_ATTR_SYNC_MSGQ, diff --git a/src/include/usr/mmio/mmio_reasoncodes.H b/src/include/usr/mmio/mmio_reasoncodes.H index 86ff60b5b..fb7a059a8 100644 --- a/src/include/usr/mmio/mmio_reasoncodes.H +++ b/src/include/usr/mmio/mmio_reasoncodes.H @@ -36,6 +36,12 @@ namespace MMIO MOD_MMIO_PERFORM_OP = 0x02, MOD_MMIO_GET_PROC_SCOM = 0x03, MOD_MMIO_SET_PROC_SCOM = 0x04, + MOD_VALIDATE_OCMB_MMIO_OP = 0x05, + MOD_MMIO_CHAN_CHECKSTOP = 0x06, + MOD_CHECK_OCMB_ERROR = 0x07, + MOD_DETERMINE_CALLOUTS = 0x08, + MOD_DETERMINE_EXP_CALLOUTS = 0x09, + RT_OCMB_MMIO_PERFORM_OP = 0x0A, }; enum MMIOReasonCode @@ -52,6 +58,8 @@ namespace MMIO RC_BAD_MMIO_WRITE = MMIO_COMP_ID | 0x09, RC_PROC_NOT_FOUND = MMIO_COMP_ID | 0x0A, RC_BAR_OFFSET_MISMATCH = MMIO_COMP_ID | 0x0B, + RC_MMIO_CHAN_CHECKSTOP = MMIO_COMP_ID | 0x0C, + RC_UNSUPPORTED_CHIPID = MMIO_COMP_ID | 0x0D, }; }; diff --git a/src/include/usr/pnor/pnor_const.H b/src/include/usr/pnor/pnor_const.H index 801fa34aa..c975c684c 100644 --- a/src/include/usr/pnor/pnor_const.H +++ b/src/include/usr/pnor/pnor_const.H @@ -27,7 +27,6 @@ #include <stdint.h> #include <builtins.h> -#include <config.h> namespace PNOR { @@ -41,7 +40,6 @@ enum SectionId // Value of HB_EXT_CODE must be 1 for debug framework. #ifndef BOOTLOADER HB_EXT_CODE, /**< Hostboot Extended Image */ - GLOBAL_DATA, /**< Global Data */ #endif HB_BASE_CODE, /**< Hostboot Base Image */ #ifndef BOOTLOADER @@ -77,6 +75,7 @@ enum SectionId HDAT, /**< HDAT data */ EECACHE, OCMBFW, /**< OCMB image */ + BOOTKERNEL, /**< Bootkernel -- HB uses for PHYP */ #endif NUM_SECTIONS, /**< Number of defined sections */ @@ -112,7 +111,8 @@ struct SectionInfo_t reprovision(false), Volatile(false), secure(false), - clearOnEccErr(false) + clearOnEccErr(false), + hasHashTable(false) {} SectionId id; /**< Identifier for this section */ const char* name; /**< Name of the section */ @@ -127,6 +127,7 @@ struct SectionInfo_t bool Volatile; /**< Section loses contents on non HB reboots */ bool secure; /**< Indicates if a section is secure */ bool clearOnEccErr; /**< Indicates on ECC errors, clear and reboot*/ + bool hasHashTable; /**< Indicates if there exists a hash page table*/ size_t secureProtectedPayloadSize; /**< Cache the secure payload size so that the secure container only needs to be parsed once */ diff --git a/src/include/usr/pnor/pnor_reasoncodes.H b/src/include/usr/pnor/pnor_reasoncodes.H index fb7435a33..10c3e7b22 100644 --- a/src/include/usr/pnor/pnor_reasoncodes.H +++ b/src/include/usr/pnor/pnor_reasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -98,8 +98,7 @@ namespace PNOR MOD_PNORCOMMON_PARSETOC = 0xC0, /**< PNOR::parseTOC */ // spnorrp.C - // Note: 0xD0 is available, so should be the next one used for spnorrp. - // Remove this comment after doing so. + MOD_SPNORRP_VERIFY_PAGE = 0xD0, /**< SPnorRP::verify_page */ MOD_SPNORRP_DIDSTARTUPFAIL = 0xD1, /**< didSecureStartupFail(rc) */ MOD_SPNORRP_ALLOCATE_BLOCK = 0xD2, /**< SPnorRP::initDaemon */ MOD_SPNORRP_WAITFORMESSAGE = 0xD3, /**< SPnorRP::waitForMessage */ @@ -192,7 +191,7 @@ namespace PNOR RC_NOT_PAGE_ALIGNED = PNOR_COMP_ID | 0x3B, RC_SECURE_PRO_SIZE_MISMATCH = PNOR_COMP_ID | 0x3C, RC_READ_ONLY_PERM_FAIL = PNOR_COMP_ID | 0x3D, - + RC_VERIFY_PAGE_FAILED = PNOR_COMP_ID | 0x3E, //@fixme-RTC:131607-Temporary value to allow HWSV compile //termination_rc RC_PNOR_CORRUPTION = PNOR_COMP_ID | 0x99, diff --git a/src/include/usr/pnor/pnorif.H b/src/include/usr/pnor/pnorif.H index 11cc98a10..9a2fb39fc 100644 --- a/src/include/usr/pnor/pnorif.H +++ b/src/include/usr/pnor/pnorif.H @@ -31,7 +31,6 @@ #include <pnor/pnor_const.H> #include <errl/errlentry.H> #include <utility> -#include <config.h> namespace PNOR { @@ -269,7 +268,6 @@ bool cmpSecurebootMagicNumber(const uint8_t* i_vaddr); * False otherwise. */ bool isSectionEmpty(const PNOR::SectionId i_section); - } // PNOR #endif diff --git a/src/include/usr/runtime/customize_attrs_for_payload.H b/src/include/usr/runtime/customize_attrs_for_payload.H index a5158f996..6d6928bda 100644 --- a/src/include/usr/runtime/customize_attrs_for_payload.H +++ b/src/include/usr/runtime/customize_attrs_for_payload.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,7 @@ */ #include <errl/errlentry.H> -#include <runtime/rt_targeting.H> +#include <targeting/runtime/rt_targeting.H> #include <targeting/common/attributes.H> namespace RUNTIME @@ -42,7 +42,7 @@ namespace RUNTIME static const TARGETING::ATTR_HBRT_HYP_ID_type HBRT_HYP_ID_UNKNOWN = 0xFFFFFFFFFFFFFFFFULL; -static const RT_TARG::rtChipId_t RT_TYPE_UNKNOWN +static const TARGETING::rtChipId_t RT_TYPE_UNKNOWN = 0xFFFFFFFFFFFFFFFFULL; /** diff --git a/src/include/usr/runtime/runtime.H b/src/include/usr/runtime/runtime.H index 9d22e387b..eba9f68bf 100644 --- a/src/include/usr/runtime/runtime.H +++ b/src/include/usr/runtime/runtime.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -188,7 +188,7 @@ errlHndl_t sendSBESystemConfig(); // HOMER*8/OCC_Common/VPD/ATTR/HBRT_Image/Res/Res/Res // should be the same as HDAT_RHB_MAX_RANGE_ENTRIES_PER_NODE in // src/hdat/fsp/hdat.H -#define HB_RSV_MEM_NUM_PTRS 50 +#define HB_RSV_MEM_NUM_PTRS 60 //Note this means the Reserved Mem sub-section is the 6th //(0 based) of the MDT section (See HDAT spec 11.1.1) diff --git a/src/include/usr/runtime/runtime_reasoncodes.H b/src/include/usr/runtime/runtime_reasoncodes.H index 6b77d621a..8bc4c858d 100644 --- a/src/include/usr/runtime/runtime_reasoncodes.H +++ b/src/include/usr/runtime/runtime_reasoncodes.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2018 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -66,6 +66,10 @@ namespace RUNTIME MOD_CHECK_HB_RES_MEM_LIMIT = 0x26, /**< populate_hbruntime.C */ MOD_INIT_RT_RES_MEM_TRACE_BUF = 0x27, /**< rt_rsvdtracebuffer.C */ MOD_OPEN_UNTRUSTED_SP_AREAS = 0x28, /**< populate_hbruntime.C */ + MOD_SEND_ATTRIBUTES_TO_FSP = 0x29, /**< hbrt_utilities.H */ + MOD_RT_DO_NVDIMM_OP = 0x2A, /**< rt_fwnotify.C */ + SET_ATTR_NVDIMM_ENCRYPTION_ENABLE = 0x2B, /**< rt_fwnotify.C */ + MOD_CONFIGURE_HBRT_HYP_IDS = 0x2C, }; enum RuntimeReasonCode @@ -139,6 +143,13 @@ namespace RUNTIME RC_SP_ATTN_AREA_OVERFLOW = RUNTIME_COMP_ID | 0x42, RC_SP_ATTN_AREA1_SIZE_OVERFLOW = RUNTIME_COMP_ID | 0x43, RC_UNKNOWN_LABEL = RUNTIME_COMP_ID | 0x44, + RC_NULL_FIRMWARE_MSG_PTR = RUNTIME_COMP_ID | 0x45, + RC_SERIALIZE_ATTRIBUTE_FAILED = RUNTIME_COMP_ID | 0x46, + RC_NO_SPACE_FOR_ATTRIBUTE_SERIALIZATION = RUNTIME_COMP_ID | 0x47, + RC_CANNOT_MAKE_ATTRIBUTE = RUNTIME_COMP_ID | 0x48, + RT_NO_OMI_TARGET_FOUND = RUNTIME_COMP_ID | 0x49, + RC_LOG_GARD_EVENT_UNKNOWN_ERROR_TYPE = RUNTIME_COMP_ID | 0x4A, + RC_LOG_GARD_EVENT = RUNTIME_COMP_ID | 0x4B, }; enum UserDetailsTypes diff --git a/src/include/usr/sbeio/runtime/sbe_msg_passing.H b/src/include/usr/sbeio/runtime/sbe_msg_passing.H index e50b4493e..e280e3e2f 100644 --- a/src/include/usr/sbeio/runtime/sbe_msg_passing.H +++ b/src/include/usr/sbeio/runtime/sbe_msg_passing.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2017,2018 */ +/* Contributors Listed Below - COPYRIGHT 2017,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -90,6 +90,7 @@ namespace SBE_MSG PASSTHRU_HBRT_GET_PSTATE = 0x00E10001, // HBRT Get PState Table PASSTHRU_HBRT_OVERRIDE_ATTR = 0x00E10002, // HBRT Apply Override // attributes + PASSTHRU_HBRT_NVDIMM_OP = 0x00E10003, // HBRT NVDIMM operation }; diff --git a/src/include/usr/sbeio/runtime/sbeio_nvdimm_operation.H b/src/include/usr/sbeio/runtime/sbeio_nvdimm_operation.H new file mode 100644 index 000000000..2b650bfae --- /dev/null +++ b/src/include/usr/sbeio/runtime/sbeio_nvdimm_operation.H @@ -0,0 +1,58 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/sbeio/runtime/sbeio_nvdimm_operation.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2017,2019 */ +/* [+] 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 */ +#ifndef __SBE_MSG_SBEIO_NVDIMM_OPERATION_H +#define __SBE_MSG_SBEIO_NVDIMM_OPERATION_H + +#include <errl/errlentry.H> +#include <targeting/common/target.H> + +namespace SBE_MSG +{ + +/** + * @brief SBE pass-through command for executing nvdimm operations at runtime. + * This command acts as a bridge between sbe pass-through and the + * runtime doNvDimmOperation function. + * + * @param[in] i_targetHandle - The target of the request. + * @param[in] i_reqDataSize - Size of the nvdimm operation blob. + * @param[in] i_reqData - NVDIMM operation data. + * @param[out] o_rspStatus - The return value from doNvDimmOperation + * @param[out] o_rspDataSize - Set to 0 on return. + * @param[out] o_rspData - Not Used. + * + * @return nullptr upon success, pointer to ErrlEntry if an error occurred. + * + */ +errlHndl_t sbeNvdimmOperation( TARGETING::TargetHandle_t i_targetHandle, + uint32_t i_reqDataSize, + uint8_t * i_reqData, + uint32_t * o_rspStatus, + uint32_t * o_rspDataSize, + uint8_t * o_rspData ); + +} + +#endif diff --git a/src/include/usr/sbeio/sbe_psudd.H b/src/include/usr/sbeio/sbe_psudd.H index 3a21ad122..688c9086b 100644 --- a/src/include/usr/sbeio/sbe_psudd.H +++ b/src/include/usr/sbeio/sbe_psudd.H @@ -338,7 +338,7 @@ class SbePsu */ enum psuSecurityListBinDumpNonReservedMsgs { - SBE_SECURITY_LIST_BIN_DUMP_REQ_USED_REGS = 0x01, + SBE_SECURITY_LIST_BIN_DUMP_REQ_USED_REGS = 0x03, SBE_SECURITY_LIST_BIN_DUMP_RSP_USED_REGS = 0x01, }; diff --git a/src/include/usr/scom/centaurScomCache.H b/src/include/usr/scom/centaurScomCache.H index 94f345694..0817ae11e 100644 --- a/src/include/usr/scom/centaurScomCache.H +++ b/src/include/usr/scom/centaurScomCache.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2011,2018 */ +/* Contributors Listed Below - COPYRIGHT 2011,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -42,11 +42,6 @@ extern trace_desc_t* g_trac_scom; -// These defines allow standard logging of error information in traces -#define TRACE_ERR_FMT "Error info: PLID=0x%08X, EID=0x%08X, Reason=0x%04X. " -#define TRACE_ERR_ARGS(pError) \ - ERRL_GETPLID_SAFE(pError), ERRL_GETEID_SAFE(pError), ERRL_GETRC_SAFE(pError) - namespace SECUREBOOT { diff --git a/src/include/usr/secureboot/drtm.H b/src/include/usr/secureboot/drtm.H index e061502ae..345407f81 100644 --- a/src/include/usr/secureboot/drtm.H +++ b/src/include/usr/secureboot/drtm.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2017 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -27,7 +27,6 @@ #define __SECUREBOOT_DRTM_H #include <initservice/mboxRegs.H> -#include <config.h> #include <errl/errlentry.H> #include <errl/errlmanager.H> #include <vector> diff --git a/src/include/usr/secureboot/nodecommif.H b/src/include/usr/secureboot/nodecommif.H index cd445d7c9..9dec0605c 100644 --- a/src/include/usr/secureboot/nodecommif.H +++ b/src/include/usr/secureboot/nodecommif.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2018 */ +/* Contributors Listed Below - COPYRIGHT 2018,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,7 +26,6 @@ #define __NODECOMMIF_H #include <initservice/mboxRegs.H> -#include <config.h> #include <errl/errlentry.H> namespace SECUREBOOT diff --git a/src/include/usr/secureboot/phys_presence_if.H b/src/include/usr/secureboot/phys_presence_if.H new file mode 100644 index 000000000..a723e8726 --- /dev/null +++ b/src/include/usr/secureboot/phys_presence_if.H @@ -0,0 +1,68 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/secureboot/phys_presence_if.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019 */ +/* [+] 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 */ +/** + * @file phys_presence_if.H + * + * @brief Interfaces to Detect and Open Physical Presence Windows + * + */ +#ifndef __PHYS_PRESENCE_H +#define __PHYS_PRESENCE_H +// ----------------------------------------------- +// Includes +// ----------------------------------------------- + +#include <errl/errlentry.H> +#include <targeting/common/commontargeting.H> +#include <config.h> + +namespace SECUREBOOT +{ + /** + * @brief Checks if the Physical Presence Window was opened and if + * Physical Presence was asserted. + * + * @post Will ensure the window is closed at the end of the function + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ + errlHndl_t detectPhysPresence(void); + + /** + * @brief Handle Physical Presence Window first checks to see if a physical + * presence window should be opened. Then, if necessary, it sets up + * the physical presence detect circuit and then shuts down the + * system. + * + * @post If successful, this function will shutdown the system + * + * @return errlHndl_t nullptr on success; non-nullptr on error. + */ + errlHndl_t handlePhysPresenceWindow(void); + +} // namespace SECUREBOOT + + +#endif // __PHYS_PRESENCE_H diff --git a/src/include/usr/secureboot/secure_reasoncodes.H b/src/include/usr/secureboot/secure_reasoncodes.H index d121fc7b9..9e0e52c6e 100644 --- a/src/include/usr/secureboot/secure_reasoncodes.H +++ b/src/include/usr/secureboot/secure_reasoncodes.H @@ -53,7 +53,7 @@ namespace SECUREBOOT MOD_CHECK_RISK_LEVEL_FOR_SMF = 0x13, MOD_SMF_SPLIT_SMF_MEM = 0x14, - // Use 0x20-0x2F range for Node Communications + // Use 0x20-0x3F range for Node Communications MOD_NCDD_CHECK_FOR_ERRORS = 0x20, MOD_NCDD_WAIT_FOR_CMD_COMP = 0x21, MOD_NC_XBUS_TEST = 0x22, @@ -70,7 +70,12 @@ namespace SECUREBOOT MOD_NC_PROCESS_SLAVE_QUOTE = 0x2D, MOD_NCT_SEND = 0x2E, MOD_NCT_RECEIVE = 0x2F, - }; + + // Use 0x40-0x4F range for Physical Presence Detection + MOD_PHYS_PRES_DETECT = 0x40, + MOD_PHYS_PRES_OPEN_WINDOW = 0x41, + + }; enum SECUREReasonCode { @@ -123,6 +128,16 @@ namespace SECUREBOOT RC_NCT_INITIATION_MISMATCH = SECURE_COMP_ID | 0x33, RC_NCEX_NO_FUNCTIONAL_PRIMARY_TPM = SECURE_COMP_ID | 0x34, + // Use 0x20-0x3F range for Node Communications + + // RC_PHYS_PRES_WINDOW_OPENED_SHUTDOWN Must have one unique use + // for Shutdown path since FSP relies on it. + // termination_rc + RC_PHYS_PRES_WINDOW_OPENED_SHUTDOWN = SECURE_COMP_ID | 0x40, + RC_PHYS_PRES_ATTR_NOT_FOUND = SECURE_COMP_ID | 0x41, + RC_PHYS_PRES_WINDOW_NOT_CLOSED = SECURE_COMP_ID | 0x42, + RC_PHYS_PRES_WINDOW_NOT_OPENED = SECURE_COMP_ID | 0x43, + // Reason codes 0xA0 - 0xEF reserved for trustedboot_reasoncodes.H }; diff --git a/src/include/usr/secureboot/service.H b/src/include/usr/secureboot/service.H index bb6ea1516..2a01cdd6b 100644 --- a/src/include/usr/secureboot/service.H +++ b/src/include/usr/secureboot/service.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2018 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,7 +26,6 @@ #define __SECUREBOOT_SERVICE_H #include <errl/errlentry.H> -#include <config.h> #include <secureboot/settings.H> #include <utility> #include <cstdint> diff --git a/src/include/usr/secureboot/trustedbootif.H b/src/include/usr/secureboot/trustedbootif.H index 66d44852e..16da54c03 100644 --- a/src/include/usr/secureboot/trustedbootif.H +++ b/src/include/usr/secureboot/trustedbootif.H @@ -41,7 +41,6 @@ #include <secureboot/containerheader.H> #include <targeting/common/commontargeting.H> #include <targeting/common/utilFilter.H> -#include <config.h> namespace TRUSTEDBOOT { diff --git a/src/include/usr/targeting/common/attributeTank.H b/src/include/usr/targeting/common/attributeTank.H index a3f9afeab..1a4c5a4ce 100644 --- a/src/include/usr/targeting/common/attributeTank.H +++ b/src/include/usr/targeting/common/attributeTank.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2017 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -34,13 +34,12 @@ #include <stdint.h> #include <list> #include <vector> +#include <attributeenums.H> // TARGETING::ATTRIBUTE_ID #ifndef STANDALONE_COMPILE #include <targeting/adapters/mutexadapter.H> #include <targeting/common/error.H> namespace TARGETING { - - /** * @class AttributeTank * @@ -146,6 +145,328 @@ namespace AttributeTank #ifndef STANDALONE_COMPILE /** + * @struct Attribute + * + * This structure defines a single attribute. + */ + struct Attribute + { + /** + * @brief Constructor + */ + Attribute() + : iv_hdr(), + iv_pVal(NULL) + { + } + + /** + * @brief Destructor. Frees memory + */ + ~Attribute() + { + delete[] iv_pVal; + iv_pVal = NULL; + } + + /** + * @brief Set the Attribute ID + */ + void setId(const uint32_t i_attrId) + { + iv_hdr.iv_attrId = i_attrId; + } + + /** + * @brief Set the Attribute Target Type + */ + void setTargetType(const uint32_t i_targetType) + { + iv_hdr.iv_targetType = i_targetType; + } + + /** + * @brief Set the Attribute Position + */ + void setPosition(const uint16_t i_pos) + { + iv_hdr.iv_pos = i_pos; + } + + /** + * @brief Set the Attribute Unit Position + */ + void setUnitPosition(const uint8_t i_unitPos) + { + iv_hdr.iv_unitPos = i_unitPos; + } + + /** + * @brief Set the Attribute Node + */ + void setNode(const uint8_t i_node) + { + iv_hdr.iv_node = i_node; + } + + /** + * @brief Set the Attribute Flags + */ + void setFlags(const uint8_t i_flags) + { + iv_hdr.iv_flags = i_flags; + } + + /** + * @brief Get the size of all the Attribute's data members, + * aggregated together + * + * return Aggregated size of the Attribute's data members + */ + uint32_t getSize() const + { + return (sizeof(iv_hdr) + iv_hdr.iv_valSize); + } + + /** + * @brief Get a constant reference to the Attribute Header. + * Returning a reference for fast retrieval. + * + * @note Caller should not attempt to modify contents of the + * Attribute Header. Use appropriate Attribute set methods + * + * return A constant reference to the Attribute Header + */ + const AttributeHeader & getHeader() const + { + return iv_hdr; + } + + /** + * @brief Set the Attribute Value to a copy of the given buffer + * + * @pre Passing in nonsensical parameters will produce unpredictable + * results, ie passing in a null buffer with size > 0 + * + * @note Passing in a null buffer with size 0 will clear the value + * + * @param[in] i_buffer The buffer that contains the value to + * be copied + * @param[in] i_bufferSize Size of the given buffer + * + * return The size of the data that was copied + */ + uint32_t setValue(const void * const i_buffer, + const uint32_t i_bufferSize) + + { + // Reuse storage when possible + if (i_bufferSize != iv_hdr.iv_valSize) + { + // Clean up current Attribute Value + delete []iv_pVal; + iv_pVal = NULL; + + // Set size and allocate memory space + iv_hdr.iv_valSize = i_bufferSize; + if (iv_hdr.iv_valSize) + { + iv_pVal = new uint8_t[iv_hdr.iv_valSize]; + } + } + + // Make a copy of the data. Passing in a size of 0 + // or NULL turns this call to no-op + memcpy(iv_pVal, i_buffer, iv_hdr.iv_valSize); + + return iv_hdr.iv_valSize; + } + + /** + * @brief Get a constant pointer to the Attribute Value. + * Returning a constant pointer for fast retrieval. + * + * @note Caller should not attempt to modify the contents nor + * delete the pointer, use method setValue if + * need be. + * + * return A constant pointer to the Attribute Value + */ + const void* getValue() const + { + return iv_pVal; + } + + /** + * @brief Return a copy of the Attribute Value into caller's bufffer + * + * @param[in] i_buffer The buffer to copy Attribute Value into + * @param[in] i_bufferSize Size of the given buffer + * + * return The size of the Attribute Value that was copied + * or 0 if unable to copy the Attribute Value - buffer + * size to small will cause this + */ + uint32_t cloneValue(void* const o_buffer, + const uint32_t i_bufferSize) const + { + // Return the size of the cloned data + uint32_t l_attributeValueSize(0); + + // Is the buffer large enough to contain the Attribute Value? + if (i_bufferSize >= iv_hdr.iv_valSize) + { + // Buffer is large enough to contain the Attribute Value - + // copy the Attribute Value to given buffer + memcpy(o_buffer, iv_pVal, iv_hdr.iv_valSize); + + // Return the size of the cloned data + l_attributeValueSize = iv_hdr.iv_valSize; + } + + return l_attributeValueSize; + } + + /** + * @brief Serialize the Attribute, if the buffer given is large + * enough to contain the Attribute's data members + * + * @param[out] o_buffer The buffer to contain the serialized + * data members + * @param[in] i_bufferSize Size of the given buffer + * + * return 0 if buffer is to small to contain the data members; + * otherwise the aggregated size of the Attribute's data + * members copied + */ + uint32_t serialize(void* const o_buffer, + const uint32_t i_bufferSize) const + { + // Return the size of the serialized data + uint32_t l_attributeSize(0); + + // If buffer size greater than or equal to the size of the + // Attribute's data members aggregated together then + // copy the data members to buffer + if (i_bufferSize >= getSize()) + { + // Get an Attribute handle to buffer for easy access + uint8_t* l_attribute = static_cast<uint8_t*>(o_buffer); + + // Copy the Attribute Header + memcpy(l_attribute, &iv_hdr, sizeof(iv_hdr)); + l_attribute += sizeof(iv_hdr); + + // Copy the Attribute Value + memcpy(l_attribute, iv_pVal, iv_hdr.iv_valSize); + + // Return the size of the serialized data + l_attributeSize = sizeof(iv_hdr) + iv_hdr.iv_valSize; + } + + return l_attributeSize; + } + + /** + * @brief Deserialize the buffer, if the buffer given is at least + * the same size as an Attribute + * + * @param[out] i_buffer The buffer to deserialize + * @param[in] i_bufferSize Size of the given buffer + * + * @post If the buffer is large enough to populate the Attribute, then + * the Attribute will be populated, with it's own copy of the + * data. If the buffer is too small, then the Attribute is + * untouched. + * + * return 0 if buffer is to small to populate an Attribute; + * otherwise the aggregated size of the Attribute's data + * members deserialized + */ + uint32_t deserialize(const void* const i_buffer, + const uint32_t i_bufferSize) + { + // Return the size of the Attribute + uint32_t l_attributeSize(0); + + // Get an Attribute handle to buffer for easy access + const Attribute* const l_attribute = + reinterpret_cast<const Attribute* const>(i_buffer); + + // Get the minimum size needed to check for values + uint32_t l_attributeHeaderSize(sizeof(iv_hdr)); + + // Make sure the buffer is not just large enough to inspect the + // Attribute Header but large enough to read Values if they exist + // Need to make sure size is at minimum threshold before calling + // getSize(), because getSize assumes the data is there to read + if ( (i_bufferSize >= l_attributeHeaderSize) && + (i_bufferSize >= (l_attribute->getSize())) ) + { + // Get an uint8_t handle to buffer for easy access + const uint8_t* l_attributeData = + reinterpret_cast<const uint8_t*>(i_buffer); + + // Copy header data + memcpy(&iv_hdr, l_attributeData, l_attributeHeaderSize); + + // Free iv_pVal data, if it currently has data, and set to NULL + delete []iv_pVal; // OK to delete a NULL ptr + iv_pVal = NULL; + + // Populate values if they exist + uint32_t l_valueSize = iv_hdr.iv_valSize; + if (l_valueSize) + { + // Copy the Attribute Value + iv_pVal = new uint8_t[l_valueSize]; + l_attributeData += l_attributeHeaderSize; + memcpy(iv_pVal, l_attributeData, l_valueSize); + } + + // Return the size of the Attribute + l_attributeSize = getSize(); + } + + return l_attributeSize; + } + + + /** + * @brief Assignment operator defined + */ + Attribute& operator=(const Attribute& rhs) + { + // check for self-assignment + if (&rhs != this) + { + // Deep copy the attribute value + setValue(rhs.iv_pVal, rhs.iv_hdr.iv_valSize); + // Copy the Attribute header + iv_hdr = rhs.iv_hdr; + } + + return *this; + } + + /** + * @brief Copy constructor defined + */ + Attribute(const Attribute& rhs) + : iv_hdr(), + iv_pVal(NULL) + { + // Call the assignment operator to do the work + *this = rhs; + } + + // Private data + private: + AttributeHeader iv_hdr; + uint8_t * iv_pVal; // Pointer to attribute value + }; + + /** * @struct AttributeSerializedChunk * * This structure defines a chunk of memory for containing serialized @@ -183,7 +504,7 @@ namespace AttributeTank /** * @brief Destructor. Deletes all Attributes */ - virtual ~AttributeTank(); + ~AttributeTank(); /** * @brief Checks if the platform has enabled synchronization @@ -209,9 +530,8 @@ namespace AttributeTank * specific node (i_node) * @param[in] i_node See i_nodeFilter */ - virtual void clearAllAttributes( - const NodeFilter i_nodeFilter = NODE_FILTER_NONE, - const uint8_t i_node = ATTR_NODE_NA); + void clearAllAttributes(const NodeFilter i_nodeFilter = NODE_FILTER_NONE, + const uint8_t i_node = ATTR_NODE_NA); /** * @brief Clear any non-const attribute for a specified ID and Target @@ -225,11 +545,11 @@ namespace AttributeTank * @param[in] i_unitPos Target Unit Position * @param[in] i_node Target Node */ - virtual void clearNonConstAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node); + void clearNonConstAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node); /** * @brief Set an Attribute @@ -251,14 +571,14 @@ namespace AttributeTank * @param[in] i_valSize Size of attribute value in bytes * @param[in] i_pVal Pointer to attribute value */ - virtual void setAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node, - const uint8_t i_flags, - const uint32_t i_valSize, - const void * i_pVal); + void setAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node, + const uint8_t i_flags, + const uint32_t i_valSize, + const void * i_pVal); /** * @brief Get a copy of an Attribute @@ -266,21 +586,24 @@ namespace AttributeTank * This is called on an OverrideAttributeTank to query/get an Attribute * Override when an attribute is got * + * @note Caller's responsibility to ensure the passed in buffer + * is large enough to contain the Attribute Value. + * * @param[in] i_attrId Attribute ID * @param[in] i_targetType Target Type attribute is for * @param[in] i_pos Target Position * @param[in] i_unitPos Target Unit Position * @param[in] i_node Target Node - * @param[out] o_pVal Pointer to attribute value + * @param[out] o_pVal Pointer to a copy of the attribute value * * return true if attribute exists and a copy was written to o_pVal */ - virtual bool getAttribute(const uint32_t i_attrId, - const uint32_t i_targetType, - const uint16_t i_pos, - const uint8_t i_unitPos, - const uint8_t i_node, - void * o_pVal) const; + bool getAttribute(const uint32_t i_attrId, + const uint32_t i_targetType, + const uint16_t i_pos, + const uint8_t i_unitPos, + const uint8_t i_node, + void * o_pVal) const; /** * @brief Serialize all Attributes into newly allocated memory chunks @@ -310,7 +633,7 @@ namespace AttributeTank * specific node (i_node) * @param[in] i_node See i_nodeFilter */ - virtual void serializeAttributes( + void serializeAttributes( const AllocType i_allocType, const uint32_t i_chunkSize, std::vector<AttributeSerializedChunk> & o_attributes, @@ -327,8 +650,7 @@ namespace AttributeTank * @param[in] i_attributes Reference to AttributeSerializedChunk containing * attributes. */ - virtual void deserializeAttributes( - const AttributeSerializedChunk & i_attributes); + void deserializeAttributes(const AttributeSerializedChunk & i_attributes); /** @@ -344,9 +666,8 @@ namespace AttributeTank * * @param[in] i_echoAttributes Select whether or not to echo the attributes */ - virtual void deserializeAttributes( - const AttributeSerializedChunk & i_attributes, - bool i_echoAttributes ); + void deserializeAttributes(const AttributeSerializedChunk & i_attributes, + bool i_echoAttributes ); /** @@ -359,7 +680,7 @@ namespace AttributeTank * * return true if any attributes exist */ - virtual bool attributesExist() const { return iv_attributesExist; } + bool attributesExist() const { return iv_attributesExist; } /** * @brief Check if an attribute exists in the tank @@ -374,7 +695,7 @@ namespace AttributeTank * * return true if any attributes exist */ - virtual bool attributeExists(const uint32_t i_attrId) const; + bool attributeExists(const uint32_t i_attrId) const; /** * @brief This function writes attributes in an AttributeTank to targeting @@ -392,32 +713,25 @@ namespace AttributeTank */ size_t size() const; -private: - // Copy constructor and assignment operator disabled - AttributeTank(const AttributeTank & i_right); - AttributeTank & operator=(const AttributeTank & i_right); - /** - * @struct Attribute + * @brief Return a copy of all attributes in the tank * - * This structure defines a single attribute. + * @param[out] List of all attributes in this tank + * @return n/a */ - struct Attribute - { - /** - * @brief Constructor - */ - Attribute(); + void getAllAttributes( std::list<Attribute *>& o_attributes ) const; - /** - * @brief Destructor. Frees memory - */ - ~Attribute(); + /** + * @brief Return a string description of the given tank layer + * + * @return String representation of layer + */ + static const char* layerToString( TankLayer i_layer ); - // Public data - AttributeHeader iv_hdr; - uint8_t * iv_pVal; // Pointer to attribute value - }; +private: + // Copy constructor and assignment operator disabled + AttributeTank(const AttributeTank & i_right); + AttributeTank & operator=(const AttributeTank & i_right); // The attributes // Note: A possible performance boost could be to store the elements in a @@ -429,7 +743,8 @@ private: // Lock for thread safety (class provided by platform) mutable TARG_MUTEX_TYPE iv_mutex; -}; + +}; // end AttributeTank #endif //STANDALONE_COMPILE diff --git a/src/include/usr/targeting/common/hbrt_target.H b/src/include/usr/targeting/common/hbrt_target.H new file mode 100644 index 000000000..1a6989bf4 --- /dev/null +++ b/src/include/usr/targeting/common/hbrt_target.H @@ -0,0 +1,45 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/hbrt_target.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2019,2020 */ +/* [+] 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 */ +#ifndef __HBRT_TARGET_H +#define __HBRT_TARGET_H + +#include <errl/errlentry.H> + +namespace TARGETING +{ + typedef uint64_t rtChipId_t; + /** + * @brief Convert a TARGETING::Target to an unit ID that can be used + * in calls to the runtime host + * @param[in] The HB TARGETING::Target + * @param[out] Sapphire target id + * @return an error handle on error + */ + errlHndl_t getRtTarget(const TARGETING::Target* i_target, + rtChipId_t &o_targetId); + +} + +#endif
\ No newline at end of file diff --git a/src/include/usr/targeting/common/target.H b/src/include/usr/targeting/common/target.H index 08fcb3f76..3e7eb82e7 100644 --- a/src/include/usr/targeting/common/target.H +++ b/src/include/usr/targeting/common/target.H @@ -47,6 +47,9 @@ #include <targeting/common/util.H> #include <targeting/common/pointer.H> #include <vector> +#ifdef __HOSTBOOT_MODULE +#include <array> +#endif // This component #include <targeting/common/attributes.H> @@ -181,6 +184,34 @@ class Target template<const ATTRIBUTE_ID A> bool tryGetAttrNotSynced( typename AttributeTraits<A>::Type& o_attrValue) const; + + /** + * @brief Try to get the target's specified std::array attribute value + * + * A special tryGetAttr function for getting the attribute values + * of the attributes which support std::array. + * It returns false (with invalid o_attrValue) if the specified + * attribute does not exist for the associated target, true (with a + * valid o_attrValue) otherwise. + * + * @param[out] o_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post See "return" + * + * @return bool indicating whether the specified attribute was returned + * or not + * + * @retval true Attribute returned in o_attrValue + * @retval false Attribute not found; o_attValue not valid + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + bool tryGetAttr( + typename AttributeTraits<A>::TypeStdArr& o_attrValue) const; +#endif + /** * @brief Get the target's specified attribute value * @@ -250,6 +281,26 @@ class Target const char* getAttrAsString() const; /** + * @brief For targets whose attribute value type is an array, return + * the array in std::array form. + * + * @pre Target service must be initialized + * + * @post Target's specified attribute value returned as a std::array, + * or assert called if specified attribute doesn't exist for the + * associated target or type is not an array + * + * @return std::array + * + * @retval Content and dimension varies, see xml file where the + * attribute's type is set + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + typename AttributeTraits<A>::TypeStdArr getAttrAsStdArr() const; +#endif + + /** * @brief Tries to set the target's specified attribute value * * Attempts to set the target's specified attribute value. It @@ -298,6 +349,34 @@ class Target typename AttributeTraits<A>::Type const& i_attrValue); /** + * + * @brief Tries to set the target's specified std::array attribute value + * + * A special trySetAttr function for setting the attribute values + * of the attributes which support std::array. + * It returns false if the specified attribute does not exist for the + * associated target, true otherwise. + * + * @param[in] i_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post Target's attribute value updated (if it exists), and caller + * notified whether the update occurred or not. + * + * @return bool indicating whether the specified attribute was updated + * or not + * + * @retval true Attribute updated + * @retval false Attribute not updated + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + bool trySetAttr( + typename AttributeTraits<A>::TypeStdArr const& i_attrValue); +#endif + + /** * @brief Returns pointer to a mutex attribute associated with the * target * @@ -361,6 +440,23 @@ class Target void setAttr(typename AttributeTraits<A>::Type const& i_attrValue); /** + * @brief For targets whose attribute value type is an array, set value + * from a std::array of any dimension + * + * @param[in] i_attrValue Value of the attribute + * + * @pre Target service must be initialized + * + * @post Target's attribute value updated if it exists and if it + * suppports TypeStdArr type, otherwise routine asserts + */ +#ifdef __HOSTBOOT_MODULE + template<const ATTRIBUTE_ID A> + void setAttrFromStdArr(typename AttributeTraits<A>::TypeStdArr const& + i_attrValue); +#endif + + /** * @brief Perform FFDC for the target instance * * @param[out] io_size @@ -488,7 +584,16 @@ class Target return _trySetAttr(i_attr, i_size, i_pAttrData); } - + /** + * @brief Returns the target's type as used in a Targeting attribute + * tank. + * + * This target type is associated with an attribute in an attribute + * tank and helps identify which target(s) the attribute belongs to + * + * @return uint32_t The target type + */ + uint32_t getAttrTankTargetType() const; private: // Private helper interfaces @@ -713,24 +818,15 @@ class Target mutex_t*& o_pMutex) const; /** - * @brief Returns the target's type as used in a Targeting attribute - * tank. - * - * This target type is associated with an attribute in an attribute - * tank and helps identify which target(s) the attribute belongs to - * - * @return uint32_t The target type - */ - uint32_t getAttrTankTargetType() const; - - /** * @brief enumeration of assert reasons */ enum TargAssertReason { SET_ATTR, + SET_ATTR_FROM_STD_ARR, GET_ATTR, GET_ATTR_AS_STRING, + GET_ATTR_AS_STD_ARRAY, GET_HB_MUTEX_ATTR, GET_ATTR_TANK_TARGET_POS_DATA, GET_ATTR_TANK_TARGET_POS_DATA_ATTR, @@ -865,6 +961,19 @@ bool Target::tryGetAttr(typename AttributeTraits<A>::Type& o_attrValue) const return _tryGetAttr(A,sizeof(o_attrValue),&o_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +bool Target::tryGetAttr( + typename AttributeTraits<A>::TypeStdArr& o_attrValue) const +{ + if(AttributeTraits<A>::readable == AttributeTraits<A>::readable) { } + if(AttributeTraits<A>::notHbMutex == AttributeTraits<A>::notHbMutex) { } + if(AttributeTraits<A>::fspAccessible == AttributeTraits<A>::fspAccessible) + { } + return _tryGetAttr(A, sizeof(o_attrValue), &o_attrValue); +} +#endif + template<const ATTRIBUTE_ID A> bool Target::trySetAttr(typename AttributeTraits<A>::Type const& i_attrValue) { @@ -886,6 +995,17 @@ bool Target::trySetAttrNotSynced( return _trySetAttr(A,sizeof(i_attrValue),&i_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +bool Target::trySetAttr(typename AttributeTraits<A>::TypeStdArr + const& i_attrValue) +{ + if(AttributeTraits<A>::writeable == AttributeTraits<A>::writeable) { } + if(AttributeTraits<A>::notHbMutex == AttributeTraits<A>::notHbMutex) { } + return _trySetAttr(A,sizeof(i_attrValue),&i_attrValue); +} +#endif + template<const ATTRIBUTE_ID A> typename AttributeTraits<A>::Type Target::getAttr() const { @@ -933,6 +1053,19 @@ void Target::setAttr(typename AttributeTraits<A>::Type const& i_attrValue) } } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +void Target::setAttrFromStdArr(typename AttributeTraits<A>::TypeStdArr const& + i_attrValue) +{ + bool l_wrote = trySetAttr<A>(i_attrValue); + if (unlikely(!l_wrote)) + { + targAssert(SET_ATTR_FROM_STD_ARR, A); + } +} +#endif + template<const ATTRIBUTE_ID A> mutex_t* Target::getHbMutexAttr() const { @@ -978,6 +1111,23 @@ const char* Target::getAttrAsString() const return attrToString<A>(l_attrValue); } +#ifdef __HOSTBOOT_MODULE +template<const ATTRIBUTE_ID A> +typename AttributeTraits<A>::TypeStdArr Target::getAttrAsStdArr() const +{ + typename AttributeTraits<A>::TypeStdArr l_stdArr; + + bool l_read = tryGetAttr<A>(l_stdArr); + + if (unlikely(!l_read)) + { + targAssert(GET_ATTR_AS_STD_ARRAY, A); + } + + return l_stdArr; +} +#endif + // Function to set various frequency related attributes /** * @brief - sets various attributes directly related to the nest frequency. diff --git a/src/include/usr/targeting/common/targetUtil.H b/src/include/usr/targeting/common/targetUtil.H new file mode 100644 index 000000000..86a49c8b0 --- /dev/null +++ b/src/include/usr/targeting/common/targetUtil.H @@ -0,0 +1,154 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/targeting/common/targetUtil.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ +/* [+] 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 */ + +/** + * @file + * + * @brief Defines templates methods that require the use of the + * class Target and struct Attribute. Having the methods + * in this file helps with circular dependencies issue. + */ + +#ifndef __TARGETING_COMMON_TARGET_UTIL_H +#define __TARGETING_COMMON_TARGET_UTIL_H + +#include <stdint.h> // int16_t, uint8_t +#include <attributeenums.H> // TARGETING::ATTRIBUTE_ID +#include <targeting/common/target.H> // Target +#include <targeting/common/attributeTank.H> // AttributeTank::Attribute + +#ifndef STANDALONE_COMPILE + +namespace TARGETING +{ +/** + * @brief Returns the target handle's attribute associated with the given + * simple type attribute ID. + * + * @param[in] i_target The target to retrieve the attribute data from + * @param[out] o_attribute The attribute data, for the given attribute ID, + * if found + * + * @pre i_target must be a valid target + * + * @return Attribute data for given attribute ID, if found, else + * outgoing attribute will not touched + * + * @retval true is successful in locating the attribute ID, false otherwise + */ +template<const ATTRIBUTE_ID A> +bool makeAttribute(TargetHandle_t i_target, + AttributeTank::Attribute& o_attribute) +{ + // Set up the return value to true ... hoping for the best + bool retVal(true); + + do + { + // Some needed variables and their defaults + uint16_t l_positon(TARGETING::AttributeTank::ATTR_POS_NA); + uint8_t l_unitPositon(AttributeTank::ATTR_UNIT_POS_NA), + l_node(AttributeTank::ATTR_NODE_NA); + + // Get the target's position data + i_target->getAttrTankTargetPosData(l_positon, l_unitPositon, l_node); + + // Get the target's type and the target's attribute data + auto l_targetType = i_target->getAttrTankTargetType(); + auto l_attributeData = i_target->getAttr<A>(); + + // Populate the outgoing Attribute with the data retrieved above + o_attribute.setId(A); + o_attribute.setTargetType(l_targetType); + o_attribute.setPosition(l_positon); + o_attribute.setUnitPosition(l_unitPositon); + o_attribute.setNode(l_node); + o_attribute.setValue(&l_attributeData, sizeof(l_attributeData)); + } while (0); + + return retVal; +}; // end makeAttribute + +/** + * @brief Returns the target handle's attribute associated with the given + * complex type attribute ID. + * + * @param[in] i_target The target to retrieve the attribute data from + * @param[out] o_attribute The attribute data, for the given attribute ID, + * if found + * + * @pre i_target must be a valid target + * + * @return Attribute data for given attribute ID, if found, else + * outgoing attribute will not touched + * + * @retval true is successful in locating the attribute ID, false otherwise + */ +template<const ATTRIBUTE_ID A> +bool makeAttributeStdArr(TargetHandle_t i_target, + AttributeTank::Attribute& o_attribute) +{ + // Set up the return value to true ... hoping for the best + bool retVal(true); + + // Variable to hold the complex type, when found + typename AttributeTraits<A>::TypeStdArr l_attributeValue; + + do + { + // Some needed variables and their defaults + uint16_t l_positon(TARGETING::AttributeTank::ATTR_POS_NA); + uint8_t l_unitPositon(AttributeTank::ATTR_UNIT_POS_NA), + l_node(AttributeTank::ATTR_NODE_NA); + + // Get the target's position data + i_target->getAttrTankTargetPosData(l_positon, l_unitPositon, l_node); + + // Get the target's type and the target's attribute data + auto l_targetType = i_target->getAttrTankTargetType(); + bool l_found = i_target->tryGetAttr<A>(l_attributeValue); + if (!l_found) + { + retVal = false; + break; + } + + // Populate the outgoing Attribute with the data retrieved above + o_attribute.setId(A); + o_attribute.setTargetType(l_targetType); + o_attribute.setPosition(l_positon); + o_attribute.setUnitPosition(l_unitPositon); + o_attribute.setNode(l_node); + o_attribute.setValue(&l_attributeValue, sizeof(l_attributeValue)); + } while (0); + + return retVal; +}; // end makeAttributeStdArr + +}; // end namespace TARGETING + +#endif // end STANDALONE_COMPILE + +#endif // end __TARGETING_COMMON_TARGET_UTIL_H diff --git a/src/include/usr/targeting/common/trace.H b/src/include/usr/targeting/common/trace.H index bf42dd625..4376b56d7 100644 --- a/src/include/usr/targeting/common/trace.H +++ b/src/include/usr/targeting/common/trace.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] Google Inc. */ /* [+] International Business Machines Corp. */ /* */ @@ -41,7 +41,6 @@ // Other includes #include <targeting/adapters/traceadapter.H> #ifdef __HOSTBOOT_MODULE -#include <config.h> #endif #define TARG_LOC TARG_NAMESPACE TARG_CLASS TARG_FN ": " diff --git a/src/include/usr/targeting/common/util.H b/src/include/usr/targeting/common/util.H index 6f0fcb307..ba41445c1 100644 --- a/src/include/usr/targeting/common/util.H +++ b/src/include/usr/targeting/common/util.H @@ -102,6 +102,15 @@ namespace UTIL P9N23_P9C13_NATIVE_MODE_MINIMUM = 0x04, P9N23_P9C13_NATIVE_SMF_RUGBY_FAVOR_SECURITY = 0x04, P9N23_P9C13_NATIVE_SMF_RUGBY_FAVOR_PERFORMANCE = 0x05, + + // Axone modes (same as DD2.3 native mode) + P9A_RUGBY_FAVOR_SECURITY = 0x04, + P9A_RUGBY_FAVOR_PERFORMANCE = 0x05, + // The _LOWER numbered values are equivalent to the higher + // values but they exist to maintain compatibility with + // Nimbus DD2.3 settings. + P9A_RUGBY_FAVOR_SECURITY_LOWER = 0x00, + P9A_RUGBY_FAVOR_PERFORMANCE_LOWER = 0x01, } Risk_level; } diff --git a/src/include/usr/runtime/rt_targeting.H b/src/include/usr/targeting/runtime/rt_targeting.H index 9070dbc88..c94b871a9 100644 --- a/src/include/usr/runtime/rt_targeting.H +++ b/src/include/usr/targeting/runtime/rt_targeting.H @@ -1,11 +1,11 @@ /* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ -/* $Source: src/include/usr/runtime/rt_targeting.H $ */ +/* $Source: src/include/usr/targeting/runtime/rt_targeting.H $ */ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014,2018 */ +/* Contributors Listed Below - COPYRIGHT 2014,2020 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,6 +26,7 @@ #define __RT_TARGETING_H #include <errl/errlentry.H> +#include <targeting/common/hbrt_target.H> namespace TARGETING { @@ -34,7 +35,6 @@ namespace TARGETING namespace RT_TARG { - typedef uint64_t rtChipId_t; enum { @@ -43,15 +43,6 @@ namespace RT_TARG }; - /** - * @brief Convert a TARGETING::Target to an unit ID that can be used - * in calls to the runtime host - * @param[in] The HB TARGETING::Target - * @param[out] Sapphire target id - * @return an error handle on error - */ - errlHndl_t getRtTarget(const TARGETING::Target* i_target, - rtChipId_t &o_targetId); /** * @brief Convert a runtime chip_id (target) into a TARGETING::Target @@ -59,7 +50,7 @@ namespace RT_TARG * @param[out] The TARGETING::Target pointer * @return error log handle on error else NULL */ - errlHndl_t getHbTarget(rtChipId_t i_rt_chip_id, + errlHndl_t getHbTarget(TARGETING::rtChipId_t i_rt_chip_id, TARGETING::Target *& o_target); /** diff --git a/src/include/usr/util/impl/threadpool.H b/src/include/usr/util/impl/threadpool.H index 84ee9afd7..5ad530057 100644 --- a/src/include/usr/util/impl/threadpool.H +++ b/src/include/usr/util/impl/threadpool.H @@ -5,7 +5,9 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* COPYRIGHT International Business Machines Corp. 2012,2014 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ +/* [+] 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. */ @@ -38,6 +40,7 @@ #include <algorithm> #include <sys/sync.h> #include <sys/task.h> +#include <errl/errlentry.H> namespace Util { @@ -82,7 +85,11 @@ namespace __Util_ThreadPool_Impl /** Simple constructor, call __init to avoid the in-charge and * not-in-charge construction costs. */ - ThreadPoolImpl() { __init(); }; + ThreadPoolImpl(bool i_checkChildRc = true) : + iv_checkChildRc(i_checkChildRc) + { + __init(); + }; protected: /** Initialize the object. */ @@ -105,7 +112,7 @@ namespace __Util_ThreadPool_Impl */ void __start(start_fn_t fn, void* instance); /** Stop the thread-pool. */ - void __shutdown(); + errlHndl_t __shutdown(); /** Outstanding work-list. */ worklist_t iv_worklist; @@ -119,6 +126,7 @@ namespace __Util_ThreadPool_Impl std::list<tid_t> iv_children; /** State of object. */ bool iv_shutdown; + bool iv_checkChildRc; }; diff --git a/src/include/usr/util/runtime/rt_fwnotify.H b/src/include/usr/util/runtime/rt_fwnotify.H new file mode 100644 index 000000000..1f6bc7efb --- /dev/null +++ b/src/include/usr/util/runtime/rt_fwnotify.H @@ -0,0 +1,45 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/include/usr/util/runtime/rt_fwnotify.H $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2010,2019 */ +/* [+] 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 */ +#ifndef __RUNTIME_FWNOTIFY_H +#define __RUNTIME_FWNOTIFY_H + +#include <runtime/interface.h> + +/** + * @brief Perform an NVDIMM operation + * @param[in] nvDimmOp - A struct that contains the operation(s) to perform + * and a flag indicating whether to perform operation + * on all processors or a given single processor. + * @Note The operations below are in the order of which they should be + * performed. If a new operation is added, make sure it inserted in the + * correct order. + * The current order is: disarm -> disable encryption -> remove keys -> + * enable encryption -> arm + **/ +int doNvDimmOperation(const hostInterfaces::nvdimm_operation_t& nvDimmOp); + + + +#endif // __RUNTIME_FWNOTIFY_H diff --git a/src/include/usr/util/threadpool.H b/src/include/usr/util/threadpool.H index f96e0b916..43fdeba7a 100644 --- a/src/include/usr/util/threadpool.H +++ b/src/include/usr/util/threadpool.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2012,2015 */ +/* Contributors Listed Below - COPYRIGHT 2012,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -58,6 +58,7 @@ #include <stdint.h> #include <util/traits/has_lessthan.H> #include <util/impl/threadpool.H> +#include <errl/errlentry.H> namespace Util { @@ -87,7 +88,10 @@ class ThreadPool : public Util::__Util_ThreadPool_Impl::ThreadPoolImpl { public: /** Basic Constructor. Initialize ThreadPool. */ - ThreadPool() : Util::__Util_ThreadPool_Impl::ThreadPoolImpl() { }; + ThreadPool(bool i_checkChildRc = true) : + Util::__Util_ThreadPool_Impl::ThreadPoolImpl(i_checkChildRc) + { + }; /** Basic Destructor. Ensures pool is properly shut down. */ ~ThreadPool() { shutdown(); }; @@ -98,12 +102,20 @@ class ThreadPool : public Util::__Util_ThreadPool_Impl::ThreadPoolImpl __start(reinterpret_cast<start_fn_t>(&run), this); }; /** @brief Completes outstanding work and destroys worker threads. + * Returns an error log when any child task crashes when + * iv_checkChildRc is set. * * @note This function will block until all work is completed and * worker threads are destroyed. + * + * @return nullptr if all child tasks finished (child status + * checking disabled); + * nullptr if all child tasks finished successfully, or a + * pointer to error log otherwise (child status checking + * enabled). */ - void shutdown() - { __shutdown(); }; + errlHndl_t shutdown() + { return __shutdown(); }; /** @brief Insert a work item onto the thread-pool's queue. * diff --git a/src/include/usr/util/util_reasoncodes.H b/src/include/usr/util/util_reasoncodes.H index 17ea0edfc..1f8146baf 100644 --- a/src/include/usr/util/util_reasoncodes.H +++ b/src/include/usr/util/util_reasoncodes.H @@ -53,6 +53,7 @@ namespace Util UTIL_MOD_GET_OBUS_PLL_BUCKET = 0x14, // UtilCommonAttr::getObusPllBucket UTIL_LIDMGR_CSTOR = 0x15, // UtilLidMgr::UtilLidMgr UTIL_MCL_PROCESS_SINGLE_COMP = 0x16, // UtilLidMgr::processSingleComponent + UTIL_MOD_TP_SHUTDOWN = 0x17, // Util::__Util_ThreadPool_Impl::ThreadPoolImpl::__shutdown }; enum ReasonCode @@ -85,6 +86,7 @@ namespace Util UTIL_ERC_NO_MATCHING_FREQ = UTIL_COMP_ID | 0x1B, UTIL_LIDMGR_INVAL_LID_REQUEST = UTIL_COMP_ID | 0x1C, UTIL_LIDMGR_INVAL_COMP = UTIL_COMP_ID | 0x1D, + UTIL_RC_CHILD_TASK_FAILED = UTIL_COMP_ID | 0x1E, }; }; diff --git a/src/include/usr/util/utillidmgr.H b/src/include/usr/util/utillidmgr.H index e78eba133..bd1c587c0 100644 --- a/src/include/usr/util/utillidmgr.H +++ b/src/include/usr/util/utillidmgr.H @@ -63,6 +63,10 @@ enum LidId TARGETING_BINARY_LIDID = 0x81e00630, NVDIMM_16GB_LIDID = 0x81e00640, NVDIMM_32GB_LIDID = 0x81e00641, + NVDIMM_16GB_BPM_FW_LIDID = 0x81e00642, + NVDIMM_32GB_BPM_FW_LIDID = 0x81e00643, + NVDIMM_16GB_BPM_CONFIG_LIDID = 0x81e00644, + NVDIMM_32GB_BPM_CONFIG_LIDID = 0x81e00645, UCD_LIDID = 0x81e00650, INVALID_LIDID = 0xFFFFFFFF diff --git a/src/include/usr/vmmconst.h b/src/include/usr/vmmconst.h index b6841eea4..f826f45d2 100644 --- a/src/include/usr/vmmconst.h +++ b/src/include/usr/vmmconst.h @@ -31,7 +31,6 @@ */ #include <limits.h> -#include <config.h> /** * Segments @@ -208,9 +207,13 @@ enum BlockPriority #define VMM_MODULE_VPD_SIZE (512*KILOBYTE) /* must be 64KB aligned */ #define VMM_CENTAUR_VPD_SIZE (256*KILOBYTE) /* must be 64KB aligned */ #define VMM_DIMM_JEDEC_VPD_SIZE (256*KILOBYTE) /* must be 64KB aligned */ +#ifndef CONFIG_SUPPORT_EEPROM_CACHING #define VMM_RT_VPD_SIZE ( VMM_MODULE_VPD_SIZE + \ VMM_CENTAUR_VPD_SIZE + \ VMM_DIMM_JEDEC_VPD_SIZE ) +#else +#define VMM_RT_VPD_SIZE (512*KILOBYTE) /* 64KB aligned (size EECACHE section size - ecc) */ +#endif /** Internode communication area outside of the HB image. diff --git a/src/include/usr/vpd/spdenums.H b/src/include/usr/vpd/spdenums.H index a6577ed12..f1dc7aa29 100644 --- a/src/include/usr/vpd/spdenums.H +++ b/src/include/usr/vpd/spdenums.H @@ -46,6 +46,19 @@ enum }; /** +* @brief Enumerations for common SPD values +*/ +enum +{ + MEM_DDR3 = 0xB, + MEM_DDR4 = 0xC, + DDR3_SPD_SIZE = 256, + DDR4_SPD_SIZE = 512, + DDIMM_DDR4_SPD_SIZE = 640, + MEM_DDIMM = 0xA +}; + +/** * @brief Enumerations for fields that can be accessed in the SPD */ enum @@ -343,9 +356,15 @@ enum LRMM_CRC = SPD_FIRST_MOD_SPEC | 0xb4, SPD_LAST_MOD_SPEC = SPD_FIRST_MOD_SPEC | 0xb5, + // Latest DDR SPD specifcations have standard SPD + // in the front followed by extendable function + // descriptors (EFDs). ENTIRE_SPD will grab everything + // ENTIRE_SPD_WITHOUT_EFD will skip getting the EFD info + ENTIRE_SPD_WITHOUT_EFD = 0xFFFD, + //read entire SPD contents + ENTIRE_SPD = 0xFFFE, // This keyword should be last in the list // Invalid Keyword - ENTIRE_SPD = 0xFFFE, //read entire SPD INVALID_SPD_KEYWORD = 0xFFFF, }; diff --git a/src/include/usr/vpd/vpd_if.H b/src/include/usr/vpd/vpd_if.H index 4e63a0965..b649b46ab 100644 --- a/src/include/usr/vpd/vpd_if.H +++ b/src/include/usr/vpd/vpd_if.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2018 */ +/* Contributors Listed Below - COPYRIGHT 2013,2019 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -108,6 +108,21 @@ namespace VPD errlHndl_t ensureCacheIsInSync ( TARGETING::Target * i_target ); /** + * @brief This function checks if the eeprom cache for the target is in + * sync with hardware and returns the result in o_isInSync. + * + * @param[in] i_target Target device + * @param[in] i_eepromType Eeprom content type of target device + * @param[out] o_isInSync true if part and serial numbers in cache match + * hardware. Otherwise, false. + * @return errlHndl_t - NULL if successful, otherwise a pointer to the + * error log. + */ + errlHndl_t ensureEepromCacheIsInSync(TARGETING::Target * i_target, + TARGETING::EEPROM_CONTENT_TYPE i_eepromType, + bool & o_isInSync); + + /** * @brief This function invalidates the VPD data in the PNOR cache. * @param[in] i_target - Target device * @return errlHndl_t - NULL if successful, otherwise a pointer to the diff --git a/src/include/usr/vpd/vpdreasoncodes.H b/src/include/usr/vpd/vpdreasoncodes.H index 8a201c422..9307af7b7 100644 --- a/src/include/usr/vpd/vpdreasoncodes.H +++ b/src/include/usr/vpd/vpdreasoncodes.H @@ -99,7 +99,10 @@ enum vpdModuleId // OCMB SPD VPD_OCMB_GET_SPD = 0x90, + VPD_OCMB_SPD_PERFORM_OP = 0x91, + VPD_READ_FROM_EEPROM_SOURCE = 0x92, + VPD_GET_MEMTYPE = 0x93, }; @@ -124,10 +127,10 @@ enum vpdReasonCode VPD_MEMTYPE_NOT_SUPPORTED = VPD_COMP_ID | 0x0A, VPD_KEYWORD_NOT_WRITABLE = VPD_COMP_ID | 0x0B, VPD_NOT_SUPPORTED = VPD_COMP_ID | 0x0C, - VPD_MOD_SPECIFIC_MISMATCH_UMM = VPD_COMP_ID | 0x0D, - VPD_MOD_SPECIFIC_MISMATCH_RMM = VPD_COMP_ID | 0x0E, - VPD_MOD_SPECIFIC_MISMATCH_CMM = VPD_COMP_ID | 0x0F, - VPD_MOD_SPECIFIC_MISMATCH_LRMM = VPD_COMP_ID | 0x10, + VPD_MOD_SPECIFIC_MISMATCH_UMM = VPD_COMP_ID | 0x0D, // Deprecated + VPD_MOD_SPECIFIC_MISMATCH_RMM = VPD_COMP_ID | 0x0E, // Deprecated + VPD_MOD_SPECIFIC_MISMATCH_CMM = VPD_COMP_ID | 0x0F, // Deprecated + VPD_MOD_SPECIFIC_MISMATCH_LRMM = VPD_COMP_ID | 0x10, // Deprecated VPD_MOD_SPECIFIC_UNSUPPORTED = VPD_COMP_ID | 0x11, VPD_SIZE_MISMATCH = VPD_COMP_ID | 0x12, VPD_INVALID_WRITE_METHOD = VPD_COMP_ID | 0x13, @@ -157,7 +160,7 @@ enum vpdReasonCode VPD_BAD_REC_NUM = VPD_COMP_ID | 0x3e, VPD_INVALID_MASTER_I2C_PATH = VPD_COMP_ID | 0x3f, VPD_NULL_I2C_MASTER = VPD_COMP_ID | 0x40, - VPD_MOD_SPECIFIC_MISMATCH_DDIMM = VPD_COMP_ID | 0x41, + VPD_INVALID_EEPROM_CONTENT_TYPE = VPD_COMP_ID | 0x41, }; |