xserver: Branch 'server-1.7-branch' - 11 commits

Peter Hutterer whot at kemper.freedesktop.org
Fri Feb 5 00:20:52 PST 2010


 configure.ac                             |    4 -
 dix/devices.c                            |   44 ++++++++++++++-----
 dix/getevents.c                          |    2 
 fb/fbpict.c                              |    1 
 hw/xfree86/common/xf86Events.c           |   10 +++-
 hw/xfree86/common/xf86cmap.c             |   31 +++++++------
 hw/xfree86/doc/man/xorg.conf.man.pre     |    1 
 hw/xfree86/os-support/solaris/sun_VTsw.c |   26 +++++++++--
 hw/xfree86/os-support/solaris/sun_init.c |   19 +++++---
 hw/xfree86/x86emu/ops.c                  |   70 +++++++++++++++++++------------
 hw/xquartz/xpr/xprScreen.c               |   13 +++++
 render/render.c                          |    4 -
 xkb/xkmread.c                            |    6 ++
 13 files changed, 164 insertions(+), 67 deletions(-)

New commits:
commit 85b04bb0ebaf7a6f1b1a34f7b1704a3e6cbdab8a
Author: Peter Hutterer <peter.hutterer at who-t.net>
Date:   Fri Feb 5 18:08:37 2010 +1000

    xserver 1.7.4.902
    
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/configure.ac b/configure.ac
index 2b6ec6b..fc7ff05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -26,8 +26,8 @@ dnl
 dnl Process this file with autoconf to create configure.
 
 AC_PREREQ(2.57)
-AC_INIT([xorg-server], 1.7.4.901, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
-RELEASE_DATE="2010-01-23"
+AC_INIT([xorg-server], 1.7.4.902, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], xorg-server)
+RELEASE_DATE="2010-02-05"
 AC_CONFIG_SRCDIR([Makefile.am])
 AM_INIT_AUTOMAKE([dist-bzip2 foreign])
 AM_MAINTAINER_MODE
commit 219a0d8fb54f179c7ac8d5953585849ab65a778b
Author: Oldřich Jedlička <oldium.pro at seznam.cz>
Date:   Sun Jan 17 17:59:03 2010 +0100

    Allow driver to call DeleteInputDeviceRequest during UnInit
    
    When the input driver (like xf86-input-wacom) removes it's devices
    during a call to UnInit, the CloseDownDevices() cannot handle it. The
    "next" variable can become a pointer to freed memory.
    
    The patch introduces order-independent device freeing mechanism by
    remembering the already freed device ids. The devices can reorder any
    time during freeing. No device will be double-freed - if the removing
    failed for any reason; some implementations of DeleteInputDeviceRequest
    don't free the devices already.
    
    Signed-off-by: Oldřich Jedlička <oldium.pro at seznam.cz>
    Reviewed-by: Simon Thum <simon.thum at gmx.de>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 08b22c7faf97217ea4d497eec6624fc3dd916d9b)

diff --git a/dix/devices.c b/dix/devices.c
index 245a95b..ef199b7 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -878,13 +878,43 @@ CloseDevice(DeviceIntPtr dev)
 }
 
 /**
+ * Shut down all devices of one list and free all resources.
+ */
+static
+void
+CloseDeviceList(DeviceIntPtr *listHead)
+{
+    /* Used to mark devices that we tried to free */
+    Bool freedIds[MAXDEVICES];
+    DeviceIntPtr dev;
+    int i;
+
+    if (listHead == NULL)
+        return;
+
+    for (i = 0; i < MAXDEVICES; i++)
+        freedIds[i] = FALSE;
+
+    dev = *listHead;
+    while (dev != NULL)
+    {
+        freedIds[dev->id] = TRUE;
+        DeleteInputDeviceRequest(dev);
+
+        dev = *listHead;
+        while (dev != NULL && freedIds[dev->id])
+            dev = dev->next;
+    }
+}
+
+/**
  * Shut down all devices, free all resources, etc.
  * Only useful if you're shutting down the server!
  */
 void
 CloseDownDevices(void)
 {
-    DeviceIntPtr dev, next;
+    DeviceIntPtr dev;
 
     /* Float all SDs before closing them. Note that at this point resources
      * (e.g. cursors) have been freed already, so we can't just call
@@ -897,16 +927,8 @@ CloseDownDevices(void)
             dev->u.master = NULL;
     }
 
-    for (dev = inputInfo.devices; dev; dev = next)
-    {
-	next = dev->next;
-        DeleteInputDeviceRequest(dev);
-    }
-    for (dev = inputInfo.off_devices; dev; dev = next)
-    {
-	next = dev->next;
-        DeleteInputDeviceRequest(dev);
-    }
+    CloseDeviceList(&inputInfo.devices);
+    CloseDeviceList(&inputInfo.off_devices);
 
     CloseDevice(inputInfo.pointer);
     CloseDevice(inputInfo.keyboard);
commit a6a4c20121301905399c4e1c23980993bcbf2152
Author: Horst Wente <horst.wente at acm.org>
Date:   Wed Dec 30 19:35:20 2009 +0100

    xkb: make ctrl+alt+keypad + / ctrl+alt+keypad - work again (#25743)
    
    Video mode switching via keypad keys did not work
    
    Signed-off-by: Horst Wente <horst.wente at acm.org>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit b91cec26de367f75388e620772747b08eee34294)

diff --git a/xkb/xkmread.c b/xkb/xkmread.c
index 6623d1b..3c2df03 100644
--- a/xkb/xkmread.c
+++ b/xkb/xkmread.c
@@ -531,7 +531,13 @@ XkbAction               *act;
             act->devval.v2_ndx = wire.actionData[5];
             act->devval.v2_what = wire.actionData[6];
             break;
+
         case XkbSA_XFree86Private:
+            /* copy the kind of action */
+            strncpy((char*)act->any.data, (char*)wire.actionData,
+                    XkbAnyActionDataSize);
+            break ;
+
         case XkbSA_Terminate:
             /* no args, kinda (note: untrue for xfree86). */
             break;
commit a5b558d065e24880ff14b3781f27d1a9ea6094ab
Author: Oldřich Jedlička <oldium.pro at seznam.cz>
Date:   Tue Jan 12 19:15:06 2010 +0100

    Fix typo in updateSlaveDeviceCoords
    
    The index [0] for the second valuator looks bogus; fix it.
    
    Signed-off-by: Oldřich Jedlička <oldium.pro at seznam.cz>
    Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
    (cherry picked from commit 993e78d6c433f65bd8a87890a6bb6da480b2cdc4)

diff --git a/dix/getevents.c b/dix/getevents.c
index 2df32e8..18c6302 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -296,7 +296,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
                         &pDev->last.remainder[0], NULL, pDev->valuator->axes + 0, scr->width);
     if(pDev->valuator->numAxes > 1)
         pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1], pDev->last.remainder[1],
-                        &pDev->last.remainder[0], NULL, pDev->valuator->axes + 1, scr->height);
+                        &pDev->last.remainder[1], NULL, pDev->valuator->axes + 1, scr->height);
 
     /* calculate the other axis as well based on info from the old
      * slave-device. If the old slave had less axes than this one,
commit 5d34e78c81bfba3d14146ddfd8e714cdfd9a1692
Author: Robert Morell <rmorell at nvidia.com>
Date:   Thu Jan 21 12:38:47 2010 -0800

    Render: Fix request size verification
    
    RenderSetPictureClipRectangles and the Xinerama version of
    RenderChangePicture were using the wrong structure types for request
    size verification.
    
    Signed-off-by: Robert Morell <rmorell at nvidia.com>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit 8d6b1838330625b758ebc55bb0df1b425c5cefaf)

diff --git a/render/render.c b/render/render.c
index a32d797..10554ad 100644
--- a/render/render.c
+++ b/render/render.c
@@ -656,7 +656,7 @@ ProcRenderSetPictureClipRectangles (ClientPtr client)
     if (!pPicture->pDrawable)
         return BadDrawable;
 
-    nr = (client->req_len << 2) - sizeof(xRenderChangePictureReq);
+    nr = (client->req_len << 2) - sizeof(xRenderSetPictureClipRectanglesReq);
     if (nr & 4)
 	return BadLength;
     nr >>= 3;
@@ -2728,7 +2728,7 @@ PanoramiXRenderChangePicture (ClientPtr client)
     int		    result = Success, j;
     REQUEST(xRenderChangePictureReq);
 
-    REQUEST_AT_LEAST_SIZE(xChangeWindowAttributesReq);
+    REQUEST_AT_LEAST_SIZE(xRenderChangePictureReq);
     
     VERIFY_XIN_PICTURE(pict, stuff->picture, client, DixWriteAccess,
 		       RenderErrBase + BadPicture);
commit 6f533994921725653306753f474c343fbb3b88a4
Author: Simon Thum <simon.thum at gmx.de>
Date:   Sat Jan 23 13:36:22 2010 +0100

    xfree86: remove man page reference inexistent acceleration profile
    
    not implemented in the X.org server 1.7
    
    Signed-off-by: Simon Thum <simon.thum at gmx.de>
    Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre
index 687ec76..f0a7373 100644
--- a/hw/xfree86/doc/man/xorg.conf.man.pre
+++ b/hw/xfree86/doc/man/xorg.conf.man.pre
@@ -904,7 +904,6 @@ is constructed. This is mainly a matter of personal preference.
 .B  " 4      simple (normal when slow, otherwise accelerated)"
 .B  " 5      power (power function)"
 .B  " 6      linear (more speed, more acceleration)"
-.B  " 7      limited (like linear, but maxes out at threshold)"
 .fi
 .RE
 .TP 7
commit 1c126ba53161933fa1a756e696e98f1395dfa61a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Jan 30 14:49:02 2010 -0800

    XQuartz: Attatch a stub display when CoreGraphics reports no displays.
    
    This is half of the required changes to address the "stuck mouse pointer"
    bug that occurs when X11 launches while the displays are asleep.  The
    remainder of the fix is part of libXplugin which needs to be updated to
    send XP_EVENT_DISPLAY_CHANGED when the display wakes up.  If you don't
    have a recent enough libXplugin (expected in 2.5.0_beta2 or later), you
    can cause this event to be sent by changing your display resolution (or
    you could just start X11.app with your screens awake).
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
    (cherry picked from commit 52456c602c3cdd7d5eac677889a18fad37dfb7ae)

diff --git a/hw/xquartz/xpr/xprScreen.c b/hw/xquartz/xpr/xprScreen.c
index 22a727e..735b2ba 100644
--- a/hw/xquartz/xpr/xprScreen.c
+++ b/hw/xquartz/xpr/xprScreen.c
@@ -184,7 +184,20 @@ xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height)
 
     // Find all the CoreGraphics displays
     CGGetActiveDisplayList(0, NULL, &displayCount);
+    DEBUG_LOG("displayCount: %d\n", (int)displayCount);
+
+    if(!displayCount) {
+        ErrorF("CoreGraphics has reported no connected displays.  Creating a stub 800x600 display.\n");
+        *x = *y = 0;
+        *width = 800;
+        *height = 600;
+        PseudoramiXAddScreen(*x, *y, *width, *height);
+        return;
+    }
+
     displayList = xalloc(displayCount * sizeof(CGDirectDisplayID));
+    if(!displayList)
+        FatalError("Unable to allocate memory for list of displays.\n");
     CGGetActiveDisplayList(displayCount, displayList, &displayCount);
 
     /* Get the union of all screens */
commit 734a6b9c2150ce38cf120e179cdac9d3c625434e
Author: Alan Coopersmith <alan.coopersmith at sun.com>
Date:   Tue Jan 26 22:25:04 2010 -0800

    Avoid segfaults in XF86VidMode GammaRamp functions if randr_crtc is NULL
    
    Fixes crash when xscreensaver tries to use GammaRamp calls to fade out
    http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6915712
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>
    Reviewed-by: Keith Packard <keithp at keithp.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>

diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index 08f557c..edd5ae9 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -1004,12 +1004,14 @@ xf86ChangeGammaRamp(
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
 
-	if (crtc->gammaSize != size)
-	    return BadValue;
+	if (crtc) {
+	    if (crtc->gammaSize != size)
+		return BadValue;
 
-	RRCrtcGammaSet(crtc, red, green, blue);
+	    RRCrtcGammaSet(crtc, red, green, blue);
 
-	return Success;
+	    return Success;
+	}
     }
 
     if(CMapScreenKey == NULL)
@@ -1077,7 +1079,8 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
 
-	return crtc->gammaSize;
+	if (crtc)
+	    return crtc->gammaSize;
     }
 
     if(CMapScreenKey == NULL) return 0;
@@ -1106,17 +1109,19 @@ xf86GetGammaRamp(
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
 	RRCrtcPtr crtc = config->output[config->compat_output]->crtc->randr_crtc;
 
-	if (crtc->gammaSize < size)
-	    return BadValue;
+	if (crtc) {
+	    if (crtc->gammaSize < size)
+		return BadValue;
 
-	if (!RRCrtcGammaGet(crtc))
-	    return BadImplementation;
+	    if (!RRCrtcGammaGet(crtc))
+		return BadImplementation;
 
-	memcpy(red, crtc->gammaRed, size * sizeof(*red));
-	memcpy(green, crtc->gammaGreen, size * sizeof(*green));
-	memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
+	    memcpy(red, crtc->gammaRed, size * sizeof(*red));
+	    memcpy(green, crtc->gammaGreen, size * sizeof(*green));
+	    memcpy(blue, crtc->gammaBlue, size * sizeof(*blue));
 
-	return Success;
+	    return Success;
+	}
     }
 
     if(CMapScreenKey == NULL) 
commit b47231b2fd4e403403945d6da6119398b16f385d
Author: Aaron Zang <Aaron.Zang at Sun.COM>
Date:   Mon Dec 14 17:55:46 2009 -0800

    Solaris: Avoid switching to inactive VT's
    
    Fix for OpenSolaris bug 6876992: "[vconsole] Ctrl+Alt+F12 switchs to blank
    console screen with hotkeys property turned-off"
    http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6876992
    
    Xorg needs to do sanity test for the VT it is commanded to switch to.
    If the VT is not opened by any process, discard the switching request.
    
    The changes also contain the fix for some flaws discovered when
    getting the new gdm to run.
    
    Signed-off-by: Aaron Zang <Aaron.Zang at Sun.COM>
    Signed-off-by: Alan Coopersmith <alan.coopersmith at sun.com>

diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
index 8cd765a..8e6a15b 100644
--- a/hw/xfree86/common/xf86Events.c
+++ b/hw/xfree86/common/xf86Events.c
@@ -202,8 +202,16 @@ xf86ProcessActionEvent(ActionEvent action, void *arg)
 	    vtno--;
 #endif
 #if defined(sun)
-	    if (vtno == xf86Info.vtno)
+	    if (vtno == xf86Info.vtno) {
 		break;
+	    } else {
+		struct vt_stat state;
+		if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &state) < 0)
+			break;
+
+		if ((state.v_state & (1 << vtno)) == 0)
+			break;
+	    }
 
 	    xf86Info.vtRequestsPending = TRUE;
 	    xf86Info.vtPendingNum = vtno;
diff --git a/hw/xfree86/os-support/solaris/sun_VTsw.c b/hw/xfree86/os-support/solaris/sun_VTsw.c
index ded2f27..7f4e08e 100644
--- a/hw/xfree86/os-support/solaris/sun_VTsw.c
+++ b/hw/xfree86/os-support/solaris/sun_VTsw.c
@@ -38,17 +38,27 @@
  * Handle the VT-switching interface for Solaris/OpenSolaris
  */
 
+static int xf86VTPruneDoor = 0;
+
 void
-xf86VTRequest(int sig)
+xf86VTRelease(int sig)
 {
-	if (xf86Info.vtPendingNum != -1)
+	if (xf86Info.vtPendingNum == -1)
 	{
-		ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
-		xf86Info.vtPendingNum = -1;
-
+		xf86VTPruneDoor = 1;
+		xf86Info.vtRequestsPending = TRUE;
 		return;
 	}
 
+	ioctl(xf86Info.consoleFd, VT_RELDISP, 1);
+	xf86Info.vtPendingNum = -1;
+
+	return;
+}
+
+void
+xf86VTAcquire(int sig)
+{
 	xf86Info.vtRequestsPending = TRUE;
 	return;
 }
@@ -68,6 +78,12 @@ xf86VTSwitchAway(void)
 
 	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;
diff --git a/hw/xfree86/os-support/solaris/sun_init.c b/hw/xfree86/os-support/solaris/sun_init.c
index 2c569f0..5846866 100644
--- a/hw/xfree86/os-support/solaris/sun_init.c
+++ b/hw/xfree86/os-support/solaris/sun_init.c
@@ -39,6 +39,8 @@ static Bool Protect0 = FALSE;
 static int VTnum = -1;
 static int xf86StartVT = -1;
 static int vtEnabled = 0;
+extern void xf86VTAcquire(int);
+extern void xf86VTRelease(int);
 #endif
 
 /* Device to open as xf86Info.consoleFd */
@@ -137,7 +139,8 @@ xf86OpenConsole(void)
 	    else
 	    {
 		if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
-		    (xf86Info.vtno == -1)) {
+		    (xf86Info.vtno == -1))
+		{
 		    FatalError("xf86OpenConsole: Cannot find a free VT\n");
 		}
 	    }
@@ -146,7 +149,8 @@ xf86OpenConsole(void)
 	    snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
 	}
 
-	if (fd != -1) {
+	if (fd != -1)
+	{
 	    close(fd);
 	}
 
@@ -178,11 +182,12 @@ xf86OpenConsole(void)
 	    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
 		FatalError("xf86OpenConsole: VT_GETMODE failed\n");
 
-	    OsSignal(SIGUSR1, xf86VTRequest);
+	    OsSignal(SIGUSR1, xf86VTAcquire);
+	    OsSignal(SIGUSR2, xf86VTRelease);
 
 	    VT.mode = VT_PROCESS;
-	    VT.relsig = SIGUSR1;
 	    VT.acqsig = SIGUSR1;
+	    VT.relsig = SIGUSR2;
 
 	    if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0)
 		FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
@@ -204,7 +209,8 @@ xf86OpenConsole(void)
     else /* serverGeneration != 1 */
     {
 #ifdef HAS_USL_VTS
-	if (vtEnabled) {
+	if (vtEnabled)
+	{
 	    /*
 	     * Now re-get the VT
 	     */
@@ -285,7 +291,8 @@ xf86CloseConsole(void)
 #endif
 
 #ifdef HAS_USL_VTS
-    if (vtEnabled == 1) {
+    if (vtEnabled)
+    {
 	if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
 	{
 	    VT.mode = VT_AUTO;		/* Set default vt handling */
commit 66b6e2fd49fdc650703e56aa176a902e4921251c
Author: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
Date:   Wed Jan 27 14:03:03 2010 -0800

    Fix source pictures getting random transforms after 2d6a8f668342a5190cdf43b5.
    
    *xoff and *yoff were uninitialized for source-only pictures.x
    
    Signed-off-by: Pierre-Loup A. Griffais <pgriffais at nvidia.com>
    Reviewed-by: Aaron Plattner <aplattner at nvidia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit a6bd5d2e482a5aa84acb3d4932e2a166d8670ef1)

diff --git a/fb/fbpict.c b/fb/fbpict.c
index f9f4343..c046bae 100644
--- a/fb/fbpict.c
+++ b/fb/fbpict.c
@@ -453,6 +453,7 @@ image_from_pict_18 (PicturePtr pict, Bool has_clip, int *xoff, int *yoff)
 	    else if (sp->type == SourcePictTypeConical)
 		image = create_conical_gradient_image (gradient);
 	}
+	*xoff = *yoff = 0;
     }
     
     if (image)
commit a191318f8dde2a4ff47c051244e8c88e8f92883a
Author: Christian Zander <chzander at nvidia.com>
Date:   Mon Jan 11 12:29:07 2010 -0800

    x86emu: Respect the LEA 67h address size prefix.
    
    Signed-off-by: Christian Zander <chzander at nvidia.com>
    Signed-off-by: Aaron Plattner <aplattner at nvidia.com>
    Tested-by: Tiago Vignatti <tiago.vignatti at nokia.com>
    Signed-off-by: Keith Packard <keithp at keithp.com>
    (cherry picked from commit f57bc0ede8e018c7e264b917927c42a018cd1d5a)

diff --git a/hw/xfree86/x86emu/ops.c b/hw/xfree86/x86emu/ops.c
index 37ae2c9..21a0347 100644
--- a/hw/xfree86/x86emu/ops.c
+++ b/hw/xfree86/x86emu/ops.c
@@ -6567,42 +6567,62 @@ Handles opcode 0x8d
 static void x86emuOp_lea_word_R_M(u8 X86EMU_UNUSED(op1))
 {
     int mod, rl, rh;
-    u16 *srcreg;
     uint destoffset;
 
-/*
- * TODO: Need to handle address size prefix!
- *
- * lea  eax,[eax+ebx*2] ??
- */
-    
     START_OF_INSTR();
     DECODE_PRINTF("LEA\t");
     FETCH_DECODE_MODRM(mod, rh, rl);
     switch (mod) {
     case 0:
-        srcreg = DECODE_RM_WORD_REGISTER(rh);
-        DECODE_PRINTF(",");
-        destoffset = decode_rm00_address(rl);
-        DECODE_PRINTF("\n");
-        TRACE_AND_STEP();
-        *srcreg = (u16)destoffset;
+        if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+            u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm00_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u32)destoffset;
+        } else {
+            u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm00_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u16)destoffset;
+        }
         break;
     case 1:
-        srcreg = DECODE_RM_WORD_REGISTER(rh);
-        DECODE_PRINTF(",");
-        destoffset = decode_rm01_address(rl);
-        DECODE_PRINTF("\n");
-        TRACE_AND_STEP();
-        *srcreg = (u16)destoffset;
+        if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+            u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm01_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u32)destoffset;
+        } else {
+            u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm01_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u16)destoffset;
+        }
         break;
     case 2:
-        srcreg = DECODE_RM_WORD_REGISTER(rh);
-        DECODE_PRINTF(",");
-        destoffset = decode_rm10_address(rl);
-        DECODE_PRINTF("\n");
-        TRACE_AND_STEP();
-        *srcreg = (u16)destoffset;
+        if (M.x86.mode & SYSMODE_PREFIX_ADDR) {
+            u32 *srcreg = DECODE_RM_LONG_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm10_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u32)destoffset;
+        } else {
+            u16 *srcreg = DECODE_RM_WORD_REGISTER(rh);
+            DECODE_PRINTF(",");
+            destoffset = decode_rm10_address(rl);
+            DECODE_PRINTF("\n");
+            TRACE_AND_STEP();
+            *srcreg = (u16)destoffset;
+        }
         break;
     case 3:                     /* register to register */
         /* undefined.  Do nothing. */


More information about the xorg-commit mailing list