Anton Arapov c2a608
From 6486331cf66e35bcf01e1c15c4396af68b6eb4d4 Mon Sep 17 00:00:00 2001
Anton Arapov c2a608
From: Jean Delvare <jdelvare@suse.de>
Anton Arapov c2a608
Date: Tue, 25 Jul 2017 11:21:22 +0200
Anton Arapov c2a608
Subject: [PATCH 06/21] biosdecode: Add option --pir full
Anton Arapov c2a608
Anton Arapov c2a608
Add an option to decode the details of the PIR table.
Anton Arapov c2a608
Anton Arapov c2a608
This implements support request #109339:
Anton Arapov c2a608
https://savannah.nongnu.org/support/index.php?109339
Anton Arapov c2a608
---
Anton Arapov c2a608
 biosdecode.c     | 59 +++++++++++++++++++++++++++---------------------
Anton Arapov c2a608
 man/biosdecode.8 |  3 +++
Anton Arapov c2a608
 2 files changed, 36 insertions(+), 26 deletions(-)
Anton Arapov c2a608
Anton Arapov c2a608
diff --git a/biosdecode.c b/biosdecode.c
Anton Arapov c2a608
index ad3d4bc..8293e61 100644
Anton Arapov c2a608
--- a/biosdecode.c
Anton Arapov c2a608
+++ b/biosdecode.c
Anton Arapov c2a608
@@ -73,12 +73,16 @@ struct opt
Anton Arapov c2a608
 {
Anton Arapov c2a608
 	const char *devmem;
Anton Arapov c2a608
 	unsigned int flags;
Anton Arapov c2a608
+	unsigned char pir;
Anton Arapov c2a608
 };
Anton Arapov c2a608
 static struct opt opt;
Anton Arapov c2a608
 
Anton Arapov c2a608
 #define FLAG_VERSION            (1 << 0)
Anton Arapov c2a608
 #define FLAG_HELP               (1 << 1)
Anton Arapov c2a608
 
Anton Arapov c2a608
+#define PIR_SHORT               0
Anton Arapov c2a608
+#define PIR_FULL                1
Anton Arapov c2a608
+
Anton Arapov c2a608
 struct bios_entry {
Anton Arapov c2a608
 	const char *anchor;
Anton Arapov c2a608
 	size_t anchor_len; /* computed */
Anton Arapov c2a608
@@ -386,32 +390,29 @@ static int pir_decode(const u8 *p, size_t len)
Anton Arapov c2a608
 			i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
Anton Arapov c2a608
 		pir_slot_number(p[(i + 1) * 16 + 14]);
Anton Arapov c2a608
 		printf("\n");
Anton Arapov c2a608
-/*		printf("\tSlot Entry %u\n", i);
Anton Arapov c2a608
-		printf("\t\tID: %02x:%02x\n",
Anton Arapov c2a608
-			p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
Anton Arapov c2a608
-		printf("\t\tLink Value for INTA#: %u\n",
Anton Arapov c2a608
-			p[(i + 1) * 16 + 2]);
Anton Arapov c2a608
-		printf("\t\tIRQ Bitmap for INTA#:");
Anton Arapov c2a608
-		pir_irqs(WORD(p + (i + 1) * 16 + 3));
Anton Arapov c2a608
-		printf("\n");
Anton Arapov c2a608
-		printf("\t\tLink Value for INTB#: %u\n",
Anton Arapov c2a608
-			p[(i + 1) * 16 + 5]);
Anton Arapov c2a608
-		printf("\t\tIRQ Bitmap for INTB#:");
Anton Arapov c2a608
-		pir_irqs(WORD(p + (i + 1) * 16 + 6));
Anton Arapov c2a608
-		printf("\n");
Anton Arapov c2a608
-		printf("\t\tLink Value for INTC#: %u\n",
Anton Arapov c2a608
-			p[(i + 1) * 16 + 8]);
Anton Arapov c2a608
-		printf("\t\tIRQ Bitmap for INTC#:");
Anton Arapov c2a608
-		pir_irqs(WORD(p + (i + 1) * 16 + 9));
Anton Arapov c2a608
-		printf("\n");
Anton Arapov c2a608
-		printf("\t\tLink Value for INTD#: %u\n",
Anton Arapov c2a608
-			p[(i + 1) * 16 + 11]);
Anton Arapov c2a608
-		printf("\t\tIRQ Bitmap for INTD#:");
Anton Arapov c2a608
-		pir_irqs(WORD(p + (i + 1) * 16 + 12));
Anton Arapov c2a608
-		printf("\n");
Anton Arapov c2a608
-		printf("\t\tSlot Number:");
Anton Arapov c2a608
-		pir_slot_number(p[(i + 1) * 16 + 14]);
Anton Arapov c2a608
-		printf("\n");*/
Anton Arapov c2a608
+		if (opt.pir == PIR_FULL)
Anton Arapov c2a608
+		{
Anton Arapov c2a608
+			printf("\t\tLink Value for INTA#: %u\n",
Anton Arapov c2a608
+				p[(i + 1) * 16 + 2]);
Anton Arapov c2a608
+			printf("\t\tIRQ Bitmap for INTA#:");
Anton Arapov c2a608
+			pir_irqs(WORD(p + (i + 1) * 16 + 3));
Anton Arapov c2a608
+			printf("\n");
Anton Arapov c2a608
+			printf("\t\tLink Value for INTB#: %u\n",
Anton Arapov c2a608
+				p[(i + 1) * 16 + 5]);
Anton Arapov c2a608
+			printf("\t\tIRQ Bitmap for INTB#:");
Anton Arapov c2a608
+			pir_irqs(WORD(p + (i + 1) * 16 + 6));
Anton Arapov c2a608
+			printf("\n");
Anton Arapov c2a608
+			printf("\t\tLink Value for INTC#: %u\n",
Anton Arapov c2a608
+				p[(i + 1) * 16 + 8]);
Anton Arapov c2a608
+			printf("\t\tIRQ Bitmap for INTC#:");
Anton Arapov c2a608
+			pir_irqs(WORD(p + (i + 1) * 16 + 9));
Anton Arapov c2a608
+			printf("\n");
Anton Arapov c2a608
+			printf("\t\tLink Value for INTD#: %u\n",
Anton Arapov c2a608
+				p[(i + 1) * 16 + 11]);
Anton Arapov c2a608
+			printf("\t\tIRQ Bitmap for INTD#:");
Anton Arapov c2a608
+			pir_irqs(WORD(p + (i + 1) * 16 + 12));
Anton Arapov c2a608
+			printf("\n");
Anton Arapov c2a608
+		}
Anton Arapov c2a608
 	}
Anton Arapov c2a608
 
Anton Arapov c2a608
 	return 1;
Anton Arapov c2a608
@@ -616,6 +617,7 @@ static int parse_command_line(int argc, char * const argv[])
Anton Arapov c2a608
 	const char *optstring = "d:hV";
Anton Arapov c2a608
 	struct option longopts[] = {
Anton Arapov c2a608
 		{ "dev-mem", required_argument, NULL, 'd' },
Anton Arapov c2a608
+		{ "pir", required_argument, NULL, 'P' },
Anton Arapov c2a608
 		{ "help", no_argument, NULL, 'h' },
Anton Arapov c2a608
 		{ "version", no_argument, NULL, 'V' },
Anton Arapov c2a608
 		{ NULL, 0, NULL, 0 }
Anton Arapov c2a608
@@ -627,6 +629,10 @@ static int parse_command_line(int argc, char * const argv[])
Anton Arapov c2a608
 			case 'd':
Anton Arapov c2a608
 				opt.devmem = optarg;
Anton Arapov c2a608
 				break;
Anton Arapov c2a608
+			case 'P':
Anton Arapov c2a608
+				if (strcmp(optarg, "full") == 0)
Anton Arapov c2a608
+					opt.pir = PIR_FULL;
Anton Arapov c2a608
+				break;
Anton Arapov c2a608
 			case 'h':
Anton Arapov c2a608
 				opt.flags |= FLAG_HELP;
Anton Arapov c2a608
 				break;
Anton Arapov c2a608
@@ -646,6 +652,7 @@ static void print_help(void)
Anton Arapov c2a608
 		"Usage: biosdecode [OPTIONS]\n"
Anton Arapov c2a608
 		"Options are:\n"
Anton Arapov c2a608
 		" -d, --dev-mem FILE     Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
Anton Arapov c2a608
+		"     --pir full         Decode the details of the PCI IRQ routing table\n"
Anton Arapov c2a608
 		" -h, --help             Display this help text and exit\n"
Anton Arapov c2a608
 		" -V, --version          Display the version and exit\n";
Anton Arapov c2a608
 
Anton Arapov c2a608
diff --git a/man/biosdecode.8 b/man/biosdecode.8
Anton Arapov c2a608
index c39d6a0..a96eb68 100644
Anton Arapov c2a608
--- a/man/biosdecode.8
Anton Arapov c2a608
+++ b/man/biosdecode.8
Anton Arapov c2a608
@@ -60,6 +60,9 @@ program.
Anton Arapov c2a608
 .BR "-d" ", " "--dev-mem FILE"
Anton Arapov c2a608
 Read memory from device \fBFILE\fR (default: \fB/dev/mem\fR)
Anton Arapov c2a608
 .TP
Anton Arapov c2a608
+.BR "  " "  " "--pir full"
Anton Arapov c2a608
+Decode the details of the PCI IRQ routing table
Anton Arapov c2a608
+.TP
Anton Arapov c2a608
 .BR "-h" ", " "--help"
Anton Arapov c2a608
 Display usage information and exit
Anton Arapov c2a608
 .TP
Anton Arapov c2a608
-- 
Anton Arapov c2a608
2.17.1
Anton Arapov c2a608