cpcgen.c (00fc50d191cf90458c41a077d59fe2f81223f00a) cpcgen.c (31aa620247ae407b2bee2dccd71693d1938f54d6)
1/*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at

--- 318 unchanged lines hidden (view full) ---

327".\\\"\n"
328".\\\" We would like to thank AMD for providing the PMC data for use in\n"
329".\\\" our manual pages.\n"
330".Dd March 25, 2019\n"
331".Dt AMD_%s_EVENTS 3CPC\n"
332".Os\n"
333".Sh NAME\n"
334".Nm amd_%s_events\n"
1/*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at

--- 318 unchanged lines hidden (view full) ---

327".\\\"\n"
328".\\\" We would like to thank AMD for providing the PMC data for use in\n"
329".\\\" our manual pages.\n"
330".Dd March 25, 2019\n"
331".Dt AMD_%s_EVENTS 3CPC\n"
332".Os\n"
333".Sh NAME\n"
334".Nm amd_%s_events\n"
335".Nd AMD family %s processor performance monitoring events\n"
335".Nd AMD Family %s processor performance monitoring events\n"
336".Sh DESCRIPTION\n"
336".Sh DESCRIPTION\n"
337"This manual page describes events specfic to AMD family %s processors.\n"
337"This manual page describes events specfic to AMD Family %s processors.\n"
338"For more information, please consult the appropriate AMD BIOS and Kernel\n"
338"For more information, please consult the appropriate AMD BIOS and Kernel\n"
339"Developer's guide or Open-Source Register Reference manual.\n"
339"Developer's guide or Open-Source Register Reference.\n"
340".Pp\n"
341"Each of the events listed below includes the AMD mnemonic which matches\n"
342"the name found in the AMD manual and a brief summary of the event.\n"
343"If available, a more detailed description of the event follows and then\n"
344"any additional unit values that modify the event.\n"
345"Each unit can be combined to create a new event in the system by placing\n"
346"the '.' character between the event name and the unit name.\n"
347".Pp\n"

--- 277 unchanged lines hidden (view full) ---

625
626 free(mappath);
627}
628
629/*
630 * Read in all the data files that exist for AMD.
631 *
632 * Our family names for AMD systems are based on the family and type so a given
340".Pp\n"
341"Each of the events listed below includes the AMD mnemonic which matches\n"
342"the name found in the AMD manual and a brief summary of the event.\n"
343"If available, a more detailed description of the event follows and then\n"
344"any additional unit values that modify the event.\n"
345"Each unit can be combined to create a new event in the system by placing\n"
346"the '.' character between the event name and the unit name.\n"
347".Pp\n"

--- 277 unchanged lines hidden (view full) ---

625
626 free(mappath);
627}
628
629/*
630 * Read in all the data files that exist for AMD.
631 *
632 * Our family names for AMD systems are based on the family and type so a given
633 * name will look like f17h_core.json.
633 * name will look like f17h_<core>_core.json.
634 */
635static void
636cpcgen_read_amd(const char *datadir, const char *platform)
637{
638 DIR *dir;
639 struct dirent *d;
640 const char *suffix = ".json";
641 const size_t slen = strlen(suffix);

--- 13 unchanged lines hidden (view full) ---

655 }
656 c = strstr(name, suffix);
657
658 if (c == NULL) {
659 free(name);
660 continue;
661 }
662
634 */
635static void
636cpcgen_read_amd(const char *datadir, const char *platform)
637{
638 DIR *dir;
639 struct dirent *d;
640 const char *suffix = ".json";
641 const size_t slen = strlen(suffix);

--- 13 unchanged lines hidden (view full) ---

655 }
656 c = strstr(name, suffix);
657
658 if (c == NULL) {
659 free(name);
660 continue;
661 }
662
663 /*
664 * Chop off the .json. Next, make sure we have both _ present.
665 */
663 if (*(c + slen) != '\0') {
664 free(name);
665 continue;
666 }
666 if (*(c + slen) != '\0') {
667 free(name);
668 continue;
669 }
667
668 *c = '\0';
670 *c = '\0';
671
669 c = strchr(name, '_');
670 if (c == NULL) {
672 c = strchr(name, '_');
673 if (c == NULL) {
671 free(name);
672 continue;
674 errx(EXIT_FAILURE, "unexpected AMD JSON file name: %s",
675 d->d_name);
673 }
676 }
677
678 c++;
679 c = strchr(c, '_');
680 if (c == NULL) {
681 errx(EXIT_FAILURE, "unexpected AMD JSON file name: %s",
682 d->d_name);
683 }
674 *c = '\0';
675 c++;
676 if (strcmp(c, "core") != 0) {
677 errx(EXIT_FAILURE, "unexpected AMD JSON file name: %s",
678 d->d_name);
679 }
680
681 if (platform != NULL && strcmp(platform, name) != 0) {

--- 721 unchanged lines hidden (view full) ---

1403
1404 return (name);
1405}
1406
1407static boolean_t
1408cpcgen_manual_amd_file_before(FILE *f, cpc_map_t *map)
1409{
1410 size_t i;
684 *c = '\0';
685 c++;
686 if (strcmp(c, "core") != 0) {
687 errx(EXIT_FAILURE, "unexpected AMD JSON file name: %s",
688 d->d_name);
689 }
690
691 if (platform != NULL && strcmp(platform, name) != 0) {

--- 721 unchanged lines hidden (view full) ---

1413
1414 return (name);
1415}
1416
1417static boolean_t
1418cpcgen_manual_amd_file_before(FILE *f, cpc_map_t *map)
1419{
1420 size_t i;
1411 char *upper;
1412 const char *family;
1421 char *upper, *desc, *c;
1413
1414 if ((upper = strdup(map->cmap_name)) == NULL) {
1415 warn("failed to duplicate manual name for %s", map->cmap_name);
1416 return (B_FALSE);
1417 }
1418
1422
1423 if ((upper = strdup(map->cmap_name)) == NULL) {
1424 warn("failed to duplicate manual name for %s", map->cmap_name);
1425 return (B_FALSE);
1426 }
1427
1428 if ((desc = strdup(map->cmap_name)) == NULL) {
1429 warn("failed to duplicate manual name for %s", map->cmap_name);
1430 free(upper);
1431 return (B_FALSE);
1432 }
1433
1419 for (i = 0; upper[i] != '\0'; i++) {
1420 upper[i] = toupper(upper[i]);
1421 }
1422
1434 for (i = 0; upper[i] != '\0'; i++) {
1435 upper[i] = toupper(upper[i]);
1436 }
1437
1423 family = map->cmap_name + 1;
1438 desc++;
1439 c = strchr(desc, '_');
1440 if (c != NULL) {
1441 *c = ' ';
1442 c++;
1443 *c = toupper(*c);
1444 }
1424
1425 if (fprintf(f, cpcgen_manual_amd_header, map->cmap_path, upper,
1445
1446 if (fprintf(f, cpcgen_manual_amd_header, map->cmap_path, upper,
1426 family, family, family) == -1) {
1447 map->cmap_name, desc, desc) == -1) {
1427 warn("failed to write out manual header for %s",
1428 map->cmap_name);
1429 free(upper);
1448 warn("failed to write out manual header for %s",
1449 map->cmap_name);
1450 free(upper);
1451 free(desc);
1430 return (B_FALSE);
1431 }
1432
1433 free(upper);
1452 return (B_FALSE);
1453 }
1454
1455 free(upper);
1456 free(desc);
1434 return (B_TRUE);
1435}
1436
1437static boolean_t
1438cpcgen_manual_amd_file_after(FILE *f, cpc_map_t *map)
1439{
1440 if (fprintf(f, cpcgen_manual_amd_trailer) == -1) {
1441 warn("failed to write out manual header for %s",

--- 604 unchanged lines hidden ---
1457 return (B_TRUE);
1458}
1459
1460static boolean_t
1461cpcgen_manual_amd_file_after(FILE *f, cpc_map_t *map)
1462{
1463 if (fprintf(f, cpcgen_manual_amd_trailer) == -1) {
1464 warn("failed to write out manual header for %s",

--- 604 unchanged lines hidden ---