Commit Graph

2902 Commits

Author SHA1 Message Date
Shwartsman
c043d0ce0f initialize boolean with true/false instead of '0' or '1' 2023-10-01 13:23:53 +03:00
Benjamin David Lunt
7abed66ae5
Add minimal support for MMC command 0xAC (#80)
This changes a BX_INFO to a BX_DEBUG. It does not needed to be a
BX_INFO.

Second, this adds (very) minimal support for SCSI command 0xAC.
When emulating a .iso image via USB CD-ROM on Win10, without this
command, the emulation freezes when trying to access the CD-ROM. I don't
know if it is Bochs or Win10. I think Win10 expects the command to work,
or Bochs is not failing correctly.

This PR simply adds code to acknowledge the command and returns a zero
length report. This SCSI (MMC) specification states that a zero length
report is allowed.
The 8 byte header is returned, but the header indicates a zero byte
return: No report segments returned.
This seems to keep Win10 from freezing at USB CD-ROM device access time.

The code also BX_DEBUG's the command sent to the "controller", for
future use when adding the actual support of the command.
2023-09-26 07:55:29 +03:00
Benjamin David Lunt
74ed550334
Allow large VHD files (#79)
This PR allows larger VHD image files. The size in question doesn't
necessarily mean the size of the VHD file on disk. The size is the total
size of the image emulated. This total size is in question.

Without this patch, the total size allowed is 65535 * 16 * 255, or
roughly 32gig.
With this patch, the total size is calculated by who the creator of the
image is, what the CHS values are, and possibly a total size of up to a
limit of 2TB.

Since the original code was ported from QEMU, I ported an updated QEMU
code snippet.

https://gitlab.com/qemu-project/qemu/-/blob/master/block/vpc.c?ref_type=heads#L305

This PR now allows VHD image files with a total size emulated less than
or equal to 2TB.
2023-09-19 08:04:32 +03:00
Benjamin David Lunt
b46fc681d2
Improve default device detection (#77)
This improves the detection of the default speed of a device when given
in bochsrc.

It will first get the max speed of the port given. For example, uhci and
ohci will return FULL, ehci will return HIGH.
xHCI will return SUPER if the port is a super-speed port, else it will
return HIGH.

Then it will compare this with the max speed allowed for that device,
returning the highest common speed.

Of course, if the speed option is given, the above is overwritten by the
specified speed.

Both checks are still performed on the result.
1) does device allow the result speed?
2) does the controller allow the result speed?
2023-09-14 07:30:26 +03:00
Benjamin David Lunt
b2a44e2284
Additional controller checks (#74)
This adds three additional checks to make sure the Guest is working
correctly.
- checks that the guest allocated the Scratchpad Area. If left zero
(NULL) the controller may access low memory.
- checks that the guest uses correct segment sizes in the interrupter
ring(s)
- checks the burst size value given to be within normal range

This also adds an internal register value for the HcCrcr (Command Ring
Control) register. Since this register reads zero by the Guest, we keep
an internal value so that the emulation can read the value, internally.
This is for features soon to be released.

Minor other syntax/comment changes (misspelled word, etc)

Checked with WinXP, Win7, and Win10
2023-09-08 08:44:56 +03:00
Benjamin David Lunt
43dd4164fe
Fix zero length packet handling (#73)
This fixes zero length packet handling.
See the following example that requests 128 bytes:

```
SETUP(8)
IN(64)
IN(64)
STATUS(0)
```

The current code erroneously assumes that there are no more IN packets
after the first two 64-byte packets.

However, what happens with the following:

```
SETUP(8)
IN(64)
IN(64)
IN(64)    <--- current code assumes this will be, and expects a STATUS packet
STATUS(0)
```

Currently, the third IN(64) above will result in a coding error because
the code is expecting the STATUS packet, not another IN packet.

The "controller" must allow for more packets than expected, returning a
short packet detect on the third IN(64) packet shown above, actually
returning zero bytes, hence the Short Packet Detect.

This patch was tested on WinXP, Win7, and Win10.
2023-09-07 08:04:10 +03:00
Benjamin David Lunt
0d48349a60
fixed bandwidth overage detection (#71)
The check for the amount of byte transferred in one frame time was done
before the update of the vertical pointer in the current Queue of the
last executed TD. Therefore, on the next frame time, the last executed
TD was being "executed" again. The check has now been moved to the top
of the loop.
2023-09-05 08:12:42 +03:00
Stanislav Shwartsman
fe53752ddf
rename USE_RAW_SERIAL -> BX_USE_RAW_SERIAL (#70) 2023-09-04 20:21:37 +03:00
Benjamin David Lunt
8272ee3f6c
Include cstddef 2023-04-09 10:54:08 -07:00
Benjamin David Lunt
0985f9bfec
hid mouse improvements 2023-04-09 10:44:00 -07:00
Stanislav Shwartsman
caf80c29bf Merge branch 'master' of https://github.com/bochs-emu/Bochs 2023-04-06 22:04:04 +03:00
Stanislav Shwartsman
c10268f5b5 fixed compilation warnings in usb code 2023-04-06 22:03:36 +03:00
Volker Ruppert
bee4b45ad7 usb_uasp is not a separate plugin device 2023-04-06 20:59:14 +02:00
Stanislav Shwartsman
8d35b84a61 fixed potentially non-initialized var warning 2023-04-06 21:37:22 +03:00
Stanislav Shwartsman
55e66d4d6f
Merge pull request #42 from fysnet/master
Updates to USBMSD/SCSI emulation
2023-04-01 10:44:27 +03:00
Benjamin David Lunt
b20ddc75ff
Updates to USBMSD/SCSI emulation 2023-03-31 19:05:59 -07:00
Benjamin David Lunt
45469a7929
Updates to USBMSD/SCSI emulation 2023-03-31 18:55:05 -07:00
Benjamin David Lunt
0135a545c0
Updates to USBMSD/SCSI emulation 2023-03-31 18:33:38 -07:00
Stanislav Shwartsman
8eee519f4e
Merge pull request #39 from fysnet/master
Add over-current signaling
2023-03-23 07:22:46 +02:00
Benjamin David Lunt
dacc965593
Add over-current signaling
This adds over-current signaling to the USBs four host controllers.
To signal an OC, use the runtime configuration and set the checkbox (GUI) or text config's parameter to 1.
This pull request also adds USB documentation to user.dbk.
2023-03-22 16:05:44 -07:00
Stanislav Shwartsman
45ed74dc1b
Merge pull request #38 from fysnet/master
Forgot to add SPD action to UHCI
2023-03-22 06:54:26 +02:00
Benjamin David Lunt
d01e0f6cf8
Forgot to add SPD action to UHCI 2023-03-21 18:40:11 -07:00
Stanislav Shwartsman
5b45a2e985
Merge pull request #36 from fysnet/master
Fix issue #25
2023-03-18 07:44:19 +02:00
Benjamin David Lunt
64009cb067
Fix issue #25
The 'd.pcap_image_t pcapture' in usb_common.h called its constructor and set 'fd' to -1. However, in the usb_device_c() constructor, we then cleared all of 'd', resetting pcapture.fd back to zero. Then on Bochs exit, the pcap_image_t destructor tried to close the file since 'fd' was zero instead of -1. To fix this, I removed the pcap_image_t constructor and now call pcap_image_init() within the usb_device_c constructor.
2023-03-17 17:30:10 -07:00
Stanislav Shwartsman
a34bc01592
Merge pull request #35 from fysnet/master
USB emulation update
2023-03-13 16:07:47 +02:00
Benjamin David Lunt
6a0e7a5306
Allow a usb port number to be more than one digit
Also fixed an error with xhci and the save/restore Bochs environment
2023-03-12 16:40:02 -07:00
Benjamin David Lunt
3c6a97c676
add dependencies 2023-03-11 17:37:27 -07:00
Benjamin David Lunt
7e046f5a27
indentation corrections 2023-03-11 17:28:59 -07:00
Benjamin David Lunt
418ef4e1ca
USB emulation update
add usb_uasp to the build
2023-03-10 12:56:32 -07:00
Benjamin David Lunt
9075864647
USB emulation update
change to 'public'
2023-03-10 12:30:03 -07:00
Benjamin David Lunt
5b6ed6274b
USB emulation update
Add protected declaration
2023-03-10 12:22:13 -07:00
Benjamin David Lunt
884d4c272e
USB emulation update
fix two comments
2023-03-10 11:56:12 -07:00
Benjamin David Lunt
7041926aac
USB emulation update
Added examples for new options.
 - xhci: model= option
 - xhci: allow the user to select number of ports
 - usb disk: proto= option (bbb or uasp)
Added xhci primary stream support.
 (Secondary stream support is not included)
Added (experimental) usb disk protocol UASP for super- and high-speed usb disk devices.
  (high-speed uasp support is not thoroughly tested)
xhci: fixed "change event" function
scsi: fixed bug in command 0x25
scsi: added command 9E/10
2023-03-10 11:37:08 -07:00
Stanislav Shwartsman
43f18a1e2e
Merge pull request #34 from fysnet/master
minor error in validation of slot and ep fixed
2023-02-25 19:49:23 +02:00
Benjamin David Lunt
8078e5f85f
removed unprintable characters 2023-02-25 08:15:17 -07:00
Benjamin David Lunt
db49706bbd
minor error in validation of slot and ep fixed 2023-02-24 17:19:11 -07:00
Stanislav Shwartsman
a11b4e1c20
Merge pull request #31 from fysnet/master
Minor:

Check speed indicator in the Transfer Descriptor matching the device speed.
Max packet size check, checking that the amount requested/sent is within limits.
Checking that the first packet sent is the GetDescriptor Request with a length equal to or less than the max packet size.
Checking the command length in the USB SCSI emulation.
Checking command parameters within various emulations (SCSI (BBB), etc.)
Implemented "Boot Protocol" for the (HID) Mouse emulation.
Fixed wheel mouse HID report (along with the other HID reports)
Added the Over Current bits to the UHCI code
Added the monitoring of the toggle bit in the TDs

Major:

Re-wrote the UHCI stack processing so that control and bulk reclamation can be used.
(This made it so Windows 7 now works)
Adding function to the USB SCSI emulation.
Enhanced the xHCI emulation to further check for errors in a driver.
2023-02-20 20:34:00 +02:00
Benjamin David Lunt
a098f5f153
Use defines instead of bits 2023-02-18 12:36:25 -07:00
Benjamin David Lunt
71694e34cd
Error fix for compiler 2023-02-16 17:58:06 -07:00
Benjamin David Lunt
996d081d4c
Minor fix for compiler error 2023-02-16 17:52:29 -07:00
Benjamin David Lunt
a4492a9179
USB Enhancement (minor addition) 2023-02-16 17:38:41 -07:00
Benjamin David Lunt
a996807435
Enhanced the USB emulation
The enhancements include fixes and error checks targeting hobbyists who are writing USB drivers.
2023-02-16 17:24:13 -07:00
ImWuX
a83e275382
forgot to update header :D 2023-02-16 14:17:24 +02:00
ImWuX
9d65d5e261
patched an issue with the HPET where writing an u64 with HPET_TN_SETVAL set, would only write the lower 32bits into the comparator. 2023-02-16 14:11:43 +02:00
Benjamin David Lunt
5d81785db6
Add SCSI_CD_EVENT_STATUS 2023-02-01 16:51:16 -07:00
Volker Ruppert
5ebe6b46d0 Removed useless BX_DEBUG messages in devices init 2022-08-29 18:14:59 +02:00
Stanislav Shwartsman
1e4f1624c8 remove trailing whitespace from source files 2022-08-23 21:46:04 +03:00
Stanislav Shwartsman
4d227d15fb remove instrument.h from bochs.h so it won't be included everywhere
include it only where required
move PHY_ADDRESS reserved bits consts to cpu.h
2022-07-30 22:35:43 +03:00
Stanislav Shwartsman
3f65841714
use boolean constants true/false instead of 0/1 (#26)
* use boolean constants true/false instead of 0/1

* fix code comment

Co-authored-by: Stanislav Shwartsman <sshwarts@users.sourceforge.net>
2022-07-30 18:38:22 +03:00
Volker Ruppert
1408de3ad2 Fixed and improved PCI slot config error handling. 2021-10-14 17:59:08 +00:00