Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corner case #99

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions libpdbg/dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Loading