26 Commits

Author SHA1 Message Date
Stanley Chang
2bf9d30e02 fix: [xhci] get port speed thru Protocol Speed ID (PSI)
The commit is to detect more kind of Protocol Speed in USB3 by
cherry picking the following patches from edk2:
  7f4eca: Add access xHCI Extended Capabilities Pointer
  01c2fb: Don't check for invalid PSIV
  ec25e9: Check port is compatible before getting PSIV

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
ec76965dfa fix: [xhci] Reset endpoint while USB Transaction error
This commit cherry picks the commit c12bbc from edk2 that resets
endpoint while USB Transaction occur according to XHCI spec 4.8.3.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=4556

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
bb9a9f16d7 fix: [xhci] Abort the Address Device cmd when time out
This commit cherry picks the commit d11f0e from edk2 that aborts
the execution of Address Device Command when command failed
due to timeout.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=4552

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
767eff159e fix: [xhci] Reset port if status change returns an error
This commit cherry picks the 992d54 from edk2 that force resetting
the port when failed in poll port status change.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
9357e54a89 fix: [xhci] Input context update for Evaluate Context command
This commit cherry picks the b3dd9c from edk2 that initializes
the input context for Evaluate Context command.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=4074

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
6969cd123f fix: [xhci] Initial XHCI DCI slot's Context value
The commit cherry picks the edk2 commit 8147fe that corrects
the initilized value of ContextEntries

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
06df615c28 fix: [xhci] Error handle for USB slot initialization failure
This commit cherry picks the a32120 from edk2 that cleans up
UsbDevContext if USB slot initialization is failed.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=3007

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
6549177659 fix: [xhci] Retry device slot init on failure
The commit cherry picks the edk2 commit 2363c6 that retries the device
slot initialization if it fails due to a device error.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
511a2f389e fix: [xhci] Fix TRT when data length is 0
The commit cherry pick the b53798 from edk2.

Reference: https://bugzilla.tianocore.org/show_bug.cgi?id=3418

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
Stanley Chang
174d18fa9f fix: [xhci] Check return value of XHC_PAGESIZE register
This commit cherry picks the b97243 from edk2 that
reports error if reserved bits are not 0 for PageSize.

reference: https://bugzilla.tianocore.org/show_bug.cgi?id=3954

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2024-07-17 08:14:13 -07:00
tsaikevin
0d45c3e60a fix: [Common] Fix Coverity issues (#1958)
Fixed dead default in switch and logically dead code (CWE 561)

Signed-off-by: Kevin Tsai <kevin.tsai@intel.com>
2023-07-19 14:03:41 -07:00
Leon Theunissen
192e8a568a Interrupt packet length is maximum 8, not exclusively 8
Accomodate USB interrupt transfers that require less than 8 bytes per packet.

Signed-off-by: Leon Theunissen <leon.theunissen@etion.co.za>
2022-10-17 11:55:10 -07:00
Kalp Parikh
213cad7205 KW fix for unitialized buffer (#1594)
Signed-off-by: Kalp Parikh <kalp.parikh@intel.com>
2022-06-01 13:50:08 -07:00
Mike Crowe
990e3e81e6 Use LF line endings in the repository
Convert the line endings stored for all text files in the repository to
LF. The majority previously used DOS-style CRLF line endings. Add a
.gitattributes file to enforce this and treat certain extensions as
never being text files.

Update PatchCheck.py to insist on LF line endings rather than CRLF.
However, its other checks fail on this commit due to lots of
pre-existing complaints that it only notices because the line endings
have changed.

Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch
needs to be treated as binary since it contains a mixture of line
endings.

This change has implications depending on the client platform you are
using the repository from:

* Windows

The usual configuration for Git on Windows means that text files will
be checked out to the work tree with DOS-style CRLF line endings. If
that's not the case then you can configure Git to do so for the entire
machine with:

 git config --global core.autocrlf true

or for just the repository with:

 git config core.autocrlf true

Line endings will be normalised to LF when they are committed to the
repository. If you commit a text file with only LF line endings then it
will be converted to CRLF line endings in your work tree.

* Linux, MacOS and other Unices

The usual configuration for Git on such platforms is to check files out
of the repository with LF line endings. This is probably the right thing
for you. In the unlikely even that you are using Git on Unix but editing
or compiling on Windows for some reason then you may need to tweak your
configuration to force the use of CRLF line endings as described above.

* General

For more information see
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings .

Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400
Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 12:46:42 -08:00
Maurice Ma
de621184e8 Adjust debug message in USB libraries
This patch adjusted the following debug message for USB libraries:
  - For SBL, since mutli-TT is not utilized, it should not be
    classified as error message. It is changed to be DEBUG_INFO now.
  - Added DeInit debug print for USB so that it tells the USB
    resources are de-allocated.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-26 14:19:14 -07:00
Maurice Ma
2954034a06 Improve XHCI library timeout polling mechanism
Current XHCI library does a big loop to poll the status of a
USB command execution. In each loop it will delay 1us until
it completes or reachs the timeout. When the loop is very big,
the accumulated 1us delay together will be shifted far beyond
the original timeout requested. This is because of the inaccuracy
of the 1us delay provided by ACPI timer library. This patch
addressed this issue by checking the actual executed time rather
than looping with delay.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-14 11:05:29 -07:00
stalamudupula
6cfe319efc Support 64-bit XHCI MMIO address (#675)
If Platform code assigns 64-bit BAR address to XHCI,
get the full 64-bit address to access MMIO space.
Behavior is undefined if building IA32 and assigning
64-bit XHCI resources.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2020-04-15 14:02:29 -07:00
Maurice Ma
c94fccb54a Fix XHCI library memory de-allocation issue (#668)
* Fix XHCI library memory de-allocation issue

This patch added code to XHCI de-initialization funciton to free
all used memory.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>

* Enhance USB De-initialization flow

This patch enhanced the USB De-initializaiton flow by trying to
call de-init functions in the full USB driver stack including XHCI,
UsbBus, UsbBot, etc.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-04-14 11:08:00 -07:00
Maurice Ma
359a9465dc Fix USB boot assertion (#660)
Assertion will occur when booting from USB behind hubs. This was
caused by duplicated freeing the same address page. The for loop
in UsbHcFreeMemPool() does not move to next node in the list. The
similar bug exists in UFS driver. This patch fixed both.

It fixed #659.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-04-12 22:27:33 -07:00
Maurice Ma
48ff85fc3d Add IoMmu support for XHCI library
This patch synced up to the latest EDKII XHCI library and then
added support for IoMmu interfaces. This will allow the library
to use DMA buffer for I/O transactions.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-03-19 22:07:45 -07:00
Aiden Park
b24fd2759c Cosmetic: Convert LF to CRLF
This will fully support PatchCheck.py.
- Remove all trailing whitespace
- Convert LF to CRLF by default
- Update EFI_D_* to DEBUG_*
- Re-enable CRLF check in PatchCheck.py

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-12-02 16:21:19 -08:00
Maurice Ma
3422b34208 Implement USB deinitialization flow
USB sub-system will have host controller scheduling frames on its
own once it is initialized and enabled. Leaving it running while
payload restarting or OS booting could potentially cause memory
corruption since the DMA might still be running on the background
targeting to previously allocated memory. The safer approach is
to stop the USB controller.

It also fixed #351.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 19:55:25 -07:00
Guo Dong
5e10bd1e07 Update BSD license to BSD+Patent license
To align with EDK2, update file license
to use BSD+Patent license

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-13 10:46:49 -07:00
Maurice Ma
697c02302f Enable USB keyboard console support for QEMU
Previous USB keyboard console support commit worked fine on APL real
platform, but it has issue on QEMU. This patch further enables USB
keyboard console support for QEMU. A new PcdUsbKeyboardPollingTimeout
is added. It will be used to control the USB keyboard interrupt
transfer polling timeout. For QEMU, it needs a larger number due to
timing issue. As part of it, booting from USB device is also enabled
by this patch. This patch fixes #30.

To test USB keyboard console in QEMU, please first change
CONSOLE_IN _DEVICE_MASK in BoardConfig.py to 3, and then add the
following in the QEMU command line to add XHCI controller and USB KB:
-device qemu-xhci,id=xhci,bus=pcie.0,addr=4 -device usb-kbd,bus=xhci.0

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2018-10-29 09:39:27 -07:00
Maurice Ma
09f8270825 Add USB input console support
This patch implemented USB keyboard library and added it as an
input console device. It can be enabled by setting BIT1 in
self.CONSOLE_IN_DEVICE_MASK in BoardConfig.py. By default, it
will be disabled for performance and size consideration.

Test has been done on APL Leafhill board. USB keyboard can work
in Shell.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2018-10-09 12:56:58 -07:00