Commit Graph

65 Commits

Author SHA1 Message Date
Alan Coopersmith
23e83724df Fix spelling/wording issues
Most (but not all) of these were found by using
  codespell --builtin clear,rare,usage,informal,code,names
but not everything reported by that was fixed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2020-07-05 13:07:33 -07:00
Sven Joachim
47387916fb Fix various spelling errors 2019-10-01 17:05:28 +00:00
Adam Jackson
15d91df474 x86emu: Teach the debug code about varargs
With -Wformat-nonliteral and a debug build you'd get yelled at here:

../hw/xfree86/x86emu/x86emu/debug.h:188:9: warning: format not a string literal, argument types not checked [-Wformat-nonliteral]

To fix this, rewrite the printf code to actually use varargs and the
appropriate format attribute. All callers of DECODE_PRINTF() pass a
string with no % specifiers, so we pass that as the argument to
printf("%s"). For DECODE_PRINTF2() we just pass the args through.

Signed-off-by: Adam Jackson <ajax@redhat.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2018-01-16 16:08:38 -05:00
Lyude Paul
cbca18c551 x86emu: Fix type conversion warnings on x86_64 with DEBUG
Warnings come from the fact that PRIx32 is not used for printing 32 bit
values instead of "%lx", and "%lx" evaluates to a 64 bit long on 64 bit
systems while PRIx32 always evaluates to the right type for the
respective arch.

Signed-off-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2017-10-20 13:15:32 -04:00
Eric Anholt
1549e30372 Add a Meson build system alongside autotools.
This is a work in progress that builds Xvfb, Xephyr, Xwayland, Xnest,
and Xdmx so far.  The outline of Xquartz/Xwin support is in tree, but
hasn't been built yet.  The unit tests are also not done.

The intent is to build this as a complete replacement for the
autotools system, then eventually replace autotools.  meson is faster
to generate the build, faster to run the bulid, shorter to write the
build files in, and less error-prone than autotools.

v2: Fix indentation nits, move version declaration to project(), use
    existing meson_options for version-config.h's vendor name/web.

Signed-off-by: Eric Anholt <eric@anholt.net>
Acked-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-04-26 15:25:27 -07:00
Andreas Schwab
23dfa01729 x86emu: Change include order to avoid conflict with system header
R_SP is also defined in <sys/ucontext.h> on m68k.  Also remove duplicate
definitions.

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Andreas Schwab <schwab@suse.de>
2016-04-29 11:05:38 -04:00
Adam Jackson
2a52c06e23 x86emu: Squash a warning
Apologies, should have caught this one when applying the previous x86emu
patch.

Signed-off-by: Adam Jackson <ajax@redhat.com>
2015-12-07 17:05:39 -05:00
Julian Pidancet
59b618227e x86emu: Correctly handle 0x66 prefix for some instructions
(Sorry for double posting)

I repost this patch because I havn't got any replies from maintainers
since I posted the initial patch back in March.

Some instructions are not emulated correctly by x86emu when they
are prefixed by the 0x66 opcode.
I've identified problems in the emulation of these intructions: ret,
enter, leave, iret and some forms of call.

Most of the time, the problem is that these instructions should push or
pop 32-bit values to/from the stack, instead of 16bit, when they are
prefixed by the 0x66 special opcode.

The SeaBIOS project aims to produce a complete legacy BIOS
implementation as well as a VGA option ROM, entirely written in C and
using the GCC compiler.

In 16bit code produced by the GCC compiler, the 0x66 prefix is used
almost everywhere. This patch is necessary to allow the SeaBIOS VGA
option ROM to function with Xorg when using the vesa driver.

SeaBIOS currently use postprocessing on the ROM assembly output to
replace the affected instruction with alternative unaffected instructions.
This is obviously not very elegant, and this fix in x86emu would be
more appropriate.

v2: - Decrement BP instead of EBP in accordance with the Intel Manual
    - Assign EIP instead of IP when poping the return address from the
    stack in 32-bit operand size mode in ret_far_IMM, ret_far, and iret
    - When poping EFLAGS from the stack in iret in 32-bit operand size
    mode, apply some mask to preserve Read-only flags.

v3: - Rebase

Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
2015-12-07 14:49:36 -05:00
Eric Anholt
e6f8a0340b x86emu: Fix some set-but-not-used warnings.
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
2015-09-23 15:01:25 -04:00
Peter Hutterer
732fd7e571 Drop trailing whitespaces
sed -i "s/[ ]\+$//g" **/*.(c|h)

happy reviewing...
git diff -w is an empty diff.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2014-11-12 10:25:00 +10:00
Adam Jackson
4433bc6d53 x86emu: Undefine _NO_INLINE
Never defined by the server.

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2014-09-26 15:27:18 -04:00
Keith Packard
07b03e721e xfree86: Fix -Wshadow warnings
Just rename variables to eliminate -Wshadow warnings.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
2014-01-22 19:56:31 -08:00
Keith Packard
2a93e75ff8 xfree86/int10: mark printk as _X_ATTRIBUTE_PRINTF
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:50 -08:00
Keith Packard
c78be3a4b7 xfree86 warning reduction
This gets the easy warnings, mostly constant string problems.

Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2014-01-12 10:14:49 -08:00
Alan Coopersmith
c4c154d18e Avoid conflicts with Solaris <sys/regset.h> defines that clash with our names
When building on Solaris with _XOPEN_SOURCE set to a recent XPG release,
<stdlib.h> and other core headers start including <sys/regset.h>, which
has a bunch of unfortunately named macros such as "CS", "ES", etc. for
x86 & x64 registers which clash with existing variable & struct member
names in Xorg - so #undef these so they don't interfere with our use.

(Yes, have filed a bug against the system headers for exposing these,
 but this solves the problem for building on existing releases.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2013-11-12 21:03:53 +09:00
Peter Hutterer
bbef8e46f2 Replace INCLUDES with AM_CPPFLAGS
newer automake gets quite noisy about this.
hw/xfree86/ddc/Makefile.am:7: warning:
'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
and many more of these.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2013-08-06 13:08:13 +10:00
Keith Packard
9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Alan Coopersmith
71efd86828 x86emu: constify debug strings
Strings are all pointers to literal constants, just used as input
to printf calls when debugging is enabled.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2011-12-12 17:03:11 -08:00
Alan Coopersmith
05d8a7f7a7 Convert a bunch of sprintf to snprintf calls
This batch is the straightforward set - others are more complex and
need more analysis to determine right size to pass.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
2011-11-23 12:15:06 -08:00
Jamey Sharp
60b4bd181b x86emu: There is no NO_INLINE implementation of unaligned access here.
Patch produced with:
	unifdef -UNO_INLINE -B

This change isn't relevant to the similar code in
hw/xfree86/common/compiler.h, because x86emu is expected to someday move
out of xserver entirely and so should not depend on any xserver headers.
Also, some platforms apparently do have NO_INLINE versions of
compiler.h.

Signed-off-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2011-09-15 10:07:11 -05:00
Adam Jackson
bb18f27715 x86emu: Fix more mis-decoding of the data prefix
cc2c73ddcb4370a7c3ad439cda4da825156c26c9's three-cent titanium tax
doesn't go too far enough.  Fix the rest of the call and jmp
instructions to handle the data prefix correctly.

Reference: Intel 64 and IA-32 Architectures Software Developer's Manual
Volume 2A: Instruction Set Reference, A-M

http://www.intel.com/Assets/PDF/manual/253666.pdf

Reviewed-by: Julien Cristau <jcristau@debian.org>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2011-01-04 09:23:52 -05:00
Luc Verhaegen
cc2c73ddcb x86emu: fix jump_near_IMM to handle DATA: flag correctly.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=24348

Before (data flag ignored -> broken):
66                  DATA:
e944f1              JMP       1ff6

After (fixed):
66                  DATA:
e944f1ffff          JMP       00001ff8

This subtle difference in the length of decoded instruction meant
that the VBE call jumped to the routine setting AX=0x14F (VBE Failed)
instead of the routine that set AX=0x4F (VBE success).

The ability to run the same code in vm86 significantly aided the
debugging of this issue. Those X.org developers who would like to drop
vm86 better take special care towards _all_ vesa bugs, as those will
expose further issues.

Patch applies easily to even xserver 1.4.2.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
Tested-by: Luc Verhaegen <libv@skynet.be>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-11-10 14:56:57 -08:00
Alan Coopersmith
82cf3a4ae0 Convert x86emu fixed size int typedefs to use stdint types
Fixes x86emu builds when using non-gnu compilers now that u64 is required

Before this fix, the u64 type would not be defined, causing
x86emu/sys.c to fail to build:
"sys.c", line 102: syntax error before or at: ldq_u
"sys.c", line 102: syntax error before or at: *

Since Keith requested using <stdint.h>, converted all the x86emu
typedefs to use the stdint types.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Acked-by: Matt Turner <mattst88@gmail.com>
Acked-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-04-07 16:18:24 -07:00
Matt Turner
bbae92795c Replace assembly with generic unaligned access code
Removes Alpha assembly, and probably works around unaligned accesses on
other sensitive platforms.

Signed-off-by: Matt Turner <mattst88@gmail.com>
Acked-by: Adam Jackson <ajax@redhat.com>
Compiled-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-03-03 20:02:49 -08:00
Matt Turner
2d40f22d1e Use C-style comments in x86emu
Signed-off-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-02-17 23:13:04 -08:00
Christian Zander
f57bc0ede8 x86emu: Respect the LEA 67h address size prefix.
Signed-off-by: Christian Zander <chzander@nvidia.com>
Signed-off-by: Aaron Plattner <aplattner@nvidia.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-27 13:48:37 -08:00
Tiago Vignatti
74ab27f64a Revert "Make sys.c use unaligned access functions provided in compiler."
This reverts commit da923d0bc1.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-01-08 12:51:21 -08:00
Alan Coopersmith
dd2c83d03e Fix builds with --with-int10=stub
Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
Acked-by: Adam Jackson <ajax@redhat.com>
2009-12-15 10:23:16 -08:00
Matt Turner
da923d0bc1 Make sys.c use unaligned access functions provided in compiler.
Favorite deleted line was definitely
	/* to cope with broken egcs-1.1.2 :-(((( */

Signed-off-by: Matt Turner <mattst88@gmail.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2009-11-01 12:33:14 -08:00
Tiago Vignatti
d908ee6e54 Revert "Make sys.c use compiler.h unaligned access functions"
This reverts commit 1b30545c04.

Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2009-09-11 15:31:04 +10:00
Matt Turner
1b30545c04 Make sys.c use compiler.h unaligned access functions
Signed-off-by: Matt Turner <mattst88@gmail.com>
2009-08-31 16:16:02 -04:00
Paulo Cesar Pereira de Andrade
5a8068b390 Convert libx86emu.a to a "libtool convenience library". 2008-12-07 18:31:32 -02:00
Julien Cristau
102c4dac7c x86emu: fix sparse warnings
ops2.c:113:18: warning: Using plain integer as NULL pointer
ops2.c:207:18: warning: Using plain integer as NULL pointer
2008-10-26 13:17:31 +01:00
Adam Jackson
856db05b58 Unifdef sgi. 2008-07-23 13:37:42 -04:00
Adam Jackson
2e3c43d306 Assume __GNUC__ >= 3.
gcc 3.0 was seven years ago.  Get with the times.
2008-07-23 11:35:06 -04:00
Julien Cristau
9ed9d98dec x86emu: fix build, fallout from 9719354 2008-06-24 22:36:32 +02:00
Adam Jackson
9719354ae0 Check for __amd64__, not __x86_64__.
Spiritual revert of 1fa4de80fc.  Intel's C
compiler claims to be gcc-compatible; if they're not defining the same
macros as gcc then that's their bug, not ours.  Even if we were to do
this aliasing we should do it once and for all in servermd.h.
2008-06-24 14:37:06 -04:00
Adam Jackson
c8d066a151 Implement bswap in x86emu.
Yes, this is a 486+ instruction and thus not strictly legal in vm86
mode, but enough BIOSes use it (looking at you VIA) that we might as
well implement it.
2008-06-23 14:00:50 -04:00
Matt Turner
1fa4de80fc Check for __x86_64__ when we check for __amd64__
It seems Intel C Compiler neglects to define __amd64__, __amd64, or
amd64, but *does* define __x86_64__.
2008-04-12 20:39:18 +02:00
Adam Jackson
34b69e3bc0 Fix distcheck.
(cherry picked from commit 2a47accff8)
2008-03-05 23:57:15 -05:00
Bart Trojanowski
66f8001b61 X86EMU: handle CPUID instruction
After trying to switch from X to VT (or just quit) the video-amd driver
attempts to issue INT 10/0 to go to mode 3 (VGA).  The emulator, running
the BIOS code, would then spit out:

        c000:0282: A2 ILLEGAL EXTENDED X86 OPCODE!

The opcode was 0F A2, or CPUID; it was not implemented in the emulator.
This simple patch, against 1.3.0.0, handles the CPUID instruction in one of
two ways:
 1) if ran on __i386__ or __x86_64__ then it calls the CPUID instruction
     directly.
 2) if ran elsewhere it returns a canned 486dx4 set of values for
     function 1.

This fix allows the video-amd driver to switch back to console mode,
with the GSW BIOS.

Thanks to Symbio Technologies for funding my work, and ThinCan for
providing hardware :)

Signed-off-by: Bart Trojanowski <bart@jukie.net>
Acked-by: Eric Anholt <eric@anholt.net>
2008-02-08 10:48:40 -08:00
Adam Jackson
028a00bc51 Make x86emu's I/O cycle tracing more useful.
Print debug messages only when the appropriate debug bit is set in the
8086 state vector, so you can focus in on the call you're actually
interested in.
2007-07-02 18:41:55 -04:00
Matthias Hopf
2fe74ef339 Fix calculations in x86 emulator for the long long case (Andreas Schwab). 2007-03-15 16:56:01 +01:00
Aaron Plattner
c4b7e9d1c1 Add an RDTSC implementation to the x86 emulator.
This instruction is being used in some debug VBIOSes.  This implementation
doesn't even try to be accurate.  Instead, it just increments the counter by a
fixed amount every time an rdtsc instruction in encountered, to avoid divides by
zero.
2007-02-06 15:45:05 -08:00
Aaron Plattner
66fa87292e Fix BSF and BSR instructions in the x86 emulator.
Patch courtesy of Michael Yaroslavtsev.
2007-01-03 13:47:01 -08:00
Keith Packard
2be1ac15ae Remove smashing of CFLAGS from server build.
CFLAGS is a user variable, extracted from the environment at configure time
and settable by the user at build time. We must not override this variable.
2006-09-18 12:11:18 -07:00
Felix Kuehling
21f7f2fb11 Enable correct handling of the BTS instruction (opcode 0f ab) The code was
there but #ifdefed out. Insead of BTS, BT was executed. This patch
    enables the BTS function and hooks it up the the correct opcode. (ATI
    Technologies Inc.)
2006-03-15 18:43:32 +00:00
Eric Anholt
c3d1403672 Remove libcwrapper usage from xorg server modules. The libcwrapper is only
of (marginal) use in the drivers, and that usage remains.
2006-02-10 22:00:30 +00:00
Kevin E Martin
7c00afd0ec Define XFree86Server only where it is required. 2005-12-02 06:02:45 +00:00
Kevin E Martin
da5d66f2ff Fix usage of XFree86LOADER/XFree86Module/IN_MODULE and update loadable
module builds to reflect this change.
2005-11-29 16:39:33 +00:00