summaryrefslogtreecommitdiff
path: root/xserver/hw/xfree86/os-support/solaris
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2012-06-10 13:21:33 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2012-06-10 13:21:33 +0000
commit171e929a08098b6c844887adc43879c7579dc15f (patch)
tree6b4d2e3bc20dbd4dc9a1f031416e66614c53dd21 /xserver/hw/xfree86/os-support/solaris
parent68781b09de2c95b87ea898c4ecf3018dfb4460d2 (diff)
Update to xserver 1.12.2. tested by naddy@, krw@, mpi@.
Diffstat (limited to 'xserver/hw/xfree86/os-support/solaris')
-rw-r--r--xserver/hw/xfree86/os-support/solaris/Makefile.in14
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_VTsw.c115
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_agp.c389
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_apm.c123
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_bell.c43
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_init.c512
-rw-r--r--xserver/hw/xfree86/os-support/solaris/sun_vid.c177
7 files changed, 678 insertions, 695 deletions
diff --git a/xserver/hw/xfree86/os-support/solaris/Makefile.in b/xserver/hw/xfree86/os-support/solaris/Makefile.in
index 21f8794a0..a9cbedefc 100644
--- a/xserver/hw/xfree86/os-support/solaris/Makefile.in
+++ b/xserver/hw/xfree86/os-support/solaris/Makefile.in
@@ -113,7 +113,6 @@ AGP_FALSE = @AGP_FALSE@
AGP_TRUE = @AGP_TRUE@
AIGLX_DRI_LOADER_FALSE = @AIGLX_DRI_LOADER_FALSE@
AIGLX_DRI_LOADER_TRUE = @AIGLX_DRI_LOADER_TRUE@
-ALLOCA = @ALLOCA@
ALPHA_VIDEO_FALSE = @ALPHA_VIDEO_FALSE@
ALPHA_VIDEO_TRUE = @ALPHA_VIDEO_TRUE@
AMDEP_FALSE = @AMDEP_FALSE@
@@ -132,6 +131,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
+BASE_CFLAGS = @BASE_CFLAGS@
BASE_FONT_PATH = @BASE_FONT_PATH@
BSD_APM_FALSE = @BSD_APM_FALSE@
BSD_APM_TRUE = @BSD_APM_TRUE@
@@ -339,8 +339,6 @@ LIB_MAN_DIR = @LIB_MAN_DIR@
LIB_MAN_SUFFIX = @LIB_MAN_SUFFIX@
LINUX_ALPHA_FALSE = @LINUX_ALPHA_FALSE@
LINUX_ALPHA_TRUE = @LINUX_ALPHA_TRUE@
-LINUX_IA64_FALSE = @LINUX_IA64_FALSE@
-LINUX_IA64_TRUE = @LINUX_IA64_TRUE@
LIPO = @LIPO@
LNXACPI_FALSE = @LNXACPI_FALSE@
LNXACPI_TRUE = @LNXACPI_TRUE@
@@ -359,10 +357,6 @@ MISC_MAN_DIR = @MISC_MAN_DIR@
MISC_MAN_SUFFIX = @MISC_MAN_SUFFIX@
MITSHM_FALSE = @MITSHM_FALSE@
MITSHM_TRUE = @MITSHM_TRUE@
-NEED_STRLCAT_FALSE = @NEED_STRLCAT_FALSE@
-NEED_STRLCAT_TRUE = @NEED_STRLCAT_TRUE@
-NEED_VSNPRINTF_FALSE = @NEED_VSNPRINTF_FALSE@
-NEED_VSNPRINTF_TRUE = @NEED_VSNPRINTF_TRUE@
NM = @NM@
NMEDIT = @NMEDIT@
OBJC = @OBJC@
@@ -506,18 +500,18 @@ XNEST_SYS_LIBS = @XNEST_SYS_LIBS@
XNEST_TRUE = @XNEST_TRUE@
XORG_BUS_BSDPCI_FALSE = @XORG_BUS_BSDPCI_FALSE@
XORG_BUS_BSDPCI_TRUE = @XORG_BUS_BSDPCI_TRUE@
-XORG_BUS_LINUXPCI_FALSE = @XORG_BUS_LINUXPCI_FALSE@
-XORG_BUS_LINUXPCI_TRUE = @XORG_BUS_LINUXPCI_TRUE@
+XORG_BUS_PCI_FALSE = @XORG_BUS_PCI_FALSE@
+XORG_BUS_PCI_TRUE = @XORG_BUS_PCI_TRUE@
XORG_BUS_SPARC_FALSE = @XORG_BUS_SPARC_FALSE@
XORG_BUS_SPARC_TRUE = @XORG_BUS_SPARC_TRUE@
XORG_CFLAGS = @XORG_CFLAGS@
XORG_FALSE = @XORG_FALSE@
XORG_INCS = @XORG_INCS@
XORG_LIBS = @XORG_LIBS@
+XORG_MALLOC_DEBUG_ENV = @XORG_MALLOC_DEBUG_ENV@
XORG_MAN_PAGE = @XORG_MAN_PAGE@
XORG_MODULES_CFLAGS = @XORG_MODULES_CFLAGS@
XORG_MODULES_LIBS = @XORG_MODULES_LIBS@
-XORG_OS = @XORG_OS@
XORG_OS_SUBDIR = @XORG_OS_SUBDIR@
XORG_SGML_PATH = @XORG_SGML_PATH@
XORG_SYS_LIBS = @XORG_SYS_LIBS@
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_VTsw.c b/xserver/hw/xfree86/os-support/solaris/sun_VTsw.c
index e6f31879b..573358b43 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -43,24 +43,23 @@ static int xf86VTPruneDoor = 0;
void
xf86VTRelease(int sig)
{
- if (xf86Info.vtPendingNum == -1)
- {
- xf86VTPruneDoor = 1;
- xf86Info.vtRequestsPending = TRUE;
- return;
- }
+ if (xf86Info.vtPendingNum == -1) {
+ xf86VTPruneDoor = 1;
+ xf86Info.vtRequestsPending = TRUE;
+ return;
+ }
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- xf86Info.vtPendingNum = -1;
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
+ xf86Info.vtPendingNum = -1;
- return;
+ return;
}
void
xf86VTAcquire(int sig)
{
- xf86Info.vtRequestsPending = TRUE;
- return;
+ xf86Info.vtRequestsPending = TRUE;
+ return;
}
Bool
@@ -72,66 +71,64 @@ xf86VTSwitchPending(void)
Bool
xf86VTSwitchAway(void)
{
- int door_fd;
- vt_cmd_arg_t vt_door_arg;
- door_arg_t door_arg;
-
- xf86Info.vtRequestsPending = FALSE;
-
- if (xf86VTPruneDoor) {
- xf86VTPruneDoor = 0;
- ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
- return TRUE;
- }
-
- vt_door_arg.vt_ev = VT_EV_HOTKEYS;
- vt_door_arg.vt_num = xf86Info.vtPendingNum;
- door_arg.data_ptr = (char *)&vt_door_arg;
- door_arg.data_size = sizeof (vt_cmd_arg_t);
- door_arg.rbuf = NULL;
- door_arg.rsize = 0;
- door_arg.desc_ptr = NULL;
- door_arg.desc_num = 0;
-
- if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
- return FALSE;
-
- if (door_call(door_fd, &door_arg) != 0) {
- close(door_fd);
- return FALSE;
- }
-
- close(door_fd);
- return TRUE;
+ int door_fd;
+ vt_cmd_arg_t vt_door_arg;
+ door_arg_t door_arg;
+
+ xf86Info.vtRequestsPending = FALSE;
+
+ if (xf86VTPruneDoor) {
+ xf86VTPruneDoor = 0;
+ ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
+ return TRUE;
+ }
+
+ vt_door_arg.vt_ev = VT_EV_HOTKEYS;
+ vt_door_arg.vt_num = xf86Info.vtPendingNum;
+ door_arg.data_ptr = (char *) &vt_door_arg;
+ door_arg.data_size = sizeof(vt_cmd_arg_t);
+ door_arg.rbuf = NULL;
+ door_arg.rsize = 0;
+ door_arg.desc_ptr = NULL;
+ door_arg.desc_num = 0;
+
+ if ((door_fd = open(VT_DAEMON_DOOR_FILE, O_RDONLY)) < 0)
+ return FALSE;
+
+ if (door_call(door_fd, &door_arg) != 0) {
+ close(door_fd);
+ return FALSE;
+ }
+
+ close(door_fd);
+ return TRUE;
}
Bool
xf86VTSwitchTo(void)
{
- xf86Info.vtRequestsPending = FALSE;
- if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
- {
- return FALSE;
- }
- else
- {
- return TRUE;
- }
+ xf86Info.vtRequestsPending = FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0) {
+ return FALSE;
+ }
+ else {
+ return TRUE;
+ }
}
Bool
xf86VTActivate(int vtno)
{
- struct vt_stat state;
+ struct vt_stat state;
- if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
- return FALSE;
+ if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
+ return FALSE;
- if ((state.v_state & (1 << vtno)) == 0)
- return FALSE;
+ if ((state.v_state & (1 << vtno)) == 0)
+ return FALSE;
- xf86Info.vtRequestsPending = TRUE;
- xf86Info.vtPendingNum = vtno;
+ xf86Info.vtRequestsPending = TRUE;
+ xf86Info.vtPendingNum = vtno;
- return TRUE;
+ return TRUE;
}
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_agp.c b/xserver/hw/xfree86/os-support/solaris/sun_agp.c
index 0331ac1c5..fb58eca81 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_agp.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_agp.c
@@ -51,6 +51,7 @@
static int gartFd = -1;
static int acquiredScreen = -1;
static Bool initDone = FALSE;
+
/*
* Close /dev/agpgart. This frees all associated memory allocated during
* this server generation.
@@ -58,17 +59,17 @@ static Bool initDone = FALSE;
Bool
xf86GARTCloseScreen(int screenNum)
{
- if (gartFd != -1) {
- close(gartFd);
- acquiredScreen = -1;
- gartFd = -1;
- initDone = FALSE;
+ if (gartFd != -1) {
+ close(gartFd);
+ acquiredScreen = -1;
+ gartFd = -1;
+ initDone = FALSE;
- xf86DrvMsg(screenNum, X_INFO,
- "xf86GARTCloseScreen: device closed successfully\n");
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86GARTCloseScreen: device closed successfully\n");
- }
- return TRUE;
+ }
+ return TRUE;
}
/*
@@ -77,251 +78,249 @@ xf86GARTCloseScreen(int screenNum)
static Bool
GARTInit(int screenNum)
{
- if (initDone)
- return gartFd != -1;
-
- if (gartFd == -1)
- gartFd = open(AGP_DEVICE, O_RDWR);
- else
- return FALSE;
-
- if (gartFd == -1) {
- xf86DrvMsg(screenNum, X_ERROR,
- "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
- strerror(errno));
- return FALSE;
- }
-
- initDone = TRUE;
- xf86DrvMsg(screenNum, X_INFO,
- "GARTInit: " AGP_DEVICE " opened successfully\n");
-
- return TRUE;
+ if (initDone)
+ return gartFd != -1;
+
+ if (gartFd == -1)
+ gartFd = open(AGP_DEVICE, O_RDWR);
+ else
+ return FALSE;
+
+ if (gartFd == -1) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "GARTInit: Unable to open " AGP_DEVICE " (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+
+ initDone = TRUE;
+ xf86DrvMsg(screenNum, X_INFO,
+ "GARTInit: " AGP_DEVICE " opened successfully\n");
+
+ return TRUE;
}
Bool
xf86AgpGARTSupported(void)
{
- return (GARTInit(-1));
+ return (GARTInit(-1));
}
AgpInfoPtr
xf86GetAGPInfo(int screenNum)
{
- agp_info_t agpinf;
- AgpInfoPtr info;
-
- if (!GARTInit(screenNum))
- return NULL;
-
- if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
- strerror(errno));
- return NULL;
- }
-
- if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
- xf86DrvMsg(screenNum, X_ERROR,
- "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
- return NULL;
- }
-
- info->bridgeId = agpinf.agpi_devid;
- info->agpMode = agpinf.agpi_mode;
- info->base = agpinf.agpi_aperbase;
- info->size = agpinf.agpi_apersize;
- info->totalPages = (unsigned long)agpinf.agpi_pgtotal;
- info->systemPages = (unsigned long)agpinf.agpi_pgsystem;
- info->usedPages = (unsigned long)agpinf.agpi_pgused;
-
- return info;
+ agp_info_t agpinf;
+ AgpInfoPtr info;
+
+ if (!GARTInit(screenNum))
+ return NULL;
+
+ if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
+ strerror(errno));
+ return NULL;
+ }
+
+ if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
+ xf86DrvMsg(screenNum, X_ERROR,
+ "xf86GetAGPInfo: Failed to allocate AgpInfo\n");
+ return NULL;
+ }
+
+ info->bridgeId = agpinf.agpi_devid;
+ info->agpMode = agpinf.agpi_mode;
+ info->base = agpinf.agpi_aperbase;
+ info->size = agpinf.agpi_apersize;
+ info->totalPages = (unsigned long) agpinf.agpi_pgtotal;
+ info->systemPages = (unsigned long) agpinf.agpi_pgsystem;
+ info->usedPages = (unsigned long) agpinf.agpi_pgused;
+
+ return info;
}
Bool
xf86AcquireGART(int screenNum)
{
- if (!GARTInit(screenNum))
- return FALSE;
-
- if (acquiredScreen != screenNum) {
- if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
- xf86DrvMsg(screenNum, X_WARNING,
- "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
- strerror(errno));
- return FALSE;
- }
- acquiredScreen = screenNum;
- xf86DrvMsg(screenNum, X_INFO,
- "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n");
- }
- return TRUE;
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen != screenNum) {
+ if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86AcquireGART: AGPIOC_ACQUIRE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = screenNum;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86AcquireGART: AGPIOC_ACQUIRE succeeded\n");
+ }
+ return TRUE;
}
Bool
xf86ReleaseGART(int screenNum)
{
- if (!GARTInit(screenNum))
- return FALSE;
-
- if (acquiredScreen == screenNum) {
- /*
- * The FreeBSD agp driver removes allocations on release.
- * The Solaris driver doesn't. xf86ReleaseGART() is expected
- * to give up access to the GART, but not to remove any
- * allocations.
- */
-
- if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
- xf86DrvMsg(screenNum, X_WARNING,
- "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
- strerror(errno));
- return FALSE;
- }
- acquiredScreen = -1;
- xf86DrvMsg(screenNum, X_INFO,
- "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n");
- return TRUE;
- }
- return FALSE;
+ if (!GARTInit(screenNum))
+ return FALSE;
+
+ if (acquiredScreen == screenNum) {
+ /*
+ * The FreeBSD agp driver removes allocations on release.
+ * The Solaris driver doesn't. xf86ReleaseGART() is expected
+ * to give up access to the GART, but not to remove any
+ * allocations.
+ */
+
+ if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING,
+ "xf86ReleaseGART: AGPIOC_RELEASE failed (%s)\n",
+ strerror(errno));
+ return FALSE;
+ }
+ acquiredScreen = -1;
+ xf86DrvMsg(screenNum, X_INFO,
+ "xf86ReleaseGART: AGPIOC_RELEASE succeeded\n");
+ return TRUE;
+ }
+ return FALSE;
}
int
xf86AllocateGARTMemory(int screenNum, unsigned long size, int type,
- unsigned long *physical)
+ unsigned long *physical)
{
- agp_allocate_t alloc;
- int pages;
-
- /*
- * Allocates "size" bytes of GART memory (rounds up to the next
- * page multiple) or type "type". A handle (key) for the allocated
- * memory is returned. On error, the return value is -1.
- * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will
- * return error.
- */
-
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return -1;
-
- pages = (size / AGP_PAGE_SIZE);
- if (size % AGP_PAGE_SIZE != 0)
- pages++;
-
- alloc.agpa_pgcount = pages;
- alloc.agpa_type = type;
-
- if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
- "allocation of %d pages failed\n\t(%s)\n", pages,
- strerror(errno));
- return -1;
- }
-
- if (physical)
- *physical = (unsigned long)alloc.agpa_physical;
-
- return alloc.agpa_key;
+ agp_allocate_t alloc;
+ int pages;
+
+ /*
+ * Allocates "size" bytes of GART memory (rounds up to the next
+ * page multiple) or type "type". A handle (key) for the allocated
+ * memory is returned. On error, the return value is -1.
+ * "size" should be larger than 0, or AGPIOC_ALLOCATE ioctl will
+ * return error.
+ */
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return -1;
+
+ pages = (size / AGP_PAGE_SIZE);
+ if (size % AGP_PAGE_SIZE != 0)
+ pages++;
+
+ alloc.agpa_pgcount = pages;
+ alloc.agpa_type = type;
+
+ if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86AllocateGARTMemory: "
+ "allocation of %d pages failed\n\t(%s)\n", pages,
+ strerror(errno));
+ return -1;
+ }
+
+ if (physical)
+ *physical = (unsigned long) alloc.agpa_physical;
+
+ return alloc.agpa_key;
}
Bool
xf86DeallocateGARTMemory(int screenNum, int key)
{
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return FALSE;
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
- if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *)key) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: "
- "deallocation of gart memory with key %d failed\n"
- "\t(%s)\n", key, strerror(errno));
- return FALSE;
- }
+ if (ioctl(gartFd, AGPIOC_DEALLOCATE, (int *) (uintptr_t) key) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86DeAllocateGARTMemory: "
+ "deallocation of gart memory with key %d failed\n"
+ "\t(%s)\n", key, strerror(errno));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
/* Bind GART memory with "key" at "offset" */
Bool
xf86BindGARTMemory(int screenNum, int key, unsigned long offset)
{
- agp_bind_t bind;
- int pageOffset;
-
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return FALSE;
-
- if (offset % AGP_PAGE_SIZE != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
- "offset (0x%lx) is not page-aligned (%d)\n",
- offset, AGP_PAGE_SIZE);
- return FALSE;
- }
- pageOffset = offset / AGP_PAGE_SIZE;
-
- xf86DrvMsgVerb(screenNum, X_INFO, 3,
- "xf86BindGARTMemory: bind key %d at 0x%08lx "
- "(pgoffset %d)\n", key, offset, pageOffset);
-
- bind.agpb_pgstart = pageOffset;
- bind.agpb_key = key;
-
- if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
- "binding of gart memory with key %d\n"
- "\tat offset 0x%lx failed (%s)\n",
- key, offset, strerror(errno));
- return FALSE;
- }
-
- return TRUE;
+ agp_bind_t bind;
+ int pageOffset;
+
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
+
+ if (offset % AGP_PAGE_SIZE != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "offset (0x%lx) is not page-aligned (%d)\n",
+ offset, AGP_PAGE_SIZE);
+ return FALSE;
+ }
+ pageOffset = offset / AGP_PAGE_SIZE;
+
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86BindGARTMemory: bind key %d at 0x%08lx "
+ "(pgoffset %d)\n", key, offset, pageOffset);
+
+ bind.agpb_pgstart = pageOffset;
+ bind.agpb_key = key;
+
+ if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86BindGARTMemory: "
+ "binding of gart memory with key %d\n"
+ "\tat offset 0x%lx failed (%s)\n",
+ key, offset, strerror(errno));
+ return FALSE;
+ }
+
+ return TRUE;
}
/* Unbind GART memory with "key" */
Bool
xf86UnbindGARTMemory(int screenNum, int key)
{
- agp_unbind_t unbind;
+ agp_unbind_t unbind;
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return FALSE;
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
- unbind.agpu_pri = 0;
- unbind.agpu_key = key;
+ unbind.agpu_pri = 0;
+ unbind.agpu_key = key;
- if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
- "unbinding of gart memory with key %d "
- "failed (%s)\n", key, strerror(errno));
- return FALSE;
- }
+ if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86UnbindGARTMemory: "
+ "unbinding of gart memory with key %d "
+ "failed (%s)\n", key, strerror(errno));
+ return FALSE;
+ }
- xf86DrvMsgVerb(screenNum, X_INFO, 3,
- "xf86UnbindGARTMemory: unbind key %d\n", key);
+ xf86DrvMsgVerb(screenNum, X_INFO, 3,
+ "xf86UnbindGARTMemory: unbind key %d\n", key);
- return TRUE;
+ return TRUE;
}
-
/* XXX Interface may change. */
Bool
xf86EnableAGP(int screenNum, CARD32 mode)
{
- agp_setup_t setup;
+ agp_setup_t setup;
- if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
- return FALSE;
+ if (!GARTInit(screenNum) || (acquiredScreen != screenNum))
+ return FALSE;
- setup.agps_mode = mode;
- if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
- xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
- "AGPIOC_SETUP with mode %x failed (%s)\n",
- (unsigned int) mode, strerror(errno));
- return FALSE;
- }
+ setup.agps_mode = mode;
+ if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
+ xf86DrvMsg(screenNum, X_WARNING, "xf86EnableAGP: "
+ "AGPIOC_SETUP with mode %x failed (%s)\n",
+ (unsigned int) mode, strerror(errno));
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
}
-
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_apm.c b/xserver/hw/xfree86/os-support/solaris/sun_apm.c
index 55081b6d1..4ff64649a 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_apm.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_apm.c
@@ -79,9 +79,8 @@
#define APM_IOC_STANDBY 0xa0f
#endif
-typedef struct apm_event_info
-{
- int type;
+typedef struct apm_event_info {
+ int type;
} apm_event_info;
/*
@@ -97,20 +96,22 @@ static void sunCloseAPM(void);
static struct {
u_int apmBsd;
pmEvent xf86;
-} sunToXF86Array [] = {
- { APM_STANDBY_REQ, XF86_APM_SYS_STANDBY },
- { APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND },
- { APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME },
- { APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME },
- { APM_BATTERY_LOW, XF86_APM_LOW_BATTERY },
- { APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE },
- { APM_UPDATE_TIME, XF86_APM_UPDATE_TIME },
- { APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND },
- { APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY },
- { APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND },
- { APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME },
+} sunToXF86Array[] = {
+ {
+ APM_STANDBY_REQ, XF86_APM_SYS_STANDBY}, {
+ APM_SUSPEND_REQ, XF86_APM_SYS_SUSPEND}, {
+ APM_NORMAL_RESUME, XF86_APM_NORMAL_RESUME}, {
+ APM_CRIT_RESUME, XF86_APM_CRITICAL_RESUME}, {
+ APM_BATTERY_LOW, XF86_APM_LOW_BATTERY}, {
+ APM_POWER_CHANGE, XF86_APM_POWER_STATUS_CHANGE}, {
+ APM_UPDATE_TIME, XF86_APM_UPDATE_TIME}, {
+ APM_CRIT_SUSPEND_REQ, XF86_APM_CRITICAL_SUSPEND}, {
+ APM_USER_STANDBY_REQ, XF86_APM_USER_STANDBY}, {
+ APM_USER_SUSPEND_REQ, XF86_APM_USER_SUSPEND}, {
+ APM_SYS_STANDBY_RESUME, XF86_APM_STANDBY_RESUME},
#ifdef APM_CAPABILITY_CHANGE
- { APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED },
+ {
+ APM_CAPABILITY_CHANGE, XF86_APM_CAPABILITY_CHANGED},
#endif
};
@@ -122,9 +123,9 @@ sunToXF86(int type)
int i;
for (i = 0; i < numApmEvents; i++) {
- if (type == sunToXF86Array[i].apmBsd) {
- return sunToXF86Array[i].xf86;
- }
+ if (type == sunToXF86Array[i].apmBsd) {
+ return sunToXF86Array[i].xf86;
+ }
}
return XF86_APM_UNKNOWN;
}
@@ -132,22 +133,22 @@ sunToXF86(int type)
/*
* APM events can be requested direclty from /dev/apm
*/
-static int
-sunPMGetEventFromOS(int fd, pmEvent *events, int num)
+static int
+sunPMGetEventFromOS(int fd, pmEvent * events, int num)
{
struct apm_event_info sunEvent;
int i;
for (i = 0; i < num; i++) {
-
- if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) {
- if (errno != EAGAIN) {
- xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT"
- " %s\n", strerror(errno));
- }
- break;
- }
- events[i] = sunToXF86(sunEvent.type);
+
+ if (ioctl(fd, APM_IOC_NEXTEVENT, &sunEvent) < 0) {
+ if (errno != EAGAIN) {
+ xf86Msg(X_WARNING, "sunPMGetEventFromOS: APM_IOC_NEXTEVENT"
+ " %s\n", strerror(errno));
+ }
+ break;
+ }
+ events[i] = sunToXF86(sunEvent.type);
}
xf86Msg(X_WARNING, "Got some events\n");
return i;
@@ -158,38 +159,38 @@ sunPMConfirmEventToOs(int fd, pmEvent event)
{
switch (event) {
/* XXX: NOT CURRENTLY RETURNED FROM OS */
- case XF86_APM_SYS_STANDBY:
- case XF86_APM_USER_STANDBY:
- if (ioctl( fd, APM_IOC_STANDBY, NULL ) == 0)
- return PM_WAIT; /* should we stop the Xserver in standby, too? */
+ case XF86_APM_SYS_STANDBY:
+ case XF86_APM_USER_STANDBY:
+ if (ioctl(fd, APM_IOC_STANDBY, NULL) == 0)
+ return PM_WAIT; /* should we stop the Xserver in standby, too? */
else
return PM_NONE;
- case XF86_APM_SYS_SUSPEND:
- case XF86_APM_CRITICAL_SUSPEND:
- case XF86_APM_USER_SUSPEND:
- xf86Msg(X_WARNING, "Got SUSPENDED\n");
- if (ioctl( fd, APM_IOC_SUSPEND, NULL ) == 0)
+ case XF86_APM_SYS_SUSPEND:
+ case XF86_APM_CRITICAL_SUSPEND:
+ case XF86_APM_USER_SUSPEND:
+ xf86Msg(X_WARNING, "Got SUSPENDED\n");
+ if (ioctl(fd, APM_IOC_SUSPEND, NULL) == 0)
return PM_CONTINUE;
else {
- xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND"
- " %s\n", strerror(errno));
+ xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_SUSPEND"
+ " %s\n", strerror(errno));
return PM_FAILED;
- }
- case XF86_APM_STANDBY_RESUME:
- case XF86_APM_NORMAL_RESUME:
- case XF86_APM_CRITICAL_RESUME:
- case XF86_APM_STANDBY_FAILED:
- case XF86_APM_SUSPEND_FAILED:
- xf86Msg(X_WARNING, "Got RESUME\n");
- if (ioctl( fd, APM_IOC_RESUME, NULL ) == 0)
+ }
+ case XF86_APM_STANDBY_RESUME:
+ case XF86_APM_NORMAL_RESUME:
+ case XF86_APM_CRITICAL_RESUME:
+ case XF86_APM_STANDBY_FAILED:
+ case XF86_APM_SUSPEND_FAILED:
+ xf86Msg(X_WARNING, "Got RESUME\n");
+ if (ioctl(fd, APM_IOC_RESUME, NULL) == 0)
return PM_CONTINUE;
else {
- xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME"
- " %s\n", strerror(errno));
+ xf86Msg(X_WARNING, "sunPMConfirmEventToOs: APM_IOC_RESUME"
+ " %s\n", strerror(errno));
return PM_FAILED;
- }
- default:
- return PM_NONE;
+ }
+ default:
+ return PM_NONE;
}
}
@@ -199,13 +200,13 @@ xf86OSPMOpen(void)
int fd;
if (APMihPtr || !xf86Info.pmFlag) {
- return NULL;
+ return NULL;
}
if ((fd = open(APM_DEVICE, O_RDWR)) == -1) {
- if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) {
- return NULL;
- }
+ if ((fd = open(APM_DEVICE1, O_RDWR)) == -1) {
+ return NULL;
+ }
}
xf86PMGetEventFromOs = sunPMGetEventFromOS;
xf86PMConfirmEventToOs = sunPMConfirmEventToOs;
@@ -219,8 +220,8 @@ sunCloseAPM(void)
int fd;
if (APMihPtr) {
- fd = xf86RemoveGeneralHandler(APMihPtr);
- close(fd);
- APMihPtr = NULL;
+ fd = xf86RemoveGeneralHandler(APMihPtr);
+ close(fd);
+ APMihPtr = NULL;
}
}
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_bell.c b/xserver/hw/xfree86/os-support/solaris/sun_bell.c
index b59835e53..beb13d2e9 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_bell.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_bell.c
@@ -45,19 +45,19 @@
void
xf86OSRingBell(int loudness, int pitch, int duration)
{
- static short samples[BELL_SAMPLES];
- static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
- static int lastFreq;
- int cnt;
- int i;
- int written;
- int repeats;
- int freq;
- audio_info_t audioInfo;
- struct iovec iov[IOV_MAX];
- int iovcnt;
- double ampl, cyclen, phase;
- int audioFD;
+ static short samples[BELL_SAMPLES];
+ static short silence[BELL_SAMPLES]; /* "The Sound of Silence" */
+ static int lastFreq;
+ int cnt;
+ int i;
+ int written;
+ int repeats;
+ int freq;
+ audio_info_t audioInfo;
+ struct iovec iov[IOV_MAX];
+ int iovcnt;
+ double ampl, cyclen, phase;
+ int audioFD;
if ((loudness <= 0) || (pitch <= 0) || (duration <= 0)) {
return;
@@ -84,7 +84,7 @@ xf86OSRingBell(int loudness, int pitch, int duration)
if (freq != lastFreq) {
lastFreq = freq;
- ampl = 16384.0;
+ ampl = 16384.0;
cyclen = (double) freq / (double) BELL_RATE;
phase = 0.0;
@@ -115,7 +115,7 @@ xf86OSRingBell(int loudness, int pitch, int duration)
audioInfo.play.precision = 16;
audioInfo.play.gain = min(AUDIO_MAX_GAIN, AUDIO_MAX_GAIN * loudness / 100);
- if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0){
+ if (ioctl(audioFD, AUDIO_SETINFO, &audioInfo) < 0) {
xf86Msg(X_ERROR,
"Bell: AUDIO_SETINFO failed on audio device \"%s\": %s\n",
AUDIO_DEVICE, strerror(errno));
@@ -132,14 +132,15 @@ xf86OSRingBell(int loudness, int pitch, int duration)
*/
iov[iovcnt].iov_base = (char *) silence;
iov[iovcnt++].iov_len = sizeof(silence);
- } else {
+ }
+ else {
iov[iovcnt].iov_base = (char *) samples;
iov[iovcnt++].iov_len = sizeof(samples);
}
if ((iovcnt >= IOV_MAX) || (cnt == repeats)) {
written = writev(audioFD, iov, iovcnt);
- if ((written < ((int)(sizeof(samples) * iovcnt)))) {
+ if ((written < ((int) (sizeof(samples) * iovcnt)))) {
/* audio buffer was full! */
int naptime;
@@ -147,13 +148,14 @@ xf86OSRingBell(int loudness, int pitch, int duration)
if (written == -1) {
if (errno != EAGAIN) {
xf86Msg(X_ERROR,
- "Bell: writev failed on audio device \"%s\": %s\n",
+ "Bell: writev failed on audio device \"%s\": %s\n",
AUDIO_DEVICE, strerror(errno));
close(audioFD);
return;
}
i = iovcnt;
- } else {
+ }
+ else {
i = ((sizeof(samples) * iovcnt) - written)
/ sizeof(samples);
}
@@ -169,7 +171,8 @@ xf86OSRingBell(int loudness, int pitch, int duration)
iov[iovcnt].iov_base = ((char *) samples) + i;
iov[iovcnt++].iov_len = sizeof(samples) - i;
}
- } else {
+ }
+ else {
iovcnt = 0;
}
}
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_init.c b/xserver/hw/xfree86/os-support/solaris/sun_init.c
index 281a6df9f..4b75a98ac 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_init.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_init.c
@@ -30,7 +30,7 @@
#include "xf86Priv.h"
#include "xf86_OSlib.h"
#ifdef HAVE_SYS_KD_H
-# include <sys/kd.h>
+#include <sys/kd.h>
#endif
/*
@@ -48,6 +48,7 @@
static Bool KeepTty = FALSE;
static Bool Protect0 = FALSE;
static Bool UseConsole = FALSE;
+
#ifdef HAS_USL_VTS
static int VTnum = -1;
static int xf86StartVT = -1;
@@ -63,10 +64,27 @@ static char consoleDev[PATH_MAX] = "/dev/fb";
Used by hw/xfree86/common/xf86AutoConfig.c for VIS_GETIDENTIFIER */
_X_HIDDEN char xf86SolarisFbDev[PATH_MAX] = "/dev/fb";
+static void
+switch_to(int vt, const char *from)
+{
+ int ret;
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_ACTIVATE, vt));
+ if (ret != 0)
+ xf86Msg(X_WARNING, "%s: VT_ACTIVATE failed: %s\n",
+ from, strerror(errno));
+
+ SYSCALL(ret = ioctl(xf86Info.consoleFd, VT_WAITACTIVE, vt));
+ if (ret != 0)
+ xf86Msg(X_WARNING, "%s: VT_WAITACTIVE failed: %s\n",
+ from, strerror(errno));
+}
+
void
xf86OpenConsole(void)
{
int i;
+
#ifdef HAS_USL_VTS
int fd;
struct vt_mode VT;
@@ -74,208 +92,192 @@ xf86OpenConsole(void)
MessageType from = X_PROBED;
#endif
- if (serverGeneration == 1)
- {
- /* Check if we're run with euid==0 */
- if (geteuid() != 0)
- FatalError("xf86OpenConsole: Server must be suid root\n");
-
- /* Protect page 0 to help find NULL dereferencing */
- /* mprotect() doesn't seem to work */
- if (Protect0)
- {
- int fd = -1;
-
- if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
- {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: cannot open /dev/zero (%s)\n",
- strerror(errno));
- }
- else
- {
- if (mmap(0, 0x1000, PROT_NONE,
- MAP_FIXED | MAP_SHARED, fd, 0) == MAP_FAILED)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: failed to protect page 0 (%s)\n",
- strerror(errno));
-
- close(fd);
- }
- }
+ if (serverGeneration == 1) {
+ /* Check if we're run with euid==0 */
+ if (geteuid() != 0)
+ FatalError("xf86OpenConsole: Server must be suid root\n");
+
+ /* Protect page 0 to help find NULL dereferencing */
+ /* mprotect() doesn't seem to work */
+ if (Protect0) {
+ int fd = -1;
+
+ if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ strerror(errno));
+ }
+ else {
+ if (mmap(0, 0x1000, PROT_NONE,
+ MAP_FIXED | MAP_SHARED, fd, 0) == MAP_FAILED)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: failed to protect page 0 (%s)\n",
+ strerror(errno));
+
+ close(fd);
+ }
+ }
#ifdef HAS_USL_VTS
- /*
- * Setup the virtual terminal manager
- */
- if ((fd = open("/dev/vt/0",O_RDWR,0)) == -1)
- {
- xf86ErrorF("xf86OpenConsole: Cannot open /dev/vt/0 (%s)\n",
- strerror(errno));
- vtEnabled = 0;
- }
- else
- {
- if (ioctl(fd, VT_ENABLED, &vtEnabled) < 0)
- {
- xf86ErrorF("xf86OpenConsole: VT_ENABLED failed (%s)\n",
- strerror(errno));
- vtEnabled = 0;
- }
- }
-#endif /* HAS_USL_VTS */
-
- if (UseConsole)
- {
- strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
+ /*
+ * Setup the virtual terminal manager
+ */
+ if ((fd = open("/dev/vt/0", O_RDWR, 0)) == -1) {
+ xf86ErrorF("xf86OpenConsole: Cannot open /dev/vt/0 (%s)\n",
+ strerror(errno));
+ vtEnabled = 0;
+ }
+ else {
+ if (ioctl(fd, VT_ENABLED, &vtEnabled) < 0) {
+ xf86ErrorF("xf86OpenConsole: VT_ENABLED failed (%s)\n",
+ strerror(errno));
+ vtEnabled = 0;
+ }
+ }
+#endif /* HAS_USL_VTS */
+
+ if (UseConsole) {
+ strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
#ifdef HAS_USL_VTS
- xf86Info.vtno = CONSOLE_VTNO;
-
- if (vtEnabled == 0)
- {
- xf86StartVT = 0;
- }
- else
- {
- if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
- FatalError("xf86OpenConsole: Cannot determine current VT\n");
- xf86StartVT = vtinfo.v_active;
- }
-#endif /* HAS_USL_VTS */
- goto OPENCONSOLE;
- }
+ xf86Info.vtno = CONSOLE_VTNO;
+
+ if (vtEnabled == 0) {
+ xf86StartVT = 0;
+ }
+ else {
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError
+ ("xf86OpenConsole: Cannot determine current VT\n");
+ xf86StartVT = vtinfo.v_active;
+ }
+#endif /* HAS_USL_VTS */
+ goto OPENCONSOLE;
+ }
#ifdef HAS_USL_VTS
- if (vtEnabled == 0)
- {
- /* VT not enabled - kernel too old or Sparc platforms
- without visual_io support */
- xf86Msg(from, "VT infrastructure is not available\n");
-
- xf86StartVT = 0;
- xf86Info.vtno = 0;
- strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
- goto OPENCONSOLE;
- }
-
- if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
- FatalError("xf86OpenConsole: Cannot determine current VT\n");
-
- xf86StartVT = vtinfo.v_active;
-
- if (VTnum != -1)
- {
- xf86Info.vtno = VTnum;
- from = X_CMDLINE;
- }
- else
- {
- if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
- (xf86Info.vtno == -1))
- {
- FatalError("xf86OpenConsole: Cannot find a free VT\n");
- }
- }
-
- xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
- snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
-
- if (fd != -1)
- {
- close(fd);
- }
-
-#endif /* HAS_USL_VTS */
-
-OPENCONSOLE:
- if (!KeepTty)
- setpgrp();
-
- if (((xf86Info.consoleFd = open(consoleDev, O_RDWR | O_NDELAY, 0)) < 0))
- FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
- consoleDev, strerror(errno));
-
- /* Change ownership of the vt or console */
- chown(consoleDev, getuid(), getgid());
+ if (vtEnabled == 0) {
+ /* VT not enabled - kernel too old or Sparc platforms
+ without visual_io support */
+ xf86Msg(from, "VT infrastructure is not available\n");
+
+ xf86StartVT = 0;
+ xf86Info.vtno = 0;
+ strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
+ goto OPENCONSOLE;
+ }
+
+ if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+ FatalError("xf86OpenConsole: Cannot determine current VT\n");
+
+ xf86StartVT = vtinfo.v_active;
+
+ if (VTnum != -1) {
+ xf86Info.vtno = VTnum;
+ from = X_CMDLINE;
+ }
+ else if (xf86Info.ShareVTs) {
+ xf86Info.vtno = vtinfo.v_active;
+ from = X_CMDLINE;
+ }
+ else {
+ if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+ (xf86Info.vtno == -1)) {
+ FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ }
+ }
+
+ xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
+ snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
+
+ if (fd != -1) {
+ close(fd);
+ }
+
+#endif /* HAS_USL_VTS */
+
+ OPENCONSOLE:
+ if (!KeepTty)
+ setpgrp();
+
+ if (((xf86Info.consoleFd = open(consoleDev, O_RDWR | O_NDELAY, 0)) < 0))
+ FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ consoleDev, strerror(errno));
+
+ /* Change ownership of the vt or console */
+ chown(consoleDev, getuid(), getgid());
#ifdef HAS_USL_VTS
- if (vtEnabled)
- {
- /*
- * Now get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
-
-#ifdef VT_SET_CONSUSER /* added in snv_139 */
- if (strcmp(display, "0") == 0)
- if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_SET_CONSUSER failed\n");
+ if (xf86Info.ShareVTs)
+ return;
+
+ if (vtEnabled) {
+ /*
+ * Now get the VT
+ */
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+
+#ifdef VT_SET_CONSUSER /* added in snv_139 */
+ if (strcmp(display, "0") == 0)
+ if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_SET_CONSUSER failed\n");
#endif
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_GETMODE failed\n");
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_GETMODE failed\n");
- OsSignal(SIGUSR1, xf86VTAcquire);
- OsSignal(SIGUSR2, xf86VTRelease);
+ OsSignal(SIGUSR1, xf86VTAcquire);
+ OsSignal(SIGUSR2, xf86VTRelease);
- VT.mode = VT_PROCESS;
- VT.acqsig = SIGUSR1;
- VT.relsig = SIGUSR2;
+ VT.mode = VT_PROCESS;
+ VT.acqsig = SIGUSR1;
+ VT.relsig = SIGUSR2;
- if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
- FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
+ FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
- if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
- }
+ if (ioctl(xf86Info.consoleFd, VT_SETDISPINFO, atoi(display)) < 0)
+ xf86Msg(X_WARNING, "xf86OpenConsole: VT_SETDISPINFO failed\n");
+ }
#endif
#ifdef KDSETMODE
- SYSCALL(i = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
- if (i < 0) {
- xf86Msg(X_WARNING,
- "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed on %s (%s)\n",
- consoleDev, strerror(errno));
- }
+ SYSCALL(i = ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS));
+ if (i < 0) {
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: KDSETMODE KD_GRAPHICS failed on %s (%s)\n",
+ consoleDev, strerror(errno));
+ }
#endif
}
- else /* serverGeneration != 1 */
- {
+ else { /* serverGeneration != 1 */
+
#ifdef HAS_USL_VTS
- if (vtEnabled)
- {
- /*
- * Now re-get the VT
- */
- if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_ACTIVATE failed\n");
-
- if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
- xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
-
-#ifdef VT_SET_CONSUSER /* added in snv_139 */
- if (strcmp(display, "0") == 0)
- if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
- xf86Msg(X_WARNING,
- "xf86OpenConsole: VT_SET_CONSUSER failed\n");
+ if (vtEnabled && !xf86Info.ShareVTs) {
+ /*
+ * Now re-get the VT
+ */
+ if (xf86Info.autoVTSwitch)
+ switch_to(xf86Info.vtno, "xf86OpenConsole");
+
+#ifdef VT_SET_CONSUSER /* added in snv_139 */
+ if (strcmp(display, "0") == 0)
+ if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
+ xf86Msg(X_WARNING,
+ "xf86OpenConsole: VT_SET_CONSUSER failed\n");
#endif
- /*
- * If the server doesn't have the VT when the reset occurs,
- * this is to make sure we don't continue until the activate
- * signal is received.
- */
- if (!xf86Screens[0]->vtSema)
- sleep(5);
- }
-#endif /* HAS_USL_VTS */
+ /*
+ * If the server doesn't have the VT when the reset occurs,
+ * this is to make sure we don't continue until the activate
+ * signal is received.
+ */
+ if (!xf86Screens[0]->vtSema)
+ sleep(5);
+ }
+#endif /* HAS_USL_VTS */
}
}
@@ -290,44 +292,47 @@ xf86CloseConsole(void)
#if !defined(__i386__) && !defined(__i386) && !defined(__x86)
if (!xf86DoConfigure) {
- int fd;
-
- /*
- * 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.
- */
- if ((fd = open(xf86SolarisFbDev, O_RDWR, 0)) < 0) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to open framebuffer (%s)\n",
- strerror(errno));
- } else {
- struct fbgattr fbattr;
-
- if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
- (ioctl(fd, 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, fd, 0);
- if (fbdata == MAP_FAILED) {
- xf86Msg(X_WARNING,
- "xf86CloseConsole(): unable to mmap framebuffer"
- " (%s)\n", strerror(errno));
- } else {
- memset(fbdata, 0, fbattr.fbtype.fb_size);
- munmap(fbdata, fbattr.fbtype.fb_size);
- }
- }
-
- close(fd);
- }
+ int fd;
+
+ /*
+ * 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.
+ */
+ if ((fd = open(xf86SolarisFbDev, O_RDWR, 0)) < 0) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to open framebuffer (%s)\n",
+ strerror(errno));
+ }
+ else {
+ struct fbgattr fbattr;
+
+ if ((ioctl(fd, FBIOGATTR, &fbattr) < 0) &&
+ (ioctl(fd, 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, fd, 0);
+ if (fbdata == MAP_FAILED) {
+ xf86Msg(X_WARNING,
+ "xf86CloseConsole(): unable to mmap framebuffer"
+ " (%s)\n", strerror(errno));
+ }
+ else {
+ memset(fbdata, 0, fbattr.fbtype.fb_size);
+ munmap(fbdata, fbattr.fbtype.fb_size);
+ }
+ }
+
+ close(fd);
+ }
}
#endif
@@ -338,18 +343,17 @@ xf86CloseConsole(void)
#endif
#ifdef HAS_USL_VTS
- if (vtEnabled)
- {
- if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
- {
- VT.mode = VT_AUTO; /* Set default vt handling */
- ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
- }
-
- /* Activate the VT that X was started on */
- ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86StartVT);
+ if (vtEnabled) {
+ if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO; /* Set default vt handling */
+ ioctl(xf86Info.consoleFd, VT_SETMODE, &VT);
+ }
+
+ /* Activate the VT that X was started on */
+ if (xf86Info.autoVTSwitch)
+ switch_to(xf86StartVT, "xf86CloseConsole");
}
-#endif /* HAS_USL_VTS */
+#endif /* HAS_USL_VTS */
close(xf86Info.consoleFd);
}
@@ -361,58 +365,54 @@ xf86ProcessArgument(int argc, char **argv, int i)
* Keep server from detaching from controlling tty. This is useful when
* debugging, so the server can receive keyboard signals.
*/
- if (!strcmp(argv[i], "-keeptty"))
- {
- KeepTty = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-keeptty")) {
+ KeepTty = TRUE;
+ return 1;
}
/*
* Undocumented flag to protect page 0 from read/write to help catch NULL
* pointer dereferences. This is purely a debugging flag.
*/
- if (!strcmp(argv[i], "-protect0"))
- {
- Protect0 = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-protect0")) {
+ Protect0 = TRUE;
+ return 1;
}
/*
* Use /dev/console as the console device.
*/
- if (!strcmp(argv[i], "-C"))
- {
- UseConsole = TRUE;
- return 1;
+ if (!strcmp(argv[i], "-C")) {
+ UseConsole = TRUE;
+ return 1;
}
#ifdef HAS_USL_VTS
- if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
- {
- if (sscanf(argv[i], "vt%d", &VTnum) == 0)
- {
- UseMsg();
- VTnum = -1;
- return 0;
- }
+ if ((argv[i][0] == 'v') && (argv[i][1] == 't')) {
+ if (sscanf(argv[i], "vt%d", &VTnum) == 0) {
+ UseMsg();
+ VTnum = -1;
+ return 0;
+ }
- return 1;
+ return 1;
}
-#endif /* HAS_USL_VTS */
+#endif /* HAS_USL_VTS */
if ((i + 1) < argc) {
- if (!strcmp(argv[i], "-dev")) {
- strlcpy(xf86SolarisFbDev, argv[i+1], sizeof(xf86SolarisFbDev));
- return 2;
- }
+ if (!strcmp(argv[i], "-dev")) {
+ strlcpy(xf86SolarisFbDev, argv[i + 1], sizeof(xf86SolarisFbDev));
+ return 2;
+ }
}
return 0;
}
-void xf86UseMsg(void)
+void
+xf86UseMsg(void)
{
#ifdef HAS_USL_VTS
ErrorF("vtX Use the specified VT number\n");
diff --git a/xserver/hw/xfree86/os-support/solaris/sun_vid.c b/xserver/hw/xfree86/os-support/solaris/sun_vid.c
index f99bac517..67ef17689 100644
--- a/xserver/hw/xfree86/os-support/solaris/sun_vid.c
+++ b/xserver/hw/xfree86/os-support/solaris/sun_vid.c
@@ -48,10 +48,10 @@
#include <xorg-config.h>
#endif
-#include <sys/types.h> /* get __x86 definition if not set by compiler */
+#include <sys/types.h> /* get __x86 definition if not set by compiler */
#if defined(__i386__) || defined(__i386) || defined(__x86)
-# define _NEED_SYSI86
+#define _NEED_SYSI86
#endif
#include "xf86.h"
#include "xf86Priv.h"
@@ -70,44 +70,39 @@ static int apertureDevFD_rw = -1;
static Bool
solOpenAperture(void)
{
- if (apertureDevName == NULL)
- {
- apertureDevName = "/dev/xsvc";
- if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0)
- {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- apertureDevName = "/dev/fbs/aperture";
- apertureDevFD_rw = open(apertureDevName, O_RDWR);
- }
- apertureDevFD_ro = open(apertureDevName, O_RDONLY);
-
- if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0))
- {
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- xf86MsgVerb(X_WARNING, 0,
- "solOpenAperture: either /dev/fbs/aperture"
- " or /dev/xsvc required\n");
-
- apertureDevName = NULL;
-
- if (apertureDevFD_rw >= 0)
- {
- close(apertureDevFD_rw);
- }
- apertureDevFD_rw = -1;
-
- if (apertureDevFD_ro >= 0)
- {
- close(apertureDevFD_ro);
- }
- apertureDevFD_ro = -1;
-
- return FALSE;
- }
+ if (apertureDevName == NULL) {
+ apertureDevName = "/dev/xsvc";
+ if ((apertureDevFD_rw = open(apertureDevName, O_RDWR)) < 0) {
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ apertureDevName = "/dev/fbs/aperture";
+ apertureDevFD_rw = open(apertureDevName, O_RDWR);
+ }
+ apertureDevFD_ro = open(apertureDevName, O_RDONLY);
+
+ if ((apertureDevFD_rw < 0) || (apertureDevFD_ro < 0)) {
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ xf86MsgVerb(X_WARNING, 0,
+ "solOpenAperture: either /dev/fbs/aperture"
+ " or /dev/xsvc required\n");
+
+ apertureDevName = NULL;
+
+ if (apertureDevFD_rw >= 0) {
+ close(apertureDevFD_rw);
+ }
+ apertureDevFD_rw = -1;
+
+ if (apertureDevFD_ro >= 0) {
+ close(apertureDevFD_ro);
+ }
+ apertureDevFD_ro = -1;
+
+ return FALSE;
+ }
}
return TRUE;
}
@@ -119,32 +114,29 @@ solMapVidMem(int ScreenNum, unsigned long Base, unsigned long Size, int Flags)
int fd;
int prot;
- if (Flags & VIDMEM_READONLY)
- {
- fd = apertureDevFD_ro;
- prot = PROT_READ;
+ if (Flags & VIDMEM_READONLY) {
+ fd = apertureDevFD_ro;
+ prot = PROT_READ;
}
- else
- {
- fd = apertureDevFD_rw;
- prot = PROT_READ | PROT_WRITE;
+ else {
+ fd = apertureDevFD_rw;
+ prot = PROT_READ | PROT_WRITE;
}
- if (fd < 0)
- {
- xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to open %s (%s)\n",
- apertureDevName, strerror(errno));
- return NULL;
+ if (fd < 0) {
+ xf86DrvMsg(ScreenNum, X_ERROR,
+ "solMapVidMem: failed to open %s (%s)\n",
+ apertureDevName, strerror(errno));
+ return NULL;
}
- base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t)Base);
+ base = mmap(NULL, Size, prot, MAP_SHARED, fd, (off_t) Base);
if (base == MAP_FAILED) {
xf86DrvMsg(ScreenNum, X_ERROR,
- "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n",
- apertureDevName, Base, Size, strerror(errno));
- return NULL;
+ "solMapVidMem: failed to mmap %s (0x%08lx,0x%lx) (%s)\n",
+ apertureDevName, Base, Size, strerror(errno));
+ return NULL;
}
return base;
@@ -155,11 +147,10 @@ static void
solUnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
{
if (munmap(Base, Size) != 0) {
- xf86DrvMsgVerb(ScreenNum, X_WARNING, 0,
- "solUnMapVidMem: failed to unmap %s"
- " (0x%p,0x%lx) (%s)\n",
- apertureDevName, Base, Size,
- strerror(errno));
+ xf86DrvMsgVerb(ScreenNum, X_WARNING, 0,
+ "solUnMapVidMem: failed to unmap %s"
+ " (0x%p,0x%lx) (%s)\n",
+ apertureDevName, Base, Size, strerror(errno));
}
}
@@ -168,11 +159,12 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
{
pVidMem->linearSupported = solOpenAperture();
if (pVidMem->linearSupported) {
- pVidMem->mapMem = solMapVidMem;
- pVidMem->unmapMem = solUnMapVidMem;
- } else {
- xf86MsgVerb(X_WARNING, 0,
- "xf86OSInitVidMem: linear memory access disabled\n");
+ pVidMem->mapMem = solMapVidMem;
+ pVidMem->unmapMem = solUnMapVidMem;
+ }
+ else {
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86OSInitVidMem: linear memory access disabled\n");
}
pVidMem->initialised = TRUE;
}
@@ -182,7 +174,7 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
*/
int
xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
- int Len)
+ int Len)
{
unsigned char *ptr;
int psize;
@@ -193,33 +185,30 @@ xf86ReadBIOS(unsigned long Base, unsigned long Offset, unsigned char *Buf,
Base &= ~(psize - 1);
mlen = (Offset + Len + psize - 1) & ~(psize - 1);
- if (solOpenAperture() == FALSE)
- {
- xf86Msg(X_WARNING,
- "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
- return -1;
+ if (solOpenAperture() == FALSE) {
+ xf86Msg(X_WARNING,
+ "xf86ReadBIOS: Failed to open aperture to read BIOS\n");
+ return -1;
}
- ptr = (unsigned char *)mmap(NULL, mlen, PROT_READ,
- MAP_SHARED, apertureDevFD_ro, (off_t)Base);
- if (ptr == MAP_FAILED)
- {
- xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
- apertureDevName, Base, mlen);
- return -1;
+ ptr = (unsigned char *) mmap(NULL, mlen, PROT_READ,
+ MAP_SHARED, apertureDevFD_ro, (off_t) Base);
+ if (ptr == MAP_FAILED) {
+ xf86Msg(X_WARNING, "xf86ReadBIOS: %s mmap failed [0x%08lx, 0x%04x]\n",
+ apertureDevName, Base, mlen);
+ return -1;
}
- (void)memcpy(Buf, (void *)(ptr + Offset), Len);
- if (munmap((caddr_t)ptr, mlen) != 0) {
- xf86MsgVerb(X_WARNING, 0,
- "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
- apertureDevName, ptr, mlen, strerror(errno));
+ (void) memcpy(Buf, (void *) (ptr + Offset), Len);
+ if (munmap((caddr_t) ptr, mlen) != 0) {
+ xf86MsgVerb(X_WARNING, 0,
+ "xf86ReadBIOS: failed to unmap %s (0x%p,0x%x) (%s)\n",
+ apertureDevName, ptr, mlen, strerror(errno));
}
return Len;
}
-
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
@@ -233,14 +222,14 @@ xf86EnableIO(void)
{
#if defined(__i386__) || defined(__i386) || defined(__x86)
if (ExtendedEnabled)
- return TRUE;
+ return TRUE;
if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0) {
- xf86Msg(X_WARNING, "xf86EnableIOPorts: Failed to set IOPL for I/O\n");
- return FALSE;
+ xf86Msg(X_WARNING, "xf86EnableIOPorts: Failed to set IOPL for I/O\n");
+ return FALSE;
}
ExtendedEnabled = TRUE;
-#endif /* i386 */
+#endif /* i386 */
return TRUE;
}
@@ -248,11 +237,11 @@ void
xf86DisableIO(void)
{
#if defined(__i386__) || defined(__i386) || defined(__x86)
- if(!ExtendedEnabled)
- return;
+ if (!ExtendedEnabled)
+ return;
sysi86(SI86V86, V86SC_IOPL, 0);
ExtendedEnabled = FALSE;
-#endif /* i386 */
+#endif /* i386 */
}