summaryrefslogtreecommitdiffstats
path: root/ioport.c
Commit message (Collapse)AuthorAgeFilesLines
* trace: switch to modular code generation for sub-directoriesDaniel P. Berrange2017-01-311-1/+1
| | | | | | | | | | | | | | | Introduce rules in the top level Makefile that are able to generate trace.[ch] files in every subdirectory which has a trace-events file. The top level directory is handled specially, so instead of creating trace.h, it creates trace-root.h. This allows sub-directories to include the top level trace-root.h file, without ambiguity wrt to the trace.g file in the current sub-dir. Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 20170125161417.31949-7-berrange@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
* hw: remove pio_addr_tPaolo Bonzini2016-05-191-6/+6
| | | | | | | | | | | | | | | pio_addr_t is almost unused, because these days I/O ports are simply accessed through the address space. cpu_{in,out}[bwl] themselves are almost unused; monitor.c and xen-hvm.c could use address_space_read/write directly, since they have an integer size at hand. This leaves qtest as the only user of those functions. On the other hand even portio_* functions use this type; the only interesting use of pio_addr_t thus is include/hw/sysbus.h. I guess I could move it there, but I don't see much benefit in that either. Using uint32_t is enough and avoids the need to include ioport.h everywhere. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* qemu-common: push cpu.h inclusion out of qemu-common.hPaolo Bonzini2016-05-191-0/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* all: Clean up includesPeter Maydell2016-02-041-0/+1
| | | | | | | | | | Clean up includes so that osdep.h is included first and headers which it implies are not included manually. This commit was created with scripts/clean-includes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1454089805-5470-16-git-send-email-peter.maydell@linaro.org
* ioport: do not use CPU_LOG_IOPORTPaolo Bonzini2015-11-041-20/+6Star
| | | | | | | | These messages are disabled by default; a perfect usecase for tracepoints, which in fact already exist. Add the missing information to them and stop using qemu_log_mask. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell2015-04-301-13/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - miscellaneous cleanups for TCG (Emilio) and NBD (Bogdan) - next part in the thread-safe address_space_* saga: atomic access to the bounce buffer and the map_clients list, from Fam - optional support for linking with tcmalloc, also from Fam - reapplying Peter Crosthwaite's "Respect as_translate_internal length clamp" after fixing the SPARC fallout. - build system fix from Wei Liu - small acpi-build and ioport cleanup by myself # gpg: Signature made Wed Apr 29 09:34:00 2015 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: (22 commits) nbd/trivial: fix type cast for ioctl translate-all: use bitmap helpers for PageDesc's bitmap target-i386: disable LINT0 after reset Makefile.target: prepend $libs_softmmu to $LIBS milkymist: do not modify libs-softmmu configure: Add support for tcmalloc exec: Respect as_translate_internal length clamp ioport: reserve the whole range of an I/O port in the AddressSpace ioport: loosen assertions on emulation of 16-bit ports ioport: remove wrong comment ide: there is only one data port gus: clean up MemoryRegionPortio sb16: remove useless mixer_write_indexw sun4m: fix slavio sysctrl and led register sizes acpi-build: remove dependency from ram_addr.h memory: add memory_region_ram_resize dma-helpers: Fix race condition of continue_after_map_failure and dma_aio_cancel exec: Notify cpu_register_map_client caller if the bounce buffer is available exec: Protect map_client_list with mutex linux-user, bsd-user: Remove two calls to cpu_exec_init_all ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
| * ioport: reserve the whole range of an I/O port in the AddressSpacePaolo Bonzini2015-04-271-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When an I/O port is more than 1 byte long, ioport.c is currently creating "short" regions, for example 0x1ce-0x1ce for the 16-bit Bochs index port. When I/O ports are memory mapped, and thus accessed via a subpage_ops memory region, subpage_accepts gets confused because it finds a hole at 0x1cf and rejects the access. In order to fix this, modify registration of the region to cover the whole size of the I/O port. Attempts to access an invalid port will be blocked by find_portio returning NULL. This only affects the VBE DISPI regions. For all other cases, the MemoryRegionPortio entries for 2- or 4-byte accesses overlap an entry for 1-byte accesses, thus the size of the memory region is not affected. Reported-by: Zoltan Balaton <balaton@eik.bme.hu> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * ioport: loosen assertions on emulation of 16-bit portsPaolo Bonzini2015-04-271-6/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, ioport.c assumes that the entire range specified with MemoryRegionPortio includes a region with size == 1. This however is not true for the VBE DISPI ports, which are 16-bit only. The next patch will make these regions' length equal to two, which can cause the assertions to trigger. Replace them with simple conditionals. Also, ioport.c will emulate a 16-bit ioport with two distinct reads or writes, even if one of the two accesses is out of the bounds given by the MemoryRegionPortio array. Do not do this anymore, instead discard writes to the incorrect register and read it as all-ones. This ensures that the mrp->read and mrp->write callbacks get an in-range ioport number. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
| * ioport: remove wrong commentPaolo Bonzini2015-04-271-4/+0Star
| | | | | | | | | | | | | | | | ioport.c has not been using an alias since commit b40acf9 (ioport: Switch dispatching to memory core layer, 2013-06-24). Remove the obsolete comment. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | exec.c: Make address_space_rw take transaction attributesPeter Maydell2015-04-261-6/+10
|/ | | | | | | | | | Make address_space_rw take transaction attributes, rather than always using the 'unspecified' attributes. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
* memory: convert memory_region_destroy to object_unparentPaolo Bonzini2014-08-181-1/+1
| | | | | | | | | Explicitly call object_unparent in the few places where we will re-create the memory region. If the memory region is simply being destroyed as part of device teardown, let QOM handle it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* ioport: split deletion and destructionPaolo Bonzini2014-08-171-3/+8
| | | | | | | | | | | | Of the two functions portio_list_del and portio_list_destroy, the latter is just freeing a memory area. However, portio_list_del is the logical equivalent of memory_region_del_subregion so destruction of memory regions does not belong there. Actually, neither of these APIs are in use; portio is mostly used by ISA devices or VGAs, and neither of these is currently hot-unpluggable. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* portio: Allow to mark portio lists as coalesced MMIO flushingJan Kiszka2013-10-171-0/+9
| | | | | | | | This will enable us to remove all remaining explicit calls of qemu_flush_coalesced_mmio_buffer in IO handlers. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* memory: Provide separate handling of unassigned io ports accessesJan Kiszka2013-09-051-0/+16
| | | | | | | | | | Accesses to unassigned io ports shall return -1 on read and be ignored on write. Ensure these properties via dedicated ops, decoupling us from the memory core's handling of unassigned accesses. Cc: qemu-stable@nongnu.org Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Revert "ioport: remove LITTLE_ENDIAN mark for portio"Paolo Bonzini2013-07-251-0/+1
| | | | | | | | | | | | | This reverts commit c3cb8e77804313e1be99b5f28a34a346736707a5. The scenario where I/O ports are accessed with DEVICE_LITTLE_ENDIAN endianness now works and will soon be unit tested. Since the PortioList indirection assumes little endian, define portio_ops the same way. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Message-id: 1374501278-31549-16-git-send-email-pbonzini@redhat.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ioport: remove LITTLE_ENDIAN mark for portioAnthony Liguori2013-07-121-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | | Setting it to LE forces a byte swap when host != guest endian but this makes no sense at all. Herve made the suggestion upon observing that word writes/reads were broken into byte writes/reads in such a way as to assume devices are interpret registers as LE. However, even if this were a problem, marking the region as LE is not useful because what's essentially happening here is that LE is open coded. So by marking it LE in MemoryRegionOps, we're doing a superflous swap. Now, the portio code is suspicious to begin with. The dispatch layer really has no purpose in splitting I/O requests in the first place... Cc: Hervé Poussineau <hpoussin@reactos.org> Cc: Alex Graf <agraf@suse.de> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* piolist: add owner argument to initialization functions and pass devicesPaolo Bonzini2013-07-041-2/+4
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* memory: add owner argument to initialization functionsPaolo Bonzini2013-07-041-1/+1
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* ioport: Remove unused old dispatching servicesJan Kiszka2013-07-041-238/+0Star
| | | | | | | | Remove unused ioport_register and isa_unassign_ioport along with everything that only those services used. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* ioport: Switch dispatching to memory core layerJan Kiszka2013-07-041-37/+101
| | | | | | | | | | | | | | | | | | | | | The current ioport dispatcher is a complex beast, mostly due to the need to deal with old portio interface users. But we can overcome it without converting all portio users by embedding the required base address of a MemoryRegionPortio access into that data structure. That removes the need to have the additional MemoryRegionIORange structure in the loop on every access. To handle old portio memory ops, we simply install dispatching handlers for portio memory regions when registering them with the memory core. This removes the need for the old_portio field. We can drop the additional aliasing of ioport regions and also the special address space listener. cpu_in and cpu_out now simply call address_space_read/write. And we can concentrate portio handling in a single source file. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* isa: implement isa_is_ioport_assigned via memory_region_findJan Kiszka2013-07-041-7/+0Star
| | | | | | | | | Open-code isa_is_ioport_assigned via a memory region lookup. As all IO ports are now directly or indirectly registered via the memory API, this becomes possible and will finally allow us to drop the ioport tables. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* Privatize register_ioport_read/writeJan Kiszka2013-07-041-4/+4
| | | | | | | No more users outside of ioport.c. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* exec: move include files to include/exec/Paolo Bonzini2012-12-191-2/+2
| | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* ioport: use INT64_MAX for IO rangesBlue Swirl2012-03-191-1/+1
| | | | | | | | | Expression UINT64_MAX + 1 will make the range bigger than what can be represented with a 64 bit type. This would trigger an assert in int128_get64() after the next patch. Signed-off-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
* ioport: add destructor method to IORangeAvi Kivity2012-03-051-0/+15
| | | | | | | | | | Previously all callers had a containing object with a destructor that could be used to trigger cleanup of the IORange objects (typically just freeing the containing object), but a forthcoming memory API change doesn't fit this pattern. Rather than setting up a new global table, extend the ioport system to support destructors. Signed-off-by: Avi Kivity <avi@redhat.com>
* ioport: change portio_list not to use memory_region_set_offset()Avi Kivity2012-02-291-7/+21
| | | | | | | | memory_region_set_offset() will be going away soon, so don't use it. Use an alias instead. Signed-off-by: Avi Kivity <avi@redhat.com> Reviewed-by: Richard Henderson <rth@twiddle.net>
* Introduce PortioListAvi Kivity2011-10-111-0/+108
| | | | | | | | | | Add a type and methods for manipulating a list of disjoint I/O ports, used in some older hardware devices. Based on original patch by Richard Henderson. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
* ioport: register ranges by byte aligned addresses alwaysAvi Kivity2011-07-291-2/+2
| | | | | | | | | | | The I/O port space is byte addressable, even for word and long accesses. An example is the VMware svga card, which has long ports on offsets 0, 1, and 2. Reviewed-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* report serial devices created with -device in the PIIX4 config spacePaolo Bonzini2011-07-231-6/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Serial and parallel devices created with -device are not reported in the PIIX4 configuration space, and are hence not picked up by the DSDT. This upsets Windows, which hides them altogether from the guest. To avoid this, check at the end of machine initialization whether the corresponding I/O ports have been registered. The new function in ioport.c does this; this also requires a tweak to isa_unassign_ioport. I left the comment in piix4_pm_initfn since the registers I moved do seem to match the 82371AB datasheet. There are some quirks though. We are setting this bit: "Device 8 EIO Enable (EIO_EN_DEV8)—R/W. 1=Enable PCI access to the device 8 enabled I/O ranges to be claimed by PIIX4 and forwarded to the ISA/EIO bus. 0=Disable. The LPT_MON_EN must be set to enable the decode." but not LPT_MON_EN (bit 18 at 50h): LPT Port Enable (LPT_MON_EN)—R/W. 1=Enable accesses to parallel port address range (LPT_DEC_SEL) to generate a device 8 (parallel port) decode event. 0=Disable. We're also setting the LPT_DEC_SEL field (that's the 0x60 written to 63h) to 11, which means reserved, rather than to 01 (378h-37Fh). Likewise we're not setting SA_MON_EN, SB_MON_EN (respectively bit 14 and bit 16 at address 50h) for the serial ports. However, we're setting COMA_DEC_SEL and COMB_DEC_SEL correctly, unlike the corresponding register for the parallel port. All these fields are left as they are, since they are probably only meant to be used in the DSDT. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ioport: Improve error outputAndreas Färber2011-03-061-2/+4
| | | | | | | | | When failing due to conflicting I/O port registrations, include the offending I/O port address in the message. Cc: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Andreas Färber <andreas.faerber@web.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* Type-safe ioport callbacksAvi Kivity2010-11-211-0/+64
| | | | | | | | | | | | | | | | | | The current ioport callbacks are not type-safe, in that they accept an "opaque" pointer as an argument whose type must match the argument to the registration function; this is not checked by the compiler. This patch adds an alternative that is type-safe. Instead of an opaque argument, both registation and the callback use a new IOPort type. The callback then uses container_of() to access its main structures. Currently the old and new methods exist side by side; once the old way is gone, we can also save a bunch of memory since the new method requires one pointer per ioport instead of 6. Acked-by: Anthony Liguori <aliguori@us.ibm.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* trace: Trace port IOPrerna Saxena2010-09-091-0/+7
| | | | | Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* Revert "Get rid of _t suffix"Anthony Liguori2009-10-011-9/+9
| | | | | | | | | | | | In the very least, a change like this requires discussion on the list. The naming convention is goofy and it causes a massive merge problem. Something like this _must_ be presented on the list first so people can provide input and cope with it. This reverts commit 99a0949b720a0936da2052cb9a46db04ffc6db29. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Get rid of _t suffixmalc2009-10-011-9/+9
| | | | | | | Some not so obvious bits, slirp and Xen were left alone for the time being. Signed-off-by: malc <av1474@comtv.ru>
* ioports: remove unused env parameter and compile only onceBlue Swirl2009-09-201-6/+6
| | | | | | | The CPU state parameter is not used, remove it and adjust callers. Now we can compile ioport.c once for all targets. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Make ioport default tables constBlue Swirl2009-09-061-2/+2
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Unbreak large mem support by removing kqemuAnthony Liguori2009-08-241-24/+0Star
| | | | | | | | | | | | | | | | | | | | | | kqemu introduces a number of restrictions on the i386 target. The worst is that it prevents large memory from working in the default build. Furthermore, kqemu is fundamentally flawed in a number of ways. It relies on the TSC as a time source which will not be reliable on a multiple processor system in userspace. Since most modern processors are multicore, this severely limits the utility of kqemu. kvm is a viable alternative for people looking to accelerate qemu and has the benefit of being supported by the upstream Linux kernel. If someone can implement work arounds to remove the restrictions introduced by kqemu, I'm happy to avoid and/or revert this patch. N.B. kqemu will still function in the 0.11 series but this patch removes it from the 0.12 series. Paul, please Ack or Nack this patch. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ioport: use uint{32, 16, 8}_t for ioport value and pio_addr_t for ioport ↵Isaku Yamahata2009-07-171-19/+18Star
| | | | | | | | | | | | | | | | | | | | | | | | address. Using int for cpu_{in, out}[bwl] is inconsistent with other part because for address or value, uintN_t is used by other qemu part. At least, softmmu, CPU{Read, Write}MemoryFunc, pci, target_phys_addr_t and the callers of cpu_{in, out}[bwl](). This patch removes the inconsistency. IO port has its own address space so define pio_addr_t as uint32_t because PCI io space width is 32bit. And use uint{32, 16, 8}_t for ioport value. Changing signedness of value might cause subtle issue. However only a suspicious caller is kvm_handle_io() which is ok. And other callers pass unsigned value in the first place. Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Cc: Stuart Brady <sdbrady@ntlworld.com> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: Samuel Thibault <samuel.thibault@gnu.org> Cc: Tristan Gingold <gingold@adacore.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ioport: remove some #ifdef DEBUG_UNUSED_IOPORT.Isaku Yamahata2009-07-171-12/+12
| | | | | | | | | | remove some #ifdef DEBUG_UNUSED_IOPORT in ioport.c and use PRIx32 where appropriate Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Cc: Anthony Liguori <anthony@codemonkey.ws> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* ioport: consolidate duplicated logic in register_ioport_{read, write}().Isaku Yamahata2009-07-091-14/+16
| | | | | Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* use constant IOPORTS_MASK instead of 0xffff.Isaku Yamahata2009-07-091-2/+2
| | | | | Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* split out ioport related stuffs from vl.c into ioport.c.Isaku Yamahata2009-07-091-0/+258
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>