[Skiboot] [PATCH 5/7] hdata: Remove legacy SPIRA structure

Nicholas Piggin npiggin at gmail.com
Wed Sep 6 20:10:15 AEST 2023


skiboot only supports POWER8 > DD1 now, all supported platforms
should use the new SPIRA-S/H structure.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 hdata/fsp.c               |  12 +--
 hdata/iohub.c             |   4 +-
 hdata/memory.c            |   8 +-
 hdata/naca.c              |   4 +-
 hdata/pcia.c              |   6 +-
 hdata/slca.c              |   4 +-
 hdata/spira.c             | 149 +++++++-------------------------------
 hdata/spira.h             |  69 ++----------------
 hdata/test/Makefile.check |  21 +++---
 hdata/test/hdata_to_dt.c  |  53 ++++----------
 hdata/tpmrel.c            |   2 +-
 hdata/vpd.c               |  27 +++----
 hw/fsp/fsp-attn.c         |   1 -
 include/mem-map.h         |  20 +++--
 skiboot.lds.S             |   5 --
 15 files changed, 101 insertions(+), 284 deletions(-)

diff --git a/hdata/fsp.c b/hdata/fsp.c
index 30cda53f6..66b351b42 100644
--- a/hdata/fsp.c
+++ b/hdata/fsp.c
@@ -282,7 +282,7 @@ static void add_chip_id_to_sensors(struct dt_node *sensor_node, uint32_t slca_in
 		return;
 	}
 
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i, SPPCRD_HDIF_SIG) {
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i, SPPCRD_HDIF_SIG) {
 		fru_id = HDIF_get_idata(hdif, SPPCRD_IDATA_FRU_ID, NULL);
 		if (!fru_id)
 			return;
@@ -309,7 +309,7 @@ static void add_ipmi_sensors(struct dt_node *bmc_node)
 	const struct ipmi_sensors *ipmi_sensors;
 	struct dt_node *sensors_node, *sensor_node;
 
-	hdif_sensor = get_hdif(&spira.ntuples.ipmi_sensor, IPMI_SENSORS_HDIF_SIG);
+	hdif_sensor = get_hdif(&spiras->ntuples.ipmi_sensor, IPMI_SENSORS_HDIF_SIG);
 	if (!hdif_sensor) {
 		prlog(PR_DEBUG, "SENSORS: Missing IPMI sensors mappings tuple\n");
 		return;
@@ -498,11 +498,11 @@ void bmc_parse(void)
 	const void *sp;
 	int i;
 
-	sp = get_hdif(&spira.ntuples.sp_subsys, SPSS_HDIF_SIG);
+	sp = get_hdif(&spiras->ntuples.sp_subsys, SPSS_HDIF_SIG);
 	if (!sp)
 		return;
 
-	for_each_ntuple_idx(&spira.ntuples.sp_subsys, sp, i, SPSS_HDIF_SIG) {
+	for_each_ntuple_idx(&spiras->ntuples.sp_subsys, sp, i, SPSS_HDIF_SIG) {
 		if (find_service_proc_type(sp, i) == SP_BMC) {
 			bmc_create_node(sp);
 			found = true;
@@ -520,13 +520,13 @@ void fsp_parse(void)
 	int index;
 
 	/* Find SPSS tuple in SPIRA */
-	sp = get_hdif(&spira.ntuples.sp_subsys, SPSS_HDIF_SIG);
+	sp = get_hdif(&spiras->ntuples.sp_subsys, SPSS_HDIF_SIG);
 	if (!sp) {
 		prlog(PR_WARNING, "HDAT: No FSP/BMC found!\n");
 		return;
 	}
 
-	for_each_ntuple_idx(&spira.ntuples.sp_subsys, sp, index, SPSS_HDIF_SIG) {
+	for_each_ntuple_idx(&spiras->ntuples.sp_subsys, sp, index, SPSS_HDIF_SIG) {
 		switch (find_service_proc_type(sp, index)) {
 		case SP_FSP:
 			if (!fsp_root) {
diff --git a/hdata/iohub.c b/hdata/iohub.c
index 92655407e..d1074241b 100644
--- a/hdata/iohub.c
+++ b/hdata/iohub.c
@@ -868,7 +868,7 @@ void io_parse(void)
 	unsigned int i, size;
 
 	/* Look for IO Hubs */
-	if (!get_hdif(&spira.ntuples.cec_iohub_fru, "IO HUB")) {
+	if (!get_hdif(&spiras->ntuples.cec_iohub_fru, "IO HUB")) {
 		prerror("CEC: Cannot locate IO Hub FRU data !\n");
 		return;
 	}
@@ -881,7 +881,7 @@ void io_parse(void)
 	 * increment it for each chip. Works for the machines I have here
 	 */
 
-	for_each_ntuple_idx(&spira.ntuples.cec_iohub_fru, sp_iohubs, i,
+	for_each_ntuple_idx(&spiras->ntuples.cec_iohub_fru, sp_iohubs, i,
 			    CECHUB_FRU_HDIF_SIG) {
 		const struct cechub_hub_fru_id *fru_id_data;
 		unsigned int type;
diff --git a/hdata/memory.c b/hdata/memory.c
index efdb502b1..0b4e78585 100755
--- a/hdata/memory.c
+++ b/hdata/memory.c
@@ -236,7 +236,7 @@ static void add_bus_freq_to_ram_area(struct dt_node *ram_node, u32 chip_id)
 	u64 freq;
 	u32 size;
 
-	pcia = get_hdif(&spira.ntuples.pcia, SPPCIA_HDIF_SIG);
+	pcia = get_hdif(&spiras->ntuples.pcia, SPPCIA_HDIF_SIG);
 	if (!pcia) {
 		prlog(PR_WARNING, "HDAT: Failed to add memory bus frequency "
 		      "as PCIA does not exist\n");
@@ -897,15 +897,15 @@ static bool __memory_parse(struct dt_node *root)
 	const struct msvpd_total_config_ms *tcms;
 	unsigned int size;
 
-	ms_vpd = get_hdif(&spira.ntuples.ms_vpd, MSVPD_HDIF_SIG);
+	ms_vpd = get_hdif(&spiras->ntuples.ms_vpd, MSVPD_HDIF_SIG);
 	if (!ms_vpd) {
 		prerror("MS VPD: invalid\n");
 		op_display(OP_FATAL, OP_MOD_MEM, 0x0000);
 		return false;
 	}
-	if (be32_to_cpu(spira.ntuples.ms_vpd.act_len) < sizeof(*ms_vpd)) {
+	if (be32_to_cpu(spiras->ntuples.ms_vpd.act_len) < sizeof(*ms_vpd)) {
 		prerror("MS VPD: invalid size %u\n",
-			be32_to_cpu(spira.ntuples.ms_vpd.act_len));
+			be32_to_cpu(spiras->ntuples.ms_vpd.act_len));
 		op_display(OP_FATAL, OP_MOD_MEM, 0x0001);
 		return false;
 	}
diff --git a/hdata/naca.c b/hdata/naca.c
index 9581bb632..4fc43d861 100644
--- a/hdata/naca.c
+++ b/hdata/naca.c
@@ -9,9 +9,9 @@
 __section(".naca.data") struct naca naca = {
 	.spirah_addr = CPU_TO_BE64(SPIRAH_OFF),
 	.hv_release_data_addr = CPU_TO_BE64(NACA_OFF + offsetof(struct naca, hv_release_data)),
-	.spira_addr = CPU_TO_BE64(SPIRA_OFF),
+	.spira_addr = 0,
 	.lid_table_addr = CPU_TO_BE64(NACA_OFF + offsetof(struct naca, hv_lid_load_table)),
-	.spira_size = CPU_TO_BE32(SPIRA_ACTUAL_SIZE),
+	.spira_size = 0,
 	.hv_load_map_addr = 0,
 	.attn_enabled = 0,
 	.pcia_supported = 1,
diff --git a/hdata/pcia.c b/hdata/pcia.c
index f10048674..47f40cfec 100644
--- a/hdata/pcia.c
+++ b/hdata/pcia.c
@@ -15,8 +15,8 @@
 
 static unsigned int pcia_index(const void *pcia)
 {
-	return (pcia - (void *)get_hdif(&spira.ntuples.pcia, "SPPCIA"))
-		/ be32_to_cpu(spira.ntuples.pcia.alloc_len);
+	return (pcia - (void *)get_hdif(&spiras->ntuples.pcia, "SPPCIA"))
+		/ be32_to_cpu(spiras->ntuples.pcia.alloc_len);
 }
 
 static const struct sppcia_cpu_thread *find_tada(const void *pcia,
@@ -180,7 +180,7 @@ bool pcia_parse(void)
 	const void *pcia;
 	struct dt_node *cpus;
 
-	pcia = get_hdif(&spira.ntuples.pcia, "SPPCIA");
+	pcia = get_hdif(&spiras->ntuples.pcia, "SPPCIA");
 	if (!pcia)
 		return false;
 
diff --git a/hdata/slca.c b/hdata/slca.c
index 131e815af..fe8ed61e8 100644
--- a/hdata/slca.c
+++ b/hdata/slca.c
@@ -13,7 +13,7 @@ const struct slca_entry *slca_get_entry(uint16_t slca_index)
 	struct HDIF_common_hdr *slca_hdr;
 	int count;
 
-	slca_hdr = get_hdif(&spira.ntuples.slca, SLCA_HDIF_SIG);
+	slca_hdr = get_hdif(&spiras->ntuples.slca, SLCA_HDIF_SIG);
 	if (!slca_hdr) {
 		prerror("SLCA Invalid\n");
 		return NULL;
@@ -89,7 +89,7 @@ static const struct slca_entry *slca_get_sai_entry(void)
 	struct HDIF_common_hdr *slca_hdr;
 	uint16_t sai_fru_id = SLCA_SAI_INDICATOR_ID;
 
-	slca_hdr = get_hdif(&spira.ntuples.slca, SLCA_HDIF_SIG);
+	slca_hdr = get_hdif(&spiras->ntuples.slca, SLCA_HDIF_SIG);
 	if (!slca_hdr) {
 		prerror("SLCA Invalid\n");
 		return NULL;
diff --git a/hdata/spira.c b/hdata/spira.c
index fbb14b0ec..500d317a1 100644
--- a/hdata/spira.c
+++ b/hdata/spira.c
@@ -121,48 +121,6 @@ __section(".mdst.data") struct mdst_table init_mdst_table[2] = {
 	},
 };
 
-/* SP Interface Root Array, aka SPIRA */
-__section(".spira.data") struct spira spira = {
-	.hdr = HDIF_SIMPLE_HDR("SPIRA ", SPIRA_VERSION, struct spira),
-	.ntuples_ptr = HDIF_IDATA_PTR(offsetof(struct spira, ntuples),
-				      sizeof(struct spira_ntuples)),
-	.ntuples = {
-		.array_hdr = {
-			.offset		= CPU_TO_BE32(HDIF_ARRAY_OFFSET),
-			.ecnt		= CPU_TO_BE32(SPIRA_NTUPLES_COUNT),
-			.esize
-				= CPU_TO_BE32(sizeof(struct spira_ntuple)),
-			.eactsz		= CPU_TO_BE32(0x18),
-		},
-		/* We only populate some n-tuples */
-		.proc_init = {
-			.addr  		= CPU_TO_BE64(PROCIN_OFF),
-			.alloc_cnt	= CPU_TO_BE16(1),
-			.act_cnt	= CPU_TO_BE16(1),
-			.alloc_len
-			= CPU_TO_BE32(sizeof(struct proc_init_data)),
-		},
-		.heap = {
-			.addr		= CPU_TO_BE64(SPIRA_HEAP_BASE),
-			.alloc_cnt	= CPU_TO_BE16(1),
-			.alloc_len	= CPU_TO_BE32(SPIRA_HEAP_SIZE),
-		},
-		.mdump_src = {
-			.addr		= CPU_TO_BE64(MDST_TABLE_OFF),
-			.alloc_cnt	= CPU_TO_BE16(ARRAY_SIZE(init_mdst_table)),
-			.act_cnt	= CPU_TO_BE16(ARRAY_SIZE(init_mdst_table)),
-			.alloc_len	=
-				CPU_TO_BE32(sizeof(init_mdst_table)),
-		},
-		.cpu_ctrl = {
-			.addr		= CPU_TO_BE64(CPU_CTL_INIT_DATA_OFF),
-			.alloc_cnt	= CPU_TO_BE16(1),
-			.act_cnt	= CPU_TO_BE16(1),
-			.alloc_len	= CPU_TO_BE32(sizeof(cpu_ctl_init_data)),
-		},
-	},
-};
-
 /* The Hypervisor SPIRA-H Structure */
 __section(".spirah.data") struct spirah spirah = {
 	.hdr = HDIF_SIMPLE_HDR(SPIRAH_HDIF_SIG, SPIRAH_VERSION, struct spirah),
@@ -376,7 +334,7 @@ static struct dt_node *add_xscom_node(uint64_t base,
 #define GET_HDIF_HDR -1
 static const void *xscom_to_pcrd(struct dt_node *xscom, int idata_index)
 {
-	struct spira_ntuple *t = &spira.ntuples.proc_chip;
+	struct spira_ntuple *t = &spiras->ntuples.proc_chip;
 	const struct HDIF_common_hdr *hdif;
 	const void *idata;
 	unsigned int size;
@@ -567,7 +525,7 @@ static void add_xscom_add_pcia_assoc(struct dt_node *np, uint32_t pcid)
 	 * affinity can be different for groups of cores within the
 	 * chip, but for now we are going to ignore that
 	 */
-	hdr = get_hdif(&spira.ntuples.pcia, SPPCIA_HDIF_SIG);
+	hdr = get_hdif(&spiras->ntuples.pcia, SPPCIA_HDIF_SIG);
 	if (!hdr)
 		return;
 
@@ -605,7 +563,7 @@ static bool add_xscom_sppcrd(uint64_t xscom_base)
 	const void *vpd;
 	struct dt_node *np, *vpd_node;
 
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i,
 			    SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
 		const struct spira_fru_id *fru_id = NULL;
@@ -731,7 +689,7 @@ static void add_xscom(void)
 	unsigned int size;
 	uint64_t xscom_base;
 
-	ms_vpd = get_hdif(&spira.ntuples.ms_vpd, MSVPD_HDIF_SIG);
+	ms_vpd = get_hdif(&spiras->ntuples.ms_vpd, MSVPD_HDIF_SIG);
 	if (!ms_vpd) {
 		prerror("XSCOM: Can't find MS VPD\n");
 		return;
@@ -809,35 +767,7 @@ static void add_chiptod_node(unsigned int chip_id, int flags)
 		dt_add_property(node, "secondary", NULL, 0);
 }
 
-static bool add_chiptod_old(void)
-{
-	const void *hdif;
-	unsigned int i;
-	bool found = false;
-
-	/*
-	 * Locate chiptod ID structures in SPIRA
-	 */
-	if (!get_hdif(&spira.ntuples.chip_tod, "TOD   "))
-		return found;
-
-	for_each_ntuple_idx(&spira.ntuples.chip_tod, hdif, i, "TOD   ") {
-		const struct chiptod_chipid *id;
-
-		id = HDIF_get_idata(hdif, CHIPTOD_IDATA_CHIPID, NULL);
-		if (!CHECK_SPPTR(id)) {
-			prerror("CHIPTOD: Bad ChipID data %d\n", i);
-			continue;
-		}
-
-		add_chiptod_node(pcid_to_chip_id(be32_to_cpu(id->chip_id)),
-				 be32_to_cpu(id->flags));
-		found = true;
-	}
-	return found;
-}
-
-static bool add_chiptod_new(void)
+static bool add_chiptod(void)
 {
 	const void *hdif;
 	unsigned int i;
@@ -846,10 +776,10 @@ static bool add_chiptod_new(void)
 	/*
 	 * Locate Proc Chip ID structures in SPIRA
 	 */
-	if (!get_hdif(&spira.ntuples.proc_chip, SPPCRD_HDIF_SIG))
+	if (!get_hdif(&spiras->ntuples.proc_chip, SPPCRD_HDIF_SIG))
 		return found;
 
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i,
 			    SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
 		const struct sppcrd_chip_tod *tinfo;
@@ -941,7 +871,7 @@ static void add_nx(void)
 	unsigned int i;
 	void *hdif;
 
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i,
 			SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
 		u32 ve;
@@ -1051,7 +981,7 @@ static void dt_init_secureboot_node(const struct iplparams_sysparams *sysparams)
 
 static void opal_dump_add_mpipl_boot(const struct iplparams_iplparams *p)
 {
-	u32 mdrt_cnt = be16_to_cpu(spira.ntuples.mdump_res.act_cnt);
+	u32 mdrt_cnt = be16_to_cpu(spirah.ntuples.mdump_res.act_cnt);
 	u32 mdrt_max_cnt = MDRT_TABLE_SIZE / sizeof(struct mdrt_table);
 	struct dt_node *dump_node;
 
@@ -1386,7 +1316,7 @@ static void add_iplparams(void)
 	struct dt_node *iplp_node;
 	const void *ipl_parms;
 
-	ipl_parms = get_hdif(&spira.ntuples.ipl_parms, "IPLPMS");
+	ipl_parms = get_hdif(&spiras->ntuples.ipl_parms, "IPLPMS");
 	if (!ipl_parms) {
 		prerror("IPLPARAMS: Cannot find IPL Parms in SPIRA\n");
 		return;
@@ -1415,7 +1345,7 @@ uint32_t pcid_to_chip_id(uint32_t proc_chip_id)
 	const void *hdif;
 
 	/* First, try the proc_chip ntuples for chip data */
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i,
 			    SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
 
@@ -1441,7 +1371,7 @@ uint32_t pcid_to_topology_idx(uint32_t proc_chip_id)
 	const void *hdif;
 
 	/* First, try the proc_chip ntuples for chip data */
-	for_each_ntuple_idx(&spira.ntuples.proc_chip, hdif, i,
+	for_each_ntuple_idx(&spiras->ntuples.proc_chip, hdif, i,
 			    SPPCRD_HDIF_SIG) {
 		const struct sppcrd_chip_info *cinfo;
 
@@ -1491,15 +1421,15 @@ static void hostservices_parse(void)
 		return;
 
 	ntuples_size = sizeof(struct HDIF_array_hdr) + 
-		be32_to_cpu(spira.ntuples.array_hdr.ecnt) *
+		be32_to_cpu(spiras->ntuples.array_hdr.ecnt) *
 		sizeof(struct spira_ntuple);
 
-	if (offsetof(struct spira_ntuples, hs_data) >= ntuples_size) {
+	if (offsetof(struct spiras_ntuples, hs_data) >= ntuples_size) {
 		prerror("SPIRA: No host services data found\n");
 		return;
 	}
 
-	hs_hdr = get_hdif(&spira.ntuples.hs_data, HSERV_HDIF_SIG);
+	hs_hdr = get_hdif(&spiras->ntuples.hs_data, HSERV_HDIF_SIG);
 	if (!hs_hdr) {
 		prerror("SPIRA: No host services data found\n");
 		return;
@@ -1515,7 +1445,7 @@ static void hostservices_parse(void)
 
 static void add_stop_levels(void)
 {
-	struct spira_ntuple *t = &spira.ntuples.proc_chip;
+	struct spira_ntuple *t = &spiras->ntuples.proc_chip;
 	struct HDIF_common_hdr *hdif;
 	u32 stop_levels = ~0;
 	bool valid = false;
@@ -1775,13 +1705,10 @@ static void add_npus(void)
 }
 
 /*
- * Legacy SPIRA is being deprecated and we have new SPIRA-H/S structures.
- * But on older system (p7?) we will continue to get legacy SPIRA.
- *
- * SPIRA-S is initialized and provided by FSP. We use SPIRA-S signature
- * to identify supported format. Also if required adjust spira pointer.
+ * SPIRA-S is initialized and provided by boot firmware. Check the SPIRA-S
+ * signature to confirm it was provided.
  */
-static void fixup_spira(void)
+static bool find_spiras(void)
 {
 #if !defined(TEST)
 	spiras = (struct spiras *)SPIRA_HEAP_BASE;
@@ -1789,35 +1716,12 @@ static void fixup_spira(void)
 
 	/* Validate SPIRA-S signature */
 	if (!spiras)
-		return;
+		return false;
 	if (!HDIF_check(&spiras->hdr, SPIRAS_HDIF_SIG))
-		return;
+		return false;
 
 	prlog(PR_DEBUG, "SPIRA-S found.\n");
-
-	spira.ntuples.sp_subsys = spiras->ntuples.sp_subsys;
-	spira.ntuples.ipl_parms = spiras->ntuples.ipl_parms;
-	spira.ntuples.nt_enclosure_vpd = spiras->ntuples.nt_enclosure_vpd;
-	spira.ntuples.slca = spiras->ntuples.slca;
-	spira.ntuples.backplane_vpd = spiras->ntuples.backplane_vpd;
-	spira.ntuples.system_vpd = spiras->ntuples.system_vpd;
-	spira.ntuples.proc_init = spirah.ntuples.proc_init;
-	spira.ntuples.clock_vpd = spiras->ntuples.clock_vpd;
-	spira.ntuples.anchor_vpd = spiras->ntuples.anchor_vpd;
-	spira.ntuples.op_panel_vpd = spiras->ntuples.op_panel_vpd;
-	spira.ntuples.misc_cec_fru_vpd = spiras->ntuples.misc_cec_fru_vpd;
-	spira.ntuples.ms_vpd = spiras->ntuples.ms_vpd;
-	spira.ntuples.cec_iohub_fru = spiras->ntuples.cec_iohub_fru;
-	spira.ntuples.cpu_ctrl = spirah.ntuples.cpu_ctrl;
-	spira.ntuples.mdump_src = spirah.ntuples.mdump_src;
-	spira.ntuples.mdump_dst = spirah.ntuples.mdump_dst;
-	spira.ntuples.mdump_res  = spirah.ntuples.mdump_res;
-	spira.ntuples.proc_dump_area = spirah.ntuples.proc_dump_area;
-	spira.ntuples.pcia = spiras->ntuples.pcia;
-	spira.ntuples.proc_chip = spiras->ntuples.proc_chip;
-	spira.ntuples.hs_data = spiras->ntuples.hs_data;
-	spira.ntuples.ipmi_sensor = spiras->ntuples.ipmi_sensor;
-	spira.ntuples.node_stb_data = spiras->ntuples.node_stb_data;
+	return true;
 }
 
 /*
@@ -1831,7 +1735,7 @@ static void update_spirah_addr(void)
 		return;
 
 	naca.spirah_addr = CPU_TO_BE64(SPIRAH_OFF);
-	naca.spira_addr = CPU_TO_BE64(SPIRA_OFF);
+	naca.spira_addr = 0;
 	spirah.ntuples.hs_data_area.addr = CPU_TO_BE64(SPIRA_HEAP_BASE - SKIBOOT_BASE);
 	spirah.ntuples.mdump_res.addr = CPU_TO_BE64(MDRT_TABLE_BASE - SKIBOOT_BASE);
 #endif
@@ -1843,7 +1747,10 @@ int parse_hdat(bool is_opal)
 
 	prlog(PR_DEBUG, "Parsing HDAT...\n");
 
-	fixup_spira();
+	if (!find_spiras()) {
+		prlog(PR_ERR, "SPIRA-S not found.\n");
+		return -1;
+	}
 
 	update_spirah_addr();
 
@@ -1882,7 +1789,7 @@ int parse_hdat(bool is_opal)
 	fsp_parse();
 
 	/* Add ChipTOD's */
-	if (!add_chiptod_old() && !add_chiptod_new())
+	if (!add_chiptod())
 		prerror("CHIPTOD: No ChipTOD found !\n");
 
 	/* Add NX */
diff --git a/hdata/spira.h b/hdata/spira.h
index c0eb2a037..1789de1b5 100644
--- a/hdata/spira.h
+++ b/hdata/spira.h
@@ -7,16 +7,15 @@
 #include "hdif.h"
 
 /*
- * The SPIRA structure
+ * The SPIRA-H and SPIRA-S structures
  *
- * NOTE: This is one of the only HDIF structure that we layout entirely
- * as a C struct because it's provided by us to the FSP. Almost everything
- * else is generated by the FSP, and thus must be "parsed" since the various
- * offsets and alignments might change.
+ * SPIRA-H is built in the primary hypervisor (skiboot) lid, pointed to by
+ * the NACA and provides details to the boot firmware.
+ *
+ * SPIRA-S is built at IPL time by the boot firmware at the host data area
+ * location specified in SPIRA-H, and thus must be parsed.
  */
 
-#define SPIRA_VERSION		0x20	/* Like 730 ? */
-
 struct spira_ntuple {
 	__be64		addr;
 	__be16		alloc_cnt;
@@ -27,59 +26,6 @@ struct spira_ntuple {
 	__be64		padding;
 } __packed;
 
-#define SPIRA_NTUPLES_COUNT	0x19
-
-struct spira_ntuples {
-	struct HDIF_array_hdr	array_hdr;
-	struct spira_ntuple	sp_subsys;		/* 0x040 */
-	struct spira_ntuple	ipl_parms;		/* 0x060 */
-	struct spira_ntuple	nt_enclosure_vpd;	/* 0x080 */
-	struct spira_ntuple	slca;			/* 0x0a0 */
-	struct spira_ntuple	backplane_vpd;		/* 0x0c0 */
-	struct spira_ntuple	system_vpd;		/* 0x0e0 */
-	struct spira_ntuple	chip_tod;		/* 0x100 */
-	struct spira_ntuple	proc_init;		/* 0x120 */
-	struct spira_ntuple	clock_vpd;		/* 0x140 */
-	struct spira_ntuple	anchor_vpd;		/* 0x160 */
-	struct spira_ntuple	op_panel_vpd;		/* 0x180 */
-	struct spira_ntuple	ext_cache_fru_vpd;	/* 0x1a0 */
-	struct spira_ntuple	misc_cec_fru_vpd;	/* 0x1c0 */
-	struct spira_ntuple	paca;			/* 0x1e0 */
-	struct spira_ntuple	ms_vpd;			/* 0x200 */
-	struct spira_ntuple	cec_iohub_fru;		/* 0x220 */
-	struct spira_ntuple	cpu_ctrl;		/* 0x240 */
-	struct spira_ntuple	mdump_src;		/* 0x260 */
-	struct spira_ntuple	mdump_dst;		/* 0x280 */
-	struct spira_ntuple	mdump_res;		/* 0x2a0 */
-	struct spira_ntuple	heap;			/* 0x2c0 */
-	struct spira_ntuple	pcia;			/* 0x2e0 */
-	struct spira_ntuple	proc_chip;		/* 0x300 */
-	struct spira_ntuple	hs_data;		/* 0x320 */
-	struct spira_ntuple	ipmi_sensor;		/* 0x360 */
-	struct spira_ntuple	node_stb_data;		/* 0x380 */
-	struct spira_ntuple	proc_dump_area;		/* 0x400 */
-};
-
-#define SPIRA_RESERVED_BYTES	0x60
-
-struct spira {
-	struct HDIF_common_hdr	hdr;
-	struct HDIF_idata_ptr	ntuples_ptr;
-	__be64			pad;
-	struct spira_ntuples	ntuples;
-	/*
-	 * We reserve 0xc0 rather than 0x4c0 so we fit SPIRAH/SPIRAS here
-	 * while preserving compatibility with existing P8 systems.
-	 *
-	 * According to FSP engineers, this is an okay thing to do.
-	 */
-	u8			reserved[SPIRA_RESERVED_BYTES];
-} __packed __align(0x100);
-
-#define SPIRA_ACTUAL_SIZE (sizeof(struct spira) - SPIRA_RESERVED_BYTES)
-
-extern struct spira spira;
-
 /* SPIRA-H signature */
 #define SPIRAH_HDIF_SIG		"SPIRAH"
 
@@ -152,7 +98,6 @@ struct spiras {
 
 extern struct spiras *skiboot_constant_addr spiras;
 
-
 /* This macro can be used to check the validity of a pointer returned
  * by one of the HDIF API functions. It returns true if the pointer
  * appears valid. If it's not valid and not NULL, it will print some
@@ -178,7 +123,7 @@ extern struct HDIF_common_hdr *__get_hdif(struct spira_ntuple *n,
 			be32_to_cpu((_ntuples)->alloc_len));		\
 	     _p = (void *)_p + be32_to_cpu((_ntuples)->alloc_len))
 
-#define for_each_pcia(p) for_each_ntuple(&spira.ntuples.pcia, p, SPPCIA_HDIF_SIG)
+#define for_each_pcia(p) for_each_ntuple(&spiras->ntuples.pcia, p, SPPCIA_HDIF_SIG)
 
 /* We override these for testing. */
 #ifndef ntuple_addr
diff --git a/hdata/test/Makefile.check b/hdata/test/Makefile.check
index 7eb5f3f45..81d55614a 100644
--- a/hdata/test/Makefile.check
+++ b/hdata/test/Makefile.check
@@ -18,24 +18,21 @@ hdata/test/hdata_to_dt-check: hdata/test/hdata_to_dt-check-dt
 
 # Add some test ntuples for open source version...
 hdata/test/hdata_to_dt-check-q: hdata/test/hdata_to_dt
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -q hdata/test/p81-811.spira hdata/test/p81-811.spira.heap, $<)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -s -q hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras, $<)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -9 -s -q hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap, $<)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -10 -s -q hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras, $<)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -q hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras, $<)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -9 -q hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap, $<)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -10 -q hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras, $<)
 
 hdata/test/hdata_to_dt-check-dt: hdata/test/hdata_to_dt
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p81-811.spira.dts, $< device-tree)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -9 -s hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/op920.wsp.dts, $< device-tree)
-	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -10 -s hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p10-rainier.dts, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -8E hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -9 hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/op920.wsp.dts, $< device-tree)
+	$(call Q, TEST , $(VALGRIND) hdata/test/hdata_to_dt -10 hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p10-rainier.dts, $< device-tree)
 
 hdata/test/hdata_to_dt-gcov-run: hdata/test/hdata_to_dt-check-dt-gcov-run
 
 hdata/test/hdata_to_dt-check-dt-gcov-run: hdata/test/hdata_to_dt-gcov
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E hdata/test/p81-811.spira hdata/test/p81-811.spira.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p81-811.spira.dts, $< device-tree)
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E -s hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt -9 -s hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/op920.wsp.dts, $< device-tree)
-	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt -10 -s hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p10-rainier.dts, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt-gcov -8E hdata/test/p8-840-spira.spirah hdata/test/p8-840-spira.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p8-840-spira.dts, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt -9 hdata/test/p8-840-spira.spirah hdata/test/op920.wsp.heap 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/op920.wsp.dts, $< device-tree)
+	$(call Q, TEST-COVERAGE , ./hdata/test/hdata_to_dt -10 hdata/test/p8-840-spira.spirah hdata/test/p10-rainier.spiras 2>/dev/null | hdata/test/dtdiff_wrap.sh hdata/test/p10-rainier.dts, $< device-tree)
 
 hdata/test/stubs.o: hdata/test/stubs.c
 	$(call Q, HOSTCC , $(HOSTCC) $(HOSTCFLAGS) -g -c -o $@ $<, $<)
diff --git a/hdata/test/hdata_to_dt.c b/hdata/test/hdata_to_dt.c
index ead6e3c98..e088924ef 100644
--- a/hdata/test/hdata_to_dt.c
+++ b/hdata/test/hdata_to_dt.c
@@ -301,7 +301,7 @@ static void dump_hdata_fdt(struct dt_node *root)
 int main(int argc, char *argv[])
 {
 	int fd, r, i = 0, opt_count = 0;
-	bool verbose = false, quiet = false, new_spira = false, blobs = false;
+	bool verbose = false, quiet = false, blobs = false;
 
 	while (argv[++i]) {
 		if (strcmp(argv[i], "-v") == 0) {
@@ -310,9 +310,6 @@ int main(int argc, char *argv[])
 		} else if (strcmp(argv[i], "-q") == 0) {
 			quiet = true;
 			opt_count++;
-		} else if (strcmp(argv[i], "-s") == 0) {
-			new_spira = true;
-			opt_count++;
 		} else if (strcmp(argv[i], "-b") == 0) {
 			blobs = true;
 			opt_count++;
@@ -345,8 +342,7 @@ int main(int argc, char *argv[])
 		errx(1, "Converts HDAT dumps to DTB.\n"
 		     "\n"
 		     "Usage:\n"
-		     "	hdata <opts> <spira-dump> <heap-dump>\n"
-		     "	hdata <opts> -s <spirah-dump> <spiras-dump>\n"
+		     "	hdata <opts> <spirah-dump> <spiras-dump>\n"
 		     "Options: \n"
 		     "	-v Verbose\n"
 		     "	-q Quiet mode\n"
@@ -368,36 +364,19 @@ int main(int argc, char *argv[])
 		phys_map_init(fake_pvr);
 
 	/* Copy in spira dump (assumes little has changed!). */
-	if (new_spira) {
-		fd = open(argv[1], O_RDONLY);
-		if (fd < 0)
-			err(1, "opening %s", argv[1]);
-		r = read(fd, &spirah, sizeof(spirah));
-		if (r < sizeof(spirah.hdr))
-			err(1, "reading %s gave %i", argv[1], r);
-		if (verbose)
-			printf("verbose: read spirah %u bytes\n", r);
-		close(fd);
-
-		undefined_bytes((void *)&spirah + r, sizeof(spirah) - r);
-
-		base_addr = be64_to_cpu(spirah.ntuples.hs_data_area.addr);
-	} else {
-		fd = open(argv[1], O_RDONLY);
-		if (fd < 0)
-			err(1, "opening %s", argv[1]);
-		r = read(fd, &spira, sizeof(spira));
-		if (r < sizeof(spira.hdr))
-			err(1, "reading %s gave %i", argv[1], r);
-		if (verbose)
-			printf("verbose: read spira %u bytes\n", r);
-		close(fd);
-
-		undefined_bytes((void *)&spira + r, sizeof(spira) - r);
-
-		base_addr = be64_to_cpu(spira.ntuples.heap.addr);
-	}
+	fd = open(argv[1], O_RDONLY);
+	if (fd < 0)
+		err(1, "opening %s", argv[1]);
+	r = read(fd, &spirah, sizeof(spirah));
+	if (r < sizeof(spirah.hdr))
+		err(1, "reading %s gave %i", argv[1], r);
+	if (verbose)
+		printf("verbose: read spirah %u bytes\n", r);
+	close(fd);
+
+	undefined_bytes((void *)&spirah + r, sizeof(spirah) - r);
 
+	base_addr = be64_to_cpu(spirah.ntuples.hs_data_area.addr);
 	if (!base_addr)
 		errx(1, "Invalid base addr");
 	if (verbose)
@@ -417,8 +396,8 @@ int main(int argc, char *argv[])
 		       spira_heap_size, spira_heap);
 	close(fd);
 
-	if (new_spira)
-		spiras = (struct spiras *)spira_heap;
+	/* SPIRA-S defined to be at the start of the SPIRA Host Data Area */
+	spiras = (struct spiras *)spira_heap;
 
 	if (quiet) {
 		fclose(stdout);
diff --git a/hdata/tpmrel.c b/hdata/tpmrel.c
index 4be3f81c4..c70791839 100644
--- a/hdata/tpmrel.c
+++ b/hdata/tpmrel.c
@@ -209,7 +209,7 @@ void node_stb_parse(void)
 {
 	struct HDIF_common_hdr *hdif_hdr;
 
-	hdif_hdr = get_hdif(&spira.ntuples.node_stb_data, STB_HDIF_SIG);
+	hdif_hdr = get_hdif(&spiras->ntuples.node_stb_data, STB_HDIF_SIG);
 	if (!hdif_hdr) {
 		prlog(PR_DEBUG, "TPMREL data not found\n");
 		return;
diff --git a/hdata/vpd.c b/hdata/vpd.c
index c778de346..cfc8d22a6 100644
--- a/hdata/vpd.c
+++ b/hdata/vpd.c
@@ -423,7 +423,7 @@ void dt_init_vpd_node(void)
 	dt_add_property_cells(dt_vpd, "#size-cells", 0);
 	dt_add_property_cells(dt_vpd, "#address-cells", 1);
 
-	slca_hdr = get_hdif(&spira.ntuples.slca, SLCA_HDIF_SIG);
+	slca_hdr = get_hdif(&spiras->ntuples.slca, SLCA_HDIF_SIG);
 	if (!slca_hdr) {
 		prerror("SLCA Invalid\n");
 		return;
@@ -551,7 +551,7 @@ static void dt_add_model_name(void)
 
 	model = dt_find_property(dt_root, "model");
 
-	iplp = get_hdif(&spira.ntuples.ipl_parms, "IPLPMS");
+	iplp = get_hdif(&spiras->ntuples.ipl_parms, "IPLPMS");
 	if (!iplp)
 		goto def_model;
 
@@ -627,7 +627,7 @@ static void sysvpd_parse(void)
 	const struct spira_fru_id *fru_id;
 	struct HDIF_common_hdr *sysvpd_hdr;
 
-	sysvpd_hdr = get_hdif(&spira.ntuples.system_vpd, SYSVPD_HDIF_SIG);
+	sysvpd_hdr = get_hdif(&spiras->ntuples.system_vpd, SYSVPD_HDIF_SIG);
 	if (!sysvpd_hdr)
 		return;
 
@@ -683,12 +683,12 @@ static void iohub_vpd_parse(void)
 	const struct cechub_hub_fru_id *fru_id_data;
 	unsigned int i, vpd_sz, fru_id_sz;
 
-	if (!get_hdif(&spira.ntuples.cec_iohub_fru, CECHUB_FRU_HDIF_SIG)) {
+	if (!get_hdif(&spiras->ntuples.cec_iohub_fru, CECHUB_FRU_HDIF_SIG)) {
 		prerror("VPD: Could not find IO HUB FRU data\n");
 		return;
 	}
 
-	for_each_ntuple_idx(&spira.ntuples.cec_iohub_fru, iohub_hdr,
+	for_each_ntuple_idx(&spiras->ntuples.cec_iohub_fru, iohub_hdr,
 					i, CECHUB_FRU_HDIF_SIG) {
 
 		fru_id_data = HDIF_get_idata(iohub_hdr,
@@ -732,25 +732,22 @@ void vpd_parse(void)
 	sysvpd_parse();
 
 	/* Enclosure */
-	_vpd_parse(spira.ntuples.nt_enclosure_vpd);
+	_vpd_parse(spiras->ntuples.nt_enclosure_vpd);
 
 	/* Backplane */
-	_vpd_parse(spira.ntuples.backplane_vpd);
+	_vpd_parse(spiras->ntuples.backplane_vpd);
 
 	/* clock card -- does this use the FRUVPD sig? */
-	_vpd_parse(spira.ntuples.clock_vpd);
+	_vpd_parse(spiras->ntuples.clock_vpd);
 
 	/* Anchor card */
-	_vpd_parse(spira.ntuples.anchor_vpd);
+	_vpd_parse(spiras->ntuples.anchor_vpd);
 
 	/* Op panel -- does this use the FRUVPD sig? */
-	_vpd_parse(spira.ntuples.op_panel_vpd);
-
-	/* External cache FRU vpd -- does this use the FRUVPD sig? */
-	_vpd_parse(spira.ntuples.ext_cache_fru_vpd);
+	_vpd_parse(spiras->ntuples.op_panel_vpd);
 
 	/* Misc CEC FRU */
-	_vpd_parse(spira.ntuples.misc_cec_fru_vpd);
+	_vpd_parse(spiras->ntuples.misc_cec_fru_vpd);
 
 	/* CEC IO HUB FRU */
 	iohub_vpd_parse();
@@ -760,7 +757,7 @@ void vpd_parse(void)
 	 * different, the FRU ID data and pointer pair to keyword VPD
 	 * are the same offset as a FRUVPD entry. So reuse it
 	 */
-	fruvpd_hdr = get_hdif(&spira.ntuples.sp_subsys, SPSS_HDIF_SIG);
+	fruvpd_hdr = get_hdif(&spiras->ntuples.sp_subsys, SPSS_HDIF_SIG);
 	if (fruvpd_hdr)
 		dt_add_vpd_node(fruvpd_hdr,
 				FRUVPD_IDATA_FRU_ID, FRUVPD_IDATA_KW_VPD);
diff --git a/hw/fsp/fsp-attn.c b/hw/fsp/fsp-attn.c
index 6e358e0d4..877390240 100644
--- a/hw/fsp/fsp-attn.c
+++ b/hw/fsp/fsp-attn.c
@@ -11,7 +11,6 @@
 #include <skiboot.h>
 #include <fsp-elog.h>
 #include <fsp-attn.h>
-#include <hdata/spira.h>
 #include <stack.h>
 #include <processor.h>
 #include <opal-dump.h>
diff --git a/include/mem-map.h b/include/mem-map.h
index 9250a63d5..9fd8c91c9 100644
--- a/include/mem-map.h
+++ b/include/mem-map.h
@@ -26,17 +26,13 @@
 /* The NACA and other stuff in head.S need to be at the start: we
  * give it 64k before placing the SPIRA and related data.
  */
-#define SPIRA_OFF		0x00010000
-#define SPIRA_SIZE		0x400
-#define SPIRAH_OFF		0x00010400
+#define SPIRAH_OFF		0x00010000
 #define SPIRAH_SIZE		0x300
 
 #define PROC_DUMP_AREA_OFF	(SPIRAH_OFF + SPIRAH_SIZE)
 #define PROC_DUMP_AREA_SIZE	0x100
 
-/* Actual SPIRA size is lesser than 1K (presently 0x340 bytes).
- * Use 1K for legacy SPIRA.
- *
+/*
  * SPIRA-H is lesser than 768 bytes (presently we use 288 bytes)
  * Use 768 bytes for SPIRAH.
  *
@@ -48,21 +44,23 @@
  * endian: linker can't endian reverse a pointer for us.  Text, data
  * et. al. follows this.
  */
-#define PROCIN_OFF		(SPIRA_OFF + 0x800)
+#define PROCIN_OFF		(PROC_DUMP_AREA_OFF + PROC_DUMP_AREA_SIZE)
+#define PROCIN_SIZE		0x800
 
 /* Initial MDST and MDDT tables like PROCIN, we need fixed addresses,
  * we leave a 2k gap for PROCIN
  */
-#define MDST_TABLE_OFF		(SPIRA_OFF + 0x1000)
+#define MDST_TABLE_OFF		(PROCIN_OFF + PROCIN_SIZE)
 #define MDST_TABLE_SIZE		0x400
 
-#define MDDT_TABLE_OFF		(SPIRA_OFF + 0x1400)
+#define MDDT_TABLE_OFF		(MDST_TABLE_OFF + MDST_TABLE_SIZE)
 #define MDDT_TABLE_SIZE		0x400
 
 /* Like MDST and MDDT, we need fixed address for CPU control header.
- * We leave a 2k gap for MDST. CPU_CTL table is of size ~4k
+ * We leave a 2k gap for MDST. CPU_CTL table is of size ~4k, give it 8k.
  */
-#define CPU_CTL_OFF             (SPIRA_OFF + 0x1800)
+#define CPU_CTL_OFF		(MDDT_TABLE_OFF + MDDT_TABLE_SIZE)
+#define CPU_CTL_SIZE		0x2000
 
 /* We keep a gap of 5M for skiboot text & bss for now. We will
  * then we have our heap which goes up to base + 14M (so 11M for
diff --git a/skiboot.lds.S b/skiboot.lds.S
index 058848fa9..f45e90df0 100644
--- a/skiboot.lds.S
+++ b/skiboot.lds.S
@@ -66,11 +66,6 @@ SECTIONS
 		KEEP(*(.naca.data))
 	}
 
-	. = SPIRA_OFF;
-	.spira : {
-		KEEP(*(.spira.data))
-	}
-
 	. = SPIRAH_OFF;
 	.spirah : {
 		KEEP(*(.spirah.data))
-- 
2.40.1



More information about the Skiboot mailing list