arch/x86/acpigen: Add function to write a CPU package

Emits a list of CPU cores, e.g.

  Name (PPKG, Package (2) { \_PR.CP00, \_PR.CP01 })

Tested on Lenovo Thinkpad T500.

Change-Id: I10e9ebad84343d1fb282b3fbb28f5f014f664f14
Signed-off-by: Nico Huber <nico.h@gmx.de>
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/21324
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/src/arch/x86/acpigen.c b/src/arch/x86/acpigen.c
index 758386d..9637b7d 100644
--- a/src/arch/x86/acpigen.c
+++ b/src/arch/x86/acpigen.c
@@ -353,6 +353,22 @@
 	acpigen_emit_byte(pblock_len);
 }
 
+void acpigen_write_processor_package(const char *const name,
+				     const unsigned int first_core,
+				     const unsigned int core_count)
+{
+	unsigned int i;
+	char pscope[16];
+
+	acpigen_write_name(name);
+	acpigen_write_package(core_count);
+	for (i = first_core; i < first_core + core_count; ++i) {
+		snprintf(pscope, sizeof(pscope), CONFIG_ACPI_CPU_STRING, i);
+		acpigen_emit_namestring(pscope);
+	}
+	acpigen_pop_len();
+}
+
 /*
  * Generate ACPI AML code for OperationRegion
  * Arg0: Pointer to struct opregion opreg = OPREGION(rname, space, offset, len)