b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson--- a/hw/xfree86/os-support/solaris/sun_init.c Fri Jun 5 12:41:14 2015
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+++ b/hw/xfree86/os-support/solaris/sun_init.c Fri Jun 5 12:48:06 2015
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson@@ -2,6 +2,7 @@
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson * Copyright 1993 by David Wexelblat <dwex@goblin.org>
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson * Copyright 1999 by David Holland <davidh@iquest.net>
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ * Copyright (c) 2013 Oracle and/or its affiliates. All Rights Reserved.
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson *
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson * Permission to use, copy, modify, distribute, and sell this software and its
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson * documentation for any purpose is hereby granted without fee, provided that
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson@@ -64,6 +65,11 @@
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson _X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#if (defined(__sparc__) || defined(__sparc))
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+static void GetFbDevFromProbe(void);
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+static Bool xf86SolarisFbDevIsSet = FALSE;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#endif
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson static void
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson switch_to(int vt, const char *from)
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson@@ -97,6 +103,16 @@
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson if (geteuid() != 0)
05b42f00b813c3dc70cbb80d62089f9cc0f6f549ludovicp FatalError("xf86OpenConsole: Server must be suid root\n");
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#if (defined(__sparc__) || defined(__sparc))
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ struct stat buf;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (!xf86SolarisFbDevIsSet && (stat("/dev/fb", &buf) != 0) &&
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ (xf86NumDrivers == 1))
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ GetFbDevFromProbe();
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#endif
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson #ifdef HAS_USL_VTS
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson /*
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson@@ -376,6 +392,9 @@
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson if ((i + 1) < argc) {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson if (!strcmp(argv[i], "-dev")) {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson strlcpy(xf86SolarisFbDev, argv[i + 1], sizeof(xf86SolarisFbDev));
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#if (defined(__sparc__) || defined(__sparc))
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ xf86SolarisFbDevIsSet = TRUE;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+#endif
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson return 2;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson@@ -383,6 +402,87 @@
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson return 0;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+#if (defined(__sparc__) || defined(__sparc))
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+static void
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+GetFbDevFromProbe(void) {
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+ unsigned numDevs;
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+ GDevPtr *devList;
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+ numDevs = xf86MatchDevice(xf86DriverList[0]->driverName, &devList);
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+
36bb690a409d9e6e3defd678f47acbbf02bd9167kenneth_suter+ if (numDevs != 1)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ return;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ else {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ struct pci_device_iterator *iter;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ unsigned device_id;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ const struct pci_id_match *const devices =
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ xf86DriverList[0]->supported_devices;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ int i;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ Bool found = FALSE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ struct pci_device *pPci;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ struct sol_device_private {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ struct pci_device base;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ const char * device_string;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ };
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+#define DEV_PATH(dev) (((struct sol_device_private *) dev)->device_string)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+#define END_OF_MATCHES(m) \
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ (((m).vendor_id == 0) && ((m).device_id == 0) && ((m).subvendor_id == 0))
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ /* Find the pciVideoRec associated with this device section.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ iter = pci_id_match_iterator_create(NULL);
d25372dc8e65a9ed019a88fdf659ca61313f1b31jcduff+ while ((pPci = pci_device_next(iter)) != NULL) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (devList[0]->busID && *devList[0]->busID) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (xf86ComparePciBusString(devList[0]->busID,
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ ((pPci->domain << 8)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ | pPci->bus),
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ pPci->dev, pPci->func)) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ break;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ else if (xf86IsPrimaryPci(pPci)) {
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ break;
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ pci_iterator_destroy(iter);
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (pPci == NULL)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ return;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ /* If driver provides supported_devices, then check if this
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ device is on the list. Otherwise skip check.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (!devices)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ found = TRUE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ else {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ device_id = (devList[0]->chipID > 0)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ ? devList[0]->chipID : pPci->device_id;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ /* Once the pciVideoRec is found, determine if the device is supported
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ * by the driver.
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ */
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ for (i = 0; !END_OF_MATCHES(devices[i]); i++) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (PCI_ID_COMPARE(devices[i].vendor_id, pPci->vendor_id)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ && PCI_ID_COMPARE(devices[i].device_id, device_id)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ && ((devices[i].device_class_mask & pPci->device_class)
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ == devices[i].device_class)) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ found = TRUE;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ break;
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ }
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ if (found) {
52867003bf09a12f814bf427e6f7e2fa34016d03neil_a_wilson+ strcpy(xf86SolarisFbDev, "/devices");
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ strcat(xf86SolarisFbDev, DEV_PATH(pPci));
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ xf86Msg(X_INFO, "Got xf86SolarisFbDev From Probe: %s\n", xf86SolarisFbDev);
b2dbceafd99150e6a864b244a22356a8162a0b19neil_a_wilson+ }
+
+ }
+}
+#endif
+
void
xf86UseMsg(void)
{