162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Intel dynamic_speed_select -- Enumerate and control features
462306a36Sopenharmony_ci * Copyright (c) 2019 Intel Corporation.
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include "isst.h"
862306a36Sopenharmony_ci
962306a36Sopenharmony_cistatic void printcpulist(int str_len, char *str, int mask_size,
1062306a36Sopenharmony_ci			 cpu_set_t *cpu_mask)
1162306a36Sopenharmony_ci{
1262306a36Sopenharmony_ci	int i, first, curr_index, index;
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci	if (!CPU_COUNT_S(mask_size, cpu_mask)) {
1562306a36Sopenharmony_ci		snprintf(str, str_len, "none");
1662306a36Sopenharmony_ci		return;
1762306a36Sopenharmony_ci	}
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci	curr_index = 0;
2062306a36Sopenharmony_ci	first = 1;
2162306a36Sopenharmony_ci	for (i = 0; i < get_topo_max_cpus(); ++i) {
2262306a36Sopenharmony_ci		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
2362306a36Sopenharmony_ci			continue;
2462306a36Sopenharmony_ci		if (!first) {
2562306a36Sopenharmony_ci			index = snprintf(&str[curr_index],
2662306a36Sopenharmony_ci					 str_len - curr_index, ",");
2762306a36Sopenharmony_ci			curr_index += index;
2862306a36Sopenharmony_ci			if (curr_index >= str_len)
2962306a36Sopenharmony_ci				break;
3062306a36Sopenharmony_ci		}
3162306a36Sopenharmony_ci		index = snprintf(&str[curr_index], str_len - curr_index, "%d",
3262306a36Sopenharmony_ci				 i);
3362306a36Sopenharmony_ci		curr_index += index;
3462306a36Sopenharmony_ci		if (curr_index >= str_len)
3562306a36Sopenharmony_ci			break;
3662306a36Sopenharmony_ci		first = 0;
3762306a36Sopenharmony_ci	}
3862306a36Sopenharmony_ci}
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_cistatic void printcpumask(int str_len, char *str, int mask_size,
4162306a36Sopenharmony_ci			 cpu_set_t *cpu_mask)
4262306a36Sopenharmony_ci{
4362306a36Sopenharmony_ci	int i, max_cpus = get_topo_max_cpus();
4462306a36Sopenharmony_ci	unsigned int *mask;
4562306a36Sopenharmony_ci	int size, index, curr_index;
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci	size = max_cpus / (sizeof(unsigned int) * 8);
4862306a36Sopenharmony_ci	if (max_cpus % (sizeof(unsigned int) * 8))
4962306a36Sopenharmony_ci		size++;
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci	mask = calloc(size, sizeof(unsigned int));
5262306a36Sopenharmony_ci	if (!mask)
5362306a36Sopenharmony_ci		return;
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	for (i = 0; i < max_cpus; ++i) {
5662306a36Sopenharmony_ci		int mask_index, bit_index;
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci		if (!CPU_ISSET_S(i, mask_size, cpu_mask))
5962306a36Sopenharmony_ci			continue;
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci		mask_index = i / (sizeof(unsigned int) * 8);
6262306a36Sopenharmony_ci		bit_index = i % (sizeof(unsigned int) * 8);
6362306a36Sopenharmony_ci		mask[mask_index] |= BIT(bit_index);
6462306a36Sopenharmony_ci	}
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ci	curr_index = 0;
6762306a36Sopenharmony_ci	for (i = size - 1; i >= 0; --i) {
6862306a36Sopenharmony_ci		index = snprintf(&str[curr_index], str_len - curr_index, "%08x",
6962306a36Sopenharmony_ci				 mask[i]);
7062306a36Sopenharmony_ci		curr_index += index;
7162306a36Sopenharmony_ci		if (curr_index >= str_len)
7262306a36Sopenharmony_ci			break;
7362306a36Sopenharmony_ci		if (i) {
7462306a36Sopenharmony_ci			strncat(&str[curr_index], ",", str_len - curr_index);
7562306a36Sopenharmony_ci			curr_index++;
7662306a36Sopenharmony_ci		}
7762306a36Sopenharmony_ci		if (curr_index >= str_len)
7862306a36Sopenharmony_ci			break;
7962306a36Sopenharmony_ci	}
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci	free(mask);
8262306a36Sopenharmony_ci}
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_cistatic void format_and_print_txt(FILE *outf, int level, char *header,
8562306a36Sopenharmony_ci				 char *value)
8662306a36Sopenharmony_ci{
8762306a36Sopenharmony_ci	char *spaces = "  ";
8862306a36Sopenharmony_ci	static char delimiters[256];
8962306a36Sopenharmony_ci	int i, j = 0;
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci	if (!level)
9262306a36Sopenharmony_ci		return;
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci	if (level == 1) {
9562306a36Sopenharmony_ci		strcpy(delimiters, " ");
9662306a36Sopenharmony_ci	} else {
9762306a36Sopenharmony_ci		for (i = 0; i < level - 1; ++i)
9862306a36Sopenharmony_ci			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
9962306a36Sopenharmony_ci				      "%s", spaces);
10062306a36Sopenharmony_ci	}
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci	if (header && value) {
10362306a36Sopenharmony_ci		fprintf(outf, "%s", delimiters);
10462306a36Sopenharmony_ci		fprintf(outf, "%s:%s\n", header, value);
10562306a36Sopenharmony_ci	} else if (header) {
10662306a36Sopenharmony_ci		fprintf(outf, "%s", delimiters);
10762306a36Sopenharmony_ci		fprintf(outf, "%s\n", header);
10862306a36Sopenharmony_ci	}
10962306a36Sopenharmony_ci}
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_cistatic int last_level;
11262306a36Sopenharmony_cistatic void format_and_print(FILE *outf, int level, char *header, char *value)
11362306a36Sopenharmony_ci{
11462306a36Sopenharmony_ci	char *spaces = "  ";
11562306a36Sopenharmony_ci	static char delimiters[256];
11662306a36Sopenharmony_ci	int i;
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci	if (!out_format_is_json()) {
11962306a36Sopenharmony_ci		format_and_print_txt(outf, level, header, value);
12062306a36Sopenharmony_ci		return;
12162306a36Sopenharmony_ci	}
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci	if (level == 0) {
12462306a36Sopenharmony_ci		if (header)
12562306a36Sopenharmony_ci			fprintf(outf, "{");
12662306a36Sopenharmony_ci		else
12762306a36Sopenharmony_ci			fprintf(outf, "\n}\n");
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci	} else {
13062306a36Sopenharmony_ci		int j = 0;
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci		for (i = 0; i < level; ++i)
13362306a36Sopenharmony_ci			j += snprintf(&delimiters[j], sizeof(delimiters) - j,
13462306a36Sopenharmony_ci				      "%s", spaces);
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci		if (last_level == level)
13762306a36Sopenharmony_ci			fprintf(outf, ",\n");
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci		if (value) {
14062306a36Sopenharmony_ci			if (last_level != level)
14162306a36Sopenharmony_ci				fprintf(outf, "\n");
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci			fprintf(outf, "%s\"%s\": ", delimiters, header);
14462306a36Sopenharmony_ci			fprintf(outf, "\"%s\"", value);
14562306a36Sopenharmony_ci		} else {
14662306a36Sopenharmony_ci			for (i = last_level - 1; i >= level; --i) {
14762306a36Sopenharmony_ci				int k = 0;
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci				for (j = i; j > 0; --j)
15062306a36Sopenharmony_ci					k += snprintf(&delimiters[k],
15162306a36Sopenharmony_ci						      sizeof(delimiters) - k,
15262306a36Sopenharmony_ci						      "%s", spaces);
15362306a36Sopenharmony_ci				if (i == level && header)
15462306a36Sopenharmony_ci					fprintf(outf, "\n%s},", delimiters);
15562306a36Sopenharmony_ci				else
15662306a36Sopenharmony_ci					fprintf(outf, "\n%s}", delimiters);
15762306a36Sopenharmony_ci			}
15862306a36Sopenharmony_ci			if (abs(last_level - level) < 3)
15962306a36Sopenharmony_ci				fprintf(outf, "\n");
16062306a36Sopenharmony_ci			if (header)
16162306a36Sopenharmony_ci				fprintf(outf, "%s\"%s\": {", delimiters,
16262306a36Sopenharmony_ci					header);
16362306a36Sopenharmony_ci		}
16462306a36Sopenharmony_ci	}
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci	last_level = level;
16762306a36Sopenharmony_ci}
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_cistatic int print_package_info(struct isst_id *id, FILE *outf)
17062306a36Sopenharmony_ci{
17162306a36Sopenharmony_ci	char header[256];
17262306a36Sopenharmony_ci	int level = 1;
17362306a36Sopenharmony_ci
17462306a36Sopenharmony_ci	if (out_format_is_json()) {
17562306a36Sopenharmony_ci		if (api_version() > 1)
17662306a36Sopenharmony_ci			snprintf(header, sizeof(header), "package-%d:die-%d:powerdomain-%d:cpu-%d",
17762306a36Sopenharmony_ci				 id->pkg, id->die, id->punit, id->cpu);
17862306a36Sopenharmony_ci		else
17962306a36Sopenharmony_ci			snprintf(header, sizeof(header), "package-%d:die-%d:cpu-%d",
18062306a36Sopenharmony_ci				 id->pkg, id->die, id->cpu);
18162306a36Sopenharmony_ci		format_and_print(outf, level, header, NULL);
18262306a36Sopenharmony_ci		return 1;
18362306a36Sopenharmony_ci	}
18462306a36Sopenharmony_ci	snprintf(header, sizeof(header), "package-%d", id->pkg);
18562306a36Sopenharmony_ci	format_and_print(outf, level++, header, NULL);
18662306a36Sopenharmony_ci	snprintf(header, sizeof(header), "die-%d", id->die);
18762306a36Sopenharmony_ci	format_and_print(outf, level++, header, NULL);
18862306a36Sopenharmony_ci	if (api_version() > 1) {
18962306a36Sopenharmony_ci		snprintf(header, sizeof(header), "powerdomain-%d", id->punit);
19062306a36Sopenharmony_ci		format_and_print(outf, level++, header, NULL);
19162306a36Sopenharmony_ci	}
19262306a36Sopenharmony_ci	snprintf(header, sizeof(header), "cpu-%d", id->cpu);
19362306a36Sopenharmony_ci	format_and_print(outf, level, header, NULL);
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci	return level;
19662306a36Sopenharmony_ci}
19762306a36Sopenharmony_ci
19862306a36Sopenharmony_cistatic void _isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
19962306a36Sopenharmony_ci					  struct isst_pbf_info *pbf_info,
20062306a36Sopenharmony_ci					  int disp_level)
20162306a36Sopenharmony_ci{
20262306a36Sopenharmony_ci	char header[256];
20362306a36Sopenharmony_ci	char value[512];
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci	snprintf(header, sizeof(header), "speed-select-base-freq-properties");
20662306a36Sopenharmony_ci	format_and_print(outf, disp_level, header, NULL);
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci	snprintf(header, sizeof(header), "high-priority-base-frequency(MHz)");
20962306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d",
21062306a36Sopenharmony_ci		 pbf_info->p1_high * isst_get_disp_freq_multiplier());
21162306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci	snprintf(header, sizeof(header), "high-priority-cpu-mask");
21462306a36Sopenharmony_ci	printcpumask(sizeof(value), value, pbf_info->core_cpumask_size,
21562306a36Sopenharmony_ci		     pbf_info->core_cpumask);
21662306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
21762306a36Sopenharmony_ci
21862306a36Sopenharmony_ci	snprintf(header, sizeof(header), "high-priority-cpu-list");
21962306a36Sopenharmony_ci	printcpulist(sizeof(value), value,
22062306a36Sopenharmony_ci		     pbf_info->core_cpumask_size,
22162306a36Sopenharmony_ci		     pbf_info->core_cpumask);
22262306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
22362306a36Sopenharmony_ci
22462306a36Sopenharmony_ci	snprintf(header, sizeof(header), "low-priority-base-frequency(MHz)");
22562306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d",
22662306a36Sopenharmony_ci		 pbf_info->p1_low * isst_get_disp_freq_multiplier());
22762306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci	if (is_clx_n_platform())
23062306a36Sopenharmony_ci		return;
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci	snprintf(header, sizeof(header), "tjunction-temperature(C)");
23362306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", pbf_info->t_prochot);
23462306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci	snprintf(header, sizeof(header), "thermal-design-power(W)");
23762306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", pbf_info->tdp);
23862306a36Sopenharmony_ci	format_and_print(outf, disp_level + 1, header, value);
23962306a36Sopenharmony_ci}
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_cistatic void _isst_fact_display_information(struct isst_id *id, FILE *outf, int level,
24262306a36Sopenharmony_ci					   int fact_bucket, int fact_avx,
24362306a36Sopenharmony_ci					   struct isst_fact_info *fact_info,
24462306a36Sopenharmony_ci					   int base_level)
24562306a36Sopenharmony_ci{
24662306a36Sopenharmony_ci	struct isst_fact_bucket_info *bucket_info = fact_info->bucket_info;
24762306a36Sopenharmony_ci	int trl_max_levels = isst_get_trl_max_levels();
24862306a36Sopenharmony_ci	char header[256];
24962306a36Sopenharmony_ci	char value[256];
25062306a36Sopenharmony_ci	int print = 0, j;
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci	for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
25362306a36Sopenharmony_ci		if (fact_bucket != 0xff && fact_bucket != j)
25462306a36Sopenharmony_ci			continue;
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci		/* core count must be valid for CPU power domain */
25762306a36Sopenharmony_ci		if (!bucket_info[j].hp_cores && id->cpu >= 0)
25862306a36Sopenharmony_ci			break;
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ci		print = 1;
26162306a36Sopenharmony_ci	}
26262306a36Sopenharmony_ci	if (!print) {
26362306a36Sopenharmony_ci		fprintf(stderr, "Invalid bucket\n");
26462306a36Sopenharmony_ci		return;
26562306a36Sopenharmony_ci	}
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci	snprintf(header, sizeof(header), "speed-select-turbo-freq-properties");
26862306a36Sopenharmony_ci	format_and_print(outf, base_level, header, NULL);
26962306a36Sopenharmony_ci	for (j = 0; j < ISST_FACT_MAX_BUCKETS; ++j) {
27062306a36Sopenharmony_ci		int i;
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci		if (fact_bucket != 0xff && fact_bucket != j)
27362306a36Sopenharmony_ci			continue;
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci		if (!bucket_info[j].hp_cores)
27662306a36Sopenharmony_ci			break;
27762306a36Sopenharmony_ci
27862306a36Sopenharmony_ci		snprintf(header, sizeof(header), "bucket-%d", j);
27962306a36Sopenharmony_ci		format_and_print(outf, base_level + 1, header, NULL);
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci		snprintf(header, sizeof(header), "high-priority-cores-count");
28262306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%d",
28362306a36Sopenharmony_ci			 bucket_info[j].hp_cores);
28462306a36Sopenharmony_ci		format_and_print(outf, base_level + 2, header, value);
28562306a36Sopenharmony_ci		for (i = 0; i < trl_max_levels; i++) {
28662306a36Sopenharmony_ci			if (!bucket_info[j].hp_ratios[i] || (fact_avx != 0xFF && !(fact_avx & (1 << i))))
28762306a36Sopenharmony_ci				continue;
28862306a36Sopenharmony_ci			if (i == 0 && api_version() == 1 && !is_emr_platform())
28962306a36Sopenharmony_ci				snprintf(header, sizeof(header),
29062306a36Sopenharmony_ci					"high-priority-max-frequency(MHz)");
29162306a36Sopenharmony_ci			else
29262306a36Sopenharmony_ci				snprintf(header, sizeof(header),
29362306a36Sopenharmony_ci					"high-priority-max-%s-frequency(MHz)", isst_get_trl_level_name(i));
29462306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
29562306a36Sopenharmony_ci				bucket_info[j].hp_ratios[i] * isst_get_disp_freq_multiplier());
29662306a36Sopenharmony_ci			format_and_print(outf, base_level + 2, header, value);
29762306a36Sopenharmony_ci		}
29862306a36Sopenharmony_ci	}
29962306a36Sopenharmony_ci	snprintf(header, sizeof(header),
30062306a36Sopenharmony_ci		 "speed-select-turbo-freq-clip-frequencies");
30162306a36Sopenharmony_ci	format_and_print(outf, base_level + 1, header, NULL);
30262306a36Sopenharmony_ci
30362306a36Sopenharmony_ci	for (j = 0; j < trl_max_levels; j++) {
30462306a36Sopenharmony_ci		if (!fact_info->lp_ratios[j])
30562306a36Sopenharmony_ci			continue;
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci		/* No AVX level name for SSE to be consistent with previous formatting */
30862306a36Sopenharmony_ci		if (j == 0 && api_version() == 1 && !is_emr_platform())
30962306a36Sopenharmony_ci			snprintf(header, sizeof(header), "low-priority-max-frequency(MHz)");
31062306a36Sopenharmony_ci		else
31162306a36Sopenharmony_ci			snprintf(header, sizeof(header), "low-priority-max-%s-frequency(MHz)",
31262306a36Sopenharmony_ci				isst_get_trl_level_name(j));
31362306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%d",
31462306a36Sopenharmony_ci			 fact_info->lp_ratios[j] * isst_get_disp_freq_multiplier());
31562306a36Sopenharmony_ci		format_and_print(outf, base_level + 2, header, value);
31662306a36Sopenharmony_ci	}
31762306a36Sopenharmony_ci}
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_civoid isst_ctdp_display_core_info(struct isst_id *id, FILE *outf, char *prefix,
32062306a36Sopenharmony_ci				 unsigned int val, char *str0, char *str1)
32162306a36Sopenharmony_ci{
32262306a36Sopenharmony_ci	char value[256];
32362306a36Sopenharmony_ci	int level = print_package_info(id, outf);
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci	level++;
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci	if (str0 && !val)
32862306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%s", str0);
32962306a36Sopenharmony_ci	else if (str1 && val)
33062306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%s", str1);
33162306a36Sopenharmony_ci	else
33262306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%u", val);
33362306a36Sopenharmony_ci	format_and_print(outf, level, prefix, value);
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_ci	format_and_print(outf, 1, NULL, NULL);
33662306a36Sopenharmony_ci}
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_civoid isst_ctdp_display_information(struct isst_id *id, FILE *outf, int tdp_level,
33962306a36Sopenharmony_ci				   struct isst_pkg_ctdp *pkg_dev)
34062306a36Sopenharmony_ci{
34162306a36Sopenharmony_ci	char header[256];
34262306a36Sopenharmony_ci	char value[512];
34362306a36Sopenharmony_ci	static int level;
34462306a36Sopenharmony_ci	int trl_max_levels = isst_get_trl_max_levels();
34562306a36Sopenharmony_ci	int i;
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_ci	if (pkg_dev->processed)
34862306a36Sopenharmony_ci		level = print_package_info(id, outf);
34962306a36Sopenharmony_ci
35062306a36Sopenharmony_ci	for (i = 0; i <= pkg_dev->levels; ++i) {
35162306a36Sopenharmony_ci		struct isst_pkg_ctdp_level_info *ctdp_level;
35262306a36Sopenharmony_ci		int j, k;
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci		ctdp_level = &pkg_dev->ctdp_level[i];
35562306a36Sopenharmony_ci		if (!ctdp_level->processed)
35662306a36Sopenharmony_ci			continue;
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci		snprintf(header, sizeof(header), "perf-profile-level-%d",
35962306a36Sopenharmony_ci			 ctdp_level->level);
36062306a36Sopenharmony_ci		format_and_print(outf, level + 1, header, NULL);
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci		if (id->cpu >= 0) {
36362306a36Sopenharmony_ci			snprintf(header, sizeof(header), "cpu-count");
36462306a36Sopenharmony_ci			j = get_cpu_count(id);
36562306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d", j);
36662306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci			j = CPU_COUNT_S(ctdp_level->core_cpumask_size,
36962306a36Sopenharmony_ci					ctdp_level->core_cpumask);
37062306a36Sopenharmony_ci			if (j) {
37162306a36Sopenharmony_ci				snprintf(header, sizeof(header), "enable-cpu-count");
37262306a36Sopenharmony_ci				snprintf(value, sizeof(value), "%d", j);
37362306a36Sopenharmony_ci				format_and_print(outf, level + 2, header, value);
37462306a36Sopenharmony_ci			}
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci			if (ctdp_level->core_cpumask_size) {
37762306a36Sopenharmony_ci				snprintf(header, sizeof(header), "enable-cpu-mask");
37862306a36Sopenharmony_ci				printcpumask(sizeof(value), value,
37962306a36Sopenharmony_ci					     ctdp_level->core_cpumask_size,
38062306a36Sopenharmony_ci					     ctdp_level->core_cpumask);
38162306a36Sopenharmony_ci				format_and_print(outf, level + 2, header, value);
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_ci				snprintf(header, sizeof(header), "enable-cpu-list");
38462306a36Sopenharmony_ci				printcpulist(sizeof(value), value,
38562306a36Sopenharmony_ci					     ctdp_level->core_cpumask_size,
38662306a36Sopenharmony_ci					     ctdp_level->core_cpumask);
38762306a36Sopenharmony_ci				format_and_print(outf, level + 2, header, value);
38862306a36Sopenharmony_ci			}
38962306a36Sopenharmony_ci		}
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci		snprintf(header, sizeof(header), "thermal-design-power-ratio");
39262306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%d", ctdp_level->tdp_ratio);
39362306a36Sopenharmony_ci		format_and_print(outf, level + 2, header, value);
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ci		snprintf(header, sizeof(header), "base-frequency(MHz)");
39662306a36Sopenharmony_ci		if (!ctdp_level->sse_p1)
39762306a36Sopenharmony_ci			ctdp_level->sse_p1 = ctdp_level->tdp_ratio;
39862306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%d",
39962306a36Sopenharmony_ci			  ctdp_level->sse_p1 * isst_get_disp_freq_multiplier());
40062306a36Sopenharmony_ci		format_and_print(outf, level + 2, header, value);
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ci		if (ctdp_level->avx2_p1) {
40362306a36Sopenharmony_ci			snprintf(header, sizeof(header), "base-frequency-avx2(MHz)");
40462306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
40562306a36Sopenharmony_ci				 ctdp_level->avx2_p1 * isst_get_disp_freq_multiplier());
40662306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
40762306a36Sopenharmony_ci		}
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ci		if (ctdp_level->avx512_p1) {
41062306a36Sopenharmony_ci			snprintf(header, sizeof(header), "base-frequency-avx512(MHz)");
41162306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
41262306a36Sopenharmony_ci				 ctdp_level->avx512_p1 * isst_get_disp_freq_multiplier());
41362306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
41462306a36Sopenharmony_ci		}
41562306a36Sopenharmony_ci
41662306a36Sopenharmony_ci		if (ctdp_level->uncore_pm) {
41762306a36Sopenharmony_ci			snprintf(header, sizeof(header), "uncore-frequency-min(MHz)");
41862306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
41962306a36Sopenharmony_ci				 ctdp_level->uncore_pm * isst_get_disp_freq_multiplier());
42062306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
42162306a36Sopenharmony_ci		}
42262306a36Sopenharmony_ci
42362306a36Sopenharmony_ci		if (ctdp_level->uncore_p0) {
42462306a36Sopenharmony_ci			snprintf(header, sizeof(header), "uncore-frequency-max(MHz)");
42562306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
42662306a36Sopenharmony_ci				 ctdp_level->uncore_p0 * isst_get_disp_freq_multiplier());
42762306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
42862306a36Sopenharmony_ci		}
42962306a36Sopenharmony_ci
43062306a36Sopenharmony_ci		if (ctdp_level->amx_p1) {
43162306a36Sopenharmony_ci			snprintf(header, sizeof(header), "base-frequency-amx(MHz)");
43262306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
43362306a36Sopenharmony_ci			ctdp_level->amx_p1 * isst_get_disp_freq_multiplier());
43462306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
43562306a36Sopenharmony_ci		}
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci		if (ctdp_level->uncore_p1) {
43862306a36Sopenharmony_ci			snprintf(header, sizeof(header), "uncore-frequency-base(MHz)");
43962306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
44062306a36Sopenharmony_ci				 ctdp_level->uncore_p1 * isst_get_disp_freq_multiplier());
44162306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
44262306a36Sopenharmony_ci		}
44362306a36Sopenharmony_ci
44462306a36Sopenharmony_ci		if (ctdp_level->mem_freq) {
44562306a36Sopenharmony_ci			snprintf(header, sizeof(header), "max-mem-frequency(MHz)");
44662306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
44762306a36Sopenharmony_ci				 ctdp_level->mem_freq);
44862306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
44962306a36Sopenharmony_ci		}
45062306a36Sopenharmony_ci
45162306a36Sopenharmony_ci		if (api_version() > 1) {
45262306a36Sopenharmony_ci			snprintf(header, sizeof(header), "cooling_type");
45362306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d",
45462306a36Sopenharmony_ci				ctdp_level->cooling_type);
45562306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
45662306a36Sopenharmony_ci		}
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_ci		snprintf(header, sizeof(header),
45962306a36Sopenharmony_ci			 "speed-select-turbo-freq");
46062306a36Sopenharmony_ci		if (ctdp_level->fact_support) {
46162306a36Sopenharmony_ci			if (ctdp_level->fact_enabled)
46262306a36Sopenharmony_ci				snprintf(value, sizeof(value), "enabled");
46362306a36Sopenharmony_ci			else
46462306a36Sopenharmony_ci				snprintf(value, sizeof(value), "disabled");
46562306a36Sopenharmony_ci		} else
46662306a36Sopenharmony_ci			snprintf(value, sizeof(value), "unsupported");
46762306a36Sopenharmony_ci		format_and_print(outf, level + 2, header, value);
46862306a36Sopenharmony_ci
46962306a36Sopenharmony_ci		snprintf(header, sizeof(header),
47062306a36Sopenharmony_ci			 "speed-select-base-freq");
47162306a36Sopenharmony_ci		if (ctdp_level->pbf_support) {
47262306a36Sopenharmony_ci			if (ctdp_level->pbf_enabled)
47362306a36Sopenharmony_ci				snprintf(value, sizeof(value), "enabled");
47462306a36Sopenharmony_ci			else
47562306a36Sopenharmony_ci				snprintf(value, sizeof(value), "disabled");
47662306a36Sopenharmony_ci		} else
47762306a36Sopenharmony_ci			snprintf(value, sizeof(value), "unsupported");
47862306a36Sopenharmony_ci		format_and_print(outf, level + 2, header, value);
47962306a36Sopenharmony_ci
48062306a36Sopenharmony_ci		snprintf(header, sizeof(header),
48162306a36Sopenharmony_ci			 "speed-select-core-power");
48262306a36Sopenharmony_ci		if (ctdp_level->sst_cp_support) {
48362306a36Sopenharmony_ci			if (ctdp_level->sst_cp_enabled)
48462306a36Sopenharmony_ci				snprintf(value, sizeof(value), "enabled");
48562306a36Sopenharmony_ci			else
48662306a36Sopenharmony_ci				snprintf(value, sizeof(value), "disabled");
48762306a36Sopenharmony_ci		} else
48862306a36Sopenharmony_ci			snprintf(value, sizeof(value), "unsupported");
48962306a36Sopenharmony_ci		format_and_print(outf, level + 2, header, value);
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci		if (is_clx_n_platform()) {
49262306a36Sopenharmony_ci			if (ctdp_level->pbf_support)
49362306a36Sopenharmony_ci				_isst_pbf_display_information(id, outf,
49462306a36Sopenharmony_ci							      tdp_level,
49562306a36Sopenharmony_ci							  &ctdp_level->pbf_info,
49662306a36Sopenharmony_ci							      level + 2);
49762306a36Sopenharmony_ci			continue;
49862306a36Sopenharmony_ci		}
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_ci		if (ctdp_level->pkg_tdp) {
50162306a36Sopenharmony_ci			snprintf(header, sizeof(header), "thermal-design-power(W)");
50262306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d", ctdp_level->pkg_tdp);
50362306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
50462306a36Sopenharmony_ci		}
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci		if (ctdp_level->t_proc_hot) {
50762306a36Sopenharmony_ci			snprintf(header, sizeof(header), "tjunction-max(C)");
50862306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%d", ctdp_level->t_proc_hot);
50962306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, value);
51062306a36Sopenharmony_ci		}
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ci		for (k = 0; k < trl_max_levels; k++) {
51362306a36Sopenharmony_ci			if (!ctdp_level->trl_ratios[k][0])
51462306a36Sopenharmony_ci				continue;
51562306a36Sopenharmony_ci
51662306a36Sopenharmony_ci			snprintf(header, sizeof(header), "turbo-ratio-limits-%s", isst_get_trl_level_name(k));
51762306a36Sopenharmony_ci			format_and_print(outf, level + 2, header, NULL);
51862306a36Sopenharmony_ci
51962306a36Sopenharmony_ci			for (j = 0; j < 8; ++j) {
52062306a36Sopenharmony_ci				snprintf(header, sizeof(header), "bucket-%d", j);
52162306a36Sopenharmony_ci				format_and_print(outf, level + 3, header, NULL);
52262306a36Sopenharmony_ci
52362306a36Sopenharmony_ci				snprintf(header, sizeof(header), "core-count");
52462306a36Sopenharmony_ci
52562306a36Sopenharmony_ci				snprintf(value, sizeof(value), "%llu", (ctdp_level->trl_cores >> (j * 8)) & 0xff);
52662306a36Sopenharmony_ci				format_and_print(outf, level + 4, header, value);
52762306a36Sopenharmony_ci
52862306a36Sopenharmony_ci				snprintf(header, sizeof(header), "max-turbo-frequency(MHz)");
52962306a36Sopenharmony_ci				snprintf(value, sizeof(value), "%d", ctdp_level->trl_ratios[k][j] * isst_get_disp_freq_multiplier());
53062306a36Sopenharmony_ci				format_and_print(outf, level + 4, header, value);
53162306a36Sopenharmony_ci			}
53262306a36Sopenharmony_ci		}
53362306a36Sopenharmony_ci
53462306a36Sopenharmony_ci		if (ctdp_level->pbf_support)
53562306a36Sopenharmony_ci			_isst_pbf_display_information(id, outf, i,
53662306a36Sopenharmony_ci						      &ctdp_level->pbf_info,
53762306a36Sopenharmony_ci						      level + 2);
53862306a36Sopenharmony_ci		if (ctdp_level->fact_support)
53962306a36Sopenharmony_ci			_isst_fact_display_information(id, outf, i, 0xff, 0xff,
54062306a36Sopenharmony_ci						       &ctdp_level->fact_info,
54162306a36Sopenharmony_ci						       level + 2);
54262306a36Sopenharmony_ci	}
54362306a36Sopenharmony_ci
54462306a36Sopenharmony_ci	format_and_print(outf, 1, NULL, NULL);
54562306a36Sopenharmony_ci}
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_cistatic int start;
54862306a36Sopenharmony_civoid isst_ctdp_display_information_start(FILE *outf)
54962306a36Sopenharmony_ci{
55062306a36Sopenharmony_ci	last_level = 0;
55162306a36Sopenharmony_ci	format_and_print(outf, 0, "start", NULL);
55262306a36Sopenharmony_ci	start = 1;
55362306a36Sopenharmony_ci}
55462306a36Sopenharmony_ci
55562306a36Sopenharmony_civoid isst_ctdp_display_information_end(FILE *outf)
55662306a36Sopenharmony_ci{
55762306a36Sopenharmony_ci	format_and_print(outf, 0, NULL, NULL);
55862306a36Sopenharmony_ci	start = 0;
55962306a36Sopenharmony_ci}
56062306a36Sopenharmony_ci
56162306a36Sopenharmony_civoid isst_pbf_display_information(struct isst_id *id, FILE *outf, int level,
56262306a36Sopenharmony_ci				  struct isst_pbf_info *pbf_info)
56362306a36Sopenharmony_ci{
56462306a36Sopenharmony_ci	int _level;
56562306a36Sopenharmony_ci
56662306a36Sopenharmony_ci	_level = print_package_info(id, outf);
56762306a36Sopenharmony_ci	_isst_pbf_display_information(id, outf, level, pbf_info, _level + 1);
56862306a36Sopenharmony_ci	format_and_print(outf, 1, NULL, NULL);
56962306a36Sopenharmony_ci}
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_civoid isst_fact_display_information(struct isst_id *id, FILE *outf, int level,
57262306a36Sopenharmony_ci				   int fact_bucket, int fact_avx,
57362306a36Sopenharmony_ci				   struct isst_fact_info *fact_info)
57462306a36Sopenharmony_ci{
57562306a36Sopenharmony_ci	int _level;
57662306a36Sopenharmony_ci
57762306a36Sopenharmony_ci	_level = print_package_info(id, outf);
57862306a36Sopenharmony_ci	_isst_fact_display_information(id, outf, level, fact_bucket, fact_avx,
57962306a36Sopenharmony_ci				       fact_info, _level + 1);
58062306a36Sopenharmony_ci	format_and_print(outf, 1, NULL, NULL);
58162306a36Sopenharmony_ci}
58262306a36Sopenharmony_ci
58362306a36Sopenharmony_civoid isst_clos_display_information(struct isst_id *id, FILE *outf, int clos,
58462306a36Sopenharmony_ci				   struct isst_clos_config *clos_config)
58562306a36Sopenharmony_ci{
58662306a36Sopenharmony_ci	char header[256];
58762306a36Sopenharmony_ci	char value[256];
58862306a36Sopenharmony_ci	int level;
58962306a36Sopenharmony_ci
59062306a36Sopenharmony_ci	level = print_package_info(id, outf);
59162306a36Sopenharmony_ci
59262306a36Sopenharmony_ci	snprintf(header, sizeof(header), "core-power");
59362306a36Sopenharmony_ci	format_and_print(outf, level + 1, header, NULL);
59462306a36Sopenharmony_ci
59562306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos");
59662306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", clos);
59762306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
59862306a36Sopenharmony_ci
59962306a36Sopenharmony_ci	snprintf(header, sizeof(header), "epp");
60062306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", clos_config->epp);
60162306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
60262306a36Sopenharmony_ci
60362306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos-proportional-priority");
60462306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", clos_config->clos_prop_prio);
60562306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
60662306a36Sopenharmony_ci
60762306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos-min");
60862306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_min * isst_get_disp_freq_multiplier());
60962306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
61062306a36Sopenharmony_ci
61162306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos-max");
61262306a36Sopenharmony_ci	if ((clos_config->clos_max * isst_get_disp_freq_multiplier()) == 25500)
61362306a36Sopenharmony_ci		snprintf(value, sizeof(value), "Max Turbo frequency");
61462306a36Sopenharmony_ci	else
61562306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%d MHz", clos_config->clos_max * isst_get_disp_freq_multiplier());
61662306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
61762306a36Sopenharmony_ci
61862306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos-desired");
61962306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d MHz", clos_config->clos_desired * isst_get_disp_freq_multiplier());
62062306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
62162306a36Sopenharmony_ci
62262306a36Sopenharmony_ci	format_and_print(outf, level, NULL, NULL);
62362306a36Sopenharmony_ci}
62462306a36Sopenharmony_ci
62562306a36Sopenharmony_civoid isst_clos_display_clos_information(struct isst_id *id, FILE *outf,
62662306a36Sopenharmony_ci					int clos_enable, int type,
62762306a36Sopenharmony_ci					int state, int cap)
62862306a36Sopenharmony_ci{
62962306a36Sopenharmony_ci	char header[256];
63062306a36Sopenharmony_ci	char value[256];
63162306a36Sopenharmony_ci	int level;
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_ci	level = print_package_info(id, outf);
63462306a36Sopenharmony_ci
63562306a36Sopenharmony_ci	snprintf(header, sizeof(header), "core-power");
63662306a36Sopenharmony_ci	format_and_print(outf, level + 1, header, NULL);
63762306a36Sopenharmony_ci
63862306a36Sopenharmony_ci	snprintf(header, sizeof(header), "support-status");
63962306a36Sopenharmony_ci	if (cap)
64062306a36Sopenharmony_ci		snprintf(value, sizeof(value), "supported");
64162306a36Sopenharmony_ci	else
64262306a36Sopenharmony_ci		snprintf(value, sizeof(value), "unsupported");
64362306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
64462306a36Sopenharmony_ci
64562306a36Sopenharmony_ci	snprintf(header, sizeof(header), "enable-status");
64662306a36Sopenharmony_ci	if (state)
64762306a36Sopenharmony_ci		snprintf(value, sizeof(value), "enabled");
64862306a36Sopenharmony_ci	else
64962306a36Sopenharmony_ci		snprintf(value, sizeof(value), "disabled");
65062306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
65162306a36Sopenharmony_ci
65262306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos-enable-status");
65362306a36Sopenharmony_ci	if (clos_enable)
65462306a36Sopenharmony_ci		snprintf(value, sizeof(value), "enabled");
65562306a36Sopenharmony_ci	else
65662306a36Sopenharmony_ci		snprintf(value, sizeof(value), "disabled");
65762306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
65862306a36Sopenharmony_ci
65962306a36Sopenharmony_ci	snprintf(header, sizeof(header), "priority-type");
66062306a36Sopenharmony_ci	if (type)
66162306a36Sopenharmony_ci		snprintf(value, sizeof(value), "ordered");
66262306a36Sopenharmony_ci	else
66362306a36Sopenharmony_ci		snprintf(value, sizeof(value), "proportional");
66462306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
66562306a36Sopenharmony_ci
66662306a36Sopenharmony_ci	format_and_print(outf, level, NULL, NULL);
66762306a36Sopenharmony_ci}
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_civoid isst_clos_display_assoc_information(struct isst_id *id, FILE *outf, int clos)
67062306a36Sopenharmony_ci{
67162306a36Sopenharmony_ci	char header[256];
67262306a36Sopenharmony_ci	char value[256];
67362306a36Sopenharmony_ci	int level;
67462306a36Sopenharmony_ci
67562306a36Sopenharmony_ci	level = print_package_info(id, outf);
67662306a36Sopenharmony_ci
67762306a36Sopenharmony_ci	snprintf(header, sizeof(header), "get-assoc");
67862306a36Sopenharmony_ci	format_and_print(outf, level + 1, header, NULL);
67962306a36Sopenharmony_ci
68062306a36Sopenharmony_ci	snprintf(header, sizeof(header), "clos");
68162306a36Sopenharmony_ci	snprintf(value, sizeof(value), "%d", clos);
68262306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
68362306a36Sopenharmony_ci
68462306a36Sopenharmony_ci	format_and_print(outf, level, NULL, NULL);
68562306a36Sopenharmony_ci}
68662306a36Sopenharmony_ci
68762306a36Sopenharmony_civoid isst_display_result(struct isst_id *id, FILE *outf, char *feature, char *cmd,
68862306a36Sopenharmony_ci			 int result)
68962306a36Sopenharmony_ci{
69062306a36Sopenharmony_ci	char header[256];
69162306a36Sopenharmony_ci	char value[256];
69262306a36Sopenharmony_ci	int level = 3;
69362306a36Sopenharmony_ci
69462306a36Sopenharmony_ci	level = print_package_info(id, outf);
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ci	snprintf(header, sizeof(header), "%s", feature);
69762306a36Sopenharmony_ci	format_and_print(outf, level + 1, header, NULL);
69862306a36Sopenharmony_ci	snprintf(header, sizeof(header), "%s", cmd);
69962306a36Sopenharmony_ci	if (!result)
70062306a36Sopenharmony_ci		snprintf(value, sizeof(value), "success");
70162306a36Sopenharmony_ci	else
70262306a36Sopenharmony_ci		snprintf(value, sizeof(value), "failed(error %d)", result);
70362306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
70462306a36Sopenharmony_ci
70562306a36Sopenharmony_ci	format_and_print(outf, level, NULL, NULL);
70662306a36Sopenharmony_ci}
70762306a36Sopenharmony_ci
70862306a36Sopenharmony_civoid isst_display_error_info_message(int error, char *msg, int arg_valid, int arg)
70962306a36Sopenharmony_ci{
71062306a36Sopenharmony_ci	FILE *outf = get_output_file();
71162306a36Sopenharmony_ci	static int error_index;
71262306a36Sopenharmony_ci	char header[256];
71362306a36Sopenharmony_ci	char value[256];
71462306a36Sopenharmony_ci
71562306a36Sopenharmony_ci	if (!out_format_is_json()) {
71662306a36Sopenharmony_ci		if (arg_valid)
71762306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%s %d", msg, arg);
71862306a36Sopenharmony_ci		else
71962306a36Sopenharmony_ci			snprintf(value, sizeof(value), "%s", msg);
72062306a36Sopenharmony_ci
72162306a36Sopenharmony_ci		if (error)
72262306a36Sopenharmony_ci			fprintf(outf, "Error: %s\n", value);
72362306a36Sopenharmony_ci		else
72462306a36Sopenharmony_ci			fprintf(outf, "Information: %s\n", value);
72562306a36Sopenharmony_ci		return;
72662306a36Sopenharmony_ci	}
72762306a36Sopenharmony_ci
72862306a36Sopenharmony_ci	if (!start)
72962306a36Sopenharmony_ci		format_and_print(outf, 0, "start", NULL);
73062306a36Sopenharmony_ci
73162306a36Sopenharmony_ci	if (error)
73262306a36Sopenharmony_ci		snprintf(header, sizeof(header), "Error%d", error_index++);
73362306a36Sopenharmony_ci	else
73462306a36Sopenharmony_ci		snprintf(header, sizeof(header), "Information:%d", error_index++);
73562306a36Sopenharmony_ci	format_and_print(outf, 1, header, NULL);
73662306a36Sopenharmony_ci
73762306a36Sopenharmony_ci	snprintf(header, sizeof(header), "message");
73862306a36Sopenharmony_ci	if (arg_valid)
73962306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%s %d", msg, arg);
74062306a36Sopenharmony_ci	else
74162306a36Sopenharmony_ci		snprintf(value, sizeof(value), "%s", msg);
74262306a36Sopenharmony_ci
74362306a36Sopenharmony_ci	format_and_print(outf, 2, header, value);
74462306a36Sopenharmony_ci	format_and_print(outf, 1, NULL, NULL);
74562306a36Sopenharmony_ci	if (!start)
74662306a36Sopenharmony_ci		format_and_print(outf, 0, NULL, NULL);
74762306a36Sopenharmony_ci}
74862306a36Sopenharmony_ci
74962306a36Sopenharmony_civoid isst_trl_display_information(struct isst_id *id, FILE *outf, unsigned long long trl)
75062306a36Sopenharmony_ci{
75162306a36Sopenharmony_ci	char header[256];
75262306a36Sopenharmony_ci	char value[256];
75362306a36Sopenharmony_ci	int level;
75462306a36Sopenharmony_ci
75562306a36Sopenharmony_ci	level = print_package_info(id, outf);
75662306a36Sopenharmony_ci
75762306a36Sopenharmony_ci	snprintf(header, sizeof(header), "get-trl");
75862306a36Sopenharmony_ci	format_and_print(outf, level + 1, header, NULL);
75962306a36Sopenharmony_ci
76062306a36Sopenharmony_ci	snprintf(header, sizeof(header), "trl");
76162306a36Sopenharmony_ci	snprintf(value, sizeof(value), "0x%llx", trl);
76262306a36Sopenharmony_ci	format_and_print(outf, level + 2, header, value);
76362306a36Sopenharmony_ci
76462306a36Sopenharmony_ci	format_and_print(outf, level, NULL, NULL);
76562306a36Sopenharmony_ci}
766