summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortsi <tsi>2008-03-26 19:04:50 +0000
committertsi <tsi>2008-03-26 19:04:50 +0000
commitdeaf70e09c40e009d73afe78631e0c5b6ca564eb (patch)
tree63027a9e5149035e5fd27e3625863b446e0d4d77
parentddac60d1836ab7ba9d7dc7b2d5d853da8669a5e2 (diff)
32. Zero out all SPARC SunOS framebuffers on server exit (Marc La France).
-rw-r--r--programs/Xserver/hw/xfree86/CHANGELOG3
-rw-r--r--programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c90
2 files changed, 60 insertions, 33 deletions
diff --git a/programs/Xserver/hw/xfree86/CHANGELOG b/programs/Xserver/hw/xfree86/CHANGELOG
index df767c04c..c2fd604ef 100644
--- a/programs/Xserver/hw/xfree86/CHANGELOG
+++ b/programs/Xserver/hw/xfree86/CHANGELOG
@@ -1,4 +1,5 @@
XFree86 4.7.99.15 (xx April 2008)
+ 32. Zero out all SPARC SunOS framebuffers on server exit (Marc La France).
32. Temporarily ignore 64-bit PCI memory address spaces on SPARC
(Marc La France).
31. For fault isolation purposes, on SPARC, bracket all PCI configuration
@@ -20688,4 +20689,4 @@ XFree86 3.0a (28 April 1994)
XFree86 3.0 (26 April 1994)
-$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.3940 2008/03/26 18:39:08 tsi Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.3941 2008/03/26 18:57:48 tsi Exp $
diff --git a/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c b/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
index 14a1e746a..ea9dc0f7e 100644
--- a/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
+++ b/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.9 2006/01/12 02:41:51 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sunos/sun_init.c,v 1.10tsi Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -94,7 +94,8 @@ xf86OpenConsole(void)
strerror(errno));
if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
- FatalError("xf86OpenConsole: Cannot determine current VT\n");
+ FatalError("xf86OpenConsole: Cannot determine current VT"
+ " (%s)\n", strerror(errno));
xf86StartVT = vtinfo.v_active;
@@ -146,13 +147,16 @@ xf86OpenConsole(void)
* Now get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed (%s)\n",
+ strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed (%s)\n",
+ strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ FatalError("xf86OpenConsole: VT_GETMODE failed (%s)\n",
+ strerror(errno));
signal(SIGUSR1, xf86VTRequest);
@@ -161,10 +165,14 @@ xf86OpenConsole(void)
VT.acqsig = SIGUSR1;
if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed (%s)\n",
+ strerror(errno));
+#ifdef KDSETMODE
if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
- FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed (%s)\n",
+ strerror(errno));
+#endif
#else
#ifdef KDSETMODE
/* This may fail. */
@@ -179,10 +187,12 @@ xf86OpenConsole(void)
* Now re-get the VT
*/
if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed (%s)\n",
+ strerror(errno));
if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed (%s)\n",
+ strerror(errno));
/*
* If the server doesn't have the VT when the reset occurs,
@@ -211,33 +221,49 @@ xf86CloseConsole(void)
if (!xf86DoProbe && !xf86DoConfigure) {
/*
- * Wipe out framebuffer just like the non-SI Xsun server does. This
- * could be improved by saving framebuffer contents in
- * xf86OpenConsole() above and restoring them here. Also, it's unclear
- * at this point whether this should be done for all framebuffers in
- * the system, rather than only the console.
+ * Wipe out framebuffers, given we have nothing to restore them with.
*/
- struct fbgattr fbattr;
-
- if ((ioctl(xf86Info.consoleFd, FBIOGATTR, &fbattr) < 0) &&
- (ioctl(xf86Info.consoleFd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to retrieve framebuffer"
- " attributes (%s)\n", strerror(errno));
- } else {
- pointer fbdata;
-
- fbdata = mmap(NULL, fbattr.fbtype.fb_size,
- PROT_READ | PROT_WRITE, MAP_SHARED,
- xf86Info.consoleFd, 0);
- if (fbdata == MAP_FAILED) {
+ for (tmp = 0; ; tmp++) {
+ struct fbgattr fbattr;
+ char *fbdev;
+ int fd;
+
+ fbdev = NULL;
+ xasprintf(&fbdev, "/dev/fb%d", tmp);
+ if (!fbdev) {
xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to mmap framebuffer"
- " (%s)\n", strerror(errno));
+ "Cannot allocate space for framebuffer name\n");
+ break;
+ }
+
+ fd = open(fbdev, O_RDWR | O_NDELAY, 0);
+ if (fd < 0) {
+ xfree(fbdev);
+ break;
+ }
+
+ if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
+ (ioctl(fd, FBIOGTYPE, &fbattr.fbtype) < 0)) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole: Unable to retrieve %s attributes"
+ " (%s)\n", fbdev, strerror(errno));
} else {
- (void)memset(fbdata, 0, fbattr.fbtype.fb_size);
- (void)munmap(fbdata, fbattr.fbtype.fb_size);
+ pointer fbdata;
+
+ fbdata = mmap(NULL, fbattr.fbtype.fb_size,
+ PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+ if (fbdata == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole: Unable to mmap %s (%s)\n",
+ fbdev, strerror(errno));
+ } else {
+ (void)memset(fbdata, 0, fbattr.fbtype.fb_size);
+ (void)munmap(fbdata, fbattr.fbtype.fb_size);
+ }
}
+
+ close(fd);
+ xfree(fbdev);
}
}