Commit Graph

11326 Commits

Author SHA1 Message Date
Volker Ruppert
cc1fa2bc61 Implemented USB remote wakeup mechanism in xHCI and the external hub. 2016-12-11 12:26:12 +00:00
Volker Ruppert
1f5222e096 Fixed string usage after delete. 2016-12-11 07:51:21 +00:00
Volker Ruppert
c3b608a3c9 Implemented USB remote wakeup mechanism.
- Extended USB callback definition to support different event types sent from
  device to HC. Currently we only have the two events "async completion" and
  "remote wakeup".
- Implemented event handlers in the UHCI, OHCI and EHCI. For the EHCI version
  we currently have no test case.
- The external USB hub now uses this feature at device connect/disconnect.
  Now the device change on the hub is correctly detected by the guest OS.
- TODO #1: remote wakeup and async completion for the xHCI.
- TODO #2: event handler for the external hub to make a USB device work on
  a chain of hubs.
- TODO #3: the event handler possibly could be used for the packet copy code.
2016-12-10 13:45:49 +00:00
Stanislav Shwartsman
7b2a8bb340 added missing EPT misconfig condition check 2016-12-10 05:06:59 +00:00
Stanislav Shwartsman
46b4a76cd3 fetchdecode rework step 0.1, no impact on correctness, small speedup 2016-12-09 12:34:37 +00:00
Volker Ruppert
974c8d5124 Fixed compilation errors that occur with debugger enabled. 2016-12-06 18:07:05 +00:00
Stanislav Shwartsman
7ccc859b00 static code analysis: remove redundant include 2016-12-05 19:15:59 +00:00
Stanislav Shwartsman
98c69ce6ae c++ better to use new/delete and not malloc 2016-12-05 19:05:31 +00:00
Stanislav Shwartsman
0059d33102 c++ better to use new/delete and not malloc 2016-12-05 18:56:56 +00:00
Stanislav Shwartsman
2895031c7e c++ better to use new/delete and not malloc 2016-12-05 18:51:12 +00:00
Stanislav Shwartsman
20efa2ddec c++ better to use new/delete and not malloc 2016-12-05 18:49:22 +00:00
Stanislav Shwartsman
ca403b69c4 c++ better to use delete and not malloc 2016-12-05 18:47:16 +00:00
Stanislav Shwartsman
40609d3ab2 c++ better to use delete and not malloc 2016-12-05 18:41:35 +00:00
Stanislav Shwartsman
1283292613 static code analysis fixes - what if file didn't open? 2016-12-05 18:17:22 +00:00
Volker Ruppert
07172634ab Two SF links fixed (to be continued). 2016-12-04 21:48:12 +00:00
Volker Ruppert
3fd323abc5 USB xHCI endianness and warning fixes
- use get_dwords() and put_dwords() from EHCI sources for reading / writing
  xHCI data structures as dword array. This fixes some endianness issues.
- simplified copying data from / to data structures since we can now use the
  dword array with the correct byte order directly.
- fixed all remaining "strict-aliasing" GCC warnings.
2016-12-04 18:54:51 +00:00
Volker Ruppert
91c58cffc3 Moved standard USB device request processing (set address, get status, get/set
configuration, get/set status, get descriptor) to the base class to reduce code
duplication. The device calls the common handle_control() method and then it
processes unhandled requests in it's specific code. (similar to Qemu).
2016-12-04 09:51:14 +00:00
Volker Ruppert
0d74aec48c Some more xHCI fixes by Ben Lunt (NAK handling, TRB type "No Op"). 2016-12-03 12:15:16 +00:00
Volker Ruppert
185ae80925 Some USB code changes by Ben Lunt
- USB xHCI NAK handling fix by Ben. Now openSUSE 13.2 boots without hang with
  hub connected to an xHCI port.
- Updated Ben's email address and year in some copyright headers.
2016-12-02 17:30:16 +00:00
Volker Ruppert
3341ca6cff Updated some broken links (to be continued). 2016-11-30 16:58:15 +00:00
Volker Ruppert
26af4f279b Modified xHCI packet handling similar to other HCs.
- Get rid of device_buffer and use packet init / cleanup functions.
- Read immediate data from memory location instead of possibly byte-swapped
  TRB parameter.
2016-11-29 19:19:05 +00:00
Volker Ruppert
a138f07fe1 Fixed OHCI ED / TD handling and removed hacks for async packet completion. 2016-11-27 18:16:06 +00:00
Volker Ruppert
a22e66ef13 Added support for multiple async packets on OHCI.
- Moved UHCI async packet functions to usb_common.h for using then on both
  UHCI and OHCI.
- Modified OHCI packet handling based on the UHCI implementation.
- Renamed EHCI helper function to avoid conflicts.
- TODO: async packet support on xHCI.
2016-11-27 12:18:37 +00:00
Volker Ruppert
ff3b20be1a Minor changes and comment additions in the EHCI emulation code.
- Added missing queue handling code for init, reset and device disconnect.
- Added EHCI status access methods for async and periodic state.
- Added a lot of comments (mostly from the original EHCI core code).
2016-11-27 09:19:55 +00:00
Volker Ruppert
ab69aae575 Zeroing out newly allocated structures fixes EHCI async packet support.
It has been tested successfully with USB disk in high speed mode.
2016-11-26 11:15:25 +00:00
Volker Ruppert
f6608938bf Some more small xHCI changes by Ben Lunt. 2016-11-25 13:15:27 +00:00
Volker Ruppert
1c8986f01f Return USB device status depending it's attributes.
- UFI/CBI floppy: bus-powered, no remote wakeup
- HID (mouse, tablet, keypad): bus-powered, remote wakeup
- MSD (disk, cdrom), printer: self-powered, no remote wakeup
TODO: Remote wakeup is not yet implemented. A device should be able to resume
it's upstream port if suspended.
2016-11-24 21:57:02 +00:00
Volker Ruppert
a5c2115d27 Two small xHCI changes by Ben Lunt. 2016-11-24 18:05:05 +00:00
Volker Ruppert
385ad83df3 Minor changes in the OHCI code.
- HcLSThreshold is writable, but it's usually not modified (same as Qemu).
- BX_ERROR should only occur on an attempt to change the number of ports.
- Don't register read-only items for save/restore.
2016-11-24 17:21:40 +00:00
Volker Ruppert
20e9d21fc7 Small changes in serial loopback mode
- The transmit FIFO is not used in loopback mode.
- Don't flood log file with error messages when Linux probes the FIFO.
2016-11-23 16:42:22 +00:00
Volker Ruppert
f82bb13f88 Added support for multiple async packets on UHCI (TODO: other HCs). 2016-11-22 18:06:44 +00:00
Volker Ruppert
666780dab5 Some work on the USB hub device emulation.
- Changed some device descriptor fields (using values from Qemu).
- Ported device reset code from Qemu.
- Check device speed setting on connect (only low/full speed supported yet).
- TODO: External hub doesn't work properly in some test cases (device change
  not detected by guest OS, openSUSE 13.2 hangs with hub on xHCI).
2016-11-20 20:39:32 +00:00
Volker Ruppert
72af99c372 Some more work on USB HID devices and related stuff
- Now really fixed NAK behaviour in UHCI.
- USB tablet now also returns NAK response when idle and there is no change.
2016-11-20 07:30:06 +00:00
Volker Ruppert
4660c7ad98 Some work on USB HID devices and related stuff
- USB mouse and keypad now return NAK response when idle and there is no change.
- Implemented HID commands for get/set idle duration.
- Fixed NAK behaviour in UHCI and OHCI.
TODO list: USB tablet should also return NAK (doesn't work yet), review xHCI for
the NAK behaviour, accurate implementation of the idle duration
2016-11-19 23:11:51 +00:00
Volker Ruppert
0192554c25 Started rewrite of USB packet handling required for full async packet support.
Step #1: Allocate buffer for data transfers dynamicly with the required size
(done in UHCI, OHCI and EHCI).
2016-11-18 21:27:43 +00:00
Volker Ruppert
de6ee1d7eb Added basic async packet support in the UHCI core. Only one async operation
is currently supported per hub at the same time (same as OHCI).
TODO #1: We should support at least one async operation per connected device.
TODO #2: Async packet support for EHCI and xHCI.
2016-11-16 16:49:57 +00:00
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
Stanislav Shwartsman
bd24d7fb17 fixed reset value of xcr0 as published in latest Intel SDM update 2016-10-08 15:17:12 +00:00
Stanislav Shwartsman
1543034fb7 in the latest intel docs PCOMMIT CPUID bit doesn't exists anymore 2016-10-02 11:56:18 +00:00
Stanislav Shwartsman
239f793f37 in the latest intel docs PCOMMIT CPUID bit doesn't exists anymore 2016-10-02 11:54:19 +00:00
Stanislav Shwartsman
42b0714992 rename fetchdecode.cc -> fetchdecode32.cc 2016-09-25 18:25:47 +00:00
Stanislav Shwartsman
d9e818cd5d refactoring in the Bochs decoder code 2016-09-25 18:19:59 +00:00
Stanislav Shwartsman
8f20cecbae fixed code style in fetchdecode.cc, avoid code duplication 2016-09-08 17:29:09 +00:00
Stanislav Shwartsman
b7091b09f6 cleanup in fetchdecode functions 2016-09-08 15:09:29 +00:00
Stanislav Shwartsman
14b7fff442 remove unexpected change in fetchdecode.cc 2016-08-30 18:43:36 +00:00
Stanislav Shwartsman
032da78e52 remove SMP and AVX from Android build script. reduce the binary size and make faster binary (SMP makes binary a lot slower) 2016-08-30 18:42:39 +00:00