diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c index e9bf95451..a201202ad 100644 --- a/libpdbg/dtb.c +++ b/libpdbg/dtb.c @@ -65,6 +65,8 @@ static const uint16_t ODYSSEY_CHIP_ID = 0x60C0; static const uint8_t ATTR_TYPE_OCMB_CHIP = 75; static const char* RAINIER = "rainier"; static const char* EVEREST = "everest"; +static const char* FUJI = "fuji"; +static const char* BLUERIDGE = "blueridge"; static struct pdbg_dtb pdbg_dtb = { .backend = { @@ -116,6 +118,13 @@ bool contains_substring_ignoring_case(const char* buffer, const char* substring) size_t bufferLen = strlen(buffer); size_t substringLen = strlen(substring); + //If the string that we are looking for is longer than the + //given string, return as not found + if(substringLen > bufferLen) + { + return false; + } + for (size_t i = 0; i <= bufferLen - substringLen; ++i) { size_t j; for (j = 0; j < substringLen; ++j) { @@ -319,10 +328,12 @@ static void bmc_target(struct pdbg_dtb *dtb) pdbg_proc = PDBG_PROC_P10; if (!dtb->backend.fdt) { char *system_type = get_p10_system_type(); - if (contains_substring_ignoring_case(system_type, EVEREST)) { + if (contains_substring_ignoring_case(system_type, EVEREST) || + contains_substring_ignoring_case(system_type, FUJI)) { pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel everest target"); dtb->backend.fdt = &_binary_bmc_kernel_everest_dtb_o_start; - } else if (contains_substring_ignoring_case(system_type, RAINIER)) { + } else if (contains_substring_ignoring_case(system_type, RAINIER)|| + contains_substring_ignoring_case(system_type, BLUERIDGE)) { pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel rainier target"); dtb->backend.fdt = &_binary_bmc_kernel_rainier_dtb_o_start; } else { @@ -350,10 +361,12 @@ static void bmc_target(struct pdbg_dtb *dtb) pdbg_proc = PDBG_PROC_P10; if (!dtb->backend.fdt) { char *system_type = get_p10_system_type(); - if (contains_substring_ignoring_case(system_type, EVEREST)) { + if (contains_substring_ignoring_case(system_type, EVEREST) || + contains_substring_ignoring_case(system_type, FUJI)) { pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel everest target"); dtb->backend.fdt = &_binary_bmc_kernel_everest_dtb_o_start; - } else if (contains_substring_ignoring_case(system_type, RAINIER)) { + } else if (contains_substring_ignoring_case(system_type, RAINIER) || + contains_substring_ignoring_case(system_type, BLUERIDGE)) { pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel rainier target"); dtb->backend.fdt = &_binary_bmc_kernel_rainier_dtb_o_start; } else { @@ -406,11 +419,13 @@ static void sbefifo_target(struct pdbg_dtb *dtb) pdbg_proc = PDBG_PROC_P10; if (!dtb->backend.fdt) { char *system_type = get_p10_system_type(); - if (contains_substring_ignoring_case(system_type, EVEREST)) { + if (contains_substring_ignoring_case(system_type, EVEREST) || + contains_substring_ignoring_case(system_type, FUJI)) { pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo everest target"); dtb->backend.fdt = &_binary_bmc_sbefifo_everest_dtb_o_start; - } else if (contains_substring_ignoring_case(system_type, RAINIER)) { + } else if (contains_substring_ignoring_case(system_type, RAINIER) || + contains_substring_ignoring_case(system_type, BLUERIDGE)) { pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo rainier target"); dtb->backend.fdt = &_binary_bmc_sbefifo_rainier_dtb_o_start; @@ -439,11 +454,13 @@ static void sbefifo_target(struct pdbg_dtb *dtb) pdbg_proc = PDBG_PROC_P10; if (!dtb->backend.fdt) { char *system_type = get_p10_system_type(); - if (contains_substring_ignoring_case(system_type, EVEREST)) { + if (contains_substring_ignoring_case(system_type, EVEREST) || + contains_substring_ignoring_case(system_type, FUJI)) { pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo everest target"); dtb->backend.fdt = &_binary_bmc_sbefifo_everest_dtb_o_start; - } else if (contains_substring_ignoring_case(system_type, RAINIER)) { + } else if (contains_substring_ignoring_case(system_type, RAINIER) || + contains_substring_ignoring_case(system_type, BLUERIDGE)) { pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo rainier target"); dtb->backend.fdt = &_binary_bmc_sbefifo_rainier_dtb_o_start; @@ -725,7 +742,7 @@ static void close_dtb(struct pdbg_mfile *mfile) bool is_ody_ocmb_chip(struct pdbg_target *target) { - uint8_t type; + uint8_t type = 0; pdbg_target_get_attribute(target, "ATTR_TYPE", 1, 1, &type); if(type != ATTR_TYPE_OCMB_CHIP) { return false; diff --git a/libpdbg/ocmb.c b/libpdbg/ocmb.c index a341577d2..2a02e20fe 100644 --- a/libpdbg/ocmb.c +++ b/libpdbg/ocmb.c @@ -48,7 +48,9 @@ static int sbefifo_ocmb_getscom(struct ocmb *ocmb, uint64_t addr, uint64_t *valu struct sbefifo_context *sctx = sbefifo->get_sbefifo_context(sbefifo); uint8_t instance_id; - instance_id = pdbg_target_index(&ocmb->target) & 0xff; + uint32_t fapi_pos = 0; + pdbg_target_get_attribute(&ocmb->target, "ATTR_FAPI_POS", 4, 1, &fapi_pos); + instance_id = fapi_pos & 0x0f; return sbefifo_hw_register_get(sctx, SBEFIFO_TARGET_TYPE_OCMB, diff --git a/libpdbg/sbe_api.c b/libpdbg/sbe_api.c index 8cf6a8232..056171dc0 100644 --- a/libpdbg/sbe_api.c +++ b/libpdbg/sbe_api.c @@ -213,10 +213,14 @@ int sbe_dump(struct pdbg_target *target, uint8_t type, uint8_t clock, } int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc, - uint32_t *ffdc_len) + uint32_t *ffdc_len) { if(!is_ody_ocmb_chip(target)) { - struct chipop *chipop = pib_to_chipop(target); + struct chipop *chipop; + const uint8_t *data = NULL; + uint32_t len = 0; + + chipop = pib_to_chipop(target); if (!chipop) return -1; @@ -225,10 +229,23 @@ int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc, return -1; } - *status = chipop->ffdc_get(chipop, (const uint8_t**)ffdc, ffdc_len); + *status = chipop->ffdc_get(chipop, &data, &len); + if (data && len > 0) { + *ffdc = malloc(len); + assert(*ffdc); + memcpy(*ffdc, data, len); + *ffdc_len = len; + } else { + *ffdc = NULL; + *ffdc_len = 0; + } } else { + struct chipop_ody *chipop; + const uint8_t *data = NULL; + uint32_t len = 0; + struct pdbg_target *co_target = get_ody_chipop_target(target); - struct chipop_ody *chipop = target_to_chipop_ody(co_target); + chipop = target_to_chipop_ody(co_target); if (!chipop) { PR_ERROR("chipop target not found for ody ocmb chip\n"); return -1; @@ -237,14 +254,21 @@ int sbe_ffdc_get(struct pdbg_target *target, uint32_t *status, uint8_t **ffdc, PR_ERROR("ffdc_get() not implemented for the target\n"); return -1; } - struct pdbg_target *fsi = get_ody_fsi_target(target); - if (!fsi) { PR_ERROR("fsi target not found for ody ocmb chip\n"); return -1; } - *status = chipop->ffdc_get(chipop, fsi, (const uint8_t**)ffdc, ffdc_len); + *status = chipop->ffdc_get(chipop, fsi, &data, &len); + if (data && len > 0) { + *ffdc = malloc(len); + assert(*ffdc); + memcpy(*ffdc, data, len); + *ffdc_len = len; + } else { + *ffdc = NULL; + *ffdc_len = 0; + } } return 0; } @@ -397,7 +421,7 @@ int sbe_ody_get_state(struct pdbg_target *fsi, enum sbe_state *state) rc = sbe_ody_read_state_register(fsi, &value); if (rc) return -1; - if (value == SBE_STATE_CHECK_CFAM) { + if ((value == SBE_STATE_CHECK_CFAM) || (value == SBE_MSG_STATE_UNKNOWN)) { rc = sbe_ody_read_msg_register(fsi, &msg.reg); if (rc) return -1;