[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH] pci: Klasse und Revision richtig einlesen



! pci: Revision ist nur ein Byte und kein DWord
* pci: Roher Classcode in 3 einzelne Felder in der PCI-Struktur
       aufgespalten (class, subclass, interface).
* pci: pci:/info zeigt jetzt subclass und interface separat an
---
 src/modules/include/pci.h       |   11 ++++++++---
 src/modules/pci/include/pcihw.h |   39 ++++++++++++++++++++++++++++++++++++++-
 src/modules/pci/pcihw.c         |   10 +++++++---
 src/modules/pci/pciscan.c       |    7 +++++--
 4 files changed, 58 insertions(+), 9 deletions(-)

diff --git a/src/modules/include/pci.h b/src/modules/include/pci.h
index e0b15ca..ca2f1ec 100644
--- a/src/modules/include/pci.h
+++ b/src/modules/include/pci.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
+ * Copyright (c) 2007-2009 The tyndur Project. All rights reserved.
  *
  * This code is derived from software contributed to the tyndur Project
  * by Kevin Wolf.
@@ -51,8 +51,13 @@ struct pci_device {
     word    device_id;
     byte    rev_id;
     byte    irq;
-    
-    dword   class_id;
+
+    byte    interface_id;
+    byte    subclass_id;
+    byte    class_id;
+
+    /// XXX: Fuer Abwaertskompatibilitaet eingefuehrt
+    byte    :8 ;
 
     list_t* resources;
 } __attribute__ ((packed));
diff --git a/src/modules/pci/include/pcihw.h b/src/modules/pci/include/pcihw.h
index b2579ad..f423660 100644
--- a/src/modules/pci/include/pcihw.h
+++ b/src/modules/pci/include/pcihw.h
@@ -1,3 +1,38 @@
+/*
+ * Copyright (c) 2007-2009 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Kevin Wolf.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the tyndur Project
+ *     and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
 #ifndef _PCI_HW_
 #define _PCI_HW_
 
@@ -9,7 +44,9 @@
 #define PCI_COMMAND     0x04
 #define PCI_STATUS      0x06
 #define PCI_REVISION    0x08
-#define PCI_CLASS       0x09
+#define PCI_CLASS       0x0B
+#define PCI_SUBCLASS    0x0A
+#define PCI_INTERFACE   0x09
 #define PCI_HEADERTYPE  0x0E
 #define PCI_BAR0        0x10
 #define PCI_INTERRUPT   0x3C
diff --git a/src/modules/pci/pcihw.c b/src/modules/pci/pcihw.c
index 4013617..536ad74 100644
--- a/src/modules/pci/pcihw.c
+++ b/src/modules/pci/pcihw.c
@@ -1,5 +1,5 @@
 /*  
- * Copyright (c) 2007 The tyndur Project. All rights reserved.
+ * Copyright (c) 2007-2009 The tyndur Project. All rights reserved.
  *
  * This code is derived from software contributed to the tyndur Project
  * by Kevin Wolf.
@@ -213,8 +213,12 @@ struct pci_device pci_get_device(dword bus, dword device, dword func)
 
         .vendor_id  = pci_config_read_word(bus, device, func, PCI_VENDOR_ID),
         .device_id  = pci_config_read_word(bus, device, func, PCI_DEVICE_ID),
-        .class_id   = pci_config_read_dword(bus, device, func, PCI_CLASS),
-        .rev_id     = pci_config_read_dword(bus, device, func, PCI_REVISION),
+
+        .class_id   = pci_config_read_byte(bus, device, func, PCI_CLASS),
+        .subclass_id  = pci_config_read_byte(bus, device, func, PCI_SUBCLASS),
+        .interface_id = pci_config_read_byte(bus, device, func, PCI_INTERFACE),
+
+        .rev_id     = pci_config_read_byte(bus, device, func, PCI_REVISION),
         .irq        = pci_config_read_byte(bus, device, func, PCI_INTERRUPT),
 
         .resources  = NULL
diff --git a/src/modules/pci/pciscan.c b/src/modules/pci/pciscan.c
index 2ea4c7e..c82aa28 100644
--- a/src/modules/pci/pciscan.c
+++ b/src/modules/pci/pciscan.c
@@ -225,14 +225,17 @@ char* pciinfo()
         old_buffer = buffer;
         asprintf(
             &buffer, 
-            "%s%x:%x:%x -- Hersteller %x, Geraete-ID %x [Klasse %x]\n",
+            "%s%x:%x:%x -- Hersteller %x, Geraete-ID %x [Klasse %x Sub %x "
+                "Int %x]\n",
             old_buffer ? old_buffer : "",
             dev->bus,
             dev->device,
             dev->function,
             dev->vendor_id,
             dev->device_id,
-            dev->class_id
+            dev->class_id,
+            dev->subclass_id,
+            dev->interface_id
         );
         free(old_buffer);
 
-- 
1.6.0.6