Please bear with me - another rename checkin. This qualifies as trivial, no
[coreboot.git] / src / devices / device.c
index 303a669d9ffdd8c377172e946ce742b4929d1f94..635f876bbebb940ee2f011241240535078e5cf3d 100644 (file)
@@ -1,7 +1,21 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * It was originally based on the Linux kernel (arch/i386/kernel/pci-pc.c).
+ *
+ * Modifications are:
+ * Copyright (C) 2003 Eric Biederman <ebiederm@xmission.com>
+ * Copyright (C) 2003-2004 Linux Networx
+ * (Written by Eric Biederman <ebiederman@lnxi.com> for Linux Networx)
+ * Copyright (C) 2003 Ronald G. Minnich <rminnich@gmail.com>
+ * Copyright (C) 2004-2005 Li-Ta Lo <ollie@lanl.gov>
+ * Copyright (C) 2005-2006 Tyan
+ * (Written by Yinghai Lu <yhlu@tyan.com> for Tyan)
+ * Copyright (C) 2005-2006 Stefan Reinauer <stepan@openbios.org>
+ */
+
 /*
  *      (c) 1999--2000 Martin Mares <mj@suse.cz>
- *      (c) 2003 Eric Biederman <ebiederm@xmission.com>
- *     (c) 2003 Linux Networx
  */
 /* lots of mods by ron minnich (rminnich@lanl.gov), with 
  * the final architecture guidance from Tom Merritt (tjm@codegen.com)
@@ -369,7 +383,6 @@ void compute_allocate_resource(
 }
 
 #if CONFIG_CONSOLE_VGA == 1
-
 device_t vga_pri = 0;
 static void allocate_vga_resource(void)
 {
@@ -377,31 +390,52 @@ static void allocate_vga_resource(void)
 #warning "This function knows to much about PCI stuff, it should be just a ietrator/visitor."
 
        /* FIXME handle the VGA pallette snooping */
-       struct device *dev, *vga, *vga_onboard;
+       struct device *dev, *vga, *vga_onboard, *vga_first, *vga_last;
        struct bus *bus;
        bus = 0;
        vga = 0;
        vga_onboard = 0;
+       vga_first = 0;
+       vga_last = 0;
        for(dev = all_devices; dev; dev = dev->next) {
                if (!dev->enabled) continue;
                if (((dev->class >> 16) == PCI_BASE_CLASS_DISPLAY) &&
                        ((dev->class >> 8) != PCI_CLASS_DISPLAY_OTHER)) 
                {
-                       if (!vga) {
-                               if (dev->on_mainboard) {
-                                       vga_onboard = dev;
-                               } else {
-                                       vga = dev;
-                               }
-                       }
+                        if (!vga_first) {
+                                if (dev->on_mainboard) {
+                                        vga_onboard = dev;
+                                } else {
+                                        vga_first = dev;
+                                }
+                        } else {
+                                if (dev->on_mainboard) {
+                                        vga_onboard = dev;
+                                } else {
+                                        vga_last = dev;
+                                }
+                        }
+
                        /* It isn't safe to enable other VGA cards */
                        dev->command &= ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO);
                }
        }
        
-       if (!vga) {
-               vga = vga_onboard;
-       }
+        vga = vga_last;
+
+        if(!vga) {
+                vga = vga_first;
+        }
+
+#if CONFIG_CONSOLE_VGA_ONBOARD_AT_FIRST == 1
+        if (vga_onboard) // will use on board vga as pri
+#else
+        if (!vga) // will use last add on adapter as pri
+#endif
+        {
+                vga = vga_onboard;
+        }
+
        
        if (vga) {
                /* vga is first add on card or the only onboard vga */
@@ -419,6 +453,7 @@ static void allocate_vga_resource(void)
                bus = (bus == bus->dev->bus)? 0 : bus->dev->bus;
        } 
 }
+
 #endif
 
 
@@ -499,7 +534,6 @@ void enable_resources(struct device *dev)
  */
 int reset_bus(struct bus *bus)
 {
-       device_t dev;
        if (bus && bus->dev && bus->dev->ops && bus->dev->ops->reset_bus)
        {
                bus->dev->ops->reset_bus(bus);
@@ -664,7 +698,7 @@ void dev_configure(void)
  */
 void dev_enable(void)
 {
-       printk_info("Enabling resourcess...\n");
+       printk_info("Enabling resources...\n");
 
        /* now enable everything. */
        enable_resources(&dev_root);