Commit Graph

24270 Commits (5256a7208a7c2af19baf8f99bd4f06632f9f9ba9)

Author SHA1 Message Date
Peter Maydell 5256a7208a tcg/target-arm: Add missing parens to assertions
Silence a (legitimate) complaint about missing parentheses:

tcg/arm/tcg-target.c: In function ‘tcg_out_qemu_ld’:
tcg/arm/tcg-target.c:1148:5: error: suggest parentheses around
comparison in operand of ‘&’ [-Werror=parentheses]
tcg/arm/tcg-target.c: In function ‘tcg_out_qemu_st’:
tcg/arm/tcg-target.c:1357:5: error: suggest parentheses around
comparison in operand of ‘&’ [-Werror=parentheses]

which meant that we would mistakenly always assert if running
a QEMU built with debug enabled on ARM.

Signed-off-by: Peter Maydell <peter.maydelL@linaro.org>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:27:45 +00:00
Stefan Weil e4ada48242 Replace non-portable asprintf by g_strdup_printf
g_strdup_printf already handles OOM errors, so some error handling in
QEMU code can be removed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:24:43 +00:00
Markus Armbruster 0e7a759293 vl: Use size_t for sizes in get_boot_devices_list()
Code mixes uint32_t, int and size_t.  Very unlikely to go wrong in
practice, but clean it up anyway.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:48 +00:00
Markus Armbruster 089da572b9 fw_cfg: Use void *, size_t instead of uint8_t *, uint32_t for blobs
Many callers pass size_t, which gets silently truncated to uint32_t.
Harmless, because all practical sizes are well below 4GiB.  Clean it
up anyway.  Size overflow now fails assertions.

Bonus: saves a whole bunch of silly casts.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:44 +00:00
Markus Armbruster b3dd15529d pc: Clean up bochs_bios_init()'s (non-)use of sizeof
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:43 +00:00
Markus Armbruster 0e0d2d6295 sun4: Fix unchecked strdup() by switching to fw_cfg_add_string()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:42 +00:00
Markus Armbruster 96f8058629 pc: Fix unchecked strdup() by switching to fw_cfg_add_string()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:41 +00:00
Markus Armbruster 44687f7543 fw_cfg: New fw_cfg_add_string()
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:41 +00:00
Markus Armbruster 4cad3867b6 fw_cfg: Dumb down fw_cfg_add_*() not to return success / failure
No caller is checking the value, so all errors get ignored, usually
silently.  assert() instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:40 +00:00
Markus Armbruster f6e3534327 fw_cfg: Replace debug prints by tracepoints
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:22:39 +00:00
Paolo Bonzini 633f650254 optimize: optimize using nonzero bits
This adds two optimizations using the non-zero bit mask.  In some cases
involving shifts or ANDs the value can become zero, and can thus be
optimized to a move of zero.  Second, useless zero-extension or an
AND with constant can be detected that would only zero bits that are
already zero.

The main advantage of this optimization is that it turns zero-extensions
into moves, thus enabling much better copy propagation (around 1% code
reduction).  Here is for example a "test $0xff0000,%ecx + je" before
optimization:

 mov_i64 tmp0,rcx
 movi_i64 tmp1,$0xff0000
 discard cc_src
 and_i64 cc_dst,tmp0,tmp1
 movi_i32 cc_op,$0x1c
 ext32u_i64 tmp0,cc_dst
 movi_i64 tmp12,$0x0
 brcond_i64 tmp0,tmp12,eq,$0x0

and after (without patch on the left, with on the right):

 movi_i64 tmp1,$0xff0000                 movi_i64 tmp1,$0xff0000
 discard cc_src                          discard cc_src
 and_i64 cc_dst,rcx,tmp1                 and_i64 cc_dst,rcx,tmp1
 movi_i32 cc_op,$0x1c                    movi_i32 cc_op,$0x1c
 ext32u_i64 tmp0,cc_dst
 movi_i64 tmp12,$0x0                     movi_i64 tmp12,$0x0
 brcond_i64 tmp0,tmp12,eq,$0x0           brcond_i64 cc_dst,tmp12,eq,$0x0

Other similar cases: "test %eax, %eax + jne" where eax is already 32-bit
(after optimization, without patch on the left, with on the right):

 discard cc_src                          discard cc_src
 mov_i64 cc_dst,rax                      mov_i64 cc_dst,rax
 movi_i32 cc_op,$0x1c                    movi_i32 cc_op,$0x1c
 ext32u_i64 tmp0,cc_dst
 movi_i64 tmp12,$0x0                     movi_i64 tmp12,$0x0
 brcond_i64 tmp0,tmp12,ne,$0x0           brcond_i64 rax,tmp12,ne,$0x0

"test $0x1, %dl + je":

 movi_i64 tmp1,$0x1                      movi_i64 tmp1,$0x1
 discard cc_src                          discard cc_src
 and_i64 cc_dst,rdx,tmp1                 and_i64 cc_dst,rdx,tmp1
 movi_i32 cc_op,$0x1a                    movi_i32 cc_op,$0x1a
 ext8u_i64 tmp0,cc_dst
 movi_i64 tmp12,$0x0                     movi_i64 tmp12,$0x0
 brcond_i64 tmp0,tmp12,eq,$0x0           brcond_i64 cc_dst,tmp12,eq,$0x0

In some cases TCG even outsmarts GCC. :)  Here the input code has
"and $0x2,%eax + movslq %eax,%rbx + test %rbx, %rbx" and the optimizer,
thanks to copy propagation, does the following:

 movi_i64 tmp12,$0x2                     movi_i64 tmp12,$0x2
 and_i64 rax,rax,tmp12                   and_i64 rax,rax,tmp12
 mov_i64 cc_dst,rax                      mov_i64 cc_dst,rax
 ext32s_i64 tmp0,rax                  -> nop
 mov_i64 rbx,tmp0                     -> mov_i64 rbx,cc_dst
 and_i64 cc_dst,rbx,rbx               -> nop

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:13:16 +00:00
Paolo Bonzini 3a9d8b179b optimize: track nonzero bits of registers
Add a "mask" field to the tcg_temp_info struct.  A bit that is zero
in "mask" will always be zero in the corresponding temporary.
Zero bits in the mask can be produced from moves of immediates,
zero-extensions, ANDs with constants, shifts; they can then be
be propagated by logical operations, shifts, sign-extensions,
negations, deposit operations, and conditional moves.  Other
operations will just reset the mask to all-ones, i.e. unknown.

[rth: s/target_ulong/tcg_target_ulong/]

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:13:14 +00:00
Paolo Bonzini d193a14a2c optimize: only write to state when clearing optimizer data
The next patch will add to the TCG optimizer a field that should be
non-zero in the default case.  Thus, replace the memset of the
temps array with a loop.  Only the state field has to be up-to-date,
because others are not used except if the state is TCG_TEMP_COPY
or TCG_TEMP_CONST.

[rth: Extracted the loop to a function.]

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2013-01-19 10:13:13 +00:00
Blue Swirl 75f0585f17 Merge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf
* 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf:
  PPC: KVM: Add support for EPR with KVM
  openpic: export e500 epr enable into a ppc.c function
  Update Linux kernel headers
  PPC: e500: Change in-memory order of load blobs
  PPC: Provide zero SVR for -cpu e500mc and e5500
  PPC: E500: Calculate loading blob offsets properly
  openpic: set mixed mode as supported
  openpic: unify gcr mode mask updates
  openpic: move gcr write into a function
2013-01-19 09:56:41 +00:00
Blue Swirl 67c4f2d0e1 Merge branch 's390-for-upstream' of git://repo.or.cz/qemu/agraf
* 's390-for-upstream' of git://repo.or.cz/qemu/agraf:
  s390: Add a hypercall registration interface.
  target-s390x: Unregister reset callback on finalization
  s390x: fix indentation
  s390: Add CPU reset handler
  s390x: Remove inline function ebcdic_put and related data from cpu.h
  S390: Enable -cpu help and QMP query-cpu-definitions
  s390: Move IPL code into a separate device
  s390: new contributions GPLv2 or later
2013-01-19 09:55:46 +00:00
Blue Swirl 48b8599c99 Merge branch 'axp-next' of git://github.com/rth7680/qemu
* 'axp-next' of git://github.com/rth7680/qemu:
  alpha-linux-user: Correct select
  alpha-linux-user: Translate fcntl l_type
2013-01-19 09:54:31 +00:00
Cornelia Huck 28e942f86d s390: Add a hypercall registration interface.
Allow virtio machines to register for different diag500 function
codes and convert s390-virtio to use it.

Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Andreas Färber d5627ce8a4 target-s390x: Unregister reset callback on finalization
Since commit "s390: Add CPU reset handler" the CPU's instance_init
registers a reset callback. Unregister that on instance_finalize.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Alexander Graf 419831d710 s390x: fix indentation
In one of the last commits we accidently got 3-space indentation into
the tree. Fix it up so it's 4 spaces wide.

Reported-by: Andreas Faerber <afaerber@suse.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Jens Freimann 70bada0304 s390: Add CPU reset handler
Add a CPU reset handler to have all CPUs in a PoP compliant
state.

Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
[agraf: move hw/hw.h into existing ifdef]
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Stefan Weil a158986d85 s390x: Remove inline function ebcdic_put and related data from cpu.h
The function is only used in misc_helper.c, so move it to that file.

This reduces the size of debug executables (compiled without optimization)
because they get unused code and data for each compilation which includes
cpu.h.

Executables with optimization don't change their size.

ebcdic2ascii is currently unused and could be removed (not done here).

The array ascii2ebcdic must be accessed with an unsigned index, therefore
(int)ascii[i] was replaced by (uint8_t)ascii[i]. The old code would have
failed for a signed char less than 0. The current code only converts
"QEMU" and spaces to EBCDIC, so there is no problem today.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Viktor Mihajlovski 904e5fd5c2 S390: Enable -cpu help and QMP query-cpu-definitions
This enables qemu -cpu help to return a list of supported CPU models
on s390 and also to query for cpu definitions in the monitor.
Initially only cpu model = host is returned. This needs to be reworked
into a full-fledged CPU model handling later on.
This change is needed to allow libvirt exploiters (like OpenStack)
to specify a CPU model.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
[agraf: fix s390x-linux-user, adjust header locations]
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Christian Borntraeger e674a49aae s390: Move IPL code into a separate device
Lets move the code to setup IPL for external kernel
or via the zipl rom into a separate file. This allows to

- define a reboot handler, setting up the PSW appropriately
- enhance the boot code to IPL disks that contain a bootmap that
  was created with zipl under LPAR or z/VM (future patch)
- reuse that code for several machines (e.g. virtio-ccw and virtio-s390)
- allow different machines to provide different defaults

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
[agraf: symbolify initial psw, adjust header file location, fix for QOM]
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Christian Borntraeger ccb084d3f0 s390: new contributions GPLv2 or later
IBMs s390 contributions were meant to to be gplv2 or later (since
we were contributing to qemu). Several of the s390 specific files
link to gpl code anyway, so lets clarify the licence statement for
new contributions for those files that we have touched multiple
times or will likely touch again.

This patch does not touch files that mostly deal with tcg.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:07:47 +01:00
Alexander Graf 5b95b8b9c1 PPC: KVM: Add support for EPR with KVM
This patch links KVM EPR support to the existing TCG support we have now.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf e49798b1bd openpic: export e500 epr enable into a ppc.c function
Enabling and disabling the EPR capability (mpic_proxy) is a system
wide operation. As such, it belongs into the ppc.c file, since that's
where PPC specific machine wide logic happens.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf d3dccee187 Update Linux kernel headers
Based on kvm.git a843fac (next) plus dfdebc24 (master).

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf b8dec1443e PPC: e500: Change in-memory order of load blobs
Today, we load

  <kernel> <initrd> <dtb>

into memory in that order. However, Linux has a bug where it can only
handle the dtb if it's within the first 64MB of where <kernel> starts.

So instead, let's change the order to

  <kernel> <dtb> <initrd>

making Linux happy.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf 746a870b3c PPC: Provide zero SVR for -cpu e500mc and e5500
Even though our -cpu types for e500mc and e5500 are no real CPUs that
actually have version registers, a guest might still want to access
said version register and that has to succeed for a guest to be happy.

So let's expose a zero SVR value on E500_SVR SPR reads.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf 528e536ea2 PPC: E500: Calculate loading blob offsets properly
We have 3 blobs we need to load when booting the system:

  - kernel
  - initrd
  - dtb

We place them in physical memory in that order. At least we should.
This patch fixes the location calculation up to take any module into
account, fixing the dtb offset along the way.

Reported-by: Stuart Yoder <stuart.yoder@freescale.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:57 +01:00
Alexander Graf 86e56a885a openpic: set mixed mode as supported
The Raven MPIC implementation supports the "Mixed" mode to work with
an i8259. While we don't implement mixed mode, we should mark it as
a supported mode in the mode bitmap.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:56 +01:00
Alexander Graf 1ac3d71302 openpic: unify gcr mode mask updates
The mode mask already masks out bits we don't care about, so the
actual handling code can stay intact regardless.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:56 +01:00
Alexander Graf 7f11573b9f openpic: move gcr write into a function
The GCR register contains too much functionality to be covered inside
of the register switch statement. Move it out into a separate function.

Signed-off-by: Alexander Graf <agraf@suse.de>
2013-01-18 19:06:56 +01:00
Anthony Liguori ddc01bf16e Merge remote-tracking branch 'luiz/queue/qmp' into staging
# By Wenchao Xia
# Via Luiz Capitulino
* luiz/queue/qmp:
  HMP: add sub command table to info
  HMP: move define of mon_cmds
  HMP: add infrastructure for sub command
  HMP: delete info handler
  HMP: add QDict to info callback handler
2013-01-17 13:09:57 -06:00
Michael S. Tsirkin e387f99ebc virtio-pci: fix irqfd cleanup argument order
Order of arguments of kvm_virtio_pci_irqfd_release
got mixed up in all calls.
As a result users see assertions during cleanup.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Tested-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-17 09:45:52 -06:00
Andreas Färber 782beb5239 qom: Extend documentation on QOM method concepts
Add a documentation section "Methods" and discuss among others how to
handle overriding virtual methods.

Clarify DeviceClass::realize documentation and refer to the above.

Signed-off-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-17 07:33:16 -06:00
Stefan Hajnoczi 781c0c3321 Makefile: drop recursive libcacard clean
Commit eb8eb53e5846a957cf333f2e1ec8cb6e0c04 ("libcacard: rewrite
Makefile in non-recursive style") refactored libcacard/Makefile so it
can be included by the top-level Makefile.

The top-level clean target still loops over subdirectories, including
libcacard/, to invoke recursive clean.  Remove libcacard from the
recursive clean since its files are already included at the top level.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-17 07:32:54 -06:00
Wenchao Xia 84c44613f9 HMP: add sub command table to info
Now info command takes a table of sub info commands,
and changed do_info() to do_info_help() to do help funtion
only.
 Note that now "info <unknown-topic>" returns error instead
of list of info topics.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-17 10:24:52 -02:00
Wenchao Xia a13ced59a4 HMP: move define of mon_cmds
Because mon_cmds may use info_cmds, so adjust the declare sequence
of them.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-17 10:24:52 -02:00
Wenchao Xia 5f3d335fbd HMP: add infrastructure for sub command
This patch make parsing of hmp command aware of that it may
have sub command. Also discard simple encapsulation function
monitor_find_command(). For case "@command ", space after
@command is filtered out.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-17 10:24:52 -02:00
Wenchao Xia 5f11cb002a HMP: delete info handler
Now cmd and info handler have same format, so delete info handler.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-17 10:24:52 -02:00
Wenchao Xia 84f2d0ea0f HMP: add QDict to info callback handler
This patch change all info call back function to take
additional QDict * parameter, which allow those command
take parameter. Now it is set to NULL at default case.

Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2013-01-17 10:24:52 -02:00
Blue Swirl a4cbfe24e4 bswap: improve gluing
OpenBSD system compiler (gcc 4.2.1) has problems with concatenation
of macro arguments in macro functions:
  CC    aes.o
In file included from /src/qemu/include/qemu-common.h:126,
                 from /src/qemu/aes.c:30:
/src/qemu/include/qemu/bswap.h: In function 'leul_to_cpu':
/src/qemu/include/qemu/bswap.h:461: warning: implicit declaration of function 'bswapHOST_LONG_BITS'
/src/qemu/include/qemu/bswap.h:461: warning: nested extern declaration of 'bswapHOST_LONG_BITS'

Function leul_to_cpu() is only used in kvm-all.c, so the warnings
are not fatal on OpenBSD without -Werror.

Fix by applying glue(). Also add do {} while(0) wrapping and fix
semicolon use while at it.

Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 19:31:18 -06:00
Anthony Liguori 47f4dac3fd Merge remote-tracking branch 'kraxel/chardev.1' into staging
# By Gerd Hoffmann
# Via Gerd Hoffmann
* kraxel/chardev.1:
  chardev: add pty chardev support to chardev-add (qmp)
  chardev: add socket chardev support to chardev-add (qmp)
  chardev: add parallel chardev support to chardev-add (qmp)
  chardev: add serial chardev support to chardev-add (qmp)
  chardev: add file chardev support to chardev-add (qmp)
  chardev: add hmp hotplug commands
  chardev: add qmp hotplug commands, with null chardev support
  chardev: reduce chardev ifdef mess a bit
  chardev: fix QemuOpts lifecycle
  chardev: add error reporting for qemu_chr_new_from_opts
2013-01-16 15:20:05 -06:00
Paolo Bonzini af381ebeac build: fix Win32 clean build
The version.o file did not appear explicitly as a dependency, and
this caused clean builds to fail.  Force its build by making the
Makefile depend on version.o.

(We cannot add it to libqemuutil.a, because it doesn't export any
symbol and thus would not be pulled by the linker).

Cc: Blue Swirl <blauwirbel@gmail.com>
Cc: Stefan Weil <sw@weilnetz.de>
Tested-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:15:26 -06:00
Andreas Färber eb60d1c552 tmp105: Add temperature QOM property
This obsoletes tmp105_set() and allows for better error handling.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:14:20 -06:00
Andreas Färber 2aad80eeb7 tmp105: QOM'ify
Introduce TYPE_ constant and cast macro.
Move the state struct to the new header to allow for future embedding.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:14:20 -06:00
Andreas Färber 6e9989034b tests: Add tmp105 qtest test case
Exercise all four commands of the TMP105, testing for an issue in the
I2C TX path.

The test case uses the N800's OMAP I2C and is the first for ARM.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:14:20 -06:00
Andreas Färber cb5ef3fa18 tmp105: Fix I2C protocol bug
An early length postincrement in the TMP105's I2C TX path led to
transfers of more than one byte to place the second byte in the third
byte's place within the buffer and the third byte to get discarded.

Fix this by explictly incrementing the length after the checks but
before the callback is called, which again checks the length.

Adjust the Coding Style while at it.

Signed-off-by: Alex Horn <alex.horn@cs.ox.ac.uk>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:14:20 -06:00
Andreas Färber 6d0b430176 tmp105: Split out I2C message constants from header
Allows value sharing with qtest.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-16 12:14:20 -06:00