]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Library/BdsLib/BdsLinuxFdt.c
ArmPkg/BdsLinuxFdt.c: Check that FDT blob is correctly loaded.
[mirror_edk2.git] / ArmPkg / Library / BdsLib / BdsLinuxFdt.c
CommitLineData
0a6653bc 1/** @file\r
2*\r
7e91decd 3* Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
0a6653bc 4*\r
7e91decd 5* This program and the accompanying materials\r
6* are licensed and made available under the terms and conditions of the BSD License\r
7* which accompanies this distribution. The full text of the license may be found at\r
8* http://opensource.org/licenses/bsd-license.php\r
9*\r
10* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
0a6653bc 12*\r
13**/\r
14\r
bc87b507 15#include <Library/ArmSmcLib.h>\r
0a6653bc 16#include <Library/PcdLib.h>\r
17#include <libfdt.h>\r
18\r
bc87b507 19#include <IndustryStandard/ArmSmc.h>\r
20\r
0a6653bc 21#include "BdsInternal.h"\r
22#include "BdsLinuxLoader.h"\r
23\r
24#define ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1))\r
25#define PALIGN(p, a) ((void *)(ALIGN((unsigned long)(p), (a))))\r
26#define GET_CELL(p) (p += 4, *((const UINT32 *)(p-4)))\r
27\r
28STATIC\r
29UINTN\r
30IsPrintableString (\r
31 IN CONST VOID* data,\r
32 IN UINTN len\r
33 )\r
34{\r
35 CONST CHAR8 *s = data;\r
36 CONST CHAR8 *ss;\r
37\r
38 // Zero length is not\r
39 if (len == 0) {\r
40 return 0;\r
41 }\r
42\r
43 // Must terminate with zero\r
44 if (s[len - 1] != '\0') {\r
45 return 0;\r
46 }\r
47\r
48 ss = s;\r
49 while (*s/* && isprint(*s)*/) {\r
50 s++;\r
51 }\r
52\r
53 // Not zero, or not done yet\r
54 if (*s != '\0' || (s + 1 - ss) < len) {\r
55 return 0;\r
56 }\r
57\r
58 return 1;\r
59}\r
60\r
61STATIC\r
62VOID\r
63PrintData (\r
64 IN CONST CHAR8* data,\r
65 IN UINTN len\r
66 )\r
67{\r
68 UINTN i;\r
69 CONST CHAR8 *p = data;\r
70\r
71 // No data, don't print\r
72 if (len == 0)\r
73 return;\r
74\r
75 if (IsPrintableString (data, len)) {\r
76 Print(L" = \"%a\"", (const char *)data);\r
77 } else if ((len % 4) == 0) {\r
78 Print(L" = <");\r
79 for (i = 0; i < len; i += 4) {\r
80 Print(L"0x%08x%a", fdt32_to_cpu(GET_CELL(p)),i < (len - 4) ? " " : "");\r
81 }\r
82 Print(L">");\r
83 } else {\r
84 Print(L" = [");\r
85 for (i = 0; i < len; i++)\r
86 Print(L"%02x%a", *p++, i < len - 1 ? " " : "");\r
87 Print(L"]");\r
88 }\r
89}\r
90\r
91VOID\r
92DebugDumpFdt (\r
93 IN VOID* FdtBlob\r
94 )\r
95{\r
96 struct fdt_header *bph;\r
97 UINT32 off_dt;\r
98 UINT32 off_str;\r
99 CONST CHAR8* p_struct;\r
100 CONST CHAR8* p_strings;\r
101 CONST CHAR8* p;\r
102 CONST CHAR8* s;\r
103 CONST CHAR8* t;\r
104 UINT32 tag;\r
105 UINTN sz;\r
106 UINTN depth;\r
107 UINTN shift;\r
108 UINT32 version;\r
109\r
a01e042d 110 {\r
111 // Can 'memreserve' be printed by below code?\r
112 INTN num = fdt_num_mem_rsv(FdtBlob);\r
113 INTN i, err;\r
114 UINT64 addr = 0,size = 0;\r
115\r
116 for (i = 0; i < num; i++) {\r
117 err = fdt_get_mem_rsv(FdtBlob, i, &addr, &size);\r
118 if (err) {\r
119 DEBUG((EFI_D_ERROR, "Error (%d) : Cannot get memreserve section (%d)\n", err, i));\r
120 }\r
121 else {\r
122 Print(L"/memreserve/ \t0x%lx \t0x%lx;\n",addr,size);\r
123 }\r
124 }\r
125 }\r
126\r
0a6653bc 127 depth = 0;\r
128 shift = 4;\r
129\r
130 bph = FdtBlob;\r
131 off_dt = fdt32_to_cpu(bph->off_dt_struct);\r
132 off_str = fdt32_to_cpu(bph->off_dt_strings);\r
133 p_struct = (CONST CHAR8*)FdtBlob + off_dt;\r
134 p_strings = (CONST CHAR8*)FdtBlob + off_str;\r
135 version = fdt32_to_cpu(bph->version);\r
136\r
137 p = p_struct;\r
138 while ((tag = fdt32_to_cpu(GET_CELL(p))) != FDT_END) {\r
139 if (tag == FDT_BEGIN_NODE) {\r
140 s = p;\r
141 p = PALIGN(p + AsciiStrLen (s) + 1, 4);\r
142\r
143 if (*s == '\0')\r
144 s = "/";\r
145\r
146 Print(L"%*s%a {\n", depth * shift, L" ", s);\r
147\r
148 depth++;\r
149 continue;\r
150 }\r
151\r
152 if (tag == FDT_END_NODE) {\r
153 depth--;\r
154\r
155 Print(L"%*s};\n", depth * shift, L" ");\r
156 continue;\r
157 }\r
158\r
159 if (tag == FDT_NOP) {\r
160 Print(L"%*s// [NOP]\n", depth * shift, L" ");\r
161 continue;\r
162 }\r
163\r
164 if (tag != FDT_PROP) {\r
165 Print(L"%*s ** Unknown tag 0x%08x\n", depth * shift, L" ", tag);\r
166 break;\r
167 }\r
168 sz = fdt32_to_cpu(GET_CELL(p));\r
169 s = p_strings + fdt32_to_cpu(GET_CELL(p));\r
170 if (version < 16 && sz >= 8)\r
171 p = PALIGN(p, 8);\r
172 t = p;\r
173\r
174 p = PALIGN(p + sz, 4);\r
175\r
176 Print(L"%*s%a", depth * shift, L" ", s);\r
177 PrintData(t, sz);\r
178 Print(L";\n");\r
179 }\r
180}\r
181\r
a01e042d 182STATIC\r
183BOOLEAN\r
184IsLinuxReservedRegion (\r
185 IN EFI_MEMORY_TYPE MemoryType\r
186 )\r
187{\r
188 switch(MemoryType) {\r
189 case EfiRuntimeServicesCode:\r
190 case EfiRuntimeServicesData:\r
191 case EfiUnusableMemory:\r
192 case EfiACPIReclaimMemory:\r
193 case EfiACPIMemoryNVS:\r
194 return TRUE;\r
195 default:\r
196 return FALSE;\r
197 }\r
198}\r
199\r
200\r
0a6653bc 201typedef struct {\r
202 UINTN Base;\r
203 UINTN Size;\r
204} FdtRegion;\r
205\r
206EFI_STATUS\r
207PrepareFdt (\r
208 IN CONST CHAR8* CommandLineArguments,\r
209 IN EFI_PHYSICAL_ADDRESS InitrdImage,\r
210 IN UINTN InitrdImageSize,\r
211 IN OUT EFI_PHYSICAL_ADDRESS *FdtBlobBase,\r
c63626b7 212 IN OUT UINTN *FdtBlobSize\r
0a6653bc 213 )\r
214{\r
215 EFI_STATUS Status;\r
216 EFI_PHYSICAL_ADDRESS NewFdtBlobBase;\r
217 UINTN NewFdtBlobSize;\r
218 VOID* fdt;\r
219 INTN err;\r
220 INTN node;\r
221 INTN cpu_node;\r
222 INTN lenp;\r
223 CONST VOID* BootArg;\r
bc87b507 224 CONST VOID* Method;\r
0a6653bc 225 EFI_PHYSICAL_ADDRESS InitrdImageStart;\r
226 EFI_PHYSICAL_ADDRESS InitrdImageEnd;\r
227 FdtRegion Region;\r
228 UINTN Index;\r
229 CHAR8 Name[10];\r
230 LIST_ENTRY ResourceList;\r
231 BDS_SYSTEM_MEMORY_RESOURCE *Resource;\r
232 ARM_PROCESSOR_TABLE *ArmProcessorTable;\r
233 ARM_CORE_INFO *ArmCoreInfoTable;\r
234 UINT32 MpId;\r
235 UINT32 ClusterId;\r
236 UINT32 CoreId;\r
237 UINT64 CpuReleaseAddr;\r
a01e042d 238 UINTN MemoryMapSize;\r
239 EFI_MEMORY_DESCRIPTOR *MemoryMap;\r
240 UINTN MapKey;\r
241 UINTN DescriptorSize;\r
242 UINT32 DescriptorVersion;\r
243 UINTN Pages;\r
bc87b507 244 BOOLEAN PsciSmcSupported;\r
245 UINTN Rx;\r
7e91decd 246 UINTN OriginalFdtSize;\r
bc87b507 247\r
248 //\r
249 // Ensure the Power State Coordination Interface (PSCI) SMCs are there if supported\r
250 //\r
251 PsciSmcSupported = FALSE;\r
252 if (FeaturePcdGet (PcdArmPsciSupport) == TRUE) {\r
253 // Check the SMC response to the Presence SMC\r
254 Rx = ARM_SMC_ID_PRESENCE;\r
255 ArmCallSmc (&Rx);\r
256 if (Rx == 1) {\r
257 // Check the SMC UID\r
258 Rx = ARM_SMC_ID_UID;\r
259 ArmCallSmc (&Rx);\r
260 if (Rx == ARM_TRUSTZONE_UID_4LETTERID) {\r
261 Rx = ARM_SMC_ID_UID + 1;\r
262 ArmCallSmc (&Rx);\r
263 //TODO: Replace ARM magic number\r
264 if (Rx == 0x40524d48) {\r
265 PsciSmcSupported = TRUE;\r
266 }\r
267 }\r
268 if (PsciSmcSupported == FALSE) {\r
269 DEBUG((EFI_D_ERROR,"Warning: The Power State Coordination Interface (PSCI) is not supported"\r
270 "by your platform Trusted Firmware.\n"));\r
271 }\r
272 }\r
273 }\r
0a6653bc 274\r
7e91decd 275 //\r
276 // Sanity checks on the original FDT blob.\r
277 //\r
0a6653bc 278 err = fdt_check_header ((VOID*)(UINTN)(*FdtBlobBase));\r
279 if (err != 0) {\r
280 Print (L"ERROR: Device Tree header not valid (err:%d)\n", err);\r
281 return EFI_INVALID_PARAMETER;\r
282 }\r
283\r
7e91decd 284 // The original FDT blob might have been loaded partially.\r
285 // Check that it is not the case.\r
286 OriginalFdtSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));\r
287 if (OriginalFdtSize > *FdtBlobSize) {\r
288 Print (L"ERROR: Incomplete FDT. Only %d/%d bytes have been loaded.\n",\r
289 *FdtBlobSize, OriginalFdtSize);\r
290 return EFI_INVALID_PARAMETER;\r
291 }\r
292\r
0a6653bc 293 //\r
294 // Allocate memory for the new FDT\r
295 //\r
7e91decd 296 NewFdtBlobSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;\r
0a6653bc 297\r
298 // Try below a watermark address\r
299 Status = EFI_NOT_FOUND;\r
300 if (PcdGet32(PcdArmLinuxFdtMaxOffset) != 0) {\r
301 NewFdtBlobBase = LINUX_FDT_MAX_OFFSET;\r
302 Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);\r
303 if (EFI_ERROR(Status)) {\r
304 DEBUG ((EFI_D_WARN, "Warning: Failed to load FDT below address 0x%lX (%r). Will try again at a random address anywhere.\n", NewFdtBlobBase, Status));\r
305 }\r
306 }\r
307\r
308 // Try anywhere there is available space\r
309 if (EFI_ERROR(Status)) {\r
310 Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);\r
311 if (EFI_ERROR(Status)) {\r
312 ASSERT_EFI_ERROR(Status);\r
313 goto FAIL_NEW_FDT;\r
314 } else {\r
315 DEBUG ((EFI_D_WARN, "WARNING: Loaded FDT at random address 0x%lX.\nWARNING: There is a risk of accidental overwriting by other code/data.\n", NewFdtBlobBase));\r
316 }\r
317 }\r
318\r
319 // Load the Original FDT tree into the new region\r
320 fdt = (VOID*)(UINTN)NewFdtBlobBase;\r
321 err = fdt_open_into((VOID*)(UINTN)(*FdtBlobBase), fdt, NewFdtBlobSize);\r
322 if (err) {\r
323 DEBUG((EFI_D_ERROR, "fdt_open_into(): %a\n", fdt_strerror(err)));\r
324 Status = EFI_INVALID_PARAMETER;\r
325 goto FAIL_NEW_FDT;\r
326 }\r
327\r
328 DEBUG_CODE_BEGIN();\r
329 //DebugDumpFdt (fdt);\r
330 DEBUG_CODE_END();\r
331\r
332 node = fdt_subnode_offset(fdt, 0, "chosen");\r
333 if (node < 0) {\r
334 // The 'chosen' node does not exist, create it\r
335 node = fdt_add_subnode(fdt, 0, "chosen");\r
336 if (node < 0) {\r
337 DEBUG((EFI_D_ERROR,"Error on finding 'chosen' node\n"));\r
338 Status = EFI_INVALID_PARAMETER;\r
339 goto FAIL_NEW_FDT;\r
340 }\r
341 }\r
342\r
343 DEBUG_CODE_BEGIN();\r
344 BootArg = fdt_getprop(fdt, node, "bootargs", &lenp);\r
345 if (BootArg != NULL) {\r
346 DEBUG((EFI_D_ERROR,"BootArg: %a\n",BootArg));\r
347 }\r
348 DEBUG_CODE_END();\r
349\r
a01e042d 350 //\r
0a6653bc 351 // Set Linux CmdLine\r
a01e042d 352 //\r
0a6653bc 353 if ((CommandLineArguments != NULL) && (AsciiStrLen (CommandLineArguments) > 0)) {\r
354 err = fdt_setprop(fdt, node, "bootargs", CommandLineArguments, AsciiStrSize(CommandLineArguments));\r
355 if (err) {\r
356 DEBUG((EFI_D_ERROR,"Fail to set new 'bootarg' (err:%d)\n",err));\r
357 }\r
358 }\r
359\r
a01e042d 360 //\r
0a6653bc 361 // Set Linux Initrd\r
a01e042d 362 //\r
0a6653bc 363 if (InitrdImageSize != 0) {\r
364 InitrdImageStart = cpu_to_fdt64 (InitrdImage);\r
365 err = fdt_setprop(fdt, node, "linux,initrd-start", &InitrdImageStart, sizeof(EFI_PHYSICAL_ADDRESS));\r
366 if (err) {\r
367 DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));\r
368 }\r
369 InitrdImageEnd = cpu_to_fdt64 (InitrdImage + InitrdImageSize);\r
370 err = fdt_setprop(fdt, node, "linux,initrd-end", &InitrdImageEnd, sizeof(EFI_PHYSICAL_ADDRESS));\r
371 if (err) {\r
372 DEBUG((EFI_D_ERROR,"Fail to set new 'linux,initrd-start' (err:%d)\n",err));\r
373 }\r
374 }\r
375\r
a01e042d 376 //\r
0a6653bc 377 // Set Physical memory setup if does not exist\r
a01e042d 378 //\r
0a6653bc 379 node = fdt_subnode_offset(fdt, 0, "memory");\r
380 if (node < 0) {\r
381 // The 'memory' node does not exist, create it\r
382 node = fdt_add_subnode(fdt, 0, "memory");\r
383 if (node >= 0) {\r
384 fdt_setprop_string(fdt, node, "name", "memory");\r
385 fdt_setprop_string(fdt, node, "device_type", "memory");\r
7e91decd 386\r
0a6653bc 387 GetSystemMemoryResources (&ResourceList);\r
388 Resource = (BDS_SYSTEM_MEMORY_RESOURCE*)ResourceList.ForwardLink;\r
7e91decd 389\r
0a6653bc 390 if (sizeof(UINTN) == sizeof(UINT32)) {\r
391 Region.Base = cpu_to_fdt32((UINTN)Resource->PhysicalStart);\r
392 Region.Size = cpu_to_fdt32((UINTN)Resource->ResourceLength);\r
393 } else {\r
394 Region.Base = cpu_to_fdt64((UINTN)Resource->PhysicalStart);\r
395 Region.Size = cpu_to_fdt64((UINTN)Resource->ResourceLength);\r
396 }\r
397\r
398 err = fdt_setprop(fdt, node, "reg", &Region, sizeof(Region));\r
399 if (err) {\r
400 DEBUG((EFI_D_ERROR,"Fail to set new 'memory region' (err:%d)\n",err));\r
401 }\r
402 }\r
403 }\r
404\r
a01e042d 405 //\r
406 // Add the memory regions reserved by the UEFI Firmware\r
407 //\r
408\r
409 // Retrieve the UEFI Memory Map\r
410 MemoryMap = NULL;\r
411 MemoryMapSize = 0;\r
412 Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
413 if (Status == EFI_BUFFER_TOO_SMALL) {\r
414 Pages = EFI_SIZE_TO_PAGES (MemoryMapSize) + 1;\r
415 MemoryMap = AllocatePages (Pages);\r
416 Status = gBS->GetMemoryMap (&MemoryMapSize, MemoryMap, &MapKey, &DescriptorSize, &DescriptorVersion);\r
417 }\r
418\r
419 // Go through the list and add the reserved region to the Device Tree\r
420 if (!EFI_ERROR(Status)) {\r
421 for (Index = 0; Index < (MemoryMapSize / sizeof(EFI_MEMORY_DESCRIPTOR)); Index++) {\r
422 if (IsLinuxReservedRegion ((EFI_MEMORY_TYPE)MemoryMap[Index].Type)) {\r
423 DEBUG((DEBUG_VERBOSE, "Reserved region of type %d [0x%X, 0x%X]\n",\r
424 MemoryMap[Index].Type,\r
425 (UINTN)MemoryMap[Index].PhysicalStart,\r
426 (UINTN)(MemoryMap[Index].PhysicalStart + MemoryMap[Index].NumberOfPages * EFI_PAGE_SIZE)));\r
427 err = fdt_add_mem_rsv(fdt, MemoryMap[Index].PhysicalStart, MemoryMap[Index].NumberOfPages * EFI_PAGE_SIZE);\r
428 if (err != 0) {\r
429 Print(L"Warning: Fail to add 'memreserve' (err:%d)\n", err);\r
430 }\r
431 }\r
432 }\r
433 }\r
434\r
435 //\r
0a6653bc 436 // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms\r
a01e042d 437 //\r
0a6653bc 438 for (Index=0; Index < gST->NumberOfTableEntries; Index++) {\r
439 // Check for correct GUID type\r
440 if (CompareGuid (&gArmMpCoreInfoGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {\r
441 MpId = ArmReadMpidr ();\r
442 ClusterId = GET_CLUSTER_ID(MpId);\r
443 CoreId = GET_CORE_ID(MpId);\r
444\r
445 node = fdt_subnode_offset(fdt, 0, "cpus");\r
446 if (node < 0) {\r
447 // Create the /cpus node\r
448 node = fdt_add_subnode(fdt, 0, "cpus");\r
449 fdt_setprop_string(fdt, node, "name", "cpus");\r
450 fdt_setprop_cell(fdt, node, "#address-cells", 1);\r
451 fdt_setprop_cell(fdt, node, "#size-cells", 0);\r
452 }\r
453\r
454 // Get pointer to ARM processor table\r
455 ArmProcessorTable = (ARM_PROCESSOR_TABLE *)gST->ConfigurationTable[Index].VendorTable;\r
456 ArmCoreInfoTable = ArmProcessorTable->ArmCpus;\r
457\r
458 for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {\r
459 AsciiSPrint (Name, 10, "cpu@%d", Index);\r
460 cpu_node = fdt_subnode_offset(fdt, node, Name);\r
461 if (cpu_node < 0) {\r
462 cpu_node = fdt_add_subnode(fdt, node, Name);\r
463 fdt_setprop_string(fdt, cpu_node, "device-type", "cpu");\r
464 fdt_setprop(fdt, cpu_node, "reg", &Index, sizeof(Index));\r
465 }\r
466\r
bc87b507 467 // If Power State Coordination Interface (PSCI) is not supported then it is expected the secondary\r
39f58c9b 468 // cores are spinning waiting for the Operating System to release them\r
bc87b507 469 if (PsciSmcSupported == FALSE) {\r
39f58c9b 470 // We as the bootloader are responsible for either creating or updating\r
471 // these entries. Do not trust the entries in the DT. We only know about\r
472 // 'spin-table' type. Do not try to update other types if defined.\r
bc87b507 473 Method = fdt_getprop(fdt, cpu_node, "enable-method", &lenp);\r
39f58c9b 474 if ( (Method == NULL) || (!AsciiStrCmp((CHAR8 *)Method, "spin-table")) ) {\r
bc87b507 475 fdt_setprop_string(fdt, cpu_node, "enable-method", "spin-table");\r
476 CpuReleaseAddr = cpu_to_fdt64(ArmCoreInfoTable[Index].MailboxSetAddress);\r
477 fdt_setprop(fdt, cpu_node, "cpu-release-addr", &CpuReleaseAddr, sizeof(CpuReleaseAddr));\r
478\r
479 // If it is not the primary core than the cpu should be disabled\r
480 if (((ArmCoreInfoTable[Index].ClusterId != ClusterId) || (ArmCoreInfoTable[Index].CoreId != CoreId))) {\r
481 fdt_setprop_string(fdt, cpu_node, "status", "disabled");\r
482 }\r
39f58c9b 483 } else {\r
484 Print(L"Warning: Unsupported enable-method type for CPU[%d] : %a\n", Index, (CHAR8 *)Method);\r
bc87b507 485 }\r
0a6653bc 486 }\r
487 }\r
488 break;\r
489 }\r
490 }\r
491\r
bc87b507 492 // If the Power State Coordination Interface is supported then we signal it in the Device Tree\r
493 if (PsciSmcSupported == TRUE) {\r
494 // Before to create it we check if the node is not already defined in the Device Tree\r
495 node = fdt_subnode_offset(fdt, 0, "psci");\r
496 if (node < 0) {\r
497 // The 'psci' node does not exist, create it\r
498 node = fdt_add_subnode(fdt, 0, "psci");\r
499 if (node < 0) {\r
500 DEBUG((EFI_D_ERROR,"Error on creating 'psci' node\n"));\r
501 Status = EFI_INVALID_PARAMETER;\r
502 goto FAIL_NEW_FDT;\r
503 } else {\r
504 fdt_setprop_string(fdt, node, "compatible", "arm,psci");\r
505 fdt_setprop_string(fdt, node, "method", "smc");\r
506 fdt_setprop_cell(fdt, node, "cpu_suspend", ARM_SMC_ARM_CPU_SUSPEND);\r
507 fdt_setprop_cell(fdt, node, "cpu_off", ARM_SMC_ARM_CPU_OFF);\r
508 fdt_setprop_cell(fdt, node, "cpu_on", ARM_SMC_ARM_CPU_ON);\r
509 fdt_setprop_cell(fdt, node, "cpu_migrate", ARM_SMC_ARM_MIGRATE);\r
510 }\r
511 }\r
512 }\r
513\r
0a6653bc 514 DEBUG_CODE_BEGIN();\r
515 //DebugDumpFdt (fdt);\r
516 DEBUG_CODE_END();\r
517\r
518 *FdtBlobBase = NewFdtBlobBase;\r
519 *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(NewFdtBlobBase));\r
520 return EFI_SUCCESS;\r
521\r
522FAIL_NEW_FDT:\r
7e91decd 523 *FdtBlobSize = OriginalFdtSize;\r
0a6653bc 524 // Return success even if we failed to update the FDT blob. The original one is still valid.\r
525 return EFI_SUCCESS;\r
526}\r
527\r
528\r