aboutsummaryrefslogtreecommitdiff
path: root/util/getpir
diff options
context:
space:
mode:
Diffstat (limited to 'util/getpir')
-rw-r--r--util/getpir/Makefile24
-rw-r--r--util/getpir/README30
-rw-r--r--util/getpir/checkpir.c31
-rw-r--r--util/getpir/checksum.c13
-rw-r--r--util/getpir/checksum.h6
-rw-r--r--util/getpir/code_gen.c88
-rw-r--r--util/getpir/code_gen.h6
-rw-r--r--util/getpir/getpir.c189
-rw-r--r--util/getpir/pirq_routing.h55
9 files changed, 0 insertions, 442 deletions
diff --git a/util/getpir/Makefile b/util/getpir/Makefile
deleted file mode 100644
index 94270f54a6..0000000000
--- a/util/getpir/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-#
-#
-
-CC=gcc
-CFLAGS=-O2 -D_GNU_SOURCE -DGETPIR -Wall
-
-all: getpir
-
-getpir: getpir.o checksum.o code_gen.o
- $(CC) $(CFLAGS) -o getpir $^
-
-checkpir: checkpir.c checksum.o irq_tables.o
- $(CC) $(CFLAGS) -o checkpir $^
-
-irq_tables.c: getpir
- ./getpir
-
-clean:
- rm -f getpir checkpir *.o *~
-
-distclean: clean
- rm -f irq_tables.o irq_tables.c
-
diff --git a/util/getpir/README b/util/getpir/README
deleted file mode 100644
index 651458583b..0000000000
--- a/util/getpir/README
+++ /dev/null
@@ -1,30 +0,0 @@
-ABOUT:
-
-This utility will help to create irq_table.c file, that is very hard to create
-manually, specialy when you are testing new motherboards, changing your
-hardware often, placing new cards, etc..
-
-USAGE:
-
-Steps
-1. make distclean;
-2. make getpir
-3. ./getpir
-
- Will dump irq table to the file called irq_tables.c, ready to use with
- coreboot. Just move the file to corresponding place in the coreboot tree.
-
-
-4. CHECKING CUSTOM irq_tables.c:
-
- make checkpir
- ./checkpir
-
- checkpir.c Will verify the irq_tables.c, currently it only checks the
- checksum. In case of wrong checksum, a good value is proposed, so you can
- edit irq_tables.c manualy and replace checksum.
-
-
-Do not run make checkpir and ./checkpir directly because it needs to be linked
-to irq_table.o first.
-
diff --git a/util/getpir/checkpir.c b/util/getpir/checkpir.c
deleted file mode 100644
index c9703c6f3c..0000000000
--- a/util/getpir/checkpir.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* checkpir.c : This software is released under GPL
- * For coreboot use only
- * Aug 26 2001 , Nikolai Vladychevski, <niko@isl.net.mx>
- */
-
-#include <stdio.h>
-#include "pirq_routing.h"
-#include "checksum.h"
-
-struct irq_routing_table *rt;
-
-int main(void)
-{
- uint8_t sum, newsum;
-
- rt = (struct irq_routing_table *) &intel_irq_routing_table;
- sum = calc_checksum(rt);
-
- printf("Validating checksum, file: irq_tables.c that was in ./ at compile time...\n");
- printf("(no other tests are done)\n");
-
- if (!sum) {
- printf("Checksum for IRQ Routing table is ok. You can use irq_tables.c in coreboot now.\n");
- } else {
- newsum = rt->checksum - sum;
- printf("BAD CHECKSUM for IRQ Routing table !!!!\n");
- printf("If you want to make it valid, change the checksum to: %#x\n",
- newsum);
- }
- return 0;
-}
diff --git a/util/getpir/checksum.c b/util/getpir/checksum.c
deleted file mode 100644
index bcf342573f..0000000000
--- a/util/getpir/checksum.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "pirq_routing.h"
-#include "checksum.h"
-
-int calc_checksum(struct irq_routing_table *rt)
-{
- long i;
- uint8_t *addr, sum = 0;
-
- addr = (uint8_t *) rt;
- for (i = 0; i < rt->size; i++)
- sum += addr[i];
- return (sum);
-}
diff --git a/util/getpir/checksum.h b/util/getpir/checksum.h
deleted file mode 100644
index 2acc433b75..0000000000
--- a/util/getpir/checksum.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CHECKSUM_H__
-#define __CHECKSUM_H__
-
-int calc_checksum(struct irq_routing_table *rt);
-
-#endif /* __CHECKSUM_H__ */
diff --git a/util/getpir/code_gen.c b/util/getpir/code_gen.c
deleted file mode 100644
index d15715c220..0000000000
--- a/util/getpir/code_gen.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include "pirq_routing.h"
-
-static char *preamble[] = {
-
- "/*\n",
- " * This file is part of the coreboot project.\n",
- " *\n",
- " * Copyright (C) 200x TODO <TODO@TODO>\n",
- " *\n",
- " * This program is free software; you can redistribute it and/or modify\n",
- " * it under the terms of the GNU General Public License as published by\n",
- " * the Free Software Foundation; either version 2 of the License, or\n",
- " * (at your option) any later version.\n",
- " *\n",
- " * This program is distributed in the hope that it will be useful,\n",
- " * but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
- " * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
- " * GNU General Public License for more details.\n",
- " *\n",
- " * You should have received a copy of the GNU General Public License\n",
- " * along with this program; if not, write to the Free Software\n",
- " * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA\n",
- " */\n\n",
- "#ifdef GETPIR /* TODO: Drop this when copying to coreboot. */\n",
- "#include \"pirq_routing.h\" /* TODO: Drop this when copying to coreboot. */\n",
- "#else /* TODO: Drop this when copying to coreboot. */\n"
- "#include <arch/pirq_routing.h>\n",
- "#endif /* TODO: Drop this when copying to coreboot. */\n\n"
- "const struct irq_routing_table intel_irq_routing_table = {\n",
- "\tPIRQ_SIGNATURE, /* u32 signature */\n",
- "\tPIRQ_VERSION, /* u16 version */\n",
- 0
-};
-
-void code_gen(char *filename, struct irq_routing_table *rt)
-{
- char **code = preamble;
- struct irq_info *se_arr = (struct irq_info *) ((char *) rt + 32);
- int i, ts = (rt->size - 32) / 16;
- FILE *fpir;
-
- if ((fpir = fopen(filename, "w")) == NULL) {
- printf("Failed creating file!\n");
- exit(2);
- }
-
- while (*code)
- fprintf(fpir, "%s", *code++);
-
- fprintf(fpir, "\t32 + 16 * %d, /* Max. number of devices on the bus */\n",
- ts);
- fprintf(fpir, "\t0x%02x, /* Interrupt router bus */\n",
- rt->rtr_bus);
- fprintf(fpir, "\t(0x%02x << 3) | 0x%01x, /* Interrupt router dev */\n",
- rt->rtr_devfn >> 3, rt->rtr_devfn & 7);
- fprintf(fpir, "\t%#x, /* IRQs devoted exclusively to PCI usage */\n",
- rt->exclusive_irqs);
- fprintf(fpir, "\t%#x, /* Vendor */\n", rt->rtr_vendor);
- fprintf(fpir, "\t%#x, /* Device */\n", rt->rtr_device);
- fprintf(fpir, "\t%#x, /* Miniport */\n",
- rt->miniport_data);
- fprintf(fpir, "\t{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* u8 rfu[11] */\n");
- fprintf(fpir, "\t%#x, /* Checksum (has to be set to some value that\n * would give 0 after the sum of all bytes\n * for this structure (including checksum).\n */\n",
- rt->checksum);
- fprintf(fpir, "\t{\n");
- fprintf(fpir, "\t\t/* bus, dev | fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu */\n");
- for (i = 0; i < ts; i++) {
- fprintf(fpir, "\t\t{0x%02x, (0x%02x << 3) | 0x%01x, {{0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x%04x}}, 0x%x, 0x%x},\n",
- (se_arr+i)->bus, (se_arr+i)->devfn >> 3,
- (se_arr+i)->devfn & 7, (se_arr+i)->irq[0].link,
- (se_arr+i)->irq[0].bitmap, (se_arr+i)->irq[1].link,
- (se_arr+i)->irq[1].bitmap, (se_arr+i)->irq[2].link,
- (se_arr+i)->irq[2].bitmap, (se_arr+i)->irq[3].link,
- (se_arr+i)->irq[3].bitmap, (se_arr+i)->slot,
- (se_arr+i)->rfu);
- }
- fprintf(fpir, "\t}\n");
- fprintf(fpir, "};\n");
-
- fprintf(fpir, "\nunsigned long write_pirq_routing_table(unsigned long addr)\n");
- fprintf(fpir, "{\n");
- fprintf(fpir, "\treturn copy_pirq_routing_table(addr);\n");
- fprintf(fpir, "}\n");
-
- fclose(fpir);
-}
diff --git a/util/getpir/code_gen.h b/util/getpir/code_gen.h
deleted file mode 100644
index 93bdaec74f..0000000000
--- a/util/getpir/code_gen.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef __CODE_GEN_H__
-#define __CODE_GEN_H__
-
-void code_gen(char *filename, struct irq_routing_table *rt);
-
-#endif /* __CODE_GEN_H__ */
diff --git a/util/getpir/getpir.c b/util/getpir/getpir.c
deleted file mode 100644
index 9853d7ca94..0000000000
--- a/util/getpir/getpir.c
+++ /dev/null
@@ -1,189 +0,0 @@
-/* getpir.c : This software is released under GPL
- * For coreboot use only
- * Aug 26 2001 , Nikolai Vladychevski, <niko@isl.net.mx>
- * 2007.04.09 Jeremy Jackson <jerj@coplanar.net>
- * updated for amd64 and general 64 bit portability
- * 2010.04.24 Marc Bertens <mbertens@xs4all.nl>
- * Added functionality to read a image file for checking the checksum of the PIR
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "pirq_routing.h"
-#include "checksum.h"
-#include "code_gen.h"
-
-#if defined (__sun) && (defined(__i386) || defined(__amd64))
-# define MEM_DEV "/dev/xsvc"
-#else
-# define MEM_DEV "/dev/mem"
-#endif
-
-/**
- * The probe_table() is now called with the pointer to the memory,
- * this is to handle both the assessing memory and a file.
- *
- * This function now dumps the table found to the stdout, with
- * descriptions, it is special handy when building a PIRQ table
- * for a board to check the checksum.
- */
-static struct irq_routing_table *probe_table(char* ptr)
-{
- /**
- * Signature to search for $PIR<2-byte-version>
- *
- * this is to be sure that we find the correct table.
- */
- char signature[] = "$PIR\x00\x01";
- /** cast the pointer */
- struct irq_routing_table *rt = (struct irq_routing_table *)ptr;
- int size = 16;
- int checksum_result;
- do {
- /** find the PIRQ table */
- rt = (struct irq_routing_table *) memmem(ptr + size, 16, signature, 6);
- if (rt != NULL) {
- /** found the table */
- int i, ts = (rt->size - 32) / 16;
- struct irq_info *se_arr;
- se_arr = (struct irq_info *) ((char *) rt + 32);
- /** Dump the table information to the stdout */
- printf("Found PCI IRQ routing table signature at %p.\n", (void *) ((char *) rt - ptr + 0xf0000));
- printf("SIGNATURE = %s\n", (char*)&rt->signature);
- printf("VERSION = %04x\n", rt->version);
- printf("SIZE = %i\n", rt->size);
- printf("MAX_DEVICES_ON_BUS = 32 + 16 * %d\n", ts);
- printf("INT_ROUTER_BUS = 0x%02x\n", rt->rtr_bus);
- printf("INT_ROUTER DEVICE = (0x%02x << 3) | 0x%01x\n", rt->rtr_devfn >> 3, rt->rtr_devfn & 7);
- printf("IRQ_DEVOTED_TO_PCI = %#x\n", rt->exclusive_irqs);
- printf("VENDOR = %#x\n", rt->rtr_vendor);
- printf("DEVICE = %#x\n", rt->rtr_device);
- printf("MINIPORT = %#x\n", rt->miniport_data);
- printf("CHECKSUM = %#x\n", rt->checksum);
- printf("\tbus , dev | fn, {link, bitmap}, {link, bitmap}, {link, bitmap}, {link, bitmap}, slot, rfu\n");
- for (i = 0; i < ts; i++) {
- printf("\t0x%02x, (0x%02x << 3) | 0x%01x, {{0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x%04x}, {0x%02x, 0x%04x}}, 0x%x, 0x%x},\n",
- (se_arr+i)->bus, (se_arr+i)->devfn >> 3,
- (se_arr+i)->devfn & 7, (se_arr+i)->irq[0].link,
- (se_arr+i)->irq[0].bitmap, (se_arr+i)->irq[1].link,
- (se_arr+i)->irq[1].bitmap, (se_arr+i)->irq[2].link,
- (se_arr+i)->irq[2].bitmap, (se_arr+i)->irq[3].link,
- (se_arr+i)->irq[3].bitmap, (se_arr+i)->slot,
- (se_arr+i)->rfu);
- }
- /** A table should not be over 0x400 bytes */
- if (rt->size > 0x400) {
- return NULL;
- }
- printf("Validating...\n");
- /** Calculate the checksum value */
- checksum_result = calc_checksum(rt);
- /** Show the calculatedchecksum value */
- printf("CHECKSUM = %#x\n", 0x100-((checksum_result - rt->checksum) & 0xFF));
- /** and the result of the calculation */
- if (!checksum_result) {
- printf("checksum is ok.\n");
- break;
- } else {
- printf("checksum is wrong.\n");
- }
- }
- size += 16;
- } while (size < 0xFFFF);
- if (size >= 0xFFFF) {
- /** When the functions comes here there is no PIRQ table found. */
- printf("No PCI IRQ routing table signature found.\n");
- return NULL;
- }
-
- return rt;
-}
-
-int main(int argc, char* argv[])
-{
- char* ptr;
- int fd_mem = -1;
- struct irq_routing_table* rt = NULL;
- void* bios_image = NULL;
- if ( argc > 1 )
- {
- /** there a paramater passed to the program, assume that it is a menory file */
- printf("Opening memory image file '%s'\n", argv[1]);
- /** Open the file */
- fd_mem = open(argv[1], O_RDONLY);
- if (fd_mem > 0) {
- /** get tyhe size of the file */
- int file_size = lseek(fd_mem, 0, SEEK_END);
- printf("Memory image '%i'\n", file_size);
- /** get a memory block for it. */
- bios_image = malloc(file_size);
- if (bios_image) {
- /** Fill the created buffer */
- lseek(fd_mem, 0, SEEK_SET);
- read(fd_mem, bios_image, file_size);
- /** set the pointer for the probe function */
- ptr = (char*)bios_image;
- } else {
- /* no memory available ? */
- perror("Failed to open imagefile\n");
- return (-3);
- }
- } else {
- /** An error occourd, just exit with a message */
- perror("Failed to open imagefile");
- return (-2);
- }
- } else {
- /** No paramaters means that the program will access the system memory */
- printf("Accessing memory\n");
- if (getuid()) {
- /** i'm not root message !!!! */
- fprintf(stderr, "Run me as root, I need access to " MEM_DEV ".\n");
- }
- /** open the system memory */
- fd_mem = open(MEM_DEV, O_RDONLY);
- if (fd_mem < 0) {
- /** could not open the system memory, exit with a message */
- perror("Could not open " MEM_DEV ":");
- exit(1);
- }
- printf("Probing PIRQ table in memory.\n");
- ptr = mmap(0, 0x10000, PROT_READ, MAP_SHARED, fd_mem, (off_t)0xf0000);
- if (ptr == MAP_FAILED) {
- /** could not map the system memory, exit with a message */
- perror("Mapping system memory failed: ");
- close(fd_mem);
- return (1);
- }
- }
- if (ptr) {
- /** now do the actual probe function */
- rt = probe_table(ptr);
- if (rt != NULL && bios_image == NULL) {
- /** when probing system memory we write the 'irq_tables.c' code file */
- printf("Creating irq_tables.c ...\n");
- code_gen("irq_tables.c", rt);
- printf("Done, you can move the file to the coreboot tree now.\n");
- }
- } else {
- printf("invalid memory pointer\n");
- }
- if (bios_image) {
- /** when we are reading from a file the memory must be released */
- free(bios_image);
- } else {
- /** when reading from the system memory, it must be unmapped */
- munmap(ptr, 0x10000);
- }
- /** Close the file handle */
- close(fd_mem);
- /** return 0 as OK ) */
- return 0;
-}
diff --git a/util/getpir/pirq_routing.h b/util/getpir/pirq_routing.h
deleted file mode 100644
index 88adc210ba..0000000000
--- a/util/getpir/pirq_routing.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef ARCH_PIRQ_ROUTING_H
-#define ARCH_PIRQ_ROUTING_H
-
-#include <stdint.h>
-
-#define PIRQ_SIGNATURE (('$' << 0) + ('P' << 8) + ('I' << 16) + ('R' << 24))
-#define PIRQ_VERSION 0x0100
-
-struct irq_info {
- uint8_t bus, devfn; /* Bus, device and function */
- struct {
- uint8_t link; /* IRQ line ID, chipset dependent, 0=not routed */
- uint16_t bitmap; /* Available IRQs */
- } __attribute__((packed)) irq[4];
- uint8_t slot; /* Slot number, 0=onboard */
- uint8_t rfu;
-} __attribute__((packed));
-
-#if defined(CONFIG_IRQ_SLOT_COUNT)
-#define IRQ_SLOTS_COUNT CONFIG_IRQ_SLOT_COUNT
-#elif (__GNUC__ < 3)
-#define IRQ_SLOTS_COUNT 1
-#else
-#define IRQ_SLOTS_COUNT
-#endif
-
-struct irq_routing_table {
- uint32_t signature; /* PIRQ_SIGNATURE should be here */
- uint16_t version; /* PIRQ_VERSION */
- uint16_t size; /* Table size in bytes */
- uint8_t rtr_bus, rtr_devfn; /* Where the interrupt router lies */
- uint16_t exclusive_irqs; /* IRQs devoted exclusively to PCI usage */
- uint16_t rtr_vendor, rtr_device; /* Vendor and device ID of interrupt router */
- uint32_t miniport_data; /* Miniport data */
- uint8_t rfu[11];
- uint8_t checksum; /* Modulo 256 checksum must give zero */
- struct irq_info slots[IRQ_SLOTS_COUNT];
-} __attribute__((packed));
-
-extern const struct irq_routing_table intel_irq_routing_table;
-
-#ifdef GETPIR
-#define copy_pirq_routing_table(start) (start)
-unsigned long write_pirq_routing_table(unsigned long start);
-#else
-#if CONFIG_HAVE_PIRQ_TABLE==1
-unsigned long copy_pirq_routing_table(unsigned long start);
-unsigned long write_pirq_routing_table(unsigned long start);
-#else
-#define copy_pirq_routing_table(start) (start)
-#define write_pirq_routing_table(start) (start)
-#endif
-#endif
-
-#endif /* ARCH_PIRQ_ROUTING_H */