Revision: 14351
http://edk2.svn.sourceforge.net/edk2/?rev=14351&view=rev
Author: oliviermartin
Date: 2013-05-12 23:56:35 +0000 (Sun, 12 May 2013)
Log Message:
-----------
ArmPkg/BdsLinuxFdt.c: Fix creation of 'cpu' and 'psci' device tree nodes.
* Fix name of 'device_type' and 'migrate' properties.
* Fix 'reg' property. It is supposed to contain the CPU MPIDR of the
CPU being described.
* Fix byte ordering of data in 'psci' node.
* Fix some problems regarding the size of data. In a number of places
it was assumed data would be 32-bits wide.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <[email protected]>
Modified Paths:
--------------
trunk/edk2/ArmPkg/Include/Library/ArmLib.h
trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
Modified: trunk/edk2/ArmPkg/Include/Library/ArmLib.h
===================================================================
--- trunk/edk2/ArmPkg/Include/Library/ArmLib.h 2013-05-12 23:55:22 UTC (rev
14350)
+++ trunk/edk2/ArmPkg/Include/Library/ArmLib.h 2013-05-12 23:56:35 UTC (rev
14351)
@@ -116,6 +116,7 @@
#define ARM_CLUSTER_MASK (0xFF << 8)
#define GET_CORE_ID(MpId) ((MpId) & ARM_CORE_MASK)
#define GET_CLUSTER_ID(MpId) (((MpId) & ARM_CLUSTER_MASK) >> 8)
+#define GET_MPID(ClusterId, CoreId) (((ClusterId) << 8) | (CoreId))
// Get the position of the core for the Stack Offset (4 Core per Cluster)
// Position = (ClusterId * 4) + CoreId
#define GET_CORE_POS(MpId) ((((MpId) & ARM_CLUSTER_MASK) >> 6) + ((MpId) &
ARM_CORE_MASK))
Modified: trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
===================================================================
--- trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c 2013-05-12 23:55:22 UTC
(rev 14350)
+++ trunk/edk2/ArmPkg/Library/BdsLib/BdsLinuxFdt.c 2013-05-12 23:56:35 UTC
(rev 14351)
@@ -361,6 +361,8 @@
BOOLEAN PsciSmcSupported;
UINTN OriginalFdtSize;
BOOLEAN CpusNodeExist;
+ UINTN CoreMpId;
+ UINTN Smc;
NewFdtBlobAllocation = 0;
@@ -503,8 +505,12 @@
}
//
- // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms
+ // Setup Arm Mpcore Info if it is a multi-core or multi-cluster platforms.
//
+ // For 'cpus' and 'cpu' device tree nodes bindings, refer to this file
+ // in the kernel documentation:
+ // Documentation/devicetree/bindings/arm/cpus.txt
+ //
for (Index=0; Index < gST->NumberOfTableEntries; Index++) {
// Check for correct GUID type
if (CompareGuid (&gArmMpCoreInfoGuid,
&(gST->ConfigurationTable[Index].VendorGuid))) {
@@ -517,7 +523,7 @@
// Create the /cpus node
node = fdt_add_subnode(fdt, 0, "cpus");
fdt_setprop_string(fdt, node, "name", "cpus");
- fdt_setprop_cell(fdt, node, "#address-cells", 1);
+ fdt_setprop_cell (fdt, node, "#address-cells", sizeof (UINTN) / 4);
fdt_setprop_cell(fdt, node, "#size-cells", 0);
CpusNodeExist = FALSE;
} else {
@@ -531,12 +537,25 @@
for (Index = 0; Index < ArmProcessorTable->NumberOfEntries; Index++) {
AsciiSPrint (Name, 10, "cpu@%d", Index);
- // If the 'cpus' node did not exist then creates the 'cpu' nodes. In
case 'cpus' node
- // is provided in the original FDT then we do not add any 'cpu' node.
+ // If the 'cpus' node did not exist then create all the 'cpu' nodes.
+ // In case 'cpus' node is provided in the original FDT then we do not
add
+ // any 'cpu' node.
if (!CpusNodeExist) {
- cpu_node = fdt_add_subnode(fdt, node, Name);
- fdt_setprop_string(fdt, cpu_node, "device-type", "cpu");
- fdt_setprop(fdt, cpu_node, "reg", &Index, sizeof(Index));
+ cpu_node = fdt_add_subnode (fdt, node, Name);
+ if (cpu_node < 0) {
+ DEBUG ((EFI_D_ERROR, "Error on creating '%s' node\n", Name));
+ Status = EFI_INVALID_PARAMETER;
+ goto FAIL_COMPLETE_FDT;
+ }
+
+ fdt_setprop_string (fdt, cpu_node, "device_type", "cpu");
+ CoreMpId = (UINTN) GET_MPID (ArmCoreInfoTable[Index].ClusterId,
+ ArmCoreInfoTable[Index].CoreId);
+ CoreMpId = cpu_to_fdtn (CoreMpId);
+ fdt_setprop (fdt, cpu_node, "reg", &CoreMpId, sizeof (CoreMpId));
+ if (PsciSmcSupported) {
+ fdt_setprop_string (fdt, cpu_node, "enable-method", "psci");
+ }
} else {
cpu_node = fdt_subnode_offset(fdt, node, Name);
}
@@ -578,12 +597,20 @@
Status = EFI_INVALID_PARAMETER;
goto FAIL_COMPLETE_FDT;
} else {
- fdt_setprop_string(fdt, node, "compatible", "arm,psci");
- fdt_setprop_string(fdt, node, "method", "smc");
- fdt_setprop_cell(fdt, node, "cpu_suspend", ARM_SMC_ARM_CPU_SUSPEND);
- fdt_setprop_cell(fdt, node, "cpu_off", ARM_SMC_ARM_CPU_OFF);
- fdt_setprop_cell(fdt, node, "cpu_on", ARM_SMC_ARM_CPU_ON);
- fdt_setprop_cell(fdt, node, "cpu_migrate", ARM_SMC_ARM_MIGRATE);
+ fdt_setprop_string (fdt, node, "compatible", "arm,psci");
+ fdt_setprop_string (fdt, node, "method", "smc");
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_SUSPEND);
+ fdt_setprop (fdt, node, "cpu_suspend", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_OFF);
+ fdt_setprop (fdt, node, "cpu_off", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_CPU_ON);
+ fdt_setprop (fdt, node, "cpu_on", &Smc, sizeof (Smc));
+
+ Smc = cpu_to_fdtn (ARM_SMC_ARM_MIGRATE);
+ fdt_setprop (fdt, node, "migrate", &Smc, sizeof (Smc));
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits