Commit Graph

119 Commits

Author SHA1 Message Date
Volker Ruppert
21643ff419 Some work on the USB EHCI emulation
- added a hack to make EHCI work in Bochs, but without asynchronous packet
  support (tested with "high-speed" USB disk).
- added missing list for connected USB device state.
2016-11-13 20:57:57 +00:00
Volker Ruppert
b95ca006b8 Some work on the USB xHCI emulation
- fixed some of the endianness issues
- fixed some of the GCC warnings
- changed some BX_INFO to BX_DEBUG
- FIXME: non-bulk devices not yet working on xHCI. Linux guest hangs during boot
  when HID or hub device is connected.
2016-11-13 09:22:25 +00:00
Volker Ruppert
17b4e65bef The save/restore list for USB devices is now cleared by the device destructor
instead of the hub's remove_device() method. The external hub removes connected
devices before clearing it's own list. This fixes crash on exit when devices
are present on external hub.
2016-11-12 14:17:46 +00:00
Volker Ruppert
364bf9362c Changed handling of unsupported/invalid device speed setup. The UHCI core now
ignores connected high speed device (fixes panic with EHCI on guest OS init or
shutdown). The other HC's now panic and disconnect device if the user decides
to continue.
2016-11-11 16:11:52 +00:00
Volker Ruppert
6ba530e461 Ported most of the remaining EHCI methods to Bochs, including some ugly hacks.
Asynchronous transfers are not yet working properly (tested with USB disk device
in high speed mode). That's why the support for "speed:high" is still disabled.
Since we have no test case for the isosynchronous mode, I have not yet ported
the main code for it.
2016-11-07 21:57:56 +00:00
Volker Ruppert
5458e66f85 Added USB device method 'find_device' required for EHCI. No functional changes yet. 2016-08-20 14:20:07 +00:00
Volker Ruppert
cd68194269 Added Android host platform support to Bochs based on SF patch #534.
- added Android case to the configure script.
- renamed file memory.h to memory-bochs.h to fix conflict with NDK.
- fixed Android issues in some files.
2016-08-12 17:06:14 +00:00
Volker Ruppert
fc41b20dfe Applied current state of porting EHCI from Qemu. No functional changes yet. 2016-05-16 17:25:29 +00:00
Volker Ruppert
ce7afe050f Applied current state of porting EHCI from Qemu. No functional changes yet. 2016-02-09 17:11:59 +00:00
Volker Ruppert
0ba744b9fe Started implementing USB EHCI support. The PCI and MMIO register behaviour is
almost implemented, the port owner handling and the UHCI companion controllers
are present. High speed devices are not yet supported, since the EHCI scheduler
code has not been written yet (e.g. porting from Qemu). Low and full speed
devices should be detected correctly and work after port ownership change to
UHCI. 6 ports are available and the bochsrc syntax is similar to other HCs.
2015-12-06 20:03:42 +00:00
Volker Ruppert
5e635a87bb Fixed IRQ sharing for multi-function PCI devices and removed workaround in the
UHCI core code.
2015-11-28 10:24:22 +00:00
Volker Ruppert
e19f28dad7 Call DEV_pci_set_irq() only if the IRQ level really changes. The Bochs IRQ
routing code is possibly buggy, since it can make multiple UHCI devices fail
in a multi-function device (like EHCI).
2015-11-12 21:45:44 +00:00
Volker Ruppert
2f94f55a82 Some work in the UHCI core for the usage as a companion controller of EHCI.
- added method to change port ownership.
- fixed UHCI reset and initialized device pointers.
- added symbol UHCI_FULL_DEBUG to reduce debug output if not set.
- renamed connection handling method.
2015-11-08 18:54:30 +00:00
Volker Ruppert
d455659bd1 Split the USB UHCI code in two parts: uhci_core.cc implements the device
emulation and usb_uhci.cc implements the setup for the PIIX3 chipset and the
runtime device change code. The UHCI core is required for the EHCI emulation,
since there can be multiple "companion" controllers for USB 1.1 device handling.
2015-11-05 21:20:54 +00:00
Volker Ruppert
76c065dd89 Fixed usage of MSD device on xHCI hub.
- implemented xHCI TRB command "Reset Device".
- fixed SCSI read/write commands in non-async mode.
2015-11-02 21:36:38 +00:00
Volker Ruppert
c2b790809d Simplify xHCI code, since the capability registers are readonly.
- Moved initialization from reset_hc() to init().
- Removed save/restore registration.
- Removed extra debug output.
2015-11-01 08:55:03 +00:00
Volker Ruppert
be304bf4af Definition of maximum nuber of USB ports moved from bochs.h to device. 2015-10-31 15:12:36 +00:00
Volker Ruppert
234f10f159 The OHCI async support works fine in all tests, so some BX_INFO messages
can be changed now to BX_DEBUG.
2015-10-26 20:23:33 +00:00
Volker Ruppert
fcf9b8285b Added seek emulation for USB disk write commands (async mode required).
Fixed MSD status handling (required for seek emulation).
2015-10-22 18:13:59 +00:00
Volker Ruppert
708e946cb8 As a workaround for possibly buggy hdimage code, read() and write() calls
transfer only one disk sector. Moved disk write code to the seek_complete()
method (seek emulation for write commands is not ready yet).
2015-10-13 19:49:09 +00:00
Volker Ruppert
b22023838c Completed save/restore support for the USB xHCI device.
TODO: reduce size of saved file (find a way to skip unused slots).
2015-10-11 17:07:18 +00:00
Volker Ruppert
3fc71ec131 Now using BXRS_* macros for all USB devices.
TODO: This should be used everywhere in register_state() if possible.
2015-10-11 07:33:22 +00:00
Volker Ruppert
eed2bb15b8 Simplified register_state() for for small byte arrays in remaining i/o devices. 2015-10-06 18:20:16 +00:00
Volker Ruppert
12915a48f2 Added missing update of 'curr_lba' for the harddisk read seek emulation.
Added comments to the MSD / SCSI members similar to usb_cbi.
Now using BXRS_* macros for save/restore.
2015-10-04 08:54:36 +00:00
Volker Ruppert
b754d72ab2 Some work on the USB disk/cdrom emulation.
- More accurate seek emulation for read commands.
- Moved status indicator code to the SCSI layer.
- Fixed dump size for async packets.
TODO: Seek emulation for disk write commands.
2015-10-03 07:19:48 +00:00
Volker Ruppert
256fd99d12 USB floppy "format unit" timing implemented similar to read/write timing.
Added latency time for the "implied seek" of read/write/format commands. Both
features can be used when asynchronous packet handling is available. Some
related changes in the non-async read and write code.
2015-09-28 18:15:18 +00:00
Volker Ruppert
71774c57bb Some work on the USB floppy emulation.
- Added support for changing image mode at runtime (flat <-> vvfat).
- Added device buffer to save/restore list.
2015-09-27 15:02:38 +00:00
Volker Ruppert
b22a57d4df Some work on the USB floppy emulation.
- Added missing update of the write protection flag after runtime config.
- Added sense codes for invalid cases of some commands.
- Added buffer pointer save/restore handling and use BXRS macros now.
2015-09-27 08:32:54 +00:00
Volker Ruppert
e8d045ad30 USB floppy sector write timing implemented similar to read timing. It can be
used when asynchronous packet handling is available. Some changes in the
non-async read and write code.
TODO: seek timing (similar to legacy floppy).
2015-09-26 09:19:56 +00:00
Volker Ruppert
2232dd23d6 USB floppy sector read timing implemented based on the drive speed 300 RPM.
It can be used when asynchronous packet handling is available. Some changes in
the non-async read and write code.
TODO: sector write timing, seek timing (similar to legacy floppy).
2015-09-20 10:53:16 +00:00
Volker Ruppert
6cbd6e247a USB floppy command FORMAT UNIT implemented and read commands fixed. Formatting
media in USB floppy works now with XP guest.
2015-09-19 12:45:54 +00:00
Volker Ruppert
12cace4c5a Some work on async packet and seek emulation support.
- deactivate seek timer when operation is cancelled.
- set async packet mode with a separate method at connection time.
- renamed some variables and prepared seek emulation for USB disk writes.
2015-09-16 17:08:50 +00:00
Volker Ruppert
0b432b313f Added seek emulation support for USB harddisk reads and cleaned up the
MSD / SCSI code.
TODO list (async packet and seek support):
- seek emulation for USB harddisk write commands
- seek emulation for floppy
- async packet support for UHCI and xHCI
- improve and clean up OHCI async packet code
2015-09-15 17:55:32 +00:00
Volker Ruppert
491dc311ca Some work for asynchronus USB packet handling (needed by disk/cdrom seek emulation).
- Common USB code prepared for async USB packet handling (ported from an earlier
  Qemu version).
- Added simple async packet handling to OHCI (partly ported from earlier Qemu).
- Implemented USB cdrom seek emulation for hubs with async packet support. The
  legacy code is still present for hubs without this feature.
- For UHCI and xHCI the callback is set to NULL to force the usage of the
  legacy cdrom read code.
TODO: clean up OHCI code, async support for UHCI and xHCI, seek emulation for
USB harddisk and floppy.
2015-09-13 20:04:41 +00:00
Volker Ruppert
6dbd4c37a9 Some USB debug output (packet dump) changes
- rewrite of usb_dump_packet(), execute code only if debug output is enabled.
- OHCI: removed packet dump, it should be done in the devices code if necessary.
2015-09-06 06:54:07 +00:00
Volker Ruppert
a536aa8286 Fixed format capacities list for the "no medium" case. 2015-09-05 11:35:05 +00:00
Volker Ruppert
f54feb5b91 Some variables should not be handled by the xHCI internal save/restore, moving
them out of the hub structure.
Fixed a warning.
2015-09-05 07:23:25 +00:00
Volker Ruppert
b69e40d584 The USB host controllers have no asynchronus packet completion support yet.
TODO: implement this feature (useful for cdrom, disk and floppy devices).
2015-09-05 06:30:28 +00:00
Volker Ruppert
4b83f9e899 If the debug mode is enabled for usb_msd, turn it on for the SCSI device, too,
Don't try to insert cdrom media if device/image path is empty.
2015-09-03 18:54:51 +00:00
Volker Ruppert
44d0e8f911 Added media change support for the USB floppy. 2015-08-31 20:51:54 +00:00
Volker Ruppert
c136fa1618 Added framework for USB floppy media change support based on the USB cdrom
code (not yet functional).
Minor related changes in the USB cdrom code.
2015-08-30 08:37:27 +00:00
Volker Ruppert
2dbfae1b1c Fixes and improvements for the USB cdrom runtime options.
- Add a special list to the MSD state and add pointers to the runtime-only
  options for the cdrom. The restore handler of this list calls runtime_config()
  to make sure the media path and status are correctly updated.
- Registering a runtime config handler for the USB cdrom is not necessary since
  runtime_config() is always called from the hub it is connected to.
- Restore a string parameter value only if it's different from the initial one.
2015-08-29 14:02:13 +00:00
Volker Ruppert
946a6bf50e Fixed USB device disconnect: clear save/restore list before deleting device
(bug found with valgrind).
2015-08-28 18:52:54 +00:00
Volker Ruppert
7da8cfa4b0 Fixed save/restore support of the USB subsystem when using an external hub
with devices conected at runtime.
- Added restore handler support for the bx_list_c class. If a handler is
  registered, it will be called after restoring all of the list's members.
- USB hub: add special lists to the port state and add pointers to the
  runtime-only options for each port. The restore handler of this list calls
  init_device() to make sure all connected devices can be restored.
- Call restore_logopts() after restoring hardware to make sure all saved
  modules have been created.
- TODO: the USB cdrom also needs a fix for it's runtime-only options.
2015-08-28 17:37:38 +00:00
Volker Ruppert
cc3020ab53 Added support for connecting USB floppy without media present.
Fixed status indicator activity.
TODO: add media change support without disconnect.
2015-08-24 20:26:08 +00:00
Volker Ruppert
38fbdaa7e8 Added runtime config handler for the USB cdrom and modified parameter handling
similar to the ATAPI implementation (including locked tray case).
Fixed status indicator activity and minor other changes.
2015-08-23 16:09:24 +00:00
Volker Ruppert
1df014a8ae Implemented unregister mechanism for runtime config handlers.
TODO: use it for removable devices with removable media (USB floppy / cdrom).
2015-08-23 07:04:56 +00:00
Volker Ruppert
792c5bdec2 Set default device speed for floppy, cdrom and disk to 'full'. 2015-08-16 16:15:46 +00:00
Volker Ruppert
823ba769fb Some work on the USB floppy emulation.
- Removed USB device type handling from constructor and init code, since we
  only the 'floppy' type here.
- Write commands now using the device buffer for one sector.
TODO: support for starting without media and runtime media change.
2015-08-16 06:44:16 +00:00
Volker Ruppert
5bc1717adc Removed the data tranfer limit for read/write commands.
- The read buffer is now limited to 16 sectors and the read commands can fill
  it multiple times until all sectors have been read.
- The write commands are currently not using the device buffer, so no panic
  should happen here.
2015-08-14 17:43:25 +00:00