1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright IBM Corp. 2013
8 #define KMSG_COMPONENT "sclp_early"
9 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
11 #include <linux/errno.h>
12 #include <asm/ctl_reg.h>
15 #include "sclp_sdias.h"
18 static struct sclp_ipl_info sclp_ipl_info;
20 struct sclp_info sclp;
23 static void __init sclp_early_facilities_detect(struct read_info_sccb *sccb)
25 struct sclp_core_entry *cpue;
26 u16 boot_cpu_address, cpu;
28 if (sclp_early_get_info(sccb))
31 sclp.facilities = sccb->facilities;
32 sclp.has_sprp = !!(sccb->fac84 & 0x02);
33 sclp.has_core_type = !!(sccb->fac84 & 0x01);
34 sclp.has_gsls = !!(sccb->fac85 & 0x80);
35 sclp.has_64bscao = !!(sccb->fac116 & 0x80);
36 sclp.has_cmma = !!(sccb->fac116 & 0x40);
37 sclp.has_esca = !!(sccb->fac116 & 0x08);
38 sclp.has_pfmfi = !!(sccb->fac117 & 0x40);
39 sclp.has_ibs = !!(sccb->fac117 & 0x20);
40 sclp.has_gisaf = !!(sccb->fac118 & 0x08);
41 sclp.has_hvs = !!(sccb->fac119 & 0x80);
42 sclp.has_kss = !!(sccb->fac98 & 0x01);
43 if (sccb->fac85 & 0x02)
44 S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP;
45 if (sccb->fac91 & 0x40)
46 S390_lowcore.machine_flags |= MACHINE_FLAG_TLB_GUEST;
47 sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2;
48 sclp.rzm = sccb->rnsize ? sccb->rnsize : sccb->rnsize2;
52 if (sccb->hamaxpow && sccb->hamaxpow < 64)
53 sclp.hamax = (1UL << sccb->hamaxpow) - 1;
61 sclp.max_cores = sccb->ncpurl;
63 sclp.max_cores = sccb->hcpua + 1;
66 boot_cpu_address = stap();
67 cpue = (void *)sccb + sccb->cpuoff;
68 for (cpu = 0; cpu < sccb->ncpurl; cpue++, cpu++) {
69 if (boot_cpu_address != cpue->core_id)
71 sclp.has_siif = cpue->siif;
72 sclp.has_sigpif = cpue->sigpif;
73 sclp.has_sief2 = cpue->sief2;
74 sclp.has_gpere = cpue->gpere;
75 sclp.has_ib = cpue->ib;
76 sclp.has_cei = cpue->cei;
77 sclp.has_skey = cpue->skey;
81 /* Save IPL information */
82 sclp_ipl_info.is_valid = 1;
83 if (sccb->fac91 & 0x2)
84 sclp_ipl_info.has_dump = 1;
85 memcpy(&sclp_ipl_info.loadparm, &sccb->loadparm, LOADPARM_LEN);
88 sclp.hsa_size = (sccb->hsa_size - 1) * PAGE_SIZE;
89 sclp.mtid = (sccb->fac42 & 0x80) ? (sccb->fac42 & 31) : 0;
90 sclp.mtid_cp = (sccb->fac42 & 0x80) ? (sccb->fac43 & 31) : 0;
91 sclp.mtid_prev = (sccb->fac42 & 0x80) ? (sccb->fac66 & 31) : 0;
93 sclp.hmfai = sccb->hmfai;
97 * This function will be called after sclp_early_facilities_detect(), which gets
98 * called from early.c code. The sclp_early_facilities_detect() function retrieves
99 * and saves the IPL information.
101 void __init sclp_early_get_ipl_info(struct sclp_ipl_info *info)
103 *info = sclp_ipl_info;
106 static struct sclp_core_info sclp_early_core_info __initdata;
107 static int sclp_early_core_info_valid __initdata;
109 static void __init sclp_early_init_core_info(struct read_cpu_info_sccb *sccb)
111 if (!SCLP_HAS_CPU_INFO)
113 memset(sccb, 0, sizeof(*sccb));
114 sccb->header.length = sizeof(*sccb);
115 if (sclp_early_cmd(SCLP_CMDW_READ_CPU_INFO, sccb))
117 if (sccb->header.response_code != 0x0010)
119 sclp_fill_core_info(&sclp_early_core_info, sccb);
120 sclp_early_core_info_valid = 1;
123 int __init sclp_early_get_core_info(struct sclp_core_info *info)
125 if (!sclp_early_core_info_valid)
127 *info = sclp_early_core_info;
131 static void __init sclp_early_console_detect(struct init_sccb *sccb)
133 if (sccb->header.response_code != 0x20)
136 if (sclp_early_con_check_vt220(sccb))
139 if (sclp_early_con_check_linemode(sccb))
140 sclp.has_linemode = 1;
143 void __init sclp_early_detect(void)
145 void *sccb = &sclp_early_sccb;
147 sclp_early_facilities_detect(sccb);
148 sclp_early_init_core_info(sccb);
151 * Turn off SCLP event notifications. Also save remote masks in the
152 * sccb. These are sufficient to detect sclp console capabilities.
154 sclp_early_set_event_mask(sccb, 0, 0);
155 sclp_early_console_detect(sccb);