Skip to content

Commit

Permalink
modify to use different device tree for rainier and everest
Browse files Browse the repository at this point in the history
1) Rainier and everest uses different port mapping so modified
to use different device trees for everest and rainier

2) Modified to use fapi_pos over ocmb index for determining the
backend sbefifo target

Tested:
----rainxx test result---
      odyssey
        p[2]
          mp[0]
          perv[8]
        p[3]
          mp[0]
          perv[8]
        p[26]
          mp[0]
          perv[8]
        p[27]
          mp[0]
          perv[8]
root@xxxx:/tmp# getscom odyssey 08012400 -all
pdbg_default_dtb PDBG_BACKEND_SBEFIFO
***sbefifo_target system type returned is Rainier 4U
****sbefifo_target - loading bmc sbefifo rainier target
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p03       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p26       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p27       0x0008000000000000
/usr/bin/edbg getscom odyssey 08012400 -all

---rainxx test result-----
ecmdquery chips -dc
      odyssey
        p[4]
          mp[0,1]
          perv[8]
        p[5]
          mp[0,1]
          perv[8]

root@xxx:/tmp#  getscom odyssey 08012400 -all
system type returned is Rainier 2U
loading bmc sbefifo rainier target
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p04       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p05       0x0008000000000000
/usr/bin/edbg getscom odyssey 08012400 -all

------everest----------------
      odyssey
        p[2]
          mp[0,1]
          perv[8]
        p[3]
          mp[0,1]
          perv[8]
        p[34]
          mp[0,1]
          perv[8]
        p[35]
          mp[0,1]
          perv[8]
root@xxxx:~# getscom odyssey 08012400 -all
pdbg_default_dtb PDBG_BACKEND_SBEFIFO
***sbefifo_target system type returned is Everest
**** sbefifo_target - loading bmc sbefifo everest target
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p02       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p03       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p34       0x0008000000000000
sbefifo_ocmb_getscom
odyssey	k0:n0:s0:p35       0x0008000000000000
/usr/bin/edbg getscom odyssey 08012400 -all

Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
Change-Id: I832b5b71351a5d34a9c9223753ef211caf51731c
  • Loading branch information
devenrao committed Feb 5, 2024
1 parent af70acd commit c6610e4
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 11 deletions.
107 changes: 98 additions & 9 deletions libpdbg/dtb.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@
#include "p9r-fsi.dt.h"
#include "p9z-fsi.dt.h"
#include "bmc-kernel.dt.h"
#include "bmc-kernel-rainier.dt.h"
#include "bmc-kernel-everest.dt.h"
#include "p8-host.dt.h"
#include "p9-host.dt.h"
#include "p10-host.dt.h"
#include "p8-cronus.dt.h"
#include "cronus.dt.h"
#include "bmc-sbefifo.dt.h"

#include "bmc-sbefifo-rainier.dt.h"
#include "bmc-sbefifo-everest.dt.h"
#include "p8.dt.h"
#include "p9.dt.h"
#include "p10.dt.h"
Expand Down Expand Up @@ -107,6 +110,44 @@ static bool get_chipid(uint32_t *chip_id)
return true;
}

static char* get_p10_system_type()
{
FILE* file = fopen("/proc/device-tree/model", "r");
if (file == NULL) {
pdbg_log(PDBG_ERROR, "Unable to read device-tree model file: %s", strerror(errno));
return "";
}

// Determine the size of the file
fseek(file, 0, SEEK_END);
long file_size = ftell(file);
fseek(file, 0, SEEK_SET);

// Allocate memory for the file content
char* buffer = (char*)malloc(file_size + 1);

if (buffer == NULL) {
pdbg_log(PDBG_ERROR, "Memory allocation failed");
return "";
}

// Read the file content into the buffer
size_t bytes_read = fread(buffer, 1, file_size, file);

if (bytes_read != file_size) {
pdbg_log(PDBG_ERROR, "Error reading file");
return "";
}

// Null-terminate the buffer to create a valid C-string
buffer[bytes_read] = '\0';

// Close the file
fclose(file);

return buffer;
}

/* Determines the most appropriate backend for the host system we are
* running on. */
static enum pdbg_backend default_backend(void)
Expand Down Expand Up @@ -258,8 +299,20 @@ static void bmc_target(struct pdbg_dtb *dtb)
dtb->system.fdt = &_binary_p9_dtb_o_start;
} else if (!strcmp(pdbg_backend_option, "p10")) {
pdbg_proc = PDBG_PROC_P10;
if (!dtb->backend.fdt)
dtb->backend.fdt = &_binary_bmc_kernel_dtb_o_start;
if (!dtb->backend.fdt) {
char* system_type = get_p10_system_type();
if (strcmp(system_type, "Everest") == 0) {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel everest target");
dtb->backend.fdt = &_binary_bmc_kernel_everest_dtb_o_start;
} else if (strcmp(system_type, "Rainier 2U") == 0 || strcmp(system_type, "Rainier 4U") ==0 ) {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel rainier target");
dtb->backend.fdt = &_binary_bmc_kernel_rainier_dtb_o_start;
} else {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel target");
dtb->backend.fdt = &_binary_bmc_kernel_dtb_o_start;
}
free(system_type);
}
if (!dtb->system.fdt)
dtb->system.fdt = &_binary_p10_dtb_o_start;
} else {
Expand All @@ -277,8 +330,20 @@ static void bmc_target(struct pdbg_dtb *dtb)
case CHIP_ID_P10:
pdbg_log(PDBG_INFO, "Found a POWER10 OpenBMC based system\n");
pdbg_proc = PDBG_PROC_P10;
if (!dtb->backend.fdt)
dtb->backend.fdt = &_binary_bmc_kernel_dtb_o_start;
if (!dtb->backend.fdt) {
char* system_type = get_p10_system_type();
if (strcmp(system_type, "Everest") == 0) {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel everest target");
dtb->backend.fdt = &_binary_bmc_kernel_everest_dtb_o_start;
} else if (strcmp(system_type, "Rainier 2U") == 0 || strcmp(system_type, "Rainier 4U") ==0 ) {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel rainier target");
dtb->backend.fdt = &_binary_bmc_kernel_rainier_dtb_o_start;
} else {
pdbg_log(PDBG_INFO, "bmc_target - loading bmc kernel target");
dtb->backend.fdt = &_binary_bmc_kernel_dtb_o_start;
}
free(system_type);
}
if (!dtb->system.fdt)
dtb->system.fdt = &_binary_p10_dtb_o_start;
break;
Expand Down Expand Up @@ -321,8 +386,20 @@ static void sbefifo_target(struct pdbg_dtb *dtb)
dtb->system.fdt = &_binary_p9_dtb_o_start;
} else if (!strcmp(pdbg_backend_option, "p10")) {
pdbg_proc = PDBG_PROC_P10;
if (!dtb->backend.fdt)
dtb->backend.fdt = &_binary_bmc_sbefifo_dtb_o_start;
if (!dtb->backend.fdt) {
char* system_type = get_p10_system_type();
if (strcmp(system_type, "Everest") == 0) {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo everest target");
dtb->backend.fdt = &_binary_bmc_sbefifo_everest_dtb_o_start;
} else if (strcmp(system_type, "Rainier 2U") == 0 || strcmp(system_type, "Rainier 4U") ==0 ) {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo rainier target");
dtb->backend.fdt = &_binary_bmc_sbefifo_rainier_dtb_o_start;
} else {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo target");
dtb->backend.fdt = &_binary_bmc_sbefifo_dtb_o_start;
}
free(system_type);
}
if (!dtb->system.fdt)
dtb->system.fdt = &_binary_p10_dtb_o_start;
} else {
Expand All @@ -340,8 +417,20 @@ static void sbefifo_target(struct pdbg_dtb *dtb)
case CHIP_ID_P10:
pdbg_log(PDBG_INFO, "Found a POWER10 OpenBMC based system\n");
pdbg_proc = PDBG_PROC_P10;
if (!dtb->backend.fdt)
dtb->backend.fdt = &_binary_bmc_sbefifo_dtb_o_start;
if (!dtb->backend.fdt) {
char* system_type = get_p10_system_type();
if (strcmp(system_type, "Everest") == 0) {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo everest target");
dtb->backend.fdt = &_binary_bmc_sbefifo_everest_dtb_o_start;
} else if (strcmp(system_type, "Rainier 2U") == 0 || strcmp(system_type, "Rainier 4U") ==0 ) {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo rainier target");
dtb->backend.fdt = &_binary_bmc_sbefifo_rainier_dtb_o_start;
} else {
pdbg_log(PDBG_INFO, "sbefifo_target - loading bmc sbefifo target");
dtb->backend.fdt = &_binary_bmc_sbefifo_dtb_o_start;
}
free(system_type);
}
if (!dtb->system.fdt)
dtb->system.fdt = &_binary_p10_dtb_o_start;
break;
Expand Down
6 changes: 4 additions & 2 deletions libpdbg/target.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,13 +869,15 @@ struct pdbg_target *get_backend_target(const char* class,

uint32_t ocmb_proc = pdbg_target_index(pdbg_target_parent("proc",
ocmb));
uint32_t ocmb_index = pdbg_target_index(ocmb) % 0x8;
uint32_t fapi_pos = 0;
pdbg_target_get_attribute(ocmb, "ATTR_FAPI_POS", 4, 1, &fapi_pos);
fapi_pos = fapi_pos % 0x8;
struct pdbg_target *target;
pdbg_for_each_class_target(class, target) {
uint32_t index = pdbg_target_index(target);
uint32_t proc = 0;
if(!pdbg_target_u32_property(target, "proc", &proc)) {
if(index == ocmb_index && proc == ocmb_proc) {
if(index == fapi_pos && proc == ocmb_proc) {
return target;
}
}
Expand Down

0 comments on commit c6610e4

Please sign in to comment.