aboutsummaryrefslogtreecommitdiff
path: root/util/i915tool/pci.c
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2012-05-04 15:37:18 -0700
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-05-08 00:40:36 +0200
commit564e90f57185274130aba7b157a7dca1941dcfef (patch)
treef71985b7f878f83d7e5773675ca27a4a2da94cdf /util/i915tool/pci.c
parent44a89b34f85492c48a19db1b9b2c2c44ab29c9ae (diff)
Add a tool to work on i915 hardware in user mode
This is the beginning of a tool that transforms the i9x5 code to user mode code. Consider this a very early stage although it does produce two programs. Requires spatch 1.0 or greater. To try it out, assuming you have an up-to-date spatch, sh transform make make broken Please don't fall to the temptation to auto-magicize this process. It's primitive for a reason. That said, suggestions welcome of course. Change-Id: I0188e36637b198b06c17f6d3c714d990e88bd57d Signed-off-by: Ronald G. Minnich <rminnich@chromium.org> Reviewed-on: http://review.coreboot.org/1003 Tested-by: build bot (Jenkins) Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util/i915tool/pci.c')
-rw-r--r--util/i915tool/pci.c97
1 files changed, 97 insertions, 0 deletions
diff --git a/util/i915tool/pci.c b/util/i915tool/pci.c
new file mode 100644
index 0000000000..ca942dc314
--- /dev/null
+++ b/util/i915tool/pci.c
@@ -0,0 +1,97 @@
+/*
+ * This file is part of i915tool
+ *
+ * Copyright (C) 2012 The ChromiumOS Authors. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "video.h"
+
+int find_idlist(struct drm_device *dev, u16 vendor, u16 device)
+{
+ extern const struct pci_device_id pciidlist[];
+ int succ = 0;
+ int i;
+ for(i = 0; pciidlist[i].vendor && !succ; i++){
+ if (vendor == pciidlist[i].vendor && device ==
+ pciidlist[i].device){
+ dev->dev_private->info =
+ (void *)(pciidlist[i].driver_data);
+ succ = 1;
+ }
+ }
+ return succ;
+}
+
+/* there's only going to be one device ... */
+int pci_dev_find(struct drm_device *dev)
+{
+ struct pci_access *pacc = NULL;
+ struct pci_dev *temp;
+ int succ = 0;
+ pacc = pci_alloc();
+ if (! pacc)
+ return 0;
+ pci_init(pacc);
+ pci_scan_bus(pacc);
+
+ for (temp = pacc->devices; temp && ! dev->pdev; temp = temp->next){
+ if ((temp->device_class & 0xff00) == PCI_CLASS_DISPLAY_VGA ) {
+ pci_fill_info(temp, PCI_FILL_IDENT |
+ PCI_FILL_BASES | PCI_FILL_CLASS);
+ dev->pdev = temp;
+ }
+ }
+
+ if (dev->pdev)
+ succ = find_idlist(dev, dev->pdev->vendor_id,
+ dev->pdev->device_id);
+ return succ;
+}
+
+/* Support library for kernel style pci functions. We could do a semantic
+ * patch for it but this is easier to debug as we can fill it with prints
+ * if we want. And no cpp abuse here. Keep it simple.
+ */
+
+void pci_read_config_byte(struct pci_dev *dev, unsigned long offset, u8 *val)
+{
+ *val = pci_read_byte(dev, offset);
+}
+
+void pci_write_config_byte(struct pci_dev *dev, unsigned long offset, u8 val)
+{
+ pci_write_byte(dev, offset, val);
+}
+
+void pci_read_config_word(struct pci_dev *dev, unsigned long offset, u16 *val)
+{
+ *val = pci_read_word(dev, offset);
+}
+
+void pci_write_config_word(struct pci_dev *dev, unsigned long offset, u16 val)
+{
+ pci_write_word(dev, offset, val);
+}
+
+void pci_read_config_dword(struct pci_dev *dev, unsigned long offset, u32 *val)
+{
+ *val = pci_read_long(dev, offset);
+}
+
+void pci_write_config_dword(struct pci_dev *dev, unsigned long offset, u32 val)
+{
+ pci_write_long(dev, offset, val);
+}