[haiku-commits] r35947 - haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial

  • From: revol@xxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 25 Mar 2010 01:14:41 +0100 (CET)

Author: mmu_man
Date: 2010-03-25 01:14:41 +0100 (Thu, 25 Mar 2010)
New Revision: 35947
Changeset: http://dev.haiku-os.org/changeset/35947/haiku

Modified:
   haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
Log:
Finish the alternative device scanning code (using the PCI bus manager instead 
of config manager) and use it, it actually works better in R5 on SMP boxen 
(config manager seems to miss reporting IRQ lines).


Modified: haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp   
2010-03-24 21:02:38 UTC (rev 35946)
+++ haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp   
2010-03-25 00:14:41 UTC (rev 35947)
@@ -405,9 +405,10 @@
                }
 #endif
 
-               // instanciate devices on IO ports
                resource_descriptor iodesc;
                SerialDevice *master = NULL;
+
+               // instanciate devices on IO ports
                for (int i = 0;
                        
gConfigManagerModule->get_nth_resource_descriptor_of_type(
                        &config.c, i, B_IO_PORT_RESOURCE, &iodesc, 
sizeof(iodesc)) == B_OK;
@@ -461,6 +462,8 @@
 {
        pci_info info;
        int ix;
+       TRACE_ALWAYS("scanning PCI bus (alt)...\n");
+
        // probe PCI devices
        for (ix = 0; (*gPCIModule->get_nth_pci_info)(ix, &info) == B_OK; ix++) {
                // sanity check
@@ -489,6 +492,7 @@
                                && info.device_id != 
sSupportedDevices[i].match.device_id)
                                continue;
                        supported = &sSupportedDevices[i];
+                       break;
                }
                if (supported == NULL)
                        continue;
@@ -497,23 +501,62 @@
                        ix, info.class_base, info.class_sub, info.class_api,
                        info.vendor_id, info.device_id, supported->name);
 
+               // XXX: interrupt_line doesn't seem to 
+               TRACE_ALWAYS("irq line %d, pin %d\n",
+                       info.u.h0.interrupt_line, info.u.h0.interrupt_pin);
+               int irq = info.u.h0.interrupt_line;
+
+               SerialDevice *master = NULL;
+
                // find I/O ports
                for (int r = 0; r < 6; r++) {
+                       /**/
                        TRACE_ALWAYS("range at 0x%08lx len 0x%lx flags 
0x%02x\n",
                                info.u.h0.base_registers[r], 
info.u.h0.base_register_sizes[r],
                                info.u.h0.base_register_flags[r]);
-                       
+                       /**/
+
                        // not I/O
-                       if (info.u.h0.base_register_flags[r] & 
PCI_address_space == 0)
+                       if ((info.u.h0.base_register_flags[r] & 
PCI_address_space) == 0)
                                continue;
-                       //
+
+                       uint32 regbase = info.u.h0.base_registers[r];
+                       uint32 reglen = info.u.h0.base_register_sizes[r];
+
                        TRACE_ALWAYS("regs at 0x%08lx len 0x%lx\n",
-                               info.u.h0.base_registers[r], 
info.u.h0.base_register_sizes[r]);
+                               regbase, reglen);
                        //&PCI_address_io_mask
+
+                       if (reglen < supported->constraints.minsize)
+                               continue;
+                       if (reglen > supported->constraints.maxsize)
+                               continue;
+
+                       SerialDevice *device;
+                       uint32 ioport = regbase;
+next_split_alt:
+                       // no more to split
+                       if ((ioport - regbase) >= reglen)
+                               continue;
+               
+                       TRACE_ALWAYS("inserting device at io 0x%04lx as %s\n", 
ioport, 
+                               supported->name);
+
+                       
+/**/
+                       device = new SerialDevice(supported, ioport, irq, 
master);
+                       if (pc_serial_insert_device(device) < B_OK) {
+                               TRACE_ALWAYS("can't insert device\n");
+                               continue;
+                       }
+/**/                   if (master == NULL)
+                               master = device;
+                       
+                       ioport += supported->constraints.split;
+                       goto next_split_alt;
+                       // try next part of the I/O range now
+
                }
-               // XXX: interrupt_line doesn't seem to 
-               TRACE_ALWAYS("irq line %d, pin %d\n",
-                       info.u.h0.interrupt_line, info.u.h0.interrupt_pin);
        }
 
        return B_OK;
@@ -623,9 +666,9 @@
 
 
        scan_bus(B_ISA_BUS);
-       scan_bus(B_PCI_BUS);
+       //scan_bus(B_PCI_BUS);
+       scan_pci_alt();
 
-
        // XXX: ISA cards
        // XXX: pcmcia
        


Other related posts:

  • » [haiku-commits] r35947 - haiku/trunk/src/add-ons/kernel/drivers/ports/pc_serial - revol