BOOLEAN PsciSmcSupported;\r
UINTN Rx;\r
UINTN OriginalFdtSize;\r
+ BOOLEAN CpusNodeExist;\r
\r
//\r
// Ensure the Power State Coordination Interface (PSCI) SMCs are there if supported\r
fdt_setprop_string(fdt, node, "name", "cpus");\r
fdt_setprop_cell(fdt, node, "#address-cells", 1);\r
fdt_setprop_cell(fdt, node, "#size-cells", 0);\r
+ CpusNodeExist = FALSE;\r
+ } else {\r
+ CpusNodeExist = TRUE;\r
}\r
\r
// Get pointer to ARM processor table\r
\r
for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {\r
AsciiSPrint (Name, 10, "cpu@%d", Index);\r
- cpu_node = fdt_subnode_offset(fdt, node, Name);\r
- if (cpu_node < 0) {\r
+\r
+ // If the 'cpus' node did not exist then creates the 'cpu' nodes. In case 'cpus' node\r
+ // is provided in the original FDT then we do not add any 'cpu' node.\r
+ if (!CpusNodeExist) {\r
cpu_node = fdt_add_subnode(fdt, node, Name);\r
fdt_setprop_string(fdt, cpu_node, "device-type", "cpu");\r
fdt_setprop(fdt, cpu_node, "reg", &Index, sizeof(Index));\r
+ } else {\r
+ cpu_node = fdt_subnode_offset(fdt, node, Name);\r
}\r
\r
// If Power State Coordination Interface (PSCI) is not supported then it is expected the secondary\r
// cores are spinning waiting for the Operating System to release them\r
- if (PsciSmcSupported == FALSE) {\r
+ if ((PsciSmcSupported == FALSE) && (cpu_node >= 0)) {\r
// We as the bootloader are responsible for either creating or updating\r
// these entries. Do not trust the entries in the DT. We only know about\r
// 'spin-table' type. Do not try to update other types if defined.\r