[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).
---
 src/modules/include/pci.h       |    8 +++++---
 src/modules/pci/include/pcihw.h |   39 ++++++++++++++++++++++++++++++++++++++-
 src/modules/pci/pcihw.c         |   10 +++++++---
 3 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/src/modules/include/pci.h b/src/modules/include/pci.h
index e0b15ca..9bb4a9c 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,10 @@ struct pci_device {
     word    device_id;
     byte    rev_id;
     byte    irq;
-    
-    dword   class_id;
+
+    byte    class_id;
+    byte    subclass_id;
+    byte    interface_id;
 
     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
-- 
1.6.0.6