sdk/emulator/qemu.git
14 years agoalpha-linux-user: Fix brk error return.
Richard Henderson [Mon, 3 May 2010 17:07:49 +0000 (10:07 -0700)]
alpha-linux-user: Fix brk error return.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Nuke trailing whitespace.
Richard Henderson [Fri, 21 May 2010 15:30:35 +0000 (08:30 -0700)]
tcg-i386: Nuke trailing whitespace.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Use lea for three-operand add.
Richard Henderson [Fri, 21 May 2010 15:30:34 +0000 (08:30 -0700)]
tcg-i386: Use lea for three-operand add.

The result is shorter than the mov+add that TCG would
otherwise generate for us.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy lea.
Richard Henderson [Fri, 21 May 2010 15:30:33 +0000 (08:30 -0700)]
tcg-i386: Tidy lea.

Implement full modrm+sib addressing mode processing.
Use that in qemu_ld/st to output the LEA.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy xchg.
Richard Henderson [Fri, 21 May 2010 15:30:32 +0000 (08:30 -0700)]
tcg-i386: Tidy xchg.

Define and use OPC_XCHG_ax_r32.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy multiply.
Richard Henderson [Fri, 21 May 2010 15:30:31 +0000 (08:30 -0700)]
tcg-i386: Tidy multiply.

Define and use OPC_IMUL_GvEv{,Ib,Iz}.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy unary arithmetic.
Richard Henderson [Fri, 21 May 2010 15:30:30 +0000 (08:30 -0700)]
tcg-i386: Tidy unary arithmetic.

Define OPC_GRP3 and EXT3_FOO to match.  Use them instead of
bare constants.

Define OPC_GRP5 and rename the existing EXT_BAR to EXT5_BAR to
make it clear which extension should be used with which opcode.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy setcc.
Richard Henderson [Fri, 21 May 2010 15:30:29 +0000 (08:30 -0700)]
tcg-i386: Tidy setcc.

Define and use OPC_SETCC.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy ret.
Richard Henderson [Fri, 21 May 2010 15:30:28 +0000 (08:30 -0700)]
tcg-i386: Tidy ret.

Define and use OPC_RET.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy calls.
Richard Henderson [Fri, 21 May 2010 15:30:27 +0000 (08:30 -0700)]
tcg-i386: Tidy calls.

Define OPC_CALL_Jz, generated by tcg_out_calli; use the later
throughout.  Unify the calls within qemu_st; adjust the stack
with a single pop if applicable.

Define and use EXT_CALLN_Ev for indirect calls.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy push/pop.
Richard Henderson [Fri, 21 May 2010 15:30:26 +0000 (08:30 -0700)]
tcg-i386: Tidy push/pop.

Move tcg_out_push/pop up in the file so that they can be used
by qemu_ld/st.  Define a tcg_out_pushi to be used as well.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy movi.
Richard Henderson [Fri, 21 May 2010 15:30:25 +0000 (08:30 -0700)]
tcg-i386: Tidy movi.

Define and use OPC_MOVL_Iv.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy non-immediate arithmetic operations.
Richard Henderson [Fri, 21 May 2010 15:30:24 +0000 (08:30 -0700)]
tcg-i386: Tidy non-immediate arithmetic operations.

Add more OPC values, and tgen_arithr.  Use the later throughout.

Note that normal reg/reg arithmetic now uses the Gv,Ev opcode form
instead of the Ev,Gv opcode form used previously.  Both forms
disassemble properly, and so there's no visible change when diffing
log files before and after the change.  This change makes the operand
ordering within the output routines more natural, and avoids the need
to define an OPC_ARITH_EvGv since a read-modify-write with memory is
not needed within TCG.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy immediate arithmetic operations.
Richard Henderson [Fri, 21 May 2010 15:30:23 +0000 (08:30 -0700)]
tcg-i386: Tidy immediate arithmetic operations.

Define OPC_ARITH_EvI[bz]; use throughout.  Use tcg_out_ext8u
directly in setcond.  Use tgen_arithi in qemu_ld/st.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy ext8s and ext16s operations.
Richard Henderson [Fri, 21 May 2010 15:30:22 +0000 (08:30 -0700)]
tcg-i386: Tidy ext8s and ext16s operations.

Define OPC_MOVSBL and OPC_MOVSWL.  Factor opcode emission to
separate functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy ext8u and ext16u operations.
Richard Henderson [Fri, 21 May 2010 15:30:21 +0000 (08:30 -0700)]
tcg-i386: Tidy ext8u and ext16u operations.

Define OPC_MOVZBL and OPC_MOVZWL.  Factor opcode emission to
separate functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoaxisdev88: Fix passing of kernel cmdline.
Edgar E. Iglesias [Fri, 21 May 2010 14:09:10 +0000 (16:09 +0200)]
axisdev88: Fix passing of kernel cmdline.

Signed-off-by: Edgar E. Iglesias <edgar@axis.com>
14 years agoReplace \0s with spaces before sending strings to curses.
Bernhard Kauer [Fri, 21 May 2010 12:05:55 +0000 (14:05 +0200)]
Replace \0s with spaces before sending strings to curses.

Signed-off-by: Bernhard Kauer <kauer@tudos.org>
Signed-off-by: Andrzej Zaborowski <andrew.zaborowski@intel.com>
14 years agoarm_timer: fix oneshot mode
Rabin Vincent [Sun, 2 May 2010 09:50:52 +0000 (15:20 +0530)]
arm_timer: fix oneshot mode

In oneshot mode, the delta needs to come from the TimerLoad register,
not the maximum limit.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoarm_timer: reload timer when enabled
Rabin Vincent [Sun, 2 May 2010 09:50:51 +0000 (15:20 +0530)]
arm_timer: reload timer when enabled

Reload the timer when TimerControl is written, if the timer is to be
enabled.  Otherwise, if an earlier write to TimerLoad was done while
periodic mode was not set, s->delta may incorrectly still have the value
of the maximum limit instead of the value written to TimerLoad.

This problem is evident on versatileap on current linux-next, which
enables TIMER_CTRL_32BIT before writing to TimerLoad and then enabling
periodic mode and starting the timer.  This causes the first periodic
tick to be scheduled to occur after 0xffffffff periods, leading to a
perceived hang while the kernel waits for the first timer tick.

Signed-off-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agopflash_cfi01: add device ID read command
Michael Walle [Sat, 1 May 2010 17:34:06 +0000 (19:34 +0200)]
pflash_cfi01: add device ID read command

Add support to read manufacturer and device ID. For everything else (eg.
lock bits) 0 is returned.

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agopc: fix segfault introduced by 3d53f5c36ff6
Eduard - Gabriel Munteanu [Thu, 20 May 2010 06:14:04 +0000 (09:14 +0300)]
pc: fix segfault introduced by 3d53f5c36ff6

Commit 3d53f5c36ff6 introduced a segfault by erroneously making fw_cfg a
'void **' and passing it around in different ways.

Signed-off-by: Eduard - Gabriel Munteanu <eduard.munteanu@linux360.ro>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agotarget-sparc: Inline some generation of carry for ADDX/SUBX.
Richard Henderson [Wed, 12 May 2010 18:04:27 +0000 (11:04 -0700)]
target-sparc: Inline some generation of carry for ADDX/SUBX.

Computing carry is trivial for some inputs.  By avoiding an
external function call, we generate near-optimal code for
the common cases of add+addx (double-word arithmetic) and
cmp+addx (a setcc pattern).

Signed-off-by: Richard Henderson <rth@twiddle.net>
Acked-by: Artyom Tarasenko <atar4qemu@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agotcg-i386: Tidy jumps.
Richard Henderson [Wed, 14 Apr 2010 15:26:50 +0000 (08:26 -0700)]
tcg-i386: Tidy jumps.

Define OPC_JCC*, OC_JMP*, and EXT_JMPN_Ev.  Use them throughout.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Eliminate extra move from qemu_ld64.
Richard Henderson [Wed, 14 Apr 2010 15:06:00 +0000 (08:06 -0700)]
tcg-i386: Eliminate extra move from qemu_ld64.

If the address register overlaps one of the output registers
simply issue the clobbering load last, rather than emitting
an extra move of the address register.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy move operations.
Richard Henderson [Wed, 14 Apr 2010 14:58:59 +0000 (07:58 -0700)]
tcg-i386: Tidy move operations.

Define OPC_MOVB* and OPC_MOVL*; use them throughout.
Use tcg_out_ld/st instead of bare tcg_out_modrm_offset
when it makes sense.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy shift operations.
Richard Henderson [Wed, 28 Apr 2010 17:38:04 +0000 (10:38 -0700)]
tcg-i386: Tidy shift operations.

Define OPC_SHIFT_{1,Ib,cl}.  Factor opcode emission to a function.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Tidy bswap operations.
Richard Henderson [Wed, 28 Apr 2010 17:31:18 +0000 (10:31 -0700)]
tcg-i386: Tidy bswap operations.

Define OPC_BSWAP.  Factor opcode emission to separate functions.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoRemove i386 from .gitignore
Aurelien Jarno [Thu, 20 May 2010 19:00:23 +0000 (21:00 +0200)]
Remove i386 from .gitignore

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-sparc: Simplify ICC generation.
Richard Henderson [Wed, 12 May 2010 18:04:26 +0000 (11:04 -0700)]
target-sparc: Simplify ICC generation.

Use int32 types instead of target_ulong when computing ICC.  This
simplifies the generated code for 32-bit host and 64-bit guest.
Use the same simplified expressions for ICC as were already used
for XCC in carry flag generation.

Simplify the ADD carry generation to not consider a possible carry-in.
Use the more complex carry computation for ADDX only.  Use the same
carry algorithm for the XCC result of ADDX.  Similarly for SUB/SUBX.

Use the ADD carry generation functions for TADD/TADDTV.  Similarly
for SUB and TSUB/TSUBTV.

Tidy the code with respect to CODING_STYLE.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agotarget-sparc: Fix compilation with --enable-debug.
Richard Henderson [Wed, 12 May 2010 18:04:25 +0000 (11:04 -0700)]
target-sparc: Fix compilation with --enable-debug.

Return a target_ulong from compute_C_icc to match the width of the users.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoFix __VA__ARGS__ typo in cris mmu.c
Riccardo Magliocchetti [Wed, 19 May 2010 16:49:29 +0000 (18:49 +0200)]
Fix __VA__ARGS__ typo in cris mmu.c

Fix compilation with DEBUG defined

Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
14 years agolinux-user: fix 32-bit host breakage
Aurelien Jarno [Wed, 19 May 2010 16:30:53 +0000 (18:30 +0200)]
linux-user: fix 32-bit host breakage

Fix breakage introduced by commit 81bbe906c89b6b7af58a1eeb96ec5a0bfdc3386f.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agomicroblaze: Update elf machine nums.
Edgar E. Iglesias [Wed, 19 May 2010 13:24:17 +0000 (15:24 +0200)]
microblaze: Update elf machine nums.

189 was allocated in upstream binutils.

0xbaab was the old temporary value. Still used by some tools and the
linux kernel.

I've seen 115 in older gdb versions, but lets ignore that one.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
14 years agomicroblaze: Add linux-user core dumping support.
Edgar E. Iglesias [Wed, 19 May 2010 13:09:28 +0000 (15:09 +0200)]
microblaze: Add linux-user core dumping support.

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
14 years agotcg-i386: Tidy initialization of tcg_target_call_clobber_regs.
Richard Henderson [Tue, 13 Apr 2010 22:26:17 +0000 (15:26 -0700)]
tcg-i386: Tidy initialization of tcg_target_call_clobber_regs.

Setting the registers one by one is easier to read, and gets
optimized by the compiler just the same.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotcg-i386: Allocate call-saved registers first.
Richard Henderson [Tue, 13 Apr 2010 22:23:53 +0000 (15:23 -0700)]
tcg-i386: Allocate call-saved registers first.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoFix cross compilation
Stefan Weil [Sun, 11 Apr 2010 16:44:18 +0000 (18:44 +0200)]
Fix cross compilation

This patch enhances the algorithm which finds the correct settings for SDL.
For cross compilations (when cross_prefix is set), it looks for sdl-config
with cross prefix. Here is the complete search order:

$(cross_prefix}pkg-config              (old, only used for cross compilation)
${cross_prefix}sdl_config              (new, only used for cross compilation)
pkg-config                             (old, needs PATH)
sdl-config                             (old, needs PATH)

Cross SDL packages (or the user) now can simply set a link (for example
/usr/bin/i586-mingw32msvc-sdl-config -> /usr/i586-mingw32msvc/bin/sdl-config)
which allows cross compilations without PATH modifications.

Without the patch, configure and make (which calls configure) typically
need a non-standard PATH. Failing to set this special PATH results in
broken builds.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-s390: enable SIGP Initial Reset
Alexander Graf [Fri, 14 May 2010 14:14:31 +0000 (16:14 +0200)]
target-s390: enable SIGP Initial Reset

For SMP to work with KVM, we need to properly emulate the SIGP Initial Reset
Command. Recent (2.6.32) kernels issue that before the SIGP Reset command that
actually wakes up the vcpu.

This patch makes -smp work on S390x.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-ppc: remove dead code
Thomas Monjalon [Wed, 21 Apr 2010 09:48:11 +0000 (11:48 +0200)]
target-ppc: remove dead code

This function had been disabled from the beginning:
see 9fddaa0c0cabb610947146a79b4a9a38b0a216e5

cpu_reset() function is in target-ppc/helper.c

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
Acked-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agotarget-s390: add firmware code
Alexander Graf [Tue, 20 Apr 2010 17:37:13 +0000 (19:37 +0200)]
target-s390: add firmware code

This patch adds a firmware blob to the S390 target. The blob is a simple
implementation of a virtio client that tries to read the second stage
bootloader from sectors described as of offset 0x20 in the MBR.

In combination with an updated zipl this allows for booting from virtio
block devices. This firmware is built from the same sources as the second
stage bootloader. You can find a virtio capable s390-tools in this repo:

git://repo.or.cz/s390-tools.git

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoPPC/KVM: make iothread work
Alexander Graf [Sun, 18 Apr 2010 21:10:17 +0000 (23:10 +0200)]
PPC/KVM: make iothread work

When running with --enable-io-thread the timer we have doesn't help,
because it doesn't wake up the CPU thread. So instead we need to
actually kick it.

While at it I refined the logic a bit to not dumbly trigger a timer
every 500ms, but rather do it more often after an interrupt got injected.
If there's no level based interrupt to be expected, we don't need the
timer anyways.

This makes qemu-system-ppc with --enable-io-thread work when using KVM.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agofix chardev_init for win32
TeLeMan [Thu, 15 Apr 2010 04:37:55 +0000 (12:37 +0800)]
fix chardev_init for win32

chardev_init functions use socket,so socket_init() shoud be placed at
the front of chardev_init on win32.

Signed-off-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoqemu-sockets: avoid strlen of NULL pointer
Jens Osterkamp [Mon, 12 Apr 2010 08:51:01 +0000 (10:51 +0200)]
qemu-sockets: avoid strlen of NULL pointer

If the user wants to create a chardev of type socket but forgets to give a
host= option, qemu_opt_get returns NULL. This NULL pointer is then fed into
strlen a few lines below without a check which results in a segfault.
This fixes it.

Signed-off-by: Jens Osterkamp <jens@linux.vnet.ibm.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agolinux-user: rlimit conversion between host and target.
takasi-y@ops.dti.ne.jp [Sun, 11 Apr 2010 19:07:35 +0000 (04:07 +0900)]
linux-user: rlimit conversion between host and target.

rlim_t conversion between host and target added.
Otherwise there are some incorrect case like
- RLIM_INFINITY on 32bit target -> 64bit host.
- RLIM_INFINITY on 64bit host -> mips and sparc target ?
- Big value(for 32bit target) on 64bit host -> 32bit target.

One is added into getrlimit, setrlimit, and ugetrlimit. It converts both
RLIM_INFINITY and value bigger than target can hold(>31bit) to RLIM_INFINITY.

Another one is added to guest_stack_size calculation introduced by
703e0e89. The rule is mostly same except the result on the case is keeping
the value of guest_stack_size.

Slightly tested for SH4, and x86_64 -linux-user on x86_64-pc-linux host.

Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>
Acked-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
14 years agoCompile acpi_piix4, apm and pm_smbus only once
Blue Swirl [Mon, 17 May 2010 19:32:37 +0000 (19:32 +0000)]
Compile acpi_piix4, apm and pm_smbus only once

12 compilations less for the full build.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoMerge remote branch 'kwolf/for-anthony' into staging
Anthony Liguori [Mon, 17 May 2010 18:17:34 +0000 (13:17 -0500)]
Merge remote branch 'kwolf/for-anthony' into staging

14 years agoMerge remote branch 'mst/for_anthony' into staging
Anthony Liguori [Mon, 17 May 2010 17:41:39 +0000 (12:41 -0500)]
Merge remote branch 'mst/for_anthony' into staging

14 years agoblock: Remove special case for vvfat
Kevin Wolf [Wed, 12 May 2010 12:03:02 +0000 (14:03 +0200)]
block: Remove special case for vvfat

The special case doesn't really us buy anything. Without it vvfat works more
consistently as a protocol. We get raw on top of vvfat now, which works just
as well as using vvfat directly.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoFix docs for block stats monitor command
Daniel P. Berrange [Thu, 13 May 2010 10:30:50 +0000 (06:30 -0400)]
Fix docs for block stats monitor command

The 'parent' field in the 'query-blockstats' monitor command is
part of the top level block device QDict, not part of the 2nd
level 'stats' QDict.

* block.c: Fix docs for 'parent' field in block stats monitor
  command output

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agouse qemu_free() instead of free()
Bruce Rogers [Thu, 13 May 2010 21:14:33 +0000 (15:14 -0600)]
use qemu_free() instead of free()

There is a call to free() where qemu_free() should instead be used.

Signed-off-by: Bruce Rogers <brogers@novell.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock/vdi: Fix image opening and creation for odd disk sizes
Stefan Weil [Wed, 12 May 2010 18:25:45 +0000 (20:25 +0200)]
block/vdi: Fix image opening and creation for odd disk sizes

The fix is based on a patch from Kevin Wolf. Here his comment:

"The number of blocks needs to be rounded up to cover all of the virtual hard
disk. Without this fix, we can't even open our own images if their size is not
a multiple of the block size."

While Kevin's patch addressed vdi_create, my modification also fixes
vdi_open which now accepts images with odd disk sizes.

v3:
Don't allow reading of disk images with too large disk sizes.
Neither VBoxManage nor old versions of qemu-img read such images.
This change requires rounding of odd disk sizes before we do the checks.

Cc: Kevin Wolf <kwolf@redhat.com>
Cc: François Revol <revol@free.fr>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agodmg: use qemu block API
Christoph Hellwig [Wed, 12 May 2010 14:31:49 +0000 (16:31 +0200)]
dmg: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Dmg actually does an lseek to a negative offset in the open routine,
which we replace with offset arithmetics after doing a bdrv_getlength.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agodmg: use pread
Christoph Hellwig [Wed, 12 May 2010 14:31:35 +0000 (16:31 +0200)]
dmg: use pread

Use pread instead of lseek + read in preparation of using the qemu
block API.  Note that dmg actually uses the implicit file offset
a lot in dmg_open, and we had to replace it with an offset variable.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agodmg: fix reading of uncompressed chunks
Christoph Hellwig [Fri, 7 May 2010 14:55:33 +0000 (16:55 +0200)]
dmg: fix reading of uncompressed chunks

When dmg_read_chunk encounters an uncompressed chunk it currently
calls read without any previous adjustment of the file postion.

This seems very wrong, and the "reference" implementation in
dmg2img does a search to the same offset as done in the various
compression cases, so do the same here.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock/vpc: Fix conversion from size to disk geometry
Stefan Weil [Mon, 10 May 2010 19:46:26 +0000 (21:46 +0200)]
block/vpc: Fix conversion from size to disk geometry

The VHD algorithm calculates a disk geometry
which is usually smaller than the requested size.

QEMU tried to round up but failed for certain sizes:

qemu-img create -f vpc disk.vpc 9437184
would create an image with 9435136 bytes
(which is too small for qemu-img convert).

Instead of hacking the geometry algorithm, the patch
increases the number of sectors until we get enough
sectors.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoparallels: use qemu block API
Christoph Hellwig [Thu, 6 May 2010 20:04:50 +0000 (22:04 +0200)]
parallels: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoparallels: use pread
Christoph Hellwig [Thu, 6 May 2010 20:04:34 +0000 (22:04 +0200)]
parallels: use pread

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock/vdi: Allow disk images of size 0
Stefan Weil [Thu, 6 May 2010 18:53:47 +0000 (20:53 +0200)]
block/vdi: Allow disk images of size 0

Even it is not very useful, users may create images of size 0.

Without the special option CONFIG_ZERO_MALLOC, qemu_mallocz
aborts execution when it is told to allocate 0 bytes,
so avoid this kind of call.

Cc: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Fix bdrv_commit
Kevin Wolf [Thu, 6 May 2010 14:34:56 +0000 (16:34 +0200)]
block: Fix bdrv_commit

When reopening the image, don't guess the driver, but use the same driver as
was used before. This is important if the format=... option was used for that
image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Fix protocol detection for Windows devices
Kevin Wolf [Thu, 6 May 2010 11:04:58 +0000 (13:04 +0200)]
block: Fix protocol detection for Windows devices

We can't assume the file protocol for Windows devices, they need the same
detection as other files for which an explicit protocol is not specified.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Avoid unchecked casts for AIOCBs
Kevin Wolf [Wed, 5 May 2010 09:44:39 +0000 (11:44 +0200)]
block: Avoid unchecked casts for AIOCBs

Use container_of for one direction and &acb->common for the other one.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agobochs: use qemu block API
Christoph Hellwig [Tue, 4 May 2010 10:44:21 +0000 (12:44 +0200)]
bochs: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agobochs: use pread
Christoph Hellwig [Tue, 4 May 2010 10:44:08 +0000 (12:44 +0200)]
bochs: use pread

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoide: Fix ide_dma_cancel
Kevin Wolf [Tue, 4 May 2010 14:35:24 +0000 (16:35 +0200)]
ide: Fix ide_dma_cancel

When cancelling a request, bdrv_aio_cancel may decide that it waits for
completion of a request rather than for cancellation. IDE therefore can't
abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback
of a completed request would use invalid data.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocloop: use qemu block API
Christoph Hellwig [Tue, 4 May 2010 10:44:52 +0000 (12:44 +0200)]
cloop: use qemu block API

Use bdrv_pwrite to access the backing device instead of pread, and
convert the driver to implementing the bdrv_open method which gives
it an already opened BlockDriverState for the underlying device.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agocloop: use pread
Christoph Hellwig [Tue, 4 May 2010 10:44:38 +0000 (12:44 +0200)]
cloop: use pread

Use pread instead of lseek + read in preparation of using the qemu
block API.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoqemu-nbd: Improve error reporting
Ryota Ozaki [Sun, 2 May 2010 21:50:25 +0000 (06:50 +0900)]
qemu-nbd: Improve error reporting

- use err(3) instead of errx(3) if errno is available
  to report why failed
- let fail prior to daemon(3) if opening a nbd file
  is likely to fail after daemonizing to avoid silent
  failure exit
- add missing 'ret = 1' when unix_socket_outgoing failed

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agoblock: Remove semicolon in BDRV_SECTOR_MASK macro
Stefan Hajnoczi [Sat, 1 May 2010 06:23:32 +0000 (07:23 +0100)]
block: Remove semicolon in BDRV_SECTOR_MASK macro

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
14 years agosparc: move DT and QT defines to op_helper.c
Blue Swirl [Sun, 16 May 2010 08:33:02 +0000 (08:33 +0000)]
sparc: move DT and QT defines to op_helper.c

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: fix TT_WOTHER value
Igor V. Kovalenko [Sun, 16 May 2010 00:11:29 +0000 (04:11 +0400)]
sparc64: fix TT_WOTHER value

- fix off by one error in spill trap number bit for other window (must be bit 5)
- fixes invalid instruction issue with HelenOS

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agosparc64: fix mmu demap operand typo
Igor V. Kovalenko [Sun, 16 May 2010 00:11:24 +0000 (04:11 +0400)]
sparc64: fix mmu demap operand typo

- must use store address operand to demap, not store value

Signed-off-by: Igor V. Kovalenko <igor.v.kovalenko@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoUpdate to a hopefully more future proof FSF address
Blue Swirl [Sat, 15 May 2010 17:52:49 +0000 (17:52 +0000)]
Update to a hopefully more future proof FSF address

See also 70539e1850ddd3a7ee6f9a8db7bd8e81b85225a4,
8167ee883931cb20c6264fc19d040ce2dc6ceaaa,
530e7615ce3c01882e582c84dc6304ab98a3d5c5 and
fad6cb1a565bb73f83fc0e2654489457b489e436.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoTrim unnecessary includes
Blue Swirl [Sat, 15 May 2010 17:36:13 +0000 (17:36 +0000)]
Trim unnecessary includes

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agomc146818rtc: remove #ifdef DEBUG_CMOS.
Isaku Yamahata [Fri, 14 May 2010 07:29:24 +0000 (16:29 +0900)]
mc146818rtc: remove #ifdef DEBUG_CMOS.

remove #ifdef DEBUG_CMOS by using macro.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoapm: remove #ifdef DEBUG.
Isaku Yamahata [Fri, 14 May 2010 07:29:23 +0000 (16:29 +0900)]
apm: remove #ifdef DEBUG.

remove #ifdef DEBUG by using macro.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi_piix4: remove #ifdef DEBUG.
Isaku Yamahata [Fri, 14 May 2010 07:29:22 +0000 (16:29 +0900)]
acpi_piix4: remove #ifdef DEBUG.

removed #ifdef DEBUG by using macro.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopm_smbus: remove #ifdef DEBUG.
Isaku Yamahata [Fri, 14 May 2010 07:29:21 +0000 (16:29 +0900)]
pm_smbus: remove #ifdef DEBUG.

remove #ifdef DEBUG by using macro.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci hotadd, acpi_piix4: remove global variables
Isaku Yamahata [Fri, 14 May 2010 07:29:20 +0000 (16:29 +0900)]
pci hotadd, acpi_piix4: remove global variables

remove global variables, gpe and pci0_status by moving them
into PIIX4PMState.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopci hotplug: add argument to pci hot plug callback.
Isaku Yamahata [Fri, 14 May 2010 07:29:19 +0000 (16:29 +0900)]
pci hotplug: add argument to pci hot plug callback.

Add argument, DeviceState*, to pci hot plug callback.
The argument will be used later to remove global variable.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi_piix4: qdevfy.
Isaku Yamahata [Fri, 14 May 2010 07:29:18 +0000 (16:29 +0900)]
acpi_piix4: qdevfy.

qdevfy acpi_piix4.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agortc: make rtc_xxx accept/return ISADevice instead of RTCState.
Isaku Yamahata [Fri, 14 May 2010 07:29:17 +0000 (16:29 +0900)]
rtc: make rtc_xxx accept/return ISADevice instead of RTCState.

To match rtc_xxx with qdev, make rtc_xxx accept and return ISADevice
instead of RTCState.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: move rtc declarations from pc.h into a dedicated header file.
Isaku Yamahata [Fri, 14 May 2010 07:29:16 +0000 (16:29 +0900)]
pc: move rtc declarations from pc.h into a dedicated header file.

Move rtc_xxx declarations from pc.h into mc146818rtc.h.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out piix specific part from pc.c into pc_piix.c
Isaku Yamahata [Fri, 14 May 2010 07:29:15 +0000 (16:29 +0900)]
pc: split out piix specific part from pc.c into pc_piix.c

Finally, we can safely split out the piix specific part from pc.c
into pc_piix.c.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out pci device init from pc_init1() into pc_pci_device_init()
Isaku Yamahata [Fri, 14 May 2010 07:29:14 +0000 (16:29 +0900)]
pc: split out pci device init from pc_init1() into pc_pci_device_init()

Split out pci device initialization from pc_init1() into pc_pci_device_init().
and removed unnecessary braces.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out basic device init from pc_init1() into pc_basic_device_init()
Isaku Yamahata [Fri, 14 May 2010 07:29:13 +0000 (16:29 +0900)]
pc: split out basic device init from pc_init1() into pc_basic_device_init()

Split out basic device, i.e. legacy devices like floppy, initialization
from pc_init1() into pc_basic_device_init().
Later it will be used.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out vga initialization from pc_init1() into pc_vga_init().
Isaku Yamahata [Fri, 14 May 2010 07:29:12 +0000 (16:29 +0900)]
pc: split out vga initialization from pc_init1() into pc_vga_init().

Split out vga initialization which is independent of piix
from pc_init1() as pc_vga_init().
Later it will be used.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out memory allocation from pc_init1() into pc_memory_init()
Isaku Yamahata [Fri, 14 May 2010 07:29:11 +0000 (16:29 +0900)]
pc: split out memory allocation from pc_init1() into pc_memory_init()

Split out memory allocation and rom/bios loading which doesn't depend
on piix from pc_init1() into pc_memory_init().
Later it will be used.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: split out cpu initialization from pc_init1() into pc_cpus_init().
Isaku Yamahata [Fri, 14 May 2010 07:29:10 +0000 (16:29 +0900)]
pc: split out cpu initialization from pc_init1() into pc_cpus_init().

split out cpu initialization which is piix independent from pc_init1()
into pc_cpus_init(). Later it will be used.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: make pc_init1() not refer ferr_irq directly.
Isaku Yamahata [Fri, 14 May 2010 07:29:09 +0000 (16:29 +0900)]
pc: make pc_init1() not refer ferr_irq directly.

By introducing a registering function, make pc_init1() not refer to
ferr_irq directly in order to make ferr_irq piix independent.
Later pc_init1() will be split out into another file keeping ferr_irq
static.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: introduce a function to allocate cpu irq.
Isaku Yamahata [Fri, 14 May 2010 07:29:08 +0000 (16:29 +0900)]
pc: introduce a function to allocate cpu irq.

Introduce a function, pc_allocate_cpu_irq(), to allocate cpu irq
in order to make pic_irq_request() piix independent.
Later piix code will be split out to another file keeping pic_irq_request()
static.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: remove global variable rtc_state by using qemu_irq.
Isaku Yamahata [Fri, 14 May 2010 07:29:07 +0000 (16:29 +0900)]
pc: remove global variable rtc_state by using qemu_irq.

Remove the reference to the global variable, rtc_state, by passing
function argument to cmos_init_hd(), cmos_init().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Cc: Paolo Bonzini <bonzini@gnu.org>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: remove a global variable, floppy_controller.
Isaku Yamahata [Fri, 14 May 2010 07:29:06 +0000 (16:29 +0900)]
pc: remove a global variable, floppy_controller.

Remove a global variable, floppy_controller.
Since it is unnecessarily global, make it local and pass it as
a function argument.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: make an unnecessary global variable, pit, local.
Isaku Yamahata [Fri, 14 May 2010 07:29:05 +0000 (16:29 +0900)]
pc: make an unnecessary global variable, pit, local.

remove unnecessary global static variables, pit.
Make it local.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc, i440fx: Make smm enable/disable function i440fx independent.
Isaku Yamahata [Fri, 14 May 2010 07:29:04 +0000 (16:29 +0900)]
pc, i440fx: Make smm enable/disable function i440fx independent.

make cpu_smm_update() generic to be independent on i440fx by
registering a callback.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agopc: initialize ioapic before use.
Isaku Yamahata [Fri, 14 May 2010 07:29:03 +0000 (16:29 +0900)]
pc: initialize ioapic before use.

The changeset of 2c8d9340203c7f19265fd4cb2341f568217a3af6
prevents isa_irq_handler() from NULL refering of IsaIrqState::ioapic.
However it would be better to initialize the member before reference.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi: split acpi.c into the common part and the piix4 part.
Isaku Yamahata [Fri, 14 May 2010 07:29:02 +0000 (16:29 +0900)]
acpi: split acpi.c into the common part and the piix4 part.

Split acpi.c into the common part and the piix4 specific part.
The common part will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi: add acpi constants from linux header files and use them.
Isaku Yamahata [Fri, 14 May 2010 07:29:01 +0000 (16:29 +0900)]
acpi: add acpi constants from linux header files and use them.

add acpi constants from linux header files and
replace the old constants with them.
The acpi constants will be used by other file.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi: split out apm register emulation from acpi.c
Isaku Yamahata [Fri, 14 May 2010 07:29:00 +0000 (16:29 +0900)]
acpi: split out apm register emulation from acpi.c

Split out apm register emulation for acpi.c into apm.c.
The apm emulation will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
14 years agoacpi: split out piix4 smbus routines from acpi.c into pm_smbus.c
Isaku Yamahata [Fri, 14 May 2010 07:28:59 +0000 (16:28 +0900)]
acpi: split out piix4 smbus routines from acpi.c into pm_smbus.c

Split out piix4 smbus routines from acpi.c into pm_smbus.c and
use it.
The split out smbus emulation will be used later.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>