Skip to contentSkip to conversation

PATCH: solaris-sparc-slirp fix

Qemu-devel Ben Taylor 3 participants 5 messages May 1, 2006

lore
Share & tools
lore

Ben Taylor

author
#0 lore raw

The following patch, along with the previous solaris patch posted, booted DamnSmallLinux (x86) on a Sun Ultra10 Workstation running Solaris 9, using the -vnc display.

Other than the colors being GBR instead of RGB (and I hear a fix for that in the vnc code is in development) it works.

Ben

slirp/slirp.c renamed from slirp/slirp.c.ORIG +10 -0
@@ -137,6 +137,16 @@
     }
 #endif
 
+#if defined(HOST_SOLARIS) && defined(__sparc__)
+    /*
+     * Tell the kernel to fix unaligned accesses for us.
+     *
+     * The slirp code accesses at least |struct ip| structures
+     * from unaligned addresses.
+     */
+    asm("ta 6");
+#endif
+
     link_up = 1;
 
     if_init();
#1 lore raw

Ben,

You can use the patch I posted here recently to get QEMU to fix the BGR problem internally. It doesn't have to be done at the VNC level - and in fact, this way, you can use it on the Solaris native X server (or even SunRays) in 24-bit color mode. I am attaching a new version of the patch, complete with the detection logic (to make it automatic), against today's CVS.

My original post:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00181.html

The last (and fast) version:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00195.html

An additional hack to get SDL to configure this automatically, without needing the -bgr option on the command-line:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00230.html

Maybe Fabrice or Paul can commit this since I addressed all the original issues, but have yet to hear feedback on it. It's working fine for myself and for my customers using SunRays for several weeks now. The only issue is cirrus VGA in 16-bit mode seems to do some optimization that bypasses the swapping code. regular VGA or cirrus VGA in 24-bit mode (on the guest) works fine.

Regards,

Leo Reiter

Quoted 4 lines · Ben Taylor

<snip>
Other than the colors being GBR instead of RGB (and I hear a fix for that in the vnc code is in development) it works.
<snip>

Signature · 8 lines
Leonardo E. Reiter
Vice President of Product Development, CTO

Win4Lin, Inc.
Virtual Computing that means Business
Main: +1 512 339 7979
Fax: +1 512 532 6501
http://www.win4lin.com

Index: sdl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/sdl.c,v
retrieving revision 1.26

sdl.c +5 -0
diff -a -u -r1.26 sdl.c
@@ -548,4 +548,9 @@
         gui_fullscreen_initial_grab = 1;
         sdl_grab_start();
     }
+
+    /* guess to use BGR mode by seeing if the blue color mask is greater than
+     * the red color mask, indicating that blue comes before red */
+    if (screen->format->Bmask > screen->format->Rmask)
+        bgr_display_enabled = 1;
 }

Index: vl.c
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.c,v
retrieving revision 1.184

vl.c +7 -0
diff -a -u -r1.184 vl.c
@@ -130,6 +130,7 @@
 int vm_running;
 int rtc_utc = 1;
 int cirrus_vga_enabled = 1;
+int bgr_display_enabled = 0;
 #ifdef TARGET_SPARC
 int graphic_width = 1024;
 int graphic_height = 768;
@@ -4603,6 +4604,7 @@
            "-m megs         set virtual RAM size to megs MB [default=%d]\n"
            "-smp n          set the number of CPUs to 'n' [default=1]\n"
            "-nographic      disable graphical output and redirect serial I/Os to console\n"
+           "-bgr            invert colors for HOSTS using certain SPARC frame buffers\n"
 #ifndef _WIN32
 	   "-k language     use keyboard layout (for example \"fr\" for French)\n"
 #endif
@@ -4757,6 +4759,7 @@
     QEMU_OPTION_cirrusvga,
     QEMU_OPTION_g,
     QEMU_OPTION_std_vga,
+    QEMU_OPTION_bgr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_serial,
     QEMU_OPTION_parallel,
@@ -4835,6 +4838,7 @@
     { "full-screen", 0, QEMU_OPTION_full_screen },
     { "pidfile", HAS_ARG, QEMU_OPTION_pidfile },
     { "win2k-hack", 0, QEMU_OPTION_win2k_hack },
+    { "bgr", 0, QEMU_OPTION_bgr },
     { "usbdevice", HAS_ARG, QEMU_OPTION_usbdevice },
     { "smp", HAS_ARG, QEMU_OPTION_smp },
     { "vnc", HAS_ARG, QEMU_OPTION_vnc },
@@ -5338,6 +5342,9 @@
             case QEMU_OPTION_std_vga:
                 cirrus_vga_enabled = 0;
                 break;
+            case QEMU_OPTION_bgr:
+                bgr_display_enabled = 1;
+                break;
             case QEMU_OPTION_g:
                 {
                     const char *p;

Index: vl.h
===================================================================
RCS file: /cvsroot/qemu/qemu/vl.h,v
retrieving revision 1.116

vl.h +1 -0
diff -a -u -r1.116 vl.h
@@ -135,6 +135,7 @@
 extern int bios_size;
 extern int rtc_utc;
 extern int cirrus_vga_enabled;
+extern int bgr_display_enabled;
 extern int graphic_width;
 extern int graphic_height;
 extern int graphic_depth;

Index: hw/vga.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/vga.c,v
retrieving revision 1.42

vga.c +78 -10

180 lines not on this page · raw message

Index: hw/vga_template.h
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/vga_template.h,v
retrieving revision 1.11

vga_template.h +46 -13

133 lines not on this page · raw message

#2 lore raw

Sorry,

I should add that the automatic detection is only done for SDL. It should be easy enough to add to the VNC side of things, but I didn't get around to it yet. You can use the -bgr command-line option to qemu in the VNC case to set it manually.

- Leo Reiter

Quoted 8 lines · Leonardo E. Reiter

Ben,

You can use the patch I posted here recently to get QEMU to fix the BGR problem internally. It doesn't have to be done at the VNC level - and in fact, this way, you can use it on the Solaris native X server (or even SunRays) in 24-bit color mode. I am attaching a new version of the patch, complete with the detection logic (to make it automatic), against today's CVS.

Signature · 8 lines
Leonardo E. Reiter
Vice President of Product Development, CTO

Win4Lin, Inc.
Virtual Computing that means Business
Main: +1 512 339 7979
Fax: +1 512 532 6501
http://www.win4lin.com
#3 lore raw
In reply to Leonardo E. Reiter

Hi,

I did not accept your patch for two reasons:

1) You changed the guest vga frame buffer format and I don't think this is what you wanted (it can be useful to emulate VGA on big endian guests though - the current implementation for ppc guests is a hack). What is needed is to swap the host pixel format.

2) You added support for RGB swapping for 8/15/16 depths and I am not sure this is useful. Endianness swapping would be more useful for 15/16 depths.

Fabrice.

Quoted 34 lines · Leonardo E. Reiter

Ben,

You can use the patch I posted here recently to get QEMU to fix the BGR problem internally. It doesn't have to be done at the VNC level - and in fact, this way, you can use it on the Solaris native X server (or even SunRays) in 24-bit color mode. I am attaching a new version of the patch, complete with the detection logic (to make it automatic), against today's CVS.

My original post:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00181.html

The last (and fast) version:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00195.html

An additional hack to get SDL to configure this automatically, without needing the -bgr option on the command-line:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00230.html

Maybe Fabrice or Paul can commit this since I addressed all the original issues, but have yet to hear feedback on it. It's working fine for myself and for my customers using SunRays for several weeks now. The only issue is cirrus VGA in 16-bit mode seems to do some optimization that bypasses the swapping code. regular VGA or cirrus VGA in 24-bit mode (on the guest) works fine.

Regards,

Leo Reiter

Ben Taylor wrote:

#4 lore raw

Thanks for the explanation Fabrice... I guess I am not sure how to swap the host pixel format without taking a performance penalty. So for now I just offer the patch I made in case anyone else finds it useful for their own needs. Maybe I'll revisit this in the future when I have more time and come up with something more general. Right now, it does the job with no performance hit for guests running on little Endian hosts, trying to blit on to Sun X servers in 24-bit mode.

I agree that the 8/15/16 bit stuff is probably not too relevant - I just implemented it since it was implemented in the original patch (written by someone else) that I adapted.

- Leo Reiter

Quoted 58 lines · Fabrice Bellard

Hi,

I did not accept your patch for two reasons:

1) You changed the guest vga frame buffer format and I don't think this is what you wanted (it can be useful to emulate VGA on big endian guests though - the current implementation for ppc guests is a hack). What is needed is to swap the host pixel format.

2) You added support for RGB swapping for 8/15/16 depths and I am not sure this is useful. Endianness swapping would be more useful for 15/16 depths.

Fabrice.

Quoted 29 lines · Leonardo E. Reiter

Ben,

You can use the patch I posted here recently to get QEMU to fix the BGR problem internally. It doesn't have to be done at the VNC level - and in fact, this way, you can use it on the Solaris native X server (or even SunRays) in 24-bit color mode. I am attaching a new version of the patch, complete with the detection logic (to make it automatic), against today's CVS.

My original post:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00181.html

The last (and fast) version:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00195.html

An additional hack to get SDL to configure this automatically, without needing the -bgr option on the command-line:

http://lists.gnu.org/archive/html/qemu-devel/2006-04/msg00230.html

Maybe Fabrice or Paul can commit this since I addressed all the original issues, but have yet to hear feedback on it. It's working fine for myself and for my customers using SunRays for several weeks now. The only issue is cirrus VGA in 16-bit mode seems to do some optimization that bypasses the swapping code. regular VGA or cirrus VGA in 24-bit mode (on the guest) works fine.

Quoted 5 lines

Regards,

Leo Reiter

Ben Taylor wrote:

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Signature · 8 lines
Leonardo E. Reiter
Vice President of Product Development, CTO

Win4Lin, Inc.
Virtual Computing that means Business
Main: +1 512 339 7979
Fax: +1 512 532 6501
http://www.win4lin.com